Skip to content

Commit

Permalink
Merge pull request #304 from steven11sjf/super-missile-expansion
Browse files Browse the repository at this point in the history
added super missile expansion
  • Loading branch information
henriquegemignani authored Feb 22, 2024
2 parents 24c0fa7 + bf501f4 commit 342d707
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 42 deletions.
71 changes: 29 additions & 42 deletions src/open_dread_rando/cosmetic_patches/missile_color_patcher.py
Original file line number Diff line number Diff line change
@@ -1,90 +1,77 @@
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),
),
}


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)
2 changes: 2 additions & 0 deletions src/open_dread_rando/dread_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
50 changes: 50 additions & 0 deletions src/open_dread_rando/misc_patches/model_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -16,6 +17,51 @@ 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

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)
Expand All @@ -29,3 +75,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)
10 changes: 10 additions & 0 deletions src/open_dread_rando/pickups/model_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 342d707

Please sign in to comment.