void CTFGameMovement::AirDash( void ) { // Apply approx. the jump velocity added to an air dash. Assert( sv_gravity.GetFloat() == 800.0f ); float flDashZ = 268.3281572999747f; // Get the wish direction. Vector vecForward, vecRight; AngleVectors( mv->m_vecViewAngles, &vecForward, &vecRight, NULL ); vecForward.z = 0.0f; vecRight.z = 0.0f; VectorNormalize( vecForward ); VectorNormalize( vecRight ); // Copy movement amounts float flForwardMove = mv->m_flForwardMove; float flSideMove = mv->m_flSideMove; // Find the direction,velocity in the x,y plane. Vector vecWishDirection( ( ( vecForward.x * flForwardMove ) + ( vecRight.x * flSideMove ) ), ( ( vecForward.y * flForwardMove ) + ( vecRight.y * flSideMove ) ), 0.0f ); // Update the velocity on the scout. mv->m_vecVelocity = vecWishDirection; mv->m_vecVelocity.z += flDashZ; m_pTFPlayer->m_Shared.SetAirDash( true ); // Play the gesture. m_pTFPlayer->DoAnimationEvent( PLAYERANIMEVENT_DOUBLEJUMP ); }
void CSDKGameMovement::WalkMove( void ) { #if defined ( SDK_USE_SPRINTING ) float flSpeedCheck = m_pSDKPlayer->GetAbsVelocity().Length2D(); bool bSprintButtonPressed = ( mv->m_nButtons & IN_SPEED ) > 0; if( bSprintButtonPressed && ( mv->m_nButtons & IN_FORWARD ) && #if defined ( SDK_USE_PRONE ) !m_pSDKPlayer->m_Shared.IsProne() && #endif !m_pSDKPlayer->m_Shared.IsDucking() && flSpeedCheck > 80 ) { m_pSDKPlayer->SetSprinting( true ); } else { m_pSDKPlayer->SetSprinting( false ); } #endif // SDK_USE_SPRINTING // Get the movement angles. Vector vecForward, vecRight, vecUp; AngleVectors( mv->m_vecViewAngles, &vecForward, &vecRight, &vecUp ); vecForward.z = 0.0f; vecRight.z = 0.0f; VectorNormalize( vecForward ); VectorNormalize( vecRight ); // Copy movement amounts float flForwardMove = mv->m_flForwardMove; float flSideMove = mv->m_flSideMove; // Find the direction,velocity in the x,y plane. Vector vecWishDirection( ( ( vecForward.x * flForwardMove ) + ( vecRight.x * flSideMove ) ), ( ( vecForward.y * flForwardMove ) + ( vecRight.y * flSideMove ) ), 0.0f ); // Calculate the speed and direction of movement, then clamp the speed. float flWishSpeed = VectorNormalize( vecWishDirection ); flWishSpeed = clamp( flWishSpeed, 0.0f, mv->m_flMaxSpeed ); // Accelerate in the x,y plane. mv->m_vecVelocity.z = 0; Accelerate( vecWishDirection, flWishSpeed, sv_accelerate.GetFloat() ); Assert( mv->m_vecVelocity.z == 0.0f ); // Clamp the players speed in x,y. float flNewSpeed = VectorLength( mv->m_vecVelocity ); if ( flNewSpeed > mv->m_flMaxSpeed ) { float flScale = ( mv->m_flMaxSpeed / flNewSpeed ); mv->m_vecVelocity.x *= flScale; mv->m_vecVelocity.y *= flScale; } // Now reduce their backwards speed to some percent of max, if they are travelling backwards unless they are under some minimum if ( sdk_clamp_back_speed.GetFloat() < 1.0 && VectorLength( mv->m_vecVelocity ) > sdk_clamp_back_speed_min.GetFloat() ) { float flDot = DotProduct( vecForward, mv->m_vecVelocity ); // are we moving backwards at all? if ( flDot < 0 ) { Vector vecBackMove = vecForward * flDot; Vector vecRightMove = vecRight * DotProduct( vecRight, mv->m_vecVelocity ); // clamp the back move vector if it is faster than max float flBackSpeed = VectorLength( vecBackMove ); float flMaxBackSpeed = ( mv->m_flMaxSpeed * sdk_clamp_back_speed.GetFloat() ); if ( flBackSpeed > flMaxBackSpeed ) { vecBackMove *= flMaxBackSpeed / flBackSpeed; } // reassemble velocity mv->m_vecVelocity = vecBackMove + vecRightMove; } } // Add base velocity to the player's current velocity - base velocity = velocity from conveyors, etc. VectorAdd( mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity ); // Calculate the current speed and return if we are not really moving. float flSpeed = VectorLength( mv->m_vecVelocity ); if ( flSpeed < 1.0f ) { // I didn't remove the base velocity here since it wasn't moving us in the first place. mv->m_vecVelocity.Init(); return; } // Calculate the destination. Vector vecDestination; vecDestination.x = mv->GetAbsOrigin().x + ( mv->m_vecVelocity.x * gpGlobals->frametime ); vecDestination.y = mv->GetAbsOrigin().y + ( mv->m_vecVelocity.y * gpGlobals->frametime ); vecDestination.z = mv->GetAbsOrigin().z; // Try moving to the destination. trace_t trace; TracePlayerBBox( mv->GetAbsOrigin(), vecDestination, PlayerSolidMask(), COLLISION_GROUP_PLAYER_MOVEMENT, trace ); if ( trace.fraction == 1.0f ) { // Made it to the destination (remove the base velocity). mv->SetAbsOrigin( trace.endpos ); VectorSubtract( mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity ); // Save the wish velocity. mv->m_outWishVel += ( vecWishDirection * flWishSpeed ); // Try and keep the player on the ground. // NOTE YWB 7/5/07: Don't do this here, our version of CategorizePosition encompasses this test // StayOnGround(); return; } // Now try and do a step move. StepMove( vecDestination, trace ); // Remove base velocity. Vector baseVelocity = player->GetBaseVelocity(); VectorSubtract( mv->m_vecVelocity, baseVelocity, mv->m_vecVelocity ); // Save the wish velocity. mv->m_outWishVel += ( vecWishDirection * flWishSpeed ); // Try and keep the player on the ground. // NOTE YWB 7/5/07: Don't do this here, our version of CategorizePosition encompasses this test // StayOnGround(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFGameMovement::WalkMove( void ) { // Get the movement angles. Vector vecForward, vecRight, vecUp; AngleVectors( mv->m_vecViewAngles, &vecForward, &vecRight, &vecUp ); vecForward.z = 0.0f; vecRight.z = 0.0f; VectorNormalize( vecForward ); VectorNormalize( vecRight ); // Copy movement amounts float flForwardMove = mv->m_flForwardMove; float flSideMove = mv->m_flSideMove; // Find the direction,velocity in the x,y plane. Vector vecWishDirection( ( ( vecForward.x * flForwardMove ) + ( vecRight.x * flSideMove ) ), ( ( vecForward.y * flForwardMove ) + ( vecRight.y * flSideMove ) ), 0.0f ); // Calculate the speed and direction of movement, then clamp the speed. float flWishSpeed = VectorNormalize( vecWishDirection ); flWishSpeed = clamp( flWishSpeed, 0.0f, mv->m_flMaxSpeed ); // Accelerate in the x,y plane. mv->m_vecVelocity.z = 0; Accelerate( vecWishDirection, flWishSpeed, sv_accelerate.GetFloat() ); Assert( mv->m_vecVelocity.z == 0.0f ); // Clamp the players speed in x,y. if ( tf2c_groundspeed_cap.GetBool() ) { float flNewSpeed = VectorLength(mv->m_vecVelocity); if (flNewSpeed > mv->m_flMaxSpeed) { float flScale = (mv->m_flMaxSpeed / flNewSpeed); mv->m_vecVelocity.x *= flScale; mv->m_vecVelocity.y *= flScale; } } // Now reduce their backwards speed to some percent of max, if they are travelling backwards // unless they are under some minimum, to not penalize deployed snipers or heavies if ( tf_clamp_back_speed.GetFloat() < 1.0 && VectorLength( mv->m_vecVelocity ) > tf_clamp_back_speed_min.GetFloat() ) { float flDot = DotProduct( vecForward, mv->m_vecVelocity ); // are we moving backwards at all? if ( flDot < 0 ) { Vector vecBackMove = vecForward * flDot; Vector vecRightMove = vecRight * DotProduct( vecRight, mv->m_vecVelocity ); // clamp the back move vector if it is faster than max float flBackSpeed = VectorLength( vecBackMove ); float flMaxBackSpeed = ( mv->m_flMaxSpeed * tf_clamp_back_speed.GetFloat() ); if ( flBackSpeed > flMaxBackSpeed ) { vecBackMove *= flMaxBackSpeed / flBackSpeed; } // reassemble velocity mv->m_vecVelocity = vecBackMove + vecRightMove; } } // Add base velocity to the player's current velocity - base velocity = velocity from conveyors, etc. VectorAdd( mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity ); // Calculate the current speed and return if we are not really moving. float flSpeed = VectorLength( mv->m_vecVelocity ); if ( flSpeed < 1.0f ) { // I didn't remove the base velocity here since it wasn't moving us in the first place. mv->m_vecVelocity.Init(); return; } // Calculate the destination. Vector vecDestination; vecDestination.x = mv->GetAbsOrigin().x + ( mv->m_vecVelocity.x * gpGlobals->frametime ); vecDestination.y = mv->GetAbsOrigin().y + ( mv->m_vecVelocity.y * gpGlobals->frametime ); vecDestination.z = mv->GetAbsOrigin().z; // Try moving to the destination. trace_t trace; TracePlayerBBox( mv->GetAbsOrigin(), vecDestination, PlayerSolidMask(), COLLISION_GROUP_PLAYER_MOVEMENT, trace ); if ( trace.fraction == 1.0f ) { // Made it to the destination (remove the base velocity). mv->SetAbsOrigin( trace.endpos ); VectorSubtract( mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity ); // Save the wish velocity. mv->m_outWishVel += ( vecWishDirection * flWishSpeed ); // Try and keep the player on the ground. // NOTE YWB 7/5/07: Don't do this here, our version of CategorizePosition encompasses this test // StayOnGround(); return; } // Now try and do a step move. StepMove( vecDestination, trace ); // Remove base velocity. Vector baseVelocity = player->GetBaseVelocity(); VectorSubtract( mv->m_vecVelocity, baseVelocity, mv->m_vecVelocity ); // Save the wish velocity. mv->m_outWishVel += ( vecWishDirection * flWishSpeed ); // Try and keep the player on the ground. // NOTE YWB 7/5/07: Don't do this here, our version of CategorizePosition encompasses this test // StayOnGround(); #if 0 // Debugging!!! Vector vecTestVelocity = mv->m_vecVelocity; vecTestVelocity.z = 0.0f; float flTestSpeed = VectorLength( vecTestVelocity ); if ( baseVelocity.IsZero() && ( flTestSpeed > ( mv->m_flMaxSpeed + 1.0f ) ) ) { Msg( "Step Max Speed < %f\n", flTestSpeed ); } if ( tf_showspeed.GetBool() ) { Msg( "Speed=%f\n", flTestSpeed ); } #endif }