Skip to content

Commit

Permalink
Add reveal_map_on_start intended as debugging feature because it show…
Browse files Browse the repository at this point in the history
…s too much stuff
  • Loading branch information
ThanatosGit committed Aug 20, 2023
1 parent 035fd1b commit 05738ad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions open_samus_returns_rando/files/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"destination"
]
}
},
"reveal_map_on_start": {
"type": "boolean",
"default": false,
"description": "When true, the game will start with the whole map revealed"
}
},
"required": [
Expand Down
15 changes: 8 additions & 7 deletions open_samus_returns_rando/samus_returns_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ def _read_powerup_lua() -> bytes:
return Path(__file__).parent.joinpath("files", "randomizer_powerup.lua").read_bytes()


def create_custom_init(inventory: dict[str, int], starting_location: dict):
def create_custom_init(configuration: dict):
def _wrap(v: str):
return f'"{v}"'

starting_items = configuration["starting_items"]
starting_location = configuration["starting_location"]

# Game doesn't like to start if some fields are missing, like ITEM_WEAPON_POWER_BOMB_MAX
final_inventory = {
"ITEM_MAX_LIFE": 99,
Expand All @@ -49,7 +52,7 @@ def _wrap(v: str):
"ITEM_WEAPON_SUPER_MISSILE_MAX": 0,
"ITEM_WEAPON_POWER_BOMB_MAX": 0,
}
final_inventory.update(inventory)
final_inventory.update(starting_items)

replacement = {
"new_game_inventory": "\n".join(
Expand All @@ -58,9 +61,9 @@ def _wrap(v: str):
),
"starting_scenario": _wrap(starting_location["scenario"]),
"starting_actor": _wrap(starting_location["actor"]),
"reveal_map_on_start": configuration["reveal_map_on_start"],
}


return lua_util.replace_lua_template("custom_init.lua", replacement)

def patch_pickups(editor: PatcherEditor, pickups_config: list[dict]):
Expand Down Expand Up @@ -164,10 +167,8 @@ def patch(input_path: Path, output_path: Path, configuration: dict):
lua_util.create_script_copy(editor, "system/scripts/init")
editor.replace_asset(
"system/scripts/init.lc",
create_custom_init(
configuration["starting_items"],
configuration["starting_location"]
).encode("ascii"),
create_custom_init(configuration)
.encode("ascii"),
)

lua_util.replace_script(editor, "system/scripts/scenario", "custom_scenario.lua")
Expand Down
5 changes: 4 additions & 1 deletion open_samus_returns_rando/templates/custom_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ function Init.InitGameBlackboard()
function Init.InitNewGame(arg1, arg2, arg3, arg4, arg4)
Game.LogWarn(0, string.format("Will start Game - %s / %s / %s / %s", tostring(arg1), tostring(arg2), tostring(arg3), tostring(arg4)))
Game.LoadScenario("c10_samus", TEMPLATE("starting_scenario"), TEMPLATE("starting_actor"), "Samus", 1)
end
if TEMPLATE("reveal_map_on_start") then
Game.AddGUISF(0.0, Game.ScanVisitDiscoverEverything, "", "")
end
end

Game.SetForceSkipCutscenes(true)
Game.LogWarn(0, "Finished modded system/init.lc")

0 comments on commit 05738ad

Please sign in to comment.