On release Macro

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