| 232 | } |
| 233 | |
| 234 | bool MultiplayerBot::TryFindRandomPathableLocation(Tag tag, Point2D& target_pos) { |
| 235 | // First, find a random point inside the playable area of the map. |
| 236 | float playable_w = game_info_.playable_max.x - game_info_.playable_min.x; |
| 237 | float playable_h = game_info_.playable_max.y - game_info_.playable_min.y; |
| 238 | |
| 239 | // The case where game_info_ does not provide a valid answer |
| 240 | if (playable_w == 0 || playable_h == 0) { |
| 241 | playable_w = 236; |
| 242 | playable_h = 228; |
| 243 | } |
| 244 | |
| 245 | target_pos.x = playable_w * GetRandomFraction() + game_info_.playable_min.x; |
| 246 | target_pos.y = playable_h * GetRandomFraction() + game_info_.playable_min.y; |
| 247 | |
| 248 | // Now send a pathing query from the unit to that point. Can also query from point to point, |
| 249 | // but using a unit tag wherever possible will be more accurate. |
| 250 | // Note: This query must communicate with the game to get a result which affects performance. |
| 251 | // Ideally batch up the queries (using PathingDistanceBatched) and do many at once. |
| 252 | float distance = Query()->PathingDistance(tag, target_pos); |
| 253 | |
| 254 | return distance > 0.1f; |
| 255 | } |
| 256 | |
| 257 | void MultiplayerBot::AttackWithUnitType(UnitTypeID unit_type, const ObservationInterface* observation) { |
| 258 | Units units = observation->GetUnits(Unit::Alliance::Self, IsUnit(unit_type)); |
nothing calls this directly
no test coverage detected