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

fixed Berserk (wont loose attack)

stats on levelup are bound without considering items
traps are correctly detected by the Sense spell


git-svn-id: http://svn.net-core.org/repos/t-engine4@645 51575b47-30f0-44d4-a5cc-537603b46e54
parent f655cec8
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,7 @@ end
--- Gains some experience
-- If a levelup happens it calls self:levelup(), modules are encourraged to rewrite it to do whatever is needed.
function _M:gainExp(value)
self.changed = true
self.exp = math.max(0, self.exp + value)
while self:getExpChart(self.level + 1) and self.exp >= self:getExpChart(self.level + 1) and (not self.actors_max_level or self.level < self.actors_max_level) do
-- At max level, if any
......
......@@ -52,6 +52,7 @@ end
--- Heal some
function _M:heal(value, src)
self.life = util.bound(self.life + value, 0, self.max_life)
self.changed = true
end
--- Remove some HP from an actor
......@@ -60,6 +61,7 @@ end
function _M:takeHit(value, src)
if self.onTakeHit then value = self:onTakeHit(value, src) end
self.life = self.life - value
self.changed = true
if self.life <= 0 then
game.logSeen(self, "%s killed %s!", src.name:capitalize(), self.name)
return self:die(src)
......@@ -70,6 +72,7 @@ end
function _M:die(src)
game.level:removeEntity(self)
self.dead = true
self.changed = true
self:check("on_die", src)
end
......
......@@ -74,6 +74,7 @@ function _M:incStat(stat, val)
if self:getStat(stat) ~= old then
self:onStatChange(stat, self:getStat(stat) - old)
end
self.changed = true
return self:getStat(stat) - old
end
......@@ -83,7 +84,8 @@ end
-- @param stat the stat id
-- @param scale a scaling factor, nil means max stat value
-- @param raw false if the scaled result must be rounded down
function _M:getStat(stat, scale, raw)
-- @param no_inc if true it wont include stats gained by self.inc_stats
function _M:getStat(stat, scale, raw, no_inc)
local val, inc
if type(stat) == "string" then
val = self.stats[_M.stats_def[stat].id]
......@@ -92,7 +94,7 @@ function _M:getStat(stat, scale, raw)
val = self.stats[stat]
inc = self.inc_stats[stat]
end
val = util.bound(val, _M.stats_def[stat].min, _M.stats_def[stat].max) + inc
val = util.bound(val, _M.stats_def[stat].min, _M.stats_def[stat].max) + ((not no_inc) and inc or 0)
if scale then
if not raw then
val = math.floor(val * scale / _M.stats_def[stat].max)
......
......@@ -169,6 +169,7 @@ function _M:playerFOV()
if self:attr("detect_object") and game.level.map(x, y, game.level.map.OBJECT) then ok = true end
if self:attr("detect_trap") and game.level.map(x, y, game.level.map.TRAP) then
game.level.map(x, y, game.level.map.TRAP):setKnown(self, true)
game.level.map:updateMap(x, y)
ok = true
end
......
......@@ -33,8 +33,8 @@ newTalent{
end
return {
atk = self:addTemporaryValue("combat_dam", 5 + self:getStr(7) * self:getTalentLevel(t)),
dam = self:addTemporaryValue("combat_atk", 5 + self:getDex(7) * self:getTalentLevel(t)),
dam = self:addTemporaryValue("combat_dam", 5 + self:getStr(7) * self:getTalentLevel(t)),
atk = self:addTemporaryValue("combat_atk", 5 + self:getDex(7) * self:getTalentLevel(t)),
def = self:addTemporaryValue("combat_def", -5 - 2 * (self:getTalentLevelRaw(t)-1)),
armor = self:addTemporaryValue("combat_armor", -5 - 2 * (self:getTalentLevelRaw(t)-1)),
}
......
......@@ -63,7 +63,7 @@ function _M:incStat(v)
self:simplePopup("Not enough stat points", "You have no stat points left!")
return
end
if self.actor:getStat(self.sel) >= self.actor.level * 1.4 + 20 then
if self.actor:getStat(self.sel, nil, nil, true) >= self.actor.level * 1.4 + 20 then
self:simplePopup("Stat is at the maximun for your level", "You can not increase this stat further until next level!")
return
end
......@@ -72,7 +72,7 @@ function _M:incStat(v)
return
end
else
if self.actor_dup:getStat(self.sel) == self.actor:getStat(self.sel) then
if self.actor_dup:getStat(self.sel, nil, nil, true) == self.actor:getStat(self.sel, nil, nil, true) then
self:simplePopup("Impossible", "You cannot take out more points!")
return
end
......
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