TGC Codebase Backup



Operation Genocide(alienware 10th place) source code by dark coder

7th Mar 2004 19:11
Summary

alienware competition 10th place operation genocide fps



Description

all the source code for operation genocide,

if you wish to have the media, http://atmospherestudios.com/Operation Genocide release.rar

however it has been modified, so its not quite as usable basically, so you dont claim it as your own :-P



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    set display mode 800,600,32
autocam off
sync on
hide mouse
disable escapekey
dim sav(31)
health=100
dim shell(2,5)

dim guns(10)


top:

gun=1
message=0
aliengog=0
player__oldx#=0
player__oldy#=0
player__oldz#=0
player__x#=0
player__y#=0
player__z#=0
cx#=0
cy#=0
acx#=0
acy#=0
al=0
messgeend=0
position camera 0,0,0
rotate camera 0,0,0

ink rgb(255,255,255),1

load object "map/office.3ds",1

sel=1

if dop=0
 load music "music/mmus.mid",1
 play music 1
 loop music 1
endif

load image "map/scrn.bmp",70
load image "2d/cred.png",71

do

dec waitforturn

if options=1
if waitforturn<0
if returnkey()=1 : options=0 : waitforturn=10 : endif
endif



 texture limb 1,38,71
else
 texture limb 1,38,70
endif

llg=0

if dop=1

CLEAN_SWEEP()

load image "2d/load.png",7000
draw to front
paste image 7000,0,0
lev=lev+1

exit

endif

if wait<5
if options=0
  if leftkey()=1 : sel=sel-1 : wait=25 : endif
  if rightkey()=1 : sel=sel+1 : wait=25 : endif
endif
endif
dec wait

if sel>6 then sel=1
if sel<1 then sel=6

msg1$="<  NEW GAME  >"
msg2$="<  PRACTICE  >"
msg3$="<  CREDITS  >"
msg4$="<  EXIT  >"
msg5$="<  SAVE  >"
msg6$="<  LOAD  >"

if waitforturn<0
if sel=1
 set cursor (400-(len(msg1$)/2)*10),100
 print msg1$
 if returnkey()=1

 CLEAN_SWEEP()
dim guns(10)
lev=1
load image "2d/brief.png",7000
health=100
draw to front
paste image 7000,0,0
exit

 endif
endif
endif

if waitforturn<0
if sel=2
health=100
 set cursor (400-(len(msg2$)/2)*10),100
 print msg2$

 if returnkey()=1

 CLEAN_SWEEP()
dim guns(10)
lev=0
load image "2d/practice.png",7000
draw to front
paste image 7000,0,0
exit

 endif
endif
endif

if waitforturn<0
if sel=3

if returnkey()=1 : options=1 : waitforturn=10 : selection=1 : endif
if options=0 then set cursor (400-(len(msg3$)/2)*10),100
if options=0 then print msg3$

endif
endif

if sel=4
 set cursor (400-(len(msg4$)/2)*10),100
 print msg4$
  if returnkey()=1 : CLEAN_SWEEP() : end : endif
endif

if waitforturn<0
if sel=5
 set cursor (400-(len(msg5$)/2)*10),100
 print msg5$

 if returnkey()=1 : save array "files/sav",sav(0) : sv=1 : endif
endif
endif

if sel=5
else
sv=0
endif

if sv=1
set cursor 364,150
print "saved"
endif

if waitforturn<0
if sel=6
 set cursor (400-(len(msg6$)/2)*10),100
 print msg6$
 if returnkey()=1 : CLEAN_SWEEP() : dim guns(10) : load array "files/sav",sav(0) : llg=1 : load image "2d/load.png",7000 : draw to front : paste image 7000,0,0 : exit : endif
endif
endif

if sel=1 : cx#=17 : cy#=89 : ax#=5 : ay#=10 : az#=11 : endif
if sel=2 : cx#=21 : cy#=113 : ax#=9 : ay#=13 : az#=-4 : endif
if sel=3 : cx#=45 : cy#=175 : ax#=3 : ay#=13 : az#=0 : endif
if sel=4 : cx#=9 : cy#=268 : ax#=2 : ay#=10 : az#=-5 : endif
if sel=5 : cx#=59 : cy#=265 : ax#=-9 : ay#=10 : az#=8 : endif
if sel=6 : cx#=52 : cy#=281 : ax#=-9 : ay#=10 : az#=16 : endif

if options=1 : cx#=359.7 : cy#=72.9 : ax#=12.38 : ay#=9.42 : az#=13.97 : endif

cx#=curveangle(cx#,camera angle x(),10)
cy#=curveangle(cy#,camera angle y(),10)

ax#=curvevalue(ax#,camera position x(),10)
ay#=curvevalue(ay#,camera position y(),10)
az#=curvevalue(az#,camera position z(),10)


rotate camera cx#,cy#,0
position camera ax#,ay#,az#


sync
loop


draw to front
paste image 7000,1,2




if llg=1 then lev=sav(31)
`====================================================================================================================
`====================================================================================================================
`====================================================================================================================
`====================================================================================================================

`====================================================================================================================
`====================================================================================================================
`====================================================================================================================

`====================================================================================================================
`====================================================================================================================

`==================================================================================================================== load in alien sfx
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== camera + setup code
if lev<2
set camera range 1,10000000
else
set camera range 1,3000
endif

if lev=11 then set camera range 1,10000000

sync on
set camera rotation zyx
set cursor 0,0
sync rate 60
autocam off
hide mouse

med:
undim MasterObjNo(1)
if med=1 then CLEAN_SWEEP()
med=0
CollisionObjNo=0
player__oldx#=0
player__oldy#=0
player__oldz#=0
player__x#=0
player__y#=0
player__z#=0
cx#=0
cy#=0
acx#=0
acy#=0
al=0
position camera 0,0,0
rotate camera 0,0,0

`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== scope in + out images+models

Dim MasterObjNo(1) : MasterObjNo(0) = 9999

paste image 7000,0,0
`-=-=-=-=-=
load image "2d/scope.png",775
load image "2d/scope2.png",774
load image "2d/scope3.png",773
make object plain 775,8,6
lock object on 775
position object 775,0,0,4.9
texture object 775,775
ghost object on 775

hide object 775

load image "2d/scoper.png",776
make object plain 776,8,6
lock object on 776
position object 776,0,0,4.9
texture object 776,776
`ghost object on 776
set object 776,1,0,0,1

hide object 776
`--=--=-=-= crosshair loading

load image "2d/xhair.bmp",10
load image "2d/xhair2.bmp",11

load object "3d/sky02.3ds",199
scale object 199,1000000,1000000,1000000
SET OBJECT 199,1,0,0,0,0,0,0
if lev>1 then hide object 199
if lev=11 then show object 199
`                                                                 __
`==============================================    /   /  /  /  /   
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X   /---/  /  /  /    /
`==============================================  /   /  /__/  /____/

load image "2d/gui.png",1

make object plain 1,.7,.27
lock object on 1
texture object 1,1
position object 1,1.25,-1.07,2
ghost object on 1
set object 1,1,1,0,0,0,0

make object plain 2,0.70,0.04
lock object on 2
position object 2,0,0,2.1
ghost object on 2

set text font "arial"
set text size 20
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== guns stuffs
for i=1 to 10

make object sphere 1099+i,0.6

next i


load object "3d/p99wf.3ds",12
load object "3d/mac10wf.3ds",22
load object "3d/uziwf.3ds",32
load object "3d/mp5wf.3ds",42
load object "3d/scorpionwf.3ds",52
load object "3d/fn2000wf.3ds",62
load object "3d/akwf.3ds",72
load object "3d/m4a1wf.3ds",82
load object "3d/m249wf.3ds",92
load object "3d/psg1wf.3ds",102

for i=1 to 10
 lock object on 2+(i*10)
 position object 2+(i*10),1.45,-1.072,2.1
 color object 2+(i*10),rgb(0,0,255)
 set object 2+(i*10),0,1,0
 scale object 2+(i*10),0.7,0.7,0.7
 color object 2+(i*10),rgb(0,0,255)
 next i


load object "3d/p99.3ds",100
load object "3d/mac10.3ds",110
load object "3d/uzi.3ds",120
load object "3d/mp5.3ds",130
load object "3d/scorpion.3ds",140
load object "3d/fn2000.3ds",150
load object "3d/ak.3ds",160
load object "3d/m4a1.3ds",170
load object "3d/m249.3ds",180
load object "3d/psg1.3ds",190

for i=0 to 9
set object rotation zyx 100+(i*10)
next i

load object "3d/laser.3ds",104
set object rotation zyx 104
color object 104,rgb(255,0,0)
ghost object on 104
hide object 104

load object "3d/flash.3ds",101 : load object "3d/flash2.3ds",111 : load object "3d/flash3.3ds",121 : load object "3d/flash4.3ds",131
load object "3d/flash5.3ds",141 : load object "3d/flash6.3ds",151 : load object "3d/flash7.3ds",161 : load object "3d/flash8.3ds",171
load object "3d/flash9.3ds",181 : load object "3d/flash10.3ds",191


for i=0 to 9
set object rotation zyx 101+(i*10)
ghost object on 101+(i*10)
set object 101+(i*10),1,0,0,0,0,1
next i

load image "3d/flash.bmp",101
load image "3d/flash2.bmp",102

load sound "sfx/p99.wav",1
load sound "sfx/mac10.wav",2
load sound "sfx/uzi.wav",3
load sound "sfx/mp5.wav",4
load sound "sfx/scorpion.wav",5
load sound "sfx/fn2000.wav",6
load sound "sfx/ak47.wav",7
load sound "sfx/m16.wav",8
load sound "sfx/m249.wav",9
load sound "sfx/psg1.wav",10

load sound "sfx/reload.wav",11
load sound "sfx/out.wav",12
`set sound speed 1,15000
load sound "sfx/see1.wav",500
load sound "sfx/see2.wav",501
load sound "sfx/see3.wav",502
load sound "sfx/see4.wav",503
load sound "sfx/see5.wav",504
load sound "sfx/see6.wav",505
load sound "sfx/see7.wav",506

load sound "sfx/tack1.wav",507

load sound "sfx/hit.wav",400
`========

for i=0 to 5
load sound "sfx/shell.wav",700+i
next i

for i=0 to 5
load object "3d/bullet.3ds",3+i
hide object 3+i
set object rotation zyx 3+i
position object 3+i,0,-1000000,0
next i
guns(1)=1
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== LOAD UP ALIENS 9000-9100

dim alien(100,14)

if wtt=0 then dim wtt(210,14)
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== load up all the game models 9000-9100
dim objects(100,5)

if lev=0

 load array "files/lev_0",objects(0)
 load object "map/map0.3ds",9998
 position object 9998,0,-40,0
 set object 9998,1,0,0

endif

if lev=1

 load array "files/lev_1",objects(0)
 load object "map/map1.3ds",9998
 position object 9998,0,-40,0
 set object 9998,1,0,0

endif

if lev=2

 load array "files/lev_2",objects(0)
 load object "map/map2.3ds",9998
 position object 9998,0,-40,0

endif

if lev=3

 load array "files/lev_3",objects(0)
 load object "map/map3.3ds",9998
 position object 9998,0,-40,0

endif

if lev=4

 load array "files/lev_4",objects(0)
 load object "map/map4.3ds",9998
 position object 9998,0,-40,0

endif

if lev=5

 load array "files/lev_5",objects(0)
 load object "map/map5.3ds",9998
 position object 9998,0,-40,0

endif

if lev=6

 load array "files/lev_6",objects(0)
 load object "map/map6.3ds",9998
 position object 9998,0,-40,0

endif

if lev=7

 load array "files/lev_7",objects(0)
 load object "map/map7.3ds",9998
 position object 9998,0,-40,0

endif

if lev=8

 load array "files/lev_8",objects(0)
 load object "map/map8.3ds",9998
 position object 9998,0,-40,0

endif

if lev=9

 load array "files/lev_9",objects(0)
 load object "map/map9.3ds",9998
 position object 9998,0,-40,0

endif

if lev=10

 load array "files/lev_10",objects(0)
 load object "map/map10.3ds",9998
 position object 9998,0,-40,0

endif

if lev=11

 load array "files/lev_11",objects(0)
 load object "map/map11.3ds",9998
 position object 9998,0,-40,0
 set object 9998,1,0,0

endif


for i=1 to 100

if objects(i,1)>0


if objects(i,1)=1 : load object "objects/mac10.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=2 : load object "objects/uzi.3ds",8999+i : scale object 8999+i,18,18,18 : endif
if objects(i,1)=3 : load object "objects/mp5.3ds",8999+i : scale object 8999+i,200,200,200 : endif
if objects(i,1)=4 : load object "objects/scorpion.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=5 : load object "objects/fn2000.3ds",8999+i : scale object 8999+i,30,30,30 : endif
if objects(i,1)=6 : load object "objects/ak47.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=7 : load object "objects/m4a1.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=8 : load object "objects/m249.3ds",8999+i : scale object 8999+i,80,80,80 : endif
if objects(i,1)=9 : load object "objects/psg1.3ds",8999+i : scale object 8999+i,50,50,50 : endif

if objects(i,1)=10 : load object "objects/pistolmag.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=11 : load object "objects/mac10mag.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=12 : load object "objects/uzimag.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=13 : load object "objects/mp5mag.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=14 : load object "objects/scorpionmag.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=15 : load object "objects/fn2000mag.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=16 : load object "objects/ak47mag.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=17 : load object "objects/m4a1mag.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=18 : load object "objects/m249mag.3ds",8999+i : scale object 8999+i,50,50,50 : endif
if objects(i,1)=19 : load object "objects/psg1mag.3ds",8999+i : scale object 8999+i,50,50,50 : endif

load image "objects/door1.bmp",9992

if objects(i,1)=21 : load object "objects/door1.x",8999+i : texture object 8999+i,9992 : scale object 8999+i,2000,3200,4000 : xrotate object 8999+i,90 : fix object pivot 8999+i : endif
if objects(i,1)=22 : load object "objects/door2.x",8999+i : texture object 8999+i,9992 : scale object 8999+i,2000,3200,4000 : xrotate object 8999+i,90 : fix object pivot 8999+i : endif
if objects(i,1)=23 : load object "objects/door3.x",8999+i : texture object 8999+i,9992 : scale object 8999+i,2000,3200,4000 : xrotate object 8999+i,90 : fix object pivot 8999+i : endif
if objects(i,1)=24 : load object "objects/door4.x",8999+i : texture object 8999+i,9992 : scale object 8999+i,2000,3200,4000 : xrotate object 8999+i,90 : fix object pivot 8999+i : endif
if objects(i,1)=25 : load object "objects/door5.x",8999+i : scale object 8999+i,2000,3200,4000 : xrotate object 8999+i,90 : fix object pivot 8999+i : endif

delete image 9992

if objects(i,1)=31 : make object plain 8999+i,1,1 : hide object 8999+i : endif

if objects(i,1)=39 : load object "alien.x",7600 : if lev=1 : ghost object on 7600 : endif : position object 7600,objects(i,2),objects(i,3),objects(i,4) : yrotate object 7600,90 : fix object pivot 7600
alien__x#=objects(i,2)
alien__Y#=objects(i,3)
alien__Z#=objects(i,4)
alien__oldx#=objects(i,2)
alien__oldy#=objects(i,3)
alien__oldz#=objects(i,4)
scale object 7600,30,30,30 : aliengog=1 : objects(i,1)=0 : set object rotation zyx 7600 : set object speed 7600,30 : endif

if objects(i,1)=40

player__oldx#=objects(i,2)
player__oldy#=objects(i,3)
player__oldz#=objects(i,4)
player__x#=objects(i,2)
player__y#=objects(i,3)
player__z#=objects(i,4)
cx#=objects(i,5)
cy#=0
acx#=objects(i,5)
acy#=0
al=0

endif


if objects(i,1)=41 : load object "map/tgt.3ds",8999+i : scale object 8999+i,800,800,800 : endif

if objects(i,1)=20 : load object "objects/health.3ds",8999+i : scale object 8999+i,100,100,100 : endif

if objects(i,1)=26 : make object plain 8999+i,1,1 : hide object 8999+i : endif
if objects(i,1)=27 : make object plain 8999+i,1,1 : hide object 8999+i : endif
if objects(i,1)=28 : make object plain 8999+i,1,1 : hide object 8999+i : endif
if objects(i,1)=29 : make object plain 8999+i,1,1 : hide object 8999+i : endif
if objects(i,1)=30 : make object plain 8999+i,1,1 : hide object 8999+i : endif

if objects(i,1)=32 : load object "alien/alien1.x",9100+al : yrotate object 9100+al,90 : fix object pivot 9100+al : yrotate object 9100+al,objects(i,5) :   position object 9100+al,objects(i,2),objects(i,3),objects(i,4) : set object speed 9100+al,60
alien(al,3)=0 : alien(al,4)=0 : alien(al,5)=0 : alien(al,1)=1000 : alien(al,2)=50 : alien(al,6)=0 : alien(al,7)=80  : alien(al,8)=10 : objects(i,1)=0 : al=al+1 : set object rotation zyx 9100+al-1 : scale object 9100+al-1,30,30,30 : endif

if objects(i,1)=33 : load object "alien/alien2.x",9100+al : yrotate object 9100+al,90 : fix object pivot 9100+al : yrotate object 9100+al,objects(i,5) :   position object 9100+al,objects(i,2),objects(i,3),objects(i,4) : set object speed 9100+al,60
alien(al,3)=0 : alien(al,4)=0 : alien(al,5)=0 : alien(al,1)=1500 : alien(al,2)=100 : alien(al,6)=0 : alien(al,7)=200  : alien(al,8)=30 : objects(i,1)=0 : al=al+1 : set object rotation zyx 9100+al-1 : scale object 9100+al-1,30,30,30 : endif

if objects(i,1)=34 : load object "alien/alien3.x",9100+al : yrotate object 9100+al,90 : fix object pivot 9100+al : yrotate object 9100+al,objects(i,5) :   position object 9100+al,objects(i,2),objects(i,3),objects(i,4) : set object speed 9100+al,60
alien(al,3)=0 : alien(al,4)=0 : alien(al,5)=0 : alien(al,1)=1200 : alien(al,2)=100 : alien(al,6)=0 : alien(al,7)=400  : alien(al,8)=20 : objects(i,1)=0 : al=al+1 : set object rotation zyx 9100+al-1 : scale object 9100+al-1,30,30,30 : endif

if objects(i,1)=35 : load object "alien/alien4.x",9100+al : yrotate object 9100+al,90 : fix object pivot 9100+al : yrotate object 9100+al,objects(i,5) :   position object 9100+al,objects(i,2),objects(i,3),objects(i,4) : set object speed 9100+al,60
alien(al,3)=0 : alien(al,4)=0 : alien(al,5)=0 : alien(al,1)=900 : alien(al,2)=100 : alien(al,6)=0 : alien(al,7)=300  : alien(al,8)=40 : objects(i,1)=0 : al=al+1 : set object rotation zyx 9100+al-1 : scale object 9100+al-1,30,30,30 : endif

if objects(i,1)=36 : load object "alien/alien5.x",9100+al : yrotate object 9100+al,90 : fix object pivot 9100+al : yrotate object 9100+al,objects(i,5) :   position object 9100+al,objects(i,2),objects(i,3),objects(i,4) : set object speed 9100+al,60
alien(al,3)=0 : alien(al,4)=0 : alien(al,5)=0 : alien(al,1)=700 : alien(al,2)=80 : alien(al,6)=0 : alien(al,7)=300  : alien(al,8)=35 : objects(i,1)=0 : al=al+1 : set object rotation zyx 9100+al-1 : scale object 9100+al-1,30,30,30 : endif

if objects(i,1)=37 : load object "alien/alien6.x",9100+al : yrotate object 9100+al,90 : fix object pivot 9100+al : yrotate object 9100+al,objects(i,5) :   position object 9100+al,objects(i,2),objects(i,3),objects(i,4) : set object speed 9100+al,60
alien(al,3)=0 : alien(al,4)=0 : alien(al,5)=0 : alien(al,1)=1400 : alien(al,2)=300 : alien(al,6)=0 : alien(al,7)=1000  : alien(al,8)=10 : objects(i,1)=0 : al=al+1 : set object rotation zyx 9100+al-1 : scale object 9100+al-1,30,30,30 : endif

if objects(i,1)=38 : load object "alien/alien7.x",9100+al : yrotate object 9100+al,90 : fix object pivot 9100+al : yrotate object 9100+al,objects(i,5) :   position object 9100+al,objects(i,2),objects(i,3),objects(i,4) : set object speed 9100+al,60
alien(al,3)=0 : alien(al,4)=0 : alien(al,5)=0 : alien(al,1)=1100 : alien(al,2)=150 : alien(al,6)=0 : alien(al,7)=700  : alien(al,8)=40 : objects(i,1)=0 : al=al+1 : set object rotation zyx 9100+al-1 : scale object 9100+al-1,30,30,30 : endif



if object exist(8999+i)=1
 position object 8999+i,objects(i,2),objects(i,3),objects(i,4)
 yrotate object 8999+i,wrapvalue(objects(i,5))
endif

endif

next i

make object plain 8998,1,1 : hide object 8998
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`==============================================
if dop=0
dim bullet(10,3)
bullet(1,3)=15
bullet(2,3)=30
bullet(3,3)=45
bullet(4,3)=30
bullet(5,3)=35
bullet(6,3)=20
bullet(7,3)=30
bullet(8,3)=30
bullet(9,3)=200
bullet(10,3)=10

`==================  bullet count

bullet(1,1)=bullet(1,3)
bullet(2,1)=bullet(2,3)
bullet(3,1)=bullet(3,3)
bullet(4,1)=bullet(4,3)
bullet(5,1)=bullet(5,3)
bullet(6,1)=bullet(6,3)
bullet(7,1)=bullet(7,3)
bullet(8,1)=bullet(8,3)
bullet(9,1)=bullet(9,3)
bullet(10,1)=bullet(10,3)

`===================   mag counts

bullet(1,2)=2
bullet(2,2)=0
bullet(3,2)=0
bullet(4,2)=0
bullet(5,2)=0
bullet(6,2)=0
bullet(7,2)=0
bullet(8,2)=0
bullet(9,2)=0
bullet(10,2)=0
endif

dop=0

set text font "arial"
set text size 20

`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== make temp level
`make object plain 9999,100,100
`position object 9999,0,-20,0


`load object "map/test.3ds",9999
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X

load dll "files/DBCollisions.dll",1
dllError = CheckCollisionDLL(1)
if dllError > 0 then EXIT PROMPT "Fatal ERROR with dll" , "Code " + str$(dllError): end

` STEP 2:  Create Collision Object from any X/3ds file
if lev=0 then CollisionObjNo = LoadCollisionObject("map/map0.3ds")
if lev=1 then CollisionObjNo = LoadCollisionObject("map/map1.3ds")
if lev=2 then CollisionObjNo = LoadCollisionObject("map/map2.3ds")
if lev=3 then CollisionObjNo = LoadCollisionObject("map/map3.3ds")
if lev=4 then CollisionObjNo = LoadCollisionObject("map/map4.3ds")
if lev=5 then CollisionObjNo = LoadCollisionObject("map/map5.3ds")
if lev=6 then CollisionObjNo = LoadCollisionObject("map/map6.3ds")
if lev=7 then CollisionObjNo = LoadCollisionObject("map/map7.3ds")
if lev=8 then CollisionObjNo = LoadCollisionObject("map/map8.3ds")
if lev=9 then CollisionObjNo = LoadCollisionObject("map/map9.3ds")
if lev=10 then CollisionObjNo = LoadCollisionObject("map/map10.3ds")
if lev=11 then CollisionObjNo = LoadCollisionObject("map/map11.3ds")

Speed# = 40 : player__x# = 0 : player__y# = 100 : player__z# = 0
Radius# = 40 : Gravity# = 10.0

load sound "sfx/beat.wav",991
`============================================== START OF LOOP
bulletselected=1
gun=1

if llg=1

health=sav(0)
for i=1 to 10
 guns(i)=sav(i)
next i

for i=1 to 10
 bullet(i,1)=sav(i+10)
next i

for i=1 to 10
 bullet(i,2)=sav(i+20)
next i

endif

if lev=0 then load music "music/ptc.mid",1

if lev=1 then load music "music/aa1.mid",1
if lev=2 then load music "music/aa2.mid",1
if lev=3 then load music "music/aa3.mid",1
if lev=4 then load music "music/aa4.mid",1
if lev=5 then load music "music/aa5.mid",1
if lev=6 then load music "music/aa6.mid",1
if lev=7 then load music "music/aa7.mid",1
if lev=8 then load music "music/aa3.mid",1
if lev=9 then load music "music/aa2.mid",1
if lev=10 then load music "music/aa10.mid",1

if lev<11
 play music 1
 loop music 1
endif

load image "2d/message.png",8000

make object plain 5000,50,50
set object rotation zyx 5000
load image "plasma.png",5000
texture object 5000,5000
ghost object on 5000
position object 5000,0,-10000000,0

for I = 1 to 1024
    if sound exist(I)
        set sound volume I,100
        endif
next I

do


set cursor 0,0
`============================================== START OF LOOP
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== reset the old positions so it dont mess up
position camera oxxf#,oyyf#,ozzf#
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== move camera

mov=0
if keystate(17)=1 : cf#=cf#+2 : mov=1 : endif
if keystate(31)=1 : cf#=cf#-2 : mov=1 : endif
if keystate(32)=1 : cr#=cr#+2 : mov=1 : endif
if keystate(30)=1 : cr#=cr#-2 : mov=1 : endif

if cf#>0 then dec cf#,1
if cf#<0 then inc cf#,1
if cr#>0 then dec cr#,1
if cr#<0 then inc cr#,1
if cf#>-1 and cf#<1 then cf#=0
if cr#>-1 and cr#<1 then cr#=0

if cf#>10 then cf#=10
if cf#<-10 then cf#=-10
if cr#>8 then cr#=8
if cr#<-8 then cr#=-8

`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== scope wobble, rotation for camera

rotate camera 0,acy#,0
move camera cf#
rotate camera 0,wrapvalue(acy#+90),0
move camera cr#
if showscope=1
if mov=0 then rotate camera wrapvalue(acx#-shot#+sin(d)*1.1),wrapvalue(acy#+cos(d)*1.1),0
if mov=1 then rotate camera wrapvalue(acx#-shot#+sin(d)*0.3),wrapvalue(acy#+cos(d)*2.1),0
else
rotate camera acx#,acy#,0
endif

`============================================== alien ai,/\/////-/
for i=0 to al

if alien(i,1)=1000 then uy=0
if alien(i,1)=1500 then uy=1
if alien(i,1)=1200 then uy=2
if alien(i,1)=900 then uy=3
if alien(i,1)=700 then uy=4
if alien(i,1)=1400 then uy=5
if alien(i,1)=1100 then uy=6

for oy=1 to 10

if alien(i,7)>0
if object exist(9100+i)=1
if dist(1099+oy,0,9100+i,0)<100

 position object 1099+oy,0,100000000,0
 alien(i,4)=camera position x()
 alien(i,5)=camera position y()
 alien(i,6)=camera position z()

ohel=alien(i,7)

if gun=1 then alien(i,7)=alien(i,7)-(10+rnd(40))
if gun=2 then alien(i,7)=alien(i,7)-(15+rnd(40))
if gun=3 then alien(i,7)=alien(i,7)-(30+rnd(20))
if gun=4 then alien(i,7)=alien(i,7)-(50+rnd(20))
if gun=5 then alien(i,7)=alien(i,7)-(25+rnd(20))
if gun=6 then alien(i,7)=alien(i,7)-(40+rnd(30))
if gun=7 then alien(i,7)=alien(i,7)-(45+rnd(25))
if gun=8 then alien(i,7)=alien(i,7)-(60+rnd(20))
if gun=9 then alien(i,7)=alien(i,7)-(30+rnd(20))
if gun=10 then alien(i,7)=alien(i,7)-(80+rnd(40))

nhel=alien(i,7)
if ohel>0 and nhel<1 then play sound 500+uy

if alien(i,7)>0
  if alien(i,3)=0
   play sound 500+uy
   else
   play sound 507
  endif
endif

 alien(i,3)=1

endif
endif
endif

next oy

next i


for i=0 to al-1

if alien(i,7)>0

gf=alien(i,3)

if dist(999,0,9100+i,0)<(alien(i,1)/2) then alien(i,3)=1
if dist(999,0,9100+i,0)<alien(i,2) then alien(i,3)=1
for r=1 to 10
  if dist(1099+r,0,9100+i,0)<50
   alien(i,3)=1
  endif
next r

gr=alien(i,3)

if gr=1 and gf=0 then play sound 500+uy

if dist(999,0,9100+i,0)>alien(i,1) : alien(i,3)=0 : loop object 9100+i,1,10 : endif

if alien(i,3)=1
 alien(i,4)=camera position x()
 alien(i,5)=camera position y()
 alien(i,6)=camera position z()

no=0

  point object 9100+i,alien(i,4),alien(i,5),alien(i,6)
  xrotate object 9100+i,0
  zrotate object 9100+i,0
endif

if dist(999,0,9100+i,0)<alien(i,2)
  no=1
  ghl=rnd(50)
  loop object 9100+i,30,40
  if ghl=1 : health=health-(alien(i,8)-rnd(5)) : play sound 400 : endif
endif

if alien(i,3)=1
if alien(i,1)=1000 then yymov=2
if alien(i,1)=1500 then yymov=5
if alien(i,1)=1200 then yymov=5
if alien(i,1)=900 then yymov=6
if alien(i,1)=700 then yymov=4
if alien(i,1)=1400 then yymov=2
if alien(i,1)=1100 then yymov=2
 if no=0 then move object 9100+i,yymov
 if no=0 then loop object 9100+i,10,30
endif

endif

if dist(999,0,9100+i,0)<1500
 if alien(i,7)>0

   player__xg#=object position x(9100+i)
   player__yg#=object position y(9100+i)
   player__zg#=object position z(9100+i)

   alien(i,12)=(object position x(9100+i))*2
   alien(i,13)=(object position y(9100+i))*2
   alien(i,14)=(object position z(9100+i))*2

player_oldx#=(alien(i,12))/2
player_oldy#=(alien(i,13))/2
player_oldz#=(alien(i,14))/2

   bHit = call dll(1, "UpdateSlidingCollision", Radius#, Gravity#, player__xg#, player__yg#, player__zg#, player_oldx#, player_oldy#, player_oldz#)

   ` Whether we hit something or not the DLL will give us the right player coords so update ours now
   player__xg# = call dll(1, "NewPlayerX")
   player__yg# = call dll(1, "NewPlayerY")
   player__zg# = call dll(1, "NewPlayerZ")

   ` And finally update the player to the new position

   Position object 9100+i,player__xg#, player__yg#, player__zg#

   alien(i,12)=(object position x(9100+i))*2
   alien(i,13)=(object position y(9100+i))*2
   alien(i,14)=(object position z(9100+i))*2

 else

 loop object 9100+i,45,47

 endif
endif

next i

`======-=-=-=-=-=--==-=-///////////////-=-=-=---//////

   player__x#=camera position x()
   player__y#=camera position y()
   player__z#=camera position z()

   bHit = call dll(1, "UpdateSlidingCollision", Radius#, Gravity#, player__x#, player__y#, player__z#, player__oldx#, player__oldy#, player__oldz#)

   ` Whether we hit something or not the DLL will give us the right player coords so update ours now
   player__x# = call dll(1, "NewPlayerX")
   player__y# = call dll(1, "NewPlayerY")
   player__z# = call dll(1, "NewPlayerZ")

   ` And finally update the player to the new position

player__x#=curvevalue(player__oldx#,player__x#,3)
player__y#=curvevalue(player__oldy#,player__y#,3)
player__z#=curvevalue(player__oldz#,player__z#,3)

   Position camera player__x#, player__y#, player__z#

   player__oldx#=camera position x()
   player__oldy#=camera position y()
   player__oldz#=camera position z()


`============================================='==========
`============================================='==========
`============================================='==========  HELPER ALIEN CODE
`============================================='==========
if aliengog=1

if dist(999,0,7600,0)>100 : point object 7600,camera position x(),camera position y(),camera position z() : xrotate object 7600,0 : zrotate object 7600,0 : loop object 7600,10,30 : move object 7600,9

else

loop object 7600,1,10

endif

for i=0 to al-1

if dist(7600,0,9100+i,0)<500
 if alien(i,7)>0
loop object 7600,30,40
point object 7600,object position x(9100+i),object position y(9100+i),object position z(9100+i) : xrotate object 7600,0 : zrotate object 7600,0
alienshoot=rnd(40)
  if alienshoot=1

   inc bulletselected : if bulletselected>10 then bulletselected=1
   position object 1099+bulletselected,object position x(7600),object position y(7600),object position z(7600)
   set object to object orientation 1099+bulletselected,7600

alienbullet=bulletselected

  endif
 endif
endif


next i

   alien__x#=object position x(7600)
   alien__y#=object position y(7600)
   alien__z#=object position z(7600)

   bHit = call dll(1, "UpdateSlidingCollision", Radius#, Gravity#, alien__x#, alien__y#, alien__z#, alien__oldx#, alien__oldy#, alien__oldz#)

   ` Whether we hit something or not the DLL will give us the right player coords so update ours now
   alien__x# = call dll(1, "NewPlayerX")
   alien__y# = call dll(1, "NewPlayerY")
   alien__z# = call dll(1, "NewPlayerZ")

   ` And finally update the player to the new position

alien__x#=curvevalue(alien__oldx#,alien__x#,3)
alien__y#=curvevalue(alien__oldy#,alien__y#,3)
alien__z#=curvevalue(alien__oldz#,alien__z#,3)

   Position object 7600,alien__x#,alien__y#,alien__z#

   alien__oldx#=object position x(7600)
   alien__oldy#=object position y(7600)
   alien__oldz#=object position z(7600)

endif


if alienbullet=0 then position object 5000,0,100000000,0
   `#
   `############################## ACTION ENDS #########################################################



`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`==============================================  LASER AND SCOPE CODE

if laserwait<0 and keystate(38)=1 : inc showlaser : laserwait=20 : endif : if showlaser=2 then showlaser=0
if laserwait<0 and mouseclick()=2 : inc showscope
 if showscope=2 then showscope=0
if showscope=0 then set camera fov 3.14/2.905
if showscope=1 then set camera fov 2.14/2.905
if gun=4 or gun=6 or gun=10
if showscope=1 then set camera fov 1.24/2.905
endif

 laserwait=20 : endif

if showscope=0 then hide object 775
if gun=4 or gun=6 or gun=10
if showscope=1 then show object 775
endif
if showscope=0 then hide object 776

if gun=4 or gun=6 or gun=10
if showscope=1 then show object 776
endif

dec laserwait
if showlaser=0 then hide object 104
if showlaser=1 then show object 104

`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`==============================================
shoot=1

if bullet(gun,1)<1 then shoot=0

`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== shooting code, 101=muzzle flash, shot#= recoil
if mouseclick()=1 and shootwait<0 and bullet(gun,1)<1 and bullet(gun,2)<1 and hold=0

play sound 12

if gun=1 then shootwait=15+rnd(5)
if gun=2 then shootwait=15+rnd(2)
if gun=3 then shootwait=15+rnd(2)
if gun=4 then shootwait=15+rnd(2)
if gun=5 then shootwait=15+rnd(2)
if gun=6 then shootwait=15+rnd(2)
if gun=7 then shootwait=15+rnd(3)
if gun=8 then shootwait=15+rnd(2)
if gun=9 then shootwait=15+rnd(4)
if gun=10 then shootwait=15+rnd(10)

endif


for i=1 to 10

move object 1099+i,40

next i

for i=0 to 9
hide object 101+(i*10)
texture object 101+(i*10),101+rnd(1)
next i
if changing=0
if mouseclick()=1 and shootwait<0 and shoot=1 : shoot=1
`======= bullet decreace

bullet(gun,1)=bullet(gun,1)-1

`======= =-=-= shootwaits

if gun=1 then shootwait=15+rnd(5)
if gun=2 then shootwait=5+rnd(2)
if gun=3 then shootwait=2+rnd(2)
if gun=4 then shootwait=3+rnd(2)
if gun=5 then shootwait=2+rnd(2)
if gun=6 then shootwait=6+rnd(2)
if gun=7 then shootwait=4+rnd(3)
if gun=8 then shootwait=6+rnd(2)
if gun=9 then shootwait=5+rnd(4)
if gun=10 then shootwait=50+rnd(20)

siz#=siz#+shootwait
`========
h=1 : show object 91+(gun*10) : play sound gun : inc bulletselected : if bulletselected>10 then bulletselected=1
position object 1099+bulletselected,camera position x(),camera position y(),camera position z()
set object to object orientation 1099+bulletselected,101
yrotate object 1099+bulletselected,wrapvalue(object angle y(1099+bulletselected)+90)
move object 1099+bulletselected,2.5
yrotate object 1099+bulletselected,wrapvalue(object angle y(1099+bulletselected)-90)
move object 1099+bulletselected,3
xrotate object 1099+bulletselected,wrapvalue(object angle x(1099+bulletselected)+90)
move object 1099+bulletselected,3.5
xrotate object 1099+bulletselected,wrapvalue(object angle x(1099+bulletselected)-90)

if alienbullet=bulletselected : position object 5000,0,100000000,0 : alienbullet=0 : endif

 shot#=shot#+2+rnd(3) : endif : endif
dec shootwait
if shot#>5 then shot#=5

if alienbullet>0
 position object 5000,object position x(1099+alienbullet),object position y(1099+alienbullet),object position z(1099+alienbullet)
 point object 5000,camera position x(),camera position y(),camera position z()
 xrotate object 5000,wrapvalue(sin(g)*18)
 inc g
endif
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== SHELL EJECTION

if h=1

position object 3+selshell,object position x(100),object position y(100),object position z(100)
set object to camera orientation 3+selshell
xrotate object 3+selshell,wrapvalue(object angle x(3+selshell)-rnd(5)-2)
shell(1,selshell)=50
shell(2,selshell)=30
inc selshell : if selshell>5 then selshell=0
endif
h=0
dec hidewait

for i=0 to 5

 if shell(1,i)<0
 hide object 3+i
 else
 show object 3+i
 endif

next i

for i=0 to 5
 yrotate object 3+i,wrapvalue(object angle y(3+i)-90)
 move object 3+i,1.75
 yrotate object 3+i,wrapvalue(object angle y(3+i)+90)
 shell(2,i)=shell(2,i)-4
 shuww#=shell(2,i)
 position object 3+i,object position x(3+i),object position y(3+i)+shuww#/15,object position z(3+i)

if shell(1,i)>0
if object position y(3+i)<(camera position y()-80)
   shell(1,i)=0
   play sound 700+i
endif
endif

next i

for i=1 to 10
 turn object right 2+(i*10),5
 hide object 2+(i*10)
next i

show object 2+(gun*10)

`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== camera wobble amount

position object 100,camera position x(),camera position y(),camera position z()
if mov=0 then rotate object 100,wrapvalue(camera angle x()-shot#+sin(d)*1.1),wrapvalue(camera angle y()+cos(d)*1.1),0
if mov=1 then rotate object 100,wrapvalue(camera angle x()-shot#+sin(d)*0.3),wrapvalue(camera angle y()+cos(d)*2.1),0


dec shot#,0.5
if shot#<0 then shot#=0
if mov=0 then inc d,1
if mov=1 then inc d,10
`==== 15 if running
d=wrapvalue(d)
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== position the laser and the mussle flash where it should be

for i=0 to 9
position object 101+(i*10),object position x(100),object position y(100),object position z(100)
set object to object orientation 101+(i*10),100
next i

position object 104,object position x(100),object position y(100),object position z(100)
set object to object orientation 104,100

`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`==============================================


`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== save old positions for repositioning
oxxf#=camera position x()
oyyf#=camera position y()
ozzf#=camera position z()
`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== if the scope is on then put the camera where the scope is
if gun=4 or gun=6
if showscope=1

xxcs#=camera angle x()
zzcs#=camera angle x()
yycs#=camera angle y()
rotate camera 0,0,0

yrotate camera wrapvalue(yycs#+90)
move camera 2.5
rotate camera xxcs#,wrapvalue(camera angle y()-90),0
move camera 15

endif
endif

`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== pickingup stuff

`=================== then objects :-P

for i=1 to 100

if object exist(8999+i)=1

 if dist(999,0,8999+i,0)<400
   if objects(i,1)>20
    if objects(i,1)<26
      frax=(dist(999,0,8999+i,0)/10)-20
      if frax<1 : frax=1 : endif
      if frax>11 : frax=11 : endif
      fraz=(11-frax)
      set object frame 8999+i,fraz
    endif
   endif
  endif

if objects(i,1)=29
 if lev=1

 position object 8999+i,object position x(7600),object position y(7600),object position z(7600)

 endif
 if lev=3

 position object 8999+i,object position x(7600),object position y(7600),object position z(7600)

 endif
endif
if dist(999,0,8999+i,0)<100

if guns(2)=0
if objects(i,1)=1 : guns(2)=1 : bullet(2,2)=bullet(2,2)+1 : alienspeak=2 : mec=10 : messg$="You got a mac 10 (2)" : messgeend=200 : message=1 : endif
else
if objects(i,1)=1 : guns(2)=1 : bullet(2,2)=bullet(2,2)+1 : alienspeak=2 : mec=10 : messg$="You got a mac 10 (2) but took the ammo" : messgeend=200 : message=1 : endif
endif

if guns(3)=0
if objects(i,1)=2 : guns(3)=1 : bullet(3,2)=bullet(3,2)+1 : alienspeak=2 : mec=10 : messg$="You got a uzi (3)" : messgeend=200 : message=1 : endif
else
if objects(i,1)=2 : guns(3)=1 : bullet(3,2)=bullet(3,2)+1 : alienspeak=2 : mec=10 : messg$="You got a uzi (3) but took the ammo" : messgeend=200 : message=1 : endif
endif

if guns(4)=0
if objects(i,1)=3 : guns(4)=1 : bullet(4,2)=bullet(4,2)+1 : alienspeak=2 : mec=10 : messg$="You got a mp5 (4)" : messgeend=200 : message=1 : endif
else
if objects(i,1)=3 : guns(4)=1 : bullet(4,2)=bullet(4,2)+1 : alienspeak=2 : mec=10 : messg$="You got a mp5 (4) but took the ammo" : messgeend=200 : message=1 : endif
endif

if guns(5)=0
if objects(i,1)=4 : guns(5)=1 : bullet(5,2)=bullet(5,2)+1 : alienspeak=2 : mec=10 : messg$="You got a scorpion (5)" : messgeend=200 : message=1 : endif
else
if objects(i,1)=4 : guns(5)=1 : bullet(5,2)=bullet(5,2)+1 : alienspeak=2 : mec=10 : messg$="You got a scorpion (5) but took the ammo" : messgeend=200 : message=1 : endif
endif

if guns(6)=0
if objects(i,1)=5 : guns(6)=1 : bullet(6,2)=bullet(6,2)+1 : alienspeak=2 : mec=10 : messg$="You got a fn-2000 (6)" : messgeend=200 : message=1 : endif
else
if objects(i,1)=5 : guns(6)=1 : bullet(6,2)=bullet(6,2)+1 : alienspeak=2 : mec=10 : messg$="You got a fn-2000 (6) but took the ammo" : messgeend=200 : message=1 : endif
endif

if guns(7)=0
if objects(i,1)=6 : guns(7)=1 : bullet(7,2)=bullet(7,2)+1 : alienspeak=2 : mec=10 : messg$="You got a ak-47 (7)" : messgeend=200 : message=1 : endif
else
if objects(i,1)=6 : guns(7)=1 : bullet(7,2)=bullet(7,2)+1 : alienspeak=2 : mec=10 : messg$="You got a ak-47 (7) but took the ammo" : messgeend=200 : message=1 : endif
endif

if guns(8)=0
if objects(i,1)=7 : guns(8)=1 : bullet(8,2)=bullet(8,2)+1 : alienspeak=2 : mec=10 : messg$="You got a m4a1 (8)" : messgeend=200 : message=1 : endif
else
if objects(i,1)=7 : guns(8)=1 : bullet(8,2)=bullet(8,2)+1 : alienspeak=2 : mec=10 : messg$="You got a m4a1 (8) but took the ammo" : messgeend=200 : message=1 : endif
endif

if guns(9)=0
if objects(i,1)=8 : guns(9)=1 : bullet(9,2)=bullet(9,2)+1 : alienspeak=2 : mec=10 : messg$="You got a m249 (9)" : messgeend=200 : message=1 : endif
else
if objects(i,1)=8 : guns(9)=1 : bullet(9,2)=bullet(9,2)+1 : alienspeak=2 : mec=10 : messg$="You got a m249 (9) but took the ammo" : messgeend=200 : message=1 : endif
endif

if guns(10)=0
if objects(i,1)=9 : guns(10)=1 : bullet(10,2)=bullet(10,2)+1 : alienspeak=2 : mec=10 : messg$="You got a psg1 (0)" : messgeend=200 : message=1 : endif
else
if objects(i,1)=9 : guns(10)=1 : bullet(10,2)=bullet(10,2)+1 : alienspeak=2 : mec=10 : messg$="You got a psg1 (0) but took the ammo" : messgeend=200 : message=1 : endif
endif

if objects(i,1)=10 : bullet(1,2)=bullet(1,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the p99 (1)" : messgeend=200 : message=1 : endif
if objects(i,1)=11 : bullet(2,2)=bullet(2,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the mac10 (2)" : messgeend=200 : message=1 : endif
if objects(i,1)=12 : bullet(3,2)=bullet(3,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the uzi (3)" : messgeend=200 : message=1 : endif
if objects(i,1)=13 : bullet(4,2)=bullet(4,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the mp5 (4)" : messgeend=200 : message=1 : endif
if objects(i,1)=14 : bullet(5,2)=bullet(5,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the scorpion (5)" : messgeend=200 : message=1 : endif
if objects(i,1)=15 : bullet(6,2)=bullet(6,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the fn-2000 (6)" : messgeend=200 : message=1 : endif
if objects(i,1)=16 : bullet(7,2)=bullet(7,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the ak-47 (7)" : messgeend=200 : message=1 : endif
if objects(i,1)=17 : bullet(8,2)=bullet(8,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the m4a1 (8)" : messgeend=200 : message=1 : endif
if objects(i,1)=18 : bullet(9,2)=bullet(9,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the m249 (9)" : messgeend=200 : message=1 : endif
if objects(i,1)=19 : bullet(10,2)=bullet(10,2)+1 : alienspeak=2 : mec=10 : messg$="You got ammo for the psg1 (0)" : messgeend=200 : message=1 : endif


if objects(i,1)=31

dop=1

endif

if objects(i,1)<20 then play sound 11

if objects(i,1)=20 : health=health+(10+rnd(20)) : play sound 991 : alienspeak=2 : mec=10 : messg$="You got health" : messgeend=200 : message=1 : endif

if objects(i,1)=41

else
if object exist(8999+i)=1
 if objects(i,1)>20 and objects(i,1)<26
 else
  delete object 8999+i
 endif
endif
endif

else

if dist(999,0,8999+i,0)<500
if objects(i,1)=26 : message=1 : messgeend=200 : alienspeak=0 : mec=1 : objects(i,1)=0 :  delete object 8999+i : endif
if objects(i,1)=27 : message=1 : messgeend=200 : alienspeak=0 : mec=2 : objects(i,1)=0 :  delete object 8999+i : endif
if objects(i,1)=28 : message=1 : messgeend=200 : alienspeak=0 : mec=3 : objects(i,1)=0 :  delete object 8999+i : endif
if objects(i,1)=29 : message=1 : messgeend=400 : alienspeak=1 : mec=4 : objects(i,1)=0 :  delete object 8999+i : endif
if objects(i,1)=30 : message=1 : messgeend=400 : alienspeak=1 : mec=5 : objects(i,1)=0 :  delete object 8999+i : endif
endif


endif


 endif

next i


for i=1 to 100

for r=1 to 10

if objects(i,1)=41
  if objects(i,5)>-1
 if dist(1099+r,0,8999+i,40)<30
  hide limb 8999+i,2
  objects(i,5)=-1
  position object 1099+r,0,100000000,0
  endif
   endif
endif

next r

next i

`==============================================
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== camera angle movement
if hold=0
cx#=wrapvalue(cx#+mousemovey()*0.3)
cy#=wrapvalue(cy#+mousemovex()*0.3)
endif
if cx#<=290 and cx#>180 then cx#=290
if cx#>=70 and cx#<=180 then cx#=70
acx#=curveangle(cx#,acx#,3)
acy#=curveangle(cy#,acy#,3)

`================ changing guns
for h=1 to 10

if gun=h
for i=0 to 9
hide object 100+(i*10)
next i
show object 100+((h-1)*10)
endif

next h

if changing=0
 if inkey$()="1" then changeto=1
 if inkey$()="2" then changeto=2
 if inkey$()="3" then changeto=3
 if inkey$()="4" then changeto=4
 if inkey$()="5" then changeto=5
 if inkey$()="6" then changeto=6
 if inkey$()="7" then changeto=7
 if inkey$()="8" then changeto=8
 if inkey$()="9" then changeto=9
 if inkey$()="0" then changeto=10
endif
if changeto=gun then changeto=0
if guns(changeto)=0 then changeto=0

if rotgun<40
if rel=0
  if inkey$()="r"
   if bullet(gun,2)>0
    if bullet(gun,1)<bullet(gun,3)
     rel=1
    endif
   endif
  endif

  if bullet(gun,1)<1
   if bullet(gun,2)>0
    rel=1
   endif
  endif
  if rel=1 then changeto=gun

endif
endif

if changeto>0
 changing=1
 rotgun=1
 changeif=changeto
 changeto=0
endif

if bullet(gun,1)<1 and bullet(gun,2)>0 then rel=1
if bullet(gun,1)=0 and bullet(gun,2)>0 then rel=1

if bullet(gun,1)<1 and bullet(gun,2)>0 then changing=1
if bullet(gun,1)=0 and bullet(gun,2)>0 then changing=1

if bullet(gun,1)<1 and bullet(gun,2)>0 then changeif=gun
if bullet(gun,1)=0 and bullet(gun,2)>0 then changeif=gun

if changing=1

if gof=0 then inc rotgun
if gof=1 then dec rotgun

if rel=0
if rotgun=15 : hide object 100 : gun=changeif : set camera fov 3.14/2.905 : showscope=0 : gof=1
 if rel=1 : bullet(gun,1)=bullet(gun,3) : bullet(gun,2)=bullet(gun,2)-1 : rel=0 : endif
endif
if rotgun<0 : rotgun=0 : changing=0 : gof=0 : changeif=0 : endif

endif
endif

if bullet(gun,1)<1 and bullet(gun,2)>0 then rel=1
if bullet(gun,1)=0 and bullet(gun,2)>0 then rel=1

if rel=1
if rotgun=2 : set camera fov 3.14/2.905 : showscope=0 : endif
if rotgun=50 : play sound 11 : hide object 100 : ogun=gun : gun=changeif : set camera fov 3.14/2.905 : showscope=0 : gof=1

if changeif=ogun
else

rel=0

if bullet(gun,1)<1 and bullet(gun,2)>0 then rel=1
if bullet(gun,1)=0 and bullet(gun,2)>0 then rel=1

endif

if bullet(gun,1)<1 and bullet(gun,2)>0 then rel=1
if bullet(gun,1)=0 and bullet(gun,2)>0 then rel=1

 if rel=1
 if bullet(gun,1)<bullet(gun,3)
  bullet(gun,1)=bullet(gun,3) : bullet(gun,2)=bullet(gun,2)-1 : rel=0
 endif
 endif

endif
if rotgun<0 : rotgun=0 : changing=0 : gof=0 : changeif=0 : endif

endif

if mov=0 then xrotate object 100,wrapvalue((camera angle x()-shot#+sin(d)*1.1)+(rotgun*2))
if mov=1 then xrotate object 100,wrapvalue((camera angle x()-shot#+sin(d)*0.3)+(rotgun*2))

for i=1 to 9
position object 100+(i*10),object position x(100),object position y(100),object position z(100)
set object to object orientation 100+(i*10),100
next i
set object to object orientation 104,100


`================ scope
if gun=6 : texture object 775,774 : endif
if gun=10 : texture object 775,773 : endif

if gun=1 : hide object 775 : hide object 776 : endif
if gun=2 : hide object 775 : hide object 776 : endif
if gun=3 : hide object 775 : hide object 776 : endif
if gun=5 : hide object 775 : hide object 776 : endif
if gun=7 : hide object 775 : hide object 776 : endif
if gun=8 : hide object 775 : hide object 776 : endif
if gun=9 : hide object 775 : hide object 776 : endif

hide object 104
if gun=4 : show object 104 : texture object 775,775 : endif
`         __                 _____
`   |  | |      /     |       |    |  |
`   |__| |__   /      |       |    |__|
`   |  | |    /____   |       |    |  |
`   |  | |__ /        |___    |    |  |

if health<0 then health=0
if health>100 then health=100

scale object 2,health,100,100
position object 2,1.315+(0.345-(0.00345*health)),-1.225,2.1
color object 2,rgb(255-(2.55*health),0,0+(2.55*health))


if health=0

CLEAN_SWEEP()
sync
cls
load image "2d/go.png",1
ink rgb(0,0,0),rgb(0,0,0)
for i=1 to 100
 draw to front
 paste image 1,0,0
 sync
next i
CLEAN_SWEEP()
rotate camera 0,0,0
position camera 0,0,0
 exit : endif

if escapekey()=1

sav(0)=health
for i=1 to 10
 sav(i)=guns(i)
next i

for i=1 to 10
 sav(i+10)=bullet(i,1)
next i

for i=1 to 10
 sav(i+20)=bullet(i,2)
next i

sav(31)=lev

position camera 0,0,0
player__oldx#=0
player__oldy#=0
player__oldz#=0
player__x#=0
player__y#=0
player__z#=0
cx#=0
cy#=0
acx#=0
acy#=0
al=0
 CLEAN_SWEEP()
 exit
endif
`========= CROSSHAIR

if mov=1 then siz#=siz#+0.6


if siz#<1 then siz#=1
if siz#>15 then siz#=15
siz#=siz#-0.3


if gun=4 or gun=6 or gun=10
xhair=1
if showscope=1
xhair=0
endif
else
xhair=1
endif



if xhair=1

paste image 10,400,288-siz#
paste image 10,400,303+siz#
paste image 11,388-siz#,300
paste image 11,403+siz#,300

endif
`==============================================
hold=0

bull$=str$(bullet(gun,1))
bulr$=str$(bullet(gun,2))

ink rgb(0,0,0),1
text 659,540,bull$
text 659,564,bulr$

text 659,539,bull$
text 659,563,bulr$

text 660,540,bull$
text 660,564,bulr$

ink rgb(0,0,200),1
text 660,539,bull$
text 660,563,bulr$

if dop=1
exit
endif
`=============== messages
dec messgeend
if messgeend<0 then message=0

if message=1

if mec=10 then xo=1

if lev=1
 if mec=1 then xo=1
 if mec=2 then xo=1
 if mec=4 then xo=2
endif
if lev=2
 if mec=1 then xo=1
endif
if lev=3
 if mec=4 then xo=1
endif
if lev=11
 if mec=1 then xo=1
endif

paste image 8000,0,-95+(xo*15)

if alienspeak=0
 ink rgb(255,255,255),1
else
 ink rgb(0,200,0),1
endif

if alienspeak=2
 ink rgb(155,0,0),1
endif

if lev=1
 if mec=1 : set cursor 2,2 : print "This door seems to be broken, you must find another way to get into here" : endif
 if mec=2 : set cursor 2,2 : print "What are these things? They look like some type of mutated crab!" : endif
 if mec=4 : set cursor 2,2 : print "ALIEN: You got my sos message, Help me, i am trapped in this structure and i can only sustain as"
 set cursor 2,17 : print "a hologram on the surface, i will help you once you have freed me from this place." : endif
endif
if lev=2
 if mec=1 : set cursor 2,2 : print "This elevator is broken, try to find a working one" : endif
endif
if lev=3
 if mec=4 : set cursor 2,2 : print "ALIEN: Oh thank you for finding me, for this i will help you defeat your enemys" : endif
endif

if lev=11
 if mec=1 : set cursor 2,2 : print "Congratulations you have eliminated all threat of aliens, you are now back at the army barracks" : endif
endif

if mec=10 : set cursor 2,1 : print messg$ : endif

if mec>3 and mec<6

if messgeend>380
 point camera object position x(7600), object position y(7600), object position z(7600)
 cx#=camera angle x()
 cy#=camera angle y()
 acx#=camera angle x()
 acy#=camera angle y()
endif

if messgeend>380
 hold=1
endif

endif
endif
`=====
position object 199,camera position x(),0,camera position z()
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`============================================== END OF LOOP
sync
loop

CLEAN_SWEEP()

oxxf#=0
oyyf#=0
ozzf#=0
alien__x#=0
alien__Y#=0
alien__Z#=0
alien__oldx#=0
alien__oldy#=0
alien__oldz#=0
player__oldx#=0
player__oldy#=0
player__oldz#=0
player__xg#=0
player__yg#=0
player__zg#=0
player_oldx#=0
player_oldy#=0
player_oldz#=0
player__x#=0
player__y#=0
player__z#=0
cx#=0
cy#=0
acx#=0
acy#=0
llg=0

CLEAN_SWEEP()
goto top
`============================================== END OF LOOP
`== X  ==  X  ==  X  ==  X  ==  X  ==  X  ==  X
`==============================================

function CLEAN_SWEEP()
`*****
`I think I got all the numbers right, modify if they're incorrect.
`Didn't add memblock and other stuff, add as you need.

`make sure you're looking at the screen & mop video memory
set current bitmap 0

for I = 1 to 31
    if memblock exist(I)
       delete memblock I
    endif
    if bitmap exist(I)
        delete bitmap I
        endif
    if music exist(I)
        delete music I
        endif
    if animation exist(I)
        delete animation I
        endif
    next I

for I = 1 to 65535
    if image exist(I)
        delete image I
        endif
    if sprite exist(I)
        delete sprite I
        endif
    if object exist(I)
        delete object I
        endif
    if matrix exist(I)
        delete matrix I
        endif
    next I
for I = 1 to 1024
    if sound exist(I)
        delete sound I
        endif
    next I

for I = 1 to 255
    if dll exist(I)
        delete dll I
        endif
    next I

endfunction
`*****

function dist(obj1__,offone,obj2__,offtwo)


if obj1__<>999
vox__#=object position x(obj1__)
voy__#=object position y(obj1__)+offone
voz__#=object position z(obj1__)
endif

if obj1__=999
vox__#=camera position x()
voy__#=camera position y()
voz__#=camera position z()
endif

vpx__#=object position x(obj2__)
vpy__#=object position y(obj2__)+offtwo
vpz__#=object position z(obj2__)


vxdist__#=vpx__#-vox__#
vydist__#=vpy__#-voy__#
vzdist__#=vpz__#-voz__#
dist#=sqrt((vxdist__#*vxdist__#)+(vydist__#*vydist__#)+(vzdist__#*vzdist__#))


endfunction dist#



`# FUNCTIONS #############
`#
Function LoadObject(FileName$)
   ObjNo = MasterObjNo(0)
   MasterObjNo(0) = MasterObjNo(0) + 1
   Load Object FileName$, ObjNo
EndFunction ObjNo

Function LoadCollisionObject(FileName$)
   ` Create Collision Object
   CollisionObjNo = LoadObject(FileName$) : Hide object CollisionObjNo
   ` Make a mesh -> Memblock -> Pointer
   make mesh from object 1, CollisionObjNo   : make memblock from mesh 1,1 : MeshPtr = GET MEMBLOCK PTR(1)

   ` Make Collision Object in DLL - this is the ONLY difference between Pro & 1.13 versions
   OK = call dll(1, "CreateCollisionObject", MeshPtr)
   ` For Pro
   `OK = call dll(1, "CreateCollisionObjectPro", MeshPtr)
EndFunction CollisionObjNo

Function MakeSky(FileName$, CameraRange)
   SkyObjNo = LoadObject("Skyboxes" + FileName$)
   set camera range 10,CameraRange

   Scale object SkyObjNo, CameraRange*12,CameraRange*12, CameraRange*12
   SET OBJECT COLLISION OFF SkyObjNo
   SET OBJECT SkyObjNo, 1, 1, 1, 1, 0, 0,1

EndFunction SkyObjNo

Function CheckCollisionDLL(i)
   retval = 0
   if dll exist(i) = 0 then retval = 1
   if dll call exist(i, "CreateCollisionObjectPro") = 0 then retval = 2
   if dll call exist(i, "CreateCollisionVertex") = 0 then retval = 3
   if dll call exist(i, "CreateModelLog") = 0 then retval = 4
   if dll call exist(i, "DefineVerts") = 0 then retval = 5
   if dll call exist(i, "GetNumFaces") = 0 then retval = 6
   if dll call exist(i, "UpdateSlidingCollision") = 0 then retval = 7
   if dll call exist(i, "NewPlayerX") = 0 then retval = 8
   if dll call exist(i, "NewPlayerY") = 0 then retval = 9
   if dll call exist(i, "NewPlayerZ") = 0 then retval = 10
   if dll call exist(i, "HitNormalX") = 0 then retval = 11
   if dll call exist(i, "HitNormalY") = 0 then retval = 12
   if dll call exist(i, "HitNormalZ") = 0 then retval = 13
   if dll call exist(i, "HitX") = 0 then retval = 14
   if dll call exist(i, "HitY") = 0 Then retval = 15
   if dll call exist(i, "HitZ") = 0 Then retval = 16
EndFunction retval