Thread Tools Display Modes
12-28-19, 06:11 PM   #1
doofus
A Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
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 Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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 Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
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: 223
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 Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
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
09-17-20, 09:27 AM   #7
doofus
A Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
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?
  Reply With Quote
09-17-20, 10:37 AM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Originally Posted by doofus View Post
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.
__________________

Last edited by Xrystal : 09-17-20 at 10:48 AM.
  Reply With Quote
09-21-20, 01:10 PM   #9
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Originally Posted by doofus View Post
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
  Reply With Quote
09-21-20, 03:07 PM   #10
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Originally Posted by sezz View Post
Totem functions work with summoned pets ?

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

Last edited by Xrystal : 09-21-20 at 03:49 PM.
  Reply With Quote
09-22-20, 08:35 AM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,308
Originally Posted by Xrystal View Post
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.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
10-08-20, 07:23 PM   #12
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Originally Posted by SDPhantom View Post
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.

Just took a look at this and found it working this way with the warlock short term demons. Death Knight seemed to use the pet bar and at least survival hunter only has the one pet. It's likely the beast master multiple summoned beasts will be a totem. So added it to the todo list for nUI for after pre-launch patch hits and I have nUI working somewhat stable.
__________________
  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