Fix maximum hit taken calculation when multiple hit pools are in effect #6729
+340
−304
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is mainly a refactor of some hit pools, but also fixes a related calculation bug.
Bugfix
Description of the problem being solved:
The calculation for maximum sustainable hit relies on applying the hit pools in reverse order from how they take damage.
Best known order here: https://www.pathofexile.com/forum/view-thread/3123794
This reverse order was not being done for aegis+guard or the allies who can take damage for you, so mixing aegis, a guard skill or an ally could lead to incorrect max hit and weird breakdown values.
Steps taken to verify a working solution:
Link to a build that showcases this PR:
Build A:
Build B:
Before screenshot:
Build B:

After screenshot:
Build B:

Refactor
Scope
The refactor concerns three health pools:
Aegis
,Guard
andAlliesTakenBeforeYou
. The refactor is a continuation of #6391Design choices
The three hit pools have been moved into their own new file
CalcHitPools.lua
. The behaviour of the pools are implemented using metatables, with each metatable sharing 5 functions / behaviours:init
: Initializes values related to the pool in theoutput
table.new
: Acts as a construcor, creating a new instance of the hit pool, able to take damage for the player, based on the values found inoutput
.takeDamage
: Reduces the size of the hit pool, depending on the type of the damage taken. Only reduces values local to the pool instance.adjustTotalHitPool
: Increases the players effective hit pool, depending on the values inoutput
.displayMaxHit
: Inserts the local values of a pool instance into a breakdown table.A lot of behavior was duplicated across hit pools, especially allies. I have tried generalizing by extracting the keys / names used in calculations, and then looping over those keys and applying the calculation, rather than doing each key manually. My hope is that this reduces the chance of errors, and makes adding new hit pools easier in the future.