forked from MagicBane/Server
item_wt refactored to template
This commit is contained in:
@@ -508,7 +508,7 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
ItemBase itemBase = item.getItemBase();
|
ItemBase itemBase = item.getItemBase();
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
|
||||||
output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20);
|
output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20);
|
||||||
output += "Weight: " + itemBase.getWeight();
|
output += "Weight: " + template.item_wt;
|
||||||
output += newline;
|
output += newline;
|
||||||
DecimalFormat df = new DecimalFormat("###,###,###,###,##0");
|
DecimalFormat df = new DecimalFormat("###,###,###,###,##0");
|
||||||
output += StringUtils.addWS("Qty: "
|
output += StringUtils.addWS("Qty: "
|
||||||
|
|||||||
@@ -208,10 +208,9 @@ public enum BuildingManager {
|
|||||||
|
|
||||||
ItemBase elanIB = ItemBase.getItemBase(1705032);
|
ItemBase elanIB = ItemBase.getItemBase(1705032);
|
||||||
|
|
||||||
if (elanIB == null)
|
ItemTemplate template = ItemTemplate.itemTemplates.get(1705032); // Elan Stone
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!player.getCharItemManager().hasRoomInventory(elanIB.getWeight()))
|
if (!player.getCharItemManager().hasRoomInventory(template.item_wt))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Item.MakeItemForPlayer(elanIB, player, amount))
|
if (!Item.MakeItemForPlayer(elanIB, player, amount))
|
||||||
@@ -227,7 +226,10 @@ public enum BuildingManager {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (ItemBase resourceBase : ItemBase.getResourceList()) {
|
for (ItemBase resourceBase : ItemBase.getResourceList()) {
|
||||||
if (!player.getCharItemManager().hasRoomInventory(resourceBase.getWeight())) {
|
|
||||||
|
template = ItemTemplate.itemTemplates.get(resourceBase.getUUID());
|
||||||
|
|
||||||
|
if (!player.getCharItemManager().hasRoomInventory(template.item_wt)) {
|
||||||
ChatManager.chatSystemInfo(player, "You can not carry any more of that item.");
|
ChatManager.chatSystemInfo(player, "You can not carry any more of that item.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -240,7 +242,6 @@ public enum BuildingManager {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (Warehouse.loot(warehouse, player, resourceBase, resourceAmount, true)) {
|
if (Warehouse.loot(warehouse, player, resourceBase, resourceAmount, true)) {
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(resourceBase.getUUID());
|
|
||||||
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + template.item_base_name);
|
ChatManager.chatInfoInfo(player, "You have looted " + resourceAmount + ' ' + template.item_base_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ public enum CombatManager {
|
|||||||
if (wb == null) {
|
if (wb == null) {
|
||||||
if (abstractCharacter.getStamina() < 1)
|
if (abstractCharacter.getStamina() < 1)
|
||||||
attackFailure = true;
|
attackFailure = true;
|
||||||
} else if (abstractCharacter.getStamina() < wb.getWeight())
|
} else if (abstractCharacter.getStamina() < weapon.template.item_wt)
|
||||||
attackFailure = true;
|
attackFailure = true;
|
||||||
|
|
||||||
//see if attacker is stunned. If so, stop here
|
//see if attacker is stunned. If so, stop here
|
||||||
@@ -514,7 +514,7 @@ public enum CombatManager {
|
|||||||
if (wb == null)
|
if (wb == null)
|
||||||
attacker.modifyStamina(-0.5f, attacker, true);
|
attacker.modifyStamina(-0.5f, attacker, true);
|
||||||
else {
|
else {
|
||||||
float stam = wb.getWeight() / 3;
|
float stam = weapon.template.item_wt / 3f;
|
||||||
stam = (stam < 1) ? 1 : stam;
|
stam = (stam < 1) ? 1 : stam;
|
||||||
attacker.modifyStamina(-(stam), attacker, true);
|
attacker.modifyStamina(-(stam), attacker, true);
|
||||||
}
|
}
|
||||||
@@ -1333,7 +1333,7 @@ public enum CombatManager {
|
|||||||
|
|
||||||
if (wb != null)
|
if (wb != null)
|
||||||
if (wb.isGlass()) //glass used weighted so fast weapons don't break faster
|
if (wb.isGlass()) //glass used weighted so fast weapons don't break faster
|
||||||
chance = 9000 / wb.getWeight();
|
chance = 9000 / weapon.template.item_wt;
|
||||||
|
|
||||||
//test damaging attackers weapon
|
//test damaging attackers weapon
|
||||||
|
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ public enum LootManager {
|
|||||||
|
|
||||||
//early exit if the inventory of the player will not old the item
|
//early exit if the inventory of the player will not old the item
|
||||||
|
|
||||||
if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) {
|
if (itemMan.hasRoomInventory(winnings.template.item_wt) == false) {
|
||||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (!itemManager.hasRoomBank(item.getItemBase().getWeight()))
|
if (!itemManager.hasRoomBank(item.template.item_wt))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!itemManager.moveItemToBank(item))
|
if (!itemManager.moveItemToBank(item))
|
||||||
@@ -430,7 +430,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
|
|
||||||
// Not gold, process update here
|
// Not gold, process update here
|
||||||
|
|
||||||
if (!itemManager.hasRoomInventory(item.getItemBase().getWeight()))
|
if (!itemManager.hasRoomInventory(item.template.item_wt))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (itemManager.moveItemToInventory(item) == false)
|
if (itemManager.moveItemToInventory(item) == false)
|
||||||
@@ -1224,13 +1224,11 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
|
|
||||||
//get item to sell
|
//get item to sell
|
||||||
|
|
||||||
ItemBase ib = sell.getItemBase();
|
if (sell.template == null)
|
||||||
|
|
||||||
if (ib == null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID != 0)
|
if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID != 0)
|
||||||
if (!npc.getCharItemManager().hasRoomInventory(ib.getWeight())) {
|
if (!npc.getCharItemManager().hasRoomInventory(sell.template.item_wt)) {
|
||||||
|
|
||||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||||
return;
|
return;
|
||||||
@@ -1390,12 +1388,14 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
return;
|
return;
|
||||||
for (MobEquipment me : sellInventory) {
|
for (MobEquipment me : sellInventory) {
|
||||||
if (me.getObjectUUID() == msg.getItemID()) {
|
if (me.getObjectUUID() == msg.getItemID()) {
|
||||||
|
|
||||||
ItemBase ib = me.getItemBase();
|
ItemBase ib = me.getItemBase();
|
||||||
|
|
||||||
if (ib == null)
|
if (ib == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//test room available for item
|
//test room available for item
|
||||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
if (!itemMan.hasRoomInventory(me.template.item_wt))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int cost = me.getMagicValue();
|
int cost = me.getMagicValue();
|
||||||
@@ -1407,10 +1407,8 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
if (profit < 1)
|
if (profit < 1)
|
||||||
profit = 1;
|
profit = 1;
|
||||||
|
|
||||||
|
|
||||||
cost *= profit;
|
cost *= profit;
|
||||||
|
|
||||||
|
|
||||||
if (gold.getNumOfItems() - cost < 0) {
|
if (gold.getNumOfItems() - cost < 0) {
|
||||||
//dont' have enough goldItem exit!
|
//dont' have enough goldItem exit!
|
||||||
// chatMan.chatSystemInfo(pc, "" + "You dont have enough gold.");
|
// chatMan.chatSystemInfo(pc, "" + "You dont have enough gold.");
|
||||||
@@ -1453,16 +1451,11 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
if (buy == null)
|
if (buy == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ItemBase ib = buy.getItemBase();
|
|
||||||
|
|
||||||
if (ib == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!npcCim.inventoryContains(buy))
|
if (!npcCim.inventoryContains(buy))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//test room available for item
|
//test room available for item
|
||||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
if (!itemMan.hasRoomInventory(buy.template.item_wt))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//TODO test cost and subtract goldItem
|
//TODO test cost and subtract goldItem
|
||||||
@@ -1524,16 +1517,11 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
if (buy == null)
|
if (buy == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ItemBase ib = buy.getItemBase();
|
|
||||||
|
|
||||||
if (ib == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!npcCim.inventoryContains(buy))
|
if (!npcCim.inventoryContains(buy))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//test room available for item
|
//test room available for item
|
||||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
if (!itemMan.hasRoomInventory(buy.template.item_wt))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//TODO test cost and subtract goldItem
|
//TODO test cost and subtract goldItem
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (targetItem.getItemBase().getType() == ItemType.GOLD)
|
if (targetItem.getItemBase().getType() == ItemType.GOLD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!vendor.getCharItemManager().hasRoomInventory(targetItem.getItemBase().getWeight())) {
|
if (!vendor.getCharItemManager().hasRoomInventory(targetItem.template.item_wt)) {
|
||||||
|
|
||||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||||
return;
|
return;
|
||||||
@@ -407,7 +407,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (vendor.getCharItemManager().inventoryContains(targetItem) == false)
|
if (vendor.getCharItemManager().inventoryContains(targetItem) == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (player.getCharItemManager().hasRoomInventory(targetItem.getItemBase().getWeight()) == false)
|
if (player.getCharItemManager().hasRoomInventory(targetItem.template.item_wt) == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player.getCharItemManager().buyFromNPC(targetItem, vendor);
|
player.getCharItemManager().buyFromNPC(targetItem, vendor);
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ public class Account extends AbstractGameObject {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (item.containerType == Enum.ItemContainerType.INVENTORY && player.getCharItemManager().isVaultOpen()) {
|
if (item.containerType == Enum.ItemContainerType.INVENTORY && player.getCharItemManager().isVaultOpen()) {
|
||||||
if (!player.getCharItemManager().hasRoomVault(item.getItemBase().getWeight())) {
|
if (!player.getCharItemManager().hasRoomVault(item.template.item_wt)) {
|
||||||
ClientMessagePump.forceTransferFromVaultToInventory(msg, origin, "There is no room in your vault.");
|
ClientMessagePump.forceTransferFromVaultToInventory(msg, origin, "There is no room in your vault.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ public class Account extends AbstractGameObject {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (item.containerType == Enum.ItemContainerType.VAULT && itemManager.isVaultOpen()) {
|
if (item.containerType == Enum.ItemContainerType.VAULT && itemManager.isVaultOpen()) {
|
||||||
if (!itemManager.hasRoomInventory(item.getItemBase().getWeight())) {
|
if (!itemManager.hasRoomInventory(item.template.item_wt)) {
|
||||||
ClientMessagePump.forceTransferFromInventoryToVault(msg, origin, "There is no room in your inventory.");
|
ClientMessagePump.forceTransferFromInventoryToVault(msg, origin, "There is no room in your inventory.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
if (!npcCim.inventoryContains(take))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!itemMan.hasRoomInventory(template.item_wt))
|
||||||
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ public class Corpse extends AbstractWorldObject {
|
|||||||
Logger.error("Can't find inventory for player " + belongsTo.getObjectUUID());
|
Logger.error("Can't find inventory for player " + belongsTo.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item lootItem(Item i, PlayerCharacter looter) {
|
public Item lootItem(Item item, PlayerCharacter looter) {
|
||||||
//make sure looter exists
|
//make sure looter exists
|
||||||
if (looter == null)
|
if (looter == null)
|
||||||
return null;
|
return null;
|
||||||
@@ -294,38 +294,36 @@ public class Corpse extends AbstractWorldObject {
|
|||||||
synchronized (this.inventory) {
|
synchronized (this.inventory) {
|
||||||
|
|
||||||
//make sure player has item in inventory
|
//make sure player has item in inventory
|
||||||
if (!this.inventory.contains(i))
|
if (!this.inventory.contains(item))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
//get weight of item
|
//get weight of item
|
||||||
ItemBase ib = i.getItemBase();
|
|
||||||
if (ib == null)
|
int weight = item.template.item_wt;
|
||||||
return null;
|
|
||||||
short weight = ib.getWeight();
|
|
||||||
|
|
||||||
//make sure looter has room for item
|
//make sure looter has room for item
|
||||||
if (ib.getType().equals(ItemType.GOLD) == false && !looterItems.hasRoomInventory(weight))
|
if (item.template.item_type.equals(ItemType.GOLD) == false && !looterItems.hasRoomInventory(weight))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
//attempt to transfer item in db
|
//attempt to transfer item in db
|
||||||
if (ib.getType().equals(ItemType.GOLD)) {
|
if (item.template.item_type.equals(ItemType.GOLD)) {
|
||||||
if (!looterItems.moveGoldToInventory(i, i.getNumOfItems()))
|
if (!looterItems.moveGoldToInventory(item, item.getNumOfItems()))
|
||||||
return null;
|
return null;
|
||||||
} else if (!i.moveItemToInventory(looter))
|
} else if (!item.moveItemToInventory(looter))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
//db transfer successful, remove from this character
|
//db transfer successful, remove from this character
|
||||||
this.inventory.remove(this.inventory.indexOf(i));
|
this.inventory.remove(this.inventory.indexOf(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
//add item to looter.
|
//add item to looter.
|
||||||
if (!looterItems.addItemToInventory(i))
|
if (!looterItems.addItemToInventory(item))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
//calculate new weights
|
//calculate new weights
|
||||||
looterItems.calculateInventoryWeight();
|
looterItems.calculateInventoryWeight();
|
||||||
|
|
||||||
return i;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasGold() {
|
public boolean hasGold() {
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public class ItemBase {
|
|||||||
public EnumSet<Enum.ClassType> requiredClasses;
|
public EnumSet<Enum.ClassType> requiredClasses;
|
||||||
public EnumSet<Enum.DisciplineType> requiredDiscs;
|
public EnumSet<Enum.DisciplineType> requiredDiscs;
|
||||||
public EnumSet<Enum.DisciplineType> restrictedDiscs;
|
public EnumSet<Enum.DisciplineType> restrictedDiscs;
|
||||||
private final short weight;
|
|
||||||
private final short color;
|
private final short color;
|
||||||
private final ItemType type;
|
private final ItemType type;
|
||||||
private int vendorType;
|
private int vendorType;
|
||||||
@@ -90,7 +89,6 @@ public class ItemBase {
|
|||||||
|
|
||||||
this.uuid = rs.getInt("ID");
|
this.uuid = rs.getInt("ID");
|
||||||
|
|
||||||
this.weight = rs.getShort("weight");
|
|
||||||
this.color = rs.getShort("color");
|
this.color = rs.getShort("color");
|
||||||
this.type = ItemType.valueOf(rs.getString("Type"));
|
this.type = ItemType.valueOf(rs.getString("Type"));
|
||||||
this.useID = rs.getInt("useID");
|
this.useID = rs.getInt("useID");
|
||||||
@@ -256,11 +254,6 @@ public class ItemBase {
|
|||||||
DbManager.ItemBaseQueries.LOAD_BAKEDINSTATS(this);
|
DbManager.ItemBaseQueries.LOAD_BAKEDINSTATS(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getWeight() {
|
|
||||||
return this.weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isConsumable() {
|
public boolean isConsumable() {
|
||||||
return this.isConsumable;
|
return this.isConsumable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,33 +30,36 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
|
|
||||||
public class ItemFactory {
|
public class ItemFactory {
|
||||||
|
|
||||||
public static void fillInventory(PlayerCharacter pc, int objectID, int count) {
|
public static void fillInventory(PlayerCharacter pc, int templateID, int count) {
|
||||||
|
|
||||||
if (pc == null)
|
if (pc == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int max = 20;
|
int max = 20;
|
||||||
CharacterItemManager itemManager = pc.getCharItemManager();
|
CharacterItemManager itemManager = pc.getCharItemManager();
|
||||||
ItemBase ib = ItemBase.getItemBase(objectID);
|
|
||||||
|
ItemTemplate template = ItemTemplate.itemTemplates.get(templateID);
|
||||||
|
|
||||||
if (count > max)
|
if (count > max)
|
||||||
count = max;
|
count = max;
|
||||||
|
|
||||||
ClientConnection cc = pc.getClientConnection();
|
ClientConnection cc = pc.getClientConnection();
|
||||||
|
|
||||||
if (itemManager == null || ib == null || cc == null)
|
if (itemManager == null || template == null || cc == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean worked;
|
boolean worked;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
worked = false;
|
worked = false;
|
||||||
|
|
||||||
if (!itemManager.hasRoomInventory(ib.getWeight())) {
|
if (!itemManager.hasRoomInventory(template.item_wt)) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ChatManager.chatSystemInfo(pc, "You can not carry any more of that item.");
|
ChatManager.chatSystemInfo(pc, "You can not carry any more of that item.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item item = new Item(ib.getUUID());
|
Item item = new Item(templateID);
|
||||||
item.ownerID = pc.getObjectUUID();
|
item.ownerID = pc.getObjectUUID();
|
||||||
item.ownerType = OwnerType.PlayerCharacter;
|
item.ownerType = OwnerType.PlayerCharacter;
|
||||||
item.containerType = ItemContainerType.INVENTORY;
|
item.containerType = ItemContainerType.INVENTORY;
|
||||||
@@ -74,7 +77,7 @@ public class ItemFactory {
|
|||||||
itemManager.updateInventory();
|
itemManager.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Item fillForge(NPC npc, PlayerCharacter pc, int itemsToRoll, int itemID, int pToken, int sToken, String customName) {
|
public static Item fillForge(NPC npc, PlayerCharacter pc, int itemsToRoll, int templateID, int pToken, int sToken, String customName) {
|
||||||
|
|
||||||
String prefixString = "";
|
String prefixString = "";
|
||||||
String suffixString = "";
|
String suffixString = "";
|
||||||
@@ -83,10 +86,10 @@ public class ItemFactory {
|
|||||||
|
|
||||||
boolean useWarehouse = false;
|
boolean useWarehouse = false;
|
||||||
|
|
||||||
ItemBase ib = ItemBase.getItemBase(itemID);
|
ItemBase ib = ItemBase.getItemBase(templateID);
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(itemID);
|
ItemTemplate template = ItemTemplate.itemTemplates.get(templateID);
|
||||||
|
|
||||||
if (ib == null)
|
if (template == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Building forge = npc.getBuilding();
|
Building forge = npc.getBuilding();
|
||||||
@@ -94,8 +97,7 @@ public class ItemFactory {
|
|||||||
if (forge == null)
|
if (forge == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
if (!npc.getCharItemManager().hasRoomInventory(template.item_wt)) {
|
||||||
if (!npc.getCharItemManager().hasRoomInventory(ib.getWeight())) {
|
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorPopup(pc, 21);
|
ErrorPopupMsg.sendErrorPopup(pc, 21);
|
||||||
return null;
|
return null;
|
||||||
@@ -120,12 +122,13 @@ public class ItemFactory {
|
|||||||
useWarehouse = true;
|
useWarehouse = true;
|
||||||
// ROLL BANE SCROLL.
|
// ROLL BANE SCROLL.
|
||||||
|
|
||||||
if (ib.getUUID() > 910010 && ib.getUUID() < 910019) {
|
if (templateID > 910010 && templateID < 910019) {
|
||||||
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.resources;
|
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.resources;
|
||||||
|
|
||||||
|
|
||||||
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, template.item_value);
|
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, template.item_value);
|
||||||
int overdraft = BuildingManager.GetOverdraft(forge, template.item_value);
|
int overdraft = BuildingManager.GetOverdraft(forge, template.item_value);
|
||||||
|
|
||||||
if (overdraft > 0 && !useWarehouse) {
|
if (overdraft > 0 && !useWarehouse) {
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + " " + template.item_base_name);
|
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + " " + template.item_base_name);
|
||||||
@@ -144,15 +147,6 @@ public class ItemFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//All checks passed, lets withdraw from building first.
|
|
||||||
|
|
||||||
// if (pc != null){
|
|
||||||
// ChatManager.chatGuildInfo(pc.getGuild(), "Building withdraw = " + buildingWithdraw);
|
|
||||||
// ChatManager.chatGuildInfo(pc.getGuild(), "Warehouse overdraft withdraw = " + overdraft);
|
|
||||||
//
|
|
||||||
// ChatManager.chatGuildInfo(pc.getGuild(), "total withdraw = " + (overdraft + buildingWithdraw));
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (!forge.transferGold(-buildingWithdraw, false)) {
|
if (!forge.transferGold(-buildingWithdraw, false)) {
|
||||||
overdraft += buildingWithdraw;
|
overdraft += buildingWithdraw;
|
||||||
|
|
||||||
@@ -169,15 +163,12 @@ public class ItemFactory {
|
|||||||
|
|
||||||
if (overdraft > 0)
|
if (overdraft > 0)
|
||||||
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||||
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
|
||||||
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
|
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ml = new MobLoot(npc, ib, false);
|
ml = new MobLoot(npc, ib, false);
|
||||||
|
|
||||||
|
|
||||||
ml.containerType = Enum.ItemContainerType.FORGE;
|
ml.containerType = Enum.ItemContainerType.FORGE;
|
||||||
ml.setValue(0);
|
ml.setValue(0);
|
||||||
ml.loadEnchantments();
|
ml.loadEnchantments();
|
||||||
@@ -660,10 +651,10 @@ public class ItemFactory {
|
|||||||
ItemBase ib = ItemBase.getItemBase(itemBaseID);
|
ItemBase ib = ItemBase.getItemBase(itemBaseID);
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBaseID);
|
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBaseID);
|
||||||
|
|
||||||
if (ib == null)
|
if (template == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (!vendor.getCharItemManager().hasRoomInventory(ib.getWeight())) {
|
if (!vendor.getCharItemManager().hasRoomInventory(template.item_wt)) {
|
||||||
|
|
||||||
if (playerCharacter != null)
|
if (playerCharacter != null)
|
||||||
ChatManager.chatSystemInfo(playerCharacter, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full.");
|
ChatManager.chatSystemInfo(playerCharacter, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full.");
|
||||||
|
|||||||
@@ -715,7 +715,7 @@ public class Warehouse extends AbstractWorldObject {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (addToInventory)
|
if (addToInventory)
|
||||||
if (!itemMan.hasRoomInventory(ib.getWeight())) {
|
if (!itemMan.hasRoomInventory(template.item_wt)) {
|
||||||
ChatManager.chatSystemInfo(pc, "You can not carry any more of that item.");
|
ChatManager.chatSystemInfo(pc, "You can not carry any more of that item.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -790,7 +790,9 @@ public class Warehouse extends AbstractWorldObject {
|
|||||||
if (pc == null)
|
if (pc == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ib == null)
|
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID());
|
||||||
|
|
||||||
|
if (template == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (warehouse.resources.get(ib) == null)
|
if (warehouse.resources.get(ib) == null)
|
||||||
@@ -804,7 +806,7 @@ public class Warehouse extends AbstractWorldObject {
|
|||||||
if (itemMan == null)
|
if (itemMan == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!itemMan.hasRoomInventory(ib.getWeight())) {
|
if (!itemMan.hasRoomInventory(template.item_wt)) {
|
||||||
ChatManager.chatSystemInfo(pc, "You can not carry any more of that item.");
|
ChatManager.chatSystemInfo(pc, "You can not carry any more of that item.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user