The limb is for aiming from object 1(which is player 1,who has the rifle) to limb 32,offset 1000 units away,which when object 1 rotates it rotates with it,any enemy in between using the intersect object command gets health dec,when the spacekey is pressed and mouse click,also the camera changes to 1st person view,when the spacekey isnt pressed it follows in 3rd person view,everything runs well with this code,I just need a little help rotating the offset limb when the spacekey is pressed with the mouse.
"hide mouse
autocam off
Load object "Walkcycle1,22,Waiting23,283,2.x",1
Load object "paratrooper3b.dbo",2
position object 2, -220,-11,-50
show object 2
Position object 1, x#, 0, z#
yrotate object 1,90
xrotate object 1,90
cy = object size y(1)/2
Position camera x#, cy + 15, z# -50
point camera 0, cy, 0
set object speed 1,39
show object 1
rem enemy
MAKE OBJECT SPHERE 3,50
COLOR OBJECT 3,RGB(255,000,000)
POSITION OBJECT 3,130,10,500
rem ammo
MAKE OBJECT BOX 4,15,20,50:COLOR OBJECT 4,RGB(000,255,255):POSITION OBJECT 4,140,2,90
EnemyHP#=100
Ammo#=30
MaxAmmo#=30
clips#=3
`perform checklist for object limbs 1
`limb_count = GET LIMB COUNT(1)
`print limb_count
MAKE OBJECT SPHERE 9999,10
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
ADD LIMB 1,32,1
OFFSET LIMB 1,32,0,-1000,-10
`DELETE MESH 1
Camdist# = 55.0
TrackAngle = 180: Rem 0 - Behind, 180 - Front, 90 & 270 - Sides
CamHeight# = 15.0
Camsmooth = 10
ColFlag = 0
do
rem xxxxxxxxxxxxxxxxxx control player1 xxxxxxxxxxxxxxxxxxxxxxxxxx
rem running
`if shiftkey() = 1 and upkey() = 1
`position object 1, x#, 0, z#
`loop object 1,264,286
`x# = newxvalue( x#, object angle y(1), -0.21 )
`z# = newzvalue( z#, object angle y(1), -0.21 )
`position camera x#, cy + 15, z# -50
`endif
rem waiting
`print limb_count
if upkey() = 0 and spacekey() = 0
`position camera x#, cy + 15, z# -50
Set Camera To Follow X#, Y#, Z#,WrapValue(Object Angle Y(1)+TrackAngle), Camdist#,Camheight#,Camsmooth,ColFlag
point camera x#, cy, z#
position object 1, x#, y, z#
loop object 1,23,283
endif
rem walk forwards
if upkey() = 1 and spacekey() = 0
position object 1, x#, y, z#
loop object 1,1,22
x# = newxvalue( x#, object angle y(1), -0.13 )
z# = newzvalue( z#, object angle y(1), -0.13 )
`position camera x#, cy + 15, z# -50
point camera x#, cy, z#
Set Camera To Follow X#, Y#, Z#,WrapValue(Object Angle Y(1)+TrackAngle), Camdist#,Camheight#,Camsmooth,ColFlag
endif
rem switch view to aiming and firing
if spacekey() = 1
stop object 1
set object frame 1,23
position camera x#, 8, z#
`yrotate camera ay#
`mx = 320
`my = 240
rem get mouse x y
mousex()=mx
mousey()=my
mx = 320
my = 160
rem draw line from x y
line mx-10 ,my ,mx+10 ,my
line mx ,my-10 ,mx ,my+10
rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
rem heres where I need the limb 32,mesh1 to rotate with the camera and mouse
rotate camera camera angle x()+mousemovey(),camera angle y()+mousemovex(),0
`ROTATE LIMB mousemovey,32, x, my, z
`rotate limb mousemovex, 32, mx, y, z
rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
IF MOUSECLICK()=1
IF Ammo#>0
DEC Ammo#,1
ENDIF
IF OBJECT EXIST(3)=1
IF Ammo#>0
IF INTERSECT OBJECT (3, LIMB POSITION X(1,32), LIMB POSITION Y(1,32), LIMB POSITION Z(1,32), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0
DEC EnemyHP#,1
ENDIF
ENDIF
ENDIF
ENDIF
rem
endif
IF EnemyHP#=0
IF OBJECT EXIST(3)=1
DELETE OBJECT 3
ENDIF
ENDIF
rem reload with R if ammo = 0
IF KEYSTATE(19)=1 AND Ammo#=0
if clips#>=1
Ammo#=MaxAmmo#
clips#=clips#-1
endif
if clips#=<0 and ammo#=0
clips#=0
endif
endif
IF OBJECT EXIST(3)=1
CENTER TEXT OBJECT SCREEN X(3),OBJECT SCREEN Y(3)-70,"Enemy Health: "+str$(EnemyHP#)
ENDIF
rem print ammo
TEXT 0,SCREEN HEIGHT()-50,"Ammo: "+str$(Ammo#)
IF OBJECT EXIST(4)=1
IF clips#<=2 AND INTERSECT OBJECT (4, OBJECT POSITION X(1),OBJECT POSITION Y(1)-25,OBJECT POSITION Z(1),OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1))>0
rem pick up ammo
IF INTERSECT OBJECT (4, OBJECT POSITION X(1),OBJECT POSITION Y(1)-25,OBJECT POSITION Z(1),OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1))>0
INC Clips#
`INC Ammo#,(MaxAmmo#-Ammo#)
DELETE OBJECT 4
ENDIF
endif
endif
rem print clips
TEXT 0,SCREEN HEIGHT()-40,"Clips: "+str$(Clips#)
Rem Left and Right
If Leftkey()=1 then aY# = Wrapvalue(aY#-3)
If Rightkey()=1 then aY# = Wrapvalue(aY#+3)
`rem rotate the Player1
Yrotate object 1,aY# + 180
`yrotate camera ay#
rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
loop"