Hello again,
Here's the latest. I fixed a couple of bugs that I found when loading a larger level. I expanded the entity arrays from 100 to 999, and added a routine where the proper BIN file is found by the name of the entity in the map rather than just incrementing the entity ID. What this means is that you can NOT change the name of any entities you place in your map, or the code will ignore them.
Rem Project: RailGame
Rem Created: Tuesday, May 29, 2012
rem Variables
type entitydata
bankindex as integer
name$ as string
x as float
y as float
z as float
rx as float
ry as float
rz as float
model$ as string
texpath$ as string
effect$ as string
endtype
dim entityelement(999) as entitydata
dim entitybank$(999)
Rem ***** Main Source File *****
sync on : sync rate 0
desktopwidth=desktop width()
desktopheight=desktop height()
set display mode desktopwidth,desktopheight,32
rem Initialise application and hide mouse pointer
autocam off : hide mouse : disable escapekey
Rem Set Directory
rootpath$ = "Files\"
level = 1
Rem Open Zip File containing Level
rem Load if exists
set dir rootpath$
rem Load if exists
levelfilename$="levelbank\level"+str$(level)+".zip"
if file exist(levelfilename$)=1
`
rem Read FPL into testlevel area
open file block levelfilename$,1,"mypassword"
perform checklist for file block data 1
tpath$="levelbank\testlevel\"
for i = 1 to checklist quantity( )
extract file from block 1, checklist string$( i ), tpath$
next i
close file block 1
`
endif
Rem Load Level Geometry
universefile$="levelbank\testlevel\universe.dbo"
load static objects universefile$,0
Rem Load Entities
open to read 1,"levelbank\testlevel\map.ent"
read file 1,entidmaster
if entidmaster>0
for entid=1 to entidmaster
read string 1,entitybank$(entid)
entitybank$(entid) = left$(entitybank$(entid),len(entitybank$(entid))-4)+".bin"
next entid
endif
close file 1
elementsfilename$ = "levelbank\testlevel\universe.ele"
open to read 1,elementsfilename$
read file 1,versionnumberload
read file 1,entityelementlist
e=0
while file end(1) = 0
read file 1,a
read file 1,a : entityelement(e).bankindex=a
read file 1,a
read float 1,a# : entityelement(e).x=a#
read float 1,a# : entityelement(e).y=a#
read float 1,a# : entityelement(e).z=a#
read float 1,a# : entityelement(e).rx=a#
read float 1,a# : entityelement(e).ry=a#
read float 1,a# : entityelement(e).rz=a#
read string 1,a$ : entityelement(e).name$=a$
read string 1,a$
read string 1,a$
read string 1,a$
read file 1,a
read string 1,a$
read string 1,a$
read string 1,a$
read file 1,a
read string 1,a$
read string 1,a$
read string 1,a$
read file 1,a :
read file 1,a :
read string 1,a$
read string 1,a$
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read string 1,a$
read string 1,a$
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read float 1,a#
read float 1,a#
read float 1,a#
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read string 1,a$
if versionnumberload>=102
rem Version 1.02
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read float 1,a#
read float 1,a#
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
endif
if versionnumberload>=103
rem Version 1.03 - V1 draft physics
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
endif
if versionnumberload>=104
rem Version 1.04 - BETA4 extra field
read file 1,a
endif
if versionnumberload>=105
rem Version 1.05 - BETA8 extra fields
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
endif
if versionnumberload>=106
rem Version 1.06 - BETA10 extra fields
read file 1,a
read file 1,a
endif
if versionnumberload>=107
rem FPSCV104RC8 - forgot to save infinilight index (dynamic lights in final build never worked)
read file 1,a
endif
if versionnumberload>=199
rem X10 EXTRAS - Ignored in X9
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
endif
if versionnumberload>=200
rem X10 EXTRAS 190707 - Ignored in X9
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
endif
if versionnumberload>=217
rem FPGC - 300710 - save new entity element data
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
read file 1,a
endif
if versionnumberload>=218
rem V118 - 060810 - knxrb - Decal animation setting (Added animation choice setting).
read file 1,a
endif
e = e + 1
endwhile
close file 1
Rem Place Entities based on name
entid = 1
for i = 0 to e-1
entid = 0
if entityelement(i).name$ = "Player Start"
playerstartx# = entityelement(i).x
playerstarty# = entityelement(i).y
playerstartz# = entityelement(i).z
playerstartrx# = entityelement(i).rx
playerstartry# = entityelement(i).ry
playerstartrz# = entityelement(i).rz
else
rem Read BIN File to load entity
rem quick and dirty method based on name
for j = 1 to entidmaster
n$ = entityelement(i).name$
en$ = entitybank$(j)
k = find sub string$(entitybank$(j),entityelement(i).name$)
if k > 5 then entid = j
NEXT
rem load binary version of entity profile file
if file exist("entitybank\"+entitybank$(entid))
open to read 1,"entitybank\"+entitybank$(entid)
read string 1,tstr$ : read file 1,tversion
read string 1,tstr$
read memblock 1,1
read string 1,tstr$
read string 1,tstr$
read string 1,tstr$
read string 1,tstr$
read string 1,tstr$
read string 1,tstr$
read string 1,tstr$
read string 1,tstr$
read string 1,tstr$
read string 1,tstr$:entityelement(i).model$ = left$(tstr$,len(tstr$)-2)+".dbo"
read string 1,tstr$
read string 1,tstr$ : entityelement(i).texpath$=left$(tstr$,len(tstr$)-4)+".dds"
read string 1,tstr$
close file 1
delete memblock 1
if file exist(entityelement(i).model$)
load object entityelement(i).model$ ,i+100,5
load image entityelement(i).texpath$, i+100,1
texture object i+100,i+100
position object i+100,entityelement(i).x,entityelement(i).y,entityelement(i).z
rotate object i+100,entityelement(i).rx,entityelement(i).ry,entityelement(i).rz
` sync
endif
skip_bin:
ENDIF
endif
NEXT
position camera playerstartx#,playerstarty#+70,playerstartz#
rotate camera playerstartrx#,playerstartry#,playerstartrz#
skip_load:
rem Main loop
while escapekey()=0
`
rem Control camera
gosub _camera
`
rem Keep light with camera
set point light 0,camera position x(),camera position y()+50,camera position z()
`
rem Update
text screen width()/2,screen height()-50,str$(cmx#)+","+str$(cmy#)+","+str$(cmz#)
sync
endwhile
rem Delete level
delete static objects
rem End program
end
_camera:
rem Read W,A,S,D keys for movement
tkeystate17=keystate(17)
tkeystate31=keystate(31)
tkeystate30=keystate(30)
tkeystate32=keystate(32)
rem Store CURRENT camera position
cox#=camera position x()
coy#=camera position y()
coz#=camera position z()
rem Determine camera direction
movement=0
if tkeystate17=1
if tkeystate30=1
y#=315 : movement=1
else
if tkeystate32=1
y#=45 : movement=1
else
y#=0 : movement=1
endif
endif
else
if tkeystate31=1
if tkeystate30=1
y#=225 : movement=1
else
if tkeystate32=1
y#=135 : movement=1
else
y#=180 : movement=1
endif
endif
else
if tkeystate30=1
y#=270 : movement=1
else
if tkeystate32=1
y#=90 : movement=1
endif
endif
endif
endif
rem Store camera angles
sx#=camera angle x()
sy#=camera angle y()
sz#=camera angle z()
rem Move camera in direction and restore camera angles
rotate camera 0,camera angle y()+y#,0
if movement=1 then move camera 3.0
rotate camera sx#,sy#,sz#
rem Store NEW camera position (and apply gravity)
cmx#=camera position x()
cmy#=camera position y()-gravity#
cmz#=camera position z()
rem Check volume collision between CURRENT and NEW camera positions
if static volume(cox#,coy#-25,coz#,cmx#,cmy#-25,cmz#,1.0)=1
`
rem If collision detected, determine material touching
materialtype=get static collision value()
`
rem If collision, calculate new ADJUSTED NEW camera position to avoid this collision
cmx#=cox#+get static collision x()
cmy#=coy#+get static collision y()
cmz#=coz#+get static collision z()
`
rem Reset gravity
gravity#=0.5
`
else
`
rem If no collision, must be in freefall so increase gravity
inc gravity#,0.5
`
endif
rem Update camera with ADJUSTED NEW position
position camera cmx#,cmy#,cmz#
rem Mouselook control
position mouse 400,300
cammovex#=mousemovex()*2
cammovey#=mousemovey()*2
camangx#=camera angle x()+cammovey#
camangy#=camera angle y()+cammovex#
if wrapvalue(camangx#)>85 and wrapvalue(camangx#)<180 then camangx#=85.0
if wrapvalue(camangx#)>180 and wrapvalue(camangx#)<275 then camangx#=275.0
rotate camera curveangle(camangx#,camera angle x(),15.0),curveangle(camangy#,camera angle y(),15.0),camera angle z()
return
Here you go guys. All that's left to do is load and place the weapons that the characters are carrying and of course clean up this code.

Enjoy!
-Anigma
It compiled! Ship it!