Player Speed

Discuss programming in the QuakeC language.
Post Reply
ajay
Posts: 559
Joined: Fri Oct 29, 2004 6:44 am
Location: Swindon, UK

Player Speed

Post by ajay »

I have done a search for this, but results were almost but not quite what I was after. Probably needed to spend more time. Lazy.
Anyway; player speed. I've messed with player speed before; slowing them down dependant on what weapon was being carried. However, I'm still unsure about a few things:

1) What's the most efficient way of adjusting player speed? stuffcmd(self,"cl_forwardspeed 400\n"); type thing, or is there a better way?
2) In the example in bold above, does that change the walking or running speed?
3) If walking speed, does the running speed stay the same or is it a percentage increase of the walking speed?
4) If it changes the running speed, how do you change the walking speed?

For some, probably only partially, helpful background, I'm basically wanting to slow the player walking speed down to something realistic (that scary pretence!) and slow the running speed down to a realistic (again!) and temporary increase of that.

As always, thanks for any and all support.

ajay
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Player Speed

Post by Spike »

.float maxspeed;

use it. it is your friend.

Edit: I'm informed that maxspeed is QW only.
for reference, correct values are in qu. It is not a scaler.
Last edited by Spike on Wed Oct 23, 2013 6:22 pm, edited 1 time in total.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: Player Speed

Post by r00k »

thew walk and run speed is the same its just lower values feel like your walking and higher speed is running.

I did this in my QBall mod, where the ball carrier would run 20% slower.
in playerprethink

Code: Select all

		if ((self.flags) & FL_ONGROUND)
		{
			self.velocity_x = (1 - ((0.9 * (3)) * frametime)) * (self.velocity_x);// slow down ball carrier
			self.velocity_y = (1 - ((0.9 * (3)) * frametime)) * (self.velocity_y);// slow down ball carrier
		}

you could use an impulse to toggle run or walk i suppose....
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Player Speed

Post by Nahuel »

well, i get something like you said usin maxspeed value in player_prethink function, when you crouch

Code: Select all

self.velocity_x = self.velocity_x * self.maxspeed;
self.velocity_y = self.velocity_y * self.maxspeed;
i defined "maxspeed" value default as 0.85
after you can call a function like this in "player_run" function

Code: Select all

if (vlen(self.velocity) >= 120) // adjust 120 value is the minor velocity when you are "runing"
{
if (self.maxspeed >= 0.85)
self.maxspeed = self.maxspeed - *a very little value here* ;
}
else
{
if (self.maxspeed < 0.85)
self.maxspeed = self.maxspeed + *a very little value here* ;
}
but when you are walking maybe you need to get more stamine in a few time
so in player_stand function

Code: Select all

if (self.maxspeed < 0.85)
self.maxspeed = self.maxspeed + *a very little value here but bigger than the first values * ;

EDIT: be careful with the jump values and maxspeed function
hi, I am nahuel, I love quake and qc.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Player Speed

Post by Cobalt »

If using DP, include the supplied svplayerphysics.qc file, in it theres a wishspeed float already coded that works very well.

vlen (self.velocity) also has some uses...some examples of it are here on this site somewhere.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Player Speed

Post by Cobalt »

Got another question related to player movememt, may have asked it before but wanna make sure.

There is really no way to set the rate at with the client executes pitch or yaw? [ with Darkplaces mostly ]

cl_yawspeed and cl_pitchspeed will work on the keyboard but not the mouse. If you are doing multiplayer
stuffing the mousespeed cvar is sucky. I have tried .avelocity and does not work. Is it possible using .angles
or v_angle ?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Player Speed

Post by Spike »

Client view angles are owned by the client not the server. This allows the client to look around without waiting for an echo off the server. Latency sucks. Trying to override it on the server will seriously fuck everything up.
m_pitch and m_yaw control the indivudal mouse axis speeds. Beware that invert mouse is implemented by inverting the sign of m_pitch, so be sure to preserve the sign. Or you can override the user's sensitivity. Either way whatever you do will suck. Yay.
Max_Salivan
Posts: 96
Joined: Thu Dec 15, 2011 1:00 pm

Re: Player Speed

Post by Max_Salivan »

one time i used cvar_set ("sv_maxspeed", "80"); in worldspawn function for player's speed :lol:
Sorry for my english :)
Post Reply