CommandState  CommandDestroyBlock  :: Process()
{
	// If this is the first time processing, then activate:
	ActivateIfInactive();

	if( (owner->GetSceneNode()->getPosition()).getDistanceFrom(vector3df(block.X + 0.5f, block.Y, block.Z + 0.5f)) > 2.0f)
	{
		std::cout << "CommandDestroyBlock - Failed - to far from block" << std::endl;
		state = failed;
	}
	else if( !MapMgr->IsBlockSolid(vector3df(block.X, block.Y, block.Z)) )
	{

		std::cout << "CommandDestroyBlock - Suceeded - block is now open" << std::endl;
		state = completed;
	}
	/*
	else if(owner->GetActionDelay() <= 0)
	{
		//owner->DamageBlock(block, hotBarSlot);
	}
	*/

	return state;

}
//------------------------------ Process --------------------------------------
//-----------------------------------------------------------------------------
int Goal_Wander::Process()
{
  //if status is inactive, call Activate()
  ActivateIfInactive();

  return m_iStatus;
}
Exemplo n.º 3
0
//------------------------------ Process -------------------------------------
//-----------------------------------------------------------------------------
int Goal_InstallBomb::Process()
{
	//if status is inactive, call Activate()
	ActivateIfInactive();

	//process the subgoals
	m_iStatus = ProcessSubgoals();

	return m_iStatus;
}
Exemplo n.º 4
0
//------------------------------ Process --------------------------------------
//-----------------------------------------------------------------------------
int Goal_NegotiateDoor::Process()
{
  //if status is inactive, call Activate()
  ActivateIfInactive();

  //process the subgoals
  m_iStatus = ProcessSubgoals();

  return m_iStatus;
}
Exemplo n.º 5
0
//-------------------------- Process ------------------------------------------
//-----------------------------------------------------------------------------
int Goal_AttackTarget::Process()
{
  //if status is inactive, call Activate()
  ActivateIfInactive();
    
  //process the subgoals
  m_iStatus = ProcessSubgoals();

  ReactivateIfFailed();

  return m_iStatus;
}
Exemplo n.º 6
0
CommandState BrainWorker :: Process()
{
	ActivateIfInactive();

	CommandState subCommandState = ProcessSubCommands();

	if (subCommandState == completed || subCommandState == failed)
	{
		state = inactive;
	}

  return state;
}
//------------------------------ Process --------------------------------------
//-----------------------------------------------------------------------------
int Goal_MoveToPosition::Process()
{
  //if status is inactive, call Activate()
  ActivateIfInactive();
    
  //process the subgoals
  m_iStatus = ProcessSubgoals();

  //if any of the subgoals have failed then this goal re-plans
  ReactivateIfFailed();

  return m_iStatus;
}
Exemplo n.º 8
0
CommandState AnimalBrain :: Process()
{
	ActivateIfInactive();

	CommandState subCommandState = ProcessSubCommands();

	// if the animal is not currently running a subcommand then determine what the next command is:
	if((subCommandState == completed || subCommandState == failed))
	{
		AddSubCommand(new CommandWander(owner));
	}

	return state;
}
Exemplo n.º 9
0
		int GoalFollowPath::Process(const UpdateArgs& args)
		{
			// if status is inactive, call Activate()
			ActivateIfInactive(args);

			status = ProcessSubgoals(args);

			//if there are no subgoals present check to see if the path still has edges.
			//remaining. If it does then call activate to grab the next edge.
			if (status == Completed && !path.empty())
				Activate(args);

			return status;
		}
//------------------------------ Process --------------------------------------
//-----------------------------------------------------------------------------
int Goal_HuntTarget::Process()
{
  //if status is inactive, call Activate()
  ActivateIfInactive();

  m_iStatus = ProcessSubgoals();

  //if target is in view this goal is satisfied
  if (m_pOwner->GetTargetSys()->isTargetWithinFOV())
  {
     m_iStatus = completed;
  }

  return m_iStatus;
}
//-------------------------- Process ------------------------------------------
//-----------------------------------------------------------------------------
int Goal_FollowPath::Process()
{
  //if status is inactive, call Activate()
  ActivateIfInactive();

  m_iStatus = ProcessSubgoals();

  //if there are no subgoals present check to see if the path still has edges.
  //remaining. If it does then call activate to grab the next edge.
  if (m_iStatus == completed && !m_Path.empty())
  {
    Activate(); 
  }

  return m_iStatus;
}
//-------------------------- Process ------------------------------------------
//-----------------------------------------------------------------------------
int Goal_GetItem::Process()
{
  ActivateIfInactive();

  if (hasItemBeenStolen())
  {
    Terminate();
  }

  else
  {
    //process the subgoals
    m_iStatus = ProcessSubgoals();
  }

  return m_iStatus;
}
Exemplo n.º 13
0
//-------------------------- Process ------------------------------------------
//-----------------------------------------------------------------------------
int Goal_DodgeSideToSide::Process()
{
	//if status is inactive, call Activate()
	ActivateIfInactive(); 

	//if target goes out of view terminate
	if (!m_pOwner->GetTargetSys()->isTargetWithinFOV())
	{
		m_iStatus = completed;
	}

	//else if bot reaches the target position set status to inactive so the goal 
	//is reactivated on the next update-step
	else if (m_pOwner->isAtPosition(m_vStrafeTarget))
	{
		m_iStatus = inactive;
	}

	return m_iStatus;
}
Exemplo n.º 14
0
CommandState  CommandPickUpItem  :: Process()
{
	ActivateIfInactive();

	ProcessSubCommands();

	if(owner->GetFeetPosition().getDistanceFrom(item->GetPosition()) > 1.0f
	&& !IsCurrentCommand(COMMAND_PATH_TO_POSITION))
	{
		AddSubCommand(new CommandPathToPosition(owner, item->GetPosition() + vector3df(0,0.1f,0))); // Vector is to deal with items partially submerged in ground
	}
	else
	{
		owner->AddToInventory(item->GetItem(), item->GetItemAmount());
		InstanceMgr->DestroyItemInstance(item);
		state = completed;
	}

	return state;
}
Exemplo n.º 15
0
//------------------------------ Process --------------------------------------
//-----------------------------------------------------------------------------
int Goal_TraverseEdge::Process()
{
    //if status is inactive, call Activate()
    ActivateIfInactive();

    //if the bot has become stuck return failure
    if (isStuck())
    {
        m_iStatus = failed;
    }

    //if the bot has reached the end of the edge return completed
    else
    {
        if (m_pOwner->isAtPosition(m_Edge.Destination()))
        {
            m_iStatus = completed;
        }
    }

    return m_iStatus;
}
Exemplo n.º 16
0
//------------------------------ Process --------------------------------------
//-----------------------------------------------------------------------------
int Goal_SeekToPosition::Process()
{
//	std::cout << "Goal_SeekToPosition::Process" << std::endl;
//	std::cout << " ++ ";
  //if status is inactive, call Activate()
  ActivateIfInactive();
//  Vector2D Estoy = m_pOwner->Pos();
//  Vector2D Voy = m_vPosition;
//	std::cout << "Estoy (" << Estoy.x << "," << Estoy.y << ") Voy (" << Voy.x
//			<< "," << Voy.y << ")" << std::endl;
  //test to see if the bot has become stuck
  if ( isStuck() ) {
    m_iStatus = failed;
  }
  //test to see if the bot has reached the waypoint. If so terminate the goal
  else {

    if ( m_pOwner->isAtPosition( m_vPosition ) ) {
      m_iStatus = completed;
    }
  }
  return m_iStatus;
}
Exemplo n.º 17
0
CommandState  CommandWander  :: Process()
{
	// If this is the first time processing, then activate:
	ActivateIfInactive();

	CommandState subCommandState = ProcessSubCommands();

	// if the animal is not currently running a subcommand then determine what the next command is:
	if((subCommandState == completed || subCommandState == failed))
	{
		int choice = rand() % 2;

		if(choice == 0)
		{
			AddSubCommand(new CommandMoveToRandomPosition(owner, 10));
		}
		if(choice == 1)
		{
			AddSubCommand(new CommandIdle(owner, 3000));
		}
	}

	return state;
}
Exemplo n.º 18
0
int FindWorkGoal::Process()
{
	ActivateIfInactive();
	return m_gStatus;
}