c39801d - Add simple red alert aura tracking
[wowui.git] / kehys / auras.lua
1 -- auras.lua
2 -- 2019 Aleksi Blinnikka
3 local _, addon = ...;
4 local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo;
5
6 local guids = addon.FrameGuids;
7 local watchedAuras = {
8     --[286988] = duration, -- Searing Embers
9     --[257908] = {bar=false}, -- Oiled Blade
10     --[268391] = {bar=false}, -- Mental Assault
11     --[272571] = {bar=false}, -- Choking Waters
12     --[268008] = {bar=false}, -- Snake Charm
13     --[260741] = {bar=false}, -- Jagged Nettles
14     --[280605] = {bar=false}, -- Brain Freeze
15     --[268797] = {bar=false}, -- Transmute to Goo
16     --[265889] = {bar=false}, -- Torch Strike
17     --[266209] = {bar=false}, -- Wicked Frenzy
18     --[258323] = {bar=false}, -- Infected Wound
19     --[262513] = {bar=false}, -- Azerite Heartseeker
20     -- Uldir
21     [265264] = 2, -- Void Lash (Zek'voz)
22     -- Battle of Dazar'alor
23     [285213] = 1, -- Caress of Death (Rastakhan)
24 };
25
26 local auraEvents = {};
27 auraEvents.SPELL_AURA_APPLIED = function(frame, id, _, _, _, amount)
28     if amount == nil or amount >= watchedAuras[id] then
29         frame.alert[id] = true;
30     end
31 end
32 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
33 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
34 auraEvents.SPELL_AURA_REMOVED = function(frame, id, _, _, _, amount)
35     if amount == nil or amount == 0 then
36         frame.alert[id] = nil;
37     end
38 end
39 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
40 auraEvents.SPELL_AURA_BROKEN = function(frame, id)
41     return auraEvents.SPELL_AURA_REMOVED(frame, id, nil, nil, nil, 0);
42 end
43 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
44
45 local counter = 0;
46 local function clog(ts, event, _, _, _, _, _, dest, _, flags, _, spellid, ...)
47     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
48         auraEvents[event](guids[dest], spellid, ...);
49     end
50 end
51 addon.Events.Clog = clog;
52
53 local frame = CreateFrame("Frame");
54 frame:Hide();
55 frame:SetScript("OnEvent", function()
56     frame:UnregisterAllEvents();
57     frame:SetScript("OnEvent", function()
58         return clog(CombatLogGetCurrentEventInfo());
59     end);
60     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
61 end);
62 frame:RegisterEvent("PLAYER_LOGIN");