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

+3 -3
View File
@@ -325,7 +325,7 @@ public class dbItemHandler extends dbHandlerBase {
for (Item item : inventory) {
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (item.template.getItemType().equals(ItemType.GOLD))
continue;
try (Connection connection = DbManager.getConnection();
@@ -474,7 +474,7 @@ public class dbItemHandler extends dbHandlerBase {
*/
public boolean UPDATE_GOLD(final Item item, int newValue, int oldValue) {
if (!item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (!item.template.getItemType().equals(ItemType.GOLD))
return false;
try (Connection connection = DbManager.getConnection();
@@ -554,7 +554,7 @@ public class dbItemHandler extends dbHandlerBase {
// Write 0 if we will not modify the value from template
if (value == item.template.cacheTemplate.getItemValue())
if (value == item.template.getItemValue())
value = 0;
try (Connection connection = DbManager.getConnection();
+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.cacheTemplate.getItemInitialCharges();
+ '/' + item.template.getItemInitialCharges();
output += newline;
output += "Name: " + template.cacheTemplate.getItemBaseName();
output += newline;
+3 -3
View File
@@ -66,7 +66,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (mbEnums.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
Item equip = tarMob.charItemManager.equipped.get(slot);
throwbackInfo(pc, equip.templateID + " : " + equip.template.cacheTemplate.getItemBaseName() + ", slot: " + slot);
throwbackInfo(pc, equip.templateID + " : " + equip.template.getItemBaseName() + ", slot: " + slot);
}
return;
}
@@ -76,7 +76,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (mbEnums.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
Item equip = tarMob.charItemManager.equipped.get(slot);
throwbackInfo(pc, equip.templateID + " : " + equip.template.cacheTemplate.getItemBaseName() + ", slot: " + slot);
throwbackInfo(pc, equip.templateID + " : " + equip.template.getItemBaseName() + ", slot: " + slot);
}
return;
}
@@ -87,7 +87,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
for (mbEnums.EquipSlotType slot : list.keySet()) {
Item item = list.get(slot);
throwbackInfo(pc, " " + item.template.cacheTemplate.getItemBaseName() + ", slot: " + slot);
throwbackInfo(pc, " " + item.template.getItemBaseName() + ", slot: " + slot);
}
}
@@ -77,7 +77,7 @@ public class PrintInventoryCmd extends AbstractDevCmd {
for (Item item : inventory) {
ItemTemplate template = ItemTemplate.templates.get(item.templateID);
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD) == false) {
if (item.template.getItemType().equals(ItemType.GOLD) == false) {
String chargeInfo = "";
int chargeMax = template.cacheTemplate.getItemInitialCharges();
+1 -1
View File
@@ -57,7 +57,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
try {
mob.loadInventory();
for (Item lootItem : mob.charItemManager.getInventory()) {
switch (lootItem.template.cacheTemplate.getItemType()) {
switch (lootItem.template.getItemType()) {
case EMPLOYMENTCONTRACT: //CONTRACT
Contracts.add(lootItem);
break;
+1 -1
View File
@@ -535,7 +535,7 @@ public enum ChatManager {
if (item != null) //Steal
if (success) {
String name = "";
if (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD))
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD))
name = amount + " gold ";
else {
String vowels = "aeiou";
+12 -11
View File
@@ -18,6 +18,7 @@ import engine.net.client.msg.PowerProjectileMsg;
import engine.net.client.msg.TargetedActionMsg;
import engine.net.client.msg.UpdateStateMsg;
import engine.objects.*;
import engine.parsers.objects.CObjectTemplate;
import engine.parsers.objects.RuneTemplate;
import engine.powers.DamageShield;
import engine.powers.effectmodifiers.AbstractEffectModifier;
@@ -93,25 +94,25 @@ public enum CombatManager {
return;
}
if (mainWeapon == null && offWeapon != null && !offWeapon.template.cacheTemplate.getItemSkillUsed().equals("Block")) {
if (mainWeapon == null && offWeapon != null && !offWeapon.template.getItemSkillUsed().equals("Block")) {
//swing left hand only
processAttack(attacker, target, mbEnums.EquipSlotType.LHELD);
return;
}
if (mainWeapon == null && offWeapon != null && offWeapon.template.cacheTemplate.getItemSkillUsed().equals("Block")) {
if (mainWeapon == null && offWeapon != null && offWeapon.template.getItemSkillUsed().equals("Block")) {
//no weapon equipped with a shield, punch with one hand
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
return;
}
if (mainWeapon != null && offWeapon != null && offWeapon.template.cacheTemplate.getItemSkillUsed().equals("Block")) {
if (mainWeapon != null && offWeapon != null && offWeapon.template.getItemSkillUsed().equals("Block")) {
//one weapon equipped with a shield, swing with one hand
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
return;
}
if (mainWeapon != null && offWeapon != null && !offWeapon.template.cacheTemplate.getItemSkillUsed().equals("Block")) {
if (mainWeapon != null && offWeapon != null && !offWeapon.template.getItemSkillUsed().equals("Block")) {
//two weapons equipped, swing both hands
processAttack(attacker, target, mbEnums.EquipSlotType.RHELD);
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
@@ -271,13 +272,13 @@ public enum CombatManager {
if (weapon != null && !attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) {
//check if Out of Stamina
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
if (attacker.getStamina() < (weapon.template.cacheTemplate.getItemWt() / 3f)) {
if (attacker.getStamina() < (weapon.template.getItemWt() / 3f)) {
//set auto attack job
setAutoAttackJob(attacker, slot, delay);
return;
}
}
float stam = weapon.template.cacheTemplate.getItemWt() / 3f;
float stam = weapon.template.getItemWt() / 3f;
stam = (stam < 1) ? 1 : stam;
attacker.modifyStamina(-(stam), attacker, true);
} else
@@ -578,14 +579,14 @@ public enum CombatManager {
target.setCombatTarget(attacker);
}
public static int getSwingAnimation(ItemTemplate wb, DeferredPowerJob dpj, mbEnums.EquipSlotType slot) {
public static int getSwingAnimation(CObjectTemplate wb, DeferredPowerJob dpj, mbEnums.EquipSlotType slot) {
//No weapon, return default animation
if (wb == null)
return 75;
int token;
engine.parsers.objects.ItemTemplate.Weapon weapon = engine.parsers.objects.ItemTemplate.getWeapon(wb.template_id);
engine.parsers.objects.ItemTemplate.Weapon weapon = engine.parsers.objects.ItemTemplate.getWeapon(wb.getTemplateId());
if (dpj != null) {
@@ -596,7 +597,7 @@ public enum CombatManager {
}
//Item has no equipment slots and should not try to return an animation, return default instead
if (wb.cacheTemplate.getItemEqSlotsOr().isEmpty()) {
if (wb.getItemEqSlotsOr().isEmpty()) {
return 75;
}
@@ -605,8 +606,8 @@ public enum CombatManager {
int random;
//Item can only be equipped in one slot, return animation for that slot
if (wb.cacheTemplate.getItemEqSlotsOr().size() == 1) {
if (wb.cacheTemplate.getItemEqSlotsOr().iterator().next().equals(mbEnums.EquipSlotType.RHELD)) {
if (wb.getItemEqSlotsOr().size() == 1) {
if (wb.getItemEqSlotsOr().iterator().next().equals(mbEnums.EquipSlotType.RHELD)) {
anim = weapon.weapon_attack_anim_right.get(0)[0];
if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(weapon.weapon_attack_anim_right.size());
+1 -1
View File
@@ -307,7 +307,7 @@ public enum GroupManager {
return false;
}
if (!item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD)) //only split goldItem
if (!item.template.getItemType().equals(mbEnums.ItemType.GOLD)) //only split goldItem
return false;
Group group = getGroup(pc);
+21 -20
View File
@@ -2,6 +2,7 @@ package engine.gameManager;
import engine.mbEnums;
import engine.objects.*;
import engine.parsers.objects.CObjectTemplate;
import engine.powers.EffectsBase;
import org.pmw.tinylog.Logger;
@@ -25,8 +26,8 @@ public enum ItemManager {
public static Boolean ValidRace(Item item, mbEnums.MonsterType race) {
EnumSet<mbEnums.MonsterType> races = item.template.cacheTemplate.getItemRaceReq();
boolean restrict = item.template.cacheTemplate.getItemRaceReqRestrict();
EnumSet<mbEnums.MonsterType> races = item.template.getItemRaceReq();
boolean restrict = item.template.getItemRaceReqRestrict();
if (races.isEmpty())
return true;
@@ -36,8 +37,8 @@ public enum ItemManager {
public static Boolean ValidClass(Item item, mbEnums.ClassType base, mbEnums.ClassType profession) {
EnumSet<mbEnums.ClassType> classes = item.template.cacheTemplate.getItemClassReq();
boolean restrict = item.template.cacheTemplate.getItemClassReqRestrict();
EnumSet<mbEnums.ClassType> classes = item.template.getItemClassReq();
boolean restrict = item.template.getItemClassReqRestrict();
boolean listed;
if (classes.isEmpty())
@@ -50,8 +51,8 @@ public enum ItemManager {
public static Boolean ValidDiscipline(Item item, EnumSet<mbEnums.DisciplineType> discs) {
EnumSet<mbEnums.DisciplineType> disciplines = item.template.cacheTemplate.getItemDiscReq();
boolean restrict = item.template.cacheTemplate.getItemDiscReqRestrict();
EnumSet<mbEnums.DisciplineType> disciplines = item.template.getItemDiscReq();
boolean restrict = item.template.getItemDiscReqRestrict();
EnumSet<mbEnums.DisciplineType> workSet;
if (disciplines.isEmpty())
@@ -71,12 +72,12 @@ public enum ItemManager {
CharacterSkill characterSkill;
if (item.template.cacheTemplate.getItemSkillReq().isEmpty())
if (item.template.getItemSkillReq().isEmpty())
return true;
for (String skillRequired : item.template.cacheTemplate.getItemSkillReq().keySet()) {
for (String skillRequired : item.template.getItemSkillReq().keySet()) {
int required_value = item.template.cacheTemplate.getItemSkillReq().get(skillRequired);
int required_value = item.template.getItemSkillReq().get(skillRequired);
characterSkill = skills.get(skillRequired);
if (characterSkill == null)
@@ -92,31 +93,31 @@ public enum ItemManager {
public static boolean isTwoHanded(Item item) {
if (!item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.WEAPON))
if (!item.template.getItemType().equals(mbEnums.ItemType.WEAPON))
return false;
return item.template.cacheTemplate.getItemEqSlotsAnd().containsAll(EnumSet.of(mbEnums.EquipSlotType.LHELD, mbEnums.EquipSlotType.RHELD));
return item.template.getItemEqSlotsAnd().containsAll(EnumSet.of(mbEnums.EquipSlotType.LHELD, mbEnums.EquipSlotType.RHELD));
}
public static boolean isTwoHanded(ItemTemplate template) {
public static boolean isTwoHanded(CObjectTemplate template) {
if (!template.cacheTemplate.getItemType().equals(mbEnums.ItemType.WEAPON))
if (!template.getItemType().equals(mbEnums.ItemType.WEAPON))
return false;
return template.cacheTemplate.getItemEqSlotsAnd().containsAll(EnumSet.of(mbEnums.EquipSlotType.LHELD, mbEnums.EquipSlotType.RHELD));
return template.getItemEqSlotsAnd().containsAll(EnumSet.of(mbEnums.EquipSlotType.LHELD, mbEnums.EquipSlotType.RHELD));
}
public static boolean isShield(Item item) {
if (item.template.cacheTemplate.getItemSkillReq().containsKey("Block"))
if (item.template.getItemSkillReq().containsKey("Block"))
return true;
return false;
}
public static boolean isShield(ItemTemplate template) {
public static boolean isShield(CObjectTemplate template) {
if (template.cacheTemplate.getItemSkillReq().containsKey("Block"))
if (template.getItemSkillReq().containsKey("Block"))
return true;
return false;
@@ -130,7 +131,7 @@ public enum ItemManager {
return false;
//Item not valid for slot
if (item.template.cacheTemplate.getItemEqSlotsOr().contains(slot) == false)
if (item.template.getItemEqSlotsOr().contains(slot) == false)
return false;
// Slot is taken
@@ -145,7 +146,7 @@ public enum ItemManager {
(slot == mbEnums.EquipSlotType.RHELD && equipped.get(mbEnums.EquipSlotType.LHELD) != null)))
return false;
if (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.WEAPON))
if (item.template.getItemType().equals(mbEnums.ItemType.WEAPON))
if (equipped.get(slot) != null && equipped.get(slot).equals(item) == false)
return false;
@@ -177,7 +178,7 @@ public enum ItemManager {
//players can't wear 0 value items.
return item.template.cacheTemplate.getItemValue() != 0 || Kit.IsNoobGear(item.templateID);
return item.template.getItemValue() != 0 || Kit.IsNoobGear(item.templateID);
}
+9 -8
View File
@@ -13,6 +13,7 @@ import engine.mbEnums;
import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.chat.ChatSystemMsg;
import engine.objects.*;
import engine.parsers.objects.CObjectTemplate;
import org.pmw.tinylog.Logger;
import java.util.ArrayList;
@@ -91,8 +92,8 @@ public enum LootManager {
//lastly, check mobs inventory for godly or disc runes to send a server announcement
for (Item item : mob.getInventory()) {
if ((item.templateID > 2499 && item.templateID <= 3050) || item.template.cacheTemplate.getItemBaseName().toLowerCase().contains("of the gods")) {
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + item.template.cacheTemplate.getItemBaseName() + ". Are you tough enough to take it?");
if ((item.templateID > 2499 && item.templateID <= 3050) || item.template.getItemBaseName().toLowerCase().contains("of the gods")) {
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + item.template.getItemBaseName() + ". Are you tough enough to take it?");
chatMsg.setMessageType(10);
chatMsg.setChannel(mbEnums.ChatChannelType.SYSTEM.getChannelID());
DispatchManager.dispatchMsgToAll(chatMsg);
@@ -179,12 +180,12 @@ public enum LootManager {
if (itemUUID == 0)
return null;
if (ItemTemplate.templates.get(itemUUID).cacheTemplate.getItemType().equals(mbEnums.ItemType.RESOURCE)) {
if (CObjectTemplate.lookup(itemUUID).getItemType().equals(mbEnums.ItemType.RESOURCE)) {
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
return new MobLoot(mob, ItemTemplate.templates.get(itemUUID), amount, false);
return new MobLoot(mob, CObjectTemplate.lookup(itemUUID), amount, false);
}
outItem = new MobLoot(mob, ItemTemplate.templates.get(itemUUID), false);
outItem = new MobLoot(mob, CObjectTemplate.lookup(itemUUID), false);
if (selectedRow.pModTable != 0)
try {
@@ -374,7 +375,7 @@ public enum LootManager {
if (chanceRoll > bse.dropChance)
return;
MobLoot lootItem = new MobLoot(mob, ItemTemplate.templates.get(bse.templateID), true);
MobLoot lootItem = new MobLoot(mob, CObjectTemplate.lookup(bse.templateID), true);
if (lootItem != null)
mob.charItemManager.addItemToInventory(lootItem);
@@ -422,14 +423,14 @@ public enum LootManager {
//create the item from the table, quantity is always 1
MobLoot winnings = new MobLoot(playerCharacter, ItemTemplate.templates.get(selectedItem.templateID), 1, false);
MobLoot winnings = new MobLoot(playerCharacter, CObjectTemplate.lookup(selectedItem.templateID), 1, false);
if (winnings == null)
return;
//early exit if the inventory of the player will not old the item
if (itemMan.hasRoomInventory(winnings.template.cacheTemplate.getItemWt()) == false) {
if (itemMan.hasRoomInventory(winnings.template.getItemWt()) == false) {
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
return;
}
+5 -5
View File
@@ -353,7 +353,7 @@ public enum NPCManager {
int baseDef = guard.mobBase.getDefenseRating();
int armorDefense = 0;
for (Item equipped : guard.charItemManager.equipped.values())
if (equipped.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.ARMOR) || ItemManager.isShield(equipped.template))
if (equipped.template.getItemType().equals(mbEnums.ItemType.ARMOR) || ItemManager.isShield(equipped.template))
armorDefense += engine.parsers.objects.ItemTemplate._items.get(equipped.templateID).item_defense_rating;
guard.defenseRating = dexterity + baseDef + armorDefense;
}
@@ -362,9 +362,9 @@ public enum NPCManager {
int strength = guard.getStatStrCurrent();
int baseAtr = guard.mobBase.getAttackRating();
if (guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD) != null)
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD).template.cacheTemplate.getItemSkillReq().values().toArray()[0] * 4) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD).template.cacheTemplate.getItemSkillReq().values().toArray()[0] * 3));
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD).template.getItemSkillReq().values().toArray()[0] * 4) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.RHELD).template.getItemSkillReq().values().toArray()[0] * 3));
else if (guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD) != null && !ItemManager.isShield(guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template))
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template.cacheTemplate.getItemSkillReq().values().toArray()[0] * 4) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template.cacheTemplate.getItemSkillReq().values().toArray()[0] * 3));
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template.getItemSkillReq().values().toArray()[0] * 4) + ((int) guard.charItemManager.equipped.get(mbEnums.EquipSlotType.LHELD).template.getItemSkillReq().values().toArray()[0] * 3));
else
guard.atrHandOne = baseAtr;
}
@@ -445,8 +445,8 @@ public enum NPCManager {
return;
for (Item equipped : mob.charItemManager.equipped.values()) {
if (equipped.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.ARMOR)) {
armorResists = equipped.template.cacheTemplate.getCombatAttackResist();
if (equipped.template.getItemType().equals(mbEnums.ItemType.ARMOR)) {
armorResists = equipped.template.getCombatAttackResist();
mob.resists.setResist(mbEnums.DamageType.SLASHING, mob.resists.getResist(mbEnums.DamageType.SLASHING, 0) + armorResists.getOrDefault(mbEnums.DamageType.SLASHING, 0f));
mob.resists.setResist(mbEnums.DamageType.CRUSHING, mob.resists.getResist(mbEnums.DamageType.CRUSHING, 0) + armorResists.getOrDefault(mbEnums.DamageType.CRUSHING, 0f));
mob.resists.setResist(mbEnums.DamageType.PIERCING, mob.resists.getResist(mbEnums.DamageType.PIERCING, 0) + armorResists.getOrDefault(mbEnums.DamageType.PIERCING, 0f));
+3 -3
View File
@@ -2255,12 +2255,12 @@ public enum PowersManager {
if (pb.targetItem())
return true;
// TODO add these checks later
else if (pb.targetArmor() && item.template.cacheTemplate.getItemType().equals(ItemType.ARMOR))
else if (pb.targetArmor() && item.template.getItemType().equals(ItemType.ARMOR))
return true;
else if (pb.targetJewelry() && item.template.cacheTemplate.getItemType().equals(ItemType.JEWELRY))
else if (pb.targetJewelry() && item.template.getItemType().equals(ItemType.JEWELRY))
return true;
else
return pb.targetWeapon() && item.template.cacheTemplate.getItemType().equals(ItemType.WEAPON);
return pb.targetWeapon() && item.template.getItemType().equals(ItemType.WEAPON);
} // How did we get here? all valid targets have been covered
else
return false;
@@ -46,7 +46,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
// Filter hirelings by slot type
for (Item hirelings : player.getInventory()) {
if (hirelings.template.cacheTemplate.getItemType().equals(ItemType.EMPLOYMENTCONTRACT)) {
if (hirelings.template.getItemType().equals(ItemType.EMPLOYMENTCONTRACT)) {
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templateID);
@@ -78,7 +78,7 @@ public class AddItemToTradeWindowMsgHandler extends AbstractClientMsgHandler {
if (!item.validForInventory(source.getClientConnection(), source, source.charItemManager))
return false;
if (!tradingWith.hasRoomTrade(item.template.cacheTemplate.getItemWt())) {
if (!tradingWith.hasRoomTrade(item.template.getItemWt())) {
dispatch = Dispatch.borrow(source, msg);
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.PRIMARY);
return false;
@@ -238,10 +238,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem == null)
return;
if (targetItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (targetItem.template.getItemType().equals(ItemType.GOLD))
return;
if (!vendor.charItemManager.hasRoomInventory(targetItem.template.cacheTemplate.getItemWt())) {
if (!vendor.charItemManager.hasRoomInventory(targetItem.template.getItemWt())) {
ErrorPopupMsg.sendErrorPopup(player, 21);
return;
}
@@ -319,7 +319,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem == null)
continue;
if (targetItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (targetItem.template.getItemType().equals(ItemType.GOLD))
return;
if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID()))
@@ -328,14 +328,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (!vendor.charItemManager.inventoryContains(targetItem))
continue;
itemValue = targetItem.template.cacheTemplate.getItemValue();
itemValue = targetItem.template.getItemValue();
if (vendor.getBuilding().getStrongboxValue() + itemValue > vendor.getBuilding().getMaxGold()) {
ErrorPopupMsg.sendErrorPopup(player, 201);
break;
}
switch (targetItem.template.cacheTemplate.getItemType()) {
switch (targetItem.template.getItemType()) {
case EMPLOYMENTCONTRACT:
case CHARTER:
case DEED:
@@ -465,13 +465,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem == null)
return;
if (targetItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (targetItem.template.getItemType().equals(ItemType.GOLD))
return;
if (!vendor.charItemManager.inventoryContains(targetItem))
return;
if (!player.charItemManager.hasRoomInventory(targetItem.template.cacheTemplate.getItemWt()))
if (!player.charItemManager.hasRoomInventory(targetItem.template.getItemWt()))
return;
player.charItemManager.buyFromNPC(targetItem, vendor);
@@ -161,7 +161,7 @@ public class LootMsgHandler extends AbstractClientMsgHandler {
if (itemRet == null)
return true;
if (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD)) {
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD)) {
// this is done to prevent the temporary goldItem item
// (from the mob) from appearing in player's inventory.
// It also updates the goldItem quantity display
@@ -187,7 +187,7 @@ public class LootMsgHandler extends AbstractClientMsgHandler {
//TODO send group loot message if player is grouped and visible
Group group = GroupManager.getGroup(player);
if (group != null && group.getSplitGold() && (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD) == false)) {
if (group != null && group.getSplitGold() && (item.template.getItemType().equals(mbEnums.ItemType.GOLD) == false)) {
String name = item.getName();
String text = player.getFirstName() + " has looted " + name + '.';
ChatManager.chatGroupInfoCanSee(player, text);
@@ -202,7 +202,7 @@ public class LootMsgHandler extends AbstractClientMsgHandler {
if (itemRet == null)
return true;
if (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD)) {
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD)) {
// this is done to prevent the temporary goldItem item
// (from the mob) from appearing in player's inventory.
// It also updates the goldItem quantity display
@@ -241,7 +241,7 @@ public class LootMsgHandler extends AbstractClientMsgHandler {
//TODO send group loot message if player is grouped and visible
Group group = GroupManager.getGroup(player);
if (group != null && group.getSplitGold() && (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD) == false)) {
if (group != null && group.getSplitGold() && (item.template.getItemType().equals(mbEnums.ItemType.GOLD) == false)) {
String name = item.getName();
String text = player.getFirstName() + " has looted " + name + '.';
ChatManager.chatGroupInfoCanSee(player, text);
@@ -79,7 +79,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
int uuid = item.templateID;
switch (item.template.cacheTemplate.getItemType()) {
switch (item.template.getItemType()) {
case DEED: //buildings
//Call add building screen here, ib.getUseID() get's building ID
@@ -188,14 +188,14 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
if (uuid > 680069 && uuid < 680074) //Handle Charter, Deed, Petition, Warrant here
break;
if (item.template.cacheTemplate.getItemBaneRank() > 0) {
if (item.template.getItemBaneRank() > 0) {
// Only one banestone at a time
lock.writeLock().lock();
try {
if (Bane.summonBanestone(player, origin, item.template.cacheTemplate.getItemBaneRank()) == true)
if (Bane.summonBanestone(player, origin, item.template.getItemBaneRank()) == true)
itemMan.consume(item);
} finally {
lock.writeLock().unlock();
@@ -226,7 +226,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
// Bypass for waterbuckets
if (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.BUCKET)) {
if (item.template.getItemType().equals(mbEnums.ItemType.BUCKET)) {
// test for valid target type
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter)
@@ -251,7 +251,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
}
if (waterbucketBypass == false) {
engine.parsers.objects.PowerGrant powerGrant = item.template.cacheTemplate.getItemPowerGrant().get(0);
engine.parsers.objects.PowerGrant powerGrant = item.template.getItemPowerGrant().get(0);
PowersBase powerAction = PowersManager.powersBaseByIDString.get(powerGrant.power_type);
PowersManager.applyPower(player, target, Vector3fImmutable.ZERO, powerAction.getToken(), powerGrant.power_value, true);
}
@@ -357,7 +357,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
Item contract = null;
for (Item inventoryItem : playerCharacter.getInventory()) {
if (inventoryItem.template.cacheTemplate.getItemType().equals(ItemType.DEED) &&
if (inventoryItem.template.getItemType().equals(ItemType.DEED) &&
DeedTemplate._deeds.get(inventoryItem.templateID).deed_structure_id == buildingList.getBlueprintUUID()) {
contract = inventoryItem;
break;
@@ -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.cacheTemplate.getCombatHealthFull();
short max = (short) toRepair.template.getCombatHealthFull();
//account for durability modifications
@@ -68,7 +68,7 @@ public class TransferItemFromBankMsgHandler extends AbstractClientMsgHandler {
return true;
;
if (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD)) {
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD)) {
if (!itemManager.moveGoldToInventory(item, msg.getNumItems()))
return true;
@@ -85,7 +85,7 @@ public class TransferItemFromBankMsgHandler extends AbstractClientMsgHandler {
// Not gold, process update here
if (!itemManager.hasRoomInventory(item.template.cacheTemplate.getItemWt()))
if (!itemManager.hasRoomInventory(item.template.getItemWt()))
return true;
if (itemManager.moveItemToInventory(item) == false)
@@ -65,7 +65,7 @@ public class TransferItemToBankMsgHandler extends AbstractClientMsgHandler {
return true;
if (item.containerType == mbEnums.ItemContainerType.INVENTORY && itemManager.isBankOpen())
if (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD)) {
if (item.template.getItemType().equals(mbEnums.ItemType.GOLD)) {
if (!itemManager.moveGoldToBank(item, msg.getNumItems()))
return true;
UpdateGoldMsg goldMes = new UpdateGoldMsg(player);
@@ -76,7 +76,7 @@ public class TransferItemToBankMsgHandler extends AbstractClientMsgHandler {
} else {
if (!itemManager.hasRoomBank(item.template.cacheTemplate.getItemWt()))
if (!itemManager.hasRoomBank(item.template.getItemWt()))
return true;
if (!itemManager.moveItemToBank(item))
@@ -86,7 +86,7 @@ public class VendorBuyMsgHandler extends AbstractClientMsgHandler {
if (me.objectUUID == vendorBuyMsg.getItemID()) {
//test room available for item
if (!itemMan.hasRoomInventory(me.template.cacheTemplate.getItemWt()))
if (!itemMan.hasRoomInventory(me.template.getItemWt()))
return true;
int cost = me.getValue();
@@ -148,10 +148,10 @@ public class VendorBuyMsgHandler extends AbstractClientMsgHandler {
//test room available for item
if (!itemMan.hasRoomInventory(vendorItem.template.cacheTemplate.getItemWt()))
if (!itemMan.hasRoomInventory(vendorItem.template.getItemWt()))
return true;
int cost = vendorItem.template.cacheTemplate.getItemValue();
int cost = vendorItem.template.getItemValue();
if (vendorItem.flags.contains(mbEnums.ItemFlags.Identified) || vendorItem.isCustomValue())
cost = vendorItem.magicValue;
@@ -94,7 +94,7 @@ public class VendorSellMsgHandler extends AbstractClientMsgHandler {
return true;
if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID != 0)
if (!npc.charItemManager.hasRoomInventory(sell.template.cacheTemplate.getItemWt())) {
if (!npc.charItemManager.hasRoomInventory(sell.template.getItemWt())) {
ErrorPopupMsg.sendErrorPopup(player, 21);
return true;
}
@@ -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.cacheTemplate.getCombatHealthFull()));
cost = (int) (sell.template.getItemValue() * (sell.combat_health_current / sell.template.getCombatHealthFull()));
float bargain = player.getBargain();
float profit = npc.getBuyPercent(player) + bargain;
+1 -1
View File
@@ -445,7 +445,7 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(0);
writer.putInt(item.templateID);
writer.putInt(item.template.cacheTemplate.getItemValue());
writer.putInt(item.template.getItemValue());
long timeLife = item.getDateToUpgrade() - System.currentTimeMillis();
@@ -54,7 +54,7 @@ public class UpdateInventoryMsg extends ClientNetMsg {
for (Item item : list) {
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (item.template.getItemType().equals(ItemType.GOLD)) {
if (item.getNumOfItems() == 0)
continue;
}
@@ -156,7 +156,7 @@ public class VendorBuyWindowMsg extends ClientNetMsg {
for (Item item : inventory) {
if (item.getOwnerID() != ownerID)
continue;
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (item.template.getItemType().equals(ItemType.GOLD)) {
if (item.getNumOfItems() == 0)
continue;
}
+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());
@@ -63,7 +63,7 @@ public class StealPowerAction extends AbstractPowerAction {
//called to get amount of gold to steal between 0 and max gold
protected static int getAmountToSteal(Item item) {
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (item.template.getItemType().equals(ItemType.GOLD)) {
int amount = item.getNumOfItems();
@@ -159,7 +159,7 @@ public class StealPowerAction extends AbstractPowerAction {
if (myCIM == null || ownerCIM == null)
return;
if (tar.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (tar.template.getItemType().equals(ItemType.GOLD)) {
//stealing gold
if (!myCIM.transferGoldToMyInventory((AbstractCharacter) owner, amount))
return;