Writing a World of Warcraft Macro


I wrote my first macro as a level 20 druid. It was a complete disaster. I couldn’t quite figure out how to make it work and unable to fix it, I decided that copy and paste were very useful features. It was such an easy solution, that I shelved my idea of writing my own macros – why reinvent the wheel?

Turns out that not all macros I would like to have has been written. Or written in the exact way I would like to make it work. So I began tweaking a little. Reading macros that others have written is not that difficult to figure out. It’s quite obvious what most things are suppose to help you do and so I started changing a little to see what happens. Mostly what happened was that my macro stopped working. Mhm. Time to do more research.

I picked up my copy of Gilbert & Whitehead’s Hacking World of Warcraft as the internet seemed to lack a concise, yet ‘for dummies’ guide on how to write a marco. As is the norm with books, they tend to be a little out of date, the book was published in June 2007, but the forward slash command system is still the same, so the basics are very sound. It was an interesting read written in a language I can understand. It made it obvious that macros can be more straightforward to write than they seem to be at first glance for someone with little or no experience.

Easy macros, how to go about it:

1. Type /macro then select ‘new’ in the pop up box.

2. Enter the name of the macro and select the ? icon if you want the macro to automatically populate the box with the icon of the spell, otherwise select your icon from the list. Then click ‘okay’.

3. In the macro box, type the first line of code – this line is optional and can be left out. It’s a choice of either:

#showtooltip <spellname>     or     #show <spellname>

The first option will show in the tooltip the name of the spell, the icon of the spell and the cooldown of the spell. The second option will show in the tooltip the name of the macro, the icon of the spell and the cooldown of the spell.

4. Type in your macro by customizing the standard line of:

/<command> [condition1, condition2, etc] spell or name ; [condition1, condition2, etc] spell or name

This is the most useful piece of information I have come across. I can make a macro as simplistic or as complicated as I’d like by added more conditions and more options. Also, conditions are optional and can be left out entirely. A simple macro will be something like /target snobold, where there is a command, no conditions and the name of the target. A complicated macro can have multiple conditions – as many as you can fit in the the code length restriction on a macro – and more than one option. Simply use the formula above and insert your choice of command, your choice of multiple conditions, followed by the spell or item name. More details on this step here.

5. /stopcasting If a spell does not trigger the global cooldown, you have to add this command or your macro will not work. Do not add if the spell triggers the global cooldown. You can check whether the global cooldown is triggered by watching your action bar when you cast a spell. If the little clock tick-down is triggered across multiple buttons, the global cooldown has been triggered. If the above is not a spell, like /target snobold, there is no global cooldown.

6. This step can only be added if the spell in step four does NOT trigger the global cooldown. If it does, you’re macro is complete at step 4, otherwise, another line can be included here. Again it’s:

/<command> [condition1, condition2, etc] spellname ; [condition1, condition2, etc] spellname

And that’s all there is to it. There is a slightly more advanced alternative to the usual /cast macro, which is /castsequence used for spell rotation and it comes with a slightly tricky add that allows macro reset based on various options, but that’s a different blog post altogether. If the spell /item affected by this command line doesn’t trigger the global cooldown, you can add another set of instructions, in fact you can add as many as you can squeeze in.

A couple of pointers

  • A macro can only be used to cast a single spell per button click. The exception that proves the rule is that a spell that does not trigger the global cooldown doesn’t count. It can be used to cast different spells every time you click the same but via spell rotation, but it can’t cast two spells with one click.
  • In step 4 and 6: The comma’s separating the conditions is interpreted as a plus so that all conditions must be met before the spell will be cast.
  • In step 4 and 6: The ; denotes a step-by-step process. If the conditions for the first step is met, the spell will be cast and the macro is finished. If the conditions aren’t met, it will move past step 1 onto step two and look at the conditions in the second step and if those conditions are met, the spell will cast and the macro is finished. You can include as many steps as you like, but each adds a layer of complexity to your macro. If none of the conditions are met, you’ll get an error message and no spell cast. If no conditions are set, the spell will automatically cast.

UPDATE: If you are after a macro guide, wowwiki has some useful pages, including UI beginner’s guide (explaining the differences between a macro, script and addon) and Making a macro, list of macro API fuctions. The wow forums also have a UI and interface forum: EU / US. If you have your macro already or have experimented with conditions and commands to your heart’s content, plug it into Fitzcairn’s Macro Explain-o-matic to see if it does what you think it will do.