if u have studied the distance function and have a variable that determines how far away each ship is to the player ship then u can start to set certain AI criteria.
Imagine if the enemy radar could detect your ship within 500 units or something, this would be a distance condition to make the ship turn and move towards the player.
If the enemy ship was smart enough it would try to avoid u if it was low on a hitpoint variable.
A combination of these attributes gives u a good base start to work with.
In this example we are using a distance function and DBS internal collision functions but we dont need to rely on them its just there in case u need it.
` -----------------------------
` indis distance help script
` 2002 db1 v1.11
`
` a simple test of distance
` -----------------------------
cls
sync rate 0
sync on
randomize timer()
set text font "verdana"
set text size 14
make matrix 1,500,500,10,10
position matrix 1,-250,0,-250
make object cube 1,10
position object 1,0,0,0
make object cube 2,10
position object 2,0,0,100
position camera 0,200,-300
point camera 0,0,0
do
if upkey() = 1
position object 1,object position x(1),object position y(1),object position z(1)+1
endif
if downkey() = 1
position object 1,object position x(1),object position y(1),object position z(1)-1
endif
obj1x# = object position x(1)
obj1y# = object position y(1)
obj1z# = object position z(1)
obj2x# = object position x(2)
obj2y# = object position y(2)
obj2z# = object position z(2)
point camera object position x(1),object position y(1),object position z(1)
dist# = getdist(obj1x#,obj2x#,obj1y#,obj2y#,obj1z#,obj2z#)
if dist# < 30
text 10,90,"30 units or and less"
set object collision on 1
if object collision(1,2)=1
text 10,120,"collide"
set object collision on 1
endif
set object collision off 1
endif
text 10,10,STR$(dist#)
text 10,50,STR$(screen fps())
sync
loop
function getdist(obj1x#,obj2x#,obj1y#,obj2y#,obj1z#,obj2z#)
distance# = SQRT((obj1x#-obj2x#)^2+(obj1y#-obj2y#)^2+(obj1z#-obj2z#)^2)
endfunction distance#