void CASW_Drone_Movement::ProcessMovement( CAI_BaseNPC *pNPC, CMoveData *pMove, float flInterval) { Assert( pMove && pNPC ); m_pNPC = pNPC; mv = pMove; m_flInterval = flInterval; mv->m_outWishVel.Init(); mv->m_outJumpVel.Init(); Vector start = pMove->GetAbsOrigin(); CategorizePosition(); StartGravity(); WalkMove(); FinishGravity(); // pushes him down by gravity CategorizePosition(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CSDKGameMovement::CheckJumpButton( void ) { if (!m_pSDKPlayer->IsAlive()) { mv->m_nOldButtons |= IN_JUMP ; // don't jump again until released return false; } #if defined ( SDK_USE_PRONE ) if( m_pSDKPlayer->m_Shared.IsProne() || m_pSDKPlayer->m_Shared.IsGettingUpFromProne() || m_pSDKPlayer->m_Shared.IsGoingProne() ) { mv->m_nOldButtons |= IN_JUMP; return false; } #endif // See if we are waterjumping. If so, decrement count and return. float flWaterJumpTime = player->GetWaterJumpTime(); if ( flWaterJumpTime > 0 ) { flWaterJumpTime -= gpGlobals->frametime; if (flWaterJumpTime < 0) flWaterJumpTime = 0; player->SetWaterJumpTime( flWaterJumpTime ); return false; } // If we are in the water most of the way... if ( m_pSDKPlayer->GetWaterLevel() >= 2 ) { // swimming, not jumping SetGroundEntity( NULL ); if(m_pSDKPlayer->GetWaterType() == CONTENTS_WATER) // We move up a certain amount mv->m_vecVelocity[2] = 100; else if (m_pSDKPlayer->GetWaterType() == CONTENTS_SLIME) mv->m_vecVelocity[2] = 80; // play swiming sound if ( player->GetSwimSoundTime() <= 0 ) { // Don't play sound again for 1 second player->SetSwimSoundTime( 1000 ); PlaySwimSound(); } return false; } // No more effect if (m_pSDKPlayer->GetGroundEntity() == NULL) { mv->m_nOldButtons |= IN_JUMP; return false; // in air, so no effect } if ( mv->m_nOldButtons & IN_JUMP ) return false; // don't pogo stick // In the air now. SetGroundEntity( NULL ); m_pSDKPlayer->PlayStepSound( (Vector &)mv->GetAbsOrigin(), player->GetSurfaceData(), 1.0, true ); m_pSDKPlayer->DoAnimationEvent( PLAYERANIMEVENT_JUMP ); //Tony; liek the landing sound, leaving this here if as an example for playing a jump sound. // // make the jump sound // CPASFilter filter( m_pSDKPlayer->GetAbsOrigin() ); // filter.UsePredictionRules(); // m_pSDKPlayer->EmitSound( filter, m_pSDKPlayer->entindex(), "Player.Jump" ); float flGroundFactor = 1.0f; if ( player->GetSurfaceData() ) { flGroundFactor = player->GetSurfaceData()->game.jumpFactor; } Assert( sv_gravity.GetFloat() == 800.0f ); float flJumpHeight = 268.3281572999747f; //Warning("HERE team: %d", player->GetTeamNumber()); // Accelerate upward // If we are ducking... float startz = mv->m_vecVelocity[2]; if ( ( m_pSDKPlayer->m_Local.m_bDucking ) || ( m_pSDKPlayer->GetFlags() & FL_DUCKING ) ) { // d = 0.5 * g * t^2 - distance traveled with linear accel // t = sqrt(2.0 * 45 / g) - how long to fall 45 units // v = g * t - velocity at the end (just invert it to jump up that high) // v = g * sqrt(2.0 * 45 / g ) // v^2 = g * g * 2.0 * 45 / g // v = sqrt( g * 2.0 * 45 ) if(player->GetTeamNumber() == 2){ mv->m_vecVelocity[2] = flGroundFactor * flJumpHeight ; //mv->m_vecVelocity[1] *= 1.8; //mv->m_vecVelocity[0] *= 1.8; Vector vecForward; AngleVectors( mv->m_vecViewAngles, &vecForward ); vecForward.z = 0; VectorNormalize( vecForward ); VectorAdd( (vecForward*(fabs( mv->m_flForwardMove * 0.5f ))*2), mv->m_vecVelocity, mv->m_vecVelocity ); } else mv->m_vecVelocity[2] = flGroundFactor * flJumpHeight; // flJumpSpeed of 45 } else { if(player->GetTeamNumber() == 2) mv->m_vecVelocity[2] += flGroundFactor * flJumpHeight * 2; // 2 * gravity * height else mv->m_vecVelocity[2] += flGroundFactor * flJumpHeight; // 2 * gravity * height //mv->m_vecVelocity[2] += flGroundFactor * flJumpHeight; // flJumpSpeed of 45 } FinishGravity(); mv->m_outWishVel.z += mv->m_vecVelocity[2] - startz; mv->m_outStepHeight += 0.1f; // Flag that we jumped. mv->m_nOldButtons |= IN_JUMP; // don't jump again until released m_pSDKPlayer->m_Shared.SetJumping( true ); return true; }
bool CHL2GameMovement::CheckJumpButton() { CHL2_Player *m_pCSPlayer = GetHL2Player(); if (m_pCSPlayer->pl.deadflag) { mv->m_nOldButtons |= IN_JUMP; // don't jump again until released return false; } // See if we are waterjumping. If so, decrement count and return. if (m_pCSPlayer->m_flWaterJumpTime) { m_pCSPlayer->m_flWaterJumpTime -= gpGlobals->frametime; if (m_pCSPlayer->m_flWaterJumpTime < 0) m_pCSPlayer->m_flWaterJumpTime = 0; return false; } // If we are in the water most of the way... if (m_pCSPlayer->GetWaterLevel() >= 2) { // swimming, not jumping SetGroundEntity(NULL); if (m_pCSPlayer->GetWaterType() == CONTENTS_WATER) // We move up a certain amount mv->m_vecVelocity[2] = 100; else if (m_pCSPlayer->GetWaterType() == CONTENTS_SLIME) mv->m_vecVelocity[2] = 80; // play swiming sound if (m_pCSPlayer->m_flSwimSoundTime <= 0) { // Don't play sound again for 1 second m_pCSPlayer->m_flSwimSoundTime = 1000; PlaySwimSound(); } return false; } // No more effect if (m_pCSPlayer->GetGroundEntity() == NULL) { mv->m_nOldButtons |= IN_JUMP; return false; // in air, so no effect } //if (mv->m_nOldButtons & IN_JUMP) // return false; // don't pogo stick // In the air now. SetGroundEntity(NULL); m_pCSPlayer->PlayStepSound((Vector &)mv->GetAbsOrigin(), player->m_pSurfaceData, 1.0, true); //MoveHelper()->PlayerSetAnimation( PLAYER_JUMP ); //m_pCSPlayer->DoAnimationEvent(PLAYERANIMEVENT_JUMP); float flGroundFactor = 1.0f; if (player->m_pSurfaceData) { flGroundFactor = player->m_pSurfaceData->game.jumpFactor; } // if we weren't ducking, bots and hostages do a crouchjump programatically if ((!player || player->IsBot()) && !(mv->m_nButtons & IN_DUCK)) { //m_pCSPlayer->m_duckUntilOnGround = true; FinishDuck(); } // Acclerate upward // If we are ducking... float startz = mv->m_vecVelocity[2]; if ((m_pCSPlayer->m_Local.m_bDucking) || (m_pCSPlayer->GetFlags() & FL_DUCKING)) { mv->m_vecVelocity[2] = flGroundFactor * sqrt(2 * 800 * 57.0); // 2 * gravity * height } else { mv->m_vecVelocity[2] += flGroundFactor * sqrt(2 * 800 * 57.0); // 2 * gravity * height } FinishGravity(); mv->m_outWishVel.z += mv->m_vecVelocity[2] - startz; mv->m_outStepHeight += 0.1f; // Flag that we jumped. mv->m_nOldButtons |= IN_JUMP; // don't jump again until released return true; }
//----------------------------------------------------------------------------- // 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 } }
bool CTFGameMovement::CheckJumpButton() { // Are we dead? Then we cannot jump. if ( player->pl.deadflag ) return false; // Check to see if we are in water. if ( !CheckWaterJumpButton() ) return false; // Cannot jump while taunting if ( m_pTFPlayer->m_Shared.InCond( TF_COND_TAUNTING ) ) return false; // Check to see if the player is a scout. bool bScout = m_pTFPlayer->GetPlayerClass()->IsClass( TF_CLASS_SCOUT ); bool bAirDash = false; bool bOnGround = ( player->GetGroundEntity() != NULL ); // Cannot jump will ducked. if ( player->GetFlags() & FL_DUCKING ) { // Let a scout do it. bool bAllow = (bScout && !bOnGround) || tf2c_duckjump.GetBool() || TFGameRules()->IsDeathmatch(); if ( !bAllow ) return false; } // Cannot jump while in the unduck transition. if ( ( player->m_Local.m_bDucking && ( player->GetFlags() & FL_DUCKING ) ) || ( player->m_Local.m_flDuckJumpTime > 0.0f ) && !tf2c_duckjump.GetBool() ) return false; // Cannot jump again until the jump button has been released. if ( mv->m_nOldButtons & IN_JUMP && !(tf2c_autojump.GetBool() || TFGameRules()->IsDeathmatch()) ) return false; // In air, so ignore jumps (unless you are a scout). if ( !bOnGround ) { if ( bScout && !m_pTFPlayer->m_Shared.IsAirDashing() ) { bAirDash = true; } else { mv->m_nOldButtons |= IN_JUMP; return false; } } // Check for an air dash. if ( bAirDash ) { AirDash(); return true; } PreventBunnyJumping(); // Start jump animation and player sound (specific TF animation and flags). m_pTFPlayer->DoAnimationEvent( PLAYERANIMEVENT_JUMP ); player->PlayStepSound( (Vector &)mv->GetAbsOrigin(), player->m_pSurfaceData, 1.0, true ); m_pTFPlayer->m_Shared.SetJumping( true ); // Set the player as in the air. SetGroundEntity( NULL ); // Check the surface the player is standing on to see if it impacts jumping. float flGroundFactor = 1.0f; if ( player->m_pSurfaceData ) { flGroundFactor = player->m_pSurfaceData->game.jumpFactor; } // fMul = sqrt( 2.0 * gravity * jump_height (21.0units) ) * GroundFactor Assert( sv_gravity.GetFloat() == 800.0f ); float flMul = 268.3281572999747f * flGroundFactor; // Save the current z velocity. float flStartZ = mv->m_vecVelocity[2]; // Acclerate upward if ( ( player->m_Local.m_bDucking ) || ( player->GetFlags() & FL_DUCKING ) ) { // If we are ducking... // d = 0.5 * g * t^2 - distance traveled with linear accel // t = sqrt(2.0 * 45 / g) - how long to fall 45 units // v = g * t - velocity at the end (just invert it to jump up that high) // v = g * sqrt(2.0 * 45 / g ) // v^2 = g * g * 2.0 * 45 / g // v = sqrt( g * 2.0 * 45 ) mv->m_vecVelocity[2] = flMul; // 2 * gravity * jump_height * ground_factor } else { mv->m_vecVelocity[2] += flMul; // 2 * gravity * jump_height * ground_factor } // Apply gravity. FinishGravity(); // Save the output data for the physics system to react to if need be. mv->m_outJumpVel.z += mv->m_vecVelocity[2] - flStartZ; mv->m_outStepHeight += 0.15f; // Flag that we jumped and don't jump again until it is released. mv->m_nOldButtons |= IN_JUMP; return true; }
//----------------------------------------------------------------------------- // 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(); }
bool CMomentumGameMovement::CheckJumpButton() { if (player->pl.deadflag) { mv->m_nOldButtons |= IN_JUMP; // don't jump again until released return false; } // See if we are waterjumping. If so, decrement count and return. if (player->m_flWaterJumpTime) { player->m_flWaterJumpTime -= gpGlobals->frametime; if (player->m_flWaterJumpTime < 0) player->m_flWaterJumpTime = 0; return false; } // If we are in the water most of the way... if (player->GetWaterLevel() >= 2) { // swimming, not jumping SetGroundEntity(NULL); if (player->GetWaterType() == CONTENTS_WATER) // We move up a certain amount mv->m_vecVelocity[2] = 100; else if (player->GetWaterType() == CONTENTS_SLIME) mv->m_vecVelocity[2] = 80; // play swiming sound if (player->m_flSwimSoundTime <= 0) { // Don't play sound again for 1 second player->m_flSwimSoundTime = 1000; PlaySwimSound(); } return false; } // No more effect if (player->GetGroundEntity() == NULL) { mv->m_nOldButtons |= IN_JUMP; return false; // in air, so no effect } //AUTOBHOP--- //only run this code if autobhop is disabled if (!player->HasAutoBhop()) { if (mv->m_nOldButtons & IN_JUMP) return false; // don't pogo stick } // In the air now. SetGroundEntity(NULL); player->PlayStepSound((Vector &) mv->GetAbsOrigin(), player->m_pSurfaceData, 1.0, true); //MoveHelper()->PlayerSetAnimation( PLAYER_JUMP ); //player->DoAnimationEvent(PLAYERANIMEVENT_JUMP); float flGroundFactor = 1.0f; if (player->m_pSurfaceData) { flGroundFactor = player->m_pSurfaceData->game.jumpFactor; } // if we weren't ducking, bots and hostages do a crouchjump programatically if ((!player || player->IsBot()) && !(mv->m_nButtons & IN_DUCK)) { player->m_duckUntilOnGround = true; FinishDuck(); } // Acclerate upward // If we are ducking... float startz = mv->m_vecVelocity[2]; if ((player->m_Local.m_bDucking) || (player->GetFlags() & FL_DUCKING)) { mv->m_vecVelocity[2] = flGroundFactor * sqrt(2 * 800 * 57.0); // 2 * gravity * height } else { mv->m_vecVelocity[2] += flGroundFactor * sqrt(2 * 800 * 57.0); // 2 * gravity * height } //stamina stuff (scroll gamemode only) ConVarRef gm("mom_gamemode"); if (gm.GetInt() == MOMGM_SCROLL) { if (player->m_flStamina > 0) { float flRatio; flRatio = (STAMINA_MAX - ((player->m_flStamina / 1000.0) * STAMINA_RECOVER_RATE)) / STAMINA_MAX; mv->m_vecVelocity[2] *= flRatio; } player->m_flStamina = (STAMINA_COST_JUMP / STAMINA_RECOVER_RATE) * 1000.0; } FinishGravity(); mv->m_outWishVel.z += mv->m_vecVelocity[2] - startz; mv->m_outStepHeight += 0.1f; // Flag that we jumped. mv->m_nOldButtons |= IN_JUMP; // don't jump again until released return true; }