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

Pathfinding: Add support for underwater doors #614

Merged
merged 1 commit into from
Jan 13, 2025
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
10 changes: 9 additions & 1 deletion modules/map_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,15 @@ def tile_index(x: int, y: int):
destination = warp.destination_location
extra_warp_direction = None
if tile.tile_type.endswith(" Arrow Warp"):
extra_warp_direction = Direction[tile.tile_type.replace(" Arrow Warp", "")]
match tile.tile_type:
case "North Arrow Warp":
extra_warp_direction = Direction.North
case "South Arrow Warp" | "Water South Arrow Warp":
extra_warp_direction = Direction.South
case "East Arrow Warp":
extra_warp_direction = Direction.East
case "West Arrow Warp":
extra_warp_direction = Direction.West
warps_to = (
(destination.map_group, destination.map_number),
destination.local_position,
Expand Down
7 changes: 1 addition & 6 deletions modules/modes/util/walking.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,7 @@ def follow_waypoints(path: Iterable[Waypoint], run: bool = True) -> Generator:
# this flag will just be ignored.
# Similarly, running is not possible when surfing or swimming underwater, but pressing B can
# cause the game to try and dive/emerge which we don't want.
if run and get_player_avatar().flags in (
AvatarFlags.OnAcroBike,
AvatarFlags.OnMachBike,
AvatarFlags.Surfing,
AvatarFlags.Underwater,
):
if run and (get_player_avatar().is_on_bike or get_player_avatar().is_in_water):
run = False

# For each waypoint (i.e. each step of the path) we set a timeout. If the player avatar does not reach the
Expand Down
4 changes: 4 additions & 0 deletions modules/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def flags(self) -> AvatarFlags:
def is_on_bike(self) -> bool:
return AvatarFlags.OnAcroBike in self.flags or AvatarFlags.OnMachBike in self.flags

@property
def is_in_water(self) -> bool:
return AvatarFlags.Surfing in self.flags or AvatarFlags.Underwater in self.flags

@property
def running_state(self) -> RunningState:
return RunningState(self._player_avatar_data[2])
Expand Down
Loading