Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions spec/System/TestOffence_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,59 @@ 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)

-- 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
Expand Down
19 changes: 11 additions & 8 deletions src/Modules/CalcOffence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,28 @@ 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),
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),
})
end
if convDst then
return addMin, addMax
return min, max
end
return round(addMin), round(addMax)
return round(min), round(max)
end

-- Combine modifiers
Expand All @@ -113,10 +120,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, {
Expand Down
Loading