-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #510 from randovania/rando-api
Implement RandoAPI
- Loading branch information
Showing
11 changed files
with
156 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from pathlib import Path | ||
|
||
from open_samus_returns_rando.files import files_path | ||
|
||
|
||
def create_exefs_patches( | ||
out_code: Path, out_exheader: Path, input_code: bytes | None, input_exheader: bytes | ||
) -> None: | ||
if input_code is None: | ||
raise ValueError("Could not get decompressed + decrypted code binary") | ||
|
||
import ips # type: ignore | ||
|
||
# code.bin patching | ||
code_ips_path = files_path().joinpath("exefs_patches", "code.ips") | ||
out_code.parent.mkdir(parents=True, exist_ok=True) | ||
with ( | ||
Path.open(code_ips_path, "rb") as code_ips, | ||
Path.open(out_code, "wb") as result | ||
): | ||
content = code_ips.read() | ||
patch = ips.Patch.load(content) | ||
patch.apply(input_code, result) | ||
|
||
# exheader.bin patching | ||
# Citra and Luma don't support patching the exheader. User needs to provide it as input and | ||
# here the patch is just applied | ||
exheader_ips_path = files_path().joinpath("exefs_patches", "exheader.ips") | ||
out_exheader.parent.mkdir(parents=True, exist_ok=True) | ||
with ( | ||
Path.open(exheader_ips_path, "rb") as exheader_ips, | ||
Path.open(out_exheader, "wb") as result | ||
): | ||
content = exheader_ips.read() | ||
patch = ips.Patch.load(content) | ||
patch.apply(input_exheader, result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Game.ImportLibrary("actors/items/randomizerpowerup/scripts/randomizerpowerup.lc", false) | ||
|
||
RandoApi = RandoApi or { | ||
ChangeSuitValues = function(hasVaria, hasGravity) end, | ||
ChangeBeams = function(hasWave, hasSpazer, hasPlasma, dmgSpazer, dmgPlasma, dmgPlasmaWave, dmgPlasmaSpazer) end | ||
} | ||
|
||
function RandoApi.main() | ||
end | ||
|
||
function RandoApi.CheckSuits() | ||
local hasVaria = RandomizerPowerup.GetItemAmount("ITEM_VARIA_SUIT") > 0 | ||
local hasGravity = RandomizerPowerup.GetItemAmount("ITEM_GRAVITY_SUIT") > 0 | ||
|
||
-- Update damage reductions based on the suits | ||
RandoApi.ChangeSuitValues(hasVaria, hasGravity) | ||
|
||
-- Model and damage_alarm updates | ||
if hasGravity then | ||
Game.GetEntity("Samus").MODELUPDATER.sModelAlias = "Gravity" | ||
if hasVaria then | ||
Game.GetPlayer():StopEntityLoopWithFade("actors/samus/damage_alarm.wav", 0.6) | ||
end | ||
elseif hasVaria then | ||
Game.GetEntity("Samus").MODELUPDATER.sModelAlias = "Varia" | ||
Game.GetPlayer():StopEntityLoopWithFade("actors/samus/damage_alarm.wav", 0.6) | ||
end | ||
end | ||
|
||
function RandoApi.CheckBeams() | ||
local hasWave = RandomizerPowerup.GetItemAmount("ITEM_WEAPON_WAVE_BEAM") > 0 | ||
local hasSpazer = RandomizerPowerup.GetItemAmount("ITEM_WEAPON_SPAZER_BEAM") > 0 | ||
local hasPlasma = RandomizerPowerup.GetItemAmount("ITEM_WEAPON_PLASMA_BEAM") > 0 | ||
|
||
-- Damage values are Solo Spazer, Solo Plasma, Plasma + Wave, and Plasma + Spazer, respctively | ||
RandoApi.ChangeBeams(hasWave, hasSpazer, hasPlasma, 40, 75, 90, 82.5) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.