diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index d9966ae8..c77975f8 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -29,6 +29,8 @@ import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; +import static java.lang.Math.pow; + public enum CombatManager { @@ -228,8 +230,8 @@ public enum CombatManager { } } - // take stamina away from attacker - if (weapon != null) { + // take stamina away from attacker if its not a mob + if (weapon != null && !attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) { //check if Out of Stamina if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { if (attacker.getStamina() < (weapon.template.item_wt / 3f)) { @@ -341,6 +343,9 @@ public enum CombatManager { setAutoAttackJob(attacker, slot, delay); return; } + if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob)attacker).isPet()) + calculatePetDamage(attacker); + //get the damage type mbEnums.DamageType damageType; @@ -606,4 +611,32 @@ public enum CombatManager { Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); } + public static int calculatePetDamage(AbstractCharacter agent) { + //damage calc for pet + float range; + float damage; + float min = 40; + float max = 60; + float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(mbEnums.ModType.MeleeDamageModifier, mbEnums.SourceType.None); + double minDmg = getMinDmg(min, agent); + double maxDmg = getMaxDmg(max, agent); + 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 double getMinDmg(double min, AbstractCharacter agent) { + int primary = agent.getStatStrCurrent(); + int secondary = agent.getStatDexCurrent(); + int focusLevel = 0; + int masteryLevel = 0; + 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, AbstractCharacter agent) { + int primary = agent.getStatStrCurrent(); + int secondary = agent.getStatDexCurrent(); + int focusLevel = 0; + int masteryLevel = 0; + 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)); + } } \ No newline at end of file