c39801d - Add simple red alert aura tracking
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sun, 10 Feb 2019 20:39:10 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sun, 10 Feb 2019 20:39:10 +0000
kehys/auras.lua
kehys/events.lua
kehys/frame.lua
kehys/setup.lua
kehys/updater.lua

index e72224e..3e29a31 100644 (file)
@@ -3,60 +3,49 @@
 local _, addon = ...;
 local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo;
 
+local guids = addon.FrameGuids;
 local watchedAuras = {
-    -- Battle of Dazar'alor
     --[286988] = duration, -- Searing Embers
-    [257908] = {bar=false}, -- Oiled Blade
-    [268391] = {bar=false}, -- Mental Assault
-    [272571] = {bar=false}, -- Choking Waters
-    [268008] = {bar=false}, -- Snake Charm
-    [260741] = {bar=false}, -- Jagged Nettles
-    [280605] = {bar=false}, -- Brain Freeze
-    [268797] = {bar=false}, -- Transmute to Goo
-    [265889] = {bar=false}, -- Torch Strike
-    [266209] = {bar=false}, -- Wicked Frenzy
-    [258323] = {bar=false}, -- Infected Wound
-    [262513] = {bar=false}, -- Azerite Heartseeker
-    [53563] = "TOPRIGHT", -- Beacon of Light
-    [156910] = "TOPRIGHT", -- Beacon of Faith
-    [200025] = "TOPRIGHT", -- Beacon of Virtue
-    [33763] = "TOPLEFT", -- Lifebloom
-    [774] = "TR1", -- Rejuvenation
-    [102352] = "TR2", -- Cenarion Ward (102351 is the pre-buff)
-    [207386] = "TR3", -- Spring Blossoms (207385 is the talent)
-    [155777] = "TR3", -- Germination (either this or Spring Blossoms taken)
-    [8936] = "TR4", -- Regrowth
-    [200389] = "TR5", -- Cultivation
+    --[257908] = {bar=false}, -- Oiled Blade
+    --[268391] = {bar=false}, -- Mental Assault
+    --[272571] = {bar=false}, -- Choking Waters
+    --[268008] = {bar=false}, -- Snake Charm
+    --[260741] = {bar=false}, -- Jagged Nettles
+    --[280605] = {bar=false}, -- Brain Freeze
+    --[268797] = {bar=false}, -- Transmute to Goo
+    --[265889] = {bar=false}, -- Torch Strike
+    --[266209] = {bar=false}, -- Wicked Frenzy
+    --[258323] = {bar=false}, -- Infected Wound
+    --[262513] = {bar=false}, -- Azerite Heartseeker
+    -- Uldir
+    [265264] = 2, -- Void Lash (Zek'voz)
+    -- Battle of Dazar'alor
+    [285213] = 1, -- Caress of Death (Rastakhan)
 };
 
 local auraEvents = {};
 auraEvents.SPELL_AURA_APPLIED = function(frame, id, _, _, _, amount)
-    if UnitDebuff(frame.unit, 1, "RAID") ~= nil then
-        -- update dispel indicator
-        frame:ColorOverlay("low", 1, 0.5, 0, 0.5);
-    end
-    if auras[id] then
-        if amount > 0 then
-            frame.auraStarts[id] = GetTime();
-            return updateApplication(frame, id, amount);
-        else
-            return updateRemoval(frame, id);
-        end
+    if amount == nil or amount >= watchedAuras[id] then
+        frame.alert[id] = true;
     end
 end
 auraEvents.SPELL_AURA_APPLIED_DOSE = auraEvents.SPELL_AURA_APPLIED;
 auraEvents.SPELL_AURA_REFRESH = auraEvents.SPELL_AURA_APPLIED;
-auraEvents.SPELL_AURA_REMOVED = auraEvents.SPELL_AURA_APPLIED;
-auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_APPLIED;
+auraEvents.SPELL_AURA_REMOVED = function(frame, id, _, _, _, amount)
+    if amount == nil or amount == 0 then
+        frame.alert[id] = nil;
+    end
+end
+auraEvents.SPELL_AURA_REMOVED_DOSE = auraEvents.SPELL_AURA_REMOVED;
 auraEvents.SPELL_AURA_BROKEN = function(frame, id)
-    return auraEvents.SPELL_AURA_APPLIED(frame, id, nil, nil, nil, 0);
+    return auraEvents.SPELL_AURA_REMOVED(frame, id, nil, nil, nil, 0);
 end
 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
 
 local counter = 0;
 local function clog(ts, event, _, _, _, _, _, dest, _, flags, _, spellid, ...)
-    if auraEvents[event] and watchedAuras[spellid] then
-        counter = counter + 1;
+    if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
+        auraEvents[event](guids[dest], spellid, ...);
     end
 end
 addon.Events.Clog = clog;
index 32241e4..4a9264f 100644 (file)
@@ -23,6 +23,7 @@ local READY_CHECK_WAITING_TEXTURE = READY_CHECK_WAITING_TEXTURE;
 
 local _, addon = ...;
 addon.Events = {};
+local guids = addon.FrameGuids;
 local baseColor = {0, 0, 0};
 local overlayColorDispel = {1, 0.5, 0, 0.5};
 local overlayColorCharm = {0.8, 0, 1, 0.5};
@@ -141,6 +142,13 @@ local eventFuncs = {
     end,
     ["UNIT_NAME_UPDATE"] = function(frame)
         updateName(frame, frame.unit);
+        if frame.guid then
+            guids[frame.guid] = nil;
+        end
+        frame.guid = UnitGUID(frame.unit);
+        if frame.guid then
+            guids[frame.guid] = frame;
+        end
     end,
     ["PLAYER_ROLES_ASSIGNED"] = function(frame)
         updateRole(frame, frame.unit);
@@ -158,6 +166,15 @@ local eventFuncs = {
         updateName(frame, frame.unit);
         updateReadyCheck(frame, frame.unit);
         updateRaidMarker(frame, frame.displayed);
+
+        if frame.guid then
+            guids[frame.guid] = nil;
+        end
+        frame.guid = UnitGUID(frame.unit);
+        if frame.guid then
+            guids[frame.guid] = frame;
+        end
+        -- TODO update initial aura state
     end,
 };
 eventFuncs["READY_CHECK_CONFIRM"] = eventFuncs["READY_CHECK"];
index a723f47..535899c 100644 (file)
@@ -6,6 +6,7 @@ local format = string.format;
 local CreateFrame = CreateFrame;
 local CTimerAfter = C_Timer.After;
 
+local guids = addon.FrameGuids;
 local updaters = {};
 local function showTooltip(frame)
     GameTooltip_SetDefaultAnchor(GameTooltip, frame);
@@ -48,6 +49,7 @@ function addon.NewRaidFrame(parent, width, height, unit, attributes,
     f.displayed = unit;
     f.vehicle = unit == "player" and "vehicle" or format("%spet", unit);
     f.prev = {} -- values stored from previous update
+    f.alert = {}; -- alerting auras
     -- set up periodic updates
     updaters[f] = function()
         if f.updating then
@@ -64,6 +66,10 @@ function addon.NewRaidFrame(parent, width, height, unit, attributes,
     f:SetScript("OnHide", function()
         f:UnregisterAllEvents();
         f.updating = false;
+        if f.guid then
+            guids[f.guid] = nil;
+            f.guid = nil;
+        end
     end);
     f:SetScript("OnEvent", event);
     f:SetScript("OnEnter", showTooltip);
index 200243e..fbfb3d3 100644 (file)
@@ -20,3 +20,5 @@ addon.Colors = {
     OverlayColorCharm = {0.8, 0, 1, 0.5},
     OverlayColorAlert = {1, 0, 0, 0.5},
 }
+
+addon.FrameGuids = {};
index 5114d5f..f881ff7 100644 (file)
@@ -126,7 +126,7 @@ function addon.FrameUpdate(frame)
             frame.healpred:Hide();
         end
         -- auras
-        if updateAuras(frame, unit) then
+        if frame.alert and next(frame.alert) then
             -- major
             if frame.overlay.color ~= majorcolor then
                 frame.overlay:SetVertexColor(unpack(majorcolor));