Here you go:
`SET UP REFRESH RATES
SYNC ON
SYNC RATE 0
HIDE MOUSE
`SPHERE TO REPRESENT CHARACTER(GREEN)
MAKE OBJECT SPHERE 1,50
COLOR OBJECT 1,RGB(000,255,000)
`SPHERE TO REPRESENT ENEMY(RED)
MAKE OBJECT SPHERE 2,50
COLOR OBJECT 2,RGB(255,000,000)
POSITION OBJECT 2,130,0,0
set object collision to spheres 2
`TEST WALL(WHITE)
MAKE OBJECT BOX 3,100,100,5
POSITION OBJECT 3,0,0,150
set object collision to boxes 3
`AIMING SYSTEM
MAKE OBJECT BOX 9999,10,5,500
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
ADD LIMB 1,1,1
OFFSET LIMB 1,1,0,0,250
DELETE MESH 1
`HIDE LIMB 1,1
`LIMB FOR PICKING GUP OBJECTS
MAKE OBJECT BOX 9999,20,30,40
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
ADD LIMB 1,2,1
OFFSET LIMB 1,2,0,-35,0
DELETE MESH 1
`HIDE LIMB 1,1
`AMMO CLIP (BLUE)
MAKE OBJECT BOX 4,15,20,50:COLOR OBJECT 4,RGB(000,255,255):POSITION OBJECT 4,-100,-40,0
set object collision on 4
`GIVE CAMERA A GOOD VIEW
POSITION CAMERA 0,500,-500
POINT CAMERA 0,0,0
set object collision to polygons 1
`DEFINE VARIABLES
EnemyHP#=5000
Ammo#=1000
MaxAmmo#=1000
Clips#=3
MaxClips#=3
`BEGIN MAIN LOOP
DO
`USE ARROW KEYS TO MOVE CHARACTER
IF UPKEY()=1 THEN MOVE OBJECT 1,.5
IF DOWNKEY()=1 THEN MOVE OBJECT 1,-.5
IF LEFTKEY()=1 THEN TURN OBJECT LEFT 1,.1.5
IF RIGHTKEY()=1 THEN TURN OBJECT RIGHT 1,.1.5
`CONTROL SHOOTING WITH MOUSE
IF KEYSTATE(19)=0 AND MOUSECLICK()=1
IF MOUSECLICK()=1
IF Ammo#>0
DEC Ammo#,1
ENDIF
if object collision(1,0) = 2
IF Ammo#>0
DEC EnemyHP#,1
ENDIF
ENDIF
ENDIF
IF EnemyHP#=0
IF OBJECT EXIST(2)=1
DELETE OBJECT 2
ENDIF
ENDIF
ENDIF
if object collision(1,0) > 0
center text 50,50,"hitting something"
endif
`DISPLAY ONSCREEN INFORMATION
IF OBJECT EXIST(2)=1
CENTER TEXT OBJECT SCREEN X(2),OBJECT SCREEN Y(2)-70,"Enemy Health: "+str$(EnemyHP#)
ENDIF
TEXT 0,SCREEN HEIGHT()-50,"Ammo: "+str$(Ammo#)
TEXT 0,SCREEN HEIGHT()-40,"Clips: "+str$(Clips#)
`RELOAD WEAPON WITH "R" BUTTON
IF MOUSECLICK()=0 AND KEYSTATE(19)=1 AND Ammo#<MaxAmmo# AND Clips#>0 THEN Ammo#=MaxAmmo#:DEC Clips#,1
`IF CHARACTER MOVES OVER AMMO BOX, PICK IT UP AND REPLACE AMMO
IF OBJECT EXIST(4)=1
IF Ammo#<MaxAmmo# AND object collision(1,0) = 4
INC Clips#,(MaxClips#-Clips#)
INC Ammo#,(MaxAmmo#-Ammo#)
DELETE OBJECT 4
ENDIF
ENDIF
`END MAIN LOOP
SYNC
LOOP
I changed:
if object collision(1,2)
IF Ammo#>0
DEC EnemyHP#,1
ENDIF
TO
if object collision(1,0) = 2
IF Ammo#>0
DEC EnemyHP#,1
ENDIF
and
IF Ammo#<MaxAmmo# AND object collision(1,4)
INC Clips#,(MaxClips#-Clips#)
INC Ammo#,(MaxAmmo#-Ammo#)
DELETE OBJECT 4
ENDIF
TO
IF Ammo#<MaxAmmo# AND object collision(1,0) = 4
INC Clips#,(MaxClips#-Clips#)
INC Ammo#,(MaxAmmo#-Ammo#)
DELETE OBJECT 4
ENDIF
I also added
set object collision to spheres objnr
set object collision to boxes objnr
set object collision to polygons objnr
It should work now.
Immunity and Annihalation makes Immunihalation...