Skip to content

Instantly share code, notes, and snippets.

@BenMakesGames
Last active August 29, 2015 13:56
Show Gist options
  • Save BenMakesGames/8923886 to your computer and use it in GitHub Desktop.
Save BenMakesGames/8923886 to your computer and use it in GitHub Desktop.
# I did not make this script, a user named "Shaz" did, on this
# thread: http://forums.rpgmakerweb.com/index.php?/topic/9139-simple-slopes/
# I made trivial modifications, and fixed an issue where characters
# would sometimes face in weird directions when moving on stairs.
# terrain tag for stairs sloping from the bottom-left to upper-right
SLOPE_UP_TAG = 4
# terrain for stairs sloping from the top-left to bottom-right
SLOPE_DOWN_TAG = 6
class Game_CharacterBase
alias original_move_straight move_straight
def diagonal_override(d)
this_override = $game_map.terrain_tag(@x, @y)
new_x = $game_map.round_x_with_direction(@x, d)
new_y = $game_map.round_y_with_direction(@y, d)
new_override = $game_map.terrain_tag(new_x, new_y)
if(new_override == SLOPE_UP_TAG && d == 6)
return 6, 8
elsif(new_override == SLOPE_DOWN_TAG && d == 4)
return 4, 8
elsif(this_override == SLOPE_UP_TAG && (d == 4 || d == 2))
return 4, 2
elsif(this_override == SLOPE_DOWN_TAG && (d == 6 || d == 2))
return 6, 2
else
return 0, 0
end
end
def move_straight(d, turn_ok = true)
x_direction, y_direction = diagonal_override(d)
if x_direction != 0 && y_direction != 0
set_direction(x_direction)
move_diagonal(x_direction, y_direction)
else
original_move_straight(d, turn_ok)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment