Browse Source

Durability and initial charges migrated to template.

combat-2
MagicBot 9 months ago
parent
commit
8a1cd316fe
  1. 25
      src/engine/objects/ItemBase.java
  2. 13
      src/engine/objects/MobEquipment.java

25
src/engine/objects/ItemBase.java

@ -45,7 +45,6 @@ public class ItemBase { @@ -45,7 +45,6 @@ public class ItemBase {
public EnumSet<Enum.ClassType> requiredClasses;
public EnumSet<Enum.DisciplineType> requiredDiscs;
public EnumSet<Enum.DisciplineType> restrictedDiscs;
private final float durability;
private final int value;
private final short weight;
private final short color;
@ -75,7 +74,7 @@ public class ItemBase { @@ -75,7 +74,7 @@ public class ItemBase {
private final boolean twoHanded;
private boolean isConsumable;
private boolean isStackable;
private final int numCharges;
// Item stat modifiers
private final HashMap<Integer, Integer> bakedInStats = new HashMap<>();
private final HashMap<Integer, Integer> usedStats = new HashMap<>();
@ -92,7 +91,6 @@ public class ItemBase { @@ -92,7 +91,6 @@ public class ItemBase {
this.uuid = rs.getInt("ID");
this.durability = rs.getInt("durability");
this.value = rs.getInt("value");
this.weight = rs.getShort("weight");
this.color = rs.getShort("color");
@ -105,7 +103,6 @@ public class ItemBase { @@ -105,7 +103,6 @@ public class ItemBase {
this.isConsumable = false;
this.isStackable = false;
this.numCharges = rs.getShort("numCharges");
this.equipFlag = rs.getInt("equipFlag");
this.restrictFlag = rs.getInt("restrictFlag");
@ -256,13 +253,6 @@ public class ItemBase { @@ -256,13 +253,6 @@ public class ItemBase {
}
/*
* Getters
*/
public float getDurability() {
return this.durability;
}
private void initBakedInStats() {
DbManager.ItemBaseQueries.LOAD_BAKEDINSTATS(this);
@ -281,24 +271,11 @@ public class ItemBase { @@ -281,24 +271,11 @@ public class ItemBase {
return this.weight;
}
public int getColor() {
return this.color;
}
public boolean isConsumable() {
return this.isConsumable;
}
public boolean isStackable() {
return this.isStackable;
}
public int getNumCharges() {
return this.numCharges;
}
public int getEquipFlag() {
if ((this.type == ItemType.ARMOR)

13
src/engine/objects/MobEquipment.java

@ -37,6 +37,8 @@ public class MobEquipment extends AbstractGameObject { @@ -37,6 +37,8 @@ public class MobEquipment extends AbstractGameObject {
private int magicValue;
private float dropChance = 0;
public int templateID;
public ItemTemplate template;
/**
* No Id Constructor
@ -44,6 +46,8 @@ public class MobEquipment extends AbstractGameObject { @@ -44,6 +46,8 @@ public class MobEquipment extends AbstractGameObject {
public MobEquipment(ItemBase itemBase, int slot, int parentID) {
super(MobEquipment.getNewID());
this.itemBase = itemBase;
this.templateID = this.itemBase.getUUID();
this.template = ItemTemplate.itemTemplates.get(templateID);
this.slot = slot;
this.parentID = parentID;
this.enchanted = false;
@ -57,6 +61,8 @@ public class MobEquipment extends AbstractGameObject { @@ -57,6 +61,8 @@ public class MobEquipment extends AbstractGameObject {
public MobEquipment(ItemBase itemBase, int slot, int parentID, String pIDString, String sIDString, int pValue, int sValue) {
super(MobEquipment.getNewID());
this.itemBase = itemBase;
this.templateID = this.itemBase.getUUID();
this.template = ItemTemplate.itemTemplates.get(templateID);
this.slot = slot;
this.parentID = parentID;
@ -77,6 +83,8 @@ public class MobEquipment extends AbstractGameObject { @@ -77,6 +83,8 @@ public class MobEquipment extends AbstractGameObject {
super(MobEquipment.getNewID());
int itemBaseID = rs.getInt("ItemID");
this.itemBase = ItemBase.getItemBase(itemBaseID);
this.templateID = this.itemBase.getUUID();
this.template = ItemTemplate.itemTemplates.get(itemBaseID);
this.slot = rs.getInt("slot");
this.parentID = rs.getInt("mobID");
setMagicValue();
@ -86,6 +94,7 @@ public class MobEquipment extends AbstractGameObject { @@ -86,6 +94,7 @@ public class MobEquipment extends AbstractGameObject {
public MobEquipment(int itemBaseID, float dropChance) {
super(MobEquipment.getNewID());
this.itemBase = ItemBase.getItemBase(itemBaseID);
this.template = ItemTemplate.itemTemplates.get(itemBaseID);
if (this.itemBase != null)
this.slot = this.itemBase.getValidSlot();
@ -144,8 +153,8 @@ public class MobEquipment extends AbstractGameObject { @@ -144,8 +153,8 @@ public class MobEquipment extends AbstractGameObject {
writer.putInt(0); // Unknown. pad?
writer.put((byte) 1); // End Datablock byte
writer.putFloat(mobEquipment.itemBase.getDurability());
writer.putFloat(mobEquipment.itemBase.getDurability());
writer.putFloat(mobEquipment.template.item_health_full);
writer.putFloat(mobEquipment.template.item_health_full);
writer.put((byte) 1); // End Datablock byte

Loading…
Cancel
Save