-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLoathebCastOrder.lua
374 lines (298 loc) · 11.2 KB
/
LoathebCastOrder.lua
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
local lco = CreateFrame("Frame")
local me = UnitName('player')
lco.enabled = false
lco.targetNameEnable = 'Loatheb'
--lco.debuffIcon = 'Interface\\Icons\\Spell_Holy_AshesToAshes' --
lco.debuffIcon = 'Interface\\Icons\\Spell_Shadow_AuraOfDarkness'
lco.casterFrames = {}
lco.healCooldown = 60
local _, class = UnitClass('player')
class = string.lower(class)
local cooldownFrame = CreateFrame("Frame")
cooldownFrame:Hide()
function lcoprint(a)
DEFAULT_CHAT_FRAME:AddMessage("|cff69ccf0[TWLC2cLCO] |cffffffff" .. a)
end
lco:RegisterEvent("ADDON_LOADED")
lco:RegisterEvent("CHAT_MSG_ADDON")
lco:RegisterEvent("PLAYER_TARGET_CHANGED")
--lco:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH")
local classColors = {
["warrior"] = { r = 0.78, g = 0.61, b = 0.43, c = "|cffc79c6e" },
["mage"] = { r = 0.41, g = 0.8, b = 0.94, c = "|cff69ccf0" },
["rogue"] = { r = 1, g = 0.96, b = 0.41, c = "|cfffff569" },
["druid"] = { r = 1, g = 0.49, b = 0.04, c = "|cffff7d0a" },
["hunter"] = { r = 0.67, g = 0.83, b = 0.45, c = "|cffabd473" },
["shaman"] = { r = 0.14, g = 0.35, b = 1.0, c = "|cff0070de" },
["priest"] = { r = 1, g = 1, b = 1, c = "|cffffffff" },
["warlock"] = { r = 0.58, g = 0.51, b = 0.79, c = "|cff9482c9" },
["paladin"] = { r = 0.96, g = 0.55, b = 0.73, c = "|cfff58cba" }
}
lco.healers = {}
lco.bossDied = false
lco:SetScript("OnEvent", function()
if event then
if event == "ADDON_LOADED" and arg1 == 'TWLC2c' then
if lco.twlc2isRL(me) then
getglobal('LCOAddHealer'):Show()
getglobal('LCOResetHealers'):Show()
getglobal('LCOSyncHealers'):Show()
else
getglobal('LCOAddHealer'):Hide()
getglobal('LCOResetHealers'):Hide()
getglobal('LCOSyncHealers'):Hide()
end
end
if event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" then
if arg1 == lco.targetNameEnable .. " dies." then
if lco.twlc2isRL(me) then
SendAddonMessage("TWLClco", "lcoCast=disable", "RAID")
end
end
end
if event == "PLAYER_TARGET_CHANGED" then
if UnitName('target') == lco.targetNameEnable then
if lco.twlc2isRL(me) then
SendAddonMessage("TWLClco", "lcoCast=enable", "RAID")
end
end
end
if event == 'CHAT_MSG_ADDON' and arg1 == 'TWLClco' then
local sender = arg4
local t = arg2
if not string.find(t, 'lcoCooldown', 1, true) then
--lcoprint('recv ' .. t .. ' ' .. sender)
end
if t == "lcoCast=enable" then
if not lco.enabled then
lco.enabled = true
end
if lco.twlc2isRL(me) then
lco.show()
lco.init()
--lcoprint('enabled')
cooldownFrame:Show()
end
return true
end
if t == "lcoCast=disable" then
lco.enabled = false
cooldownFrame:Hide()
end
if string.find(t, "lcoCooldown=", 1, true) then
local ex = string.split(t, "=")
for index, f in next, lco.casterFrames do
if f.name == sender then
f.cooldown = math.floor(tonumber(ex[2]))
end
end
lco.updateCooldowns()
end
if string.find(t, 'rotSync=reset') then
lco.healers = {}
getglobal('LCO'):Hide()
--lcoprint('Healer list reset.')
getglobal('LCONextHealer'):SetText('Next: _')
for index in next, lco.casterFrames do
lco.casterFrames[index]:Hide()
end
getglobal('LCO'):SetHeight(table.getn(lco.healers) * 21 + 57)
if sender ~= me then
end
elseif string.find(t, 'rotSync=start') then
if sender ~= me then
lco.healers = {}
end
elseif string.find(t, 'rotSync=end') then
if sender ~= me then
for i, healer in next, lco.healers do
if healer.name == me then
lco.enabled = true
lco.init()
lco.show()
cooldownFrame:Show()
break
end
end
end
elseif string.find(t, 'rotSync=') then
if sender ~= me then
local ex = string.split(t, '=')
lco.healers[tonumber(ex[2])] = {
name = ex[3],
class = ex[4]
}
end
end
end
end
end)
function lco.init()
for index in next, lco.casterFrames do
lco.casterFrames[index]:Hide()
end
for index, healer in next, lco.healers do
if not lco.casterFrames[index] then
lco.casterFrames[index] = CreateFrame('Frame', 'LCOCaster' .. index, getglobal("LCO"), 'LCOCaster')
end
local itemOffset = 1
lco.casterFrames[index]:SetPoint("TOPLEFT", getglobal("LCO"), "TOPLEFT", 2, -21 * (index - itemOffset) - 55)
lco.casterFrames[index]:Show()
lco.casterFrames[index].cooldown = 0
lco.casterFrames[index].name = healer.name
lco.casterFrames[index].class = healer.class
if healer.name == me then
getglobal("LCOCaster" .. index .. 'PlayerName'):SetText(classColors[healer.class].c .. healer.name .. ' ' .. classColors['priest'].c .. ' (YOU)')
else
getglobal("LCOCaster" .. index .. 'PlayerName'):SetText(classColors[healer.class].c .. healer.name)
end
getglobal("LCOCaster" .. index):SetBackdropColor(classColors[healer.class].r, classColors[healer.class].g, classColors[healer.class].b)
end
getglobal('LCO'):SetHeight(table.getn(lco.healers) * 21 + 57)
lco.updateCooldowns()
end
function lco.updateCooldowns()
for i, f in next, lco.casterFrames do
if f.cooldown == 0 then
getglobal("LCOCaster" .. i .. 'Cooldown'):SetText(classColors['hunter'].c .. 'READY')
getglobal("LCOCaster" .. i):SetBackdropColor(classColors[f.class].r, classColors[f.class].g, classColors[f.class].b, 1)
elseif f.cooldown == 100 then
getglobal("LCOCaster" .. i .. 'Cooldown'):SetText(classColors['warrior'].c .. 'DEAD')
getglobal("LCOCaster" .. i):SetBackdropColor(classColors[f.class].r, classColors[f.class].g, classColors[f.class].b, 0)
else
getglobal("LCOCaster" .. i .. 'Cooldown'):SetText(f.cooldown)
getglobal("LCOCaster" .. i):SetBackdropColor(classColors[f.class].r, classColors[f.class].g, classColors[f.class].b, 1 - f.cooldown / lco.healCooldown)
end
end
end
function lco.updateNext()
local minCooldown = lco.healCooldown + 1
local nextHealer = ''
local nextHealerClass = ''
local you = '(YOU)'
if table.getn(lco.healers) > 0 then
for i, f in next, lco.casterFrames do
if f.cooldown == 0 or f.cooldown == 60 and f:IsVisible() then
if f.name ~= me then
you = ''
end
getglobal('LCONextHealer'):SetText('Next: ' .. classColors[f.class].c .. f.name .. you)
return true
end
if f.cooldown < minCooldown then
minCooldown = f.cooldown
nextHealer = f.name
nextHealerClass = f.class
end
end
end
if nextHealer ~= '' then
if nextHealer ~= me then
you = ''
end
getglobal('LCONextHealer'):SetText('Next: ' .. classColors[nextHealerClass].c .. nextHealer .. you)
return true
end
getglobal('LCONextHealer'):SetText('Next: Panik!!')
end
function ResetHealers_OnClick()
if lco.twlc2isRL(me) then
SendAddonMessage("TWLClco", "rotSync=reset", "RAID")
end
end
function AddHealer_OnClick()
if not UnitIsPlayer('target') then
lcoprint('Target is not a player.')
return false
end
local name = UnitName('target')
for _, healer in next, lco.healers do
if healer.name == name then
lcoprint('Healer ' .. name .. ' already exists.')
return false
end
end
local _, c = UnitClass('target')
local halerClass = string.lower(c)
lco.healers[table.getn(lco.healers) + 1] = {
name = name,
class = halerClass
}
SendAddonMessage("TWLClco", "rotSync=start", "RAID")
for i, healer in next, lco.healers do
SendAddonMessage("TWLClco", "rotSync=" .. i .. "=" .. healer.name .. "=" .. healer.class, "RAID")
end
SendAddonMessage("TWLClco", "rotSync=end", "RAID")
lco.init()
end
function SyncData_OnClick()
SendAddonMessage("TWLClco", "rotSync=start", "RAID")
for i, healer in next, lco.healers do
SendAddonMessage("TWLClco", "rotSync=" .. i .. "=" .. healer.name .. "=" .. healer.class, "RAID")
end
SendAddonMessage("TWLClco", "rotSync=end", "RAID")
end
cooldownFrame:SetScript("OnShow", function()
this.startTime = GetTime()
end)
cooldownFrame:SetScript("OnHide", function()
end)
cooldownFrame:SetScript("OnUpdate", function()
if lco.enabled then
if GetTime() >= this.startTime + 0.5 then
this.startTime = GetTime()
local debuffTimeLeft = 0
if UnitIsDead('player') then
debuffTimeLeft = 100 --dead
else
for i = 0, 31 do
local id = GetPlayerBuff(i, "HARMFUL")
if id > -1 then
local timeleft = GetPlayerBuffTimeLeft(id)
local texture = GetPlayerBuffTexture(GetPlayerBuff(i, "HARMFUL"))
if texture == lco.debuffIcon then
debuffTimeLeft = timeleft
end
end
end
end
SendAddonMessage("TWLClco", "lcoCooldown=" .. debuffTimeLeft, "RAID")
lco.updateNext()
end
end
end)
function lco.show()
getglobal('LCO'):Show()
if lco.twlc2isRL(me) then
getglobal('LCOAddHealer'):Show()
getglobal('LCOResetHealers'):Show()
getglobal('LCOSyncHealers'):Show()
else
getglobal('LCOAddHealer'):Hide()
getglobal('LCOResetHealers'):Hide()
getglobal('LCOSyncHealers'):Hide()
end
end
-- /lco set 1 Er
SLASH_LCO1 = "/lco"
SlashCmdList["LCO"] = function(cmd)
if cmd then
if string.find(cmd, 'show', 1, true) then
lco.show()
end
if string.find(cmd, 'hide', 1, true) then
getglobal('LCO'):Hide()
end
end
end
function lco.twlc2isRL(name)
for i = 0, GetNumRaidMembers() do
if (GetRaidRosterInfo(i)) then
local n, r = GetRaidRosterInfo(i);
if (n == name and r == 2) then
return true
end
end
end
return false
end