Skip to content

Commit 59c2f95

Browse files
committed
No deflect at 0 rating and DR at 100%
1 parent 4226baa commit 59c2f95

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/Modules/CalcDefence.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ function calcs.hitChance(evasion, accuracy, uncapped)
3737
end
3838
-- Calculate Deflect chance
3939
function calcs.deflectChance(deflection, accuracy)
40+
if deflection < 1 then
41+
return 0
42+
end
4043
local rawChance = ( accuracy * 0.9 ) / ( accuracy + deflection * 0.2 ) * 100
4144
return 100 - m_max(m_min(round(rawChance), 100), 0)
4245
end
@@ -2358,15 +2361,16 @@ function calcs.buildDefenceEstimations(env, actor)
23582361
takenMult = (output[damageType.."SpellTakenHitMult"] + output[damageType.."AttackTakenHitMult"]) / 2
23592362
spellSuppressMult = output.EffectiveSpellSuppressionChance == 100 and (1 - output.SpellSuppressionEffect / 100 / 2) or 1
23602363
end
2364+
local deflectMulti = output.DeflectChance == 100 and (1 - output.DeflectEffect / 100) or 1
23612365
output[damageType.."EffectiveAppliedArmour"] = effectiveAppliedArmour
23622366
output[damageType.."ResistTakenHitMulti"] = resMult
2363-
local afterReductionMulti = takenMult * spellSuppressMult
2367+
local afterReductionMulti = takenMult * spellSuppressMult * deflectMulti
23642368
output[damageType.."AfterReductionTakenHitMulti"] = afterReductionMulti
23652369
local baseMult = resMult * reductMult
23662370
output[damageType.."BaseTakenHitMult"] = baseMult * afterReductionMulti
23672371
local takenMultReflect = output[damageType.."TakenReflect"]
23682372
local finalReflect = baseMult * takenMultReflect
2369-
output[damageType.."TakenHit"] = m_max(damage * baseMult + takenFlat, 0) * takenMult * spellSuppressMult + impaleDamage
2373+
output[damageType.."TakenHit"] = m_max(damage * baseMult + takenFlat, 0) * afterReductionMulti + impaleDamage
23702374
output[damageType.."TakenHitMult"] = (damage > 0) and (output[damageType.."TakenHit"] / damage) or 0
23712375
output["totalTakenHit"] = output["totalTakenHit"] + output[damageType.."TakenHit"]
23722376
if output.AnyTakenReflect then
@@ -2426,10 +2430,13 @@ function calcs.buildDefenceEstimations(env, actor)
24262430
if spellSuppressMult ~= 1 then
24272431
t_insert(breakdown[damageType.."TakenHitMult"], s_format("x Spell Suppression: %.3f", spellSuppressMult))
24282432
end
2433+
if deflectMulti ~= 1 then
2434+
t_insert(breakdown[damageType.."TakenHitMult"], s_format("x Deflection: %.3f", deflectMulti))
2435+
end
24292436
if impaleDamage ~= 0 then
24302437
t_insert(breakdown[damageType.."TakenHitMult"], s_format("+ Impale: %.1f", impaleDamage))
24312438
end
2432-
if takenMult ~= 1 or takenFlat ~= 0 or spellSuppressMult ~= 1 or impaleDamage ~= 0 then
2439+
if takenFlat ~= 0 or afterReductionMulti ~= 1 or impaleDamage ~= 0 then
24332440
t_insert(breakdown[damageType.."TakenHitMult"], s_format("= %.3f", output[damageType.."TakenHitMult"]))
24342441
end
24352442
if output.AnyTakenReflect then
@@ -3107,7 +3114,7 @@ function calcs.buildDefenceEstimations(env, actor)
31073114
DamageIn.EnergyShieldWhenHit = (DamageIn.EnergyShieldWhenHit or 0) + output.EnergyShieldOnSuppress * ( damageCategoryConfig == "Average" and 0.5 or 1 )
31083115
DamageIn.LifeWhenHit = (DamageIn.LifeWhenHit or 0) + output.LifeOnSuppress * ( damageCategoryConfig == "Average" and 0.5 or 1 )
31093116
end
3110-
local effectiveDeflectMulti = 1 - output.DeflectChance * output.DeflectEffect / 10000
3117+
local effectiveDeflectMulti = output.DeflectChance < 100 and 1 - output.DeflectChance * output.DeflectEffect / 10000 or 1
31113118
-- extra avoid chance
31123119
if damageCategoryConfig == "Projectile" or damageCategoryConfig == "SpellProjectile" then
31133120
ExtraAvoidChance = ExtraAvoidChance + output.AvoidProjectilesChance

0 commit comments

Comments
 (0)