for some reason, it's not decreasing the enemy's hp when it is supposed to. i had it working and then when i tried to advance my code, somehow i messed it up. man is this frustrating the hell out of me.
`-------- Title: My First FPS-----------------------------------
`-------- Author: Krimzon DestinE-------------------------------
`-------- Date: October 15, 2005--------------------------------
`Setup Client Options
SYNC ON:SYNC RATE 0:HIDE MOUSE: AUTOCAM OFF:RANDOMIZE TIMER()
`---------------------------------------------------------------
`------------------Main Variables-------------------------------
`---------------------------------------------------------------
`make initial weapon Unarmed
global CWeapon=0
`weapon
type weapon
name as string
ammo as integer
maxammo as integer
clips as integer
maxclips as integer
endtype
`weapon array
dim weapon(3) as weapon
weapon(0).name="Unarmed"
weapon(1).name="Machinegun"
weapon(1).ammo=2000
weapon(1).maxammo=2000
weapon(1).clips=5
weapon(1).maxclips=5
weapon(2).name="Shotgun"
weapon(2).ammo=2000
weapon(2).maxammo=2000
weapon(2).clips=6
weapon(2).maxclips=6
weapon(3).name="Rocket Launcher"
weapon(3).ammo=2000
weapon(3).maxammo=2000
weapon(3).clips=3
weapon(3).maxclips=3
`Define the main variables needed
playerhp=2000`----------Player's Health
maxplayerhp=2000`-------Player's Max Health
enemyhp=2000`-----------Enemy's Health
MaxEnemyHP=2000`--------Enemy's Max Health
ArmorHP=500`------------Armor Health
play_out = 0`-----------Tells when player has gone off matrix
`---------------------------------------------------------------
`------------------In Game Objects------------------------------
`---------------------------------------------------------------
`Create Main Player
MAKE OBJECT SPHERE 1,50:COLOR OBJECT 1,RGB(255,000,000):POSITION OBJECT 1,RND(1000),Ground#+25,RND(1000)
`Create Enemy Player
MAKE OBJECT SPHERE 2,50:COLOR OBJECT 2,RGB(255,000,000):POSITION OBJECT 2,RND(1000),Ground#+25,RND(1000)
`create machinegun
MAKE OBJECT CUBE 3,10:COLOR OBJECT 3,RGB(000,000,255):POSITION OBJECT 3,100,Ground#+5,160
`create shotgun
MAKE OBJECT CUBE 4,10:COLOR OBJECT 4,RGB(000,000,255):POSITION OBJECT 4,100,Ground#+5,190
`create rocketlauncher
MAKE OBJECT CUBE 5,10:COLOR OBJECT 5,RGB(000,000,255):POSITION OBJECT 5,100,Ground#+5,220
`create armor
MAKE OBJECT CUBE 6,10:COLOR OBJECT 6,RGB(000,255,000):POSITION OBJECT 6,100,Ground#+5,250
`create ammo crate
MAKE OBJECT CUBE 7,10:COLOR OBJECT 7,RGB(000,255,000):POSITION OBJECT 7,100,Ground#+5,280
`create health crate
MAKE OBJECT CUBE 8,10:COLOR OBJECT 8,RGB(000,255,000):POSITION OBJECT 8,100,Ground#+5,310
`create playing field
MAKE MATRIX 1,1000,1000,50,50
`make matrix the ground
ground#=GET GROUND HEIGHT(1,0,0)
`---------------------------------------------------------------
`------------------Player Limbs---------------------------------
`---------------------------------------------------------------
`Add limb for intersection checks
MAKE OBJECT SPHERE 9999,10
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
ADD LIMB 1,1,1
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
`---------------------------------------------------------------
`------------------Main Do/Loop---------------------------------
`---------------------------------------------------------------
DO
`---------------------------------------------------------------
`------------------Info Display---------------------------------
`---------------------------------------------------------------
display_items()
`display text enemyhp above enemy
IF OBJECT EXIST(2)=1
IF OBJECT IN SCREEN(2)=1
CENTER TEXT OBJECT SCREEN X(2),OBJECT SCREEN Y(2)-70,"Enemy Health: "+str$(EnemyHP)
ENDIF
ENDIF
`Display health on-screen
TEXT 0,SCREEN HEIGHT()-80,"Health: "+str$(PlayerHP)
if CWeapon > 0
TEXT 0,SCREEN HEIGHT()-55,weapon(CWeapon).name
TEXT 0,SCREEN HEIGHT()-40,"Ammo: "+str$(weapon(CWeapon).ammo)
TEXT 0,SCREEN HEIGHT()-30,"Clips: "+str$(weapon(CWeapon).clips)
endif
`Add a target reticule to the screen
CIRCLE SCREEN WIDTH()/2,SCREEN HEIGHT()/2,5
`Fix player moving through the matrix
if posy# < ground#+25
posy# = ground#+25
position object 1,posx#, posy#, posz#
endif
`Screen FPS
FPS#=SCREEN FPS()
TEXT 500,0,"FPS: "+STR$(FPS#)
`Camera Positioning
POSITION CAMERA OBJECT POSITION X(1),OBJECT POSITION Y(1)+10,OBJECT POSITION Z(1)
`---------------------------------------------------------------
`------------------Movement Settings----------------------------
`---------------------------------------------------------------
`stop player from flying
xrotate object 1, 0
`Movement Controls
IF KEYSTATE(17)=1 THEN MOVE OBJECT 1,1
IF KEYSTATE(31)=1 THEN MOVE OBJECT 1,-1
IF KEYSTATE(30)=1 THEN MOVE OBJECT LEFT 1,1.5
IF KEYSTATE(32)=1 THEN MOVE OBJECT RIGHT 1,1.5
`Use variables to make code easier to read (shorter lines)
posx# = object position x(1)
posy# = object position y(1)
posz# = object position z(1)
legx# = LIMB POSITION X(1,2)
legy# = LIMB POSITION Y(1,2)
legz# = LIMB POSITION Z(1,2)
enemy_x# = object position x(2)
enemy_y# = object position y(2)
enemy_z# = object position z(2)
`prevent player from moving off matrix
if posx# < 0 then posx# = 0 : play_out = 1
if posx# > 1000 then posx# = 1000 : play_out = 1
if posz# < 0 then posz# = 0 : play_out = 1
if posz# > 1000 then posz# = 1000 : play_out = 1
if play_out = 1
position object 1, posx#, posy# , posz#
play_out = 0
endif
`Space key Controls
IF SPACEKEY()=1 AND JUMPING=0
JUMP_SPEED#=1
JUMPING=1
ENDIF
`Jumping
IF JUMPING=1
DEC JUMP_SPEED#,.009
POSITION OBJECT 1,posx#,posy#+JUMP_SPEED#, posz#
IF posy#<=ground#+25 THEN JUMPING=0
ENDIF
`Put player direction back to mouselook angle
xrotate object 1, CAMX#
`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#
`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 Part 2 (delay)
IF Reload=1 THEN INC Time#,.005
IF Time#>=1 THEN weapon(CWeapon).ammo=weapon(CWeapon).maxammo:DEC weapon(CWeapon).clips,1:Time#=0:Reload=0
`---------------------------------------------------------------
`------------------Enemy Code-----------------------------------
`---------------------------------------------------------------
if object exist(2)=1
point object 2,posx#,posy#,posz#
move object 2, .8
endif
`---------------------------------------------------------------
`------------------Weapons/Items--------------------------------
`---------------------------------------------------------------
`create machinegun
if object exist(3)=1
if intersect object (3, legx#,legy#,legz#,posx#,posy#,posz#)>0
delete object 3
CWeapon=1
endif
endif
`create shogun
if object exist(4)=1
if intersect object (4, legx#,legy#,legz#,posx#,posy#,posz#)>0
delete object 4
CWeapon=2
endif
endif
`create rocketlauncher
if object exist(5)=1
if intersect object (5, legx#,legy#,legz#,posx#,posy#,posz#)>0
delete object 5
CWeapon=3
endif
endif
`Get Armor
IF OBJECT EXIST(6)=1
IF INTERSECT OBJECT (6, legx#, legy#, legz#, posx#,posy#, posz#)>0
DELETE OBJECT 6
ENDIF
ENDIF
if object exist(6)=0
TEXT 0,SCREEN HEIGHT()-100,"Armor: "+str$(ArmorHP)
endif
`Ammo Crate code A (ammo increase)
IF OBJECT EXIST(7)=1
IF weapon(CWeapon).ammo<weapon(CWeapon).maxammo AND INTERSECT OBJECT (7, legx#, legy#, legz#, posx#,posy#,posz#)>0
INC weapon(CWeapon).ammo,(weapon(CWeapon).maxammo-weapon(CWeapon).ammo)
DELETE OBJECT 7
ENDIF
ENDIF
`ammo crate code B (clips increase)
if object exist(7)=1
If weapon(CWeapon).clips<weapon(CWeapon).maxclips and weapon(Cweapon).ammo>= weapon(Cweapon).maxammo
if INTERSECT OBJECT (7, legx#, legy#, legz#, posx#,posy#, posz#)>0
INC weapon(Cweapon).clips,1
delete object 7
endif
endif
endif
`health crate code
If PlayerHP<MaxPlayerHP and intersect object (8, legx#, legy#, legz#, posx#, posy#, posz#)>0
inc PlayerHP,(MaxPlayerHP-PlayerHP)
delete object 8
endif
`---------------------------------------------------------------
`------------------Shooting-------------------------------------
`---------------------------------------------------------------
`Mouseclick Shooting
if keystate(19)=0 AND mouseclick()=1
If weapon(CWeapon).ammo > 0 then dec weapon(CWeapon).ammo,1
if object exist(2)=1
If intersect object (2, limb position x(1,1), limb position y(1,1), limb position z(1,1), posx#, posy#, posz#)>0 then dec EnemyHP,1
endif
endif
`Reloading (press R)
IF MOUSECLICK()=0 AND KEYSTATE(19)=1 AND weapon(CWeapon).ammo<weapon(CWeapon).maxammo AND weapon(CWeapon).clips>0
Reload=1
ENDIF
`Show that we're reloading
IF Reload=1 THEN CENTER TEXT SCREEN WIDTH()/2,SCREEN HEIGHT()/2,"Reloading..."
SYNC
LOOP
function SetWeapon()
select CWeapon
case 0: offset limb 1,1,0,0,10: endcase
case 1:offset limb 1,1,0,0,500: endcase
case 2:offset limb 1,1,0,0,600: endcase
case 3: offset limb 1,1,0,0,10000: endcase
endselect
endfunction
function display_items()
IF OBJECT EXIST(3)=1
IF OBJECT IN SCREEN(3)=1
CENTER TEXT OBJECT SCREEN X(3),OBJECT SCREEN Y(3)-20,"Machinegun"
ENDIF
ENDIF
IF OBJECT EXIST(4)=1
IF OBJECT IN SCREEN(4)=1
CENTER TEXT OBJECT SCREEN X(4),OBJECT SCREEN Y(4)-20,"Shotgun"
ENDIF
ENDIF
IF OBJECT EXIST(5)=1
IF OBJECT IN SCREEN(5)=1
CENTER TEXT OBJECT SCREEN X(5),OBJECT SCREEN Y(5)-20,"Rocket Launcher"
ENDIF
ENDIF
IF OBJECT EXIST(6)=1
IF OBJECT IN SCREEN(6)=1
CENTER TEXT OBJECT SCREEN X(6),OBJECT SCREEN Y(6)-20,"Armor"
ENDIF
ENDIF
IF OBJECT EXIST(7)=1
IF OBJECT IN SCREEN(7)=1
CENTER TEXT OBJECT SCREEN X(7),OBJECT SCREEN Y(7)-20,"Ammo"
ENDIF
ENDIF
IF OBJECT EXIST(8)=1
IF OBJECT IN SCREEN(8)=1
CENTER TEXT OBJECT SCREEN X(8),OBJECT SCREEN Y(8)-20,"Health"
ENDIF
ENDIF
endfunction
i would really appreciate it!!!