Skip to content

Fix inverted negative resistance exceeding the enemy's maximum resistance - #10492

Merged
Wires77 merged 2 commits into
PathOfBuildingCommunity:devfrom
lucaskarsten:fix/9375-inverted-res-cap
Nov 19, 2026
Merged

Wires77 merged 2 commits into
PathOfBuildingCommunity:devfrom
lucaskarsten:fix/9375-inverted-res-cap

Conversation

@lucaskarsten

@lucaskarsten lucaskarsten commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9375 .

Description of the problem being solved:

Resistance inversion ("Hits have X% chance to treat Enemy Monster Elemental Resistance values as inverted", Wild Strike of the Extremes, etc.) negated the enemy resistance after calcResistForType had already capped it, so the inverted value skipped the enemy's maximum resistance. An enemy at -150% became +150%, the effective DPS modifier went to -0.5 and the build showed negative DPS.

Inverted resistances are still subject to the maximum resistance cap (poewiki, Chaos Resistance: "Inverted resistances are still subject to maximum/minimum resistance caps"), and penetration applies after inversion. The inverted value is now min(-resist, enemy max resistance) in both the normal and the "cannot penetrate or ignore" branches, and the breakdown shows the capped value with a "capped at maximum resistance" note.

The max resistance lookup was moved into a small calcEnemyMaxResist helper shared with calcResistForType (unchanged behaviour) and only runs when there is an inversion chance, so builds without inversion are unaffected.

Not changed: with "uses lowest resistance" mods the inversion chance still follows the hit's damage type rather than the element whose resistance is used, and the cannot-penetrate branch still ignores the chance to use resistance. Both predate this PR.

Steps taken to verify a working solution:

  • New spec in TestSkills_spec.lua (enemy at -150% fire resistance): 100% inversion = 0.25, with 20% penetration = 0.45, with "cannot penetrate" = 0.25, 50% inversion = 1.375, plus the breakdown text. It fails without the fix (-0.5).
  • Mutation checks: reverting the cannot-penetrate formula or applying penetration before the cap both fail the spec.
  • busted --lua=luajit in the pathofbuilding-tests image: 743 successes / 0 failures.
  • Loaded the build from the issue headless (loadBuildFromXML): Combined DPS -214,632 on dev, 433,211 with this PR.

Link to a build that showcases this PR:

https://pobb.in/pGaj43d1ZKOw (from the issue)

Before screenshot:

See the issue: Combined DPS is negative (-214,632 headless on dev).

After screenshot:

Combined DPS 433,211 (headless, this branch).

…ance

Resistance inversion negated the enemy resistance after calcResistForType
had capped it, so an enemy at -150% became +150% and hits dealt negative
damage. Inverted resistances are still subject to the maximum resistance
cap, so cap the inverted value at the enemy's maximum before penetration,
in both the normal and the cannot-penetrate branches, and show it in the
breakdown.
…erted resistance

Only look up the enemy maximum resistance when there is an inversion
chance, so builds without inversion do no extra work, and note the cap in
the breakdown. The spec now checks the cap with 20% penetration, with
"cannot penetrate", with 50% inversion chance and the breakdown text.
@lucaskarsten
lucaskarsten force-pushed the fix/9375-inverted-res-cap branch from 02f3e4c to e92cee7 Compare November 18, 2026 19:47
@Wires77 Wires77 added the bug: calculation Numerical differences label Nov 19, 2026
@Wires77
Wires77 merged commit 61641fd into PathOfBuildingCommunity:dev Nov 19, 2026
3 checks passed
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.

Inverted resistance above 100% causes negative damage

2 participants