|
@@ -18,156 +18,148 @@
|
|
*/
|
|
*/
|
|
package com.l2jserver.gameserver.network.clientpackets;
|
|
package com.l2jserver.gameserver.network.clientpackets;
|
|
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
+import static com.l2jserver.gameserver.ai.CtrlEvent.EVT_FINISH_CASTING;
|
|
|
|
+import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_CAST;
|
|
|
|
+import static com.l2jserver.gameserver.enums.PrivateStoreType.NONE;
|
|
|
|
+import static com.l2jserver.gameserver.enums.Race.KAMAEL;
|
|
|
|
+import static com.l2jserver.gameserver.model.PcCondOverride.ITEM_CONDITIONS;
|
|
|
|
+import static com.l2jserver.gameserver.model.effects.L2EffectType.TELEPORT;
|
|
|
|
+import static com.l2jserver.gameserver.model.itemcontainer.Inventory.PAPERDOLL_LHAND;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_BACK;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_CHEST;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_DECO;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_FEET;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_FULL_ARMOR;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_GLOVES;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_HEAD;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_LEGS;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_LR_HAND;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_L_HAND;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.L2Item.SLOT_R_HAND;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.type.ArmorType.HEAVY;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.type.ArmorType.MAGIC;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.type.ItemType2.QUEST;
|
|
|
|
+import static com.l2jserver.gameserver.model.items.type.WeaponType.FISHINGROD;
|
|
|
|
+import static com.l2jserver.gameserver.network.SystemMessageId.CANNOT_DO_WHILE_FISHING_3;
|
|
|
|
+import static com.l2jserver.gameserver.network.SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION;
|
|
|
|
+import static com.l2jserver.gameserver.network.SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE;
|
|
|
|
+import static com.l2jserver.gameserver.network.SystemMessageId.CANNOT_USE_QUEST_ITEMS;
|
|
|
|
+import static com.l2jserver.gameserver.network.SystemMessageId.S1_CANNOT_BE_USED;
|
|
|
|
+import static com.l2jserver.gameserver.network.SystemMessageId.S2_HOURS_S3_MINUTES_S4_SECONDS_REMAINING_FOR_REUSE_S1;
|
|
|
|
+import static com.l2jserver.gameserver.network.SystemMessageId.S2_MINUTES_S3_SECONDS_REMAINING_FOR_REUSE_S1;
|
|
|
|
+import static com.l2jserver.gameserver.network.SystemMessageId.S2_SECONDS_REMAINING_FOR_REUSE_S1;
|
|
|
|
+import static com.l2jserver.gameserver.network.serverpackets.ActionFailed.STATIC_PACKET;
|
|
|
|
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
|
|
|
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
|
|
|
+
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Level;
|
|
|
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+
|
|
import com.l2jserver.Config;
|
|
import com.l2jserver.Config;
|
|
import com.l2jserver.gameserver.ThreadPoolManager;
|
|
import com.l2jserver.gameserver.ThreadPoolManager;
|
|
-import com.l2jserver.gameserver.ai.CtrlEvent;
|
|
|
|
-import com.l2jserver.gameserver.ai.CtrlIntention;
|
|
|
|
import com.l2jserver.gameserver.ai.NextAction;
|
|
import com.l2jserver.gameserver.ai.NextAction;
|
|
-import com.l2jserver.gameserver.enums.PrivateStoreType;
|
|
|
|
-import com.l2jserver.gameserver.enums.Race;
|
|
|
|
import com.l2jserver.gameserver.handler.IItemHandler;
|
|
import com.l2jserver.gameserver.handler.IItemHandler;
|
|
import com.l2jserver.gameserver.handler.ItemHandler;
|
|
import com.l2jserver.gameserver.handler.ItemHandler;
|
|
import com.l2jserver.gameserver.instancemanager.FortSiegeManager;
|
|
import com.l2jserver.gameserver.instancemanager.FortSiegeManager;
|
|
-import com.l2jserver.gameserver.model.PcCondOverride;
|
|
|
|
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
|
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
|
-import com.l2jserver.gameserver.model.effects.L2EffectType;
|
|
|
|
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
|
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
|
-import com.l2jserver.gameserver.model.itemcontainer.Inventory;
|
|
|
|
import com.l2jserver.gameserver.model.items.L2EtcItem;
|
|
import com.l2jserver.gameserver.model.items.L2EtcItem;
|
|
-import com.l2jserver.gameserver.model.items.L2Item;
|
|
|
|
import com.l2jserver.gameserver.model.items.L2Weapon;
|
|
import com.l2jserver.gameserver.model.items.L2Weapon;
|
|
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
|
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
|
-import com.l2jserver.gameserver.model.items.type.ArmorType;
|
|
|
|
-import com.l2jserver.gameserver.model.items.type.ItemType2;
|
|
|
|
-import com.l2jserver.gameserver.model.items.type.WeaponType;
|
|
|
|
import com.l2jserver.gameserver.model.skills.Skill;
|
|
import com.l2jserver.gameserver.model.skills.Skill;
|
|
-import com.l2jserver.gameserver.network.SystemMessageId;
|
|
|
|
-import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
|
|
|
import com.l2jserver.gameserver.network.serverpackets.ExUseSharedGroupItem;
|
|
import com.l2jserver.gameserver.network.serverpackets.ExUseSharedGroupItem;
|
|
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
|
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
|
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
|
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
|
|
|
|
|
-public final class UseItem extends L2GameClientPacket
|
|
|
|
-{
|
|
|
|
|
|
+public final class UseItem extends L2GameClientPacket {
|
|
|
|
+
|
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(UseItem.class);
|
|
|
|
+
|
|
private static final String _C__19_USEITEM = "[C] 19 UseItem";
|
|
private static final String _C__19_USEITEM = "[C] 19 UseItem";
|
|
|
|
|
|
|
|
+ private static final int FORMAL_WEAR_ID = 6408;
|
|
|
|
+
|
|
private int _objectId;
|
|
private int _objectId;
|
|
|
|
+
|
|
private boolean _ctrlPressed;
|
|
private boolean _ctrlPressed;
|
|
- private int _itemId;
|
|
|
|
|
|
|
|
- /** Weapon Equip Task */
|
|
|
|
- private static class WeaponEquipTask implements Runnable
|
|
|
|
- {
|
|
|
|
- private final L2ItemInstance item;
|
|
|
|
- private final L2PcInstance activeChar;
|
|
|
|
-
|
|
|
|
- protected WeaponEquipTask(L2ItemInstance it, L2PcInstance character)
|
|
|
|
- {
|
|
|
|
- item = it;
|
|
|
|
- activeChar = character;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void run()
|
|
|
|
- {
|
|
|
|
- // Equip or unEquip
|
|
|
|
- activeChar.useEquippableItem(item, false);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ private int _itemId;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- protected void readImpl()
|
|
|
|
- {
|
|
|
|
|
|
+ protected void readImpl() {
|
|
_objectId = readD();
|
|
_objectId = readD();
|
|
_ctrlPressed = readD() != 0;
|
|
_ctrlPressed = readD() != 0;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- protected void runImpl()
|
|
|
|
- {
|
|
|
|
|
|
+ protected void runImpl() {
|
|
final L2PcInstance activeChar = getClient().getActiveChar();
|
|
final L2PcInstance activeChar = getClient().getActiveChar();
|
|
- if (activeChar == null)
|
|
|
|
- {
|
|
|
|
|
|
+ if (activeChar == null) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (Config.DEBUG)
|
|
|
|
- {
|
|
|
|
- _log.log(Level.INFO, activeChar + ": use item " + _objectId);
|
|
|
|
|
|
+ if (Config.DEBUG) {
|
|
|
|
+ LOG.debug("{} uses item with object Id {}.", activeChar.toString(), _objectId);
|
|
}
|
|
}
|
|
|
|
|
|
// Flood protect UseItem
|
|
// Flood protect UseItem
|
|
- if (!getClient().getFloodProtectors().getUseItem().tryPerformAction("use item"))
|
|
|
|
- {
|
|
|
|
|
|
+ if (!getClient().getFloodProtectors().getUseItem().tryPerformAction("use item")) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (activeChar.getActiveTradeList() != null)
|
|
|
|
- {
|
|
|
|
|
|
+ if (activeChar.getActiveTradeList() != null) {
|
|
activeChar.cancelActiveTrade();
|
|
activeChar.cancelActiveTrade();
|
|
}
|
|
}
|
|
|
|
|
|
- if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE)
|
|
|
|
- {
|
|
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE);
|
|
|
|
- activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
|
|
|
|
|
+ if (activeChar.getPrivateStoreType() != NONE) {
|
|
|
|
+ activeChar.sendPacket(CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE);
|
|
|
|
+ activeChar.sendPacket(STATIC_PACKET);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
|
|
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
|
|
- if (item == null)
|
|
|
|
- {
|
|
|
|
|
|
+ if (item == null) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (item.getItem().getType2() == ItemType2.QUEST)
|
|
|
|
- {
|
|
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_USE_QUEST_ITEMS);
|
|
|
|
|
|
+ if (item.getItem().getType2() == QUEST) {
|
|
|
|
+ activeChar.sendPacket(CANNOT_USE_QUEST_ITEMS);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
// No UseItem is allowed while the player is in special conditions
|
|
// No UseItem is allowed while the player is in special conditions
|
|
- if (activeChar.isStunned() || activeChar.isParalyzed() || activeChar.isSleeping() || activeChar.isAfraid() || activeChar.isAlikeDead())
|
|
|
|
- {
|
|
|
|
|
|
+ if (activeChar.isStunned() || activeChar.isParalyzed() || activeChar.isSleeping() || activeChar.isAfraid() || activeChar.isAlikeDead()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
_itemId = item.getId();
|
|
_itemId = item.getId();
|
|
|
|
|
|
// Char cannot use item when dead
|
|
// Char cannot use item when dead
|
|
- if (activeChar.isDead() || !activeChar.getInventory().canManipulateWithItemId(_itemId))
|
|
|
|
- {
|
|
|
|
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
|
|
|
|
|
|
+ if (activeChar.isDead() || !activeChar.getInventory().canManipulateWithItemId(_itemId)) {
|
|
|
|
+ final SystemMessage sm = SystemMessage.getSystemMessage(S1_CANNOT_BE_USED);
|
|
sm.addItemName(item);
|
|
sm.addItemName(item);
|
|
activeChar.sendPacket(sm);
|
|
activeChar.sendPacket(sm);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!item.isEquipped() && !item.getItem().checkCondition(activeChar, activeChar, true))
|
|
|
|
- {
|
|
|
|
|
|
+ if (!item.isEquipped() && !item.getItem().checkCondition(activeChar, activeChar, true)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (activeChar.isFishing() && ((_itemId < 6535) || (_itemId > 6540)))
|
|
|
|
- {
|
|
|
|
|
|
+ if (activeChar.isFishing() && ((_itemId < 6535) || (_itemId > 6540))) {
|
|
// You cannot do anything else while fishing
|
|
// You cannot do anything else while fishing
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
|
|
|
|
|
|
+ activeChar.sendPacket(CANNOT_DO_WHILE_FISHING_3);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TELEPORT && (activeChar.getKarma() > 0))
|
|
|
|
- {
|
|
|
|
|
|
+ if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TELEPORT && (activeChar.getKarma() > 0)) {
|
|
SkillHolder[] skills = item.getItem().getSkills();
|
|
SkillHolder[] skills = item.getItem().getSkills();
|
|
- if (skills != null)
|
|
|
|
- {
|
|
|
|
- for (SkillHolder sHolder : skills)
|
|
|
|
- {
|
|
|
|
|
|
+ if (skills != null) {
|
|
|
|
+ for (SkillHolder sHolder : skills) {
|
|
Skill skill = sHolder.getSkill();
|
|
Skill skill = sHolder.getSkill();
|
|
- if ((skill != null) && skill.hasEffectType(L2EffectType.TELEPORT))
|
|
|
|
- {
|
|
|
|
|
|
+ if ((skill != null) && skill.hasEffectType(TELEPORT)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -178,87 +170,70 @@ public final class UseItem extends L2GameClientPacket
|
|
// Message from reuse delay must come from item.
|
|
// Message from reuse delay must come from item.
|
|
final int reuseDelay = item.getReuseDelay();
|
|
final int reuseDelay = item.getReuseDelay();
|
|
final int sharedReuseGroup = item.getSharedReuseGroup();
|
|
final int sharedReuseGroup = item.getSharedReuseGroup();
|
|
- if (reuseDelay > 0)
|
|
|
|
- {
|
|
|
|
|
|
+ if (reuseDelay > 0) {
|
|
final long reuse = activeChar.getItemRemainingReuseTime(item.getObjectId());
|
|
final long reuse = activeChar.getItemRemainingReuseTime(item.getObjectId());
|
|
- if (reuse > 0)
|
|
|
|
- {
|
|
|
|
|
|
+ if (reuse > 0) {
|
|
reuseData(activeChar, item, reuse);
|
|
reuseData(activeChar, item, reuse);
|
|
sendSharedGroupUpdate(activeChar, sharedReuseGroup, reuse, reuseDelay);
|
|
sendSharedGroupUpdate(activeChar, sharedReuseGroup, reuse, reuseDelay);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
final long reuseOnGroup = activeChar.getReuseDelayOnGroup(sharedReuseGroup);
|
|
final long reuseOnGroup = activeChar.getReuseDelayOnGroup(sharedReuseGroup);
|
|
- if (reuseOnGroup > 0)
|
|
|
|
- {
|
|
|
|
|
|
+ if (reuseOnGroup > 0) {
|
|
reuseData(activeChar, item, reuseOnGroup);
|
|
reuseData(activeChar, item, reuseOnGroup);
|
|
sendSharedGroupUpdate(activeChar, sharedReuseGroup, reuseOnGroup, reuseDelay);
|
|
sendSharedGroupUpdate(activeChar, sharedReuseGroup, reuseOnGroup, reuseDelay);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (item.isEquipable())
|
|
|
|
- {
|
|
|
|
|
|
+ if (item.isEquipable()) {
|
|
// Don't allow to put formal wear while a cursed weapon is equipped.
|
|
// Don't allow to put formal wear while a cursed weapon is equipped.
|
|
- if (activeChar.isCursedWeaponEquipped() && (_itemId == 6408))
|
|
|
|
- {
|
|
|
|
|
|
+ if (activeChar.isCursedWeaponEquipped() && (_itemId == FORMAL_WEAR_ID)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
// Equip or unEquip
|
|
// Equip or unEquip
|
|
- if (FortSiegeManager.getInstance().isCombat(_itemId))
|
|
|
|
- {
|
|
|
|
|
|
+ if (FortSiegeManager.getInstance().isCombat(_itemId)) {
|
|
return; // no message
|
|
return; // no message
|
|
}
|
|
}
|
|
|
|
|
|
- if (activeChar.isCombatFlagEquipped())
|
|
|
|
- {
|
|
|
|
|
|
+ if (activeChar.isCombatFlagEquipped()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- switch (item.getItem().getBodyPart())
|
|
|
|
- {
|
|
|
|
- case L2Item.SLOT_LR_HAND:
|
|
|
|
- case L2Item.SLOT_L_HAND:
|
|
|
|
- case L2Item.SLOT_R_HAND:
|
|
|
|
- {
|
|
|
|
|
|
+ switch (item.getItem().getBodyPart()) {
|
|
|
|
+ case SLOT_LR_HAND:
|
|
|
|
+ case SLOT_L_HAND:
|
|
|
|
+ case SLOT_R_HAND: {
|
|
// Prevent players to equip weapon while wearing combat flag
|
|
// Prevent players to equip weapon while wearing combat flag
|
|
- if ((activeChar.getActiveWeaponItem() != null) && (activeChar.getActiveWeaponItem().getId() == 9819))
|
|
|
|
- {
|
|
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
|
|
|
|
+ if ((activeChar.getActiveWeaponItem() != null) && (activeChar.getActiveWeaponItem().getId() == 9819)) {
|
|
|
|
+ activeChar.sendPacket(CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (activeChar.isMounted())
|
|
|
|
- {
|
|
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
|
|
|
|
+ if (activeChar.isMounted()) {
|
|
|
|
+ activeChar.sendPacket(CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (activeChar.isDisarmed())
|
|
|
|
- {
|
|
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
|
|
|
|
+ if (activeChar.isDisarmed()) {
|
|
|
|
+ activeChar.sendPacket(CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
// Don't allow weapon/shield equipment if a cursed weapon is equipped.
|
|
// Don't allow weapon/shield equipment if a cursed weapon is equipped.
|
|
- if (activeChar.isCursedWeaponEquipped())
|
|
|
|
- {
|
|
|
|
|
|
+ if (activeChar.isCursedWeaponEquipped()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
// Don't allow other Race to Wear Kamael exclusive Weapons.
|
|
// Don't allow other Race to Wear Kamael exclusive Weapons.
|
|
- if (!item.isEquipped() && item.isWeapon() && !activeChar.canOverrideCond(PcCondOverride.ITEM_CONDITIONS))
|
|
|
|
- {
|
|
|
|
|
|
+ if (!item.isEquipped() && item.isWeapon() && !activeChar.canOverrideCond(ITEM_CONDITIONS)) {
|
|
L2Weapon wpn = (L2Weapon) item.getItem();
|
|
L2Weapon wpn = (L2Weapon) item.getItem();
|
|
|
|
|
|
- switch (activeChar.getRace())
|
|
|
|
- {
|
|
|
|
- case KAMAEL:
|
|
|
|
- {
|
|
|
|
- switch (wpn.getItemType())
|
|
|
|
- {
|
|
|
|
|
|
+ switch (activeChar.getRace()) {
|
|
|
|
+ case KAMAEL: {
|
|
|
|
+ switch (wpn.getItemType()) {
|
|
case NONE:
|
|
case NONE:
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
|
|
|
|
+ activeChar.sendPacket(CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -267,14 +242,12 @@ public final class UseItem extends L2GameClientPacket
|
|
case DWARF:
|
|
case DWARF:
|
|
case ELF:
|
|
case ELF:
|
|
case DARK_ELF:
|
|
case DARK_ELF:
|
|
- case ORC:
|
|
|
|
- {
|
|
|
|
- switch (wpn.getItemType())
|
|
|
|
- {
|
|
|
|
|
|
+ case ORC: {
|
|
|
|
+ switch (wpn.getItemType()) {
|
|
case RAPIER:
|
|
case RAPIER:
|
|
case CROSSBOW:
|
|
case CROSSBOW:
|
|
case ANCIENTSWORD:
|
|
case ANCIENTSWORD:
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
|
|
|
|
+ activeChar.sendPacket(CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -283,55 +256,43 @@ public final class UseItem extends L2GameClientPacket
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case L2Item.SLOT_CHEST:
|
|
|
|
- case L2Item.SLOT_BACK:
|
|
|
|
- case L2Item.SLOT_GLOVES:
|
|
|
|
- case L2Item.SLOT_FEET:
|
|
|
|
- case L2Item.SLOT_HEAD:
|
|
|
|
- case L2Item.SLOT_FULL_ARMOR:
|
|
|
|
- case L2Item.SLOT_LEGS:
|
|
|
|
- {
|
|
|
|
- if ((activeChar.getRace() == Race.KAMAEL) && ((item.getItem().getItemType() == ArmorType.HEAVY) || (item.getItem().getItemType() == ArmorType.MAGIC)))
|
|
|
|
- {
|
|
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
|
|
|
|
+ case SLOT_CHEST:
|
|
|
|
+ case SLOT_BACK:
|
|
|
|
+ case SLOT_GLOVES:
|
|
|
|
+ case SLOT_FEET:
|
|
|
|
+ case SLOT_HEAD:
|
|
|
|
+ case SLOT_FULL_ARMOR:
|
|
|
|
+ case SLOT_LEGS: {
|
|
|
|
+ if ((activeChar.getRace() == KAMAEL) && ((item.getItem().getItemType() == HEAVY) || (item.getItem().getItemType() == MAGIC))) {
|
|
|
|
+ activeChar.sendPacket(CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case L2Item.SLOT_DECO:
|
|
|
|
- {
|
|
|
|
- if (!item.isEquipped() && (activeChar.getInventory().getTalismanSlots() == 0))
|
|
|
|
- {
|
|
|
|
- activeChar.sendPacket(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
|
|
|
|
+ case SLOT_DECO: {
|
|
|
|
+ if (!item.isEquipped() && (activeChar.getInventory().getTalismanSlots() == 0)) {
|
|
|
|
+ activeChar.sendPacket(CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (activeChar.isCastingNow() || activeChar.isCastingSimultaneouslyNow())
|
|
|
|
- {
|
|
|
|
|
|
+ if (activeChar.isCastingNow() || activeChar.isCastingSimultaneouslyNow()) {
|
|
// Creating next action class.
|
|
// Creating next action class.
|
|
- final NextAction nextAction = new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> activeChar.useEquippableItem(item, true));
|
|
|
|
|
|
+ final NextAction nextAction = new NextAction(EVT_FINISH_CASTING, AI_INTENTION_CAST, () -> activeChar.useEquippableItem(_objectId, true));
|
|
|
|
|
|
// Binding next action to AI.
|
|
// Binding next action to AI.
|
|
activeChar.getAI().setNextAction(nextAction);
|
|
activeChar.getAI().setNextAction(nextAction);
|
|
|
|
+ } else if (activeChar.isAttackingNow()) {
|
|
|
|
+ ThreadPoolManager.getInstance().scheduleGeneral(() -> activeChar.useEquippableItem(_objectId, false), MILLISECONDS.convert(activeChar.getAttackEndTime() - System.nanoTime(), NANOSECONDS));
|
|
|
|
+ } else {
|
|
|
|
+ activeChar.useEquippableItem(_objectId, true);
|
|
}
|
|
}
|
|
- else if (activeChar.isAttackingNow())
|
|
|
|
- {
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(new WeaponEquipTask(item, activeChar), TimeUnit.MILLISECONDS.convert(activeChar.getAttackEndTime() - System.nanoTime(), TimeUnit.NANOSECONDS));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- activeChar.useEquippableItem(item, true);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
|
|
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
|
|
- if (((weaponItem != null) && (weaponItem.getItemType() == WeaponType.FISHINGROD))
|
|
|
|
- && (((_itemId >= 6519) && (_itemId <= 6527)) || ((_itemId >= 7610) && (_itemId <= 7613)) || ((_itemId >= 7807) && (_itemId <= 7809)) || ((_itemId >= 8484) && (_itemId <= 8486)) || ((_itemId >= 8505) && (_itemId <= 8513))))
|
|
|
|
- {
|
|
|
|
- activeChar.getInventory().setPaperdollItem(Inventory.PAPERDOLL_LHAND, item);
|
|
|
|
|
|
+ if (((weaponItem != null) && (weaponItem.getItemType() == FISHINGROD))
|
|
|
|
+ && (((_itemId >= 6519) && (_itemId <= 6527)) || ((_itemId >= 7610) && (_itemId <= 7613)) || ((_itemId >= 7807) && (_itemId <= 7809)) || ((_itemId >= 8484) && (_itemId <= 8486)) || ((_itemId >= 8505) && (_itemId <= 8513)))) {
|
|
|
|
+ activeChar.getInventory().setPaperdollItem(PAPERDOLL_LHAND, item);
|
|
activeChar.broadcastUserInfo();
|
|
activeChar.broadcastUserInfo();
|
|
// Send a Server->Client packet ItemList to this L2PcINstance to update left hand equipment.
|
|
// Send a Server->Client packet ItemList to this L2PcINstance to update left hand equipment.
|
|
sendPacket(new ItemList(activeChar, false));
|
|
sendPacket(new ItemList(activeChar, false));
|
|
@@ -340,14 +301,10 @@ public final class UseItem extends L2GameClientPacket
|
|
|
|
|
|
final L2EtcItem etcItem = item.getEtcItem();
|
|
final L2EtcItem etcItem = item.getEtcItem();
|
|
final IItemHandler handler = ItemHandler.getInstance().getHandler(etcItem);
|
|
final IItemHandler handler = ItemHandler.getInstance().getHandler(etcItem);
|
|
- if (handler == null)
|
|
|
|
- {
|
|
|
|
- if ((etcItem != null) && (etcItem.getHandlerName() != null))
|
|
|
|
- {
|
|
|
|
|
|
+ if (handler == null) {
|
|
|
|
+ if ((etcItem != null) && (etcItem.getHandlerName() != null)) {
|
|
_log.log(Level.WARNING, "Unmanaged Item handler: " + etcItem.getHandlerName() + " for Item Id: " + _itemId + "!");
|
|
_log.log(Level.WARNING, "Unmanaged Item handler: " + etcItem.getHandlerName() + " for Item Id: " + _itemId + "!");
|
|
- }
|
|
|
|
- else if (Config.DEBUG)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (Config.DEBUG) {
|
|
_log.log(Level.WARNING, "No Item handler registered for Item Id: " + _itemId + "!");
|
|
_log.log(Level.WARNING, "No Item handler registered for Item Id: " + _itemId + "!");
|
|
}
|
|
}
|
|
return;
|
|
return;
|
|
@@ -355,10 +312,8 @@ public final class UseItem extends L2GameClientPacket
|
|
|
|
|
|
// Item reuse time should be added if the item is successfully used.
|
|
// Item reuse time should be added if the item is successfully used.
|
|
// Skill reuse delay is done at handlers.itemhandlers.ItemSkillsTemplate;
|
|
// Skill reuse delay is done at handlers.itemhandlers.ItemSkillsTemplate;
|
|
- if (handler.useItem(activeChar, item, _ctrlPressed))
|
|
|
|
- {
|
|
|
|
- if (reuseDelay > 0)
|
|
|
|
- {
|
|
|
|
|
|
+ if (handler.useItem(activeChar, item, _ctrlPressed)) {
|
|
|
|
+ if (reuseDelay > 0) {
|
|
activeChar.addTimeStampItem(item, reuseDelay);
|
|
activeChar.addTimeStampItem(item, reuseDelay);
|
|
sendSharedGroupUpdate(activeChar, sharedReuseGroup, reuseDelay, reuseDelay);
|
|
sendSharedGroupUpdate(activeChar, sharedReuseGroup, reuseDelay, reuseDelay);
|
|
}
|
|
}
|
|
@@ -366,51 +321,41 @@ public final class UseItem extends L2GameClientPacket
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void reuseData(L2PcInstance activeChar, L2ItemInstance item, long remainingTime)
|
|
|
|
- {
|
|
|
|
|
|
+ private void reuseData(L2PcInstance activeChar, L2ItemInstance item, long remainingTime) {
|
|
final int hours = (int) (remainingTime / 3600000L);
|
|
final int hours = (int) (remainingTime / 3600000L);
|
|
final int minutes = (int) (remainingTime % 3600000L) / 60000;
|
|
final int minutes = (int) (remainingTime % 3600000L) / 60000;
|
|
final int seconds = (int) ((remainingTime / 1000) % 60);
|
|
final int seconds = (int) ((remainingTime / 1000) % 60);
|
|
final SystemMessage sm;
|
|
final SystemMessage sm;
|
|
- if (hours > 0)
|
|
|
|
- {
|
|
|
|
- sm = SystemMessage.getSystemMessage(SystemMessageId.S2_HOURS_S3_MINUTES_S4_SECONDS_REMAINING_FOR_REUSE_S1);
|
|
|
|
|
|
+ if (hours > 0) {
|
|
|
|
+ sm = SystemMessage.getSystemMessage(S2_HOURS_S3_MINUTES_S4_SECONDS_REMAINING_FOR_REUSE_S1);
|
|
sm.addItemName(item);
|
|
sm.addItemName(item);
|
|
sm.addInt(hours);
|
|
sm.addInt(hours);
|
|
sm.addInt(minutes);
|
|
sm.addInt(minutes);
|
|
- }
|
|
|
|
- else if (minutes > 0)
|
|
|
|
- {
|
|
|
|
- sm = SystemMessage.getSystemMessage(SystemMessageId.S2_MINUTES_S3_SECONDS_REMAINING_FOR_REUSE_S1);
|
|
|
|
|
|
+ } else if (minutes > 0) {
|
|
|
|
+ sm = SystemMessage.getSystemMessage(S2_MINUTES_S3_SECONDS_REMAINING_FOR_REUSE_S1);
|
|
sm.addItemName(item);
|
|
sm.addItemName(item);
|
|
sm.addInt(minutes);
|
|
sm.addInt(minutes);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- sm = SystemMessage.getSystemMessage(SystemMessageId.S2_SECONDS_REMAINING_FOR_REUSE_S1);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ sm = SystemMessage.getSystemMessage(S2_SECONDS_REMAINING_FOR_REUSE_S1);
|
|
sm.addItemName(item);
|
|
sm.addItemName(item);
|
|
}
|
|
}
|
|
sm.addInt(seconds);
|
|
sm.addInt(seconds);
|
|
activeChar.sendPacket(sm);
|
|
activeChar.sendPacket(sm);
|
|
}
|
|
}
|
|
|
|
|
|
- private void sendSharedGroupUpdate(L2PcInstance activeChar, int group, long remaining, int reuse)
|
|
|
|
- {
|
|
|
|
- if (group > 0)
|
|
|
|
- {
|
|
|
|
|
|
+ private void sendSharedGroupUpdate(L2PcInstance activeChar, int group, long remaining, int reuse) {
|
|
|
|
+ if (group > 0) {
|
|
activeChar.sendPacket(new ExUseSharedGroupItem(_itemId, group, remaining, reuse));
|
|
activeChar.sendPacket(new ExUseSharedGroupItem(_itemId, group, remaining, reuse));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public String getType()
|
|
|
|
- {
|
|
|
|
|
|
+ public String getType() {
|
|
return _C__19_USEITEM;
|
|
return _C__19_USEITEM;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- protected boolean triggersOnActionRequest()
|
|
|
|
- {
|
|
|
|
|
|
+ protected boolean triggersOnActionRequest() {
|
|
return !Config.SPAWN_PROTECTION_ALLOWED_ITEMS.contains(_itemId);
|
|
return !Config.SPAWN_PROTECTION_ALLOWED_ITEMS.contains(_itemId);
|
|
}
|
|
}
|
|
}
|
|
}
|