From 5c81730ad8ab07a366f6f30113904b1cf758a418 Mon Sep 17 00:00:00 2001 From: DarkGod <darkgod@net-core.org> Date: Sat, 19 Oct 2013 17:50:18 +0200 Subject: [PATCH] Automatic talents will be used in order: instant ones first, then higher CD ones first. Only one non-instant talent will be used each turn --- game/modules/tome/class/Player.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 53af85e5c2..116e130c83 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -734,29 +734,43 @@ function _M:automaticTalents() if self.no_automatic_talents then return end self:attr("_forbid_sounds", 1) + local uses = {} for tid, c in pairs(self.talents_auto) do local t = self.talents_def[tid] local spotted = spotHostiles(self) if (t.mode ~= "sustained" or not self.sustain_talents[tid]) and not self.talents_cd[tid] and self:preUseTalent(t, true, true) and (not t.auto_use_check or t.auto_use_check(self, t)) then if (c == 1) or (c == 2 and #spotted <= 0) or (c == 3 and #spotted > 0) then if c ~= 2 then - self:useTalent(tid) + uses[#uses+1] = {name=t.name, no_energy=t.no_energy == true and 0 or 1, cd=self:getTalentCooldown(t) or 0, fct=function() self:useTalent(tid) end} else if not self:attr("blind") then - self:useTalent(tid,nil,nil,nil,self) + uses[#uses+1] = {name=t.name, no_energy=t.no_energy == true and 0 or 1, cd=self:getTalentCooldown(t) or 0, fct=function() self:useTalent(tid,nil,nil,nil,self) end} end end end if c == 4 and #spotted > 0 then for fid, foe in pairs(spotted) do if foe.x >= self.x-1 and foe.x <= self.x+1 and foe.y >= self.y-1 and foe.y <= self.y+1 then - self:useTalent(tid) - break + uses[#uses+1] = {name=t.name, no_energy=t.no_energy == true and 0 or 1, cd=self:getTalentCooldown(t) or 0, fct=function() self:useTalent(tid) end} end end end end end + table.sort(uses, function(a, b) + if a.no_energy < b.no_energy then return true + elseif a.no_energy > b.no_energy then return false + else + if a.cd > b.cd then return true + else return false + end + end + end) + table.print(uses) + for _, use in ipairs(uses) do + use.fct() + if use.no_energy == 1 then break end + end self:attr("_forbid_sounds", -1) end -- GitLab