//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void UnitBaseAirLocomotion::FullAirMove() { CategorizePosition(); UpdateCurrentHeight(); if( mv->upmove == 0.0f ) { // Get Ground distance and compare to desired height. Modify up/down velocity based on it. float fDiff = m_fDesiredHeight - m_fCurrentHeight; if( fDiff < 0.0f ) mv->velocity.z = Max(fDiff, -mv->maxspeed); else mv->velocity.z = Min(fDiff, mv->maxspeed); if( m_fFlyNoiseZ > DIST_EPSILON && mv->sidemove == 0.0f && mv->forwardmove == 0.0f ) { if( m_bFlyNoiseUp ) { m_fFlyCurNoise += m_fFlyNoiseRate * mv->interval; if( m_fFlyCurNoise > m_fFlyNoiseZ ) m_bFlyNoiseUp = !m_bFlyNoiseUp; } else { m_fFlyCurNoise -= m_fFlyNoiseRate * mv->interval; if( m_fFlyCurNoise < -m_fFlyNoiseZ ) m_bFlyNoiseUp = !m_bFlyNoiseUp; } mv->velocity.z += m_fFlyCurNoise; } } else { mv->velocity.z = Min(mv->upmove, mv->maxspeed); } // Always air move AirMove(); mv->stopdistance = GetStopDistance(); // If we are on ground, no downward velocity. if( GetGroundEntity() != NULL) mv->velocity.z = 0.0f; }
void CMomentumGameMovement::FullWalkMove() { if (!CheckWater()) { StartGravity(); } // If we are leaping out of the water, just update the counters. if (player->m_flWaterJumpTime) { WaterJump(); TryPlayerMove(); // See if we are still in water? CheckWater(); return; } // If we are swimming in the water, see if we are nudging against a place we can jump up out // of, and, if so, start out jump. Otherwise, if we are not moving up, then reset jump timer to 0 if (player->GetWaterLevel() >= WL_Waist) { if (player->GetWaterLevel() == WL_Waist) { CheckWaterJump(); } // If we are falling again, then we must not trying to jump out of water any more. if (mv->m_vecVelocity[2] < 0 && player->m_flWaterJumpTime) { player->m_flWaterJumpTime = 0; } // Was jump button pressed? if (mv->m_nButtons & IN_JUMP) { CheckJumpButton(); } else { mv->m_nOldButtons &= ~IN_JUMP; } // Perform regular water movement WaterMove(); // Redetermine position vars CategorizePosition(); // If we are on ground, no downward velocity. if (player->GetGroundEntity() != NULL) { mv->m_vecVelocity[2] = 0; } } else // Not fully underwater { // Was jump button pressed? if (mv->m_nButtons & IN_JUMP) { CheckJumpButton(); } else { mv->m_nOldButtons &= ~IN_JUMP; } // Fricion is handled before we add in any base velocity. That way, if we are on a conveyor, // we don't slow when standing still, relative to the conveyor. if (player->GetGroundEntity() != NULL) { mv->m_vecVelocity[2] = 0.0; Friction(); } // Make sure velocity is valid. CheckVelocity(); // By default assume we did the reflect for WalkMove() flReflectNormal = 1.0f; if (player->GetGroundEntity() != NULL) { WalkMove(); } else { AirMove(); // Take into account movement when in air. } // Set final flags. CategorizePosition(flReflectNormal); // Make sure velocity is valid. CheckVelocity(); // Add any remaining gravitational component. if (!CheckWater()) { FinishGravity(); } // If we are on ground, no downward velocity. if (player->GetGroundEntity() != NULL) { mv->m_vecVelocity[2] = 0; } CheckFalling(); } if ((m_nOldWaterLevel == WL_NotInWater && player->GetWaterLevel() != WL_NotInWater) || (m_nOldWaterLevel != WL_NotInWater && player->GetWaterLevel() == WL_NotInWater)) { PlaySwimSound(); #if !defined( CLIENT_DLL ) player->Splash(); #endif } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFGameMovement::FullWalkMove() { if ( !InWater() ) { StartGravity(); } // If we are leaping out of the water, just update the counters. if ( player->m_flWaterJumpTime ) { // Try to jump out of the water (and check to see if we still are). WaterJump(); TryPlayerMove(); CheckWater(); return; } // If we are swimming in the water, see if we are nudging against a place we can jump up out // of, and, if so, start out jump. Otherwise, if we are not moving up, then reset jump timer to 0 if ( InWater() ) { FullWalkMoveUnderwater(); return; } if (mv->m_nButtons & IN_JUMP) { CheckJumpButton(); } else { mv->m_nOldButtons &= ~IN_JUMP; } // Make sure velocity is valid. CheckVelocity(); if (player->GetGroundEntity() != NULL) { mv->m_vecVelocity[2] = 0.0; Friction(); WalkMove(); } else { AirMove(); } // Set final flags. CategorizePosition(); // Add any remaining gravitational component if we are not in water. if ( !InWater() ) { FinishGravity(); } // If we are on ground, no downward velocity. if ( player->GetGroundEntity() != NULL ) { mv->m_vecVelocity[2] = 0; } // Handling falling. CheckFalling(); // Make sure velocity is valid. CheckVelocity(); }