| 443 | } |
| 444 | |
| 445 | bool MultiplayerBot::TryBuildUnit(AbilityID ability_type_for_unit, UnitTypeID unit_type) { |
| 446 | const ObservationInterface* observation = Observation(); |
| 447 | |
| 448 | //If we are at supply cap, don't build anymore units, unless its an overlord. |
| 449 | if (observation->GetFoodUsed() >= observation->GetFoodCap() && ability_type_for_unit != ABILITY_ID::TRAIN_OVERLORD) { |
| 450 | return false; |
| 451 | } |
| 452 | Unit unit; |
| 453 | if (!GetRandomUnit(unit, observation, unit_type)) { |
| 454 | return false; |
| 455 | } |
| 456 | if (!unit.orders.empty()) { |
| 457 | return false; |
| 458 | } |
| 459 | |
| 460 | if (unit.build_progress != 1) { |
| 461 | return false; |
| 462 | } |
| 463 | |
| 464 | Actions()->UnitCommand(unit.tag, ability_type_for_unit); |
| 465 | return true; |
| 466 | } |
| 467 | |
| 468 | // Mine the nearest mineral to Town hall. |
| 469 | // If we don't do this, probes may mine from other patches if they stray too far from the base after building. |
nothing calls this directly
no test coverage detected