| 2505 | } |
| 2506 | |
| 2507 | bool TerranMultiplayerBot::TryBuildAddOn(AbilityID ability_type_for_structure, Tag base_structure) { |
| 2508 | float rx = GetRandomScalar(); |
| 2509 | float ry = GetRandomScalar(); |
| 2510 | const Unit* unit = Observation()->GetUnit(base_structure); |
| 2511 | |
| 2512 | if (unit->build_progress != 1) { |
| 2513 | return false; |
| 2514 | } |
| 2515 | |
| 2516 | Point2D build_location = Point2D(unit->pos.x + rx * 15, unit->pos.y + ry * 15); |
| 2517 | |
| 2518 | Units units = Observation()->GetUnits(Unit::Self, IsStructure(Observation())); |
| 2519 | |
| 2520 | if (Query()->Placement(ability_type_for_structure, unit->pos, unit->tag)) { |
| 2521 | Actions()->UnitCommand(base_structure, ability_type_for_structure); |
| 2522 | return true; |
| 2523 | } |
| 2524 | |
| 2525 | float distance = std::numeric_limits<float>::max(); |
| 2526 | for (const auto& u : units) { |
| 2527 | float d = Distance2D(u.pos, build_location); |
| 2528 | if (d < distance) { |
| 2529 | distance = d; |
| 2530 | } |
| 2531 | } |
| 2532 | if (distance < 6) { |
| 2533 | return false; |
| 2534 | } |
| 2535 | |
| 2536 | if(Query()->Placement(ability_type_for_structure,build_location,unit->tag)){ |
| 2537 | Actions()->UnitCommand(base_structure, ability_type_for_structure, build_location); |
| 2538 | return true; |
| 2539 | } |
| 2540 | return false; |
| 2541 | |
| 2542 | } |
| 2543 | |
| 2544 | bool TerranMultiplayerBot::TryBuildStructureRandom(AbilityID ability_type_for_structure, UnitTypeID unit_type) { |
| 2545 | float rx = GetRandomScalar(); |
nothing calls this directly
no test coverage detected