29d93c0 - change raid frame position as mage
[wowui.git] / OmaCD / Cooldowns.lua
index 9c7add4..7bb0fc2 100644 (file)
@@ -48,15 +48,9 @@ local trackedcds = {
         [98008] = 180, -- Spirit Link Totem
     },
     [270] = { -- Mistweaver Monk
-        [115310] = (180-40), -- Revival, already lowered by Artifact when lvl 75
+        [115310] = 180, -- Revival
     },
 };
-local monkRelics = { -- Tendrils of Revival
-    ["151012"] = -10,
-    ["151010"] = -10,
-    ["147112"] = -10,
-    ["152291"] = -10,
-};
 
 local cds = {}; -- CD durations currently available modified by passive cdfixes
 -- CD fixes active e.g. cdfixes[guid] = -60, no need for spellid as
@@ -67,8 +61,6 @@ local runningcds = {}; -- CDs currently active
 local idToGuid = {};
 local guidToId = {};
 local guidToSpecid = {};
-local monks = {};
-local monksWithLegendary = {};
 local dead = {};
 local disconnected = {};
 
@@ -132,8 +124,6 @@ local function removeFrame(frame)
     frames[frame.guid][frame.spellid] = nil;
     if not next(frames[frame.guid]) then frames[frame.guid] = nil end
     cds[frame.guid][frame.spellid] = nil;
-    monks[frame.guid] = nil;
-    monksWithLegendary[frame.guid] = nil;
     dead[frame.guid] = nil;
     disconnected[frame.guid] = nil;
     if runningcds[frame.guid] then runningcds[frame.guid][frame.spellid] = nil end
@@ -169,6 +159,7 @@ local function getFrame()
     return frame;
 end
 local function updateCD(guid, specid, spellid)
+    if not guidToId[guid] then return end
     -- update cd value
     local cd = trackedcds[specid][spellid];
     if cdfixes[guid] then cd = cd + cdfixes[guid] end
@@ -196,48 +187,13 @@ end
 
 local function updateUnitCD(guid)
     local specid = guidToSpecid[guid];
-    if specid then
+    if specid and trackedcds[specid] then
         for spellid, _ in pairs(trackedcds[specid]) do
             updateCD(guid, specid, spellid);
         end
     end
 end
 
-local function updateMonk(guid, _, _, weapon, wrist)
-    local id = guidToId[guid];
-    if id then
-        local _, _, _, relic1, relic2, relic3 = strsplit(":", weapon);
-        local cdfix = 0;
-        if monkRelics[relic1] then cdfix = cdfix + monkRelics[relic1] end
-        if monkRelics[relic2] then cdfix = cdfix + monkRelics[relic2] end
-        if monkRelics[relic3] then cdfix = cdfix + monkRelics[relic3] end
-        if cdfix ~= 0 then
-            cdfixes[guid] = cdfix;
-        else
-            cdfixes[guid] = nil;
-        end
-
-        if wrist == 137096 then -- Petrichor Lagniappe
-            monksWithLegendary[guid] = true;
-        else
-            monksWithLegendary[guid] = nil;
-        end
-        monks[guid] = true;
-        updateUnitCD(guid);
-    end
-end
-
--- a secondary tick for monks inventory check out of combat
-local function monkTick()
-    if not InCombatLockdown() then
-        for guid, _ in pairs(monks) do
-            local id = guidToId[guid];
-            if id then OmaInspect.Request(guid, id, updateMonk) end
-        end
-    end
-    CTimerAfter(10, monkTick);
-end
-
 local function updateDruid(guid, _, talent)
     local id = guidToId[guid];
     if id then
@@ -253,7 +209,7 @@ end
 local function updatePriest(guid, specid)
     local id = guidToId[guid];
     if id then
-        if guidToSpecid[guid] ~= specid then
+        if guidToSpecid[guid] ~= specid and frames[guid] then
             for _, frame in pairs(frames[guid]) do
                 removeFrame(frame);
             end
@@ -269,12 +225,8 @@ local function updatePlayer()
     if trackedcds[specid] then
         guidToId[guid] = "player";
         guidToSpecid[guid] = specid;
-        if specid == 270 then -- Monk
-            local weapon = GetInventoryItemLink("player", INVSLOT_MAINHAND);
-            local wrist = GetInventoryItemID("player", INVSLOT_WRIST);
-            updateMonk(guid, nil, nil, weapon, wrist);
-        elseif specid == 105 then -- Druid
-            local _, _, _, talent = GetTalentInfo(6, 2, 1);
+        if specid == 105 then -- Druid
+            local _, _, _, talent = GetTalentInfo(6, 1, 1);
             updateDruid(guid, nil, talent);
         else
             updateUnitCD(guid);
@@ -307,12 +259,7 @@ local function updateUnitid(id)
                     guidToSpecid[guid] = 257; -- assume Holy for now to get something visible
                 end
                 updateUnitCD(guid);
-                OmaInspect.Request(guid, id, updatePriest);
-            elseif specs[class] == 270 then
-                -- Monk, have to check inventory for CD modifications
-                -- updateUnitCD (without having fixes yet)
-                updateUnitCD(guid);
-                OmaInspect.Request(guid, id, updateMonk, true);
+                --OmaInspect.Request(guid, id, updatePriest);
             elseif specs[class] == 105 then
                 -- Druid, have to inspect to get talents
                 -- updateUnitCD (without having fixes yet)
@@ -418,17 +365,12 @@ local events = {
             end
         end
     end,
-    ["UNIT_SPELLCAST_SUCCEEDED"] = function(id, _, _, _, spellid)
+    ["UNIT_SPELLCAST_SUCCEEDED"] = function(id, _, spellid)
         local guid = idToGuid[id];
         if guid and frames[guid] then
             local frame = frames[guid][spellid];
             if frame then
                 CdDown(guid, spellid, GetTime());
-            elseif monksWithLegendary[guid] and spellid == 115151 then
-                -- Renewing Mist with legendary affects Revival
-                if runningcds[guid] and runningcds[guid][115310] then
-                    runningcds[guid][115310] = runningcds[guid][115310] - 2;
-                end
             elseif guidToSpecid[guid] == 257 and spellid == 62618 then
                 -- assumed Holy priest cast Barrier, set to update to Disc
                 guidToSpecid[guid] = 256;
@@ -473,12 +415,7 @@ local function cdtracker()
     cdframe:RegisterEvent("PLAYER_ENTERING_WORLD");
     -- initial tick
     CTimerAfter(0.5, tick);
-    CTimerAfter(10, monkTick);
 end
 
+cdframe:SetScript("OnEvent", cdtracker);
 cdframe:RegisterEvent("PLAYER_LOGIN");
-cdframe:SetScript("OnEvent", function(self, event)
-    if event == "PLAYER_LOGIN" then
-        return cdtracker();
-    end
-end);