From 7608ce79ba8a61aa772ba2ec42e6a95b0d1ead2d Mon Sep 17 00:00:00 2001 From: dyceron Date: Mon, 10 Jun 2024 00:28:16 -0400 Subject: [PATCH 01/17] Add mapping for pickups and the map --- .../files/custom/sprites_texturehud.lua | 27 +++++++++++ .../files/romfs/gui/textures/texturehud.bctex | Bin 524555 -> 524555 bytes .../pickups/pickup.py | 42 +++++++++++++++++- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/src/open_samus_returns_rando/files/custom/sprites_texturehud.lua b/src/open_samus_returns_rando/files/custom/sprites_texturehud.lua index 3284b8e8..8184038c 100644 --- a/src/open_samus_returns_rando/files/custom/sprites_texturehud.lua +++ b/src/open_samus_returns_rando/files/custom/sprites_texturehud.lua @@ -1,5 +1,32 @@ Game.ImportLibrary("gui/scripts/sprites_texturehud_original.lua") +GUI.AddSpriteSheetItem("powerup", "gui/textures/texturehud.bctex", { + TextureWidth = "512", + TextureHeight = "256", + UPixelOffset = "144", + VPixelOffset = "24", + UPixelScale = "8", + VPixelScale = "8", + AngleOffset = "0" +}) +GUI.AddSpriteSheetItem("item_offworld", "gui/textures/texturehud.bctex", { + TextureWidth = "512", + TextureHeight = "256", + UPixelOffset = "104", + VPixelOffset = "40", + UPixelScale = "8", + VPixelScale = "8", + AngleOffset = "0" +}) +GUI.AddSpriteSheetItem("adn", "gui/textures/texturehud.bctex", { + TextureWidth = "512", + TextureHeight = "256", + UPixelOffset = "112", + VPixelOffset = "40", + UPixelScale = "8", + VPixelScale = "8", + AngleOffset = "0" +}) GUI.AddSpriteSheetItem("dooriceleft", "gui/textures/texturehud.bctex", { TextureWidth = "512", TextureHeight = "256", diff --git a/src/open_samus_returns_rando/files/romfs/gui/textures/texturehud.bctex b/src/open_samus_returns_rando/files/romfs/gui/textures/texturehud.bctex index 62fd04c06744d35064a2bb57055ddf18a7ae268b..5ba51b881cdd00ab0b52f0ddad33188fef4c2706 100644 GIT binary patch delta 582 zcmX|+T}YE*6vxjtx5s^?bg}S*bVhDQvvjsmAojXRk*U0hmtJ|*ozaEj)hp885Qa%OlopX%EA};mh{9FM9S%9vuWM8~TSKlNh}=tlZYJNWdQu#tvfn{+ zaTED?Z||-3?zyY@zNd1(o?I`lL*GUhxtshqDwP{ZDuB@p?ztXXEAO@YGhyia$bWE^ zlyMj$C*LODYk@S9hXpK4AmC0_A;t6o<&2 z4dP!8!At?m=CJq>2i}6oD9iyV_Y-j<{?5+hc}^rgdJyX*zuWPF+Y;}+$YZDG_iDt! zI zOKgnigD8x@$*)%sADunl&g=qQ97ug0%!&cN*^;(Nyc0_cSY8Qg1&Ekf*?6*?`|@~E z@`p#pC(lW8s~>-5GE>xFJ~h8JfzR>w^$XJ1;yI@SiK*L6-EQg*Q!g=fr>VOZb>+?c E119MOm;e9( delta 59 zcmeBfQs{0{XxPH&=rfu3dHnPRK8%XfLwT4KrawHx7{9&YAoBsHwgASq03gZS7QoUL Oz}gnTwk?32dm{jw=oJM3 diff --git a/src/open_samus_returns_rando/pickups/pickup.py b/src/open_samus_returns_rando/pickups/pickup.py index 7a7d9a41..992aa9d0 100644 --- a/src/open_samus_returns_rando/pickups/pickup.py +++ b/src/open_samus_returns_rando/pickups/pickup.py @@ -4,7 +4,7 @@ from enum import Enum from construct import Container, ListContainer -from mercury_engine_data_structures.formats import Bmsad, Lua +from mercury_engine_data_structures.formats import Bmsad, Bmsmsd, Lua from open_samus_returns_rando.constants import get_package_name from open_samus_returns_rando.files import templates_path from open_samus_returns_rando.logger import LOG @@ -288,6 +288,8 @@ def patch(self, editor: PatcherEditor) -> None: script_class.ensure_files(editor) + self.patch_minimap(editor, scenario_name, actor_name) + # Dependencies for level_pkg in pkgs_for_level: for model_name in model_names: @@ -295,6 +297,44 @@ def patch(self, editor: PatcherEditor) -> None: for dep in model_data.dependencies: editor.ensure_present(get_package_name(level_pkg, dep), dep) + + def patch_minimap(self, editor: PatcherEditor, scenario_name: str, actor_name: str) -> None: + if scenario_name != "s110_surfaceb": + scenario_minimap = editor.get_file(f"gui/minimaps/c10_samus/{scenario_name}.bmsmsd", Bmsmsd) + else: + scenario_minimap = editor.get_file("gui/minimaps/c10_samus/s000_surface.bmsmsd", Bmsmsd) + tiles = scenario_minimap.raw["tiles"] + + # find item tile + tile_for_item = [ + x for x in tiles if len(x.icons) and next((y for y in x.icons if actor_name in y.actor_name), 0) + ] + + if len(tile_for_item) == 1: + pickup_tile_icon = next((y for y in tile_for_item[0].icons if "item" in y.icon), None) + + if not pickup_tile_icon: + raise ValueError("No icon found") + + pickup_model = self.pickup["model"][0] + + # Tanks, DNA, and offworld items just use the icon with the same name as the pickup_model + # Powerups and Nothing items use a "custom" itemsphere so they update on the map + if "itemsphere" in pickup_model or "powerup" in pickup_model: + pickup_model = "powerup" + + # Special cases for area6/area10 + # area6 reveals what the Phase Drift hidden item is before the block is broken if it is a custom icon + # area10 reveals what the Queen pickup is without fighing it + if (scenario_name == "s060_area6" and actor_name == "LE_HiddenPowerup001") or ( + scenario_name == "s100_area10" and actor_name == "LE_Baby_Hatchling" + ): + pickup_tile_icon.icon = "itemenabled" + + # change the icons to their new item type + pickup_tile_icon.icon = pickup_model + + def get_scenario(self) -> str: return self.pickup["pickup_actor"]["scenario"] From 57ef6fb1ac6d2e1b29db5830eb41a01c1cf5044d Mon Sep 17 00:00:00 2001 From: dyceron Date: Mon, 10 Jun 2024 00:45:39 -0400 Subject: [PATCH 02/17] Fix hidden items --- src/open_samus_returns_rando/pickups/pickup.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/open_samus_returns_rando/pickups/pickup.py b/src/open_samus_returns_rando/pickups/pickup.py index 992aa9d0..368fedfa 100644 --- a/src/open_samus_returns_rando/pickups/pickup.py +++ b/src/open_samus_returns_rando/pickups/pickup.py @@ -323,17 +323,17 @@ def patch_minimap(self, editor: PatcherEditor, scenario_name: str, actor_name: s if "itemsphere" in pickup_model or "powerup" in pickup_model: pickup_model = "powerup" - # Special cases for area6/area10 - # area6 reveals what the Phase Drift hidden item is before the block is broken if it is a custom icon - # area10 reveals what the Queen pickup is without fighing it - if (scenario_name == "s060_area6" and actor_name == "LE_HiddenPowerup001") or ( + # change the icons to their new item type + pickup_tile_icon.icon = pickup_model + + # Special cases + # Custom icons are always visible, even for hidden pickups, so make them generic + # The Queen pickup is always visible on the map without fighing it, so make it generic + if pickup_tile_icon.icon_priority == "HIDDEN_ITEM" or ( scenario_name == "s100_area10" and actor_name == "LE_Baby_Hatchling" ): pickup_tile_icon.icon = "itemenabled" - # change the icons to their new item type - pickup_tile_icon.icon = pickup_model - def get_scenario(self) -> str: return self.pickup["pickup_actor"]["scenario"] From eeea7a737895971bd762ea6d99d6b5dd2d17f261 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:50:46 +0000 Subject: [PATCH 03/17] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.7 → v0.4.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.7...v0.4.8) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b2838c4..03cc6bdd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.4.7 + rev: v0.4.8 hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ] \ No newline at end of file From 102c2b6a368ffc262db247a1b4cc9933f10f2a91 Mon Sep 17 00:00:00 2001 From: Thanatos <117127188+ThanatosGit@users.noreply.github.com> Date: Wed, 12 Jun 2024 22:26:02 +0200 Subject: [PATCH 04/17] Really delete old files (#375) --- src/open_samus_returns_rando/samus_returns_patcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/open_samus_returns_rando/samus_returns_patcher.py b/src/open_samus_returns_rando/samus_returns_patcher.py index 2ea71705..48987e61 100644 --- a/src/open_samus_returns_rando/samus_returns_patcher.py +++ b/src/open_samus_returns_rando/samus_returns_patcher.py @@ -133,8 +133,8 @@ def patch_extracted(input_path: Path, input_exheader: Path, output_path: Path, c out_code = output_path.joinpath("code.bps") out_exheader = output_path.joinpath("exheader.bin") shutil.rmtree(out_romfs, ignore_errors=True) - shutil.rmtree(out_code, ignore_errors=True) - shutil.rmtree(out_exheader, ignore_errors=True) + out_code.unlink(missing_ok=True) + out_exheader.unlink(missing_ok=True) # this is just to clean up old version shutil.rmtree(out_exefs, ignore_errors=True) From 69ced0da610139ab268fcdcacc60cec8db8ae527 Mon Sep 17 00:00:00 2001 From: Thanatos <117127188+ThanatosGit@users.noreply.github.com> Date: Wed, 12 Jun 2024 22:26:14 +0200 Subject: [PATCH 05/17] Add None as type for input_exheader as it is not required (#376) --- src/open_samus_returns_rando/__init__.py | 2 +- src/open_samus_returns_rando/multiworld_integration.py | 6 ++++-- src/open_samus_returns_rando/patch_util.py | 2 +- src/open_samus_returns_rando/samus_returns_patcher.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/open_samus_returns_rando/__init__.py b/src/open_samus_returns_rando/__init__.py index 12e9841a..73be7a70 100644 --- a/src/open_samus_returns_rando/__init__.py +++ b/src/open_samus_returns_rando/__init__.py @@ -3,7 +3,7 @@ from .patch_util import patch_with_status_update -def patch(input_path: Path, input_exheader: Path, output_path: Path, configuration: dict) -> None: +def patch(input_path: Path, input_exheader: Path | None, output_path: Path, configuration: dict) -> None: from .samus_returns_patcher import patch_extracted return patch_extracted(input_path, input_exheader, output_path, configuration) diff --git a/src/open_samus_returns_rando/multiworld_integration.py b/src/open_samus_returns_rando/multiworld_integration.py index 235d8a46..91999771 100644 --- a/src/open_samus_returns_rando/multiworld_integration.py +++ b/src/open_samus_returns_rando/multiworld_integration.py @@ -32,8 +32,10 @@ def get_lua_for_item(progression: list[list[dict[str, str | int]]]) -> str: ) -def create_exefs_patches(out_code: Path, out_exheader: Path, input_exheader: Path, enabled: bool, region: str) -> None: - if not enabled: +def create_exefs_patches( + out_code: Path, out_exheader: Path, input_exheader: Path | None, enabled: bool, region: str + ) -> None: + if not enabled or input_exheader is None: return import shutil diff --git a/src/open_samus_returns_rando/patch_util.py b/src/open_samus_returns_rando/patch_util.py index 72654835..d1be1861 100644 --- a/src/open_samus_returns_rando/patch_util.py +++ b/src/open_samus_returns_rando/patch_util.py @@ -5,7 +5,7 @@ from open_samus_returns_rando.logger import LOG -def patch_with_status_update(input_path: Path, input_exheader: Path, output_path: Path, configuration: dict, +def patch_with_status_update(input_path: Path, input_exheader: Path | None, output_path: Path, configuration: dict, status_update: typing.Callable[[float, str], None]) -> None: from open_samus_returns_rando.samus_returns_patcher import patch_extracted # messages depends on the layout but it is a good approximation diff --git a/src/open_samus_returns_rando/samus_returns_patcher.py b/src/open_samus_returns_rando/samus_returns_patcher.py index 48987e61..ebd959ea 100644 --- a/src/open_samus_returns_rando/samus_returns_patcher.py +++ b/src/open_samus_returns_rando/samus_returns_patcher.py @@ -66,7 +66,7 @@ def validate(configuration: dict, input_exheader: Path | None) -> None: -def patch_extracted(input_path: Path, input_exheader: Path, output_path: Path, configuration: dict) -> None: +def patch_extracted(input_path: Path, input_exheader: Path | None, output_path: Path, configuration: dict) -> None: LOG.info("Will patch files from %s", input_path) validate(configuration, input_exheader) From e8c1d79dbd984853f504f36d29cd05d17f0f4746 Mon Sep 17 00:00:00 2001 From: dyceron Date: Wed, 12 Jun 2024 17:43:31 -0400 Subject: [PATCH 06/17] Fix icons showing up with Scan Pulse --- .../files/custom/sprites_texturehud.lua | 4 ++-- .../pickups/pickup.py | 11 +++++++---- tests/test_files/starter_preset_patcher.json | 19 ++++++++++--------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/open_samus_returns_rando/files/custom/sprites_texturehud.lua b/src/open_samus_returns_rando/files/custom/sprites_texturehud.lua index 8184038c..32931786 100644 --- a/src/open_samus_returns_rando/files/custom/sprites_texturehud.lua +++ b/src/open_samus_returns_rando/files/custom/sprites_texturehud.lua @@ -1,6 +1,6 @@ Game.ImportLibrary("gui/scripts/sprites_texturehud_original.lua") -GUI.AddSpriteSheetItem("powerup", "gui/textures/texturehud.bctex", { +GUI.AddSpriteSheetItem("item_powerup", "gui/textures/texturehud.bctex", { TextureWidth = "512", TextureHeight = "256", UPixelOffset = "144", @@ -18,7 +18,7 @@ GUI.AddSpriteSheetItem("item_offworld", "gui/textures/texturehud.bctex", { VPixelScale = "8", AngleOffset = "0" }) -GUI.AddSpriteSheetItem("adn", "gui/textures/texturehud.bctex", { +GUI.AddSpriteSheetItem("item_adn", "gui/textures/texturehud.bctex", { TextureWidth = "512", TextureHeight = "256", UPixelOffset = "112", diff --git a/src/open_samus_returns_rando/pickups/pickup.py b/src/open_samus_returns_rando/pickups/pickup.py index 368fedfa..7cd7a591 100644 --- a/src/open_samus_returns_rando/pickups/pickup.py +++ b/src/open_samus_returns_rando/pickups/pickup.py @@ -318,18 +318,21 @@ def patch_minimap(self, editor: PatcherEditor, scenario_name: str, actor_name: s pickup_model = self.pickup["model"][0] - # Tanks, DNA, and offworld items just use the icon with the same name as the pickup_model + # Tanks and offworld items just use the icon with the same name as the pickup_model # Powerups and Nothing items use a "custom" itemsphere so they update on the map if "itemsphere" in pickup_model or "powerup" in pickup_model: - pickup_model = "powerup" + pickup_model = "item_powerup" + # DNA uses a custom icon + elif "adn" in pickup_model: + pickup_model = "item_adn" # change the icons to their new item type pickup_tile_icon.icon = pickup_model # Special cases - # Custom icons are always visible, even for hidden pickups, so make them generic - # The Queen pickup is always visible on the map without fighing it, so make it generic + # Custom blockx are no longer attached to the pickup, so make all hidden pickups consistent and generic if pickup_tile_icon.icon_priority == "HIDDEN_ITEM" or ( + # The Queen pickup is always visible on the map without fighing it, so make it generic scenario_name == "s100_area10" and actor_name == "LE_Baby_Hatchling" ): pickup_tile_icon.icon = "itemenabled" diff --git a/tests/test_files/starter_preset_patcher.json b/tests/test_files/starter_preset_patcher.json index a5479391..768935e1 100644 --- a/tests/test_files/starter_preset_patcher.json +++ b/tests/test_files/starter_preset_patcher.json @@ -2,7 +2,7 @@ "$schema": "../../src/open_samus_returns_rando/files/schema.json", "starting_location": { "scenario": "s000_surface", - "actor": "StartPoint0" + "actor": "ST_DEBUG_Morphball" }, "starting_items": { "ITEM_WEAPON_MISSILE_LAUNCHER": 1, @@ -40,6 +40,7 @@ "ITEM_MAX_LIFE": 99, "ITEM_MAX_SPECIAL_ENERGY": 1000 }, + "reveal_map_on_start": true, "starting_text": [], "pickups": [ { @@ -63,12 +64,12 @@ }, { "pickup_type": "actor", - "caption": "Missile Tank acquired.\nMissile capacity increased by 3.", + "caption": "Sent Missile Tank acquired.\nMissile capacity increased by 3.", "resources": [ [ { - "item_id": "ITEM_MISSILE_TANKS", - "quantity": 3 + "item_id": "ITEM_NONE", + "quantity": 0 } ] ], @@ -272,12 +273,12 @@ }, { "pickup_type": "actor", - "caption": "Morph Ball acquired.", + "caption": "Sent Speed Booster to meep.", "resources": [ [ { - "item_id": "ITEM_MORPH_BALL", - "quantity": 1 + "item_id": "ITEM_NONE", + "quantity": 0 } ] ], @@ -286,7 +287,7 @@ "actor": "LE_PowerUP_Morphball" }, "model": [ - "powerup_morphball" + "item_offworld" ] }, { @@ -331,7 +332,7 @@ "actor": "HiddenPowerup001" }, "model": [ - "item_missiletank" + "item_offworld" ] }, { From 82400fa178651a671583a65a59c55fe4a5dde53e Mon Sep 17 00:00:00 2001 From: dyceron Date: Thu, 13 Jun 2024 00:38:12 -0400 Subject: [PATCH 07/17] Add support for constant heat/lava damage --- .../files/schema.json | 31 +++ .../samus_returns_patcher.py | 4 + .../specific_patches/environmental_damage.py | 26 +++ .../environmental_damage_sources.py | 199 ++++++++++++++++++ 4 files changed, 260 insertions(+) create mode 100644 src/open_samus_returns_rando/specific_patches/environmental_damage.py create mode 100644 src/open_samus_returns_rando/specific_patches/environmental_damage_sources.py diff --git a/src/open_samus_returns_rando/files/schema.json b/src/open_samus_returns_rando/files/schema.json index 2a5b5afd..54617eda 100644 --- a/src/open_samus_returns_rando/files/schema.json +++ b/src/open_samus_returns_rando/files/schema.json @@ -301,6 +301,24 @@ }, "additionalProperties": false }, + "constant_environment_damage": { + "description": "Each property, when not null, will change the damage from that type to be that much per second", + "default": {}, + "type": "object", + "properties": { + "heat": { + "title": "Heated Rooms", + "$ref": "#/$defs/constant_damage_value", + "default": null + }, + "lava": { + "title": "Lava", + "$ref": "#/$defs/constant_damage_value", + "default": null + } + }, + "additionalProperties": false + }, "debug_spawn_points": { "type": "array", "description": "Creates new spawn points for debugging", @@ -700,6 +718,19 @@ "scenario", "spawngroup" ] + }, + "constant_damage_value": { + "default": null, + "anyOf": [ + { + "type": "number", + "minimum": 0, + "maximum": 1000 + }, + { + "type": "null" + } + ] } } } diff --git a/src/open_samus_returns_rando/samus_returns_patcher.py b/src/open_samus_returns_rando/samus_returns_patcher.py index ebd959ea..358b65df 100644 --- a/src/open_samus_returns_rando/samus_returns_patcher.py +++ b/src/open_samus_returns_rando/samus_returns_patcher.py @@ -21,6 +21,7 @@ from open_samus_returns_rando.specific_patches import cosmetic_patches, game_patches, tunable_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 from open_samus_returns_rando.specific_patches.heat_room_patches import patch_heat_rooms from open_samus_returns_rando.specific_patches.hint_patches import patch_hints from open_samus_returns_rando.specific_patches.map_icons import patch_tiles @@ -97,6 +98,9 @@ def patch_extracted(input_path: Path, input_exheader: Path | None, output_path: # Fix unheated heat rooms patch_heat_rooms(editor) + # Environmental Damage + apply_constant_damage(editor, configuration["constant_environment_damage"]) + # Patch door types and make shields on both sides patch_doors(editor, configuration["door_patches"], configuration["custom_doors"]) diff --git a/src/open_samus_returns_rando/specific_patches/environmental_damage.py b/src/open_samus_returns_rando/specific_patches/environmental_damage.py new file mode 100644 index 00000000..0bc9d163 --- /dev/null +++ b/src/open_samus_returns_rando/specific_patches/environmental_damage.py @@ -0,0 +1,26 @@ +from open_samus_returns_rando.patcher_editor import PatcherEditor +from open_samus_returns_rando.specific_patches.environmental_damage_sources import ALL_DAMAGE_ROOM_ACTORS + + +def apply_constant_damage(editor: PatcherEditor, configuration: dict) -> None: + for reference in ALL_DAMAGE_ROOM_ACTORS: + actor = editor.resolve_actor_reference(reference) + + if actor["components"][1]["arguments"][26]["value"] == "HEAT": + config_field = "heat" + elif actor["components"][1]["arguments"][26]["value"] == "LAVA": + config_field = "lava" + else: + raise ValueError(f"{reference} does not have a valid actorDef for environmental damage") + + if configuration[config_field] is None: + continue + + damage = configuration[config_field] + + # Max damage per tick + actor["components"][1]["arguments"][19]["value"] = damage + # Damage Scale + actor["components"][1]["arguments"][28]["value"] = damage + # Damage of first tick. Set to half to give room for player error + actor["components"][2]["arguments"][19]["value"] = damage / 2 diff --git a/src/open_samus_returns_rando/specific_patches/environmental_damage_sources.py b/src/open_samus_returns_rando/specific_patches/environmental_damage_sources.py new file mode 100644 index 00000000..2aec174f --- /dev/null +++ b/src/open_samus_returns_rando/specific_patches/environmental_damage_sources.py @@ -0,0 +1,199 @@ +import itertools + +_AREA_1_HEAT_ACTORS = [ + { + "scenario": "s010_area1", + "layer": 2, + "actor": "TG_Heat_001" + } +] + +_AREA_1_LAVA_ACTORS = [ + { + "scenario": "s010_area1", + "layer": 0, + "actor": "Lava_Trigger_001" + } +] + +_AREA_2_HEAT_ACTORS = [ + { + "scenario": "s020_area2", + "layer": 2, + "actor": "TG_SP_Heat_001" + }, + { + "scenario": "s020_area2", + "layer": 0, + "actor": "TG_Heat_002" + }, + { + "scenario": "s025_area2b", + "layer": 2, + "actor": "TG_SP_Heat_001" + } +] + +_AREA_2_LAVA_ACTORS = [ + { + "scenario": "s020_area2", + "layer": 0, + "actor": "TG_Lava_001" + }, + { + "scenario": "s020_area2", + "layer": 0, + "actor": "TG_Lava_002" + }, + { + "scenario": "s020_area2", + "layer": 0, + "actor": "TG_Lava_003" + }, + { + "scenario": "s020_area2", + "layer": 0, + "actor": "TG_Lava_004" + } +] + +_AREA_3_HEAT_ACTORS = [ + { + "scenario": "s033_area3b", + "layer": 2, + "actor": "TG_Heat_Rando_001" + }, + { + "scenario": "s036_area3c", + "layer": 2, + "actor": "TG_Heat_Rando_001" + } +] + +_AREA_3_LAVA_ACTORS = [ + { + "scenario": "s033_area3b", + "layer": 0, + "actor": "TG_Lava_001" + }, + { + "scenario": "s033_area3b", + "layer": 0, + "actor": "TG_Lava_002" + }, + { + "scenario": "s036_area3c", + "layer": 0, + "actor": "TG_Lava_001" + }, + { + "scenario": "s036_area3c", + "layer": 0, + "actor": "TG_Lava_002" + } +] + +_AREA_4_HEAT_ACTORS = [ + { + "scenario": "s040_area4", + "layer": 2, + "actor": "TG_Heat_Rando_001" + }, + { + "scenario": "s050_area5", + "layer": 2, + "actor": "TG_Heat_Rando_001" + }, + { + "scenario": "s050_area5", + "layer": 2, + "actor": "TG_Heat_Rando_002" + } +] + +_AREA_4_LAVA_ACTORS = [ + { + "scenario": "s040_area4", + "layer": 0, + "actor": "TG_Lava_001" + }, + { + "scenario": "s040_area4", + "layer": 0, + "actor": "TG_Lava_002" + }, + { + "scenario": "s040_area4", + "layer": 0, + "actor": "TG_Lava_003" + }, + { + "scenario": "s050_area5", + "layer": 0, + "actor": "TG_Lava_001" + }, + { + "scenario": "s050_area5", + "layer": 0, + "actor": "TG_Lava_003" + }, + { + "scenario": "s050_area5", + "layer": 0, + "actor": "TG_Lava_005" + } +] + +_AREA_5_HEAT_ACTORS = [ + { + "scenario": "s065_area6b", + "layer": 2, + "actor": "TG_Heat_Rando_001" + }, + { + "scenario": "s067_area6c", + "layer": 2, + "actor": "TG_Heat_Rando_001" + } +] + +_AREA_5_LAVA_ACTORS = [ + { + "scenario": "s065_area6b", + "layer": 0, + "actor": "TG_Lava_001" + }, + { + "scenario": "s067_area6c", + "layer": 0, + "actor": "TG_Lava_001" + }, + { + "scenario": "s067_area6c", + "layer": 0, + "actor": "TG_Lava_002" + }, + { + "scenario": "s067_area6c", + "layer": 0, + "actor": "TG_Lava_003" + }, + { + "scenario": "s067_area6c", + "layer": 0, + "actor": "TG_Lava_004" + } +] + +ALL_DAMAGE_ROOM_ACTORS = list(itertools.chain( + _AREA_1_HEAT_ACTORS, + _AREA_1_LAVA_ACTORS, + _AREA_2_HEAT_ACTORS, + _AREA_2_LAVA_ACTORS, + _AREA_3_HEAT_ACTORS, + _AREA_3_LAVA_ACTORS, + _AREA_4_HEAT_ACTORS, + _AREA_4_LAVA_ACTORS, + _AREA_5_HEAT_ACTORS, + _AREA_5_LAVA_ACTORS, +)) From e759872cfcca369223244babf638ffd03e91a3f3 Mon Sep 17 00:00:00 2001 From: dyceron <38679103+dyceron@users.noreply.github.com> Date: Thu, 13 Jun 2024 12:51:16 -0400 Subject: [PATCH 08/17] Revert starter_preset_patcher.json --- tests/test_files/starter_preset_patcher.json | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/test_files/starter_preset_patcher.json b/tests/test_files/starter_preset_patcher.json index 768935e1..a5479391 100644 --- a/tests/test_files/starter_preset_patcher.json +++ b/tests/test_files/starter_preset_patcher.json @@ -2,7 +2,7 @@ "$schema": "../../src/open_samus_returns_rando/files/schema.json", "starting_location": { "scenario": "s000_surface", - "actor": "ST_DEBUG_Morphball" + "actor": "StartPoint0" }, "starting_items": { "ITEM_WEAPON_MISSILE_LAUNCHER": 1, @@ -40,7 +40,6 @@ "ITEM_MAX_LIFE": 99, "ITEM_MAX_SPECIAL_ENERGY": 1000 }, - "reveal_map_on_start": true, "starting_text": [], "pickups": [ { @@ -64,12 +63,12 @@ }, { "pickup_type": "actor", - "caption": "Sent Missile Tank acquired.\nMissile capacity increased by 3.", + "caption": "Missile Tank acquired.\nMissile capacity increased by 3.", "resources": [ [ { - "item_id": "ITEM_NONE", - "quantity": 0 + "item_id": "ITEM_MISSILE_TANKS", + "quantity": 3 } ] ], @@ -273,12 +272,12 @@ }, { "pickup_type": "actor", - "caption": "Sent Speed Booster to meep.", + "caption": "Morph Ball acquired.", "resources": [ [ { - "item_id": "ITEM_NONE", - "quantity": 0 + "item_id": "ITEM_MORPH_BALL", + "quantity": 1 } ] ], @@ -287,7 +286,7 @@ "actor": "LE_PowerUP_Morphball" }, "model": [ - "item_offworld" + "powerup_morphball" ] }, { @@ -332,7 +331,7 @@ "actor": "HiddenPowerup001" }, "model": [ - "item_offworld" + "item_missiletank" ] }, { From 4af0f5620de37d9e4bc4879dc801b66beae73822 Mon Sep 17 00:00:00 2001 From: dyceron <38679103+dyceron@users.noreply.github.com> Date: Mon, 17 Jun 2024 18:52:53 -0400 Subject: [PATCH 09/17] Attempted fix for Reverse Area 8 crash (#379) * Only update all Metroid setups if RA8 is disabled * Disable intro triggers if going backwards * Add comment * Update all but entry room regardless if ra8 is enabled --- src/open_samus_returns_rando/files/levels/s100_area10.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/open_samus_returns_rando/files/levels/s100_area10.lua b/src/open_samus_returns_rando/files/levels/s100_area10.lua index 844f3fb6..44ce78c7 100644 --- a/src/open_samus_returns_rando/files/levels/s100_area10.lua +++ b/src/open_samus_returns_rando/files/levels/s100_area10.lua @@ -208,6 +208,11 @@ function s100_area10.OnLarva_010_Generated(_ARG_0_, _ARG_1_) end end function s100_area10.OnMetroidDead() + -- Disable the intro and the camera change triggers if a Metroid has been defeated, which means that Reverse Area 8 should be enabled + Game.DisableTrigger("TG_Intro_Larva") + if Game.GetEntity("TG_ChangeCamera_IntroLarva") ~= nil then + Game.GetEntity("TG_ChangeCamera_IntroLarva").TRIGGER:DisableTrigger() + end if Blackboard.GetProp("DEFEATED_ENEMIES", "Metroid") ~= nil and s100_area10.iNumMetroids == Blackboard.GetProp("DEFEATED_ENEMIES", "Metroid") then if Game.GetEntity("LE_ValveQueen") ~= nil then Game.GetEntity("LE_ValveQueen").MODELUPDATER:SetMeshVisible("Valve", false) @@ -217,7 +222,6 @@ function s100_area10.OnMetroidDead() Scenario.WriteToBlackboard("QueenDiscovered", "b", true) Game.AddSF(3.5, "s100_area10.ScheduledQueenRoar", "") for _FORV_6_, _FORV_7_ in pairs({ - "collision_camera_008", "collision_camera_013", "collision_camera_014", "collision_camera_015", From da8a23937e18a35e18a2cc89af8abbdebc4d941f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:41:30 -0400 Subject: [PATCH 10/17] [pre-commit.ci] pre-commit autoupdate (#380) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.8 → v0.4.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.8...v0.4.9) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03cc6bdd..d457f863 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.4.8 + rev: v0.4.9 hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ] \ No newline at end of file From 1389c605f445ca17429cc2e32847a04d182b106b Mon Sep 17 00:00:00 2001 From: dyceron Date: Wed, 19 Jun 2024 20:11:03 -0400 Subject: [PATCH 11/17] Remove redundant code and fix heat item tiles --- .../pickups/pickup.py | 26 ++++++++++--------- .../specific_patches/map_icons.py | 10 ------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/open_samus_returns_rando/pickups/pickup.py b/src/open_samus_returns_rando/pickups/pickup.py index 7cd7a591..60b13ec5 100644 --- a/src/open_samus_returns_rando/pickups/pickup.py +++ b/src/open_samus_returns_rando/pickups/pickup.py @@ -5,6 +5,7 @@ from construct import Container, ListContainer from mercury_engine_data_structures.formats import Bmsad, Bmsmsd, Lua +from mercury_engine_data_structures.formats.bmsmsd import TileType from open_samus_returns_rando.constants import get_package_name from open_samus_returns_rando.files import templates_path from open_samus_returns_rando.logger import LOG @@ -318,24 +319,25 @@ def patch_minimap(self, editor: PatcherEditor, scenario_name: str, actor_name: s pickup_model = self.pickup["model"][0] - # Tanks and offworld items just use the icon with the same name as the pickup_model # Powerups and Nothing items use a "custom" itemsphere so they update on the map if "itemsphere" in pickup_model or "powerup" in pickup_model: - pickup_model = "item_powerup" + pickup_tile_icon.icon = "item_powerup" # DNA uses a custom icon elif "adn" in pickup_model: - pickup_model = "item_adn" - - # change the icons to their new item type - pickup_tile_icon.icon = pickup_model - - # Special cases - # Custom blockx are no longer attached to the pickup, so make all hidden pickups consistent and generic - if pickup_tile_icon.icon_priority == "HIDDEN_ITEM" or ( - # The Queen pickup is always visible on the map without fighing it, so make it generic + pickup_tile_icon.icon = "item_adn" + # Custom blocks are no longer attached to the pickup, so make all hidden pickups consistent and generic + elif pickup_tile_icon.icon_priority == "HIDDEN_ITEM" or ( + # The Queen pickup is always visible on the map without fighting it, so make it generic scenario_name == "s100_area10" and actor_name == "LE_Baby_Hatchling" ): - pickup_tile_icon.icon = "itemenabled" + if tile_for_item[0]["tile_type"] == TileType.HEAT: + pickup_tile_icon.icon = "itemenabledheat" + else: + pickup_tile_icon.icon = "itemenabled" + else: + # Tanks and offworld items just use the icon with the same name as the pickup_model + pickup_tile_icon.icon = pickup_model + def get_scenario(self) -> str: diff --git a/src/open_samus_returns_rando/specific_patches/map_icons.py b/src/open_samus_returns_rando/specific_patches/map_icons.py index 1d260042..02c750ca 100644 --- a/src/open_samus_returns_rando/specific_patches/map_icons.py +++ b/src/open_samus_returns_rando/specific_patches/map_icons.py @@ -1,5 +1,4 @@ from mercury_engine_data_structures.formats import Bmsmsd -from mercury_engine_data_structures.formats.bmsmsd import TileType from open_samus_returns_rando.constants import ALL_SCENARIOS from open_samus_returns_rando.patcher_editor import PatcherEditor @@ -29,15 +28,6 @@ def patch_tiles(editor: PatcherEditor) -> None: icons = current_tile["icons"] if len(icons) != 0: - # Items - if "tank" in icons[0]["icon"] or "itemsphere" in icons[0]["icon"]: - if current_tile["tile_type"] == TileType.HEAT: - icons[0]["icon"] = "itemenabledheat" - else: - icons[0]["icon"] = "itemenabled" - if len(icons) > 1 and "tank" in icons[1]["icon"]: - icons[1]["icon"] = "itemenabled" - # Doors door_tile = icons[0] if len(icons) == 1 else icons[1] for door in doors: From 3432f36457ad43e7df71a0f8e10910c4071205ee Mon Sep 17 00:00:00 2001 From: dyceron Date: Fri, 21 Jun 2024 23:53:43 -0400 Subject: [PATCH 12/17] Fix edge cases --- src/open_samus_returns_rando/pickups/pickup.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/open_samus_returns_rando/pickups/pickup.py b/src/open_samus_returns_rando/pickups/pickup.py index 60b13ec5..2b3fb9bb 100644 --- a/src/open_samus_returns_rando/pickups/pickup.py +++ b/src/open_samus_returns_rando/pickups/pickup.py @@ -319,21 +319,21 @@ def patch_minimap(self, editor: PatcherEditor, scenario_name: str, actor_name: s pickup_model = self.pickup["model"][0] - # Powerups and Nothing items use a "custom" itemsphere so they update on the map - if "itemsphere" in pickup_model or "powerup" in pickup_model: - pickup_tile_icon.icon = "item_powerup" - # DNA uses a custom icon - elif "adn" in pickup_model: - pickup_tile_icon.icon = "item_adn" # Custom blocks are no longer attached to the pickup, so make all hidden pickups consistent and generic - elif pickup_tile_icon.icon_priority == "HIDDEN_ITEM" or ( - # The Queen pickup is always visible on the map without fighting it, so make it generic - scenario_name == "s100_area10" and actor_name == "LE_Baby_Hatchling" + if pickup_tile_icon.icon_priority == "HIDDEN_ITEM" or ( + # Boss pickups are now always visible on the map without fighting them, so make icons generic + actor_name in {"LE_PowerUp_Springball", "LE_PowerUp_Powerbomb", "LE_Baby_Hatchling"} ): if tile_for_item[0]["tile_type"] == TileType.HEAT: pickup_tile_icon.icon = "itemenabledheat" else: pickup_tile_icon.icon = "itemenabled" + # Powerups and Nothing items use a "custom" itemsphere so they update on the map + elif "itemsphere" in pickup_model or "powerup" in pickup_model or "babyhatchling" in pickup_model: + pickup_tile_icon.icon = "item_powerup" + # DNA uses a custom icon + elif "adn" in pickup_model: + pickup_tile_icon.icon = "item_adn" else: # Tanks and offworld items just use the icon with the same name as the pickup_model pickup_tile_icon.icon = pickup_model From eb919e80db71aeeda1cfde33e4bce0924637de16 Mon Sep 17 00:00:00 2001 From: dyceron Date: Sat, 22 Jun 2024 00:06:31 -0400 Subject: [PATCH 13/17] Move static door tile patches to `door_patches.py` --- .../samus_returns_patcher.py | 4 -- .../specific_patches/door_patches.py | 35 ++++++++++++++++ .../specific_patches/map_icons.py | 40 ------------------- 3 files changed, 35 insertions(+), 44 deletions(-) delete mode 100644 src/open_samus_returns_rando/specific_patches/map_icons.py diff --git a/src/open_samus_returns_rando/samus_returns_patcher.py b/src/open_samus_returns_rando/samus_returns_patcher.py index 358b65df..234354e0 100644 --- a/src/open_samus_returns_rando/samus_returns_patcher.py +++ b/src/open_samus_returns_rando/samus_returns_patcher.py @@ -24,7 +24,6 @@ from open_samus_returns_rando.specific_patches.environmental_damage import apply_constant_damage from open_samus_returns_rando.specific_patches.heat_room_patches import patch_heat_rooms from open_samus_returns_rando.specific_patches.hint_patches import patch_hints -from open_samus_returns_rando.specific_patches.map_icons import patch_tiles 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.validator_with_default import DefaultValidatingDraft7Validator @@ -81,9 +80,6 @@ def patch_extracted(input_path: Path, input_exheader: Path | None, output_path: # Apply fixes apply_static_fixes(editor) - # Update Map Icons - patch_tiles(editor) - # Custom pickups patch_custom_pickups(editor) debug_custom_pickups(editor, configuration["debug_custom_pickups"]) diff --git a/src/open_samus_returns_rando/specific_patches/door_patches.py b/src/open_samus_returns_rando/specific_patches/door_patches.py index 2750e487..8a61cc42 100644 --- a/src/open_samus_returns_rando/specific_patches/door_patches.py +++ b/src/open_samus_returns_rando/specific_patches/door_patches.py @@ -186,12 +186,47 @@ def _patch_one_way_doors(editor: PatcherEditor) -> None: properties.components[0]["arguments"][2]["value"] = False +def _patch_tiles(editor: PatcherEditor) -> None: + SCENARIO_TO_DOORS = { + "s000_surface": ["Door004", "Door011"], + "s010_area1": ["Door002", "Door004", "Door012", "Door016"], + "s025_area2b": ["Door008"], + "s028_area2c": ["Door001", "Door007"], + "s030_area3": ["Door002", "Door005", "Door006", "Door008"], + "s040_area4": ["Door001", "Door006", "Door014"], + "s050_area5": ["Door005"], + "s060_area6": ["Door001"], + "s067_area6c": ["Door005", "Door006", "Door009"], + "s090_area9": ["Door012"], + } + + for scenario, _ in SCENARIO_TO_DOORS.items(): + scenario_file = editor.get_file(f"gui/minimaps/c10_samus/{scenario}.bmsmsd", Bmsmsd) + tiles = scenario_file.raw["tiles"] + doors = SCENARIO_TO_DOORS.get(scenario, []) + + for tile_idx in range(len(tiles)): + icons = tiles[tile_idx]["icons"] + if len(icons) != 0: + door_tile = icons[0] if len(icons) == 1 else icons[1] + for door in doors: + if door in door_tile["actor_name"]: + door_tile["clear_condition"] = "" + if "closed" in door_tile["icon"] or "charge" in door_tile["icon"]: + if "left" in door_tile["icon"]: + door_tile["icon"] = "doorpowerleft" + else: + door_tile["icon"] = "doorpowerright" + + + def _static_door_patches(editor: PatcherEditor) -> None: _patch_one_way_doors(editor) _patch_missile_covers(editor) _patch_beam_bmsads(editor) _patch_beam_covers(editor) _patch_charge_doors(editor) + _patch_tiles(editor) class ActorData(Enum): diff --git a/src/open_samus_returns_rando/specific_patches/map_icons.py b/src/open_samus_returns_rando/specific_patches/map_icons.py deleted file mode 100644 index 02c750ca..00000000 --- a/src/open_samus_returns_rando/specific_patches/map_icons.py +++ /dev/null @@ -1,40 +0,0 @@ -from mercury_engine_data_structures.formats import Bmsmsd -from open_samus_returns_rando.constants import ALL_SCENARIOS -from open_samus_returns_rando.patcher_editor import PatcherEditor - - -def patch_tiles(editor: PatcherEditor) -> None: - SCENARIO_TO_DOORS = { - "s000_surface": ["Door004", "Door011"], - "s010_area1": ["Door002", "Door004", "Door012", "Door016"], - "s025_area2b": ["Door008"], - "s028_area2c": ["Door001", "Door007"], - "s030_area3": ["Door002", "Door005", "Door006", "Door008"], - "s040_area4": ["Door001", "Door006", "Door014"], - "s050_area5": ["Door005"], - "s060_area6": ["Door001"], - "s067_area6c": ["Door005", "Door006", "Door009"], - "s090_area9": ["Door012"], - } - - for scenario in ALL_SCENARIOS: - if scenario != "s110_surfaceb": - scenario_file = editor.get_file(f"gui/minimaps/c10_samus/{scenario}.bmsmsd", Bmsmsd) - tiles = scenario_file.raw["tiles"] - doors = SCENARIO_TO_DOORS.get(scenario, []) - - for tile_idx in range(len(tiles)): - current_tile = tiles[tile_idx] - - icons = current_tile["icons"] - if len(icons) != 0: - # Doors - door_tile = icons[0] if len(icons) == 1 else icons[1] - for door in doors: - if door in door_tile["actor_name"]: - door_tile["clear_condition"] = "" - if "closed" in door_tile["icon"] or "charge" in door_tile["icon"]: - if "left" in door_tile["icon"]: - door_tile["icon"] = "doorpowerleft" - else: - door_tile["icon"] = "doorpowerright" From 4d8928e3ab7446d3a7f05696e5141b18ee3a4a2f Mon Sep 17 00:00:00 2001 From: dyceron Date: Sat, 22 Jun 2024 09:09:13 -0400 Subject: [PATCH 14/17] Change constant env dps to match the tick rate --- .../specific_patches/environmental_damage.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/open_samus_returns_rando/specific_patches/environmental_damage.py b/src/open_samus_returns_rando/specific_patches/environmental_damage.py index 0bc9d163..7ee9ff4b 100644 --- a/src/open_samus_returns_rando/specific_patches/environmental_damage.py +++ b/src/open_samus_returns_rando/specific_patches/environmental_damage.py @@ -16,11 +16,12 @@ def apply_constant_damage(editor: PatcherEditor, configuration: dict) -> None: if configuration[config_field] is None: continue - damage = configuration[config_field] + # Uses the default time per tick of 0.5 + damage = configuration[config_field] / 2 - # Max damage per tick + # Damage per tick actor["components"][1]["arguments"][19]["value"] = damage # Damage Scale actor["components"][1]["arguments"][28]["value"] = damage - # Damage of first tick. Set to half to give room for player error - actor["components"][2]["arguments"][19]["value"] = damage / 2 + # Damage of first tick + actor["components"][2]["arguments"][19]["value"] = damage From 33d150dab5a18dee81b6c3b03a386935b6c86ad4 Mon Sep 17 00:00:00 2001 From: dyceron Date: Sat, 22 Jun 2024 20:36:28 -0400 Subject: [PATCH 15/17] Prevent inventory update if launcher < 0 --- src/open_samus_returns_rando/lua_editor.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/open_samus_returns_rando/lua_editor.py b/src/open_samus_returns_rando/lua_editor.py index cdabf099..c4c7603a 100644 --- a/src/open_samus_returns_rando/lua_editor.py +++ b/src/open_samus_returns_rando/lua_editor.py @@ -215,13 +215,15 @@ def _create_custom_init(self, editor: PatcherEditor, configuration: dict) -> str max_life += etanks * energy_per_tank # use _MAX if main is unlocked to unlock the ammo too - # FIXME: These checks are kinda wrong if you use something like `"ITEM_WEAPON_MISSILE_LAUNCHER": 0` - if "ITEM_WEAPON_MISSILE_LAUNCHER" in inventory and "ITEM_MISSILE_TANKS" in inventory: - inventory["ITEM_WEAPON_MISSILE_MAX"] = inventory.pop("ITEM_MISSILE_TANKS") - if "ITEM_WEAPON_SUPER_MISSILE" in inventory and "ITEM_SUPER_MISSILE_TANKS" in inventory: - inventory["ITEM_WEAPON_SUPER_MISSILE_MAX"] = inventory.pop("ITEM_SUPER_MISSILE_TANKS") - if "ITEM_WEAPON_POWER_BOMB" in inventory and "ITEM_POWER_BOMB_TANKS" in inventory: - inventory["ITEM_WEAPON_POWER_BOMB_MAX"] = inventory.pop("ITEM_POWER_BOMB_TANKS") + LAUNCHER_TANK_MAPPING = [ + ("ITEM_WEAPON_MISSILE_LAUNCHER", "ITEM_MISSILE_TANKS"), + ("ITEM_WEAPON_SUPER_MISSILE", "ITEM_SUPER_MISSILE_TANKS"), + ("ITEM_WEAPON_POWER_BOMB", "ITEM_POWER_BOMB_TANKS"), + ] + for launcher, tanks in LAUNCHER_TANK_MAPPING: + ammo_max = "ITEM_WEAPON_" + tanks[5:].replace("TANKS", "MAX") + if max(1, inventory.get(launcher, 0)) and tanks in inventory: + inventory[ammo_max] = inventory.pop(tanks) # These fields are required to start the game final_inventory = { From f44bf47f09b11b4357fdf0a6c5ee6b083137c7a9 Mon Sep 17 00:00:00 2001 From: dyceron Date: Sat, 22 Jun 2024 22:34:06 -0400 Subject: [PATCH 16/17] Actually do the check --- src/open_samus_returns_rando/lua_editor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/open_samus_returns_rando/lua_editor.py b/src/open_samus_returns_rando/lua_editor.py index c4c7603a..01752f90 100644 --- a/src/open_samus_returns_rando/lua_editor.py +++ b/src/open_samus_returns_rando/lua_editor.py @@ -221,8 +221,8 @@ def _create_custom_init(self, editor: PatcherEditor, configuration: dict) -> str ("ITEM_WEAPON_POWER_BOMB", "ITEM_POWER_BOMB_TANKS"), ] for launcher, tanks in LAUNCHER_TANK_MAPPING: - ammo_max = "ITEM_WEAPON_" + tanks[5:].replace("TANKS", "MAX") - if max(1, inventory.get(launcher, 0)) and tanks in inventory: + if inventory.get(launcher) and tanks in inventory: + ammo_max = "ITEM_WEAPON_" + tanks[5:].replace("TANKS", "MAX") inventory[ammo_max] = inventory.pop(tanks) # These fields are required to start the game From 6489bbace807199def67ff1969c432ef3834afb7 Mon Sep 17 00:00:00 2001 From: dyceron Date: Sun, 23 Jun 2024 10:19:28 -0400 Subject: [PATCH 17/17] Only update inventory if lauchers > 0 --- src/open_samus_returns_rando/lua_editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/open_samus_returns_rando/lua_editor.py b/src/open_samus_returns_rando/lua_editor.py index 01752f90..db4942d2 100644 --- a/src/open_samus_returns_rando/lua_editor.py +++ b/src/open_samus_returns_rando/lua_editor.py @@ -221,7 +221,7 @@ def _create_custom_init(self, editor: PatcherEditor, configuration: dict) -> str ("ITEM_WEAPON_POWER_BOMB", "ITEM_POWER_BOMB_TANKS"), ] for launcher, tanks in LAUNCHER_TANK_MAPPING: - if inventory.get(launcher) and tanks in inventory: + if launcher in inventory and inventory[launcher] > 0 and tanks in inventory: ammo_max = "ITEM_WEAPON_" + tanks[5:].replace("TANKS", "MAX") inventory[ammo_max] = inventory.pop(tanks)