Durability and initial charges migrated to template.

This commit is contained in:
2024-03-03 08:38:24 -05:00
parent 436d0cec9b
commit d7dfab5e74
6 changed files with 19 additions and 26 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ public class dbItemHandler extends dbHandlerBase {
preparedStatement.setInt(2, toAdd.getTemplsteID()); preparedStatement.setInt(2, toAdd.getTemplsteID());
preparedStatement.setInt(3, (byte) toAdd.chargesRemaining); preparedStatement.setInt(3, (byte) toAdd.chargesRemaining);
preparedStatement.setInt(4, (short) toAdd.durabilityCurrent); preparedStatement.setInt(4, (short) toAdd.durabilityCurrent);
preparedStatement.setInt(5, toAdd.getDurabilityMax()); preparedStatement.setInt(5, (int) toAdd.template.item_health_full);
if (toAdd.getNumOfItems() < 1) if (toAdd.getNumOfItems() < 1)
preparedStatement.setInt(6, 1); preparedStatement.setInt(6, 1);
+1 -1
View File
@@ -514,7 +514,7 @@ public class InfoCmd extends AbstractDevCmd {
output += StringUtils.addWS("Qty: " output += StringUtils.addWS("Qty: "
+ df.format(item.getNumOfItems()), 20); + df.format(item.getNumOfItems()), 20);
output += "Charges: " + (byte) item.chargesRemaining output += "Charges: " + (byte) item.chargesRemaining
+ '/' + item.getChargesMax(); + '/' + item.template.item_initial_charges;
output += newline; output += newline;
output += "Name: " + template.item_base_name; output += "Name: " + template.item_base_name;
output += newline; output += newline;
@@ -75,14 +75,17 @@ public class PrintInventoryCmd extends AbstractDevCmd {
int goldCount = 0; int goldCount = 0;
for (Item item : inventory) { for (Item item : inventory) {
if (item.getItemBase().getType().equals(ItemType.GOLD) == false) { ItemTemplate template = ItemTemplate.itemTemplates.get(item.templsteID);
if (item.template.item_type.equals(ItemType.GOLD) == false) {
String chargeInfo = ""; String chargeInfo = "";
byte chargeMax = item.getChargesMax(); int chargeMax = template.item_initial_charges;
if (chargeMax > 0) { if (chargeMax > 0) {
byte charges = (byte) item.chargesRemaining; int charges = item.chargesRemaining;
chargeInfo = " charges: " + charges + '/' + chargeMax; chargeInfo = " charges: " + charges + '/' + chargeMax;
} }
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems() + chargeInfo); throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems() + chargeInfo);
} else } else
goldCount += item.getNumOfItems(); goldCount += item.getNumOfItems();
+3 -2
View File
@@ -1246,7 +1246,7 @@ public class ClientMessagePump implements NetMsgHandler {
//apply damaged value reduction //apply damaged value reduction
float durabilityCurrent = (short) sell.durabilityCurrent; float durabilityCurrent = (short) sell.durabilityCurrent;
float durabilityMax = sell.getDurabilityMax(); float durabilityMax = sell.template.item_health_full;
float damagedModifier = durabilityCurrent / durabilityMax; float damagedModifier = durabilityCurrent / durabilityMax;
cost *= damagedModifier; cost *= damagedModifier;
float bargain = player.getBargain(); float bargain = player.getBargain();
@@ -1640,7 +1640,8 @@ public class ClientMessagePump implements NetMsgHandler {
//make sure item is damaged and not destroyed //make sure item is damaged and not destroyed
short dur = (short) toRepair.durabilityCurrent; short dur = (short) toRepair.durabilityCurrent;
short max = toRepair.getDurabilityMax(); short max = (short) toRepair.template.item_health_full;
//account for durability modifications //account for durability modifications
float durMod = toRepair.getBonusPercent(ModType.Durability, SourceType.NONE); float durMod = toRepair.getBonusPercent(ModType.Durability, SourceType.NONE);
max *= (1 + (durMod * 0.01f)); max *= (1 + (durMod * 0.01f));
+2 -1
View File
@@ -2444,13 +2444,14 @@ public class CharacterItemManager {
return; return;
//don't damage noob gear, hair or beards. //don't damage noob gear, hair or beards.
if (item.getDurabilityMax() == 0) if (item.template.item_health_full == 0)
return; return;
if (!item.isCanDestroy()) if (!item.isCanDestroy())
return; return;
int dur = (int) (short) item.durabilityCurrent; int dur = (int) (short) item.durabilityCurrent;
if (dur - amount <= 0) { if (dur - amount <= 0) {
//destroy the item //destroy the item
junk(item); junk(item);
+5 -17
View File
@@ -39,8 +39,6 @@ import java.util.concurrent.locks.ReentrantLock;
public class Item extends AbstractWorldObject { public class Item extends AbstractWorldObject {
private static ConcurrentHashMap<String, Integer> enchantValues = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static ConcurrentHashMap<String, Integer> enchantValues = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private short durabilityMax;
private byte chargesMax;
private final ConcurrentHashMap<AbstractEffectModifier, Float> bonuses = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private final ConcurrentHashMap<AbstractEffectModifier, Float> bonuses = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private final ArrayList<String> effectNames = new ArrayList<>(); private final ArrayList<String> effectNames = new ArrayList<>();
public Enum.ItemContainerType containerType; public Enum.ItemContainerType containerType;
@@ -87,7 +85,11 @@ public class Item extends AbstractWorldObject {
super(rs); super(rs);
this.templsteID = rs.getInt("item_itemBaseID"); this.templsteID = rs.getInt("item_itemBaseID");
this.template = ItemTemplate.itemTemplates.get(this.templsteID);
if (this.template == null)
Logger.error("Null template of " + this.templsteID)
;
// Set container enumeration // Set container enumeration
String container = rs.getString("item_container"); String container = rs.getString("item_container");
@@ -115,15 +117,9 @@ public class Item extends AbstractWorldObject {
this.ownerID = rs.getInt("parent"); this.ownerID = rs.getInt("parent");
if (this.getItemBase() != null)
this.chargesMax = (byte) this.getItemBase().getNumCharges();
else
this.chargesMax = 0;
this.chargesRemaining = rs.getByte("item_chargesRemaining"); this.chargesRemaining = rs.getByte("item_chargesRemaining");
this.durabilityCurrent = rs.getShort("item_durabilityCurrent"); this.durabilityCurrent = rs.getShort("item_durabilityCurrent");
this.durabilityMax = rs.getShort("item_durabilityMax");
DbObjectType ownerType; DbObjectType ownerType;
ownerType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerID); ownerType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerID);
@@ -221,7 +217,7 @@ public class Item extends AbstractWorldObject {
writer.putString(item.customName); // Unknown. pad? writer.putString(item.customName); // Unknown. pad?
writer.put((byte) 1); // End Datablock byte writer.put((byte) 1); // End Datablock byte
writer.putFloat((float) item.durabilityMax); writer.putFloat(item.template.item_health_full);
writer.putFloat((float) item.durabilityCurrent); writer.putFloat((float) item.durabilityCurrent);
writer.put((byte) 1); // End Datablock byte writer.put((byte) 1); // End Datablock byte
@@ -708,18 +704,10 @@ public class Item extends AbstractWorldObject {
return true; return true;
} }
public byte getChargesMax() {
return chargesMax;
}
public void setDurabilityCurrent(float value) { public void setDurabilityCurrent(float value) {
this.durabilityCurrent = value; this.durabilityCurrent = value;
} }
public short getDurabilityMax() {
return durabilityMax;
}
public boolean isCanDestroy() { public boolean isCanDestroy() {
return canDestroy; return canDestroy;
} }