8b1be3a - More auras and stagger tracking
[wowui.git] / kehys / updater.lua
index 96e9f49..42aedf0 100644 (file)
@@ -14,6 +14,7 @@ local UnitGetIncomingHeals, UnitGetTotalAbsorbs = UnitGetIncomingHeals, UnitGetT
 local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected;
 local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs;
 local InCombatLockdown, IsResting = InCombatLockdown, IsResting;
+local UnitInRange, UnitInPhase = UnitInRange, UnitInPhase;
 
 local dispelcolor = addon.Colors.OverlayColorDispel;
 local charmcolor = addon.Colors.OverlayColorCharm;
@@ -22,14 +23,21 @@ local healcolor = addon.Colors.OverlayColorHeal;
 
 local ignoredAuras = {
     [315176] = true, -- Grasping Tendrils
+    [313759] = true, -- Cursed Blood (Il'gynoth)
+    [312486] = true, -- Recurring Nightmare (Il'gynoth)
 };
 
 local powerColors = {
     [Enum.PowerType.Mana] = {0.1, 0.5, 0.9},
     [Enum.PowerType.Rage] = {1, 0, 0},
+    [Enum.PowerType.Pain] = {1, 0, 0},
     [Enum.PowerType.Focus] = {1, 0.5, 0},
     [Enum.PowerType.Energy] = {1, 0.8, 0},
+    [Enum.PowerType.Fury] = {0.8, 0.3, 0.9},
     [Enum.PowerType.RunicPower] = {0.8, 0, 0.2},
+    [Enum.PowerType.LunarPower] = {0.3, 0.5, 0.9},
+    [Enum.PowerType.Maelstrom] = {0, 0.5, 1},
+    [Enum.PowerType.Insanity] = {0.4, 0, 0.8},
 };
 
 function addon.FrameUpdate(frame)
@@ -40,7 +48,8 @@ function addon.FrameUpdate(frame)
     -- range check (doesn't have an event) frames can be marked constantly visible
     if not frame.constant then
         local inrange, checked = UnitInRange(unit);
-        if checked and not inrange then
+        local inphase = UnitPhaseReason(unit);
+        if (checked and not inrange) or inphase then
             frame:SetAlpha(0.55);
         else
             frame:SetAlpha(1);
@@ -69,15 +78,22 @@ function addon.FrameUpdate(frame)
         frame.prev.hmax = nil;
     else
         if UnitIsAFK(unit) then
+            frame.text.status = true;
+            frame.prev.htext = nil;
             frame.text:SetText("afk");
             if not frame.text:IsShown() then frame.text:Show() end
         elseif UnitIsDND(unit) then
+            frame.text.status = true;
+            frame.prev.htext = nil;
             frame.text:SetText("dnd");
             if not frame.text:IsShown() then frame.text:Show() end
         else
-            if frame.text:IsShown() then frame.text:Hide() end
+            frame.text.status = false;
+            if frame.raid and frame.text:IsShown() then
+                frame.text:Hide();
+            end
         end
-        if frame.nonraid and frame.unit == "player" then
+        if not frame.raid and frame.unit == "player" then
             if InCombatLockdown() then
                 frame.status:SetTexCoord(0.5, 1, 0, 0.484375);
                 frame.status:Show();
@@ -88,7 +104,6 @@ function addon.FrameUpdate(frame)
                 frame.status:Hide();
             end
         end
-        -- TODO incoming res, maybe just with events?
         -- health
         local current, hmax = UnitHealth(unit), UnitHealthMax(unit);
         if frame.prev.health ~= current or frame.prev.hmax ~= hmax then
@@ -107,6 +122,32 @@ function addon.FrameUpdate(frame)
                 if not frame.health:IsShown() then frame.health:Show() end
             end
         end
+        -- health text
+        if not frame.raid and not frame.text.status and frame.prev.htext ~= current then
+            frame.prev.htext = current;
+            if frame.boss then
+                if hmax < current or hmax <= 1 then
+                    frame.text:SetText("100");
+                    if not frame.text:IsShown() then frame.text:Show() end
+                elseif current <= 0 then
+                    if frame.text:IsShown() then frame.text:Hide() end
+                else
+                    frame.text:SetFormattedText("%.1f", current/hmax*100);
+                    if not frame.text:IsShown() then frame.text:Show() end
+                end
+            else
+                if current > 1000000000 then -- 1.0B
+                    frame.text:SetFormattedText("%.2fB", current / 1000000000);
+                elseif current > 1000000 then -- 1.0M
+                    frame.text:SetFormattedText("%.2fM", current / 1000000);
+                elseif current > 1000 then -- 1.0K
+                    frame.text:SetFormattedText("%.1fK", current / 1000);
+                else
+                    frame.text:SetFormattedText("%i", current);
+                end
+                if not frame.text:IsShown() then frame.text:Show() end
+            end
+        end
         -- shield
         local hwidth = frame.health.width;
         current = UnitGetTotalAbsorbs(unit) or 0;
@@ -159,9 +200,12 @@ function addon.FrameUpdate(frame)
             if frame.prev.mana ~= current or frame.prev.mmax ~= max then
                 frame.prev.mana = current;
                 frame.prev.mmax = max;
-                if max < current or max <= 1 then
+                if max < 1 then
+                    if frame.mana:IsShown() then frame.mana:Hide() end
+                    if frame.manatext:IsShown() then frame.manatext:Hide() end
+                elseif max < current then
                     frame.mana:SetWidth(width);
-                    frame.mana:SetText("100");
+                    frame.manatext:SetText("100");
                     if not frame.mana:IsShown() then frame.mana:Show() end
                     if not frame.manatext:IsShown() then frame.manatext:Show() end
                 elseif current <= 0 then
@@ -185,11 +229,13 @@ function addon.FrameUpdate(frame)
                 frame.stacks = {};
                 frame.heal = {};
                 frame.buff1 = {};
+                frame.buff2 = {};
+                frame.stagger = {};
                 addon.SetAuras(frame.unit, frame.guid);
                 frame.rounds = 0;
             end
         end
-        if not frame.nonraid then
+        if frame.raid then
             -- tank CD marker
             if next(frame.tankcd) then
                 if not frame.defensive:IsShown() then frame.defensive:Show() end
@@ -201,6 +247,10 @@ function addon.FrameUpdate(frame)
                 local _, amount = next(frame.stacks);
                 frame.stack:SetText(amount);
                 if not frame.stack:IsShown() then frame.stack:Show() end
+            elseif next(frame.hits) then
+                local _, amount = next(frame.hits);
+                frame.stack:SetText(amount);
+                if not frame.stack:IsShown() then frame.stack:Show() end
             elseif frame.stack:IsShown() then
                 frame.stack:Hide();
             end
@@ -222,6 +272,25 @@ function addon.FrameUpdate(frame)
             elseif frame.glow:IsShown() then
                 frame.glow:Hide();
             end
+            -- DK Death Strike and Monk Stagger tracking
+            if frame.rolename == "TANK" then
+                if frame.classname == "DEATHKNIGHT" then
+                    local power = UnitPower(unit);
+                    if power < 45 then
+                        if not frame.bottomwarn:IsShown() then frame.bottomwarn:Show() end
+                    elseif frame.bottomwarn:IsShown() then
+                        frame.bottomwarn:Hide();
+                    end
+                elseif frame.classname == "MONK" then
+                    if next(frame.stagger) then -- Heavy Stagger
+                        if not frame.bottomwarn:IsShown() then frame.bottomwarn:Show() end
+                    elseif frame.bottomwarn:IsShown() then
+                        frame.bottomwarn:Hide();
+                    end
+                end
+            elseif frame.bottomwarn:IsShown() then
+                frame.bottomwarn:Hide();
+            end
             -- overlays
             if next(frame.alert) then
                 -- major