diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 53af85e5c2ad5d1d56d2521c54df542995dbabfb..116e130c83d095b62f066bea37f64756b4e79bae 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