Quantcast UnitOwner (GUID), identifying guardians and pets. - WoWInterface
Thread Tools Display Modes
09-24-14, 04:55 PM   #1
Tercioo
An Aku'mai Servant
 
Tercioo's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 38
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.
  Reply With Quote
09-24-14, 06:05 PM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
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";
  Reply With Quote
09-24-14, 07:57 PM   #3
Tercioo
An Aku'mai Servant
 
Tercioo's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 38
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.
  Reply With Quote
09-24-14, 08:01 PM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
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.

Last edited by semlar : 09-24-14 at 08:13 PM.
  Reply With Quote
09-25-14, 08:24 AM   #5
Tercioo
An Aku'mai Servant
 
Tercioo's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 38
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
  Reply With Quote

WoWInterface » Developer Discussions » Wish List » UnitOwner (GUID), identifying guardians and pets.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off