14.1 gotoFieldPosTheirKickOff
This function was implemented to move 2 agents to respective positions based on their UNUM, and was specifically called when the play mode was : PM_KICK_OFF_LEFT or PM_KICK_OFF_RIGHT and we were on the opposite side. Here you can see there are multiple if statements that seperate the behaviour based on the pNum variable which is representing UNUM. This can be easily extended to more players. Important to note after determining the position to move we call the SmartGoToTarget function which is an extension of the previous GoToTarget functions, however, it has an added avoidance system included. Meaning that agents will try to avoid obstacles in their path while moving to their destination.
SkillType NaoBehavior::gotoFieldPosTheirKickOff(int pNum){
double x = -1;
double y = -1;
double angle = -1;
if(pNum== 1){
WorldObject* opponent1 = worldModel->getWorldObject(WO_OPPONENT1);
VecPosition temp = opponent1->pos;
x = -HALF_FIELD_X /3;
y = temp.getY();
angle = 0;
}
else if(pNum == 2){
WorldObject* opponent2 = worldModel->getWorldObject(WO_OPPONENT2);
VecPosition temp = opponent2->pos;
x = -HALF_FIELD_X /3;
y = temp.getY();
angle = 0;
}
return SmartGoToTarget(VecPosition(x,y,0));
}