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

Racial stat bonuses do not count toward the max of 60

Both base & actual stats are displayed in the leveling screen


git-svn-id: http://svn.net-core.org/repos/t-engine4@2184 51575b47-30f0-44d4-a5cc-537603b46e54
parent 57d7c141
No related branches found
No related tags found
No related merge requests found
......@@ -277,7 +277,7 @@ end
--- Apply all birth options to the actor
function _M:apply()
self.actor.descriptor = {}
local stats = {}
local stats, inc_stats = {}, {}
for i, d in ipairs(self.descriptors) do
print("[BIRTH] Applying descriptor "..d.name)
self.actor.descriptor[d.type] = d.name
......@@ -308,6 +308,11 @@ function _M:apply()
stats[stat] = (stats[stat] or 0) + inc
end
end
if d.inc_stats then
for stat, inc in pairs(d.inc_stats) do
inc_stats[stat] = (inc_stats[stat] or 0) + inc
end
end
if d.talents_types then
for t, v in pairs(d.talents_types) do
local mastery
......@@ -338,4 +343,7 @@ function _M:apply()
for stat, inc in pairs(stats) do
self.actor:incStat(stat, inc)
end
for stat, inc in pairs(inc_stats) do
self.actor:incIncStat(stat, inc)
end
end
......@@ -43,8 +43,8 @@ function _M:defineStat(name, short_name, default_value, min, max, desc)
self.stats_def[#self.stats_def].id = #self.stats_def
self.stats_def[short_name] = self.stats_def[#self.stats_def]
self["STAT_"..short_name:upper()] = #self.stats_def
self["get"..short_name:lower():capitalize()] = function(self, scale, raw)
return self:getStat(_M["STAT_"..short_name:upper()], scale, raw)
self["get"..short_name:lower():capitalize()] = function(self, scale, raw, no_inc)
return self:getStat(_M["STAT_"..short_name:upper()], scale, raw, no_inc)
end
end
......@@ -85,6 +85,23 @@ function _M:incStat(stat, val)
return self:getStat(stat) - old
end
--- Increases a stat additional value
-- @param stat the stat id to change
-- @param val the increment to add/substract
function _M:incIncStat(stat, val)
if type(stat) == "string" then
stat = _M.stats_def[stat].id
end
local old = self:getStat(stat)
self.inc_stats[stat] = self.inc_stats[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
--- Gets a stat value
-- Not that the engine also auto-defines stat specific methods on the form: self:getShortname().
-- If you stat short name is STR then it becomes getStr()
......
......@@ -65,7 +65,7 @@ newBirthDescriptor
"#GOLD#Life per levels:#LIGHT_BLUE# 12",
"#GOLD#Experience penality:#LIGHT_BLUE# 25%",
},
stats = { str=4, con=3, wil=3, mag=-2, dex=-2 },
inc_inc_stats = { str=4, con=3, wil=3, mag=-2, dex=-2 },
talents = {
[ActorTalents.T_DWARF_RESILIENCE]=1,
},
......
......@@ -70,7 +70,7 @@ newBirthDescriptor
"#GOLD#Life per levels:#LIGHT_BLUE# 9",
"#GOLD#Experience penality:#LIGHT_BLUE# 35%",
},
stats = { str=-2, mag=2, wil=3, cun=1, dex=1, con=0 },
inc_stats = { str=-2, mag=2, wil=3, cun=1, dex=1, con=0 },
experience = 1.3,
talents = { [ActorTalents.T_SHALOREN_SPEED]=1 },
copy = {
......@@ -96,7 +96,7 @@ newBirthDescriptor
"#GOLD#Life per levels:#LIGHT_BLUE# 11",
"#GOLD#Experience penality:#LIGHT_BLUE# 35%",
},
stats = { str=2, mag=-2, wil=1, cun=0, dex=3, con=1 },
inc_stats = { str=2, mag=-2, wil=1, cun=0, dex=3, con=1 },
experience = 1.3,
talents = { [ActorTalents.T_THALOREN_WRATH]=1 },
copy = {
......
......@@ -74,7 +74,7 @@ newBirthDescriptor
"#GOLD#Life per levels:#LIGHT_BLUE# 12",
"#GOLD#Experience penality:#LIGHT_BLUE# 20%",
},
stats = { str=-3, dex=3, con=1, cun=3, lck=5, },
inc_stats = { str=-3, dex=3, con=1, cun=3, lck=5, },
experience = 1.20,
talents = {
[ActorTalents.T_HALFLING_LUCK]=1,
......
......@@ -70,7 +70,7 @@ newBirthDescriptor
"#GOLD#Life per levels:#LIGHT_BLUE# 11",
"#GOLD#Experience penality:#LIGHT_BLUE# 15%",
},
stats = { str=1, mag=1, dex=1, wil=1 },
inc_stats = { str=1, mag=1, dex=1, wil=1 },
experience = 1.15,
talents = {
[ActorTalents.T_HIGHER_HEAL]=1,
......
......@@ -45,7 +45,7 @@ newBirthDescriptor{
Mage = "disallow",
},
},
stats = { str=4, con=1, wil=2, mag=-2, dex=-2 },
inc_stats = { str=4, con=1, wil=2, mag=-2, dex=-2 },
talents = {
[ActorTalents.T_ORC_FURY]=1,
},
......
......@@ -39,7 +39,7 @@ newBirthDescriptor{
Male = "allow",
},
},
stats = { str=4, con=3, wil=3, mag=-2, dex=-2 },
inc_stats = { str=4, con=3, wil=3, mag=-2, dex=-2 },
talents = {
-- [ActorTalents.T_DWARF_RESILIENCE]=1,
},
......
......@@ -84,7 +84,7 @@ newBirthDescriptor
Male = "allow",
},
},
stats = { str=3, con=5, wil=-2, mag=0, dex=1, cun=-2 },
inc_stats = { str=3, con=5, wil=-2, mag=0, dex=1, cun=-2 },
talents_types = {
["undead/ghoul"]={true, 0.1},
},
......@@ -130,7 +130,7 @@ newBirthDescriptor
Male = "allow",
},
},
stats = { str=3, con=0, wil=0, mag=0, dex=4, cun=0 },
inc_stats = { str=3, con=0, wil=0, mag=0, dex=4, cun=0 },
talents_types = {
["undead/skeleton"]={true, 0.1},
},
......
......@@ -47,15 +47,16 @@ Mouse: #00FF00#Left click#FFFFFF# to increase a stat; #00FF00#right click#FFFFFF
self.c_points = Textzone.new{width=math.floor(self.iw / 2 - 10), auto_height=true, no_color_bleed=true, text=_points_text:format(self.actor.unused_stats)}
self.c_list = ListColumns.new{width=math.floor(self.iw / 2 - 10), height=self.ih - 10, all_clicks=true, columns={
{name="Stat", width=70, display_prop="name"},
{name="Value", width=30, display_prop="val"},
{name="Stat", width=50, display_prop="name"},
{name="Base", width=25, display_prop="base"},
{name="Value", width=25, display_prop="val"},
}, list={
{name="Strength", val=self.actor:getStr(), stat_id=self.actor.STAT_STR},
{name="Dexterity", val=self.actor:getDex(), stat_id=self.actor.STAT_DEX},
{name="Magic", val=self.actor:getMag(), stat_id=self.actor.STAT_MAG},
{name="Willpower", val=self.actor:getWil(), stat_id=self.actor.STAT_WIL},
{name="Cunning", val=self.actor:getCun(), stat_id=self.actor.STAT_CUN},
{name="Constitution", val=self.actor:getCon(), stat_id=self.actor.STAT_CON},
{name="Strength", base=self.actor:getStr(nil, nil, true), val=self.actor:getStr(), stat_id=self.actor.STAT_STR},
{name="Dexterity", base=self.actor:getDex(nil, nil, true), val=self.actor:getDex(), stat_id=self.actor.STAT_DEX},
{name="Magic", base=self.actor:getMag(nil, nil, true), val=self.actor:getMag(), stat_id=self.actor.STAT_MAG},
{name="Willpower", base=self.actor:getWil(nil, nil, true), val=self.actor:getWil(), stat_id=self.actor.STAT_WIL},
{name="Cunning", base=self.actor:getCun(nil, nil, true), val=self.actor:getCun(), stat_id=self.actor.STAT_CUN},
{name="Constitution", base=self.actor:getCon(nil, nil, true), val=self.actor:getCon(), stat_id=self.actor.STAT_CON},
}, fct=function(item, _, v)
self:incStat(v == "left" and 1 or -1)
end, select=function(item, sel) self.sel = sel self.c_desc:switchItem(item, self.actor.stats_def[item.stat_id].description) end}
......@@ -132,6 +133,7 @@ function _M:incStat(v)
local sel = self.sel
self.actor:incStat(sel, v)
self.actor.unused_stats = self.actor.unused_stats - v
self.c_list.list[sel].base = self.actor:getStat(sel, nil, nil, true)
self.c_list.list[sel].val = self.actor:getStat(sel)
self.c_list:generate()
self.c_list.sel = sel
......
No preview for this file type
No preview for this file type
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