Player speed variable in HL code Created 7 years ago2017-10-16 10:56:03 UTC by Mr Gnang Mr Gnang

Created 7 years ago2017-10-16 10:56:03 UTC by Mr Gnang Mr Gnang

Posted 7 years ago2017-10-16 10:56:03 UTC Post #337774
Hello again guys!

I am somehow failing to find the player speed variables in the Half-Life code. I am hoping to make the player slower than the breakneck speed of the one free man. Hopefully someone can point out the obvious place I am missing!

Cheers as always
Posted 7 years ago2017-10-16 11:50:47 UTC Post #337775
There are 2 things to consider:
First, the global maximum speed setting, governed by sv_maxspeed. Can be changed in ServerActivate: https://github.com/ValveSoftware/halflife/blob/5d761709a31ce1e71488f2668321de05f791b405/ricochet/dlls/client.cpp#L657

Second, the per-player speed. Can be changed anytime, but usually in the player's Spawn method to set the initial speed, and anywhere else when it needs to be altered: https://github.com/ValveSoftware/halflife/blob/5d761709a31ce1e71488f2668321de05f791b405/dmc/dlls/player.cpp#L2886

I would advise against directly modifying pev->maxspeed, but you can read from it to get the player's current maximum speed.
Posted 7 years ago2017-10-17 15:45:16 UTC Post #337780
Also
cl_forwardspeed
cl_backspeed
cl_sidespeed

Default is "400".
Posted 7 years ago2017-10-18 11:10:49 UTC Post #337785
Thanks for the info! Is it possible to add the cl_ values in a config file rather than code it in?
Posted 7 years ago2017-10-18 12:56:52 UTC Post #337786
Those are used on the client side, so you'll need to use a config executed on the client side. You can add one yourself if you add an "exec <config_name>.cfg\n" console command somewhere in client code. Alternatively you could add it to the options screen to allow users to change it there.
Posted 7 years ago2017-10-18 16:46:28 UTC Post #337788
It's possible to add cl_* (and other) parameters in autoexec.cfg. AFAIK it should work.
You must be logged in to post a response.