Skip to content

Commit

Permalink
Add warp to start via "Cancel" the save and then get a second dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanatosGit committed Sep 22, 2023
1 parent 5c8e66f commit d8a1914
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
37 changes: 37 additions & 0 deletions open_samus_returns_rando/files/savestation.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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
4 changes: 3 additions & 1 deletion open_samus_returns_rando/files/templates/custom_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions open_samus_returns_rando/lua_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@ 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"))
4 changes: 3 additions & 1 deletion tests/test_files/starter_preset_patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down

0 comments on commit d8a1914

Please sign in to comment.