From 32f8d8d0b7105415fc4e9a615a882a732aef69d4 Mon Sep 17 00:00:00 2001 From: Raffson Date: Fri, 1 Mar 2024 23:06:46 +0100 Subject: [PATCH] New cheat option: manage REDFOR's TGOs --- changelog.md | 3 ++- game/settings/settings.py | 1 + .../groundobject/QGroundObjectBuyMenu.py | 9 ++++++--- .../windows/groundobject/QGroundObjectMenu.py | 18 ++++++++++++++---- qt_ui/windows/settings/QSettingsWindow.py | 14 ++++++++++++++ 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 11be3812..11716d44 100644 --- a/changelog.md +++ b/changelog.md @@ -41,7 +41,8 @@ * **[Config]** Preference setting to use custom Liberation payloads instead of prioritizing Retribution's default * **[Config]** Preference setting to configure the server-port on which Retribution's back-end will run * **[Options]** Made AI jettisoning empty fuel tanks optional (disabled by default) -* **[Options]** Add option (so it can be disabled when fixed in DCS) to force air-starts (except for the slots that work) at Nevatim due to https://forum.dcs.world/topic/335545-29-nevatim-ramp-starts-still-bugged/. +* **[Options]** Add option (so it can be disabled when fixed in DCS) to force air-starts (except for the slots that work) at Nevatim due to https://forum.dcs.world/topic/335545-29-nevatim-ramp-starts-still-bugged/ +* **[Cheat]** Add cheat option to manually manage REDFOR's TGOs ## Fixes * **[Mission Generation]** Anti-ship strikes should use "group attack" in their attack-task diff --git a/game/settings/settings.py b/game/settings/settings.py index 5089ce2d..3c48a20a 100644 --- a/game/settings/settings.py +++ b/game/settings/settings.py @@ -998,6 +998,7 @@ class Settings: enable_transfer_cheat: bool = False enable_runway_state_cheat: bool = False enable_air_wing_adjustments: bool = False + enable_enemy_buy_sell: bool = False # LUA Plugins system plugins: Dict[str, bool] = field(default_factory=dict) diff --git a/qt_ui/windows/groundobject/QGroundObjectBuyMenu.py b/qt_ui/windows/groundobject/QGroundObjectBuyMenu.py index 5b641695..6a97e804 100644 --- a/qt_ui/windows/groundobject/QGroundObjectBuyMenu.py +++ b/qt_ui/windows/groundobject/QGroundObjectBuyMenu.py @@ -188,7 +188,8 @@ class QGroundObjectTemplateLayout(QGroupBox): @property def affordable(self) -> bool: - return self.cost <= self.game.blue.budget + coalition = self.ground_object.coalition + return self.cost <= coalition.budget def add_theater_group( self, group_name: str, force_group: ForceGroup, groups: list[TgoLayoutUnitGroup] @@ -226,7 +227,8 @@ class QGroundObjectTemplateLayout(QGroupBox): self.game.theater.heading_to_conflict_from(self.ground_object.position) or self.ground_object.heading ) - self.game.blue.budget -= self.cost + coalition = self.ground_object.coalition + coalition.budget -= self.cost self.ground_object.groups = [] for group_name, groups in self.layout_model.groups.items(): for group in groups: @@ -282,7 +284,8 @@ class QGroundObjectBuyMenu(QDialog): if not tasks: tasks = role.tasks - for group in game.blue.armed_forces.groups_for_tasks(tasks): + coalition = ground_object.coalition + for group in coalition.armed_forces.groups_for_tasks(tasks): self.force_group_selector.addItem(group.name, userData=group) self.force_group_selector.setEnabled(self.force_group_selector.count() > 1) self.force_group_selector.adjustSize() diff --git a/qt_ui/windows/groundobject/QGroundObjectMenu.py b/qt_ui/windows/groundobject/QGroundObjectMenu.py index 6ce4e8df..0b15182d 100644 --- a/qt_ui/windows/groundobject/QGroundObjectMenu.py +++ b/qt_ui/windows/groundobject/QGroundObjectMenu.py @@ -109,10 +109,16 @@ class QGroundObjectMenu(QDialog): self.actionLayout.addWidget(self.sell_all_button) self.actionLayout.addWidget(self.buy_replace) - if self.cp.captured and self.ground_object.purchasable: + if self.show_buy_sell_actions and self.ground_object.purchasable: self.mainLayout.addLayout(self.actionLayout) self.setLayout(self.mainLayout) + @property + def show_buy_sell_actions(self) -> bool: + buysell_allowed = self.game.settings.enable_enemy_buy_sell + buysell_allowed |= self.cp.captured + return buysell_allowed + def doLayout(self): self.update_total_value() self.intelBox = QGroupBox("Units :") @@ -240,7 +246,7 @@ class QGroundObjectMenu(QDialog): self.actionLayout.addWidget(self.sell_all_button) self.actionLayout.addWidget(self.buy_replace) - if self.cp.captured and self.ground_object.purchasable: + if self.show_buy_sell_actions and self.ground_object.purchasable: self.mainLayout.addLayout(self.actionLayout) except Exception as e: logging.exception(e) @@ -276,7 +282,8 @@ class QGroundObjectMenu(QDialog): def sell_all(self): self.update_total_value() - self.game.blue.budget += self.total_value + coalition = self.ground_object.coalition + coalition.budget += self.total_value self.ground_object.groups = [] self.update_game() @@ -296,7 +303,10 @@ class QGroundObjectMenu(QDialog): for package in self.game.ato_for(player=False).packages ): # Replan if the tgo was a target of the redfor - self.game.initialize_turn(events, for_red=True, for_blue=False) + coalition = self.ground_object.coalition + self.game.initialize_turn( + events, for_red=coalition.player, for_blue=not coalition.player + ) EventStream.put_nowait(events) GameUpdateSignal.get_instance().updateGame(self.game) # Refresh the dialog diff --git a/qt_ui/windows/settings/QSettingsWindow.py b/qt_ui/windows/settings/QSettingsWindow.py index 72d5009d..2766fd3b 100644 --- a/qt_ui/windows/settings/QSettingsWindow.py +++ b/qt_ui/windows/settings/QSettingsWindow.py @@ -113,6 +113,15 @@ class CheatSettingsBox(QGroupBox): ) self.main_layout.addLayout(self.air_wing_cheat) + # Buy/Sell actions for REDFOR + self.redfor_buysell_checkbox = QCheckBox() + self.redfor_buysell_checkbox.setChecked(sc.settings.enable_enemy_buy_sell) + self.redfor_buysell_checkbox.toggled.connect(apply_settings) + self.redfor_buysell_cheat = QLabeledWidget( + "Enable REDFOR Buy/Sell actions Cheat:", self.redfor_buysell_checkbox + ) + self.main_layout.addLayout(self.redfor_buysell_cheat) + @property def show_red_ato(self) -> bool: return self.red_ato_checkbox.isChecked() @@ -137,6 +146,10 @@ class CheatSettingsBox(QGroupBox): def enable_air_wing_cheats(self) -> bool: return self.air_wing_adjustments_checkbox.isChecked() + @property + def enable_redfor_buysell(self) -> bool: + return self.redfor_buysell_checkbox.isChecked() + class AutoSettingsLayout(QGridLayout): def __init__( @@ -495,6 +508,7 @@ class QSettingsWidget(QtWidgets.QWizardPage, SettingsContainer): self.settings.enable_air_wing_adjustments = ( self.cheat_options.enable_air_wing_cheats ) + self.settings.enable_enemy_buy_sell = self.cheat_options.enable_redfor_buysell if self.game: events = GameUpdateEvents()