Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve EHP overkill approximation, especially for MoM #7568

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

0xjc
Copy link

@0xjc 0xjc commented Apr 14, 2024

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

@QuickStick123 QuickStick123 added the bug:calculation Numerical differences label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:calculation Numerical differences
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants