I have tried to set my game up so once the enemy are hit they dissapear and stop firing. At the moment the enemy dissapear but you can still see the bullets being fired.
Here is all the code:
load image "media/ai_2_D2.dds",42
MAKE OBJECT CONE 500,50
POSITION OBJECT 500,700,50,-500
XROTATE OBJECT 500,90
FIX OBJECT PIVOT 500
MAKE MESH FROM OBJECT 1,500
TEXTURE OBJECT 500,42
DELETE OBJECT 500
MAKE OBJECT SPHERE 15,4
LOAD IMAGE "textures/red.bmp",41
MAKE MESH FROM OBJECT 2,15
FOR e = 501 to 520
MAKE OBJECT e,1,0
TEXTURE OBJECT e,42
MAKE OBJECT e+1000,2,41
HIDE OBJECT e+1000
AI Add Enemy e
AI Set Entity View Arc e,360,360
AI Set Entity View Range e,1000
NEXT e
FUNCTION enemies()
POSITION OBJECT 501,700,30,-2000
POSITION OBJECT 502,800,30,-1500
POSITION OBJECT 503,1000,30,-2200
POSITION OBJECT 504,1100,30,-1200
POSITION OBJECT 505,2350,30,-650
POSITION OBJECT 506,1700,30,-1500
POSITION OBJECT 507,1800,30,-2000
POSITION OBJECT 508,2000,30,-2300
POSITION OBJECT 509,2300,30,-1450
POSITION OBJECT 510,2450,30,-900
POSITION OBJECT 511,2500,30,-1100
POSITION OBJECT 512,2700,30,-1000
POSITION OBJECT 513,2975,30,-2000
POSITION OBJECT 514,3300,30,-2500
POSITION OBJECT 515,3250,30,-3000
POSITION OBJECT 516,2900,30,-3000
POSITION OBJECT 517,2000,30,-3100
POSITION OBJECT 518,1500,30,-2800
POSITION OBJECT 519,1050,30,-3350
POSITION OBJECT 520,1400,30,-3500
for e= 1501 to 1520
if object exist(e) and shootTimer(e-1000)=0 then hide object e
next e
FOR e = 501 to 520
IF OBJECT HIT(e+1000,2)>0 then health = health - 20
IF OBJECT HIT(4,e)>0 then HIDE OBJECT e : HIDE OBJECT 4 : POSITION OBJECT e,-2000,0,-2000 : killcount = killcount + 1 : PlayerScore = PlayerScore + 1000: SET OBJECT COLLISION OFF e :HIDE OBJECT e+1000 : SET OBJECT COLLISION OFF e+1000
NEXT e
rem Call this command every sync to update entity AI state
AI Update
rem displaying the attck is handled outside the ai system
FOR e = 501 to 520
IF AI Entity Exist(e)=1
IF AI Get Entity Can Fire(e) and shootTimer(e)<=0
rem get the target position and then fire bullet
tx# = AI Get Entity Target X(e)
tz# = AI Get Entity Target Z(e)
x# = OBJECT POSITION X(e)
z# = OBJECT POSITION Z(e)
IF ebulletlife=0
POSITION OBJECT e+1000,X#,Y#+30,Z#
ebulletlife = 100
SHOW OBJECT e+1000
ENDIF
IF ebulletlife>0
DEC ebulletlife
YROTATE OBJECT e+1000, OBJECT ANGLE Y(e)
Move object e+1000,50
IF ebulletlife=0 then HIDE OBJECT e+1000
ENDIF
shootTimer(e)=100
ENDIF
ENDIF
rem control how often the entity can shoot
IF shootTimer(e)>0 then shootTimer(e) = shootTimer(e)-(speed#*15)
NEXT e
ENDFUNCTION
Cant see the problem myself, any help?
Thanks