Skip to content
Snippets Groups Projects
Commit a884870b authored by Hachem_Muche's avatar Hachem_Muche
Browse files

ActorStats will automatically clone a stats table provided with an actor...

ActorStats will automatically clone a stats table provided with an actor definition to prevent multiple actors referencing the same table.  (for static definitions, like those in ToME necrotic minions)

Entity.init will automatically initialize the compute_vals table for temporary values.
parent 7ecece3e
No related branches found
No related tags found
No related merge requests found
......@@ -125,7 +125,7 @@ function _M:init(t, no_default)
error("Entity definition has a closure: "..err)
end
end
self.compute_vals = self.compute_vals or {n=0}
if self.color then
self.color_r = self.color.r
self.color_g = self.color.g
......@@ -941,11 +941,10 @@ end
-- @int id the id of the increase to delete
-- @param[type=boolean] noupdate if true the actual property is not changed and needs to be changed by the caller
function _M:removeTemporaryValue(prop, id, noupdate)
if not id then util.send_error_backtrace("error removing prop "..tostring(prop).." with id nil") return end
local oldval = self.compute_vals[id]
-- print("removeTempVal", prop, oldval, " :=: ", id)
if not id then util.send_error_backtrace("error removing prop "..tostring(prop).." with id nil") return end
self.compute_vals[id] = nil
-- Find the base, one removed from the last prop
local initial_base, initial_prop
if type(prop) == "table" then
......
......@@ -51,8 +51,8 @@ end
--- Initialises stats with default values if needed
function _M:init(t)
self.stats = t.stats or {}
self.inc_stats = t.inc_stats or {}
self.stats = t.stats and table.clone(t.stats) or {}
self.inc_stats = t.inc_stats and table.clone(t.inc_stats) or {}
for i, s in ipairs(_M.stats_def) do
if self.stats[i] then
elseif self.stats[s.short_name] then
......
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