Skip to content

Commit

Permalink
Update manager_effect_aura.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
bmos committed Feb 21, 2022
1 parent d14c96f commit c036292
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions scripts/manager_effect_aura.lua
Expand Up @@ -36,6 +36,21 @@ local function isSourceDisabled(nodeChar)
end

--- This function is called when effect components are changed.
local function onEffectRemoved(nodeEffect)
if checkEffectRecursion(nodeEffect, auraString) and not checkEffectRecursion(nodeEffect, fromAuraString) then
local nodeCT = nodeEffect.getChild("...");
local tokenCT = CombatManager.getTokenFromCT(nodeCT);
if tokenCT then
if DB.getValue(nodeEffect, aEffectVarMap["nActive"]["sDBField"], 0) ~= 1 then
checkDeletedAuraEffects(nodeEffect);
else
updateAuras(tokenCT);
end
end
end
end

--- This function is called when effects are removed.
local function onEffectChanged(nodeEffect)
if checkEffectRecursion(nodeEffect, auraString) and not checkEffectRecursion(nodeEffect, fromAuraString) then
local nodeCT = nodeEffect.getChild("...");
Expand Down Expand Up @@ -536,9 +551,11 @@ end
local function manageHandlers(bRemove)
if bRemove then
DB.removeHandler(DB.getPath(CombatManager.CT_LIST .. ".*.effects.*"), "onChildUpdate", onEffectChanged)
DB.removeHandler(DB.getPath(CombatManager.CT_LIST .. ".*.effects"), 'onChildDeleted', onEffectRemoved)
DB.removeHandler(DB.getPath(CombatManager.CT_LIST .. ".*.status"), "onUpdate", onStatusChanged)
else
DB.addHandler(DB.getPath(CombatManager.CT_LIST .. ".*.effects.*"), "onChildUpdate", onEffectChanged)
DB.addHandler(DB.getPath(CombatManager.CT_LIST .. ".*.effects"), 'onChildDeleted', onEffectRemoved)
DB.addHandler(DB.getPath(CombatManager.CT_LIST .. ".*.status"), "onUpdate", onStatusChanged)
end
end
Expand Down Expand Up @@ -609,9 +626,6 @@ function onInit()
OOBManager.registerOOBMsgHandler(OOB_MSGTYPE_AURAAPPLYSILENT, handleApplyEffectSilent);
OOBManager.registerOOBMsgHandler(OOB_MSGTYPE_AURAEXPIRESILENT, handleExpireEffectSilent);

-- register function to recalculate auras when effects are deleted
CombatManager.setCustomDeleteCombatantEffectHandler(checkDeletedAuraEffects);

-- set up the effect manager proxy functions for the detected ruleset
local DetectedEffectManager = nil
if EffectManager35E then
Expand Down

0 comments on commit c036292

Please sign in to comment.