3a03236 - Remove unused OmaGtfo features
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Mon, 7 May 2018 01:14:18 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Mon, 7 May 2018 01:14:18 +0000
OmaGtfo/Gtfo.lua

index 10cd002..f76d2e8 100644 (file)
@@ -1,16 +1,12 @@
 -- Gtfo.lua
 local _;
 -- Gtfo.lua
 local _;
-local print, tonumber, pairs = print, tonumber, pairs;
+local tonumber = tonumber;
 local format = string.format;
 local format = string.format;
-local strsplit = strsplit;
 local UnitGUID = UnitGUID;
 local UnitExists, UnitIsUnit = UnitExists, UnitIsUnit;
 local UnitBuff, UnitDebuff = UnitBuff, UnitDebuff;
 local UnitGUID = UnitGUID;
 local UnitExists, UnitIsUnit = UnitExists, UnitIsUnit;
 local UnitBuff, UnitDebuff = UnitBuff, UnitDebuff;
-local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
 local PlaySoundFile = PlaySoundFile;
 local playerGuid, guids;
 local PlaySoundFile = PlaySoundFile;
 local playerGuid, guids;
-local playerTank;
-local printAll = false;
 local frame = CreateFrame("Frame");
 frame:Hide();
 
 local frame = CreateFrame("Frame");
 frame:Hide();
 
@@ -30,14 +26,6 @@ local environs = {
     ["Slime"] = sounds[2],
 };
 
     ["Slime"] = sounds[2],
 };
 
-local function mobId(guid)
-    local mob, _, _, _, _, id = strsplit("-", guid);
-    if mob and (mob == "Creature" or mob == "Vehicle" or mob == "Pet") then
-        return tonumber(id);
-    end
-    return nil;
-end
-
 local function checkDebuff(id)
     local i = 1;
     while true do
 local function checkDebuff(id)
     local i = 1;
     while true do
@@ -51,30 +39,22 @@ local function checkDebuff(id)
     end
 end
 
     end
 end
 
--- negatingIgnoreTime-like functionality not implemented
+local auraEvents = {
+    ["SPELL_AURA_APPLIED"] = true,
+    ["SPELL_AURA_APPLIED_DOSE"] = true,
+    ["SPELL_AURA_REFRESH"] = true,
+};
 local events = {
     ["SPELL_DAMAGE"] = function(event, source, spellid, spellname, _, arg1, arg2)
 local events = {
     ["SPELL_DAMAGE"] = function(event, source, spellid, spellname, _, arg1, arg2)
-        if (event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_APPLIED_DOSE" or
-            event == "SPELL_AURA_REFRESH") and arg1 ~= "DEBUFF" then
+        if auraEvents[event] and arg1 ~= "DEBUFF" then
             return;
         elseif taken[spellid] then
             return;
         elseif taken[spellid] then
-            -- TODO uncomment checks when they're in use
             local spell = taken[spellid];
             local sound = spell.sound;
             local spell = taken[spellid];
             local sound = spell.sound;
+
             if spell.eventType and spell.eventType ~= event then return end
             if spell.eventType and spell.eventType ~= event then return end
-            --if (event == "SPELL_MISSED" or event == "SPELL_PERIODIC_MISSED") and not spell.always then return end
-            if spell.negatingDebuff and checkDebuff(spell.negatingDebuff) then return end
-            --if spell.negatingBuff and UnitBuff("player", spell.negatingBuff) then return end
-            --if spell.affirmingDebuff and not UnitDebuff("player", spell.affirmingDebuff) then return end
-            --if spell.mobs and source and not spell.mobs[mobId(source)] then return end
-            --if spell.ignoreSelf and source == playerGuid then return end
-            if spell.tankMechanic and playerTank then
-                if spell.tankMechanic == true then return end
-                sound = spell.tankMechanic;
-            end
             if spell.applicationOnly then
             if spell.applicationOnly then
-                if event ~= "SPELL_AURA_APPLIED" and event ~= "SPELL_AURA_APPLIED_DOSE" and
-                    event ~= "SPELL_AURA_REFRESH" then
+                if not auraEvents[event] then
                     return;
                 elseif spell.minStacks and (event ~= "SPELL_AURA_APPLIED_DOSE" or
                     not arg2 or arg2 <= spell.minStacks) then
                     return;
                 elseif spell.minStacks and (event ~= "SPELL_AURA_APPLIED_DOSE" or
                     not arg2 or arg2 <= spell.minStacks) then
@@ -96,10 +76,9 @@ local events = {
                     return;
                 end
             end
                     return;
                 end
             end
+            if spell.negatingDebuff and checkDebuff(spell.negatingDebuff) then return end
 
             return PlaySoundFile(sounds[sound], "SFX");
 
             return PlaySoundFile(sounds[sound], "SFX");
-        --elseif printAll then -- TODO uncomment when wanting to print all non-tracked events
-        --    return print(event, spellid, spellname);
         end
     end,
     ["ENVIRONMENTAL_DAMAGE"] = function(_, _, env)
         end
     end,
     ["ENVIRONMENTAL_DAMAGE"] = function(_, _, env)
@@ -109,21 +88,17 @@ local events = {
 events["SPELL_MISSED"] = events["SPELL_DAMAGE"];
 events["SPELL_PERIODIC_DAMAGE"] = events["SPELL_DAMAGE"];
 events["SPELL_PERIODIC_MISSED"] = events["SPELL_DAMAGE"];
 events["SPELL_MISSED"] = events["SPELL_DAMAGE"];
 events["SPELL_PERIODIC_DAMAGE"] = events["SPELL_DAMAGE"];
 events["SPELL_PERIODIC_MISSED"] = events["SPELL_DAMAGE"];
-events["SPELL_ENERGIZE"] = events["SPELL_DAMAGE"];
-events["SPELL_INSTAKILL"] = events["SPELL_DAMAGE"];
 events["SPELL_AURA_APPLIED"] = events["SPELL_DAMAGE"];
 events["SPELL_AURA_APPLIED_DOSE"] = events["SPELL_DAMAGE"];
 events["SPELL_AURA_REFRESH"] = events["SPELL_DAMAGE"];
 
 local function clog(_, event, _, sourceGuid, _, _, _, destGuid, _, _, _, ...)
     -- TODO vehicle support?
 events["SPELL_AURA_APPLIED"] = events["SPELL_DAMAGE"];
 events["SPELL_AURA_APPLIED_DOSE"] = events["SPELL_DAMAGE"];
 events["SPELL_AURA_REFRESH"] = events["SPELL_DAMAGE"];
 
 local function clog(_, event, _, sourceGuid, _, _, _, destGuid, _, _, _, ...)
     -- TODO vehicle support?
-    if destGuid == playerGuid then
-        if events[event] then return events[event](event, sourceGuid, ...) end
-    elseif sourceGuid == playerGuid and event == "SPELL_DAMAGE" then
+    if destGuid == playerGuid and events[event] then
+        return events[event](event, sourceGuid, ...);
+    elseif sourceGuid == playerGuid and event == "SPELL_DAMAGE" and guids[destGuid] then
         local spellid = ...;
         local spellid = ...;
-        if guids[destGuid] and caused[spellid] then
-            return PlaySoundFile(sounds[caused[spellid]], "SFX");
-        end
+        if caused[spellid] then return PlaySoundFile(sounds[caused[spellid]], "SFX") end
     end
 end
 
     end
 end
 
@@ -148,41 +123,27 @@ local function updateGuids()
     end
 end
 
     end
 end
 
-local function updateRole()
-    playerTank = UnitGroupRolesAssigned("player") == "TANK";
-end
-
-local realEvents = {
+local frameEvents = {
     ["COMBAT_LOG_EVENT_UNFILTERED"] = function()
         return clog(CombatLogGetCurrentEventInfo());
     end,
     ["GROUP_ROSTER_UPDATE"] = updateGuids,
     ["COMBAT_LOG_EVENT_UNFILTERED"] = function()
         return clog(CombatLogGetCurrentEventInfo());
     end,
     ["GROUP_ROSTER_UPDATE"] = updateGuids,
-    ["PLAYER_ROLES_ASSIGNED"] = updateRole,
     ["MIRROR_TIMER_START"] = function(timer, _, _, scale)
         if (timer == "EXHAUSTION" and scale < 0) then
             return PlaySoundFile(sounds[1], "SFX");
         end
     end,
 };
     ["MIRROR_TIMER_START"] = function(timer, _, _, scale)
         if (timer == "EXHAUSTION" and scale < 0) then
             return PlaySoundFile(sounds[1], "SFX");
         end
     end,
 };
-local function handleEvent(frame, event, ...)
-    realEvents[event](...);
-end
 
 frame:SetScript("OnEvent", function()
     frame:UnregisterAllEvents();
     playerGuid = UnitGUID("player");
     updateGuids();
 
 frame:SetScript("OnEvent", function()
     frame:UnregisterAllEvents();
     playerGuid = UnitGUID("player");
     updateGuids();
-    updateRole();
-    frame:SetScript("OnEvent", handleEvent);
+    frame:SetScript("OnEvent", function(_, event, ...)
+        frameEvents[event](...);
+    end);
     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
     frame:RegisterEvent("GROUP_ROSTER_UPDATE");
     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
     frame:RegisterEvent("GROUP_ROSTER_UPDATE");
-    frame:RegisterEvent("PLAYER_ROLES_ASSIGNED");
     frame:RegisterEvent("MIRROR_TIMER_START");
 end);
 frame:RegisterEvent("PLAYER_LOGIN");
     frame:RegisterEvent("MIRROR_TIMER_START");
 end);
 frame:RegisterEvent("PLAYER_LOGIN");
-
-SLASH_OMAGTFO1 = "/omag";
-function SlashCmdList.OMAGTFO(msg, editBox)
-    printAll = not printAll;
-    print("printAll", printAll)
-end