From 9c68bca8c08cef75418c276f97d6eccc648a70af Mon Sep 17 00:00:00 2001 From: Thanatos <117127188+ThanatosGit@users.noreply.github.com> Date: Fri, 22 Sep 2023 23:18:53 +0200 Subject: [PATCH] Add warp to start via "Cancel" the save and then get a second dialog (#101) * Add warp to start via "Cancel" the save and then get a second dialog * Reuse original lua, add the same for samusship --- .../files/custom_savestation.lua | 14 ++++++++++++++ open_samus_returns_rando/files/custom_ship.lua | 14 ++++++++++++++ .../files/templates/custom_init.lua | 4 +++- open_samus_returns_rando/samus_returns_patcher.py | 2 ++ tests/test_files/starter_preset_patcher.json | 4 +++- 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 open_samus_returns_rando/files/custom_savestation.lua create mode 100644 open_samus_returns_rando/files/custom_ship.lua diff --git a/open_samus_returns_rando/files/custom_savestation.lua b/open_samus_returns_rando/files/custom_savestation.lua new file mode 100644 index 0000000..d3b780a --- /dev/null +++ b/open_samus_returns_rando/files/custom_savestation.lua @@ -0,0 +1,14 @@ +Game.ImportLibrary("actors/props/savestation/scripts/savestation_original.lc") +function SaveStation.ShowDialogChoice(_ARG_0_, _ARG_1_) + Usable._oUsableObject = _ARG_0_ + GUI.LaunchMessage(_ARG_1_, "Usable.OnDialogAccepted", "SaveStation.OnDialogDeclined") +end +function SaveStation.Dummy() +end +function SaveStation.WarpToStart() + Game.LoadScenario("c10_samus", Init.sStartingScenario, Init.sStartingActor, "samus", 1) +end +function SaveStation.OnDialogDeclined() + Usable._oUsableObject.USABLE:OnDialogDeclined() + GUI.LaunchMessage("Warp to Start?", "SaveStation.WarpToStart", " SaveStation.Dummy()") +end \ No newline at end of file diff --git a/open_samus_returns_rando/files/custom_ship.lua b/open_samus_returns_rando/files/custom_ship.lua new file mode 100644 index 0000000..a15967f --- /dev/null +++ b/open_samus_returns_rando/files/custom_ship.lua @@ -0,0 +1,14 @@ +Game.ImportLibrary("actors/props/samusship/scripts/samusship_original.lc") +function SamusShip.ShowDialogChoice(_ARG_0_, _ARG_1_) + Usable._oUsableObject = _ARG_0_ + GUI.LaunchMessage(_ARG_1_, "Usable.OnDialogAccepted", "SamusShip.OnDialogDeclined") +end +function SamusShip.Dummy() +end +function SamusShip.WarpToStart() + Game.LoadScenario("c10_samus", Init.sStartingScenario, Init.sStartingActor, "samus", 1) +end +function SamusShip.OnDialogDeclined() + Usable._oUsableObject.USABLE:OnDialogDeclined() + GUI.LaunchMessage("Warp to Start?", "SamusShip.WarpToStart", " SamusShip.Dummy()") +end \ No newline at end of file diff --git a/open_samus_returns_rando/files/templates/custom_init.lua b/open_samus_returns_rando/files/templates/custom_init.lua index 74bd589..20e93a3 100644 --- a/open_samus_returns_rando/files/templates/custom_init.lua +++ b/open_samus_returns_rando/files/templates/custom_init.lua @@ -3,6 +3,8 @@ Game.ImportLibrary("system/scripts/init_original.lua") Init.tNewGameInventory = TEMPLATE("new_game_inventory") Init.bRevealMap = TEMPLATE("reveal_map_on_start") +Init.sStartingScenario = TEMPLATE("starting_scenario") +Init.sStartingActor = TEMPLATE("starting_actor") Game.LogWarn(0, "Inventory:") for k, v in pairs(Init.tNewGameInventory) do @@ -38,7 +40,7 @@ end 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) + Game.LoadScenario("c10_samus", Init.sStartingScenario, Init.sStartingActor, "samus", 1) if Init.bRevealMap then Game.AddGUISF(0.0, Game.ScanVisitDiscoverEverything, "", "") end diff --git a/open_samus_returns_rando/samus_returns_patcher.py b/open_samus_returns_rando/samus_returns_patcher.py index b0d8519..e36932c 100644 --- a/open_samus_returns_rando/samus_returns_patcher.py +++ b/open_samus_returns_rando/samus_returns_patcher.py @@ -120,6 +120,8 @@ def patch_extracted(input_path: Path, output_path: Path, configuration: dict): # Add custom lua files lua_util.replace_script(editor, "system/scripts/scenario", "custom_scenario.lua") lua_util.replace_script(editor, "actors/characters/player/scripts/player", "custom_player.lua") + lua_util.replace_script(editor, "actors/props/samusship/scripts/samusship", "custom_ship.lua") + lua_util.replace_script(editor, "actors/props/savestation/scripts/savestation", "custom_savestation.lua") # Custom pickups patch_custom_pickups(editor, configuration["custom_pickups"]) diff --git a/tests/test_files/starter_preset_patcher.json b/tests/test_files/starter_preset_patcher.json index 5004cbd..7ddfa96 100644 --- a/tests/test_files/starter_preset_patcher.json +++ b/tests/test_files/starter_preset_patcher.json @@ -14,7 +14,9 @@ "ITEM_ENERGY_TANKS": 2, "ITEM_AEION_TANKS": 3, "ITEM_WEAPON_BOMB": 1, - "ITEM_WEAPON_WAVE_BEAM": 1 + "ITEM_WEAPON_WAVE_BEAM": 1, + "ITEM_METROID_COUNT": 0, + "ITEM_METROID_TOTAL_COUNT": 40 }, "pickups": [ {