Just like the title states I currently have a problem of my bullet array falling out of bounds I've isolated the problem that when every I perform a check on a value inside an array using the IF statement my FireGun subroutine fails
Heres the section that the Array is set up, this section runs flawlessly:
Type bullet
Bulletnumber as integer
BulletDBPnumber as integer
BulletInUse as Boolean
OldBulletposx as Float
OldBulletposy as Float
OldBulletposz as Float
Bulletposx as Float
Bulletposy as Float
Bulletposz as Float
Endtype
Dim bullets(12) as bullet
For i=1 to 12
Make object sphere 25+i,0.5,4,2
SC_setupObject 25+i,0,1
Hide object 25+i
SC_setObjectCollisionOff 25+i
bullets(i).BulletInuse=0
next i
Return
And here is the subroutine that fails (Bold command is the one that is reported to have gone out of bounds:
FireGun:
`bullet Fire
Playeraimx#=(sin(objectangley#)*cubesize)+object position x(player)
Playeraimz#=(cos(objectangley#)*cubesize)+object position z(player)
For e=1 to 12
[b]If bullets(e).BulletInuse=0[/b]
Show object 25+i
Position object 25+i,Playeraimx#,object position y(player),Playeraimz#
Sc_SetObjectcollisionOn 25+i
Position object player,object position x(player),object position y(player),object position z(player)
Point object 25+i,Playeraimx#, object position y(player),Playeraimz#
State=1
bullets(e).BulletInUse=1
bullets(e).OldBulletposX=object position x(25+i)
bullets(e).OldBulletposY=object position y(25+i)
bullets(e).OldBulletposZ=object position z(25+i)
bullets(e).BulletposX=object position x(25+i)
bullets(e).BulletposY=object position y(25+i)
bullets(e).BulletposZ=object position z(25+i)
Shottime=Timer()
ENDIF
NEXT e
Return
I've attempted a Debug and the Debugger returns a "Broke from nested subroutine cannot return to CLI" Error. Am aware that the subroutine for the Playerinput and Bullet fired is the same, but could this cause the problem?