Skip to content

Commit

Permalink
Fix bug with functions expecting stage when it should be gamestate
Browse files Browse the repository at this point in the history
  • Loading branch information
altf4 committed May 16, 2024
1 parent 845a15b commit ce7ebfe
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions melee/framedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,12 @@ def last_roll_frame(self, character, action):
return -1
return max(frames)

def roll_end_position(self, character_state, stage):
def roll_end_position(self, character_state, gamestate):
"""Returns the x coordinate that the current roll will end in
Args:
character_state (gamestate.PlayerState): The player we're calculating for
stage (enums.Stage): The stage being played on
gamestate (gamestate.Gamestate): The current gamestate
"""
distance = 0
try:
Expand Down Expand Up @@ -675,14 +675,20 @@ def roll_end_position(self, character_state, stage):
]:
# Adjust the position to account for the fact that we can't roll off the platform
side_platform_height, side_platform_left, side_platform_right = (
stages.side_platform_position(character_state.position.x > 0, stage)
stages.side_platform_position(
character_state.position.x > 0, gamestate
)
)
top_platform_height, top_platform_left, top_platform_right = (
stages.top_platform_position(stage)
stages.top_platform_position(gamestate)
)
if character_state.position.y < 5:
position = min(position, stages.EDGE_GROUND_POSITION[stage])
position = max(position, -stages.EDGE_GROUND_POSITION[stage])
position = min(
position, stages.EDGE_GROUND_POSITION[gamestate.stage]
)
position = max(
position, -stages.EDGE_GROUND_POSITION[gamestate.stage]
)
elif (side_platform_height is not None) and abs(
character_state.position.y - side_platform_height
) < 5:
Expand Down Expand Up @@ -1135,7 +1141,7 @@ def _intersect(A, B, C, D):
A, B, C
) != FrameData._ccw(A, B, D)

def project_hit_location(self, character_state, stage, frames=-1):
def project_hit_location(self, character_state, gamestate, frames=-1):
"""How far does the given character fly, assuming they've been hit?
Only considers air-movement, not ground sliding.
Projection ends if hitstun ends, or if a platform is encountered
Expand All @@ -1147,7 +1153,7 @@ def project_hit_location(self, character_state, stage, frames=-1):
Args:
character_state (GameState.PlayerState): The character state to calculate for
stage (enums.Stage): The stage being played on
gamestate (gamestate.Gamestate): The current gamestate
frames (int): The number of frames to calculate for. -1 means "until end of hitstun"
Returns:
Expand All @@ -1165,12 +1171,16 @@ def project_hit_location(self, character_state, stage, frames=-1):
# Get list of all platforms, tuples of (height, left, right)
platforms = []
platforms.append(
(0, -stages.EDGE_GROUND_POSITION[stage], stages.EDGE_GROUND_POSITION[stage])
(
0,
-stages.EDGE_GROUND_POSITION[gamestate.stage],
stages.EDGE_GROUND_POSITION[gamestate.stage],
)
)
left_plat = stages.left_platform_position(stage)
left_plat = stages.left_platform_position(gamestate)
if left_plat[0] is not None:
platforms.append(left_plat)
right_plat = stages.right_platform_position(stage)
right_plat = stages.right_platform_position(gamestate)
if right_plat[0] is not None:
platforms.append(right_plat)

Expand Down

0 comments on commit ce7ebfe

Please sign in to comment.