here's one way of doing it. basicly it finds the direction the enemy is in from the player, turns the ai away from the player, and moves the ai away, same type of thing could easily be done make the ai follow the player.
`setup
sync on : sync rate 0 :
color backdrop rgb(0,0,128) : hide mouse
set text font "tocoma" : set text size 12 : set text transparent
close$="close!!!"
`make stuff
make object cube 1,20
color object 1,RGB(203,33,75)
make object cube 2,20
color object 2,RGB(230,164,40)
position object 2,50,0,100
`spheres to give the effect of moving instead of just blue
for b=3 to 500
make object sphere b,rnd(20)
color object b,rnd(16000000)
position object b,rnd(5000),0,rnd(5000)
next b
ai_turn_speed#=5.0
ai_move_speed#=2.0
`main loop
do
`movement
px#=object position x(1)
py#=object position y(1)
pz#=object position z(1)
ex#=object position x(2)
ey#=object position y(2)
ez#=object position z(2)
if upkey()=1 then dec px#,.7
if downkey()=1 then inc px#,.7
if leftkey()=1 then dec pz#,.7
if rightkey()=1 then inc pz#,.7
position object 1,px#,py#,pz#
`camera
point camera px#,py#,pz#
position camera px#+50,py#+300,pz#
dist#=int(sqrt(((px#-ex#)*(px#-ex#))+((pz#-ez#)*(pz#-ez#))))
`ai kinda thing. if the player gets to close the enemy will
`point a tthe player move away at the opposite angle
if dist# < 100
text 320,240,close$
color object 2,RGB(81,176,187)
angle#=object angle y(2)
target_angle#=wrapvalue(atanfull(px#-ex#,pz#-ez#))
turn_angle#=wrapvalue(target_angle#-angle#)
if turn_angle#>180 then dec turn_angle#,360
if turn_angle#>0
yrotate object 2,angle#-ai_turn_speed#
endif
if turn_angle#<0
yrotate object 2,angle#+ai_turn_speed#
endif
move object 2,ai_move_speed#
endif
PRINT DIST#
sync
loop
-----------------------------------
To delete the bug, delete the code.
Specs: Sony VAIO Laptop, Windows XP, P4 2.8Ghz, 512MB RAM, ATI Radeon 64MB video memory, DBP Upgrade 5.3.