Switch Item.template and MobLoot to CObjectTemplate
Item.template is now the cache template from CObjectTemplate.lookup instead of the legacy DB ItemTemplate, so item.template.cacheTemplate.X becomes item.template.X. MobLoot, LootManager, ItemManager.isTwoHanded/ isShield and CombatManager.getSwingAnimation take a CObjectTemplate. No value changes: every getter already read the cache template through the bridge, and the lookup resolves the same 7586 ids as static_item_templates with the same item_type (offline parity p17.py, 0 differences). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f39e35ac23
commit
6b4e9815e0
38 files changed
+201
-193
No files matched your search
@@ -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";
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user