Browse Source

Refactored isShield and removed equipflag.

combat-2
MagicBot 8 months ago
parent
commit
6f028ab8c8
  1. 2
      src/engine/devcmd/cmds/PrintStatsCmd.java
  2. 2
      src/engine/gameManager/CombatManager.java
  3. 6
      src/engine/gameManager/NPCManager.java
  4. 12
      src/engine/mobileAI/utilities/CombatUtilities.java
  5. 3
      src/engine/objects/CharacterItemManager.java
  6. 26
      src/engine/objects/ItemBase.java
  7. 18
      src/engine/objects/ItemTemplate.java
  8. 17
      src/engine/objects/Mob.java
  9. 16
      src/engine/objects/PlayerCharacter.java

2
src/engine/devcmd/cmds/PrintStatsCmd.java

@ -105,7 +105,7 @@ public class PrintStatsCmd extends AbstractDevCmd {
ItemBase off = null; ItemBase off = null;
if(equip != null){ if(equip != null){
if(equip.get(2) != null && !equip.get(2).getItemBase().isShield()){ if (equip.get(2) != null && !ItemTemplate.isShield(equip.get(2).template)) {
//off hand weapon //off hand weapon
out += "Attack Rating: " + tar.atrHandTwo + newline; out += "Attack Rating: " + tar.atrHandTwo + newline;
out += "Damage: " + tar.minDamageHandTwo + " - " + tar.maxDamageHandTwo + newline; out += "Damage: " + tar.minDamageHandTwo + " - " + tar.maxDamageHandTwo + newline;

2
src/engine/gameManager/CombatManager.java

@ -891,7 +891,7 @@ public enum CombatManager {
if (tarOff == null) if (tarOff == null)
return false; return false;
return tarOff.getItemBase().isShield() != false; return ItemTemplate.isShield((tarOff));
} }
private static boolean isRanged(Item item) { private static boolean isRanged(Item item) {

6
src/engine/gameManager/NPCManager.java

@ -309,7 +309,7 @@ public enum NPCManager {
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat; guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat;
guard.speedHandOne = weapon.getSpeed(); guard.speedHandOne = weapon.getSpeed();
guard.rangeHandOne = weapon.getRange(); guard.rangeHandOne = weapon.getRange();
} else if(guard.equip.containsKey(2) && !guard.equip.get(2).getItemBase().isShield()){ } else if (guard.equip.containsKey(2) && !ItemTemplate.isShield(guard.equip.get(2).template)) {
//has off hand weapon //has off hand weapon
ItemBase weapon = guard.equip.get(2).getItemBase(); ItemBase weapon = guard.equip.get(2).getItemBase();
if (weapon.isStrBased()) if (weapon.isStrBased())
@ -337,7 +337,7 @@ public enum NPCManager {
int baseDef = guard.mobBase.getDefenseRating(); int baseDef = guard.mobBase.getDefenseRating();
int armorDefense = 0; int armorDefense = 0;
for(MobEquipment equipped : guard.equip.values()) for(MobEquipment equipped : guard.equip.values())
if(equipped.getItemBase().isArmor() || equipped.getItemBase().isShield()) if (equipped.getItemBase().isArmor() || ItemTemplate.isShield(equipped.template))
armorDefense += equipped.getItemBase().getDefense(); armorDefense += equipped.getItemBase().getDefense();
guard.defenseRating = dexterity + baseDef + armorDefense; guard.defenseRating = dexterity + baseDef + armorDefense;
} }
@ -347,7 +347,7 @@ public enum NPCManager {
int baseAtr = guard.mobBase.getAttackRating(); int baseAtr = guard.mobBase.getAttackRating();
if (guard.equip.get(1) != null) if (guard.equip.get(1) != null)
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(1).getItemBase().getPercentRequired() * 4) + (guard.equip.get(1).getItemBase().getPercentRequired() * 3)); guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(1).getItemBase().getPercentRequired() * 4) + (guard.equip.get(1).getItemBase().getPercentRequired() * 3));
else if (guard.equip.get(2) != null && !guard.equip.get(2).getItemBase().isShield()) else if (guard.equip.get(2) != null && !ItemTemplate.isShield(guard.equip.get(2).template))
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(2).getItemBase().getPercentRequired() * 4) + (guard.equip.get(2).getItemBase().getPercentRequired() * 3)); guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(2).getItemBase().getPercentRequired() * 4) + (guard.equip.get(2).getItemBase().getPercentRequired() * 3));
else else
guard.atrHandOne = baseAtr; guard.atrHandOne = baseAtr;

12
src/engine/mobileAI/utilities/CombatUtilities.java

@ -334,22 +334,24 @@ public class CombatUtilities {
if (agent.getEquip().get(1) != null) { if (agent.getEquip().get(1) != null) {
return agent.getEquip().get(1).getItemBase().getDamageType(); return agent.getEquip().get(1).getItemBase().getDamageType();
} }
if (agent.getEquip().get(2) != null && agent.getEquip().get(2).getItemBase().isShield() == false) { if (agent.getEquip().get(2) != null && ItemTemplate.isShield(agent.getEquip().get(2).template) == false) {
return agent.getEquip().get(2).getItemBase().getDamageType(); return agent.getEquip().get(2).getItemBase().getDamageType();
} }
return dt; return dt;
} }
public static double getMinDmg(Mob agent) { public static double getMinDmg(Mob agent) {
if(agent.equip.get(2) != null && !agent.equip.get(2).getItemBase().isShield()) if (agent.equip.get(2) != null && !ItemTemplate.isShield(agent.equip.get(2).template))
return agent.minDamageHandTwo; return agent.minDamageHandTwo;
else return agent.minDamageHandOne; else
return agent.minDamageHandOne;
} }
public static double getMaxDmg(Mob agent) { public static double getMaxDmg(Mob agent) {
if(agent.equip.get(2) != null && !agent.equip.get(2).getItemBase().isShield()) if (agent.equip.get(2) != null && !ItemTemplate.isShield(agent.equip.get(2).template))
return agent.maxDamageHandTwo; return agent.maxDamageHandTwo;
else return agent.maxDamageHandOne; else
return agent.maxDamageHandOne;
} }
} }

3
src/engine/objects/CharacterItemManager.java

@ -2491,8 +2491,7 @@ public class CharacterItemManager {
if (this.equipped.containsKey(Enum.EquipSlotType.LHELD)) { if (this.equipped.containsKey(Enum.EquipSlotType.LHELD)) {
Item item = this.equipped.get(Enum.EquipSlotType.LHELD); Item item = this.equipped.get(Enum.EquipSlotType.LHELD);
ItemBase ib = item.getItemBase(); if (ItemTemplate.isShield(item))
if (ib.isShield())
armor.add(item); armor.add(item);
} }

26
src/engine/objects/ItemBase.java

@ -42,8 +42,8 @@ public class ItemBase {
private final int useID; private final int useID;
private int hashID; private int hashID;
private final byte useAmount; private final byte useAmount;
// Armor and weapon related values // Armor and weapon related values
private final int equipFlag;
private final int restrictFlag; private final int restrictFlag;
private final String skillRequired; private final String skillRequired;
private final short percentRequired; private final short percentRequired;
@ -83,8 +83,6 @@ public class ItemBase {
this.hashID = rs.getInt("itemHashID"); this.hashID = rs.getInt("itemHashID");
this.isConsumable = false; this.isConsumable = false;
this.equipFlag = rs.getInt("equipFlag");
this.restrictFlag = rs.getInt("restrictFlag"); this.restrictFlag = rs.getInt("restrictFlag");
this.skillRequired = rs.getString("skillRequired"); this.skillRequired = rs.getString("skillRequired");
this.percentRequired = rs.getShort("percentRequired"); this.percentRequired = rs.getShort("percentRequired");
@ -228,16 +226,6 @@ public class ItemBase {
return this.isConsumable; return this.isConsumable;
} }
public int getEquipFlag() {
if ((this.type == ItemType.ARMOR)
|| (this.type == ItemType.WEAPON)
|| (this.type == ItemType.JEWELRY))
return this.equipFlag;
else
return 0;
}
public boolean isRune() { public boolean isRune() {
int ID = uuid; int ID = uuid;
if (ID > 2499 && ID < 3050) //class, discipline runes if (ID > 2499 && ID < 3050) //class, discipline runes
@ -442,18 +430,6 @@ public class ItemBase {
return uuid; return uuid;
} }
public boolean isRing() {
return ((this.equipFlag & (64 | 128 | 192)) != 0);
}
public boolean isNecklace() {
return (this.equipFlag == 256);
}
public boolean isShield() {
return this.type.equals(ItemType.ARMOR) && this.equipFlag == 2;
}
public boolean isLightArmor() { public boolean isLightArmor() {
return this.skillRequired.equals("Wear Armor, Light"); return this.skillRequired.equals("Wear Armor, Light");
} }

18
src/engine/objects/ItemTemplate.java

@ -467,4 +467,22 @@ public class ItemTemplate {
return false; return false;
} }
public static boolean isShield(Item item) {
if (item.template.item_type.equals(Enum.ItemType.ARMOR) &&
item.template.item_eq_slots_and.contains(Enum.EquipSlotType.LHELD))
return true;
return false;
}
public static boolean isShield(ItemTemplate template) {
if (template.item_type.equals(Enum.ItemType.ARMOR) &&
template.item_eq_slots_and.contains(Enum.EquipSlotType.LHELD))
return true;
return false;
}
} }

17
src/engine/objects/Mob.java

@ -1141,14 +1141,13 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
this.rangeHandTwo = 6.5f; this.rangeHandTwo = 6.5f;
this.speedHandTwo = 20; this.speedHandTwo = 20;
if (this.equip.get(EquipSlotType.RHELD) != null) { if (this.equip.get(EquipSlotType.RHELD) != null)
//has mainhand weapon to calculate calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), true); //has mainhand weapon to calculate
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), true);
}
if (this.equip.get(EquipSlotType.LHELD) != null && !this.equip.get(EquipSlotType.LHELD).getItemBase().isShield()) { if (this.equip.get(EquipSlotType.LHELD) != null && !ItemTemplate.isShield(this.equip.get(EquipSlotType.LHELD).template))
//has offhand weapon to calculate calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), false); //has offhand weapon to calculate
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), false);
}
try { try {
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.RHELD), true); calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.RHELD), true);
@ -1264,7 +1263,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
ItemBase ab = shield.getItemBase(); ItemBase ab = shield.getItemBase();
if (ab == null || !ab.isShield()) if (!ItemTemplate.isShield(shield.template))
return 0; return 0;
CharacterSkill blockSkill = this.skills.get("Block"); CharacterSkill blockSkill = this.skills.get("Block");

16
src/engine/objects/PlayerCharacter.java

@ -4088,19 +4088,29 @@ public class PlayerCharacter extends AbstractCharacter {
* @ Calculates Defense for shield * @ Calculates Defense for shield
*/ */
private float getShieldDefense(Item shield) { private float getShieldDefense(Item shield) {
if (shield == null) if (shield == null)
return 0; return 0;
if (ItemTemplate.isShield(shield) == false)
return 0;
ItemBase ab = shield.getItemBase(); ItemBase ab = shield.getItemBase();
if (ab == null || !ab.isShield())
if (ab == null)
return 0; return 0;
CharacterSkill blockSkill = this.skills.get("Block"); CharacterSkill blockSkill = this.skills.get("Block");
float skillMod; float skillMod;
if (blockSkill == null) { if (blockSkill == null) {
skillMod = 0; skillMod = 0;
} else } else
skillMod = blockSkill.getModifiedAmount(); skillMod = blockSkill.getModifiedAmount();
float def = ab.getDefense(); float def = ab.getDefense();
//apply item defense bonuses //apply item defense bonuses
if (shield != null) { if (shield != null) {
def += shield.getBonus(ModType.DR, SourceType.NONE); def += shield.getBonus(ModType.DR, SourceType.NONE);
@ -4127,7 +4137,7 @@ public class PlayerCharacter extends AbstractCharacter {
//set block if block found //set block if block found
this.bonuses.setBool(ModType.Block, SourceType.NONE, false); this.bonuses.setBool(ModType.Block, SourceType.NONE, false);
if (this.baseClass != null && (this.baseClass.getObjectUUID() == 2500 || this.baseClass.getObjectUUID() == 2501)) if (this.baseClass != null && (this.baseClass.getObjectUUID() == 2500 || this.baseClass.getObjectUUID() == 2501))
if (off != null && off.getItemBase() != null && off.getItemBase().isShield()) if (off != null && off.getItemBase() != null && ItemTemplate.isShield(off))
this.bonuses.setBool(ModType.Block, SourceType.NONE, true); this.bonuses.setBool(ModType.Block, SourceType.NONE, true);
//set dodge if rogue //set dodge if rogue
@ -4194,7 +4204,7 @@ public class PlayerCharacter extends AbstractCharacter {
boolean unarmed = false; boolean unarmed = false;
if (weapon == null) { if (weapon == null) {
weapon = equipped.get(EquipSlotType.LHELD); weapon = equipped.get(EquipSlotType.LHELD);
if (weapon == null || weapon.getItemBase().isShield()) if (weapon == null || ItemTemplate.isShield(weapon))
unarmed = true; unarmed = true;
else else
wb = weapon.getItemBase(); wb = weapon.getItemBase();

Loading…
Cancel
Save