WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   What mount is a person using? (https://www.wowinterface.com/forums/showthread.php?t=53303)

Hiketeia 04-11-16 11:31 PM

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.

SDPhantom 04-12-16 01:58 AM

I'm going to first answer some questions, then give some example code.



Quote:

Originally Posted by Hiketeia (Post 314054)
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.

Quote:

Originally Posted by Hiketeia (Post 314054)
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.

Quote:

Originally Posted by Hiketeia (Post 314054)
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.

Hiketeia 04-12-16 10:32 AM

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!

semlar 04-12-16 11:09 AM

Quote:

Originally Posted by Hiketeia (Post 314058)
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?

Hiketeia 04-12-16 12:35 PM

Quote:

Originally Posted by semlar (Post 314059)
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?

SDPhantom 04-12-16 12:51 PM

Quote:

Originally Posted by Hiketeia (Post 314058)
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.

Quote:

Originally Posted by Hiketeia (Post 314062)
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.

Hiketeia 04-12-16 01:25 PM

Quote:

Originally Posted by SDPhantom (Post 314063)
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.

SDPhantom 04-12-16 03:46 PM

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.


All times are GMT -6. The time now is 09:30 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI