void Team::requestPass(Player* player, double delay_time /* = 0 */) { // With a possibility to execute if (WithPossibility(Prm.RequestPassPosibility)) { if (isSafeGoingThroughAllOpponents( getControllingPlayer()->getPosition(), player->getPosition(), Prm.PlayerMaxPassingForce) ) { MessageDispatcher::get().dispatchMessage( 0, player, getControllingPlayer(), MSG_REQUEST_PASS, player); } } }
void Team::requestPass(Player* player, double delay_time /* = 0 */) { // With a possibility to execute if (WithPossibility(Prm.RequestPassPosibility)) { float dot = mControllingPlayer->getHeading().dotProduct( (player->getPosition() - mControllingPlayer->getPosition()).normalisedCopy()); // Not behind the controlling player if (dot > -0.1 && isSafeGoingThroughAllOpponents( getControllingPlayer()->getPosition(), player->getPosition(), Prm.PlayerMaxPassingForce) ) { MessageDispatcher::get().dispatchMessage( 0, player, getControllingPlayer(), MSG_REQUEST_PASS, player); } } }
float Team::_getScoreOfPosition(const Ogre::Vector3& position) { // Closer to opponent's goal float score = 9.f * fabs((position - mGoal->getCenter()).x) / (2 * Prm.HalfPitchWidth); // 距离控球队员的距离 float best_dist = 8.f; float dist_to_ctrl = fabs(position.distance(getControllingPlayer()->getPosition())); if (dist_to_ctrl > best_dist) { score += 4.f * (best_dist / (1.1 * dist_to_ctrl)); } else { score += 4.f * (dist_to_ctrl / best_dist); } return score; }