From 4f6759b03ee310af57eed04aa873aac7b40a2bc9 Mon Sep 17 00:00:00 2001 From: vaisest <4550061+vaisest@users.noreply.github.com> Date: Wed, 29 Jul 2026 17:57:12 +0300 Subject: [PATCH] Revert "Fix Cost efficiency math" --- spec/System/TestSkills_spec.lua | 18 +++++++++--------- src/Modules/CalcOffence.lua | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/spec/System/TestSkills_spec.lua b/spec/System/TestSkills_spec.lua index 345187f53a..f4c6110135 100644 --- a/spec/System/TestSkills_spec.lua +++ b/spec/System/TestSkills_spec.lua @@ -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") @@ -226,10 +226,10 @@ 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 @@ -237,11 +237,11 @@ describe("TestAttacks", function() 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 @@ -249,8 +249,8 @@ describe("TestAttacks", function() 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 diff --git a/src/Modules/CalcOffence.lua b/src/Modules/CalcOffence.lua index 956ac30db3..85ecb9f772 100644 --- a/src/Modules/CalcOffence.lua +++ b/src/Modules/CalcOffence.lua @@ -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 @@ -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]) @@ -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] = { @@ -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