Page 1 of 1
scripting weapons
Posted: Sat Feb 24, 2007 10:00 pm
by darksmaster923
errr....how to?

oh yeah, i also want iron sights in the script
and 1 2 3 4 5 etc as select weapons
i need a step by step tut!
PLEASE!!! I NEED ONE!!!!!!!!!!!!!!!!!!!1
Posted: Mon Feb 26, 2007 5:01 am
by darksmaster923
never mind i updated my code but it doesnt shoot
Code: Select all
{
Spawn[ ()
{
Console(true); //Turns on debug
Gravity(false); //No grav
SetNoCollision(); //No coll
HideFromRadar(true);
BoxWidth(0);
BoxHeight(20);
LowLevel("Setup");
} ]
Setup[ ()
{
PositionToPawn("player",0,0+0+25*sin(-self.camera_pitch),25*cos(self.camera_pitch),true,false);
self.ideal_pitch = self.camera_pitch;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
ChangePitch();
PawnRender(false);
self.ThinkTime = 0;
if(self.lbutton_pressed)
{
SetTargetPoint(500 + random(-100,100),1000 + random(-100,100),0);
FireProjectile("rifle_shell", "BIP01", 25, 25, 25, "enemy_health");
}
} ]
}
Posted: Mon Feb 26, 2007 2:39 pm
by Juutis
Code: Select all
PositionToPawn("player",0,0+0+25*sin(-self.camera_pitch),25*cos(self.camera_pitch),true,false);
If you want the weapon to move with the built-in player, you have to use "Player" as the entityname. There's a difference between 'p' and 'P'.
Code: Select all
SetTargetPoint(500 + random(-100,100),1000 + random(-100,100),0);
Let me make the offsets clear.
X = left / right
Y = up / down
Z = front / back
So you're telling the pawn to shoot projectiles to the far-right and very high.
Instead, use a large number for the Z-offset (the last parameter), and give a small random value to X and Y.
You also need a 'self.ThinkTime = ...' in the Setup order.
Posted: Tue Feb 27, 2007 1:34 am
by darksmaster923
okay, but clicky dont work X(
Code: Select all
{
Spawn[ ()
{
Console(true); //Turns on debug
Gravity(false); //No grav
SetNoCollision(); //No coll
HideFromRadar(true);
BoxWidth(0);
BoxHeight(20);
LowLevel("Setup");
} ]
Setup[ ()
{
self.ThinkTime = 0.05;
PositionToPawn("Player",0,0+0+25*sin(-self.camera_pitch),25*cos(self.camera_pitch),true,false);
self.ideal_pitch = self.camera_pitch;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
ChangePitch();
PawnRender(false);
if(self.lbutton_pressed) //SHOOT!!!!
{
PlaySound("weapon\modern\m16a2.wav",500);
self.ThinkTime = 0.05;
SetTargetPoint(0,0,25);
FireProjectile("rifle_shell", "BIP01", 25, 25, 25, "enemy_health");
}
} ]
}