Skip to content

Commit 2982901

Browse files
authored
Fix penetration calculations (#390)
1 parent 834ea4b commit 2982901

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/Modules/CalcBreakdown.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ function breakdown.effMult(damageType, resist, pen, taken, mult, takenMore, sour
132132
if not useRes then
133133
t_insert(out, s_format("x %d%% ^8(resistance ignored)", 0))
134134
t_insert(out, s_format("= %d%%", (0)))
135+
elseif resist <= 0 then
136+
t_insert(out, s_format("= %d%% ^8(negative resistance unaffected by penetration)", resist))
135137
elseif (resist - pen) < 0 then
136138
t_insert(out, s_format("= %d%% ^8(penetration cannot bring resistances below 0)", 0))
137139
else

src/Modules/CalcDefence.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ function calcs.buildDefenceEstimations(env, actor)
19721972
local impaleArmourReduct = 0
19731973
local percentOfArmourApplies = m_min((not modDB:Flag(nil, "ArmourDoesNotApplyTo"..damageType.."DamageTaken") and modDB:Sum("BASE", nil, "ArmourAppliesTo"..damageType.."DamageTaken") or 0), 100)
19741974
local effectiveAppliedArmour = (output.Armour * percentOfArmourApplies / 100) * (1 + output.ArmourDefense)
1975-
local resMult = 1 - (resist - enemyPen) / 100
1975+
local resMult = 1 - (resist > 0 and m_max(resist - enemyPen, 0) or resist) / 100
19761976
local reductMult = 1
19771977
local takenFlat = modDB:Sum("BASE", nil, "DamageTaken", damageType.."DamageTaken", "DamageTakenWhenHit", damageType.."DamageTakenWhenHit")
19781978
if damageCategoryConfig == "Melee" or damageCategoryConfig == "Projectile" then
@@ -2068,7 +2068,11 @@ function calcs.buildDefenceEstimations(env, actor)
20682068
if enemyPen ~= 0 then
20692069
t_insert(breakdown[damageType.."TakenHitMult"], s_format("+ Enemy Pen: %.2f", enemyPen / 100))
20702070
end
2071-
if resist ~= 0 and enemyPen ~= 0 then
2071+
if resist <= 0 and enemyPen ~=0 then
2072+
t_insert(breakdown[damageType.."TakenHitMult"], s_format("= %.2f ^8(Negative resistance unaffected by penetration)", resMult))
2073+
elseif (resist - enemyPen) < 0 then
2074+
t_insert(breakdown[damageType.."TakenHitMult"], s_format("= %.2f ^8(Penetration cannot bring resistances below 0)", resMult))
2075+
elseif resist ~= 0 then
20722076
t_insert(breakdown[damageType.."TakenHitMult"], s_format("= %.2f", resMult))
20732077
end
20742078
if resMult ~= 1 and reductMult ~= 1 then

src/Modules/CalcOffence.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,7 +3183,7 @@ function calcs.offence(env, actor, activeSkill)
31833183
resist = resist > 0 and resist * (1 - (skillModList:Sum("BASE", nil, "PartialIgnoreEnemyPhysicalDamageReduction") / 100 + ChanceToIgnoreEnemyPhysicalDamageReduction / 100)) or resist
31843184
end
31853185
else
3186-
resist = calcResistForType(damageType, dotCfg)
3186+
resist = calcResistForType(damageType, cfg)
31873187
if ((skillModList:Flag(cfg, "ChaosDamageUsesLowestResistance") or skillModList:Flag(cfg, "ChaosDamageUsesHighestResistance")) and damageType == "Chaos") or
31883188
(skillModList:Flag(cfg, "ElementalDamageUsesLowestResistance") and isElemental[damageType]) then
31893189
-- Default to using the current damage type
@@ -3194,7 +3194,7 @@ function calcs.offence(env, actor, activeSkill)
31943194
-- Find the lowest resist of all the elements and use that if it's lower
31953195
for _, eleDamageType in ipairs(dmgTypeList) do
31963196
if isElemental[eleDamageType] and useThisResist(eleDamageType) and damageType ~= eleDamageType then
3197-
local currentElementResist = calcResistForType(eleDamageType, dotCfg)
3197+
local currentElementResist = calcResistForType(eleDamageType, cfg)
31983198
-- If it's explicitly lower, then use the resist and update which element we're using to account for penetration
31993199
if skillModList:Flag(cfg, "ChaosDamageUsesHighestResistance") then
32003200
if resist < currentElementResist then
@@ -3244,7 +3244,7 @@ function calcs.offence(env, actor, activeSkill)
32443244
if skillModList:Flag(cfg, isElemental[damageType] and "CannotElePenIgnore" or nil) then
32453245
effMult = effMult * (1 - resist / 100)
32463246
elseif useRes then
3247-
effMult = effMult * (1 - (m_max(resist - pen, 0)) / 100)
3247+
effMult = effMult * (1 - (resist > 0 and m_max(resist - pen, 0) or resist) / 100)
32483248
end
32493249
damageTypeHitMin = damageTypeHitMin * effMult
32503250
damageTypeHitMax = damageTypeHitMax * effMult

0 commit comments

Comments
 (0)