示例#1
0
    def generate_sead(self, flight, location, custom_targets=[]):
        """
        Generate a sead flight at a given location
        :param flight: Flight to setup
        :param location: Location of the SEAD target
        :param custom_targets: Custom targets if any
        """
        flight.points = []
        flight.flight_type = random.choice([FlightType.SEAD, FlightType.DEAD])

        ascend = self.generate_ascend_point(flight.from_cp)
        flight.points.append(ascend)

        heading = flight.from_cp.position.heading_between_point(
            location.position)
        ingress_heading = heading - 180 + 25
        egress_heading = heading - 180 - 25

        ingress_pos = location.position.point_from_heading(
            ingress_heading, self.doctrine["INGRESS_EGRESS_DISTANCE"])
        ingress_point = FlightWaypoint(ingress_pos.x, ingress_pos.y,
                                       self.doctrine["INGRESS_ALT"])
        ingress_point.name = "INGRESS"
        ingress_point.pretty_name = "INGRESS on " + location.obj_name
        ingress_point.description = "INGRESS on " + location.obj_name
        ingress_point.waypoint_type = FlightWaypointType.INGRESS_SEAD
        flight.points.append(ingress_point)

        if len(custom_targets) > 0:
            for target in custom_targets:
                point = FlightWaypoint(target.position.x, target.position.y, 0)
                point.alt_type = "RADIO"
                if flight.flight_type == FlightType.DEAD:
                    point.description = "SEAD on " + target.type
                    point.pretty_name = "SEAD on " + location.obj_name
                    point.only_for_player = True
                else:
                    point.description = "DEAD on " + location.obj_name
                    point.pretty_name = "DEAD on " + location.obj_name
                    point.only_for_player = True
            ingress_point.targets.append(location)
            ingress_point.targetGroup = location
            flight.points.append(point)
        else:
            point = FlightWaypoint(location.position.x, location.position.y, 0)
            point.alt_type = "RADIO"
            if flight.flight_type == FlightType.DEAD:
                point.description = "SEAD on " + location.obj_name
                point.pretty_name = "SEAD on " + location.obj_name
                point.only_for_player = True
            else:
                point.description = "DEAD on " + location.obj_name
                point.pretty_name = "DEAD on " + location.obj_name
                point.only_for_player = True
            ingress_point.targets.append(location)
            ingress_point.targetGroup = location
            flight.points.append(point)

        egress_pos = location.position.point_from_heading(
            egress_heading, self.doctrine["INGRESS_EGRESS_DISTANCE"])
        egress_point = FlightWaypoint(egress_pos.x, egress_pos.y,
                                      self.doctrine["EGRESS_ALT"])
        egress_point.name = "EGRESS"
        egress_point.pretty_name = "EGRESS from " + location.obj_name
        egress_point.description = "EGRESS from " + location.obj_name
        egress_point.waypoint_type = FlightWaypointType.EGRESS
        flight.points.append(egress_point)

        descend = self.generate_descend_point(flight.from_cp)
        flight.points.append(descend)

        rtb = self.generate_rtb_waypoint(flight.from_cp)
        flight.points.append(rtb)
示例#2
0
    def generate_strike(self, flight, location):

        flight.flight_type = FlightType.STRIKE
        ascend = self.generate_ascend_point(flight.from_cp)
        flight.points.append(ascend)

        heading = flight.from_cp.position.heading_between_point(
            location.position)
        ingress_heading = heading - 180 + 25
        egress_heading = heading - 180 - 25

        ingress_pos = location.position.point_from_heading(
            ingress_heading, self.doctrine["INGRESS_EGRESS_DISTANCE"])
        ingress_point = FlightWaypoint(ingress_pos.x, ingress_pos.y,
                                       self.doctrine["INGRESS_ALT"])
        ingress_point.pretty_name = "INGRESS on " + location.obj_name
        ingress_point.description = "INGRESS on " + location.obj_name
        ingress_point.name = "INGRESS"
        ingress_point.waypoint_type = FlightWaypointType.INGRESS_STRIKE
        flight.points.append(ingress_point)

        if len(location.groups) > 0 and location.dcs_identifier == "AA":
            for g in location.groups:
                for j, u in enumerate(g.units):
                    point = FlightWaypoint(u.position.x, u.position.y, 0)
                    point.description = "STRIKE " + "[" + str(
                        location.obj_name) + "] : " + u.type + " #" + str(j)
                    point.pretty_name = "STRIKE " + "[" + str(
                        location.obj_name) + "] : " + u.type + " #" + str(j)
                    point.name = location.obj_name + "#" + str(j)
                    point.only_for_player = True
                    ingress_point.targets.append(location)
                    flight.points.append(point)
        else:
            if hasattr(location, "obj_name"):
                buildings = self.game.theater.find_ground_objects_by_obj_name(
                    location.obj_name)
                print(buildings)
                for building in buildings:
                    print("BUILDING " + str(building.is_dead) + " " +
                          str(building.dcs_identifier))
                    if building.is_dead:
                        continue

                    point = FlightWaypoint(building.position.x,
                                           building.position.y, 0)
                    point.description = "STRIKE on " + building.obj_name + " " + building.category + " [" + str(
                        building.dcs_identifier) + " ]"
                    point.pretty_name = "STRIKE on " + building.obj_name + " " + building.category + " [" + str(
                        building.dcs_identifier) + " ]"
                    point.name = building.obj_name
                    point.only_for_player = True
                    ingress_point.targets.append(building)
                    flight.points.append(point)
            else:
                point = FlightWaypoint(location.position.x,
                                       location.position.y, 0)
                point.description = "STRIKE on " + location.obj_name
                point.pretty_name = "STRIKE on " + location.obj_name
                point.name = location.obj_name
                point.only_for_player = True
                ingress_point.targets.append(location)
                flight.points.append(point)

        egress_pos = location.position.point_from_heading(
            egress_heading, self.doctrine["INGRESS_EGRESS_DISTANCE"])
        egress_point = FlightWaypoint(egress_pos.x, egress_pos.y,
                                      self.doctrine["EGRESS_ALT"])
        egress_point.name = "EGRESS"
        egress_point.pretty_name = "EGRESS from " + location.obj_name
        egress_point.description = "EGRESS from " + location.obj_name
        egress_point.waypoint_type = FlightWaypointType.EGRESS
        flight.points.append(egress_point)

        descend = self.generate_descend_point(flight.from_cp)
        flight.points.append(descend)

        rtb = self.generate_rtb_waypoint(flight.from_cp)
        flight.points.append(rtb)