I assume your sniper starts out facing the optimal direction initially. A small script could do the following:
- Record inital dir sniper is facing.
- Pick a maximum degrees you want sniper to scan from initial dir (say 40 degrees to left and right of center dir).
- Create a gamelogic at the the sniper's position, and setdir it to initial dir of sniper.
- Write loop that:
--setdir dir of gamelogic gradually to scan 40 degrees left, back to center, then 40 degrees right. You could do this in increments of 10 degrees.
--After every setdir change for gamelogic, have sniper watch a position 100 meters in front of game logic:
sniper dowatch (gamelogic modelToWorld [0,0,100]);
Add a nice sleep in there so sniper doesn't change watching positions to often, and terminate the loop if sniper killed, etc.
You may also want to stop loop if sniper's knowsabout enemies is high enough, or his combatmode changes because he sees targets to shoot.