Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Ladder Climbing Done Right, No more walking down a ladder facing the screen
BigEd781
post Jan 18 2009, 03:01 AM
Post #1


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




Ladder Climbing Animation
By BigEd781
Credit to DerVVulfman for his tile id formula


Introduction
By default, when you climb down a ladder you face straight at the screen. I was making a mountain map and really didn't like it, so I made this. It doesn't need any configuration, but things can be adjusted if they need to be. All this does is turn the player around (i.e., facing up) when you are walking on a wall tile. Because wall tiles are generally unpassable, the only time this happens is when you are climbing up or down a ladder. This won't effect events or anything else but the player. Maybe I will add an option for events later on, but I really just did this because it was annoying me. This script also allows you to use a custom animation if you wish to, but as I had none that option is turned off by default.

Configuration / Use
Just place it in the materials section. This script does not overwrite anything, so if you have any problems try placing it at the end of your list of scripts.

There are some things that you can configure if you wish. Like I said before, this works by setting certain tile id's which will act like "climbing ladder" tiles. All of the wall tiles in the RTP are already ON by default, so you probably will never have to configure anything. Most alternative tilesets place the walls in the same places as the RTP. If you are using tilesets which do not have wall tiles in the same places as the RTP, you can use the debug window to figure out which ones to remove. By default and when in test mode, pressing F5 will display a window that tells you the id of the tile you are standing on. When you need to add or remove a ladder tile, step on it in test mode and press F5. Remove that number from the collection of id's in the config section (shown below).

CODE
# this is the key that you may use to
  # display the id of the tile that you
  # are on.  You shouldn't need to use
  # this, but if you would like to add
  # more tiles to the "ladder tile"
  # collection you can use this to find
  # the id.
  DEBUG_KEY = Input::F5
  # this is a collection of tile ids.
  # this default set is all of the "wall"
  # type tiles in the RTP.  If you need
  # to add or remove tiles to this set
  # you can use the debug window to do so.
  # to add a tile id, simply type in the
  # id number where noted below and add a
  # comma after it.  Always keep the id's
  # between the two braces ('[' and ']').
  # if you are using the Mack tileset, comment out
  # the two lines labeled "comment out for Mack".
  # you can do this by adding a '#' character
  # to the beginning of the line.
  TILE_IDS = [
                56,  57,  58,  59,  60,  61,  62,  63,
                72,  73,  74,  75,  76,  77,  78,  79,
                88,  89,  90,  91,  92,  93,  94,  95,
                104, 105, 106, 107, 108, 109, 110, 111,
                120, 121, 122, 123, 124, 125, 126, 127,
                152, 153, 154, 155, 156, 157, 158, 159, # <-- comment out for Aërendyll's Mack tilesets
                168, 169, 170, 171, 172, 173, 174, 175,
                184, 185, 186, 187, 188, 189, 190, 191, # <-- comment out for Aërendyll's Mack tilesets
                    # <-- Add id's here.  
             ]
  # set this to true if you would like to
  # use a different graphic when climbing.
  USE_GRAPHIC = false
  # the file name of the custom graphic.
  # you do not need to add the file extension,
  # i.e., 'Actor1' not 'Actor1.png'.
  CHARACTER_NAME = 'Actor1'
  # the index of the character in the sheet.
  # in an 8 character sheet, '1' is the
  # top-left, '2' is the next to the right,
  # and '4' is the bottom left.
  CHARACTER_INDEX = 1


Script
CODE
module Ladder_Config
    
  # this is the key that you may use to
  # display the id of the tile that you
  # are on.  You shouldn't need to use
  # this, but if you would like to add
  # more tiles to the "ladder tile"
  # collection you can use this to find
  # the id.
  DEBUG_KEY = Input::F5
  # this is a collection of tile ids.
  # this default set is all of the "wall"
  # type tiles in the RTP.  If you need
  # to add or remove tiles to this set
  # you can use the debug window to do so.
  # to add a tile id, simply type in the
  # id number where noted below and add a
  # comma after it.  Always keep the id's
  # between the two braces ('[' and ']').
  # if you are using the Mack tileset, comment out
  # the two lines labeled "comment out for Mack".
  # you can do this by adding a '#' character
  # to the beginning of the line.
  TILE_IDS = [
                56,  57,  58,  59,  60,  61,  62,  63,
                72,  73,  74,  75,  76,  77,  78,  79,
                88,  89,  90,  91,  92,  93,  94,  95,
                104, 105, 106, 107, 108, 109, 110, 111,
                120, 121, 122, 123, 124, 125, 126, 127,
                152, 153, 154, 155, 156, 157, 158, 159, # <-- comment out for Aërendyll's Mack tilesets
                168, 169, 170, 171, 172, 173, 174, 175,
                184, 185, 186, 187, 188, 189, 190, 191, # <-- comment out for Aërendyll's Mack tilesets
                    # <-- Add id's here.  
             ]
  # set this to true if you would like to
  # use a different graphic when climbing.
  USE_GRAPHIC = false
  # the file name of the custom graphic.
  # you do not need to add the file extension,
  # i.e., 'Actor1' not 'Actor1.png'.
  CHARACTER_NAME = 'Actor1'
  # the index of the character in the sheet.
  # in an 8 character sheet, '1' is the
  # top-left, '2' is the next to the right,
  # and '4' is the bottom left.
  CHARACTER_INDEX = 1
  
end

#---------------------------------------------------------------------
# * Debug class
#---------------------------------------------------------------------
class Debug
  
  def initialize
    @debug_window = nil
    @frame_count = 1
  end
  
  def hide_window?
    @frame_count += 1
    @frame_count = 0 if @frame_count == 180
    return (!@debug_window.nil?) && (@frame_count == 0)
  end
  
  def hide_window
    unless @debug_window.nil?
      @frame_count = 1
      @debug_window.dispose
      @debug_window = nil
    end
  end
  
  def long_line(lines)
    long = ''
    lines.each { |line| long = line if line.size > long.size }
    return long
  end
  
  def find_width(line)
    return Bitmap.new(544, 416).text_size(line).width + 32
  end
  
  def find_height(num_lines)    
    return (num_lines * 24) + 32
  end
  
  def log(text, x=0, y=0)  
    @debug_window = Window_Base.new(x, y, find_width(text), find_height(1))
    draw(text)
  end
  
  def log_lines(lines, x=0, y=0)
  @debug_window =
    Window_Base.new(x, y, find_width(long_line(lines)), find_height(lines.size))
  draw_lines(lines)
  end
  
  def draw(text)
    @debug_window.contents.draw_text(@debug_window.contents.rect, text)
  end
  
  def draw_lines(lines)
    i = 0
    for line in lines
      @debug_window.contents.draw_text(0, i, 544, 416, text)
      i += 24
    end
  end
  
end

class Scene_Title
  
  alias :eds_debug_create_game_objects :create_game_objects
  def create_game_objects
    eds_debug_create_game_objects
    $debugger = Debug.new
  end
  
end

class Scene_Base
  
  def update
    $debugger.hide_window if ($debugger.hide_window? && $TEST)
  end
  
end

class Game_Map
  
  #--------------------------------------------------------------------------
  # * DerVVulfman method L get_tile_index
  #--------------------------------------------------------------------------
  def tile_index(tile_id)
    case tile_id
      # Multi-tiled ids in Tileset 'A'
      when 2048..8191; return ((tile_id - 2000) / 48) - 1
      # Individual tile ids in Tileset 'A'
      when 1536..1663; return(tile_id - 1408)
      # Tilesets 'B' to 'E'
      when 0..1023; return (tile_id + 256)        
    end
    return 0  
  end  
  
end

class Game_Player < Game_Character
    
  def character_name=(value)
    @character_name = value
  end
  
  def character_index=(value)
    @character_index = value
  end
  
  alias :eds_pre_ladder_turn_left :turn_left
  def turn_left
    tile_index = $game_map.tile_index($game_map.data[x, y, 0])                  
    return if Ladder_Config::TILE_IDS.include?(tile_index)
    eds_pre_ladder_turn_left
  end
  
  alias :eds_pre_ladder_turn_right :turn_right
  def turn_right
    tile_index = $game_map.tile_index($game_map.data[x, y, 0])                  
    return if Ladder_Config::TILE_IDS.include?(tile_index)
    eds_pre_ladder_turn_right
  end
  #--------------------------------------------------------------------------
  # * Processing of Movement via input from the Directional Buttons
  #--------------------------------------------------------------------------
  alias :eds_pre_ladder_move_by_input :move_by_input
  def move_by_input        
    @move_failed = true
    eds_pre_ladder_move_by_input
    unless @move_failed
      tile_index = $game_map.tile_index($game_map.data[x, y, 0])                  
      if Ladder_Config::TILE_IDS.include?(tile_index)
        if Ladder_Config::USE_GRAPHIC
          $game_player.character_name = Ladder_Config::CHARACTER_NAME
          $game_player.character_index = Ladder_Config::CHARACTER_INDEX                    
        else
          turn_up
        end
      else
        if Ladder_Config::USE_GRAPHIC
          $game_player.character_name = $game_party.members[0].character_name
          $game_player.character_index = $game_party.members[0].character_index
        end
      end
    end
  end  
  #--------------------------------------------------------------------------
  # * update
  #--------------------------------------------------------------------------
  alias :eds_pre_ladder_update :update
  def update
    eds_pre_ladder_update    
    if $TEST && Ladder_Config::DEBUG_KEY != nil
      if Input.trigger?(Ladder_Config::DEBUG_KEY)
        $debugger.hide_window        
        $debugger.log($game_map.tile_index($game_map.data[x, y, 0]))
      end
    end
  end
  
end


Compatibility / Bugs
Let me know of any issues.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   

Posts in this topic
- BigEd781   Ladder Climbing Done Right   Jan 18 2009, 03:01 AM
- - pim321   You could do the same with events...though perhaps...   Jan 18 2009, 05:28 AM
|- - BigEd781   QUOTE (pim321 @ Jan 18 2009, 05:28 AM) Yo...   Jan 18 2009, 12:45 PM
- - Mickadell   Comment Rate: Good I find it very good and useful...   Jan 18 2009, 07:28 AM
- - sandy   Great idea, BigEd! One of those little things ...   Jan 18 2009, 01:33 PM
- - woratana   Good idea~! I've never think about this. ...   Jan 18 2009, 07:10 PM
|- - BigEd781   QUOTE (woratana @ Jan 18 2009, 07:10 PM) ...   Jan 18 2009, 07:19 PM
- - woratana   My suggestion is that class 'Debug' is no...   Jan 18 2009, 07:42 PM
- - BigEd781   If that class also had a Debug class with a method...   Jan 18 2009, 08:07 PM
|- - DragonRaw22   I like this script but I can't seem to get it ...   Jan 26 2009, 03:28 PM
|- - BigEd781   QUOTE (DragonRaw22 @ Jan 26 2009, 03:28 P...   Jan 26 2009, 03:48 PM
|- - DragonRaw22   Sorry about the delay internet went down, this is ...   Jan 29 2009, 09:02 AM
- - cello_marl   This is definitely an interesting script, and some...   Feb 15 2009, 10:21 AM
- - miget man12   Well first off, this is a great idea! but unfo...   Feb 15 2009, 10:59 AM
|- - BigEd781   QUOTE (miget man12 @ Feb 15 2009, 11:59 A...   May 3 2009, 04:20 PM
- - jick6   Cool, it seems a lot simpler than doing the whole ...   Mar 6 2009, 10:25 PM
- - gamemakernoob   I tested this script and it was conveniently aweso...   Oct 20 2009, 09:45 AM
- - alexstore1   Can you make a demo or screenshot?   Nov 11 2009, 09:36 AM
- - alexstore1   I don't understand! please dont double po...   Nov 11 2009, 09:43 AM
|- - BigEd781   QUOTE (alexstore1 @ Nov 11 2009, 09:36 AM...   Dec 9 2009, 10:54 AM
- - ShadoweD   Do you think you can make something that "hid...   Dec 15 2009, 09:08 AM
- - musashi_2pedang   the problem is, i can't pass the wall.   Jul 4 2010, 10:23 PM
- - ShinGamix   Hey BigEd can this be configed into a ladder slide...   Jan 2 2011, 11:47 AM
- - Lunajuice-Co   I love this script. Thanks.   Jan 5 2011, 11:13 PM
- - RPGMakerVX52   Love the script! Just wondering if it's po...   Feb 8 2011, 05:34 PM
- - Digioso   Heya, I found this script a vere nice idea but un...   Oct 2 2011, 12:34 AM
- - Digioso   Just a small update. If you pressed F12 to reset t...   Nov 2 2011, 12:58 PM
- - Digioso   Another update. If you saved and loaded your game ...   Nov 7 2011, 01:48 PM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 10:31 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker