I'm going to first answer some questions, then give some example code.
Originally Posted by Hiketeia
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
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
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:
local MountCache={};-- Stores our discovered mounts' spell IDs
for i=1,C_MountJournal.GetNumMounts() do-- Loop though all mounts
local _,spellid=C_MountJournal.GetMountInfo(i);-- Grab mount spell ID
MountCache[spellid]=true;-- Register spell ID in our cache
end
local function UnitMount(unit)
local i=1;-- Initialize at index 1
while true do-- Infinite loop, we'll break manually
local _,_,_,_,_,_,_,_,_,_,spellid=UnitBuff(unit,i);-- Grab buff info
if spellid then-- If we have a buff, we have a spell ID
if MountCache[spellid] then return spellid; end-- Return SpellID if mount is found
i=i+1;-- Increment by 1 and try again
else break; end-- Else break loop if no more buffs
end
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.