diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 451a580c1925ead2103dd8785bdd7c554a8a5e90..5d43f8eed3beae3fe0dbb11ae611196c8228846e 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -8002,12 +8002,7 @@ function _M:checkStillInCombat() -- Ok no more in combat! self.in_combat = nil - for tid, _ in pairs(self.sustain_talents) do - local t = self:getTalentFromId(tid) - if t.deactivate_on and t.deactivate_on.no_combat then - self:forceUseTalent(tid, {ignore_energy=true, ignore_cd=true}) - end - end + self:checkSustainDeactivate("no_combat") self:updateInCombatStatus() end @@ -8061,4 +8056,19 @@ function _M:projectDoAct(typ, tg, damtype, dam, particles, px, py, tmp) DamageType:projectingFor(self, nil) end end +end + +function _M:checkSustainDeactivate(check) + for tid, _ in pairs(self.sustain_talents) do + local t = self:getTalentFromId(tid) + if t.deactivate_on and t.deactivate_on[check] then + local ok = false + if type(t.deactivate_on[check]) == "function" then + ok = t.deactivate_on[check](self, t) + else + ok = true + end + if ok then self:forceUseTalent(tid, {ignore_energy=true, ignore_cd=true}) end + end + end end \ No newline at end of file diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 9a070bbc53a38c164f68a81cb0f12b4578e1f9a3..a5134d06809c378c0fa4fcbedcc46b96ad4deaa2 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -1153,12 +1153,8 @@ function _M:restStep() self:fireTalentCheck("callbackOnWait") -- Disable sustains that deactivate on rest - for tid, _ in pairs(self.sustain_talents) do - local t = self:getTalentFromId(tid) - if t.deactivate_on and t.deactivate_on.rest then - self:forceUseTalent(tid, {ignore_energy=true, ignore_cd=true}) - end - end + self:checkSustainDeactivate("rest") + return true end end @@ -1237,12 +1233,7 @@ function _M:runCheck(ignore_memory) if noticed then return false, noticed end local can, noticed = engine.interface.PlayerRun.runCheck(self) if can then - for tid, _ in pairs(self.sustain_talents) do - local t = self:getTalentFromId(tid) - if t.deactivate_on and t.deactivate_on.run then - self:forceUseTalent(tid, {ignore_energy=true, ignore_cd=true}) - end - end + self:checkSustainDeactivate("run") end return can, noticed end