void CMomentumGameMovement::AirMove(void) { int i; Vector wishvel; float fmove, smove; Vector wishdir; float wishspeed; Vector forward, right, up; AngleVectors(mv->m_vecViewAngles, &forward, &right, &up); // Determine movement angles // Copy movement amounts fmove = mv->m_flForwardMove; smove = mv->m_flSideMove; // Zero out z components of movement vectors forward[2] = 0; right[2] = 0; VectorNormalize(forward); // Normalize remainder of vectors VectorNormalize(right); // for (i = 0; i<2; i++) // Determine x and y parts of velocity wishvel[i] = forward[i] * fmove + right[i] * smove; wishvel[2] = 0; // Zero out z part of velocity VectorCopy(wishvel, wishdir); // Determine maginitude of speed of move wishspeed = VectorNormalize(wishdir); // // clamp to server defined max speed // if (wishspeed != 0 && (wishspeed > mv->m_flMaxSpeed)) { VectorScale(wishvel, mv->m_flMaxSpeed / wishspeed, wishvel); wishspeed = mv->m_flMaxSpeed; } AirAccelerate(wishdir, wishspeed, sv_airaccelerate.GetFloat()); // Add in any base velocity to the current velocity. VectorAdd(mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity); flReflectNormal = NO_REFL_NORMAL_CHANGE; TryPlayerMove(NULL, NULL); // Now pull the base velocity back out. Base velocity is set if you are on a moving object, like a conveyor (or maybe another monster?) VectorSubtract(mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity); CheckForLadders(false); //return bDidReflect; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPortalGameMovement::AirMove( void ) { int i; Vector wishvel; float fmove, smove; Vector wishdir; float wishspeed; Vector forward, right, up; AngleVectors (mv->m_vecViewAngles, &forward, &right, &up); // Determine movement angles // Copy movement amounts fmove = mv->m_flForwardMove; smove = mv->m_flSideMove; // Zero out z components of movement vectors forward[2] = 0; right[2] = 0; VectorNormalize(forward); // Normalize remainder of vectors VectorNormalize(right); // for (i=0 ; i<2 ; i++) // Determine x and y parts of velocity wishvel[i] = forward[i]*fmove + right[i]*smove; wishvel[2] = 0; // Zero out z part of velocity VectorCopy (wishvel, wishdir); // Determine maginitude of speed of move // // Don't let the player screw their fling because of adjusting into a floor portal // if ( mv->m_vecVelocity[ 0 ] * mv->m_vecVelocity[ 0 ] + mv->m_vecVelocity[ 1 ] * mv->m_vecVelocity[ 1 ] > MIN_FLING_SPEED * MIN_FLING_SPEED ) { if ( mv->m_vecVelocity[ 0 ] > MIN_FLING_SPEED * 0.5f && wishdir[ 0 ] < 0.0f ) wishdir[ 0 ] = 0.0f; else if ( mv->m_vecVelocity[ 0 ] < -MIN_FLING_SPEED * 0.5f && wishdir[ 0 ] > 0.0f ) wishdir[ 0 ] = 0.0f; if ( mv->m_vecVelocity[ 1 ] > MIN_FLING_SPEED * 0.5f && wishdir[ 1 ] < 0.0f ) wishdir[ 1 ] = 0.0f; else if ( mv->m_vecVelocity[ 1 ] < -MIN_FLING_SPEED * 0.5f && wishdir[ 1 ] > 0.0f ) wishdir[ 1 ] = 0.0f; } // // Try to autocorrect the player to fall into the middle of the portal // else if ( sv_player_funnel_into_portals.GetBool() ) { int iPortalCount = CProp_Portal_Shared::AllPortals.Count(); if( iPortalCount != 0 ) { CProp_Portal **pPortals = CProp_Portal_Shared::AllPortals.Base(); for( int i = 0; i != iPortalCount; ++i ) { CProp_Portal *pTempPortal = pPortals[i]; if( pTempPortal->IsActivedAndLinked() ) { FunnelIntoPortal( pTempPortal, wishdir ); } } } } wishspeed = VectorNormalize(wishdir); // // clamp to server defined max speed // if ( wishspeed != 0 && (wishspeed > mv->m_flMaxSpeed)) { VectorScale (wishvel, mv->m_flMaxSpeed/wishspeed, wishvel); wishspeed = mv->m_flMaxSpeed; } AirAccelerate( wishdir, wishspeed, 15.0f ); // Add in any base velocity to the current velocity. VectorAdd(mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity ); TryPlayerMove(); // Now pull the base velocity back out. Base velocity is set if you are on a moving object, like a conveyor (or maybe another monster?) VectorSubtract( mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity ); }