#===========================================================================
# paste above main
# â– Jump Script
#------------------------------------------------------------------------------
# Enables jumping around the map
# Made by: Huitzilopoctli of rmxp.net as part of Interactive World
# Edited by: ToriVerly
#------------------------------------------------------------------------------
# The player will be able to jump over any any tile with a TerrainID the same
# as the JumpID.
# The player must land on a passable tile without a solid event blocking it
# If the player can't jump the full 2 tiles, it will go 1 or, failing that, none
# To stop the player from jumping over a particular event, make the first
# command for the event a comment, containing this word: \Tall
# To create a 'tall' tile that will stop the player from jumping over it even if
# the tile below is jumpable, set the tile's id to not the JumpID or 0
#==============================================================================
#==============================================================================
# â— Customization
#==============================================================================
JumpID = 6 # The terrain ID of the tiles which can be jumped over
MaxJump = 2 # The longest jump that can be made by the player
#==============================================================================
# â— Game_Player
#==============================================================================
class Game_Player < Game_Character
def leap
# finds the jumpable distance
dist = jumpable_distance
# finds the increases to x & y for the current direction
xdir = (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
ydir = (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
route = RPG::MoveRoute.new
route.list.clear
route.list.push(RPG::MoveCommand.new(37))
route.list.push(RPG::MoveCommand.new(14, [xdir * dist, ydir * dist]))
route.list.push(RPG::MoveCommand.new(38))
route.list.push(RPG::MoveCommand.new(0))
route.repeat = false
$game_player.force_move_route(route)
end
alias update_primary update
def update
update_primary
leap if moving? && @direction == 2 && $game_map.terrain_tag($game_player.x,$game_player.y+1) == JumpID #Jumps when facing down
leap if moving? && @direction == 8 && $game_map.terrain_tag($game_player.x,$game_player.y-1) == JumpID #Jumps when facing up
leap if moving? && @direction == 6 && $game_map.terrain_tag($game_player.x+1,$game_player.y) == JumpID #Jumps when facing right
leap if moving? && @direction == 4 && $game_map.terrain_tag($game_player.x-1,$game_player.y) == JumpID #Jumps when facing left
end
def jumpable_distance(dir = @direction, max_dist = MaxJump, x = @x, y = @y)
xdir = (dir == 6 ? 1 : dir == 4 ? -1 : 0)
ydir = (dir == 2 ? 1 : dir == 8 ? -1 : 0)
jumpable_tiles = []
for i in 0..max_dist
check_x = x + i * xdir
check_y = y + i * ydir
e = $game_map.events[$game_map.check_event(check_x, check_y)]
if e
if e.list[0].parameters[0] =~ "\Tall"
break
end
if not e.through
next
end
end
if $game_map.passable?(check_x, check_y, dir, self) or
$game_map.terrain_tag(check_x, check_y) == JumpID
jumpable_tiles.push(i)
end
end
jumpable_tiles.reverse.each do |i|
check_x = x + i * xdir
check_y = y + i * ydir
return i if $game_map.passable?(check_x, check_y, dir, self)
end
return 0
end
end
#__________________ [url]http://www.tsubasachronicle[/url]