| 314 | } |
| 315 | |
| 316 | bool Battle::initialMapCheck(GameState &state, std::list<StateRef<Agent>> agents) |
| 317 | { |
| 318 | initMap(); |
| 319 | |
| 320 | // No checks for base defense |
| 321 | if (mission_type == MissionType::BaseDefense) |
| 322 | { |
| 323 | return true; |
| 324 | } |
| 325 | |
| 326 | // Mark as low-priority all the enemy spawn los blocks that are seen from any player spawn block |
| 327 | for (auto &playerSpawn : losBlocks) |
| 328 | { |
| 329 | if (playerSpawn->spawn_type != SpawnType::Player || playerSpawn->spawn_priority == 0) |
| 330 | { |
| 331 | continue; |
| 332 | } |
| 333 | auto sPos = Vec3<float>((playerSpawn->start.x + playerSpawn->end.x) / 2.0f + 0.5f, |
| 334 | (playerSpawn->start.y + playerSpawn->end.y) / 2.0f + 0.5f, |
| 335 | playerSpawn->start.z + 0.5f); |
| 336 | for (auto &enemySpawn : losBlocks) |
| 337 | { |
| 338 | if (enemySpawn->spawn_type != SpawnType::Enemy || enemySpawn->spawn_priority == 0 || |
| 339 | enemySpawn->low_priority) |
| 340 | { |
| 341 | continue; |
| 342 | } |
| 343 | auto ePos = Vec3<float>((enemySpawn->start.x + enemySpawn->end.x) / 2.0f + 0.5f, |
| 344 | (enemySpawn->start.y + enemySpawn->end.y) / 2.0f + 0.5f, |
| 345 | enemySpawn->start.z + 0.5f); |
| 346 | if (glm::length(ePos - sPos) > VIEW_DISTANCE || |
| 347 | map->findCollision(sPos, ePos, {}, nullptr, true)) |
| 348 | { |
| 349 | continue; |
| 350 | } |
| 351 | LogWarning("Los block center %s visible from %s", ePos, sPos); |
| 352 | enemySpawn->low_priority = true; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | // Find out spawn point ratio for enemies |
| 357 | int spawnPoints = 0; |
| 358 | int spawnPointsRequired = 0; |
| 359 | |
| 360 | for (auto &enemySpawn : losBlocks) |
| 361 | { |
| 362 | if (enemySpawn->spawn_type != SpawnType::Enemy || enemySpawn->low_priority) |
| 363 | { |
| 364 | continue; |
| 365 | } |
| 366 | for (int x = enemySpawn->start.x; x < enemySpawn->end.x; x++) |
| 367 | { |
| 368 | for (int y = enemySpawn->start.y; y < enemySpawn->end.y; y++) |
| 369 | { |
| 370 | auto tile = map->getTile(x, y, enemySpawn->start.z); |
| 371 | if (tile->getCanStand()) |
| 372 | { |
| 373 | spawnPoints++; |
no test coverage detected