PathOfBuildingCommunity / PathOfBuilding

Offline build planner for Path of Exile.
https://pathofbuilding.community
Other
3.63k stars 2k forks source link

Improve EHP overkill approximation, especially for MoM #7568

Open 0xjc opened 2 months ago

0xjc commented 2 months ago

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:

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: image

With +6% chance to block spell damage: image

After screenshot:

With +5% chance to block spell damage: image

With +6% chance to block spell damage: image