diff --git a/game/engines/default/engine/Entity.lua b/game/engines/default/engine/Entity.lua index dee17fd7df41d8384612e593aa1cee9f8e960fec..23c178a0a4a755db6c0606233cd7b6adc045a0f6 100644 --- a/game/engines/default/engine/Entity.lua +++ b/game/engines/default/engine/Entity.lua @@ -428,7 +428,7 @@ function _M:addTemporaryValue(prop, v, noupdate) if type(v) == "number" then -- Simple addition base[prop] = (base[prop] or 0) + v - self:onTemporaryValueChange(prop, nil, v) + self:onTemporaryValueChange(prop, v, base) print("addTmpVal", base, prop, v, " :=: ", #t, id) elseif type(v) == "table" then for k, e in pairs(v) do @@ -479,7 +479,7 @@ function _M:removeTemporaryValue(prop, id, noupdate) if type(v) == "number" then -- Simple addition base[prop] = base[prop] - v - self:onTemporaryValueChange(prop, nil, v) + self:onTemporaryValueChange(prop, -v, base) print("delTmpVal", prop, v) elseif type(v) == "table" then for k, e in pairs(v) do @@ -499,9 +499,9 @@ end --- Called when a temporary value changes (added or deleted) -- This does nothing by default, you can overload it to react to changes -- @param prop the property changing --- @param sub the sub element of the property if it is a table, or nil -- @param v the value of the change -function _M:onTemporaryValueChange(prop, sub, v) +-- @param base the base table of prop +function _M:onTemporaryValueChange(prop, v, base) end --- Increases/decreases an attribute diff --git a/game/modules/angband/class/Actor.lua b/game/modules/angband/class/Actor.lua index e72ffe8c0bb66e5d0c9db99f0b98b804c7e2604c..e6cb7b130a0bae2e363fc743ffd92b3090db8ac5 100644 --- a/game/modules/angband/class/Actor.lua +++ b/game/modules/angband/class/Actor.lua @@ -140,10 +140,10 @@ end --- Called when a temporary value changes (added or deleted) -- Takes care to compute energy mod -- @param prop the property changing --- @param sub the sub element of the property if it is a table, or nil -- @param v the value of the change -function _M:onTemporaryValueChange(prop, sub, v) - if prop == "speed" then +-- @param base the base table of prop +function _M:onTemporaryValueChange(prop, v, base) + if prop == "speed" and base == self then self:computeEnergyMod() end end diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index f489cff67fa81ed1b9f56f09dc067986d26fb98f..910c90779662bfa333ff5145f7a3d9e7c1be4b54 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -943,7 +943,7 @@ function _M:onTakeHit(value, src) self:forceUseTalent(self.T_SHIELD_OF_LIGHT, {ignore_energy=true}) end end - + -- Second Life if self:isTalentActive(self.T_SECOND_LIFE) and value >= self.life then local sl = self.max_life * (0.05 + self:getTalentLevelRaw(self.T_SECOND_LIFE)/25) @@ -952,7 +952,7 @@ function _M:onTakeHit(value, src) game.logSeen(self, "%s has been saved by a blast of positive energy!", self.name:capitalize()) self:forceUseTalent(self.T_SECOND_LIFE, {ignore_energy=true}) end - + if value >= self.life and self.ai_state and self.ai_state.can_reform then local t = self:getTalentFromId(self.T_SHADOW_REFORM) if rng.percent(t.getChance(self, t)) then @@ -1307,11 +1307,11 @@ end --- Called when a temporary value changes (added or deleted) -- Takes care to call onStatChange when needed -- @param prop the property changing --- @param sub the sub element of the property if it is a table, or nil -- @param v the value of the change -function _M:onTemporaryValueChange(prop, sub, v) - if prop == "inc_stats" then - self:onStatChange(sub, v) +-- @param base the base table of prop +function _M:onTemporaryValueChange(prop, v, base) + if base == self.inc_stats then + self:onStatChange(prop, v) end end