6a32145 - Update aura state on combat start and all bars update
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sat, 16 Nov 2019 17:27:37 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sat, 16 Nov 2019 17:27:37 +0000
kehys/auras.lua
kehys/events.lua

index 42afc12..641e128 100644 (file)
@@ -95,13 +95,36 @@ end
 auraEvents.SPELL_AURA_BROKEN_SPELL = auraEvents.SPELL_AURA_BROKEN;
 
 local counter = 0;
-local function clog(ts, event, _, source, _, _, _, dest, _, flags, _, spellid, ...)
+local function clog(ts, event, _, source, _, _, _, dest, _, _, _, spellid, ...)
     if auraEvents[event] and watchedAuras[spellid] and guids[dest] then
         auraEvents[event](guids[dest], spellid, source, ...);
     end
 end
 addon.Events.Clog = clog;
 
+local types = {["HELPFUL"] = "BUFF", ["HARMFUL"] = "DEBUFF"};
+local function setAuras(unit, guid)
+    local name;
+    local spellid, count, source;
+    for filter, atype in pairs(types) do
+        local i = 1;
+        while true do
+            name, _, count, _, _, _, source, _, _, spellid = UnitAura(unit, i, filter);
+            if not spellid then break end
+            if count == 0 then count = nil end
+            if source ~= nil then
+                clog(0, "SPELL_AURA_APPLIED", nil, UnitGUID(source), nil, nil, nil,
+                     guid, nil, nil, nil, spellid, nil, nil, atype, count);
+            elseif filter == "HARMFUL" then
+                clog(0, "SPELL_AURA_APPLIED", nil, nil, nil, nil, nil,
+                     guid, nil, nil, nil, spellid, nil, nil, atype, count);
+            end
+            i = i + 1;
+        end
+    end
+end
+addon.SetAuras = setAuras;
+
 local frame = CreateFrame("Frame");
 frame:Hide();
 frame:SetScript("OnEvent", function()
index 97f56da..b194192 100644 (file)
@@ -167,6 +167,7 @@ local eventFuncs = {
         frame.stacks = {};
         frame.heal = {};
         frame.buff1 = {};
+        addon.SetAuras(frame.unit, frame.guid);
     end,
     ["UPDATE_ALL_BARS"] = function(frame)
         updateRole(frame, frame.unit);
@@ -183,7 +184,12 @@ local eventFuncs = {
         if frame.guid then
             guids[frame.guid] = frame;
         end
-        -- TODO update initial aura state
+        frame.tankcd = {};
+        frame.alert = {};
+        frame.stacks = {};
+        frame.heal = {};
+        frame.buff1 = {};
+        addon.SetAuras(frame.unit, frame.guid);
     end,
 };
 eventFuncs["READY_CHECK_CONFIRM"] = eventFuncs["READY_CHECK"];