WOW Gold Home --> Targeting

Targeting is another common task in macros. This is accomplished either by using dedicated targeting slash commands which actually change your target or by using the [target=] macro option on commands that accept them. When you use the macro option, you are actually casting the spell or using the item directly on the unit without changing targets. Macro options will be covered in great detail in Part II. For now, I'll show you how to use the targeting commands.

The most basic targeting command (unsurprisingly) is /target. Its use is as simple as
/target Cogwheel/target does a closest match which means if you do /target Cog and I'm standing near you (and no one named Cog is) it will target me. This is a plus or a minus depending on your situation. Unfortunately, it will also target irrelevant units (like corpses). This makes macros like the following much less useful than they might first appear.
/target Blackwing Mage
/cast Curse of AgonyIf no Blackwing Mages are around, this might target someone in your raid who happens to have the letters B and L in their name. While they're safe from the wrath of your curse, it's still a bit disconcerting. Another problem is that it may target something 100 yards behind you that you don't really care about. (Patch 2.3 will add a /targetexact command to eliminate part of the problem.)

In addition to specifying the name of someone you would like to target, you can also provide a unit ID. Unit IDs are a way to identify a particular character, mob, NPC, etc. For instance, your current target can always be accessed by the "target" unit ID (obviously not the most useful for the command we're discussing at the moment :P). You yourself are accessed by the "player" ID, and if you have a pet it would be referenced by "pet." You can also append "target" to the end of any valid unit ID to arrive at that unit's target. There is a joke about Kevin Bacon involving a macro like:
/target targettargettargettargettargettargethttp://www.wowwiki.com/UnitId has a full list of allowed IDs.

Other targeting commands

Here is a brief overview of the other targeting commands:

/assist

By itself, assist targets your target's target (e.g. if you are targeting me, and I'm targeting Iriel, /assist would make you target Iriel). You can also provide a name or unit to /assist and you will assist the specified entity:
/assist Cogwheel There is an interface option which will automatically start you attacking if you end up with a hostile target.

/cleartarget

Leaves you with no target

/targetlasttarget

As the name suggests, this will target your previous target. If you previously had no target, this command will do nothing.

/targetenemy, /targetfriend

These commands cycle through the specified type of unit. /targetenemy is like pressing TAB, and /targetfriend is like pressing CTRL-TAB (in the default key bindings). You can also add a parameter of 1 which reverses the direction of the cycle (/targetenemy 1 is like pressing SHIFT-TAB).

Note: You can only use these commands once per macro.

/targetparty, /targetraid

Cycles through your nearest party or raid members. Like /targetenemy, you can add a 1 to reverse the direction.