Ejemplo n.º 1
0
        public bool unequipItem(ItemData.EQUIP slot)
        {
            int equipSlotIndex = (int)slot;

            if (player.getInventory().addItem(slots[equipSlotIndex].getItemId(), slots[equipSlotIndex].getItemAmount()))
            {
                if (slot == ItemData.EQUIP.HAT)
                {
                    if (RuneCraft.wearingTiara(player))
                    {
                        RuneCraft.toggleRuin(player, getItemInSlot(slot), false);
                    }
                }
                slots[equipSlotIndex].setItemId(-1);
                slots[equipSlotIndex].setItemAmount(0);
                player.getPackets().refreshEquipment();
                player.getUpdateFlags().setAppearanceUpdateRequired(true);
                refreshBonuses();
                player.setEntityFocus(65535);
                if (slot == ItemData.EQUIP.WEAPON)
                {
                    setWeapon();
                    MagicData.cancelAutoCast(player, true);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        private bool duelRuleActive(ItemData.EQUIP equipType)
        {
            if (player.getDuel() == null)
            {
                return(false);
            }
            if (player.getDuel().getStatus() == 5 || player.getDuel().getStatus() == 6)
            {
                ItemData.EQUIP[] slot = { ItemData.EQUIP.HAT,    ItemData.EQUIP.CAPE,  ItemData.EQUIP.AMULET,
                                          ItemData.EQUIP.WEAPON, ItemData.EQUIP.CHEST, ItemData.EQUIP.SHIELD,
                                          ItemData.EQUIP.LEGS,   ItemData.EQUIP.HANDS, ItemData.EQUIP.FEET,
                                          ItemData.EQUIP.RING,   ItemData.EQUIP.ARROWS };

                DuelSession.RULE[] rule = { DuelSession.RULE.HAT,    DuelSession.RULE.CAPE,   DuelSession.RULE.AMULET,
                                            DuelSession.RULE.WEAPON, DuelSession.RULE.BODY,   DuelSession.RULE.SHIELD,
                                            DuelSession.RULE.LEGS,   DuelSession.RULE.GLOVES, DuelSession.RULE.BOOTS,
                                            DuelSession.RULE.RING,   DuelSession.RULE.ARROWS };
                for (int j = 0; j < rule.Length; j++)
                {
                    if (player.getDuel().ruleEnabled(rule[j]))
                    {
                        if (equipType == slot[j])
                        {
                            player.getPackets().sendMessage("You cannot equip that item in this duel.");
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        private void handleOperateItem(Player player, Packet packet)
        {
            int item        = packet.readShortA();
            int slot        = packet.readLEShort();
            int interfaceId = packet.readLEShort();
            int childId     = packet.readLEShort();

            if (slot < 0 || slot > 13 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
            {
                return;
            }
            ItemData.EQUIP equipSlot = (ItemData.EQUIP)slot;
            if (player.getEquipment().getItemInSlot(equipSlot) == item)
            {
                SkillHandler.resetAllSkills(player);
                player.getPackets().closeInterfaces();
                if (JewelleryTeleport.useJewellery(player, player.getEquipment().getItemInSlot(equipSlot), slot, true))
                {
                    return;
                }
                else
                if (equipSlot == ItemData.EQUIP.CAPE && Skillcape.emote(player))
                {
                    return;
                }
                player.getPackets().sendMessage("This item isn't operable.");
            }
        }
Ejemplo n.º 4
0
        public bool equipItem(int itemID, int slot)
        {
            ItemData.EQUIP equipType = ItemData.getItemType(itemID);
            int            amount    = player.getInventory().getAmountInSlot(slot);
            bool           stackable = ItemData.forId(itemID).isStackable();
            bool           twoHanded = ItemData.isTwoHanded(itemID);

            if (equipType == ItemData.EQUIP.NOTHING)
            {
                player.getPackets().sendMessage("Unable to find an item slot for item : " + itemID + " , please report this to a staff member.");
                return(false);
            }
            if (duelRuleActive(equipType))
            {
                return(true);
            }
            if (twoHanded)
            {
                if (player.getInventory().getTotalFreeSlots() < getNeeded2HSlots())
                {
                    player.getPackets().sendMessage("Not enough space in your inventory.");
                    return(false);
                }
            }
            if (!player.getInventory().deleteItem(itemID, slot, amount))
            {
                return(false);
            }
            if (twoHanded && getItemInSlot(ItemData.EQUIP.SHIELD) != -1)
            {
                if (!unequipItem(ItemData.EQUIP.SHIELD))
                {
                    return(false);
                }
            }
            if (equipType == ItemData.EQUIP.SHIELD)
            {
                if (getItemInSlot(ItemData.EQUIP.WEAPON) != -1)
                {
                    if (ItemData.isTwoHanded(slots[3].getItemId()))
                    {
                        if (!unequipItem(ItemData.EQUIP.WEAPON))
                        {
                            return(false);
                        }
                    }
                }
            }
            int equipSlot = Convert.ToInt32(equipType);

            if (slots[equipSlot].getItemId() != itemID && slots[equipSlot].getItemId() > 0)
            {
                if (!player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot))
                {
                    return(false);
                }
                if (equipType == ItemData.EQUIP.HAT)
                {
                    RuneCraft.toggleRuin(player, slots[equipSlot].getItemId(), false);
                    if (RuneCraft.getTiaraIndex(itemID) != -1)                   // switching from tiara to tiara.
                    {
                        RuneCraft.toggleRuin(player, itemID, true);
                    }
                }
            }
            else if (stackable && slots[equipSlot].getItemId() == itemID)
            {
                amount = slots[equipSlot].getItemAmount() + amount;
            }
            else if (slots[equipSlot].getItemId() != -1)
            {
                player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot);
            }
            slots[equipSlot].setItemId(itemID);
            slots[equipSlot].setItemAmount(amount);
            player.getPackets().refreshEquipment();
            player.getUpdateFlags().setAppearanceUpdateRequired(true);
            if (equipType == ItemData.EQUIP.HAT)
            {
                RuneCraft.toggleRuin(player, itemID, RuneCraft.wearingTiara(player));
            }
            if (equipType == ItemData.EQUIP.WEAPON)
            {
                setWeapon();
                MagicData.cancelAutoCast(player, true);
            }
            refreshBonuses();
            player.setEntityFocus(65535);
            return(true);
        }
Ejemplo n.º 5
0
 public int getItemInSlot(ItemData.EQUIP slot)
 {
     return(slots[Convert.ToInt32(slot)].getItemId());
 }
Ejemplo n.º 6
0
 public Item getSlot(ItemData.EQUIP slot)
 {
     return(slots[Convert.ToInt32(slot)]);
 }
Ejemplo n.º 7
0
 public int getLook(ItemData.EQUIP id)       //TODO move EQUIP to model folder -.-
 {
     return(look[Convert.ToInt32(id)]);
 }