From 4ccd261beb85238ea6e6bcfa07cb0bc79ea83742 Mon Sep 17 00:00:00 2001 From: Thanatos Date: Fri, 22 Sep 2023 16:02:33 +0200 Subject: [PATCH] Reuse original lua, add the same for samusship --- .../files/custom_savestation.lua | 14 +++++++ .../files/custom_ship.lua | 14 +++++++ .../files/savestation.lua | 37 ------------------- open_samus_returns_rando/lua_editor.py | 2 - .../samus_returns_patcher.py | 2 + 5 files changed, 30 insertions(+), 39 deletions(-) create mode 100644 open_samus_returns_rando/files/custom_savestation.lua create mode 100644 open_samus_returns_rando/files/custom_ship.lua delete mode 100644 open_samus_returns_rando/files/savestation.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/savestation.lua b/open_samus_returns_rando/files/savestation.lua deleted file mode 100644 index 5a5cf99..0000000 --- a/open_samus_returns_rando/files/savestation.lua +++ /dev/null @@ -1,37 +0,0 @@ -Game.ImportLibraryWithName("actors/props/usable/scripts/usable.lua", "Usable") -SaveStation = {} -setmetatable(SaveStation, {__index = Usable}) -function SaveStation.OnStart(_ARG_0_, _ARG_1_) - local platform = Game.GetEntity("LE_Platform_" .. string.sub(_ARG_0_.sName, 4)) - if platform ~= nil then - platform.SMARTOBJECT:OnStartUse(_ARG_0_.sName) - end -end -function SaveStation.OnLevelChangeUse(_ARG_0_, _ARG_1_, _ARG_2_) - if not Game.PreviousLoadWasReload() and Game.GetPreviousGameMode() == "MAINMENU" then - Game.SetSFXMuted(true) - Game.PlayMusicStream(0, "streams/music/matad_jintojo_32728k.wav", -1, -1, 0, 0, 0, 0) - if _ARG_0_.FX ~= nil then - _ARG_0_.FX:SetEffectEnabled("glitchSpawn", true, true) - end - end -end -function SaveStation.OnLevelChangeUseEnd(_ARG_0_, _ARG_1_, _ARG_2_) - Game.SetSFXMuted(false) - if _ARG_0_.FX ~= nil then - _ARG_0_.FX:SetEffectEnabled("glitchSpawn", false, false) - end -end -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/lua_editor.py b/open_samus_returns_rando/lua_editor.py index 978a333..3edb24a 100644 --- a/open_samus_returns_rando/lua_editor.py +++ b/open_samus_returns_rando/lua_editor.py @@ -112,7 +112,5 @@ def save_modifications(self, editor: PatcherEditor): editor.replace_asset("actors/items/randomizer_powerup/scripts/randomizer_powerup.lc", self._powerup_script) editor.replace_asset("actors/props/heatzone/scripts/heatzone.lc", files_path().joinpath("heatzone.lua").read_bytes()) - editor.replace_asset("actors/props/savestation/scripts/savestation.lc", - files_path().joinpath("savestation.lua").read_bytes()) for scenario, script in self._custom_level_scripts.items(): editor.replace_asset(path_for_level(scenario) + ".lc", script["script"].encode("utf-8")) 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"])