From 6dc529613065d71d7042e197704f67818c5c5e85 Mon Sep 17 00:00:00 2001 From: Raffson Date: Sun, 30 Jun 2024 01:41:09 +0200 Subject: [PATCH] Disband squadrons sinking with ship + Sink/Resurrect cheat --- changelog.md | 2 ++ game/theater/theatergroundobject.py | 8 ++++++++ game/theater/theatergroup.py | 12 ++++++++++++ qt_ui/windows/basemenu/QBaseMenu2.py | 23 ++++++++++++++++++----- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 9e34c673..f9677e31 100644 --- a/changelog.md +++ b/changelog.md @@ -18,12 +18,14 @@ * **[Campaign Design]** Support for Kola map by Orbx * **[UI]** Zoom level retained when switching campaigns * **[UX]** Allow changing squadrons in flight's edit dialog +* **[Cheats]** Sink/Resurrect carriers instead of showing an error during cheat-capture (use AWCD-cheat to add squadrons upon resurrection) ## Fixes * **[UI/UX]** A-10A flights can be edited again * **[Mission Generation]** IADS bug sometimes triggering "no skynet usable units" error during mission generation * **[New Game Wizard]** Campaign errors show a dialog again and avoid CTDs * **[UI]** Landmap wasn't updating when switching to a different theater +* **[Mission Results Processor]** Squadrons of a sunken carrier are now disbanded # Retribution v1.3.1 #### Note: Re-save your missions in DCS' Mission Editor to avoid possible crashes due to datalink (usually the case when F-16C blk50s are used) when hosting missions on a dedicated server. diff --git a/game/theater/theatergroundobject.py b/game/theater/theatergroundobject.py index 70467c34..2f8d3bbf 100644 --- a/game/theater/theatergroundobject.py +++ b/game/theater/theatergroundobject.py @@ -283,6 +283,10 @@ class TheaterGroundObject(MissionTarget, SidcDescribable, ABC): def coalition(self) -> Coalition: return self.control_point.coalition + @property + def is_naval_control_point(self) -> bool: + return False + class BuildingGroundObject(TheaterGroundObject): def __init__( @@ -384,6 +388,10 @@ class GenericCarrierGroundObject(NavalGroundObject, ABC): def is_control_point(self) -> bool: return True + @property + def is_naval_control_point(self) -> bool: + return True + # TODO: Why is this both a CP and a TGO? class CarrierGroundObject(GenericCarrierGroundObject): diff --git a/game/theater/theatergroup.py b/game/theater/theatergroup.py index 2965f146..206112d3 100644 --- a/game/theater/theatergroup.py +++ b/game/theater/theatergroup.py @@ -66,6 +66,18 @@ class TheaterUnit: if self.ground_object.is_iads: iads = self.ground_object.control_point.coalition.game.theater.iads_network iads.update_tgo(self.ground_object, events) + if self.ground_object.is_naval_control_point: + cp = self.ground_object.control_point + for squadron in cp.squadrons: + cp.coalition.air_wing.squadrons[squadron.aircraft].remove(squadron) + + def revive(self, events: GameUpdateEvents) -> None: + self.alive = True + self.ground_object.threat_poly() + events.update_tgo(self.ground_object) + if self.ground_object.is_iads: + iads = self.ground_object.control_point.coalition.game.theater.iads_network + iads.update_tgo(self.ground_object, events) @property def unit_name(self) -> str: diff --git a/qt_ui/windows/basemenu/QBaseMenu2.py b/qt_ui/windows/basemenu/QBaseMenu2.py index da4dea79..1e2ad458 100644 --- a/qt_ui/windows/basemenu/QBaseMenu2.py +++ b/qt_ui/windows/basemenu/QBaseMenu2.py @@ -159,7 +159,8 @@ class QBaseMenu2(QDialog): transfer_button.clicked.connect(self.open_transfer_dialog) if self.cheat_capturable: - capture_button = QPushButton("CHEAT: Capture") + label = "Sink/Resurrect" if self.cp.is_fleet else "Capture" + capture_button = QPushButton(f"CHEAT: {label}") capture_button.setProperty("style", "btn-danger") bottom_row.addWidget(capture_button) capture_button.clicked.connect(self.cheat_capture) @@ -181,11 +182,23 @@ class QBaseMenu2(QDialog): def cheat_capture(self) -> None: events = GameUpdateEvents() - self.cp.capture(self.game_model.game, events, for_player=not self.cp.captured) - mrp = MissionResultsProcessor(self.game_model.game) - mrp.redeploy_units(self.cp) + if self.cp.is_fleet: + for go in self.cp.ground_objects: + if go.is_naval_control_point: + if go.alive_unit_count > 0: + for u in go.units: + u.kill(events) + else: + for u in go.units: + u.revive(events) + else: + self.cp.capture( + self.game_model.game, events, for_player=not self.cp.captured + ) + mrp = MissionResultsProcessor(self.game_model.game) + mrp.redeploy_units(self.cp) # Reinitialized ground planners and the like. The ATO needs to be reset because - # missions planned against the flipped base are no longer valid. + # missions planned against the flipped base (or killed carrier) are no longer valid. self.game_model.game.initialize_turn(events) EventStream.put_nowait(events) GameUpdateSignal.get_instance().updateGame(self.game_model.game)