View Single Post
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,326
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