On release Macro

Was wondering if it was possible to have an on release macro for traps, where clicking down would bring up the reticle area indicator, and then releasing would then cast the trap at the cursor spot? Such that I could it down and then release, for a much smoother process.

@Gello has you covered. There are some caveats he can explain better than I, but check this post:

Actually, after mucking around with this a while ago and failing to get it working (because I was modifying the addon in the _beta_ folder rather than _retail_ >.<), I took the time to figure it out. Enjoy.

--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

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 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 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

You can add more in the same format for other ground-targeted spells (e.g. Flare, Volley, Wild Spirits, Resonating Arrow, etc). Make sure to adjust the keybinds to what you want to use.

1 Like

Thanks for the reply! But am I missing something? The text is too long and wont fit into a single macro…

1 Like

You can turn it into an addon by pasting it into https://addon.bool.no/

The code defines the keys too. You may want to change them to suit your preferred keybinds.

2 Likes

Again, @Gello has you covered. I thought the addon.bool.no bit was covered in the linked post, but on rereading I think it was mentioned elsewhere in that thread.