Read defense, bulk and primary attr from the cache ItemTemplate

item_defense_rating, item_bulk_factor and item_primary_attr are
Item-only fields, not on CObjectTemplate, so their consumers read
engine.parsers.objects.ItemTemplate._items by templateID, like the
RuneTemplate and DeedTemplate consumers. The primary attr checks
compare with == because the cache template leaves the attr null
(legacy: None) on non-weapons.

Parity (offline, scripts/p14.py, 7586 templates): 0 differences in
item_defense_rating, item_bulk_factor and item_primary_attr. Every DB
ARMOR and WEAPON template is in the ITEM folder, so both sides gate
these fields on the same templates. 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:59 -04:00
1 parent d197f62c1f
commit 9a10574e59
3 files changed
+10 -10

No files matched your search

+6 -6
View File
@@ -778,7 +778,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
min = damages[0];
max = damages[1];
strBased = weaponTemplate.item_primary_attr.equals(AttributeType.Strength);
strBased = engine.parsers.objects.ItemTemplate._items.get(weapon.templateID).item_primary_attr == AttributeType.Strength;
}
if (abstractCharacter.effects != null && abstractCharacter.effects.containsKey("DeathShroud"))
@@ -970,7 +970,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
} else
skillMod = blockSkill.getModifiedAmount();
float def = template.item_defense_rating;
float def = engine.parsers.objects.ItemTemplate._items.get(shield.templateID).item_defense_rating;
//apply item defense bonuses
@@ -1001,20 +1001,20 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
return 0;
if (armor.template.item_skill_used.isEmpty())
return template.item_defense_rating;
return engine.parsers.objects.ItemTemplate._items.get(armor.templateID).item_defense_rating;
CharacterSkill armorSkill = abstractCharacter.skills.get(armor.template.item_skill_used);
if (abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter) && armorSkill == null) {
Logger.error("Player " + abstractCharacter.getObjectUUID()
+ " has armor equipped without the nescessary skill to equip it");
return template.item_defense_rating;
return engine.parsers.objects.ItemTemplate._items.get(armor.templateID).item_defense_rating;
}
if (armorSkill == null)
return template.item_defense_rating; // Mobiles do not have armor skills @TODO
return engine.parsers.objects.ItemTemplate._items.get(armor.templateID).item_defense_rating; // Mobiles do not have armor skills @TODO
float def = template.item_defense_rating;
float def = engine.parsers.objects.ItemTemplate._items.get(armor.templateID).item_defense_rating;
//apply item defense bonuses