rendered paste bodyIndex: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 2917)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -556,6 +556,7 @@
private long _requestExpireTime = 0;
private L2Request _request = new L2Request(this);
private L2ItemInstance _arrowItem;
+ private L2ItemInstance _boltItem;
// Used for protection after teleport
private long _protectEndTime = 0;
@@ -5314,6 +5315,66 @@
return _arrowItem != null;
}
+ /**
+ * Reduce the number of bolts owned by the L2PcInstance and send it Server->Client Packet InventoryUpdate or ItemList (to unequip if the last bolt was consummed).<BR><BR>
+ */
+ @Override
+ protected void reduceBoltCount()
+ {
+ L2ItemInstance bolts = getInventory().destroyItem("Consume", getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LHAND), 1, this, null);
+
+ if (Config.DEBUG) _log.fine("bolt count:" + (bolts==null? 0 : bolts.getCount()));
+
+ if (bolts == null || bolts.getCount() == 0)
+ {
+ getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_LHAND);
+ _boltItem = null;
+
+ if (Config.DEBUG) _log.fine("removed bolts count");
+ sendPacket(new ItemList(this,false));
+ }
+ else
+ {
+ if (!Config.FORCE_INVENTORY_UPDATE)
+ {
+ InventoryUpdate iu = new InventoryUpdate();
+ iu.addModifiedItem(bolts);
+ sendPacket(iu);
+ }
+ else sendPacket(new ItemList(this, false));
+ }
+ }
+
+ /**
+ * Equip bolts needed in left hand and send a Server->Client packet ItemList to the L2PcINstance then return True.<BR><BR>
+ */
+ @Override
+ protected boolean checkAndEquipBolts()
+ {
+ // Check if nothing is equiped in left hand
+ if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND) == null)
+ {
+ // Get the L2ItemInstance of the arrows needed for this bow
+ _boltItem = getInventory().findBoltForCrossBow(getActiveWeaponItem());
+
+ if (_boltItem != null)
+ {
+ // Equip arrows needed in left hand
+ getInventory().setPaperdollItem(Inventory.PAPERDOLL_LHAND, _boltItem);
+
+ // Send a Server->Client packet ItemList to this L2PcINstance to update left hand equipement
+ ItemList il = new ItemList(this, false);
+ sendPacket(il);
+ }
+ }
+ else
+ {
+ // Get the L2ItemInstance of arrows equiped in left hand
+ _boltItem = getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
+ }
+
+ return _boltItem != null;
+ }
/**
* Disarm the player's weapon and shield.<BR><BR>
*/