Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Bullet Collision

Author
Message
Pwnage
17
Years of Service
User Offline
Joined: 3rd Apr 2007
Location: Counter-Strike Source/My Computer
Posted: 6th Apr 2007 02:54
Hey guys I was wondering if you could tell me what is wrong with my intersect object command? It doent register a hit when i shoot . Here is the code:

playerhealth#=100
shotgunammo#=30
enemyhealth#=100
ammoclips#=1
shotgundamage#=50
pistoldamage#=10
teamkills#=0

make object sphere 16,20
MAKE OBJECT SPHERE 9999,10
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
ADD LIMB 16,1,1
OFFSET LIMB 16,1,0,0,5000
HIDE LIMB 16,1


REM load world
load bsp "map/swat map.pk3" , "swat map.3dw.bsp"
rem load all objects
load object "shotgun/h-shotgun-static.x" , 2
load object "pistol/h-pistol-static.x" , 6
load object "swat/h-swat-idle.x",1
append object "swat/h-swat-attack1.x",1,total object frames (1)
append object "swat/h-swat-impact.x",1,total object frames (1)
append object "swat/h-swat-move.x",1,total object frames(1)
append object "swat/h-swat-die.x",1,total object frames (1)
load object "thug/l-thug-idle.x",7
append object "thug/l-thug-attack1.x",7,total object frames (7)
append object "thug/l-thug-impact.x",7,total object frames (7)
append object "thug/l-thug-move.x",7,total object frames (7)
append object "thug/l-thug-die.x",7,total object frames (7)
scale object 1,4000,4000,4000
scale object 7,4000,4000,4000
set object smoothing 7,100
set object smoothing 1,100


rem load all sounds
load sound "guns/gun 6.wav",3
load sound "guns/rifle reload.wav",4

rem load crosshair and lock it to the screen
load image "crosshair/crosshair.bmp",5
load image "crosshair/thumbnail[1].jpg",8
sprite 1,320-16,240-16,5
sprite 2,380,270,8
scale sprite 2,14
hide sprite 2
set bsp camera collision radius 1,0,50,50,50
set bsp object collision radius 2,1,45,45,45
set bsp object collision radius 3,7,38,38,38
position object 7,0,0,70

rem position player in bsp world
position camera camera position x()-500,camera position y()+140,camera position z()

rem setup guns for player
lock object on 2
scale object 2,500,500,500
position object 2,1,-1,0.5
rotate object 2,270,0,0
disable object zdepth 2
pitch object down 2,90
lock object on 6
scale object 6,800,800,800
position object 6,1,-1,0.5
rotate object 6,270,0,0
disable object zdepth 6
pitch object down 6,90
hide object 6

rem main game loop
do

rem camera control
rotate camera camera angle x(0)+(mousemovey()/2.0),camera angle y(0)+(mousemovex()/2.0),0
cx#=camera angle x(0) : cy#=camera angle y(0)
if keystate(17) then xrotate camera 0,0 : move camera 0,0.5 : xrotate camera 0,cx#
if keystate(31) then xrotate camera 0,0 : move camera 0,-0.5 : xrotate camera 0,cx#
if keystate(30) then yrotate camera 0,cy#-90 : move camera 0.5 : yrotate camera 0,cy#
if keystate(32) then yrotate camera 0,cy#+90 : move camera 0.5 : yrotate camera 0,cy#
position camera camera position x(),camera position y()-0.3,camera position z()
position object 1,object position x(1),object position y(1)-0.1,object position z(1)
position object 7,object position x(7),object position y(7)-0.1,object position z(7)
if wrapvalue(camera angle x(0))>40 and wrapvalue(camera angle x(0))<180 then xrotate camera 0,40
if wrapvalue(camera angle x(0))>180 and wrapvalue(camera angle x(0))<280 then xrotate camera 0,280


rem weapon control
if keystate(3) then show object 6
if keystate(3) then hide object 2
if keystate(2) then hide object 6
if keystate(2) then show object 2
if mouseclick()=1 and flag=0 then dec shotgunammo#
if shotgunammo#<0 then flag=1
if shotgunammo#<0 then shotgunammo#=0
if mouseclick()=1 and flag=0 then show sprite 2
if mouseclick()=1 and flag=0 then play sound 3
flag=1
if mouseclick()=0 then flag=0
if mouseclick()=0 then hide sprite 2
if mouseclick()=2 and delay=50 then play sound 4
if mouseclick()=2 and ammoclips#>0 then inc shotgunammo#,30
if mouseclick()=2 and delay=50 then dec ammoclips#
if ammoclips#=0 then delay=0
if ammoclips#<=0 then ammoclips#=0
delay=0
if mouseclick()=0 then delay=50

rem collision for enemys
position object 16, camera position x(),camera position y(),camera position z()
rotate object 16,camera angle x(),camera angle y(),0
IF mouseclick()=1 AND INTERSECT OBJECT (7, LIMB POSITION X(16,1), LIMB POSITION Y(16,1), LIMB POSITION Z(16,1), OBJECT POSITION X(7),OBJECT POSITION Y(7), OBJECT POSITION Z(7))>0 THEN DEC EnemyHP#,1
if enemyhealth#<0 then play object 7
rem bsp collision
set bsp camera 0
process bsp collision 2
process bsp collision 3
if restart=1
restart=0
set bsp collision off 1
rotate camera 0,0,0
position camera 2,2,2
set bsp camera collision 1,0,0.75,0
endif

rem object visible commands
if object visible (6) then flag=1
if object visible (6) then stop sound 4

rem object test
if controlkey()=1
play object 7
set object speed 7,8
endif
if returnkey()=1
play object 1
set object speed 1,8
endif

rem print stats
print "shotgunammo "+str$(shotgunammo#)
text 550,450, "Clips "+str$(ammoclips#)
IF OBJECT EXIST(7)=1 THEN CENTER TEXT OBJECT SCREEN X(7),OBJECT SCREEN Y(7)-70,"Enemy Health: "+str$(Enemyhealth#)


Init_game()

loop

rem bsp collision
restart=1

Function Init_game()
sync off
hide mouse
autocam off
endfunction (1)

Function AI()
ai start
endfunction (2)

rem refresh screen
sync

Any help would be great thanks!!!
zeeenza
18
Years of Service
User Offline
Joined: 2nd Jul 2006
Location:
Posted: 6th Apr 2007 07:10
I think this is your problem...



should be



The last 3 parameters should be the position of your player's object. Not the enemy's.
Pwnage
17
Years of Service
User Offline
Joined: 3rd Apr 2007
Location: Counter-Strike Source/My Computer
Posted: 12th Apr 2007 00:34
Thank You

Login to post a reply

Server time is: 2024-11-25 20:31:02
Your offset time is: 2024-11-25 20:31:02