19b1609 - Change main events to a constant update to fix event issues
[wowui.git] / kehys / auras.lua
1 -- auras.lua
2 -- 2019 Aleksi Blinnikka
3 local _, addon = ...;
4 local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo;
5
6 local watchedAuras = {
7     -- Battle of Dazar'alor
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     [53563] = "TOPRIGHT", -- Beacon of Light
21     [156910] = "TOPRIGHT", -- Beacon of Faith
22     [200025] = "TOPRIGHT", -- Beacon of Virtue
23     [33763] = "TOPLEFT", -- Lifebloom
24     [774] = "TR1", -- Rejuvenation
25     [102352] = "TR2", -- Cenarion Ward (102351 is the pre-buff)
26     [207386] = "TR3", -- Spring Blossoms (207385 is the talent)
27     [155777] = "TR3", -- Germination (either this or Spring Blossoms taken)
28     [8936] = "TR4", -- Regrowth
29     [200389] = "TR5", -- Cultivation
30 };
31
32 local auraEvents = {};
33 auraEvents.SPELL_AURA_APPLIED = function(frame, id, _, _, _, amount)
34     if UnitDebuff(frame.unit, 1, "RAID") ~= nil then
35         -- update dispel indicator
36         frame:ColorOverlay("low", 1, 0.5, 0, 0.5);
37     end
38     if auras[id] then
39         if amount > 0 then
40             frame.auraStarts[id] = GetTime();
41             return updateApplication(frame, id, amount);
42         else
43             return updateRemoval(frame, id);
44         end
45     end
46 end
47 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
48 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
49 auraEvents.SPELL_AURA_REMOVED = auraEvents.SPELL_AURA_APPLIED;
50 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_APPLIED;
51 auraEvents.SPELL_AURA_BROKEN = function(frame, id)
52     return auraEvents.SPELL_AURA_APPLIED(frame, id, nil, nil, nil, 0);
53 end
54 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
55
56 local counter = 0;
57 local function clog(ts, event, _, _, _, _, _, dest, _, flags, _, spellid, ...)
58     if auraEvents[event] and watchedAuras[spellid] then
59         counter = counter + 1;
60     end
61 end
62 addon.Events.Clog = clog;
63
64 local frame = CreateFrame("Frame");
65 frame:Hide();
66 frame:SetScript("OnEvent", function()
67     frame:UnregisterAllEvents();
68     frame:SetScript("OnEvent", function()
69         return clog(CombatLogGetCurrentEventInfo());
70     end);
71     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
72 end);
73 frame:RegisterEvent("PLAYER_LOGIN");