コード例 #1
0
    def _target_area(
        name: str, location: MissionTarget, flyover: bool = False
    ) -> FlightWaypoint:
        waypoint = FlightWaypoint(
            name,
            FlightWaypointType.TARGET_GROUP_LOC,
            location.position,
            meters(0),
            "RADIO",
            description=name,
            pretty_name=name,
        )

        # Most target waypoints are only for the player's benefit. AI tasks for
        # the target are set on the ingress point so they begin their attack
        # *before* reaching the target.
        #
        # The exception is for flight plans that require passing over the
        # target. For example, OCA strikes need to get close enough to detect
        # the targets in their engagement zone or they will RTB immediately.
        if flyover:
            waypoint.flyover = True
        else:
            waypoint.only_for_player = True
        return waypoint
コード例 #2
0
    def land(self, arrival: ControlPoint) -> FlightWaypoint:
        """Create descent waypoint for the given arrival airfield or carrier.

        Args:
            arrival: Arrival airfield or carrier.
        """
        position = arrival.position
        if isinstance(arrival, OffMapSpawn):
            return FlightWaypoint(
                "NAV",
                FlightWaypointType.NAV,
                position,
                meters(500) if self.is_helo else self.doctrine.rendezvous_altitude,
                description="Exit theater",
                pretty_name="Exit theater",
            )

        return FlightWaypoint(
            "LANDING",
            FlightWaypointType.LANDING_POINT,
            position,
            meters(0),
            alt_type="RADIO",
            description="Land",
            pretty_name="Land",
            control_point=arrival,
        )
コード例 #3
0
    def takeoff(self, departure: ControlPoint) -> FlightWaypoint:
        """Create takeoff waypoint for the given arrival airfield or carrier.

        Note that the takeoff waypoint will automatically be created by pydcs
        when we create the group, but creating our own before generation makes
        the planning code simpler.

        Args:
            departure: Departure airfield or carrier.
        """
        position = departure.position
        if isinstance(departure, OffMapSpawn):
            return FlightWaypoint(
                "NAV",
                FlightWaypointType.NAV,
                position,
                meters(500) if self.is_helo else self.doctrine.rendezvous_altitude,
                description="Enter theater",
                pretty_name="Enter theater",
            )

        return FlightWaypoint(
            "TAKEOFF",
            FlightWaypointType.TAKEOFF,
            position,
            meters(0),
            alt_type="RADIO",
            description="Takeoff",
            pretty_name="Takeoff",
        )
コード例 #4
0
    def escort(
        self,
        ingress: Point,
        target: MissionTarget,
    ) -> Tuple[FlightWaypoint, FlightWaypoint]:
        """Creates the waypoints needed to escort the package.

        Args:
            ingress: The package ingress point.
            target: The mission target.
        """
        alt_type: AltitudeReference = "BARO"
        if self.is_helo:
            alt_type = "RADIO"

        # This would preferably be no points at all, and instead the Escort task
        # would begin on the join point and end on the split point, however the
        # escort task does not appear to work properly (see the longer
        # description in gen.aircraft.JoinPointBuilder), so instead we give
        # the escort flights a flight plan including the ingress point and target area.
        ingress_wp = self.ingress(FlightWaypointType.INGRESS_ESCORT, ingress, target)

        return ingress_wp, FlightWaypoint(
            "TARGET",
            FlightWaypointType.TARGET_GROUP_LOC,
            target.position,
            meters(60) if self.is_helo else self.doctrine.ingress_altitude,
            alt_type,
            description="Escort the package",
            pretty_name="Target area",
        )
コード例 #5
0
    def divert(self, divert: Optional[ControlPoint]) -> Optional[FlightWaypoint]:
        """Create divert waypoint for the given arrival airfield or carrier.

        Args:
            divert: Divert airfield or carrier.
        """
        if divert is None:
            return None

        position = divert.position
        altitude_type: AltitudeReference
        if isinstance(divert, OffMapSpawn):
            if self.is_helo:
                altitude = meters(500)
            else:
                altitude = self.doctrine.rendezvous_altitude
            altitude_type = "BARO"
        else:
            altitude = meters(0)
            altitude_type = "RADIO"

        return FlightWaypoint(
            "DIVERT",
            FlightWaypointType.DIVERT,
            position,
            altitude,
            alt_type=altitude_type,
            description="Divert",
            pretty_name="Divert",
            only_for_player=True,
            control_point=divert,
        )
コード例 #6
0
 def bullseye(self) -> FlightWaypoint:
     return FlightWaypoint(
         "BULLSEYE",
         FlightWaypointType.BULLSEYE,
         self._bullseye.position,
         meters(0),
         description="Bullseye",
         pretty_name="Bullseye",
         only_for_player=True,
     )
コード例 #7
0
 def cas(self, position: Point) -> FlightWaypoint:
     return FlightWaypoint(
         "CAS",
         FlightWaypointType.CAS,
         position,
         meters(60) if self.is_helo else meters(1000),
         "RADIO",
         description="Provide CAS",
         pretty_name="CAS",
     )
コード例 #8
0
 def _target_point(target: StrikeTarget, description: str) -> FlightWaypoint:
     return FlightWaypoint(
         target.name,
         FlightWaypointType.TARGET_POINT,
         target.target.position,
         meters(0),
         "RADIO",
         description=description,
         pretty_name=description,
         # The target waypoints are only for the player's benefit. AI tasks for
         # the target are set on the ingress point so that they begin their attack
         # *before* reaching the target.
         only_for_player=True,
     )
コード例 #9
0
    def hold(self, position: Point) -> FlightWaypoint:
        alt_type: AltitudeReference = "BARO"
        if self.is_helo:
            alt_type = "RADIO"

        return FlightWaypoint(
            "HOLD",
            FlightWaypointType.LOITER,
            position,
            meters(500) if self.is_helo else self.doctrine.rendezvous_altitude,
            alt_type,
            description="Wait until push time",
            pretty_name="Hold",
        )
コード例 #10
0
    def join(self, position: Point) -> FlightWaypoint:
        alt_type: AltitudeReference = "BARO"
        if self.is_helo:
            alt_type = "RADIO"

        return FlightWaypoint(
            "JOIN",
            FlightWaypointType.JOIN,
            position,
            meters(80) if self.is_helo else self.doctrine.ingress_altitude,
            alt_type,
            description="Rendezvous with package",
            pretty_name="Join",
        )
コード例 #11
0
    def egress(self, position: Point, target: MissionTarget) -> FlightWaypoint:
        alt_type: AltitudeReference = "BARO"
        if self.is_helo:
            alt_type = "RADIO"

        return FlightWaypoint(
            "EGRESS",
            FlightWaypointType.EGRESS,
            position,
            meters(60) if self.is_helo else self.doctrine.ingress_altitude,
            alt_type,
            description=f"EGRESS from {target.name}",
            pretty_name=f"EGRESS from {target.name}",
        )
コード例 #12
0
    def refuel(self, position: Point) -> FlightWaypoint:
        alt_type: AltitudeReference = "BARO"
        if self.is_helo:
            alt_type = "RADIO"

        return FlightWaypoint(
            "REFUEL",
            FlightWaypointType.REFUEL,
            position,
            meters(80) if self.is_helo else self.doctrine.ingress_altitude,
            alt_type,
            description="Refuel from tanker",
            pretty_name="Refuel",
        )
コード例 #13
0
    def split(self, position: Point) -> FlightWaypoint:
        alt_type: AltitudeReference = "BARO"
        if self.is_helo:
            alt_type = "RADIO"

        return FlightWaypoint(
            "SPLIT",
            FlightWaypointType.SPLIT,
            position,
            meters(80) if self.is_helo else self.doctrine.ingress_altitude,
            alt_type,
            description="Depart from package",
            pretty_name="Split",
        )
コード例 #14
0
    def sweep_end(position: Point, altitude: Distance) -> FlightWaypoint:
        """Creates a sweep end waypoint.

        Args:
            position: Position of the waypoint.
            altitude: Altitude of the sweep in meters.
        """
        return FlightWaypoint(
            "SWEEP END",
            FlightWaypointType.EGRESS,
            position,
            altitude,
            description="End of sweep",
            pretty_name="Sweep end",
        )
コード例 #15
0
    def sweep_start(position: Point, altitude: Distance) -> FlightWaypoint:
        """Creates a sweep start waypoint.

        Args:
            position: Position of the waypoint.
            altitude: Altitude of the sweep in meters.
        """
        return FlightWaypoint(
            "SWEEP START",
            FlightWaypointType.INGRESS_SWEEP,
            position,
            altitude,
            description="Proceed to the target and engage enemy aircraft",
            pretty_name="Sweep start",
        )
コード例 #16
0
    def race_track_start(position: Point, altitude: Distance) -> FlightWaypoint:
        """Creates a racetrack start waypoint.

        Args:
            position: Position of the waypoint.
            altitude: Altitude of the racetrack.
        """
        return FlightWaypoint(
            "RACETRACK START",
            FlightWaypointType.PATROL_TRACK,
            position,
            altitude,
            description="Orbit between this point and the next point",
            pretty_name="Race-track start",
        )
コード例 #17
0
    def pickup(control_point: ControlPoint) -> FlightWaypoint:
        """Creates a cargo pickup waypoint.

        Args:
            control_point: Pick up location.
        """
        return FlightWaypoint(
            "PICKUP",
            FlightWaypointType.PICKUP,
            control_point.position,
            meters(0),
            "RADIO",
            description=f"Pick up cargo from {control_point}",
            pretty_name="Pick up location",
        )
コード例 #18
0
    def race_track_end(position: Point, altitude: Distance) -> FlightWaypoint:
        """Creates a racetrack end waypoint.

        Args:
            position: Position of the waypoint.
            altitude: Altitude of the racetrack.
        """
        return FlightWaypoint(
            "RACETRACK END",
            FlightWaypointType.PATROL,
            position,
            altitude,
            description="Orbit between this point and the previous point",
            pretty_name="Race-track end",
        )
コード例 #19
0
def waypoints_for_flight(flight: Flight) -> list[FlightWaypointJs]:
    departure = FlightWaypointJs.for_waypoint(
        FlightWaypoint(
            "TAKEOFF",
            FlightWaypointType.TAKEOFF,
            flight.departure.position,
            meters(0),
            "RADIO",
        ),
        flight,
        0,
    )
    return [departure] + [
        FlightWaypointJs.for_waypoint(w, flight, i)
        for i, w in enumerate(flight.flight_plan.waypoints, 1)
    ]
コード例 #20
0
    def orbit(start: Point, altitude: Distance) -> FlightWaypoint:
        """Creates an circular orbit point.

        Args:
            start: Position of the waypoint.
            altitude: Altitude of the racetrack.
        """

        return FlightWaypoint(
            "ORBIT",
            FlightWaypointType.LOITER,
            start,
            altitude,
            description="Anchor and hold at this point",
            pretty_name="Orbit",
        )
コード例 #21
0
    def drop_off(control_point: ControlPoint) -> FlightWaypoint:
        """Creates a cargo drop-off waypoint.

        Args:
            control_point: Drop-off location.
        """
        return FlightWaypoint(
            "DROP OFF",
            FlightWaypointType.PICKUP,
            control_point.position,
            meters(0),
            "RADIO",
            description=f"Drop off cargo at {control_point}",
            pretty_name="Drop off location",
            control_point=control_point,
        )
コード例 #22
0
    def ingress(
        self,
        ingress_type: FlightWaypointType,
        position: Point,
        objective: MissionTarget,
    ) -> FlightWaypoint:
        alt_type: AltitudeReference = "BARO"
        if self.is_helo:
            alt_type = "RADIO"

        return FlightWaypoint(
            "INGRESS",
            ingress_type,
            position,
            meters(60) if self.is_helo else self.doctrine.ingress_altitude,
            alt_type,
            description=f"INGRESS on {objective.name}",
            pretty_name=f"INGRESS on {objective.name}",
            targets=objective.strike_targets,
        )
コード例 #23
0
    def nav(
        position: Point, altitude: Distance, altitude_is_agl: bool = False
    ) -> FlightWaypoint:
        """Creates a navigation point.

        Args:
            position: Position of the waypoint.
            altitude: Altitude of the waypoint.
            altitude_is_agl: True for altitude is AGL. False if altitude is MSL.
        """
        alt_type: AltitudeReference = "BARO"
        if altitude_is_agl:
            alt_type = "RADIO"

        return FlightWaypoint(
            "NAV",
            FlightWaypointType.NAV,
            position,
            altitude,
            alt_type,
            description="NAV",
            pretty_name="Nav",
        )
コード例 #24
0
    def find_possible_waypoints(self):

        self.wpts = []
        model = QStandardItemModel()
        i = 0

        def add_model_item(i, model, name, wpt):
            item = QStandardItem(name)
            model.setItem(i, 0, item)
            self.wpts.append(wpt)
            return i + 1

        if self.include_frontlines:
            for front_line in self.game.theater.conflicts():
                pos = FrontLineConflictDescription.frontline_position(
                    front_line, self.game.theater)[0]
                wptname = f"Frontline {front_line.name} [CAS]"
                wpt = FlightWaypoint(wptname, FlightWaypointType.CUSTOM, pos,
                                     Distance.from_meters(800))

                wpt.alt_type = "RADIO"
                wpt.pretty_name = wpt.name
                wpt.description = "Frontline"
                i = add_model_item(i, model, wpt.pretty_name, wpt)

        if self.include_targets:
            for cp in self.game.theater.controlpoints:
                if (self.include_enemy
                        and not cp.captured) or (self.include_friendly
                                                 and cp.captured):
                    for ground_object in cp.ground_objects:
                        if not ground_object.is_dead and isinstance(
                                ground_object, BuildingGroundObject):
                            wpt = FlightWaypoint(
                                ground_object.waypoint_name,
                                FlightWaypointType.CUSTOM,
                                ground_object.position,
                                Distance.from_meters(0),
                            )
                            wpt.alt_type = "RADIO"
                            wpt.pretty_name = wpt.name
                            wpt.obj_name = ground_object.obj_name
                            wpt.targets.append(ground_object)
                            if cp.captured:
                                wpt.description = "Friendly Building"
                            else:
                                wpt.description = "Enemy Building"
                            i = add_model_item(i, model, wpt.pretty_name, wpt)

        if self.include_units:
            for cp in self.game.theater.controlpoints:
                if (self.include_enemy
                        and not cp.captured) or (self.include_friendly
                                                 and cp.captured):
                    for ground_object in cp.ground_objects:
                        if not ground_object.is_dead and (isinstance(
                                ground_object, IadsGroundObject)):
                            for g in ground_object.groups:
                                for j, u in enumerate(g.units):
                                    wptname = ("[" +
                                               str(ground_object.obj_name) +
                                               "] : " + u.name + " #" + str(j))
                                    wpt = FlightWaypoint(
                                        wptname,
                                        FlightWaypointType.CUSTOM,
                                        u.position,
                                        Distance.from_meters(0),
                                    )
                                    wpt.alt_type = "RADIO"
                                    wpt.pretty_name = wptname
                                    wpt.targets.append(u)
                                    wpt.obj_name = ground_object.obj_name
                                    wpt.waypoint_type = FlightWaypointType.CUSTOM
                                    if cp.captured:
                                        wpt.description = "Friendly unit: " + u.name
                                    else:
                                        wpt.description = "Enemy unit: " + u.name
                                    i = add_model_item(i, model,
                                                       wpt.pretty_name, wpt)

        if self.include_airbases:
            for cp in self.game.theater.controlpoints:
                if (self.include_enemy
                        and not cp.captured) or (self.include_friendly
                                                 and cp.captured):
                    wpt = FlightWaypoint(
                        cp.name,
                        FlightWaypointType.CUSTOM,
                        cp.position,
                        Distance.from_meters(0),
                    )
                    wpt.alt_type = "RADIO"
                    if cp.captured:
                        wpt.description = ("Position of " + cp.name +
                                           " [Friendly Airbase]")
                    else:
                        wpt.description = "Position of " + cp.name + " [Enemy Airbase]"

                    if cp.cptype == ControlPointType.AIRCRAFT_CARRIER_GROUP:
                        wpt.pretty_name = cp.name + " (Aircraft Carrier Group)"
                    elif cp.cptype == ControlPointType.LHA_GROUP:
                        wpt.pretty_name = cp.name + " (LHA Group)"
                    else:
                        wpt.pretty_name = cp.name + " (Airbase)"

                    i = add_model_item(i, model, wpt.pretty_name, wpt)

        self.setModel(model)