Thread Tools Display Modes
09-08-21, 05:51 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Get pet summon spell ID

Hi all

I want to be able to determine the summon spellID from the petGUID.

Right now I can get the pet summon spellID only when I track the UNIT_SPELLCAST_SUCCEEDED event.

Here is my chunk and its result;


Here is all the pet details in-game using the WoWLua addon;


I have read up on strings and wonder if I can strip and convert the petGUID to the spellID, yet have not yet been successful.

Is there a way to capture the pet summon spellID other than summoning?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
09-08-21, 10:57 PM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Walkerbo View Post
I want to be able to determine the summon spellID from the petGUID.

I have no idea WHY you want to map from a GUID to a SpellID, like in this thread and the other thread
I did explain how to do that anyway there, by mapping from SummonSpellID to
  1. SpeciesID with BattlePetSpecies.db2
  2. Pet GUIDs with C_PetJournal.GetPetInfoByIndex
Lua Code:
  1. local SpeciesIDtoSummonSpellID = {
  2.     [39] = 4055, -- Mechanical Squirrel
  3.     [40] = 10673, -- Bombay Cat
  4.     [41] = 10674, -- Cornish Rex Cat
  5. }
  6.  
  7. local guids = {}
  8. local _, numOwnedPets = C_PetJournal.GetNumPets()
  9. for i = 1, numOwnedPets do
  10.     local guid, speciesID = C_PetJournal.GetPetInfoByIndex(i)
  11.     guids[guid] = SpeciesIDtoSummonSpellID[speciesID]
  12. end
  13.  
  14. DevTools_Dump(guids)
Code:
["BattlePet-0-00000338F99E"] = 10673,
["BattlePet-0-00000338F9A3"] = 10674,
["BattlePet-0-00000338F94E"] = 4055
But you still didn't explain what you're actually trying to do https://xyproblem.info/

Last edited by Ketho : 09-16-21 at 03:24 AM.
  Reply With Quote
09-13-21, 06:54 PM   #3
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Ketho

Thanks for your post, and for the link to the wowtools database, something that I can see will be very useful in the future.

I have a button that will get the petGUID from the cursor on drop.

From the petGUID I want to add the following pet details to a table;
Lua Code:
  1. petGUID
  2. petHyperlink
  3. petSpeciesID
  4. petSummonSpellID

Testing with Abyssal Slitherling I can get the following on drop;
Lua Code:
  1. petGUID = BattlePet-0-000007554101
  2. petHyperlink = C_PetJournal.GetBattlePetLink(petGUID)
  3. petSpeciesID = 2678

However I can only get the petSummonSpellID by tracking the UNIT_SPELLCAST_SUCCEEDED event;
Lua Code:
  1. petSummonSpellID = 118301

I want to be able to get the petSummonSpellID without having to summon the pet itself.

Using the csv table from the wowtools database the Abyssal Slitherling does not have a corresponding petSummonSpellID; so even if I use the database in a lua file and map the petSpeciesID I get a zero instead of the correct 118301.

Is there a reliable way to get either the petSummonSpellID without having to track the UNIT_SPELLCAST_SUCCEEDED event, or, getting a full and complete pet database?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
09-14-21, 09:04 PM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
All pets obtained from pet battles use the same summonSpellID so you cannot use this ID for that purpose
https://www.wowhead.com/spell=118301/summon-battle-pet

Originally Posted by Walkerbo View Post
I want to be able to get the petSummonSpellID without having to summon the pet itself.

You still didn't explain why you need it and how you're going to use it
  Reply With Quote
09-15-21, 09:09 PM   #5
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Ketho

Thanks for your post.

I did not realise that all pets that we can catch share the same summonSpellID.

Also after testing the spellCastGUID, (arg2), from UNIT_SPELLCAST_SUCCEEDED these too do not match as each summon has a unique spellCastGUID even if it is the exact same pet that is summoned.

As for my goal;
I wish to be able to add a pet to a table, and when a UNIT_SPELLCAST_SUCCEEDED event fires if the pet is listed it will send a customisable emote to chat.

I figured that tracking the spellID, (arg3), from UNIT_SPELLCAST_SUCCEEDED I could send the appropriate customisable emote for that pet to chat.

As it stands right now I can filter out all pets that have a zero petSummonSpellID from the wowtools database to only allow pets with a unique petSummonSpellID to be added to the table.

If there is a better solution I would be grateful for some direction.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
09-16-21, 03:53 AM   #6
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Walkerbo View Post
I wish to be able to add a pet to a table, and when a UNIT_SPELLCAST_SUCCEEDED event fires if the pet is listed it will send a customisable emote to chat.
[...]
If there is a better solution I would be grateful for some direction.

Hook the summon pet API to get the GUID and map it to a speciesID. This is just a minimal example without e.g. formatting the pet name in the message with "%s"

This is why I keep telling you to always explain what you're trying to do for the bazillionth time

Lua Code:
  1. local messages = {
  2.     [40] = "pets the Bombay Cat", -- Bombay Cat
  3.     [379] = "hello world", -- Squirrel (from pet battles)
  4. }
  5. local guids = {}
  6.  
  7. local function OnEvent(self, event)
  8.     if not next(guids) then -- numOwnedPets is 0 at login
  9.         local _, numOwnedPets = C_PetJournal.GetNumPets()
  10.         for i = 1, numOwnedPets do
  11.             local guid, speciesID = C_PetJournal.GetPetInfoByIndex(i)
  12.             guids[guid] = speciesID
  13.         end
  14.     end
  15. end
  16.  
  17. local function SendPetEmoteMessage(petGUID)
  18.     local speciesID = guids[petGUID]
  19.     if messages[speciesID] then
  20.         SendChatMessage(messages[speciesID], "EMOTE")
  21.     end
  22. end
  23.  
  24. hooksecurefunc(C_PetJournal, "SummonPetByGUID", function(petGUID)
  25.     SendPetEmoteMessage(petGUID)
  26. end)
  27.  
  28. hooksecurefunc(C_PetJournal, "SummonRandomPet", function()
  29.     C_Timer.After(.3, function() -- does not return proper data yet
  30.         local petGUID = C_PetJournal.GetSummonedPetGUID()
  31.         SendPetEmoteMessage(petGUID)
  32.     end)
  33. end)
  34.  
  35. local f = CreateFrame("Frame")
  36. f:RegisterEvent("PET_JOURNAL_LIST_UPDATE")
  37. f:SetScript("OnEvent", OnEvent)


Last edited by Ketho : 09-16-21 at 02:13 PM.
  Reply With Quote
09-16-21, 06:48 PM   #7
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Ketho

Thanks for your post.

In you chunk you have;
Lua Code:
  1. local messages = {
  2.     [40] = "pets the Bombay Cat", -- Bombay Cat
  3.     [379] = "hello world", -- Squirrel (from pet battles)
  4. }

Is this not just a mapped table, as you have to have the petSpeciesID to compare to the summoned pet?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
09-16-21, 09:54 PM   #8
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
That is for the custom messages. You do know how to look up a speciesID?

https://wowpedia.fandom.com/wiki/BattlePetSpeciesID
  Reply With Quote
09-19-21, 07:48 PM   #9
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Ketho

Yes getting the speciesID is pretty easy, though I prefer the BattlePetSpecies.db2 on wowtools database that you linked; once again a great tool that you introduced to me.

Thanks for your help.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Get pet summon spell ID

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