Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all pickup models display properly #89

Merged
merged 19 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,78 @@
"fields": {},
"dependencies": []
},
"FX": {
"type": "CFXComponent",
"unk_1": 1500,
"unk_2": 0.0,
"functions": [
{
"name": "FXCreateAndLink",
"unk1": true,
"unk2": false,
"params": {
"Param1": {
"type": "s",
"value": ""
},
"Param2": {
"type": "s",
"value": ""
},
"Param3": {
"type": "s",
"value": ""
},
"Param4": {
"type": "s",
"value": ""
},
"Param5": {
"type": "i",
"value": 0
},
"Param6": {
"type": "i",
"value": 4
},
"Param7": {
"type": "f",
"value": 0.0
},
"Param8": {
"type": "f",
"value": 0.0
},
"Param9": {
"type": "f",
"value": 0.0
},
"Param10": {
"type": "f",
"value": 0.0
},
"Param11": {
"type": "f",
"value": 0.0
},
"Param12": {
"type": "f",
"value": 0.0
},
"Param13": {
"type": "b",
"value": false
},
"Param14": {
"type": "b",
"value": true
}
}
}
],
"fields": {},
"dependencies": []
},
"AUDIO": {
"type": "CAudioComponent",
"unk_1": 3000,
Expand Down
147 changes: 31 additions & 116 deletions open_samus_returns_rando/model_data.py

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions open_samus_returns_rando/patcher_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from mercury_engine_data_structures.game_check import Game

from open_samus_returns_rando.bmsld_add import remove_actor_from_all_groups
from open_samus_returns_rando.constants import ALL_AREAS

T = typing.TypeVar("T")

Expand All @@ -31,6 +32,12 @@ def get_file(self, path: str, type_hint: type[T] = BaseResource) -> T:
def get_level_pkgs(self, name: str) -> set[str]:
return set(self.find_pkgs(path_for_level(name) + ".bmsld"))

def get_all_level_pkgs(self) -> list[str]:
def get_nested_list():
for area in ALL_AREAS:
yield self.get_level_pkgs(area)
return [pkg for all_level_pkgs in get_nested_list() for pkg in all_level_pkgs]

def ensure_present_in_scenario(self, scenario: str, asset):
for pkg in self.get_level_pkgs(scenario):
self.ensure_present(pkg, asset)
Expand Down
67 changes: 62 additions & 5 deletions open_samus_returns_rando/pickup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,51 @@ def patch_single_item_pickup(self, bmsad: dict) -> dict:
quantity: float = self.pickup["resources"][0][0]["quantity"]
set_custom_params: dict = pickable["functions"][0]["params"]

action_sets: dict = bmsad["action_sets"][0]["animations"][0]

fx_create_and_link: dict = bmsad["components"]["FX"]["functions"][0]["params"]

if item_id == "ITEM_ENERGY_TANKS":
item_id = "fMaxLife"
quantity *= self.configuration["energy_per_tank"]
set_custom_params["Param4"]["value"] = "Full"
set_custom_params["Param5"]["value"] = "fCurrentLife"
set_custom_params["Param6"]["value"] = "LIFE"
action_sets["animation_id"] = 150
action_sets["action"]["bcskla"] = "actors/items/itemtank/animations/relax.bcskla"

elif item_id == "ITEM_AEION_TANKS":
item_id = "fMaxEnergy"
quantity *= self.configuration["aeion_per_tank"]
set_custom_params["Param4"]["value"] = "Full"
set_custom_params["Param5"]["value"] = "fEnergy"
set_custom_params["Param6"]["value"] = "SPECIALENERGY"
action_sets["animation_id"] = 150
action_sets["action"]["bcskla"] = "actors/items/itemtank/animations/relax.bcskla"

elif item_id in {"ITEM_WEAPON_MISSILE_MAX", "ITEM_RANDO_LOCKED_SUPERS", "ITEM_RANDO_LOCKED_PBS"}:
action_sets["animation_id"] = 150
action_sets["action"]["bcskla"] = "actors/items/itemtank/animations/relax.bcskla"

elif item_id.startswith("ITEM_SPECIAL_ENERGY"):
fx_create_and_link["Param13"]["value"] = True
if item_id == "ITEM_SPECIAL_ENERGY_SCANNING_PULSE":
fx_create_and_link["Param1"]["value"] = "orb"
fx_create_and_link["Param2"]["value"] = "actors/items/powerup_scanningpulse/fx/orb.bcptl"
if item_id == "ITEM_SPECIAL_ENERGY_ENERGY_SHIELD":
fx_create_and_link["Param1"]["value"] = "orb"
fx_create_and_link["Param2"]["value"] = "actors/items/powerup_energyshield/fx/orb.bcptl"
if item_id == "ITEM_SPECIAL_ENERGY_ENERGY_WAVE":
fx_create_and_link["Param1"]["value"] = "yelloworb"
fx_create_and_link["Param2"]["value"] = "actors/items/powerup_energywave/fx/yelloworb.bcptl"
elif item_id == "ITEM_SPECIAL_ENERGY_PHASE_DISPLACEMENT":
fx_create_and_link["Param1"]["value"] = "purpleorb"
fx_create_and_link["Param2"]["value"] = "actors/items/powerup_phasedisplacement/fx/purpleorb.bcptl"

elif item_id == "ITEM_ADN":
fx_create_and_link["Param1"]["value"] = "leak"
fx_create_and_link["Param2"]["value"] = "actors/items/adn/fx/adnleak.bcptl"
fx_create_and_link["Param13"]["value"] = True

set_custom_params["Param1"]["value"] = item_id
set_custom_params["Param2"]["value"] = quantity
Expand Down Expand Up @@ -86,12 +118,19 @@ def patch_multi_item_pickup(self, bmsad: dict) -> dict:

return bmsad

def patch_model(self, editor: PatcherEditor, model_names: list[str], new_template: dict):
def patch_model(self, model_names: list[str], new_template: dict) -> None:
if len(model_names) == 1:
model_data = get_data(model_names[0])
new_template["model_name"] = model_data.bcmdl_path
new_template["header"]["model_name"] = model_data.bcmdl_path
MODELUPDATER = new_template["components"]["MODELUPDATER"]
MODELUPDATER["functions"][0]["params"]["Param1"]["value"] = model_data.bcmdl_path

if model_names[0] in {"item_missiletank", "item_supermissiletank",
"item_powerbombtank", "item_senergytank"}:
energytank_bcmdl = "actors/items/item_energytank/models/item_energytank.bcmdl"
MODELUPDATER["functions"][0]["params"]["Param2"]["value"] = energytank_bcmdl
elif model_names[0] == "item_energytank":
MODELUPDATER["functions"][0]["params"].pop("Param2")
else:
MODELUPDATER = new_template["components"]["MODELUPDATER"]
MODELUPDATER["type"] = "CMultiModelUpdaterComponent"
Expand Down Expand Up @@ -133,7 +172,7 @@ def patch(self, editor: PatcherEditor):

# Update model
model_names: list[str] = self.pickup["model"]
self.patch_model(editor, model_names, new_template)
self.patch_model(model_names, new_template)

# TODO Update minimap

Expand All @@ -155,8 +194,6 @@ def patch(self, editor: PatcherEditor):

# Dependencies
for level_pkg in pkgs_for_level:
editor.ensure_present(level_pkg, "system/animtrees/base.bmsat")
editor.ensure_present(level_pkg, "actors/items/randomizer_powerup/scripts/randomizer_powerup.lc")
for model_name in model_names:
model_data = get_data(model_name)
for dep in model_data.dependencies:
Expand All @@ -169,10 +206,30 @@ def patch(self, editor: PatcherEditor):
# json.dumps(new_template, indent=4)
# )

def ensure_base_models(editor: PatcherEditor) -> None:
for level_pkg in editor.get_all_level_pkgs():
# ensure base stuff
editor.ensure_present(level_pkg, "system/animtrees/base.bmsat")
editor.ensure_present(level_pkg, "sounds/generic/obtencion.bcwav")
editor.ensure_present(level_pkg, "actors/items/randomizer_powerup/scripts/randomizer_powerup.lc")

# ensure itemsphere stuff (base for many majors)
editor.ensure_present(level_pkg, "actors/items/itemsphere/animations/relax.bcskla")
model_data = get_data("itemsphere")
for dep in model_data.dependencies:
editor.ensure_present(level_pkg, dep)

# ensure energytank stuff (base for all tanks)
editor.ensure_present(level_pkg, "actors/items/itemtank/animations/relax.bcskla")
model_data = get_data("item_energytank")
for dep in model_data.dependencies:
editor.ensure_present(level_pkg, dep)



def patch_pickups(editor: PatcherEditor, lua_scripts: LuaEditor, pickups_config: list[dict], configuration: dict):
editor.add_new_asset("actors/items/randomizer_powerup/scripts/randomizer_powerup.lc", b'', [])
ensure_base_models(editor)

for i, pickup in enumerate(pickups_config):
LOG.debug("Writing pickup %d: %s", i, pickup["caption"])
Expand Down
Loading