12d76ae - TOC updates to 8.2
[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     -- Tank defensives
21     [6940] = {1, "tankcd"}, -- Blessing of Sacrifice
22     [33206] = {1, "tankcd"}, -- Pain Suppression
23     [47788] = {1, "tankcd"}, -- Guardian Spirit
24     [102342] = {1, "tankcd"}, -- Ironbark
25     [116849] = {1, "tankcd"}, -- Life Cocoon
26     -- Uldir
27     [265264] = {2, "alert"}, -- Void Lash (Zek'voz)
28     -- Battle of Dazar'alor
29     [285213] = {1, "alert"}, -- Caress of Death (Rastakhan)
30     [288415] = {1, "alert"}, -- Caress of Death in Death realm (Rastakhan)
31     [285195] = {8, "stacks"}, -- Deathly Withering (Rastakhan)
32     [286646] = {1, "heal"}, -- Gigavolt Charge (Mekkatorque)
33     [287891] = {1, "stacks"}, -- Sheep Shrapnel (Mekkatorque)
34     [287993] = {1, "stacks"}, -- Chilling Touch (Jaina)
35 };
36
37 local auraEvents = {};
38 auraEvents.SPELL_AURA_APPLIED = function(frame, id, _, _, _, amount)
39     if (amount == nil and watchedAuras[id][1] == 1) or (amount ~= nil and amount >= watchedAuras[id][1]) then
40         amount = amount or 1;
41         frame[watchedAuras[id][2]][id] = amount;
42     end
43 end
44 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
45 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
46 auraEvents.SPELL_AURA_REMOVED = function(frame, id, _, _, _, amount)
47     if amount == nil or amount == 0 then
48         frame[watchedAuras[id][2]][id] = nil;
49     end
50 end
51 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
52 auraEvents.SPELL_AURA_BROKEN = function(frame, id)
53     return auraEvents.SPELL_AURA_REMOVED(frame, id, nil, nil, nil, 0);
54 end
55 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
56
57 local counter = 0;
58 local function clog(ts, event, _, _, _, _, _, dest, _, flags, _, spellid, ...)
59     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
60         auraEvents[event](guids[dest], spellid, ...);
61     end
62 end
63 addon.Events.Clog = clog;
64
65 local frame = CreateFrame("Frame");
66 frame:Hide();
67 frame:SetScript("OnEvent", function()
68     frame:UnregisterAllEvents();
69     frame:SetScript("OnEvent", function()
70         return clog(CombatLogGetCurrentEventInfo());
71     end);
72     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
73 end);
74 frame:RegisterEvent("PLAYER_LOGIN");