Skip to content

Commit 042211f

Browse files
LocalIdentityLocalIdentity
andauthored
Fix Heraldry not granting Exposure to enemies (#9179)
* Fix Heraldry not granting Exposure to enemies With my change in #9173, I moved the place in the file where EnemyModifiers were calculated but didn't realise that they also need to be recalculated later so that mods that rely on "AffectedBy" x still work Changed it to use a cache so it doesn't duplicate earlier added mods * Test for bug * Fix test * Enemy curse effect test --------- Co-authored-by: LocalIdentity <[email protected]>
1 parent ae2200a commit 042211f

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

spec/System/TestItemMods_spec.lua

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,4 +553,36 @@ describe("TetsItemMods", function()
553553
assert.are_not.equals(64, build.calcsTab.mainOutput.Armour)
554554
runCallback("OnFrame")
555555
end)
556+
557+
it("Heralds apply exposure with Heraldry", function()
558+
build.skillsTab:PasteSocketGroup("Arc 20/0 Default 1\nHerald of Thunder 20/0 Default 1\n")
559+
runCallback("OnFrame")
560+
561+
assert.are.equals(0.5, build.calcsTab.calcsOutput.LightningEffMult)
562+
563+
build.configTab.input.customMods = [[
564+
Nearby Enemies have Cold Exposure while you are affected by Herald of Ice
565+
Nearby Enemies have Fire Exposure while you are affected by Herald of Ash
566+
Nearby Enemies have Lightning Exposure while you are affected by Herald of Thunder
567+
]]
568+
build.configTab:BuildModList()
569+
runCallback("OnFrame")
570+
571+
assert.are.equals(0.6, build.calcsTab.calcsOutput.LightningEffMult)
572+
end)
573+
574+
it("Enemy self curse effect", function()
575+
build.skillsTab:PasteSocketGroup("Arc 20/0 Default 1\nConductivity 14/0 Default 1\n")
576+
runCallback("OnFrame")
577+
578+
assert.are.equals(0.8, build.calcsTab.calcsOutput.LightningEffMult)
579+
580+
build.configTab.input.customMods = [[
581+
Nearby Enemies have 20% increased Effect of Curses on them
582+
]]
583+
build.configTab:BuildModList()
584+
runCallback("OnFrame")
585+
586+
assert.are.equals(0.86, build.calcsTab.calcsOutput.LightningEffMult)
587+
end)
556588
end)

src/Modules/CalcPerform.lua

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,19 @@ local function determineCursePriority(curseName, activeSkill)
565565
return basePriority + socketPriority + slotPriority + sourcePriority
566566
end
567567

568-
local function applyEnemyModifiers(actor)
569-
-- Process enemy modifiers
568+
local function applyEnemyModifiers(actor, clearCache)
569+
if clearCache or not actor.appliedEnemyModifiers then
570+
actor.appliedEnemyModifiers = { }
571+
end
572+
local cache = actor.appliedEnemyModifiers
573+
local enemyDB = actor.enemy.modDB
570574
for _, value in ipairs(actor.modDB:Tabulate(nil, nil, "EnemyModifier")) do
571-
actor.enemy.modDB:AddMod(modLib.setSource(value.value.mod, value.value.mod.source or value.mod.source))
575+
local mod = value.value and value.value.mod
576+
if mod and not cache[mod] then
577+
local source = mod.source or value.mod.source
578+
enemyDB:AddMod(modLib.setSource(mod, source))
579+
cache[mod] = true
580+
end
572581
end
573582
end
574583

@@ -579,6 +588,9 @@ local function doActorMisc(env, actor)
579588
local output = actor.output
580589
local condList = modDB.conditions
581590

591+
-- Process enemy modifiers
592+
applyEnemyModifiers(actor)
593+
582594
-- Add misc buffs/debuffs
583595
if env.mode_combat then
584596
if env.player.mainSkill.baseSkillModList:Flag(nil, "Cruelty") then
@@ -1170,11 +1182,11 @@ function calcs.perform(env, skipEHP)
11701182
output.WarcryPower = modDB:Override(nil, "WarcryPower") or modDB:Sum("BASE", nil, "WarcryPower") or 0
11711183
modDB.multipliers["WarcryPower"] = output.WarcryPower
11721184

1173-
applyEnemyModifiers(env.player)
1185+
applyEnemyModifiers(env.player, true)
11741186
if env.minion then
1175-
applyEnemyModifiers(env.minion)
1187+
applyEnemyModifiers(env.minion, true)
11761188
end
1177-
applyEnemyModifiers(env.enemy)
1189+
applyEnemyModifiers(env.enemy, true)
11781190

11791191
for _, activeSkill in ipairs(env.player.activeSkillList) do
11801192
if activeSkill.skillTypes[SkillType.Brand] then

0 commit comments

Comments
 (0)