Skip to content

Commit 0395117

Browse files
authored
Fix Nebulis and similar mods being treated as uncapped (#8666)
* FIX: globalLimit not applying * MISC(test): add some more tests for globlaLimit type mods * MISC(test): test PerStat code path
1 parent dfb6ce3 commit 0395117

2 files changed

Lines changed: 57 additions & 10 deletions

File tree

spec/System/TestItemMods_spec.lua

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,48 @@ describe("TetsItemMods", function()
509509

510510
assert.are_not.equals(baseLife, build.calcsTab.mainOutput.Life)
511511
end)
512+
513+
it("globalLimit mods", function()
514+
build.configTab.input.customMods = [[
515+
-1000% to cold resistance
516+
]]
517+
build.configTab:BuildModList()
518+
build.itemsTab:CreateDisplayItemFromRaw([[Replica Nebulis
519+
Void Sceptre
520+
League: Heist
521+
Quality: 20
522+
Sockets: B-B-B
523+
LevelReq: 68
524+
Implicits: 1
525+
40% increased Elemental Damage
526+
{fractured}{range:1}(15-20)% increased Cast Speed
527+
{range:1}(15-20)% increased Cold Damage per 1% Missing Cold Resistance, up to a maximum of 300%
528+
{range:1}(15-20)% increased Fire Damage per 1% Missing Fire Resistance, up to a maximum of 300%]])
529+
build.itemsTab:AddDisplayItem()
530+
build.skillsTab:PasteSocketGroup("Slot: Weapon 1\nFireball 20/0 Default 1\n")
531+
runCallback("OnFrame")
532+
533+
assert.are_not.equals(340, build.calcsTab.mainEnv.modDB:Sum("INC", "FireDamage"))
534+
assert.are_not.equals(340, build.calcsTab.mainEnv.modDB:Sum("INC", "ColdDamage"))
535+
536+
newBuild()
537+
538+
build.configTab.input.customMods = [[
539+
Gain 25% increased Armour per 5 Power for 8 seconds when you Warcry, up to a maximum of 100%
540+
Warcries have infinite Power
541+
warcries grant arcane surge to you and allies, with 10% increased effect per 5 power, up to 100%
542+
]]
543+
build.configTab:BuildModList()
544+
build.itemsTab:CreateDisplayItemFromRaw([[
545+
New Item
546+
Plate Vest
547+
Armour: 32
548+
]])
549+
build.itemsTab:AddDisplayItem()
550+
build.skillsTab:PasteSocketGroup("Arc 20/0 Default 1")
551+
552+
assert.are_not.equals(40, build.calcsTab.mainEnv.modDB:Sum("INC", { flags = ModFlag.Cast }, "Speed"))
553+
assert.are_not.equals(64, build.calcsTab.mainOutput.Armour)
554+
runCallback("OnFrame")
555+
end)
512556
end)

src/Classes/ModStore.lua

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,6 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
267267
local target = self
268268
local limitTarget = self
269269

270-
if globalLimits and tag.globalLimit and tag.globalLimitKey then
271-
value = value or 0
272-
globalLimits[tag.globalLimitKey] = globalLimits[tag.globalLimitKey] or 0
273-
if globalLimits[tag.globalLimitKey] + value > tag.globalLimit then
274-
value = tag.globalLimit - globalLimits[tag.globalLimitKey]
275-
end
276-
globalLimits[tag.globalLimitKey] = globalLimits[tag.globalLimitKey] + value
277-
end
278-
279270
-- Allow limiting a self multiplier on a parent multiplier (eg. Agony Crawler on player virulence)
280271
-- This explicit target is necessary because even though the GetMultiplier method does call self.parent.GetMultiplier, it does so with noMod = true,
281272
-- disabling the summation (3rd part): (not noMod and self:Sum("BASE", cfg, multiplierName[var]) or 0)
@@ -824,6 +815,18 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
824815
return
825816
end
826817
end
827-
end
818+
end
819+
820+
-- Apply global limits
821+
for _, tag in ipairs(mod) do
822+
if globalLimits and tag.globalLimit and tag.globalLimitKey then
823+
value = value or 0
824+
globalLimits[tag.globalLimitKey] = globalLimits[tag.globalLimitKey] or 0
825+
if globalLimits[tag.globalLimitKey] + value > tag.globalLimit then
826+
value = tag.globalLimit - globalLimits[tag.globalLimitKey]
827+
end
828+
globalLimits[tag.globalLimitKey] = globalLimits[tag.globalLimitKey] + value
829+
end
830+
end
828831
return value
829832
end

0 commit comments

Comments
 (0)