remove ItemBase form absChar and Mob

This commit is contained in:
2024-03-27 17:31:04 -05:00
parent aff2a8fa0e
commit def5ceee46
2 changed files with 27 additions and 404 deletions
+2 -379
View File
@@ -1046,7 +1046,8 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
} else {
try {
calculateAtrDefenseDamage();
AbstractCharacter.calculateAtrDamageForWeapon(this,this.charItemManager.equipped.get(EquipSlotType.RHELD),true,this.charItemManager.equipped.get(EquipSlotType.LHELD));
AbstractCharacter.calculateAtrDefenseDamage(this);
} catch (Exception e) {
Logger.error(this.getMobBaseID() + " /" + e.getMessage());
}
@@ -1122,384 +1123,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
}
public void calculateAtrDefenseDamage() {
if (this.charItemManager == null || this.charItemManager.equipped == null) {
Logger.error("Player " + currentID + " missing skills or equipment");
defaultAtrAndDamage(true);
defaultAtrAndDamage(false);
this.defenseRating = 0;
return;
}
this.atrHandOne = (short) this.mobBase.getAttackRating();
this.minDamageHandOne = (short) this.mobBase.getDamageMin();
this.maxDamageHandOne = (short) this.mobBase.getDamageMax();
this.rangeHandOne = 6.5f;
this.speedHandOne = 20;
this.atrHandTwo = (short) this.mobBase.getAttackRating();
this.minDamageHandTwo = (short) this.mobBase.getDamageMin();
this.maxDamageHandTwo = (short) this.mobBase.getDamageMax();
this.rangeHandTwo = 6.5f;
this.speedHandTwo = 20;
if (this.charItemManager.equipped.get(EquipSlotType.RHELD) != null)
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.LHELD), true); //has mainhand weapon to calculate
if (this.charItemManager.equipped.get(EquipSlotType.LHELD) != null && !ItemTemplate.isShield(this.charItemManager.equipped.get(EquipSlotType.LHELD).template))
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.LHELD), false); //has offhand weapon to calculate
try {
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.RHELD), true);
} catch (Exception e) {
this.atrHandOne = (short) this.mobBase.getAttackRating();
this.minDamageHandOne = (short) this.mobBase.getDamageMin();
this.maxDamageHandOne = (short) this.mobBase.getDamageMax();
this.rangeHandOne = 6.5f;
this.speedHandOne = 20;
Logger.info("Mobbase ID " + this.getMobBaseID() + " returned an error. setting to default ATR and Damage." + e.getMessage());
}
try {
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.LHELD), false);
} catch (Exception e) {
this.atrHandTwo = (short) this.mobBase.getAttackRating();
this.minDamageHandTwo = (short) this.mobBase.getDamageMin();
this.maxDamageHandTwo = (short) this.mobBase.getDamageMax();
this.rangeHandTwo = 6.5f;
this.speedHandTwo = 20;
Logger.info("Mobbase ID " + this.getMobBaseID() + " returned an error. setting to default ATR and Damage." + e.getMessage());
}
try {
float defense = this.mobBase.getDefenseRating();
defense += getShieldDefense(charItemManager.equipped.get(EquipSlotType.LHELD));
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.HELM));
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.CHEST));
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.UPARM));
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.HANDS));
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.LEGS));
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.FEET));
defense += getWeaponDefense(charItemManager.equipped);
// TODO add error log here
if (this.bonuses != null) {
// add any bonuses
defense += (short) this.bonuses.getFloat(ModType.DCV, SourceType.NONE);
// Finally, multiply any percent modifiers. DO THIS LAST!
float pos_Bonus = 1 + this.bonuses.getFloatPercentPositive(ModType.DCV, SourceType.NONE);
defense = (short) (defense * pos_Bonus);
//Lucky rune applies next
float neg_Bonus = this.bonuses.getFloatPercentNegative(ModType.DCV, SourceType.NONE);
defense = (short) (defense * (1 + neg_Bonus));
} else
Logger.error("Error: missing bonuses");
defense = (defense < 1) ? 1 : defense;
this.defenseRating = (short) (defense + 0.5f);
} catch (Exception e) {
Logger.info("Mobbase ID " + this.getMobBaseID() + " returned an error. Setting to Default Defense." + e.getMessage());
this.defenseRating = (short) this.mobBase.getDefenseRating();
}
// calculate defense for equipment
}
private float getWeaponDefense(ConcurrentHashMap<Enum.EquipSlotType, Item> equipped) {
Item weapon = equipped.get(EquipSlotType.RHELD);
ItemBase wb = null;
CharacterSkill skill, mastery;
float val = 0;
boolean unarmed = false;
if (weapon == null) {
weapon = equipped.get(EquipSlotType.LHELD);
if (weapon == null)
unarmed = true;
else
wb = weapon.getItemBase();
} else
wb = weapon.getItemBase();
if (wb == null)
unarmed = true;
if (unarmed) {
skill = null;
mastery = null;
} else {
skill = this.skills.get(weapon.template.item_skill_used);
mastery = this.skills.get(wb.getMastery());
}
if (skill != null)
val += (int) skill.getModifiedAmount() / 2f;
if (mastery != null)
val += (int) mastery.getModifiedAmount() / 2f;
return val;
}
private float getShieldDefense(Item shield) {
if (shield == null)
return 0;
ItemBase ab = shield.getItemBase();
if (!ItemTemplate.isShield(shield.template))
return 0;
CharacterSkill blockSkill = this.skills.get("Block");
float skillMod;
if (blockSkill == null) {
skillMod = CharacterSkill.getQuickMastery(this, "Block");
if (skillMod == 0f)
return 0;
} else
skillMod = blockSkill.getModifiedAmount();
float def = ab.getDefense();
//apply item defense bonuses
return (def * (1 + ((int) skillMod / 100f)));
}
private float getArmorDefense(Item armor) {
if (armor == null)
return 0;
ItemBase ib = armor.getItemBase();
if (ib == null)
return 0;
if (!armor.template.item_type.equals(ItemType.ARMOR))
return 0;
if (armor.template.item_skill_used.isEmpty())
return ib.getDefense();
CharacterSkill armorSkill = this.skills.get(armor.template.item_skill_used);
if (armorSkill == null)
return ib.getDefense();
float def = ib.getDefense();
//apply item defense bonuses
return (def * (1 + ((int) armorSkill.getModifiedAmount() / 50f)));
}
private void calculateAtrDamageForWeapon(Item weapon, boolean mainHand) {
int baseStrength = 0;
float skillPercentage, masteryPercentage;
float mastDam;
// make sure weapon exists
boolean noWeapon = false;
ItemBase wb = null;
if (weapon == null)
noWeapon = true;
else {
ItemBase ib = weapon.getItemBase();
if (ib == null)
noWeapon = true;
else if (weapon.template.item_type.equals(ItemType.WEAPON) == false) {
defaultAtrAndDamage(mainHand);
return;
} else
wb = ib;
}
float min, max;
float speed;
boolean strBased = false;
// get skill percentages and min and max damage for weapons
if (noWeapon) {
if (mainHand)
this.rangeHandOne = this.mobBase.getAttackRange();
else
this.rangeHandTwo = -1; // set to do not attack
skillPercentage = getModifiedAmount(this.skills.get("Unarmed Combat"));
masteryPercentage = getModifiedAmount(this.skills.get("Unarmed Combat Mastery"));
if (masteryPercentage == 0f)
mastDam = CharacterSkill.getQuickMastery(this, "Unarmed Combat Mastery");
else
mastDam = masteryPercentage;
// TODO Correct these
min = this.mobBase.getDamageMin();
max = this.mobBase.getDamageMax();
} else {
if (mainHand)
this.rangeHandOne = weapon.getItemBase().getRange() * (1 + (baseStrength / 600.0f));
else
this.rangeHandTwo = weapon.getItemBase().getRange() * (1 + (baseStrength / 600.0f));
skillPercentage = getModifiedAmount(this.skills.get(weapon.template.item_skill_used));
masteryPercentage = getModifiedAmount(this.skills.get(wb.getMastery()));
if (masteryPercentage == 0f)
mastDam = 0f;
else
mastDam = masteryPercentage;
min = wb.getMinDamage();
max = wb.getMaxDamage();
strBased = wb.isStrBased();
}
// calculate atr
float atr = this.mobBase.getAttackRating();
if (this.statStrCurrent > this.statDexCurrent)
atr += statStrCurrent * .5;
else
atr += statDexCurrent * .5;
// add in any bonuses to atr
if (this.bonuses != null) {
atr += this.bonuses.getFloat(ModType.OCV, SourceType.NONE);
// Finally use any multipliers. DO THIS LAST!
float pos_Bonus = 1 + this.bonuses.getFloatPercentPositive(ModType.OCV, SourceType.NONE);
atr *= pos_Bonus;
//and negative percent modifiers
//TODO DO DEBUFFS AFTER?? wILL TEst when finished
float neg_Bonus = this.bonuses.getFloatPercentNegative(ModType.OCV, SourceType.NONE);
atr *= (1 + neg_Bonus);
}
atr = (atr < 1) ? 1 : atr;
// set atr
if (mainHand)
this.atrHandOne = (short) (atr + 0.5f);
else
this.atrHandTwo = (short) (atr + 0.5f);
//calculate speed
if (wb != null)
speed = wb.getSpeed();
else
speed = 20f; //unarmed attack speed
if (this.bonuses != null && this.bonuses.getFloat(ModType.AttackDelay, SourceType.NONE) != 0f) //add effects speed bonus
speed *= (1 + this.bonuses.getFloatPercentAll(ModType.AttackDelay, SourceType.NONE));
if (speed < 10)
speed = 10;
//add min/max damage bonuses for weapon **REMOVED
//if duel wielding, cut damage by 30%
// calculate damage
float minDamage;
float maxDamage;
float pri = (strBased) ? (float) this.statStrCurrent : (float) this.statDexCurrent;
float sec = (strBased) ? (float) this.statDexCurrent : (float) this.statStrCurrent;
minDamage = (float) (min * ((0.0315f * Math.pow(pri, 0.75f)) + (0.042f * Math.pow(sec, 0.75f)) + (0.01f * ((int) skillPercentage + (int) mastDam))));
maxDamage = (float) (max * ((0.0785f * Math.pow(pri, 0.75f)) + (0.016f * Math.pow(sec, 0.75f)) + (0.0075f * ((int) skillPercentage + (int) mastDam))));
minDamage = (float) ((int) (minDamage + 0.5f)); //round to nearest decimal
maxDamage = (float) ((int) (maxDamage + 0.5f)); //round to nearest decimal
//add Base damage last.
float minDamageMod = this.mobBase.getDamageMin();
float maxDamageMod = this.mobBase.getDamageMax();
minDamage += minDamageMod;
maxDamage += maxDamageMod;
// add in any bonuses to damage
if (this.bonuses != null) {
// Add any base bonuses
minDamage += this.bonuses.getFloat(ModType.MinDamage, SourceType.NONE);
maxDamage += this.bonuses.getFloat(ModType.MaxDamage, SourceType.NONE);
// Finally use any multipliers. DO THIS LAST!
minDamage *= (1 + this.bonuses.getFloatPercentAll(ModType.MinDamage, SourceType.NONE));
maxDamage *= (1 + this.bonuses.getFloatPercentAll(ModType.MaxDamage, SourceType.NONE));
}
// set damages
if (mainHand) {
this.minDamageHandOne = (short) minDamage;
this.maxDamageHandOne = (short) maxDamage;
this.speedHandOne = 30;
} else {
this.minDamageHandTwo = (short) minDamage;
this.maxDamageHandTwo = (short) maxDamage;
this.speedHandTwo = 30;
}
}
private void defaultAtrAndDamage(boolean mainHand) {
if (mainHand) {
this.atrHandOne = 0;
this.minDamageHandOne = 0;
this.maxDamageHandOne = 0;
this.rangeHandOne = -1;
this.speedHandOne = 20;
} else {
this.atrHandTwo = 0;
this.minDamageHandTwo = 0;
this.maxDamageHandTwo = 0;
this.rangeHandTwo = -1;
this.speedHandTwo = 20;
}
}
@Override
public void runAfterLoad() {