Quantcast API UnitExists("pet") - WoWInterface
Thread Tools Display Modes
12-28-19, 06:11 PM   #1
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 126
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 ?
  Reply With Quote
12-28-19, 06:18 PM   #2
Kanegasi
A Firelord
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 481
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.
  Reply With Quote
12-29-19, 03:55 AM   #3
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 126
thanks :-)
  Reply With Quote
12-29-19, 09:43 PM   #4
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 214
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.
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
  Reply With Quote
12-30-19, 02:27 PM   #5
JDoubleU00
A Scalebane Royal Guard
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 445
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?
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
01-01-20, 03:01 PM   #6
aallkkaa
A Warpwood Thunder Caller
 
aallkkaa's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2017
Posts: 98
Originally Posted by JDoubleU00 View Post
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<ptionally 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).
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » API UnitExists("pet")

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