From 5e10ea4135b6dd4c9dba069d3a593dd07a4524f0 Mon Sep 17 00:00:00 2001 From: dyceron Date: Wed, 14 Aug 2024 19:32:20 -0400 Subject: [PATCH 1/2] Support custom Baby size --- .../files/schema.json | 19 +++++++++++++++++++ .../misc_patches/actor_attributes.py | 11 +++++++++++ .../samus_returns_patcher.py | 4 ++++ 3 files changed, 34 insertions(+) create mode 100644 src/open_samus_returns_rando/misc_patches/actor_attributes.py diff --git a/src/open_samus_returns_rando/files/schema.json b/src/open_samus_returns_rando/files/schema.json index bf87e3d..3043c24 100644 --- a/src/open_samus_returns_rando/files/schema.json +++ b/src/open_samus_returns_rando/files/schema.json @@ -590,6 +590,25 @@ }, "default": {} }, + "actor_attributes": { + "description": "Modifications to actor attributes.", + "type": "object", + "properties": { + "babyhatchling": { + "properties": { + "size": { + "description": "Size of the Baby Metroid.", + "type": "number", + "minimum": 0.1, + "maximum": 10, + "default": 0.6600000262260437 + } + }, + "default": {} + } + }, + "default": {} + }, "configuration_identifier": { "type": "string", "description": "An unique identifier for this configuration. Only save files created with this identifier can be loaded." diff --git a/src/open_samus_returns_rando/misc_patches/actor_attributes.py b/src/open_samus_returns_rando/misc_patches/actor_attributes.py new file mode 100644 index 0000000..14870eb --- /dev/null +++ b/src/open_samus_returns_rando/misc_patches/actor_attributes.py @@ -0,0 +1,11 @@ +from mercury_engine_data_structures.formats import Bmsad +from open_samus_returns_rando.patcher_editor import PatcherEditor + + +def patch_actor_attributes(editor: PatcherEditor, configuration: dict) -> None: + _custom_baby_size(editor, configuration) + + +def _custom_baby_size(editor: PatcherEditor, configuration: dict) -> None: + baby = editor.get_file("actors/characters/babyhatchling/charclasses/babyhatchling.bmsad", Bmsad) + baby.raw["header"]["model_scale"] = configuration["babyhatchling"]["size"] diff --git a/src/open_samus_returns_rando/samus_returns_patcher.py b/src/open_samus_returns_rando/samus_returns_patcher.py index 09a7d00..1aaeadc 100644 --- a/src/open_samus_returns_rando/samus_returns_patcher.py +++ b/src/open_samus_returns_rando/samus_returns_patcher.py @@ -9,6 +9,7 @@ from open_samus_returns_rando.files import files_path from open_samus_returns_rando.logger import LOG from open_samus_returns_rando.lua_editor import LuaEditor +from open_samus_returns_rando.misc_patches.actor_attributes import patch_actor_attributes from open_samus_returns_rando.misc_patches.block_patches import patch_block_types from open_samus_returns_rando.misc_patches.collision_camera_table import create_collision_camera_table from open_samus_returns_rando.misc_patches.credits import patch_credits @@ -137,6 +138,9 @@ def patch_extracted(input_path: Path, input_exheader: Path | None, output_path: # Patch blocks to another type patch_block_types(editor, configuration) + # Patch actor attributes + patch_actor_attributes(editor, configuration["actor_attributes"]) + out_exefs = output_path.joinpath("exefs") out_romfs = output_path.joinpath("romfs") out_code = output_path.joinpath("code.bps") From 6b26616ba48c2c829c502c188e40a21fa4186976 Mon Sep 17 00:00:00 2001 From: dyceron Date: Wed, 14 Aug 2024 19:55:19 -0400 Subject: [PATCH 2/2] Rename field --- src/open_samus_returns_rando/files/schema.json | 2 +- src/open_samus_returns_rando/misc_patches/actor_attributes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/open_samus_returns_rando/files/schema.json b/src/open_samus_returns_rando/files/schema.json index 3043c24..95f7976 100644 --- a/src/open_samus_returns_rando/files/schema.json +++ b/src/open_samus_returns_rando/files/schema.json @@ -596,7 +596,7 @@ "properties": { "babyhatchling": { "properties": { - "size": { + "model_scale": { "description": "Size of the Baby Metroid.", "type": "number", "minimum": 0.1, diff --git a/src/open_samus_returns_rando/misc_patches/actor_attributes.py b/src/open_samus_returns_rando/misc_patches/actor_attributes.py index 14870eb..485cbb7 100644 --- a/src/open_samus_returns_rando/misc_patches/actor_attributes.py +++ b/src/open_samus_returns_rando/misc_patches/actor_attributes.py @@ -8,4 +8,4 @@ def patch_actor_attributes(editor: PatcherEditor, configuration: dict) -> None: def _custom_baby_size(editor: PatcherEditor, configuration: dict) -> None: baby = editor.get_file("actors/characters/babyhatchling/charclasses/babyhatchling.bmsad", Bmsad) - baby.raw["header"]["model_scale"] = configuration["babyhatchling"]["size"] + baby.raw["header"]["model_scale"] = configuration["babyhatchling"]["model_scale"]