-
-
Save RA80533/316067564e613fc65e793807481bc57b to your computer and use it in GitHub Desktop.
Creature Spawn Inspector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Creature GUID Inspector | |
-- | |
function GTT_CreatureInspect(self) | |
local _, unit = self:GetUnit(); | |
local guid = UnitGUID(unit or "none"); | |
local prefix = string.match(guid, "^([CVP][^l][^-]+)"); | |
if not guid or not prefix then | |
return; | |
end | |
if string.find(prefix, "^[CV]") then | |
local guidSpawnOffset = bit.band(tonumber(string.sub(guid, -6), 16), 0x7fffff); | |
local guidSpawnIndex = bit.rshift(bit.band(tonumber(string.sub(guid, -10, -6), 16), 0xffff8), 3); | |
local serverSpawnEpoch = GetServerTime() - (GetServerTime() % 2^23); | |
local guidSpawnTime = serverSpawnEpoch + guidSpawnOffset; | |
if guidSpawnTime > GetServerTime() then | |
-- Correction for units that survived the last epoch. | |
guidSpawnTime = guidSpawnTime - ((2^23) - 1); | |
end | |
local guidSpawnDate = date("%Y-%m-%d %H:%M:%S", guidSpawnTime); | |
GameTooltip_AddBlankLineToTooltip(self); | |
GameTooltip_AddColoredDoubleLine(self, "GUID", guid, NORMAL_FONT_COLOR, HIGHLIGHT_FONT_COLOR); | |
GameTooltip_AddColoredDoubleLine(self, "Spawn Date/Time", guidSpawnDate, NORMAL_FONT_COLOR, HIGHLIGHT_FONT_COLOR); | |
GameTooltip_AddColoredDoubleLine(self, "Spawn Time Data", string.format("%.6X", guidSpawnTime), NORMAL_FONT_COLOR, HIGHLIGHT_FONT_COLOR); | |
GameTooltip_AddColoredDoubleLine(self, "Spawn Index Data", string.format("%.5X", guidSpawnIndex), NORMAL_FONT_COLOR, HIGHLIGHT_FONT_COLOR); | |
elseif prefix == "Pet" then | |
local guidPetUID = string.sub(guid, -8); | |
local guidSpawnIndex = tonumber(string.sub(guid, -10, -9), 16); | |
GameTooltip_AddBlankLineToTooltip(self); | |
GameTooltip_AddColoredDoubleLine(self, "GUID", guid, NORMAL_FONT_COLOR, HIGHLIGHT_FONT_COLOR); | |
GameTooltip_AddColoredDoubleLine(self, "Pet UID", guidPetUID, NORMAL_FONT_COLOR, HIGHLIGHT_FONT_COLOR); | |
GameTooltip_AddColoredDoubleLine(self, "Spawn Index", guidSpawnIndex, NORMAL_FONT_COLOR, HIGHLIGHT_FONT_COLOR); | |
end | |
end | |
if not GTT_CreatureInspectHooked then | |
GTT_CreatureInspectHooked = true; | |
GameTooltip:HookScript("OnTooltipSetUnit", function(...) return GTT_CreatureInspect(...); end); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment