Skip to content

Fix EHP falling with life gained on block when defences increase - #10382

Open
mcagnion wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
mcagnion:bugfix/ehp-gain-on-block-clamp
Open

mcagnion wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
mcagnion:bugfix/ehp-gain-on-block-clamp

Conversation

@mcagnion

@mcagnion mcagnion commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9446.

Description of the problem being solved:

With life gained on block (or other gain when hit), adding life or resistance could lower Total EHP.

To speed up the hit count, numberOfHitsToDie applies several hits at once after crediting their gains. The Defiance of Destiny recovery is guarded by if DamageIn.MissingLifeBeforeEnemyHit, but that value is a modDB:Sum, so it is 0 rather than nil without Defiance of Destiny, and 0 is truthy in Lua. The block therefore ran for every build and clamped Life back to its maximum, discarding the credited gains. It now only runs for a non-zero value (same for mana), like the nearby LifeWhenHit checks.

Steps taken to verify a working solution:

  • New TestDefence spec: with life gained on block, Total EHP must not drop when Cold Resistance goes from 30% to 33%. Before: 4622 -> 3812, after: 4687 -> 5030.
  • Build from EHP calculation for mitigated hits with life gain on block is incorrect #9446 on v2.60.0: allocating Discipline and Training took Total EHP from 124718 to 117909. With this change: 147006 to 161611.
  • Compared with the same calculation done hit by hit, results are now within 0.5% on the test case and 6% on the issue build, where they were up to 47% too low.

Before screenshot:

before-ehp-cold-33

After screenshot:

after-ehp-cold-33

The per-hit "missing life/mana before enemy hit" recovery for Defiance of
Destiny checked its value by truthiness, but the value is a modDB sum and is
0 for every other build. Since 0 is truthy in Lua, the block ran on every
iteration and clamped Life back to its maximum, discarding the life gained on
block that the EHP speed-up had just credited for the batched hits. Lowering
damage taken could then enlarge the batch, discard more gains and reduce the
number of hits survived, so more resistance or life gave less EHP
(issue 9446).

Only apply the recovery when the value is non-zero, as the nearby
LifeWhenHit checks already do. Defiance of Destiny keeps its behaviour.
@mcagnion
mcagnion marked this pull request as ready for review October 7, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EHP calculation for mitigated hits with life gain on block is incorrect

1 participant