Skip to content

Commit 6bb623b

Browse files
github-actions[bot]unrealdreamzLocalIdentity
authored
[pob2-port] Fix eHP value decreasing when allocating defence nodes (#9867)
* Apply changes from PathOfBuildingCommunity/PathOfBuilding-PoE2#1929 * Fix merge * Fix test * Fix test --------- Co-authored-by: unrealdreamz <unrealdreamz@users.noreply.github.com> Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent c730455 commit 6bb623b

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

spec/System/TestDefence_spec.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,4 +1283,46 @@ describe("TestDefence", function()
12831283
assert.are.equals(0, floor(poolsRemaining.Life))
12841284
assert.are.equals(0, floor(poolsRemaining.OverkillDamage))
12851285
end)
1286+
1287+
it("limits EHP speedup when hit damage is delayed", function()
1288+
local function assertClose(actual, expected)
1289+
assert.is_true(math.abs(actual - expected) < 0.01,
1290+
string.format("expected %.12f, got %.12f", expected, actual))
1291+
end
1292+
1293+
local function calcEHP(extraMods)
1294+
newBuild()
1295+
build.configTab.input.enemyPhysicalDamage = "500"
1296+
build.configTab.input.enemyFireDamage = "500"
1297+
build.configTab.input.enemyColdDamage = "500"
1298+
build.configTab.input.enemyLightningDamage = "500"
1299+
build.configTab.input.enemyChaosDamage = "0"
1300+
build.configTab.input.conditionUsingFlask = true
1301+
build.configTab.input.customMods = [[
1302+
+4000 to maximum Life
1303+
When Hit during effect, 75% of Life loss from Damage taken occurs over 4 seconds instead
1304+
+75% to all Elemental Resistances
1305+
+75% to Chaos Resistance
1306+
]] .. (extraMods or "")
1307+
build.configTab:BuildModList()
1308+
runCallback("OnFrame")
1309+
runCallback("OnFrame")
1310+
local calcsOutput = build.calcsTab.calcsOutput
1311+
return {
1312+
TotalEHP = calcsOutput.TotalEHP,
1313+
EffectiveBlockChance = calcsOutput.EffectiveBlockChance,
1314+
NumberOfMitigatedDamagingHits = calcsOutput.NumberOfMitigatedDamagingHits,
1315+
}
1316+
end
1317+
1318+
local base = calcEHP()
1319+
local block = calcEHP("\n+10% to Block chance\n")
1320+
1321+
newBuild()
1322+
1323+
assertClose(base.TotalEHP, 17570.183511070)
1324+
assertClose(block.TotalEHP, 18488.832919738)
1325+
assertClose(block.EffectiveBlockChance, 10)
1326+
assert.is_true(block.TotalEHP > base.TotalEHP)
1327+
end)
12861328
end)

src/Modules/CalcDefence.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2681,14 +2681,17 @@ function calcs.buildDefenceEstimations(env, actor)
26812681
end
26822682
iterationMultiplier = 1
26832683
-- to speed it up, run recursively but accelerated
2684-
local speedUp = data.misc.ehpCalcSpeedUp
2684+
-- MoM/life-loss-prevention mechanics can collapse too many hits into one
2685+
-- resulting in eHP jumps so we slow the acceleration.
2686+
local speedUp = DamageIn["LimitEHPSpeedup"] and 4 or data.misc.ehpCalcSpeedUp
26852687
DamageIn["cyclesRan"] = DamageIn["cyclesRan"] or false
26862688
local wardAvoidBreakActive = wardAvoidBreakChance < 1 and (poolTable.WardActiveChance or 0) > 0.01
26872689
if not DamageIn["cyclesRan"] and not wardAvoidBreakActive and poolTable.Life > 0 and DamageIn["iterations"] < maxIterations then
26882690
Damage = { }
26892691
for _, damageType in ipairs(dmgTypeList) do
26902692
Damage[damageType] = DamageIn[damageType] * speedUp
26912693
end
2694+
Damage["LimitEHPSpeedup"] = DamageIn["LimitEHPSpeedup"]
26922695
if DamageIn.GainWhenHit then
26932696
Damage.GainWhenHit = true
26942697
Damage.LifeWhenHit = DamageIn.LifeWhenHit
@@ -2740,6 +2743,7 @@ function calcs.buildDefenceEstimations(env, actor)
27402743
for _, damageType in ipairs(dmgTypeList) do
27412744
DamageIn[damageType] = output[damageType.."TakenHit"]
27422745
end
2746+
DamageIn["LimitEHPSpeedup"] = output["preventedLifeLossTotal"] > 0
27432747
output["NumberOfDamagingHits"] = numberOfHitsToDie(DamageIn)
27442748
end
27452749

@@ -2834,6 +2838,7 @@ function calcs.buildDefenceEstimations(env, actor)
28342838
output["LifeLossLostOverTime"] = 0
28352839
output["LifeBelowHalfLossLostOverTime"] = 0
28362840
end
2841+
DamageIn["LimitEHPSpeedup"] = DamageIn["TrackRecoupable"] or DamageIn["TrackLifeLossOverTime"] or DamageIn.GainWhenHit
28372842
averageAvoidChance = averageAvoidChance / 5
28382843
output["ConfiguredDamageChance"] = 100 * (blockEffect * suppressionEffect * (1 - averageAvoidChance / 100))
28392844
output["NumberOfMitigatedDamagingHits"] = (output["ConfiguredDamageChance"] ~= 100 or DamageIn["TrackRecoupable"] or DamageIn["TrackLifeLossOverTime"] or DamageIn.GainWhenHit) and numberOfHitsToDie(DamageIn) or output["NumberOfDamagingHits"]

0 commit comments

Comments
 (0)