Skip to content
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
18 changes: 18 additions & 0 deletions src/mars_patcher/mf/auto_generated_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,23 @@ class MarsschemamfCreditstextItem(typ.TypedDict, total=False):
]


class MarsschemamfEnvironmentaldamage(typ.TypedDict):
Lava: Typeu8 = 20
"""The amount of damage per second taken while submerged in lava."""

Acid: Typeu8 = 60
"""The amount of damage per second taken while submerged in acid."""

Heat: Typeu8 = 6
"""The amount of damage per second taken while in a heated environment."""

Cold: Typeu8 = 6
"""The amount of damage per second taken while in a cold environment."""

Subzero: Typeu8 = 15
"""The amount of damage per second taken while in Sub-Zero Containment. Currently unused, will always use Cold."""


@typ.final
class MarsschemamfLeveledits(typ.TypedDict, total=False):
"""Specifies the Room ID."""
Expand Down Expand Up @@ -633,6 +650,7 @@ class Marsschemamf(typ.TypedDict, total=False):
DisableSoundEffects: bool = False
"""Disables all sound effects when true."""

EnvironmentalDamage: MarsschemamfEnvironmentaldamage
MissileLimit: Typeu8 = 3
"""Changes how many missiles can be on-screen at a time. The vanilla game has it set to 2, the randomizer changes it to 3 by default. Zero Mission uses 4."""

Expand Down
2 changes: 1 addition & 1 deletion src/mars_patcher/mf/constants/reserved_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ReservedPointersMF(IntEnum):
STARTING_LOCATION_ADDR = auto()
CREDITS_PARAMETERS_ADDR = auto() # Unused. Remnant of when we didn't have looping credits music
HINT_SECURITY_LEVELS_ADDR = auto()
ENVIRONMENTAL_HARZARD_DAMAGE_ADDR = auto() # TODO: Implement this
ENVIRONMENTAL_HAZARD_DAMAGE_ADDR = auto()
MISSILE_LIMIT_ADDR = auto()
ROOM_NAMES_TABLE_ADDR = auto()
REVEAL_HIDDEN_TILES_ADDR = auto()
Expand Down
31 changes: 31 additions & 0 deletions src/mars_patcher/mf/data/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,37 @@
"description": "Disables all sound effects when true.",
"default": false
},
"EnvironmentalDamage": {
"type": "object",
"properties": {
"Lava": {
"$ref": "#/$defs/TypeU8",
"description": "The amount of damage per second taken while submerged in lava.",
"default": 20
},
"Acid": {
"$ref": "#/$defs/TypeU8",
"description": "The amount of damage per second taken while submerged in acid.",
"default": 60
},
"Heat": {
"$ref": "#/$defs/TypeU8",
"description": "The amount of damage per second taken while in a heated environment.",
"default": 6
},
"Cold": {
"$ref": "#/$defs/TypeU8",
"description": "The amount of damage per second taken while in a cold environment.",
"default": 6
},
"Subzero": {
"$ref": "#/$defs/TypeU8",
"description": "The amount of damage per second taken while in Sub-Zero Containment. Currently unused, will always use Cold.",
"default": 15
}
},
"required": ["Lava", "Acid", "Heat", "Cold", "Subzero"]
},
"MissileLimit": {
"$ref": "#/$defs/TypeU8",
"description": "Changes how many missiles can be on-screen at a time. The vanilla game has it set to 2, the randomizer changes it to 3 by default. Zero Mission uses 4.",
Expand Down
15 changes: 15 additions & 0 deletions src/mars_patcher/mf/misc_patches.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import mars_patcher.constants.game_data as gd
from mars_patcher.mf.auto_generated_types import MarsschemamfEnvironmentaldamage
from mars_patcher.mf.constants.reserved_space import ReservedPointersMF
from mars_patcher.mf.data import get_data_path
from mars_patcher.patching import BpsDecoder, IpsDecoder
Expand Down Expand Up @@ -85,6 +86,20 @@ def apply_alternative_health_layout(rom: Rom) -> None:
rom.write_8(rom.read_ptr(ReservedPointersMF.USE_ALTERNATIVE_HUD_DISPLAY.value), 1)


def apply_environmental_damage(rom: Rom, damage_dict: MarsschemamfEnvironmentaldamage) -> None:
base_address = rom.read_ptr(ReservedPointersMF.ENVIRONMENTAL_HAZARD_DAMAGE_ADDR.value)
damage = [
damage_dict["Lava"],
damage_dict["Acid"],
damage_dict["Heat"],
# ASM currently has Subzero and Cold mislabelled. https://github.com/MetroidAdvRandomizerSystem/mars-fusion-asm/issues/374
damage_dict["Cold"],
damage_dict["Subzero"],
]
for offset, damage_amount in enumerate(damage):
rom.write_8(base_address + offset, damage_amount)


def apply_reveal_hidden_tiles(rom: Rom) -> None:
rom.write_8(rom.read_ptr(ReservedPointersMF.REVEAL_HIDDEN_TILES_ADDR.value), 1)

Expand Down
4 changes: 4 additions & 0 deletions src/mars_patcher/mf/patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
apply_accessibility_patch,
apply_alternative_health_layout,
apply_base_patch,
apply_environmental_damage,
apply_instant_unmorph_patch,
apply_nerf_gerons,
apply_reveal_hidden_tiles,
Expand Down Expand Up @@ -151,6 +152,9 @@ def patch_mf(
if patch_data.get("DisableSoundEffects"):
disable_sound_effects(rom)

if environmental_damage := patch_data.get("EnvironmentalDamage"):
apply_environmental_damage(rom, environmental_damage)

if "MissileLimit" in patch_data:
change_missile_limit(rom, patch_data["MissileLimit"])

Expand Down