Here'a a "quick" and dirty method for getting the faction from a unit's GUID using its tooltip:
Lua Code:
local guidCache = {}
local _, myFaction = UnitFactionGroup('player')
local utip = CreateFrame("GameTooltip", "uTip", UIParent, "GameTooltipTemplate")
local function DoSomething(guid)
local faction = guidCache[guid]
if faction then
print(guid, faction, faction == myFaction)
end
end
utip:SetScript("OnTooltipSetUnit", function(self)
if guidCache[self.guid] then return end
local tipName, numLines = self:GetName()..'TextLeft', self:NumLines()
local faction = _G[tipName..numLines]:GetText() == PVP and _G[tipName..(numLines-1)]:GetText() or _G[tipName..numLines]:GetText()
guidCache[self.guid] = faction
DoSomething(self.guid)
end)
function ScanFaction(guid)
if guid and tonumber(guid:sub(5,5), 16) % 8 == 0 then
if guidCache[guid] then
DoSomething(guid)
else
utip.guid = guid
utip:SetHyperlink('unit:'..guid)
end
end
end
Usage: ScanFaction(UnitGUID('example')), calls
DoSomething when it's finished.
Probably not the best solution but maybe it'll help somebody.