¡Bienvenid@ a Mundo Maker!

¿Quieres aprender todo sobre el RPG Maker?



Regístrate y forma parte de Mundo Maker.
Conectarse

Recuperar mi contraseña

Temas importantes
----------------------------------------
Páginas con recursos RPG Maker
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
Afiliados
Estadísticas
Tenemos 3394 miembros registrados.
El último usuario registrado es Yember Games.

Nuestros miembros han publicado un total de 79794 mensajes en 11255 argumentos.
Navega con Google Chrome
[DESCARGA]

Edit corregir chara (Necesario)

 :: RPG Maker :: Ayuda RPG

Ver el tema anterior Ver el tema siguiente Ir abajo

RPG Maker XP Edit corregir chara (Necesario)

Mensaje por Ledai el 2014-05-19, 16:33

Hola a todos; bueno, sabéis todos más o menos que estoy trabajando en el juego de Stolen Shadows, y algunos ya me han dicho que hay un pequeño pretexto con el chara del protagonista al saltar y es que el script de plataformas que uso en el juego usa los gráficos de mirar arriba y abajo para subir y bajar en altura cosa que hace que el personaje salte mirando atrás y caiga mirando abajo y pues queda según algunos un tanto mal
Ejemplo: https://www.youtube.com/watch?v=KbnPw2oVMcY&feature=youtu.be
Podría arreglarse mediante script, pero eso generaría más lag por la continua comprobación de dirección...
En resumen:
Necesitaría que alguien editara el script de plataforma para que al saltar se quedara con un gráfico de saltar hacia el lado al que avanza o se mueve como es lógico; o bien espejando el gráfico original (que el script invierta el gráfico dependiendo de en qué dirección estés, o cambiando de gráfico por uno hecho hacia la otra dirección eso a gusto del editor

Por favor, sería un paso importante para el juego.

Dejo el script aunque es muy largo para que puedan ayudarme:
Código:

#==============================================================================
# ** Platform Mode script
#------------------------------------------------------------------------------
# Author      : Eilei
# Version    : 0.9
# Date        : September 14, 2007
# SDK Version : Version 2.3, Parts I & II
#==============================================================================

=begin                    Installation Instructions

0.) Get SDK if you don't have it

1.) Paste Platform Mode Script just above Main

2.) Edit the line which says

      PLATFORMERS = [ 2, 3, 4 ]
   
    so that the list include only the map IDs you want played in platform mode
 
                          Event Editing Instructions
                       
1.) Events come in three main varieties under platform mode; normal, flying, and
    platform.
 
    PLATFORM events need to have a comment that says "platform" on the first
    line of the active event page.  Platform events can push the player and
    other events around on the screen, and even off the screen, so be careful
    where you put them.  Platform events automatically ignore gravity.
 
    FLYING events need to have a comment that says "flying" on the first line
    of the active event page.  Flying events ignore gravity, but don't push
    the player or other events around; they bump into other things as normal.
 
    NORMAL events are events without a "flying" or "platform" comment.  They
    are affected by gravity.

2.) The three movement types are HIGHLY modified.

    First of all, custom movement needs a lot more statements to move an equal
    distance compared to a tile-based movement map.  This is because each move
    command only moves the event one "step" of its movement speed.  Movement
    Speed 3 requires 16 move lefts to move one tile to the left!  This was done
    deliberately so you can customize movement paths outside normal tile
    boundaries.
 
    Second, toward player only works with left and right unless the event is
    flying, in which case it works up/down, too.  There is no pathfinding if
    something is in the way.
 
    Third, random movement only moves left or right, even for flying events.
 
                          Script Editing Instructions
                       
1.) First, make sure that ALL and ONLY map IDs you want played in platform mode
    are in the PLATFORMERS array.

2.) To modify jump and run keys, edit the lines for JUMP_KEY and RUN_KEY,
    respectively
 
3.) To change run speed increases when you hold down the run button, modify
    the array RUN_SPEED_INCREASE.  The first number is the move speed, and the
    second number is the number of frames necessary to bump up to the next
    speed.  If the second number is -1, the speed won't increase.
 
4.) Falling speed increases are treated as above for running speed.

5.) To control scrolling, change the values of the AUTO_SCROLL_ constants below.
    To imitate Mario scrolling, as in this demo, you turn off AUTO_SCROLL_UP and
    AUTO_SCROLL_DOWN.

6.) As of version 0.9, jumping and falling animations aren't handled very well.
    If TURN_ON_JUMP is true, then jumping will use the "UP" animation.  If
    TURN_ON_FALL is true, then falling will use the "DOWN" animation.  Otherwise
    the game sticks to the left/right character animations.

8.) If you find a bug, please screenshot it and post it with a detailed
    description in the platform mode thread at http://www.rmxp.org/forums.

                          Legal Notices
                       
    This script is Copyright © 2007 C. Schrupp

    This script is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This script is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    A copy of the GNU General Public License is in gpl.txt in the main
    directory.  If not, see <http://www.gnu.org/licenses/>.
=end

#--------------------------------------------------------------------------
# * Begin SDK Log
#--------------------------------------------------------------------------
SDK.log( 'Platform Mode', 'Eilei', '0.9', '2007-09-25')

#--------------------------------------------------------------------------
# * Begin SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements( 2.3, [ 1, 2 ] )

#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.enabled?( 'Platform Mode' )

#==============================================================================
# ** Platform
#------------------------------------------------------------------------------
#  This module is used to perform and control platform movement.  Platform
#  movement is changed to be pixel-based for the player, regardless of what
#  it was before.
#==============================================================================
module Platform

  #---------------------------------------------------------------------------+
  # Platform Mode Constants                                                  |
  #---------------------------------------------------------------------------+
 
  # list of platformer map IDs
  PLATFORMERS = [2, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20,
  21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 34, 35, 38]
 
  # key constants
  JUMP_KEY = Input::X
  RUN_KEY  = Input::Y
 
  # standing jump height in tiles; running jumps will be higher
  JUMP_HEIGHT = 4
   
  # auto scrolling of the map
  AUTO_SCROLL_RIGHT      = true
  AUTO_SCROLL_LEFT      = true
  AUTO_SCROLL_UP        = true
  AUTO_SCROLL_DOWN      = true

  # Turn the character a direction when jumping or falling?
  TURN_ON_JUMP          = true # false
  TURN_ON_FALL          = true
 
  # Run speed constants
  MOVE_SPEED = 4
  RUN_SPEED_INCREASE = {
    4 => 5,
    5 => 40,
    6 => -1
  }
 
  # Fall speed constants
  FALL_SPEED = 4
  FALL_SPEED_INCREASE = {
    4 => 5,
    5 => 5,
    6 => -1
  }
 
  # Audio constants
  JUMP_SOUND = RPG::AudioFile.new( 'jump', 80 ) #RPG::AudioFile.new( 'jump', 80 )
 
  #---------------------------------------------------------------------------+
  # Platform Mode Variables                                                  |
  #---------------------------------------------------------------------------+
  @platform_list = {}
  @old_move_speed = 1
  @flying = false
  @platform_id = 0
 
  #---------------------------------------------------------------------------+
  # Platform Mode Methods                                                    |
  #---------------------------------------------------------------------------+
 
  #---------------------------------------------------------------------------+
  # * self.on?  checks to see if currently in platform mode
  #---------------------------------------------------------------------------+
  def self.on?
    PLATFORMERS.include?( $game_map.map_id )
  end
 
  #---------------------------------------------------------------------------+
  # * self.flying?  checks to see if the player is currently flying
  #---------------------------------------------------------------------------+
  def self.flying?
    return @flying
  end
 
  #---------------------------------------------------------------------------+
  # * self.flying  checks to see if currently in platform mode
  #
  #  Sets flying mode on if flymode is true
  #---------------------------------------------------------------------------+
  def self.flying=( flymode = false )
    @flying = flymode
  end
 
  #---------------------------------------------------------------------------+
  # * self.ride_platform adds an event to the list of platforms being ridden
  #  platform_event_id : event id of the platform something is riding
  # Player is event id 0.
  #---------------------------------------------------------------------------+
  def self.ride_platform( rider_id, platform_event_id )
    @platform_list[ rider_id ] = platform_event_id
  end

  #---------------------------------------------------------------------------+
  # * self.off_platform removes an event from the list of platforms being
  #  ridden.  Player is event id 0.
  #  platform_event_id : event id of the platform something is riding
  #---------------------------------------------------------------------------+
  def self.off_platform( rider_id )
    @platform_list.delete( rider_id )
  end
 
  #---------------------------------------------------------------------------+
  # * self.get_riders returns an array containing all the ids of events that
  #  are riding the platform.  Player is event id 0.
  #  platform_event_id : event id of the platform something is riding
  #---------------------------------------------------------------------------+
  def self.get_riders( platform_event_id )
    if @platform_list.has_value?( platform_event_id )
      riders = []
      @platform_list.each_pair {
        |key, value|
        riders.push( key ) if value == platform_event_id
      }
      return riders
    else
      return []
    end
  end
 
  #---------------------------------------------------------------------------+
  # * self.rider? returns an an event id for an event riding a platform
  #  event_id is the ID number of the event to check, or 0 for the player
  #---------------------------------------------------------------------------+
  def self.rider?( event_id )
    return @platform_list.include?( event_id )
  end
 
  #---------------------------------------------------------------------------+
  # * self.platform_id returns an an event id for an event riding a platform
  #---------------------------------------------------------------------------+
  def self.platform_id
    return @platform_id
  end
  #---------------------------------------------------------------------------+
  # * self.platform_id= sets an an event id for an event riding a platform
  #---------------------------------------------------------------------------+
  def self.platform_id=( id )
    @platform_id = id
  end

  #---------------------------------------------------------------------------+
  # * self.old_move_speed returns the player's previous move speed
  #---------------------------------------------------------------------------+
  def self.old_move_speed
    return @old_move_speed
  end
  #---------------------------------------------------------------------------+
  # * self.old_move_speed= stores the player's previous move speed
  #---------------------------------------------------------------------------+
  def self.old_move_speed=( speed )
    @old_move_speed = speed
  end

end # module Platform

#----------------------------------------------------------------------------
# Begin Interpreter Edit
#----------------------------------------------------------------------------
class Interpreter

  #--------------------------------------------------------------------------
  # * Transfer Player
  #  modified to reset tile offset variables for the player
  #--------------------------------------------------------------------------
  alias_method :eilei_platform_Interpreter_command_201, :command_201
  def command_201
    # Do normal processing
    result = eilei_platform_Interpreter_command_201

    # if we're moving off a platform map, make sure all the offsets are zero
    if Platform.on? and not
        Platform::PLATFORMERS.include?( $game_temp.player_new_map_id )
      $game_player.platform_reset
    # check if moving onto a platform map
    elsif not Platform.on? and
        Platform::PLATFORMERS.include?( $game_temp.player_new_map_id )
      $game_player.platform_setup
    end
    result
  end
 
  #--------------------------------------------------------------------------
  # * execute command is modified for speed
  #  affects all interpreter actions, not just platform mode
  #--------------------------------------------------------------------------
  alias_method :eilei_platform_Interpreter_execute_command, :execute_command
  def execute_command
 
    # If last to arrive for list of event commands
    if @index >= @list.size - 1
      # End event
      command_end
      # Continue
      return true
    end
 
    # Make event command parameters available for reference via @parameters
    @parameters = @list[ @index ].parameters
 
    # Branch by command code
    return send( "command_#{ @list[ @index ].code }" )
 
  rescue NoMethodError  # no command_# method exists
    return true
  end

end
#----------------------------------------------------------------------------
# End Interpreter Edit
#----------------------------------------------------------------------------

#----------------------------------------------------------------------------
# Begin Game_Map Edit
#----------------------------------------------------------------------------
class Game_Map
 
  #--------------------------------------------------------------------------
  # * Determine if Passable
  #    x          : x-coordinate
  #    y          : y-coordinate
  #    d          : direction (2,4,6,8)
  # determines if a map square is passable, ignoring events
  #--------------------------------------------------------------------------
  def platform_map_passable?( x, y, d )

    # Change direction (2,4,6,8) to obstacle bit (1,2,4,8)
    bit = ( 1 << ( d / 2 - 1 ) ) & 0x0f
    # Loop searches in order from top of layer
    for i in [ 2, 1, 0 ]
      # Get tile ID
      tile_id = data[ x, y, i ]

      if tile_id == nil or @passages[ tile_id ] & bit != 0
        # impassable
        return false
      elsif @priorities[ tile_id ] == 0
        # passable
        return true
      end
    end
    # passable
    return true
  end

  #--------------------------------------------------------------------------
  # * Find the nearest non-passable, non-self event in the move path
  #    x          : real x-coordinate
  #    y          : real y-coordinate
  #    x_offset  : real x-coordinate
  #    y_offset  : real y-coordinate
  #
  # returns the distance to the nearest intersecting event in the
  # direction specified
  #--------------------------------------------------------------------------
  def platform_event_left( x, x_offset, y, y_offset, self_event = nil )

    low_distance = 128
 
    # Loop in all events
    for event in events.values
      # only bother with non-through map tiles
      if event.tile_id >= 0 and not event.through and event != self_event
        # narrow it down
        ydif = event.y * 128 + event.y_offset - y * 128 - y_offset
        xdif = x * 128 + x_offset - event.x * 128 - event.x_offset
        if -128 < ydif and ydif < 128 and 0 < xdif and xdif < 256
          # tile passability rules
          if @passages[ event.tile_id ] & 0x04 == 0x04 or event.tile_id == 0
            low_distance = [ low_distance, xdif - 128 ].min
          elsif @passages[ event.tile_id ] & 0x02 == 0x02
            low_distance = [ low_distance, xdif ].min
          end
        end
      end
    end
 
    return low_distance
  end

  #--------------------------------------------------------------------------
  # * Find the nearest non-passable, non-self event in the move path
  #    x          : real x-coordinate
  #    y          : real y-coordinate
  #    x_offset  : real x-coordinate
  #    y_offset  : real y-coordinate
  #
  # returns the distance to the nearest intersecting event in the
  # direction specified
  #--------------------------------------------------------------------------
  def platform_event_right( x, x_offset, y, y_offset, self_event = nil )

    low_distance = 128
 
    # Loop in all events
    for event in events.values
      # only bother with non-through tiles
      if event.tile_id >= 0 and not event.through and event != self_event
        # narrow it down
        ydif = event.y * 128 + event.y_offset - y * 128 - y_offset
        xdif = event.x * 128 + event.x_offset - x * 128 - x_offset
        if -128 < ydif and ydif < 128 and 0 < xdif and xdif < 256
          # tile passability rules
          if @passages[ event.tile_id ] & 0x02 == 0x02 or event.tile_id == 0
            low_distance = [ low_distance, xdif - 128 ].min
          elsif @passages[ event.tile_id ] & 0x04 == 0x04
            low_distance = [ low_distance, xdif ].min
          end
        end
      end
    end
 
    return low_distance
  end
 
  #--------------------------------------------------------------------------
  # * Find the nearest non-passable, non-self event in the move path
  #    x          : real x-coordinate
  #    y          : real y-coordinate
  #    x_offset  : real x-coordinate
  #    y_offset  : real y-coordinate
  #
  # returns the distance to the nearest intersecting event in the
  # direction specified
  #--------------------------------------------------------------------------
  def platform_event_up( x, x_offset, y, y_offset, self_event = nil )

    low_distance = 128
 
    # Loop in all events
    for event in events.values
      # only bother with non-through map tiles
      if event.tile_id >= 0 and not event.through and event != self_event
        # narrow it down
        xdif = event.x * 128 + event.x_offset - x * 128 - x_offset
        ydif = y * 128 + y_offset - event.y * 128 - event.y_offset
        if -128 < xdif and xdif < 128 and 0 < ydif and ydif < 256
          # tile passability rules
          if @passages[ event.tile_id ] & 0x01 == 0x01 or event.tile_id == 0
            low_distance = [ low_distance, ydif - 128 ].min
          elsif @passages[ event.tile_id ] & 0x08 == 0x08
            low_distance = [ low_distance, ydif ].min
          end
        end
      end
    end
 
    return low_distance
  end
 
  #--------------------------------------------------------------------------
  # * Find the nearest non-passable, non-self event in the move path
  #    x          : real x-coordinate
  #    y          : real y-coordinate
  #    x_offset  : real x-coordinate
  #    y_offset  : real y-coordinate
  #
  # returns the distance to the nearest intersecting event in the
  # direction specified
  #--------------------------------------------------------------------------
  def platform_event_down( x, x_offset, y, y_offset, self_event = nil )

    low_distance = 128

    Platform.platform_id = 0
 
    # Loop in all events
    for event in events.values
      # only bother with non-through map tiles
      if event.tile_id >= 0 and not event.through and event != self_event
        # narrow it down
        xdif = event.x * 128 + event.x_offset - x * 128 - x_offset
        ydif = event.y * 128 + event.y_offset - y * 128 - y_offset
        if -128 < xdif and xdif < 128 and 0 < ydif and ydif < 256
          # tile passability rules
          if @passages[ event.tile_id ] & 0x08 == 0x08 or event.tile_id == 0
            low_distance = [ low_distance, ydif - 128 ].min
            if low_distance == 0 and event.platform # close to platform
              Platform.platform_id = event.id
            end
          elsif @passages[ event.tile_id ] & 0x01 == 0x01
            low_distance = [ low_distance, ydif ].min
            if low_distance == 0 and event.platform # close to platform
              Platform.platform_id = event.id
            end
          end
        end
      end
    end
 
    return low_distance
  end

end
#----------------------------------------------------------------------------
# End Game_Map Edit
#----------------------------------------------------------------------------

#----------------------------------------------------------------------------
# Begin Game_Character Edit
#----------------------------------------------------------------------------
class Game_Character

  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  attr_reader :x_offset            # sub-tile grid x offset
  attr_reader :y_offset            # sub-tile grid y offset

  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias_method :eilei_platform_Game_Character_initialize, :initialize
  def initialize
    # don't want to ignore any other initialization
    eilei_platform_Game_Character_initialize
 
    # for non-discrete tile movement
    @x_offset = 0
    @y_offset = 0
 
    # for platform falling
    @fall_count = 0
    @fall_speed = Platform::FALL_SPEED
 
    # for random move type to make it not quite so frenetic
    @last_dir = 4
  end
 
  #---------------------------------------------------------------------------+
  # * Frame update
  # handles movement specially in platform mode
  #---------------------------------------------------------------------------+
  alias_method :eilei_platform_Game_Character_update, :update
  def update
    if not Platform.on?
      eilei_platform_Game_Character_update
    else
      platform_update_movement_type            # Update Movement Type
      update_animation                          # Update Animation Counters
      return if update_wait?                    # Update Wait Test
      return if update_force?                  # Update Force Route Test
      return if update_startlock?              # Update Start/Lock Test
      platform_update_movement                  # Update Movement
    end
  end
 
  #--------------------------------------------------------------------------
  # * Determine the passable distance to the left
  #    distance : the desired distance in the indicated direction
  #--------------------------------------------------------------------------
  def platform_passable_left( distance )
 
    # Get new x coordinate
    new_x = ( @x * 128 + @x_offset - distance ) / 128
    @y
 
    # If coordinates are outside of map
    unless $game_map.valid?( new_x, @y )
      # impassable; assume we're off in the direction moved
      return @x_offset
    end
 
    # If through is ON, then move anywhere actually on the map
    if @through
      # passable
      return distance
    end
 
    # Check current map tile passability, not counting events
    unless $game_map.platform_map_passable?( @x, @y, 4 )
      return 0
    end
 
    # Check move-to map tile passability, not counting events
    unless $game_map.platform_map_passable?( new_x, @y, 6 )
      return @x_offset
    end
    if @y_offset > 0 and
        not $game_map.platform_map_passable?( new_x, @y + 1, 6 )
      return @x_offset
    end
 
    # Find the distance to the nearest non-passable event
    event_distance = $game_map.platform_event_left( @x, @x_offset, @y,
      @y_offset, self )
     
    # push player if platform, otherwise don't run through the player
    if self != $game_player
      ydif = $game_player.y * 128 + $game_player.y_offset - @y * 128 - @y_offset
      xdif = @x * 128 + @x_offset - $game_player.x * 128 - $game_player.x_offset
      if -128 < ydif and ydif < 128 and 0 < xdif and xdif < 256
        if @platform
          if xdif - event_distance < 0
            $game_player.platform_push( 4, 128 - xdif )
          end
        else
          distance = [ distance, xdif - 128 ].min
        end
      end
    end

    return [ event_distance, distance ].min
  end
 
  #--------------------------------------------------------------------------
  # * Determine the passable distance in the given direction
  #    distance : the desired distance in the indicated direction
  #--------------------------------------------------------------------------
  def platform_passable_right( distance )
 
    # Get new x coordinate
    new_x = ( @x * 128 + @x_offset + distance ) / 128
 
    # If coordinates are outside of map
    unless $game_map.valid?( new_x, @y )
      # impassable; assume we're off in the direction moved
      return ( ( 128 - @x_offset ) % 128 ) # 0 if @x_offset == 0
    end
 
    # If through is ON, then move anywhere actually on the map
    if @through
      # passable
      return distance
    end
 
    # Check current map tile passability, not counting events
    unless $game_map.platform_map_passable?( @x, @y, 6 )
      return 0
    end
 
    # Check move-to map tile passability, not counting events
    unless $game_map.platform_map_passable?( new_x + 1, @y, 4 )
      return ( 128 - @x_offset ) % 128
    end
    if @y_offset > 0 and
        not $game_map.platform_map_passable?( new_x + 1, @y + 1, 4 )
      return ( 128 - @x_offset ) % 128
    end
 
    # Find the distance to the nearest non-passable event
    event_distance = $game_map.platform_event_right( @x, @x_offset, @y,
      @y_offset, self )
 
    if self != $game_player
      ydif = $game_player.y * 128 + $game_player.y_offset - @y * 128 - @y_offset
      xdif = $game_player.x * 128 + $game_player.x_offset - @x * 128 - @x_offset
      if -128 < ydif and ydif < 128 and 0 < xdif and xdif < 256
        if @platform
          if xdif - event_distance < 0
            $game_player.platform_push( 6, 128 - xdif )
          end
        else
          distance = [ distance, xdif - 128 ].min
        end
      end
    end

    return [ event_distance, distance ].min
  end

  #--------------------------------------------------------------------------
  # * Determine the passable distance in the given direction
  #    distance : the desired distance in the indicated direction
  #--------------------------------------------------------------------------
  def platform_passable_up( distance )
 
    # Get new y coordinate
    new_y = ( @y * 128 + @y_offset - distance ) / 128
 
    # If coordinates are outside of map
    unless $game_map.valid?( @x, new_y )
      # impassable; assume we're off in the direction moved
      return @y_offset
    end
 
    # If through is ON, then move anywhere actually on the map
    if @through
      # passable
      return distance
    end
 
    # Check current map tile passability, not counting events
    unless $game_map.platform_map_passable?( @x, @y, 8 )
      return 0
    end
 
    # Check move-to map tile passability, not counting events
    unless $game_map.platform_map_passable?( @x, new_y, 2 )
      return @y_offset
    end
    if @x_offset > 0 and
        not $game_map.platform_map_passable?( @x + 1, new_y, 2 )
      return @y_offset
    end
 
    # Find the distance to the nearest non-passable event
    event_distance = $game_map.platform_event_up( @x, @x_offset, @y,
      @y_offset, self )
 
    return [ event_distance, distance ].min
  end

  #--------------------------------------------------------------------------
  # * Determine the passable distance in the given direction
  #    distance : the desired distance in the indicated direction
  #--------------------------------------------------------------------------
  def platform_passable_down( distance )
 
    # Get new y coordinate
    new_y = ( @y * 128 + @y_offset + distance ) / 128

    # If coordinates are outside of map
    unless $game_map.valid?( @x, new_y )
      # impassable; assume we're off in the direction moved
      return ( ( 128 - @y_offset ) % 128 ) # 0 if @y_offset == 0
    end
 
    # If through is ON, then move anywhere actually on the map
    if @through
      # passable
      return distance
    end
 
    # Check current map tile passability, not counting events
    unless $game_map.platform_map_passable?( @x, @y, 2 )
      return 0
    end
 
    # Check move-to map tile passability, not counting events
    unless $game_map.platform_map_passable?( @x, new_y + 1, 8 )
      return ( 128 - @y_offset ) % 128
    end
    if @x_offset > 0 and
        not $game_map.platform_map_passable?( @x + 1, new_y + 1, 8 )
      return ( 128 - @y_offset ) % 128
    end

    # Find the distance to the nearest non-passable event
    event_distance = $game_map.platform_event_down( @x, @x_offset, @y,
      @y_offset, self )
 
    return [ event_distance, distance ].min
  end

  #--------------------------------------------------------------------------
  # * Determine if Moving
  # Won't affect normal movement as long as @x_offset and @y_offset are 0
  #--------------------------------------------------------------------------
  alias_method :eilei_platform_Game_Character_moving?, :moving?
  def moving?
    # If logical coordinates differ from real coordinates,
    # movement is occurring.
    return ( @real_x != @x * 128 + @x_offset or
      @real_y != @y * 128 + @y_offset )
  end

  #---------------------------------------------------------------------------+
  # * update_platform_movement_type handles movement type during platform mode
  #---------------------------------------------------------------------------+
  def platform_update_movement_type
    # Branch with jumping, moving, and stopping
    if moving?
      platform_update_move
    elsif jumping?
      update_jump
    else
      update_stop
    end
  end
 
  #---------------------------------------------------------------------------+
  # * update_platform_movement handles movement during platform mode
  #---------------------------------------------------------------------------+
  def platform_update_movement

    # If stop count exceeds a certain value (computed from move frequency)
    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
      # Branch by move type
      case @move_type
      when 1  # Random
        platform_move_type_random
      when 2  # Approach
        platform_move_type_toward_player
      when 3  # Custom
        platform_move_type_custom
      end
    end

    # gravity! only non-fixed items fall
    if @move_type > 0
      platform_fall_down
    end
  end

  #--------------------------------------------------------------------------
  # * Update frame (move)
  #  modified to reflect platformer mode
  #--------------------------------------------------------------------------
  def platform_update_move

    # Convert map coordinates from map move speed into move distance
    distance = 2 ** @move_speed

    # If logical coordinates are more to the left than real coordinates
    if @x * 128 + @x_offset < @real_x
      # Move left
      @real_x = [ @real_x - distance, @x * 128 + @x_offset ].max
    end
    # If logical coordinates are more to the right than real coordinates
    if @x * 128 + @x_offset > @real_x
      # Move right
      @real_x = [ @real_x + distance, @x * 128 + @x_offset ].min
    end

    # If logical coordinates are further down than real coordinates
    if @y * 128 + @y_offset > @real_y
      # Move down
      if flying?
        @real_y = [ @real_y + distance, @y * 128 + @y_offset ].min
      else
        @real_y = [ @real_y + 2 ** @fall_speed, @y * 128 + @y_offset ].min
      end
    end
    # If logical coordinates are further up than real coordinates
    if @y * 128 + @y_offset < @real_y
      # Move up
      @real_y = [ @real_y - distance, @y * 128 + @y_offset ].max
    end
 
    # If move animation is ON
    if @walk_anime
      # Increase animation count by 1.5
      @anime_count += ( @move_speed / 2.0 ) # faster animation for higher speed
    # If move animation is OFF, and stop animation is ON
    elsif @step_anime
      # Increase animation count by 1
      @anime_count += 1
    end

  end
 
  #--------------------------------------------------------------------------
  # * Platform Move Type : Random
  #--------------------------------------------------------------------------
  def platform_move_type_random
 
    # Branch by random numbers
    case rand( 10 )
    when 0    # 10% chance change direction
      if @last_dir == 4
        platform_move_right( false )
        @last_dir = 6
      else
        platform_move_left( false )
        @last_dir = 4
      end
    when 1..2 # 20% chance to stop
      @stop_count = 0
    else      # 70% chance to go straight
      if @last_dir == 4
        platform_move_left( false )
      else
        platform_move_right( false )
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Platform Move Type : Approach
  #--------------------------------------------------------------------------
  def platform_move_type_toward_player
 
    # no need to recalculate these a bunch of times
    player_x = $game_player.x * 128 + $game_player.x_offset
    player_y = $game_player.y * 128 + $game_player.y_offset
    self_x = @x * 128 + @x_offset
    self_y = @y * 128 + @y_offset
 
    # don't move onto the player
    if player_x < self_x
      if player_x < self_x - 128
        platform_move_left( false )
      elsif player_y < self_y - 128 or player_y > self_y + 128
        platform_move_left( false )
      end
    elsif player_x > self_x
      if player_x > self_x + 128
        platform_move_right( false )
      elsif player_y < self_y - 128 or player_y > self_y + 128
        platform_move_right( false )
      end
    end
 
    # if this event flies, it can move up and down
    if flying?
      if player_y < self_y
        if player_y < self_y - 128
          platform_jump_up( false )
        elsif player_x < self_x - 128 or player_x > self_x + 128
          platform_jump_up( false )
        end
      elsif player_y > self_y
        if player_y > self_y + 128
          platform_fall_down( false, true )
        elsif player_x < self_x - 128 or player_x > self_x + 128
          platform_fall_down( false, true )
        end
      end
    end
 
  end
 
  #--------------------------------------------------------------------------
  # * Platform Move Type : Custom
  #
  #  This method is mostly cut and paste from the non-platform version,
  #  but some unsupported custom move commands have been commented out
  #--------------------------------------------------------------------------
  def platform_move_type_custom
    # Interrupt if not stopping
    if jumping? or moving?
      return
    end
    # Loop until finally arriving at move command list
    while @move_route_index < @move_route.list.size
      # Acquiring move command
      command = @move_route.list[@move_route_index]
      # If command code is 0 (last part of list)
      if command.code == 0
        # If [repeat action] option is ON
        if @move_route.repeat
          # First return to the move route index
          @move_route_index = 0
        end
        # If [repeat action] option is OFF
        unless @move_route.repeat
          # If move route is forcing
          if @move_route_forcing and not @move_route.repeat
            # Release forced move route
            @move_route_forcing = false
            # Restore original move route
            @move_route = @original_move_route
            @move_route_index = @original_move_route_index
            @original_move_route = nil
          end
          # Clear stop count
          @stop_count = 0
        end
        return
      end
      # During move command (from move down to jump)
      if command.code <= 14
        # Branch by command code
        case command.code
        when 1  # Move down
          platform_fall_down( false, flying? )
        when 2  # Move left
          platform_move_left
        when 3  # Move right
          platform_move_right
        when 4  # Move up
          platform_jump_up
        when 5  # Move lower left
          platform_move_left
          platform_fall_down( false, flying? )
        when 6  # Move lower right
          platform_move_right
          platform_fall_down( false, flying? )
        when 7  # Move upper left
          platform_move_left
          platform_jump_up
        when 8  # Move upper right
          platform_move_right
          platform_jump_up
#        when 9  # Move at random
#          platform_move_type_random
        when 10  # Move toward player
          platform_move_type_toward_player
#        when 11  # Move away from player
#          move_away_from_player
#        when 12  # 1 step forward
#          move_forward
#        when 13  # 1 step backward
#          move_backward
        when 14  # Jump
          jump(command.parameters[0], command.parameters[1])
        end
        # If movement failure occurs when [Ignore if can't move] option is OFF
        if not @move_route.skippable and not moving? and not jumping?
          return
        end
        @move_route_index += 1
        return
      end
      # If waiting
      if command.code == 15
        # Set wait count
        @wait_count = command.parameters[0] * 2 - 1
        @move_route_index += 1
        return
      end
      # If direction change command
      if command.code >= 16 and command.code <= 26
        # Branch by command code
        case command.code
        when 16  # Turn down
          turn_down
        when 17  # Turn left
          turn_left
        when 18  # Turn right
          turn_right
        when 19  # Turn up
          turn_up
        when 20  # Turn 90° right
          turn_right_90
        when 21  # Turn 90° left
          turn_left_90
        when 22  # Turn 180°
          turn_180
        when 23  # Turn 90° right or left
          turn_right_or_left_90
        when 24  # Turn at Random
          turn_random
        when 25  # Turn toward player
          turn_toward_player
        when 26  # Turn away from player
          turn_away_from_player
        end
        @move_route_index += 1
        return
      end
      # If other command
      if command.code >= 27
        # Branch by command code
        case command.code
        when 27  # Switch ON
          $game_switches[command.parameters[0]] = true
          $game_map.need_refresh = true
        when 28  # Switch OFF
          $game_switches[command.parameters[0]] = false
          $game_map.need_refresh = true
        when 29  # Change speed
          @move_speed = command.parameters[0]
        when 30  # Change freq
          @move_frequency = command.parameters[0]
        when 31  # Move animation ON
          @walk_anime = true
        when 32  # Move animation OFF
          @walk_anime = false
        when 33  # Stop animation ON
          @step_anime = true
        when 34  # Stop animation OFF
          @step_anime = false
        when 35  # Direction fix ON
          @direction_fix = true
        when 36  # Direction fix OFF
          @direction_fix = false
        when 37  # Through ON
          @through = true
        when 38  # Through OFF
          @through = false
        when 39  # Always on top ON
          @always_on_top = true
        when 40  # Always on top OFF
          @always_on_top = false
        when 41  # Change Graphic
          @tile_id = 0
          @character_name = command.parameters[0]
          @character_hue = command.parameters[1]
          if @original_direction != command.parameters[2]
            @direction = command.parameters[2]
            @original_direction = @direction
            @prelock_direction = 0
          end
          if @original_pattern != command.parameters[3]
            @pattern = command.parameters[3]
            @original_pattern = @pattern
          end
        when 42  # Change Opacity
          @opacity = command.parameters[0]
        when 43  # Change Blending
          @blend_type = command.parameters[0]
        when 44  # Play SE
          $game_system.se_play(command.parameters[0])
        when 45  # Script
          result = eval(command.parameters[0])
        end
        @move_route_index += 1
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * move left, modified for platform movement
  #    turn_enabled : a flag permits direction change on that spot
  #--------------------------------------------------------------------------
  def platform_move_left( turn_enabled = true )

    if turn_enabled
      turn_left
    end

    # Check to see how far in that direction the character can move
    movable_distance = platform_passable_left( 2 ** @move_speed )

    # move the character's location, if necessary
    if movable_distance == 0

    elsif @x_offset - movable_distance < 0
      @x -= 1
      # Increase steps only fires when the base tile is changed
      increase_steps
    end
    @x_offset = ( @x_offset - movable_distance ) % 128
 
    # check for platform riders
    if @platform
      for rider in Platform.get_riders( @id )
        if rider == 0 then
          $game_player.platform_push( 4, movable_distance )
        else
          $game_map.events[ rider ].platform_push( 4, movable_distance )
        end
      end
    end

    # Determine if touch event is triggered
    platform_check_event_trigger_touch
  end

  #--------------------------------------------------------------------------
  # * Move right, modified for platform movement
  #    turn_enabled : a flag permits direction change on that spot
  #--------------------------------------------------------------------------
  def platform_move_right( turn_enabled = true )

    if turn_enabled
      turn_right
    end

    # Check to see how far in that direction the character can move
    movable_distance = platform_passable_right( 2 ** @move_speed )
    # move the character's location, if necessary
    if movable_distance == 0
   
    elsif @x_offset + movable_distance >= 128
      @x += 1
      # Increase steps only fires when the base tile is changed
      increase_steps
    end
    @x_offset = ( @x_offset + movable_distance ) % 128
 
    # check for platform riders
    if @platform
      for rider in Platform.get_riders( @id )
        if rider == 0 then
          $game_player.platform_push( 6, movable_distance )
        else
          $game_map.events[ rider ].platform_push( 6, movable_distance )
        end
      end
    end

    # Determine if touch event is triggered
    platform_check_event_trigger_touch
  end

  #--------------------------------------------------------------------------
  # * move up, modified for platform movement
  #    turn_enabled : a flag permits direction change on that spot
  #--------------------------------------------------------------------------
  def platform_jump_up( turn_enabled = true )
 
    # Check to see how far in that direction the character can move
    movable_distance = platform_passable_up( 2 ** @move_speed )

    if turn_enabled and Platform::TURN_ON_JUMP
      turn_up
    end

    # move the character's location, if necessary
    if movable_distance == 0
   
    elsif @y_offset - movable_distance < 0
      @y -= 1
      # Increase steps only fires when the base tile is changed
      increase_steps
    end
    @y_offset = ( @y_offset - movable_distance ) % 128
 
    # check for platform riders
    if @platform
      for rider in Platform.get_riders( @id )
        if rider == 0 then
          $game_player.platform_push( 8, movable_distance )
        else
          $game_map.events[ rider ].platform_push( 8, movable_distance )
        end
      end
    end

    # Determine if touch event is triggered
    platform_check_event_trigger_touch
  end

  #--------------------------------------------------------------------------
  # * platform_fall_down ; move down, modified for platform movement
  #    turn_enabled : a flag permits direction change on that spot
  #    fly_down    : permits a flying thing to deliberately fly down
  #--------------------------------------------------------------------------
  def platform_fall_down( turn_enabled = true, fly_down = false )

    # don't bother falling if flying, unless we want to
    if not flying? or fly_down

      # Check to see how far in that direction the character can move
      if fly_down
        movable_distance = platform_passable_down( 2 ** @move_speed )
      else
        movable_distance = platform_passable_down( 2 ** @fall_speed )
      end

      if Platform.platform_id > 0
        if not flying?
          Platform.ride_platform( @id, Platform.platform_id )
        end
        Platform.platform_id = 0
      else
        Platform.off_platform( @id )
      end
   
      # move the character's location, if necessary
      if movable_distance > 0

        # turn down if actually falling
        if turn_enabled and Platform::TURN_ON_FALL
          turn_down
        end
 
        unless fly_down
          @fall_count += 1
          if @fall_count == Platform::FALL_SPEED_INCREASE[ @fall_speed ]
            @fall_speed += 1
          end
        end
     
        if @y_offset + movable_distance >= 128
          @y += 1
          # Increase steps only fires when the base tile is changed
          increase_steps
        end
        @y_offset = ( @y_offset + movable_distance ) % 128
     
        # check for platform riders
        if @platform
          for rider in Platform.get_riders( @id )
            if rider == 0 then
              $game_player.platform_push( 2, movable_distance )
            else
              $game_map.events[ rider ].platform_push( 2, movable_distance )
            end
          end
        end
      else # stand on the object
        @fall_count = 0
        unless fly_down
          @fall_speed = Platform::FALL_SPEED
        end
      end
    end

    # Determine if touch event is triggered
    platform_check_event_trigger_touch
  end
 
  #---------------------------------------------------------------------------+
  # * platform_push shoves an event in a particular direction
  #    d        : direction of motion (only left or right)
  #    distance : distance pushed
  #---------------------------------------------------------------------------+
  def platform_push( d, distance )
    # platform pushing is special; it ignores most restrictions, and doesn't
    # change player direction and such
    case d
    when 2:
      if @y_offset + distance >= 128
        @y += 1
        # Increase steps only fires when the base tile is changed
        increase_steps
      end
      @y_offset = ( @y_offset + distance ) % 128
    when 4:
      if @x_offset - distance < 0
        @x -= 1
        # Increase steps only fires when the base tile is changed
        increase_steps
      end
      @x_offset = ( @x_offset - distance ) % 128
    when 6:
      if @x_offset + distance >= 128
        @x += 1
        # Increase steps only fires when the base tile is changed
        increase_steps
      end
      @x_offset = ( @x_offset + distance ) % 128
    when 8:
      if @y_offset - distance < 0
        @y -= 1
        # Increase steps only fires when the base tile is changed
        increase_steps
      end
      @y_offset = ( @y_offset - distance ) % 128
    end
  end

end
#----------------------------------------------------------------------------
# End Game_Character Edit
#----------------------------------------------------------------------------

#----------------------------------------------------------------------------
# Begin Game_Player Edit
#----------------------------------------------------------------------------
class Game_Player < Game_Character

  attr_reader :fall_count
  attr_reader :platform_jump_count
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias_method :eilei_platform_Game_Player_initialize, :initialize
  def initialize
    eilei_platform_Game_Player_initialize
    @run_count = 0
    @platform_jump_count = 0
  end
 
  #--------------------------------------------------------------------------
  # * Platform variable reset
  #--------------------------------------------------------------------------
  def platform_reset
    @x_offset, @y_offset = 0, 0
    @run_count, @platform_jump_count = 0, 0
    @fall_count = 0
    @fall_speed = Platform::FALL_SPEED
    @move_speed = Platform::MOVE_SPEED
    Platform.flying = false
  end

  #--------------------------------------------------------------------------
  # * Platform variable setup
  #--------------------------------------------------------------------------
  def platform_setup
    Platform.old_move_speed = @move_speed
    Platform.platform_id = 0
  end

  #--------------------------------------------------------------------------
  # * Determine if the player is flying
  #--------------------------------------------------------------------------
  def flying?
    Platform.flying?
  end
 
  #--------------------------------------------------------------------------
  # * Frame Update : Player Movement Test
  #--------------------------------------------------------------------------
  def platform_update_plyrmvttest?
    # If moving, event running, move route forcing, and message window
    # display are all not occurring
    unless $game_system.map_interpreter.running? or
          @move_route_forcing or $game_temp.message_window_showing
      return true
    end
    return false
  end

  #--------------------------------------------------------------------------
  # * Frame Update
  # handles movement specially in platform mode
  #--------------------------------------------------------------------------
  alias_method :eilei_platform_Game_Player_update, :update
  def update
    if not Platform.on?
      eilei_platform_Game_Player_update
    else
      last_moving = moving?
      platform_update_player_movement if platform_update_plyrmvttest?
      last_real_x = @real_x
      last_real_y = @real_y
      super
      if Platform::AUTO_SCROLL_DOWN
        update_scroll_down( last_real_y )
      end
      if Platform::AUTO_SCROLL_LEFT
        update_scroll_left( last_real_x )
      end
      if Platform::AUTO_SCROLL_RIGHT
        update_scroll_right( last_real_x )
      end
      if Platform::AUTO_SCROLL_UP
        update_scroll_up( last_real_y )
      end
      update_nonmoving( last_moving )
    end
  end

  #---------------------------------------------------------------------------+
  # * update_platform_movement handles movement during platform mode
  #---------------------------------------------------------------------------+
  def platform_update_player_movement
    # Move player in the direction the directional button is being pressed
    case Input.dir8
    when 1, 4, 7:
      platform_move_left
    when 3, 6, 9:
      platform_move_right
    end
 
    # Check to see if jumping
    if Input.trigger?( Platform::JUMP_KEY ) and ( Platform.rider?( 0 ) or
        ( @platform_jump_count == 0 and @fall_count == 0 ) )
      # Initial jump
      $game_system.se_play( Platform::JUMP_SOUND )
      @platform_jump_count = Platform::JUMP_HEIGHT * ( 12 - @move_speed )
      platform_jump_up
      @platform_jump_count -= 1
      Platform.off_platform( 0 )
    elsif Input.press?( Platform::JUMP_KEY ) and @platform_jump_count > 0
      # still jumping
      platform_jump_up
      @platform_jump_count -= 1
    else
      # done jumping, fall down
      @platform_jump_count = 0
    end
 
    # Check to see if running
    if moving? and Input.press?( Platform::RUN_KEY )
      # can't boost speed while jumping or falling, but it won't go down either
      if @platform_jump_count == 0 and @fall_count == 0
        @run_count += 1 # increase run speed
        if flying? and platform_passable_down( 2 ** @move_speed ) > 0
          @run_count = 0
          @move_speed = Platform::MOVE_SPEED
        end
        if @run_count == Platform::RUN_SPEED_INCREASE[ @move_speed ]
          @move_speed += 1
          @run_count = 0
        end
      elsif Platform.flying? && @platform_jump_count > 0
        @run_count = 0
        @move_speed = Platform::MOVE_SPEED
      end
    else
      @run_count = 0
      @move_speed = Platform::MOVE_SPEED
    end

    # Check to see if falling
    if @platform_jump_count == 0
      platform_fall_down(true, flying?)
    end
 
    if Platform.flying?
      @fall_count = 0
    end
 
    platform_check_event_trigger_touch

  end

  #---------------------------------------------------------------------------+
  # * platform_check_event_trigger_touch checks player-event collision
  #---------------------------------------------------------------------------+
  def platform_check_event_trigger_touch

    # Check to see if an event just got bumped
    # Loop in all events
    for event in $game_map.events.values
      # only bother with player-touch trigger tiles
      if event.trigger == 1
        # narrow it down by location
        xdif = event.x * 128 + event.x_offset - @x * 128 - @x_offset
        ydif = event.y * 128 + event.y_offset - @y * 128 - @y_offset
        if -128 <= ydif and ydif <= 128 and -128 <= xdif and xdif <= 128
          event.start
        end
      end
    end
 
  end

end
#----------------------------------------------------------------------------
# End Game_Player Edit
#----------------------------------------------------------------------------
 
#----------------------------------------------------------------------------
# Begin Game_Event Edit
#----------------------------------------------------------------------------
class Game_Event

  attr_accessor :platform      # true if event is a platform
 
  #--------------------------------------------------------------------------
  # * Determines flying status of an event (ignores gravity)
  #--------------------------------------------------------------------------
  alias_method :eilei_platform_Game_Event_refresh_set_page, :refresh_set_page
  def refresh_set_page
    eilei_platform_Game_Event_refresh_set_page
 
    if not @page.list[ 0 ].nil? and @page.list[ 0 ].code == 108
      if not @page.list[ 0 ].parameters[ 0 ][ 'flying' ].nil?
        @flying = true
        @fall_speed = @move_speed
      elsif not @page.list[ 0 ].parameters[ 0 ][ 'platform' ].nil?
        @flying = true
        @fall_speed = @move_speed
        @platform = true
      else
        @flying = false
        @fall_speed = Platform::FALL_SPEED
        @platform = false
      end
    else
      @flying = false
      @fall_speed = Platform::FALL_SPEED
      @platform = false
    end
 
  end

  #--------------------------------------------------------------------------
  # * Determine if the event is flying
  #--------------------------------------------------------------------------
  def flying?
    return ( @flying == true )
  end

  #---------------------------------------------------------------------------+
  # * platform_check_event_trigger_touch checks event collision
  #---------------------------------------------------------------------------+
  def platform_check_event_trigger_touch

    # Check to see if the player just got bumped
    if trigger == 1
      # narrow it down by location
      xdif = @x * 128 + @x_offset - $game_player.x * 128 - $game_player.x_offset
      ydif = @y * 128 + @y_offset - $game_player.y * 128 - $game_player.y_offset
      if -128 <= ydif and ydif <= 128 and -128 <= xdif and xdif <= 128
        start
      end
    end

    # Check to see if an event just got bumped
    # Loop in all events
    for event in $game_map.events.values
      # only bother with event-touch trigger tiles
      if event.trigger == 2 and event != self
        # narrow it down by location
        xdif = event.x * 128 + event.x_offset - @x * 128 - @x_offset
        ydif = event.y * 128 + event.y_offset - @y * 128 - @y_offset
        if -128 <= ydif and ydif <= 128 and -128 <= xdif and xdif <= 128
          event.start
        end
      end
    end
  end

end

end # SDK.enabled?


El script necesita el llamado SDK en dos partes... si lo necesitan se lo posteo en otro mensaje.

Ledai
Aventurero
Aventurero

0/3

Créditos 1368

Gracias : 126

http://ahurallg.blogspot.com.es/

Volver arriba Ir abajo

Ver el tema anterior Ver el tema siguiente Volver arriba


 :: RPG Maker :: Ayuda RPG

Permisos de este foro:
No puedes responder a temas en este foro.