|
@@ -14,7 +14,6 @@
|
|
|
*/
|
|
|
package net.sf.l2j.gameserver.network.clientpackets;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
import net.sf.l2j.Config;
|
|
@@ -28,7 +27,6 @@ import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
|
|
|
import net.sf.l2j.gameserver.model.base.Race;
|
|
|
import net.sf.l2j.gameserver.network.SystemMessageId;
|
|
|
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
|
|
|
-import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
|
|
|
import net.sf.l2j.gameserver.network.serverpackets.ItemList;
|
|
|
import net.sf.l2j.gameserver.network.serverpackets.ShowCalculator;
|
|
|
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
|
|
@@ -67,92 +65,7 @@ public final class UseItem extends L2GameClientPacket
|
|
|
if (activeChar.isAttackingNow())
|
|
|
return;
|
|
|
// Equip or unEquip
|
|
|
- L2ItemInstance[] items = null;
|
|
|
- boolean isEquiped = item.isEquipped();
|
|
|
- SystemMessage sm = null;
|
|
|
- L2ItemInstance old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND);
|
|
|
- if (old == null)
|
|
|
- old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
|
|
|
-
|
|
|
- activeChar.checkSSMatch(item, old);
|
|
|
-
|
|
|
- if (isEquiped)
|
|
|
- {
|
|
|
- if (item.getEnchantLevel() > 0)
|
|
|
- {
|
|
|
- sm = new SystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
|
|
|
- sm.addNumber(item.getEnchantLevel());
|
|
|
- sm.addItemName(item);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sm = new SystemMessage(SystemMessageId.S1_DISARMED);
|
|
|
- sm.addItemName(item);
|
|
|
- }
|
|
|
- activeChar.sendPacket(sm);
|
|
|
-
|
|
|
- int slot = activeChar.getInventory().getSlotFromItem(item);
|
|
|
- items = activeChar.getInventory().unEquipItemInBodySlotAndRecord(slot);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- int tempBodyPart = item.getItem().getBodyPart();
|
|
|
- L2ItemInstance tempItem = activeChar.getInventory().getPaperdollItemByL2ItemId(tempBodyPart);
|
|
|
-
|
|
|
- //check if the item replaces a wear-item
|
|
|
- if (tempItem != null && tempItem.isWear())
|
|
|
- {
|
|
|
- // dont allow an item to replace a wear-item
|
|
|
- return;
|
|
|
- }
|
|
|
- else if (tempBodyPart == 0x4000) // left+right hand equipment
|
|
|
- {
|
|
|
- // this may not remove left OR right hand equipment
|
|
|
- tempItem = activeChar.getInventory().getPaperdollItem(7);
|
|
|
- if (tempItem != null && tempItem.isWear()) return;
|
|
|
-
|
|
|
- tempItem = activeChar.getInventory().getPaperdollItem(8);
|
|
|
- if (tempItem != null && tempItem.isWear()) return;
|
|
|
- }
|
|
|
- else if (tempBodyPart == 0x8000) // fullbody armor
|
|
|
- {
|
|
|
- // this may not remove chest or leggins
|
|
|
- tempItem = activeChar.getInventory().getPaperdollItem(10);
|
|
|
- if (tempItem != null && tempItem.isWear()) return;
|
|
|
-
|
|
|
- tempItem = activeChar.getInventory().getPaperdollItem(11);
|
|
|
- if (tempItem != null && tempItem.isWear()) return;
|
|
|
- }
|
|
|
-
|
|
|
- if (item.getEnchantLevel() > 0)
|
|
|
- {
|
|
|
- sm = new SystemMessage(SystemMessageId.S1_S2_EQUIPPED);
|
|
|
- sm.addNumber(item.getEnchantLevel());
|
|
|
- sm.addItemName(item);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sm = new SystemMessage(SystemMessageId.S1_EQUIPPED);
|
|
|
- sm.addItemName(item);
|
|
|
- }
|
|
|
- activeChar.sendPacket(sm);
|
|
|
-
|
|
|
- items = activeChar.getInventory().equipItemAndRecord(item);
|
|
|
-
|
|
|
- // Consume mana - will start a task if required; returns if item is not a shadow item
|
|
|
- item.decreaseMana(false);
|
|
|
- }
|
|
|
- sm = null;
|
|
|
-
|
|
|
- activeChar.refreshExpertisePenalty();
|
|
|
-
|
|
|
- if (item.getItem().getType2() == L2Item.TYPE2_WEAPON)
|
|
|
- activeChar.checkIfWeaponIsAllowed();
|
|
|
-
|
|
|
- InventoryUpdate iu = new InventoryUpdate();
|
|
|
- iu.addItems(Arrays.asList(items));
|
|
|
- activeChar.sendPacket(iu);
|
|
|
- activeChar.broadcastUserInfo();
|
|
|
+ activeChar.useEquippableItem(item, false);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -639,93 +552,7 @@ public final class UseItem extends L2GameClientPacket
|
|
|
return;
|
|
|
}
|
|
|
// Equip or unEquip
|
|
|
- L2ItemInstance[] items = null;
|
|
|
- boolean isEquiped = item.isEquipped();
|
|
|
- SystemMessage sm = null;
|
|
|
- L2ItemInstance old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND);
|
|
|
- if (old == null)
|
|
|
- old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
|
|
|
-
|
|
|
- activeChar.checkSSMatch(item, old);
|
|
|
-
|
|
|
- if (isEquiped)
|
|
|
- {
|
|
|
- if (item.getEnchantLevel() > 0)
|
|
|
- {
|
|
|
- sm = new SystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
|
|
|
- sm.addNumber(item.getEnchantLevel());
|
|
|
- sm.addItemName(item);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sm = new SystemMessage(SystemMessageId.S1_DISARMED);
|
|
|
- sm.addItemName(item);
|
|
|
- }
|
|
|
- activeChar.sendPacket(sm);
|
|
|
-
|
|
|
- int slot = activeChar.getInventory().getSlotFromItem(item);
|
|
|
- items = activeChar.getInventory().unEquipItemInBodySlotAndRecord(slot);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- int tempBodyPart = item.getItem().getBodyPart();
|
|
|
- L2ItemInstance tempItem = activeChar.getInventory().getPaperdollItemByL2ItemId(tempBodyPart);
|
|
|
-
|
|
|
- //check if the item replaces a wear-item
|
|
|
- if (tempItem != null && tempItem.isWear())
|
|
|
- {
|
|
|
- // dont allow an item to replace a wear-item
|
|
|
- return;
|
|
|
- }
|
|
|
- else if (tempBodyPart == 0x4000) // left+right hand equipment
|
|
|
- {
|
|
|
- // this may not remove left OR right hand equipment
|
|
|
- tempItem = activeChar.getInventory().getPaperdollItem(7);
|
|
|
- if (tempItem != null && tempItem.isWear()) return;
|
|
|
-
|
|
|
- tempItem = activeChar.getInventory().getPaperdollItem(8);
|
|
|
- if (tempItem != null && tempItem.isWear()) return;
|
|
|
- }
|
|
|
- else if (tempBodyPart == 0x8000) // fullbody armor
|
|
|
- {
|
|
|
- // this may not remove chest or leggins
|
|
|
- tempItem = activeChar.getInventory().getPaperdollItem(10);
|
|
|
- if (tempItem != null && tempItem.isWear()) return;
|
|
|
-
|
|
|
- tempItem = activeChar.getInventory().getPaperdollItem(11);
|
|
|
- if (tempItem != null && tempItem.isWear()) return;
|
|
|
- }
|
|
|
-
|
|
|
- if (item.getEnchantLevel() > 0)
|
|
|
- {
|
|
|
- sm = new SystemMessage(SystemMessageId.S1_S2_EQUIPPED);
|
|
|
- sm.addNumber(item.getEnchantLevel());
|
|
|
- sm.addItemName(item);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sm = new SystemMessage(SystemMessageId.S1_EQUIPPED);
|
|
|
- sm.addItemName(item);
|
|
|
- }
|
|
|
- activeChar.sendPacket(sm);
|
|
|
-
|
|
|
- items = activeChar.getInventory().equipItemAndRecord(item);
|
|
|
-
|
|
|
- // Consume mana - will start a task if required; returns if item is not a shadow item
|
|
|
- item.decreaseMana(false);
|
|
|
- }
|
|
|
- sm = null;
|
|
|
-
|
|
|
- activeChar.refreshExpertisePenalty();
|
|
|
-
|
|
|
- if (item.getItem().getType2() == L2Item.TYPE2_WEAPON)
|
|
|
- activeChar.checkIfWeaponIsAllowed();
|
|
|
-
|
|
|
- InventoryUpdate iu = new InventoryUpdate();
|
|
|
- iu.addItems(Arrays.asList(items));
|
|
|
- activeChar.sendPacket(iu);
|
|
|
- activeChar.abortAttack();
|
|
|
- activeChar.broadcastUserInfo();
|
|
|
+ activeChar.useEquippableItem(item, true);
|
|
|
}
|
|
|
else
|
|
|
{
|