From fe86037d216d07f17b217ccf27bd22b3a94e703d Mon Sep 17 00:00:00 2001 From: DarkGod <darkgod@net-core.org> Date: Mon, 3 Aug 2020 15:21:15 +0200 Subject: [PATCH] New "callbackOnResurrect" --- game/modules/tome/class/Actor.lua | 2 ++ game/modules/tome/data/talents/undeads/lich.lua | 4 ++-- game/modules/tome/dialogs/DeathDialog.lua | 14 ++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 352403d06a..a76cfc9a28 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -3138,6 +3138,7 @@ function _M:die(src, death_note) self:move(self.x, self.y, true) self:check("on_resurrect", "basic_resurrect") self:triggerHook{"Actor:resurrect", reason="basic_resurrect"} + self:fireTalentCheck("callbackOnResurrect", "basic_resurrect") if self:attr("self_resurrect_chat") then local chat = Chat.new(self.self_resurrect_chat, self, game.player) @@ -5984,6 +5985,7 @@ local sustainCallbackCheck = { callbackOnDeath = "talents_on_death", callbackOnDeathbox = "talents_on_deathbox", callbackOnSummonDeath = "talents_on_summon_death", + callbackOnResurrect = "talents_on_resurrect", callbackOnDie = "talents_on_die", callbackOnKill = "talents_on_kill", callbackOnSummonKill = "talents_on_summon_kill", diff --git a/game/modules/tome/data/talents/undeads/lich.lua b/game/modules/tome/data/talents/undeads/lich.lua index 791afdda8e..2c7fde94fe 100644 --- a/game/modules/tome/data/talents/undeads/lich.lua +++ b/game/modules/tome/data/talents/undeads/lich.lua @@ -35,7 +35,7 @@ newTalent{ self.lich_first_rez = true _G.a=dialog dialog:cleanActor(self) - dialog:resurrectBasic(self) + dialog:resurrectBasic(self, "lich_rebirth") dialog:restoreResources(self) self:callTalent(self.T_LICH, "becomeLich") @@ -48,7 +48,7 @@ newTalent{ elseif not self:hasEffect(self.EFF_LICH_HUNGER) and not self.lich_no_more_regen then list[#list+1] = {name=("Lich Regeneration (%d turns)"):tformat(t.getTurns(self, t)), action=function() dialog:cleanActor(self) - dialog:resurrectBasic(self) + dialog:resurrectBasic(self, "lich_regen") dialog:restoreResources(self) game.level.map:particleEmitter(self.x, self.y, 1, "demon_teleport") diff --git a/game/modules/tome/dialogs/DeathDialog.lua b/game/modules/tome/dialogs/DeathDialog.lua index 48040ffaf0..7d2fc20a80 100644 --- a/game/modules/tome/dialogs/DeathDialog.lua +++ b/game/modules/tome/dialogs/DeathDialog.lua @@ -128,7 +128,7 @@ function _M:restoreResources(actor) end --- Basic resurrection -function _M:resurrectBasic(actor) +function _M:resurrectBasic(actor, reason) actor.dead = false actor.died = (actor.died or 0) + 1 @@ -160,6 +160,8 @@ function _M:resurrectBasic(actor) game.paused = true actor:checkTwoHandedPenalty() + + actor:fireTalentCheck("callbackOnResurrect", reason or "unknown") end --- Send the party to the Eidolon Plane @@ -177,7 +179,7 @@ function _M:eidolonPlane() local is_exploration = game.permadeath == game.PERMADEATH_INFINITE self:cleanActor(self.actor) - self:resurrectBasic(self.actor) + self:resurrectBasic(self.actor, "eidolon_plane") for e, _ in pairs(game.party.members) do self:cleanActor(e) end @@ -222,7 +224,7 @@ function _M:use(item) game.logPlayer(self.actor, "#LIGHT_BLUE#You resurrect! CHEATER!") self:cleanActor(self.actor) - self:resurrectBasic(self.actor) + self:resurrectBasic(self.actor, "cheat") self:restoreResources(self.actor) self.actor:check("on_resurrect", "cheat") self.actor:triggerHook{"Actor:resurrect", reason="cheat"} @@ -231,7 +233,7 @@ function _M:use(item) game.logPlayer(self.actor, "#LIGHT_RED#The Blood of Life rushes through your dead body. You come back to life!") self:cleanActor(self.actor) - self:resurrectBasic(self.actor) + self:resurrectBasic(self.actor, "blood_life") self:restoreResources(self.actor) world:gainAchievement("UNSTOPPABLE", actor) self.actor:check("on_resurrect", "blood_life") @@ -251,7 +253,7 @@ function _M:use(item) game.logPlayer(self.actor, "#YELLOW#Your bones magically knit back together. You are once more able to dish out pain to your foes!") self:cleanActor(self.actor) - self:resurrectBasic(self.actor) + self:resurrectBasic(self.actor, "skeleton") self:restoreResources(self.actor) world:gainAchievement("UNSTOPPABLE", actor) self.actor:check("on_resurrect", "skeleton") @@ -263,7 +265,7 @@ function _M:use(item) game.logPlayer(self.actor, "#YELLOW#Your %s is consumed and disappears! You come back to life!", o:getName{do_colour=true}) self:cleanActor(self.actor) - self:resurrectBasic(self.actor) + self:resurrectBasic(self.actor, "consume", o) self:restoreResources(self.actor) world:gainAchievement("UNSTOPPABLE", actor) self.actor:check("on_resurrect", "consume", o) -- GitLab