mirror of
https://github.com/spencershepard/RotorOps.git
synced 2025-11-10 15:45:30 +00:00
added imports feature
adds an import feature for getting complex unit arrangements from miz files
This commit is contained in:
@@ -6,11 +6,11 @@ import random
|
||||
|
||||
import RotorOpsGroups
|
||||
import RotorOpsUnits
|
||||
import RotorOpsUtils
|
||||
import time
|
||||
from MissionGenerator import logger
|
||||
|
||||
|
||||
|
||||
class RotorOpsMission:
|
||||
|
||||
def __init__(self):
|
||||
@@ -23,6 +23,7 @@ class RotorOpsMission:
|
||||
self.sound_directory = self.home_dir + "\sound\embedded"
|
||||
self.output_dir = self.home_dir + "\Generator\Output"
|
||||
self.assets_dir = self.home_dir + "\Generator/assets"
|
||||
self.imports_dir = self.home_dir + "\Generator\Imports"
|
||||
|
||||
self.conflict_zones = {}
|
||||
self.staging_zones = {}
|
||||
@@ -119,6 +120,8 @@ class RotorOpsMission:
|
||||
|
||||
self.m.load_file(options["scenario_filename"])
|
||||
|
||||
self.importObjects()
|
||||
|
||||
if not self.m.country("Combined Joint Task Forces Red") or not self.m.country("Combined Joint Task Forces 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}
|
||||
@@ -134,7 +137,6 @@ class RotorOpsMission:
|
||||
self.m.add_picture_blue(self.assets_dir + '/briefing2.png')
|
||||
|
||||
|
||||
|
||||
# add zones to target mission
|
||||
zone_names = ["ALPHA", "BRAVO", "CHARLIE", "DELTA"]
|
||||
zone_flag = 101
|
||||
@@ -235,6 +237,9 @@ class RotorOpsMission:
|
||||
self.addResources(self.sound_directory, self.script_directory)
|
||||
self.scriptTriggerSetup(options)
|
||||
|
||||
# test adding static objects from a .miz
|
||||
#self.addStatics()
|
||||
|
||||
#Save the mission file
|
||||
os.chdir(self.output_dir)
|
||||
output_filename = options["scenario_filename"].removesuffix('.miz') + " " + time.strftime('%a%H%M%S') + '.miz'
|
||||
@@ -631,7 +636,7 @@ class RotorOpsMission:
|
||||
else:
|
||||
return
|
||||
|
||||
if source_helo:
|
||||
if source_helo and afg:
|
||||
for unit in afg.units:
|
||||
unit.pylons = source_helo.pylons
|
||||
unit.livery_id = source_helo.livery_id
|
||||
@@ -661,10 +666,10 @@ class RotorOpsMission:
|
||||
group_size=group_size)
|
||||
zone_attack(afg, airport)
|
||||
|
||||
if source_plane:
|
||||
for unit in afg.units:
|
||||
unit.pylons = source_plane.pylons
|
||||
unit.livery_id = source_plane.livery_id
|
||||
if source_plane:
|
||||
for unit in afg.units:
|
||||
unit.pylons = source_plane.pylons
|
||||
unit.livery_id = source_plane.livery_id
|
||||
|
||||
if options["e_transport_helos"]:
|
||||
source_helo = None
|
||||
@@ -690,10 +695,10 @@ class RotorOpsMission:
|
||||
afg.late_activation = True
|
||||
afg.units[0].skill = dcs.unit.Skill.Excellent
|
||||
|
||||
if source_helo:
|
||||
for unit in afg.units:
|
||||
unit.pylons = source_helo.pylons
|
||||
unit.livery_id = source_helo.livery_id
|
||||
if source_helo:
|
||||
for unit in afg.units:
|
||||
unit.pylons = source_helo.pylons
|
||||
unit.livery_id = source_helo.livery_id
|
||||
|
||||
def scriptTriggerSetup(self, options):
|
||||
|
||||
@@ -841,3 +846,23 @@ class RotorOpsMission:
|
||||
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 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:
|
||||
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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user