def generate_barcap(self, flight, for_cp): """ Generate a barcap flight at a given location :param flight: Flight to setup :param for_cp: CP to protect """ flight.flight_type = FlightType.BARCAP if for_cp.is_carrier else FlightType.CAP patrol_alt = random.randint(self.doctrine["PATROL_ALT_RANGE"][0], self.doctrine["PATROL_ALT_RANGE"][1]) if len(for_cp.ground_objects) > 0: loc = random.choice(for_cp.ground_objects) hdg = for_cp.position.heading_between_point(loc.position) radius = random.randint(self.doctrine["CAP_PATTERN_LENGTH"][0], self.doctrine["CAP_PATTERN_LENGTH"][1]) orbit0p = loc.position.point_from_heading(hdg - 90, radius) orbit1p = loc.position.point_from_heading(hdg + 90, radius) else: loc = for_cp.position.point_from_heading( random.randint(0, 360), random.randint(self.doctrine["CAP_DISTANCE_FROM_CP"][0], self.doctrine["CAP_DISTANCE_FROM_CP"][1])) hdg = for_cp.position.heading_between_point(loc) radius = random.randint(self.doctrine["CAP_PATTERN_LENGTH"][0], self.doctrine["CAP_PATTERN_LENGTH"][1]) orbit0p = loc.point_from_heading(hdg - 90, radius) orbit1p = loc.point_from_heading(hdg + 90, radius) # Create points ascend = self.generate_ascend_point(flight.from_cp) flight.points.append(ascend) orbit0 = FlightWaypoint(FlightWaypointType.PATROL_TRACK, orbit0p.x, orbit0p.y, patrol_alt) orbit0.name = "ORBIT 0" orbit0.description = "Standby between this point and the next one" orbit0.pretty_name = "Race-track start" flight.points.append(orbit0) orbit1 = FlightWaypoint(FlightWaypointType.PATROL, orbit1p.x, orbit1p.y, patrol_alt) orbit1.name = "ORBIT 1" orbit1.description = "Standby between this point and the previous one" orbit1.pretty_name = "Race-track end" flight.points.append(orbit1) orbit0.targets.append(for_cp) obj_added = [] for ground_object in for_cp.ground_objects: if ground_object.obj_name not in obj_added and not ground_object.airbase_group: orbit0.targets.append(ground_object) obj_added.append(ground_object.obj_name) descend = self.generate_descend_point(flight.from_cp) flight.points.append(descend) rtb = self.generate_rtb_waypoint(flight.from_cp) flight.points.append(rtb)
def generate_frontline_cap(self, flight, ally_cp, enemy_cp): """ Generate a cap flight for the frontline between ally_cp and enemy cp in order to ensure air superiority and protect friendly CAP airbase :param flight: Flight to setup :param ally_cp: CP to protect :param enemy_cp: Enemy connected cp """ flight.flight_type = FlightType.CAP patrol_alt = random.randint(self.doctrine["PATROL_ALT_RANGE"][0], self.doctrine["PATROL_ALT_RANGE"][1]) # Find targets waypoints ingress, heading, distance = Conflict.frontline_vector( ally_cp, enemy_cp, self.game.theater) center = ingress.point_from_heading(heading, distance / 2) orbit_center = center.point_from_heading( heading - 90, random.randint(nm_to_meter(6), nm_to_meter(15))) combat_width = distance / 2 if combat_width > 500000: combat_width = 500000 if combat_width < 35000: combat_width = 35000 radius = combat_width * 1.25 orbit0p = orbit_center.point_from_heading(heading, radius) orbit1p = orbit_center.point_from_heading(heading + 180, radius) # Create points ascend = self.generate_ascend_point(flight.from_cp) flight.points.append(ascend) orbit0 = FlightWaypoint(FlightWaypointType.PATROL_TRACK, orbit0p.x, orbit0p.y, patrol_alt) orbit0.name = "ORBIT 0" orbit0.description = "Standby between this point and the next one" orbit0.pretty_name = "Race-track start" flight.points.append(orbit0) orbit1 = FlightWaypoint(FlightWaypointType.PATROL, orbit1p.x, orbit1p.y, patrol_alt) orbit1.name = "ORBIT 1" orbit1.description = "Standby between this point and the previous one" orbit1.pretty_name = "Race-track end" flight.points.append(orbit1) # Note : Targets of a PATROL TRACK waypoints are the points to be defended orbit0.targets.append(flight.from_cp) orbit0.targets.append(center) descend = self.generate_descend_point(flight.from_cp) flight.points.append(descend) rtb = self.generate_rtb_waypoint(flight.from_cp) flight.points.append(rtb)
def make_waypoints(self) -> List[WaypointJs]: departure = FlightWaypoint( FlightWaypointType.TAKEOFF, self.flight.departure.position.x, self.flight.departure.position.y, meters(0), ) departure.alt_type = "RADIO" waypoints = [] for idx, point in enumerate([departure] + self.flight.points): waypoint = WaypointJs(point, idx, self, self.theater, self.ato_model) waypoint.positionChanged.connect(self.update_waypoints) waypoints.append(waypoint) return waypoints
def update_list(self): self.model.clear() self.model.setHorizontalHeaderLabels(["Name", "Alt", "TOT/DEPART"]) # The first waypoint is set up by pydcs at mission generation time, so # we need to add that waypoint manually. takeoff = FlightWaypoint(self.flight.from_cp.position.x, self.flight.from_cp.position.y, 0) takeoff.description = "Take Off" takeoff.name = takeoff.pretty_name = "Take Off from " + self.flight.from_cp.name takeoff.alt_type = "RADIO" waypoints = itertools.chain([takeoff], self.flight.points) for row, waypoint in enumerate(waypoints): self.add_waypoint_row(row, self.flight, waypoint) self.selectionModel().setCurrentIndex(self.indexAt(QPoint(1, 1)), QItemSelectionModel.Select)
def set_flight_waypoint(self, flight_wpt: FlightWaypoint): self.flight_wpt = flight_wpt if flight_wpt is None: self.flight_wpt = FlightWaypoint(0, 0, 0) self.x_position_label.setText(str(self.flight_wpt.x)) self.y_position_label.setText(str(self.flight_wpt.y)) self.alt_label.setText(str(int(self.flight_wpt.alt.feet))) self.name_label.setText(str(self.flight_wpt.name)) self.desc_label.setText(str(self.flight_wpt.description)) self.setTitle(self.flight_wpt.name)
def update_list(self): self.model.clear() self.model.setHorizontalHeaderLabels(["Name", "Alt"]) takeoff = FlightWaypoint(self.flight.from_cp.position.x, self.flight.from_cp.position.y, 0) takeoff.description = "Take Off" takeoff.name = takeoff.pretty_name = "Take Off from " + self.flight.from_cp.name self.model.appendRow(QWaypointItem(takeoff, 0)) self.model.setItem(0, 1, QStandardItem("0 ft AGL")) for i, point in enumerate(self.flight.points): self.model.insertRow(self.model.rowCount()) self.model.setItem(self.model.rowCount() - 1, 0, QWaypointItem(point, i + 1)) self.model.setItem( self.model.rowCount() - 1, 1, QStandardItem( str(meter_to_feet(point.alt)) + " ft " + str(["AGL" if point.alt_type == "RADIO" else "MSL"][0]))) self.selectionModel().setCurrentIndex(self.indexAt(QPoint(1, 1)), QItemSelectionModel.Select)
def __init__(self, flight_wpt: FlightWaypoint = None): super(QFlightWaypointInfoBox, self).__init__("Waypoint") self.flight_wpt = flight_wpt if flight_wpt is None: self.flight_wpt = FlightWaypoint(0, 0, 0) self.x_position_label = QLabel(str(self.flight_wpt.x)) self.y_position_label = QLabel(str(self.flight_wpt.y)) self.alt_label = QLabel(str(int(self.flight_wpt.alt.feet))) self.name_label = QLabel(str(self.flight_wpt.name)) self.desc_label = QLabel(str(self.flight_wpt.description)) self.init_ui()
def generate_rtb_waypoint(self, from_cp): """ Generate RTB landing point :param from_cp: Airport you're landing at :return: """ rtb = from_cp.position rtb = FlightWaypoint(rtb.x, rtb.y, 0) rtb.name = "LANDING" rtb.alt_type = "RADIO" rtb.description = "RTB" rtb.pretty_name = "RTB" rtb.waypoint_type = FlightWaypointType.LANDING_POINT return rtb
def generate_ascend_point(self, from_cp): """ Generate ascend point :param from_cp: Airport you're taking off from :return: """ ascend_heading = from_cp.heading pos_ascend = from_cp.position.point_from_heading(ascend_heading, 10000) ascend = FlightWaypoint(pos_ascend.x, pos_ascend.y, self.doctrine["PATTERN_ALTITUDE"]) ascend.name = "ASCEND" ascend.alt_type = "RADIO" ascend.description = "Ascend" ascend.pretty_name = "Ascend" ascend.waypoint_type = FlightWaypointType.ASCEND_POINT return ascend
def generate_descend_point(self, from_cp): """ Generate approach/descend point :param from_cp: Airport you're landing at :return: """ ascend_heading = from_cp.heading descend = from_cp.position.point_from_heading(ascend_heading - 180, 10000) descend = FlightWaypoint(descend.x, descend.y, self.doctrine["PATTERN_ALTITUDE"]) descend.name = "DESCEND" descend.alt_type = "RADIO" descend.description = "Descend to pattern alt" descend.pretty_name = "Descend to pattern alt" descend.waypoint_type = FlightWaypointType.DESCENT_POINT return descend
def _setup_group(self, group: FlyingGroup, for_task: typing.Type[Task], flight: Flight, dynamic_runways: Dict[str, RunwayData]): did_load_loadout = False unit_type = group.units[0].unit_type if unit_type in db.PLANE_PAYLOAD_OVERRIDES: override_loadout = db.PLANE_PAYLOAD_OVERRIDES[unit_type] if type(override_loadout) == dict: # Clear pylons for p in group.units: p.pylons.clear() # Now load loadout if for_task in db.PLANE_PAYLOAD_OVERRIDES[unit_type]: payload_name = db.PLANE_PAYLOAD_OVERRIDES[unit_type][ for_task] group.load_loadout(payload_name) did_load_loadout = True logging.info( "Loaded overridden payload for {} - {} for task {}". format(unit_type, payload_name, for_task)) elif "*" in db.PLANE_PAYLOAD_OVERRIDES[unit_type]: payload_name = db.PLANE_PAYLOAD_OVERRIDES[unit_type]["*"] group.load_loadout(payload_name) did_load_loadout = True logging.info( "Loaded overridden payload for {} - {} for task {}". format(unit_type, payload_name, for_task)) elif issubclass(override_loadout, MainTask): group.load_task_default_loadout(override_loadout) did_load_loadout = True if not did_load_loadout: group.load_task_default_loadout(for_task) if unit_type in db.PLANE_LIVERY_OVERRIDES: for unit_instance in group.units: unit_instance.livery_id = db.PLANE_LIVERY_OVERRIDES[unit_type] single_client = flight.client_count == 1 for idx in range(0, min(len(group.units), flight.client_count)): unit = group.units[idx] if single_client: unit.set_player() else: unit.set_client() # Do not generate player group with late activation. if group.late_activation: group.late_activation = False # Set up F-14 Client to have pre-stored alignement if unit_type is F_14B: unit.set_property(F_14B.Properties.INSAlignmentStored.id, True) group.points[0].tasks.append( OptReactOnThreat(OptReactOnThreat.Values.EvadeFire)) channel = self.get_intra_flight_channel(unit_type) group.set_frequency(channel.mhz) # TODO: Support for different departure/arrival airfields. cp = flight.from_cp fallback_runway = RunwayData(cp.full_name, runway_name="") if cp.cptype == ControlPointType.AIRBASE: departure_runway = self.get_preferred_runway( flight.from_cp.airport) elif cp.is_fleet: departure_runway = dynamic_runways.get(cp.name, fallback_runway) else: logging.warning(f"Unhandled departure control point: {cp.cptype}") departure_runway = fallback_runway # The first waypoint is set automatically by pydcs, so it's not in our # list. Convert the pydcs MovingPoint to a FlightWaypoint so it shows up # in our FlightData. first_point = FlightWaypoint.from_pydcs(group.points[0], flight.from_cp) self.flights.append( FlightData( flight_type=flight.flight_type, units=group.units, size=len(group.units), friendly=flight.from_cp.captured, departure_delay=flight.scheduled_in, departure=departure_runway, arrival=departure_runway, # TODO: Support for divert airfields. divert=None, waypoints=[first_point] + flight.points, intra_flight_channel=channel)) # Special case so Su 33 carrier take off if unit_type is Su_33: if task is not CAP: for unit in group.units: unit.fuel = Su_33.fuel_max / 2.2 else: for unit in group.units: unit.fuel = Su_33.fuel_max * 0.8
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 cp in self.game.theater.controlpoints: if cp.captured: enemy_cp = [ ecp for ecp in cp.connected_points if ecp.captured != cp.captured ] for ecp in enemy_cp: pos = Conflict.frontline_position( cp, ecp, self.game.theater)[0] wpt = FlightWaypoint( FlightWaypointType.CUSTOM, pos.x, pos.y, Distance.from_meters(800), ) wpt.name = "Frontline " + cp.name + "/" + ecp.name + " [CAS]" 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( FlightWaypointType.CUSTOM, ground_object.position.x, ground_object.position.y, Distance.from_meters(0), ) wpt.alt_type = "RADIO" wpt.name = ground_object.waypoint_name 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 ground_object.dcs_identifier == "AA"): for g in ground_object.groups: for j, u in enumerate(g.units): wpt = FlightWaypoint( FlightWaypointType.CUSTOM, u.position.x, u.position.y, Distance.from_meters(0), ) wpt.alt_type = "RADIO" wpt.name = wpt.name = ( "[" + str(ground_object.obj_name) + "] : " + u.type + " #" + str(j)) wpt.pretty_name = wpt.name wpt.targets.append(u) wpt.obj_name = ground_object.obj_name wpt.waypoint_type = FlightWaypointType.CUSTOM if cp.captured: wpt.description = "Friendly unit : " + u.type else: wpt.description = "Enemy unit : " + u.type 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( FlightWaypointType.CUSTOM, cp.position.x, cp.position.y, Distance.from_meters(0), ) wpt.alt_type = "RADIO" wpt.name = cp.name 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)
def find_possible_waypoints(self): self.wpts = [] model = QStandardItemModel() i = 0 def add_model_item(i, model, name, wpt): print(name) item = QStandardItem(name) model.setItem(i, 0, item) self.wpts.append(wpt) return i + 1 if self.include_frontlines: for cp in self.game.theater.controlpoints: if cp.captured: enemy_cp = [ecp for ecp in cp.connected_points if ecp.captured != cp.captured] for ecp in enemy_cp: pos = Conflict.frontline_position(self.game.theater, cp, ecp)[0] wpt = FlightWaypoint( FlightWaypointType.CUSTOM, pos.x, pos.y, 800) wpt.name = "Frontline " + cp.name + "/" + ecp.name + " [CAS]" wpt.alt_type = "RADIO" wpt.pretty_name = wpt.name wpt.description = "Frontline" wpt.data = [cp, ecp] wpt.category = PredefinedWaypointCategory.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 not ground_object.dcs_identifier == "AA": wpt = FlightWaypoint( FlightWaypointType.CUSTOM, ground_object.position.x, ground_object.position.y, 0 ) wpt.alt_type = "RADIO" wpt.name = wpt.name = "[" + str(ground_object.obj_name) + "] : " + ground_object.category + " #" + str(ground_object.object_id) wpt.pretty_name = wpt.name wpt.obj_name = ground_object.obj_name wpt.targets.append(ground_object) wpt.data = ground_object if cp.captured: wpt.description = "Friendly Building" wpt.category = PredefinedWaypointCategory.ALLY_BUILDING else: wpt.description = "Enemy Building" wpt.category = PredefinedWaypointCategory.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 ground_object.dcs_identifier == "AA": for g in ground_object.groups: for j, u in enumerate(g.units): wpt = FlightWaypoint( FlightWaypointType.CUSTOM, u.position.x, u.position.y, 0 ) wpt.alt_type = "RADIO" wpt.name = wpt.name = "[" + str(ground_object.obj_name) + "] : " + u.type + " #" + str(j) wpt.pretty_name = wpt.name wpt.targets.append(u) wpt.data = u wpt.obj_name = ground_object.obj_name wpt.waypoint_type = FlightWaypointType.CUSTOM if cp.captured: wpt.description = "Friendly unit : " + u.type wpt.category = PredefinedWaypointCategory.ALLY_UNIT else: wpt.description = "Enemy unit : " + u.type wpt.category = PredefinedWaypointCategory.ENEMY_UNIT 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( FlightWaypointType.CUSTOM, cp.position.x, cp.position.y, 0 ) wpt.alt_type = "RADIO" wpt.name = cp.name wpt.data = cp if cp.captured: wpt.description = "Position of " + cp.name + " [Friendly Airbase]" wpt.category = PredefinedWaypointCategory.ALLY_CP else: wpt.description = "Position of " + cp.name + " [Enemy Airbase]" wpt.category = PredefinedWaypointCategory.ENEMY_CP 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)
def generate_cas(self, flight, from_cp, location): """ Generate a CAS flight at a given location :param flight: Flight to setup :param location: Location of the CAS targets """ is_helo = hasattr(flight.unit_type, "helicopter") and flight.unit_type.helicopter cap_alt = 1000 flight.points = [] flight.flight_type = FlightType.CAS ingress, heading, distance = Conflict.frontline_vector( from_cp, location, self.game.theater) center = ingress.point_from_heading(heading, distance / 2) egress = ingress.point_from_heading(heading, distance) ascend = self.generate_ascend_point(flight.from_cp) if is_helo: cap_alt = 500 ascend.alt = 500 flight.points.append(ascend) ingress_point = FlightWaypoint(ingress.x, ingress.y, cap_alt) ingress_point.alt_type = "RADIO" ingress_point.name = "INGRESS" ingress_point.pretty_name = "INGRESS" ingress_point.description = "Ingress into CAS area" ingress_point.waypoint_type = FlightWaypointType.INGRESS_CAS flight.points.append(ingress_point) center_point = FlightWaypoint(center.x, center.y, cap_alt) center_point.alt_type = "RADIO" center_point.description = "Provide CAS" center_point.name = "CAS" center_point.pretty_name = "CAS" center_point.waypoint_type = FlightWaypointType.CAS flight.points.append(center_point) egress_point = FlightWaypoint(egress.x, egress.y, cap_alt) egress_point.alt_type = "RADIO" egress_point.description = "Egress from CAS area" egress_point.name = "EGRESS" egress_point.pretty_name = "EGRESS" egress_point.waypoint_type = FlightWaypointType.EGRESS flight.points.append(egress_point) descend = self.generate_descend_point(flight.from_cp) if is_helo: descend.alt = 300 flight.points.append(descend) rtb = self.generate_rtb_waypoint(flight.from_cp) flight.points.append(rtb)
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)
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)