Thread Tools Display Modes
01-16-21, 10:56 PM   #1
MHWalker
A Defias Bandit
Join Date: Jan 2021
Posts: 2
WeakAura trigger when attempting to mount

I have little to no experience in LUA or WoW APIs, and am only experienced in making WeakAuras through the built in GUI.

I'm trying to make a simple WA that displays a custom texture and plays a sound when I try to mount (successfully or unsuccessfully), and hides after a short duration.

The texture and sound I was able to figure out, but I don't know how to set up a trigger for when I attempt to cast a mount spell (if you couldn't tell, this has something to do with being in the Maw). I'm aware of the WA someone created that tracks how many times you attempt to mount in the Maw, but I'm going for something much simpler than that, and I wasn't able to figure out how to make the trigger from their WA.

I did a lot of research on my own trying to riddle it out, and the closest I got was the UNIT_SPELLCAST_SENT event, which sounds like is what I need. I just don't know how to use it for my trigger...

Any help on this would be greatly appreciated.
  Reply With Quote
01-17-21, 10:36 AM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
You're in the right direction. The way that maw mount counter works is that it loops through all of your mounts and saves each spell ID when it loads, then listens for UNIT_SPELLCAST_SENT and compares the spell ID in that event with the list of known spell IDs. I'll give you the bare basics.

Make a new icon weakaura, go to Actions tab, click Custom at the top (OnInit), and put this in the box:

Lua Code:
  1. aura_env.mountSpells = {}
  2.  
  3. for i, mountID in pairs(C_MountJournal.GetMountIDs()) do
  4.     -- 1304 is Mawsworn Soulhunter and 1442 is Corridor Creeper
  5.     -- they work in the Maw, so ignore them
  6.     if mountID ~= 1304 and mountID ~= 1442 then
  7.         local _, spellID = C_MountJournal.GetMountInfoByID(mountID)
  8.         aura_env.mountSpells[spellID] = true
  9.     end
  10. end

Then select Custom > Event in the Trigger tab and put this in the box:

Lua Code:
  1. function(_, unit, _, _, spellID)
  2.     return unit == "player" and aura_env.mountSpells[spellID]
  3. end

The event you'll be putting in the small box above that is UNIT_SPELLCAST_SENT and you should see a timed box right below the custom trigger function where you can play with the time it spends shown.

Finally, in the Load tab, scroll down to Zone ID and use 1543 which is the Maw.

Last edited by Kanegasi : 01-17-21 at 10:41 AM. Reason: oops
  Reply With Quote
01-17-21, 01:38 PM   #3
MHWalker
A Defias Bandit
Join Date: Jan 2021
Posts: 2
Works exactly how I would have liked it to!

I can't even begin to thank you enough! I was struggling so much to make what I thought would have been a very simple WA. Turns out I just needed someone far smarter than I am!

Thanks so much!
  Reply With Quote
01-17-21, 03:33 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
I kind of like this, so I made my own. However, I use LiteMount, which recognizes when you can't use a mount and doesn't send out a spellcast event. For those that want a weakaura warning with LiteMount, set up a trigger with Custom > Status > Every Frame and the following function:

Lua Code:
  1. function()
  2.    
  3.     if not LiteMount then return false end
  4.    
  5.     local litemount=false
  6.    
  7.     if LiteMount.actions and not _G["HOOKLITEMOUNTFORWEAKAURA"] then
  8.         setglobal("HOOKLITEMOUNTFORWEAKAURA",true)
  9.         hooksecurefunc(LiteMount.actions[1],"Dispatch",function()
  10.                 setglobal("LITEMOUNTFORWEAKAURA",true)
  11.         end)
  12.         hooksecurefunc(LiteMount.actions[2],"Dispatch",function()
  13.                 setglobal("LITEMOUNTFORWEAKAURA",true)
  14.         end)
  15.         hooksecurefunc(LiteMount.actions[3],"Dispatch",function()
  16.                 setglobal("LITEMOUNTFORWEAKAURA",true)
  17.         end)
  18.         hooksecurefunc(LiteMount.actions[4],"Dispatch",function()
  19.                 setglobal("LITEMOUNTFORWEAKAURA",true)
  20.         end)
  21.     end
  22.    
  23.     if _G["LITEMOUNTFORWEAKAURA"] then
  24.         litemount=true
  25.         setglobal("LITEMOUNTFORWEAKAURA",false)
  26.     end
  27.    
  28.     return litemount
  29.    
  30. end

However, this does not have the option to ignore, so druids, shamans, worgen, and anyone using the two maw mounts will get this trigger every time (LiteMount handles them all) so if you can mount in the maw on certain characters, you may want to fiddle with the load tab. Also, make sure you set the Zone ID to 1543 as mentioned above or you'll get this warning everywhere you mount.
  Reply With Quote
12-02-23, 08:52 AM   #5
vaenel
A Kobold Labourer
Join Date: Dec 2023
Posts: 1
hi do you have any idea how i put the sound Riding_Turtle_MountSpecial when i jump in a wa ,since in woltk classic they didnt add the sound of the mount
thanks .
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » WeakAura trigger when attempting to mount

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