Improve EHP overkill approximation, especially for MoM
Description of the problem being solved:
I was seeing strange breakpoints in my EHP. Normally, increasing my spell block chance by 1% would increase my EHP by <1%, but at certain breakpoints, a 1% spell block increase would cause an 8.8% EHP increase.
Checking the breakdown, I saw that my "mitigated hits" went from 5.99 to 6.52 at this spurious breakpoint.
Examining the function numberOfHitsToDie, specifically the part that adds back overkill as a fractional number of hits, I found the reason for this. The correction it performs is:
numHits = numHits + poolTable.Life / damageTotal
where poolTable.Life is the negative amount of life after the overkill, and damageTotal is the total damage of the last hit.
However, my character has 50% MoM and significantly more mana than life. Therefore, on the overkill hit, 50% of the damage goes to mana. Now supposing I have almost 0 life right before the overkill hit, poolTable.Life / damageTotal would be roughly -0.50, which is not correct. The intended correction should be closer to -1.
So with my 50% MoM setup, under the current calculation, the # of mitigated hits will never be able to have a fractional part between 0 and 0.5, which is clearly wrong. I will keep seeing these spurious breakpoints - the # of mitigated hits will jump from 5.99 to 6.5, then increase smoothly to 6.99 before it jumps to 7.5, etc.
My PR changes this correction to instead be:
numHits = numHits + poolTable.Life / (lastPositiveLife - poolTable.Life)
This is still an approximation and not fully accurate, but it should be a lot better than the previous calculation.
Steps taken to verify a working solution:
- After the change, # mitigated hits is 5.97 before the breakpoint -> 6.02 after the breakpoint.
Link to a build that showcases this PR:
https://pobb.in/lHDoriHjsnvz In custom modifiers I have: +5% chance to block spell damage Before the fix, changing this to +6% triggers the spurious breakpoint (mitigated hits 5.99 -> 6.52, EHP 88085 -> 95910)
Before screenshot:
With +5% chance to block spell damage:
With +6% chance to block spell damage:
After screenshot:
With +5% chance to block spell damage:
With +6% chance to block spell damage: