3 local tonumber = tonumber;
4 local format = string.format;
5 local UnitGUID = UnitGUID;
6 local UnitExists, UnitIsUnit = UnitExists, UnitIsUnit;
7 local UnitBuff, UnitDebuff = UnitBuff, UnitDebuff;
8 local PlaySoundFile = PlaySoundFile;
9 local playerGuid, guids;
10 local frame = CreateFrame("Frame");
14 "Interface\\Addons\\OmaGtfo\\sounds\\alarmbuzzer.ogg",
15 "Interface\\Addons\\OmaGtfo\\sounds\\alarmbeep.ogg",
16 "Interface\\Addons\\OmaGtfo\\sounds\\alarmdouble.ogg",
17 "Interface\\Addons\\OmaGtfo\\sounds\\alarmbuzz.ogg",
19 local taken = OmaGTFO.DmgTaken;
20 local caused = OmaGTFO.DmgDone;
22 ["Drowning"] = sounds[1],
23 ["Fatigue"] = sounds[1],
26 ["Slime"] = sounds[2],
29 local function checkDebuff(id)
32 local _, _, _, _, _, _, _, _, _, spell = UnitAura("player", i, "HARMFUL");
35 elseif spell == id then
43 ["SPELL_AURA_APPLIED"] = true,
44 ["SPELL_AURA_APPLIED_DOSE"] = true,
45 ["SPELL_AURA_REFRESH"] = true,
48 ["SPELL_DAMAGE"] = function(event, source, spellid, spellname, _, arg1, arg2)
49 if auraEvents[event] and arg1 ~= "DEBUFF" then
51 elseif taken[spellid] then
52 local spell = taken[spellid];
53 local sound = spell.sound;
55 if spell.eventType and spell.eventType ~= event then return end
56 if spell.applicationOnly then
57 if not auraEvents[event] then
59 elseif spell.minStacks and (event ~= "SPELL_AURA_APPLIED_DOSE" or
60 not arg2 or arg2 <= spell.minStacks) then
64 if spell.minDamage then
65 local damage = tonumber(arg1) or 0;
66 if damage < spell.minDamage then return end
68 if spell.multipleHitsTime then -- only alarm if multiple hits within a certain time
69 local now, prevHit = GetTime(), spell.prevHit;
72 if now - prevHit > spell.multipleHitsTime then
79 if spell.negatingDebuff and checkDebuff(spell.negatingDebuff) then return end
81 return PlaySoundFile(sounds[sound], "SFX");
84 ["ENVIRONMENTAL_DAMAGE"] = function(_, _, env)
85 if environs[env] then return PlaySoundFile(environs[env], "SFX") end
88 events["SPELL_MISSED"] = events["SPELL_DAMAGE"];
89 events["SPELL_PERIODIC_DAMAGE"] = events["SPELL_DAMAGE"];
90 events["SPELL_PERIODIC_MISSED"] = events["SPELL_DAMAGE"];
91 events["SPELL_AURA_APPLIED"] = events["SPELL_DAMAGE"];
92 events["SPELL_AURA_APPLIED_DOSE"] = events["SPELL_DAMAGE"];
93 events["SPELL_AURA_REFRESH"] = events["SPELL_DAMAGE"];
95 local function clog(_, event, _, sourceGuid, _, _, _, destGuid, _, _, _, ...)
96 -- TODO vehicle support?
97 if destGuid == playerGuid and events[event] then
98 return events[event](event, sourceGuid, ...);
99 elseif sourceGuid == playerGuid and event == "SPELL_DAMAGE" and guids[destGuid] then
101 if caused[spellid] then return PlaySoundFile(sounds[caused[spellid]], "SFX") end
105 local function updateGuids()
110 local unit = format("raid%i", i);
111 if not UnitExists(unit) then break end
112 if not UnitIsUnit(unit, "player") then
113 guids[UnitGUID(unit)] = true;
118 local unit = format("party%i", i);
119 if not UnitExists(unit) then break end
120 guids[UnitGUID(unit)] = true;
126 local frameEvents = {
127 ["COMBAT_LOG_EVENT_UNFILTERED"] = function()
128 return clog(CombatLogGetCurrentEventInfo());
130 ["GROUP_ROSTER_UPDATE"] = updateGuids,
131 ["MIRROR_TIMER_START"] = function(timer, _, _, scale)
132 if (timer == "EXHAUSTION" and scale < 0) then
133 return PlaySoundFile(sounds[1], "SFX");
138 frame:SetScript("OnEvent", function()
139 frame:UnregisterAllEvents();
140 playerGuid = UnitGUID("player");
142 frame:SetScript("OnEvent", function(_, event, ...)
143 frameEvents[event](...);
145 frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
146 frame:RegisterEvent("GROUP_ROSTER_UPDATE");
147 frame:RegisterEvent("MIRROR_TIMER_START");
149 frame:RegisterEvent("PLAYER_LOGIN");