Skip to content
Snippets Groups Projects
Commit 3e284592 authored by DarkGod's avatar DarkGod
Browse files

New Actor:alterTalentCost method

parent 6bb271be
No related branches found
No related tags found
No related merge requests found
......@@ -4811,6 +4811,10 @@ function _M:getFeedbackDecay(mult)
end
end
function _M:alterTalentCost(t, rname, cost)
return cost
end
--- Called before a talent is used
-- Check the actor can cast it
-- @param ab the talent (not the id, the table)
......@@ -4879,6 +4883,7 @@ function _M:preUseTalent(ab, silent, fake)
cost = ab[res_def.sustain_prop]
if cost then
cost = util.getval(cost, self, ab) or 0
cost = self:alterTalentCost(ab, res_def.sustain_prop, cost)
rmin, rmax = self[res_def.getMinFunction](self), self[res_def.getMaxFunction](self)
if cost ~= 0 and self[res_def.minname] and self[res_def.maxname] and self[res_def.minname] + cost > self[res_def.maxname] then
if not silent then game.logPlayer(self, "You %s %s to activate %s.", res_def.invert_values and "have too much committed" or "do not have enough uncommitted", res_def.name, ab.name) end
......@@ -4908,6 +4913,7 @@ function _M:preUseTalent(ab, silent, fake)
cost = ab[rname]
if cost then
cost = (util.getval(cost, self, ab) or 0) * (util.getval(res_def.cost_factor, self, ab, true) or 1)
cost = self:alterTalentCost(ab, rname, cost)
if cost ~= 0 then
rmin, rmax = self[res_def.getMinFunction](self), self[res_def.getMaxFunction](self)
if res_def.invert_values then
......@@ -5472,6 +5478,7 @@ function _M:postUseTalent(ab, ret, silent)
for res, res_def in ipairs(_M.resources_def) do
rname = res_def.short_name
cost = ab[rname] and util.getval(ab[rname], self, ab) or 0
cost = self:alterTalentCost(ab, rname, cost)
if cost ~= 0 then
trigger = true
cost = cost * (util.getval(res_def.cost_factor, self, ab) or 1)
......@@ -5716,17 +5723,20 @@ function _M:getTalentFullDescription(t, addlevel, config, fake_mastery)
if not res_def.hidden_resource then
-- list resource cost
local cost = t[res_def.short_name] and util.getval(t[res_def.short_name], self, t) or 0
cost = self:alterTalentCost(t, res_def.short_name, cost)
if cost ~= 0 then
cost = cost * (util.getval(res_def.cost_factor, self, t) or 1)
d:add({"color",0x6f,0xff,0x83}, ("%s cost: "):format(res_def.name:capitalize()), res_def.color or {"color",0xff,0xa8,0xa8}, ""..math.round(cost, .1), true)
end
-- list sustain cost
cost = t[res_def.sustain_prop] and util.getval(t[res_def.sustain_prop], self, t) or 0
cost = self:alterTalentCost(t, res_def.sustain_prop, cost)
if cost ~= 0 then
d:add({"color",0x6f,0xff,0x83}, ("Sustain %s cost: "):format(res_def.name:lower()), res_def.color or {"color",0xff,0xa8,0xa8}, ""..math.round(cost, .1), true)
end
-- list drain cost
cost = t[res_def.drain_prop] and util.getval(t[res_def.drain_prop], self, t) or 0
cost = self:alterTalentCost(t, res_def.drain_prop, cost)
if cost ~= 0 then
if res_def.invert_values then
d:add({"color",0x6f,0xff,0x83}, ("%s %s: "):format(cost > 0 and "Generates" or "Removes", res_def.name:lower()), res_def.color or {"color",0xff,0xa8,0xa8}, ""..math.round(math.abs(cost), .1), true)
......
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