diff --git a/game/engine/interface/ActorAbilities.lua b/game/engine/interface/ActorAbilities.lua index d9f601b784609f1e8a51e561fe90e2b1f1ea7ce4..24e09eff61aa9090207cf4994db10019d60fe7d3 100644 --- a/game/engine/interface/ActorAbilities.lua +++ b/game/engine/interface/ActorAbilities.lua @@ -3,82 +3,82 @@ require "engine.class" --- Handles actors stats module(..., package.seeall, class.make) -_M.abilities_def = {} -_M.abilities_types_def = {} +_M.talents_def = {} +_M.talents_types_def = {} ---- Defines actor abilities +--- Defines actor talents -- Static! function _M:loadDefinition(file) local f = loadfile(file) setfenv(f, setmetatable({ DamageType = require("engine.DamageType"), - newAbility = function(t) self:newAbility(t) end, - newAbilityType = function(t) self:newAbilityType(t) end, + newTalent = function(t) self:newTalent(t) end, + newTalentType = function(t) self:newTalentType(t) end, }, {__index=_G})) f() end ---- Defines one ability type(group) +--- Defines one talent type(group) -- Static! -function _M:newAbilityType(t) - assert(t.name, "no ability type name") - assert(t.type, "no ability type type") +function _M:newTalentType(t) + assert(t.name, "no talent type name") + assert(t.type, "no talent type type") - table.insert(self.abilities_types_def, t) + table.insert(self.talents_types_def, t) end ---- Defines one ability +--- Defines one talent -- Static! -function _M:newAbility(t) - assert(t.name, "no ability name") - assert(t.type, "no or unknown ability type") +function _M:newTalent(t) + assert(t.name, "no talent name") + assert(t.type, "no or unknown talent type") t.short_name = t.short_name or t.name t.short_name = t.short_name:upper():gsub("[ ]", "_") t.mana = t.mana or 0 t.stamina = t.stamina or 0 t.mode = t.mode or "activated" - assert(t.mode == "activated" or t.mode == "sustained", "wrong ability mode, requires either 'activated' or 'sustained'") - assert(t.info, "no ability info") + assert(t.mode == "activated" or t.mode == "sustained", "wrong talent mode, requires either 'activated' or 'sustained'") + assert(t.info, "no talent info") - table.insert(self.abilities_def, t) - self["AB_"..t.short_name] = #self.abilities_def + table.insert(self.talents_def, t) + self["T_"..t.short_name] = #self.talents_def end --- Initialises stats with default values if needed function _M:init(t) - self.abilities = t.abilities or {} + self.talents = t.talents or {} end ---- Make the actor use the ability -function _M:useAbility(id) - local ab = _M.abilities_def[id] - assert(ab, "trying to cast ability "..tostring(id).." but it is not defined") +--- Make the actor use the talent +function _M:useTalent(id) + local ab = _M.talents_def[id] + assert(ab, "trying to cast talent "..tostring(id).." but it is not defined") if ab.action then - if not self:preUseAbility(ab) then return end + if not self:preUseTalent(ab) then return end local co = coroutine.create(function() local ret = ab.action(self) - if not self:postUseAbility(ab, ret) then return end + if not self:postUseTalent(ab, ret) then return end end) local ok, err = coroutine.resume(co) if not ok and err then error(err) end end end ---- Called before an ability is used +--- Called before an talent is used -- Redefine as needed --- @param ab the ability (not the id, the table) +-- @param ab the talent (not the id, the table) -- @return true to continue, false to stop -function _M:preUseAbility(ab) +function _M:preUseTalent(ab) return true end ---- Called before an ability is used +--- Called before an talent is used -- Redefine as needed --- @param ab the ability (not the id, the table) --- @param ret the return of the ability action +-- @param ab the talent (not the id, the table) +-- @param ret the return of the talent action -- @return true to continue, false to stop -function _M:postUseAbility(ab, ret) +function _M:postUseTalent(ab, ret) return true end