Beispiel #1
0
        public static void DropItem(Client client, PacketIn packet)
        {
            int        itemId   = (int)packet.ReadUInt32();
            PlayerItem item     = PlayerItem.Get(itemId);
            int        quantity = (int)packet.ReadUInt32();

            if (item == null)
            {
                ServerConsole.WriteLine(
                    "Player #{0} attempted to drop non-existant item #{1} !",
                    client.Character.Player.PlayerId,
                    itemId
                    );
                return;
            }

            if (item.PlayerId != client.Character.Player.PlayerId)
            {
                ServerConsole.WriteLine(
                    "Player #{0} attempted to drop item that belongs to #{1}!",
                    client.Character.Player.PlayerId,
                    item.PlayerId
                    );
                return;
            }

            uint worldId = World.NewId();

            Server.WorldDrops[worldId] = new Drop(item, client.Character, quantity, worldId);

            client.Send(new Packets.SpawnDrop(Server.WorldDrops[worldId]), "Spawn Drop");
            client.Send(new Packets.RemoveFromInventory(item.ItemId, quantity), "Update Inventory");
            client.Character.Player.Inventory.Items.Remove(item);
        }
Beispiel #2
0
        public static void EquipItem(Client client, PacketIn packet)
        {
            int        itemId = (int)packet.ReadUInt32();
            PlayerItem item   = PlayerItem.Get(itemId);

            if (item == null)
            {
                ServerConsole.WriteLine(
                    System.Drawing.Color.Red,
                    "Player #{0} attempted to equip non-existant item!",
                    client.Character.Player.PlayerId
                    );
                return;
            }
            if (item.PlayerId != client.Character.Player.PlayerId)
            {
                ServerConsole.WriteLine(System.Drawing.Color.Red,
                                        "Player #{0} attempted to equip item that belongs to #{1}!",
                                        client.Character.Player.PlayerId,
                                        item.PlayerId
                                        );
                return;
            }
            if (!item.Wearable)
            {
                ServerConsole.WriteLine(
                    System.Drawing.Color.Red,
                    "Player #{0} attempted to equip non-equipable item #{1}!",
                    item.PlayerId, item.ItemId
                    );
                return;
            }
            PlayerItem.Equip(item);
            client.Send(new Packets.EquipItem(item), "Equip Item");
        }
Beispiel #3
0
        public static void BuyNpcItem(Client client, PacketIn packet)
        {
            int  npcWorldId = (int)packet.ReadUInt32();
            byte v1         = packet.ReadByte();
            byte amount     = packet.ReadByte();

            int totalPrice = 0;

            ushort[] items   = new ushort[amount];
            ushort[] amounts = new ushort[amount];
            for (int i = 0; i < amount; i++)
            {
                items[i]   = packet.ReadUShort();
                amounts[i] = packet.ReadUShort();

                // TODO, calculate correct price
                totalPrice += 100 * amounts[i];
            }

            // TODO, add geon amount check
            for (int i = 0; i < amount; i++)
            {
                // should be items, not player items
                PlayerItem item = PlayerItem.Get((int)items[i]);
                client.Character.Player.Inventory.Items.Add(item);
                // update AddToInventory with generic item-object
                client.Send(new Packets.AddToInventory((int)items[i], (int)amounts[i]), "Buy Item");
                // update amout of geons !
            }
        }
Beispiel #4
0
        public static void PickupDrop(Client client, PacketIn packet)
        {
            Drop drop;

            try {
                drop = Server.WorldDrops[packet.ReadUInt32()];
            } catch (Exception) {
                return;
            }

            PlayerItem item = PlayerItem.Get(drop.PlayerItem.ItemId);

            client.Character.Player.Inventory.Items.Add(item);

            client.Send(new Packets.PickupDrop(item), "Pickup Drop");
            client.Send(new Packets.AddToInventory(drop.ItemId, drop.Quantity), "Update Inventory");
            client.Send(new Packets.UnspawnDrop(drop), "Unspawn Drop");

            Server.WorldDrops.Remove((uint)drop.WorldId);
            World.FreeId((uint)drop.WorldId);
        }