Skip to content

Commit

Permalink
Pathfinding: Add support for underwater doors (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzi authored Jan 13, 2025
1 parent 46ecbb6 commit cb78669
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
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

0 comments on commit cb78669

Please sign in to comment.