WoWInterface (
-   Wish List (
-   -   UnitOwner (GUID), identifying guardians and pets. (

Tercioo 09-24-14 04:55 PM

UnitOwner (GUID), identifying guardians and pets.
At the moment if the client doesn't see the guardian being summoned (like mage's mirror image for instance), there is no way to know who is its owner.

In the other hand, if we hover over the guardian, the tooltip immediately tells who owns it, so the client holds this information and could be easily queried by UnitOwner (GuardianOrPetGUID). Its a simple thing, but, solves tons of issues.

semlar 09-24-14 06:05 PM

In the meantime, you can try something like this if you encounter a guardian without witnessing its creation.
Lua Code:
  1. local tip = CreateFrame('GameTooltip', 'GuardianOwnerTooltip', nil, 'GameTooltipTemplate')
  2. function GetGuardianOwner(guid)
  3.     tip:SetOwner(WorldFrame, 'ANCHOR_NONE')
  4.     tip:SetHyperlink('unit:' .. guid or '')
  5.     local text = GuardianOwnerTooltipTextLeft2
  6.     return strmatch(text and text:GetText() or '', "^([^%s']+)'")
  7. end

This example will probably only work on english clients, however there are a number of entries in GlobalStrings.lua that could potentially be matched against the line in the tooltip.
Lua Code:
  1. UNITNAME_SUMMON_TITLE1 = "%s's Pet";
  2. UNITNAME_SUMMON_TITLE10 = "%s's Mount";
  3. UNITNAME_SUMMON_TITLE11 = "%s's Lightwell";
  4. UNITNAME_SUMMON_TITLE12 = "%s's Butler";
  5. UNITNAME_SUMMON_TITLE13 = "%s'aka";
  6. UNITNAME_SUMMON_TITLE14 = "%s's Gateway";
  7. UNITNAME_SUMMON_TITLE15 = "%s's Hatred";
  8. UNITNAME_SUMMON_TITLE16 = "%s's Statue";
  9. UNITNAME_SUMMON_TITLE17 = "%s's Spirit";
  10. UNITNAME_SUMMON_TITLE18 = "%s's War Banner";
  11. UNITNAME_SUMMON_TITLE19 = "%s's Heartwarmer";
  12. UNITNAME_SUMMON_TITLE2 = "%s's Guardian";
  13. UNITNAME_SUMMON_TITLE20 = "Hired by %s";
  14. UNITNAME_SUMMON_TITLE21 = "Purchased by %s";
  15. UNITNAME_SUMMON_TITLE22 = "%s's Pride";
  16. UNITNAME_SUMMON_TITLE23 = "Twisted Image of %s";
  17. UNITNAME_SUMMON_TITLE24 = "%s's Noodle Cart";
  18. UNITNAME_SUMMON_TITLE3 = "%s's Minion";
  19. UNITNAME_SUMMON_TITLE4 = "%s's Totem";
  20. UNITNAME_SUMMON_TITLE5 = "%s's Companion";
  21. UNITNAME_SUMMON_TITLE6 = "%s's Runeblade";
  22. UNITNAME_SUMMON_TITLE7 = "%s's Construct";
  23. UNITNAME_SUMMON_TITLE8 = "%s's Opponent";
  24. UNITNAME_SUMMON_TITLE9 = "%s's Vehicle";

Tercioo 09-24-14 07:57 PM

Thanks, seems to work here and did a workaround for the workaround, rofl:
Iterating between raid members doing: GuardianOwnerTooltipTextLeft2:GetText():find (UnitName ("raid" .. i))
Its ugly, cpu heavily but fix the language at least while in raid.

semlar 09-24-14 08:01 PM

You only need to call it if you didn't actually witness the summoning event so it shouldn't be that bad, but it is relatively costly to do that kind of pattern matching.

Looping over the raid names could produce false positives if a member's name is part of another member's name (or their name was "Minion" or something).

You might want to only fall back on that if the first attempt fails.

If matching the apostrophe fails, then it would be faster to split the tooltip line on spaces and attempt to call UnitGUID on each result than looping over the entire raid looking for names.

Assuming the name is separated from the rest of the string by whitespace then it would be as effective as running find(UnitName('raid'..i)) but quite a bit faster.

Tercioo 09-25-14 08:24 AM

That's right, didn't thought about that, thanks again.
Gosh, i hope this UnitOwner get implemented on day, too much workarounds to get a simple information :mad:

Kektorian 02-28-21 01:00 PM

Hi, 6,5 years later, do you know if this functionality is implemented nowadays? Thank you!

Rilgamon 03-01-21 09:37 AM

When you find a better way let me know ;) I try to have my own damagemeter and tracking the owner is difficult ... I use this monster ... (stolen from different sources)

Lua Code:
  1. local addonName, addon = ...
  2. local scanTipName = format("%s_ScanTooltip", addonName)
  3. local scanTipText = format("%sTextLeft2", scanTipName)
  4. local scanTip = CreateFrame("GameTooltip", scanTipName, WorldFrame, "GameTooltipTemplate")
  5. local scanTipTitles = {}
  6. for i = 1, 48 do
  7.     scanTipTitles[#scanTipTitles + 1] = _G[format("UNITNAME_SUMMON_TITLE%i",i)]
  8. end
  9. local function scanTooltip(guid)
  10.     local text = _G[scanTipText]
  11.     if(guid and text) then
  12.         scanTip:SetOwner( WorldFrame, "ANCHOR_NONE" )
  13.         scanTip:SetHyperlink(format('unit:%s',guid))
  14.         local text2 = text:GetText()
  15.         if(text2) then
  16.             for i = 1, #scanTipTitles do
  17.                 local check = scanTipTitles[i]:gsub("%%s", "(.+)"):gsub("[%[%]]", "%%%1")
  18.                 local a,b,c = string.find(text2, check)
  19.                 if(c) then
  20.                     local g = UnitGUID(c)
  21.                     if(g) then
  22.                         return g
  23.                     end
  24.                 end
  25.             end
  26.         end
  27.     end
  28. end

All times are GMT -6. The time now is 05:35 AM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI