52f2ef0 - add more mage tmw icons
[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     [287280] = {1, "buff1"}, -- Glimmer of Light
11     [194384] = {1, "buff1"}, -- Atonement
12     [61295] = {1, "buff1"}, -- Riptide
13     [53563] = {1, "buff2"}, -- Beacon of Light
14     [156910] = {1, "buff2"}, -- Beacon of Faith
15     [200025] = {1, "buff2"}, -- Beacon of Virtue
16     --[974] = {1, "buff2"}, -- Earth Shield
17     -- Tank defensives
18     [6940] = {1, "tankcd"}, -- Blessing of Sacrifice
19     [33206] = {1, "tankcd"}, -- Pain Suppression
20     [47788] = {1, "tankcd"}, -- Guardian Spirit
21     [102342] = {1, "tankcd"}, -- Ironbark
22     [116849] = {1, "tankcd"}, -- Life Cocoon
23     [196555] = {1, "tankcd"}, -- Netherwalk
24     -- Raid-wide defensives
25     [31821] = {1, "tankcd"}, -- Aura Mastery
26     [81782] = {1, "tankcd"}, -- Power Word: Barrier
27     [145629] = {1, "tankcd"}, -- Anti-Magic Zone
28     [325174] = {1, "tankcd"}, -- Spirit Link Totem
29     --[124275] = {1, "stagger"}, -- Light Stagger (Monk)
30     --[124274] = {1, "stagger"}, -- Moderate Stagger (Monk)
31     [124273] = {1, "stagger"}, -- Heavy Stagger (Monk)
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     -- Crucible of Storms
56     [282566] = {1, "stacks"}, -- Promises of Power (Restless Cabal)
57     [282738] = {1, "alert"}, -- Embrace of the Void (Restless Cabal)
58     [285652] = {1, "alert"}, -- Insatiable Torment (Uu'nat)
59     [285367] = {2, "stacks"}, -- Piercing Gaze of N'Zoth (Uu'nat)
60     [284733] = {1, "alert"}, -- Embrace of the Void (Uu'nat)
61     [285685] = {1, "alert"}, -- Gift of N'Zoth: Lunacy (Uu'nat)
62     -- The Eternal Palace
63     [292127] = {1, "alert"}, -- Darkest Depths (Underwater)
64     [298569] = {1, "stacks"}, -- Drained Soul (Queen Azshara)
65     [297586] = {1, "alert"}, -- Suffering (Queen's Court)
66     [294711] = {5, "heal"}, -- Frost (Sivara)
67     [294715] = {5, "heal"}, -- Toxic (Sivara)
68     [296693] = {1, "stacks"}, -- Waterlogged (Ashvane)
69     [297333] = {1, "heal"}, -- Briny Bubble (Ashvane)
70     [298306] = {1, "stacks"}, -- Incubation Fluid (Orgozoa)
71     -- Ny'alotha
72     [313255] = {20, "stacks"}, -- Creeping Madness (Wrathion)
73     [310224] = {1, "stacks"}, -- Annihilation (Vexiona)
74     [307358] = {1, "heal"}, -- Debilitating Spit (Shad'har)
75     [318078] = {1, "alert"}, -- Fixate (Shad'har)
76     [312486] = {1, "stacks"}, -- Recurring Nightmare (Il'gynoth)
77     [313400] = {1, "stacks"}, -- Corrupted Mind (N'zoth)
78     --[319346] = {1, "heal"}, -- Infinity's Toll (N'zoth) phase marker
79     [316506] = {1, "alert"}, -- Heartpiercer Venom (Trash)
80     [315025] = {1, "heal"}, -- Ancient Curse (Maut)
81     [315311] = {1, "stacks"}, -- Ravage (Hivemind)
82     [313460] = {1, "alert"}, -- Nullification (Hivemind)
83     [313461] = {1, "heal"}, -- Corrosion (Hivemind)
84     [307359] = {1, "heal"}, -- Despair (Vexiona)
85     [313077] = {1, "heal"}, -- Unleashed Nightmare (Ra-den)
86     [316065] = {1, "alert"}, -- Corrupted Existence (Ra-den)
87     [313364] = {1, "heal"}, -- Mental Decay (Carapace of N'zoth)
88     [307044] = {4, "stacks"}, -- Nightmare Antibody (Carapace of N'zoth)
89     -- SL M+
90     [323347] = {1, "stacks"}, -- Clinging Darkness (Necrotic Wake)
91     [338357] = {2, "stacks"}, -- Tenderize (Necrotic Wake)
92     [321038] = {1, "stacks"}, -- Wrack Soul (Sanguine Depths)
93     [331415] = {1, "stacks"}, -- Wicked Gash (Sanguine Depths)
94     [328737] = {1, "stacks"}, -- Fragment of Radiance (Sanguine Depths)
95     [326632] = {5, "stacks"}, -- Stony Veins (Halls of Atonement)
96     [344993] = {5, "stacks"}, -- Jagged Swipe (Halls of Atonement)
97     [323692] = {1, "stacks"}, -- Arcane Vulnerability (De Other Side)
98     [317661] = {1, "stacks"}, -- Insidious Venom (Spires of Ascension)
99     [355732] = {1, "stacks"}, -- Melt Soul (Incinerator Arkolath)
100     [327814] = {1, "heal"}, -- Wicked Gash (Gauntlet) (Sanguine Depths)
101     [323687] = {1, "heal"}, -- Arcane Lightning (De Other Side)
102     [324154] = {1, "heal"}, -- Dark Stride (Spires of Ascension)
103     [335305] = {1, "heal"}, -- Barbed Shackles (Sanguine Depths)
104     [336279] = {1, "heal"}, -- Explosive Anger (Sanguine Depths)
105     [356011] = {1, "heal"}, -- Beam Splicer (Tazavesh)
106     [347481] = {1, "heal"}, -- Shuri (Tazavesh)
107     [357190] = {1, "heal"}, -- Star Vulnerability (Tazavesh)
108     -- Castle Nathria
109     [346301] = {1, "stacks"}, -- Bloodlight (Shriekwing)
110     [328897] = {7, "alert"}, -- Exsanguinated (Shriekwing)
111     [335304] = {1, "heal"}, -- Sinseeker (Huntsman Altimor)
112     [334971] = {2, "stacks"}, -- Jagged Claws (Huntsman Altimor)
113     [325382] = {3, "stacks"}, -- Warped Desires (Lady Inerva Darkvein)
114     [332664] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
115     [340477] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
116     [339527] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
117     [342321] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
118     [342322] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
119     [324982] = {1, "heal"}, -- Shared Suffering (Lady Inerva Darkvein)
120     [324983] = {1, "heal"}, -- Shared Suffering (Lady Inerva Darkvein)
121     [340860] = {1, "heal", 14}, -- Withering Touch (Artificer Xy'mox)
122     [326302] = {1, "alert"}, -- Stasis Trap (Artificer Xy'mox)
123     [334771] = {1, "heal"}, -- Heart Hemorrhage (Stone Legion Generals)
124     [326699] = {1, "stacks"}, -- Burden of Sin (Sire Denathrius)
125     [329298] = {1, "alert"}, -- Gluttonous Miasma (Hungering Destroyer)
126     [334755] = {14, "heal"}, -- Essence Sap (Hungering Destroyer)
127     [343320] = {1, "alert"}, -- Curse of Caramain (Trash)
128     [333913] = {1, "stacks"}, -- Wicked Laceration (Stone Legion Generals)
129     -- Sanctum of Domination
130     [357431] = {1, "heal"}, -- Grasp of Death (Tarragrue)
131     [352392] = {2, "stacks"}, -- Soulforge Heat (Tarragrue)
132     [350034] = {1, "heal"}, -- Fractured Soul (Eye of the Jailer)
133     [350542] = {1, "stacks"}, -- Fragment of Destiny (The Nine)
134     [350184] = {1, "heal"}, -- Daschla's Mighty Impact (The Nine)
135     [350647] = {1, "heal"}, -- Brand of Torment (Soulrender Dormazain)
136     [355506] = {1, "heal"}, -- Shadowsteel Chains (Painsmith Raznal)
137     [350496] = {1, "heal"}, -- Threat Neutralization (Guardian of the First Ones)
138     [357686] = {1, "heal"}, -- Runic Affinity (Fatescribe Roh-Kalo)
139     [353162] = {1, "stacks"}, -- Fate Fragment (Fatescribe Roh-Kalo)
140     [347807] = {2, "stacks"}, -- Barbed Arrow (Sylvanas Windrunner)
141     [351117] = {1, "stacks"}, -- Crushing Dread (Sylvanas Windrunner)
142     [353929] = {1, "stacks"}, -- Banshee's Bane (Sylvanas Windrunner)
143     [351870] = {1, "heal"}, -- Haunting Wave (Sylvanas Windrunner)
144     [351451] = {1, "heal"}, -- Curse of Lethargy (Sylvanas Windrunner)
145     [348064] = {1, "heal"}, -- Wailing Arrow (Sylvanas Windrunner)
146 };
147
148 --local overlapAuras = {
149 --    [53563] = {1, "buff3"}, -- other Beacon of Light
150 --    [156910] = {1, "buff3"}, -- other Beacon of Faith
151 --};
152 local playerGuid = nil;
153
154 local auraEvents = {};
155 auraEvents.SPELL_AURA_APPLIED = function(frame, id, source, _, _, atype, amount)
156     if (amount == nil and watchedAuras[id][1] == 1) or (amount ~= nil and amount >= watchedAuras[id][1]) then
157         amount = amount or 1;
158         if atype == "BUFF" and (source == playerGuid or watchedAuras[id][2] == "tankcd" or watchedAuras[id][2] == "buff2") then
159             frame[watchedAuras[id][2]][id] = amount;
160         elseif atype == "DEBUFF" then
161             frame[watchedAuras[id][2]][id] = amount;
162             if watchedAuras[id][3] ~= nil and frame.hits[id] == nil then
163                 frame.hits[id] = watchedAuras[id][3];
164             end
165         end
166     end
167 end
168 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
169 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
170 auraEvents.SPELL_AURA_REMOVED = function(frame, id, source, _, _, atype, amount)
171     if amount == nil or amount == 0 then
172         if atype == "BUFF" and (source == playerGuid or watchedAuras[id][2] == "tankcd" or watchedAuras[id][2] == "buff2") then
173             frame[watchedAuras[id][2]][id] = nil;
174         elseif atype == "DEBUFF" then
175             frame[watchedAuras[id][2]][id] = nil;
176             if watchedAuras[id][3] ~= nil then
177                 frame.hits[id] = nil;
178             end
179         end
180     end
181 end
182 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
183 auraEvents.SPELL_AURA_BROKEN = function(frame, id, source)
184     return auraEvents.SPELL_AURA_REMOVED(frame, id, source, nil, nil, nil, 0);
185 end
186 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
187 auraEvents.SPELL_PERIODIC_DAMAGE = function(frame, id, source)
188     if watchedAuras[id][3] ~= nil then
189         if frame.hits[id] ~= nil and frame.hits[id] > 0 then
190             frame.hits[id] = frame.hits[id] - 1;
191             if frame.hits[id] == 0 then
192                 frame.hits[id] = nil;
193             end
194         elseif frame.hits[id] ~= nil then
195             frame.hits[id] = nil;
196         end
197     end
198 end
199 auraEvents.SPELL_PERIODIC_ABSORBED = auraEvents.SPELL_PERIODIC_DAMAGE;
200 auraEvents.SPELL_PERIODIC_MISSED = auraEvents.SPELL_PERIODIC_DAMAGE;
201
202 local counter = 0;
203 local function clog(ts, event, _, source, _, _, _, dest, _, _, _, spellid, ...)
204     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
205         auraEvents[event](guids[dest], spellid, source, ...);
206     end
207 end
208 addon.Events.Clog = clog;
209
210 local types = {["HELPFUL"] = "BUFF", ["HARMFUL"] = "DEBUFF"};
211 local function setAuras(unit, guid)
212     local name;
213     local spellid, count, source;
214     for filter, atype in pairs(types) do
215         local i = 1;
216         while true do
217             name, _, count, _, _, _, source, _, _, spellid = UnitAura(unit, i, filter);
218             if not spellid then break end
219             if count == 0 then count = nil end
220             if source ~= nil then
221                 clog(0, "SPELL_AURA_APPLIED", nil, UnitGUID(source), nil, nil, nil,
222                      guid, nil, nil, nil, spellid, nil, nil, atype, count);
223             elseif filter == "HARMFUL" then
224                 clog(0, "SPELL_AURA_APPLIED", nil, nil, nil, nil, nil,
225                      guid, nil, nil, nil, spellid, nil, nil, atype, count);
226             end
227             i = i + 1;
228         end
229     end
230 end
231 addon.SetAuras = setAuras;
232
233 local frame = CreateFrame("Frame");
234 frame:Hide();
235 frame:SetScript("OnEvent", function()
236     playerGuid = UnitGUID("player");
237     frame:UnregisterAllEvents();
238     frame:SetScript("OnEvent", function()
239         return clog(CombatLogGetCurrentEventInfo());
240     end);
241     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
242 end);
243 frame:RegisterEvent("PLAYER_LOGIN");
244
245 -- debug slash command to get target auras
246 SLASH_KEHYS1 = "/kaura"
247 function SlashCmdList.KEHYS(msg, editBox)
248     local name, spellid, count, source;
249     local unit = "target";
250     if msg and msg ~= "" then
251         unit = msg;
252     end
253     for filter, atype in pairs(types) do
254         local i = 1;
255         while true do
256             name, _, count, _, _, _, source, _, _, spellid = UnitAura(unit, i, filter);
257             if not spellid then break end
258             print(atype, name, count, source, spellid);
259             i = i + 1;
260         end
261     end
262 end