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

Incomplete proper entrances links #37

Merged
merged 8 commits into from
Jun 1, 2024
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
29 changes: 14 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,40 @@ repos:
- id: mixed-line-ending
args: [--fix=lf]
- id: check-case-conflict
# - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
# rev: v2.8.0
# hooks:
# # Moves entire sections, I don't like that >:(
# # - id: pretty-format-toml
# # args: [--autofix]
# # I don't like it, it really messes up a lot a stuff
# # - id: pretty-format-yaml
# # args: [--autofix, --indent, "2", --offset, "0", --preserve-quotes, --line-width, "100"],
# - id: pretty-format-ini
# args: [--autofix]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.13.0
hooks:
# Moves entire sections, I don't like that >:(
# - id: pretty-format-toml
# args: [--autofix]
- id: pretty-format-yaml
args: [--autofix, --indent, "2", --offset, "2", --preserve-quotes, --line-width, "100"]
- id: pretty-format-ini
args: [--autofix]
- repo: local # https://github.com/dprint/dprint
hooks:
- id: dprint
name: dprint
entry: dprint fmt
language: node
types: [text]
additional_dependencies: ["dprint@~0.45.1"]
additional_dependencies: ["dprint@~0.46.0"]
pass_filenames: false # https://github.com/adamchainz/pre-commit-dprint/issues/3#issuecomment-1483410008
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.2" # Must match requirements-dev.txt
rev: "v0.4.5" # Must match requirements-dev.txt
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/hhatto/autopep8
rev: "v2.1.0" # Must match requirements-dev.txt
rev: "v2.1.1" # Must match requirements-dev.txt
hooks:
- id: autopep8
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0 # Must match .pre-commit-config.yaml
hooks:
- id: add-trailing-comma
- repo: https://github.com/RobertCraigie/pyright-python
rev: "v1.1.360"
rev: "v1.1.364"
hooks:
- id: pyright

Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"yaml.format.printWidth": 100,
"[markdown]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
},
Expand Down
12 changes: 11 additions & 1 deletion Dolphin scripts/Entrance Randomizer/CONFIGS.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@
Set your own seed, can be an `int`, `float`, `str`, `bytes` or `bytearray`.

Use `None` or any Falsy value to generate a random seed.

default = None
"""

STARTING_AREA: int | None = None
"""
The ID of the Area to start in. `None` for random, `0xEE8F6900` for Crash Site.

See `transition_infos.json` for all available IDs

default = None
"""

LINKED_TRANSITIONS: bool = False
LINKED_TRANSITIONS: bool = True
"""
Whether the new destination will contain an exit back to the area you came from.
Assuming both areas have as many entrances as they have exits.

default = True
"""

DISABLE_MAPS_IN_SHOP: bool = True
Expand All @@ -28,6 +34,8 @@

When maps are disabled, and using original shop prices,
the 4 lowest prices (0, 1, 2, 2) are also removed form the pool.

default = True
"""

SHOP_PRICES_RANGE: PriceRange = False # (0, 32)
Expand All @@ -45,4 +53,6 @@
So it's possible for your "minimum" price to not be respected based on RNG.

Use `False` or `()` to shuffle around original shop prices.

default = False # (0, 32)
"""
61 changes: 41 additions & 20 deletions Dolphin scripts/Entrance Randomizer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@
highjack_transition_rando,
set_transitions_map,
starting_area,
state,
transitions_map,
)
from lib.shaman_shop import patch_shaman_shop, randomize_shaman_shop
from lib.utils import draw_text, dump_spoiler_logs, reset_draw_text_index
from lib.utils import (
draw_text,
dump_spoiler_logs,
follow_pointer_path,
prevent_transition_softlocks,
reset_draw_text_index,
state,
)

set_transitions_map()
randomize_shaman_shop()
Expand All @@ -37,12 +43,7 @@
try:
starting_area_name = TRANSITION_INFOS_DICT[starting_area].name
except KeyError:
if starting_area == CRASH_SITE:
starting_area_name = "Crash Site"
elif starting_area == TELEPORTERS:
starting_area_name = "Teleport"
else:
starting_area_name = str(starting_area)
starting_area_name = hex(starting_area).upper() + " (not in randomization)"

# Dump spoiler logs
dump_spoiler_logs(starting_area_name, transitions_map, seed_string)
Expand All @@ -52,47 +53,67 @@ async def main_loop():
# Read memory, setup loop values, print debug to screen
reset_draw_text_index()
state.current_area_old = state.current_area_new
state.area_load_state_old = state.area_load_state_new
await event.frameadvance()
state.current_area_new = memory.read_u32(ADDRESSES.current_area)
state.area_load_state_new = memory.read_u32(ADDRESSES.area_load_state)
current_area = TRANSITION_INFOS_DICT.get(state.current_area_new)
previous_area_id = memory.read_u32(follow_pointer_path(ADDRESSES.prev_area))
previous_area = TRANSITION_INFOS_DICT.get(previous_area_id)
draw_text(f"Rando version: {__version__}")
draw_text(f"Seed: {seed_string}")
draw_text(patch_shaman_shop())
draw_text(
f"Starting area: {hex(starting_area)}"
f"Starting area: {hex(starting_area).upper()}"
+ " (Random)" if CONFIGS.STARTING_AREA is None else f"{starting_area_name}",
)
draw_text(
f"Current area: {hex(state.current_area_new).upper()}"
+ f"({current_area.name})" if current_area else "",
f"Current area: {hex(state.current_area_new).upper()} "
+ (f"({current_area.name})" if current_area else ""),
)
draw_text(
f"From entrance: {hex(previous_area_id).upper()} "
+ (f"({previous_area.name})" if previous_area else ""),
)

# Always re-enable Item Swap.
if memory.read_u32(ADDRESSES.item_swap) == 1:
memory.write_u32(ADDRESSES.item_swap, 0)

# Skip the intro fight and cutscene
if highjack_transition(0x0, JAGUAR, starting_area):
if highjack_transition(0x0, LevelCRC.JAGUAR, starting_area):
return

# Standardize the Altar of Ages exit
if highjack_transition(ALTAR_OF_AGES, None, MYSTERIOUS_TEMPLE):
# Standardize the Altar of Ages exit to remove the Altar -> BBCamp transition
if highjack_transition(
LevelCRC.ALTAR_OF_AGES,
LevelCRC.BITTENBINDERS_CAMP,
LevelCRC.MYSTERIOUS_TEMPLE,
):
state.current_area_new = LevelCRC.MYSTERIOUS_TEMPLE
# Even if the cutscene isn't actually watched.
# Just leaving the Altar is good enough for the rando.
state.visited_altar_of_ages = True
state.current_area_new = MYSTERIOUS_TEMPLE

# Standardize the Viracocha Monoliths cutscene
if highjack_transition(None, VIRACOCHA_MONOLITHS_CUTSCENE, VIRACOCHA_MONOLITHS):
state.current_area_new = VIRACOCHA_MONOLITHS
if highjack_transition(
None,
LevelCRC.VIRACOCHA_MONOLITHS_CUTSCENE,
LevelCRC.VIRACOCHA_MONOLITHS,
):
state.current_area_new = LevelCRC.VIRACOCHA_MONOLITHS

# Standardize St. Claire's Excavation Camp
if highjack_transition(None, ST_CLAIRE_NIGHT, ST_CLAIRE_DAY):
state.current_area_new = ST_CLAIRE_DAY
if highjack_transition(None, LevelCRC.ST_CLAIRE_NIGHT, LevelCRC.ST_CLAIRE_DAY):
state.current_area_new = LevelCRC.ST_CLAIRE_DAY

# TODO: Skip swim levels (3)

redirect = highjack_transition_rando()
if redirect:
state.current_area_new = redirect
state.current_area_new = redirect[1]

prevent_transition_softlocks()


while True:
Expand Down
Loading
Loading