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); }
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); }