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.

Author
Message
Pwnage
16
Years of Service
User Offline
Joined: 3rd Apr 2007
Location: Counter-Strike Source/My Computer
Posted: 12th Apr 2007 02:35
When I try to add a player object (a sphere) to the ai system it comes up with an error stating that the player object does not exist, here is the code

rem ai
ai start
ai add player 16










Rem Variables
playerhealth#=100
shotgunammo#=30
enemyhealth#=100
ammoclips#=1
teamkills#=0

rem bullet collision setup
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 bullet collision for enemys
IF mouseclick()=1 and object exist(7) AND INTERSECT OBJECT (7, LIMB POSITION X(16,1), LIMB POSITION Y(16,1), LIMB POSITION Z(16,1), OBJECT POSITION X(16),OBJECT POSITION Y(16), OBJECT POSITION Z(16)) THEN DEC Enemyhealth#,1
position object 16, camera position x(),camera position y(),camera position z()
rotate object 16,camera angle x(),camera angle y(),0
if enemyhealth#<0 then enemyhealth#=0
set object speed 7,20
if mouseclick()=1 and enemyhealth#=0 and shotgunammo#>0 and INTERSECT OBJECT (7, LIMB POSITION X(16,1), LIMB POSITION Y(16,1), LIMB POSITION Z(16,1), OBJECT POSITION X(16),OBJECT POSITION Y(16), OBJECT POSITION Z(16)) then play object 7,85
if enemyhealth#=0 then mouseclick()=0
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 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)


rem refresh screen
sync

plz help me!!!!
JerBil
19
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 12th Apr 2007 18:04 Edited at: 12th Apr 2007 18:05
You have to make object 16 before you can add it to AI.
You are trying to add it ahead of making the object.

Ad Astra Per Asper
Pwnage
16
Years of Service
User Offline
Joined: 3rd Apr 2007
Location: Counter-Strike Source/My Computer
Posted: 13th Apr 2007 01:45
lol i didnt realize the mistake was that simple I fixed it

Login to post a reply

Server time is: 2024-03-29 05:03:26
Your offset time is: 2024-03-29 05:03:26