Skip to content

Commit 7763400

Browse files
github-actions[bot]PeecheyLocalIdentity
authored
[pob2-port] Add support for Sacrosanctum's Energy Shield Recoup mod (#9858)
* Apply changes from PathOfBuildingCommunity/PathOfBuilding-PoE2#1868 * Fix merge --------- Co-authored-by: Peechey <Peechey@users.noreply.github.com> Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent cfb33e3 commit 7763400

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

spec/System/TestItemMods_spec.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,21 @@ describe("TetsItemMods", function()
612612
assert.are.equals(baseFrenzyChargesMax + 1, build.calcsTab.calcsOutput.FrenzyChargesMax)
613613
assert.are.equals(baseEnduranceChargesMax + 1, build.calcsTab.calcsOutput.EnduranceChargesMax)
614614
end)
615+
616+
it("adds life recoup to energy shield recoup", function()
617+
build.configTab.input.customMods = [[
618+
20% of Damage taken Recouped as Life
619+
10% of Physical Damage taken Recouped as Life
620+
Damage taken Recouped as Life is also Recouped as Energy Shield
621+
]]
622+
build.configTab:BuildModList()
623+
runCallback("OnFrame")
624+
625+
assert.are.equals(20, build.calcsTab.calcsOutput.LifeRecoup)
626+
assert.are.equals(20, build.calcsTab.calcsOutput.EnergyShieldRecoup)
627+
assert.are.equals(10, build.calcsTab.calcsOutput.PhysicalLifeRecoup)
628+
assert.are.equals(10, build.calcsTab.calcsOutput.PhysicalEnergyShieldRecoup)
629+
end)
615630

616631
it("shows a fallback tooltip when an item's base is no longer supported", function()
617632
local item = new("Item", [[

src/Modules/CalcDefence.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,11 @@ function calcs.defence(env, actor)
14181418
end
14191419
end
14201420
end
1421+
local addToEnergyShieldFlag = "Add"..recoupType.."RecoupToEnergyShieldRecoup"
1422+
if modDB:Flag(nil, addToEnergyShieldFlag) then
1423+
local flagMod = modDB:Tabulate("FLAG", nil, addToEnergyShieldFlag)[1].mod
1424+
modDB:ReplaceMod("EnergyShieldRecoup", "BASE", baseRecoup, flagMod.source)
1425+
end
14211426
end
14221427

14231428
if modDB:Flag(nil, "UsePowerCharges") and modDB:Flag(nil, "PowerChargesConvertToAbsorptionCharges") then
@@ -1429,12 +1434,11 @@ function calcs.defence(env, actor)
14291434

14301435
for _, recoupType in ipairs(recoupTypeList) do
14311436
for _, damageType in ipairs(dmgTypeList) do
1437+
local recoup = modDB:Sum("BASE", nil, damageType..recoupType.."Recoup")
14321438
if recoupType == "Life" and modDB:Flag(nil, "EnergyShieldRecoupInsteadOfLife") then
14331439
output[damageType.."LifeRecoup"] = 0
1434-
local lifeRecoup = modDB:Sum("BASE", nil, damageType.."LifeRecoup")
1435-
modDB:NewMod(damageType.."EnergyShieldRecoup", "BASE", lifeRecoup, "Life Recoup Conversion")
1440+
modDB:NewMod(damageType.."EnergyShieldRecoup", "BASE", recoup, "Life Recoup Conversion")
14361441
else
1437-
local recoup = modDB:Sum("BASE", nil, damageType..recoupType.."Recoup")
14381442
output[damageType..recoupType.."Recoup"] = recoup * output[recoupType.."RecoveryRateMod"]
14391443
output["anyRecoup"] = output["anyRecoup"] + output[damageType..recoupType.."Recoup"]
14401444
if breakdown then
@@ -1449,9 +1453,13 @@ function calcs.defence(env, actor)
14491453
end
14501454
end
14511455
end
1456+
local addToEnergyShieldFlag = "Add"..recoupType.."RecoupToEnergyShieldRecoup"
1457+
if modDB:Flag(nil, addToEnergyShieldFlag) then
1458+
local flagMod = modDB:Tabulate("FLAG", nil, addToEnergyShieldFlag)[1].mod
1459+
modDB:ReplaceMod(damageType.."EnergyShieldRecoup", "BASE", recoup, flagMod.source)
1460+
end
14521461
end
14531462
end
1454-
14551463
-- pseudo recoup (eg %physical damage prevented from hits regenerated)
14561464
for _, resource in ipairs(recoupTypeList) do
14571465
if not modDB:Flag(nil, "No"..resource.."Regen") and not modDB:Flag(nil, "CannotGain"..resource) then

src/Modules/ModParser.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4617,6 +4617,9 @@ local specialModList = {
46174617
["recoup effects instead occur over 3 seconds"] = { flag("3SecondRecoup") },
46184618
["life recoup effects instead occur over 3 seconds"] = { flag("3SecondLifeRecoup") },
46194619
["recoup energy shield instead of life"] = { flag("EnergyShieldRecoupInsteadOfLife") },
4620+
["damage taken recouped as (%a+) is also recouped as energy shield"] = function(_, type) return {
4621+
flag("Add"..firstToUpper(type).."RecoupToEnergyShieldRecoup"),
4622+
} end,
46204623
["([%d%.]+)%% of physical damage prevented from hits in the past (%d+) seconds is regenerated as life per second"] = function(num, _, duration) return {
46214624
mod("PhysicalDamageMitigatedLifePseudoRecoup", "BASE", num * duration),
46224625
mod("PhysicalDamageMitigatedLifePseudoRecoupDuration", "BASE", duration),

0 commit comments

Comments
 (0)