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).


All times are GMT -6. The time now is 08:25 PM.

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