Skip to content
Merged
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
44 changes: 44 additions & 0 deletions spec/System/TestItemMods_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,48 @@ describe("TetsItemMods", function()

assert.are_not.equals(baseLife, build.calcsTab.mainOutput.Life)
end)

it("globalLimit mods", function()
build.configTab.input.customMods = [[
-1000% to cold resistance
]]
build.configTab:BuildModList()
build.itemsTab:CreateDisplayItemFromRaw([[Replica Nebulis
Void Sceptre
League: Heist
Quality: 20
Sockets: B-B-B
LevelReq: 68
Implicits: 1
40% increased Elemental Damage
{fractured}{range:1}(15-20)% increased Cast Speed
{range:1}(15-20)% increased Cold Damage per 1% Missing Cold Resistance, up to a maximum of 300%
{range:1}(15-20)% increased Fire Damage per 1% Missing Fire Resistance, up to a maximum of 300%]])
build.itemsTab:AddDisplayItem()
build.skillsTab:PasteSocketGroup("Slot: Weapon 1\nFireball 20/0 Default 1\n")
runCallback("OnFrame")

assert.are_not.equals(340, build.calcsTab.mainEnv.modDB:Sum("INC", "FireDamage"))
assert.are_not.equals(340, build.calcsTab.mainEnv.modDB:Sum("INC", "ColdDamage"))

newBuild()

build.configTab.input.customMods = [[
Gain 25% increased Armour per 5 Power for 8 seconds when you Warcry, up to a maximum of 100%
Warcries have infinite Power
warcries grant arcane surge to you and allies, with 10% increased effect per 5 power, up to 100%
]]
build.configTab:BuildModList()
build.itemsTab:CreateDisplayItemFromRaw([[
New Item
Plate Vest
Armour: 32
]])
build.itemsTab:AddDisplayItem()
build.skillsTab:PasteSocketGroup("Arc 20/0 Default 1")

assert.are_not.equals(40, build.calcsTab.mainEnv.modDB:Sum("INC", { flags = ModFlag.Cast }, "Speed"))
assert.are_not.equals(64, build.calcsTab.mainOutput.Armour)
runCallback("OnFrame")
end)
end)
23 changes: 13 additions & 10 deletions src/Classes/ModStore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,6 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
local target = self
local limitTarget = self

if globalLimits and tag.globalLimit and tag.globalLimitKey then
value = value or 0
globalLimits[tag.globalLimitKey] = globalLimits[tag.globalLimitKey] or 0
if globalLimits[tag.globalLimitKey] + value > tag.globalLimit then
value = tag.globalLimit - globalLimits[tag.globalLimitKey]
end
globalLimits[tag.globalLimitKey] = globalLimits[tag.globalLimitKey] + value
end

-- Allow limiting a self multiplier on a parent multiplier (eg. Agony Crawler on player virulence)
-- This explicit target is necessary because even though the GetMultiplier method does call self.parent.GetMultiplier, it does so with noMod = true,
-- disabling the summation (3rd part): (not noMod and self:Sum("BASE", cfg, multiplierName[var]) or 0)
Expand Down Expand Up @@ -824,6 +815,18 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
return
end
end
end
end

-- Apply global limits
for _, tag in ipairs(mod) do
if globalLimits and tag.globalLimit and tag.globalLimitKey then
value = value or 0
globalLimits[tag.globalLimitKey] = globalLimits[tag.globalLimitKey] or 0
if globalLimits[tag.globalLimitKey] + value > tag.globalLimit then
value = tag.globalLimit - globalLimits[tag.globalLimitKey]
end
globalLimits[tag.globalLimitKey] = globalLimits[tag.globalLimitKey] + value
end
end
return value
end