QW physics user commands

QW physics. User commands.

With commands +forward +back +moveleft +moveright +moveup +movedown +speed player calculates values forwardmove, sidemove, upmove and sends them to server.

These values are determined by variables cl_sidespeed, cl_forwardspeed, cl_backspeed, cl_upspeed.

Also command +speed increases them for value of cl_movespeedkey (default 2) times.

Please note that server may send command to client to change those variables.

If 2 opposite commands are active simultaneously (for example +forward and +back) they are substracted from each other, that is they have no effect.

Values forwardmove, sidemove, upmove are sent to server and also are used in client for movement prediction.

Code for player movement must be the same on server and client.

Example: I have cl_forwardspeed 400 (ezquake default), Also in config I have string "+mlook;wait;+speed;wait;" which is executed at the client start.

When I press +forward I have forwardmove = 2 * 400 = 800. When transmitting values to server values forwardmove, sidemove, upmove are encoded as integers which are multiples of 4 with maximum value 508 (function MakeChar). So instaed of 800 value 508 is sent to server.

Hwguy and scout from TF are a bit unlucky. Server sends command to client to set value of cl_forwardspeed to 230 and 450 respectively and value cl_movespeedkey to 1. These values are not multiples of 4. So when you press forward you reach speed 228 and 448 respectively.

To fix that you may use custom forward command:

alias +custom_forward "cl_forwardspeed 500; +forward" alias -custom_forward "-forward"

They will run with theirs legal speed of 230 and and 450 respectively. (Both client and server know legal speed and use it).

Movement is processed in function PM_PlayerMove. There are several cases movement on ground, in air, in water.

Movement in air is described in next part: