diff --git a/src/Modules/CalcDefence.lua b/src/Modules/CalcDefence.lua index b56662e2eb..d03bd8a9ed 100644 --- a/src/Modules/CalcDefence.lua +++ b/src/Modules/CalcDefence.lua @@ -1166,6 +1166,30 @@ function calcs.buildDefenceEstimations(env, actor) local condList = modDB.conditions + local damageCategoryConfig = env.configInput.enemyDamageType or "Average" + + -- chance to not be hit calculations + do + local worstOf = env.configInput.EHPUnluckyWorstOf or 1 + output.MeleeNotHitChance = 100 - (1 - output.MeleeEvadeChance / 100) * (1 - output.AttackDodgeChance / 100) * (1 - output.AvoidAllDamageFromHitsChance / 100) * 100 + output.ProjectileNotHitChance = 100 - (1 - output.ProjectileEvadeChance / 100) * (1 - output.AttackDodgeChance / 100) * (1 - output.AvoidAllDamageFromHitsChance / 100) * (1 - (output.specificTypeAvoidance and 0 or output.AvoidProjectilesChance) / 100) * 100 + output.SpellNotHitChance = 100 - (1 - output.SpellDodgeChance / 100) * (1 - output.AvoidAllDamageFromHitsChance / 100) * 100 + output.SpellProjectileNotHitChance = 100 - (1 - output.SpellDodgeChance / 100) * (1 - output.AvoidAllDamageFromHitsChance / 100) * (1 - (output.specificTypeAvoidance and 0 or output.AvoidProjectilesChance) / 100) * 100 + output.AverageNotHitChance = (output.MeleeNotHitChance + output.ProjectileNotHitChance + output.SpellNotHitChance + output.SpellProjectileNotHitChance) / 4 + output.AverageEvadeChance = (output.MeleeEvadeChance + output.ProjectileEvadeChance) / 4 + output.ConfiguredNotHitChance = output[damageCategoryConfig.."NotHitChance"] + output.ConfiguredEvadeChance = output[damageCategoryConfig.."EvadeChance"] or 0 + -- unlucky config to lower the value of block, dodge, evade etc for ehp + if worstOf > 1 then + output.ConfiguredNotHitChance = output.ConfiguredNotHitChance / 100 * output.ConfiguredNotHitChance + output.ConfiguredEvadeChance = output.ConfiguredEvadeChance / 100 * output.ConfiguredEvadeChance + if worstOf == 4 then + output.ConfiguredNotHitChance = output.ConfiguredNotHitChance / 100 * output.ConfiguredNotHitChance + output.ConfiguredEvadeChance = output.ConfiguredEvadeChance / 100 * output.ConfiguredEvadeChance + end + end + end + --Enemy damage input and modifications do output["totalEnemyDamage"] = 0 @@ -1184,7 +1208,7 @@ function calcs.buildDefenceEstimations(env, actor) }, } end - local enemyCritChance = m_max(m_min((modDB:Override(nil, "enemyCritChance") or env.configInput["enemyCritChance"] or env.configPlaceholder["enemyCritChance"] or 0) * (1 + modDB:Sum("INC", nil, "EnemyCritChance") / 100 + enemyDB:Sum("INC", nil, "CritChance") / 100), 100), 0) + local enemyCritChance = m_max(m_min((modDB:Override(nil, "enemyCritChance") or env.configInput["enemyCritChance"] or env.configPlaceholder["enemyCritChance"] or 0) * (1 + modDB:Sum("INC", nil, "EnemyCritChance") / 100 + enemyDB:Sum("INC", nil, "CritChance") / 100) * (1 - output["ConfiguredEvadeChance"] / 100), 100), 0) local enemyCritDamage = m_max((env.configInput["enemyCritDamage"] or env.configPlaceholder["enemyCritDamage"] or 0) + enemyDB:Sum("BASE", nil, "CritMultiplier"), 0) output["EnemyCritEffect"] = 1 + enemyCritChance / 100 * (enemyCritDamage / 100) * (1 - output.CritExtraDamageReduction / 100) local enemyCfg = {keywordFlags = bit.bnot(KeywordFlag.MatchAll)} -- Match all keywordFlags parameter for enemy min-max damage mods @@ -1313,7 +1337,6 @@ function calcs.buildDefenceEstimations(env, actor) -- Damage taken multipliers/Degen calculations output.AnyTakenReflect = false - local damageCategoryConfig = env.configInput.enemyDamageType or "Average" for _, damageType in ipairs(dmgTypeList) do local baseTakenInc = modDB:Sum("INC", nil, "DamageTaken", damageType.."DamageTaken") local baseTakenMore = modDB:More(nil, "DamageTaken", damageType.."DamageTaken") @@ -2199,22 +2222,9 @@ function calcs.buildDefenceEstimations(env, actor) end end - -- chance to not be hit + -- chance to not be hit breakdown do local worstOf = env.configInput.EHPUnluckyWorstOf or 1 - output.MeleeNotHitChance = 100 - (1 - output.MeleeEvadeChance / 100) * (1 - output.AttackDodgeChance / 100) * (1 - output.AvoidAllDamageFromHitsChance / 100) * 100 - output.ProjectileNotHitChance = 100 - (1 - output.ProjectileEvadeChance / 100) * (1 - output.AttackDodgeChance / 100) * (1 - output.AvoidAllDamageFromHitsChance / 100) * (1 - (output.specificTypeAvoidance and 0 or output.AvoidProjectilesChance) / 100) * 100 - output.SpellNotHitChance = 100 - (1 - output.SpellDodgeChance / 100) * (1 - output.AvoidAllDamageFromHitsChance / 100) * 100 - output.SpellProjectileNotHitChance = 100 - (1 - output.SpellDodgeChance / 100) * (1 - output.AvoidAllDamageFromHitsChance / 100) * (1 - (output.specificTypeAvoidance and 0 or output.AvoidProjectilesChance) / 100) * 100 - output.AverageNotHitChance = (output.MeleeNotHitChance + output.ProjectileNotHitChance + output.SpellNotHitChance + output.SpellProjectileNotHitChance) / 4 - output.ConfiguredNotHitChance = output[damageCategoryConfig.."NotHitChance"] - -- unlucky config to lower the value of block, dodge, evade etc for ehp - if worstOf > 1 then - output.ConfiguredNotHitChance = output.ConfiguredNotHitChance / 100 * output.ConfiguredNotHitChance - if worstOf == 4 then - output.ConfiguredNotHitChance = output.ConfiguredNotHitChance / 100 * output.ConfiguredNotHitChance - end - end output["TotalNumberOfHits"] = output["NumberOfMitigatedDamagingHits"] / (1 - output["ConfiguredNotHitChance"] / 100) if breakdown then breakdown.ConfiguredNotHitChance = { }