8b1be3a - More auras and stagger tracking
[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     [974] = {1, "buff2"}, -- Earth Shield
28     -- Tank defensives
29     [6940] = {1, "tankcd"}, -- Blessing of Sacrifice
30     [33206] = {1, "tankcd"}, -- Pain Suppression
31     [47788] = {1, "tankcd"}, -- Guardian Spirit
32     [102342] = {1, "tankcd"}, -- Ironbark
33     [116849] = {1, "tankcd"}, -- Life Cocoon
34     [196555] = {1, "tankcd"}, -- Netherwalk
35     --[124275] = {1, "stagger"}, -- Light Stagger (Monk)
36     --[124274] = {1, "stagger"}, -- Moderate Stagger (Monk)
37     [124273] = {1, "stagger"}, -- Heavy Stagger (Monk)
38     -- M+
39     [209858] = {1, "stacks"}, -- Necrotic Wound (M+)
40     [240559] = {1, "stacks"}, -- Grievous Wound (M+)
41     [240443] = {1, "stacks"}, -- Burst (M+)
42     [260741] = {1, "heal"}, -- Jagged Nettles (Waycrest Manor)
43     -- Uldir
44     [265264] = {2, "alert"}, -- Void Lash (Zek'voz)
45     -- Battle of Dazar'alor
46     [285213] = {1, "alert"}, -- Caress of Death (Rastakhan)
47     [288415] = {1, "alert"}, -- Caress of Death in Death realm (Rastakhan)
48     [285195] = {8, "stacks"}, -- Deathly Withering (Rastakhan)
49     [286646] = {1, "heal"}, -- Gigavolt Charge (Mekkatorque)
50     [288939] = {1, "heal"}, -- Gigavolt Radiation (Mekkatorque)
51     [287891] = {1, "stacks"}, -- Sheep Shrapnel (Mekkatorque)
52     [287114] = {1, "alert"}, -- Miscalculated Teleport (Mekkatorque)
53     [287167] = {1, "stacks"}, -- Discombobulation (Mekkatorque)
54     [287993] = {1, "stacks"}, -- Chilling Touch (Jaina)
55     [283507] = {1, "heal"}, -- Volatile Charge (Opulence)
56     [287648] = {1, "heal"}, -- Volatile Charge (Opulence)
57     [284556] = {1, "stacks"}, -- Shadow-Touched (Opulence)
58     [287072] = {1, "heal"}, -- Liquid Gold (Opulence)
59     [284781] = {1, "heal"}, -- Grievous Axe (Rastakhan)
60     [290955] = {1, "heal"}, -- Grievous Axe (Rastakhan)
61     -- Crucible of Storms
62     [282566] = {1, "stacks"}, -- Promises of Power (Restless Cabal)
63     [282738] = {1, "alert"}, -- Embrace of the Void (Restless Cabal)
64     [285652] = {1, "alert"}, -- Insatiable Torment (Uu'nat)
65     [285367] = {2, "stacks"}, -- Piercing Gaze of N'Zoth (Uu'nat)
66     [284733] = {1, "alert"}, -- Embrace of the Void (Uu'nat)
67     [285685] = {1, "alert"}, -- Gift of N'Zoth: Lunacy (Uu'nat)
68     -- The Eternal Palace
69     [292127] = {1, "alert"}, -- Darkest Depths (Underwater)
70     [298569] = {1, "stacks"}, -- Drained Soul (Queen Azshara)
71     [297586] = {1, "alert"}, -- Suffering (Queen's Court)
72     [294711] = {5, "heal"}, -- Frost (Sivara)
73     [294715] = {5, "heal"}, -- Toxic (Sivara)
74     [296693] = {1, "stacks"}, -- Waterlogged (Ashvane)
75     [297333] = {1, "heal"}, -- Briny Bubble (Ashvane)
76     [298306] = {1, "stacks"}, -- Incubation Fluid (Orgozoa)
77     -- Ny'alotha
78     [313255] = {20, "stacks"}, -- Creeping Madness (Wrathion)
79     [310224] = {1, "stacks"}, -- Annihilation (Vexiona)
80     [307358] = {1, "heal"}, -- Debilitating Spit (Shad'har)
81     [318078] = {1, "alert"}, -- Fixate (Shad'har)
82     [312486] = {1, "stacks"}, -- Recurring Nightmare (Il'gynoth)
83     [313400] = {1, "stacks"}, -- Corrupted Mind (N'zoth)
84     --[319346] = {1, "heal"}, -- Infinity's Toll (N'zoth) phase marker
85     [316506] = {1, "alert"}, -- Heartpiercer Venom (Trash)
86     [315025] = {1, "heal"}, -- Ancient Curse (Maut)
87     [315311] = {1, "stacks"}, -- Ravage (Hivemind)
88     [313460] = {1, "alert"}, -- Nullification (Hivemind)
89     [313461] = {1, "heal"}, -- Corrosion (Hivemind)
90     [307359] = {1, "heal"}, -- Despair (Vexiona)
91     [313077] = {1, "heal"}, -- Unleashed Nightmare (Ra-den)
92     [316065] = {1, "alert"}, -- Corrupted Existence (Ra-den)
93     [313364] = {1, "heal"}, -- Mental Decay (Carapace of N'zoth)
94     [307044] = {4, "stacks"}, -- Nightmare Antibody (Carapace of N'zoth)
95     -- SL M+
96     [323347] = {1, "stacks"}, -- Clinging Darkness (Necrotic Wake)
97     [338357] = {2, "stacks"}, -- Tenderize (Necrotic Wake)
98     [321038] = {1, "stacks"}, -- Wrack Soul (Sanguine Depths)
99     [331415] = {1, "stacks"}, -- Wicked Gash (Sanguine Depths)
100     [328737] = {1, "stacks"}, -- Fragment of Radiance (Sanguine Depths)
101     [326632] = {5, "stacks"}, -- Stony Veins (Halls of Atonement)
102     [344993] = {5, "stacks"}, -- Jagged Swipe (Halls of Atonement)
103     [323692] = {1, "stacks"}, -- Arcane Vulnerability (De Other Side)
104     [317661] = {1, "stacks"}, -- Insidious Venom (Spires of Ascension)
105     [327814] = {1, "heal"}, -- Wicked Gash (Gauntlet) (Sanguine Depths)
106     [323687] = {1, "heal"}, -- Arcane Lightning (De Other Side)
107     [324154] = {1, "heal"}, -- Dark Stride (Spires of Ascension)
108     [335305] = {1, "heal"}, -- Barbed Shackles (Sanguine Depths)
109     [336279] = {1, "heal"}, -- Explosive Anger (Sanguine Depths)
110     -- Castle Nathria
111     [346301] = {1, "stacks"}, -- Bloodlight (Shriekwing)
112     [328897] = {7, "alert"}, -- Exsanguinated (Shriekwing)
113     [335304] = {1, "heal"}, -- Sinseeker (Huntsman Altimor)
114     [334971] = {2, "stacks"}, -- Jagged Claws (Huntsman Altimor)
115     [325382] = {3, "stacks"}, -- Warped Desires (Lady Inerva Darkvein)
116     [332664] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
117     [340477] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
118     [339527] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
119     [342321] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
120     [342322] = {1, "heal"}, -- Anima Add (Lady Inerva Darkvein)
121     [324982] = {1, "heal"}, -- Shared Suffering (Lady Inerva Darkvein)
122     [324983] = {1, "heal"}, -- Shared Suffering (Lady Inerva Darkvein)
123     [340860] = {1, "heal", 14}, -- Withering Touch (Artificer Xy'mox)
124     [326302] = {1, "alert"}, -- Stasis Trap (Artificer Xy'mox)
125     [334771] = {1, "heal"}, -- Heart Hemorrhage (Stone Legion Generals)
126     [326699] = {1, "stacks"}, -- Burden of Sin (Sire Denathrius)
127     [329298] = {1, "alert"}, -- Gluttonous Miasma (Hungering Destroyer)
128     [334755] = {14, "heal"}, -- Essence Sap (Hungering Destroyer)
129     [343320] = {1, "alert"}, -- Curse of Caramain (Trash)
130     [333913] = {1, "stacks"}, -- Wicked Laceration (Stone Legion Generals)
131 };
132 local playerGuid = nil;
133
134 local auraEvents = {};
135 auraEvents.SPELL_AURA_APPLIED = function(frame, id, source, _, _, atype, amount)
136     if (amount == nil and watchedAuras[id][1] == 1) or (amount ~= nil and amount >= watchedAuras[id][1]) then
137         amount = amount or 1;
138         if atype == "BUFF" and (source == playerGuid or watchedAuras[id][2] == "tankcd") then
139             frame[watchedAuras[id][2]][id] = amount;
140         elseif atype == "DEBUFF" then
141             frame[watchedAuras[id][2]][id] = amount;
142             if watchedAuras[id][3] ~= nil and frame.hits[id] == nil then
143                 frame.hits[id] = watchedAuras[id][3];
144             end
145         end
146     end
147 end
148 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
149 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
150 auraEvents.SPELL_AURA_REMOVED = function(frame, id, source, _, _, atype, amount)
151     if amount == nil or amount == 0 then
152         if atype == "BUFF" and (source == playerGuid or watchedAuras[id][2] == "tankcd") then
153             frame[watchedAuras[id][2]][id] = nil;
154         elseif atype == "DEBUFF" then
155             frame[watchedAuras[id][2]][id] = nil;
156             if watchedAuras[id][3] ~= nil then
157                 frame.hits[id] = nil;
158             end
159         end
160     end
161 end
162 auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
163 auraEvents.SPELL_AURA_BROKEN = function(frame, id, source)
164     return auraEvents.SPELL_AURA_REMOVED(frame, id, source, nil, nil, nil, 0);
165 end
166 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
167 auraEvents.SPELL_PERIODIC_DAMAGE = function(frame, id, source)
168     if watchedAuras[id][3] ~= nil then
169         if frame.hits[id] ~= nil and frame.hits[id] > 0 then
170             frame.hits[id] = frame.hits[id] - 1;
171             if frame.hits[id] == 0 then
172                 frame.hits[id] = nil;
173             end
174         elseif frame.hits[id] ~= nil then
175             frame.hits[id] = nil;
176         end
177     end
178 end
179 auraEvents.SPELL_PERIODIC_ABSORBED = auraEvents.SPELL_PERIODIC_DAMAGE;
180 auraEvents.SPELL_PERIODIC_MISSED = auraEvents.SPELL_PERIODIC_DAMAGE;
181
182 local counter = 0;
183 local function clog(ts, event, _, source, _, _, _, dest, _, _, _, spellid, ...)
184     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
185         auraEvents[event](guids[dest], spellid, source, ...);
186     end
187 end
188 addon.Events.Clog = clog;
189
190 local types = {["HELPFUL"] = "BUFF", ["HARMFUL"] = "DEBUFF"};
191 local function setAuras(unit, guid)
192     local name;
193     local spellid, count, source;
194     for filter, atype in pairs(types) do
195         local i = 1;
196         while true do
197             name, _, count, _, _, _, source, _, _, spellid = UnitAura(unit, i, filter);
198             if not spellid then break end
199             if count == 0 then count = nil end
200             if source ~= nil then
201                 clog(0, "SPELL_AURA_APPLIED", nil, UnitGUID(source), nil, nil, nil,
202                      guid, nil, nil, nil, spellid, nil, nil, atype, count);
203             elseif filter == "HARMFUL" then
204                 clog(0, "SPELL_AURA_APPLIED", nil, nil, nil, nil, nil,
205                      guid, nil, nil, nil, spellid, nil, nil, atype, count);
206             end
207             i = i + 1;
208         end
209     end
210 end
211 addon.SetAuras = setAuras;
212
213 local frame = CreateFrame("Frame");
214 frame:Hide();
215 frame:SetScript("OnEvent", function()
216     playerGuid = UnitGUID("player");
217     frame:UnregisterAllEvents();
218     frame:SetScript("OnEvent", function()
219         return clog(CombatLogGetCurrentEventInfo());
220     end);
221     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
222 end);
223 frame:RegisterEvent("PLAYER_LOGIN");
224
225 -- debug slash command to get target auras
226 SLASH_KEHYS1 = "/kaura"
227 function SlashCmdList.KEHYS(msg, editBox)
228     local name, spellid, count, source;
229     local unit = "target";
230     if msg and msg ~= "" then
231         unit = msg;
232     end
233     for filter, atype in pairs(types) do
234         local i = 1;
235         while true do
236             name, _, count, _, _, _, source, _, _, spellid = UnitAura(unit, i, filter);
237             if not spellid then break end
238             print(atype, name, count, source, spellid);
239             i = i + 1;
240         end
241     end
242 end