1a61ccc - Add Ra-den aura
[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     --[280605] = {bar=false}, -- Brain Freeze
14     --[268797] = {bar=false}, -- Transmute to Goo
15     --[265889] = {bar=false}, -- Torch Strike
16     --[266209] = {bar=false}, -- Wicked Frenzy
17     --[258323] = {bar=false}, -- Infected Wound
18     --[262513] = {bar=false}, -- Azerite Heartseeker
19     [287280] = {1, "buff1"}, -- Glimmer of Light
20     [194384] = {1, "buff1"}, -- Atonement
21     [61295] = {1, "buff1"}, -- Riptide
22     [53563] = {1, "buff2"}, -- Beacon of Light
23     [156910] = {1, "buff2"}, -- Beacon of Faith
24     [200025] = {1, "buff2"}, -- Beacon of Virtue
25     -- Tank defensives
26     [6940] = {1, "tankcd"}, -- Blessing of Sacrifice
27     [33206] = {1, "tankcd"}, -- Pain Suppression
28     [47788] = {1, "tankcd"}, -- Guardian Spirit
29     [102342] = {1, "tankcd"}, -- Ironbark
30     [116849] = {1, "tankcd"}, -- Life Cocoon
31     [196555] = {1, "tankcd"}, -- Netherwalk
32     -- M+
33     [209858] = {1, "stacks"}, -- Necrotic Wound (M+)
34     [240559] = {1, "stacks"}, -- Grievous Wound (M+)
35     [240443] = {1, "stacks"}, -- Burst (M+)
36     [260741] = {1, "heal"}, -- Jagged Nettles (Waycrest Manor)
37     -- Uldir
38     [265264] = {2, "alert"}, -- Void Lash (Zek'voz)
39     -- Battle of Dazar'alor
40     [285213] = {1, "alert"}, -- Caress of Death (Rastakhan)
41     [288415] = {1, "alert"}, -- Caress of Death in Death realm (Rastakhan)
42     [285195] = {8, "stacks"}, -- Deathly Withering (Rastakhan)
43     [286646] = {1, "heal"}, -- Gigavolt Charge (Mekkatorque)
44     [288939] = {1, "heal"}, -- Gigavolt Radiation (Mekkatorque)
45     [287891] = {1, "stacks"}, -- Sheep Shrapnel (Mekkatorque)
46     [287114] = {1, "alert"}, -- Miscalculated Teleport (Mekkatorque)
47     [287167] = {1, "stacks"}, -- Discombobulation (Mekkatorque)
48     [287993] = {1, "stacks"}, -- Chilling Touch (Jaina)
49     [283507] = {1, "heal"}, -- Volatile Charge (Opulence)
50     [287648] = {1, "heal"}, -- Volatile Charge (Opulence)
51     [284556] = {1, "stacks"}, -- Shadow-Touched (Opulence)
52     [287072] = {1, "heal"}, -- Liquid Gold (Opulence)
53     [284781] = {1, "heal"}, -- Grievous Axe (Rastakhan)
54     [290955] = {1, "heal"}, -- Grievous Axe (Rastakhan)
55     --[284663] = {1, "alert"}, -- Bwonsamdi's Wrath (Conclave)
56     -- Crucible of Storms
57     [282566] = {1, "stacks"}, -- Promises of Power (Restless Cabal)
58     [282738] = {1, "alert"}, -- Embrace of the Void (Restless Cabal)
59     [285652] = {1, "alert"}, -- Insatiable Torment (Uu'nat)
60     [285367] = {2, "stacks"}, -- Piercing Gaze of N'Zoth (Uu'nat)
61     [284733] = {1, "alert"}, -- Embrace of the Void (Uu'nat)
62     [285685] = {1, "alert"}, -- Gift of N'Zoth: Lunacy (Uu'nat)
63     -- The Eternal Palace
64     [292127] = {1, "alert"}, -- Darkest Depths (Underwater)
65     [298569] = {1, "stacks"}, -- Drained Soul (Queen Azshara)
66     [297586] = {1, "alert"}, -- Suffering (Queen's Court)
67     [294711] = {5, "heal"}, -- Frost (Sivara)
68     [294715] = {5, "heal"}, -- Toxic (Sivara)
69     [296693] = {1, "stacks"}, -- Waterlogged (Ashvane)
70     [297333] = {1, "heal"}, -- Briny Bubble (Ashvane)
71     [298306] = {1, "stacks"}, -- Incubation Fluid (Orgozoa)
72     -- Ny'alotha
73     [313255] = {20, "stacks"}, -- Creeping Madness (Wrathion)
74     [310224] = {1, "stacks"}, -- Annihilation (Vexiona)
75     [307358] = {1, "heal"}, -- Debilitating Spit (Shad'har)
76     [318078] = {1, "alert"}, -- Fixate (Shad'har)
77     [312486] = {1, "stacks"}, -- Recurring Nightmare (Il'gynoth)
78     [313400] = {1, "stacks"}, -- Corrupted Mind (N'zoth)
79     [319346] = {1, "heal"}, -- Infinity's Toll (N'zoth) phase marker
80     [316506] = {1, "alert"}, -- Heartpiercer Venom (Trash)
81     [315025] = {1, "heal"}, -- Ancient Curse (Maut)
82     [315311] = {1, "stacks"}, -- Ravage (Hivemind)
83     [313460] = {1, "alert"}, -- Nullification (Hivemind)
84     [313461] = {1, "heal"}, -- Corrosion (Hivemind)
85     [307359] = {1, "heal"}, -- Despair (Vexiona)
86     [316065] = {1, "alert"}, -- Corrupted Existence (Ra'den)
87 };
88 local playerGuid = nil;
89
90 local auraEvents = {};
91 auraEvents.SPELL_AURA_APPLIED = function(frame, id, source, _, _, atype, amount)
92     if (amount == nil and watchedAuras[id][1] == 1) or (amount ~= nil and amount >= watchedAuras[id][1]) then
93         amount = amount or 1;
94         if atype == "BUFF" and source == playerGuid then
95             frame[watchedAuras[id][2]][id] = amount;
96         elseif atype == "DEBUFF" then
97             frame[watchedAuras[id][2]][id] = amount;
98         end
99     end
100 end
101 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
102 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
103 auraEvents.SPELL_AURA_REMOVED = function(frame, id, source, _, _, atype, amount)
104     if amount == nil or amount == 0 then
105         if atype == "BUFF" and source == playerGuid then
106             frame[watchedAuras[id][2]][id] = nil;
107         elseif atype == "DEBUFF" then
108             frame[watchedAuras[id][2]][id] = nil;
109         end
110     end
111 end
112 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
113 auraEvents.SPELL_AURA_BROKEN = function(frame, id, source)
114     return auraEvents.SPELL_AURA_REMOVED(frame, id, source, nil, nil, nil, 0);
115 end
116 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
117
118 local counter = 0;
119 local function clog(ts, event, _, source, _, _, _, dest, _, _, _, spellid, ...)
120     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
121         auraEvents[event](guids[dest], spellid, source, ...);
122     end
123 end
124 addon.Events.Clog = clog;
125
126 local types = {["HELPFUL"] = "BUFF", ["HARMFUL"] = "DEBUFF"};
127 local function setAuras(unit, guid)
128     local name;
129     local spellid, count, source;
130     for filter, atype in pairs(types) do
131         local i = 1;
132         while true do
133             name, _, count, _, _, _, source, _, _, spellid = UnitAura(unit, i, filter);
134             if not spellid then break end
135             if count == 0 then count = nil end
136             if source ~= nil then
137                 clog(0, "SPELL_AURA_APPLIED", nil, UnitGUID(source), nil, nil, nil,
138                      guid, nil, nil, nil, spellid, nil, nil, atype, count);
139             elseif filter == "HARMFUL" then
140                 clog(0, "SPELL_AURA_APPLIED", nil, nil, nil, nil, nil,
141                      guid, nil, nil, nil, spellid, nil, nil, atype, count);
142             end
143             i = i + 1;
144         end
145     end
146 end
147 addon.SetAuras = setAuras;
148
149 local frame = CreateFrame("Frame");
150 frame:Hide();
151 frame:SetScript("OnEvent", function()
152     playerGuid = UnitGUID("player");
153     frame:UnregisterAllEvents();
154     frame:SetScript("OnEvent", function()
155         return clog(CombatLogGetCurrentEventInfo());
156     end);
157     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
158 end);
159 frame:RegisterEvent("PLAYER_LOGIN");
160
161 -- debug slash command to get target auras
162 SLASH_KEHYS1 = "/kaura"
163 function SlashCmdList.KEHYS(msg, editBox)
164     local name, spellid, count, source;
165     local unit = "target";
166     if msg and msg ~= "" then
167         unit = msg;
168     end
169     for filter, atype in pairs(types) do
170         local i = 1;
171         while true do
172             name, _, count, _, _, _, source, _, _, spellid = UnitAura(unit, i, filter);
173             if not spellid then break end
174             print(atype, name, count, source, spellid);
175             i = i + 1;
176         end
177     end
178 end