WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   API UnitExists("pet") (https://www.wowinterface.com/forums/showthread.php?t=57752)

doofus 12-28-19 06:11 PM

API UnitExists("pet")
 
Hello,

I use API UnitExists("pet") (https://wow.gamepedia.com/API_UnitExists) to check if my pet exists, if it's dead, or dismissed. Unfortunately I have discovered that it returns false both when the pet is dead or dismissed.

Is there a way to determine if it's dead or dismissed ?

Kanegasi 12-28-19 06:18 PM

If the corpse despawned or you're too far from it, no, there is no way to tell the difference. If the corpse is available, UnitIsDead("pet") will help.

doofus 12-29-19 03:55 AM

thanks :-)

jeruku 12-29-19 09:43 PM

You can use UnitIsVisible to make sure you even have a pet. The function HidePetActionBar is used in the default UI whenever the pet is dismissed, this includes when it "vanishes," so hooking it works alongside UnitIsVisible to determine whether it's dead or vanished/despawned.

JDoubleU00 12-30-19 02:27 PM

Not trying to hijack a thread, but this one is in line with a question I have. Is there a way to identify temporary pets such as Shaman's Feral Spirits or the Earth Elemental they summon?

aallkkaa 01-01-20 03:01 PM

Quote:

Originally Posted by JDoubleU00 (Post 334868)
Not trying to hijack a thread, but this one is in line with a question I have. Is there a way to identify temporary pets such as Shaman's Feral Spirits or the Earth Elemental they summon?

This might be outdated (or never have been very acurate at all) but Shaman "pets" were always special in different ways.

For starters, curretnly, if you take Elemental's talent "Primal Elementalist", the Elementals (all three of them) become proper controllable Pets (such as Hnters' or Warlocks'). I've read somewhere they're considered Guardians otherwise (as adressed in the default UI configuration regarding character Names (and Nameplates), same as say Druids' Force of Nature (?) Treants.
If you have the "Primal Elementalist" talent active, you can use the macro conditional [pet<:optionally pet name>] and it will return true if you have your Elemental out, even though it's still a temporary pet. If you don't have that talent, then [pet] will always return false regardless.

The other thing to note is that they used to be "spawned by totems"! (trivial PvP trick: much easier to kill the totem instead of the elemental, with same result... back then). And indeed they were considered (the elementals) as Totems (same as, back then, the DK ghouls actually).
The API for Totems (and for their Multicast Action Bar (IIRC the name)) used to be common to see in addons. But I haven't seen it in years (although I don't look at addons' code that often), and I don't know what Blizzard has done with it in recent expansions, but it might be something you can look into.

Also, I'm not sure where the Spirit Wolves fit into all of this. At a time they were actually controllable Pets. But they have been temporary Guardians for a while now. IIRC even when they were controllable, they were still totems (numbers 5 and 6, after Fire, Earth, Wind and Water?), just like the DK Ghouls back then.

A final note on "Primal Elementalist" Elementals: IIRC they do get a spell book with their spells, same as Hunter's and Warlocks', but only when they are out (their spell book vanishes afterwards). I made an addon to populate my LibSpellName2SID libraries with spells, and for those controllable Elemental Shaman pets that addon actually gets the spells primarily from the Pet Action Bar. I haven't published the addon as such (and thus the code is rather ugly) but it is available here on WoWI, through SVN: http://svn.wowinterface.com/listing....pulator_trunk_ (it's a funtional standalone addon (no need for the lib it's used to populate), producing output to SavedVariables, released under a MIT license, and thus you can install it and freely modify and test stuff with it, if you want to).

doofus 09-17-20 09:27 AM

Quite old thread, I am testing on SL, and Frost DKs have a pet that lasts one minute, so I am using UnitExists("pet") and of course it returns false. This pet does not have an actionbar of its own. Does anyone know how to detect it?

Xrystal 09-17-20 10:37 AM

Quote:

Originally Posted by doofus (Post 336851)
Quite old thread, I am testing on SL, and Frost DKs have a pet that lasts one minute, so I am using UnitExists("pet") and of course it returns false. This pet does not have an actionbar of its own. Does anyone know how to detect it?

Is a cooldown activated or a buff to show it is up. From my DK days I recall my summoned minions showed as a buff as they were combat/time limited.

Edit:
Imported my death knight and switched to frost and raised a dead minion .. as suspected there is a 2 min cooldown. So you should be able to check for active cooldown and use that as a guide. Now whether it dies before the cooldown and the cooldown isn't reset when it dies, you may not have much else you can do except to see if the combat log can be checked for a dead minion death and use that to tell your addon to ignore the cooldown test. It all depends on what you are wanting to do.

sezz 09-21-20 01:10 PM

Quote:

Originally Posted by doofus (Post 336851)
Quite old thread, I am testing on SL, and Frost DKs have a pet that lasts one minute, so I am using UnitExists("pet") and of course it returns false. This pet does not have an actionbar of its own. Does anyone know how to detect it?

GetTotemInfo

Xrystal 09-21-20 03:07 PM

Quote:

Originally Posted by sezz (Post 336877)

Totem functions work with summoned pets ?

Interesting change .. Just looked and it does indeed
https://www.townlong-yak.com/framexm...TotemFrame.lua

SDPhantom 09-22-20 08:35 AM

Quote:

Originally Posted by Xrystal (Post 336880)
Totem functions work with summoned pets ?

Interesting change .. Just looked and it does indeed
https://www.townlong-yak.com/framexm...TotemFrame.lua

Not really a change, but a reuse of an existing system. Like how warrior stances and paladin auras were considered shapeshift forms in the API.

The difference between a "totem" and a pet is you have full control over a pet and it has a standard pet UnitFrame. "Totems" just have a round button, sometimes with a timer on it. They always act on their own and are uncontrollable. Most "totems" can be dismissed by right-clicking their button on the PlayerFrame.


All times are GMT -6. The time now is 12:24 AM.

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