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
18 changes: 9 additions & 9 deletions spec/System/TestSkills_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe("TestAttacks", function()
assert.True(math.abs(finalCost - 12) < 0.1) -- floor(12 * 1.5) / 1.5
end)

it("Test flat cost is added before cost efficiency", function()
it("Test flat cost is added after cost efficiency", function()
-- In-game order is ((base cost * multipliers) + flat cost) / (1 + cost efficiency)
build.skillsTab:PasteSocketGroup("Hydrosphere 1/0 1\n")

Expand All @@ -226,31 +226,31 @@ describe("TestAttacks", function()
runCallback("OnFrame")

local finalCost = build.calcsTab.mainOutput.ManaCost
-- (12 + 10) / 1.5 = 14.667
assert.True(math.abs(finalCost - 22 / 1.5) < 0.001)
-- 12 / 1.5 + 10 = 18
assert.equals(18, finalCost)
end)
it("Test flat cost is added before cost efficiency for life costs", function()
it("Test flat cost is added after cost efficiency for life costs", function()
build.skillsTab:PasteSocketGroup("Hydrosphere 1/0 1\n")

-- Convert Hydrosphere's 12 base cost to life, then add +10 flat and 50% efficiency
build.configTab.input.customMods = "Skills Cost Life instead of Mana\n+10 to Total Cost\n50% increased Cost Efficiency"
build.configTab:BuildModList()
runCallback("OnFrame")

-- (12 + 10) / 1.5 = 14.667
assert.True(math.abs(build.calcsTab.mainOutput.LifeCost - 22 / 1.5) < 0.001)
-- 12 / 1.5 + 10 = 18
assert.equals(18, build.calcsTab.mainOutput.LifeCost)
end)

it("Test flat cost is added before cost efficiency for energy shield costs (#10003)", function()
it("Test flat cost is added after cost efficiency for energy shield costs", function()
build.skillsTab:PasteSocketGroup("Hydrosphere 1/0 1\n")

-- Convert Hydrosphere's 12 base cost to ES, then add +10 flat and 50% efficiency
build.configTab.input.customMods = "Skills Cost Energy Shield instead of Mana or Life\n+10 to Total Cost\n50% increased Cost Efficiency"
build.configTab:BuildModList()
runCallback("OnFrame")

-- (12 + 10) / 1.5 = 14.667
assert.True(math.abs(build.calcsTab.mainOutput.ESCost - 22 / 1.5) < 0.001)
-- 12 / 1.5 + 10 = 18
assert.equals(18, build.calcsTab.mainOutput.ESCost)
end)
it("Test mana cost efficiency with support gems", function()
-- Test interaction between cost efficiency and cost multipliers
Expand Down
16 changes: 8 additions & 8 deletions src/Modules/CalcOffence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ function calcs.offence(env, actor, activeSkill)
moreType = skillModList:More(skillCfg, val.type.."Cost")
moreCost = skillModList:More(skillCfg, "Cost")
inc = skillModList:Sum("INC", skillCfg, val.type.."Cost", "Cost")
output[costNameRaw] = val.baseCostRaw and m_max(0, m_max(0, (1 + inc / 100) * val.baseCostRaw * moreType * moreCost) + val.totalCost) / costEfficiency
output[costNameRaw] = val.baseCostRaw and m_max(0, m_max(0, (1 + inc / 100) * val.baseCostRaw * moreType * moreCost / costEfficiency) + val.totalCost)
if inc < 0 then
output[costName] = m_max(0, m_ceil((1 + inc / 100) * output[costName]))
else
Expand All @@ -1772,9 +1772,9 @@ function calcs.offence(env, actor, activeSkill)
else
output[costName] = m_max(0, m_floor(moreCost * output[costName]))
end
output[costName] = m_max(0, output[costName] + val.totalCost)
-- Apply cost efficiency (similar to reservation efficiency)
output[costName] = m_max(0, output[costName] / costEfficiency)
output[costName] = m_max(0, output[costName] + val.totalCost)
if val.type == "Mana" and hybridLifeCost > 0 then -- Life/Mana Mastery
output[costName] = m_max(0, m_floor((1 - hybridLifeCost) * output[costName]))
output[costNameRaw] = output[costNameRaw] and m_max(0, (1 - hybridLifeCost) * output[costNameRaw])
Expand All @@ -1785,10 +1785,10 @@ function calcs.offence(env, actor, activeSkill)
output[costName] = m_floor(val.baseCost + val.baseCostNoMult)
output[costName] = m_max(0, (1 + inc / 100) * output[costName])
output[costName] = m_max(0, moreType * output[costName])
output[costName] = m_max(0, output[costName] + val.totalCost)
-- Apply cost efficiency for unaffected costs too
output[costName] = m_max(0, output[costName] / costEfficiency)
output[costNameRaw] = val.baseCostRaw and m_max(0, m_max(0, (1 + inc / 100) * (val.baseCostRaw + val.baseCostNoMult) * moreType) + val.totalCost) / costEfficiency
output[costName] = m_max(0, output[costName] + val.totalCost)
output[costNameRaw] = val.baseCostRaw and m_max(0, m_max(0, (1 + inc / 100) * (val.baseCostRaw + val.baseCostNoMult) * moreType / costEfficiency) + val.totalCost)
end
if breakdown and hasCost then
breakdown[costName] = {
Expand All @@ -1815,16 +1815,16 @@ function calcs.offence(env, actor, activeSkill)
if moreType ~= 1 then
t_insert(breakdown[costName], s_format("x %.2f ^8(more/less "..val.text.." cost)", moreType))
end
if val.totalCost ~= 0 then
t_insert(breakdown[costName], s_format("%+d ^8(total " .. val.text .. " cost)", val.totalCost))
end
if costEfficiency ~= 1 then
t_insert(breakdown[costName], s_format("/ %.2f ^8(" .. val.text .. " cost efficiency)", costEfficiency))
end
if val.totalCost ~= 0 then
t_insert(breakdown[costName], s_format("%+d ^8(total "..val.text.." cost)", val.totalCost))
end
if val.type == "Mana" and hybridLifeCost > 0 then
t_insert(breakdown[costName], s_format("x %.2f ^8(%d%% paid for with life)", (1-hybridLifeCost), hybridLifeCost*100))
end
t_insert(breakdown[costName], s_format("= %" .. (val.upfront and "d" or ".2f") .. (val.percent and "%%" or ""), m_ceil(output[costName])))
t_insert(breakdown[costName], s_format("= %"..(val.upfront and "d" or ".2f")..(val.percent and "%%" or ""), output[costName]))
end
end
end
Expand Down
Loading