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