Skip to content

Commit

Permalink
exclude plasma in area1, change wave collision
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanatosGit authored and dyceron committed Sep 27, 2023
1 parent a67814f commit 78d0540
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
13 changes: 9 additions & 4 deletions open_samus_returns_rando/files/doors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ function Doors.RemoveDoors(_ARG_0_)
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)

if Game.GetEntity(actor_name) ~= nil then
Game.DeleteEntity(actor_name)
Scenario.WriteToBlackboard("entity_" .. actor_name .. "_dead", "b", true)
end
if Game.GetEntity(actor_name .. "_o") ~= nil then
Game.DeleteEntity(actor_name .. "_o")
Scenario.WriteToBlackboard("entity_" .. actor_name .. "_o_dead", "b", true)
end
end
39 changes: 31 additions & 8 deletions open_samus_returns_rando/specific_patches/door_patches.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import copy
import logging

from construct import Container, ListContainer
from mercury_engine_data_structures.formats import Bmsad
Expand All @@ -8,6 +9,9 @@
from open_samus_returns_rando.files import files_path
from open_samus_returns_rando.patcher_editor import PatcherEditor

# TODO: Remove it if we don't log anything after tests
LOG = logging.getLogger("door_patches")

SCRIPT_COMPONENT = Container({
"type": "CScriptComponent",
"unk_1": 3000,
Expand Down Expand Up @@ -54,12 +58,18 @@ def _patch_missile_covers(editor: PatcherEditor):
actor["rotation"][1] = 90

def _patch_beam_covers(editor: PatcherEditor):
EXCLUDES_PER_AREA = {
"s010_area1": [
"LE_DoorShieldPlasma011"
]
}

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:
for i, creature_bmsad_file in enumerate(creature_bmsad_files):
cr_bmsad = editor.get_parsed_asset(creature_bmsad_file, type_hint=Bmsad)
# add the script component, which defines the lua file where it finds functions
cr_bmsad.raw["components"]["SCRIPT"] = SCRIPT_COMPONENT
Expand All @@ -70,18 +80,28 @@ def _patch_beam_covers(editor: PatcherEditor):
# wave cb didn't work and it has animation id 21.it's maybe a bitmask? because it works
# with 29 and also with 30 (which the other two are using) and both are setting 2^3 bit
action_set_anim["animation_id"] = 30
# modify doorwave collision
if i == 2:
# Param6 and Param7 seems to be a position
cr_bmsad.components["COLLISION"].functions[1].params["Param7"].value = 148.0
# Param9 and Param10 are a rectangular
cr_bmsad.components["COLLISION"].functions[1].params["Param9"].value = 370.0
cr_bmsad.components["COLLISION"].functions[1].params["Param10"].value = 300.0
editor.replace_asset(creature_bmsad_file, cr_bmsad)

# TODO: remove it
test_door = True
beam_types = {"doorwave", "doorspazerbeam", "doorcreature"}
for area in ALL_AREAS:
editor.ensure_present_in_scenario(area, "actors/props/doors/scripts/doors.lc")
scenario = editor.get_scenario(area)
for area_name in ALL_AREAS:
editor.ensure_present_in_scenario(area_name, "actors/props/doors/scripts/doors.lc")
scenario = editor.get_scenario(area_name)
actor_list_copy = {actor_name: actor for layer, actor_name, actor in scenario.all_actors()}
excludes_of_area = EXCLUDES_PER_AREA.get(area_name, [])
for actor_name, actor in actor_list_copy.items():
if actor.type in beam_types:
if actor.type in beam_types and actor_name not in excludes_of_area:
new_actor_name = f"{actor_name}_o"
new_actor = editor.copy_actor(
area, (actor["position"][0], actor["position"][1], actor["position"][2]),
area_name, (actor["position"][0], actor["position"][1], actor["position"][2]),
actor, new_actor_name, 9
)
if new_actor["rotation"][1] == 0.0:
Expand All @@ -94,7 +114,7 @@ def _patch_beam_covers(editor: PatcherEditor):
new_actor["rotation"][2] = 0
else:
# that one is weird (because of fake surface west ?)
if area == "s000_surface" and actor_name == "LE_SpazerShield_Door_012":
if area_name == "s000_surface" and actor_name == "LE_SpazerShield_Door_012":
continue
raise Exception

Expand All @@ -107,8 +127,11 @@ def _patch_beam_covers(editor: PatcherEditor):
door_actor.components.append(copy.deepcopy(door_actor.components[0]))
door_actor.components[1]["arguments"][3]["value"] = new_actor_name

if actor.type == "doorwave" and test_door:
test_door = False
editor.copy_actor(area_name, (-15900.000, 1350.0, 0.0), actor, "COPY", 9)

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)
Expand Down

0 comments on commit 78d0540

Please sign in to comment.