Is there a way to select only enemies already in combat via macro?


switches to the next enemy (like the TAB-Key)

As far as I know there is no condition to check if it is in combat.

There is an API call to test it:

affectingCombat = UnitAffectingCombat("unit");

Is this usable in Macros?

  • Probably not, since it would make writing assisting bots even easier to use.
    – Mario
    Nov 27, 2014 at 9:18

2 Answers 2


You can't use a simple command in macros to check this condition. The only conditional check for whether something is in combat or not is [combat] or [nocombat] and this only checks whether the player is in or out of combat.

You can however call scripts with a macro but of course you'll have an annoying character limit.

The commant /run or /script allows you to execute commands in the WoW scripting language through a macro.

I'm not very familiar with the language itself (maybe you'll find more information on GameDev.SE) but it certainly is possible to achieve this through a macro although it might be more effective to write a small add-on.

Now as I said. I don't know a lot about the WoW scripting language but I could imagine that the macro looks something like this:

/run if UnitAffectingCombat("nearestenemy") == true then TargetNearestEnemy(); end

Here you can find the article of WoWwiki about using scripts in macros.

  • If the character limit is a problem for your macros, you can actually make a macro call another one to extend your text limit. You have to put the second macro on an action button and make the first macro "click" that button with the following command : /click NameOfActionButton
    – Shunwoo
    Nov 27, 2014 at 11:38
  • There is also an Addon called BindPad that internally stores its own macros that may not have the same character limit.
    – user73272
    Nov 27, 2014 at 19:00
  • @Shunwoo You wouldnt need a click NameofActionButton if you keybind.
    – Virusboy
    Nov 28, 2014 at 18:37
  • @Virusboy why wouldn't you? And I didn't say that the second one was keybinded, just that it was on a bar.
    – Shunwoo
    Dec 1, 2014 at 8:31

Added some correctness to Jutschge's answer ;)

/run local a=0;TargetNearestEnemy();while (UnitAffectingCombat("target")~=true and a < 10) do TargetNearestEnemy();a=a+1;end

I added a try number limit to 10 too, to avoid infinite loop.

  • Correct, but sadly Blocked by Blizzard for Macros. But Thanks anyway. Dec 10, 2014 at 12:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .