The core code that I am using is Ruccus' tutorial code, but I am trying to tweak it to my liking. I want there to be an ammo crate, armor crate, sniper rifle, and shotgun. When the player passes over the armor crate, I want it to be delete and display armor HP over the original player hp in the bottom left of the screen. When the enemy fires at you and hits you, your armor hp will be decreased instead of your player hp until armor hp receahes 0, then your original hp is deducted. The problem is, when I run over the armor crate, DarkBASIC Pro tells me that 'the object does not exist at line 129'. What's up with that?
REMSTART
-------- Title: My First FPS
-------- Author: Krimzon DestinE
-------- Date: October 15, 2005
REMEND
`Setup Client Options
SYNC ON:SYNC RATE 0:HIDE MOUSE
`Define the main variables needed
EnemyHP=2000` Enemy's Health
Ammo=1000` Starting Ammo
MaxAmmo=1000` Maximum amount of Ammo
Clips=3` Starting Clips
MaxClips=3` Maximum amount of Clips
JUMPING=0`
ArmorHP=500
`Create Main Player
MAKE OBJECT SPHERE 1,50:COLOR OBJECT 1,RGB(000,255,000):POSITION OBJECT 1,RND(1000),Ground#,RND(1000)
`Create Enemy Player
MAKE OBJECT SPHERE 2,50:COLOR OBJECT 2,RGB(255,000,000):POSITION OBJECT 2,RND(1000),Ground#,RND(1000)
`create armor
MAKE OBJECT CUBE 3,10:COLOR OBJECT 3,RGB(167,176,10):POSITION OBJECT 3,100,Ground#,100
`create ammo crate
MAKE OBJECT CUBE 4,10:COLOR OBJECT 4,RGB(20,250,75):POSITION OBJECT 4,199,Ground#,199
`create sniper rifle
MAKE OBJECT CUBE 5,10:COLOR OBJECT 5,RGB(133,234,132):POSITION OBJECT 5,299,Ground#,299
`create sniper shotgun
MAKE OBJECT CUBE 6,10:COLOR OBJECT 6,RGB(33,34,13):POSITION OBJECT 5,299,Ground#,299
`create playing field
MAKE MATRIX 1,1000,1000,50,50
`make matrix the ground
Ground#=GET GROUND HEIGHT(1,posx#,posz#)+10
`Add limb for intersection checks
MAKE OBJECT SPHERE 9999,10
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
ADD LIMB 1,1,1
OFFSET LIMB 1,1,0,0,500
HIDE LIMB 1,1
`Add a second limb for ground checks
ADD LIMB 1,2,1
OFFSET LIMB 1,2,0,-50,0
DELETE MESH 1
HIDE LIMB 1,2
`Start main DO/LOOP
DO
`Camera Positioning
POSITION CAMERA OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1)
`Movement Controls
IF KEYSTATE(17)=1 THEN MOVE OBJECT 1,.9
IF KEYSTATE(31)=1 THEN MOVE OBJECT 1,-.9
IF KEYSTATE(30)=1 THEN MOVE OBJECT LEFT 1,.3
IF KEYSTATE(32)=1 THEN MOVE OBJECT RIGHT 1,.3
`Space key Controls
IF SPACEKEY()=1 AND JUMPING=0
JUMP_SPEED#=1
JUMPING=1
ENDIF
`Jumping
IF JUMPING=1
DEC JUMP_SPEED#,.005
POSITION OBJECT 1,OBJECT POSITION X(1),OBJECT POSITION Y(1)+JUMP_SPEED#, OBJECT POSITION Z(1)
IF OBJECT POSITION Y(1)<=Ground# THEN JUMPING=0
ENDIF
`Mouse Camera Movement
CAMY#=CAMY#+MOUSEMOVEX()*.1
CAMX#=CAMX#+MOUSEMOVEY()*.1
IF CAMX#>90 AND CAMX#<135 THEN CAMX#=90
IF CAMX#>270 AND CAMX#<225 THEN CAMX#=90
YROTATE CAMERA CAMY#
XROTATE CAMERA CAMX#
YROTATE OBJECT 1,CAMY#
XROTATE OBJECT 1,CAMX#
`Mouseclick Shooting
IF KEYSTATE(19)=0 AND MOUSECLICK()=1
IF Ammo>0 THEN DEC Ammo,1
IF OBJECT EXIST(2)=1
IF Ammo>0 AND INTERSECT OBJECT (2, LIMB POSITION X(1,1), LIMB POSITION Y(1,1), LIMB POSITION Z(1,1), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0 THEN DEC EnemyHP,1
ENDIF
ENDIF
`enemy death, deletions, and regeneration
if EnemyHP=0 AND OBJECT EXIST(2)=1
DELETE OBJECT 2
MAKE OBJECT SPHERE 2,50
COLOR OBJECT 2,RGB(255,000,000)
POSITION OBJECT 2,RND(600),Ground#,RND(600)
EnemyHP=2000
endif
`Reloading (press R)
IF MOUSECLICK()=0 AND KEYSTATE(19)=1 AND Ammo<MaxAmmo AND Clips>0
Reload=1
ENDIF
`Reloading Part 2 (delay)
IF Reload=1 THEN INC Time#,.005
IF Time#>=1 THEN Ammo=MaxAmmo:DEC Clips,1:Time#=0:Reload=0
`Ammo Crate code (obtain ammo from ground)
IF OBJECT EXIST(4)=1
IF Ammo<MaxAmmo AND INTERSECT OBJECT (4, LIMB POSITION X(1,2), LIMB POSITION Y(1,2), LIMB POSITION Z(1,2), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0
INC Clips,(MaxClips-Clips)
INC Ammo,(MaxAmmo-Ammo)
DELETE OBJECT 4
ENDIF
ENDIF
[b]
`Armor crate code (obtain armor from ground)
IF OBJECT EXIST(3)=1 AND INTERSECT OBJECT (3, LIMB POSITION X(1,2), LIMB POSITION Y(1,2), LIMB POSITION Z(1,2), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0
TEXT 0,SCREEN HEIGHT()-70,"Armor: "+str$(ArmorHP)
DELETE OBJECT 3
ENDIF
[/b]
`Display text above enemy and crate object
IF OBJECT EXIST(2)=1 THEN CENTER TEXT OBJECT SCREEN X(2),OBJECT SCREEN Y(2)-70,"Enemy Health: "+str$(EnemyHP)
IF OBJECT EXIST(3)=1 THEN CENTER TEXT OBJECT SCREEN X(3),OBJECT SCREEN Y(3)-20,"Armor"
IF OBJECT EXIST(4)=1 THEN CENTER TEXT OBJECT SCREEN X(4),OBJECT SCREEN Y(4)-20,"Ammo Crate"
IF OBJECT EXIST(5)=1 THEN CENTER TEXT OBJECT SCREEN X(5),OBJECT SCREEN Y(5)-20,"Sniper Rifle"
IF OBJECT EXIST(6)=1 THEN CENTER TEXT OBJECT SCREEN X(6),OBJECT SCREEN Y(6)-20,"Shotgun"
`Display our Ammo, Clips, Health, and Armor on-screen
TEXT 0,SCREEN HEIGHT()-60,"Health: "+str$(PlayerHp)
TEXT 0,SCREEN HEIGHT()-50,"Ammo: "+str$(Ammo)
TEXT 0,SCREEN HEIGHT()-40,"Clips: "+str$(Clips)
`Show that we're reloading
IF Reload=1 THEN CENTER TEXT SCREEN WIDTH()/2,SCREEN HEIGHT()/2,"Reloading..."
`Add a target reticule to the screen
CIRCLE SCREEN WIDTH()/2,SCREEN HEIGHT()/2,5
`Refresh the screen(SYNC) and call the LOOP function
SYNC
LOOP
the
bold part is where i'm having problems i think.