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

multipoints talents can now have requirements for each levels

git-svn-id: http://svn.net-core.org/repos/t-engine4@195 51575b47-30f0-44d4-a5cc-537603b46e54
parent f3a4a969
No related branches found
No related tags found
No related merge requests found
......@@ -227,14 +227,19 @@ end
function _M:canLearnTalent(t)
-- Check prerequisites
if t.require then
local tlev = self:getTalentLevelRaw(t) + 1
-- Obviously this requires the ActorStats interface
if t.require.stat then
for s, v in pairs(t.require.stat) do
v = util.getval(v, tlev)
if self:getStat(s) < v then return nil, "not enough stat" end
end
end
if t.require.level and self.level < t.require.level then
return nil, "not enough levels"
if t.require.level then
if self.level < util.getval(t.require.level, tlev) then
return nil, "not enough levels"
end
end
if t.require.talent then
for _, tid in ipairs(t.require.talent) do
......@@ -255,11 +260,14 @@ end
--- Formats the requirements as a (multiline) string
-- @param t_id the id of the talent to desc
function _M:getTalentReqDesc(t_id)
-- @param levmod a number (1 should be the smartest) to add to current talent level to display requirements, defaults to 0
function _M:getTalentReqDesc(t_id, levmod)
local t = _M.talents_def[t_id]
local req = t.require
if not req then return "" end
local tlev = self:getTalentLevelRaw(t_id) + (levmod or 0)
local str = ""
if t.type[2] and t.type[2] > 1 then
......@@ -271,13 +279,15 @@ function _M:getTalentReqDesc(t_id)
-- Obviously this requires the ActorStats interface
if req.stat then
for s, v in pairs(req.stat) do
v = util.getval(v, tlev)
local c = (self:getStat(s) >= v) and "#00ff00#" or "#ff0000#"
str = str .. ("- %s%s %d\n"):format(c, self.stats_def[s].name, v)
end
end
if req.level then
local c = (self.level >= req.level) and "#00ff00#" or "#ff0000#"
str = str .. ("- %sLevel %d\n"):format(c, req.level)
local v = util.getval(req.level, tlev)
local c = (self.level >= v) and "#00ff00#" or "#ff0000#"
str = str .. ("- %sLevel %d\n"):format(c, v)
end
if req.talent then
for _, tid in ipairs(req.talent) do
......
......@@ -235,6 +235,13 @@ function util.scroll(sel, scroll, max)
return scroll
end
function util.getval(val, ...)
if type(val) == "function" then return val(...)
elseif type(val) == "table" then return val[rng.range(1, #val)]
else return val
end
end
function core.fov.circle_grids(x, y, radius, block)
local grids = {}
core.fov.calc_circle(x, y, radius, function(self, lx, ly)
......
......@@ -2,6 +2,7 @@ newTalent{
name = "Sword Mastery",
type = {"physical/weapon-training", 1},
points = 10,
require = { stat = { str=function(level) return 10 + level * 3 end }, },
mode = "passive",
info = function(self)
return [[Increases damage and attack with swords.]]
......@@ -12,6 +13,7 @@ newTalent{
name = "Axe Mastery",
type = {"physical/weapon-training", 1},
points = 10,
require = { stat = { str=function(level) return 10 + level * 3 end }, },
mode = "passive",
info = function(self)
return [[Increases damage and attack with axes.]]
......@@ -22,6 +24,7 @@ newTalent{
name = "Mace Mastery",
type = {"physical/weapon-training", 1},
points = 10,
require = { stat = { str=function(level) return 10 + level * 3 end }, },
mode = "passive",
info = function(self)
return [[Increases damage and attack with maces.]]
......@@ -32,6 +35,7 @@ newTalent{
name = "Knife Mastery",
type = {"physical/weapon-training", 1},
points = 10,
require = { stat = { str=function(level) return 10 + level * 3 end }, },
mode = "passive",
info = function(self)
return [[Increases damage and attack with knifes.]]
......
......@@ -159,9 +159,9 @@ Mouse: #00FF00#Left click#FFFFFF# to learn; #00FF00#right click#FFFFFF# to unlea
helplines = str:splitLines(self.iw / 2 - 10, self.font)
local t = self.actor:getTalentFromId(self.list[self.sel].talent)
lines = t.info(self.actor, t):splitLines(self.iw / 2 - 10, self.font)
local req = self.actor:getTalentReqDesc(self.list[self.sel].talent)
local req = self.actor:getTalentReqDesc(self.list[self.sel].talent, 1)
if req ~= "" then
req = "Requirements:\n"..req
req = "Requirements for next point:\n"..req
reqlines = req:splitLines(self.iw / 2 - 10, self.font)
end
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