Browse Source

item_value refactored to template

combat-2
MagicBot 9 months ago
parent
commit
f11fcc535a
  1. 7
      src/engine/net/client/msg/ManageNPCMsg.java
  2. 8
      src/engine/objects/Item.java
  3. 13
      src/engine/objects/ItemBase.java
  4. 17
      src/engine/objects/ItemFactory.java
  5. 7
      src/engine/objects/MobEquipment.java

7
src/engine/net/client/msg/ManageNPCMsg.java

@ -423,10 +423,11 @@ public class ManageNPCMsg extends ClientNetMsg {
for (int ib : rollableSet) { for (int ib : rollableSet) {
ItemBase item = ItemBase.getItemBase(ib); ItemBase item = ItemBase.getItemBase(ib);
ItemTemplate template = ItemTemplate.itemTemplates.get(ib);
writer.put((byte) 1); writer.put((byte) 1);
writer.putInt(0); writer.putInt(0);
writer.putInt(ib); //itemID writer.putInt(ib); //itemID
writer.putInt(item.getBaseValue()); writer.putInt(template.item_value);
writer.putInt(600); writer.putInt(600);
writer.put((byte) 1); writer.put((byte) 1);
writer.put((byte) item.getModTable()); writer.put((byte) item.getModTable());
@ -443,14 +444,14 @@ public class ManageNPCMsg extends ClientNetMsg {
for (Item i : itemList) { for (Item i : itemList) {
ItemBase ib = i.getItemBase(); ItemBase ib = i.getItemBase();
ItemTemplate template = ItemTemplate.itemTemplates.get(ib);
writer.put((byte) 0); // ? Unknown45 writer.put((byte) 0); // ? Unknown45
writer.putInt(i.getObjectType().ordinal()); writer.putInt(i.getObjectType().ordinal());
writer.putInt(i.getObjectUUID()); writer.putInt(i.getObjectUUID());
writer.putInt(0); writer.putInt(0);
writer.putInt(i.getTemplsteID()); writer.putInt(i.getTemplsteID());
writer.putInt(ib.getBaseValue()); writer.putInt(template.item_value);
long timeLife = i.getDateToUpgrade() - System.currentTimeMillis(); long timeLife = i.getDateToUpgrade() - System.currentTimeMillis();

8
src/engine/objects/Item.java

@ -234,7 +234,7 @@ public class Item extends AbstractWorldObject {
} else } else
writer.putInt(item.numberOfItems); // Amount of gold writer.putInt(item.numberOfItems); // Amount of gold
} else } else
writer.putInt(item.getItemBase().getBaseValue()); writer.putInt(item.template.item_value);
writer.putInt(item.getValue()); writer.putInt(item.getValue());
@ -1049,7 +1049,7 @@ public class Item extends AbstractWorldObject {
public final void loadEnchantments() { public final void loadEnchantments() {
//dont load mobloot enchantments, they arent in db. //dont load mobloot enchantments, they arent in db.
if (this.getObjectType().equals(GameObjectType.MobLoot)) { if (this.getObjectType().equals(GameObjectType.MobLoot)) {
this.magicValue = this.getItemBase().getBaseValue() + calcMagicValue(); this.magicValue = this.template.item_value + calcMagicValue();
return; return;
} }
@ -1063,7 +1063,7 @@ public class Item extends AbstractWorldObject {
} }
} }
this.magicValue = this.getItemBase().getBaseValue() + calcMagicValue(); this.magicValue = this.template.item_value + calcMagicValue();
} }
public HashMap<Integer, Integer> getBakedInStats() { public HashMap<Integer, Integer> getBakedInStats() {
@ -1226,7 +1226,7 @@ public class Item extends AbstractWorldObject {
public int getValue() { public int getValue() {
if (this.value == 0) if (this.value == 0)
if (this.template.item_flags.contains(ItemFlags.Identified)) { if (this.isID()) {
return this.getMagicValue(); return this.getMagicValue();
} else } else
return this.template.item_value; return this.template.item_value;

13
src/engine/objects/ItemBase.java

@ -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 int value;
private final short weight; private final short weight;
private final short color; private final short color;
private final ItemType type; private final ItemType type;
@ -91,7 +90,6 @@ public class ItemBase {
this.uuid = rs.getInt("ID"); this.uuid = rs.getInt("ID");
this.value = rs.getInt("value");
this.weight = rs.getShort("weight"); 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"));
@ -258,15 +256,6 @@ public class ItemBase {
DbManager.ItemBaseQueries.LOAD_BAKEDINSTATS(this); DbManager.ItemBaseQueries.LOAD_BAKEDINSTATS(this);
} }
//TODO fix this later. Shouldn't be gotten from item base
public int getMagicValue() {
return this.value;
}
public int getBaseValue() {
return this.value;
}
public short getWeight() { public short getWeight() {
return this.weight; return this.weight;
} }
@ -463,7 +452,7 @@ public class ItemBase {
if (this.canCharacterEquip(abstractCharacter) == false) if (this.canCharacterEquip(abstractCharacter) == false)
return false; return false;
return item.getItemBase().value != 0 || Kit.IsNoobGear(item.getItemBase().uuid); return item.template.item_value != 0 || Kit.IsNoobGear(item.getItemBase().uuid);
//players can't wear 0 value items. //players can't wear 0 value items.
} }

17
src/engine/objects/ItemFactory.java

@ -124,9 +124,8 @@ public class ItemFactory {
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.resources; ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.resources;
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, ib.getBaseValue()); int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, template.item_value);
int overdraft = BuildingManager.GetOverdraft(forge, ib.getBaseValue()); 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);
@ -308,7 +307,7 @@ public class ItemFactory {
if (prefixValue == null) if (prefixValue == null)
return null; return null;
int baseCost = ib.getBaseValue(); int baseCost = template.item_value;
int effectCost = (int) prefixValue.getValue(); int effectCost = (int) prefixValue.getValue();
int total = baseCost * 10 + effectCost; int total = baseCost * 10 + effectCost;
@ -361,7 +360,7 @@ public class ItemFactory {
if (suffixValue == null) if (suffixValue == null)
return null; return null;
suffixResourceCosts = suffix.getResourcesForEffect(); suffixResourceCosts = suffix.getResourcesForEffect();
int baseCost = ib.getBaseValue(); int baseCost = template.item_value;
int effectCost = (int) suffixValue.getValue(); int effectCost = (int) suffixValue.getValue();
suffixCost = effectCost; suffixCost = effectCost;
int total = baseCost * 10 + effectCost; int total = baseCost * 10 + effectCost;
@ -405,7 +404,7 @@ public class ItemFactory {
//Check if Total suffix and prefix costs + itemCost can be withdrawn. //Check if Total suffix and prefix costs + itemCost can be withdrawn.
int costToCreate = suffixCost + prefixCost + (ib.getBaseValue()); int costToCreate = suffixCost + prefixCost + template.item_value;
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate); int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate);
int overdraft = BuildingManager.GetOverdraft(forge, costToCreate); int overdraft = BuildingManager.GetOverdraft(forge, costToCreate);
@ -510,7 +509,7 @@ public class ItemFactory {
if (prefix == null && suffix == null) { if (prefix == null && suffix == null) {
int baseCost = ib.getBaseValue(); int baseCost = template.item_value;
int total = (int) (baseCost + baseCost * (float) .10); int total = (int) (baseCost + baseCost * (float) .10);
buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, total); buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, total);
@ -889,7 +888,7 @@ public class ItemFactory {
ItemBase goldIB = ItemBase.getGoldItemBase(); ItemBase goldIB = ItemBase.getGoldItemBase();
int baseCost = ib.getBaseValue(); int baseCost = template.item_value;
int total = (int) (baseCost + baseCost * .10); int total = (int) (baseCost + baseCost * .10);
EffectsBase suffix = null; EffectsBase suffix = null;
@ -903,7 +902,7 @@ public class ItemFactory {
//calculate gold costs and remove from the warehouse //calculate gold costs and remove from the warehouse
if (prefix != null || suffix != null) { if (prefix != null || suffix != null) {
int costToCreate = (int) (ib.getBaseValue() + ib.getBaseValue() * .10f); int costToCreate = (int) (template.item_value + template.item_value * .10f);
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate); int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate);
int overdraft = BuildingManager.GetOverdraft(forge, costToCreate); int overdraft = BuildingManager.GetOverdraft(forge, costToCreate);

7
src/engine/objects/MobEquipment.java

@ -115,7 +115,6 @@ public class MobEquipment extends AbstractGameObject {
public static void serializeForVendor(MobEquipment mobEquipment, ByteBufferWriter writer, float percent) throws SerializationException { public static void serializeForVendor(MobEquipment mobEquipment, ByteBufferWriter writer, float percent) throws SerializationException {
_serializeForClientMsg(mobEquipment, writer, false); _serializeForClientMsg(mobEquipment, writer, false);
int baseValue = mobEquipment.itemBase.getBaseValue() + mobEquipment.itemBase.getMagicValue();
writer.putInt(mobEquipment.magicValue); writer.putInt(mobEquipment.magicValue);
writer.putInt(mobEquipment.magicValue); writer.putInt(mobEquipment.magicValue);
} }
@ -161,7 +160,7 @@ public class MobEquipment extends AbstractGameObject {
writer.putInt(0); // Pad writer.putInt(0); // Pad
writer.putInt(0); // Pad writer.putInt(0); // Pad
writer.putInt(mobEquipment.itemBase.getBaseValue()); writer.putInt(mobEquipment.template.item_value);
writer.putInt(mobEquipment.magicValue); writer.putInt(mobEquipment.magicValue);
serializeEffects(mobEquipment, writer); serializeEffects(mobEquipment, writer);
@ -262,7 +261,7 @@ public class MobEquipment extends AbstractGameObject {
public final void setMagicValue() { public final void setMagicValue() {
float value = 1; float value = 1;
if (itemBase != null) if (itemBase != null)
value = itemBase.getBaseValue(); value = template.item_value;
if (this.prefix != null) { if (this.prefix != null) {
if (this.prefix.getEffectsBase() != null) if (this.prefix.getEffectsBase() != null)
value += this.prefix.getEffectsBase().getValue(); value += this.prefix.getEffectsBase().getValue();
@ -300,7 +299,7 @@ public class MobEquipment extends AbstractGameObject {
public int getMagicValue() { public int getMagicValue() {
if (!this.isID) { if (!this.isID) {
return itemBase.getBaseValue(); return template.item_value;
} }
return this.magicValue; return this.magicValue;
} }

Loading…
Cancel
Save