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