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

Resources regen is faster and more efficient, we can now add new resources without fear!

git-svn-id: http://svn.net-core.org/repos/t-engine4@5699 51575b47-30f0-44d4-a5cc-537603b46e54
parent e71914a6
No related branches found
No related tags found
No related merge requests found
......@@ -108,8 +108,27 @@ function _M:init(t)
end
end
function _M:recomputeRegenResources()
if not self._no_save_fields.regenResourcesFast then return end
local fstr = "return function(self) "
local r
for i = 1, #_M.resources_def do
r = _M.resources_def[i]
if r.regen_prop and (not r.talent or self:knowTalent(r.talent)) then
fstr = fstr..("self.%s = util.bound(self.%s + self.%s, self.%s, self.%s) "):format(r.short_name, r.short_name, r.regen_prop, r.minname, r.maxname)
self[r.short_name] = util.bound(self[r.short_name] + self[r.regen_prop], self[r.minname], self[r.maxname])
end
end
fstr = fstr.." end"
self.regenResourcesFast = loadstring(fstr)()
end
--- Regen resources, shout be called in your actor's act() method
function _M:regenResources()
if self.regenResourcesFast then return self:regenResourcesFast() end
local r
for i = 1, #_M.resources_def do
r = _M.resources_def[i]
......
......@@ -61,6 +61,9 @@ module(..., package.seeall, class.inherit(
-- Dont save the can_see_cache
_M._no_save_fields.can_see_cache = true
-- Activate fast regen computing
_M._no_save_fields.regenResourcesFast = true
-- Use distance maps
_M.__do_distance_map = true
......@@ -233,6 +236,12 @@ function _M:init(t, no_default)
self:resetCanSeeCache()
self:recomputeGlobalSpeed()
self:recomputeRegenResources()
end
function _M:loaded()
engine.Actor.loaded(self)
self:recomputeRegenResources()
end
function _M:onEntityMerge(a)
......@@ -3036,6 +3045,8 @@ function _M:learnPool(t)
self.resource_pool_refs[self.T_RELOAD] = (self.resource_pool_refs[self.T_RELOAD] or 0) + 1
end
self:recomputeRegenResources()
return true
end
......@@ -3064,6 +3075,8 @@ function _M:unlearnTalent(t_id, nb, no_unsustain)
-- Unsustain ?
if not no_unsustain and not self:knowTalent(t_id) and t.mode == "sustained" and self:isTalentActive(t_id) then self:forceUseTalent(t_id, {ignore_energy=true}) end
self:recomputeRegenResources()
return true
end
......
......@@ -63,7 +63,7 @@ load_tips = {
{image="/data/gfx/shockbolt/npc/humanoid_human_rogue.png", text=[[Stunning an opponent slows down their movement and reduces their damage output, giving you the opportunity to tactically reposition or finish them off at less risk.]]},
{image="/data/gfx/shockbolt/npc/humanoid_human_bandit.png", text=[[Movement is key on the battlefield. A stationary fighter will become a dead fighter. One must always seek the position of greatest tactical advantage and continue to re-evaluate throughout the battle.]]},
{image="/data/gfx/shockbolt/npc/humanoid_orc_orc_blood_mage.png", text=[[In the Age of Pyre the orcs learned the secrets of magic, and with their newfound powers nearly overcame the whole of Maj'Eyal.]]},
{image="/data/gfx/shockbolt/npc/humanoid_orc_orc_berserker.png", text=[[The orcs once terrorised the whole content. In the Age of Ascendancy they were rendered extinct, but rumours abound of hidden groups biding their time to return.]]},
{image="/data/gfx/shockbolt/npc/humanoid_orc_orc_berserker.png", text=[[The orcs once terrorised the whole continent. In the Age of Ascendancy they were rendered extinct, but rumours abound of hidden groups biding their time to return.]]},
{image="/data/gfx/shockbolt/npc/humanoid_human_fire_wyrmic.png", text=[[Intense willpower lets wyrmics take on the natural powers of dragons.]]},
{image="/data/gfx/loadtiles/alchemist_golem.png", text=[[Alchemist can transmute gems to create fiery explosions, and are known to travel with a sturdy golem for extra protection.]]},
{image="/data/gfx/shockbolt/npc/construct_golem_athamathon_the_giant_golem.png", text=[[In the Age of Pyre the giant golem Atamathon was built with the sole purpose of stopping the orcish leader Garkul the Devourer. The golem was single-handedly destroyed by the orc, who then slaughtered an army of thousands before the demonic fighter was finally slain.]]},
......
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