HL SDK 2.1

Player Physics System

	In this version of the Half-Life engine SDK, the MOD authors now have control over all player movement physics behavior.  This allows interesting physics tweaks for MODs as well as allowing the creation of new physics types ( e.g., allowing various spectator modes ) which can be shared between the game server and client code.

	The source files for the player physics code may be found in the pm_shared/ directory.  Note that the files in the shared folder are shared between both the client and game .dll.  You should also note that some of the headers are referenced in the engine, so care should be taken not to alter important data structures in those files.  To alter player physics, one simply changes the appropriate code in the pm_shared/ directory ( most likely in pm_shared.c ) and recompiles the client .dll and the game .dll.  Both of those projects reference the same source file so prediction errors are unlikely to occur - so long as you remember to compile both projects if you make physics changes.

	All player movements ( either predicted on the client or actual on the server ) occur by the engine invoking PM_PlayerMove ( found in pm_shared.c ) called via PM_Move().

	This function evaluates the move as follows ( generally ):

Parameters such as maximum speed, punch angle adjustment, and dead player view angle tweaks are checked in PM_CheckParameters().

Any timers associated with player physics ( e.g., time before playing another step sound, etc. ) are decremented in PM_ReduceTimers().

The player's position is checked to see if the player is stuck in the world or another entity.  If not, the player's position is categorized in PM_CatagorizePosition(), which checks whether the player is standing on an entity/the ground or is in the air and also, if the player is under water, this checks how far under water ( feet, torso, eyes ).

If the player is holding the crouch/duck key, PM_Duck deals with that action.

Finally, depending on the player's movetype, one of various movetype specific code paths is followed.  The MOVETYPE_WALK code path is the most relevant, as this handles the player in the normal state ( walking, swimming ).  This is where gravity, friction, water or ground movement, jumping, velocity capping, and falling are taken into account.

	The main data structure for player movement is the pmove structure.  This structure contains the relevant data elements as input / output for the move.  I.e., the engine fills in most of the data before calling this function and the results of movement on the relevant variables is recorded by setting them in the pmove structure before returning control to the engine.

In addition, various API callbacks are provided to help the physics system perform the move.  Such things as retrieving physics key/value pairs for the player, testing the player position, printing to the console, getting the current clock, determining the contents value for a point, tracing rays, generating random numbers, getting model data from a model pointer, playing sounds, tracing to determine a texture name, and playing back events are supported.  The pmove structure ( playermove_t ) is defined in pm_defs.h.
