Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

bg_pmove.c File Reference

#include "q_shared.h"
#include "bg_public.h"
#include "bg_local.h"

Include dependency graph for bg_pmove.c:

Include dependency graph

Go to the source code of this file.

Functions

void PM_Accelerate (vec3_t wishdir, float wishspeed, float accel)
void PM_AddEvent (int newEvent)
void PM_AddTouchEnt (int entityNum)
void PM_AirMove (void)
void PM_Animate (void)
void PM_BeginWeaponChange (int weapon)
void PM_CheckDuck (void)
qboolean PM_CheckJump (void)
qboolean PM_CheckWaterJump (void)
void PM_ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce)
float PM_CmdScale (usercmd_t *cmd)
void PM_ContinueLegsAnim (int anim)
void PM_ContinueTorsoAnim (int anim)
int PM_CorrectAllSolid (trace_t *trace)
void PM_CrashLand (void)
void PM_DeadMove (void)
void PM_DropTimers (void)
void PM_FinishWeaponChange (void)
void PM_FlyMove (void)
int PM_FootstepForSurface (void)
void PM_Footsteps (void)
void PM_ForceLegsAnim (int anim)
void PM_Friction (void)
void PM_GrappleMove (void)
void PM_GroundTrace (void)
void PM_GroundTraceMissed (void)
void PM_NoclipMove (void)
void PM_SetMovementDir (void)
void PM_SetWaterLevel (void)
void PM_StartLegsAnim (int anim)
void PM_StartTorsoAnim (int anim)
void PM_TorsoAnimation (void)
void PM_UpdateViewAngles (playerState_t *ps, const usercmd_t *cmd)
void PM_WalkMove (void)
void PM_WaterEvents (void)
void PM_WaterJumpMove (void)
void PM_WaterMove (void)
void PM_Weapon (void)
void Pmove (pmove_t *pmove)
void PmoveSingle (pmove_t *pmove)
void trap_SnapVector (float *v)

Variables

int c_pmove = 0
pmove_tpm
float pm_accelerate = 10.0f
float pm_airaccelerate = 1.0f
float pm_duckScale = 0.25f
float pm_flightfriction = 3.0f
float pm_flyaccelerate = 8.0f
float pm_friction = 6.0f
float pm_spectatorfriction = 5.0f
float pm_stopspeed = 100.0f
float pm_swimScale = 0.50f
float pm_wadeScale = 0.70f
float pm_wateraccelerate = 4.0f
float pm_waterfriction = 1.0f
pml_t pml


Function Documentation

void PM_Accelerate vec3_t  wishdir,
float  wishspeed,
float  accel
[static]
 

Definition at line 240 of file bg_pmove.c.

References DotProduct, pml_t::frametime, i, pm, pml, pmove_t::ps, vec3_t, VectorMA, VectorNormalize(), VectorScale, VectorSubtract, and playerState_s::velocity.

Referenced by PM_AirMove(), PM_FlyMove(), PM_NoclipMove(), PM_WalkMove(), and PM_WaterMove().

00240                                                                           {
00241 #if 1
00242     // q2 style
00243     int         i;
00244     float       addspeed, accelspeed, currentspeed;
00245 
00246     currentspeed = DotProduct (pm->ps->velocity, wishdir);
00247     addspeed = wishspeed - currentspeed;
00248     if (addspeed <= 0) {
00249         return;
00250     }
00251     accelspeed = accel*pml.frametime*wishspeed;
00252     if (accelspeed > addspeed) {
00253         accelspeed = addspeed;
00254     }
00255     
00256     for (i=0 ; i<3 ; i++) {
00257         pm->ps->velocity[i] += accelspeed*wishdir[i];   
00258     }
00259 #else
00260     // proper way (avoids strafe jump maxspeed bug), but feels bad
00261     vec3_t      wishVelocity;
00262     vec3_t      pushDir;
00263     float       pushLen;
00264     float       canPush;
00265 
00266     VectorScale( wishdir, wishspeed, wishVelocity );
00267     VectorSubtract( wishVelocity, pm->ps->velocity, pushDir );
00268     pushLen = VectorNormalize( pushDir );
00269 
00270     canPush = accel*pml.frametime*wishspeed;
00271     if (canPush > pushLen) {
00272         canPush = pushLen;
00273     }
00274 
00275     VectorMA( pm->ps->velocity, canPush, pushDir, pm->ps->velocity );
00276 #endif
00277 }

Here is the call graph for this function:

void PM_AddEvent int  newEvent  ) 
 

Definition at line 58 of file bg_pmove.c.

References BG_AddPredictableEventToPlayerstate(), pm, and pmove_t::ps.

Referenced by PM_Animate(), PM_BeginWeaponChange(), PM_CheckJump(), PM_CrashLand(), PM_Footsteps(), PM_StepSlideMove(), PM_WaterEvents(), and PM_Weapon().

00058                                  {
00059     BG_AddPredictableEventToPlayerstate( newEvent, 0, pm->ps );
00060 }

Here is the call graph for this function:

void PM_AddTouchEnt int  entityNum  ) 
 

Definition at line 67 of file bg_pmove.c.

References i, pmove_t::numtouch, pm, and pmove_t::touchents.

Referenced by PM_GroundTrace(), and PM_SlideMove().

00067                                      {
00068     int     i;
00069 
00070     if ( entityNum == ENTITYNUM_WORLD ) {
00071         return;
00072     }
00073     if ( pm->numtouch == MAXTOUCH ) {
00074         return;
00075     }
00076 
00077     // see if it is already added
00078     for ( i = 0 ; i < pm->numtouch ; i++ ) {
00079         if ( pm->touchents[ i ] == entityNum ) {
00080             return;
00081         }
00082     }
00083 
00084     // add it
00085     pm->touchents[pm->numtouch] = entityNum;
00086     pm->numtouch++;
00087 }

void PM_AirMove void   )  [static]
 

Definition at line 601 of file bg_pmove.c.

References pmove_t::cmd, pml_t::forward, usercmd_s::forwardmove, pml_t::groundPlane, pml_t::groundTrace, i, cplane_s::normal, OVERCLIP, trace_t::plane, pm, PM_Accelerate(), pm_airaccelerate, PM_ClipVelocity(), PM_CmdScale(), playerState_s::pm_flags, PM_Friction(), PM_SetMovementDir(), PM_SlideMove(), PM_StepSlideMove(), pml, pmove_t::ps, qtrue, pml_t::right, usercmd_s::rightmove, usercmd_t, vec3_t, VectorCopy, VectorNormalize(), and playerState_s::velocity.

Referenced by PM_WalkMove(), and PmoveSingle().

00601                                {
00602     int         i;
00603     vec3_t      wishvel;
00604     float       fmove, smove;
00605     vec3_t      wishdir;
00606     float       wishspeed;
00607     float       scale;
00608     usercmd_t   cmd;
00609 
00610     PM_Friction();
00611 
00612     fmove = pm->cmd.forwardmove;
00613     smove = pm->cmd.rightmove;
00614 
00615     cmd = pm->cmd;
00616     scale = PM_CmdScale( &cmd );
00617 
00618     // set the movementDir so clients can rotate the legs for strafing
00619     PM_SetMovementDir();
00620 
00621     // project moves down to flat plane
00622     pml.forward[2] = 0;
00623     pml.right[2] = 0;
00624     VectorNormalize (pml.forward);
00625     VectorNormalize (pml.right);
00626 
00627     for ( i = 0 ; i < 2 ; i++ ) {
00628         wishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove;
00629     }
00630     wishvel[2] = 0;
00631 
00632     VectorCopy (wishvel, wishdir);
00633     wishspeed = VectorNormalize(wishdir);
00634     wishspeed *= scale;
00635 
00636     // not on ground, so little effect on velocity
00637     PM_Accelerate (wishdir, wishspeed, pm_airaccelerate);
00638 
00639     // we may have a ground plane that is very steep, even
00640     // though we don't have a groundentity
00641     // slide along the steep plane
00642     if ( pml.groundPlane ) {
00643         PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, 
00644             pm->ps->velocity, OVERCLIP );
00645     }
00646 
00647 #if 0
00648     //ZOID:  If we are on the grapple, try stair-stepping
00649     //this allows a player to use the grapple to pull himself
00650     //over a ledge
00651     if (pm->ps->pm_flags & PMF_GRAPPLE_PULL)
00652         PM_StepSlideMove ( qtrue );
00653     else
00654         PM_SlideMove ( qtrue );
00655 #endif
00656 
00657     PM_StepSlideMove ( qtrue );
00658 }

Here is the call graph for this function:

void PM_Animate void   )  [static]
 

Definition at line 1714 of file bg_pmove.c.

References usercmd_s::buttons, pmove_t::cmd, EV_TAUNT, pm, PM_AddEvent(), PM_StartTorsoAnim(), pmove_t::ps, TORSO_AFFIRMATIVE, TORSO_FOLLOWME, TORSO_GESTURE, TORSO_GETFLAG, TORSO_GUARDBASE, TORSO_NEGATIVE, TORSO_PATROL, and playerState_s::torsoTimer.

Referenced by PmoveSingle().

01714                                {
01715     if ( pm->cmd.buttons & BUTTON_GESTURE ) {
01716         if ( pm->ps->torsoTimer == 0 ) {
01717             PM_StartTorsoAnim( TORSO_GESTURE );
01718             pm->ps->torsoTimer = TIMER_GESTURE;
01719             PM_AddEvent( EV_TAUNT );
01720         }
01721 #ifdef MISSIONPACK
01722     } else if ( pm->cmd.buttons & BUTTON_GETFLAG ) {
01723         if ( pm->ps->torsoTimer == 0 ) {
01724             PM_StartTorsoAnim( TORSO_GETFLAG );
01725             pm->ps->torsoTimer = 600;   //TIMER_GESTURE;
01726         }
01727     } else if ( pm->cmd.buttons & BUTTON_GUARDBASE ) {
01728         if ( pm->ps->torsoTimer == 0 ) {
01729             PM_StartTorsoAnim( TORSO_GUARDBASE );
01730             pm->ps->torsoTimer = 600;   //TIMER_GESTURE;
01731         }
01732     } else if ( pm->cmd.buttons & BUTTON_PATROL ) {
01733         if ( pm->ps->torsoTimer == 0 ) {
01734             PM_StartTorsoAnim( TORSO_PATROL );
01735             pm->ps->torsoTimer = 600;   //TIMER_GESTURE;
01736         }
01737     } else if ( pm->cmd.buttons & BUTTON_FOLLOWME ) {
01738         if ( pm->ps->torsoTimer == 0 ) {
01739             PM_StartTorsoAnim( TORSO_FOLLOWME );
01740             pm->ps->torsoTimer = 600;   //TIMER_GESTURE;
01741         }
01742     } else if ( pm->cmd.buttons & BUTTON_AFFIRMATIVE ) {
01743         if ( pm->ps->torsoTimer == 0 ) {
01744             PM_StartTorsoAnim( TORSO_AFFIRMATIVE);
01745             pm->ps->torsoTimer = 600;   //TIMER_GESTURE;
01746         }
01747     } else if ( pm->cmd.buttons & BUTTON_NEGATIVE ) {
01748         if ( pm->ps->torsoTimer == 0 ) {
01749             PM_StartTorsoAnim( TORSO_NEGATIVE );
01750             pm->ps->torsoTimer = 600;   //TIMER_GESTURE;
01751         }
01752 #endif
01753     }
01754 }

Here is the call graph for this function:

void PM_BeginWeaponChange int  weapon  )  [static]
 

Definition at line 1469 of file bg_pmove.c.

References EV_CHANGE_WEAPON, pm, PM_AddEvent(), PM_StartTorsoAnim(), pmove_t::ps, playerState_s::stats, TORSO_DROP, playerState_s::weaponstate, and playerState_s::weaponTime.

Referenced by PM_Weapon().

01469                                                {
01470     if ( weapon <= WP_NONE || weapon >= WP_NUM_WEAPONS ) {
01471         return;
01472     }
01473 
01474     if ( !( pm->ps->stats[STAT_WEAPONS] & ( 1 << weapon ) ) ) {
01475         return;
01476     }
01477     
01478     if ( pm->ps->weaponstate == WEAPON_DROPPING ) {
01479         return;
01480     }
01481 
01482     PM_AddEvent( EV_CHANGE_WEAPON );
01483     pm->ps->weaponstate = WEAPON_DROPPING;
01484     pm->ps->weaponTime += 200;
01485     PM_StartTorsoAnim( TORSO_DROP );
01486 }

Here is the call graph for this function:

void PM_CheckDuck void   )  [static]
 

Definition at line 1249 of file bg_pmove.c.

References trace_t::allsolid, playerState_s::clientNum, pmove_t::cmd, pmove_t::maxs, pmove_t::mins, MINS_Z, playerState_s::origin, pm, playerState_s::pm_flags, playerState_s::pm_type, playerState_s::powerups, pmove_t::ps, pmove_t::trace, pmove_t::tracemask, usercmd_s::upmove, VectorSet, and playerState_s::viewheight.

Referenced by PmoveSingle().

01250 {
01251     trace_t trace;
01252 
01253     if ( pm->ps->powerups[PW_INVULNERABILITY] ) {
01254         if ( pm->ps->pm_flags & PMF_INVULEXPAND ) {
01255             // invulnerability sphere has a 42 units radius
01256             VectorSet( pm->mins, -42, -42, -42 );
01257             VectorSet( pm->maxs, 42, 42, 42 );
01258         }
01259         else {
01260             VectorSet( pm->mins, -15, -15, MINS_Z );
01261             VectorSet( pm->maxs, 15, 15, 16 );
01262         }
01263         pm->ps->pm_flags |= PMF_DUCKED;
01264         pm->ps->viewheight = CROUCH_VIEWHEIGHT;
01265         return;
01266     }
01267     pm->ps->pm_flags &= ~PMF_INVULEXPAND;
01268 
01269     pm->mins[0] = -15;
01270     pm->mins[1] = -15;
01271 
01272     pm->maxs[0] = 15;
01273     pm->maxs[1] = 15;
01274 
01275     pm->mins[2] = MINS_Z;
01276 
01277     if (pm->ps->pm_type == PM_DEAD)
01278     {
01279         pm->maxs[2] = -8;
01280         pm->ps->viewheight = DEAD_VIEWHEIGHT;
01281         return;
01282     }
01283 
01284     if (pm->cmd.upmove < 0)
01285     {   // duck
01286         pm->ps->pm_flags |= PMF_DUCKED;
01287     }
01288     else
01289     {   // stand up if possible
01290         if (pm->ps->pm_flags & PMF_DUCKED)
01291         {
01292             // try to stand up
01293             pm->maxs[2] = 32;
01294             pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask );
01295             if (!trace.allsolid)
01296                 pm->ps->pm_flags &= ~PMF_DUCKED;
01297         }
01298     }
01299 
01300     if (pm->ps->pm_flags & PMF_DUCKED)
01301     {
01302         pm->maxs[2] = 16;
01303         pm->ps->viewheight = CROUCH_VIEWHEIGHT;
01304     }
01305     else
01306     {
01307         pm->maxs[2] = 32;
01308         pm->ps->viewheight = DEFAULT_VIEWHEIGHT;
01309     }
01310 }

qboolean PM_CheckJump void   )  [static]
 

Definition at line 359 of file bg_pmove.c.

References pmove_t::cmd, EV_JUMP, usercmd_s::forwardmove, playerState_s::groundEntityNum, pml_t::groundPlane, LEGS_JUMP, LEGS_JUMPB, pm, PM_AddEvent(), playerState_s::pm_flags, PM_ForceLegsAnim(), pml, pmove_t::ps, qboolean, usercmd_s::upmove, playerState_s::velocity, and pml_t::walking.

Referenced by PM_WalkMove().

00359                                      {
00360     if ( pm->ps->pm_flags & PMF_RESPAWNED ) {
00361         return qfalse;      // don't allow jump until all buttons are up
00362     }
00363 
00364     if ( pm->cmd.upmove < 10 ) {
00365         // not holding jump
00366         return qfalse;
00367     }
00368 
00369     // must wait for jump to be released
00370     if ( pm->ps->pm_flags & PMF_JUMP_HELD ) {
00371         // clear upmove so cmdscale doesn't lower running speed
00372         pm->cmd.upmove = 0;
00373         return qfalse;
00374     }
00375 
00376     pml.groundPlane = qfalse;       // jumping away
00377     pml.walking = qfalse;
00378     pm->ps->pm_flags |= PMF_JUMP_HELD;
00379 
00380     pm->ps->groundEntityNum = ENTITYNUM_NONE;
00381     pm->ps->velocity[2] = JUMP_VELOCITY;
00382     PM_AddEvent( EV_JUMP );
00383 
00384     if ( pm->cmd.forwardmove >= 0 ) {
00385         PM_ForceLegsAnim( LEGS_JUMP );
00386         pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP;
00387     } else {
00388         PM_ForceLegsAnim( LEGS_JUMPB );
00389         pm->ps->pm_flags |= PMF_BACKWARDS_JUMP;
00390     }
00391 
00392     return qtrue;
00393 }

Here is the call graph for this function:

qboolean PM_CheckWaterJump void   )  [static]
 

Definition at line 400 of file bg_pmove.c.

References playerState_s::clientNum, pml_t::forward, playerState_s::origin, pm, playerState_s::pm_flags, playerState_s::pm_time, pml, pmove_t::pointcontents, pmove_t::ps, qboolean, vec3_t, VectorMA, VectorNormalize(), VectorScale, playerState_s::velocity, and pmove_t::waterlevel.

Referenced by PM_WaterMove().

00400                                           {
00401     vec3_t  spot;
00402     int     cont;
00403     vec3_t  flatforward;
00404 
00405     if (pm->ps->pm_time) {
00406         return qfalse;
00407     }
00408 
00409     // check for water jump
00410     if ( pm->waterlevel != 2 ) {
00411         return qfalse;
00412     }
00413 
00414     flatforward[0] = pml.forward[0];
00415     flatforward[1] = pml.forward[1];
00416     flatforward[2] = 0;
00417     VectorNormalize (flatforward);
00418 
00419     VectorMA (pm->ps->origin, 30, flatforward, spot);
00420     spot[2] += 4;
00421     cont = pm->pointcontents (spot, pm->ps->clientNum );
00422     if ( !(cont & CONTENTS_SOLID) ) {
00423         return qfalse;
00424     }
00425 
00426     spot[2] += 16;
00427     cont = pm->pointcontents (spot, pm->ps->clientNum );
00428     if ( cont ) {
00429         return qfalse;
00430     }
00431 
00432     // jump out of water
00433     VectorScale (pml.forward, 200, pm->ps->velocity);
00434     pm->ps->velocity[2] = 350;
00435 
00436     pm->ps->pm_flags |= PMF_TIME_WATERJUMP;
00437     pm->ps->pm_time = 2000;
00438 
00439     return qtrue;
00440 }

Here is the call graph for this function:

void PM_ClipVelocity vec3_t  in,
vec3_t  normal,
vec3_t  out,
float  overbounce
 

Definition at line 145 of file bg_pmove.c.

References DotProduct, i, and in.

Referenced by PM_AirMove(), PM_SlideMove(), PM_StepSlideMove(), PM_WalkMove(), and PM_WaterMove().

00145                                                                                {
00146     float   backoff;
00147     float   change;
00148     int     i;
00149     
00150     backoff = DotProduct (in, normal);
00151     
00152     if ( backoff < 0 ) {
00153         backoff *= overbounce;
00154     } else {
00155         backoff /= overbounce;
00156     }
00157 
00158     for ( i=0 ; i<3 ; i++ ) {
00159         change = normal[i]*backoff;
00160         out[i] = in[i] - change;
00161     }
00162 }

float PM_CmdScale usercmd_t cmd  )  [static]
 

Definition at line 290 of file bg_pmove.c.

References abs(), usercmd_s::forwardmove, max, pm, pmove_t::ps, usercmd_s::rightmove, playerState_s::speed, sqrt(), usercmd_s::upmove, and usercmd_t.

Referenced by PM_AirMove(), PM_FlyMove(), PM_NoclipMove(), PM_WalkMove(), and PM_WaterMove().

00290                                            {
00291     int     max;
00292     float   total;
00293     float   scale;
00294 
00295     max = abs( cmd->forwardmove );
00296     if ( abs( cmd->rightmove ) > max ) {
00297         max = abs( cmd->rightmove );
00298     }
00299     if ( abs( cmd->upmove ) > max ) {
00300         max = abs( cmd->upmove );
00301     }
00302     if ( !max ) {
00303         return 0;
00304     }
00305 
00306     total = sqrt( cmd->forwardmove * cmd->forwardmove
00307         + cmd->rightmove * cmd->rightmove + cmd->upmove * cmd->upmove );
00308     scale = (float)pm->ps->speed * max / ( 127.0 * total );
00309 
00310     return scale;
00311 }

Here is the call graph for this function:

void PM_ContinueLegsAnim int  anim  )  [static]
 

Definition at line 112 of file bg_pmove.c.

References playerState_s::legsAnim, playerState_s::legsTimer, pm, PM_StartLegsAnim(), and pmove_t::ps.

Referenced by PM_Footsteps().

00112                                             {
00113     if ( ( pm->ps->legsAnim & ~ANIM_TOGGLEBIT ) == anim ) {
00114         return;
00115     }
00116     if ( pm->ps->legsTimer > 0 ) {
00117         return;     // a high priority animation is running
00118     }
00119     PM_StartLegsAnim( anim );
00120 }

Here is the call graph for this function:

void PM_ContinueTorsoAnim int  anim  )  [static]
 

Definition at line 122 of file bg_pmove.c.

References pm, PM_StartTorsoAnim(), pmove_t::ps, playerState_s::torsoAnim, and playerState_s::torsoTimer.

Referenced by PM_TorsoAnimation().

00122                                              {
00123     if ( ( pm->ps->torsoAnim & ~ANIM_TOGGLEBIT ) == anim ) {
00124         return;
00125     }
00126     if ( pm->ps->torsoTimer > 0 ) {
00127         return;     // a high priority animation is running
00128     }
00129     PM_StartTorsoAnim( anim );
00130 }

Here is the call graph for this function:

int PM_CorrectAllSolid trace_t trace  )  [static]
 

Definition at line 1024 of file bg_pmove.c.

References trace_t::allsolid, c_pmove, playerState_s::clientNum, Com_Printf(), pmove_t::debugLevel, playerState_s::groundEntityNum, pml_t::groundPlane, pml_t::groundTrace, i, j, k, pmove_t::maxs, pmove_t::mins, playerState_s::origin, pm, pml, point, pmove_t::ps, pmove_t::trace, pmove_t::tracemask, vec3_t, VectorCopy, and pml_t::walking.

Referenced by PM_GroundTrace().

01024                                                 {
01025     int         i, j, k;
01026     vec3_t      point;
01027 
01028     if ( pm->debugLevel ) {
01029         Com_Printf("%i:allsolid\n", c_pmove);
01030     }
01031 
01032     // jitter around
01033     for (i = -1; i <= 1; i++) {
01034         for (j = -1; j <= 1; j++) {
01035             for (k = -1; k <= 1; k++) {
01036                 VectorCopy(pm->ps->origin, point);
01037                 point[0] += (float) i;
01038                 point[1] += (float) j;
01039                 point[2] += (float) k;
01040                 pm->trace (trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
01041                 if ( !trace->allsolid ) {
01042                     point[0] = pm->ps->origin[0];
01043                     point[1] = pm->ps->origin[1];
01044                     point[2] = pm->ps->origin[2] - 0.25;
01045 
01046                     pm->trace (trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
01047                     pml.groundTrace = *trace;
01048                     return qtrue;
01049                 }
01050             }
01051         }
01052     }
01053 
01054     pm->ps->groundEntityNum = ENTITYNUM_NONE;
01055     pml.groundPlane = qfalse;
01056     pml.walking = qfalse;
01057 
01058     return qfalse;
01059 }

Here is the call graph for this function:

void PM_CrashLand void   )  [static]
 

Definition at line 924 of file bg_pmove.c.

References a, b, playerState_s::bobCycle, c, den, EV_FALL_FAR, EV_FALL_MEDIUM, EV_FALL_SHORT, playerState_s::gravity, pml_t::groundTrace, LEGS_LAND, LEGS_LANDB, playerState_s::legsTimer, playerState_s::origin, pm, PM_AddEvent(), playerState_s::pm_flags, PM_FootstepForSurface(), PM_ForceLegsAnim(), pml, pml_t::previous_origin, pml_t::previous_velocity, pmove_t::ps, sqrt(), playerState_s::stats, trace_t::surfaceFlags, t, and pmove_t::waterlevel.

Referenced by PM_GroundTrace().

00924                                  {
00925     float       delta;
00926     float       dist;
00927     float       vel, acc;
00928     float       t;
00929     float       a, b, c, den;
00930 
00931     // decide which landing animation to use
00932     if ( pm->ps->pm_flags & PMF_BACKWARDS_JUMP ) {
00933         PM_ForceLegsAnim( LEGS_LANDB );
00934     } else {
00935         PM_ForceLegsAnim( LEGS_LAND );
00936     }
00937 
00938     pm->ps->legsTimer = TIMER_LAND;
00939 
00940     // calculate the exact velocity on landing
00941     dist = pm->ps->origin[2] - pml.previous_origin[2];
00942     vel = pml.previous_velocity[2];
00943     acc = -pm->ps->gravity;
00944 
00945     a = acc / 2;
00946     b = vel;
00947     c = -dist;
00948 
00949     den =  b * b - 4 * a * c;
00950     if ( den < 0 ) {
00951         return;
00952     }
00953     t = (-b - sqrt( den ) ) / ( 2 * a );
00954 
00955     delta = vel + t * acc;
00956     delta = delta*delta * 0.0001;
00957 
00958     // ducking while falling doubles damage
00959     if ( pm->ps->pm_flags & PMF_DUCKED ) {
00960         delta *= 2;
00961     }
00962 
00963     // never take falling damage if completely underwater
00964     if ( pm->waterlevel == 3 ) {
00965         return;
00966     }
00967 
00968     // reduce falling damage if there is standing water
00969     if ( pm->waterlevel == 2 ) {
00970         delta *= 0.25;
00971     }
00972     if ( pm->waterlevel == 1 ) {
00973         delta *= 0.5;
00974     }
00975 
00976     if ( delta < 1 ) {
00977         return;
00978     }
00979 
00980     // create a local entity event to play the sound
00981 
00982     // SURF_NODAMAGE is used for bounce pads where you don't ever
00983     // want to take damage or play a crunch sound
00984     if ( !(pml.groundTrace.surfaceFlags & SURF_NODAMAGE) )  {
00985         if ( delta > 60 ) {
00986             PM_AddEvent( EV_FALL_FAR );
00987         } else if ( delta > 40 ) {
00988             // this is a pain grunt, so don't play it if dead
00989             if ( pm->ps->stats[STAT_HEALTH] > 0 ) {
00990                 PM_AddEvent( EV_FALL_MEDIUM );
00991             }
00992         } else if ( delta > 7 ) {
00993             PM_AddEvent( EV_FALL_SHORT );
00994         } else {
00995             PM_AddEvent( PM_FootstepForSurface() );
00996         }
00997     }
00998 
00999     // start footstep cycle over
01000     pm->ps->bobCycle = 0;
01001 }

Here is the call graph for this function:

void PM_DeadMove void   )  [static]
 

Definition at line 817 of file bg_pmove.c.

References pm, pml, pmove_t::ps, VectorClear, VectorLength(), VectorNormalize(), VectorScale, playerState_s::velocity, and pml_t::walking.

Referenced by PmoveSingle().

00817                                 {
00818     float   forward;
00819 
00820     if ( !pml.walking ) {
00821         return;
00822     }
00823 
00824     // extra friction
00825 
00826     forward = VectorLength (pm->ps->velocity);
00827     forward -= 20;
00828     if ( forward <= 0 ) {
00829         VectorClear (pm->ps->velocity);
00830     } else {
00831         VectorNormalize (pm->ps->velocity);
00832         VectorScale (pm->ps->velocity, forward, pm->ps->velocity);
00833     }
00834 }

Here is the call graph for this function:

void PM_DropTimers void   )  [static]
 

Definition at line 1762 of file bg_pmove.c.

References playerState_s::legsTimer, pml_t::msec, pm, playerState_s::pm_flags, playerState_s::pm_time, pml, pmove_t::ps, and playerState_s::torsoTimer.

Referenced by PmoveSingle().

01762                                   {
01763     // drop misc timing counter
01764     if ( pm->ps->pm_time ) {
01765         if ( pml.msec >= pm->ps->pm_time ) {
01766             pm->ps->pm_flags &= ~PMF_ALL_TIMES;
01767             pm->ps->pm_time = 0;
01768         } else {
01769             pm->ps->pm_time -= pml.msec;
01770         }
01771     }
01772 
01773     // drop animation counter
01774     if ( pm->ps->legsTimer > 0 ) {
01775         pm->ps->legsTimer -= pml.msec;
01776         if ( pm->ps->legsTimer < 0 ) {
01777             pm->ps->legsTimer = 0;
01778         }
01779     }
01780 
01781     if ( pm->ps->torsoTimer > 0 ) {
01782         pm->ps->torsoTimer -= pml.msec;
01783         if ( pm->ps->torsoTimer < 0 ) {
01784             pm->ps->torsoTimer = 0;
01785         }
01786     }
01787 }

void PM_FinishWeaponChange void   )  [static]
 

Definition at line 1494 of file bg_pmove.c.

References pmove_t::cmd, pm, PM_StartTorsoAnim(), pmove_t::ps, playerState_s::stats, TORSO_RAISE, playerState_s::weapon, usercmd_s::weapon, playerState_s::weaponstate, and playerState_s::weaponTime.

Referenced by PM_Weapon().

01494                                           {
01495     int     weapon;
01496 
01497     weapon = pm->cmd.weapon;
01498     if ( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS ) {
01499         weapon = WP_NONE;
01500     }
01501 
01502     if ( !( pm->ps->stats[STAT_WEAPONS] & ( 1 << weapon ) ) ) {
01503         weapon = WP_NONE;
01504     }
01505 
01506     pm->ps->weapon = weapon;
01507     pm->ps->weaponstate = WEAPON_RAISING;
01508     pm->ps->weaponTime += 250;
01509     PM_StartTorsoAnim( TORSO_RAISE );
01510 }

Here is the call graph for this function:

void PM_FlyMove void   )  [static]
 

Definition at line 560 of file bg_pmove.c.

References pmove_t::cmd, pml_t::forward, usercmd_s::forwardmove, i, pm, PM_Accelerate(), PM_CmdScale(), pm_flyaccelerate, PM_Friction(), PM_StepSlideMove(), pml, qfalse, pml_t::right, usercmd_s::rightmove, usercmd_s::upmove, vec3_t, VectorCopy, and VectorNormalize().

Referenced by PmoveSingle().

00560                                {
00561     int     i;
00562     vec3_t  wishvel;
00563     float   wishspeed;
00564     vec3_t  wishdir;
00565     float   scale;
00566 
00567     // normal slowdown
00568     PM_Friction ();
00569 
00570     scale = PM_CmdScale( &pm->cmd );
00571     //
00572     // user intentions
00573     //
00574     if ( !scale ) {
00575         wishvel[0] = 0;
00576         wishvel[1] = 0;
00577         wishvel[2] = 0;
00578     } else {
00579         for (i=0 ; i<3 ; i++) {
00580             wishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove;
00581         }
00582 
00583         wishvel[2] += scale * pm->cmd.upmove;
00584     }
00585 
00586     VectorCopy (wishvel, wishdir);
00587     wishspeed = VectorNormalize(wishdir);
00588 
00589     PM_Accelerate (wishdir, wishspeed, pm_flyaccelerate);
00590 
00591     PM_StepSlideMove( qfalse );
00592 }

Here is the call graph for this function:

int PM_FootstepForSurface void