Browse Source

Refactored isShield and removed equipflag.

combat-2
MagicBot 8 months ago
parent
commit
6f028ab8c8
  1. 12
      src/engine/devcmd/cmds/PrintStatsCmd.java
  2. 2
      src/engine/gameManager/CombatManager.java
  3. 18
      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

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

@ -105,13 +105,13 @@ public class PrintStatsCmd extends AbstractDevCmd { @@ -105,13 +105,13 @@ public class PrintStatsCmd extends AbstractDevCmd {
ItemBase off = null;
if(equip != null){
if(equip.get(2) != null && !equip.get(2).getItemBase().isShield()){
//off hand weapon
out += "Attack Rating: " + tar.atrHandTwo + newline;
out += "Damage: " + tar.minDamageHandTwo + " - " + tar.maxDamageHandTwo + newline;
out += "Range: " + tar.rangeHandTwo + newline;
if (equip.get(2) != null && !ItemTemplate.isShield(equip.get(2).template)) {
//off hand weapon
out += "Attack Rating: " + tar.atrHandTwo + newline;
out += "Damage: " + tar.minDamageHandTwo + " - " + tar.maxDamageHandTwo + newline;
out += "Range: " + tar.rangeHandTwo + newline;
out += "Attack Speed: " + tar.speedHandTwo + newline;
} else{
} else {
out += "Attack Rating: " + tar.atrHandOne + newline;
out += "Damage: " + tar.minDamageHandOne + " - " + tar.maxDamageHandOne + newline;
out += "Range: " + tar.rangeHandOne + newline;

2
src/engine/gameManager/CombatManager.java

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

18
src/engine/gameManager/NPCManager.java

@ -301,23 +301,23 @@ public enum NPCManager { @@ -301,23 +301,23 @@ public enum NPCManager {
if(guard.equip.containsKey(1)){
//has main hand weapon
ItemBase weapon = guard.equip.get(1).getItemBase();
if(weapon.isStrBased())
if (weapon.isStrBased())
primaryStat = guard.getStatStrCurrent();
else
primaryStat = guard.getStatDexCurrent();
guard.minDamageHandOne = (int)((guard.mobBase.getDamageMin() + weapon.getMinDamage()) * rankModifier) + primaryStat;
guard.maxDamageHandOne = (int)((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat;
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin() + weapon.getMinDamage()) * rankModifier) + primaryStat;
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat;
guard.speedHandOne = weapon.getSpeed();
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
ItemBase weapon = guard.equip.get(2).getItemBase();
if(weapon.isStrBased())
if (weapon.isStrBased())
primaryStat = guard.getStatStrCurrent();
else
primaryStat = guard.getStatDexCurrent();
guard.minDamageHandTwo = (int)((guard.mobBase.getDamageMin() + weapon.getMinDamage()) * rankModifier) + primaryStat;
guard.maxDamageHandTwo = (int)((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat;
guard.minDamageHandTwo = (int) ((guard.mobBase.getDamageMin() + weapon.getMinDamage()) * rankModifier) + primaryStat;
guard.maxDamageHandTwo = (int) ((guard.mobBase.getDamageMax() + weapon.getMaxDamage()) * rankModifier) + primaryStat;
guard.speedHandTwo = weapon.getSpeed();
guard.rangeHandTwo = weapon.getRange();
} else {
@ -337,7 +337,7 @@ public enum NPCManager { @@ -337,7 +337,7 @@ public enum NPCManager {
int baseDef = guard.mobBase.getDefenseRating();
int armorDefense = 0;
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();
guard.defenseRating = dexterity + baseDef + armorDefense;
}
@ -347,7 +347,7 @@ public enum NPCManager { @@ -347,7 +347,7 @@ public enum NPCManager {
int baseAtr = guard.mobBase.getAttackRating();
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));
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));
else
guard.atrHandOne = baseAtr;

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

@ -334,22 +334,24 @@ public class CombatUtilities { @@ -334,22 +334,24 @@ public class CombatUtilities {
if (agent.getEquip().get(1) != null) {
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 dt;
}
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;
else return agent.minDamageHandOne;
else
return agent.minDamageHandOne;
}
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;
else return agent.maxDamageHandOne;
else
return agent.maxDamageHandOne;
}
}

3
src/engine/objects/CharacterItemManager.java

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

26
src/engine/objects/ItemBase.java

@ -42,8 +42,8 @@ public class ItemBase { @@ -42,8 +42,8 @@ public class ItemBase {
private final int useID;
private int hashID;
private final byte useAmount;
// Armor and weapon related values
private final int equipFlag;
private final int restrictFlag;
private final String skillRequired;
private final short percentRequired;
@ -83,8 +83,6 @@ public class ItemBase { @@ -83,8 +83,6 @@ public class ItemBase {
this.hashID = rs.getInt("itemHashID");
this.isConsumable = false;
this.equipFlag = rs.getInt("equipFlag");
this.restrictFlag = rs.getInt("restrictFlag");
this.skillRequired = rs.getString("skillRequired");
this.percentRequired = rs.getShort("percentRequired");
@ -228,16 +226,6 @@ public class ItemBase { @@ -228,16 +226,6 @@ public class ItemBase {
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() {
int ID = uuid;
if (ID > 2499 && ID < 3050) //class, discipline runes
@ -442,18 +430,6 @@ public class ItemBase { @@ -442,18 +430,6 @@ public class ItemBase {
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() {
return this.skillRequired.equals("Wear Armor, Light");
}

18
src/engine/objects/ItemTemplate.java

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

16
src/engine/objects/PlayerCharacter.java

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

Loading…
Cancel
Save