예제 #1
0
AIMoveResult_t CAI_Motor::MoveClimbExecute( const Vector &climbDest, float yaw)
{
	const float climbSpeed = 100.0;

	Vector moveDir = climbDest - GetLocalOrigin();
	float flDist = VectorNormalize( moveDir );
	SetSmoothedVelocity( moveDir * climbSpeed );

	if ( flDist < climbSpeed * GetMoveInterval() )
	{
		if (flDist <= 1e-2)
			flDist = 0;

		const float climbTime = flDist / climbSpeed;
		
		SetMoveInterval( GetMoveInterval() - climbTime );
		SetLocalOrigin( climbDest );

		return AIMR_CHANGE_TYPE;
	}
	else
	{
		SetMoveInterval( 0 );
	}

	// --------------------------------------------
	// Turn to face the climb
	// --------------------------------------------
	SetIdealYawAndUpdate( yaw );

	return AIMR_OK;
}
예제 #2
0
AIMoveResult_t CAI_Motor::MoveJumpStop()
{
	SetSmoothedVelocity( Vector(0,0,0) );

	if (GetOuter()->GetActivity() == ACT_GLIDE)
	{
		float flTime = GetOuter()->GetGroundChangeTime();
		GetOuter()->AddStepDiscontinuity( flTime, GetAbsOrigin(), GetAbsAngles() );

		if ( SelectWeightedSequence( ACT_LAND ) == ACT_INVALID )
			return AIMR_CHANGE_TYPE;

		SetActivity( ACT_LAND );
		// FIXME: find out why the client doesn't interpolate immediatly after sequence change
		// GetOuter()->SetCycle( flTime - gpGlobals->curtime );
	}
	if (GetOuter()->GetActivity() != ACT_LAND || GetOuter()->IsActivityFinished())
	{
		return AIMR_CHANGE_TYPE;
	}

	SetMoveInterval( 0 );

	SetGravity( 1.0f );

	return AIMR_OK;
}
예제 #3
0
void CAI_Motor::MoveJumpStart( const Vector &velocity )
{
	SetSmoothedVelocity( velocity );
	SetGravity( 1.0 );
	RemoveEntFlag( FL_ONGROUND );

	SetActivity( ACT_JUMP );

	SetIdealYawAndUpdate( velocity );
}
예제 #4
0
void CAI_Motor::MoveJumpStart( const Vector &velocity )
{
	// take the npc off the ground and throw them in the air
	SetSmoothedVelocity( velocity );
	SetGravity( GetOuter()->GetJumpGravity() );
	SetGroundEntity( NULL );

	SetActivity( ACT_JUMP );

	SetIdealYawAndUpdate( velocity );
}
예제 #5
0
void CAI_Motor::MoveClimbStop()
{
	if ( GetNavigator()->GetMovementActivity() > ACT_RESET )
		SetActivity( GetNavigator()->GetMovementActivity() );
	else
		SetActivity( ACT_IDLE );

	GetOuter()->RemoveFlag( FL_FLY );
	SetSmoothedVelocity( vec3_origin );
	SetGravity( 1.0 );
}
예제 #6
0
void CAI_Motor::MoveJumpStop()
{
	SetSmoothedVelocity( Vector(0,0,0) );
	SetActivity( ACT_LAND );
}
예제 #7
0
void CAI_Motor::MoveClimbStop()
{
	SetMoveType( MOVETYPE_STEP );
	SetSmoothedVelocity( vec3_origin );
	SetGravity( 1.0 );
}
예제 #8
0
AIMoveResult_t CAI_Motor::MoveClimbExecute( const Vector &climbDest, const Vector &climbDir, float climbDist, float yaw, int climbNodesLeft )
{
	if ( fabsf( climbDir.z ) > .1 )
	{
		if ( GetActivity() != ACT_CLIMB_DISMOUNT )
		{
			Activity desiredActivity = (climbDir.z > -0.01 ) ? ACT_CLIMB_UP : ACT_CLIMB_DOWN;
			if ( GetActivity() != desiredActivity )
			{
				SetActivity( desiredActivity );
			}
		}

		if ( GetActivity() != ACT_CLIMB_UP && GetActivity() != ACT_CLIMB_DOWN && GetActivity() != ACT_CLIMB_DISMOUNT )
		{
			DevMsg( "Climber not in a climb activity!\n" );
			return AIMR_ILLEGAL;
		}

		if (m_nDismountSequence != ACT_INVALID)
		{
			if (GetActivity() == ACT_CLIMB_UP )
			{
				if (climbNodesLeft <= 2 && climbDist < fabs( m_vecDismount.z ))
				{
					// fixme: No other way to force m_nIdealSequence?
					GetOuter()->SetActivity( ACT_CLIMB_DISMOUNT );
					GetOuter()->SetCycle( GetOuter()->GetMovementFrame( m_vecDismount.z - climbDist ) );
				}
			}
		}
	}

	float climbSpeed = GetOuter()->GetInstantaneousVelocity();

	if (m_nDismountSequence != ACT_INVALID)
	{
		// catch situations where the climb mount/dismount finished before reaching goal
		climbSpeed = MAX( climbSpeed, 30.0 );
	}
	else
	{
		// FIXME: assume if they don't have a dismount animation then they probably don't really support climbing.
		climbSpeed = 100.0;
	}

	SetSmoothedVelocity( climbDir * climbSpeed );

	if ( climbDist < climbSpeed * GetMoveInterval() )
	{
		if (climbDist <= 1e-2)
			climbDist = 0;

		const float climbTime = climbDist / climbSpeed;
		
		SetMoveInterval( GetMoveInterval() - climbTime );
		SetLocalOrigin( climbDest );

		return AIMR_CHANGE_TYPE;
	}
	else
	{
		SetMoveInterval( 0 );
	}

	// --------------------------------------------
	// Turn to face the climb
	// --------------------------------------------
	SetIdealYawAndUpdate( yaw );

	return AIMR_OK;
}