7d88db242ffeda41ff7d01e4a3c9c4865a1f3bf6
[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     [196555] = {1, "tankcd"}, -- Netherwalk
27     -- M+
28     [209858] = {1, "stacks"}, -- Necrotic Wound (M+)
29     -- Uldir
30     [265264] = {2, "alert"}, -- Void Lash (Zek'voz)
31     -- Battle of Dazar'alor
32     [285213] = {1, "alert"}, -- Caress of Death (Rastakhan)
33     [288415] = {1, "alert"}, -- Caress of Death in Death realm (Rastakhan)
34     [285195] = {8, "stacks"}, -- Deathly Withering (Rastakhan)
35     [286646] = {1, "heal"}, -- Gigavolt Charge (Mekkatorque)
36     [287891] = {1, "stacks"}, -- Sheep Shrapnel (Mekkatorque)
37     [287993] = {1, "stacks"}, -- Chilling Touch (Jaina)
38     [283507] = {1, "heal"}, -- Volatile Charge (Opulence)
39     [287648] = {1, "heal"}, -- Volatile Charge (Opulence)
40     [284556] = {1, "stacks"}, -- Shadow-Touched (Opulence)
41     [287072] = {1, "heal"}, -- Liquid Gold (Opulence)
42     [284781] = {1, "heal"}, -- Grievous Axe (Rastakhan)
43     [290955] = {1, "heal"}, -- Grievous Axe (Rastakhan)
44     --[284663] = {1, "alert"}, -- Bwonsamdi's Wrath (Conclave)
45     -- Crucible of Storms
46     [282566] = {1, "stacks"}, -- Promises of Power (Restless Cabal)
47     [282738] = {1, "alert"}, -- Embrace of the Void (Restless Cabal)
48     [285652] = {1, "alert"}, -- Insatiable Torment (Uu'nat)
49     [285367] = {2, "stacks"}, -- Piercing Gaze of N'Zoth (Uu'nat)
50     [284733] = {1, "alert"}, -- Embrace of the Void (Uu'nat)
51     [285685] = {1, "alert"}, -- Gift of N'Zoth: Lunacy (Uu'nat)
52     -- The Eternal Palace
53     [292127] = {1, "alert"}, -- Darkest Depths (Underwater)
54     [298569] = {1, "stacks"}, -- Drained Soul (Queen Azshara)
55     [297586] = {1, "alert"}, -- Suffering (Queen's Court)
56 };
57
58 local auraEvents = {};
59 auraEvents.SPELL_AURA_APPLIED = function(frame, id, _, _, _, amount)
60     if (amount == nil and watchedAuras[id][1] == 1) or (amount ~= nil and amount >= watchedAuras[id][1]) then
61         amount = amount or 1;
62         frame[watchedAuras[id][2]][id] = amount;
63     end
64 end
65 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
66 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
67 auraEvents.SPELL_AURA_REMOVED = function(frame, id, _, _, _, amount)
68     if amount == nil or amount == 0 then
69         frame[watchedAuras[id][2]][id] = nil;
70     end
71 end
72 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
73 auraEvents.SPELL_AURA_BROKEN = function(frame, id)
74     return auraEvents.SPELL_AURA_REMOVED(frame, id, nil, nil, nil, 0);
75 end
76 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
77
78 local counter = 0;
79 local function clog(ts, event, _, _, _, _, _, dest, _, flags, _, spellid, ...)
80     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
81         auraEvents[event](guids[dest], spellid, ...);
82     end
83 end
84 addon.Events.Clog = clog;
85
86 local frame = CreateFrame("Frame");
87 frame:Hide();
88 frame:SetScript("OnEvent", function()
89     frame:UnregisterAllEvents();
90     frame:SetScript("OnEvent", function()
91         return clog(CombatLogGetCurrentEventInfo());
92     end);
93     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
94 end);
95 frame:RegisterEvent("PLAYER_LOGIN");