From 8a73455dab69864f4e7c26e7f156faa02a58d9b6 Mon Sep 17 00:00:00 2001 From: dyceron Date: Fri, 26 Jul 2024 20:43:25 -0400 Subject: [PATCH 1/2] Add support for custom damage reduction per suit --- src/open_samus_returns_rando/files/schema.json | 15 +++++++++++++++ .../samus_returns_patcher.py | 5 +++-- .../specific_patches/tunable_patches.py | 13 +++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/open_samus_returns_rando/files/schema.json b/src/open_samus_returns_rando/files/schema.json index 8cc002e..348075e 100644 --- a/src/open_samus_returns_rando/files/schema.json +++ b/src/open_samus_returns_rando/files/schema.json @@ -255,6 +255,21 @@ }, "default": {} }, + "suit_reductions": { + "description": "Set the damage reduction per suit.", + "type": "object", + "properties": { + "varia_suit_reduction": { + "type": "number", + "default": 0.75 + }, + "gravity_suit_reduction": { + "type": "number", + "default": 0.5 + } + }, + "default": {} + }, "reveal_map_on_start": { "type": "boolean", "default": false, diff --git a/src/open_samus_returns_rando/samus_returns_patcher.py b/src/open_samus_returns_rando/samus_returns_patcher.py index 313b4dc..63b1b6d 100644 --- a/src/open_samus_returns_rando/samus_returns_patcher.py +++ b/src/open_samus_returns_rando/samus_returns_patcher.py @@ -19,7 +19,7 @@ from open_samus_returns_rando.patcher_editor import PatcherEditor from open_samus_returns_rando.pickups.custom_pickups import patch_custom_pickups from open_samus_returns_rando.pickups.pickup import patch_pickups -from open_samus_returns_rando.specific_patches import cosmetic_patches, game_patches, tunable_patches +from open_samus_returns_rando.specific_patches import cosmetic_patches, game_patches from open_samus_returns_rando.specific_patches.chozo_seal_patches import patch_chozo_seals from open_samus_returns_rando.specific_patches.door_patches import patch_doors from open_samus_returns_rando.specific_patches.environmental_damage import apply_constant_damage @@ -27,6 +27,7 @@ from open_samus_returns_rando.specific_patches.hint_patches import patch_hints from open_samus_returns_rando.specific_patches.metroid_patches import patch_metroids from open_samus_returns_rando.specific_patches.static_fixes import apply_static_fixes +from open_samus_returns_rando.specific_patches.tunable_patches import patch_tunables from open_samus_returns_rando.validator_with_default import DefaultValidatingDraft7Validator T = typing.TypeVar("T") @@ -102,7 +103,7 @@ def patch_extracted(input_path: Path, input_exheader: Path | None, output_path: patch_doors(editor, configuration["door_patches"], configuration["custom_doors"]) # Patch tunables - tunable_patches.patch_tunables(editor, configuration.get("reserves_per_tank", {})) + patch_tunables(editor, configuration) # Patch cosmetics cosmetic_patches.patch_cosmetics(editor, configuration.get("cosmetic_patches", {})) diff --git a/src/open_samus_returns_rando/specific_patches/tunable_patches.py b/src/open_samus_returns_rando/specific_patches/tunable_patches.py index 6a9551a..6c4db9b 100644 --- a/src/open_samus_returns_rando/specific_patches/tunable_patches.py +++ b/src/open_samus_returns_rando/specific_patches/tunable_patches.py @@ -5,13 +5,12 @@ def patch_tunables(editor: PatcherEditor, configuration: dict) -> None: tunables = editor.get_file("system/tunables/tunables.bmtun", Bmtun) _patch_scan_pulse(tunables) - _reserves_per_tank(tunables, configuration) + _reserves_per_tank(tunables, configuration.get("reserves_per_tank", {})) + _suit_reductions(tunables, configuration.get("suit_reductions", {})) def _patch_scan_pulse(tunables: Bmtun) -> None: - tunables.raw["classes"]["CTunableAbilityScanningPulse"]["tunables"][ - "fConsumptionOnActivation" - ]["value"] = 0.0 + tunables.raw["classes"]["CTunableAbilityScanningPulse"]["tunables"]["fConsumptionOnActivation"]["value"] = 0.0 def _reserves_per_tank(tunables: Bmtun, configuration: dict) -> None: @@ -20,3 +19,9 @@ def _reserves_per_tank(tunables: Bmtun, configuration: dict) -> None: amiibo["fSETankSize"]["value"] = configuration["aeion_tank_size"] amiibo["fMissileTankSize"]["value"] = configuration["missile_tank_size"] amiibo["fSuperMissileTankSize"]["value"] = configuration["super_missile_tank_size"] + + +def _suit_reductions(tunables: Bmtun, configuration: dict) -> None: + life = tunables.raw["classes"]["Player|CTunablePlayerLifeComponent"]["tunables"] + life["fVariaSuitDamageMult"]["value"] = configuration["varia_suit_reduction"] + life["fGravitySuitDamageMult"]["value"] = configuration["gravity_suit_reduction"] From fbe11d97742d0eb903fa1e1682db6de8bf5c3e45 Mon Sep 17 00:00:00 2001 From: dyceron Date: Sun, 28 Jul 2024 11:38:22 -0400 Subject: [PATCH 2/2] Simplify config calls --- .../specific_patches/tunable_patches.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/open_samus_returns_rando/specific_patches/tunable_patches.py b/src/open_samus_returns_rando/specific_patches/tunable_patches.py index 6c4db9b..f2df14f 100644 --- a/src/open_samus_returns_rando/specific_patches/tunable_patches.py +++ b/src/open_samus_returns_rando/specific_patches/tunable_patches.py @@ -5,8 +5,8 @@ def patch_tunables(editor: PatcherEditor, configuration: dict) -> None: tunables = editor.get_file("system/tunables/tunables.bmtun", Bmtun) _patch_scan_pulse(tunables) - _reserves_per_tank(tunables, configuration.get("reserves_per_tank", {})) - _suit_reductions(tunables, configuration.get("suit_reductions", {})) + _reserves_per_tank(tunables, configuration["reserves_per_tank"]) + _suit_reductions(tunables, configuration["suit_reductions"]) def _patch_scan_pulse(tunables: Bmtun) -> None: