Skip to content

Commit

Permalink
Merge pull request #414 from randovania/block_shuffle
Browse files Browse the repository at this point in the history
Support shuffling block types
  • Loading branch information
ThanatosGit authored Jul 16, 2024
2 parents c564a93 + 7d6126c commit 3fd8f17
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/open_samus_returns_rando/files/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@
},
"default": []
},
"block_patches": {
"type": "object",
"patternProperties": {
".*": {
"type": "object",
"$ref": "#/$defs/block_types"
}
},
"default": {}
},
"energy_per_tank": {
"description": "How much energy collecting an Energy Tank gives",
"type": "number",
Expand Down Expand Up @@ -805,6 +815,19 @@
"t_matad_area01_damage",
"tank_jingle"
]
},
"block_types": {
"type": "string",
"enum": [
"power_beam",
"missile",
"super_missile",
"bomb",
"power_bomb",
"screw_attack",
"baby",
"weight"
]
}
}
}
19 changes: 19 additions & 0 deletions src/open_samus_returns_rando/misc_patches/block_patches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from mercury_engine_data_structures.formats import Bmsbk
from open_samus_returns_rando.constants import ALL_SCENARIOS
from open_samus_returns_rando.patcher_editor import PatcherEditor


def patch_block_types(editor: PatcherEditor, configuration: dict) -> None:
if len(configuration["block_patches"]) == 0:
return

for scenario_name in ALL_SCENARIOS:
bmsbk = editor.get_file(f"maps/levels/c10_samus/{scenario_name}/{scenario_name}.bmsbk", Bmsbk)
blocks = bmsbk.raw["block_groups"]
for block in blocks:
block_type = block["types"][0]
for original_type, new_type in configuration["block_patches"].items():
# Check for the block type and change it to the new type
if original_type == block_type["block_type"]:
block_type["block_type"] = new_type
break
4 changes: 4 additions & 0 deletions src/open_samus_returns_rando/samus_returns_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.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
from open_samus_returns_rando.misc_patches.elevators import patch_elevators
Expand Down Expand Up @@ -128,6 +129,9 @@ def patch_extracted(input_path: Path, input_exheader: Path | None, output_path:
# Patch elevator destinations
patch_elevators(editor, configuration)

# Patch blocks to another type
patch_block_types(editor, configuration)

out_exefs = output_path.joinpath("exefs")
out_romfs = output_path.joinpath("romfs")
out_code = output_path.joinpath("code.bps")
Expand Down

0 comments on commit 3fd8f17

Please sign in to comment.