From a769c6c4865f681be95198fd778c2f12283279b0 Mon Sep 17 00:00:00 2001 From: Lucas Karsten Date: Thu, 19 Nov 2026 11:39:54 -0300 Subject: [PATCH 1/2] Fix minimum/maximum damage mods not applying to fully converted damage Damage types with no base damage of their own (e.g. Lightning on a spell whose Physical damage is 100% converted) returned the converted damage before their "more/increased Minimum/Maximum Damage" modifiers were applied, so Roiling Tempest and similar mods did nothing for phys to lightning spells. --- spec/System/TestOffence_spec.lua | 18 ++++++++++++++++++ src/Modules/CalcOffence.lua | 18 ++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/spec/System/TestOffence_spec.lua b/spec/System/TestOffence_spec.lua index ac343924a81..8ddcd505bef 100644 --- a/spec/System/TestOffence_spec.lua +++ b/spec/System/TestOffence_spec.lua @@ -254,6 +254,24 @@ describe("TestOffence", function() assertNear(baseMin * 0.5 * 2, build.calcsTab.calcsOutput.LightningMin, "less + increased min") end) + it("applies min/max damage mods to damage fully converted to that type (issue #10407)", function() + build.skillsTab:PasteSocketGroup("Slot: Body Armour\nBladefall 20/0 1\n") + build.configTab.input.customMods = "100% of Physical Damage Converted to Lightning Damage" + build.configTab:BuildModList() + runCallback("OnFrame") + + local baseMin = build.calcsTab.calcsOutput.LightningMin + local baseMax = build.calcsTab.calcsOutput.LightningMax + assert.is_true(baseMax > 0) + + build.configTab.input.customMods = "100% of Physical Damage Converted to Lightning Damage\n25% more Maximum Lightning Damage\n50% less Minimum Lightning Damage" + build.configTab:BuildModList() + runCallback("OnFrame") + + assertNear(baseMax * 1.25, build.calcsTab.calcsOutput.LightningMax, "25%% more max on converted damage") + assertNear(baseMin * 0.5, build.calcsTab.calcsOutput.LightningMin, "50%% less min on converted damage") + end) + it("applies minimum and maximum attack damage mods", function() build.itemsTab:CreateDisplayItemFromRaw([[ New Item diff --git a/src/Modules/CalcOffence.lua b/src/Modules/CalcOffence.lua index bea7d97e17e..2cbaf77a13c 100644 --- a/src/Modules/CalcOffence.lua +++ b/src/Modules/CalcOffence.lua @@ -90,21 +90,27 @@ local function calcDamage(activeSkill, output, cfg, breakdown, damageType, typeF end local baseMin = output[damageType.."MinBase"] local baseMax = output[damageType.."MaxBase"] + local moreMinDamage = skillModList:More(cfg, "Min"..damageType.."Damage") + local moreMaxDamage = skillModList:More(cfg, "Max"..damageType.."Damage") + local incMinDamage = 1 + skillModList:Sum("INC", cfg, "Min"..damageType.."Damage") / 100 + local incMaxDamage = 1 + skillModList:Sum("INC", cfg, "Max"..damageType.."Damage") / 100 if baseMin == 0 and baseMax == 0 then - -- No base damage for this type, don't need to calculate modifiers + -- No base damage for this type, so only its minimum/maximum modifiers apply, to the damage converted into it + local min = addMin * moreMinDamage * incMinDamage + local max = addMax * moreMaxDamage * incMaxDamage if breakdown and (addMin ~= 0 or addMax ~= 0) then t_insert(breakdown.damageTypes, { source = damageType, convSrc = (addMin ~= 0 or addMax ~= 0) and (round(addMin) .. " to " .. round(addMax)), - total = round(addMin) .. " to " .. round(addMax), + total = round(min) .. " to " .. round(max), convDst = convDst and s_format("%d%% to %s", conversionTable[damageType].conversion[convDst] * 100, convDst), gainDst = convDst and s_format("%d%% gained as %s", conversionTable[damageType].gain[convDst] * 100, convDst), }) end if convDst then - return addMin, addMax + return min, max end - return round(addMin), round(addMax) + return round(min), round(max) end -- Combine modifiers @@ -113,10 +119,6 @@ local function calcDamage(activeSkill, output, cfg, breakdown, damageType, typeF local more = skillModList:More(cfg, unpack(modNames)) local genericMoreMinDamage = skillModList:More(cfg, "MinDamage") local genericMoreMaxDamage = skillModList:More(cfg, "MaxDamage") - local moreMinDamage = skillModList:More(cfg, "Min"..damageType.."Damage") - local moreMaxDamage = skillModList:More(cfg, "Max"..damageType.."Damage") - local incMinDamage = 1 + skillModList:Sum("INC", cfg, "Min"..damageType.."Damage") / 100 - local incMaxDamage = 1 + skillModList:Sum("INC", cfg, "Max"..damageType.."Damage") / 100 if breakdown then t_insert(breakdown.damageTypes, { From d1a15bf22dfc34881db37bb2a897d49b569dfeae Mon Sep 17 00:00:00 2001 From: Lucas Karsten Date: Thu, 19 Nov 2026 11:47:46 -0300 Subject: [PATCH 2/2] Show min/max multipliers in the breakdown of converted damage and test chained and gained conversion --- spec/System/TestOffence_spec.lua | 35 ++++++++++++++++++++++++++++++++ src/Modules/CalcOffence.lua | 1 + 2 files changed, 36 insertions(+) diff --git a/spec/System/TestOffence_spec.lua b/spec/System/TestOffence_spec.lua index 8ddcd505bef..3f345fa2076 100644 --- a/spec/System/TestOffence_spec.lua +++ b/spec/System/TestOffence_spec.lua @@ -272,6 +272,41 @@ describe("TestOffence", function() assertNear(baseMin * 0.5, build.calcsTab.calcsOutput.LightningMin, "50%% less min on converted damage") end) + -- Bladefall with the given custom mods; returns output without and with Roiling Tempest's min/max lightning mods + local function withAndWithoutMinMaxLightning(mods) + build.skillsTab:PasteSocketGroup("Slot: Body Armour\nBladefall 20/0 1\n") + build.configTab.input.customMods = mods + build.configTab:BuildModList() + runCallback("OnFrame") + local before = copyTable(build.calcsTab.calcsOutput, true) + build.configTab.input.customMods = mods .. "\n25% more Maximum Lightning Damage\n50% less Minimum Lightning Damage" + build.configTab:BuildModList() + runCallback("OnFrame") + return before, build.calcsTab.calcsOutput + end + + it("applies min/max lightning mods to the lightning step of a chained conversion (issue #10407)", function() + local before, after = withAndWithoutMinMaxLightning("100% of Physical Damage Converted to Lightning Damage\n100% of Lightning Damage Converted to Cold Damage") + assert.is_true(before.ColdMax > 0) + assertNear(before.ColdMax * 1.25, after.ColdMax, "cold max scaled via the lightning step") + assertNear(before.ColdMin * 0.5, after.ColdMin, "cold min scaled via the lightning step") + end) + + it("does not apply min/max lightning mods to physical converted directly to cold", function() + local before, after = withAndWithoutMinMaxLightning("100% of Physical Damage Converted to Cold Damage") + assert.is_true(before.ColdMax > 0) + assert.are.equals(before.ColdMax, after.ColdMax) + assert.are.equals(before.ColdMin, after.ColdMin) + end) + + it("applies min/max lightning mods to damage gained as extra lightning with no lightning base (issue #10407)", function() + local before, after = withAndWithoutMinMaxLightning("Gain 50% of Physical Damage as Extra Lightning Damage") + assert.is_true(before.LightningMax > 0) + assertNear(before.LightningMax * 1.25, after.LightningMax, "gained lightning max") + assertNear(before.LightningMin * 0.5, after.LightningMin, "gained lightning min") + assert.are.equals(before.PhysicalMax, after.PhysicalMax) + end) + it("applies minimum and maximum attack damage mods", function() build.itemsTab:CreateDisplayItemFromRaw([[ New Item diff --git a/src/Modules/CalcOffence.lua b/src/Modules/CalcOffence.lua index 2cbaf77a13c..59bfcd74efa 100644 --- a/src/Modules/CalcOffence.lua +++ b/src/Modules/CalcOffence.lua @@ -102,6 +102,7 @@ local function calcDamage(activeSkill, output, cfg, breakdown, damageType, typeF t_insert(breakdown.damageTypes, { source = damageType, convSrc = (addMin ~= 0 or addMax ~= 0) and (round(addMin) .. " to " .. round(addMax)), + more = (min ~= addMin or max ~= addMax) and s_format("x %g min, x %g max", round(moreMinDamage * incMinDamage, 4), round(moreMaxDamage * incMaxDamage, 4)), total = round(min) .. " to " .. round(max), convDst = convDst and s_format("%d%% to %s", conversionTable[damageType].conversion[convDst] * 100, convDst), gainDst = convDst and s_format("%d%% gained as %s", conversionTable[damageType].gain[convDst] * 100, convDst),