-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVanguardAntiCooldown.lua
506 lines (467 loc) · 21.9 KB
/
VanguardAntiCooldown.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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
VGAC_BuffInfo = {
-- Debugging
["Frost Armor"] = {icon = "Interface\\Icons\\Spell_Frost_FrostArmor02", duration = 1800, priority = 0},
["Blessing of Protection"] = {icon = "Interface\\Icons\\Spell_Holy_SealOfProtection", duration = 10, absorbType = nil, priority = 0},
["Free Action"] = {icon = "Interface\\Icons\\INV_Potion_04", duration = 30, absorbType = nil, priority = 0},
["Invulnerability"] = {icon = "Interface\\Icons\\INV_Potion_62", duration = 6, absorbType = nil, priority = 0},
["Blessing of Freedom"] = {icon = "Interface\\Icons\\Spell_Holy_SealOfValor", duration = 16, absorbType = nil, priority = 0},
["Living Free Action"] = {icon = "Interface\\Icons\\INV_Potion_07", duration = 5, absorbType = nil, priority = 0},
["Power Word: Shield"] = {icon = "Interface\\Icons\\Spell_Holy_PowerWordShield", duration = 30, absorbType = "Physical", priority = 1},
["Ice Barrier"] = {icon = "Interface\\Icons\\Spell_Ice_Lament", duration = 60, absorbType = "Physical", priority = 1},
["Sacrifice"] = {icon = "Interface\\Icons\\Spell_Shadow_SacrificialShield", duration = 30, absorbType = nil, priority = 1},
["Fear Ward"] = {icon = "Interface\\Icons\\Spell_Holy_Excorcism", duration = 600, absorbType = nil, priority = 1},
["Mana Shield"] = {icon = "Interface\\Icons\\Spell_Shadow_DetectLesserInvisibility", duration = 60, absorbType = "Physical", priority = 1},
["Arcane Power"] = {icon = "Interface\\Icons\\Spell_Nature_Lightning", duration = 15, absorbType = nil, priority = 2},
["Power Infusion"] = {icon = "Interface\\Icons\\Spell_Holy_PowerInfusion", duration = 15, absorbType = nil, priority = 2},
["Rapid Fire"] = {icon = "Interface\\Icons\\Ability_Hunter_RunningShot", duration = 15, absorbType = nil, priority = 2},
["Restoration"] = {icon = "Interface\\Icons\\INV_Potion_01", duration = 30, absorbType = nil, priority = 3},
["Arcane Protection"] = {icon = "Interface\\Icons\\INV_Potion_83", duration = 3600, absorbType = "Arcane", priority = 3},
["Fire Protection"] = {icon = "Interface\\Icons\\INV_Potion_24", duration = 3600, absorbType = "Fire", priority = 3},
["Frost Protection"] = {icon = "Interface\\Icons\\INV_Potion_20", duration = 3600, absorbType = "Frost", priority = 3},
["Nature Protection"] = {icon = "Interface\\Icons\\INV_Potion_22", duration = 3600, absorbType = "Nature", priority = 3},
["Shadow Protection"] = {icon = "Interface\\Icons\\INV_Potion_23", duration = 3600, absorbType = "Shadow", priority = 3},
["Speed"] = {icon = "Interface\\Icons\\INV_Potion_19", duration = 15, absorbType = nil, priority = 4},
["Barkskin"] = {icon = "Interface\\Icons\\Spell_Nature_StoneClawTotem", duration = 15, absorbType = nil, priority = 4},
["Innervate"] = {icon = "Interface\\Icons\\Spell_Nature_Lightning", duration = 20, absorbType = nil, priority = 4},
["Abolish Poison"] = {icon = "Interface\\Icons\\Spell_Nature_NullifyPoison_02", duration = 8, absorbType = nil, priority = 4},
["Blessing of Sacrifice"] = {icon = "Interface\\Icons\\Spell_Holy_SealOfSacrifice", duration = 30, absorbType = nil, priority = 4},
["Clearcasting"] = {icon = "Interface\\Icons\\Spell_Shadow_ManaBurn", duration = 15, absorbType = nil, priority = 4},
-- ["Nature's Swiftness"] = {icon = "Interface\\Icons\\Spell_Nature_RavenForm", duration = -1, priority = -1},
-- ["Divine Favor"] = {icon = "Interface\\Icons\\Spell_Holy_Heal", duration = -1, priority = -1},
-- ["Presence of Mind"] = {icon = "Interface\\Icons\\Spell_Nature_EnchantArmor", duration = -1, priority = -1},
-- ["Combustion"] = {icon = "Interface\\Icons\\Spell_Fire_SealOfFire", duration = -1, priority = -1},
}
VGAC_defaultConfig = {x = 0, y = 0, isUnlocked = true, scale = 1.0, defaultHeight = 50, defaultWidth = 50, defaultTextSize = 16, numSlots = 15}
VGAC_UpdateInterval = 0.05
VGAC_LastUpdate = GetTime()
VGAC_ActiveBuffs = nil
VGAC_NumActiveBuffs = 0
VGAC_GroupLevel = 0 -- Not in a group: 0; In a party: 1; In a raid group: 2
VGAC_RecentTargets = {}
VanguardAntiCooldownFrame = CreateFrame("Frame", nil, UIParent)
VanguardAntiCooldownFrame:RegisterEvent("VARIABLES_LOADED")
VanguardAntiCooldownFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
-- VanguardAntiCooldownFrame:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE") -- You cast Purge on blabla.
VanguardAntiCooldownFrame:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS")
VanguardAntiCooldownFrame:RegisterEvent("CHAT_MSG_SPELL_BREAK_AURA")
VanguardAntiCooldownFrame:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH")
VanguardAntiCooldownFrame:RegisterEvent("CHAT_MSG_ADDON")
VanguardAntiCooldownFrame:RegisterEvent("PARTY_MEMBERS_CHANGED")
VanguardAntiCooldownFrame:RegisterEvent("RAID_ROSTER_UPDATE")
VanguardAntiCooldownFrame.Tooltip = CreateFrame("GameTooltip", "VGACTooltip", nil, "GameTooltipTemplate")
VanguardAntiCooldownFrame.Tooltip:SetOwner(WorldFrame, "ANCHOR_NONE")
VGAC_Bars = nil
function VGAC_OnDragStart()
if (VGACConfig.isUnlocked == true) then
VGAC_Bars.mainFrame:StartMoving()
end
end
function VGAC_OnDragStop()
VGAC_Bars.mainFrame:StopMovingOrSizing()
VGACConfig.x = VGAC_Bars.mainFrame:GetLeft()
VGACConfig.y = VGAC_Bars.mainFrame:GetBottom()
end
function VGAC_SecondsToTime(seconds)
local m = math.floor(seconds / 60)
local s = seconds - m * 60
if (m > 0) then
if (s < 10) then
s = "0"..s
end
return m..":"..s
else
return s
end
end
function VGAC_InitializeBars()
if (VGAC_Bars == nil) then VGAC_Bars = {} end
if (VGAC_Bars.mainFrame ~= nil) then VGAC_Bars.mainFrame = CreateFrame("Frame", nil, UIParent) end
VGAC_Bars.mainFrame = CreateFrame("Frame", nil, UIParent)
VGAC_Bars.mainFrame:SetPoint("BOTTOMLEFT", VGACConfig.x, VGACConfig.y)
VGAC_Bars.mainFrame:SetWidth(VGACConfig.numSlots * VGACConfig.defaultWidth)
VGAC_Bars.mainFrame:SetHeight(VGACConfig.defaultHeight * 1.2)
VGAC_Bars.mainFrame:SetBackdrop({bgFile = "Interface/RaidFrame/UI-RaidFrame-GroupBg", tile = true, tileSize = VGACConfig.defaultHeight})
VGAC_Bars.mainFrame:RegisterForDrag("LeftButton")
VGAC_Bars.mainFrame:SetScript("OnDragStart", function() VGAC_OnDragStart() end)
VGAC_Bars.mainFrame:SetScript("OnDragStop", function() VGAC_OnDragStop() end)
VGAC_Bars.mainFrame:SetAlpha(0)
VGAC_Bars.mainFrame:EnableMouse(false)
VGAC_Bars.BuffFrames = {}
for i = 1, VGACConfig.numSlots do
VGAC_Bars.BuffFrames[i] = CreateFrame("Frame", nil, VGAC_Bars.mainFrame)
local frame = VGAC_Bars.BuffFrames[i]
frame:SetPoint("TOPLEFT", VGACConfig.defaultWidth * (i - 1), 0)
frame:SetWidth(VGACConfig.defaultWidth)
frame:SetHeight(VGACConfig.defaultHeight * 1.2)
frame:SetBackdrop({edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", edgeSize = "10", tile = true})
frame.auraName = "None"
frame.texture = frame:CreateTexture(nil, "BACKGROUND")
local texture = frame.texture
texture:SetPoint("TOPLEFT", 0, 0);
texture:SetHeight(VGACConfig.defaultHeight)
texture:SetWidth(VGACConfig.defaultWidth)
texture:SetTexture("Interface\\Icons\\Spell_Holy_SealOfValor")
frame.timer = frame:CreateFontString(nil, "ARTWORK")
local timer = frame.timer
timer:SetAllPoints(frame)
timer:SetShadowColor(0, 0, 0, 1.0)
timer:SetShadowOffset(0.80, -0.80)
timer:SetFont("Fonts\\FRIZQT__.TTF", VGACConfig.defaultTextSize, "OUTLINE")
timer:SetText(VGAC_SecondsToTime(0))
timer:SetTextColor(1, 1, 1)
frame.buffOwner = frame:CreateFontString(nil, "ARTWORK")
local buffOwner = frame.buffOwner
buffOwner:SetPoint("BOTTOMLEFT", 3, 3);
buffOwner:SetHeight(VGACConfig.defaultHeight * 0.2)
buffOwner:SetWidth(VGACConfig.defaultWidth - 6)
buffOwner:SetShadowColor(0, 0, 0, 1.0)
buffOwner:SetShadowOffset(0.80, -0.80)
buffOwner:SetFont("Fonts\\FRIZQT__.TTF", VGACConfig.defaultTextSize * 0.6, "OUTLINE")
buffOwner:SetText("None")
buffOwner:SetTextColor(1, 1, 1)
end
if (VGACConfig.scale ~= 1.0) then
VGAC_UpdateScale()
end
if (VGACConfig.isUnlocked == true) then
VGACConfig.isUnlocked = false
VGAC_SlashCommand("move")
end
end
function VGAC_PurgeHostile()
_,playerClass = UnitClass("player")
local spellName = "None"
if (playerClass == "PRIEST") then
spellName = "Dispel Magic"
elseif (playerClass == "SHAMAN") then
spellName = "Purge"
else
return
end
VGAC_PurgeTargets = {}
VGAC_BucketSize = {}
local s = 100
local e = -100
if (VGAC_ActiveBuffs == nil) then
if (UnitExists("target")) then
CastSpellByName(spellName)
end
return
end
-- Find all candidate targets
for buffOwner, val in pairs(VGAC_ActiveBuffs) do
if (VGAC_RecentTargets[buffOwner] == nil) then
local minPriority = 100
for auraName, entry in pairs(VGAC_ActiveBuffs[buffOwner]) do
if (entry.priority < minPriority) then minPriority = entry.priority end
end
if (minPriority < 100) then
if (VGAC_BucketSize[minPriority] == nil) then
VGAC_BucketSize[minPriority] = 0
VGAC_PurgeTargets[minPriority] = {}
end
local n = VGAC_BucketSize[minPriority] + 1
VGAC_PurgeTargets[minPriority][n] = buffOwner
VGAC_BucketSize[minPriority] = n
if (s > minPriority) then s = minPriority end
if (e < minPriority) then e = minPriority end
end
end
end
-- Try to purge in order of priority
-- local scStatus = GetCVar("autoSelfCast")
-- SetCVar("autoSelfCast", 0)
for i = s, e do
if (VGAC_PurgeTargets[i] ~= nil) then
for j = 1, VGAC_BucketSize[i] do
local buffOwner = VGAC_PurgeTargets[i][j]
TargetByName(buffOwner, true)
if (UnitExists("target") and UnitIsEnemy("player", "target") and UnitName("target") == buffOwner) then
if (CheckInteractDistance("target", 4)) then
CastSpellByName(spellName)
VGAC_RecentTargets[buffOwner] = GetTime()
return
end
end
end
end
end
-- SetCVar("autoSelfCast", scStatus)
end
function VGAC_AddBuff(buffOwner, auraName, castBefore)
if (VGAC_BuffInfo[auraName] == nil) then return end
local skipUpdate = false
if (VGAC_ActiveBuffs == nil) then VGAC_ActiveBuffs = {} end
if (VGAC_ActiveBuffs[buffOwner] == nil) then VGAC_ActiveBuffs[buffOwner] = {} end
if (VGAC_ActiveBuffs[buffOwner][auraName] ~= nil) then
skipUpdate = true -- We already have this buff tracked, and it only needs its duration refreshed
end
VGAC_ActiveBuffs[buffOwner][auraName] = {duration = VGAC_BuffInfo[auraName].duration, castAt = GetTime() - tonumber(castBefore), priority = VGAC_BuffInfo[auraName].priority}
if (skipUpdate == false) then -- the buff is new and your bars need updating
VGAC_UpdateTrackedBuffs()
end
end
function VGAC_UpdateTrackedBuffs()
local VGAC_BuffCheck = {}
if (VGAC_ActiveBuffs == nil) then VGAC_ActiveBuffs = {} end
-- Check if your currently displayed buffs need to be removed (someone else purged them)
local n = 0
for i = 1, VGAC_NumActiveBuffs do
local buffOwner = VGAC_Bars.BuffFrames[i].buffOwner:GetText()
local auraName = VGAC_Bars.BuffFrames[i].auraName
if (VGAC_ActiveBuffs[buffOwner] ~= nil and VGAC_ActiveBuffs[buffOwner][auraName] ~= nil) then -- The displayed buff is still present
n = n + 1
VGAC_Bars.BuffFrames[n].auraName = auraName
VGAC_Bars.BuffFrames[n].texture:SetTexture(VGAC_BuffInfo[auraName].icon)
VGAC_Bars.BuffFrames[n].timer:SetText(VGAC_Bars.BuffFrames[i].timer:GetText())
VGAC_Bars.BuffFrames[n].buffOwner:SetText(buffOwner)
VGAC_Bars.BuffFrames[n]:Show()
if (VGAC_BuffCheck[buffOwner] == nil) then VGAC_BuffCheck[buffOwner] = {} end
VGAC_BuffCheck[buffOwner][auraName] = true
end
end
-- Hide the frames for removed buffs
for i = n + 1, VGAC_NumActiveBuffs do
VGAC_Bars.BuffFrames[i]:Hide()
end
VGAC_NumActiveBuffs = n
-- Check if additional buffs need to be displayed
for buffOwner, val in pairs(VGAC_ActiveBuffs) do
for auraName, entry in pairs(VGAC_ActiveBuffs[buffOwner]) do
if (VGAC_BuffCheck == nil or VGAC_BuffCheck[buffOwner] == nil or VGAC_BuffCheck[buffOwner][auraName] == nil) then
if (VGAC_NumActiveBuffs < VGACConfig.numSlots) then
VGAC_NumActiveBuffs = VGAC_NumActiveBuffs + 1
local n = VGAC_NumActiveBuffs
VGAC_Bars.BuffFrames[n].auraName = auraName
VGAC_Bars.BuffFrames[n].texture:SetTexture(VGAC_BuffInfo[auraName].icon)
VGAC_Bars.BuffFrames[n].timer:SetText(VGAC_SecondsToTime(math.floor(GetTime() - entry.castAt)))
VGAC_Bars.BuffFrames[n].buffOwner:SetText(buffOwner)
VGAC_Bars.BuffFrames[n]:Show()
end
end
end
end
end
function VGAC_OnEvent()
local playerName = UnitName("player")
if (event == "VARIABLES_LOADED" or event == "PLAYER_ENTERING_WORLD") then
if (VGACConfig == nil) then
VGACConfig = VGAC_defaultConfig
else
VGACConfig.defaultHeight = VGAC_defaultConfig.defaultHeight
VGACConfig.defaultWidth = VGAC_defaultConfig.defaultWidth
VGACConfig.defaultTextSize = VGAC_defaultConfig.defaultTextSize
VGACConfig.numSlots = VGAC_defaultConfig.numSlots
end
if (VGAC_Bars == nil) then VGAC_InitializeBars() end
elseif (event == "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS") then
for buffOwner, auraName in string.gfind(arg1, "(.*) gains (.*).") do
if (VGAC_BuffInfo[auraName] ~= nil) then
if (GetNumRaidMembers() > 0 or GetNumPartyMembers() > 0) then
local zone = GetZoneText()
local channel = "RAID"
if (zone == "Warsong Gulch" or zone == "Arathi Basin" or zone == "Alterac Valley") then channel = "BATTLEGROUND" end
SendAddonMessage("VGAC_NewBuff", buffOwner.."!"..auraName.."!"..(0), channel)
else
VGAC_AddBuff(buffOwner, auraName, 0)
end
end
end
elseif (event == "CHAT_MSG_SPELL_BREAK_AURA") then
for buffOwner, auraName in string.gfind(arg1, "(.*)'s (.*) is removed.") do
if (VGAC_BuffInfo[auraName] ~= nil) then
if (GetNumRaidMembers() > 0 or GetNumPartyMembers() > 0) then
local zone = GetZoneText()
local channel = "RAID"
if (zone == "Warsong Gulch" or zone == "Arathi Basin" or zone == "Alterac Valley") then channel = "BATTLEGROUND" end
SendAddonMessage("VGAC_RemoveBuff", buffOwner.."!"..auraName, channel)
else
if (VGAC_ActiveBuffs ~= nil and VGAC_ActiveBuffs[buffOwner] ~= nil) then
VGAC_ActiveBuffs[buffOwner][auraName] = nil
end
end
end
end
elseif (event == "CHAT_MSG_COMBAT_HOSTILE_DEATH") then
local deadGuysName = nil
for deadGuy in string.gfind(arg1, "You have slain (.*)!") do
deadGuysName = deadGuy
end
for deadGuy in string.gfind(arg1, "(.*) dies.") do
deadGuysName = deadGuy
end
if (GetNumRaidMembers() > 0 or GetNumPartyMembers() > 0) then
local zone = GetZoneText()
local channel = "RAID"
if (zone == "Warsong Gulch" or zone == "Arathi Basin" or zone == "Alterac Valley") then channel = "BATTLEGROUND" end
SendAddonMessage("VGAC_RemovePlayer", deadGuysName, channel)
else
if (VGAC_ActiveBuffs ~= nil and VGAC_ActiveBuffs[deadGuysName] ~= nil) then
VGAC_ActiveBuffs[deadGuysName] = nil
end
end
elseif (event == "CHAT_MSG_ADDON" and arg1 == "VGAC_NewBuff") then
for buffOwner, auraName, castBefore in string.gfind(arg2, "(.+)!(.+)!(.+)") do
VGAC_AddBuff(buffOwner, auraName, castBefore)
end
elseif (event == "CHAT_MSG_ADDON" and arg1 == "VGAC_RemoveBuff") then
for buffOwner, auraName in string.gfind(arg2, "(.+)!(.+)") do
if (VGAC_ActiveBuffs ~= nil and VGAC_ActiveBuffs[buffOwner] ~= nil) then
VGAC_ActiveBuffs[buffOwner][auraName] = nil
end
end
elseif (event == "CHAT_MSG_ADDON" and arg1 == "VGAC_RemovePlayer") then
local buffOwner = arg2
if (VGAC_ActiveBuffs ~= nil and VGAC_ActiveBuffs[buffOwner] ~= nil) then
VGAC_ActiveBuffs[buffOwner] = nil
end
elseif (event == "CHAT_MSG_ADDON" and arg1 == "VGAC_HiImBob") then -- A new player joined the group and is asking for active buff info
for buffOwner, val in pairs(VGAC_ActiveBuffs) do
for auraName, entry in pairs(VGAC_ActiveBuffs[buffOwner]) do
local zone = GetZoneText()
local channel = "RAID"
if (zone == "Warsong Gulch" or zone == "Arathi Basin" or zone == "Alterac Valley") then channel = "BATTLEGROUND" end
SendAddonMessage("VGAC_HiBob!"..arg2, buffOwner.."!"..auraName.."!"..(GetTime() - entry.castAt), channel)
end
end
elseif (event == "CHAT_MSG_ADDON" and string.find(arg1, "VGAC_HiBob!")) then
for recipient in string.gfind(arg1, "VGAC_HiBob!(.*)") do
if (recipient == playerName) then -- our call for buff info sharing was answered
for buffOwner, auraName, castBefore in string.gfind(arg2, "(.+)!(.+)!(.+)!(.+)") do
VGAC_AddBuff(buffOwner, auraName, castBefore)
end
end
end
elseif (event == "PARTY_MEMBERS_CHANGED" or event == "RAID_ROSTER_UPDATE") then
local oldGroupLevel = VGAC_GroupLevel
local zone = GetZoneText()
local channel = "RAID"
if (zone == "Warsong Gulch" or zone == "Arathi Basin" or zone == "Alterac Valley") then channel = "BATTLEGROUND" end
if (oldGroupLevel < VGAC_GroupLevel) then -- Since you joined a new group, it's time to tell everyone about the buffs that you know of and ask for them to share theirs
SendAddonMessage("VGAC_HiImBob", playerName, channel)
if (VGAC_ActiveBuffs ~= nil) then
for buffOwner, val in pairs(VGAC_ActiveBuffs) do
for auraName, entry in pairs(VGAC_ActiveBuffs) do
SendAddonMessage("VGAC_NewBuff", buffOwner.."!"..auraName.."!"..(GetTime() - entry.castAt), channel)
end
end
end
end
end
end
function VGAC_OnUpdate()
local currentTime = GetTime()
local delta = currentTime - VGAC_LastUpdate
local needsCleanup = false
if (delta >= VGAC_UpdateInterval) then
local playerName = UnitName("player")
-- Update targets that should be available for purge again
for buffOwner, timestamp in pairs(VGAC_RecentTargets) do
if (currentTime - timestamp >= 1.5) then
VGAC_RecentTargets[buffOwner] = nil
end
end
-- Update time for ALL buffs that you are aware of
if (VGAC_ActiveBuffs ~= nil) then
for buffOwner, val in pairs(VGAC_ActiveBuffs) do
for auraName, entry in pairs(val) do
local maxDelay = 60
if (VGAC_ActiveBuffs[buffOwner][auraName].duration < maxDelay) then
maxDelay = VGAC_ActiveBuffs[buffOwner][auraName].duration
end
if (VGAC_ActiveBuffs[buffOwner][auraName].castAt + maxDelay <= currentTime) then
VGAC_ActiveBuffs[buffOwner][auraName] = nil
end
end
end
end
-- Update timers that you have displayed
for i = 1, VGAC_NumActiveBuffs do
local buffOwner = VGAC_Bars.BuffFrames[i].buffOwner:GetText()
local auraName = VGAC_Bars.BuffFrames[i].auraName
if (VGAC_ActiveBuffs ~= nil and VGAC_ActiveBuffs[buffOwner] ~= nil and VGAC_ActiveBuffs[buffOwner][auraName] ~= nil) then
if (VGAC_ActiveBuffs[buffOwner][auraName].castAt + VGAC_ActiveBuffs[buffOwner][auraName].duration > currentTime) then
local remaining = math.floor(VGAC_ActiveBuffs[buffOwner][auraName].duration - (currentTime - VGAC_ActiveBuffs[buffOwner][auraName].castAt))
VGAC_Bars.BuffFrames[i].timer:SetText(VGAC_SecondsToTime(remaining))
end
elseif (VGAC_ActiveBuffs ~= nil and (VGAC_ActiveBuffs[buffOwner] == nil or VGAC_ActiveBuffs[buffOwner][auraName] == nil)) then
needsCleanup = true
end
end
VGAC_LastUpdate = currentTime
end
if (VGACConfig.isUnlocked == true) then
for i = VGAC_NumActiveBuffs + 1, VGACConfig.numSlots do
if (not VGAC_Bars.BuffFrames[i]:IsShown()) then VGAC_Bars.BuffFrames[i]:Show() end
end
elseif (VGACConfig.isUnlocked == false) then
for i = VGAC_NumActiveBuffs + 1, VGACConfig.numSlots do
if (VGAC_Bars.BuffFrames[i]:IsShown()) then VGAC_Bars.BuffFrames[i]:Hide() end
end
end
if (needsCleanup == true) then
VGAC_UpdateTrackedBuffs()
end
end
VanguardAntiCooldownFrame:SetScript("OnEvent", VGAC_OnEvent)
VanguardAntiCooldownFrame:SetScript("OnUpdate", VGAC_OnUpdate)
function VGAC_UpdateScale()
local scale = VGACConfig.scale
-- VGAC_Bars.mainFrame:SetScale(scale)
for i = 1, VGACConfig.numSlots do
local frame = VGAC_Bars.BuffFrames[i]
local texture = frame.texture
local timer = frame.timer
local buffOwner = frame.buffOwner
frame:SetPoint("TOPLEFT", scale * VGACConfig.defaultWidth * (i - 1), 0)
frame:SetWidth(scale * VGACConfig.defaultWidth)
frame:SetHeight(scale * VGACConfig.defaultHeight * 1.2)
texture:SetHeight(scale * VGACConfig.defaultHeight)
texture:SetWidth(scale * VGACConfig.defaultWidth)
timer:SetFont("Fonts\\FRIZQT__.TTF", scale * VGACConfig.defaultTextSize, "OUTLINE")
timer:SetAllPoints(frame)
buffOwner:SetFont("Fonts\\FRIZQT__.TTF", scale * VGACConfig.defaultTextSize * 0.6, "OUTLINE")
buffOwner:SetWidth(scale * VGACConfig.defaultWidth - 6)
buffOwner:SetHeight(scale * VGACConfig.defaultHeight * 0.2)
buffOwner:SetPoint("BOTTOMLEFT", 3, 3);
end
local frame = VGAC_Bars.mainFrame
frame:SetWidth(scale * VGACConfig.defaultWidth * VGACConfig.numSlots)
frame:SetHeight(scale * VGACConfig.defaultHeight)
end
function VGAC_SlashCommand(msg)
if (msg == "reset") then
VGACConfig = VGAC_defaultConfig
VGAC_InitializeBars()
elseif (msg == "move") then
if (VGACConfig.isUnlocked == false) then
VGACConfig.isUnlocked = true
VGAC_Bars.mainFrame:SetAlpha(0.5)
VGAC_Bars.mainFrame:EnableMouse(true)
for i = 1, VGACConfig.numSlots do
VGAC_Bars.BuffFrames[i]:SetAlpha(0.5)
end
VGAC_Bars.mainFrame:SetMovable(true)
else
VGAC_Bars.mainFrame:EnableMouse(false)
VGACConfig.isUnlocked = false
VGAC_Bars.mainFrame:SetAlpha(0)
for i = 1, VGACConfig.numSlots do
VGAC_Bars.BuffFrames[i]:SetAlpha(1)
end
VGAC_Bars.mainFrame:SetMovable(false)
end
elseif (string.find(msg, "scale ")) then
for scale in string.gfind(msg, "scale (.*)") do
VGACConfig.scale = scale
VGAC_UpdateScale()
end
else
DEFAULT_CHAT_FRAME:AddMessage("VanguardAntiCooldown (vgac), by Threewords <Vanguard> of Kronos, Twinstar")
DEFAULT_CHAT_FRAME:AddMessage("/vgac reset")
DEFAULT_CHAT_FRAME:AddMessage("/vgac move")
DEFAULT_CHAT_FRAME:AddMessage("/vgac scale "..VGACConfig.scale)
end
end
SLASH_VGAC1 = "/vgac"
SlashCmdList["VGAC"] = function(msg) VGAC_SlashCommand(msg) end