#include "GoalHuntTarget.h" #include "../SteeringBehaviours.h" #include "../Vehicle.h" #include "GoalExplore.h" #include "GoalMoveToPosition.h" #include "GoalWander.h" //---------------------------- Initialize ------------------------------------- void GoalHuntTarget::Activate() { m_Status = active; markOwnerWithGoal(); // if this goal is reactivated then there may be some existing subgoals that // must be removed removeAllSubgoals(); // it is possible for the target to die whilst this goal is active so we // must test to make sure the bot always has an active target if (m_Owner->getTargetSys()->isTargetPresent()) { // grab a local copy of the last recorded position (LRP) of the target const glm::vec2 lrp = m_Owner->getTargetSys() ->getLastRecordedPosition(); // if the bot has reached the LRP and it still hasn't found the target // it starts to search by using the explore goal to move to random // map locations if (glm::length(lrp) < 0.000001 || m_Owner->isAtPosition(lrp)) { // eventually bring this in but in the mean time, just wander // addSubgoal(new GoalExplore(m_Owner)); addSubgoal(new GoalWander(m_Owner)); // std::cout << "Bot " << m_Owner->getID() << " Hunting - Wandering // near LRP of Enemy" << std::endl; } // else move to the LRP else { addSubgoal(new GoalMoveToPosition(m_Owner, lrp)); // std::cout << "Bot " << m_Owner->getID() << " Hunting - moving to // enemies last record position" << std::endl; } } } //------------------------------ Process ------------------------------------ int GoalHuntTarget::Process() { // if status is inactive, call Activate() activateIfInactive(); m_Status = processSubgoals(); // if target is in view this goal is satisfied if (m_Owner->getTargetSys()->isTargetWithinFOV()) { m_Status = completed; } return m_Status; }