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