WR Heart rpg
Vuoi reagire a questo messaggio? Crea un account in pochi clic o accedi per continuare.

Salto del personaggio

Andare in basso

Iconxp Salto del personaggio

Messaggio Da Yushi II il Mar Mag 15, 2012 10:46 am

Salto del personaggio

Questo script permette al pg di saltare premendo il tasto SHIFT

Script
Spoiler:

Codice:
#===========================================================================
# ■ Jump Script
#------------------------------------------------------------------------------
# Enables jumping around the map
# Made by: Huitzilopoctli of rmxp.net as part of Interactive World
#------------------------------------------------------------------------------
# Press the A Input (ShiftKey) to jump
# The player will be able to jump over any passable tile, or 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
#==============================================================================

#==============================================================================
# ● Customisation
#==============================================================================

JumpID  = 1 # 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 Input.trigger?(Input::A) && !moving?
 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

Si può modificare la distanza del salto, cambiando i seguenti parametri:

Codice:
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)
Yushi II
Yushi II

Data d'iscrizione : 09.07.11
Età : 30

Torna in alto Andare in basso

Torna in alto

- Argomenti simili

 
Permessi in questa sezione del forum:
Non puoi rispondere agli argomenti in questo forum.