void CBPGameMovement::FullWalkMove( ) { if (player->GetGroundEntity() != NULL) { mv->m_vecVelocity[2] = 0.0; Friction(); } CheckVelocity(); GetBPPlayer()->m_flTurnRate = 0; if (player->GetGroundEntity() != NULL && !(mv->m_nButtons & IN_JUMP)) { WalkMove(); } else { FlyMove(); } engine->Con_NPrintf( 0, " L: %.2f, R: %.2f", bpmv->m_flLTrigger, bpmv->m_flRTrigger ); engine->Con_NPrintf( 1, "SL: %.2f, SR: %.2f", m_flLTriggerAvg, m_flRTriggerAvg ); // Set final flags. CategorizePosition(); }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void UnitBaseAirLocomotion::Move( float interval, UnitBaseMoveCommand &move_command ) { VPROF_BUDGET( "UnitBaseAirLocomotion::Move", VPROF_BUDGETGROUP_UNITS ); mv = &move_command; mv->interval = interval; mv->outwishvel.Init(); Friction(); FullAirMove(); MoveFacing(); // Sometimes an unit spawns with an invalid velocity and can't move // Validate velocity after each move CheckVelocity(); }
void CASW_Drone_Movement::StartGravity( void ) { float ent_gravity; if (m_pNPC->GetGravity()) ent_gravity = m_pNPC->GetGravity(); else ent_gravity = 1.0; // asw, was 1.0 if (!m_pNPC->GetGroundEntity()) ent_gravity = 30.0f; // Add gravity so they'll be in the correct position during movement // yes, this 0.5 looks wrong, but it's not. float gravity_effect = (ent_gravity * sv_gravity.GetFloat() * 0.5 * m_flInterval ); mv->m_vecVelocity[2] -= gravity_effect; mv->m_vecVelocity[2] += m_pNPC->GetBaseVelocity()[2] * m_flInterval; Vector temp = m_pNPC->GetBaseVelocity(); temp[ 2 ] = 0; m_pNPC->SetBaseVelocity( temp ); CheckVelocity(); }
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::FullTossMove( void ) { trace_t pm; Vector move; // add velocity if player is moving if ( (mv->m_flForwardMove != 0.0f) || (mv->m_flSideMove != 0.0f) || (mv->m_flUpMove != 0.0f)) { Vector forward, right, up; float fmove, smove; Vector wishdir, wishvel; float wishspeed; int i; AngleVectors (mv->m_vecViewAngles, &forward, &right, &up); // Determine movement angles // Copy movement amounts fmove = mv->m_flForwardMove; smove = mv->m_flSideMove; VectorNormalize (forward); // Normalize remainder of vectors. VectorNormalize (right); // for (i=0 ; i<3 ; i++) // Determine x and y parts of velocity wishvel[i] = forward[i]*fmove + right[i]*smove; wishvel[2] += mv->m_flUpMove; VectorCopy (wishvel, wishdir); // Determine maginitude of speed of move wishspeed = VectorNormalize(wishdir); // // Clamp to server defined max speed // if (wishspeed > mv->m_flMaxSpeed) { VectorScale (wishvel, mv->m_flMaxSpeed/wishspeed, wishvel); wishspeed = mv->m_flMaxSpeed; } // Set pmove velocity Accelerate ( wishdir, wishspeed, sv_accelerate.GetFloat() ); } if ( mv->m_vecVelocity[2] > 0 ) { SetGroundEntity( NULL ); } // If on ground and not moving, return. if ( player->GetGroundEntity() != NULL ) { if (VectorCompare(player->GetBaseVelocity(), vec3_origin) && VectorCompare(mv->m_vecVelocity, vec3_origin)) return; } CheckVelocity(); // add gravity if ( player->GetMoveType() == MOVETYPE_FLYGRAVITY ) { AddGravity(); } // move origin // Base velocity is not properly accounted for since this entity will move again after the bounce without // taking it into account VectorAdd (mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity); CheckVelocity(); VectorScale (mv->m_vecVelocity, gpGlobals->frametime, move); VectorSubtract (mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity); PushEntity( move, &pm ); // Should this clear basevelocity CheckVelocity(); if (pm.allsolid) { // entity is trapped in another solid SetGroundEntity( &pm ); mv->m_vecVelocity.Init(); return; } if ( pm.fraction != 1.0f ) { PerformFlyCollisionResolution( pm, move ); } // Check for in water CheckWater(); }
//----------------------------------------------------------------------------- // 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(); }