From d865d967bd1737cf8c075e841004d7357f00079e Mon Sep 17 00:00:00 2001 From: Shibari <ShibariTOME@Gmail.com> Date: Tue, 31 Dec 2019 05:07:06 -0500 Subject: [PATCH] Add an ActorTalent.deactivate_on property for things that disable at various events Copying and pasting really awkward callbacks for this was getting old. Also, theres an unknown bug with autocast and the deactivate callbacks causing permanent stat loss, hopefully moving where they happen indirectly fixes it. --- game/modules/tome/class/Actor.lua | 6 ++++++ game/modules/tome/class/Player.lua | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index c38715116f..a6d153c1f1 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -8002,6 +8002,12 @@ 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}) + end + end self:updateInCombatStatus() end diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index d0d94e9741..9a070bbc53 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -1151,6 +1151,14 @@ function _M:restStep() self:useEnergy() self.resting.cnt = self.resting.cnt + 1 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 return true end end @@ -1227,8 +1235,16 @@ function _M:runCheck(ignore_memory) if game.level.map:checkAllEntities(x, y, "store") then noticed = "store entrance spotted" ; return false, noticed end end) if noticed then return false, noticed end - - return engine.interface.PlayerRun.runCheck(self) + 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 + end + return can, noticed end --- Move with the mouse -- GitLab