Skip to content
Snippets Groups Projects
Commit 20cdac78 authored by DarkGod's avatar DarkGod
Browse files

Merge branch 'ActorStatsFix' into 'master'

ActorStats Fix

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

Entity.init will automatically initialize the compute_vals table for temporary values.

See merge request !362
parents 7ecece3e 416b9bb8
No related branches found
No related tags found
No related merge requests found
......@@ -125,7 +125,6 @@ function _M:init(t, no_default)
error("Entity definition has a closure: "..err)
end
end
if self.color then
self.color_r = self.color.r
self.color_g = self.color.g
......@@ -941,11 +940,11 @@ 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 self.compute_vals then util.send_error_backtrace("removeTemporaryValue: attempting to remove prop "..tostring(prop).." with no temporary values initialized") return end
if not id then util.send_error_backtrace("removeTemporaryValue: error removing prop "..tostring(prop).." with id "..tostring(id)) 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