def load_templates(): temp_mis = Mission() temp_mis.load_file("resources/tools/groundobject_templates.miz") groups = { } # type: typing.Dict[str, typing.Dict[int, typing.List[Static]]] for static_group in temp_mis.country( "USA").static_group + temp_mis.country( "USAF Aggressors").static_group: for static in static_group.units: static_name = str(static.name).split()[0] tpl_name, tpl_idx = static_name[:-1], int(static_name[-1]) groups[tpl_name] = groups.get(tpl_name, {}) groups[tpl_name][tpl_idx] = groups[tpl_name].get(tpl_idx, []) groups[tpl_name][tpl_idx].append(static) tpls = { name: {idx: [] for idx in groups[name].keys()} for name in groups.keys() } for category_name, category_groups in groups.items(): for idx, static_groups in category_groups.items(): dist = -1 a, b = None, None for aa in static_groups: for bb in static_groups: if aa.position.distance_to_point(bb.position) > dist: dist = aa.position.distance_to_point(bb.position) a = aa b = bb center = a.position.point_from_heading( a.position.heading_between_point(b.position), dist / 2) for static in static_groups: tpls[category_name][idx].append({ "type": static.type, "offset": Point(center.x - static.position.x, center.y - static.position.y), "heading": static.heading, }) tpls["aa"] = {0: [{"type": "AA", "offset": Point(0, 0), "heading": 0}]} return tpls
def sa10_site(mission: Mission, position: mapping.Point, heading, prefix="", skill=unit.Skill.Average): russia = mission.country("Russia") vg = mission.vehicle_group(russia, prefix + "SA10 site", Russia.Vehicle.AirDefence.SAM_SA_10_S_300_Grumble_Big_Bird_SR, position, heading) u = mission.vehicle("Operator 1", Russia.Vehicle.Infantry.Infantry_AK_74_Rus) u.position = position.point_from_heading(heading + 180, 10) u.heading = heading vg.add_unit(u) hdg = 90 for i in range(0, 3): # 3 launchers u = mission.vehicle("launcher #" + str(i + 1), Russia.Vehicle.AirDefence.SAM_SA_10_S_300_Grumble_TEL_C) u.position = position.point_from_heading(heading + hdg, 50) u.heading = heading vg.add_unit(u) hdg += 90 u = mission.vehicle("radar", Russia.Vehicle.AirDefence.SAM_SA_10_S_300_Grumble_Flap_Lid_TR) u.position = position.point_from_heading(heading, 80) u.heading = heading vg.add_unit(u) u = mission.vehicle("radar", Russia.Vehicle.AirDefence.SAM_SA_10_S_300_Grumble_C2) u.position = position.point_from_heading(heading + 180, 100) u.heading = heading vg.add_unit(u) for u in vg.units: u.skill = skill return vg
def sa10_site(mission: Mission, position: mapping.Point, heading, prefix="", skill=unit.Skill.Average): russia = mission.country("Russia") vg = mission.vehicle_group(russia, prefix + "SA10 site", Russia.Vehicle.AirDefence.S_300PS_64H6E_sr, position, heading) u = mission.vehicle("Operator 1", Russia.Vehicle.Infantry.Paratrooper_AKS_74) u.position = position.point_from_heading(heading + 180, 10) u.heading = heading vg.add_unit(u) hdg = 90 for i in range(0, 3): # 3 launchers u = mission.vehicle("launcher #" + str(i + 1), Russia.Vehicle.AirDefence.S_300PS_5P85C_ln) u.position = position.point_from_heading(heading + hdg, 50) u.heading = heading vg.add_unit(u) hdg += 90 u = mission.vehicle("radar", Russia.Vehicle.AirDefence.S_300PS_40B6M_tr) u.position = position.point_from_heading(heading, 80) u.heading = heading vg.add_unit(u) u = mission.vehicle("radar", Russia.Vehicle.AirDefence.S_300PS_54K6_cp) u.position = position.point_from_heading(heading + 180, 100) u.heading = heading vg.add_unit(u) for u in vg.units: u.skill = skill return vg
def sa10_site(mission: Mission, position: mapping.Point, heading, prefix="", skill=unit.Skill.Average): russia = mission.country("Russia") vg = mission.vehicle_group(russia, prefix + "SA10 site", Russia.Vehicle.AirDefence.SAM_SA_10_S_300PS_CP_54K6, position, heading) u = mission.vehicle("Operator 1", Russia.Vehicle.Infantry.Infantry_Soldier_Rus) u.position = position.point_from_heading(heading + 180, 10) u.heading = heading vg.add_unit(u) hdg = 90 for i in range(0, 3): # 3 launchers u = mission.vehicle("launcher #" + str(i + 1), Russia.Vehicle.AirDefence.SAM_SA_10_S_300PS_LN_5P85C) u.position = position.point_from_heading(heading + hdg, 50) u.heading = heading vg.add_unit(u) hdg += 90 u = mission.vehicle("radar", Russia.Vehicle.AirDefence.SAM_SA_10_S_300PS_TR_30N6) u.position = position.point_from_heading(heading, 80) u.heading = heading vg.add_unit(u) u = mission.vehicle("radar", Russia.Vehicle.AirDefence.SAM_SA_10_S_300PS_SR_64H6E) u.position = position.point_from_heading(heading + 180, 100) u.heading = heading vg.add_unit(u) for u in vg.units: u.skill = skill return vg
def patriot_site(mission: Mission, position, heading, prefix="", skill=unit.Skill.Average): usa = mission.country("USA") vg = mission.vehicle_group(usa, prefix + "Patriot site", USA.Vehicle.AirDefence.SAM_Patriot_ICC, position, heading) u = mission.vehicle("Operator 1", USA.Vehicle.Infantry.Infantry_M4) u.position = position.point_from_heading(heading + 180, 5) u.heading = heading vg.add_unit(u) hdg = 90 for i in range(0, 2): # 2 launchers u = mission.vehicle("launcher #" + str(i + 1), USA.Vehicle.AirDefence.SAM_Patriot_LN_M901) u.position = position.point_from_heading(heading + hdg, 50) u.heading = heading vg.add_unit(u) hdg += 90 u = mission.vehicle("Electronic power plant", USA.Vehicle.AirDefence.SAM_Patriot_EPP_III) u.position = position.point_from_heading(heading + 180, 50) u.heading = heading vg.add_unit(u) u = mission.vehicle( "radar", USA.Vehicle.AirDefence.SAM_Patriot_STR_AN_MPQ_53) u.position = position.point_from_heading(heading, 80) u.heading = heading vg.add_unit(u) inf = mission.vehicle("Operator 2", USA.Vehicle.Infantry.Infantry_M4) inf.position = position.point_from_heading(heading + 270, 5) vg.add_unit(inf) u = mission.vehicle( "Antenna", USA.Vehicle.AirDefence.SAM_Patriot_AMG_AN_MRC_137) u.position = position.point_from_heading(heading + 180, 100) u.heading = heading vg.add_unit(u) u = mission.vehicle( "ECS", USA.Vehicle.AirDefence.SAM_Patriot_ECS_AN_MSQ_104) u.position = position.point_from_heading(heading + 120, 80) u.heading = heading vg.add_unit(u) for u in vg.units: u.skill = skill
def hawk_site(mission: Mission, position, heading, prefix="", skill=unit.Skill.Average): usa = mission.country("USA") vg = mission.vehicle_group(usa, prefix + "Hawk site", USA.Vehicle.AirDefence.SAM_Hawk_PCP, position, heading) u = mission.vehicle("Operator 1", USA.Vehicle.Infantry.Infantry_M4) u.position = position.point_from_heading(heading + 180, 5) u.heading = heading vg.add_unit(u) hdg = 90 for i in range(0, 2): # 2 launchers u = mission.vehicle("launcher #" + str(i + 1), USA.Vehicle.AirDefence.SAM_Hawk_LN_M192) u.position = position.point_from_heading(heading + hdg, 50) u.heading = heading vg.add_unit(u) hdg += 90 u = mission.vehicle("Radar", USA.Vehicle.AirDefence.SAM_Hawk_SR_AN_MPQ_50) u.position = position.point_from_heading(heading + 180, 20) u.heading = heading vg.add_unit(u) inf = mission.vehicle("Operator 2", USA.Vehicle.Infantry.Infantry_M4) inf.position = position.point_from_heading(heading + 270, 5) vg.add_unit(inf) u = mission.vehicle("Tower", USA.Vehicle.AirDefence.SAM_Hawk_TR_AN_MPQ_46) u.position = position.point_from_heading(heading + 80, 80) u.heading = heading vg.add_unit(u) u = mission.vehicle("Wave Radar", USA.Vehicle.AirDefence.SAM_Hawk_CWAR_AN_MPQ_55) u.position = position.point_from_heading(heading + 180, 100) u.heading = heading vg.add_unit(u) for u in vg.units: u.skill = skill
import pickle from dcs.mission import Mission from shapely import geometry for terrain in ["cau", "nev", "syria", "channel", "normandy", "gulf"]: print("Terrain " + terrain) m = Mission() m.load_file("./{}_terrain.miz".format(terrain)) inclusion_zones = [] exclusion_zones = [] seas_zones = [] for plane_group in m.country("USA").plane_group: zone = [(x.position.x, x.position.y) for x in plane_group.points] if terrain == "cau" and inclusion_zones: # legacy exclusion_zones.append(geometry.Polygon(zone)) else: if plane_group.units[0].type == "F-15C": exclusion_zones.append(geometry.Polygon(zone)) else: inclusion_zones.append(geometry.Polygon(zone)) for ship_group in m.country("USA").ship_group: zone = [(x.position.x, x.position.y) for x in ship_group.points] seas_zones.append(geometry.Polygon(zone)) with open("../{}landmap.p".format(terrain), "wb") as f: print(len(inclusion_zones), len(exclusion_zones), len(seas_zones))
import pickle from dcs.mission import Mission from dcs.planes import A_10C for terrain in ["cau", "gulf", "nev", "channel"]: print("Terrain " + terrain) m = Mission() m.load_file("./{}_terrain.miz".format(terrain)) inclusion_zones = [] exclusion_zones = [] for plane_group in m.country("USA").plane_group: zone = [(x.position.x, x.position.y) for x in plane_group.points] if terrain == "cau" and inclusion_zones: # legacy exclusion_zones.append(zone) else: if plane_group.units[0].type == "F-15C": exclusion_zones.append(zone) else: inclusion_zones.append(zone) with open("../{}landmap.p".format(terrain), "wb") as f: print(len(inclusion_zones), len(exclusion_zones)) pickle.dump((inclusion_zones, exclusion_zones), f)
min_distance, min_cp = None, None for cp in theater.controlpoints: if not min_distance or location.distance_to_point( cp.position) < min_distance: min_distance = location.distance_to_point(cp.position) min_cp = cp.id assert min_cp is not None return min_cp if __name__ == "__main__": theater_objects = [] for group in m.country("Russia").static_group + m.country( "Russia").vehicle_group: for unit in group.units: theater_object = TheaterGroundObject() theater_object.object_id = len(theater_objects) + 1 theater_object.position = unit.position theater_object.heading = unit.heading if isinstance( unit, Vehicle ) and unit.type in vehicles.AirDefence.__dict__.values(): theater_object.dcs_identifier = "AA" else: theater_object.dcs_identifier = unit.type