44065ae - Add EP debuffs, buffind1 color change
[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     [287280] = {1, "buff1"}, -- Glimmer of Light
21     -- Tank defensives
22     [6940] = {1, "tankcd"}, -- Blessing of Sacrifice
23     [33206] = {1, "tankcd"}, -- Pain Suppression
24     [47788] = {1, "tankcd"}, -- Guardian Spirit
25     [102342] = {1, "tankcd"}, -- Ironbark
26     [116849] = {1, "tankcd"}, -- Life Cocoon
27     [196555] = {1, "tankcd"}, -- Netherwalk
28     -- M+
29     [209858] = {1, "stacks"}, -- Necrotic Wound (M+)
30     -- Uldir
31     [265264] = {2, "alert"}, -- Void Lash (Zek'voz)
32     -- Battle of Dazar'alor
33     [285213] = {1, "alert"}, -- Caress of Death (Rastakhan)
34     [288415] = {1, "alert"}, -- Caress of Death in Death realm (Rastakhan)
35     [285195] = {8, "stacks"}, -- Deathly Withering (Rastakhan)
36     [286646] = {1, "heal"}, -- Gigavolt Charge (Mekkatorque)
37     [287891] = {1, "stacks"}, -- Sheep Shrapnel (Mekkatorque)
38     [287993] = {1, "stacks"}, -- Chilling Touch (Jaina)
39     [283507] = {1, "heal"}, -- Volatile Charge (Opulence)
40     [287648] = {1, "heal"}, -- Volatile Charge (Opulence)
41     [284556] = {1, "stacks"}, -- Shadow-Touched (Opulence)
42     [287072] = {1, "heal"}, -- Liquid Gold (Opulence)
43     [284781] = {1, "heal"}, -- Grievous Axe (Rastakhan)
44     [290955] = {1, "heal"}, -- Grievous Axe (Rastakhan)
45     --[284663] = {1, "alert"}, -- Bwonsamdi's Wrath (Conclave)
46     -- Crucible of Storms
47     [282566] = {1, "stacks"}, -- Promises of Power (Restless Cabal)
48     [282738] = {1, "alert"}, -- Embrace of the Void (Restless Cabal)
49     [285652] = {1, "alert"}, -- Insatiable Torment (Uu'nat)
50     [285367] = {2, "stacks"}, -- Piercing Gaze of N'Zoth (Uu'nat)
51     [284733] = {1, "alert"}, -- Embrace of the Void (Uu'nat)
52     [285685] = {1, "alert"}, -- Gift of N'Zoth: Lunacy (Uu'nat)
53     -- The Eternal Palace
54     [292127] = {1, "alert"}, -- Darkest Depths (Underwater)
55     [298569] = {1, "stacks"}, -- Drained Soul (Queen Azshara)
56     [297586] = {1, "alert"}, -- Suffering (Queen's Court)
57     [294711] = {5, "heal"}, -- Frost (Sivara)
58     [294715] = {5, "heal"}, -- Toxic (Sivara)
59     [296693] = {1, "stacks"}, -- Waterlogged (Ashvane)
60 };
61 local playerGuid = nil;
62
63 local auraEvents = {};
64 auraEvents.SPELL_AURA_APPLIED = function(frame, id, source, _, _, atype, amount)
65     if (amount == nil and watchedAuras[id][1] == 1) or (amount ~= nil and amount >= watchedAuras[id][1]) then
66         amount = amount or 1;
67         if atype == "BUFF" and source == playerGuid then
68             frame[watchedAuras[id][2]][id] = amount;
69         elseif atype == "DEBUFF" then
70             frame[watchedAuras[id][2]][id] = amount;
71         end
72     end
73 end
74 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
75 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
76 auraEvents.SPELL_AURA_REMOVED = function(frame, id, source, _, _, atype, amount)
77     if amount == nil or amount == 0 then
78         if atype == "BUFF" and source == playerGuid then
79             frame[watchedAuras[id][2]][id] = nil;
80         elseif atype == "DEBUFF" then
81             frame[watchedAuras[id][2]][id] = nil;
82         end
83     end
84 end
85 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
86 auraEvents.SPELL_AURA_BROKEN = function(frame, id, source)
87     return auraEvents.SPELL_AURA_REMOVED(frame, id, source, nil, nil, nil, 0);
88 end
89 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
90
91 local counter = 0;
92 local function clog(ts, event, _, source, _, _, _, dest, _, flags, _, spellid, ...)
93     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
94         auraEvents[event](guids[dest], spellid, source, ...);
95     end
96 end
97 addon.Events.Clog = clog;
98
99 local frame = CreateFrame("Frame");
100 frame:Hide();
101 frame:SetScript("OnEvent", function()
102     playerGuid = UnitGUID("player");
103     frame:UnregisterAllEvents();
104     frame:SetScript("OnEvent", function()
105         return clog(CombatLogGetCurrentEventInfo());
106     end);
107     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
108 end);
109 frame:RegisterEvent("PLAYER_LOGIN");