306a575 - Optimizations to events, removal of heal prediction
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sat, 2 Feb 2019 15:56:17 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sat, 2 Feb 2019 15:56:17 +0000
kehys/auras.lua [new file with mode: 0644]
kehys/events.lua
kehys/kehys.toc
kehys/setup.lua

diff --git a/kehys/auras.lua b/kehys/auras.lua
new file mode 100644 (file)
index 0000000..e72224e
--- /dev/null
@@ -0,0 +1,73 @@
+-- auras.lua
+-- 2019 Aleksi Blinnikka
+local _, addon = ...;
+local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo;
+
+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
+};
+
+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
+    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_BROKEN = function(frame, id)
+    return auraEvents.SPELL_AURA_APPLIED(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;
+    end
+end
+addon.Events.Clog = clog;
+
+local frame = CreateFrame("Frame");
+frame:Hide();
+frame:SetScript("OnEvent", function()
+    frame:UnregisterAllEvents();
+    frame:SetScript("OnEvent", function()
+        return clog(CombatLogGetCurrentEventInfo());
+    end);
+    frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
+end);
+frame:RegisterEvent("PLAYER_LOGIN");
index f030057..16c6479 100644 (file)
@@ -22,6 +22,7 @@ local READY_CHECK_NOT_READY_TEXTURE = READY_CHECK_NOT_READY_TEXTURE;
 local READY_CHECK_WAITING_TEXTURE = READY_CHECK_WAITING_TEXTURE;
 
 local _, addon = ...;
 local READY_CHECK_WAITING_TEXTURE = READY_CHECK_WAITING_TEXTURE;
 
 local _, addon = ...;
+addon.Events = {};
 local baseColor = {0, 0, 0};
 local overlayColorDispel = {1, 0.5, 0, 0.5};
 local overlayColorCharm = {0.8, 0, 1, 0.5};
 local baseColor = {0, 0, 0};
 local overlayColorDispel = {1, 0.5, 0, 0.5};
 local overlayColorCharm = {0.8, 0, 1, 0.5};
@@ -45,7 +46,7 @@ function addon.RegisterUnitEvents(frame)
     frame:RegisterUnitEvent("UNIT_MAXHEALTH", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_NAME_UPDATE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_AURA", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_MAXHEALTH", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_NAME_UPDATE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_AURA", frame.unit, displayed);
-    frame:RegisterUnitEvent("UNIT_HEAL_PREDICTION", frame.unit, displayed);
+    --frame:RegisterUnitEvent("UNIT_HEAL_PREDICTION", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", frame.unit, displayed);
@@ -76,13 +77,19 @@ local function updateText(frame, unit)
         frame.text:Hide();
     end
 end
         frame.text:Hide();
     end
 end
+addon.Events.UpdateText = updateText;
 
 local function updateMaxHealth(frame, unit)
     frame.health.max = UnitHealthMax(unit);
 end
 
 local function updateMaxHealth(frame, unit)
     frame.health.max = UnitHealthMax(unit);
 end
+addon.Events.UpdateMaxHealth = updateMaxHealth;
 
 local function updateHealth(frame, unit)
     local current, max = UnitHealth(unit), frame.health.max;
 
 local function updateHealth(frame, unit)
     local current, max = UnitHealth(unit), frame.health.max;
+    if current == frame.prev.health then
+        return false;
+    end
+    frame.prev.health = current;
     if current > max or max <= 0 then
         -- somehow current health has gone over the maximum (missed maxhealth event possibly)
         -- just put health bar full and update max health for next event
     if current > max or max <= 0 then
         -- somehow current health has gone over the maximum (missed maxhealth event possibly)
         -- just put health bar full and update max health for next event
@@ -92,7 +99,7 @@ local function updateHealth(frame, unit)
         frame.health:Show();
     elseif current <= 0 or UnitIsDeadOrGhost(unit) then
         frame.health:Hide();
         frame.health:Show();
     elseif current <= 0 or UnitIsDeadOrGhost(unit) then
         frame.health:Hide();
-        return updateText(frame, unit); -- update death
+        updateText(frame, unit); -- update death
     else
         local w = current/max*width;
         frame.health:SetWidth(w);
     else
         local w = current/max*width;
         frame.health:SetWidth(w);
@@ -104,7 +111,9 @@ local function updateHealth(frame, unit)
         frame.dead = nil;
         updateText(frame, unit); -- update revive
     end
         frame.dead = nil;
         updateText(frame, unit); -- update revive
     end
+    return true;
 end
 end
+addon.Events.UpdateHealth = updateHealth;
 
 local function updateName(frame, unit)
     local name = UnitName(unit);
 
 local function updateName(frame, unit)
     local name = UnitName(unit);
@@ -120,6 +129,7 @@ local function updateName(frame, unit)
     local color = RAID_CLASS_COLORS[class];
     if color then frame.name:SetVertexColor(color.r, color.g, color.b) end
 end
     local color = RAID_CLASS_COLORS[class];
     if color then frame.name:SetVertexColor(color.r, color.g, color.b) end
 end
+addon.Events.UpdateName = updateName;
 
 local function updateHealPred(frame, unit)
     local incoming = UnitGetIncomingHeals(unit) or 0;
 
 local function updateHealPred(frame, unit)
     local incoming = UnitGetIncomingHeals(unit) or 0;
@@ -127,11 +137,12 @@ local function updateHealPred(frame, unit)
         incoming = (incoming / frame.health.max) * width;
         -- always at least 1 pixel space for heal prediction
         frame.healpred:SetWidth(min(width - frame.health.width + 1, incoming));
         incoming = (incoming / frame.health.max) * width;
         -- always at least 1 pixel space for heal prediction
         frame.healpred:SetWidth(min(width - frame.health.width + 1, incoming));
-        frame.healpred:Show();
+        if not frame.healpred:IsShown() then frame.healpred:Show() end
     else
     else
-        frame.healpred:Hide();
+        if frame.healpred:IsShown() then frame.healpred:Hide() end
     end
 end
     end
 end
+addon.Events.UpdateHealPred = updateHealPred;
 
 local function updateShield(frame, unit)
     local shield = UnitGetTotalAbsorbs(unit) or 0;
 
 local function updateShield(frame, unit)
     local shield = UnitGetTotalAbsorbs(unit) or 0;
@@ -139,22 +150,23 @@ local function updateShield(frame, unit)
         local space = width - frame.health.width;
         shield = (shield / frame.health.max) * width;
         if space == 0 then
         local space = width - frame.health.width;
         shield = (shield / frame.health.max) * width;
         if space == 0 then
-            frame.shield:Hide();
-            frame.shieldhl:Show();
+            if frame.shield:IsShown() then frame.shield:Hide() end
+            if not frame.shieldhl:IsShown() then frame.shieldhl:Show() end
         elseif space < shield then
             frame.shield:SetWidth(space);
         elseif space < shield then
             frame.shield:SetWidth(space);
-            frame.shield:Show();
-            frame.shieldhl:Show();
+            if not frame.shield:IsShown() then frame.shield:Show() end
+            if not frame.shieldhl:IsShown() then frame.shieldhl:Show() end
         else
             frame.shield:SetWidth(shield);
         else
             frame.shield:SetWidth(shield);
-            frame.shield:Show();
-            frame.shieldhl:Hide();
+            if not frame.shield:IsShown() then frame.shield:Show() end
+            if frame.shieldhl:IsShown() then frame.shieldhl:Hide() end
         end
     else
         end
     else
-        frame.shield:Hide();
-        frame.shieldhl:Hide();
+        if frame.shield:IsShown() then frame.shield:Hide() end
+        if frame.shieldhl:IsShown() then frame.shieldhl:Hide() end
     end
 end
     end
 end
+addon.Events.UpdateShield = updateShield;
 
 local function updateHealAbsorb(frame, unit)
     local absorb = UnitGetTotalHealAbsorbs(unit) or 0;
 
 local function updateHealAbsorb(frame, unit)
     local absorb = UnitGetTotalHealAbsorbs(unit) or 0;
@@ -166,29 +178,32 @@ local function updateHealAbsorb(frame, unit)
         frame.healabsorb:Hide();
     end
 end
         frame.healabsorb:Hide();
     end
 end
+addon.Events.UpdateHealAbsorb = updateHealAbsorb;
 
 local function updateAuras(frame, unit)
     -- don't overlay charmed when in vehicle
 
 local function updateAuras(frame, unit)
     -- don't overlay charmed when in vehicle
-    if UnitIsCharmed(unit) and unit == frame.unit then
+    --[[if UnitIsCharmed(unit) and unit == frame.unit then
         if frame.overlay.color ~= overlayColorCharm then
             frame.overlay:SetVertexColor(unpack(overlayColorCharm));
             frame.overlay.color = overlayColorCharm;
             frame.overlay:Show();
         end
         if frame.overlay.color ~= overlayColorCharm then
             frame.overlay:SetVertexColor(unpack(overlayColorCharm));
             frame.overlay.color = overlayColorCharm;
             frame.overlay:Show();
         end
-    elseif UnitDebuff(unit, 1, "RAID") ~= nil then
+    else--]]
+    if UnitDebuff(unit, 1, "RAID") ~= nil then
         -- something dispellable
         if frame.overlay.color ~= overlayColorDispel then
             frame.overlay:SetVertexColor(unpack(overlayColorDispel));
             frame.overlay.color = overlayColorDispel;
         -- something dispellable
         if frame.overlay.color ~= overlayColorDispel then
             frame.overlay:SetVertexColor(unpack(overlayColorDispel));
             frame.overlay.color = overlayColorDispel;
-            frame.overlay:Show();
+            if not frame.overlay:IsShown() then frame.overlay:Show() end
         end
     else
         if frame.overlay.color ~= nil then
             frame.overlay.color = nil;
         end
     else
         if frame.overlay.color ~= nil then
             frame.overlay.color = nil;
-            frame.overlay:Hide();
+            if frame.overlay:IsShown() then frame.overlay:Hide() end
         end
     end
 end
         end
     end
 end
+addon.Events.UpdateAuras = updateAuras;
 
 local function updateAggro(frame, unit)
     local status = UnitThreatSituation(unit);
 
 local function updateAggro(frame, unit)
     local status = UnitThreatSituation(unit);
@@ -198,6 +213,7 @@ local function updateAggro(frame, unit)
         frame.base:SetVertexColor(unpack(baseColor));
     end
 end
         frame.base:SetVertexColor(unpack(baseColor));
     end
 end
+addon.Events.UpdateAggro = updateAggro;
 
 local function updateVehicle(frame)
     local shouldTargetVehicle = UnitHasVehicleUI(frame.unit) and
 
 local function updateVehicle(frame)
     local shouldTargetVehicle = UnitHasVehicleUI(frame.unit) and
@@ -214,6 +230,7 @@ local function updateVehicle(frame)
         registerUnitEvents(frame);
     end
 end
         registerUnitEvents(frame);
     end
 end
+addon.Events.UpdateVehicle = updateVehicle;
 
 local function updateRole(frame, unit)
     local role = UnitGroupRolesAssigned(unit);
 
 local function updateRole(frame, unit)
     local role = UnitGroupRolesAssigned(unit);
@@ -227,6 +244,7 @@ local function updateRole(frame, unit)
         frame.role:Hide();
     end
 end
         frame.role:Hide();
     end
 end
+addon.Events.UpdateRole = updateRole;
 
 local function updateReadyCheck(frame, unit)
     local status = GetReadyCheckStatus(unit);
 
 local function updateReadyCheck(frame, unit)
     local status = GetReadyCheckStatus(unit);
@@ -243,6 +261,7 @@ local function updateReadyCheck(frame, unit)
         frame.ready:Hide()
     end
 end
         frame.ready:Hide()
     end
 end
+addon.Events.UpdateReadyCheck = updateReadyCheck;
 
 local function updateRaidMarker(frame, unit)
     local index = GetRaidTargetIndex(unit);
 
 local function updateRaidMarker(frame, unit)
     local index = GetRaidTargetIndex(unit);
@@ -253,13 +272,15 @@ local function updateRaidMarker(frame, unit)
         frame.targeticon:Hide();
     end
 end
         frame.targeticon:Hide();
     end
 end
+addon.Events.UpdateRaidMarker = updateRaidMarker;
 
 local eventFuncs = {
     ["UNIT_HEALTH"] = function(frame)
 
 local eventFuncs = {
     ["UNIT_HEALTH"] = function(frame)
-        updateHealth(frame, frame.displayed);
-        updateShield(frame, frame.displayed);
-        updateHealAbsorb(frame, frame.displayed);
-        -- no heal prediction update, that doesn't overflow too much
+        if updateHealth(frame, frame.displayed) then
+            updateShield(frame, frame.displayed);
+            updateHealAbsorb(frame, frame.displayed);
+            -- no heal prediction update, that doesn't overflow too much
+        end
     end,
     ["UNIT_AURA"] = function(frame)
         updateAuras(frame, frame.displayed);
     end,
     ["UNIT_AURA"] = function(frame)
         updateAuras(frame, frame.displayed);
@@ -305,7 +326,7 @@ local eventFuncs = {
         updateText(frame, frame.displayed);
         updateAuras(frame, frame.displayed);
         updateShield(frame, frame.displayed);
         updateText(frame, frame.displayed);
         updateAuras(frame, frame.displayed);
         updateShield(frame, frame.displayed);
-        updateHealPred(frame, frame.displayed);
+        --updateHealPred(frame, frame.displayed);
         updateHealAbsorb(frame, frame.displayed);
         updateAggro(frame, frame.displayed);
         updateName(frame, frame.unit);
         updateHealAbsorb(frame, frame.displayed);
         updateAggro(frame, frame.displayed);
         updateName(frame, frame.unit);
index eca895a..4dbc3b4 100644 (file)
@@ -10,3 +10,4 @@ paladin.lua
 events.lua
 frame.lua
 raid.lua
 events.lua
 frame.lua
 raid.lua
+auras.lua
index 8c47b57..200243e 100644 (file)
@@ -3,6 +3,7 @@
 local _;
 
 local _, addon = ...;
 local _;
 
 local _, addon = ...;
+KehysAddon = addon;
 
 addon.ClassAuras = {};
 addon.ClassIndicators = {};
 
 addon.ClassAuras = {};
 addon.ClassIndicators = {};