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;
}
void CAI_Motor::MoveFacing( const AILocalMoveGoal_t &move )
{
	if ( GetOuter()->OverrideMoveFacing( move, GetMoveInterval() ) )
		return;

	// required movement direction
	float flMoveYaw = UTIL_VecToYaw( move.dir );

	int nSequence = GetSequence();
	float fSequenceMoveYaw = GetSequenceMoveYaw( nSequence );
	if ( fSequenceMoveYaw == NOMOTION )
	{
		fSequenceMoveYaw = 0;
	}

	if (!HasPoseParameter( nSequence, "move_yaw" ))
	{
		SetIdealYawAndUpdate( UTIL_AngleMod( flMoveYaw - fSequenceMoveYaw ) );
	}
	else
	{
		// FIXME: move this up to navigator so that path goals can ignore these overrides.
		Vector dir;
		float flInfluence = GetFacingDirection( dir );
		dir = move.facing * (1 - flInfluence) + dir * flInfluence;
		VectorNormalize( dir );

		// ideal facing direction
		float idealYaw = UTIL_AngleMod( UTIL_VecToYaw( dir ) );
		
		// FIXME: facing has important max velocity issues
		SetIdealYawAndUpdate( idealYaw );	

		// find movement direction to compensate for not being turned far enough
		float flDiff = UTIL_AngleDiff( flMoveYaw, GetLocalAngles().y );
		SetPoseParameter( "move_yaw", flDiff );
		/*
		if ((GetOuter()->m_debugOverlays & OVERLAY_NPC_SELECTED_BIT))
		{
			Msg( "move %.1f : diff %.1f  : ideal %.1f\n", flMoveYaw, flDiff, m_IdealYaw );
		}
		*/
	}
}
void CAI_Motor::MoveJumpStart( const Vector &velocity )
{
	SetSmoothedVelocity( velocity );
	SetGravity( 1.0 );
	RemoveEntFlag( FL_ONGROUND );

	SetActivity( ACT_JUMP );

	SetIdealYawAndUpdate( velocity );
}
Example #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 );
}
int CAI_Motor::MoveJumpExecute( )
{
	// needs to detect being hit
	SetIdealYawAndUpdate( GetSmoothedVelocity() );

	SetActivity( ACT_GLIDE );

	// use all the time
	SetMoveInterval( 0 );

	return AIMR_OK;
}
void CAI_Motor::SetIdealYawToTargetAndUpdate( const Vector &target, float yawSpeed )
{ 
	SetIdealYawAndUpdate( CalcIdealYaw( target ), yawSpeed ); 
}
Example #7
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;
}