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

Add setting to change all portals to accept all beams #14

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions open_prime_rando/echoes/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@
"default": {},
"$comment": "The list of docks is replaced in runtime with the existing docks of each specific area."
},
"portals_with_any_beams": {
"type": "boolean",
"description": "Changes all portals in this area to accept all four beams",
"default": false
},
"layers": {
"type": "object",
"patternProperties": {
Expand Down
38 changes: 35 additions & 3 deletions open_prime_rando/echoes_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
import logging
from pathlib import Path

from retro_data_structures.asset_manager import FileProvider
from retro_data_structures.formats.mlvl import AreaWrapper
from retro_data_structures.enums.echoes import Effect
from retro_data_structures.properties.echoes.objects.DamageableTrigger import DamageableTrigger
from retro_data_structures.game_check import Game

from open_prime_rando import dynamic_schema
from open_prime_rando.echoes import specific_area_patches, asset_ids
from open_prime_rando.echoes.inverted import apply_inverted
from open_prime_rando.echoes.small_randomizations import apply_small_randomizations
from open_prime_rando.patcher_editor import PatcherEditor
from open_prime_rando.unique_area_name import get_name_for_area
from open_prime_rando.validator_with_default import DefaultValidatingDraft7Validator
from retro_data_structures.asset_manager import FileProvider
from retro_data_structures.formats.mlvl import AreaWrapper
from retro_data_structures.game_check import Game

LOG = logging.getLogger("echoes_patcher")

Expand All @@ -21,6 +24,31 @@ def _read_schema():
return json.load(f)


def _change_portals_to_all_beams(area: AreaWrapper) -> None:
def fix_vuln(vuln):
vuln.damage_multiplier = 100.0
vuln.effect = Effect.Normal

for layer in area.layers:
for obj in layer.instances:
if obj.type == DamageableTrigger:
properties = obj.get_properties_as(DamageableTrigger)
if properties.get_name() == "Shoot to activate PORTAL":
fix_vuln(properties.vulnerability.power)
fix_vuln(properties.vulnerability.dark)
fix_vuln(properties.vulnerability.light)
fix_vuln(properties.vulnerability.annihilator)
fix_vuln(properties.vulnerability.power_charge)
fix_vuln(properties.vulnerability.entangler)
fix_vuln(properties.vulnerability.light_blast)
fix_vuln(properties.vulnerability.sonic_boom)
fix_vuln(properties.vulnerability.super_missle)
fix_vuln(properties.vulnerability.black_hole)
fix_vuln(properties.vulnerability.sunburst)
fix_vuln(properties.vulnerability.imploder)
obj.set_properties(properties)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be something like this:

def _change_portals_to_all_beams(area: AreaWrapper) -> None:
    fixed = WeaponVulnerability(damage_multiplier=100.0, effect=Effect.Normal)
    for layer in area.layers:
        for obj in layer.instances:
            if obj.type == DamageableTrigger and obj.name == "Shoot to activate PORTAL":
                with obj.edit_properties(DamageableTrigger) as props:
                    props.vulnerability.annihilator = fixed # etc...



def apply_area_modifications(editor: PatcherEditor, configuration: dict[str, dict]):
for world_name, world_config in configuration.items():
world_meta = asset_ids.world.load_dedicated_file(world_name)
Expand All @@ -46,6 +74,9 @@ def apply_area_modifications(editor: PatcherEditor, configuration: dict[str, dic
area.connect_dock_to(dock_number, areas_by_name[dock_target["area"]],
world_meta.DOCK_NAMES[dock_target["area"]][dock_target["dock"]])

if area_config["portals_with_any_beams"]:
_change_portals_to_all_beams(area)

for layer_name, layer_state in area_config["layers"].items():
LOG.debug("Setting layer %s of %s - %s to %s", layer_name, world_name, area_name, str(layer_state))
area.get_layer(layer_name).active = layer_state
Expand All @@ -68,6 +99,7 @@ def patch_paks(file_provider: FileProvider, output_path: Path, configuration: di
apply_small_randomizations(editor, configuration["small_randomizations"])
# apply_door_rando(editor, [])


if configuration["inverted"]:
apply_inverted(editor)

Expand Down