I do not remember how much I wrote and how much I ripped off from one macro or another :-). This is simply one of the things in the automatic beastlord macro I compiled for myself once upon a time.
Code: Select all
Sub Check_Behind
/declare strafedir string local
/declare behindIt FALSE
/declare dir int local
/declare delta int local
|- Are we behind our target?
/declare i int local
/if (${Target.Type.Compare["NPC"]}) {
/echo Target (${Target.Name}) is NOT an NPC... abort!
/return
}
/for i -1 to 1
/if (${Target.Type.Compare["NPC"]}) /return
/varcalc dir (${Target.Heading.Clock}+${i})%12
/if (${dir}<1) /varcalc dir ${dir}+12
/if (${dir}>12) /varcalc dir ${dir}-12
/if (${dir} == ${Me.Heading.Clock}) /varset behindIt TRUE
/next i
/if (!${behindIt}) {
|- Which way do we strafe?
/varcalc delta ${Me.Heading.Clock}-${Target.Heading.Clock}
/if (${delta}>6) /varcalc delta ${delta}-12
/if (${delta}<-6) /varcalc delta ${delta}+12
/if (${delta}<0) {
/varset strafedir STRAFE_LEFT
} else {
/varset strafedir STRAFE_RIGHT
}
/echo Getting Behind: Strafing ${strafedir} a half-second...
/keypress ${strafedir} hold
/delay 4
/keypress ${strafedir}
}
/return
Most likely your macro is going to loop until the target is dead. In that loop, do a /call Check_Behind. There isn't really a simple way to do this that I know, because you have to align your character to be facing a certain direction calculated based on the direction the npc is facing.