|
|
@ -90,21 +90,29 @@ public class CharacterItemManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void takeFromNPC(NPC npc, PlayerCharacter pc, Item take, ClientMessagePump clientMessagePump) { |
|
|
|
public static void takeFromNPC(NPC npc, PlayerCharacter pc, Item take, ClientMessagePump clientMessagePump) { |
|
|
|
|
|
|
|
|
|
|
|
ItemBase ib = take.getItemBase(); |
|
|
|
ItemBase ib = take.getItemBase(); |
|
|
|
if (ib == null) |
|
|
|
ItemTemplate template = take.template; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (template == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
CharacterItemManager itemMan = pc.getCharItemManager(); |
|
|
|
CharacterItemManager itemMan = pc.getCharItemManager(); |
|
|
|
|
|
|
|
|
|
|
|
if (itemMan == null) |
|
|
|
if (itemMan == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
CharacterItemManager npcCim = npc.getCharItemManager(); |
|
|
|
CharacterItemManager npcCim = npc.getCharItemManager(); |
|
|
|
|
|
|
|
|
|
|
|
if (npcCim == null) |
|
|
|
if (npcCim == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
if (!npcCim.inventoryContains(take)) { |
|
|
|
|
|
|
|
|
|
|
|
if (!npcCim.inventoryContains(take)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!itemMan.hasRoomInventory(ib.getWeight())) |
|
|
|
if (!itemMan.hasRoomInventory(template.item_wt)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (take != null) { |
|
|
|
if (take != null) { |
|
|
|
itemMan.buyFromNPC(take, npc); |
|
|
|
itemMan.buyFromNPC(take, npc); |
|
|
|
itemMan.updateInventory(); |
|
|
|
itemMan.updateInventory(); |
|
|
@ -621,7 +629,7 @@ public class CharacterItemManager { |
|
|
|
if (!i.validForInventory(source.getClientConnection(), source, this)) |
|
|
|
if (!i.validForInventory(source.getClientConnection(), source, this)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (!tradingWith.hasRoomTrade(i.getItemBase().getWeight())) { |
|
|
|
if (!tradingWith.hasRoomTrade(i.template.item_wt)) { |
|
|
|
dispatch = Dispatch.borrow(source, msg); |
|
|
|
dispatch = Dispatch.borrow(source, msg); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1251,9 +1259,10 @@ public class CharacterItemManager { |
|
|
|
this.inventory.add(i); |
|
|
|
this.inventory.add(i); |
|
|
|
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); |
|
|
|
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); |
|
|
|
|
|
|
|
|
|
|
|
ItemBase ib = i.getItemBase(); |
|
|
|
|
|
|
|
if (ib != null) |
|
|
|
if (i.template != null) |
|
|
|
this.inventoryWeight += ib.getWeight(); |
|
|
|
this.inventoryWeight += i.template.item_wt; |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1503,18 +1512,19 @@ public class CharacterItemManager { |
|
|
|
|
|
|
|
|
|
|
|
synchronized (this) { |
|
|
|
synchronized (this) { |
|
|
|
synchronized (itemMan) { |
|
|
|
synchronized (itemMan) { |
|
|
|
itemBase = purchasedItem.getItemBase(); |
|
|
|
ItemTemplate template = purchasedItem.template; |
|
|
|
|
|
|
|
|
|
|
|
if (itemBase == null) |
|
|
|
if (template == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
//test inventory is not full
|
|
|
|
//test inventory is not full
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasRoomInventory(itemBase.getWeight())) |
|
|
|
if (!hasRoomInventory(template.item_wt)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (!itemMan.inventory.contains(purchasedItem)) |
|
|
|
if (!itemMan.inventory.contains(purchasedItem)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
// attempt to transfer item in db
|
|
|
|
// attempt to transfer item in db
|
|
|
|
|
|
|
|
|
|
|
|
if (purchasedItem.getObjectType() == GameObjectType.MobLoot) { |
|
|
|
if (purchasedItem.getObjectType() == GameObjectType.MobLoot) { |
|
|
@ -1625,10 +1635,11 @@ public class CharacterItemManager { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
// get weight of item
|
|
|
|
// get weight of item
|
|
|
|
ItemBase ib = lootItem.getItemBase(); |
|
|
|
|
|
|
|
if (ib == null) |
|
|
|
if (lootItem.template == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
short weight = ib.getWeight(); |
|
|
|
|
|
|
|
|
|
|
|
int weight = lootItem.template.item_wt; |
|
|
|
|
|
|
|
|
|
|
|
// make sure lootingPlayer has room for item
|
|
|
|
// make sure lootingPlayer has room for item
|
|
|
|
if (!lootItem.getItemBase().getType().equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight)) |
|
|
|
if (!lootItem.getItemBase().getType().equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight)) |
|
|
@ -2106,7 +2117,7 @@ public class CharacterItemManager { |
|
|
|
return true; // npc's need checked
|
|
|
|
return true; // npc's need checked
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean hasRoomTrade(short itemWeight) { |
|
|
|
public boolean hasRoomTrade(int itemWeight) { |
|
|
|
|
|
|
|
|
|
|
|
PlayerCharacter playerCharacter; |
|
|
|
PlayerCharacter playerCharacter; |
|
|
|
PlayerCharacter tradeCharacter; |
|
|
|
PlayerCharacter tradeCharacter; |
|
|
@ -2134,13 +2145,15 @@ public class CharacterItemManager { |
|
|
|
return tradeWeight <= (int) playerCharacter.statStrBase * 3; |
|
|
|
return tradeWeight <= (int) playerCharacter.statStrBase * 3; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean hasRoomBank(short weight) { |
|
|
|
public boolean hasRoomBank(int weight) { |
|
|
|
|
|
|
|
|
|
|
|
if (this.absCharacter == null) |
|
|
|
if (this.absCharacter == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
return weight <= this.absCharacter.getBankCapacityRemaining(); |
|
|
|
return weight <= this.absCharacter.getBankCapacityRemaining(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean hasRoomVault(short weight) { |
|
|
|
public boolean hasRoomVault(int weight) { |
|
|
|
if (this.absCharacter == null) |
|
|
|
if (this.absCharacter == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
return weight <= this.absCharacter.getVaultCapacityRemaining(); |
|
|
|
return weight <= this.absCharacter.getVaultCapacityRemaining(); |
|
|
@ -2181,8 +2194,7 @@ public class CharacterItemManager { |
|
|
|
if (item == null) |
|
|
|
if (item == null) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
ItemBase ib = item.getItemBase(); |
|
|
|
weight += item.template.item_wt; |
|
|
|
weight += ib.getWeight(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return weight; |
|
|
|
return weight; |
|
|
|
} |
|
|
|
} |
|
|
@ -2200,10 +2212,9 @@ public class CharacterItemManager { |
|
|
|
|
|
|
|
|
|
|
|
public void calculateBankWeight() { |
|
|
|
public void calculateBankWeight() { |
|
|
|
this.bankWeight = 0; |
|
|
|
this.bankWeight = 0; |
|
|
|
for (Item i : this.bank) { |
|
|
|
for (Item item : this.bank) { |
|
|
|
ItemBase ib = i.getItemBase(); |
|
|
|
if (item.template != null) |
|
|
|
if (ib != null) |
|
|
|
this.bankWeight += item.template.item_value; |
|
|
|
this.bankWeight += ib.getWeight(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2212,28 +2223,25 @@ public class CharacterItemManager { |
|
|
|
Collection<Item> c = this.equipped.values(); |
|
|
|
Collection<Item> c = this.equipped.values(); |
|
|
|
Iterator<Item> it = c.iterator(); |
|
|
|
Iterator<Item> it = c.iterator(); |
|
|
|
while (it.hasNext()) { |
|
|
|
while (it.hasNext()) { |
|
|
|
Item i = it.next(); |
|
|
|
Item item = it.next(); |
|
|
|
ItemBase ib = i.getItemBase(); |
|
|
|
if (item.template != null) |
|
|
|
if (ib != null) |
|
|
|
this.equipWeight += item.template.item_wt; |
|
|
|
this.equipWeight += ib.getWeight(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void calculateInventoryWeight() { |
|
|
|
public void calculateInventoryWeight() { |
|
|
|
this.inventoryWeight = 0; |
|
|
|
this.inventoryWeight = 0; |
|
|
|
for (Item i : this.inventory) { |
|
|
|
for (Item item : this.inventory) { |
|
|
|
ItemBase ib = i.getItemBase(); |
|
|
|
if (item.template != null) |
|
|
|
if (ib != null) |
|
|
|
this.inventoryWeight += item.template.item_wt; |
|
|
|
this.inventoryWeight += ib.getWeight(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void calculateVaultWeight() { |
|
|
|
public void calculateVaultWeight() { |
|
|
|
this.vaultWeight = 0; |
|
|
|
this.vaultWeight = 0; |
|
|
|
for (Item i : this.vault) { |
|
|
|
for (Item item : this.vault) { |
|
|
|
ItemBase ib = i.getItemBase(); |
|
|
|
if (item.template != null) |
|
|
|
if (ib != null) |
|
|
|
this.vaultWeight += item.template.item_wt; |
|
|
|
this.vaultWeight += ib.getWeight(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|