Ok, I got an example code here to show a basic idea of what is happening. So the deal is: the first time before any restart, the enemies have a further following distance. When it's restarted, that following distance is shoter by about half as much.
beginning:
sync on
sync rate 60
autocam off
ai start
position camera 0,250,0
point camera 0,0,0
make object sphere 1,10
ai add player 1
enemy#=3
for e=2 to enemy#
make object cube e,10
ai add enemy e
ai set entity view range e,500
ai set entity speed e,75
ai set entity can roam e,1
ai set entity can strafe e,1
ai set entity aggressive e
ai set entity attack distance e,100
position object e,0,0,10
next e
ai set radius 5
do
if upkey()=1 then move object 1,1
if downkey()=1 then move object 1,-1
if leftkey()=1 then move object left 1,1
if rightkey()=1 then move object right 1,1
if spacekey()=1 then gosub mediaflush
text 0,0,"Press spacekey to restart."
text 0,20,"Use arrowkeys to move."
text 0,40,"Enemy 1 distance: "+str$(distance(1,2))
text 0,60,"Enemy 2 distance: "+str$(distance(1,3))
ai update
sync
loop
mediaflush:
for x=1 to 30000
if object exist(x) then delete object x
next x
flush video memory
ai reset
goto beginning
return
function distance(obj1,obj2)
xx#=(object position x(obj2)-object position x(obj1))*(object position x(obj2)-object position x(obj1))
yy#=(object position y(obj2)-object position y(obj1))*(object position y(obj2)-object position y(obj1))
zz#=(object position z(obj2)-object position z(obj1))*(object position z(obj2)-object position z(obj1))
distance=sqrt(xx#+yy#+zz#)
endfunction distance