From 056c397e6862f324405fd45520c0209ba54f6c78 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sat, 11 Aug 2018 12:31:09 +0200 Subject: [PATCH 1/6] [Cherry Picked] Added possibility to add 'DCS: Combined Arms' slots to the generated mission. --- game/event/event.py | 2 ++ game/operation/operation.py | 7 ++++++- gen/armor.py | 3 +++ ui/eventmenu.py | 23 ++++++++++++++++++++--- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/game/event/event.py b/game/event/event.py index 6a8885be..7b9400c1 100644 --- a/game/event/event.py +++ b/game/event/event.py @@ -21,6 +21,7 @@ class Event: silent = False informational = False is_awacs_enabled = False + ca_slots = 0 operation = None # type: Operation difficulty = 1 # type: int game = None # type: Game @@ -74,6 +75,7 @@ class Event: def generate(self): self.operation.is_awacs_enabled = self.is_awacs_enabled + self.operation.ca_slots = self.ca_slots self.operation.prepare(self.game.theater.terrain, is_quick=False) self.operation.generate() diff --git a/game/operation/operation.py b/game/operation/operation.py index 171f97cd..5e873738 100644 --- a/game/operation/operation.py +++ b/game/operation/operation.py @@ -27,6 +27,7 @@ class Operation: trigger_radius = TRIGGER_RADIUS_MEDIUM is_quick = None is_awacs_enabled = False + ca_slots = 0 def __init__(self, game, @@ -50,7 +51,6 @@ class Operation: def initialize(self, mission: Mission, conflict: Conflict): self.mission = mission self.conflict = conflict - self.armorgen = ArmorConflictGenerator(mission, conflict) self.airgen = AircraftConflictGenerator(mission, conflict, self.game.settings) self.aagen = AAConflictGenerator(mission, conflict) @@ -90,6 +90,11 @@ class Operation: if self.is_awacs_enabled: self.briefinggen.append_frequency("AWACS", "133 MHz AM") + # combined arms + self.mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0 + self.mission.groundControl.blue_tactical_commander = self.ca_slots + self.mission.groundControl.red_tactical_commander = self.ca_slots + # ground infrastructure self.groundobjectgen.generate() self.extra_aagen.generate() diff --git a/gen/armor.py b/gen/armor.py index 876fa13c..a64cba4b 100644 --- a/gen/armor.py +++ b/gen/armor.py @@ -45,6 +45,9 @@ class ArmorConflictGenerator: group_size=1, move_formation=PointAction.OffRoad) + vehicle: Vehicle = group.units[0] + vehicle.player_can_drive = True + if not to: to = self.conflict.position.point_from_heading(0, 500) diff --git a/ui/eventmenu.py b/ui/eventmenu.py index db76176f..e0656994 100644 --- a/ui/eventmenu.py +++ b/ui/eventmenu.py @@ -9,7 +9,7 @@ from .styles import STYLES, RED class EventMenu(Menu): scramble_entries = None # type: typing.Dict[typing.Type[Task], typing.Dict[typing.Type[UnitType], typing.Tuple[Entry, Entry]]] - + ca_slot_entry = None error_label = None # type: Label awacs = None # type: IntVar @@ -100,8 +100,15 @@ class EventMenu(Menu): header("Support:") # Options awacs_enabled = self.game.budget >= AWACS_BUDGET_COST and NORMAL or DISABLED - Checkbutton(self.frame, var=self.awacs, state=awacs_enabled, **STYLES["radiobutton"]).grid(row=row, column=0, sticky=E) - Label(self.frame, text="AWACS ({}m)".format(AWACS_BUDGET_COST), **STYLES["widget"]).grid(row=row, column=3, sticky=W, padx=5, pady=5) + Label(self.frame, text="AWACS ({}m)".format(AWACS_BUDGET_COST), **STYLES["widget"]).grid(row=row, column=0, sticky=W) + Checkbutton(self.frame, var=self.awacs, state=awacs_enabled, **STYLES["radiobutton"]).grid(row=row, column=3, sticky=E) + row += 1 + + Label(self.frame, text="Combined Arms Slots", **STYLES["widget"]).grid(row=row, sticky=W) + self.ca_slot_entry = Entry(self.frame, width=2) + self.ca_slot_entry.insert(0, "0") + self.ca_slot_entry.grid(column=2, row=row, sticky=E, padx=5) + Button(self.frame, text="+", command=self.add_ca_slot, **STYLES["btn-primary"]).grid(column=3, row=row, padx=15) row += 1 header("Ready?") @@ -124,6 +131,12 @@ class EventMenu(Menu): return action + def add_ca_slot(self): + value = self.ca_slot_entry.get() + amount = int(value and value or "0") + self.ca_slot_entry.delete(0, END) + self.ca_slot_entry.insert(0, str(amount+1)) + def client_one(self, task: typing.Type[Task], unit_type: UnitType) -> typing.Callable: def action(): entry = self.scramble_entries[task][unit_type][1] # type: Entry @@ -140,6 +153,10 @@ class EventMenu(Menu): else: self.event.is_awacs_enabled = False + ca_slot_entry_value = self.ca_slot_entry.get() + ca_slots = int(ca_slot_entry_value and ca_slot_entry_value or "0") + self.event.ca_slots = ca_slots + flights = {k: {} for k in self.event.tasks} # type: db.TaskForceDict units_scramble_counts = {} # type: typing.Dict[typing.Type[UnitType], int] tasks_scramble_counts = {} # type: typing.Dict[typing.Type[Task], int] From c699567c7315df7bd987092cfa2061f5881348a4 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sat, 22 Sep 2018 13:33:31 +0200 Subject: [PATCH 2/6] Only generate Combined Arms "Tactical Commander" slots for player side. --- game/operation/operation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/game/operation/operation.py b/game/operation/operation.py index 5e873738..0e823f07 100644 --- a/game/operation/operation.py +++ b/game/operation/operation.py @@ -92,8 +92,10 @@ class Operation: # combined arms self.mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0 - self.mission.groundControl.blue_tactical_commander = self.ca_slots - self.mission.groundControl.red_tactical_commander = self.ca_slots + if self.game.player == "USA": + self.mission.groundControl.blue_tactical_commander = self.ca_slots + else: + self.mission.groundControl.red_tactical_commander = self.ca_slots # ground infrastructure self.groundobjectgen.generate() From 3500c85e8d514e948b005706cdbc0405ef99f456 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sat, 22 Sep 2018 13:42:51 +0200 Subject: [PATCH 3/6] UI for CA slot selection (align with unit count rows) --- ui/eventmenu.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/eventmenu.py b/ui/eventmenu.py index e0656994..e97b84be 100644 --- a/ui/eventmenu.py +++ b/ui/eventmenu.py @@ -100,15 +100,15 @@ class EventMenu(Menu): header("Support:") # Options awacs_enabled = self.game.budget >= AWACS_BUDGET_COST and NORMAL or DISABLED - Label(self.frame, text="AWACS ({}m)".format(AWACS_BUDGET_COST), **STYLES["widget"]).grid(row=row, column=0, sticky=W) - Checkbutton(self.frame, var=self.awacs, state=awacs_enabled, **STYLES["radiobutton"]).grid(row=row, column=3, sticky=E) + Checkbutton(self.frame, var=self.awacs, state=awacs_enabled, **STYLES["radiobutton"]).grid(row=row, column=2, sticky=E) + Label(self.frame, text="AWACS ({}m)".format(AWACS_BUDGET_COST), **STYLES["widget"]).grid(row=row, column=0, sticky=W, pady=5) row += 1 Label(self.frame, text="Combined Arms Slots", **STYLES["widget"]).grid(row=row, sticky=W) self.ca_slot_entry = Entry(self.frame, width=2) self.ca_slot_entry.insert(0, "0") - self.ca_slot_entry.grid(column=2, row=row, sticky=E, padx=5) - Button(self.frame, text="+", command=self.add_ca_slot, **STYLES["btn-primary"]).grid(column=3, row=row, padx=15) + self.ca_slot_entry.grid(column=1, row=row, sticky=W, padx=5) + Button(self.frame, text="+", command=self.add_ca_slot, **STYLES["btn-primary"]).grid(column=2, row=row, padx=5, sticky=W) row += 1 header("Ready?") From 8cb7c7378f77208373314f5ef04a1b60f298fb73 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sat, 29 Sep 2018 11:34:22 +0200 Subject: [PATCH 4/6] Type for ca_slot_entry --- ui/eventmenu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/eventmenu.py b/ui/eventmenu.py index e97b84be..82ad891e 100644 --- a/ui/eventmenu.py +++ b/ui/eventmenu.py @@ -9,7 +9,7 @@ from .styles import STYLES, RED class EventMenu(Menu): scramble_entries = None # type: typing.Dict[typing.Type[Task], typing.Dict[typing.Type[UnitType], typing.Tuple[Entry, Entry]]] - ca_slot_entry = None + ca_slot_entry = None # type: Entry error_label = None # type: Label awacs = None # type: IntVar From 93d0746d3e146e9fcf7ec54f8fc0365ef1ecccb5 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sat, 29 Sep 2018 11:46:15 +0200 Subject: [PATCH 5/6] Replaced with player faction check by coalition check --- game/operation/operation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/operation/operation.py b/game/operation/operation.py index 0e823f07..06384a79 100644 --- a/game/operation/operation.py +++ b/game/operation/operation.py @@ -92,7 +92,7 @@ class Operation: # combined arms self.mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0 - if self.game.player == "USA": + if self.game.player in [country.name for country in self.mission.coalition["blue"].countries.values()]: self.mission.groundControl.blue_tactical_commander = self.ca_slots else: self.mission.groundControl.red_tactical_commander = self.ca_slots From 2cbe63f1628fdd721eed9132525c7492e9503aaf Mon Sep 17 00:00:00 2001 From: Khopa Date: Sat, 29 Sep 2018 11:55:42 +0200 Subject: [PATCH 6/6] Fixed potential exception in start if user enter invalid value inside the combined arms slots entry. --- ui/eventmenu.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/eventmenu.py b/ui/eventmenu.py index 82ad891e..80eacf91 100644 --- a/ui/eventmenu.py +++ b/ui/eventmenu.py @@ -154,7 +154,10 @@ class EventMenu(Menu): self.event.is_awacs_enabled = False ca_slot_entry_value = self.ca_slot_entry.get() - ca_slots = int(ca_slot_entry_value and ca_slot_entry_value or "0") + try: + ca_slots = int(ca_slot_entry_value and ca_slot_entry_value or "0") + except: + ca_slots = 0 self.event.ca_slots = ca_slots flights = {k: {} for k in self.event.tasks} # type: db.TaskForceDict