Hunter Macro Script Help

I’m working to update my old vanilla WoW macros for the new API that will be used for Classic WoW. I’ve gotten a lot of it completed and believe they will work. I’m not sure about the script pieces though. Could someone look at the below and tell me whether they will work or not? I will not post the full macros, only the parts I am uncertain of. If anyone would like me to share any macros, I would be happy to do so.

/run if CheckInteractDistance(“target”,3) and (not PlayerFrame.inCombat) then /startattack elseif not IsAutoRepeatAction(3) then /use Auto Shot end

The intent of the above is to start melee auto attack if the target is in melee range and I am not in combat. It will turn on Auto Shot (action bar slot 3) if it is not on and the target is outside melee range.

/run local i,x=1,0 while UnitBuff(“player”,i) do if UnitBuff(“player”,i)==“Interface\Icons\Ability_Ambush” then x=1 end i=i+1 end if x==0 then /use Shadowmeld else end

The intent of the above is to cast Shadowmeld if it is not already active. It will not toggle Shadowmeld off if it is active.

/script if UnitExists(“pettarget”) and CheckInteractDistance(“target”,3) and UnitIsUnit(“target”,“pettarget”) then /petpassive /petstay else end

The intent of the above is to put my pet on passive and tell it to stay if my pet’s target is the same as my target and I am in melee range of my target.

/script class=UnitClass(“target”) if ((class==“Rogue”) or (class==“Warrior”)) then /use Scorpid Sting else /use Viper Sting end

The intent of the above is to cast Scorpid Sting if my target is a Rogue or Warrior and cast Viper Sting if they are any other class.

/run local if UnitExists(“pet”) then if UnitHealth(“pet”)==0 then /use Revive Pet elseif GetPetHappiness()~=nil and GetPetHappiness()~=3 then /use Feed Pet /use [pet] 0 13 else /use Dismiss Pet end else /use Call Pet end

The intent of the above is to cast Revive Pet if my pet is summoned and dead, cast Feed Pet (food in backpack slot 13) if my pet is summoned and not happy, cast Dismiss Pet if my pet is summoned and is happy, and cast Call Pet if my pet is not summoned.

No can do, hoss.

No such intelligence is allowed in macros.

The best you’re going to be able to do is to put markers on the buttons that indicate to you that you should take an action, but you cannot code your own conditionals for macros that will result in casting spells or using abilities.

Wow, really? That’s pretty limiting :confused: Well, thank you for the info. RIP my macros.

Here’s a follow up question: If my Auto Shot is already activated, and my macro then runs /use Auto Shot, will that cancel my Auto Shot or will Auto Shot remain active?

You should never explictly cast autoshot. It activates with any attack on its own.

There are circumstances when you should STOP shooting, but never one where that’s your best first shot.

In vanilla/classic it is best to open with Auto Shot in certain conditions for example at lower levels where you don’t have Aimed Shot yet or if you don’t want to open with a higher damage shot in order too avoid building threat to quickly. Let’s pick a different ability though for the sake of the question. Let’s say I have Aspect of the Monkey already applied. If I then run a macro that contains /use Aspect of the Monkey, will that deactivate it?

Once Aspect of the Monkey is applied, it doesn’t reapply automatically. It becomes a buff (an aura).

Apples and oranges here.

You simply cannot “reapply” or attempt to reapply Aspect of the Monkey this way. The cooldown is longer than the aura.

Auto Shot is an autocast. A nearly unique situation (some of your pet abilities are on autocast).

There is a great deal you can do to help yourself with macros as a hunter (particularly as a Beast Mastery hunter).

My own setup has been described as being “baroque” but it works very well.

Essentially, I use macro chaining to govern almost all aspects of target selection, combat pet behavior, and non-combat pet behavior in ways that allow for stacking conditionals that using single macros just don’t allow.

If you’re interested, I’ll expound, but otherwise, I’ll save the GWOT.

Use /startattack rather than /cast Auto Shot

That said, you can generally prefix spells with ! to prevent them toggling off. ie /cast !Aspect of the Cheetah

@elvenbane that’s exactly what I wanted to know, thank you. Why /startattack instead? Does it initiate melee attack or Auto Shot depending on the range?

@ehiztari I’ve never heard of macro chaining. I’d definitely be interested to hear more.

Good question. These days it does, not sure about back then, I didn’t roll a hunter till MoP.

Macro Chaining 101/102 (Focus on Beast Mastery Hunters)

I built these for myself using the Action Bar handlers in ElvUI and ElvUI_ExtraActionBars. Bartender will work as well, but don’t ask me specific questions related to Bartender as I don’t use it. I suspect Domino will work, but I don’t have that either. You can do this with the Vanilla UI, but it’s . . . awkward . . . at best. I strongly recommend a bar mod that allows you to access all 120 action slots directly.


Assumptions:

  • You have a bar of buttons you can set aside for macros executed indirectly.
    • That bar cannot be a “paging” bar.
    • That bar does not have to be visible (at least in ElvUI).
  • In 5-man content ONLY, you will assign your Tank as your Focus Unit.
  • Somewhere upstream from executing these macros (preferably a startup macro) you run this code:
  SetCVar("TargetNearestUseNew"         , 0,"scriptCVar")
  SetCVar("stopAutoAttackOnTargetChange", 1,"scriptCVar")

Conventions:

  • I’m going to use my button names.
  • You’ll need to identify what buttons you want to use based on your own UI.
    • Discover their formal names, the button frame names, using /framestack or /fstack.
    • When you’re one with /framestack, type it again to make it to away.

Target Control

  • Requires you to set aside six buttons.
  • Applies to only unit targeted, DPS actions.
  • Allows for situational targeting priority plug-ins.

Name: Tgt Atk 1
Desc: Dismounts on mod and dispatches to the rest of the chain.
Button: ElvUI_Bar6Button1
Icon: <any, but the automatic one won’t work well>

/dismount [mounted,mod]
/leavevehicle [vehicleui,mod]
/click ElvUI_Bar5Button2
/click ElvUI_Bar5Button3
/click ElvUI_Bar5Button4
/click ElvUI_Bar5Button5
/click ElvUI_Bar5Button6

Name: Tgt Atk 2
Desc: Sets targeting priority to PVP or PVE based on whether or not you know the second of your PVP talents (the first might be Honorable Medallion which always comes up true).
Button: ElvUI_Bar6Button2
Icon: <any, but the automatic one won’t work well>

/stopmacro [combat]
/run local C,I,S,N="TargetPriorityPvp",select(6,GetPvpTalentInfoByID((C_SpecializationInfo.GetAllSelectedPvpTalentIDs()[2])))S=((I and IsPlayerSpell(I)and"3")or"2")if not(GetCVar(C)==S)then SetCVar(C,tonumber(S),"scriptCVar")end

Caveat: I do this in a startup macro and I haven’t tested this version. It might error out. If so, look to the addendum at the end of this post for my full code and adjust as needed.


Name: Tgt Atk 3 (OPTIONAL)
Desc: Allows for inserting situational priority target units. This bypasses the normal targeting process by forcing in the highest priority target from the target list (if there are any).
Button: ElvUI_Bar6Button3
Icon: <any, but the automatic one won’t work well>

/targetexact \<sixth highest priority situational target unit\>
/targetexact \<fifth highest priority situational target unit\>
/targetexact \<fourth highest priority situational target unit\>
/targetexact \<third highest priority situational target unit\>
/targetexact \<second highest priority situational target unit\>
/targetexact \<highest priority situational target unit\>

Insert or delete as needed. Be careful to drag this macro off its button as soon as it’s no longer needed or you might run into problems.


Name: Tgt Atk 4
Desc: Default target selection with pet optimization.
Button: ElvUI_Bar6Button4
Icon: <any, but the automatic one won’t work well>

/petstay [dead][noharm][mod:ctrl]
/cleartarget [dead][noharm][mod:ctrl]
/tar [@mouseover,harm,nodead,mod:shift] 
/targetenemy [noharm][noexists]

Name: Tgt Atk 5
Desc: Aggro and pet taunt management. This will cast Misdirection on your Focus unit if it lives, is not mind-controlled or charmed, and you’re not in a Raid, otherwise it will cast Misdirection on your pet. It will shut off Growl autocast if you are in a Raid or if you are in a 5-man with a living, helpable Tank, otherwise, it will turn on Growl autocast (in 5-man it will put your pet in auto-tanking mode if the tank dies, is mind-controlled, or is charmed and will stop as soon as that situation no longer exists).
Button: ElvUI_Bar6Button5
Icon: Automatic (the “?” icon)

#show Misdirection
/cast [nogroup:raid,group,@focus,help,nodead][@pet,exists,nodead]Misdirection
/petautocastoff [group:raid][group,@focus,help,nodead]Growl
/stopmacro [group:raid][group,@focus,help,nodead]
/petautocaston Growl

Name: Tgt Atk 6
Desc: Ensures your pet’s stances and basic command is compatible with a targeted attack. Bypasses the flawed pet autoattack timers.
Button: ElvUI_Bar6Button6
Icon: <any, but the automatic one won’t work well>

#show
/petassist
/petattack
/use [harm,nodead]Claw
/use [harm,nodead]Bite
/use [harm,nodead]Smack

Usage:

Using Cobra shot as an example, you’d set up your attack macro like this…

#show Cobra Shot
/click ElvUI_Bar6Button1
/cast [harm,nodead]Cobra Shot

Each of your unit targeted attacks (Barbed Shot, Chimaera Shot, A Murder of Crows, etc.) should be structured like this.


I’ve got another section I want to do on pet management, but it’s late and I’ll need to add that tomorrow.


Addendum

In my startup addon, I have a slash command processor that uses “mao” as the command name.

This command…

/mao pvppve

…invokes this code:

local function DoSlashCmd(A)

  local L = {
    strsplit(" ", (strlower((strtrim((gsub((A or ""), "%s+", " ")))))))
  }
  if L[1] == "pvppve" then
    local pvpPriorityCVarString = "2"
    for k, v in ipairs(C_SpecializationInfo.GetAllSelectedPvpTalentIDs()) do
      local pvpTalentSpellID = select(6, GetPvpTalentInfoByID(v))
      if k > 1 and pvpTalentSpellID and IsPlayerSpell(pvpTalentSpellID) then
        pvpPriorityCVarString = "3"
        break
      end
    end
    local pvpPriorityCVarNumber = tonumber(pvpPriorityCVarString)
    if (GetCVar("TargetPriorityPvp") == pvpPriorityCVarString) then
    else
      if InCombatLockdown() then
      else
        SetCVar("TargetPriorityPvp", pvpPriorityCVarNumber, "scriptCVar")
      end
    end
  end

end

I have a lot more subcommands available to me and I stripped this down to its bones for clarity. It’s possible I introduced a code error when I did that, but I was pretty careful.

Thank you for the info! I’ll play around with it when Classic launches.