mirror of
https://github.com/spencershepard/RotorOps.git
synced 2025-11-10 15:45:30 +00:00
bypassing triggers and merging before save
This commit is contained in:
parent
8ffaab1e6a
commit
4a06a8ce56
@ -132,7 +132,22 @@ class RotorOpsMission:
|
||||
|
||||
window.statusBar().showMessage("Loading scenario mission", 10000)
|
||||
|
||||
self.m.load_file(options["scenario_file"])
|
||||
# self.m.load_file(options["scenario_file"])
|
||||
|
||||
# Bypass trig, triggrules, and triggers. Then load triggers
|
||||
# manually. We want to get our zones from the template mission, but leave the existing trigger actions and
|
||||
# conditions the same, since pydcs cannot yet handle some of them well.
|
||||
|
||||
self.m.load_file(options["scenario_file"], True)
|
||||
self.m.triggers.load_from_dict(self.m.bypassed_triggers)
|
||||
|
||||
# Create some 'empty' triggerrules so that we can maintain indexing when we merge dictionaries on save
|
||||
for rule in self.m.bypassed_trigrules:
|
||||
trig = dcs.triggers.TriggerOnce(comment="Empty " + str(rule))
|
||||
trig.rules.append(dcs.condition.TimeAfter(1))
|
||||
trig.actions.append(dcs.action.DoScript(dcs.action.String("Filler " + str(rule))))
|
||||
self.m.triggerrules.triggers.append(trig)
|
||||
|
||||
# Add countries if they're missing
|
||||
if not self.m.country(jtf_red):
|
||||
self.m.coalition.get("red").add_country(dcs.countries.CombinedJointTaskForcesRed())
|
||||
@ -496,6 +511,16 @@ class RotorOpsMission:
|
||||
output_dir = directories.output # default dir
|
||||
os.chdir(output_dir)
|
||||
output_filename = options["scenario_name"] + " " + time.strftime('%a%H%M%S') + '.miz'
|
||||
|
||||
# dcs.mission.save will use the bypassed trig, trigrules, and triggers. Our goal is to leave the trigrules and
|
||||
# trig from the source mission untouched. See comments in self.m.load_file above
|
||||
|
||||
#merge dictionaries
|
||||
self.m.bypassed_trig = self.m.triggerrules.trig() | self.m.bypassed_trig
|
||||
self.m.bypassed_trigrules = self.m.triggerrules.trigrules() | self.m.bypassed_trigrules
|
||||
|
||||
self.m.bypassed_triggers = self.m.triggers.dict()
|
||||
|
||||
success = self.m.save(output_filename)
|
||||
return {"success": success, "filename": output_filename, "directory": output_dir} # let the UI know the result
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ RotorOps.pickup_zone_smoke = "blue"
|
||||
RotorOps.ai_task_by_name = true --allow tasking all groups that include key strings in their group names eg 'Patrol'
|
||||
RotorOps.ai_task_by_name_scheduler = true --continually search active groups for key strings and ai tasking
|
||||
RotorOps.patrol_task_string = 'patrol' --default string to search group names for the patrol task. requires ai_task_by_name
|
||||
RotorOps.aggressive_task_string = 'aggressive' --default string to search group names for the patrol task. requires ai_task_by_name
|
||||
RotorOps.aggressive_task_string = 'aggressive' --default string to search group names for the aggressive task. requires ai_task_by_name
|
||||
RotorOps.move_to_active_task_string = "activezone" --default string to search group names for the move to active zone task. requires ai_task_by_name
|
||||
RotorOps.shift_task_string = "shift"
|
||||
RotorOps.guard_task_string = "guard"
|
||||
@ -897,13 +897,12 @@ function RotorOps.guardPosition(vars)
|
||||
start_point = first_valid_unit:getPoint()
|
||||
end
|
||||
local object_vol_thresh = 0
|
||||
local max_waypoints = 1
|
||||
local foundUnits = {}
|
||||
|
||||
local volS = {
|
||||
id = world.VolumeType.SPHERE,
|
||||
params = {
|
||||
point = grp:getUnit(1):getPoint(), --check if exists, maybe itterate through grp
|
||||
point = start_point,
|
||||
radius = search_radius
|
||||
}
|
||||
}
|
||||
@ -927,9 +926,10 @@ function RotorOps.guardPosition(vars)
|
||||
--world.searchObjects(Object.Category.BASE, volS, ifFound)
|
||||
if #foundUnits > 0 then
|
||||
local path = {}
|
||||
path[1] = mist.ground.buildWP(start_point, '', 5)
|
||||
--path[1] = mist.ground.buildWP(RotorOps.getValidUnitFromGroup(grp):getPoint(), '', 2)
|
||||
path[1] = mist.ground.buildWP(RotorOps.getValidUnitFromGroup(grp):getPoint(), '', 2)
|
||||
local rand_index = math.random(1,#foundUnits)
|
||||
path[#path + 1] = mist.ground.buildWP(foundUnits[rand_index]:getPoint(), '', 3)
|
||||
path[#path + 1] = mist.ground.buildWP(foundUnits[rand_index]:getPoint(), '', 2)
|
||||
mist.goRoute(grp, path)
|
||||
end
|
||||
end
|
||||
@ -1742,7 +1742,7 @@ function RotorOps.taskByName()
|
||||
end
|
||||
end
|
||||
if RotorOps.ai_task_by_name_scheduler then
|
||||
local timer_id = timer.scheduleFunction(RotorOps.taskByName, nil, timer.getTime() + 120)
|
||||
local timer_id = timer.scheduleFunction(RotorOps.taskByName, nil, timer.getTime() + 500)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user