-
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.
Duplicate all beam shields, add on death callback in doors.lua
- Loading branch information
1 parent
c65f03e
commit ef8849a
Showing
5 changed files
with
132 additions
and
46 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,17 @@ | ||
Doors = {} | ||
|
||
function Doors.Dummy() | ||
end | ||
function Doors.RemoveDoors(_ARG_0_) | ||
local actor_name = _ARG_0_.sName | ||
-- TOOD: Remove the debug message | ||
GUI.LaunchMessage(actor_name, "Doors.Dummy", "") | ||
local ending = string.sub(actor_name, -2) | ||
if ending == "_o" then | ||
actor_name = string.sub(actor_name, 0, -3) | ||
end | ||
Game.DeleteEntity(actor_name) | ||
Game.DeleteEntity(actor_name .. "_o") | ||
Scenario.WriteToBlackboard("entity_" .. actor_name .. "_dead", "b", true) | ||
Scenario.WriteToBlackboard("entity_" .. actor_name .. "_o_dead", "b", true) | ||
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
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
112 changes: 112 additions & 0 deletions
112
open_samus_returns_rando/specific_patches/door_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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
|
||
import copy | ||
|
||
from construct import Container, 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 | ||
|
||
SCRIPT_COMPONENT = Container({ | ||
"type": "CScriptComponent", | ||
"unk_1": 3000, | ||
"unk_2": -1.0, | ||
"functions": ListContainer([ | ||
Container({ | ||
"name": "SetParams", | ||
"unk1": True, | ||
"unk2": False, | ||
"params": Container({ | ||
"Param1": Container({ | ||
"type": "s", | ||
"value": "actors/props/doors/scripts/doors.lua", | ||
}), | ||
"Param2": Container({ | ||
"type" :"s", | ||
"value":"Doors", | ||
}), | ||
}), | ||
}), | ||
]), | ||
"fields": Container(), | ||
"dependencies": None, | ||
}) | ||
|
||
ON_DEAD_CB = Container({ | ||
"unk1": 22, | ||
"unk2": 1, | ||
"unk3": 0, | ||
"args": Container({ | ||
601445949: Container({ | ||
"type": "s", | ||
"value": "RemoveDoors", | ||
}), | ||
}), | ||
}) | ||
|
||
def _patch_missile_covers(editor: PatcherEditor): | ||
missile_types = {"doorshieldmissile", "doorshieldpowerbomb", "doorshieldsupermissile"} | ||
for area in ALL_AREAS: | ||
scenario = editor.get_scenario(area) | ||
for layer, actor_name, actor in scenario.all_actors(): | ||
if actor.type in missile_types: | ||
actor["unk06"] = 90 | ||
|
||
def _patch_beam_covers(editor: PatcherEditor): | ||
creature_bmsad_files = [ | ||
"actors/props/doorspazerbeam/charclasses/doorspazerbeam.bmsad", | ||
"actors/props/doorcreature/charclasses/doorcreature.bmsad", | ||
"actors/props/doorwave/charclasses/doorwave.bmsad", | ||
] | ||
for creature_bmsad_file in creature_bmsad_files: | ||
cr_bmsad = editor.get_parsed_asset(creature_bmsad_file, type_hint=Bmsad) | ||
cr_bmsad.raw["components"]["SCRIPT"] = SCRIPT_COMPONENT | ||
action_set_anim = cr_bmsad.action_sets[0].raw["animations"][0] | ||
action_set_anim.event_counts[0] = action_set_anim.event_counts[0] + 1 | ||
action_set_anim["events0"].append(ON_DEAD_CB) | ||
action_set_anim["animation_id"] = 30 | ||
editor.replace_asset(creature_bmsad_file, cr_bmsad) | ||
|
||
beam_types = {"doorwave", "doorspazerbeam", "doorcreature"} | ||
for area in ALL_AREAS: | ||
editor.ensure_present_in_scenario(area, "actors/props/doors/scripts/doors.lc") | ||
editor.ensure_present_in_scenario(area, "actors/props/doorspazerbeam/collisions/doorspazerbeam.bmscd") | ||
editor.ensure_present_in_scenario(area, "actors/props/doorspazerbeam/models/doorspazerbeam.bcmdl") | ||
scenario = editor.get_scenario(area) | ||
actor_list_copy = {actor_name: actor for layer, actor_name, actor in scenario.all_actors()} | ||
for actor_name, actor in actor_list_copy.items(): | ||
if actor.type in beam_types: | ||
new_actor_name = f"{actor_name}_o" | ||
new_actor = editor.copy_actor( | ||
area, (actor["x"], actor["y"], actor["z"]), actor, new_actor_name, 9 | ||
) | ||
if new_actor["unk06"] == 0.0: | ||
new_actor["unk05"] = 0 | ||
new_actor["unk06"] = 180 | ||
new_actor["unk07"] = 0 | ||
elif new_actor["unk06"] == 180.0: | ||
new_actor["unk05"] = 0 | ||
new_actor["unk06"] = 0 | ||
new_actor["unk07"] = 0 | ||
else: | ||
# that one is weird (because of fake surface west ?) | ||
if area == "s000_surface" and actor_name == "LE_SpazerShield_Door_012": | ||
continue | ||
raise Exception | ||
|
||
# no idea if this really gets the right door | ||
door_name = actor_name[actor_name.find("Door"):] | ||
door_name = door_name.replace("ShieldPlasma", "").replace("ShieldWave", "") | ||
door_actor = actor_list_copy.get(door_name, None) | ||
if door_actor is None: | ||
door_actor = actor_list_copy[door_name.replace("_", "")] | ||
door_actor.components.append(copy.deepcopy(door_actor.components[0])) | ||
door_actor.components[1]["arguments"][3]["value"] = new_actor_name | ||
|
||
def patch_shields(editor: PatcherEditor): | ||
# TODO: Commit MEDS changes | ||
editor.add_new_asset("actors/props/doors/scripts/doors.lc", files_path().joinpath("doors.lua").read_bytes(), []) | ||
|
||
_patch_missile_covers(editor) | ||
_patch_beam_covers(editor) |
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