forked from MagicBane/Server
Refactored isShield and removed equipflag.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user