-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4be16bd
commit e2a31e8
Showing
1 changed file
with
81 additions
and
9 deletions.
There are no files selected for viewing
90 changes: 81 additions & 9 deletions
90
open_samus_returns_rando/specific_patches/metroid_patches.py
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 |
---|---|---|
@@ -1,24 +1,96 @@ | ||
|
||
import logging | ||
|
||
from construct import ListContainer | ||
from mercury_engine_data_structures.formats import Bmsad | ||
|
||
from open_samus_returns_rando.constants import ALL_AREAS | ||
from open_samus_returns_rando.files import files_path | ||
from open_samus_returns_rando.patcher_editor import PatcherEditor | ||
|
||
LOG = logging.getLogger("metroid_patches") | ||
|
||
def patch_metroids(editor: PatcherEditor): | ||
METROID_DICTS = [ | ||
{ | ||
"file": "actors/characters/alpha/charclasses/alpha.bmsad", | ||
"death_index": 22, | ||
"function_index": 3 | ||
}, | ||
{ | ||
"file": "actors/characters/alphaevolved/charclasses/alphaevolved.bmsad", | ||
"death_index": 22, | ||
"function_index": 3 | ||
}, | ||
{ | ||
"file": "actors/characters/alphanewborn/charclasses/alphanewborn.bmsad", | ||
"death_index": 22, | ||
"function_index": 3 | ||
}, | ||
{ | ||
"file": "actors/characters/gamma/charclasses/gamma.bmsad", | ||
"death_index": 54, | ||
"function_index": 16 | ||
}, | ||
{ | ||
"file": "actors/characters/gammaevolved/charclasses/gammaevolved.bmsad", | ||
"death_index": 54, | ||
"function_index": 16 | ||
}, | ||
{ | ||
"file": "actors/characters/omega/charclasses/omega.bmsad", | ||
"death_index": 74, | ||
"function_index": 13 | ||
}, | ||
{ | ||
"file": "actors/characters/omegaevolved/charclasses/omegaevolved.bmsad", | ||
"death_index": 74, | ||
"function_index": 13 | ||
}, | ||
{ | ||
"file": "actors/characters/zeta/charclasses/zeta.bmsad", | ||
"death_index": 56, | ||
"function_index": 9 | ||
}, | ||
{ | ||
"file": "actors/characters/zetaevolved/charclasses/zetaevolved.bmsad", | ||
"death_index": 56, | ||
"function_index": 9 | ||
}, | ||
] | ||
|
||
editor.add_new_asset("actors/scripts/metroid.lc", files_path().joinpath("custom_metroid.lua").read_bytes(), []) | ||
for area_name in ALL_AREAS: | ||
editor.ensure_present_in_scenario(area_name, "actors/scripts/metroid.lc") | ||
|
||
for metroid_dict in METROID_DICTS: | ||
metroid_file = metroid_dict["file"] | ||
death_index = metroid_dict["death_index"] | ||
function_index = metroid_dict["function_index"] | ||
|
||
metroid_bmsad = editor.get_parsed_asset(metroid_file, type_hint=Bmsad) | ||
action_set_anim = metroid_bmsad.action_sets[0].raw["animations"][death_index] | ||
action_set_anim["events0"][function_index]["args"][601445949]["value"] = "RemoveMetroid" | ||
|
||
drop_component = metroid_bmsad.raw["components"]["DROP"] | ||
# weird case where some fields are defined two times | ||
if type(drop_component["fields"]) == ListContainer: | ||
drop_component["fields"][0]["value"]["value"] = 0.0 | ||
else: | ||
drop_component["fields"]["fADNProbability"]["value"] = 0.0 | ||
|
||
ai_component = metroid_bmsad.raw["components"]["AI"] | ||
# weird case where some fields are defined two times | ||
if type(ai_component["fields"]) == ListContainer: | ||
ai_component["fields"][94]["value"]["value"] = False | ||
ai_component["fields"][95]["value"]["value"] = False | ||
else: | ||
ai_component["fields"]["bRemovePlayerInputOnDeath"]["value"] = False | ||
ai_component["fields"]["bSetPlayerInvulnerableWithReactionOnDeath"]["value"] = False | ||
|
||
|
||
alpha = editor.get_parsed_asset("actors/characters/alpha/charclasses/alpha.bmsad", type_hint=Bmsad) | ||
action_set_anim = alpha.action_sets[0].raw["animations"][22] | ||
action_set_anim["events0"][3]["args"][601445949]["value"] = "RemoveMetroid" | ||
script_component = metroid_bmsad.raw["components"]["SCRIPT"] | ||
script_component["functions"][0]["params"]["Param1"]["value"] = "actors/scripts/metroid.lc" | ||
script_component["functions"][0]["params"]["Param2"]["value"] = "Metroid" | ||
|
||
alpha.raw["components"]["DROP"]["fields"]["fADNProbability"]["value"] = 0.0 | ||
alpha.raw["components"]["AI"]["fields"]["bRemovePlayerInputOnDeath"]["value"] = False | ||
alpha.raw["components"]["AI"]["fields"]["bSetPlayerInvulnerableWithReactionOnDeath"]["value"] = False | ||
alpha.raw["components"]["SCRIPT"]["functions"][0]["params"]["Param1"]["value"] = "actors/scripts/metroid.lc" | ||
alpha.raw["components"]["SCRIPT"]["functions"][0]["params"]["Param2"]["value"] = "Metroid" | ||
editor.replace_asset("actors/characters/alpha/charclasses/alpha.bmsad", alpha) | ||
editor.replace_asset(metroid_file, metroid_bmsad) |