mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Helicopter flights can be planned from FOBs
This commit is contained in:
@@ -1110,18 +1110,43 @@ class AircraftConflictGenerator:
|
||||
at=self.m.find_group(group_name),
|
||||
)
|
||||
else:
|
||||
if not isinstance(cp, Airfield):
|
||||
raise RuntimeError(
|
||||
f"Attempted to spawn at airfield for non-airfield {cp}"
|
||||
|
||||
# If the flight is an helicopter flight, then prioritize dedicated helipads
|
||||
group = None
|
||||
if flight.unit_type in helicopters.helicopter_map.values():
|
||||
helipad = cp.get_free_helipad()
|
||||
if helipad is not None:
|
||||
group = self._generate_at_group(
|
||||
name=name,
|
||||
side=country,
|
||||
unit_type=flight.unit_type,
|
||||
count=flight.count,
|
||||
start_type=flight.start_type,
|
||||
at=helipad.static_unit,
|
||||
)
|
||||
group.points[0].action = PointAction.FromGroundArea
|
||||
group.points[0].type = "From Ground Area"
|
||||
helipad.occupied = True
|
||||
|
||||
for i in range(flight.count - 1):
|
||||
helipad = cp.get_free_helipad()
|
||||
if helipad is not None:
|
||||
helipad.occupied = True
|
||||
group.units[1 + i].position = Point(helipad.x, helipad.y)
|
||||
|
||||
if group is None:
|
||||
if not isinstance(cp, Airfield):
|
||||
raise RuntimeError(
|
||||
f"Attempted to spawn at airfield for non-airfield {cp}"
|
||||
)
|
||||
group = self._generate_at_airport(
|
||||
name=name,
|
||||
side=country,
|
||||
unit_type=flight.unit_type,
|
||||
count=flight.count,
|
||||
start_type=flight.start_type,
|
||||
airport=cp.airport,
|
||||
)
|
||||
group = self._generate_at_airport(
|
||||
name=name,
|
||||
side=country,
|
||||
unit_type=flight.unit_type,
|
||||
count=flight.count,
|
||||
start_type=flight.start_type,
|
||||
airport=cp.airport,
|
||||
)
|
||||
except Exception as e:
|
||||
# Generated when there is no place on Runway or on Parking Slots
|
||||
logging.error(e)
|
||||
|
||||
@@ -25,7 +25,11 @@ class ClosestAirfields:
|
||||
|
||||
@property
|
||||
def operational_airfields(self) -> Iterator[ControlPoint]:
|
||||
return (c for c in self.closest_airfields if c.runway_is_operational())
|
||||
return (
|
||||
c
|
||||
for c in self.closest_airfields
|
||||
if c.runway_is_operational() or c.has_helipads
|
||||
)
|
||||
|
||||
def airfields_within(self, distance: Distance) -> Iterator[ControlPoint]:
|
||||
"""Iterates over all airfields within the given range of the target.
|
||||
|
||||
@@ -142,6 +142,8 @@ class FlightWaypoint:
|
||||
PointAction.FromParkingArea: FlightWaypointType.TAKEOFF,
|
||||
PointAction.FromParkingAreaHot: FlightWaypointType.TAKEOFF,
|
||||
PointAction.FromRunway: FlightWaypointType.TAKEOFF,
|
||||
PointAction.FromGroundArea: FlightWaypointType.TAKEOFF,
|
||||
PointAction.FromGroundAreaHot: FlightWaypointType.TAKEOFF,
|
||||
}[point.action]
|
||||
if waypoint.waypoint_type == FlightWaypointType.NAV:
|
||||
waypoint.name = "NAV"
|
||||
|
||||
@@ -1772,4 +1772,5 @@ class FlightPlanBuilder:
|
||||
for flight in self.package.flights:
|
||||
if flight.departure == airfield:
|
||||
return airfield
|
||||
|
||||
raise RuntimeError("Could not find any airfield assigned to this package")
|
||||
|
||||
@@ -587,6 +587,8 @@ class HelipadGenerator:
|
||||
sp.position = pad.position
|
||||
sg.add_point(sp)
|
||||
country.add_static_group(sg)
|
||||
helipad.static_unit = sg
|
||||
helipad.occupied = False
|
||||
|
||||
|
||||
class GroundObjectsGenerator:
|
||||
|
||||
Reference in New Issue
Block a user