public void UnequipItem(byte location)
        {
            var item = equippedItems[location];

            equippedItems[location] = null;
            if (item != null && Owner.AddItem(item))
            {
                //Track equipped super gems
                if (item.Gem1 % 10 == 3 || item.Gem2 % 10 == 3)
                {
                    if (superGems.Contains(item.Gem1 / 10))
                    {
                        superGems.Remove(item.Gem1 / 10);
                    }
                }
                Owner.SpawnPacket = SpawnEntityPacket.Create(Owner);
                if (DropManager.TwoHandWeaponTypes.Contains(item.EquipmentType) && equippedItems[5] != null)
                {
                    UnequipItem(5);
                }
                Owner.Send(ItemActionPacket.Create(item.UniqueID, (byte)item.Location, ItemAction.UnequipItem));
                Owner.SendToScreen(Owner.SpawnPacket);
                item.Location = 0;
                item.Save();
            }
        }
Example #2
0
        public static void Process_ItemActionPacket(Player client, ItemActionPacket packet)
        {
            switch (packet.ActionType)
            {
            case ItemAction.Ping: client.LastPingReceived = Common.Clock; client.Send(packet); break;

            default: Console.WriteLine("Unhandled ItemActionPacket type {0} from player {1}", packet.ActionType, client.Character.Name); break;
            }
        }
Example #3
0
        public void UnequipItem(byte location)
        {
            var item = equippedItems[location];

            equippedItems[location] = null;
            if (item != null && Owner.AddItem(item))
            {
                Owner.SpawnPacket = SpawnEntityPacket.Create(Owner);
                Owner.Send(ItemActionPacket.Create(item.UniqueID, (byte)item.Location, ItemAction.UnequipItem));
                Owner.SendToScreen(Owner.SpawnPacket);
                item.Location = 0;
                item.Save();
            }
        }
        public void Process_WarehouseActionPacket(WarehouseActionPacket _packet)
        {
            switch (_packet.Action)
            {
            case WarehouseAction.ListItems:
                SendContents(_packet.UID);
                break;

            case WarehouseAction.AddItem:
                if (owner.Inventory.ContainsKey(_packet.Value))
                {
                    var item = owner.GetItemByUID(_packet.Value);
                    if (item != null && item.IsStoreable)
                    {
                        item.Location = (ItemLocation)_packet.UID;
                        item.Save();
                        owner.RemoveItem(item);
                        LoadItem(item);
                        owner.Send(ItemActionPacket.Create(item.UniqueID, 0, ItemAction.SellToNPC));
                        SendContents(_packet.UID);
                    }
                }
                break;

            case WarehouseAction.RemoveItem:
            {
                ConquerItem item;
                TryGetItem(_packet.UID, _packet.Value, out item);
                if (item != null)
                {
                    item.Location = ItemLocation.Inventory;
                    item.Save();
                    owner.AddItem(item);
                    RemoveItem(_packet.UID, _packet.Value);
                    owner.Send(ItemInformationPacket.Create(item));
                    SendContents(_packet.UID);
                }
                break;
            }

            default:
                Console.WriteLine("Unhandled warehouse action type {0} for client {1}", _packet.Action, owner.Name);
                break;
            }
        }
        public bool EquipItem(ConquerItem item, byte location, bool updateClient = true)
        {
            //If we're equipping a 2h weapon we ALWAYS uneq the left hand item
            if (DropManager.TwoHandWeaponTypes.Contains(item.EquipmentType))
            {
                if (equippedItems[5] != null)
                {
                    UnequipItem(5);
                }
            }

            //If we're equipping to left hand then we need to be able to (based on class type and level)
            if (location == 5)
            {
                bool canEq = false;
                switch (Owner.ProfessionType)
                {
                case ProfessionType.Trojan:
                    canEq = Owner.ProfessionLevel >= 2;
                    break;

                case ProfessionType.Archer:
                    canEq = true;
                    break;

                case ProfessionType.Warrior:
                    canEq = Owner.ProfessionLevel > 1;
                    break;
                }
                if (!canEq)
                {
                    return(false);
                }

                //Now that we know it's physically possible to equip to second weapon slot we need to check the type of item
                if (Owner.ProfessionType == ProfessionType.Warrior)
                {
                    canEq = item.EquipmentType == 900;
                }
                else if (Owner.ProfessionType == ProfessionType.Archer)
                {
                    canEq = item.EquipmentType == 1050;
                }

                if (!canEq)
                {
                    return(false);
                }
            }
            else
            {
                byte toLoc = GetDefaultItemLocation(item.EquipmentType);
                if (toLoc != location)
                {
                    location = toLoc;
                }
            }
            //Check all iteminfo req's
            bool success = (item.BaseItem.GenderReq == 0 || !Owner.IsMale) &&
                           Owner.Level >= item.BaseItem.LevelReq &&
                           (Owner.RebornCount > 0 || (Owner.Strength >= item.BaseItem.StrengthReq &&
                                                      Owner.Agility >= item.BaseItem.AgilityReq &&
                                                      Owner.Spirit >= item.BaseItem.SpiritReq &&
                                                      CanEquipProfession(item)));

            if (!success)
            {
                return(false);
            }

            if (equippedItems[location] != null)
            {
                UnequipItem(location);
            }
            item.Location = (ItemLocation)location;
            item.Save();

            //Track equipped super gems
            if (item.Gem1 % 10 == 3 || item.Gem2 % 10 == 3)
            {
                if (!superGems.Contains(item.Gem1 / 10))
                {
                    superGems.Add(item.Gem1 / 10);
                }
            }

            equippedItems[location] = item;
            if (updateClient)
            {
                Owner.SpawnPacket = SpawnEntityPacket.Create(Owner);
                Owner.Send(ItemActionPacket.Create(item.UniqueID, (byte)item.Location, ItemAction.SetEquipItem));
                Owner.SendToScreen(Owner.SpawnPacket, true);
            }
            return(true);
        }
 public static ItemActionPacket HandlePacket(Models.Entities.Player player, ItemActionPacket packet, out uint subPacketId)
 {
     subPacketId = (uint)packet.Action;
     return(packet);
 }