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

Automatic talent use can now be set to fire when no actors in sight, when...

Automatic talent use can now be set to fire when no actors in sight, when actors in sight, when actors in melee range or always

git-svn-id: http://svn.net-core.org/repos/t-engine4@5722 51575b47-30f0-44d4-a5cc-537603b46e54
parent f89479af
No related branches found
No related tags found
No related merge requests found
......@@ -3867,12 +3867,20 @@ function _M:startTalentCooldown(t)
self.changed = true
end
--- Setup the talent as autocast
function _M:setTalentAuto(tid, v, opt)
if type(tid) == "table" then tid = tid.id end
if v then self.talents_auto[tid] = opt
else self.talents_auto[tid] = nil
end
end
--- Setups a talent automatic use
function _M:checkSetTalentAuto(tid, v)
function _M:checkSetTalentAuto(tid, v, opt)
local t = self:getTalentFromId(tid)
if v then
local doit = function()
self:setTalentAuto(tid, true)
self:setTalentAuto(tid, true, opt)
Dialog:simplePopup("Automatic use enabled", t.name:capitalize().." will now be used as often as possible automatically.")
end
......@@ -3880,6 +3888,12 @@ function _M:checkSetTalentAuto(tid, v)
if t.no_energy ~= true then list[#list+1] = "- requires a turn to use" end
if t.requires_target then list[#list+1] = "- requires a target, your last hostile one will be automatically used" end
if t.auto_use_warning then list[#list+1] = t.auto_use_warning end
if opt == 2 then
list[#list+1] = "- will only trigger if no enemies are visible"
list[#list+1] = "- will automatically target you if a target is required"
end
if opt == 3 then list[#list+1] = "- will only trigger if enemies are visible" end
if opt == 4 then list[#list+1] = "- will only trigger if enemies are visible and adjacent" end
if #list == 0 then
doit()
......
......@@ -641,18 +641,28 @@ end
--- Try to auto use listed talents
-- This should be called in your actors "act()" method
function _M:automaticTalents()
local spotted = nil
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 not t.no_energy then
if spotted == nil then spotted = spotHostiles(self) end
if #spotted == 0 then self:useTalent(tid) end
else
self:useTalent(tid)
if (c == 1) or (c == 2 and #spotted <= 0) or (c == 3 and #spotted > 0) then
if c ~= 2 then
self:useTalent(tid)
else
self:useTalent(tid,nil,nil,nil,self)
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
end
end
end
end
end
return
end
--- We started resting
......
......@@ -136,7 +136,11 @@ function _M:use(item, button)
--local t = self.actor:getTalentFromId(item.talent)
if self.actor:isTalentAuto(t) then table.insert(list, 1, {name="Disable automatic use", what="auto-dis"})
else table.insert(list, 1, {name="Enable automatic use", what="auto-en"})
else
table.insert(list, 1, {name="Auto-use when enemies are visible and adjacent", what="auto-en-4"})
table.insert(list, 1, {name="Auto-use when enemies are visible", what="auto-en-3"})
table.insert(list, 1, {name="Auto-use when no enemies are visible", what="auto-en-2"})
table.insert(list, 1, {name="Auto-use when available", what="auto-en-1"})
end
for i = 1, 12 * self.actor.nb_hotkey_pages do list[#list+1] = {name="Hotkey "..i, what=i} end
......@@ -160,8 +164,14 @@ function _M:use(item, button)
for i = 1, 12 * self.actor.nb_hotkey_pages do
if self.actor.hotkey[i] and self.actor.hotkey[i][1] == "talent" and self.actor.hotkey[i][2] == item.talent then self.actor.hotkey[i] = nil end
end
elseif b.what == "auto-en" then
self.actor:checkSetTalentAuto(item.talent, true)
elseif b.what == "auto-en-1" then
self.actor:checkSetTalentAuto(item.talent, true, 1)
elseif b.what == "auto-en-2" then
self.actor:checkSetTalentAuto(item.talent, true, 2)
elseif b.what == "auto-en-3" then
self.actor:checkSetTalentAuto(item.talent, true, 3)
elseif b.what == "auto-en-4" then
self.actor:checkSetTalentAuto(item.talent, true, 4)
elseif b.what == "auto-dis" then
self.actor:checkSetTalentAuto(item.talent, false)
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