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

Fixed stats inherit between base template and npcs

git-svn-id: http://svn.net-core.org/repos/t-engine4@5080 51575b47-30f0-44d4-a5cc-537603b46e54
parent a3b612f5
No related branches found
No related tags found
No related merge requests found
......@@ -765,6 +765,7 @@ function _M:loadList(file, no_default, res, mod, loaded)
-- Do we inherit things ?
if t.base then
local temp = table.clone(res[t.base], true, {define_as = true})
if res[t.base].onEntityMerge then res[t.base]:onEntityMerge(temp) end
table.mergeAppendArray(temp, t, true)
t = temp
t.base = nil
......
......@@ -225,6 +225,15 @@ function _M:init(t, no_default)
self:recomputeGlobalSpeed()
end
function _M:onEntityMerge(a)
-- Remove stats to make new stats work
for i, s in ipairs(_M.stats_def) do
if a.stats[i] then
a.stats[s.short_name], a.stats[i] = a.stats[i], nil
end
end
end
function _M:useEnergy(val)
engine.Actor.useEnergy(self, val)
......
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