Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent inventory update if launcher < 1 #383

Merged
merged 3 commits into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/open_samus_returns_rando/lua_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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)

# These fields are required to start the game
final_inventory = {
Expand Down