mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Stack aircraft when spawning right above CP
Should prevent mid-air collisions in most cases, though I'm still worried about "off map" spawns that can possibly collide, though an easy fix would be to manually use time-spacing. Alternatively we need to treat it as a special case, assigning different altitudes to avoid collisions during the first leg of the flight if that turns out to be the case...
This commit is contained in:
parent
c3024e38a6
commit
d5de5b3a78
@ -171,7 +171,7 @@ class AircraftGenerator:
|
||||
flight.state = Completed(flight, self.game.settings)
|
||||
|
||||
group = FlightGroupSpawner(
|
||||
flight, country, self.mission, self.helipads
|
||||
flight, country, self.mission, self.helipads, self.mission_data
|
||||
).create_idle_aircraft()
|
||||
AircraftPainter(flight, group).apply_livery()
|
||||
self.unit_map.add_aircraft(group, flight)
|
||||
@ -181,7 +181,7 @@ class AircraftGenerator:
|
||||
) -> FlyingGroup[Any]:
|
||||
"""Creates and configures the flight group in the mission."""
|
||||
group = FlightGroupSpawner(
|
||||
flight, country, self.mission, self.helipads
|
||||
flight, country, self.mission, self.helipads, self.mission_data
|
||||
).create_flight_group()
|
||||
self.flights.append(
|
||||
FlightGroupConfigurator(
|
||||
|
||||
@ -15,6 +15,7 @@ from game.ato import Flight
|
||||
from game.ato.flightstate import InFlight
|
||||
from game.ato.starttype import StartType
|
||||
from game.ato.traveltime import GroundSpeed
|
||||
from game.missiongenerator.missiondata import MissionData
|
||||
from game.naming import namegen
|
||||
from game.theater import Airfield, ControlPoint, Fob, NavalControlPoint, OffMapSpawn
|
||||
from game.utils import feet, meters
|
||||
@ -32,6 +33,8 @@ WARM_START_ALTITUDE = meters(3000)
|
||||
MINIMUM_MID_MISSION_SPAWN_ALTITUDE_MSL = feet(6000)
|
||||
MINIMUM_MID_MISSION_SPAWN_ALTITUDE_AGL = feet(500)
|
||||
|
||||
STACK_SEPARATION = feet(200)
|
||||
|
||||
RTB_ALTITUDE = meters(800)
|
||||
RTB_DISTANCE = 5000
|
||||
HELI_ALT = 500
|
||||
@ -44,11 +47,13 @@ class FlightGroupSpawner:
|
||||
country: Country,
|
||||
mission: Mission,
|
||||
helipads: dict[ControlPoint, StaticGroup],
|
||||
mission_data: MissionData,
|
||||
) -> None:
|
||||
self.flight = flight
|
||||
self.country = country
|
||||
self.mission = mission
|
||||
self.helipads = helipads
|
||||
self.mission_data = mission_data
|
||||
|
||||
def create_flight_group(self) -> FlyingGroup[Any]:
|
||||
"""Creates the group for the flight and adds it to the mission.
|
||||
@ -140,6 +145,10 @@ class FlightGroupSpawner:
|
||||
pos = self.flight.state.estimate_position()
|
||||
pos += Vector2(random.randint(100, 1000), random.randint(100, 1000))
|
||||
alt, alt_type = self.flight.state.estimate_altitude()
|
||||
cp = self.flight.squadron.location.id
|
||||
|
||||
if cp not in self.mission_data.cp_stack:
|
||||
self.mission_data.cp_stack[cp] = MINIMUM_MID_MISSION_SPAWN_ALTITUDE_AGL
|
||||
|
||||
# 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.
|
||||
@ -149,8 +158,9 @@ class FlightGroupSpawner:
|
||||
|
||||
# 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
|
||||
if alt_type == "RADIO" and alt < self.mission_data.cp_stack[cp]:
|
||||
alt = self.mission_data.cp_stack[cp]
|
||||
self.mission_data.cp_stack[cp] += STACK_SEPARATION
|
||||
|
||||
group = self.mission.flight_group(
|
||||
country=self.country,
|
||||
|
||||
@ -11,6 +11,8 @@ from game.runways import RunwayData
|
||||
if TYPE_CHECKING:
|
||||
from game.radio.radios import RadioFrequency
|
||||
from game.radio.tacan import TacanChannel
|
||||
from game.utils import Distance
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -94,3 +96,4 @@ class MissionData:
|
||||
tankers: list[TankerInfo] = field(default_factory=list)
|
||||
jtacs: list[JtacInfo] = field(default_factory=list)
|
||||
logistics: list[LogisticsInfo] = field(default_factory=list)
|
||||
cp_stack: dict[UUID, Distance] = field(default_factory=dict)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user