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

Limited talents respeccing available: The last 4 class and 3 generic talent...

Limited talents respeccing available: The last 4 class and 3 generic talent points you spent are always reassignable (unless they are on a special talent like imbue item to prevent abuse). Birth talents are also respeccable on birth this way.


git-svn-id: http://svn.net-core.org/repos/t-engine4@4365 51575b47-30f0-44d4-a5cc-537603b46e54
parent 51256c54
No related branches found
No related tags found
No related merge requests found
......@@ -1939,6 +1939,17 @@ function _M:canWearObject(o, try_slot)
return engine.interface.ActorInventory.canWearObject(self, o, try_slot)
end
function _M:lastLearntTalentsMax(what)
return what == "generic" and 3 or 4
end
function _M:capLastLearntTalents(what)
if self.no_last_learnt_talents_cap then return end
local list = self.last_learnt_talents[what]
local max = self:lastLearntTalentsMax(what)
while #list > max do table.remove(list, 1) end
end
--- Actor learns a talent
-- @param t_id the id of the talent to learn
-- @return true if the talent was learnt, nil and an error message otherwise
......@@ -1948,6 +1959,12 @@ function _M:learnTalent(t_id, force, nb)
-- If we learned a spell, get mana, if you learned a technique get stamina, if we learned a wild gift, get power
local t = _M.talents_def[t_id]
if not t.no_unlearn_last and self.last_learnt_talents then
local list = t.generic and self.last_learnt_talents.generic or self.last_learnt_talents.class
table.insert(list, t_id)
self:capLastLearntTalents(t.generic and "generic" or "class")
end
if t.dont_provide_pool then return true end
if t.type[1]:find("^spell/") and not self:knowTalent(self.T_MANA_POOL) and t.mana or t.sustain_mana then
......@@ -2000,6 +2017,16 @@ end
-- @return true if the talent was unlearnt, nil and an error message otherwise
function _M:unlearnTalent(t_id)
if not engine.interface.ActorTalents.unlearnTalent(self, t_id, force) then return false end
local t = _M.talents_def[t_id]
if not t.no_unlearn_last and self.last_learnt_talents then
local list = t.generic and self.last_learnt_talents.generic or self.last_learnt_talents.class
for i = #list, 1, -1 do
if list[i] == t_id then table.remove(list, i) break end
end
end
-- Check the various pools
for key, num_refs in pairs(self.resource_pool_refs) do
if num_refs == 0 then
......
......@@ -1076,12 +1076,10 @@ function _M:setupCommands()
end end
end end,
[{"_g","ctrl"}] = function() if config.settings.cheat then
local list = mod.class.Trap:loadList("/data/general/traps/complex.lua")
local b = list[2]:clone()
b:resolve() b:resolve(nil, true)
self.zone:addEntity(self.level, b, "trap", self.player.x + 1, self.player.y)
print("== CLASS")
for i, tid in ipairs(game.player.last_learnt_talents.class) do print(i, tid) end
print("== GENERIC")
for i, tid in ipairs(game.player.last_learnt_talents.generic) do print(i, tid) end
end end,
[{"_f","ctrl"}] = function() if config.settings.cheat then
self.player.quests["love-melinda"] = nil
......
......@@ -84,6 +84,7 @@ function _M:init(t, no_default)
self.descriptor = self.descriptor or {}
self.died_times = self.died_times or {}
self.last_learnt_talents = { class={}, generic={} }
end
function _M:onBirth(birther)
......
......@@ -54,6 +54,7 @@ local newInscription = function(t)
if not tt.image then
tt.image = "talents/"..(t.short_name or t.name):lower():gsub("[^a-z0-9_]", "_")..".png"
end
tt.no_unlearn_last = true
newTalent(tt)
end
end
......
......@@ -44,6 +44,7 @@ newTalent{
requires_target = true,
target = {type="hit", range=1},
tactical = { ATTACK = 1 },
no_unlearn_last = true,
action = function(self, t)
local tg = self:getTalentTarget(t)
local x, y = self:getTarget(tg)
......@@ -68,6 +69,7 @@ newTalent{
info = "Allows you to have an energy pool. Energy is used to perform psionic manipulations.",
mode = "passive",
hide = true,
no_unlearn_last = true,
}
newTalent{
......@@ -76,6 +78,7 @@ newTalent{
info = "Allows you to have a mana pool. Mana is used to cast all spells.",
mode = "passive",
hide = true,
no_unlearn_last = true,
}
newTalent{
name = "Vim Pool",
......@@ -83,6 +86,7 @@ newTalent{
info = "Allows you to have a vim pool. Vim is used by corruptions.",
mode = "passive",
hide = true,
no_unlearn_last = true,
}
newTalent{
name = "Stamina Pool",
......@@ -90,6 +94,7 @@ newTalent{
info = "Allows you to have a stamina pool. Stamina is used to activate special combat attacks.",
mode = "passive",
hide = true,
no_unlearn_last = true,
}
newTalent{
name = "Equilibrium Pool",
......@@ -97,6 +102,7 @@ newTalent{
info = "Allows you to have an equilibrium pool. Equilibrium is used to measure your balance with nature and the use of wild gifts.",
mode = "passive",
hide = true,
no_unlearn_last = true,
}
newTalent{
name = "Positive Pool",
......@@ -104,6 +110,7 @@ newTalent{
info = "Allows you to have a positive energy pool.",
mode = "passive",
hide = true,
no_unlearn_last = true,
}
newTalent{
name = "Negative Pool",
......@@ -111,6 +118,7 @@ newTalent{
info = "Allows you to have a negative energy pool.",
mode = "passive",
hide = true,
no_unlearn_last = true,
}
newTalent{
name = "Hate Pool",
......@@ -118,6 +126,7 @@ newTalent{
info = "Allows you to have a hate pool.",
mode = "passive",
hide = true,
no_unlearn_last = true,
}
newTalent{
......@@ -126,49 +135,7 @@ newTalent{
info = "Allows you to have a paradox pool.",
mode = "passive",
hide = true,
}
newTalent{
name = "Improved Health I",
type = {"base/race", 1},
info = "Improves the number of health points per level.",
mode = "passive",
hide = true,
}
newTalent{
name = "Improved Health II",
type = {"base/race", 1},
info = "Improves the number of health points per level.",
mode = "passive",
hide = true,
}
newTalent{
name = "Improved Health III",
type = {"base/race", 1},
info = "Improves the number of health points per level.",
mode = "passive",
hide = true,
}
newTalent{
name = "Decreased Health I",
type = {"base/race", 1},
info = "Improves the number of health points per level.",
mode = "passive",
hide = true,
}
newTalent{
name = "Decreased Health II",
type = {"base/race", 1},
info = "Improves the number of health points per level.",
mode = "passive",
hide = true,
}
newTalent{
name = "Decreased Health III",
type = {"base/race", 1},
info = "Improves the number of health points per level.",
mode = "passive",
hide = true,
no_unlearn_last = true,
}
-- Mages class talent, teleport to angolwen
......@@ -178,6 +145,7 @@ newTalent{
type = {"base/class", 1},
cooldown = 400,
no_npc_use = true,
no_unlearn_last = true,
no_silence=true, is_spell=true,
action = function(self, t)
if not self:canBe("worldport") or self:attr("never_move") then
......
......@@ -800,6 +800,7 @@ newTalent{
name = "Knowledge of the Way",
type = {"base/race", 1},
no_npc_use = true,
no_unlearn_last = true,
on_learn = function(self, t) self.auto_id = 2 end,
action = function(self, t)
local Chat = require("engine.Chat")
......
......@@ -46,9 +46,9 @@ newTalent{
psi = 0,
points = 5,
no_npc_use = true,
no_unlearn_last = true,
boost = function(self, t)
return math.floor(self:combatTalentIntervalDamage(t, "wil", 3, 20))
end,
action = function(self, t)
local d d = self:showInventory("Reshape which weapon?", self:getInven("INVEN"), function(o) return not o.quest and o.type == "weapon" and not o.fully_reshaped end, function(o, item)
......@@ -91,6 +91,7 @@ newTalent{
psi = 0,
points = 5,
no_npc_use = true,
no_unlearn_last = true,
arm_boost = function(self, t)
--return math.floor(0.1*self:combatTalentIntervalDamage(t, "wil", 10, 30))
return math.floor(0.25*t.fat_red(self, t))
......
......@@ -69,6 +69,7 @@ newTalent{
points = 5,
mana = 5,
no_npc_use = true,
no_unlearn_last = true,
action = function(self, t)
local d d = self:showEquipInven("Try to extract gems from which metallic item?", function(o) return o.metallic and (o.material_level or 1) <= self:getTalentLevelRaw(t) end, function(o, inven, item)
if not o then return end
......@@ -109,6 +110,7 @@ newTalent{
mana = 80,
cooldown = 100,
no_npc_use = true,
no_unlearn_last = true,
action = function(self, t)
local d d = self:showInventory("Use which gem?", self:getInven("INVEN"), function(gem) return gem.type == "gem" and gem.imbue_powers and gem.material_level and gem.material_level <= self:getTalentLevelRaw(t) end, function(gem, gem_item)
local nd = self:showInventory("Imbue which armour?", self:getInven("INVEN"), function(o) return o.type == "armor" and o.slot == "BODY" and not o.been_imbued end, function(o, item)
......
......@@ -51,6 +51,7 @@ newTalent{
name = "Knowledge of the Past",
type = {"undead/base", 1},
no_npc_use = true,
no_unlearn_last = true,
on_learn = function(self, t) self.auto_id = 2 end,
action = function(self, t)
local Chat = require("engine.Chat")
......
......@@ -40,6 +40,7 @@ Class talent points left: #00FF00#%d#LAST#
Generic talent points left: #00FF00#%d#LAST#]]
function _M:init(actor, on_finish)
actor.no_last_learnt_talents_cap = true
self.actor = actor
self.unused_stats = self.actor.unused_stats
self.new_stats_changed = false
......@@ -139,6 +140,12 @@ Mouse: #00FF00#Left click#FFFFFF# to increase a stat; #00FF00#right click#FFFFFF
end
end
function _M:unload()
self.actor.no_last_learnt_talents_cap = nil
self.actor:capLastLearntTalents("class")
self.actor:capLastLearntTalents("generic")
end
local prev_sel = nil
function _M:onSelectStat(item, force)
if item == prev_sel and not force then return end
......@@ -356,6 +363,7 @@ function _M:cancel()
self.actor:unlearnTalent(t_id)
end
end
self.actor.last_learnt_talents = self.actor_dup.last_learnt_talents
end
function _M:tabTabs()
......@@ -596,6 +604,11 @@ function _M:treeSelect(item, sel, v)
local it = self.c_t_tree.items_by_key[tid]
if it then self.c_t_tree:drawItem(it) end
end
local t = self.actor:getTalentFromId(item.talent)
for _, tid in ipairs(self.actor.last_learnt_talents[t.generic and "generic" or "class"]) do
local it = self.c_t_tree.items_by_key[tid]
if it then self.c_t_tree:drawItem(it) end
end
end
self.c_t_desc:switchItem(item)
self.c_t_tree:outputList()
......@@ -632,6 +645,18 @@ function _M:checkDeps()
end
end
function _M:isUnlearnable(t, limit)
if not self.actor.last_learnt_talents then return end
local list = self.actor.last_learnt_talents[t.generic and "generic" or "class"]
local max = self.actor:lastLearntTalentsMax(t.generic and "generic" or "class")
local min = 1
if limit then min = math.max(1, #list - (max - 1)) end
for i = #list, min, -1 do
if list[i] == t.id then return i end
end
return nil
end
function _M:learnTalent(t_id, v)
self.talents_learned[t_id] = self.talents_learned[t_id] or 0
local t = self.actor:getTalentFromId(t_id)
......@@ -659,7 +684,7 @@ function _M:learnTalent(t_id, v)
self:simplePopup("Impossible", "You do not know this talent!")
return
end
if self.actor_dup:getTalentLevelRaw(t_id) == self.actor:getTalentLevelRaw(t_id) then
if not self:isUnlearnable(t, true) and self.actor_dup:getTalentLevelRaw(t_id) >= self.actor:getTalentLevelRaw(t_id) then
self:simplePopup("Impossible", "You cannot unlearn talents!")
return
end
......@@ -700,7 +725,7 @@ function _M:learnTalent(t_id, v)
self:simplePopup("Impossible", "You do not know this talent!")
return
end
if self.actor_dup:getTalentLevelRaw(t_id) == self.actor:getTalentLevelRaw(t_id) then
if not self:isUnlearnable(t, true) and self.actor_dup:getTalentLevelRaw(t_id) >= self.actor:getTalentLevelRaw(t_id) then
self:simplePopup("Impossible", "You cannot unlearn talents!")
return
end
......@@ -801,6 +826,13 @@ function _M:onDrawItem(item)
else
local t = self.actor:getTalentFromId(item.talent)
if self:isUnlearnable(t, true) then
text:add({"color","LIGHT_BLUE"}, "This talent was recently learnt, you can still unlearn it.", true, "The last ", t.generic and "3 generic" or "4 class", " talents you learnt are always unlearnable.", {"color","LAST"}, true, true)
elseif t.no_unlearn_last then
text:add({"color","YELLOW"}, "This talent can alter the world in a permanent way, as such you can never unlearn it once known.", {"color","LAST"}, true, true)
end
local traw = self.actor:getTalentLevelRaw(t.id)
local diff = function(i2, i1, res)
res:add({"color", "LIGHT_GREEN"}, i1, {"color", "LAST"}, " [->", {"color", "YELLOW_GREEN"}, i2, {"color", "LAST"}, "]")
......@@ -887,7 +919,13 @@ function _M:generateList()
entity=t.display_entity,
talent=t.id,
_type=tt.type,
color=function(item) return ((self.actor.talents[item.talent] or 0) ~= (self.actor_dup.talents[item.talent] or 0)) and {255, 215, 0} or self.actor:knowTalentType(item._type) and {255,255,255} or {175,175,175} end,
color=function(item)
if ((self.actor.talents[item.talent] or 0) ~= (self.actor_dup.talents[item.talent] or 0)) then return {255, 215, 0}
elseif self:isUnlearnable(t, true) then return colors.simple(colors.LIGHT_BLUE)
elseif self.actor:knowTalentType(item._type) then return {255,255,255}
else return {175,175,175}
end
end,
}
list[#list].status = function(item)
local t = self.actor:getTalentFromId(item.talent)
......
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