Solution: Get the Bearing to the target or location, figure out which direction it is, press the Left/Right key once as needed, with no repetetive key presses, then do a /face when within a 15 degree arc of it being directly ahead of you.
It's very human like, and works pretty damn well.
Code: Select all
| Turn.inc - Created by GD
|
| Usage: #Include it into your current macro, then call it as follows:
|
| To turn towards Target: /call Turn
| To turn towards Location: /call LocY LocX
| IE: /call Turn -460 500
#turbo
Sub Turn(THeadingY,THeadingX)
/declare PHeading local
/declare THeading local
/declare Bearing local
/declare TurnKey local
/declare IsTurning local
:TurnLoop
/delay 0
/if $char(state)=="SIT" /sit off
/varset PHeading $int($char(heading))
/if "$defined(THeadingX)"=="TRUE" {
/varset THeading $int($heading(@THeadingY,@THeadingX))
} else {
/varset THeading $int($target(headingto))
}
/varset Bearing $int($calc($calc(@PHeading-@THeading+540)%360-180))
/if (n @Bearing>=-7 && n @Bearing<=7) {
/if "@TurnKey"!="" /sendkey up @TurnKey
/face heading @THeading nolook
/return
} else /if (n @Bearing>=-180 && n @Bearing>=7) {
/if "@TurnKey"!="RIGHT" /varset TurnKey RIGHT
} else /if (n @Bearing<=180 && n @Bearing<=7) {
/if "@TurnKey"!="LEFT" /varset TurnKey LEFT
}
/if n @IsTurning!=1 {
/sendkey down @TurnKey
/varset IsTurning 1
}
/goto :TurnLoop
/return




