Forum

Walk speed

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Walk speed

Postby SkinnedAlive » Wed Aug 02, 2006 3:39 pm

Is there any way to set seperate walk and run speeds either by cvars or qc?

I've tried sv_maxspeed and cl_<whatever>speed but it leaves the walk speed at the same default value.
SkinnedAlive
 
Posts: 65
Joined: Fri Feb 25, 2005 5:03 pm

Re: Walk speed

Postby shadowtails » Wed Aug 02, 2006 5:05 pm

You can make it lake this:

void() W_WeaponFrame =
{
if (time < self.attack_finished)
return;

ImpulseCommands ();
if (self.weapon == IT_AXE) {
stuffcmd(self,"cl_backspeed 400\n");
stuffcmd(self,"cl_forwardspeed 400\n");
stuffcmd(self,"cl_sidespeed 400\n");
}
else if (self.weapon == IT_SHOTGUN) {

stuffcmd(self,"cl_backspeed 320\n");
stuffcmd(self,"cl_forwardspeed 320\n");
stuffcmd(self,"cl_sidespeed 320\n");
}
else if (self.weapon == IT_SUPER_SHOTGUN) {

stuffcmd(self,"cl_backspeed 320\n");
stuffcmd(self,"cl_forwardspeed 320\n");
stuffcmd(self,"cl_sidespeed 320\n");
}
else if (self.weapon == IT_NAILGUN) {

stuffcmd(self,"cl_backspeed 320\n");
stuffcmd(self,"cl_forwardspeed 320\n");
stuffcmd(self,"cl_sidespeed 320\n");
}
else if (self.weapon == IT_SUPER_NAILGUN) {

stuffcmd(self,"cl_backspeed 320\n");
stuffcmd(self,"cl_forwardspeed 320\n");
stuffcmd(self,"cl_sidespeed 320\n");
}
else if (self.weapon == IT_GRENADE_LAUNCHER) {
stuffcmd(self,"cl_forwardspeed 320\n");
stuffcmd(self,"cl_sidespeed 320\n");
stuffcmd(self,"cl_backspeed 320\n");
}
else if (self.weapon == IT_ROCKET_LAUNCHER) {

stuffcmd(self,"cl_backspeed 320\n");
stuffcmd(self,"cl_forwardspeed 320\n");
stuffcmd(self,"cl_sidespeed 320\n");
}
else if (self.weapon == IT_LIGHTNING) {
stuffcmd(self,"cl_backspeed 320\n");
stuffcmd(self,"cl_forwardspeed 320\n");
stuffcmd(self,"cl_sidespeed 320\n");
}


// check for attack
if (self.button0)
{
SuperDamageSound ();
W_Attack ();
}
};

Change it to your speed
shadowtails
 
Posts: 11
Joined: Sun Jul 30, 2006 7:16 am

Postby SkinnedAlive » Wed Aug 02, 2006 6:32 pm

I think I may have gotten confused as to what these cvars actually do...

Am I right in thinking that cl_forwardspeed, backspeed, etc set the walk speed of the player and sv_maxspeed sets the run?
SkinnedAlive
 
Posts: 65
Joined: Fri Feb 25, 2005 5:03 pm

Postby shadowtails » Wed Aug 02, 2006 7:48 pm

yeah it set player how speed will he moves
shadowtails
 
Posts: 11
Joined: Sun Jul 30, 2006 7:16 am

Postby FrikaC » Wed Aug 02, 2006 7:54 pm

cl_*speed sets the individual rates of the various movement keys on the client's machine -- it's a client side cvar, so be aware all you need to do to 'cheat' with it is bring down the console and change the value.

sv_maxspeed sets the maximum player movement speed for everyone in the game, regarless of what the various cl_*speed keys are set to.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby Sajt » Wed Aug 02, 2006 7:56 pm

cl_movespeedkey sets the multiplier when holding down +speed (default 2.0).
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby SkinnedAlive » Wed Aug 02, 2006 8:04 pm

Great, cheers guys.

Edit: It might be a good idea if somebody who knows what they're talking about adds this information to the wiki.
SkinnedAlive
 
Posts: 65
Joined: Fri Feb 25, 2005 5:03 pm

Postby spamalam » Tue Aug 08, 2006 5:46 pm

oh dear, well i did this for modifying the run speed when holding a particular weapon:

Code: Select all
    // v 0.0.2 - Slow down the player if they are on the ball
    if (self.enemy.classname == "soccer_ball")
    {
        self.velocity = self.velocity * 0.5;
    }


Is this a bad way of doing it? Are the cmds a better of doing it? With that all the forward/backward/side are modified to half and it seemed to work.
User avatar
spamalam
 
Posts: 31
Joined: Mon Jul 10, 2006 7:15 am

Postby Sajt » Tue Aug 08, 2006 8:40 pm

That's a terrible way. I wonder if you set 'self.gravity = 2;' it would work though..
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby spamalam » Tue Aug 08, 2006 8:45 pm

Sajt wrote:That's a terrible way.


elaborate please. ;)
User avatar
spamalam
 
Posts: 31
Joined: Mon Jul 10, 2006 7:15 am

Postby Lardarse » Tue Aug 08, 2006 10:02 pm

If I'm reading that correctly, it will either halve the player's speed every frame, making them slow down very fast, or only affect the current speed of the player, meaning that they will speed up very soon after.

Better would be coping self_velocity, removing the z component, and then checking if the vector length is above 160. If it is, then scale the vector down until it is 160 long. Then add back in the z component and put that back into self.velocity
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby spamalam » Tue Aug 08, 2006 10:14 pm

ah okay, that makes sense. When i was using it it didn't seem to have any adverse effects though, wonder why.
User avatar
spamalam
 
Posts: 31
Joined: Mon Jul 10, 2006 7:15 am

Postby FrikaC » Tue Aug 08, 2006 11:06 pm

If you do that every frame, it will be framerate dependant. As certain engines enforce certain server frame rates (DP does this even in listen multiplayer, QW does this) under those engines it will seem fine. Under normal quake engines, it will act odd and inconsistanty.

The code you should use, as was mentioned is something akin to:

local float len;

len = vlen(self.velocity);
if (len>160)
self.velocity = normalize(self.velocity)*160;

or such.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby TimeServ » Wed Aug 09, 2006 12:37 am

QW server physics is packet rate dependant for client entities, but in QW you have the maxspeed field which allows you to set the maximum running speed.
TimeServ
 
Posts: 38
Joined: Wed Jun 08, 2005 4:02 pm

Postby FrikaC » Wed Aug 09, 2006 5:02 am

Right. I should've mentioned that.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest