From dc8d8dc113e6fb81e844b621f0bb9a72ebe6f42f Mon Sep 17 00:00:00 2001 From: Steven Franklin Date: Wed, 14 Feb 2024 08:16:32 -0600 Subject: [PATCH 1/2] added super missile expansion - refactored model_data to include a dataclass that generates all materials and replaces them in the model - refactored missile_color_patcher to extend this - added a super missile expansion with green missiles inside to act as a super missile expansion --- .../cosmetic_patches/missile_color_patcher.py | 71 ++++++++----------- src/open_dread_rando/dread_patcher.py | 2 + .../misc_patches/model_patcher.py | 51 +++++++++++++ src/open_dread_rando/pickups/model_data.py | 10 +++ 4 files changed, 92 insertions(+), 42 deletions(-) diff --git a/src/open_dread_rando/cosmetic_patches/missile_color_patcher.py b/src/open_dread_rando/cosmetic_patches/missile_color_patcher.py index 0a2960dc8..9b675e1fd 100644 --- a/src/open_dread_rando/cosmetic_patches/missile_color_patcher.py +++ b/src/open_dread_rando/cosmetic_patches/missile_color_patcher.py @@ -1,68 +1,71 @@ import dataclasses -from open_dread_rando.misc_patches.material_patcher import MaterialData, create_custom_material -from open_dread_rando.misc_patches.model_patcher import ModelData, create_custom_model +from open_dread_rando.misc_patches.material_patcher import MaterialData +from open_dread_rando.misc_patches.model_patcher import StaticModelChanger from open_dread_rando.patcher_editor import PatcherEditor # model names for pride missiles @dataclasses.dataclass() -class MissileVariant: - mat_name: str - model_path: str - shader_path: str - rgba: tuple[float, float, float, float] - +class MissileTankRecolor(StaticModelChanger): def __init__(self, name: str, color: tuple[float, float, float, float]): - self.mat_name = f"{name}_mp_fxhologram_01" - self.model_path = f"actors/items/item_missiletank/models/{name}.bcmdl" - self.shader_path = f"actors/items/item_missiletank/models/imats/{self.mat_name}.bsmat" + self.materials = { + "mp_fxhologram_01": MaterialData( + base_mat="actors/items/item_missiletank/models/imats/item_missiletank_mp_fxhologram_01.bsmat", + new_mat_name=f"{name}_mp_fxhologram_01", + new_path=f"actors/items/item_missiletank/models/imats/{name}_mp_fxhologram_01.bsmat", + uniform_params={ + "vTex0EmissiveColor": color + } + ) + } - self.rgba = color + self.base_model_path="actors/items/item_missiletank/models/item_missiletank.bcmdl" + self.new_model_path=f"actors/items/item_missiletank/models/{name}.bcmdl" -ALL_VARIANTS: dict[str, MissileVariant] = { - "ORANGE": MissileVariant( +MISSILE_TANK_RECOLORS: dict[str, MissileTankRecolor] = { + "ORANGE": MissileTankRecolor( name="item_missile__OR", color=(75.0, 10.0, 0.0, 1.0), ), - "YELLOW": MissileVariant( + "YELLOW": MissileTankRecolor( name="item_missile__YL", color=(30.0, 30.0, 0.0, 1.0), ), - "GREEN": MissileVariant( + "GREEN": MissileTankRecolor( name="item_missile__GN", color=(0.0, 30.0, 0.0, 1.0), ), - "BLUE": MissileVariant( + "BLUE": MissileTankRecolor( name="item_missile__BL", color=(0.05, 0.5, 75.0, 1.0), ), - "CYAN": MissileVariant( + "CYAN": MissileTankRecolor( name="item_missile__CY", color=(0.05, 10.0, 10.0, 1.0), ), - "PURPLE": MissileVariant( + "PURPLE": MissileTankRecolor( name="item_missile__PR", color=(15.0, 0.5, 70.0, 1.0), ), - "PINK": MissileVariant( + "PINK": MissileTankRecolor( name="item_missile__PK", color=(70.0, 0.5, 7.0, 1.0), ), - "MAGENTA": MissileVariant( + "MAGENTA": MissileTankRecolor( name="item_missile__MG", color=(70.0, 0.5, 70.0, 1.0), ), - "WHITE": MissileVariant( + "WHITE": MissileTankRecolor( name="item_missile__WH", color=(30.0, 30.0, 30.0, 1.0), ), - "BLACK": MissileVariant( + "BLACK": MissileTankRecolor( name="item_missile__BK", color=(0.0, 0.0, 0.0, 1.0), ), - "GRAY": MissileVariant( + "GRAY": MissileTankRecolor( name="item_missile__GY", color=(0.2, 0.2, 0.2, 1.0), ), @@ -70,21 +73,5 @@ def __init__(self, name: str, color: tuple[float, float, float, float]): def generate_missile_colors(editor: PatcherEditor): - for _, variant in ALL_VARIANTS.items(): - mat_dat = MaterialData( - base_mat="actors/items/item_missiletank/models/imats/item_missiletank_mp_fxhologram_01.bsmat", - new_mat_name=variant.mat_name, - new_path=variant.shader_path, - uniform_params={ - "vTex0EmissiveColor": variant.rgba - } - ) - - model_dat = ModelData( - base_model="actors/items/item_missiletank/models/item_missiletank.bcmdl", - new_path=variant.model_path, - materials={"mp_fxhologram_01": variant.shader_path} - ) - - create_custom_material(editor, mat_dat) - create_custom_model(editor, model_dat) + for _, recolor in MISSILE_TANK_RECOLORS.items(): + recolor.generate(editor) diff --git a/src/open_dread_rando/dread_patcher.py b/src/open_dread_rando/dread_patcher.py index 4e8729900..1f1ac61d2 100644 --- a/src/open_dread_rando/dread_patcher.py +++ b/src/open_dread_rando/dread_patcher.py @@ -16,6 +16,7 @@ from open_dread_rando.logger import LOG from open_dread_rando.misc_patches import elevator, lua_util from open_dread_rando.misc_patches.exefs import include_depackager, patch_exefs +from open_dread_rando.misc_patches.model_patcher import generate_custom_models from open_dread_rando.misc_patches.sprite_patches import patch_sprites from open_dread_rando.misc_patches.text_patches import apply_text_patches, patch_credits, patch_hints, patch_text from open_dread_rando.misc_patches.tilegroup_patcher import patch_tilegroup @@ -203,6 +204,7 @@ def patch_extracted(input_path: Path, output_path: Path, configuration: dict): # Copy custom files add_custom_files(editor) generate_missile_colors(editor) + generate_custom_models(editor) # Apply fixes apply_static_fixes(editor) diff --git a/src/open_dread_rando/misc_patches/model_patcher.py b/src/open_dread_rando/misc_patches/model_patcher.py index 4247272f9..c42d8cfd6 100644 --- a/src/open_dread_rando/misc_patches/model_patcher.py +++ b/src/open_dread_rando/misc_patches/model_patcher.py @@ -3,6 +3,7 @@ from mercury_engine_data_structures.formats.bcmdl import Bcmdl +from open_dread_rando.misc_patches.material_patcher import MaterialData, create_custom_material from open_dread_rando.patcher_editor import PatcherEditor @@ -16,6 +17,52 @@ class ModelData: # dictionary connecting model names (i.e. "mp_opaque_01") to material files materials: typing.Optional[dict[str, str]] = None +# contains static data to generate model/material changes +@dataclasses.dataclass() +class StaticModelChanger: + base_model_path: str + new_model_path: str + materials: dict[str, MaterialData] # key is material name in bcmdl + + def generate(self, editor: PatcherEditor): + mats: dict[str, str] = {} + + for name, mat in self.materials.items(): + create_custom_material(editor, mat) + mats[name] = mat.new_path + + print(self.base_model_path) + create_custom_model(editor, ModelData( + base_model=self.base_model_path, + new_path=self.new_model_path, + materials=mats + )) + + +ADVANCED_RECOLORS: dict[str, StaticModelChanger] = { + "item_supermissiletank": StaticModelChanger( + base_model_path="actors/items/item_missiletankplus/models/item_missiletankplus.bcmdl", + new_model_path="actors/items/item_missiletankplus/models/super_missile_tank.bcmdl", + materials={ + "mat01": MaterialData( + base_mat="actors/items/item_missiletankplus/models/imats/item_missiletankplus_mat01.bsmat", + new_mat_name="supermissiletank_mat01", + new_path="actors/items/item_missiletankplus/models/imats/super_missile_tank_mat01.bsmat", + uniform_params={ + "vConstant0": (0.0, 10.0, 0.15, 1.0) + } + ), + "mp_fxhologram_01": MaterialData( + base_mat="actors/items/item_missiletankplus/models/imats/item_missiletankplus_mp_fxhologram_01.bsmat", + new_mat_name="supermissiletank_mp_fxhologram_01", + new_path="actors/items/item_missiletankplus/models/imats/super_missile_tank_mp_fxhologram_01.bsmat", + uniform_params={ + "vTex0EmissiveColor": (10.0, 10.0, 10.0, 1.0) + } + ) + } + ) +} def create_custom_model(editor: PatcherEditor, model_data: ModelData) -> Bcmdl: mdl = editor.get_parsed_asset(model_data.base_model, type_hint=Bcmdl) @@ -29,3 +76,7 @@ def create_custom_model(editor: PatcherEditor, model_data: ModelData) -> Bcmdl: editor.add_new_asset(model_data.new_path, mdl, []) return mdl + +def generate_custom_models(editor: PatcherEditor): + for _, recolor in ADVANCED_RECOLORS.items(): + recolor.generate(editor) diff --git a/src/open_dread_rando/pickups/model_data.py b/src/open_dread_rando/pickups/model_data.py index 5dcde5cb0..842e3cc03 100644 --- a/src/open_dread_rando/pickups/model_data.py +++ b/src/open_dread_rando/pickups/model_data.py @@ -444,6 +444,16 @@ class ModelData: ), ), + "super_missile_expansion": ModelData( + bcmdl_path="actors/items/item_missiletankplus/models/super_missile_tank.bcmdl", + bmsas="actors/items/item_missiletankplus/charclasses/item_missiletankplus.bmsas", + dependencies=( + "actors/items/item_missiletankplus/models/super_missile_tank.bcmdl", + "actors/items/item_missiletankplus/models/imats/super_missile_tank_mat01.bsmat", + "actors/items/item_missiletankplus/models/imats/super_missile_tank_mp_fxhologram_01.bsmat", + ), + ), + "item_powerbombtank": ModelData( bcmdl_path="actors/items/item_powerbombtank/models/item_powerbombtank.bcmdl", bmsas="actors/items/item_powerbombtank/charclasses/item_powerbombtank.bmsas", From bf501f4094f9a186d2f9e45559cf0f305106537c Mon Sep 17 00:00:00 2001 From: Steven Franklin Date: Thu, 22 Feb 2024 10:57:54 -0600 Subject: [PATCH 2/2] removed debug print --- src/open_dread_rando/misc_patches/model_patcher.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/open_dread_rando/misc_patches/model_patcher.py b/src/open_dread_rando/misc_patches/model_patcher.py index c42d8cfd6..8900a300f 100644 --- a/src/open_dread_rando/misc_patches/model_patcher.py +++ b/src/open_dread_rando/misc_patches/model_patcher.py @@ -31,7 +31,6 @@ def generate(self, editor: PatcherEditor): create_custom_material(editor, mat) mats[name] = mat.new_path - print(self.base_model_path) create_custom_model(editor, ModelData( base_model=self.base_model_path, new_path=self.new_model_path,