Skip to content

Commit 3fb5c53

Browse files
committed
FEAT(mods): add handling for "Armour from equipped shield is doubled"
This is implemented by generalizing handling for the Unbreakable Ascendancy notable. Assumes that mods in the form of "X from Y is doubled" do not stack but do stack with other simillar mods such as "defences from equipped body armour are doubled if it has no socketed gems"
1 parent ea9dd66 commit 3fb5c53

2 files changed

Lines changed: 64 additions & 22 deletions

File tree

src/Modules/CalcDefence.lua

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -367,39 +367,56 @@ function calcs.defence(env, actor)
367367
if armourData then
368368
wardBase = not modDB:Flag(nil, "GainNoWardFrom" .. slot) and armourData.Ward or 0
369369
if wardBase > 0 then
370+
-- "X from Y is doubled" mods from the following flag do not stack
371+
if modDB:Flag(nil, "WardFrom" .. slot .. "isDoubled") then
372+
wardBase = wardBase * 2
373+
end
374+
375+
-- Mods that should stack with the above should be implemented like below
370376
if slot == "Body Armour" and modDB:Flag(nil, "DoubleBodyArmourDefence") then
371377
wardBase = wardBase * 2
372378
end
373379
output["WardOn"..slot] = wardBase
374380
end
375381
energyShieldBase = not modDB:Flag(nil, "GainNoEnergyShieldFrom" .. slot) and armourData.EnergyShield or 0
376382
if energyShieldBase > 0 then
383+
-- "X from Y is doubled" mods from the following flag do not stack
384+
if modDB:Flag(nil, "EnergyShieldFrom" .. slot .. "isDoubled") then
385+
energyShieldBase = energyShieldBase * 2
386+
end
387+
388+
-- Mods that should stack with the above should be implemented like below
377389
if slot == "Body Armour" and modDB:Flag(nil, "DoubleBodyArmourDefence") then
378390
energyShieldBase = energyShieldBase * 2
379391
end
380392
output["EnergyShieldOn"..slot] = energyShieldBase
381393
end
382394
armourBase = not modDB:Flag(nil, "GainNoArmourFrom" .. slot) and armourData.Armour or 0
383395
if armourBase > 0 then
384-
if slot == "Body Armour" then
385-
if modDB:Flag(nil, "DoubleBodyArmourDefence") then
386-
armourBase = armourBase * 2
387-
end
388-
if modDB:Flag(nil, "Unbreakable") then
389-
armourBase = armourBase * 2
390-
end
396+
-- "X from Y is doubled" mods from the following flag do not stack
397+
if modDB:Flag(nil, "ArmourFrom" .. slot .. "isDoubled") then
398+
armourBase = armourBase * 2
399+
end
400+
401+
-- Mods that should stack with the above should be implemented like below
402+
if slot == "Body Armour" and modDB:Flag(nil, "DoubleBodyArmourDefence")then
403+
armourBase = armourBase * 2
391404
end
392405
output["ArmourOn"..slot] = armourBase
393406
end
394407
evasionBase = not modDB:Flag(nil, "GainNoEvasionFrom" .. slot) and armourData.Evasion or 0
395408
if evasionBase > 0 then
396-
if slot == "Body Armour" then
397-
if modDB:Flag(nil, "DoubleBodyArmourDefence") then
398-
evasionBase = evasionBase * 2
399-
end
400-
if modDB:Flag(nil, "Unbreakable") and modDB:Flag(nil, "IronReflexes") then
401-
evasionBase = evasionBase * 2
402-
end
409+
-- "X from Y is doubled" mods from the following flag do not stack
410+
if modDB:Flag(nil, "EvasionFrom" .. slot .. "isDoubled") then
411+
evasionBase = evasionBase * 2
412+
end
413+
if modDB:Flag(nil, "ArmourFrom" .. slot .. "isDoubled") and ironReflexes then
414+
evasionBase = evasionBase * 2
415+
end
416+
417+
-- Mods that should stack with the above should be implemented like below
418+
if slot == "Body Armour" and modDB:Flag(nil, "DoubleBodyArmourDefence") then
419+
evasionBase = evasionBase * 2
403420
end
404421
output["EvasionOn"..slot] = evasionBase
405422
end
@@ -699,6 +716,12 @@ function calcs.defence(env, actor)
699716
slotCfg.slotName = slot
700717
wardBase = not modDB:Flag(nil, "GainNoWardFrom" .. slot) and armourData.Ward or 0
701718
if wardBase > 0 then
719+
-- "X from Y is doubled" mods from the following flag do not stack
720+
if modDB:Flag(nil, "WardFrom" .. slot .. "isDoubled") then
721+
wardBase = wardBase * 2
722+
end
723+
724+
-- Mods that should stack with the above should be implemented like below
702725
if slot == "Body Armour" and modDB:Flag(nil, "DoubleBodyArmourDefence") then
703726
wardBase = wardBase * 2
704727
end
@@ -727,6 +750,12 @@ function calcs.defence(env, actor)
727750
end
728751
energyShieldBase = not modDB:Flag(nil, "GainNoEnergyShieldFrom" .. slot) and armourData.EnergyShield or 0
729752
if energyShieldBase > 0 then
753+
-- "X from Y is doubled" mods from the following flag do not stack
754+
if modDB:Flag(nil, "EnergyShieldFrom" .. slot .. "isDoubled") then
755+
energyShieldBase = energyShieldBase * 2
756+
end
757+
758+
-- Mods that should stack with the above should be implemented like below
730759
if slot == "Body Armour" and modDB:Flag(nil, "DoubleBodyArmourDefence") then
731760
energyShieldBase = energyShieldBase * 2
732761
end
@@ -753,13 +782,16 @@ function calcs.defence(env, actor)
753782
end
754783
armourBase = not modDB:Flag(nil, "GainNoArmourFrom" .. slot) and armourData.Armour or 0
755784
if armourBase > 0 then
785+
-- "X from Y is doubled" mods from the following flag do not stack
786+
if modDB:Flag(nil, "ArmourFrom" .. slot .. "isDoubled") then
787+
armourBase = armourBase * 2
788+
end
789+
756790
if slot == "Body Armour" then
791+
-- Mods that should stack with the above should be implemented like below
757792
if modDB:Flag(nil, "DoubleBodyArmourDefence") then
758793
armourBase = armourBase * 2
759794
end
760-
if modDB:Flag(nil, "Unbreakable") then
761-
armourBase = armourBase * 2
762-
end
763795
if modDB:Flag(nil, "ConvertBodyArmourArmourEvasionToWard") then
764796
armourBase = armourBase * (1 - ((m_min(modDB:Sum("BASE", nil, "BodyArmourArmourEvasionToWardPercent"), 100) or 0) / 100))
765797
end
@@ -772,13 +804,19 @@ function calcs.defence(env, actor)
772804
end
773805
evasionBase = not modDB:Flag(nil, "GainNoEvasionFrom" .. slot) and armourData.Evasion or 0
774806
if evasionBase > 0 then
807+
-- "X from Y is doubled" mods from the following flag do not stack
808+
if modDB:Flag(nil, "EvasionFrom" .. slot .. "isDoubled") then
809+
evasionBase = evasionBase * 2
810+
end
811+
if modDB:Flag(nil, "ArmourFrom" .. slot .. "isDoubled") and ironReflexes then
812+
evasionBase = evasionBase * 2
813+
end
814+
775815
if slot == "Body Armour" then
816+
-- Mods that should stack with the above should be implemented like below
776817
if modDB:Flag(nil, "DoubleBodyArmourDefence") then
777818
evasionBase = evasionBase * 2
778819
end
779-
if modDB:Flag(nil, "Unbreakable") and ironReflexes then
780-
evasionBase = evasionBase * 2
781-
end
782820
if modDB:Flag(nil, "ConvertBodyArmourArmourEvasionToWard") then
783821
evasionBase = evasionBase * (1 - ((m_min(modDB:Sum("BASE", nil, "BodyArmourArmourEvasionToWardPercent"), 100) or 0) / 100))
784822
end

src/Modules/ModParser.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,8 +2629,12 @@ local specialModList = {
26292629
mod("Damage", "MORE", num, nil, ModFlag.Attack, { type = "Multiplier", var = "CastLast8Seconds", limit = max, limitTotal = true }),
26302630
} end,
26312631
-- Juggernaut
2632-
["armour received from body armour is doubled"] = { flag("Unbreakable") },
2633-
["armour from equipped body armour is doubled"] = { flag("Unbreakable") },
2632+
["(%w+%W?[^r%W]%w+) r?e?c?e?i?v?e?d? ?from ?e?q?u?i?p?p?e?d? ?(%w+%W?%w+) is doubled"] = function(_, stat, slot)
2633+
if slot == "shield" then slot = "Weapon 2" end
2634+
return {
2635+
flag(string.gsub(" "..stat, "%W%l", string.upper):sub(2):gsub(" ", "") .. "From" .. string.gsub(" "..slot, "%W%l", string.upper):sub(2) .. "isDoubled")
2636+
}
2637+
end,
26342638
["action speed cannot be modified to below base value"] = { mod("MinimumActionSpeed", "MAX", 100, { type = "GlobalEffect", effectType = "Global", unscalable = true }) },
26352639
["movement speed cannot be modified to below base value"] = { flag("MovementSpeedCannotBeBelowBase") },
26362640
["you cannot be slowed to below base speed"] = { mod("MinimumActionSpeed", "MAX", 100, { type = "GlobalEffect", effectType = "Global", unscalable = true }) },

0 commit comments

Comments
 (0)