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