Refactored isShield and removed equipflag.

This commit is contained in:
2024-03-09 11:26:19 -05:00
parent 658b442b36
commit 6f028ab8c8
9 changed files with 65 additions and 61 deletions
+1 -2
View File
@@ -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);
}
+1 -25
View File
@@ -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 {
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 {
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 {
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
View File
@@ -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;
}
}
+8 -9
View File
@@ -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 {
ItemBase ab = shield.getItemBase();
if (ab == null || !ab.isShield())
if (!ItemTemplate.isShield(shield.template))
return 0;
CharacterSkill blockSkill = this.skills.get("Block");
+14 -4
View File
@@ -4088,19 +4088,29 @@ public class PlayerCharacter extends AbstractCharacter {
* @ Calculates Defense for shield
*/
private float getShieldDefense(Item shield) {
if (shield == null)
return 0;
ItemBase ab = shield.getItemBase();
if (ab == null || !ab.isShield())
if (ItemTemplate.isShield(shield) == false)
return 0;
ItemBase ab = shield.getItemBase();
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 {
//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 {
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();