local GetTalentInfo, GetInspectSpecialization = GetTalentInfo, GetInspectSpecialization;
local GetSpecializationInfo, GetSpecialization = GetSpecializationInfo, GetSpecialization;
local GetInventoryItemLink, GetInventoryItemID = GetInventoryItemLink, GetInventoryItemID;
-local CanInspect, NotifyInspect, ClearInspectPlayer = CanInspect, NotifyInspect, ClearInspectPlayer;
local INVSLOT_MAINHAND, INVSLOT_WRIST = INVSLOT_MAINHAND, INVSLOT_WRIST;
local upColor = {0, 0.7, 0.2, 0.7};
[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
local idToGuid = {};
local guidToId = {};
local guidToSpecid = {};
-local monksWithLegendary = {};
-local inspectSent = {};
local dead = {};
local disconnected = {};
if start then frame.text:SetText(cds[guid][spellid]) end
end
-local function sendInspect(guid, id, func)
- if not inspectSent[guid] and CanInspect(id) then
- inspectSent[guid] = true;
- local _, _, _, _, _, name = GetPlayerInfoByGUID(guid);
- print(guid, name, "send inspect");
- NotifyInspect(id);
- CTimerAfter(20, func); -- precaution for never receiving INSPECT_READY
- end
-end
-
local encounter = nil;
local function tick()
if not encounter and IsEncounterInProgress() then
local function removeFrame(frame)
unused[#unused+1] = 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;
+ dead[frame.guid] = nil;
+ disconnected[frame.guid] = nil;
if runningcds[frame.guid] then runningcds[frame.guid][frame.spellid] = nil end
tremove(shown, frame.pos);
for i, frame in ipairs(shown) do
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
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)
- local id = guidToId[guid];
- if not id then return end -- called because another addon inspected
- local weapon = GetInventoryItemLink(id, INVSLOT_MAINHAND);
- if not weapon then
- -- try again directly
- if CanInspect(id) then
- print(guid, "send inspect");NotifyInspect(id);
- CTimerAfter(20, updateMonk);
- end
- return;
- end
- if inspectSent[guid] then inspectSent[guid] = nil end
- print("Got monk", guid);
- 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 end
-
- local wrist = GetInventoryItemID(guidToId[guid], INVSLOT_WRIST);
- if wrist == 137096 then -- Petrichor Lagniappe
- monksWithLegendary[guid] = true;
- else
- monksWithLegendary[guid] = nil;
- end
- updateUnitCD(guid);
-end
-
-local function updateDruid(guid, player)
+local function updateDruid(guid, _, talent)
local id = guidToId[guid];
if id then
- -- Inner Peace talent
- local selected;
- if player then
- _, _, _, selected = GetTalentInfo(6, 2, 1);
- else
- _, _, _, selected = GetTalentInfo(6, 2, 1, true, id);
- end
- if selected then
+ if talent then
cdfixes[guid] = -60;
else
cdfixes[guid] = nil;
end
end
-local function updatePriest(guid)
+local function updatePriest(guid, specid)
local id = guidToId[guid];
if id then
- local specid = GetInspectSpecialization(id);
- if specid == 0 then
- -- try again directly
- if CanInspect(id) then
- print(guid, "send inspect");NotifyInspect(id);
- CTimerAfter(20, updatePriest);
+ if guidToSpecid[guid] ~= specid and frames[guid] then
+ for _, frame in pairs(frames[guid]) do
+ removeFrame(frame);
end
end
- if inspectSent[guid] then inspectSent[guid] = nil end
- print("Got priest", guid);
guidToSpecid[guid] = specid;
updateUnitCD(guid);
end
if trackedcds[specid] then
guidToId[guid] = "player";
guidToSpecid[guid] = specid;
- if specid == 270 then -- Monk
- updateMonk(guid);
- elseif specid == 105 then -- Druid
- updateDruid(guid, true);
+ if specid == 105 then -- Druid
+ local _, _, _, talent = GetTalentInfo(6, 1, 1);
+ updateDruid(guid, nil, talent);
else
updateUnitCD(guid);
end
idToGuid["player"] = guid;
else
idToGuid["player"] = nil;
- for _, frame in pairs(frames[guid]) do
- removeFrame(frame);
+ if frames[guid] then
+ for _, frame in pairs(frames[guid]) do
+ removeFrame(frame);
+ end
end
end
end
local _, class = UnitClass(id);
if specs[class] ~= nil then
guidToId[guid] = id;
+ local specid = guidToSpecid[guid];
+ guidToSpecid[guid] = specs[class];
if specs[class] == false then
- -- Priest, have to inspect to get spec, try immediately, if not available, inspect
- local specid = GetInspectSpecialization(id);
- if specid == 0 then
- sendInspect(guid, id, updatePriest);
- elseif specid == 256 or specid == 257 then
- guidToSpecid[guid] = specid; -- only Holy and Discipline
- updateUnitCD(guid);
+ if specid == 256 or specid == 257 then
+ guidToSpecid[guid] = specid;
+ else
+ guidToSpecid[guid] = 257; -- assume Holy for now to get something visible
end
- elseif specs[class] == 270 then
- -- Monk, have to check inventory for CD modifications
- guidToSpecid[guid] = specs[class];
- -- updateUnitCD (without having fixes yet)
updateUnitCD(guid);
- sendInspect(guid, id, updateMonk);
+ OmaInspect.Request(guid, id, updatePriest);
elseif specs[class] == 105 then
-- Druid, have to inspect to get talents
- guidToSpecid[guid] = specs[class];
-- updateUnitCD (without having fixes yet)
updateUnitCD(guid);
- sendInspect(guid, id, updateDruid);
+ OmaInspect.Request(guid, id, updateDruid);
else
- guidToSpecid[guid] = specs[class];
updateUnitCD(guid);
end
idToGuid[id] = guid;
end
end
+local prevGroupType = "solo";
+local prevGroupSize = 0;
local updateQueued = nil;
local function updateUnitids()
local size = 0;
- local prefix;
- local newIdToGuid = {};
- local prevIdToGuid = {};
+ local prefix = "solo";
guidToId = {};
updateQueued = nil;
- for id, guid in pairs(idToGuid) do
- prevIdToGuid[id] = guid;
- end
-
if IsInGroup() then
if IsInRaid() then
size = 40;
end
end
+ if prevGroupType ~= prefix then
+ -- clean up players from old group
+ for i = 1,prevGroupSize do
+ local id = format("%s%i", prevGroupType, i);
+ local guid = idToGuid[id];
+ idToGuid[id] = nil;
+ if frames[guid] then
+ print(guid, "removing frames in overall updateUnitids");
+ for _, frame in pairs(frames[guid]) do
+ removeFrame(frame);
+ end
+ end
+ end
+ prevGroupType = prefix;
+ prevGroupSize = size;
+ end
+
updatePlayer();
- if prevIdToGuid["player"] then prevIdToGuid["player"] = nil end
for i = 1,size do
local id = format("%s%i", prefix, i);
- if not UnitIsUnit(id, "player") then
+ if not UnitIsUnit(id, "player") then -- player is already done
updateUnitid(id);
end
- if prevIdToGuid[id] then prevIdToGuid[id] = nil end
end
+end
- -- clean up players leaving
- for id, guid in pairs(prevIdToGuid) do
- if frames[guid] then
- for _, frame in pairs(frames[guid]) do
+-- just check removals, don't cause inspects
+local function fastUpdateUnitids()
+ for guid, unitFrames in pairs(frames) do
+ if UnitGUID(guidToId[guid]) ~= guid then
+ for _, frame in pairs(unitFrames) do
removeFrame(frame);
end
end
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;
+ elseif guidToSpecid[guid] == 257 and spellid == 62618 then
+ -- assumed Holy priest cast Barrier, set to update to Disc
+ guidToSpecid[guid] = 256;
+ for _, frame in pairs(frames[guid]) do
+ removeFrame(frame);
end
+ updateUnitCD(guid);
+ CdDown(guid, spellid, GetTime());
end
end
end,
["PLAYER_SPECIALIZATION_CHANGED"] = function(id)
updateUnitid(id);
end,
- ["UNIT_INVENTORY_CHANGED"] = function(id)
- local guid = idToGuid[id];
- if guid and guidToSpecid[guid] == 270 then
- print("OmaCD Inventory: Monk inventory update");
- updateMonk(guid);
- end
- end,
["GROUP_ROSTER_UPDATE"] = function()
+ fastUpdateUnitids();
if not updateQueued then
updateQueued = true
- CTimerAfter(2, updateUnitids);
- end
- end,
- ["INSPECT_READY"] = function(guid)
- local specid = guidToSpecid[guid];
- if inspectSent[guid] then inspectSent[guid] = nil end
- if specid == 105 then -- Druid
- print("OmaCD Inspect: druid,", guid);
- updateDruid(guid);
- ClearInspectPlayer();
- elseif specid == 270 then -- Monk
- print("OmaCD Inspect: monk,", guid);
- -- don't clear inspect player, have to track inventory changes
- elseif specid == false or specid == 256 or specid == 257 then -- Priest
- print("OmaCD Inspect: priest,", guid);
- updatePriest(guid);
- ClearInspectPlayer();
+ CTimerAfter(4, updateUnitids);
end
end,
};
events["PLAYER_ROLES_ASSIGNED"] = events["GROUP_ROSTER_UPDATE"];
+events["PLAYER_ENTERING_WORLD"] = events["GROUP_ROSTER_UPDATE"];
local function cdtracker()
cdframe:SetFrameStrata("LOW");
- cdframe:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 200, -200);
+ cdframe:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 580, -400);
cdframe:SetWidth(1);
cdframe:SetHeight(1);
cdframe:RegisterEvent("UNIT_CONNECTION");
cdframe:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED");
cdframe:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED");
- cdframe:RegisterEvent("UNIT_INVENTORY_CHANGED");
cdframe:RegisterEvent("GROUP_ROSTER_UPDATE");
- cdframe:RegisterEvent("INSPECT_READY");
cdframe:RegisterEvent("PLAYER_ROLES_ASSIGNED");
- -- initial update
- events["GROUP_ROSTER_UPDATE"]();
+ cdframe:RegisterEvent("PLAYER_ENTERING_WORLD");
+ -- initial tick
CTimerAfter(0.5, tick);
end
+cdframe:SetScript("OnEvent", cdtracker);
cdframe:RegisterEvent("PLAYER_LOGIN");
-cdframe:SetScript("OnEvent", function(self, event)
- if event == "PLAYER_LOGIN" then
- return cdtracker();
- end
-end);