Trap On Release Macro/Addon

Hello all!

I recently set up an addon to modify my trap macro, allowing me to hold down the keybind to see the reticle, then release to drop it on the cursor. Normally I’d leave this kind of thing over in the UI & Macro forums, but I have found it to be insanely useful so cross posting here.

For Hunters, this works with:

  • Freezing Trap
  • Tar Trap
  • Flare
  • Eagle Eye
  • Binding Shot
  • Volley
  • Steel Trap
  • Hi-Explosive Trap
  • Dire Beast: Hawk
  • Wild Spirits
  • Resonating Arrow
  • Door of Shadows

It works with any ground-target ability/item/toy you might want to keybind, with the exception of PetMoveTo (since that isn’t an ability but a pet command).

--Trap On Release
local key = "PageDown"
if select(2,UnitClass("player"))=="HUNTER" then
   local FreezingTrapOnUp = CreateFrame("Button","FreezingTrapOnUp",nil,"SecureActionButtonTemplate")
   FreezingTrapOnUp:RegisterForClicks("AnyDown","AnyUp")
   FreezingTrapOnUp:SetAttribute("type","macro")
   SecureHandlerWrapScript(FreezingTrapOnUp,"OnClick",FreezingTrapOnUp,[[
     if down then
       self:SetAttribute("macrotext","/cast Freezing Trap")
     else
       self:SetAttribute("macrotext","/stopspelltarget\n/cast [@cursor] Freezing Trap")
     end
   ]])
   FreezingTrapOnUp:RegisterEvent("PLAYER_LOGIN")
   FreezingTrapOnUp:SetScript("OnEvent",function(self,event,...)
     SetOverrideBindingClick(self,true,key,"FreezingTrapOnUp")
   end)
end

This example is for Freezing Trap, using Page Down. You can change it to any other ability by changing all instances of Freezing Trap or FreezingTrapOnUp to reflect the ability you want instead. You can change the keybind by changing key=PageDown to whatever binding you prefer.

You can duplicate this for multiple abilities if you like (I currently use it for Freezing Trap, Tar Trap, and Binding Shot), but be aware you will also need to update key to key1 key2 key3 etc if you are doing more than one.

Copy this code into https://addon.bool.no/ to create a mini addon that will set the keybinding for you. In my example, I have the binding set to PageDown. It will supercede (but not overwrite) your existing binds, so if you disable the addon, the keybind will work as normal.

For my personal use, I have long used this macro, keybound to PageDown (my mouse drivers have Mouse6 set to PageDown):

#showtooltip
/use [mod:shiftalt,@player][mod:shift,@cursor]Binding Shot;[mod:ctrlalt,@player][mod:ctrl,@cursor]Tar Trap;[mod:alt,@player][@cursor]Freezing Trap

So my version of the addon incorporates all three ground target CCs, using the same modifiers, with an additional [mod:alt,@player] if I want to drop it at my feet:

--Trap On Release
local key = "PageDown"
if select(2,UnitClass("player"))=="HUNTER" then
   local FreezingTrapOnUp = CreateFrame("Button","FreezingTrapOnUp",nil,"SecureActionButtonTemplate")
   FreezingTrapOnUp:RegisterForClicks("AnyDown","AnyUp")
   FreezingTrapOnUp:SetAttribute("type","macro")
   SecureHandlerWrapScript(FreezingTrapOnUp,"OnClick",FreezingTrapOnUp,[[
     if down then
       self:SetAttribute("macrotext","/cast [@player,mod:alt][]Freezing Trap")
     else
       self:SetAttribute("macrotext","/stopspelltarget\n/cast [@cursor] Freezing Trap")
     end
   ]])
   FreezingTrapOnUp:RegisterEvent("PLAYER_LOGIN")
   FreezingTrapOnUp:SetScript("OnEvent",function(self,event,...)
     SetOverrideBindingClick(self,true,key,"FreezingTrapOnUp")
   end)
end

local key2 = "CTRL-PageDown"
if select(2,UnitClass("player"))=="HUNTER" then
   local TarTrapOnUp = CreateFrame("Button","TarTrapOnUp",nil,"SecureActionButtonTemplate")
   TarTrapOnUp:RegisterForClicks("AnyDown","AnyUp")
   TarTrapOnUp:SetAttribute("type","macro")
   SecureHandlerWrapScript(TarTrapOnUp,"OnClick",TarTrapOnUp,[[
     if down then
       self:SetAttribute("macrotext","/cast [@player,mod:alt][]Tar Trap")
     else
       self:SetAttribute("macrotext","/stopspelltarget\n/cast [@cursor] Tar Trap")
     end
   ]])
   TarTrapOnUp:RegisterEvent("PLAYER_LOGIN")
   TarTrapOnUp:SetScript("OnEvent",function(self,event,...)
     SetOverrideBindingClick(self,true,key2,"TarTrapOnUp")
   end)
end

local key3 = "SHIFT-PageDown"
if select(2,UnitClass("player"))=="HUNTER" then
   local BindingShotOnUp = CreateFrame("Button","BindingShotOnUp",nil,"SecureActionButtonTemplate")
   BindingShotOnUp:RegisterForClicks("AnyDown","AnyUp")
   BindingShotOnUp:SetAttribute("type","macro")
   SecureHandlerWrapScript(BindingShotOnUp,"OnClick",BindingShotOnUp,[[
     if down then
       self:SetAttribute("macrotext","/cast [@player,mod:alt][]Binding Shot")
     else
       self:SetAttribute("macrotext","/stopspelltarget\n/cast [@cursor] Binding Shot")
     end
   ]])
   BindingShotOnUp:RegisterEvent("PLAYER_LOGIN")
   BindingShotOnUp:SetScript("OnEvent",function(self,event,...)
     SetOverrideBindingClick(self,true,key3,"BindingShotOnUp")
   end)
end

I’m able to trap with the speed of an [@cursor] macro and the precision gained by seeing the reticle. I’ve tested in raids and M+ and it works flawlessly. I’ve tested disabling the addon and my regular macro works exactly the same as it always has, without any need to change keybinds in game.

Let me know if you have any questions or need help setting it up for a specific ability or situation.

7 Likes

So has anyone tried this yet?

Interested to know how it’s working out for others, I’ve been really enjoying the added precision.

This looks promising. I tried it out briefly and it seems to work great, however I’m trying to figure out how to bind something like Shift + MouseButton5. I like using mouse buttons for traps. Thanks for sharing nonetheless!

1 Like

I may give it a go later, thanks for the cross post!

1 Like

You would use SHIFT-Mouse5.

That said, I too like traps on mouse buttons - PageDown is the mapping for one of the extra buttons on my mouse. Be aware that WoW (and most of Windows, for that matter) only recognizes Mouse4 and Mouse5. Any additional buttons your mouse has need to be mapped to keyboard keys via your mouse software/drivers.

Thanks man I tried with SHIFT-Mouse5 in there and it doesn’t seem to work with that. any ideas?

To be clear, you changed

local key = "PageDown"

to

local key = "SHIFT-Mouse5"

?

Or did you do all 3 (Freezing, Tar, and Binding) as Mouse5, CTRL-Mouse5, and SHIFT-Mouse5 respectively?

Edit: Sorry I had the wrong syntax, I checked my bindings-cache.old and its BUTTON5, so you’d want SHIFT-BUTTON5 in your case.

Hi, I’ve set this up, and absolutely love it. It was exaclty what I was looking for, but I do have one small issue, and wanted to know if maybe you knew the syntax/where to place it to fix it. I sometimes will press the keybind for the trap, and realize for some reason it’s not the right time to use the trap anymore (situations change) and I would like to cancel and not throw the trap anymore. Is there a way to add in the code that if I press my right mouse button it cancels it and doesn’t throw the trap on release of the keystroke? Thank you in advance.

This works to activate the trap but does not drop it for me. Any ideas why?

Blizzard introduced a bug with [@cursor] macros a few months ago when they made a change to self-casting behavior, and they also broke /click commands with the 10.0 prepatch - now you can’t do /click ButtonName, you need to do /click ButtonName X 1.

Personally, I’d recommend you just get the addon Grounded, which does the exact same thing as the macros here, but work on every class, have an easy GUI to set them up in game, and don’t require you to do any coding.

1 Like

hey seriously cool, but it doesn’t seem to work for me on my shift - 1 modifier, it activates the reticle but nothing happens on release, I would not like to set my default keybinds to on release, only this one bind and a few others, thanks for such a cool thing though, I seriously appreciate the complexity of it