Read template health, charges and flags through the bridge

Consumers of the legacy ItemTemplate combat_health_full,
item_initial_charges and item_flags now read getCombatHealthFull(),
getItemInitialCharges() and getItemFlags() on template.cacheTemplate.
No consumer read the template's combat_health_current; the
combat_health_current reads are the Item's own field.

Parity (offline, scripts/p14.py, 7586 templates): 0 differences in
combat_health_current, combat_health_full, item_initial_charges and
item_flags ("None" dropped on both sides). No value changes expected.

JSON-Refactor-Plan Task 1.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-19 12:45:17 -04:00
1 parent dc4a9ee08a
commit d197f62c1f
6 files changed
+14 -14

No files matched your search

+1 -1
View File
@@ -515,7 +515,7 @@ public class InfoCmd extends AbstractDevCmd {
output += StringUtils.addWS("Qty: "
+ df.format(item.getNumOfItems()), 20);
output += "Charges: " + (byte) item.chargesRemaining
+ '/' + item.template.item_initial_charges;
+ '/' + item.template.cacheTemplate.getItemInitialCharges();
output += newline;
output += "Name: " + template.cacheTemplate.getItemBaseName();
output += newline;
@@ -80,7 +80,7 @@ public class PrintInventoryCmd extends AbstractDevCmd {
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD) == false) {
String chargeInfo = "";
int chargeMax = template.item_initial_charges;
int chargeMax = template.cacheTemplate.getItemInitialCharges();
if (chargeMax > 0) {
int charges = item.chargesRemaining;
@@ -85,7 +85,7 @@ public class RepairMsgHandler extends AbstractClientMsgHandler {
//make sure item is damaged and not destroyed
short dur = (short) toRepair.combat_health_current;
short max = (short) toRepair.template.combat_health_full;
short max = (short) toRepair.template.cacheTemplate.getCombatHealthFull();
//account for durability modifications
@@ -104,7 +104,7 @@ public class VendorSellMsgHandler extends AbstractClientMsgHandler {
//get goldItem cost to sell
cost = (int) (sell.template.cacheTemplate.getItemValue() * (sell.combat_health_current / sell.template.combat_health_full));
cost = (int) (sell.template.cacheTemplate.getItemValue() * (sell.combat_health_current / sell.template.cacheTemplate.getCombatHealthFull()));
float bargain = player.getBargain();
float profit = npc.getBuyPercent(player) + bargain;
+2 -2
View File
@@ -1105,7 +1105,7 @@ public class CharacterItemManager {
// Reset value
purchasedItem.value = (int) (purchasedItem.template.cacheTemplate.getItemValue() * (purchasedItem.combat_health_current / purchasedItem.template.combat_health_full));
purchasedItem.value = (int) (purchasedItem.template.cacheTemplate.getItemValue() * (purchasedItem.combat_health_current / purchasedItem.template.cacheTemplate.getCombatHealthFull()));
purchasedItem.magicValue = purchasedItem.template.cacheTemplate.getItemValue() + purchasedItem.calcMagicValue();
// db transfer successfully, remove from this character
@@ -1932,7 +1932,7 @@ public class CharacterItemManager {
return;
//don't damage noob gear, hair or beards.
if (item.template.combat_health_full == 0)
if (item.template.cacheTemplate.getCombatHealthFull() == 0)
return;
if (!item.isCanDestroy())
+8 -8
View File
@@ -69,12 +69,12 @@ public class Item extends AbstractWorldObject {
super();
this.templateID = templateID;
this.template = ItemTemplate.templates.get(templateID);
this.chargesRemaining = this.template.item_initial_charges;
this.combat_health_current = this.template.combat_health_full;
this.chargesRemaining = this.template.cacheTemplate.getItemInitialCharges();
this.combat_health_current = this.template.cacheTemplate.getCombatHealthFull();
this.equipSlot = EquipSlotType.NONE;
this.containerType = ItemContainerType.NONE;
this.numberOfItems = 1;
this.flags.addAll(this.template.item_flags);
this.flags.addAll(this.template.cacheTemplate.getItemFlags());
this.value = this.template.cacheTemplate.getItemValue();
this.magicValue = this.value + calcMagicValue();
loadTemplateEnchantments();
@@ -238,7 +238,7 @@ public class Item extends AbstractWorldObject {
writer.putString(item.name); // Unknown. pad?
writer.put((byte) 1); // End Datablock byte
writer.putFloat(item.template.combat_health_full);
writer.putFloat(item.template.cacheTemplate.getCombatHealthFull());
writer.putFloat((float) item.combat_health_current);
writer.put((byte) 1); // End Datablock byte
@@ -1116,11 +1116,11 @@ public class Item extends AbstractWorldObject {
else
modifiedValue = this.value;
if (this.template.item_initial_charges > 0)
modifiedValue = modifiedValue * (this.chargesRemaining / this.template.item_initial_charges);
if (this.template.cacheTemplate.getItemInitialCharges() > 0)
modifiedValue = modifiedValue * (this.chargesRemaining / this.template.cacheTemplate.getItemInitialCharges());
if (this.template.combat_health_full > 0)
modifiedValue = (int) (modifiedValue * (this.combat_health_current / this.template.combat_health_full));
if (this.template.cacheTemplate.getCombatHealthFull() > 0)
modifiedValue = (int) (modifiedValue * (this.combat_health_current / this.template.cacheTemplate.getCombatHealthFull()));
return modifiedValue;
}