Thread Tools Display Modes
04-11-16, 11:31 PM   #1
Hiketeia
An Aku'mai Servant
 
Hiketeia's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 33
What mount is a person using?

So I'm trying to figure out what mount a person is using and could use a hand...

Looping through the UnitBuff()s can give me the spell ids. Calling GetSpellDescription and parsing that for the word mount as an idea but that isn't 100% accurate, tried "Summons and dismisses" but that fails on things like the chaufeuer and the sandstone drake and class mounts.

Looking through wowhead's db and it seems there is an "Effect: Applys aura mount" but I'm not seeing where that might be available in the API?

While on wowhead I used their 'make link' feature to get a link - when I click it, it does show "Account Level Mount" as the subheading of the tooltip which seems promising. But I can't see where that info is coming from either. I've dug through ItemRef and GameTooltip but I'm missing something there as I can't see the connect between how it is populated. Any ideas?

Another thought was maybe I'll have to fall back to some library that has documented what all the mounts' spellids already are -- does LibPeriodicTables do that at all? I saw a list of mounts of different types, but some of the spell ids I was playing with weren't in those lists -- I'm thinking those might be the items, or the npc ids for the mounts, or perhaps just out of date? Which at some point down the road I'll want to translate into - also the Mount Journal API doesn't seem to have an ability to connect the spell of the mounted aura to a mount in the journal?

Rambling now, sorry. Pretty new to doing addons, please be gentle in your replies :-D

-- Realized this should be in the "General Authoring" forum instead of the special Lua/Xml help forum but I don't seem to have permission to delete my post so I'll leave it here for now. Excuse the noob.

Last edited by Hiketeia : 04-11-16 at 11:45 PM.
  Reply With Quote
04-12-16, 01:58 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I'm going to first answer some questions, then give some example code.



Originally Posted by Hiketeia View Post
Looking through wowhead's db and it seems there is an "Effect: Applys aura mount" but I'm not seeing where that might be available in the API?
Sites like WoWHead dig through the game's files through a process called datamining. Most of what they show comes from the game's internal database and is inaccessible to addons.

Originally Posted by Hiketeia View Post
While on wowhead I used their 'make link' feature to get a link - when I click it, it does show "Account Level Mount" as the subheading of the tooltip which seems promising. But I can't see where that info is coming from either. I've dug through ItemRef and GameTooltip but I'm missing something there as I can't see the connect between how it is populated. Any ideas?
When you copy/paste the link code from WoWHead, it's basically a short Lua command that prints the link out in chat where you can interact with it. When you click on it, the chat window eventually hands it off to a tooltip's SetHyperlink() function, which formats the text you see from C code.

Originally Posted by Hiketeia View Post
the Mount Journal API doesn't seem to have an ability to connect the spell of the mounted aura to a mount in the journal?
The code I provide below uses the second return of C_MountJournal.GetMountInfo() to grab the SpellID of the mounts in order to cache them. The cache is used so you can look up the SpellID from the buffs quickly without needing to repeatedly scan the MountJournal for each buff.



Lua Code:
  1. local MountCache={};--  Stores our discovered mounts' spell IDs
  2. for i=1,C_MountJournal.GetNumMounts() do--  Loop though all mounts
  3.     local _,spellid=C_MountJournal.GetMountInfo(i);--   Grab mount spell ID
  4.     MountCache[spellid]=true;-- Register spell ID in our cache
  5. end
  6.  
  7. local function UnitMount(unit)
  8.     local i=1;--    Initialize at index 1
  9.     while true do-- Infinite loop, we'll break manually
  10.         local _,_,_,_,_,_,_,_,_,_,spellid=UnitBuff(unit,i);--   Grab buff info
  11.         if spellid then--   If we have a buff, we have a spell ID
  12.             if MountCache[spellid] then return spellid; end--   Return SpellID if mount is found
  13.             i=i+1;--    Increment by 1 and try again
  14.         else break; end--   Else break loop if no more buffs
  15.     end
  16. end

Using this, you call UnitMount() with a UnitID and it returns the SpellID of the mount if one is found, nil if the unit isn't mounted.
__________________
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)

Last edited by SDPhantom : 04-12-16 at 02:34 AM.
  Reply With Quote
04-12-16, 10:32 AM   #3
Hiketeia
An Aku'mai Servant
 
Hiketeia's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 33
Most excellent! Thank you SDPhantom for the though response. Kinda sad to see so much is still hidden from the api, I got excited thinking if it was seen in the UI, the info would be accessible via code somewhere.

The API reference had said that field in the GetMountInfo was creatureID - I'm not sure I would have tried to see if it was anything else. This works for round one - thanks again!
  Reply With Quote
04-12-16, 11:09 AM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by Hiketeia View Post
Kinda sad to see so much is still hidden from the api, I got excited thinking if it was seen in the UI, the info would be accessible via code somewhere.
What is it that you see in the UI that you think is not accessible via code?
  Reply With Quote
04-12-16, 12:35 PM   #5
Hiketeia
An Aku'mai Servant
 
Hiketeia's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 33
Originally Posted by semlar View Post
What is it that you see in the UI that you think is not accessible via code?
For example, in a mount tooltip where it says "Account Level Mount" - that doesn't seem to be exposed anywhere? In the earlier reply the commentator said that tooltip is generated from the C functions?
  Reply With Quote
04-12-16, 12:51 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by Hiketeia View Post
The API reference had said that field in the GetMountInfo was creatureID - I'm not sure I would have tried to see if it was anything else.
You might've been looking at C_MountJournal.GetMountInfoExtra() instead. That's the one that gives CreatureDisplayID.

Originally Posted by Hiketeia View Post
For example, in a mount tooltip where it says "Account Level Mount" - that doesn't seem to be exposed anywhere?
You can't intercept the formatting process, but you can read from the FontString objects that are contained in the tooltip afterwards. This is called "tooltip scanning" and is an inefficient and often unstable method. Especially when you start dealing with multiple locales.
__________________
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)

Last edited by SDPhantom : 04-12-16 at 01:07 PM.
  Reply With Quote
04-12-16, 01:25 PM   #7
Hiketeia
An Aku'mai Servant
 
Hiketeia's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 33
Originally Posted by SDPhantom View Post
You might've been looking at C_MountJournal.GetMountInfoExtra() instead. That's the one that gives CreatureDisplayID.
I was looking @ http://wowprogramming.com/docs/api/C...l.GetMountInfo but you linked http://wow.gamepedia.com/API_C_Mount...l.GetMountInfo which seems more up to date. Guess part of the process is just learning what resources are good to use, and which are stale.
  Reply With Quote
04-12-16, 03:46 PM   #8
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I actually spotted the usage in the UI code Blizzard_Collections/Blizzard_MountCollection.lua:198 first before linking documentation. Note MountJournal_GetMountInfo() is a shortcut in the file to calling C_MountJournal.GetMountInfo().

I corrected the entry in WoWProgramming, so it should be accurate now. The API didn't change at any time, so it isn't the matter of being out-of-date. Both sites use a wiki structure and people sometimes make mistakes writing these entries. It's up to other users to correct these as they are encountered.
__________________
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)

Last edited by SDPhantom : 04-12-16 at 03:56 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » What mount is a person using?

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