From 74f84f9799f425d8f2d04e76d5acf86d1676aa2b Mon Sep 17 00:00:00 2001 From: LocalIdentity Date: Fri, 17 Apr 2026 19:11:21 +0000 Subject: [PATCH 1/2] Apply changes from https://github.com/PathOfBuildingCommunity/PathOfBuilding/pull/9772 --- src/Modules/CalcDefence.lua | 14 ++++++++++---- src/Modules/CalcDefence.lua.rej | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 src/Modules/CalcDefence.lua.rej diff --git a/src/Modules/CalcDefence.lua b/src/Modules/CalcDefence.lua index 77a2a66673..39be0fe3fe 100644 --- a/src/Modules/CalcDefence.lua +++ b/src/Modules/CalcDefence.lua @@ -3112,7 +3112,10 @@ function calcs.buildDefenceEstimations(env, actor) if poolTable.Life >= 0 and damageTotal >= maxDamage then -- If still living and the amount of damage exceeds maximum threshold we survived infinite number of hits. return m_huge end - return numHits + if numHits ~= numHits then + return 0 + end + return m_max(numHits, 0) end if damageCategoryConfig ~= "DamageOverTime" then @@ -3578,9 +3581,12 @@ function calcs.buildDefenceEstimations(env, actor) local damageConvertedMulti = convertPercent / 100 local totalHitPool = output[damageConvertedType.."TotalHitPool"] local totalTakenMulti = output[damageConvertedType.."AfterReductionTakenHitMulti"] * (1 - output["VaalArcticArmourMitigation"]) - - if effectiveAppliedArmour == 0 and convertPercent == 100 then -- use a simpler calculation for no armour DR - local drMulti = output[damageConvertedType.."ResistTakenHitMulti"] * (1 - output[damageConvertedType.."DamageReduction"] / 100) + if damageConvertedMulti <= 0 then + local takenWithoutIncoming = m_max(takenFlat, 0) * totalTakenMulti + hitTaken = takenWithoutIncoming >= totalHitPool and 0 or m_huge + elseif effectiveAppliedArmour == 0 and convertPercent == 100 then -- use a simpler calculation for no armour DR + local totalResistMult = output[damageConvertedType.."ResistTakenHitMulti"] + local drMulti = totalResistMult * (1 - output[damageConvertedType.."DamageReduction"] / 100) hitTaken = m_max(totalHitPool / damageConvertedMulti / drMulti - takenFlat, 0) / totalTakenMulti else -- get relevant raw reductions and reduction modifiers diff --git a/src/Modules/CalcDefence.lua.rej b/src/Modules/CalcDefence.lua.rej new file mode 100644 index 0000000000..2f6620b90d --- /dev/null +++ b/src/Modules/CalcDefence.lua.rej @@ -0,0 +1,31 @@ +diff a/src/Modules/CalcDefence.lua b/src/Modules/CalcDefence.lua (rejected hunks) +@@ -3194,7 +3200,7 @@ function calcs.buildDefenceEstimations(env, actor) + local b = ((enemyOverwhelmPercent / 100 - flatDR) * effectiveAppliedArmour * totalTakenMulti - 5 * (totalHitPool - takenFlat * totalTakenMulti)) * resistXConvert + local c = -effectiveAppliedArmour * (totalHitPool - takenFlat * totalTakenMulti) + +- local RAW = (m_sqrt(b * b - 4 * a * c) - b) / (2 * a) ++ local RAW = a ~= 0 and (m_sqrt(m_max(b * b - 4 * a * c, 0)) - b) / (2 * a) or m_huge + + -- tack on some caps + local noDRMaxHit = totalHitPool / damageConvertedMulti / totalResistMult / totalTakenMulti * (1 - takenFlat * totalTakenMulti / totalHitPool) +@@ -3220,9 +3226,18 @@ function calcs.buildDefenceEstimations(env, actor) + local passOverkill = passPools.OverkillDamage - passPools.hitPoolRemaining + local passRatio = 0 + for partType, _ in pairs(passDamages) do +- passRatio = m_max(passRatio, (passOverkill + output[partType.."TotalHitPool"]) / output[partType.."TotalHitPool"]) ++ local partPool = output[partType.."TotalHitPool"] or 0 ++ if partPool > 0 then ++ passRatio = m_max(passRatio, (passOverkill + partPool) / partPool) ++ end ++ end ++ if passRatio <= 0 then ++ passRatio = 1 ++ end ++ local stepSize = 1 ++ if n > 1 and previousOverkill and previousOverkill ~= 0 and previousOverkill == previousOverkill then ++ stepSize = m_min(m_abs((passOverkill - previousOverkill) / previousOverkill), 2) + end +- local stepSize = n > 1 and m_min(m_abs((passOverkill - previousOverkill) / previousOverkill), 2) or 1 + local stepAdjust = stepSize > 1 and -passOverkill / stepSize or n > 1 and -passOverkill * stepSize or 0 + previousOverkill = passOverkill + passIncomingDamage = (passIncomingDamage + stepAdjust) / m_sqrt(passRatio) From b7d17ed87cb171766787139c28a92e2bc68ecfbd Mon Sep 17 00:00:00 2001 From: LocalIdentity Date: Sun, 26 Apr 2026 07:23:18 +1000 Subject: [PATCH 2/2] Fix merge conflict --- src/Modules/CalcDefence.lua | 16 +++++++++++++--- src/Modules/CalcDefence.lua.rej | 31 ------------------------------- 2 files changed, 13 insertions(+), 34 deletions(-) delete mode 100644 src/Modules/CalcDefence.lua.rej diff --git a/src/Modules/CalcDefence.lua b/src/Modules/CalcDefence.lua index 39be0fe3fe..47c2f0b530 100644 --- a/src/Modules/CalcDefence.lua +++ b/src/Modules/CalcDefence.lua @@ -10,6 +10,7 @@ local ipairs = ipairs local t_insert = table.insert local m_min = math.min local m_max = math.max +local m_abs = math.abs local m_floor = math.floor local m_ceil = math.ceil local m_sqrt = math.sqrt @@ -3620,7 +3621,7 @@ function calcs.buildDefenceEstimations(env, actor) local b = (effectiveAppliedArmour * oneMinusFlatPlusOverwhelm - effectiveAppliedArmour - HP_tTM_tF_DCM_tRM * data.misc.ArmourRatio * damageConvertedMulti) local c = -HP_tTM_tF_DCM_tRM * effectiveAppliedArmour - local RAW = (m_sqrt(b * b - 4 * a * c) - b) / (2 * a) + local RAW = a ~= 0 and (m_sqrt(m_max(b * b - 4 * a * c, 0)) - b) / (2 * a) or m_huge -- tack on some caps local noDRMaxHit = totalHitPool / damageConvertedMulti / totalResistMult / totalTakenMulti * (1 - takenFlat * totalTakenMulti / totalHitPool) @@ -3646,9 +3647,18 @@ function calcs.buildDefenceEstimations(env, actor) local passOverkill = passPools.OverkillDamage - passPools.hitPoolRemaining local passRatio = 0 for partType, _ in pairs(passDamages) do - passRatio = m_max(passRatio, (passOverkill + output[partType.."TotalHitPool"]) / output[partType.."TotalHitPool"]) + local partPool = output[partType.."TotalHitPool"] or 0 + if partPool > 0 then + passRatio = m_max(passRatio, (passOverkill + partPool) / partPool) + end + end + if passRatio <= 0 then + passRatio = 1 + end + local stepSize = 1 + if n > 1 and previousOverkill and previousOverkill ~= 0 and previousOverkill == previousOverkill then + stepSize = m_min(m_abs((passOverkill - previousOverkill) / previousOverkill), 2) end - local stepSize = n > 1 and m_min(math.abs((passOverkill - previousOverkill) / previousOverkill), 2) or 1 local stepAdjust = stepSize > 1 and -passOverkill / stepSize or n > 1 and -passOverkill * stepSize or 0 previousOverkill = passOverkill passIncomingDamage = (passIncomingDamage + stepAdjust) / m_sqrt(passRatio) diff --git a/src/Modules/CalcDefence.lua.rej b/src/Modules/CalcDefence.lua.rej deleted file mode 100644 index 2f6620b90d..0000000000 --- a/src/Modules/CalcDefence.lua.rej +++ /dev/null @@ -1,31 +0,0 @@ -diff a/src/Modules/CalcDefence.lua b/src/Modules/CalcDefence.lua (rejected hunks) -@@ -3194,7 +3200,7 @@ function calcs.buildDefenceEstimations(env, actor) - local b = ((enemyOverwhelmPercent / 100 - flatDR) * effectiveAppliedArmour * totalTakenMulti - 5 * (totalHitPool - takenFlat * totalTakenMulti)) * resistXConvert - local c = -effectiveAppliedArmour * (totalHitPool - takenFlat * totalTakenMulti) - -- local RAW = (m_sqrt(b * b - 4 * a * c) - b) / (2 * a) -+ local RAW = a ~= 0 and (m_sqrt(m_max(b * b - 4 * a * c, 0)) - b) / (2 * a) or m_huge - - -- tack on some caps - local noDRMaxHit = totalHitPool / damageConvertedMulti / totalResistMult / totalTakenMulti * (1 - takenFlat * totalTakenMulti / totalHitPool) -@@ -3220,9 +3226,18 @@ function calcs.buildDefenceEstimations(env, actor) - local passOverkill = passPools.OverkillDamage - passPools.hitPoolRemaining - local passRatio = 0 - for partType, _ in pairs(passDamages) do -- passRatio = m_max(passRatio, (passOverkill + output[partType.."TotalHitPool"]) / output[partType.."TotalHitPool"]) -+ local partPool = output[partType.."TotalHitPool"] or 0 -+ if partPool > 0 then -+ passRatio = m_max(passRatio, (passOverkill + partPool) / partPool) -+ end -+ end -+ if passRatio <= 0 then -+ passRatio = 1 -+ end -+ local stepSize = 1 -+ if n > 1 and previousOverkill and previousOverkill ~= 0 and previousOverkill == previousOverkill then -+ stepSize = m_min(m_abs((passOverkill - previousOverkill) / previousOverkill), 2) - end -- local stepSize = n > 1 and m_min(m_abs((passOverkill - previousOverkill) / previousOverkill), 2) or 1 - local stepAdjust = stepSize > 1 and -passOverkill / stepSize or n > 1 and -passOverkill * stepSize or 0 - previousOverkill = passOverkill - passIncomingDamage = (passIncomingDamage + stepAdjust) / m_sqrt(passRatio)