Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions spec/System/TestDefence_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1723,4 +1723,32 @@ describe("TestDefence", function()
assertClose(block.EffectiveBlockChance, 10)
assert.is_true(block.TotalEHP > base.TotalEHP)
end)

it("does not lower EHP with life gained on block when resistance increases", function()
local function calcEHP(coldResist)
newBuild()
build.configTab.input.enemyDamageType = "Melee"
build.configTab.input.enemyPhysicalDamage = "0"
build.configTab.input.enemyFireDamage = "0"
build.configTab.input.enemyColdDamage = "600"
build.configTab.input.enemyLightningDamage = "0"
build.configTab.input.enemyChaosDamage = "0"
build.configTab.input.customMods = [[
+1000 to maximum Life
+75% chance to Block Attack Damage
+100 Life gained when you Block
]] .. "+" .. coldResist .. "% to Cold Resistance\n"
build.configTab:BuildModList()
runCallback("OnFrame")
return build.calcsTab.calcsOutput.TotalEHP
end

local lowerResistEHP = calcEHP(30)
local higherResistEHP = calcEHP(33)

newBuild()

assert.is_true(higherResistEHP >= lowerResistEHP,
string.format("EHP fell from %.1f to %.1f", lowerResistEHP, higherResistEHP))
end)
end)
4 changes: 2 additions & 2 deletions src/Modules/CalcDefence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2702,10 +2702,10 @@ function calcs.buildDefenceEstimations(env, actor)
poolTable.EnergyShield = m_min(poolTable.EnergyShield + DamageIn.EnergyShieldWhenHit * (gainMult - 1), gainMult * output.EnergyShieldRecoveryCap)
end
end
if DamageIn.MissingLifeBeforeEnemyHit and poolTable.Life > 0 then
if (DamageIn.MissingLifeBeforeEnemyHit or 0) ~= 0 and poolTable.Life > 0 then
poolTable.Life = m_min(poolTable.Life + DamageIn.MissingLifeBeforeEnemyHit * ((output.LifeUnreserved or 0) - poolTable.Life) / 100, output.LifeRecoverable or 0)
end
if DamageIn.MissingManaBeforeEnemyHit and poolTable.Mana > 0 then
if (DamageIn.MissingManaBeforeEnemyHit or 0) ~= 0 and poolTable.Mana > 0 then
poolTable.Mana = m_min(poolTable.Mana + DamageIn.MissingManaBeforeEnemyHit * ((output.ManaUnreserved or 0) - poolTable.Mana) / 100, output.ManaUnreserved or 0)
end
poolTable = calcs.reducePoolsByDamage(poolTable, Damage, actor)
Expand Down
Loading