Skip to content
Snippets Groups Projects
Commit de799e67 authored by dg's avatar dg
Browse files

Meditation now also have a passive effect: when resting it grants an equilibrium regen

git-svn-id: http://svn.net-core.org/repos/t-engine4@4811 51575b47-30f0-44d4-a5cc-537603b46e54
parent b6ebb60d
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
......
......@@ -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,
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment