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:
MagicBotandClaude Opus 5.5 committed 2026-10-20 07:55:28 -04:00
1 parent f39e35ac23
commit 6b4e9815e0
38 files changed
+201 -193

No files matched your search

+18 -17
View File
@@ -29,6 +29,7 @@ import engine.net.Dispatch;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ApplyRuneMsg;
import engine.net.client.msg.UpdateStateMsg;
import engine.parsers.objects.CObjectTemplate;
import engine.parsers.objects.RuneTemplate;
import engine.powers.EffectsBase;
import engine.powers.PowersBase;
@@ -692,17 +693,17 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
// make sure weapon exists
boolean noWeapon = false;
ItemTemplate weaponTemplate = null;
CObjectTemplate weaponTemplate = null;
engine.parsers.objects.ItemTemplate.Damage damage;
if (weapon == null)
noWeapon = true;
else {
ItemTemplate itemTemplate = weapon.template;
CObjectTemplate itemTemplate = weapon.template;
if (itemTemplate == null)
noWeapon = true;
else if (!weapon.template.cacheTemplate.getItemType().equals(ItemType.WEAPON)) {
else if (!weapon.template.getItemType().equals(ItemType.WEAPON)) {
defaultAtrAndDamage(abstractCharacter, mainHand);
return;
} else
@@ -719,7 +720,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
if (noWeapon) {
if (mainHand) {
Item off = abstractCharacter.charItemManager.getEquipped().get(EquipSlotType.LHELD);
if (off != null && off.template != null && off.template.cacheTemplate.getItemType().equals(ItemType.WEAPON))
if (off != null && off.template != null && off.template.getItemType().equals(ItemType.WEAPON))
abstractCharacter.rangeHandOne = 10 * (1 + (abstractCharacter.statStrBase / 600)); // Set
// to
// no
@@ -766,8 +767,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
skillPercentage = getModifiedAmount(abstractCharacter.skills.get(weapon.template.cacheTemplate.getItemSkillUsed()));
masteryPercentage = getModifiedAmount(abstractCharacter.skills.get(weaponTemplate.cacheTemplate.getItemSkillMasteryUsed()));
skillPercentage = getModifiedAmount(abstractCharacter.skills.get(weapon.template.getItemSkillUsed()));
masteryPercentage = getModifiedAmount(abstractCharacter.skills.get(weaponTemplate.getItemSkillMasteryUsed()));
if (masteryPercentage == 0f)
mastDam = 0f;
@@ -828,7 +829,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
//calculate speed
if (weaponTemplate != null)
speed = engine.parsers.objects.ItemTemplate.getWeapon(weaponTemplate.template_id).weapon_wepspeed;
speed = engine.parsers.objects.ItemTemplate.getWeapon(weaponTemplate.getTemplateId()).weapon_wepspeed;
else
speed = 20f; //unarmed attack speed
if (weapon != null)
@@ -886,7 +887,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
// Client (0x466EB0 sets char+0xD0C, 0x46D200 applies it): 30% cut only when both hands hold a WEAPON.
if (!noWeapon && otherHand != null && otherHand.template != null
&& otherHand.template.cacheTemplate.getItemType().equals(ItemType.WEAPON)) {
&& otherHand.template.getItemType().equals(ItemType.WEAPON)) {
min *= 0.7f;
max *= 0.7f;
}
@@ -954,7 +955,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
if (ItemManager.isShield(shield) == false)
return 0;
ItemTemplate template = shield.template;
CObjectTemplate template = shield.template;
if (template == null)
return 0;
@@ -990,19 +991,19 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
if (armor == null)
return 0;
ItemTemplate template = armor.template;
CObjectTemplate template = armor.template;
if (template == null)
return 0;
if (!armor.template.cacheTemplate.getItemType().equals(ItemType.ARMOR))
if (!armor.template.getItemType().equals(ItemType.ARMOR))
return 0;
// "Cloth" is a placeholder in Skills.cfg (token 0) that no character learns
if (armor.template.cacheTemplate.getItemSkillUsed().isEmpty() || armor.template.cacheTemplate.getItemSkillUsed().equals("Cloth"))
if (armor.template.getItemSkillUsed().isEmpty() || armor.template.getItemSkillUsed().equals("Cloth"))
return engine.parsers.objects.ItemTemplate._items.get(armor.templateID).item_defense_rating;
CharacterSkill armorSkill = abstractCharacter.skills.get(armor.template.cacheTemplate.getItemSkillUsed());
CharacterSkill armorSkill = abstractCharacter.skills.get(armor.template.getItemSkillUsed());
if (abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter) && armorSkill == null) {
Logger.error("Player " + abstractCharacter.getObjectUUID()
@@ -1031,7 +1032,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
private static float getWeaponDefense(AbstractCharacter abstractCharacter, ConcurrentHashMap<EquipSlotType, Item> equipped) {
Item weapon = equipped.get(EquipSlotType.RHELD);
ItemTemplate weaponTemplate = null;
CObjectTemplate weaponTemplate = null;
CharacterSkill skill, mastery;
float val = 0;
boolean unarmed = false;
@@ -1052,8 +1053,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
skill = abstractCharacter.skills.get("Unarmed Combat");
mastery = abstractCharacter.skills.get("Unarmed Combat Mastery");
} else {
skill = abstractCharacter.skills.get(weapon.template.cacheTemplate.getItemSkillUsed());
mastery = abstractCharacter.skills.get(weaponTemplate.cacheTemplate.getItemSkillMasteryUsed());
skill = abstractCharacter.skills.get(weapon.template.getItemSkillUsed());
mastery = abstractCharacter.skills.get(weaponTemplate.getItemSkillMasteryUsed());
}
if (skill != null)
@@ -1088,7 +1089,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
for (Item item : equipped.values()) {
ItemTemplate ib = item.template;
CObjectTemplate ib = item.template;
if (ib == null)
continue;
+3 -3
View File
@@ -172,7 +172,7 @@ public class Account extends AbstractGameObject {
this.vault = DbManager.ItemQueries.GET_ITEMS_FOR_ACCOUNT(this.getObjectUUID());
for (Item item : this.vault) {
if (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD)) {
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD)) {
this.vaultGold = item;
}
}
@@ -216,7 +216,7 @@ public class Account extends AbstractGameObject {
return;
if (item.containerType == mbEnums.ItemContainerType.INVENTORY && player.charItemManager.isVaultOpen()) {
if (!player.charItemManager.hasRoomVault(item.template.cacheTemplate.getItemWt())) {
if (!player.charItemManager.hasRoomVault(item.template.getItemWt())) {
ItemToVaultMsgHandler.forceTransferFromVaultToInventory(msg, origin, "There is no room in your vault.");
return;
}
@@ -262,7 +262,7 @@ public class Account extends AbstractGameObject {
return;
if (item.containerType == mbEnums.ItemContainerType.VAULT && itemManager.isVaultOpen()) {
if (!itemManager.hasRoomInventory(item.template.cacheTemplate.getItemWt())) {
if (!itemManager.hasRoomInventory(item.template.getItemWt())) {
ItemFromVaultMsgHandler.forceTransferFromInventoryToVault(msg, origin, "There is no room in your inventory.");
return;
}
+34 -33
View File
@@ -17,6 +17,7 @@ import engine.mbEnums.ItemType;
import engine.net.Dispatch;
import engine.net.client.ClientConnection;
import engine.net.client.msg.*;
import engine.parsers.objects.CObjectTemplate;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
@@ -130,19 +131,19 @@ public class CharacterItemManager {
this.equipped.put(i.equipSlot, i);
break;
case BANK:
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (i.template.getItemType().equals(ItemType.GOLD))
this.goldBank = i;
else if (this.bank.contains(i) == false)
this.bank.add(i);
break;
case INVENTORY:
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (i.template.getItemType().equals(ItemType.GOLD))
this.goldInventory = i;
else if (this.inventory.contains(i) == false)
this.inventory.add(i);
break;
case VAULT:
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (i.template.getItemType().equals(ItemType.GOLD))
this.goldVault = i;
else if (this.vault.contains(i) == false)
this.vault.add(i);
@@ -175,13 +176,13 @@ public class CharacterItemManager {
this.equipped.put(i.equipSlot, i);
break;
case BANK:
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (i.template.getItemType().equals(ItemType.GOLD))
this.goldBank = i;
else if (this.bank.contains(i) == false)
this.bank.add(i);
break;
case INVENTORY:
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (i.template.getItemType().equals(ItemType.GOLD))
this.goldInventory = i;
else if (this.inventory.contains(i) == false)
this.inventory.add(i);
@@ -511,7 +512,7 @@ public class CharacterItemManager {
if (i == null)
return false;
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (i.template.getItemType().equals(ItemType.GOLD)) {
if (this.getGoldInventory() != null) {
if (i.getObjectUUID() == this.getGoldInventory().getObjectUUID())
this.goldInventory = null;
@@ -541,7 +542,7 @@ public class CharacterItemManager {
}
private synchronized boolean junk(Item i, boolean updateInventory) {
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (i.template.getItemType().equals(ItemType.GOLD)) {
if (this.getGoldInventory().getObjectUUID() == i.getObjectUUID())
if (DbManager.ItemQueries.UPDATE_GOLD(i, 0)) {
this.getGoldInventory().setNumOfItems(0);
@@ -596,7 +597,7 @@ public class CharacterItemManager {
if (equippedContains(item)) {
fromEquip = true;
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (item.template.getItemType().equals(ItemType.GOLD))
this.absCharacter.cancelOnUnEquip();
}
@@ -814,7 +815,7 @@ public class CharacterItemManager {
// This removes ingame item from inventory for loot.
private synchronized boolean removeItemFromInventory(Item i) {
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (i.template.getItemType().equals(ItemType.GOLD)) {
if (i.getObjectUUID() != this.getGoldInventory().getObjectUUID())
return false;
if (!DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, 0)) {
@@ -837,7 +838,7 @@ public class CharacterItemManager {
// This adds item to inventory for loot. Validity checks already handled
public synchronized boolean addItemToInventory(Item i) {
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (i.template.getItemType().equals(ItemType.GOLD))
if (this.absCharacter.getObjectType() == GameObjectType.Mob) {
if (this.goldInventory == null)
loadGoldItems();
@@ -856,7 +857,7 @@ public class CharacterItemManager {
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
if (i.template != null)
this.inventoryWeight += i.template.cacheTemplate.getItemWt();
this.inventoryWeight += i.template.getItemWt();
return true;
}
@@ -1041,7 +1042,7 @@ public class CharacterItemManager {
if (npc.getContractID() >= 1900 && npc.getContractID() <= 1906)
eatItem = true;
if (itemToSell.template.cacheTemplate.getItemType().equals(ItemType.POTION))
if (itemToSell.template.getItemType().equals(ItemType.POTION))
eatItem = true;
if (eatItem) {
@@ -1085,14 +1086,14 @@ public class CharacterItemManager {
synchronized (this) {
synchronized (itemMan) {
ItemTemplate template = purchasedItem.template;
CObjectTemplate template = purchasedItem.template;
if (template == null)
return false;
//test inventory is not full
if (!hasRoomInventory(template.cacheTemplate.getItemWt()))
if (!hasRoomInventory(template.getItemWt()))
return false;
if (!itemMan.inventory.contains(purchasedItem))
@@ -1105,8 +1106,8 @@ public class CharacterItemManager {
// Reset value
purchasedItem.value = (int) (purchasedItem.template.cacheTemplate.getItemValue() * (purchasedItem.combat_health_current / purchasedItem.template.cacheTemplate.getCombatHealthFull()));
purchasedItem.magicValue = purchasedItem.template.cacheTemplate.getItemValue() + purchasedItem.calcMagicValue();
purchasedItem.value = (int) (purchasedItem.template.getItemValue() * (purchasedItem.combat_health_current / purchasedItem.template.getCombatHealthFull()));
purchasedItem.magicValue = purchasedItem.template.getItemValue() + purchasedItem.calcMagicValue();
// db transfer successfully, remove from this character
// skip this check if this is a mobLoot item (which is not in any inventory)
@@ -1184,9 +1185,9 @@ public class CharacterItemManager {
synchronized (lockFirst) {
synchronized (lockSecond) {
// make sure current player has item in inventory
if (lootItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob)))
if (lootItem.template.getItemType().equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob)))
return null;
else if (!this.inventory.contains(lootItem) && !this.equipped.containsValue(lootItem) && !lootItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
else if (!this.inventory.contains(lootItem) && !this.equipped.containsValue(lootItem) && !lootItem.template.getItemType().equals(ItemType.GOLD))
return null;
// get weight of item
@@ -1194,13 +1195,13 @@ public class CharacterItemManager {
if (lootItem.template == null)
return null;
int weight = lootItem.template.cacheTemplate.getItemWt();
int weight = lootItem.template.getItemWt();
// make sure lootingPlayer has room for item
if (!lootItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight))
if (!lootItem.template.getItemType().equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight))
return null;
if (lootItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (lootItem.template.getItemType().equals(ItemType.GOLD))
if (amount != -1) { //from steal
int total = lootItem.getNumOfItems();
amount = (amount > total) ? total : amount;
@@ -1263,19 +1264,19 @@ public class CharacterItemManager {
* Delegates
*/
public synchronized boolean bankContains(Item item) {
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (item.template.getItemType().equals(ItemType.GOLD))
return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == item.getObjectUUID());
return bank.contains(item);
}
public synchronized boolean inventoryContains(Item item) {
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (item.template.getItemType().equals(ItemType.GOLD))
return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == item.getObjectUUID());
return inventory.contains(item);
}
public synchronized boolean vaultContains(Item item) {
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (item.template.getItemType().equals(ItemType.GOLD))
return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == item.getObjectUUID());
return this.account.getVault().contains(item);
}
@@ -1518,13 +1519,13 @@ public class CharacterItemManager {
item.zeroItem();
item.containerType = mbEnums.ItemContainerType.INVENTORY;
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (item.template.getItemType().equals(ItemType.GOLD))
//only add gold item once
if (!corpse.hasGold())
corpse.setHasGold(true);
newInventory.add(item);
} else //item
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (item.template.getItemType().equals(ItemType.GOLD)) {
int amt = item.getNumOfItems();
item.setNumOfItems(0);
MobLoot ml = new MobLoot(this.absCharacter, amt);
@@ -1676,7 +1677,7 @@ public class CharacterItemManager {
if (item == null)
continue;
weight += item.template.cacheTemplate.getItemWt();
weight += item.template.getItemWt();
}
return weight;
}
@@ -1696,7 +1697,7 @@ public class CharacterItemManager {
this.bankWeight = 0;
for (Item item : this.bank) {
if (item.template != null)
this.bankWeight += item.template.cacheTemplate.getItemWt();
this.bankWeight += item.template.getItemWt();
}
}
@@ -1707,7 +1708,7 @@ public class CharacterItemManager {
while (it.hasNext()) {
Item item = it.next();
if (item.template != null)
this.equipWeight += item.template.cacheTemplate.getItemWt();
this.equipWeight += item.template.getItemWt();
}
}
@@ -1715,7 +1716,7 @@ public class CharacterItemManager {
this.inventoryWeight = 0;
for (Item item : this.inventory) {
if (item.template != null)
this.inventoryWeight += item.template.cacheTemplate.getItemWt();
this.inventoryWeight += item.template.getItemWt();
}
}
@@ -1723,7 +1724,7 @@ public class CharacterItemManager {
this.vaultWeight = 0;
for (Item item : this.vault) {
if (item.template != null)
this.vaultWeight += item.template.cacheTemplate.getItemWt();
this.vaultWeight += item.template.getItemWt();
}
}
@@ -1755,7 +1756,7 @@ public class CharacterItemManager {
return;
if (!item.moveItemToInventory(player))
Logger.error("templateL " + item.template.template_id);
Logger.error("templateL " + item.template.getTemplateId());
// remove it from other lists:
this.remItemFromLists(item);
@@ -1932,7 +1933,7 @@ public class CharacterItemManager {
return;
//don't damage noob gear, hair or beards.
if (item.template.cacheTemplate.getCombatHealthFull() == 0)
if (item.template.getCombatHealthFull() == 0)
return;
if (!item.isCanDestroy())
+3 -3
View File
@@ -296,14 +296,14 @@ public class Corpse extends AbstractWorldObject {
//get weight of item
int weight = item.template.cacheTemplate.getItemWt();
int weight = item.template.getItemWt();
//make sure looter has room for item
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD) == false && !looterItems.hasRoomInventory(weight))
if (item.template.getItemType().equals(ItemType.GOLD) == false && !looterItems.hasRoomInventory(weight))
return null;
//attempt to transfer item in db
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (item.template.getItemType().equals(ItemType.GOLD)) {
if (!looterItems.moveGoldToInventory(item, item.getNumOfItems()))
return null;
} else if (!item.moveItemToInventory(looter))
+23 -22
View File
@@ -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;
}
+2 -2
View File
@@ -128,12 +128,12 @@ public class MobBase extends AbstractGameObject {
Item item = new Item(equipmentSetEntry.templateID);
if (item.template.cacheTemplate.getItemEqSlotsOr().isEmpty())
if (item.template.getItemEqSlotsOr().isEmpty())
continue;
item.objectUUID = ItemManager.lastNegativeID.decrementAndGet();
item.drop_chance = equipmentSetEntry.dropChance;
item.equipSlot = item.template.cacheTemplate.getItemEqSlotsOr().iterator().next();
item.equipSlot = item.template.getItemEqSlotsOr().iterator().next();
equip.put(item.equipSlot, item);
}
+7 -6
View File
@@ -15,6 +15,7 @@ import engine.gameManager.PowersManager;
import engine.mbEnums;
import engine.mbEnums.ItemType;
import engine.mbEnums.OwnerType;
import engine.parsers.objects.CObjectTemplate;
import engine.powers.poweractions.AbstractPowerAction;
import org.pmw.tinylog.Logger;
@@ -30,22 +31,22 @@ public final class MobLoot extends Item {
private String prefix = "";
private String suffix = "";
public MobLoot(AbstractCharacter mob, ItemTemplate template, boolean noSteal) {
public MobLoot(AbstractCharacter mob, CObjectTemplate template, boolean noSteal) {
this(mob, template, 0, noSteal);
}
public MobLoot(AbstractCharacter mob, int qtyOfGold) {
this(mob, ItemTemplate.templates.get(mbEnums.ResourceType.GOLD.templateID), qtyOfGold, false);
this(mob, CObjectTemplate.lookup(mbEnums.ResourceType.GOLD.templateID), qtyOfGold, false);
}
public MobLoot(AbstractCharacter mob, ItemTemplate template, int quantity, boolean noSteal) {
public MobLoot(AbstractCharacter mob, CObjectTemplate template, int quantity, boolean noSteal) {
super(template.template_id);
super(template.getTemplateId());
this.ownerType = OwnerType.Mob;
this.ownerID = mob.getObjectUUID();
this.objectUUID = generateId();
if (quantity == 0 && template.cacheTemplate.getItemType() == ItemType.RESOURCE)
if (quantity == 0 && template.getItemType() == ItemType.RESOURCE)
quantity = 1;
if (quantity > 0)
@@ -105,7 +106,7 @@ public final class MobLoot extends Item {
if (isDeleted)
return null;
if (this.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (this.template.getItemType().equals(ItemType.GOLD))
return null;
Item item = this;
+11 -10
View File
@@ -32,6 +32,7 @@ import engine.net.Dispatch;
import engine.net.client.ClientConnection;
import engine.net.client.msg.*;
import engine.net.client.msg.login.CommitNewCharacterMsg;
import engine.parsers.objects.CObjectTemplate;
import engine.powers.EffectsBase;
import engine.server.MBServerStatics;
import engine.server.login.LoginServer;
@@ -1353,7 +1354,7 @@ public class PlayerCharacter extends AbstractCharacter {
public static float getDexPenalty(Item armor) {
if (armor == null)
return 0f;
ItemTemplate ab = armor.template;
CObjectTemplate ab = armor.template;
if (ab == null)
return 0f;
return engine.parsers.objects.ItemTemplate._items.get(armor.templateID).item_bulk_factor;
@@ -2816,15 +2817,15 @@ public class PlayerCharacter extends AbstractCharacter {
if (item == null)
return false;
ItemTemplate ib = item.template;
CObjectTemplate ib = item.template;
if (ib != null) {
if ((item.template.cacheTemplate.getItemType().equals(ItemType.WEAPON))
&& (item.template.cacheTemplate.getItemSkillUsed().equals(type) || ib.cacheTemplate.getItemSkillMasteryUsed().equals(type)))
if ((item.template.getItemType().equals(ItemType.WEAPON))
&& (item.template.getItemSkillUsed().equals(type) || ib.getItemSkillMasteryUsed().equals(type)))
return true;
return (item.template.cacheTemplate.getItemType().equals(ItemType.ARMOR))
&& (item.template.cacheTemplate.getItemSkillUsed().equals(type));
return (item.template.getItemType().equals(ItemType.ARMOR))
&& (item.template.getItemSkillUsed().equals(type));
}
return false;
@@ -3768,8 +3769,8 @@ public class PlayerCharacter extends AbstractCharacter {
ConcurrentHashMap<EquipSlotType, Item> equipped = this.charItemManager.getEquipped();
Item off = equipped.get(EquipSlotType.LHELD);
Item main = equipped.get(EquipSlotType.RHELD);
ItemTemplate wbMain = null;
ItemTemplate wbOff = null;
CObjectTemplate wbMain = null;
CObjectTemplate wbOff = null;
if (main != null)
wbMain = main.template;
if (off != null)
@@ -3791,8 +3792,8 @@ public class PlayerCharacter extends AbstractCharacter {
this.bonuses.setBool(ModType.Parry, SourceType.None, false);
if ((this.baseClass != null && this.baseClass.getObjectUUID() == 2500)
|| (this.promotionClass != null && this.promotionClass.getObjectUUID() == 2520))
if (wbMain == null || engine.parsers.objects.ItemTemplate.getWeapon(wbMain.template_id).weapon_max_range < MBServerStatics.RANGED_WEAPON_RANGE)
if (wbOff == null || engine.parsers.objects.ItemTemplate.getWeapon(wbOff.template_id).weapon_max_range < MBServerStatics.RANGED_WEAPON_RANGE)
if (wbMain == null || engine.parsers.objects.ItemTemplate.getWeapon(wbMain.getTemplateId()).weapon_max_range < MBServerStatics.RANGED_WEAPON_RANGE)
if (wbOff == null || engine.parsers.objects.ItemTemplate.getWeapon(wbOff.getTemplateId()).weapon_max_range < MBServerStatics.RANGED_WEAPON_RANGE)
this.bonuses.setBool(ModType.Parry, SourceType.None, true);
}
+2 -2
View File
@@ -165,8 +165,8 @@ public class Resists {
if (armor == null)
return phys;
if (armor.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.ARMOR)) {
armorResists = armor.template.cacheTemplate.getCombatAttackResist();
if (armor.template.getItemType().equals(mbEnums.ItemType.ARMOR)) {
armorResists = armor.template.getCombatAttackResist();
phys[0] += armorResists.getOrDefault(mbEnums.DamageType.SLASHING, 0f);
phys[1] += armorResists.getOrDefault(mbEnums.DamageType.CRUSHING, 0f);
phys[2] += armorResists.getOrDefault(mbEnums.DamageType.PIERCING, 0f);
+2 -2
View File
@@ -256,13 +256,13 @@ public class Shrine extends AbstractWorldObject implements Comparable<Shrine> {
if (!boonOwner.charItemManager.doesCharOwnThisItem(boonItem.getObjectUUID()))
return false;
for (ShrineType boonShrineType : boonItem.template.cacheTemplate.getItemOfferingInfo().keySet()) {
for (ShrineType boonShrineType : boonItem.template.getItemOfferingInfo().keySet()) {
if (boonShrineType != shrineType)
continue;
//Same Shrine Type, add favors and stop loop.
int amount = boonItem.template.cacheTemplate.getItemOfferingInfo().get(boonShrineType) * boonItem.getNumOfItems();
int amount = boonItem.template.getItemOfferingInfo().get(boonShrineType) * boonItem.getNumOfItems();
int oldAmount = this.favors;
if (!DbManager.ShrineQueries.updateFavors(this, this.favors + amount, oldAmount)) {
+1 -1
View File
@@ -304,7 +304,7 @@ public class Warehouse {
return false;
}
if (resource.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD))
if (resource.template.getItemType().equals(mbEnums.ItemType.GOLD))
resourceType = mbEnums.ResourceType.GOLD;
else
resourceType = mbEnums.ResourceType.valueOf(ItemTemplate.templates.get(resource.templateID).cacheTemplate.getItemBaseName().toUpperCase());