2120a9c - Add Ny'alotha auras to frames
[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     [61295] = {1, "buff1"}, -- Riptide
23     -- Tank defensives
24     [6940] = {1, "tankcd"}, -- Blessing of Sacrifice
25     [33206] = {1, "tankcd"}, -- Pain Suppression
26     [47788] = {1, "tankcd"}, -- Guardian Spirit
27     [102342] = {1, "tankcd"}, -- Ironbark
28     [116849] = {1, "tankcd"}, -- Life Cocoon
29     [196555] = {1, "tankcd"}, -- Netherwalk
30     -- M+
31     [209858] = {1, "stacks"}, -- Necrotic Wound (M+)
32     [240559] = {1, "stacks"}, -- Grievous Wound (M+)
33     [240443] = {1, "stacks"}, -- Burst (M+)
34     -- Uldir
35     [265264] = {2, "alert"}, -- Void Lash (Zek'voz)
36     -- Battle of Dazar'alor
37     [285213] = {1, "alert"}, -- Caress of Death (Rastakhan)
38     [288415] = {1, "alert"}, -- Caress of Death in Death realm (Rastakhan)
39     [285195] = {8, "stacks"}, -- Deathly Withering (Rastakhan)
40     [286646] = {1, "heal"}, -- Gigavolt Charge (Mekkatorque)
41     [288939] = {1, "heal"}, -- Gigavolt Radiation (Mekkatorque)
42     [287891] = {1, "stacks"}, -- Sheep Shrapnel (Mekkatorque)
43     [287993] = {1, "stacks"}, -- Chilling Touch (Jaina)
44     [283507] = {1, "heal"}, -- Volatile Charge (Opulence)
45     [287648] = {1, "heal"}, -- Volatile Charge (Opulence)
46     [284556] = {1, "stacks"}, -- Shadow-Touched (Opulence)
47     [287072] = {1, "heal"}, -- Liquid Gold (Opulence)
48     [284781] = {1, "heal"}, -- Grievous Axe (Rastakhan)
49     [290955] = {1, "heal"}, -- Grievous Axe (Rastakhan)
50     --[284663] = {1, "alert"}, -- Bwonsamdi's Wrath (Conclave)
51     -- Crucible of Storms
52     [282566] = {1, "stacks"}, -- Promises of Power (Restless Cabal)
53     [282738] = {1, "alert"}, -- Embrace of the Void (Restless Cabal)
54     [285652] = {1, "alert"}, -- Insatiable Torment (Uu'nat)
55     [285367] = {2, "stacks"}, -- Piercing Gaze of N'Zoth (Uu'nat)
56     [284733] = {1, "alert"}, -- Embrace of the Void (Uu'nat)
57     [285685] = {1, "alert"}, -- Gift of N'Zoth: Lunacy (Uu'nat)
58     -- The Eternal Palace
59     [292127] = {1, "alert"}, -- Darkest Depths (Underwater)
60     [298569] = {1, "stacks"}, -- Drained Soul (Queen Azshara)
61     [297586] = {1, "alert"}, -- Suffering (Queen's Court)
62     [294711] = {5, "heal"}, -- Frost (Sivara)
63     [294715] = {5, "heal"}, -- Toxic (Sivara)
64     [296693] = {1, "stacks"}, -- Waterlogged (Ashvane)
65     [297333] = {1, "heal"}, -- Briny Bubble (Ashvane)
66     [298306] = {1, "stacks"}, -- Incubation Fluid (Orgozoa)
67     -- Ny'alotha
68     [313255] = {20, "stacks"}, -- Creeping Madness (Wrathion)
69     [310224] = {1, "stacks"}, -- Annihilation (Vexiona)
70     [307358] = {1, "heal"}, -- Debilitating Spit (Shad'har)
71     [312486] = {1, "stacks"}, -- Recurring Nightmare (Il'gynoth)
72     [313400] = {1, "stacks"}, -- Corrupted Mind (N'zoth)
73     [319346] = {1, "heal"}, -- Infinity's Toll (N'zoth) phase marker
74     [316506] = {1, "alert"}, -- Heartpiercer Venom (Trash)
75     [315025] = {1, "heal"}, -- Ancient Curse (Maut)
76 };
77 local playerGuid = nil;
78
79 local auraEvents = {};
80 auraEvents.SPELL_AURA_APPLIED = function(frame, id, source, _, _, atype, amount)
81     if (amount == nil and watchedAuras[id][1] == 1) or (amount ~= nil and amount >= watchedAuras[id][1]) then
82         amount = amount or 1;
83         if atype == "BUFF" and source == playerGuid then
84             frame[watchedAuras[id][2]][id] = amount;
85         elseif atype == "DEBUFF" then
86             frame[watchedAuras[id][2]][id] = amount;
87         end
88     end
89 end
90 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
91 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
92 auraEvents.SPELL_AURA_REMOVED = function(frame, id, source, _, _, atype, amount)
93     if amount == nil or amount == 0 then
94         if atype == "BUFF" and source == playerGuid then
95             frame[watchedAuras[id][2]][id] = nil;
96         elseif atype == "DEBUFF" then
97             frame[watchedAuras[id][2]][id] = nil;
98         end
99     end
100 end
101 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
102 auraEvents.SPELL_AURA_BROKEN = function(frame, id, source)
103     return auraEvents.SPELL_AURA_REMOVED(frame, id, source, nil, nil, nil, 0);
104 end
105 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
106
107 local counter = 0;
108 local function clog(ts, event, _, source, _, _, _, dest, _, _, _, spellid, ...)
109     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
110         auraEvents[event](guids[dest], spellid, source, ...);
111     end
112 end
113 addon.Events.Clog = clog;
114
115 local types = {["HELPFUL"] = "BUFF", ["HARMFUL"] = "DEBUFF"};
116 local function setAuras(unit, guid)
117     local name;
118     local spellid, count, source;
119     for filter, atype in pairs(types) do
120         local i = 1;
121         while true do
122             name, _, count, _, _, _, source, _, _, spellid = UnitAura(unit, i, filter);
123             if not spellid then break end
124             if count == 0 then count = nil end
125             if source ~= nil then
126                 clog(0, "SPELL_AURA_APPLIED", nil, UnitGUID(source), nil, nil, nil,
127                      guid, nil, nil, nil, spellid, nil, nil, atype, count);
128             elseif filter == "HARMFUL" then
129                 clog(0, "SPELL_AURA_APPLIED", nil, nil, nil, nil, nil,
130                      guid, nil, nil, nil, spellid, nil, nil, atype, count);
131             end
132             i = i + 1;
133         end
134     end
135 end
136 addon.SetAuras = setAuras;
137
138 local frame = CreateFrame("Frame");
139 frame:Hide();
140 frame:SetScript("OnEvent", function()
141     playerGuid = UnitGUID("player");
142     frame:UnregisterAllEvents();
143     frame:SetScript("OnEvent", function()
144         return clog(CombatLogGetCurrentEventInfo());
145     end);
146     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
147 end);
148 frame:RegisterEvent("PLAYER_LOGIN");