From 746eda70ee686a2babf79edbb5759b230c4c3b31 Mon Sep 17 00:00:00 2001 From: Raffson Date: Wed, 6 Jul 2022 20:56:39 +0200 Subject: [PATCH] In-Flight spawn: Minimum AGL altitude (#2302) Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2212 --- game/missiongenerator/aircraft/flightgroupspawner.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/game/missiongenerator/aircraft/flightgroupspawner.py b/game/missiongenerator/aircraft/flightgroupspawner.py index 5bc3bbd1..5fdfd94a 100644 --- a/game/missiongenerator/aircraft/flightgroupspawner.py +++ b/game/missiongenerator/aircraft/flightgroupspawner.py @@ -29,7 +29,8 @@ WARM_START_ALTITUDE = meters(3000) # PG at 5700ft. This could still be too low if there are tall obstacles near the # airfield, but the lowest we can push this the better to avoid spawning helicopters # well above the altitude for WP1. -MINIMUM_MID_MISSION_SPAWN_ALTITUDE = feet(6000) +MINIMUM_MID_MISSION_SPAWN_ALTITUDE_MSL = feet(6000) +MINIMUM_MID_MISSION_SPAWN_ALTITUDE_AGL = feet(500) RTB_ALTITUDE = meters(800) RTB_DISTANCE = 5000 @@ -139,8 +140,13 @@ class FlightGroupSpawner: # We don't know where the ground is, so just make sure that any aircraft # spawning at an MSL altitude is spawned at some minimum altitude. # https://github.com/dcs-liberation/dcs_liberation/issues/1941 - if alt_type == "BARO" and alt < MINIMUM_MID_MISSION_SPAWN_ALTITUDE: - alt = MINIMUM_MID_MISSION_SPAWN_ALTITUDE + if alt_type == "BARO" and alt < MINIMUM_MID_MISSION_SPAWN_ALTITUDE_MSL: + alt = MINIMUM_MID_MISSION_SPAWN_ALTITUDE_MSL + + # Set a minimum AGL value for 'alt' if needed, + # otherwise planes might crash in trees and stuff. + if alt_type == "RADIO" and alt < MINIMUM_MID_MISSION_SPAWN_ALTITUDE_AGL: + alt = MINIMUM_MID_MISSION_SPAWN_ALTITUDE_AGL group = self.mission.flight_group( country=self.country,