Exemplo n.º 1
0
//--------------------------------------------------------------
// Name:        Evaluate()
// Class:       StationaryFireCombat
//
// Description: Evaluates the behavior
//
// Parameters:  Actor &self -- The actor executing this behavior
//
// Returns:     BehaviorReturnCode_t 
//--------------------------------------------------------------
BehaviorReturnCode_t StationaryFireCombat::Evaluate( Actor & )
{
	BehaviorReturnCode_t stateResult;

	think();
	
	switch ( _state )
		{
		//---------------------------------------------------------------------
		case STATIONARY_FIRE_AIM:
		//---------------------------------------------------------------------		
			stateResult = evaluateStateAim();

			if ( stateResult == BEHAVIOR_SUCCESS )
				{
				updateEnemy();
				if ( _preFireAnim.length() )
					transitionToState( STATIONARY_FIRE_PRE_FIRE );
				else
					transitionToState( STATIONARY_FIRE_ATTACK );
				}
				
		break;

		//---------------------------------------------------------------------
		case STATIONARY_FIRE_PRE_FIRE:
		//---------------------------------------------------------------------
			stateResult = evaluateStatePreFire();

			if ( stateResult == BEHAVIOR_SUCCESS )
				{
					transitionToState( STATIONARY_FIRE_ATTACK );	
				}

			if ( stateResult == BEHAVIOR_FAILED )
				{
				transitionToState( STATIONARY_FIRE_FAILED );
				}
			
		break;

		//---------------------------------------------------------------------
		case STATIONARY_FIRE_ATTACK:
		//---------------------------------------------------------------------		
			stateResult = evaluateStateAttack();

			if ( stateResult == BEHAVIOR_SUCCESS )
				{
				_fireWeapon.End( *_self );

				if ( _postFireAnim.length() )
					transitionToState( STATIONARY_FIRE_POST_FIRE );
				else
					transitionToState( STATIONARY_FIRE_SUCCESS );
				}

			if ( stateResult == BEHAVIOR_FAILED )
				{
				_fireWeapon.End( *_self );

				if ( _postFireAnim.length() )
					transitionToState( STATIONARY_FIRE_POST_FIRE );
				else
					transitionToState( STATIONARY_FIRE_SUCCESS );
				}

		break;


		//---------------------------------------------------------------------
		case STATIONARY_FIRE_POST_FIRE:
		//---------------------------------------------------------------------
			stateResult = evaluateStatePostFire();

			if ( stateResult == BEHAVIOR_SUCCESS )
				{
					transitionToState( STATIONARY_FIRE_SUCCESS );	
				}
		break;

		//---------------------------------------------------------------------
		case STATIONARY_FIRE_SUCCESS:
		//---------------------------------------------------------------------
			return BEHAVIOR_SUCCESS;

		break;


		//---------------------------------------------------------------------
		case STATIONARY_FIRE_FAILED:
		//---------------------------------------------------------------------
			return BEHAVIOR_FAILED;

		break;


		}
	

	return BEHAVIOR_EVALUATING;   

}
Exemplo n.º 2
0
//--------------------------------------------------------------
// Name:        Evaluate()
// Class:       TorsoAimAndFireWeapon
//
// Description: Evaluates the behavior
//
// Parameters:  Actor &self -- The actor executing this behavior
//
// Returns:     BehaviorReturnCode_t 
//--------------------------------------------------------------
BehaviorReturnCode_t TorsoAimAndFireWeapon::Evaluate( Actor &self )
{
	BehaviorReturnCode_t stateResult;

	think();
	
	switch ( _state )
		{
		//---------------------------------------------------------------------
		case TORSO_AIM_AND_FIRE_PRE_FIRE:
		//---------------------------------------------------------------------
			stateResult = evaluateStatePreFire();

			if ( stateResult == BEHAVIOR_SUCCESS )
				{
					transitionToState( TORSO_AIM_AND_FIRE_AIM );	
				}

			if ( stateResult == BEHAVIOR_FAILED )
				{
				transitionToState( TORSO_AIM_AND_FIRE_FAILED );
				}
		break;

		//---------------------------------------------------------------------
		case TORSO_AIM_AND_FIRE_AIM:
		//---------------------------------------------------------------------
			stateResult = evaluateStateAim();
						
			if ( stateResult == BEHAVIOR_SUCCESS )
				{
					if ( _aimOnly )
						transitionToState(TORSO_AIM_AND_FIRE_AIM);
					else
						transitionToState( TORSO_AIM_AND_FIRE_ATTACK );
				}
			
			if ( stateResult == BEHAVIOR_FAILED )
				return BEHAVIOR_FAILED;

		break;


		//---------------------------------------------------------------------
		case TORSO_AIM_AND_FIRE_ATTACK:
		//---------------------------------------------------------------------
			stateResult = evaluateStateAttack();

			if ( stateResult == BEHAVIOR_FAILED )
				{
				_fireWeapon.End( *_self );

				if ( _postFireAnim.length() )
					transitionToState( TORSO_AIM_AND_FIRE_POST_FIRE );
				else
					transitionToState( TORSO_AIM_AND_FIRE_FAILED );
				}

			if ( stateResult == BEHAVIOR_SUCCESS )
				{
				_fireWeapon.End( *_self );

				if ( _postFireAnim.length() )
					transitionToState( TORSO_AIM_AND_FIRE_POST_FIRE );
				else
					transitionToState( TORSO_AIM_AND_FIRE_SUCCESS );
				}
		break;

		//---------------------------------------------------------------------
		case TORSO_AIM_AND_FIRE_POST_FIRE:
		//---------------------------------------------------------------------
			stateResult = evaluateStatePostFire();

			if ( stateResult == BEHAVIOR_SUCCESS )
				{
					transitionToState( TORSO_AIM_AND_FIRE_SUCCESS );	
				}
		break;

		//---------------------------------------------------------------------
		case TORSO_AIM_AND_FIRE_SUCCESS:
		//---------------------------------------------------------------------
			_self->SetControllerAngles( ActorTorsoTag, vec_zero );

			if ( _repeat )
				{
				Begin(self);
				return BEHAVIOR_EVALUATING;
				}

			return BEHAVIOR_SUCCESS;

		break;


		//---------------------------------------------------------------------
		case TORSO_AIM_AND_FIRE_FAILED:
		//---------------------------------------------------------------------
			if ( _repeat )
				{
				Begin(self);
				return BEHAVIOR_EVALUATING;
				}

			return BEHAVIOR_FAILED;

		break;


		}
	

	return BEHAVIOR_EVALUATING;   

}