//-------------------------- Process ------------------------------------------ //----------------------------------------------------------------------------- int GoalAttackTarget::process() { //if status is inactive, call Activate() activateIfInactive(); //process the subgoals _status = processSubgoals(); reactivateIfFailed(); return _status; }
//-------------------------- process ------------------------------------------ //----------------------------------------------------------------------------- int GoalPersistanceAttack::process() { //if status is INACTIVE, call activate() activateIfInactive(); _status = processSubgoals(); if (_status == COMPLETED && _owner->getTargetSys()->getTarget()->isAlive()) { activate(); } return _status; }
//------------------------------ process -------------------------------------- // // processes the subgoals //----------------------------------------------------------------------------- int GoalThink::process() { activateIfInactive(); int subgoal_status = processSubgoals(); if (subgoal_status == COMPLETED || subgoal_status == FAILED) { if (!_owner->isPossessed()) { _status = INACTIVE; } } return _status; }
GGoalStatus GoalGetALife::process() { DebugMsg::out(toString()); DebugMsg::out(": "); activateIfInactive(); while (!subGoals.empty() && (subGoals.front()->isComplete() || subGoals.front()->hasFailed())){ subGoals.pop_front(); } if (goalStatus == ACTIVE && subGoals.empty()){ goalStatus = COMPLETED; }else{ GGoalStatus lastStatus = subGoals.front()->process(); if (lastStatus==FAILED) goalStatus = FAILED; } return goalStatus; }
GGoalStatus GGoalCalculatePathTo::process(){ activateIfInactive(); DebugMsg::out("Calculating Path "); Vect pos = botControl->getBot()->getPos(); //DebugMsg::out("Target: %f, %f\n", target->X(), target->Y()); list<Vect*> newPath = botControl->getGraph()->getPath(&pos, target); list<Vect*>* path = botControl->getPath(); path->clear(); // DebugMsg::out("newPath size: %d ", newPath.size()); unsigned int newSize = newPath.size(); for (unsigned int i = 0; i < newSize; i++){ path->push_back(newPath.front()); newPath.pop_front(); }; DebugMsg::out("Path size: %d\n ", path->size()); goalStatus = GGoalStatus::COMPLETED; return GGoalStatus::COMPLETED; }
//------------------------------ process -------------------------------------- //----------------------------------------------------------------------------- int GoalSeekToPosition::process() { //if status is INACTIVE, call activate() activateIfInactive(); //test to see if the bot has become stuck if (isStuck()) { _status = FAILED; } //test to see if the bot has reached the waypoint. If so terminate the goal else { if (_owner->isAtPosition(_position)) { _status = COMPLETED; } } return _status; }