I hope this is good enough
I tweaked it alot

and now the nesting erreo is at the very bottom
at next alienall# next alien2# and next alien#
return:
cls
print "LISTEN UP! soldier we have recieved evidence that an"
print "alien saucer has crashed in the death valley"
print "you are going out with five other teamates to scout the area."
print "If you see anything, you report it back to base."
print "NOW GET OUT THERE"
print
print "(press any key)"
suspend for key
cls
sync on : sync rate 0 : hide mouse
autocam off
for q#=1 to 3
px#=object position x(q#)
py#=object position y(q#)
pz#=object position z(q#)
mp#=get ground height(1,25,25)
mt#=0
st#=0
x#=0
y#=0
z#=0
load object "/documents/darkmatter/models/DB/people/alien hivebrain/h-alien hivebrain-attack1.x",11
load object "/documents/darkmatter/models/DB/people/alien mutant/H-alien mutant-idle.x",14
load object "/documents/darkmatter/models/DB/people/alien psionic/H-alien psionic-attack1.x",12
load object "/documents/darkmatter/models/DB/people/alien rollerbug/L-alien rollerbug-attack1.x",15
load object "/documents/darkmatter/models/DB/people/android/h-android-attack1.x",13
load sound "/documents/media/sounds/weapons/shotgun.wav",2
load sound "/documents/media/sounds/weapons/machngun.wav",1
load sound "/documents/media/sounds/weapons/shoot.wav",3
load#=0
cls
set text size 200
do
text 170,150,"LOADING"
wait 400
text 170,150,"LOADING."
wait 400
text 170,150,"LOADING.."
wait 400
text 170,150,"LOADING..."
wait 400
inc load#
cls
if load#=7
print "(press any key to continue)"
suspend for key
cls
exit
endif
loop
print "All at once every thing went wrong."
print "four of my temates were killed and,"
print "one went missing"
print "I gotta get out of here!"
print "*bzzzz,bzzz,bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
print "com link disconnected"
cls
load bitmap "documents/help/fast/caverun/tiles.bmp",1
get image 1,0,0,256,256
delete bitmap 1
for matrix#=200 to 300
make matrix 1,5000,5000,25,25
prepare matrix texture 1,1,4,4
fill matrix 1,100,10
randomize matrix 1,matrix#
next matrix#
gosub monsterbullet
make object cone 17,2
rotate object 17,100,0,0
hide object 17
make object cone 18,2
rotate object 18,100,0,0
hide object 18
make object sphere 4,2
hide object 4
load object "/documents/myproj/swarm/obj/ship.x",5
rotate object 5,100,0,0
ghost object on 5
hide object 5
make object box 6,2,2,100
scale object 6,100,200,2
make object box 7,2,2,100
scale object 7,100,200,2
rotate object 7,0,0,100
hide object 6
hide object 7
make object sphere 7,2
scale object 7,50,50,1
position object 7,0,2.2,-9
color object 7,rgb(255,0,0)
make object sphere 8,25
scale object 8,10,10,1
ghost object on 7
ghost object on 8
hide object 8
ak47:
shotbuffer=timer()
shotdelay=0
delete object 3
load object "/documents/darkmatter/models/DB/weapons/ak47/H-ak47-static.x",1
make object sphere 5,2
show object 5
position object 5,x#+1,y#,z#+500
set object to object orientation 5,1
ammo=100
reload1=4
yrotate object 1,10
position object 1,x#+1,y#,z#-2
scale object 1,500,500,500
if mouseclick()=1 and bulletlife=0
position object 20,x#+1,y#,z#-2
set object to object orientation 20,1
bulletlife=25
show object 20
endif
if bulletlife>0
dec bulletlife
move object 20,30000000000
if bulletlife=0 then hide object 20
for crazy=0 to 10
point object 20,rnd(crazy),rnd(crazy),z#-2
next crazy
endif
if shiftkey()=1 then dec reload1 : ammo=200
if mouseclick()=1 and (timer()-shotbuffer> shotdelay) and (ammo > 0)
dec ammo#
play sound 1
endif
return
woddle:
if move#>0
walkha#=wrapvalue(walkha#+16.0)
else
walkha#=curveangle(0.0,walkha#,5.0)
endif
walkha#=(cos(walkha#)*4.5)
return
gosub health
dim HP#(10)
dim alienhivebrain#(10)
dim alienmutant#(5)
dim psionic#(5)
dim alienrollerbug#(15)
dim android#(2)
dim burst#(10)
alienhivebrain#=object exist(11)
alienmutant#=object exist(14)
psionic#=object exist(12)
alienrollerbug#=object exist(15)
android#=object exist(13)
gosub alienAI
sync on : hide mouse : sync rate 0
fog on
fog color rgb(150,150,150)
fog distance 1000
do
for all#=19 to 21
move#=0
if inkey$()="w" and move#<10.0 then move#=move#+10.0 :gosub angle
if inkey$()="s" and move#>-10.0 then move#=move#-10 : gosub angle
if inkey$()="a" then move#=move#+3 : wrap#=wrapvalue(wrap#-5)
if inkey$()="d" then move#=move#+3 : wrap#=wrapvalue(wrap#+5)
move camera move#
rotate camera wrap#,0,0
cy#=wrapvalue(cy#+mousemovey())
cx#=wrapvalue(cx#+mousemovex())
rotate camera cx#,cy#,0
gosub ammo
gosub woddle
if spacekey()=1
jump#=0
position camera px#,mp#+5,pz#
inc jump#
endif
curve#=curvevalue(x#,curve,10)
if jump#=5 then position camera px#,curve#,pz#
if curve#=10
position camera px#,py#-curve#,pz#
if curve#=0 then position camera px#,py#-5,pz#
endif
if object collision(13,alienall) then gosub alienhealth
gun=0
if mouseclick()=2 then inc gun
if gun>2 then gun=0
if mouseclick()=2 and gun=2 then gosub shotgun
if mouseclick()=2 and gun=1 then gosub tommy
if mouseclick()=2 and gun=0 then gosub ak47
lock object on q#
gosub box
next q#
sync
loop
shotgun:
delete object 1
make object sphere 19,2
load object "/documents/darkmatter/models/DB/weapons/shotgun/H-shotgun-static.x",2
show object 6
show object 7
position object 6,x#+1,y#+1.2,z#-6.3
position object 7,x#+1,y#+1.2,z#-6.3
set object to object orientation 6,2
set object to object orientation 7,2
shotdelay=1000
ammo=20
reload2=3
yrotate object 2,10
position object 2,x#+1,y#+1.2,z#-6.3
scale object 2,500,500,500
burst#(p#)=object exist(19)
for bam#=0 to 90
for o#=1 to 10
if mouseclick()=1 and bulletlife=0
position object 19,x#+1,y#+1.2,z#-6.3
bulletlife=25
show object 19
endif
if bulletlife>0
dec bulletlife
point object burst#(o#),bam#,bam#,pz#
move object burst#(o#),30000000000
endif
next bam#
next o#
if bulletlife=0 then hide object 19
if shiftkey()=1 then dec reload2 : ammo=20
if mouseclick()=1 and (timer()-shotbuffer> shotdelay) and (ammo > 0)
dec ammo
play sound 2
endif
return
tommy:
for e=1 to 2
delete object 2
load object "/documents/darkmatter/models/DB/weapons/tommy/H-tommy-static.x",3
show object 9
show object 10
position object 9,x#+1,y#-.2,z#+20
set object to object orientation 10,3
set object to object orientation 9,3
shotdelay=300
ammo=100
reload3=5
yrotate object 3,10
scale object 3,500,500,500
position object 3,x#+1,y#-.2,y#-1
if mouseclick()=1 and bulletlife=0
position object 21,x#+1,y#-.2,z#-1
set object to object orientation 21,3
bulletlife=25
show object 21
endif
if bulletlife>0
dec bulletlife
move object 21,30000000000
if bulletlife=0 then hide object 21
endif
if shiftkey()=1 then dec reload3 : ammo=100
if mouseclick()=1 and (timer()-shotbuffer> shotdelay) and (ammo > 0)
play sound 3
dec ammo#
endif
return
ammo:
if reload1=0 then hide object 19
if reload2=0 then hide object 20
if reload3=0 then hide object 21
if reload1<0 then reload1=0
if reload2<0 then reload2=0
if reload3<0 then reload3=0
return
alienAI:
for alien#=11 to 13
for alien2#=14 to 15
for alienall#=11 to 15
function enemymove(alienall)
yr#=rnd(360)
if mt#<0 then mt#=0
if mt#<1 then st#=st#-.1
if mt#<1 and mt#>0 then st#=10
if st#<0 then st#=0
if mt#=0 and st#>0 then move object alienall#,0
if mt#=0 and st#=0
yrotate object alienall#,yr#
mt#=rnd(10)
endif
if mt#>0 then move object alienall#,2
if mt#>0 then loop object alienall#
if mt#>0 then mt#=mt#-0.1
endfunction
position object alienall#,rnd(200),mp#,rnd(200)
sight=static line of sight(px#,py#,pz#,-100,25,300,5,1)
PDist=Sqrt((mX# - x#)^2 + (mY#+25 - y#)^2 + (mZ# - z#)^2)
if PDist<1500 and sight=1 then gosub monstershoot_bullet
monstershoot_bullet:
rotate object alienall#,px#,py#,pz#
point object alienall#,px#,py#,pz#
append object "/documents/darkmatter/models/DB/people/alien mutant/H-alien mutant-move.x",14,1
append object "/documents/darkmatter/models/DB/people/alien rollerbug/L-alien rollerbug-move.x",15,1
if PDist<1500 then move object 14,4: loop object 14
if PDist<1500 then move object 15,5: loop object 15
append object "/documents/darkmatter/models/DB/people/alien rollerbug/L-alien rollerbug-attack1.x",15,1
append object "/documents/darkmatter/models/DB/people/alien mutant/H-alien mutant-attack1.x",14,1
if PDist<2 then loop object 14
if PDist<2 then loop object 15
set object to object orientation 16,alien#
bulletlife=25
show object 16
if bulletlife>0
dec bulletlife
move object 16,30000000000
if bulletlife=0 then hide object 4
if PDist>1500 then return
for lookx#=0 to px#
for looky#=0 to py#
for lookz#=0 to pz#
if sight=0
text 475,0,"enemies cannot see you"
rotate object alienall#,lookx#,looky#,lookz#
point object alienall#,lookx#,looky#,lookz#
move object alienall#,1(lookx#,looky#,lookz#)
timer=timer()
timer=5000
if timer()=timer then return
else
if sight=1 then text 475,0,"enemies can see you!"
endif
next lookx#
next looky#
next lookz#
monsterbullet:
make object sphere 16,2
ghost object on 16
color object 16,rgb(0,255,0)
return
angle:
around=0
if around>360 then around=360
if around<-360 then around=-360
return
health:
for p#=1 to 10
make object box HP#(p#),2,2,2
scale object HP#(p#),4,5,1
color object HP#(p#),rgb(0,0,255)
HP#=object exist(p#)
position object HP#(1),-2.4,1.7,0
position object HP#(2),-2.3,1.7,0
position object HP#(3),-2.2,1.7,0
position object HP#(4),-2.1,1.7,0
position object HP#(5),-2,1.7,0
position object HP#(6),-1.9,1.7,0
position object HP#(7),-1.8,1.7,0
position object HP#(8),-1.7,1.7,0
position object HP#(9),-1.6,1.7,0
position object HP#(10),-1.5,1.7,0
load object "/documents/darkmatter/models/DB/people/SWAT/h-swat-die.x",23
hide object 23
cube=11
if object collision(q#,16)
dec cube,1
hide object p#(cube)
ink 0,rgb(255,255,255)
else
ink rgb(255,255,255),0
endif
if cube=0
position camera px#,py#,pz#-10
show object 23
position object 23,px#,py#,pz#
delete object 1
delete object 2
delete object 3
play object 23
gosub restart
endif
return
alienhealth:
for hive#=1 to 10
if PDist<1500(hivebrain#(hive#))
append object "/documents/darkmatter/models/DB/people/alien hivebrain/h-alien hivebrain-die.x",11,1
aHP#=2
if object hit(19,11) then dec aHP#
if object hit(20,11) then dec aHP#,2
if object hit(21,11) then dec aHP#
if aHP#=0 then play object 11
endif
next hive#
for psion=1 to 5
if PDist<1500(psionic#(psion#))
aHP=10
append object "/documents/darkmatter/models/DB/people/alien psionic/H-alien psionic-attack1.x",12,1
append object "/documents/darkmatter/models/DB/people/alien psionic/H-alien psionic-impact.x",12,1
make object sphere 22,100
scale object 22,200,200,200
hide object 22
set object collision on 22
if object hit(19,22)
show object 22
ghost object on 22
fade object 22,20
hide object 22
dec shield#
endif
if shield#=0 then set object collision off 22
if shield#=0 and object hit(19,12) then dec aHP#,2 : play object 12
if shield#=0 and object hit(20,12) then dec aHP#,.5
if shield#=0 and object hit(21,12) then dec aHP#,3
if aHP#=0 then play object 12
endif
next psion#
for android1#=1 to 2
if PDist<1500(android#(android1#))
aHP#=30
append object "/documents/darkmatter/models/DB/people/android/h-android-attack1.x",13,1
append object "/documents/darkmatter/models/DB/people/android/h-android-impact.x",13,1
if object hit(20,13) then dec aHP#,.1
if object hit(19,13) then dec aHP#,2 : play object 13
if object hit(21,13) then dec aHP#,3
if aHP#=o then play object 13
endif
next android1#
for mutant#= 1 to 5
if PDist<1500(alienmutant#(mutant#))
aHP#=15
append object "/documents/darkmatter/models/DB/people/alien mutant/H-alien mutant-attack1.x",14,1
append object "/documents/darkmatter/models/DB/people/alien mutant/H-alien mutant-impact.x",14,1
if object hit(20,14) then dec aHP#
if object hit(19,14) then dec aHP#,10 : play object 14
if object hit(21,14) then dec aHP#,3
if aHP#=0 then play object 14
endif
next mutant#
for roller#=1 to 15
if PDist<1500(alienrollerbug(roller))
aHP=1
append object "/documents/darkmatter/models/DB/people/alien rollerbug/L-alien rollerbug-attack1.x",15,1
if object hit(all#,15) then dec aHP
endif
if HP#=0 then play object 15
next roller#
if aHP=0 then position object alienall,rnd(200),mp#,rnd(200)
return
restart:
cls
show mouse
mouse#=mousex()
mouse1#=mousey()
set text size 100
center text 320,0,"TRY AGAIN?"
text 320,240,"yes"
text 320,235,"no"
if mouse1#=320 and mouse#=340
ink rgb(0,255,0),1
if mouseclick()=1 then goto return
endif
if mouse#=320 and mouse1#=235
ink rgb(255,0,0),2
if mouseclick()=1 then end
endif
box:
for bluebox#=24 to 27
make object cube 24,50
make object cube 25,50
make object cube 26,50
make object cube 27,50
color object bluebox#,rgb(0,0,255)
if reload1=4 then set object collision off bluebox#
if reload2=3 then set object collision off bluebox#
if reload3=5 then set object collision off bluebox#
if object collision(q#,bluebox#)
delete object bluebox#
inc reload1#,2
inc reload2#,2
inc reload3#,3
position object bluebox#,rnd(200),mp#,rnd(200)
endif
next bluebox#
return
next alienall#
next alien2#
next alien#

