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 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: 
// Input  : flInterval - 
//			&m_LastMoveTarget - 
//			eMoveType - 
//-----------------------------------------------------------------------------
void CNPC_Ichthyosaur::DoMovement( float flInterval, const Vector &MoveTarget, int eMoveType )
{
	// dvs: something is setting this bit, causing us to stop moving and get stuck that way
	Forget( bits_MEMORY_TURNING );

	Vector Steer, SteerAvoid, SteerRel;
	Vector forward, right, up;

	//Get our orientation vectors.
	GetVectors( &forward, &right, &up);

	if ( ( GetActivity() == ACT_MELEE_ATTACK1 ) && ( GetEnemy() != NULL ) )
	{
		SteerSeek( Steer, GetEnemy()->GetAbsOrigin() );
	}
	else
	{
		//If we are approaching our goal, use an arrival steering mechanism.
		if ( eMoveType == ICH_MOVETYPE_ARRIVE )
		{
			SteerArrive( Steer, MoveTarget );
		}
		else
		{
			//Otherwise use a seek steering mechanism.
			SteerSeek( Steer, MoveTarget );
		}
	}
	
#if FEELER_COLLISION

	Vector f, u, l, r, d;

	float	probeLength = GetAbsVelocity().Length();

	if ( probeLength < 150 )
		probeLength = 150;

	if ( probeLength > 500 )
		probeLength = 500;

	f = DoProbe( GetLocalOrigin() + (probeLength * forward) );
	r = DoProbe( GetLocalOrigin() + (probeLength/3 * (forward+right)) );
	l = DoProbe( GetLocalOrigin() + (probeLength/3 * (forward-right)) );
	u = DoProbe( GetLocalOrigin() + (probeLength/3 * (forward+up)) );
	d = DoProbe( GetLocalOrigin() + (probeLength/3 * (forward-up)) );

	SteerAvoid = f+r+l+u+d;
	
	//NDebugOverlay::Line( GetLocalOrigin(), GetLocalOrigin()+SteerAvoid, 255, 255, 0, false, 0.1f );	

	if ( SteerAvoid.LengthSqr() )
	{
		Steer = (SteerAvoid*0.5f);
	}

	m_vecVelocity = m_vecVelocity + (Steer*0.5f);

	VectorNormalize( m_vecVelocity );

	SteerRel.x = forward.Dot( m_vecVelocity );
	SteerRel.y = right.Dot( m_vecVelocity );
	SteerRel.z = up.Dot( m_vecVelocity );

	m_vecVelocity *= m_flGroundSpeed;

#else

	//See if we need to avoid any obstacles.
	if ( SteerAvoidObstacles( SteerAvoid, GetAbsVelocity(), forward, right, up ) )
	{
		//Take the avoidance vector
		Steer = SteerAvoid;
	}

	//Clamp our ideal steering vector to within our physical limitations.
	ClampSteer( Steer, SteerRel, forward, right, up );

	ApplyAbsVelocityImpulse( Steer * flInterval );
	
#endif

	Vector vecNewVelocity = GetAbsVelocity();
	float flLength = vecNewVelocity.Length();

	//Clamp our final speed
	if ( flLength > m_flGroundSpeed )
	{
		vecNewVelocity *= ( m_flGroundSpeed / flLength );
		flLength = m_flGroundSpeed;
	}

	Vector	workVelocity = vecNewVelocity;

	AddSwimNoise( &workVelocity );

	// Pose the fish properly
	SetPoses( SteerRel, flLength );

	//Drag our victim before moving
	if ( m_pVictim != NULL )
	{
		DragVictim( (workVelocity*flInterval).Length() );
	}

	//Move along the current velocity vector
	if ( WalkMove( workVelocity * flInterval, MASK_NPCSOLID ) == false )
	{
		//Attempt a half-step
		if ( WalkMove( (workVelocity*0.5f) * flInterval,  MASK_NPCSOLID) == false )
		{
			//Restart the velocity
			//VectorNormalize( m_vecVelocity );
			vecNewVelocity *= 0.5f;
		}
		else
		{
			//Cut our velocity in half
			vecNewVelocity *= 0.5f;
		}
	}

	SetAbsVelocity( vecNewVelocity );

}
Example #4
0
 void WalkMoveJS(double amount) {WalkMove(amount);}
Example #5
0
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
    }
}
Example #6
0
void NPC::CheckStuck(float oldSpeed)
{
	if (!IsOnFloor(GetEntity()) || IsOnLadder (GetEntity ()))
		return;

	if (WalkMove())
		return;

	if (m_checkStuckTime > gpGlobals->time)
		return;

	m_checkStuckTime = gpGlobals->time + 0.5f;

	bool isStuck = false;
	float moveDistance = GetDistance(pev->origin, m_prevOrigin);

	if (oldSpeed >= 10.0f && pev->speed >= 10.0f)
	{
		if (moveDistance <= 2.0f)
			isStuck = true;
	}

	if (isStuck)
	{
		MakeVectors(pev->angles);

		TraceResult tr;
		Vector dest = pev->origin;
		dest.z += 32;
		Vector src = pev->origin + gpGlobals->v_forward * 32;

		UTIL_TraceHull(dest, src, dont_ignore_monsters, head_hull, GetEntity(), &tr);
		if (tr.flFraction > 0.0f && tr.flFraction != 1.0f)
		{
			float newOriginZ = pev->origin.z + (tr.vecEndPos.z - GetBottomOrigin(GetEntity ()).z) - 32;
			if (newOriginZ > pev->origin.z && (newOriginZ - pev->origin.z) <= 32)
			{
				pev->velocity.z = (270.0f * pev->gravity) + 32.0f;
				m_jumpAction = false;

				goto end;
			}
		}

		for (int i = 0; i <= 18; i++)
		{
			UTIL_TraceHull(pev->origin, pev->origin, dont_ignore_monsters, human_hull, GetEntity(), &tr);
			if (!tr.fStartSolid && !tr.fAllSolid && tr.fInOpen)
				break;

			if (i == 17)
			{
				int block = MF_ExecuteForward(g_callStuck_Pre, (cell)ENTINDEX(GetEntity()));
				if (!block)
				{
					LogToFile("The NPC is stuck, remove now");
					m_needRemove = true;
				}

				break;
			}

			pev->origin.z += 1;
		}
		
		m_goalWaypoint = -1;
		m_currentWaypointIndex = -1;
		DeleteSearchNodes();
	}

	end: m_prevOrigin = pev->origin;
}
Example #7
0
//-----------------------------------------------------------------------------
// 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();
}