| 287 | } |
| 288 | |
| 289 | void MultiplayerBot::ScoutWithUnit(Unit unit, const ObservationInterface* observation) { |
| 290 | Units enemy_units = observation->GetUnits(Unit::Alliance::Enemy, IsAttackable()); |
| 291 | if (!unit.orders.empty()) { |
| 292 | return; |
| 293 | } |
| 294 | Point2D target_pos; |
| 295 | |
| 296 | if (FindEnemyPosition(unit.tag, target_pos)) { |
| 297 | if (Distance2D(unit.pos, target_pos) < 20 && enemy_units.empty()) { |
| 298 | if (TryFindRandomPathableLocation(unit.tag, target_pos)) { |
| 299 | Actions()->UnitCommand(unit, ABILITY_ID::SMART, target_pos); |
| 300 | return; |
| 301 | } |
| 302 | } |
| 303 | else if (!enemy_units.empty()) |
| 304 | { |
| 305 | Actions()->UnitCommand(unit, ABILITY_ID::ATTACK, enemy_units.front()); |
| 306 | return; |
| 307 | } |
| 308 | Actions()->UnitCommand(unit, ABILITY_ID::SMART, target_pos); |
| 309 | } |
| 310 | else { |
| 311 | if (TryFindRandomPathableLocation(unit.tag, target_pos)) { |
| 312 | Actions()->UnitCommand(unit, ABILITY_ID::SMART, target_pos); |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | //Try build structure given a location. This is used most of the time |
| 318 | bool MultiplayerBot::TryBuildStructure(AbilityID ability_type_for_structure, UnitTypeID unit_type, Point2D location, bool isExpansion = false) { |
nothing calls this directly
no test coverage detected