Target range macro

Is it possible to make a macro that if a target isn’t within let’s say 10 yards it won’t auto attack?

Ie I’m using a Dk unholy macro and I’m finding after the mob dies my macro will target the next mob and dot it and I end up pulling. I can avoid this buy stopping the macro early in the fight when the target gets to 10% health but then my dps also suffers.

in my head it’s something like /range check [within 10 yard] attack.
/range check [more than 10 yards] cancel attack, in the premacro box.
Or would it be something like /cast [only attack within range 10 yards]

But I’m only a learner with macro all help appreciated

You can just remove the auto attack from the macro

That would destroy half the efficiency of the macro

Try maybe adding a [combat] modifier to just after your /cast or /castsequence so:
/cast [combat] your spell here
and it shouldn’t fire off until combat is initiated. Hope this helps.

Thanks mystical I was going to give the combat one a. Try after work today as I’ve seen a few warlock macros with that to stop there pets roaming

You’re welcome, sir.

And there’s also addons and WeakAura’s for a Range Indicator. The one I use (RangeDisplay addon) as a ranged DPS (Hunter) it tells me how far a target is away in yards at the bottom of my cursor in real time. It’s pretty handy sometimes. Also, It can be used for a healer as well so see if Durpy the Warrior is in range to throw a heal at.

hmm still appears to be pulling the nextmob/pac/whatever

Fixed it. It’s not a macro persay but part of gse.in options under general you can select

Require target to use.
This option prevents macros firing unless you have a target. Helps reduce mistaken targeting of other mobs/groups when your target dies.

Ive tested it with none aggressive mobs and aggressive very close by and it won’t auto target unless I click on the target or grip it in which is boom exactly what I wanted. No more pulling mobs in dungeons.

Adding the [combat] I’m unsure if making a different but I have it now just incase lol I think it was outbreak that was Pulling the mobs as it was set in the macro to constantly refresh so it was hitting anything within range. But now I can stand virtually next to a target with the macro running and it won’t hit off unless I target