Skip to content

Commit

Permalink
Remote connector (#316)
Browse files Browse the repository at this point in the history
* Add inventory index

* Add location identifiers

* Collected Indices

* Integrate game state

* Add simple disconnect text

* Received pickups

* Integration for remote pickups

* Update schema.json

* Add required patches

* Forgotten changes

* Update code.bps

* Add region specific patches and fully integrate for randovania

* Add BPS file for NTSC

* Ensure the path to exheader exists

* Escape ' for multiworld integration

* Update HUD for tanks => required for multiworld

* mypy + merge

* Change Hash / Cache to contain caption (multiworld relevant)

* Untested fix for offworld DNA

* Remove MessageGUI, add Disconnect text

* Update HUD for all items recieved

* Add disconnected icon

---------

Co-authored-by: dyceron <[email protected]>
  • Loading branch information
ThanatosGit and dyceron authored Jun 9, 2024
1 parent fe9de84 commit aa4852f
Show file tree
Hide file tree
Showing 33 changed files with 322 additions and 77 deletions.
4 changes: 2 additions & 2 deletions src/open_samus_returns_rando/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from .patch_util import patch_with_status_update


def patch(input_path: Path, output_path: Path, configuration: dict) -> None:
def patch(input_path: Path, input_exheader: Path, output_path: Path, configuration: dict) -> None:
from .samus_returns_patcher import patch_extracted
return patch_extracted(input_path, output_path, configuration)
return patch_extracted(input_path, input_exheader, output_path, configuration)


__all__ = [
Expand Down
3 changes: 3 additions & 0 deletions src/open_samus_returns_rando/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def create_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser()
parser.add_argument("--input-path", required=True, type=Path,
help="Path to where the extracted Metroid: Samus Returns romfs to randomize can be found.")
parser.add_argument("--input-exheader", required=False, type=Path,
help="Path to where the decrypted exheader can be found.")
parser.add_argument("--output-path", required=True, type=Path,
help="Path to where the modified files will be written to.")
parser.add_argument("--input-json", type=Path,
Expand Down Expand Up @@ -60,6 +62,7 @@ def main() -> None:

samus_returns_patcher.patch_extracted(
args.input_path,
args.input_exheader,
args.output_path,
configuration,
)
59 changes: 46 additions & 13 deletions src/open_samus_returns_rando/files/custom/guilib.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

GUILib = GUILib or {}

function GUILib.InitCustomUI()
Expand Down Expand Up @@ -81,72 +80,72 @@ function GUILib.AddMessageBox()
if randoUI ~= nil then
GUI.DestroyDisplayObject(randoUI)
end
local ussef = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.USSEF")
local outer = GUI.CreateDisplayObjectEx("Outer", "CDisplayObjectContainer", {
local ussef = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.USSEF")
local outer = GUI.CreateDisplayObjectEx("Outer", "CDisplayObjectContainer", {
StageID = "Up",
X = "0.038",
Y = "0.829",
Visible = false
})
local topL = GUI.CreateDisplayObjectEx("TopL", "CSprite", {
local topL = GUI.CreateDisplayObjectEx("TopL", "CSprite", {
X = "0.0",
Y = "0.0",
Visible = true,
SpriteSheetItem = "TutorialWindowTop"
})
local topR = GUI.CreateDisplayObjectEx("TopR", "CSprite", {
local topR = GUI.CreateDisplayObjectEx("TopR", "CSprite", {
X = "0.462",
Y = "0.0",
FlipX = true,
Visible = true,
SpriteSheetItem = "TutorialWindowTop"
})
local hiMidL = GUI.CreateDisplayObjectEx("hiMidL", "CSprite", {
local hiMidL = GUI.CreateDisplayObjectEx("hiMidL", "CSprite", {
X = "0.0",
Y = "0.024",
Visible = true,
SpriteSheetItem = "TutorialWindowMid"
})
local hiMidR = GUI.CreateDisplayObjectEx("hiMidR", "CSprite", {
local hiMidR = GUI.CreateDisplayObjectEx("hiMidR", "CSprite", {
X = "0.462",
Y = "0.024",
FlipX = true,
Visible = true,
SpriteSheetItem = "TutorialWindowMid"
})
local loMidL = GUI.CreateDisplayObjectEx("loMidL", "CSprite", {
local loMidL = GUI.CreateDisplayObjectEx("loMidL", "CSprite", {
X = "0.0",
Y = "0.083",
Visible = true,
SpriteSheetItem = "TutorialWindowMid"
})
local loMidR = GUI.CreateDisplayObjectEx("loMidR", "CSprite", {
local loMidR = GUI.CreateDisplayObjectEx("loMidR", "CSprite", {
X = "0.462",
Y = "0.083",
FlipX = true,
Visible = true,
SpriteSheetItem = "TutorialWindowMid"
})
local bottomL = GUI.CreateDisplayObjectEx("BotL", "CSprite", {
local bottomL = GUI.CreateDisplayObjectEx("BotL", "CSprite", {
X = "0.0",
Y = "0.141",
Visible = true,
SpriteSheetItem = "TutorialWindowBot"
})
local bottomR = GUI.CreateDisplayObjectEx("BotR", "CSprite", {
local bottomR = GUI.CreateDisplayObjectEx("BotR", "CSprite", {
X = "0.462",
Y = "0.142",
FlipX = true,
Visible = true,
SpriteSheetItem = "TutorialWindowBot"
})
local firstLine = GUI.CreateDisplayObjectEx("firstLine", "CText", {
local firstLine = GUI.CreateDisplayObjectEx("firstLine", "CText", {
X = "-0.038",
Font = "digital_medium",
TextAlignment = "Centered",
Visible = true,
})
local secondLine = GUI.CreateDisplayObjectEx("secondLine", "CText", {
local secondLine = GUI.CreateDisplayObjectEx("secondLine", "CText", {
X = "-0.038",
Y = "0.080",
Font = "digital_medium",
Expand All @@ -165,9 +164,34 @@ function GUILib.AddMessageBox()
outer:AddChild(firstLine)
outer:AddChild(secondLine)

local disconnectLine = GUI.CreateDisplayObjectEx("disconnected", "CText", {
X = "-0.30",
Y = "0.05",
Font = "digital_medium",
Text= "Disconnected!",
TextAlignment = "Centered",
ColorR = 0.9, ColorG = 0.1, ColorB = 0.1,
BlinkColorR = "0.9", BlinkColorG = "0.1", BlinkColorB = "0.1", BlinkAlpha = "1.00000", Blink = "2.00000",
Visible = false
})
ussef:AddChild(disconnectLine)
local disconnectIcon = GUI.CreateDisplayObjectEx("disconnectedicon", "CSprite", {
X = "0.03",
Y = "0.05",
SizeX = "0.05",
SizeY = "0.07",
Visible = false,
ColorR = 0.9, ColorG = 0.1, ColorB = 0.1,
Blink = "2.00000",
SpriteSheetItem = "IconX_01"
})
ussef:AddChild(disconnectIcon)

GUILib.outer = outer
GUILib.firstLine = firstLine
GUILib.secondLine = secondLine
GUILib.disconnectLine = disconnectLine
GUILib.disconnectIcon = disconnectIcon
end

function GUILib.split(source, delimiters)
Expand Down Expand Up @@ -204,4 +228,13 @@ function GUILib.HideMessage()
GUI.SetProperties(GUILib.outer, {
Visible = false
})
end

function GUILib.UpdateConnected(visible)
GUI.SetProperties(GUILib.disconnectLine, {
Visible = visible
})
GUI.SetProperties(GUILib.disconnectIcon, {
Visible = visible
})
end
28 changes: 27 additions & 1 deletion src/open_samus_returns_rando/files/custom/scenario.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ setmetatable(Scenario, {__index = _G})

Scenario.tProgressiveModels = {}

Scenario.INVALID_UUID = "00000000-0000-1111-0000-000000000000"

local original_enable = Scenario.EnableHazarous
function Scenario.EnableHazarous(_ARG_0_, _ARG_1_)
if CurrentScenario.OnHazarousPoolDrain ~= nil then
Expand Down Expand Up @@ -63,6 +65,22 @@ function Scenario.InitGUI()
if Init.bEnableRoomIds then
RoomNameGui.Init()
end

-- INVALID_UUID = no multiworld => no need to schedule the check
if Init.sLayoutUUID ~= Scenario.INVALID_UUID then
if Scenario.checkConnectionSFID ~= nil then
Game.DelSFByID(Scenario.checkConnectionSFID)
end
Scenario.checkConnectionSFID = Game.AddGUISF(2, "Scenario.CheckConnectionState", "")
end

-- delete all SF functions
if Scenario.hideSFID ~= nil then
Game.DelSFByID(Scenario.hideSFID)
-- hide old popup
Scenario.HideAsyncPopup()
end

end

function Scenario.UpdateDNACounter()
Expand Down Expand Up @@ -94,7 +112,6 @@ function Scenario.InitScenario(_ARG_0_, _ARG_1_, _ARG_2_, _ARG_3_)
end

Scenario.UpdateProgressiveItemModels()

if Scenario.showNextSFID ~= nil then
Game.DelSFByID(Scenario.showNextSFID)
Scenario.showNextSFID = nil
Expand All @@ -106,6 +123,8 @@ function Scenario.InitScenario(_ARG_0_, _ARG_1_, _ARG_2_, _ARG_3_)
Scenario.HideAsyncPopup()
end

RL.UpdateRDVClient(true)

-- Only required for ils test code
-- if Scenario.CurrentScenarioID == "s000_surface" then
-- local next_number = (NextScenario % 17) + 1
Expand All @@ -115,6 +134,8 @@ function Scenario.InitScenario(_ARG_0_, _ARG_1_, _ARG_2_, _ARG_3_)
-- else
-- Game.AddSF(1.0, "Game.KillPlayer", "")
-- end
else
RL.GetGameStateAndSend()
end
end

Expand All @@ -140,6 +161,11 @@ function Scenario.LoadNewScenario(target_scenario, target_spawnpoint)
Game.ForceConvertToSamus()
end

function Scenario.CheckConnectionState()
GUILib.UpdateConnected(not RL.Connected())
Scenario.checkConnectionSFID = Game.AddGUISF(2, "Scenario.CheckConnectionState", "")
end

local fatal_messages_seen = 0
local fatal_messages
function Scenario._ShowNextFatalErrorMessage()
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RandomizerBabyHatchling = RandomizerBabyHatchling or {}
function RandomizerBabyHatchling.main()
end

function RandomizerBabyHatchling.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression)
function RandomizerBabyHatchling.OnPickedUp(progression, actorOrName)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
Game.GetDefaultPlayer("Samus").BABYHATCHLINGCREATION:SpawnBaby()
Game.GetEntity("Baby Hatchling").vPos = Game.GetDefaultPlayer("Samus").vPos
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RandomizerEnergyShield = RandomizerEnergyShield or {}
function RandomizerEnergyShield.main()
end

function RandomizerEnergyShield.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression)
function RandomizerEnergyShield.OnPickedUp(progression, actorOrName)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
Player.SetAbilityUnlocked("EnergyShield", true)
end
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function RandomizerEnergyTank.IncreaseEnergy()
life.fCurrentLife = new_max
end

function RandomizerEnergyTank.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression)
function RandomizerEnergyTank.OnPickedUp(progression, actorOrName)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
RandomizerEnergyTank.IncreaseEnergy()
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Game.ImportLibrary("actors/items/randomizerpowerup/scripts/randomizerpowerup.lc"
RandomizerEnergyWave = RandomizerEnergyWave or {}
function RandomizerEnergyWave.main()
end
function RandomizerEnergyWave.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression)
function RandomizerEnergyWave.OnPickedUp(progression, actorOrName)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
Player.SetAbilityUnlocked("EnergyWave", true)
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RandomizerMissileLauncher = RandomizerMissileLauncher or {}
function RandomizerMissileLauncher.main()
end

function RandomizerMissileLauncher.OnPickedUp(progression)
function RandomizerMissileLauncher.OnPickedUp(progression, actorOrName)
local locked_missiles = RandomizerPowerup.GetItemAmount("ITEM_MISSILE_TANKS")
for _, outer in ipairs(progression) do
for _, inner in ipairs(outer) do
Expand All @@ -13,7 +13,7 @@ function RandomizerMissileLauncher.OnPickedUp(progression)
end
end
end
RandomizerPowerup.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
RandomizerPowerup.SetItemAmount("ITEM_MISSILE_TANKS", 0)
RandomizerPowerup.IncreaseMissileCheckValue()
if RandomizerPowerup.GetItemAmount("ITEM_RESERVE_TANK_MISSILE") > 0 then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RandomizerMissileTank = RandomizerMissileTank or {}
function RandomizerMissileTank.main()
end

function RandomizerMissileTank.OnPickedUp(progression)
function RandomizerMissileTank.OnPickedUp(progression, actorOrName)
-- if we have main item use missile max else use locked missiles
local new_item_id = "ITEM_MISSILE_TANKS"
local is_main_unlocked = RandomizerPowerup.GetItemAmount("ITEM_WEAPON_MISSILE_LAUNCHER") > 0
Expand All @@ -16,6 +16,6 @@ function RandomizerMissileTank.OnPickedUp(progression)
inner.item_id = new_item_id
end
end
RandomizerPowerup.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
RandomizerPowerup.IncreaseMissileCheckValue()
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RandomizerPhaseDisplacement = RandomizerPhaseDisplacement or {}
function RandomizerPhaseDisplacement.main()
end

function RandomizerPhaseDisplacement.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression)
function RandomizerPhaseDisplacement.OnPickedUp(progression, actorOrName)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
Player.SetAbilityUnlocked("PhaseDisplacement", true)
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RandomizerPowerBomb = RandomizerPowerBomb or {}
function RandomizerPowerBomb.main()
end

function RandomizerPowerBomb.OnPickedUp(progression)
function RandomizerPowerBomb.OnPickedUp(progression, actorOrName)
local locked_pbs = RandomizerPowerup.GetItemAmount("ITEM_POWER_BOMB_TANKS")
for _, outer in ipairs(progression) do
for _, inner in ipairs(outer) do
Expand All @@ -13,6 +13,6 @@ function RandomizerPowerBomb.OnPickedUp(progression)
end
end
end
RandomizerPowerup.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
RandomizerPowerup.SetItemAmount("ITEM_POWER_BOMB_TANKS", 0)
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RandomizerPowerBombTank = RandomizerPowerBombTank or {}
function RandomizerPowerBombTank.main()
end

function RandomizerPowerBombTank.OnPickedUp(progression)
function RandomizerPowerBombTank.OnPickedUp(progression, actorOrName)
-- if we have main item use power bomb max else use locked power bombs
local new_item_id = "ITEM_POWER_BOMB_TANKS"
local is_main_unlocked = RandomizerPowerup.GetItemAmount("ITEM_WEAPON_POWER_BOMB") > 0
Expand All @@ -17,5 +17,5 @@ function RandomizerPowerBombTank.OnPickedUp(progression)
inner.item_id = new_item_id
end
end
RandomizerPowerup.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RandomizerReserveTankA = RandomizerReserveTankA or {}
function RandomizerReserveTankA.main()
end

function RandomizerReserveTankA.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression)
function RandomizerReserveTankA.OnPickedUp(progression, actorOrName)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
Blackboard.SetProp("GAME", "ITEM_RESERVE_TANK_SPECIAL_ENERGY_ACTIVE", "b", true)
Blackboard.SetProp("GAME", "ITEM_RESERVE_TANK_SPECIAL_ENERGY_FULL", "b", true)
local reserve = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.UpperComposition.StatusComposition.ReserveTankS")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RandomizerReserveTankE = RandomizerReserveTankE or {}
function RandomizerReserveTankE.main()
end

function RandomizerReserveTankE.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression)
function RandomizerReserveTankE.OnPickedUp(progression, actorOrName)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
Blackboard.SetProp("GAME", "ITEM_RESERVE_TANK_LIFE_ACTIVE", "b", true)
Blackboard.SetProp("GAME", "ITEM_RESERVE_TANK_LIFE_FULL", "b", true)
local reserve = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.UpperComposition.StatusComposition.ReserveTankE")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RandomizerReserveTankM = RandomizerReserveTankM or {}
function RandomizerReserveTankM.main()
end

function RandomizerReserveTankM.OnPickedUp(progression)
RandomizerPowerup.OnPickedUp(progression)
function RandomizerReserveTankM.OnPickedUp(progression, actorOrName)
RandomizerPowerup.OnPickedUp(progression, actorOrName)
if RandomizerPowerup.GetItemAmount("ITEM_WEAPON_MISSILE_LAUNCHER") > 0 then
RandomizerPowerup.EnableMissileReserveTank()
end
Expand Down
Loading

0 comments on commit aa4852f

Please sign in to comment.