From 5192c801f73120f8ef50f15a80ed72f0f7288936 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 9 Sep 2023 20:56:19 -0500 Subject: [PATCH] CombatUtilities cleanup --- .../mobileAI/utilities/CombatUtilities.java | 187 ++---------------- 1 file changed, 13 insertions(+), 174 deletions(-) diff --git a/src/engine/mobileAI/utilities/CombatUtilities.java b/src/engine/mobileAI/utilities/CombatUtilities.java index 3a0c0634..666f7471 100644 --- a/src/engine/mobileAI/utilities/CombatUtilities.java +++ b/src/engine/mobileAI/utilities/CombatUtilities.java @@ -264,19 +264,9 @@ public class CombatUtilities { swingIsBlock(agent, target, passiveAnim); return; } - if (agent.getEquip().get(1) != null && agent.getEquip().get(2) != null && agent.getEquip().get(2).getItemBase().isShield() == false) { - //mob is duel wielding and should conduct an attack for each hand - ItemBase weapon1 = agent.getEquip().get(1).getItemBase(); - double range1 = getMaxDmg(weapon1.getMinDamage(), agent, weapon1) - getMinDmg(weapon1.getMinDamage(), agent, weapon1); - double damage1 = getMinDmg(weapon1.getMinDamage(), agent, weapon1) + ((ThreadLocalRandom.current().nextFloat() * range1) + (ThreadLocalRandom.current().nextFloat() * range1)) / 2; - swingIsDamage(agent, target, (float) damage1, CombatManager.getSwingAnimation(weapon1, null, true)); - ItemBase weapon2 = agent.getEquip().get(2).getItemBase(); - double range2 = getMaxDmg(weapon2.getMinDamage(), agent, weapon2) - getMinDmg(weapon2.getMinDamage(), agent, weapon2); - double damage2 = getMinDmg(weapon2.getMinDamage(), agent, weapon2) + ((ThreadLocalRandom.current().nextFloat() * range2) + (ThreadLocalRandom.current().nextFloat() * range2)) / 2; - swingIsDamage(agent, target, (float) damage2, CombatManager.getSwingAnimation(weapon1, null, false)); - } else { - swingIsDamage(agent, target, determineDamage(agent), anim); - } + + swingIsDamage(agent, target, determineDamage(agent), anim); + if (agent.getWeaponPower() != null) agent.getWeaponPower().attack(target, MBServerStatics.ONE_MINUTE); @@ -319,19 +309,10 @@ public class CombatUtilities { if (target == null) return 0; - float damage = 0; + int damage = 0; DamageType dt = getDamageType(agent); - if ((agent.agentType.equals(AIAgentType.PET)) == true || agent.isPet() == true || agent.isNecroPet() == true) { - damage = calculatePetDamage(agent); - } else if (agent.isPlayerGuard() == true) { - //damage = calculateGuardDamage(agent); - damage = calculateMobDamage(agent); - } else if (agent.getLevel() > 80) { - damage = calculateEpicDamage(agent); - } else { - damage = calculateMobDamage(agent); - } + damage = ThreadLocalRandom.current().nextInt((int)getMinDmg(agent), (int)getMaxDmg(agent) + 1); if (AbstractWorldObject.IsAbstractCharacter(target)) { if (((AbstractCharacter) target).isSit()) { damage *= 2.5f; //increase damage if sitting @@ -357,158 +338,16 @@ public class CombatUtilities { return dt; } - public static int calculatePetDamage(Mob agent) { - //damage calc for pet - float range; - float damage; - float min = 40; - float max = 60; - float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None); - double minDmg = getMinDmg(min, agent, null); - double maxDmg = getMaxDmg(max, agent, null); - dmgMultiplier += agent.getLevel() * 0.1f; - range = (float) (maxDmg - minDmg); - damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; - return (int) (damage * dmgMultiplier); - } - - public static int calculateGuardDamage(Mob agent) { - //damage calc for guard - ItemBase weapon = agent.getEquip().get(1).getItemBase(); - AbstractWorldObject target = agent.getCombatTarget(); - - float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None); - - double minDmg = weapon.getMinDamage(); - double maxDmg = weapon.getMaxDamage(); - double min = getMinDmg(minDmg, agent, weapon); - double max = getMaxDmg(maxDmg, agent, weapon); - - DamageType dt = weapon.getDamageType(); - - double range = max - min; - double damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; - - if (AbstractWorldObject.IsAbstractCharacter(target)) - if (((AbstractCharacter) target).isSit()) - damage *= 2.5f; //increase damage if sitting - if (AbstractWorldObject.IsAbstractCharacter(target)) - return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0) * dmgMultiplier); - return 0; - } - - public static int calculateEpicDamage(Mob agent) { - //handle r8 mob damage - DamageType dt = DamageType.Crush; - AbstractWorldObject target = agent.getCombatTarget(); - float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None); - double min = agent.getMinDamageHandOne(); - double max = agent.getMaxDamageHandOne(); - if (agent.getEquip().get(1) != null) { - if (agent.getEquip().get(1).getItemBase() != null) { - dt = agent.getEquip().get(1).getItemBase().getDamageType(); - min = agent.getMinDamageHandOne(); - max = agent.getMaxDamageHandOne(); - } else if (agent.getEquip().get(2).getItemBase() != null && agent.getEquip().get(2).getItemBase().isShield() == false) { - dt = agent.getEquip().get(2).getItemBase().getDamageType(); - min = agent.getMinDamageHandTwo(); - max = agent.getMaxDamageHandTwo(); - } - } - - - double range = max - min; - double damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; - return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0) * dmgMultiplier); - } - - public static int calculateMobDamage(Mob agent) { - ItemBase weapon = null; - double minDmg; - double maxDmg; - DamageType dt; - - //main hand or offhand damage - - if (agent.getEquip().get(1) != null) - weapon = agent.getEquip().get(1).getItemBase(); - else if (agent.getEquip().get(2) != null) - weapon = agent.getEquip().get(2).getItemBase(); - - if (weapon != null) { - minDmg = getMinDmg(weapon.getMinDamage(), agent, weapon); - maxDmg = getMaxDmg(weapon.getMaxDamage(), agent, weapon); - dt = weapon.getDamageType(); - } else { - minDmg = agent.getMobBase().getDamageMin(); - maxDmg = agent.getMobBase().getDamageMax(); - dt = DamageType.Crush; - } - - AbstractWorldObject target = agent.getCombatTarget(); - - float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None); - double range = maxDmg - minDmg; - double damage = minDmg + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; - - if (AbstractWorldObject.IsAbstractCharacter(target)) - if (((AbstractCharacter) target).isSit()) - damage *= 2.5f; //increase damage if sitting - if (AbstractWorldObject.IsAbstractCharacter(target)) - return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0) * dmgMultiplier); - return 0; + public static double getMinDmg(Mob agent) { + if(agent.equip.get(2) != null && !agent.equip.get(2).getItemBase().isShield()) + return agent.minDamageHandTwo; + else return agent.minDamageHandOne; } - public static double getMinDmg(double min, Mob agent, ItemBase weapon) { - - int primary = agent.getStatStrCurrent(); - int secondary = agent.getStatDexCurrent(); - int focusLevel = 0; - int masteryLevel = 0; - - if (weapon != null) { - if (weapon.isStrBased() == true) { - primary = agent.getStatStrCurrent(); - secondary = agent.getStatDexCurrent(); - } else { - primary = agent.getStatDexCurrent(); - secondary = agent.getStatStrCurrent(); - if (agent.getSkills().containsKey(weapon.getSkillRequired())) { - focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount(); - } - if (agent.getSkills().containsKey(weapon.getMastery())) { - masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount(); - } - } - } - return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel)); - } - - public static double getMaxDmg(double max, Mob agent, ItemBase weapon) { - - int primary = agent.getStatStrCurrent(); - int secondary = agent.getStatDexCurrent(); - int focusLevel = 0; - int masteryLevel = 0; - - if (weapon != null) { - - if (weapon.isStrBased() == true) { - primary = agent.getStatStrCurrent(); - secondary = agent.getStatDexCurrent(); - } else { - primary = agent.getStatDexCurrent(); - secondary = agent.getStatStrCurrent(); - } - - if (agent.getSkills().containsKey(weapon.getSkillRequired())) - focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount(); - - if (agent.getSkills().containsKey(weapon.getSkillRequired())) - masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount(); - - } - return max * (pow(0.0124 * primary + 0.118 * (primary - 0.75), 0.5) + pow(0.0022 * secondary + 0.028 * (secondary - 0.75), 0.5) + 0.0075 * (focusLevel + masteryLevel)); + public static double getMaxDmg(Mob agent) { + if(agent.equip.get(2) != null && !agent.equip.get(2).getItemBase().isShield()) + return agent.maxDamageHandTwo; + else return agent.maxDamageHandOne; } }