void CTFGameMovement::FullWalkMoveUnderwater() { 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.z < 0.0f ) && player->m_flWaterJumpTime ) { player->m_flWaterJumpTime = 0.0f; } // 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; } }
/* PlayerMove Returns with origin, angles, and velocity modified in place. Numtouch and touchindex[] will be set if any of the physents were contacted during the move. */ void PlayerMove (void) { frametime = pmove.cmd.msec * 0.001; pmove.numtouch = 0; AngleVectors (pmove.angles, forward, right, up); if (pmove.spectator) { SpectatorMove (); return; } NudgePosition (); // take angles directly from command VectorCopy (pmove.cmd.angles, pmove.angles); // set onground, watertype, and waterlevel PM_CategorizePosition (); if (waterlevel == 2) CheckWaterJump (); if (pmove.velocity[2] < 0) pmove.waterjumptime = 0; if (pmove.cmd.buttons & BUTTON_JUMP) JumpButton (); else pmove.oldbuttons &= ~BUTTON_JUMP; PM_Friction (); if (waterlevel >= 2) PM_WaterMove (); else if (pmove.flying) PM_FlymodeMove (); else PM_AirMove (); // set onground, watertype, and waterlevel for final spot PM_CategorizePosition (); }
//----------------------------------------------------------------------------- // 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 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 } }