mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix waypoint altitudes for helicopters.
Fixes https://github.com/Khopa/dcs_liberation/issues/234
This commit is contained in:
parent
dd4c37cde3
commit
c3fca6696d
@ -351,9 +351,6 @@ class FlightPlanBuilder:
|
|||||||
if not isinstance(location, FrontLine):
|
if not isinstance(location, FrontLine):
|
||||||
raise InvalidObjectiveLocation(flight.flight_type, location)
|
raise InvalidObjectiveLocation(flight.flight_type, location)
|
||||||
|
|
||||||
is_helo = getattr(flight.unit_type, "helicopter", False)
|
|
||||||
cap_alt = 500 if is_helo else 1000
|
|
||||||
|
|
||||||
ingress, heading, distance = Conflict.frontline_vector(
|
ingress, heading, distance = Conflict.frontline_vector(
|
||||||
location.control_points[0], location.control_points[1],
|
location.control_points[0], location.control_points[1],
|
||||||
self.game.theater
|
self.game.theater
|
||||||
@ -362,14 +359,14 @@ class FlightPlanBuilder:
|
|||||||
egress = ingress.point_from_heading(heading, distance)
|
egress = ingress.point_from_heading(heading, distance)
|
||||||
|
|
||||||
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine)
|
||||||
builder.ascent(flight.from_cp, is_helo)
|
builder.ascent(flight.from_cp)
|
||||||
builder.hold(self._hold_point(flight))
|
builder.hold(self._hold_point(flight))
|
||||||
builder.join(self.package.waypoints.join)
|
builder.join(self.package.waypoints.join)
|
||||||
builder.ingress_cas(ingress, location)
|
builder.ingress_cas(ingress, location)
|
||||||
builder.cas(center, cap_alt)
|
builder.cas(center)
|
||||||
builder.egress(egress, location)
|
builder.egress(egress, location)
|
||||||
builder.split(self.package.waypoints.split)
|
builder.split(self.package.waypoints.split)
|
||||||
builder.rtb(flight.from_cp, is_helo)
|
builder.rtb(flight.from_cp)
|
||||||
|
|
||||||
flight.points = builder.build()
|
flight.points = builder.build()
|
||||||
|
|
||||||
|
|||||||
@ -22,15 +22,18 @@ class WaypointBuilder:
|
|||||||
self.waypoints: List[FlightWaypoint] = []
|
self.waypoints: List[FlightWaypoint] = []
|
||||||
self.ingress_point: Optional[FlightWaypoint] = None
|
self.ingress_point: Optional[FlightWaypoint] = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_helo(self) -> bool:
|
||||||
|
return getattr(self.flight.unit_type, "helicopter", False)
|
||||||
|
|
||||||
def build(self) -> List[FlightWaypoint]:
|
def build(self) -> List[FlightWaypoint]:
|
||||||
return self.waypoints
|
return self.waypoints
|
||||||
|
|
||||||
def ascent(self, departure: ControlPoint, is_helo: bool = False) -> None:
|
def ascent(self, departure: ControlPoint) -> None:
|
||||||
"""Create ascent waypoint for the given departure airfield or carrier.
|
"""Create ascent waypoint for the given departure airfield or carrier.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
departure: Departure airfield or carrier.
|
departure: Departure airfield or carrier.
|
||||||
is_helo: True if the flight is a helicopter.
|
|
||||||
"""
|
"""
|
||||||
heading = RunwayAssigner(self.conditions).takeoff_heading(departure)
|
heading = RunwayAssigner(self.conditions).takeoff_heading(departure)
|
||||||
position = departure.position.point_from_heading(
|
position = departure.position.point_from_heading(
|
||||||
@ -40,7 +43,7 @@ class WaypointBuilder:
|
|||||||
FlightWaypointType.ASCEND_POINT,
|
FlightWaypointType.ASCEND_POINT,
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
500 if is_helo else self.doctrine.pattern_altitude
|
500 if self.is_helo else self.doctrine.pattern_altitude
|
||||||
)
|
)
|
||||||
waypoint.name = "ASCEND"
|
waypoint.name = "ASCEND"
|
||||||
waypoint.alt_type = "RADIO"
|
waypoint.alt_type = "RADIO"
|
||||||
@ -48,14 +51,14 @@ class WaypointBuilder:
|
|||||||
waypoint.pretty_name = "Ascend"
|
waypoint.pretty_name = "Ascend"
|
||||||
self.waypoints.append(waypoint)
|
self.waypoints.append(waypoint)
|
||||||
|
|
||||||
def descent(self, arrival: ControlPoint, is_helo: bool = False) -> None:
|
def descent(self, arrival: ControlPoint) -> None:
|
||||||
"""Create descent waypoint for the given arrival airfield or carrier.
|
"""Create descent waypoint for the given arrival airfield or carrier.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
arrival: Arrival airfield or carrier.
|
arrival: Arrival airfield or carrier.
|
||||||
is_helo: True if the flight is a helicopter.
|
|
||||||
"""
|
"""
|
||||||
landing_heading = RunwayAssigner(self.conditions).landing_heading(arrival)
|
landing_heading = RunwayAssigner(self.conditions).landing_heading(
|
||||||
|
arrival)
|
||||||
heading = (landing_heading + 180) % 360
|
heading = (landing_heading + 180) % 360
|
||||||
position = arrival.position.point_from_heading(
|
position = arrival.position.point_from_heading(
|
||||||
heading, nm_to_meter(5)
|
heading, nm_to_meter(5)
|
||||||
@ -64,7 +67,7 @@ class WaypointBuilder:
|
|||||||
FlightWaypointType.DESCENT_POINT,
|
FlightWaypointType.DESCENT_POINT,
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
300 if is_helo else self.doctrine.pattern_altitude
|
300 if self.is_helo else self.doctrine.pattern_altitude
|
||||||
)
|
)
|
||||||
waypoint.name = "DESCEND"
|
waypoint.name = "DESCEND"
|
||||||
waypoint.alt_type = "RADIO"
|
waypoint.alt_type = "RADIO"
|
||||||
@ -96,7 +99,7 @@ class WaypointBuilder:
|
|||||||
FlightWaypointType.LOITER,
|
FlightWaypointType.LOITER,
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
self.doctrine.rendezvous_altitude
|
500 if self.is_helo else self.doctrine.rendezvous_altitude
|
||||||
)
|
)
|
||||||
waypoint.pretty_name = "Hold"
|
waypoint.pretty_name = "Hold"
|
||||||
waypoint.description = "Wait until push time"
|
waypoint.description = "Wait until push time"
|
||||||
@ -108,7 +111,7 @@ class WaypointBuilder:
|
|||||||
FlightWaypointType.JOIN,
|
FlightWaypointType.JOIN,
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
self.doctrine.ingress_altitude
|
500 if self.is_helo else self.doctrine.ingress_altitude
|
||||||
)
|
)
|
||||||
waypoint.pretty_name = "Join"
|
waypoint.pretty_name = "Join"
|
||||||
waypoint.description = "Rendezvous with package"
|
waypoint.description = "Rendezvous with package"
|
||||||
@ -120,7 +123,7 @@ class WaypointBuilder:
|
|||||||
FlightWaypointType.SPLIT,
|
FlightWaypointType.SPLIT,
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
self.doctrine.ingress_altitude
|
500 if self.is_helo else self.doctrine.ingress_altitude
|
||||||
)
|
)
|
||||||
waypoint.pretty_name = "Split"
|
waypoint.pretty_name = "Split"
|
||||||
waypoint.description = "Depart from package"
|
waypoint.description = "Depart from package"
|
||||||
@ -148,7 +151,7 @@ class WaypointBuilder:
|
|||||||
ingress_type,
|
ingress_type,
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
self.doctrine.ingress_altitude
|
500 if self.is_helo else self.doctrine.ingress_altitude
|
||||||
)
|
)
|
||||||
waypoint.pretty_name = "INGRESS on " + objective.name
|
waypoint.pretty_name = "INGRESS on " + objective.name
|
||||||
waypoint.description = "INGRESS on " + objective.name
|
waypoint.description = "INGRESS on " + objective.name
|
||||||
@ -161,7 +164,7 @@ class WaypointBuilder:
|
|||||||
FlightWaypointType.EGRESS,
|
FlightWaypointType.EGRESS,
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
self.doctrine.ingress_altitude
|
500 if self.is_helo else self.doctrine.ingress_altitude
|
||||||
)
|
)
|
||||||
waypoint.pretty_name = "EGRESS from " + target.name
|
waypoint.pretty_name = "EGRESS from " + target.name
|
||||||
waypoint.description = "EGRESS from " + target.name
|
waypoint.description = "EGRESS from " + target.name
|
||||||
@ -248,12 +251,12 @@ class WaypointBuilder:
|
|||||||
# TODO: This seems wrong, but it's what was there before.
|
# TODO: This seems wrong, but it's what was there before.
|
||||||
self.ingress_point.targets.append(location)
|
self.ingress_point.targets.append(location)
|
||||||
|
|
||||||
def cas(self, position: Point, altitude: int) -> None:
|
def cas(self, position: Point) -> None:
|
||||||
waypoint = FlightWaypoint(
|
waypoint = FlightWaypoint(
|
||||||
FlightWaypointType.CAS,
|
FlightWaypointType.CAS,
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
altitude
|
500 if self.is_helo else 1000
|
||||||
)
|
)
|
||||||
waypoint.alt_type = "RADIO"
|
waypoint.alt_type = "RADIO"
|
||||||
waypoint.description = "Provide CAS"
|
waypoint.description = "Provide CAS"
|
||||||
@ -308,14 +311,13 @@ class WaypointBuilder:
|
|||||||
self.race_track_start(start, altitude)
|
self.race_track_start(start, altitude)
|
||||||
self.race_track_end(end, altitude)
|
self.race_track_end(end, altitude)
|
||||||
|
|
||||||
def rtb(self, arrival: ControlPoint, is_helo: bool = False) -> None:
|
def rtb(self, arrival: ControlPoint) -> None:
|
||||||
"""Creates descent ant landing waypoints for the given control point.
|
"""Creates descent ant landing waypoints for the given control point.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
arrival: Arrival airfield or carrier.
|
arrival: Arrival airfield or carrier.
|
||||||
is_helo: True if the flight is a helicopter.
|
|
||||||
"""
|
"""
|
||||||
self.descent(arrival, is_helo)
|
self.descent(arrival)
|
||||||
self.land(arrival)
|
self.land(arrival)
|
||||||
|
|
||||||
def escort(self, ingress: Point, target: MissionTarget,
|
def escort(self, ingress: Point, target: MissionTarget,
|
||||||
@ -339,7 +341,7 @@ class WaypointBuilder:
|
|||||||
FlightWaypointType.TARGET_GROUP_LOC,
|
FlightWaypointType.TARGET_GROUP_LOC,
|
||||||
target.position.x,
|
target.position.x,
|
||||||
target.position.y,
|
target.position.y,
|
||||||
self.doctrine.ingress_altitude
|
500 if self.is_helo else self.doctrine.ingress_altitude
|
||||||
)
|
)
|
||||||
waypoint.name = "TARGET"
|
waypoint.name = "TARGET"
|
||||||
waypoint.description = "Escort the package"
|
waypoint.description = "Escort the package"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user