//----------------------------------------------------------------------------- // Purpose: Check the jump button to make various jumps //----------------------------------------------------------------------------- bool CTFGameMovementRecon::CheckJumpButton() { // FIXME: Refactor this so we don't have this complicated duplicate // code here + in gamemovement.cpp if ( player->pl.deadflag ) { mv->m_nOldButtons |= IN_JUMP ; // don't jump again until released return false; } // Water jumps! if ( CheckWaterJump() ) return false; if ( mv->m_nOldButtons & IN_JUMP ) return false; // don't pogo stick CTFMoveData *pTFMove = static_cast<CTFMoveData*>( mv ); // Check for wall jump... if ( !CheckWallJump( pTFMove ) ) { // If we already did one air jump, can't do another if ( (player->GetGroundEntity() == NULL ) && ( pTFMove->ReconData().m_nJumpCount > 1) ) { mv->m_nOldButtons |= IN_JUMP; return false; // in air, so no effect } pTFMove->ReconData().m_nJumpCount += 1; // Am I doing a double-jump? bool bWasInAir = (player->GetGroundEntity() == NULL); // In the air now. SetGroundEntity( NULL ); PlayStepSound( m_pSurfaceData, 1.0, true ); if (!CheckBackJump(bWasInAir)) { if (CheckStrafeJump(bWasInAir)) { // Can't double jump out of a roll.... pTFMove->ReconData().m_nJumpCount += 1; } else { CheckForwardJump(bWasInAir); } } } pTFMove->ReconData().m_flSuppressionJumpTime = TIME_WALL_SUPPRESSION_JUMP; FinishGravity(); mv->m_outWishVel = mv->m_vecVelocity; mv->m_outStepHeight += 0.1f; // Flag that we jumped. mv->m_nOldButtons |= IN_JUMP; // don't jump again until released return true; }
void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity ) { bool bWalking; float fvol; Vector knee; Vector feet; float height; float speed; float velrun; float velwalk; int fLadder; if ( m_flStepSoundTime > 0 ) { m_flStepSoundTime -= 1000.0f * gpGlobals->frametime; if ( m_flStepSoundTime < 0 ) { m_flStepSoundTime = 0; } } if ( m_flStepSoundTime > 0 ) return; if ( GetFlags() & (FL_FROZEN|FL_ATCONTROLS)) return; if ( GetMoveType() == MOVETYPE_NOCLIP || GetMoveType() == MOVETYPE_OBSERVER ) return; if ( !sv_footsteps.GetFloat() ) return; speed = VectorLength( vecVelocity ); float groundspeed = Vector2DLength( vecVelocity.AsVector2D() ); // determine if we are on a ladder fLadder = ( GetMoveType() == MOVETYPE_LADDER ); GetStepSoundVelocities( &velwalk, &velrun ); bool onground = ( GetFlags() & FL_ONGROUND ); bool movingalongground = ( groundspeed > 0.0001f ); bool moving_fast_enough = ( speed >= velwalk ); #ifdef PORTAL // In Portal we MUST play footstep sounds even when the player is moving very slowly // This is used to count the number of footsteps they take in the challenge mode // -Jeep moving_fast_enough = true; #endif // To hear step sounds you must be either on a ladder or moving along the ground AND // You must be moving fast enough if ( !moving_fast_enough || !(fLadder || ( onground && movingalongground )) ) return; // MoveHelper()->PlayerSetAnimation( PLAYER_WALK ); bWalking = speed < velrun; VectorCopy( vecOrigin, knee ); VectorCopy( vecOrigin, feet ); height = GetPlayerMaxs()[ 2 ] - GetPlayerMins()[ 2 ]; knee[2] = vecOrigin[2] + 0.2 * height; // find out what we're stepping in or on... if ( fLadder ) { psurface = GetLadderSurface(vecOrigin); fvol = 0.5; SetStepSoundTime( STEPSOUNDTIME_ON_LADDER, bWalking ); } else if ( GetWaterLevel() == WL_Waist ) { static int iSkipStep = 0; if ( iSkipStep == 0 ) { iSkipStep++; return; } if ( iSkipStep++ == 3 ) { iSkipStep = 0; } psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "wade" ) ); fvol = 0.65; SetStepSoundTime( STEPSOUNDTIME_WATER_KNEE, bWalking ); } else if ( GetWaterLevel() == WL_Feet ) { psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "water" ) ); fvol = bWalking ? 0.2 : 0.5; SetStepSoundTime( STEPSOUNDTIME_WATER_FOOT, bWalking ); } else { if ( !psurface ) return; SetStepSoundTime( STEPSOUNDTIME_NORMAL, bWalking ); switch ( psurface->game.material ) { default: case CHAR_TEX_CONCRETE: fvol = bWalking ? 0.2 : 0.5; break; case CHAR_TEX_METAL: fvol = bWalking ? 0.2 : 0.5; break; case CHAR_TEX_DIRT: fvol = bWalking ? 0.25 : 0.55; break; case CHAR_TEX_VENT: fvol = bWalking ? 0.4 : 0.7; break; case CHAR_TEX_GRATE: fvol = bWalking ? 0.2 : 0.5; break; case CHAR_TEX_TILE: fvol = bWalking ? 0.2 : 0.5; break; case CHAR_TEX_SLOSH: fvol = bWalking ? 0.2 : 0.5; break; } } // play the sound // 65% volume if ducking if ( GetFlags() & FL_DUCKING ) { fvol *= 0.65; } PlayStepSound( feet, psurface, fvol, false ); }
//----------------------------------------------------------------------------- // Purpose: Check the jump button to make various jumps //----------------------------------------------------------------------------- bool CTFGameMovementRecon::CheckWallJump( CTFMoveData *pTFMove ) { if ( player->GetGroundEntity() != NULL ) return false; if ( pTFMove->ReconData().m_flActiveJumpTime == TIME_WALL_INVALID ) return false; // Play a jump sound PlayStepSound( m_pSurfaceData, 1.0, true ); Vector jumpDir; if ( ( pTFMove->m_nButtons & ( IN_MOVELEFT | IN_MOVERIGHT ) ) ) { AngleVectors( pTFMove->m_vecViewAngles, NULL, &jumpDir, NULL ); // Apply strafe jump... jumpDir *= ( pTFMove->m_nButtons & IN_MOVELEFT ) ? -1.0f : 1.0f; jumpDir.z = 0.0f; if ( pTFMove->m_nButtons & ( IN_FORWARD | IN_BACK ) ) { Vector forward; AngleVectors( pTFMove->m_vecViewAngles, &forward, NULL, NULL ); forward *= 0.5f; forward *= ( pTFMove->m_nButtons & IN_BACK ) ? -1.0f : 1.0f; forward.z = 0.0; jumpDir += forward; } VectorNormalize( jumpDir ); jumpDir *= 400; } else { AngleVectors( pTFMove->m_vecViewAngles, &jumpDir, NULL, NULL ); jumpDir *= ( pTFMove->m_nButtons & IN_BACK ) ? -1.0f : 1.0f; jumpDir.z = 0.0; VectorNormalize( jumpDir ); jumpDir *= 400; } pTFMove->ReconData().m_flStickTime = TIME_WALL_STICK; pTFMove->ReconData().m_vecUnstickVelocity.Init( jumpDir.x, jumpDir.y, pTFMove->m_vecVelocity[2] + 1.5 * sqrt(2 * 800 * 45.0) ); if (pTFMove->ReconData().m_vecUnstickVelocity.GetZ() > MAX_VERTICAL_SPEED) pTFMove->ReconData().m_vecUnstickVelocity.SetZ( MAX_VERTICAL_SPEED ); pTFMove->m_vecVelocity.Init( 0, 0, 0 ); // Don't allow jump into wall float normalComponent = DotProduct( pTFMove->ReconData().m_vecUnstickVelocity, pTFMove->ReconData().m_vecImpactNormal ); if ( normalComponent < 0 ) { Vector vUnstickVel; VectorMA( pTFMove->ReconData().m_vecUnstickVelocity, -normalComponent, pTFMove->ReconData().m_vecImpactNormal, vUnstickVel ); pTFMove->ReconData().m_vecUnstickVelocity = vUnstickVel; } return true; }
void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity ) { int fWalking; float fvol; Vector knee; Vector feet; float height; float speed; float velrun; float velwalk; float flduck; int fLadder; if ( m_flStepSoundTime > 0 ) { m_flStepSoundTime -= 1000.0f * gpGlobals->frametime; if ( m_flStepSoundTime < 0 ) { m_flStepSoundTime = 0; } } if ( m_flStepSoundTime > 0 ) return; if ( GetFlags() & (FL_FROZEN|FL_ATCONTROLS)) return; if ( GetMoveType() == MOVETYPE_NOCLIP || GetMoveType() == MOVETYPE_OBSERVER ) return; if ( !sv_footsteps.GetFloat() ) return; speed = VectorLength( vecVelocity ); float groundspeed = Vector2DLength( vecVelocity.AsVector2D() ); // determine if we are on a ladder fLadder = ( GetMoveType() == MOVETYPE_LADDER ); // UNDONE: need defined numbers for run, walk, crouch, crouch run velocities!!!! if ( ( GetFlags() & FL_DUCKING) || fLadder ) { velwalk = 60; // These constants should be based on cl_movespeedkey * cl_forwardspeed somehow velrun = 80; flduck = 100; } else { velwalk = 90; velrun = 220; flduck = 0; } bool onground = ( GetFlags() & FL_ONGROUND ); bool movingalongground = ( groundspeed > 0.0f ); bool moving_fast_enough = ( speed >= velwalk ); // To hear step sounds you must be either on a ladder or moving along the ground AND // You must be moving fast enough if ( !moving_fast_enough || !(fLadder || ( onground && movingalongground )) ) return; // MoveHelper()->PlayerSetAnimation( PLAYER_WALK ); fWalking = speed < velrun; VectorCopy( vecOrigin, knee ); VectorCopy( vecOrigin, feet ); height = GetPlayerMaxs()[ 2 ] - GetPlayerMins()[ 2 ]; knee[2] = vecOrigin[2] + 0.2 * height; // find out what we're stepping in or on... if ( fLadder ) { #ifdef CLIENT_DLL psurface = GetFootstepSurface( vecOrigin, "ladder" ); #else psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "ladder" ) ); #endif fvol = 0.5; m_flStepSoundTime = 350; } else if ( enginetrace->GetPointContents( knee ) & MASK_WATER ) { static int iSkipStep = 0; if ( iSkipStep == 0 ) { iSkipStep++; return; } if ( iSkipStep++ == 3 ) { iSkipStep = 0; } psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "wade" ) ); fvol = 0.65; m_flStepSoundTime = 600; } else if ( enginetrace->GetPointContents( feet ) & MASK_WATER ) { psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "water" ) ); fvol = fWalking ? 0.2 : 0.5; m_flStepSoundTime = fWalking ? 400 : 300; } else { if ( !psurface ) return; m_flStepSoundTime = fWalking ? 400 : 300; switch ( psurface->game.material ) { default: case CHAR_TEX_CONCRETE: fvol = fWalking ? 0.2 : 0.5; break; case CHAR_TEX_METAL: fvol = fWalking ? 0.2 : 0.5; break; case CHAR_TEX_DIRT: fvol = fWalking ? 0.25 : 0.55; break; case CHAR_TEX_VENT: fvol = fWalking ? 0.4 : 0.7; break; case CHAR_TEX_GRATE: fvol = fWalking ? 0.2 : 0.5; break; case CHAR_TEX_TILE: fvol = fWalking ? 0.2 : 0.5; break; case CHAR_TEX_SLOSH: fvol = fWalking ? 0.2 : 0.5; break; } } m_flStepSoundTime += flduck; // slower step time if ducking // play the sound // 65% volume if ducking if ( GetFlags() & FL_DUCKING ) { fvol *= 0.65; } PlayStepSound( feet, psurface, fvol, false ); }
void CDODPlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity ) { Vector knee; Vector feet; float height; int fLadder; if ( m_flStepSoundTime > 0 ) { m_flStepSoundTime -= 1000.0f * gpGlobals->frametime; if ( m_flStepSoundTime < 0 ) { m_flStepSoundTime = 0; } } if ( m_flStepSoundTime > 0 ) return; if ( GetFlags() & (FL_FROZEN|FL_ATCONTROLS)) return; if ( GetMoveType() == MOVETYPE_NOCLIP || GetMoveType() == MOVETYPE_OBSERVER ) return; if ( !sv_footsteps.GetFloat() ) return; float speed = VectorLength( vecVelocity ); float groundspeed = Vector2DLength( vecVelocity.AsVector2D() ); // determine if we are on a ladder fLadder = ( GetMoveType() == MOVETYPE_LADDER ); float flDuck; if ( ( GetFlags() & FL_DUCKING) || fLadder ) { flDuck = 100; } else { flDuck = 0; } static float flMinProneSpeed = 10.0f; static float flMinSpeed = 70.0f; static float flRunSpeed = 110.0f; bool onground = ( GetFlags() & FL_ONGROUND ); bool movingalongground = ( groundspeed > 0.0f ); bool moving_fast_enough = ( speed >= flMinSpeed ); // always play a step sound if we are moving faster than // To hear step sounds you must be either on a ladder or moving along the ground AND // You must be moving fast enough CheckProneMoveSound( groundspeed, onground ); if ( !moving_fast_enough || !(fLadder || ( onground && movingalongground )) ) { return; } bool bWalking = ( speed < flRunSpeed ); // or ducking! VectorCopy( vecOrigin, knee ); VectorCopy( vecOrigin, feet ); height = GetPlayerMaxs()[ 2 ] - GetPlayerMins()[ 2 ]; knee[2] = vecOrigin[2] + 0.2 * height; float flVol; // find out what we're stepping in or on... if ( fLadder ) { psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "ladder" ) ); flVol = 1.0; m_flStepSoundTime = 350; } else if ( enginetrace->GetPointContents( knee ) & MASK_WATER ) { static int iSkipStep = 0; if ( iSkipStep == 0 ) { iSkipStep++; return; } if ( iSkipStep++ == 3 ) { iSkipStep = 0; } psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "wade" ) ); flVol = 0.65; m_flStepSoundTime = 600; } else if ( enginetrace->GetPointContents( feet ) & MASK_WATER ) { psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "water" ) ); flVol = bWalking ? 0.2 : 0.5; m_flStepSoundTime = bWalking ? 400 : 300; } else { if ( !psurface ) return; if ( bWalking ) { m_flStepSoundTime = 400; } else { if ( speed > 200 ) { int speeddiff = PLAYER_SPEED_SPRINT - PLAYER_SPEED_RUN; int diff = speed - PLAYER_SPEED_RUN; float percent = (float)diff / (float)speeddiff; m_flStepSoundTime = 300.0f - 30.0f * percent; } else { m_flStepSoundTime = 400; } } switch ( psurface->game.material ) { default: case CHAR_TEX_CONCRETE: flVol = bWalking ? 0.2 : 0.5; break; case CHAR_TEX_METAL: flVol = bWalking ? 0.2 : 0.5; break; case CHAR_TEX_DIRT: flVol = bWalking ? 0.25 : 0.55; break; case CHAR_TEX_VENT: flVol = bWalking ? 0.4 : 0.7; break; case CHAR_TEX_GRATE: flVol = bWalking ? 0.2 : 0.5; break; case CHAR_TEX_TILE: flVol = bWalking ? 0.2 : 0.5; break; case CHAR_TEX_SLOSH: flVol = bWalking ? 0.2 : 0.5; break; } } m_flStepSoundTime += flDuck; // slower step time if ducking if ( GetFlags() & FL_DUCKING ) { flVol *= 0.65; } // protect us from prediction errors a little bit if ( m_flMinNextStepSoundTime > gpGlobals->curtime ) { return; } m_flMinNextStepSoundTime = gpGlobals->curtime + 0.1f; PlayStepSound( feet, psurface, flVol, false ); }
void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity ) { bool bWalking; float fvol = 1.0f; Vector knee; Vector feet; float height; float speed; float velrun; float velwalk; int fLadder; if ( m_flStepSoundTime > 0 ) { m_flStepSoundTime -= 1000.0f * gpGlobals->frametime; if ( m_flStepSoundTime < 0 ) { m_flStepSoundTime = 0; } } if ( m_flStepSoundTime > 0 ) return; if ( GetFlags() & (FL_FROZEN|FL_ATCONTROLS)) return; if ( GetMoveType() == MOVETYPE_NOCLIP ) return; if ( !sv_footsteps.GetFloat() ) return; speed = VectorLength( vecVelocity ); float groundspeed = Vector2DLength( vecVelocity.AsVector2D() ); // determine if we are on a ladder fLadder = false; GetStepSoundVelocities( &velwalk, &velrun ); bool onground = ( GetFlags() & FL_ONGROUND ); bool movingalongground = ( groundspeed > 0.0001f ); bool moving_fast_enough = ( speed >= velwalk ); // To hear step sounds you must be either on a ladder or moving along the ground AND // You must be moving fast enough if ( !moving_fast_enough || !( onground && movingalongground ) ) return; // MoveHelper()->PlayerSetAnimation( PLAYER_WALK ); bWalking = speed < velrun; VectorCopy( vecOrigin, knee ); VectorCopy( vecOrigin, feet ); height = GetPlayerMaxs()[ 2 ] - GetPlayerMins()[ 2 ]; knee[2] = vecOrigin[2] + 0.2 * height; if ( !psurface ) return; SetStepSoundTime( STEPSOUNDTIME_NORMAL, bWalking ); #ifdef CLIENT_DLL if (this == GetLocalPlayer()) { fvol = 0.1f; } #endif PlayStepSound( feet, psurface, fvol, false ); }
void C_ASW_Alien::MarineStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity ) { int fWalking; float fvol; Vector knee; Vector feet; float height; float speed; float velrun; float velwalk; float flduck; int fLadder; if ( GetFlags() & (FL_FROZEN|FL_ATCONTROLS)) return; if ( GetMoveType() == MOVETYPE_NOCLIP || GetMoveType() == MOVETYPE_OBSERVER ) return; if ( gpGlobals->curtime - sm_flLastFootstepTime < asw_alien_footstep_interval.GetFloat() ) return; speed = VectorLength( vecVelocity ); float groundspeed = Vector2DLength( vecVelocity.AsVector2D() ); // determine if we are on a ladder fLadder = ( GetMoveType() == MOVETYPE_LADDER ); // UNDONE: need defined numbers for run, walk, crouch, crouch run velocities!!!! if ( ( GetFlags() & FL_DUCKING) || fLadder ) { velwalk = 60; // These constants should be based on cl_movespeedkey * cl_forwardspeed somehow velrun = 80; flduck = 100; } else { velwalk = 90; velrun = 220; flduck = 0; } bool onground = true; //( GetFlags() & FL_ONGROUND ); bool movingalongground = ( groundspeed > 0.0f ); bool moving_fast_enough = ( speed >= velwalk ); // To hear step sounds you must be either on a ladder or moving along the ground AND // You must be moving fast enough //Msg("og=%d ma=%d mf=%d\n", onground, movingalongground, moving_fast_enough); if ( !moving_fast_enough || !(fLadder || ( onground && movingalongground )) ) return; // MoveHelper()->PlayerSetAnimation( PLAYER_WALK ); fWalking = speed < velrun; VectorCopy( vecOrigin, knee ); VectorCopy( vecOrigin, feet ); height = 72.0f; // bad knee[2] = vecOrigin[2] + 0.2 * height; // find out what we're stepping in or on... if ( fLadder ) { psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "ladder" ) ); fvol = 0.5; } else if ( enginetrace->GetPointContents( knee ) & MASK_WATER ) { static int iSkipStep = 0; if ( iSkipStep == 0 ) { iSkipStep++; return; } if ( iSkipStep++ == 3 ) { iSkipStep = 0; } psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "wade" ) ); fvol = 0.65; } else if ( enginetrace->GetPointContents( feet ) & MASK_WATER ) { psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "water" ) ); fvol = fWalking ? 0.2 : 0.5; } else { if ( !psurface ) return; switch ( psurface->game.material ) { default: case CHAR_TEX_CONCRETE: fvol = fWalking ? 0.2 : 0.5; break; case CHAR_TEX_METAL: fvol = fWalking ? 0.2 : 0.5; break; case CHAR_TEX_DIRT: fvol = fWalking ? 0.25 : 0.55; break; case CHAR_TEX_VENT: fvol = fWalking ? 0.4 : 0.7; break; case CHAR_TEX_GRATE: fvol = fWalking ? 0.2 : 0.5; break; case CHAR_TEX_TILE: fvol = fWalking ? 0.2 : 0.5; break; case CHAR_TEX_SLOSH: fvol = fWalking ? 0.2 : 0.5; break; } } // play the sound // 65% volume if ducking if ( GetFlags() & FL_DUCKING ) { fvol *= 0.65; } if ( asw_override_footstep_volume.GetFloat() > 0 ) { fvol = asw_override_footstep_volume.GetFloat(); } PlayStepSound( feet, psurface, fvol, false ); }