|Useful macros by class|
Below is the entire list of conditionals that are available to the macro system. One of the goals in the 2.0 patch was to eliminate a lot of old "smart buttons" that allowed people to essentially play the entire game spamming one key repeatedly. However, many tasks people used macros to simplify were deemed OK and given Blizzard's blessing via the macro options.
If you don't see a condition listed here, then there is no way to check for it and take a combat-related action. These are essentially non-negotiable though they may be augmented in the future.
These can also be checked for falseness instead of trueness by prefixing them with "no". For example, [nocombat] is a valid conditional and will only perform the actions following it if you are not in combat.
- actionbar:1/.../6 or bar:1/.../6 — Given action bar page is selected.
- bonusbar:1/... — a (specific) bonus action bar is currently overriding the player's main action bar.
- button:1/.../5/<virtual click> or btn:1/.../5/<virtual click> — Macro activated with the given mouse button.
- canexitvehicle — Player is in a vehicle and can exit it at will.
- channeling:<spell name> — Player is channeling the given spell.
- cursor — The mouse cursor is currently holding an item/ability/macro/etc.
- combat — Player is in combat.
- dead — Conditional target exists and is dead.
- equipped:<item type> or worn:<item type> — item type is equipped (item type can be an inventory slot, item type, or item subtype).
- exists — Conditional target exists.
- extrabar — Player currently has an extra action bar/button.
- flyable — The player can use a flying mount in this zone (though incorrect in Wintergrasp during a battle).
- flying — Mounted or in flight form AND in the air.
- form:0/1/2/.../n or stance:0/.../n — In a form or stance such as , , , , etc.
- group:party/raid — Player is in the given type of group (if argument is omitted, defaults to party).
- harm — Conditional target exists and can be targeted by harmful spells (e.g. ).
- help — Conditional target exists and can be targeted by helpful spells (e.g. ).
- indoors — Player is indoors.
- modifier:shift/ctrl/alt or mod:shift/ctrl/alt — Holding the given key.
- mounted — Player is mounted.
- outdoors — Player is outdoors.
- overridebar — Player's main action bar is currently replaced by the override action bar.
- party — Conditional target exists and is in your party.
- pet:<pet name or type> — The given pet is out.
- petbattle — Currently participating in a pet battle.
- possessbar — Player's main action bar is currently replaced by the possess action bar.
- raid — Conditional target exists and is in your raid/party.
- resting — Player is currently resting.
- shapeshift — Player's main action bar is currently replaced by a temporary shapeshift action bar.
- spec:1/2 — Player's active specialization group (spec, talents and glyphs).
- stealth — Player is stealthed.
- swimming — Player is swimming.
- talent:<row#>/<column#> — Talent is activated.
- unithasvehicleui — Conditional target has vehicle UI.
- vehicleui — Player has vehicle UI.
- @unit or target=unit — Sets the condition target to unit (an arbitrary string, although unitIds may be more useful when combined with some of the other conditionals); always considered satisfied.
- 1 Conditional target
- 2 Details
- 2.1 actionbar:1/.../6
- 2.2 button:1/.../5/<virtual click> or btn:1/.../5/<virtual click>
- 2.3 channeling:<spell name>
- 2.4 equipped:<item type> or worn:<item type>
- 2.5 exists
- 2.6 flyable
- 2.7 form, stance
- 2.8 modifier:shift/ctrl/alt or mod:shift/ctrl/alt
- 2.9 pet:<pet name or type>
- 2.10 talent:<row#>/<column#>
- 3 Action bar overrides
- 4 Patch changes
Some of the macro conditionals return information about the conditional target rather than the player. By default, the conditional target is assumed to be the player's current target, but this may be altered using the
@unit conditional (which is equivalent to the older
target=unit syntax). For example, the following macro prefers to cast on the unit your mouse is over (if it exists and is hostile), but casts if that is not the case:
/cast [@mouseover,harm] Corruption; Life Tap
@mouseover conditional modifies the conditional target to the unit the mouse is over, and the
harm conditional checks if that unit can be attacked.
This can be useful to force specific spells to be cast on a player (e.g. using in conjunction with for a self-heal), or force specific spells to be explicitly targeted even if they can be cast on your current target (by using
@none to force a casting cursor).
Some commands accept units as their parameters. If the conditional target is explicitly specified (and different from the command's "key unit"), it'll override the value of the parameter associated with the conditional. The affected commands and their key units are shown in the table below:
All macro targeting uses UnitIds, the same format the Lua API uses. A list of possible values may be found on that page.
The default UI provides a number of action bar pages. These pages only affect the lower left action bar that is visible by default. Luckily, you can make macros that respond to different action bar pages and place them on the other action bars. One example is for a hunter to emulate stances using their aspects:
/swapactionbar 1 2 /cast [actionbar:1] Aspect of the Hawk; Aspect of the Pack
This macro will switch between action bars 1 and 2. When it switches to bar 1 it casts Aspect of the Hawk, and when it goes to bar 2 it casts Aspect of the Pack.
Similar to [modifier], [button] allows your macro to respond differently based on which mouse button is being used to activate the macro. Button numbers 1-5 correspond to left, right, middle, button 4, and button 5. If your macro is activated by a keybinding, [button:1] will always be true. As an example, here is the macro I use for mounting:
#show Swift Green Mechanostrider /userandom [nobutton:2, flyable, nomounted] Ebon Gryphon; [nomounted] Black Battlestrider, Swift Green Mechanostrider /dismount [noflying] [button:2]
Behavior when not mounted: left-clicking will pick Ebon Gryphon if it can be used (flyable), otherwise it will randomly pick the Black Battlestrider or the Swift Green Mechanostrider. Right-clicking will always pick one of the mechachickens.
Behavior when mounted: left-click will only dismount if not flying. Right-click will always dismount.
The "virtual click" can usually be ignored, but if you use a bar mod it can be useful. Action bars that respond to various state changes translate clicks to virtual ones that determine which action to use. Because these virtual clicks are addon-specific, I'm not going to go into any further detail here.
Normally, if you are channeling a spell and begin casting another spell, it will cancel the channel. This option allows you to keep that from happening, and also has a few other uses. For instance, maybe you do want to cancel one particular spell but not another. [channeling] alone matches any spell and you can also list an arbitrary number of spell names to check.
equipped:<item type> or worn:<item type>
[equipped] allows you to determine if a particular type of gear is equipped. The item type can be an inventory slot name, an item type, or an item subtype. See ItemType and InventorySlotName for lists of these types. Here is the macro I use to pick Shield Bash or Pummel depending on what I've got equipped:
#show [equipped:Shields] Shield Bash; Pummel /cast [equipped:Shields,stance:1/2] Shield Bash; [equipped:Shields] Defensive Stance; [stance:3] Pummel; Berserker Stance
The #show line is used to make it show either Shield Bash or Pummel. Without it, it would show the stance spells as well, when applicable. Here's some pseudocode that illustrates how the second line works:
if a shield is equipped and I'm in Battle or Defensive stance then /cast Shield Bash else if a shield is equipped then /cast Defensive Stance else if I'm in Berserker stance then /cast Pummel else /cast Berserker Stance
Here's another macro that lets you cast Overpower with a bit more vigor:
/equip [noequipped:Two-Handed Axes] Crystalforged War Axe /cast [nostance:1] Battle Stance; [equipped:Two-Handed Axes] Overpower
This determines whether the given unit exists. In other words, if you don't have a target, [exists] will return false. If you have a focus, [@focus, exists] would be true. Note that in some cases [exists] is unnecessary.
[help], [harm], [dead], [party], and [raid] all imply [exists] if they're true.
[flyable] determines whether you are in an area where you're allowed to use a flying mount. There are some exceptions, like Wintergrasp during a battle, where [flyable] would be true even though actual flight is prohibited.
Form is the generic term used for Druid shapeshift, Rogue (Stealth), Priest (Shadowform), Shaman (Ghost Wolf), Warlock Metamorphosis as well as Monk and Warrior stance. Form is only applicable to situations where certain abilities are only usable in specific forms. Because of this, Death Knight presences, Hunter aspects, and Paladin auras are NOT considered forms.
The simplest version, [form], means that you are in any form whatsoever. The more common version is [form:1/2/3/.../n] where n is the number of forms you have. [form:0] and [noform] are functionally the same. Multiple form conditionals can be combined by separating the form number with a diagonal, like [form:0/3], which evaluates as true if you are either in form 3 or not in any form.
The forms and stances themselves are ordered the same way as they appear on your shapeshift bar or stance bar. So a Druid with Bear, Aquatic, Cat, and Travel forms would have forms 1 through 4. Here is a simple chart to help you remember form numbers:
/cast [form:1/3] Mangle; [noform] Wrath
In Bear and Cat forms, this will cast Mangle. In caster form, it will cast Wrath.
The following script will print the form index of the form/stance you're currently on:
modifier:shift/ctrl/alt or mod:shift/ctrl/alt
Modifier keys are a convenient way to save action bar space and make certain decisions. Say you want an implied targeting macro but use one spell normally and another spell when you're holding down a modifier key:
/cast [modifier, help] [modifier, @targettarget, help] Flash Heal; [help] [@targettarget, help] Greater Heal
This macro will cast a helpful spell on either your target if it's friendly, or your target's target otherwise. When you hold any modifier key, it will cast Flash Heal. Otherwise it will cast Greater Heal.
Of course, you can specify particular modifier keys for more control a la [modifier:shift/ctrl] which means "shift or control." If you want to specify both, you need two modifier conditionals: [modifier:shift, modifier:ctrl].
If you need even more specific control over modifiers, you can specify right and left versions of control, shift, and alt by adding "l" or "r" to the modifier. To make a macro that casts Hunter's Mark when the left control button is pressed but casts Feign Death when the right shift button is pressed, you would use:
/cast [modifier:lctrl] Hunter's Mark; [modifier:rshift] Feign Death
If you want to create a macro with one modifier for spell x and two modifiers, where one is the same as for x, for spell y you have to write the two modifiers first:
/cast [modifier:alt, modifier:ctrl, @focus] Chimera Shot; [modifier:ctrl] Arcane Shot; Steady Shot
The negative conditional nomodifier can be useful when only wishing to take a certain effect if you are not using any modifiers. For example, the following macro casts Levitate, unless the shift modifier is being used, in which cast it cancels the Levitate aura. Without the '[nomodifier]' it would simply re-cast Levitate every time.
/cancelaura [modifier:shift] Levitate /cast [nomodifier] Levitate
Beware if you're using keybindings for your macros. If you bind A to a macro with, say, [modifier:shift] and you have something else bound to SHIFT-A, the SHIFT-A binding will take precedence and your macro will not run.
The shorter version of this conditional — mod — may be used to save characters in your macro.
While modifier keys can be any combination of shift, ctrl, or alt, and you may substitute lshift or rshift for shift, lctrl or rctrl for ctrl, and lalt or ralt for alt (you cannot use both left and right variants for a single modifier key TYPE in a single condition) there are a number of system variables that you can use in your modifier conditions as well. For instance, the SELFCAST variable means "whatever your self-cast modifier is set to." The default is alt (holding the alt key while casting a spell will attempt to cast it on yourself) though some addons give you the option to change this. If you create a macro like:
/cast [modifier:SELFCAST, @player] [@mouseover] [ ] Greater Heal
It will work as expected no matter what you have set as your self-cast key. Some other variables and their defaults (though with arguably much less utility) are as follows:
- AUTOLOOTTOGGLE (shift)
- STICKYCAMERA (ctrl)
- SPLITSTACK (shift)
- PICKUPACTION (shift)
- COMPAREITEMS (shift)
- OPENALLBAGS (shift)
- QUESTWATCHTOGGLE (shift)
pet:<pet name or type>
Every class with a pet will find this one useful. It allows you to choose an action based on which pet you have out. You can specify your pet's name or your pet's type (Voidwalker, Boar, Imp, Wolf, etc.). [pet] by itself matches any pet. For example, a Mage can choose between their elemental's Freeze spell or their own Frost Nova:
/cast [pet] Freeze; Frost Nova
If you are not certain of the pet's type, you can run this command after summoning the pet. Do not use this as part of the macro, only for testing:
This conditional evaluates as true if the talent from the specified row and column is active. For example, a Mage can put all the spells on talent row 3 into a macro that will change depending on which is selected:
#showtooltip /cast [talent:3/1] Ring of Frost; [talent:3/2] Ice Ward; [talent:3/3] Frostjaw
Action bar overrides
There are a number of macro conditionals that deal with various mechanics overriding the player's action bar.
|Conditional||Based on||Active during...|
|possessbar||HasBonusActionBar||Mind control, vehicles; e.g. Razorgore the Untamed.|
|shapeshift||HasTempShapeshiftActionBar||The Prophet Tharon'ja transform.|
|extrabar||HasExtraActionBar||Master of Puppets in Dread Wastes|
|bonusbar:x||GetBonusBarOffset||(1), (3), etc.|