-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebuffbot.lua
More file actions
111 lines (91 loc) · 2.27 KB
/
debuffbot.lua
File metadata and controls
111 lines (91 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
local mq = require('mq')
local co = require('co')
local target = require('target')
local mychar = require('mychar')
require('actions.s_cast')
local debuffbot = {}
--
-- Globals
--
local actionqueue = {}
local State = {}
local Config = {}
--
-- Functions
--
local function log(msg)
print('(debuffbot) ' .. msg)
end
local function HasDebuff(spell, id)
return mq.TLO.Spawn(id).Buff(spell.Effect)() ~= nil
end
local function CastDebuffOn(spell_name, gem, id, order)
assert(tonumber(gem))
local priority = 40 + order
if mq.TLO.Spell(spell_name).Name() then
if not mq.TLO.Spawn(id).Buff(spell_name).Name() then
actionqueue.AddUnique(
ScpCast(
spell_name,
'gem' .. gem,
Config.Debuff.MinMana(),
2,
id,
Config.Debuff.MinTargetHpPct(),
nil,
priority
)
)
-- spells.QueueSpellIfNotQueued(
-- State,
-- spell_name,
-- 'gem' .. gem,
-- id,
-- 'Debuffing ' .. mq.TLO.Spawn(id).Name() .. ' with ' .. spell_name,
-- Config.Debuff.MinMana(),
-- Config.Debuff.MinTargetHpPct(),
-- 2,
-- priority
-- )
end
end
end
local function do_debuffs()
local i = 1
for pct,spell_key in pairs(Config.Debuff.AtTargetHpPcts()) do
local castable = Config.Spells.Spell(spell_key)
local res = Config.SpellBar.GemBySpell(castable)
if res.gem < 1 then
log(res.msg)
else
---@diagnostic disable-next-line: undefined-field
local group_target_id = mq.TLO.Me.GroupAssistTarget.ID()
local group_target_pct_hps = mq.TLO.Spawn(group_target_id).PctHPs()
if group_target_id and not target.IsInGroup(group_target_id) and group_target_pct_hps and group_target_pct_hps < pct and group_target_pct_hps >= Config.Debuff.MinTargetHpPct() and not HasDebuff(castable, group_target_id) then
CastDebuffOn(castable.Name, res.gem, group_target_id, i)
end
end
i = i + 1
end
end
--
-- Init
--
function debuffbot.Init(state, cfg, aq)
State = state
Config = cfg
actionqueue = aq
end
---
--- Main Loop
---
function debuffbot.Run()
log('Up and running')
while true do
if State.Mode ~= 1 and mychar.InCombat() and not State.IsCrowdControlActive then
do_debuffs()
end
co.yield()
end
end
return debuffbot