diff --git a/Generator/MissionGenerator.py b/Generator/MissionGenerator.py index 6bbf24a..dd9829a 100644 --- a/Generator/MissionGenerator.py +++ b/Generator/MissionGenerator.py @@ -6,6 +6,7 @@ import RotorOpsMission as ROps import RotorOpsUtils import RotorOpsUnits import logging +import json from PyQt5.QtWidgets import ( QApplication, QDialog, QMainWindow, QMessageBox @@ -36,7 +37,7 @@ sys.excepthook = handle_exception maj_version = 0 -minor_version = 5 +minor_version = 6 version_string = str(maj_version) + "." + str(minor_version) scenarios = [] red_forces_files = [] @@ -76,6 +77,8 @@ class Window(QMainWindow, Ui_MainWindow): self.version_label.setText("Version " + version_string) + self.prefs = None # holds json from scenario preference files + def connectSignalsSlots(self): self.action_generateMission.triggered.connect(self.generateMissionAction) @@ -109,6 +112,7 @@ class Window(QMainWindow, Ui_MainWindow): self.slot_template_comboBox.addItem("Multiple Slots") for type in RotorOpsUnits.client_helos: self.slot_template_comboBox.addItem(type.id) + self.slot_template_comboBox.addItem("None") def defensiveModeChanged(self): if self.defense_checkBox.isChecked(): @@ -118,6 +122,46 @@ class Window(QMainWindow, Ui_MainWindow): self.red_forces_label.setText(defenders_text) self.blue_forces_label.setText(attackers_text) + self.applyScenarioPrefs() + + def loadScenarioPrefs(self, filename): + try: + j = open(filename) + prefs = json.load(j) + j.close() + return prefs + except: + return None + + def lockedSlot(self): + return self.slot_template_comboBox.findText("Locked to Scenario") + + def clearScenarioPrefs(self): + # reset default states + self.defense_checkBox.setEnabled(True) + if self.lockedSlot(): + self.slot_template_comboBox.removeItem(self.lockedSlot()) + + self.slot_template_comboBox.setEnabled(True) + self.slot_template_comboBox.setCurrentIndex(0) + + def applyScenarioPrefs(self): + + if self.prefs['defense']['allowed'] == False: + self.defense_checkBox.setChecked(False) + self.defense_checkBox.setEnabled(False) + elif self.prefs['offense']['allowed'] == False: + self.defense_checkBox.setChecked(True) + self.defense_checkBox.setEnabled(False) + + if self.prefs['defense']['player_spawn'] == "fixed": + self.slot_template_comboBox.addItem("Locked to Scenario") + self.slot_template_comboBox.setCurrentIndex(self.lockedSlot()) + self.slot_template_comboBox.setEnabled(False) + + + + def scenarioChanged(self): os.chdir(self.m.scenarios_dir) @@ -136,6 +180,13 @@ class Window(QMainWindow, Ui_MainWindow): friendly_airports = True enemy_airports = True + self.clearScenarioPrefs() + prefs_filename = filename.removesuffix(".miz") + ".json" + self.prefs = self.loadScenarioPrefs(prefs_filename) + if self.prefs: + self.applyScenarioPrefs() + + for zone in zones: if zone.name == "STAGING": staging_zones += 1 @@ -174,7 +225,6 @@ class Window(QMainWindow, Ui_MainWindow): + "\n== BRIEFING ==\n\n" + source_mission.description_text() ) - #self.description_textBrowser.setText("File error occured.") def generateMissionAction(self): diff --git a/Generator/RotorOpsGroups.py b/Generator/RotorOpsGroups.py index 25bc383..26a225a 100644 --- a/Generator/RotorOpsGroups.py +++ b/Generator/RotorOpsGroups.py @@ -25,7 +25,7 @@ class VehicleTemplate: dcs.vehicles.Unarmed.M_818, dcs.vehicles.AirDefence.Vulcan, dcs.vehicles.Unarmed.Ural_375, - dcs.vehicles.Unarmed.M978_HEMTT_Tanker + dcs.vehicles.Unarmed.M978_HEMTT_Tanker, ], position.point_from_heading(45, 7), heading=random.randint(0, 359), diff --git a/Generator/RotorOpsMission.py b/Generator/RotorOpsMission.py index 58f05d4..1b444f8 100644 --- a/Generator/RotorOpsMission.py +++ b/Generator/RotorOpsMission.py @@ -10,6 +10,8 @@ import RotorOpsUtils import time from MissionGenerator import logger +jtf_red = "Combined Joint Task Forces Red" +jtf_blue = "Combined Joint Task Forces Blue" class RotorOpsMission: @@ -38,6 +40,7 @@ class RotorOpsMission: self.position = position self.size = size + def getMission(self): return self.m @@ -122,7 +125,7 @@ class RotorOpsMission: self.importObjects() - if not self.m.country("Combined Joint Task Forces Red") or not self.m.country("Combined Joint Task Forces Blue"): + if not self.m.country(jtf_red) or not self.m.country(jtf_blue): failure_msg = "You must include a CombinedJointTaskForcesBlue and CombinedJointTaskForcesRed unit in the scenario template. See the instructions in " + self.scenarios_dir return {"success": False, "failure_msg": failure_msg} @@ -167,18 +170,18 @@ class RotorOpsMission: #Populate Red zones with ground units for zone_name in red_zones: if red_forces["vehicles"]: - self.addGroundGroups(red_zones[zone_name], self.m.country('Combined Joint Task Forces Red'), red_forces["vehicles"], options["red_quantity"]) + self.addGroundGroups(red_zones[zone_name], self.m.country(jtf_red), red_forces["vehicles"], options["red_quantity"]) #Add red FARPS if options["zone_farps"] != "farp_never" and not options["defending"]: - RotorOpsGroups.VehicleTemplate.CombinedJointTaskForcesBlue.zone_farp(self.m, self.m.country('Combined Joint Task Forces Blue'), - self.m.country('Combined Joint Task Forces Blue'), + RotorOpsGroups.VehicleTemplate.CombinedJointTaskForcesBlue.zone_farp(self.m, self.m.country(jtf_blue), + self.m.country(jtf_blue), red_zones[zone_name].position, 180, zone_name + " FARP", late_activation=True) if options["zone_protect_sams"]: self.m.vehicle_group( - self.m.country('Combined Joint Task Forces Red'), + self.m.country(jtf_red), "Static " + zone_name + " Protection SAM", random.choice(RotorOpsUnits.e_zone_sams), red_zones[zone_name].position, @@ -192,18 +195,18 @@ class RotorOpsMission: #Populate Blue zones with ground units for zone_name in blue_zones: if blue_forces["vehicles"]: - self.addGroundGroups(blue_zones[zone_name], self.m.country('Combined Joint Task Forces Blue'), blue_forces["vehicles"], + self.addGroundGroups(blue_zones[zone_name], self.m.country(jtf_blue), blue_forces["vehicles"], options["blue_quantity"]) #Add blue FARPS if options["zone_farps"] != "farp_never" and options["defending"]: - RotorOpsGroups.VehicleTemplate.CombinedJointTaskForcesBlue.zone_farp(self.m, self.m.country('Combined Joint Task Forces Blue'), - self.m.country('Combined Joint Task Forces Blue'), + RotorOpsGroups.VehicleTemplate.CombinedJointTaskForcesBlue.zone_farp(self.m, self.m.country(jtf_blue), + self.m.country(jtf_blue), blue_zones[zone_name].position, 180, zone_name + " FARP", late_activation=False) #add logistics sites if options["crates"] and zone_name in self.staging_zones: - RotorOpsGroups.VehicleTemplate.CombinedJointTaskForcesBlue.logistics_site(self.m, self.m.country('Combined Joint Task Forces Blue'), + RotorOpsGroups.VehicleTemplate.CombinedJointTaskForcesBlue.logistics_site(self.m, self.m.country(jtf_blue), blue_zones[zone_name].position, 180, zone_name) @@ -213,7 +216,7 @@ class RotorOpsMission: if options["zone_protect_sams"] and options["defending"]: vg = self.m.vehicle_group( - self.m.country('Combined Joint Task Forces Blue'), + self.m.country(jtf_blue), "Static " + zone_name + " Protection SAM", random.choice(RotorOpsUnits.e_zone_sams), blue_zones[zone_name].position, @@ -224,7 +227,8 @@ class RotorOpsMission: #Add player slots - self.addPlayerHelos(options) + if options["slots"] != "Locked to Scenario" and options["slots"] != "None": + self.addPlayerHelos(options) #Add AI Flights self.addFlights(options, red_forces, blue_forces) @@ -289,10 +293,11 @@ class RotorOpsMission: if len(airport.free_parking_slots(aircraft)) >= group_size: if not (aircraft.id in dcs.planes.plane_map and len(airport.runways) == 0): return airport - for airport in alt_airports: - if len(airport.free_parking_slots(aircraft)) >= group_size: - if not (aircraft.id in dcs.planes.plane_map and len(airport.runways) == 0): - return airport + if alt_airports: + for airport in alt_airports: + if len(airport.free_parking_slots(aircraft)) >= group_size: + if not (aircraft.id in dcs.planes.plane_map and len(airport.runways) == 0): + return airport logger.warn("No parking available for " + aircraft.id) return None @@ -314,8 +319,8 @@ class RotorOpsMission: for airport in red_airports: self.m.terrain.airports[airport.name].set_blue() - combinedJointTaskForcesBlue = self.m.country("Combined Joint Task Forces Blue") - combinedJointTaskForcesRed = self.m.country("Combined Joint Task Forces Red") + combinedJointTaskForcesBlue = self.m.country(jtf_blue) + combinedJointTaskForcesRed = self.m.country(jtf_red) #Swap ships @@ -398,13 +403,13 @@ class RotorOpsMission: client_helos = [dcs.helicopters.helicopter_map[helicopter]] #find friendly carriers and farps - carrier = self.m.country("Combined Joint Task Forces Blue").find_ship_group(name="HELO_CARRIER") + carrier = self.m.country(jtf_blue).find_ship_group(name="HELO_CARRIER") if not carrier: - carrier = self.m.country("Combined Joint Task Forces Blue").find_ship_group(name="HELO_CARRIER_1") + carrier = self.m.country(jtf_blue).find_ship_group(name="HELO_CARRIER_1") - farp = self.m.country("Combined Joint Task Forces Blue").find_static_group("HELO_FARP") + farp = self.m.country(jtf_blue).find_static_group("HELO_FARP") if not farp: - farp = self.m.country("Combined Joint Task Forces Blue").find_static_group("HELO_FARP_1") + farp = self.m.country(jtf_blue).find_static_group("HELO_FARP_1") friendly_airports, primary_f_airport = self.getCoalitionAirports("blue") @@ -415,10 +420,10 @@ class RotorOpsMission: for helotype in client_helos: if carrier: - fg = self.m.flight_group_from_unit(self.m.country('Combined Joint Task Forces Blue'), "CARRIER " + helotype.id, helotype, carrier, + fg = self.m.flight_group_from_unit(self.m.country(jtf_blue), "CARRIER " + helotype.id, helotype, carrier, dcs.task.CAS, group_size=group_size) elif farp: - fg = self.m.flight_group_from_unit(self.m.country('Combined Joint Task Forces Blue'), "FARP " + helotype.id, helotype, farp, + fg = self.m.flight_group_from_unit(self.m.country(jtf_blue), "FARP " + helotype.id, helotype, farp, dcs.task.CAS, group_size=group_size) #invisible farps need manual unit placement for multiple units @@ -428,7 +433,7 @@ class RotorOpsMission: fg.units[0].position = fg.units[0].position.point_from_heading(heading, 30) heading += 90 else: - fg = self.m.flight_group_from_airport(self.m.country('Combined Joint Task Forces Blue'), primary_f_airport.name + " " + helotype.id, helotype, + fg = self.m.flight_group_from_airport(self.m.country(jtf_blue), primary_f_airport.name + " " + helotype.id, helotype, self.getParking(primary_f_airport, helotype), group_size=group_size) fg.units[0].set_client() fg.load_task_default_loadout(dcs.task.CAS) @@ -464,13 +469,13 @@ class RotorOpsMission: enemy_airports, primary_e_airport = self.getCoalitionAirports("red") #find enemy carriers and farps - carrier = self.m.country("Combined Joint Task Forces Red").find_ship_group(name="HELO_CARRIER") + carrier = self.m.country(jtf_red).find_ship_group(name="HELO_CARRIER") if not carrier: - carrier = self.m.country("Combined Joint Task Forces Red").find_ship_group(name="HELO_CARRIER_1") + carrier = self.m.country(jtf_red).find_ship_group(name="HELO_CARRIER_1") - farp = self.m.country("Combined Joint Task Forces Red").find_static_group("HELO_FARP") + farp = self.m.country(jtf_red).find_static_group("HELO_FARP") if not farp: - farp = self.m.country("Combined Joint Task Forces Red").find_static_group("HELO_FARP_1") + farp = self.m.country(jtf_red).find_static_group("HELO_FARP_1") e_airport_heading = dcs.mapping.heading_between_points( friendly_airports[0].position.x, friendly_airports[0].position.y, enemy_airports[0].position.x, primary_e_airport.position.y @@ -507,7 +512,7 @@ class RotorOpsMission: awacs_escort = self.m.escort_flight( combinedJointTaskForcesBlue, "AWACS Escort", plane_type, - airport=self.getParking(primary_f_airport, plane_type, friendly_airports), + airport=self.getParking(primary_f_airport, plane_type, friendly_airports, group_size=2), group_to_escort=awacs, group_size=2) @@ -767,11 +772,11 @@ class RotorOpsMission: for index, zone_name in enumerate(self.conflict_zones): if index > 0: previous_zone = list(self.conflict_zones)[index - 1] - if not self.m.country("Combined Joint Task Forces Blue").find_group(previous_zone + " FARP Static"): + if not self.m.country(jtf_blue).find_group(previous_zone + " FARP Static"): continue z_farps_trig = dcs.triggers.TriggerOnce(comment="Activate " + previous_zone + " FARP") z_farps_trig.rules.append(dcs.condition.FlagEquals(game_flag, index + 1)) - z_farps_trig.actions.append(dcs.action.ActivateGroup(self.m.country("Combined Joint Task Forces Blue").find_group(previous_zone + " FARP Static").id)) + z_farps_trig.actions.append(dcs.action.ActivateGroup(self.m.country(jtf_blue).find_group(previous_zone + " FARP Static").id)) #z_farps_trig.actions.append(dcs.action.SoundToAll(str(self.res_map['forward_base_established.ogg']))) z_farps_trig.actions.append(dcs.action.DoScript(dcs.action.String( "RotorOps.farpEstablished(" + str(index) + ")"))) @@ -783,14 +788,14 @@ class RotorOpsMission: for index, zone_name in enumerate(self.conflict_zones): if index > 0: previous_zone = list(self.conflict_zones)[index - 1] - if not self.m.country("Combined Joint Task Forces Blue").find_group(previous_zone + " FARP Static"): + if not self.m.country(jtf_blue).find_group(previous_zone + " FARP Static"): continue z_farps_trig = dcs.triggers.TriggerOnce(comment= "Activate " + previous_zone + " FARP") z_farps_trig.rules.append(dcs.condition.FlagEquals(game_flag, index + 1)) z_farps_trig.rules.append(dcs.condition.FlagIsMore(111, 20)) z_farps_trig.actions.append(dcs.action.DoScript(dcs.action.String("--The 100 flag indicates which zone is active. The 111 flag value is the percentage of staged units remaining"))) z_farps_trig.actions.append( - dcs.action.ActivateGroup(self.m.country("Combined Joint Task Forces Blue").find_group(previous_zone + " FARP Static").id)) + dcs.action.ActivateGroup(self.m.country(jtf_blue).find_group(previous_zone + " FARP Static").id)) #z_farps_trig.actions.append(dcs.action.SoundToAll(str(self.res_map['forward_base_established.ogg']))) z_farps_trig.actions.append(dcs.action.DoScript(dcs.action.String( "RotorOps.farpEstablished(" + str(index) + ")"))) @@ -845,24 +850,22 @@ class RotorOpsMission: trig.actions.append(dcs.action.DoScript(dcs.action.String("---Add an action you want to happen when the game is LOST"))) self.m.triggerrules.triggers.append(trig) - - def addStatics(self): - os.chdir(self.home_dir + "/Generator/Statics") - logger.info("Looking for .miz files in '" + os.getcwd()) - dest_point = self.conflict_zones["ALPHA"].position - grps = RotorOpsUtils.extractUnits.toPoint("test.miz", dest_point, 180) - for grp in grps: - self.m.country("Combined Joint Task Forces Blue").add_vehicle_group(grp) + # + # def addStatics(self): + # os.chdir(self.home_dir + "/Generator/Statics") + # logger.info("Looking for .miz files in '" + os.getcwd()) + # dest_point = self.conflict_zones["ALPHA"].position + # grps = RotorOpsUtils.extractUnits.toPoint("test.miz", dest_point, 180) + # for grp in grps: + # self.m.country(jtf_blue).add_vehicle_group(grp) def importObjects(self): os.chdir(self.imports_dir) logger.info("Looking for import .miz files in '" + os.getcwd()) - for group in self.m.country("Combined Joint Task Forces Blue").static_group: + for group in self.m.country(jtf_blue).static_group: prefix = "IMPORT-" if group.name.find(prefix) == 0: filename = group.name.removeprefix(prefix) + ".miz" i = RotorOpsUtils.ImportObjects(filename) i.anchorByGroupName("ANCHOR") - i.copyTo(self.m, group.units[0].position) - - + i.copyTo(self.m, group.units[0].name, group.units[0].position, group.units[0].heading) diff --git a/Generator/RotorOpsUtils.py b/Generator/RotorOpsUtils.py index 59f4902..ad1a6f2 100644 --- a/Generator/RotorOpsUtils.py +++ b/Generator/RotorOpsUtils.py @@ -22,105 +22,131 @@ def convertMeterToNM(meters=int): class ImportObjects: - def __init__(self, mizfile, ref_point=None, ref_heading=0): + def __init__(self, mizfile, source_point=None, source_heading=0): + logger.info("Importing objects from " + mizfile) self.source_mission = dcs.mission.Mission() self.source_mission.load_file(mizfile) - self.ref_heading = ref_heading - if ref_point: - self.ref_point = ref_point + self.source_heading = source_heading + if source_point: + self.source_point = source_point else: - self.ref_point = dcs.Point(self.source_mission.terrain.bullseye_blue["x"], self.source_mission.terrain.bullseye_blue["y"]) + self.source_point = dcs.Point(self.source_mission.terrain.bullseye_blue["x"], self.source_mission.terrain.bullseye_blue["y"]) def anchorByGroupName(self, group_name): group = self.source_mission.find_group(group_name) if group: - self.ref_point = group.units[0].position - self.ref_heading = group.units[0].heading + self.source_point = group.units[0].position + self.source_heading = group.units[0].heading else: logger.warning("Unable to find group for anchor.") - def copyTo(self, mission, dest_point=None, dest_heading=0): + def copyTo(self, mission, dest_name, dest_point=None, dest_heading=0): + logger.info("Copying objects as " + dest_name) if not dest_point: dest_point = dcs.Point(mission.terrain.bullseye_blue["x"], mission.terrain.bullseye_blue["y"]) - #iterate over group types first? for side in "red", "blue": coalition = self.source_mission.coalition.get(side) - for country in coalition.countries: + for country_name in coalition.countries: - group_types = [coalition.countries[country].static_group, coalition.countries[country].vehicle_group, coalition.countries[country].helicopter_group, coalition.countries[country].plane_group, - coalition.countries[country].ship_group] + group_types = [coalition.countries[country_name].static_group, coalition.countries[country_name].vehicle_group, coalition.countries[country_name].helicopter_group, coalition.countries[country_name].plane_group, + coalition.countries[country_name].ship_group] for index, group_type in enumerate(group_types): for group in group_type: - self.groupToPoint(group, self.ref_point, dest_point, self.ref_heading, dest_heading) - if index == 0: - mission.country(country).add_static_group(group) - elif index == 1: - mission.country(country).add_vehicle_group(group) - elif index == 2: - #mission.country(country).add_helicopter_group(group) - print("helicopter groups not available for import") + self.groupToPoint(group, self.source_point, dest_point, self.source_heading, dest_heading) + + + if index == 0: # Statics + type_name = group.units[0].type + type_maps = [dcs.statics.cargo_map, dcs.statics.warehouse_map, dcs.statics.groundobject_map, dcs.statics.fortification_map] + classed = False + for type_map in type_maps: + if type_name in type_map: + classed = True + unit_type = type_map[type_name] + ng = mission.static_group(mission.country(country_name), + group.name, + unit_type, + group.units[0].position, + group.units[0].heading, + hidden=False) + if not classed: + print("No pydcs class for " + type_name) + + + class temp(dcs.unittype.StaticType): + id = group.units[0].type + name = group.units[0].name + shape_name = group.units[0].shape_name + rate = group.units[0].rate + + + ng = mission.static_group(mission.country(country_name), + group.name, + temp, + group.units[0].position, + group.units[0].heading, + hidden=False) + + elif index == 1: # Vehicles + + for i, unit in enumerate(group.units): + if i == 0: + ng = mission.vehicle_group(mission.country(country_name), + group.name, + dcs.vehicles.vehicle_map[group.units[0].type], + group.units[0].position, + group.units[0].heading) + + + else: + + u = mission.vehicle(group.units[i].name, dcs.vehicles.vehicle_map[group.units[i].type]) + u.position = group.units[i].position + u.heading = group.units[i].heading + ng.add_unit(u) + + mission.country(country_name).add_vehicle_group(ng) + + + elif index == 2: # Helicopters + + if group.units[0].skill == dcs.unit.Skill.Client or group.units[0].skill == dcs.unit.Skill.Player: + + farp = mission.farp(mission.country(country_name), dest_name + " " + group.name + " Pad", group.units[0].position, hidden=True, dead=False, + farp_type=dcs.unit.InvisibleFARP) + + ng = mission.flight_group_from_unit(mission.country(country_name), + dest_name + " " + group.name, + dcs.helicopters.helicopter_map[group.units[0].type], + farp, + group_size=1) + + ng.points[0].action = dcs.point.PointAction.FromGroundArea + ng.points[0].type = "TakeOffGround" + ng.units[0].heading = group.units[0].heading + ng.units[0].skill = group.units[0].skill + ng.units[0].livery_id = group.units[0].livery_id + ng.units[0].pylons = group.units[0].pylons + elif index == 3: #mission.country(country).add_plane_group(group) - print("plane groups not available for import") + print("not yet avail") elif index == 4: - mission.country(country).add_ship_group(group) - - + #mission.country(country).add_ship_group(group) + print("not yet avail") @staticmethod - def groupToPoint(group, ref_point, dest_point, ref_heading=0, dest_heading=0): + def groupToPoint(group, src_point, dest_point, src_heading=0, dest_heading=0): for unit in group.units: - heading_to_unit = dcs.mapping.heading_between_points(ref_point.x, ref_point.y, unit.position.x, + heading_to_unit = dcs.mapping.heading_between_points(src_point.x, src_point.y, unit.position.x, unit.position.y) new_heading_to_unit = dest_heading + heading_to_unit - unit_distance = ref_point.distance_to_point(unit.position) + unit_distance = src_point.distance_to_point(unit.position) unit.position = dest_point.point_from_heading(new_heading_to_unit, unit_distance) - return group - - - -# class extractUnits: -# -# @staticmethod -# def toPoint(filename, group_type, dest_point, dest_heading=0, side="blue"): -# print("Attempting to extract units from " + filename + " relative to 'HELO_FARP' initial point.") -# -# source_mission = dcs.mission.Mission() -# source_mission.load_file(filename) -# -# -# # country = source_mission.country('Combined Joint Task Forces Blue') -# # country.find -# -# #group_types = [] -# -# groups = [] -# -# for country in source_mission.coalition.get(side).countries: -# -# ref_point = country.find_static_group("HELO_FARP").position #units position instead of group? -# ref_heading = country.find_static_group("HELO_FARP").heading -# group_types = [country.static_group, country.vehicle_group, country.helicopter_group, country.plane_group, country.ship_group] -# -# for group_type in group_types: -# for group in group_type: -# for unit in group.units: -# x_rel = ref_point.x - unit.position.x -# y_rel = ref_point.y - unit.position.y -# #heading_rel = ref_heading - unit.heading # heading of unit relative to heading of the reference object -# heading_to_unit = dcs.mapping.heading_between_points(ref_point.x, ref_point.y, unit.position.x, unit.position.y) -# new_heading_to_unit = dest_heading + heading_to_unit -# unit_distance = ref_point.distance_to_point(unit.position) -# unit.position = dest_point.point_from_heading(new_heading_to_unit, unit_distance) -# -# # unit.position.x = x - x_rel -# # unit.position.y = y - y_rel -# -# groups.append(group) -# return groups - + unit.heading = unit.heading + dest_heading + return group \ No newline at end of file diff --git a/MissionGenerator.exe b/MissionGenerator.exe index ac87405..522e2d8 100644 Binary files a/MissionGenerator.exe and b/MissionGenerator.exe differ diff --git a/RotorOps.lua b/RotorOps.lua index 07f9324..f76174c 100644 --- a/RotorOps.lua +++ b/RotorOps.lua @@ -1501,8 +1501,10 @@ end --- USEFUL PUBLIC 'LUA PREDICATE' FUNCTIONS FOR MISSION EDITOR TRIGGERS ---determine if any players have broken a defined ceiling above ground level -function RotorOps.predPlayerMaxAGL(max_agl, hide_display) +--determine if any players are above a defined ceiling above ground level. If 'above' parameter is false, function will return true if no players above ceiling +function RotorOps.predPlayerMaxAGL(max_agl, above) + local players_above_ceiling = 0 + for uName, uData in pairs(mist.DBs.humansByName) do local player_unit = Unit.getByName(uData.unitName) if player_unit then @@ -1510,16 +1512,17 @@ function RotorOps.predPlayerMaxAGL(max_agl, hide_display) local terrain_height = land.getHeight({x = player_pos.x, y = player_pos.z}) local player_agl = player_pos.y - terrain_height if player_agl > max_agl then - env.info(uData.unitName.." broke the AGL limit of "..max_agl) - if not hide_display then - trigger.action.outText(uData.unitName.." is above the maximum altitude of "..max_agl.."m AGL.", 1, true) - end - return true - else - return false + players_above_ceiling = players_above_ceiling + 1 end end end + + if players_above_ceiling > 0 then + return above + else + return not above + end + end --determine if any players are in a zone (not currently working)