Posted by: omega
Date posted: Aug 31 2003 User Rating: 5 out of 5.0 | Number of views: 8668 Number of comments: 1 | Description: by Fireball |
From the Editor: I've modified this tutorial, and simplified it. For those of you who may have seen the original tutorial, there was a section on adding a message for speed; this message isn't needed, and the same task can be accomplished an easier way (which will not be covered in this tutorial anymore, since most of you will not need it for the purpose of this tutorial.)
This tutorial shows how to enable you to set what speeds the player can go, and force them to remain at those speeds. Most of the setting and checking is done on the client side, so there should be no noticable increase in network traffic. The system used should easily be altered to make use of any player class system or take into account any special items that can alter someone's speed. File names are shown in red. Existing code is shown in purple. Additions you have to make are shown in green.
First, we must modify the server to send the speed information to the client. Let's start by adding a variable to the player class so the server knows when it needs to send an update to the client, as well as a function to determine what the speed of the player should be:
| | PLAYER.H (near the bottom): void SetCustomDecalFrames( int nFrames ); int GetCustomDecalFrames( void );
int PlayerSpeed() {return 270;} //The max speed the player can move };
|
Change 270 to whatever speed you want, or perform any calculations such as determining speed based on the player's class or equipment, etc.
Now we'll set the server-side limitation on speed:
| | PLAYER.CPP (in CBasePlayer::Spawn)
g_engfuncs.pfnSetClientMaxspeed( ENT( pev ), PlayerSpeed() ); g_pGameRules->PlayerSpawn( this ); }
|
That's it! Hopefully everything compiles, and you now have very rigid player speeds that can't be modified. Some issues not covered in this tutorial are the numbers used by Half-Life for determining things such as when to show the player as running or walking, and how loud and frequently to play footstep noises. Search for "step" in PM_SHARED.C and you'll see what I mean. You should be able to base these off the PlayerSpeed() function instead of the existing hard-coded values pretty easily. From the Editor: the easiest way to do this is to set a physics key when you set the speed of the player; look in items.cpp for the way it sets the physicskey when you get the longjump module Fireball |
|
User Comments
Showing comments 1-1
I would suggest poking the players speed into fuser4 and using this to overide pmove->maxspeed, otherwise your wonderful speed system can get screwed up by the wonder of the maxspeed engince cvar. |
|
You must register to post a comment. If you have already registered, you must login.
|
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (5 guests)
|
|