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:

All times are GMT -6. The time now is 07:28 PM.

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