Switch Item.template and MobLoot to CObjectTemplate
Item.template is now the cache template from CObjectTemplate.lookup instead of the legacy DB ItemTemplate, so item.template.cacheTemplate.X becomes item.template.X. MobLoot, LootManager, ItemManager.isTwoHanded/ isShield and CombatManager.getSwingAnimation take a CObjectTemplate. No value changes: every getter already read the cache template through the bridge, and the lookup resolves the same 7586 ids as static_item_templates with the same item_type (offline parity p17.py, 0 differences). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f39e35ac23
commit
6b4e9815e0
38 files changed
+201
-193
No files matched your search
@@ -20,6 +20,7 @@ import engine.net.ByteBufferWriter;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.DeleteItemMsg;
|
||||
import engine.parsers.objects.CObjectTemplate;
|
||||
import engine.parsers.objects.UserPowerAction;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||
@@ -57,7 +58,7 @@ public class Item extends AbstractWorldObject {
|
||||
public int templateID;
|
||||
private long dateToUpgrade;
|
||||
public int magicValue;
|
||||
public ItemTemplate template;
|
||||
public CObjectTemplate template;
|
||||
public String name = "";
|
||||
public int prefixToken; // Forge support
|
||||
public int suffixToken; // Forge support
|
||||
@@ -70,14 +71,14 @@ public class Item extends AbstractWorldObject {
|
||||
public Item(int templateID) {
|
||||
super();
|
||||
this.templateID = templateID;
|
||||
this.template = ItemTemplate.templates.get(templateID);
|
||||
this.chargesRemaining = this.template.cacheTemplate.getItemInitialCharges();
|
||||
this.combat_health_current = this.template.cacheTemplate.getCombatHealthFull();
|
||||
this.template = CObjectTemplate.lookup(templateID);
|
||||
this.chargesRemaining = this.template.getItemInitialCharges();
|
||||
this.combat_health_current = this.template.getCombatHealthFull();
|
||||
this.equipSlot = EquipSlotType.NONE;
|
||||
this.containerType = ItemContainerType.NONE;
|
||||
this.numberOfItems = 1;
|
||||
this.flags.addAll(this.template.cacheTemplate.getItemFlags());
|
||||
this.value = this.template.cacheTemplate.getItemValue();
|
||||
this.flags.addAll(this.template.getItemFlags());
|
||||
this.value = this.template.getItemValue();
|
||||
this.magicValue = this.value + calcMagicValue();
|
||||
loadTemplateEnchantments();
|
||||
}
|
||||
@@ -89,7 +90,7 @@ public class Item extends AbstractWorldObject {
|
||||
super(rs);
|
||||
|
||||
this.templateID = rs.getInt("templateID");
|
||||
this.template = ItemTemplate.templates.get(this.templateID);
|
||||
this.template = CObjectTemplate.lookup(this.templateID);
|
||||
|
||||
if (this.template == null)
|
||||
Logger.error("Null template of " + this.templateID);
|
||||
@@ -168,7 +169,7 @@ public class Item extends AbstractWorldObject {
|
||||
this.value = rs.getInt("value");
|
||||
|
||||
if (this.value == 0) {
|
||||
this.value = this.template.cacheTemplate.getItemValue();
|
||||
this.value = this.template.getItemValue();
|
||||
this.magicValue = this.value + calcMagicValue();
|
||||
} else
|
||||
this.magicValue = this.value; // Value was overridden in vendor inventory
|
||||
@@ -240,7 +241,7 @@ public class Item extends AbstractWorldObject {
|
||||
writer.putString(item.name); // Unknown. pad?
|
||||
writer.put((byte) 1); // End Datablock byte
|
||||
|
||||
writer.putFloat(item.template.cacheTemplate.getCombatHealthFull());
|
||||
writer.putFloat(item.template.getCombatHealthFull());
|
||||
writer.putFloat((float) item.combat_health_current);
|
||||
|
||||
writer.put((byte) 1); // End Datablock byte
|
||||
@@ -257,7 +258,7 @@ public class Item extends AbstractWorldObject {
|
||||
} else
|
||||
writer.putInt(item.numberOfItems); // Amount of gold
|
||||
} else
|
||||
writer.putInt(item.template.cacheTemplate.getItemValue());
|
||||
writer.putInt(item.template.getItemValue());
|
||||
|
||||
writer.putInt(item.getValue());
|
||||
|
||||
@@ -290,7 +291,7 @@ public class Item extends AbstractWorldObject {
|
||||
writer.putInt(36); //Magical, blue name
|
||||
else
|
||||
writer.putInt(40); //Magical, unidentified
|
||||
else if (item.template.cacheTemplate.getItemUserPowerAction().isEmpty() == false)
|
||||
else if (item.template.getItemUserPowerAction().isEmpty() == false)
|
||||
writer.putInt(36); //Magical, blue name
|
||||
else
|
||||
writer.putInt(4); //Non-Magical, grey name
|
||||
@@ -300,7 +301,7 @@ public class Item extends AbstractWorldObject {
|
||||
writer.put((byte) 0);
|
||||
|
||||
|
||||
if (item.template.cacheTemplate.getItemType().equals(ItemType.EMPLOYMENTCONTRACT) == false) {
|
||||
if (item.template.getItemType().equals(ItemType.EMPLOYMENTCONTRACT) == false) {
|
||||
writer.putShort((short) 0);
|
||||
return;
|
||||
}
|
||||
@@ -465,7 +466,7 @@ public class Item extends AbstractWorldObject {
|
||||
int serialized = 0;
|
||||
for (Item item : list) {
|
||||
|
||||
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
|
||||
if (item.template.getItemType().equals(ItemType.GOLD))
|
||||
if (item.numberOfItems == 0)
|
||||
continue;
|
||||
try {
|
||||
@@ -499,7 +500,7 @@ public class Item extends AbstractWorldObject {
|
||||
int serialized = 0;
|
||||
for (Item item : list) {
|
||||
|
||||
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
|
||||
if (item.template.getItemType().equals(ItemType.GOLD))
|
||||
if (item.numberOfItems == 0)
|
||||
continue;
|
||||
try {
|
||||
@@ -939,7 +940,7 @@ public class Item extends AbstractWorldObject {
|
||||
return;
|
||||
|
||||
// Duplicate powers collapse to the last entry; applying one twice would double its magic value.
|
||||
for (UserPowerAction userPowerAction : this.template.cacheTemplate.getItemUserPowerAction())
|
||||
for (UserPowerAction userPowerAction : this.template.getItemUserPowerAction())
|
||||
templateEnchantments.put(userPowerAction.power, userPowerAction.arguments);
|
||||
|
||||
for (String effectID : templateEnchantments.keySet()) {
|
||||
@@ -961,7 +962,7 @@ public class Item extends AbstractWorldObject {
|
||||
// No enchantments for negative id items in the db. Early exit.
|
||||
|
||||
if (this.objectUUID < 0) {
|
||||
this.magicValue = this.template.cacheTemplate.getItemValue() + calcMagicValue();
|
||||
this.magicValue = this.template.getItemValue() + calcMagicValue();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -977,8 +978,8 @@ public class Item extends AbstractWorldObject {
|
||||
|
||||
// Value is overridden the db
|
||||
|
||||
if (this.value == this.template.cacheTemplate.getItemValue())
|
||||
this.magicValue = this.template.cacheTemplate.getItemValue() + calcMagicValue();
|
||||
if (this.value == this.template.getItemValue())
|
||||
this.magicValue = this.template.getItemValue() + calcMagicValue();
|
||||
}
|
||||
|
||||
public void addPermanentEnchantment(String enchantID, int rank) {
|
||||
@@ -1122,11 +1123,11 @@ public class Item extends AbstractWorldObject {
|
||||
else
|
||||
modifiedValue = this.value;
|
||||
|
||||
if (this.template.cacheTemplate.getItemInitialCharges() > 0)
|
||||
modifiedValue = modifiedValue * (this.chargesRemaining / this.template.cacheTemplate.getItemInitialCharges());
|
||||
if (this.template.getItemInitialCharges() > 0)
|
||||
modifiedValue = modifiedValue * (this.chargesRemaining / this.template.getItemInitialCharges());
|
||||
|
||||
if (this.template.cacheTemplate.getCombatHealthFull() > 0)
|
||||
modifiedValue = (int) (modifiedValue * (this.combat_health_current / this.template.cacheTemplate.getCombatHealthFull()));
|
||||
if (this.template.getCombatHealthFull() > 0)
|
||||
modifiedValue = (int) (modifiedValue * (this.combat_health_current / this.template.getCombatHealthFull()));
|
||||
|
||||
return modifiedValue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user