Skip to content
Snippets Groups Projects
Commit 5c81730a authored by DarkGod's avatar DarkGod
Browse files

Automatic talents will be used in order: instant ones first, then higher CD...

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
parent 3c43e258
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
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