diff --git a/game/engines/default/engine/interface/PlayerRest.lua b/game/engines/default/engine/interface/PlayerRest.lua index 92c0e5e582373e6e47fd7dd4aa7446d67c1b4d7c..0a002ae168d7a01c4ec385999b93f3f28483c90d 100644 --- a/game/engines/default/engine/interface/PlayerRest.lua +++ b/game/engines/default/engine/interface/PlayerRest.lua @@ -40,6 +40,8 @@ function _M:restInit(turns, what, past, on_end) game.log(what:capitalize().." starts...") + self:onRestStart() + local ret, msg = self:restCheck() if ret and self.resting and self.resting.rest_turns and self.resting.cnt > self.resting.rest_turns then ret = false msg = nil end if not ret then @@ -50,6 +52,16 @@ function _M:restInit(turns, what, past, on_end) end end +--- We started resting +-- Rewrite this method to do whatever you need +function _M:onRestStart() +end + +--- We stopped resting +-- Rewrite this method to do whatever you need +function _M:onRestStop() +end + --- Rest a turn -- For a turn based game you want in you player's act() something like that:<br/> -- <pre> @@ -91,6 +103,7 @@ function _M:restStop(msg) end if self.resting.on_end then self.resting.on_end(self.resting.cnt, self.resting.rest_turns) end + self:onRestStop() self.resting = nil return true end diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 692a2a891c85ab1cf9e50fbe187ff30797bf29c2..14027a9bb3752ead862a2cb126166f9cd814b345 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -576,6 +576,22 @@ local function spotHostiles(self) return seen end +--- We started resting +function _M:onRestStart() + if self:attr("equilibrium_regen_on_rest") and not self.resting.equilibrium_regen then + self:attr("equilibrium_regen", self:attr("equilibrium_regen_on_rest")) + self.resting.equilibrium_regen = self:attr("equilibrium_regen_on_rest") + end +end + +--- We stopped resting +function _M:onRestStop() + if self.resting.equilibrium_regen then + self:attr("equilibrium_regen", -self.resting.equilibrium_regen) + self.resting.equilibrium_regen = nil + end +end + --- Can we continue resting ? -- We can rest if no hostiles are in sight, and if we need life/mana/stamina/psi (and their regen rates allows them to fully regen) function _M:restCheck() @@ -606,6 +622,7 @@ function _M:restCheck() if self:getMana() < self:getMaxMana() and self.mana_regen > 0 then return true end if self:getStamina() < self:getMaxStamina() and self.stamina_regen > 0 then return true end if self:getPsi() < self:getMaxPsi() and self.psi_regen > 0 then return true end + if self:getEquilibrium() > 0 and self.equilibrium_regen < 0 then return true end if self.life < self.max_life and self.life_regen> 0 then return true end for act, def in pairs(game.party.members) do if game.level:hasEntity(act) and not act.dead then if act.life < act.max_life and act.life_regen> 0 then return true end diff --git a/game/modules/tome/data/talents/gifts/call.lua b/game/modules/tome/data/talents/gifts/call.lua index db962d7e4c27a0e1219e8b74bd43750f8edccfce..3d6b8be5fdc741c08c77a72ab55a772621c7566a 100644 --- a/game/modules/tome/data/talents/gifts/call.lua +++ b/game/modules/tome/data/talents/gifts/call.lua @@ -24,9 +24,15 @@ newTalent{ points = 5, message = "@Source@ meditates on nature.", mode = "sustained", - cooldown = 10, + cooldown = 20, range = 10, no_npc_use = true, + on_learn = function(self, t) + self.equilibrium_regen_on_rest = (self.equilibrium_regen_on_rest or 0) - 0.5 + end, + on_unlearn = function(self, t) + self.equilibrium_regen_on_rest = (self.equilibrium_regen_on_rest or 0) + 0.5 + end, activate = function(self, t) local pt = 2 + self:combatTalentMindDamage(t, 20, 120) / 10 local save = 5 + self:combatTalentMindDamage(t, 10, 40) @@ -51,11 +57,13 @@ newTalent{ local pt = 2 + self:combatTalentMindDamage(t, 20, 120) / 10 local save = 5 + self:combatTalentMindDamage(t, 10, 40) local heal = 5 + self:combatTalentMindDamage(t, 12, 30) + local rest = 0.5 * self:getTalentLevelRaw(t) return ([[Meditate on your link with Nature. While meditating you regenerate %d equilibrium per turn, your mental save is increased by %d and your healing factor by %d%%. Your deep meditation does not however let you deal damage correctly, reducing your damage done by 50%%. + Also, any time you are resting (even with Meditation not sustained) you enter a simple meditation state that lets you regenerate %0.2f equilibrium per turn. The effects will increase with your mindpower.]]): - format(pt, save, heal) + format(pt, save, heal, rest) end, }