1100f11e41573879f9cf1280ad59e116e6e695d5
[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 };
58 local playerGuid = nil;
59
60 local auraEvents = {};
61 auraEvents.SPELL_AURA_APPLIED = function(frame, id, source, _, _, atype, amount)
62     if (amount == nil and watchedAuras[id][1] == 1) or (amount ~= nil and amount >= watchedAuras[id][1]) then
63         amount = amount or 1;
64         if atype == "BUFF" and source == playerGuid then
65             frame[watchedAuras[id][2]][id] = amount;
66         elseif atype == "DEBUFF" then
67             frame[watchedAuras[id][2]][id] = amount;
68         end
69     end
70 end
71 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
72 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
73 auraEvents.SPELL_AURA_REMOVED = function(frame, id, source, _, _, atype, amount)
74     if amount == nil or amount == 0 then
75         if atype == "BUFF" and source == playerGuid then
76             frame[watchedAuras[id][2]][id] = nil;
77         elseif atype == "DEBUFF" then
78             frame[watchedAuras[id][2]][id] = nil;
79         end
80     end
81 end
82 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
83 auraEvents.SPELL_AURA_BROKEN = function(frame, id, source)
84     return auraEvents.SPELL_AURA_REMOVED(frame, id, source, nil, nil, nil, 0);
85 end
86 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
87
88 local counter = 0;
89 local function clog(ts, event, _, source, _, _, _, dest, _, flags, _, spellid, ...)
90     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
91         auraEvents[event](guids[dest], spellid, source, ...);
92     end
93 end
94 addon.Events.Clog = clog;
95
96 local frame = CreateFrame("Frame");
97 frame:Hide();
98 frame:SetScript("OnEvent", function()
99     playerGuid = UnitGUID("player");
100     frame:UnregisterAllEvents();
101     frame:SetScript("OnEvent", function()
102         return clog(CombatLogGetCurrentEventInfo());
103     end);
104     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
105 end);
106 frame:RegisterEvent("PLAYER_LOGIN");