i have an enemy AI system that works well, but has a few problems. like when his misile gets within a certain range it will home, but then if it gets behind me it will turn aroudn and come back. i dont want it to do taht last part. is there some way that once it's past me it cant home anymore?
enemy AI:
REM enemy ai
pX#=camera position x()
pY#=camera position y()
pZ#=camera position z()
tX#=object position x(26)
tY#=object position y(26)
tZ#=object position z(26)
oldyang#= object angle y(26)
pdist=sqrt((tx#-px#)^2 + (ty#-py#)^2 + (tz#-pz#)^2)
if pdist<1500 and enemybulletlife = 0
position object 31, tx#, ty#, tz#
point object 26, px#, py#, pz#
xrotate object 26, 0
zrotate object 26, 0
yrotate object 26, wrapvalue(object angle y(26)+180)
point object 31, px#, py#, pz#
enemybulletlife = 100
else
yrotate object 26, oldyang#
move object 26, -5
tx# = object position x(26)
tz# = object position z(26)
position object 26, tx#, get ground height(1, tx#, tz#), tz#
if object position z(26)<100
yrotate object 26, 180
endif
if object position z(26)>9900
yrotate object 26, 360
endif
endif
if enemybulletlife > 0 then gosub enemyshootmisile
if enmExplode > 0 then gosub explodetankmisile
enemy shootmisile subroutine:
enemyshootmisile:
enmX#=object position x(31)
enmY#=object position y(31)
enmZ#=object position z(31)
inc enpn
if enpn=321 then enpn=310
Scale object enPn,100,100,100
Position object enPn,enmX#,enmY#,enmZ#
Show object enPn
yrotate object enpn, WrapValue(359-Explode*37)
for x = 1 to 10
scale object int((Wrapvalue((enPn-9+x)*36))/36)+110,100+x*25,100+x*25,100+x*25
set cursor 10,10
next x
Dec enemyBulletLife
move object 31, 50
point object enPn,X#,Y#,Z#
REM updated position variables
enmX#=object position x(31)
enmY#=object position y(31)
enmZ#=object position z(31)
pX#=camera position x()
pY#=camera position y()
pZ#=camera position z()
if enmy#<get ground height(1,enmx#,enmz#) then enemybulletlife = 0
entdist=sqrt((px#-enmx#)^2 + (py#-enmy#)^2 + (pz#-enmz#)^2)
if entdist <20
enemybulletlife = 0
stop music 1
show object 5
load 3dsound "explode3.wav", 1
play sound 1
wait 2000
play music 1
position camera 5000, 1000, 5000
rotate camera 0, 0, 0
play sound 6
misiles=10
fx#=600
enemyscore = enemyscore+1
endif
if entdist <500 and entdist > 250 then point object 31, px#, py#, pz#
if entdist < 500
set cursor 312, 231
ink rgb(500,0,0),rgb(0,0,0)
print "warning"
endif
if enemybulletlife = 0
hide object 31
for x=310 to 320
hide object x
next x
enmExplode = 20
endif
return