Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Moshan

1
 Hello! For the past days I've been searching for a custom message system and I've finally found one that suits my needs.

The problem is that I can't make it compatibile with my project...where are already some several scripts and also the XP ace engine.

I've made a demo of my project: https://drive.google.com/file/d/0Bz22DF-S1J2naVdTYkVRaGpMLU0/edit?usp=sharing so you can easily troubleshoot the issue.

I would be grateful to anyone who can help/advice me with this error. Thanks in advance!

Here's the original Custom Message Script (I've edited the one in my project to fix the superclass missmatch error):
Spoiler: ShowHide
#==============================================================================
# ** Custom Message Script by Hodgeelmf **
#
#     Version 1.4
#
#       Version History
#         1.0.0 - Basic functionality
#         1.1.0 - Fixed issue with bubble size and bolded text
#               Modified gold window
#               Added /q function
#         1.2.0 - Added Icon display
#               Added Face Graphics
#               Fixed Gold command iteration error (This is what formerly broke
#                                                   the script)
#               Added use of Windowskin Graphic
#               Fixed sub window termination to be more natural
#         1.3.0 - Added thought indicater option
#               Added emotion colors
#         1.4.0 - Fixed glitch when switching from Windowskin to Bubble mode
#               Added function to disable bubble bouncing
#         1.4.1 - Fixed text drawing issue when choices displayed without
#               preceding message text
#                 Created \nc command
#
#       **************UPDATE NOTE*******************
#         This script displays all choices immediately after the text
#         which precedes them.  I have added a command to prevent this
#         should you elect to do so:
#
#               \nc
#
#           I see no reason to turn this into a toggle currently unless
#           there were significant push for it
#
#
#     Necessary updates
#
#       -Add other various functions like display hp, quest, etc.
#
#==============================================================================
=begin

Welcome to the Custom Message script!

Installation instructions:

1.  Install this script above Main, preferrably directly above
2.  Download attached graphics (message_bubble and pointer2)
   and place in Graphics/Pictures
3.  That's it!

Message commands:

\e[x]   Display message over a map event

   By default, bubble messages display over the player's sprite.  Values
   outside of the map events range will display over the player as well.

\c[x]   Change message text color (0-8)

\n[x]   Insert actor name

\v[x]   Insert variable value

\b      Toggle bold text

\w[x]   Wait control (0-999)

   Wait values are determined by frame.  40 FPS is the script rate.

\p      Pause control

   Forces the player to press enter before continuing.

\q      Forced ending

   Forces the message winddow to close once the character is encountered.
   Typically best to use directly after a wait timer.
   
\f      Force position

   Forces a specific position for the message bubble.
   
   0 - Upper right of the sprite
   1 - Upper left of the sprite
   2 - Lower right of the sprite
   3 - Lower left of the sprite
   
\g      Displays gold window

   Fades in the gold window to the bottom right corner of the screen.  To keep
   it displayed after current message, add \g into the next master message.

\i[x]   Display icon

   Displays an icon from the "Icons" folder.  A constant array, Icons, is
   compiled at runtime to store imported icon names in addition to RTP.
   
\z[x]   Display face graphic (found in Graphics/Faces - you may have to create this
                                                       folder)

   Displays a face graphic on the left of the message.  Currently this script
   only supports images with one face (as opposed to a whole faceset).

\t     Thought Bubble

       Uses thought indicater (ie two dots instead of mouth opening style)
       
\m[x]   Mood Coloring

       Changes bubble color to indicate speakers/thinkers mood (0-4)
       
\nc     Do not Display Choices

       Keeps choices from being appended to the text preceding them
   
\h[x]  Display Hp

   Not functioning at this point

\s[x]   Sub window controls (explained below)

 
 Master - the message which controls sub windows
 Sub - any message that displays as a part of a master
   
   1. The master message always has a higher z value than any sub messages
   2. Sub message must immediately follow the master message and be in
       consecutive order (ex. sub 0 must be the next event command after
       the master message, sub 1 must be the next event command after
       sub 0, etc.)
   3. Sub messagge numbers do not reset after a master message.  For
       example, if the first master messsage contains two sub messages,
       the second master message with sub messages must begin with sub
       message number 3, and so on.
   4. Use \s[x] where x is the number of the sub message to indicate that
       a particular message is a sub message
   5. Call sub messages in a master message with \s[x] where x is the
       number of the sub message.
   6. There is no limit to the number of sub messages, but since text is
       drawn one letter at a time, too many messages may cause lag.
       
 ***NOTE***
     If any of these commands seem bulky, it is because there is a glitch in
     the run script command in the event editor which does not allow for
     single lines changing global variables to function properly.
       
Script commands (from the Event Editor):

 1. Choose message style (bubble, windowskin or invisible)
     
     ***** If you do not have the correct images in Graphics/Pictures
     ***** the script will automatically change to WINDOWSKIN mode and
     ***** change the default text color to white
 
     $game_system.message_text_mode = x
     
     TEXT_MODE_BUBBLE
     TEXT_MODE_INVISIBLE
     TEXT_MODE_WINDOWSKIN
     
 2. Enable or disable bubble bouncing (only applies when in TEXT_MODE_BUBBLE)
 
     $game_system.message_bubble_bounce = x
     
     BUBBLE_BOUNCE_ON
     BUBBLE_BOUNCE_OFF
     
 2. Change position of invisible text
 
     $game_system.invisible_position = x
     
     INVISIBLE_POSITION_TOP
     INVISIBLE_POSITION_MIDDLE
     INVISIBLE_POSITION_BOTTOM
     INVISIBLE_POSITION_BOOK(arbitrary value from one of my projects)
     
 3. Change outline text options
 
     $game_system.message_text_outline = x
     
     TEXT_NORMAL
     TEXT_OUTLINE
     
 4. Change text speed
 
     $game_system.message_text_speed = x
     
     TEXT_SPEED_SLOW
     TEXT_SPEED_MEDIUM
     TEXT_SPEED_FAST
 
 5. Change text skip rate (one letter per frame up to all at once)
     
     $game_system.message_text_skip = x
 
     TEXT_SKIP_NORMAL  (1)
     TEXT_SKIP_DOUBLE  (2)
     TEXT_SKIP_TRIPLE  (3)
     TEXT_SKIP_FULL
 
     
 5. Change text size
 
     $game_system.message_text_size = x
     
     TEXT_SIZE_SMALL
     TEXT_SIZE_MEDIUM
     TEXT_SIZE_LARGE
     TEXT_SIZE_JUMBO
     
 6. Change text font
 
     $game_system.message_text_font = x
     
     TEXT_FONT_DEFAULT
     TEXT_FONT_CORSIVA
     
 7. Color Constants
 
     TEXT_COLOR_BLACK
     TEXT_COLOR_WHITE
     
 8. Face Graphic Functions
 
     $game_system.face_graphic_type = x
     
 9. Face Graphic Constants
 
     FACE_GRAPHIC_FULL - typically a bust which looks better offset to the left
                         and extending abovve the bubble
     FACE_GRAPHIC_BOX -  traditional boxed in face graphics which need to be
                         encased by the bubble to look correct
     
 10. Global Methods (for ease of access)
 
     message(string) - place in script box in event processing
     
     ***** Only place this command once per Event Script Box *****
     
     You may wish to have dialogue or entries that are longer than three
     lines.  This global method allows you to supply a string to
     $game_temp.message_text manually.  The best way to do so is to store
     a message in a variable and pass it to the method.  In this example
     script there is a Game_Messages class which has public methods that
     assign a message to a variable.  For full games, it would be better
     to create a text file to load from.  The best formatter to use is
     %q (ex @message = %q(lots of text...can be multiple lines).  The
     %q formatter mimicks the event dialogue box text editing format
     so you can use single "\" characters instead of using "\\" or not
     being able to use special characters at all.
     
     default_color(x) - set message default color
     
     Input either a number 0 through 8 or a Color object.
     
     face(string) - set default face graphic
     
     Use this method to supply a default face graphic for messages.  This graphic
     has secondary priority to one explicitly declared in a message, so is useful
     for largely unbroken monologues.
     
     clear_face - clears the default face graphic
     
     small_text
     medium_text   - Shortcut methods to change $game_system.message_text_size
     large_text
     jumbo_text
     
     slow_text
     fast_text     - Shortcut methods to change $game_system.messge_text_speed
     
           
     
                                     Enjoy! And remember to credit!

=end

#========================================================================
#   Game_Messages
#       You can easily create messages to display of any length using this
#       Class or a similar one of your creation.
#========================================================================

class Game_Messages
 
 # This message is obviously far too long for a bubble message, but it looks
 # quite good with a darkened screen tone
 
 # When loaded into a global variable, these class methods can be called to
 # the event editor with two lines of code.  For your own projects, you will
 # probably want a more sophisticated heirarchy.
 def message_1
   @message = %q(\c[0]\bMessage commands:\b

\c[6]\b\\e[x]\c[0]     Display message over a map event\b
                   By default, bubble messages display over the player's sprite.  Values
                   outside of the map events range will display over the player as well.
\c[6]\b\\c[x]\c[0]     Change message text color (0-8)\b
\c[6]\b\\n[x]\c[0]     Insert actor name\b
\c[6]\b\\v[x]\c[0]     Insert variable value\b
\c[6]\b\\\\b\c[0]        Toggle bold text\b
\c[6]\b\\w[x]\c[0]     Wait control (0-999)\b
                   Wait values are determined by frame.  40 FPS is the script rate.
\c[6]\b\\\\p\c[0]        Pause control\b
                   Forces the player to press enter before continuing.
\c[6]\b\\\\q\c[0]        Forced ending\b
                   Forces the message winddow to close once the character is encountered.
                   Typically best to use directly after a wait timer.
\c[6]\b\\\\f[x]\c[0]      Force position\b
                   Forces a specific position for the message bubble.

                   \b0\b - Upper right of the sprite
                   \b1\b - Upper left of the sprite
                   \b2\b - Lower right of the sprite
                   \b3\b - Lower left of the sprite
\c[6]\b\\\\g\c[0]        Displays gold window\b
                    Fades in the gold window to the bottom right corner of the screen.  To keep
                    it displayed after current message, add \\\\g into the next master message.
\c[6]\b\\\\i[x]\c[0]      Displays an icon from Graphics/Icons\b
\c[6]\b\\\\z[x]\c[0]      Displays a face graphic from Graphics/Faces\b
                    References an array compiled at runtime from Graphics/Faces.  You will have
                    to create this folder and manually install files.                    
\c[6]\b\\\\s[x]\c[0]     Sub window controls\b (see documentation for full instructions))
 end
 
 def message_2
   @message = %q(          \c[6]\b$game_system Properties\b\c[0]
   
             Change these properties in the Event Editor by using the Script command.  Begin with
             $game_system, then add a "." followed by the property you wish to alter.  In the
             Script command you will need to use two lines.  For example:
             
                         $game_system.message_text_speed =\
                         TEXT_SPEED_FAST
           
         The properties are listed below with available values to the right.  For full
         documentation, refer to the script instructions.
         
             \c[6]\bmessage_text_mode\b\c[0]             TEXT_MODE_INVISIBLE,TEXT_MODE_BUBBLE,TEXT_MODE_WINDOWSKIN
             \c[6]\binvisible_position\b\c[0]                    INVISIBLE_POSITION_TOP,INVISIBLE_POSITION_MIDDLE,
                                                                  INVISIBLE_POSITION_BOTTOM
             \c[6]\bmessage_text_outline\b\c[0]          TEXT_NORMAL,TEXT_OUTLINE
             \c[6]\bmessage_text_speed\b\c[0]           TEXT_SPEED_SLOW,TEXT_SPEED_MEDIUM,TEXT_SPEED_FAST
             \c[6]\bmessage_text_size\b\c[0]               TEXT_SIZE_SMALL,TEXT_SIZE_MEDIUM,TEXT_SIZE_LARGE,
                                                                 TEXT_SIZE_JUMBO
             \c[6]\bmessage_text_font\b\c[0]               TEXT_FONT_DEFAULT, whatever constant you would
                                                                  like to create
             \c[6]\bmessage_text_skip\b\c[0]               TEXT_SKIP_NORMAL,TEXT_SKIP_DOUBLE,TEXT_SKIP_TRIPLE,
                                                                 TEXT_SKIP_QUAD,
                                                                 TEXT_SKIP_QUIN,TEXT_SKIP_FULL
             \c[6]\bmessage_skip_disabled\b\c[0]       true,false
             \c[6]\bface_graphic_type\b\c[0]                  FACE_GRAPHIC_BOX,FACE_GRAPHIC_FULL
             \c[6]\bface_graphic_name\b\c[0]                file name of graphic - without folders
             \c[6]\bdefault_color\b\c[0]                            any Color object
             \c[6]\bmessage_text_outline_color\b\c[0]  any Color object)

 end
   
end

#========================================================================
#   Global Variables - simplest way to create communication between
#                       Interpreter and Window_Message
#========================================================================

$separate_choices = false

#========================================================================
#   Constant Declaration
#========================================================================

# Stores the class methods for quick custom message access
$game_messages = Game_Messages.new

BUBBLE_BOUNCE_ON = 1
BUBBLE_BOUNCE_OFF = 0

BUBBLE_UPPER_LEFT = Rect.new(0,0,13,10)
BUBBLE_LOWER_LEFT = Rect.new(0,10,13,9)
BUBBLE_UPPER_RIGHT = Rect.new(13,0,12,10)
BUBBLE_LOWER_RIGHT = Rect.new(13,10,12,9)

SKIN_UPPER_LEFT = Rect.new(128,0,10,10)
SKIN_LOWER_LEFT = Rect.new(128,54,10,10)
SKIN_UPPER_RIGHT = Rect.new(182,0,10,10)
SKIN_LOWER_RIGHT = Rect.new(182,54,10,10)

TEXT_MODE_BUBBLE = 0
TEXT_MODE_INVISIBLE = 1
TEXT_MODE_WINDOWSKIN = 2

INVISIBLE_POSITION_TOP = [320,0]
INVISIBLE_POSITION_MIDDLE = [320,240]
INVISIBLE_POSITION_BOTTOM = [320,480]
INVISIBLE_POSITION_BOOK = [460,35]

TEXT_NORMAL = 0
TEXT_OUTLINE = 1

TEXT_SPEED_SLOW = 2
TEXT_SPEED_MEDIUM = 1
TEXT_SPEED_FAST = 0

TEXT_SKIP_NORMAL = 1
TEXT_SKIP_DOUBLE = 2
TEXT_SKIP_TRIPLE = 3
TEXT_SKIP_QUAD = 4
TEXT_SKIP_QUIN = 5
TEXT_SKIP_FULL = 6

TEXT_SIZE_SMALL = 14
TEXT_SIZE_MEDIUM = 16
TEXT_SIZE_LARGE = 18
TEXT_SIZE_JUMBO = 28

# Remember to set a common default or fallback font since some users won't have
# them all
TEXT_FONT_DEFAULT = "Arial"
TEXT_FONT_CORSIVA = ["Monotype Corsiva", "Arial"]
TEXT_FONT_BOLI = ["MV Boli", "Arial"]
TEXT_FONT_COMICSANS = ["Comic Sans MS", "Arial"]

TEXT_COLOR_BLACK = Color.new(0,0,0)
TEXT_COLOR_WHITE = Color.new(250,250,250)

FACE_GRAPHIC_FULL = 0
FACE_GRAPHIC_BOX = 1

# Compile Icon array
# RTP icons are best stored manually
Icons = ['001-Weapon01','002-Weapon02','003-Weapon03','004-Weapon04'\
,'005-Weapon05','006-Weapon06','007-Weapon07','008-Weapon08'\
,'009-Shield01','010-Head01','011-Head02','012-Head03','013-Body01'\
,'014-Body02','015-Body03','016-Accessory01','017-Accessory02'\
,'018-Accessory03','019-Accessory04','020-Accessory05'\
,'021-Potion01','022-Potion02','023-Potion03','024-Potion04'\
,'025-Herb01','026-Herb02','027-Herb03','028-Herb04'\
,'029-Key01','030-Key02','031-Key03','032-Item01'\
,'033-Item02','034-Item03','035-Item04','036-Item05'\
,'037-Item06','038-Item07','039-Item08','040-Item09'\
,'041-Item10','042-Item11','043-Item12','044-Skill01'\
,'045-Skill02','046-Skill03','047-Skill04','048-Skill05'\
,'049-Skill06','050-Skill07']

# All icons in the icon folder are dynamically added at runtime
ICON_FOLDER_PATH = Dir::getwd + "/Graphics/Icons/"
dir = Dir.new(ICON_FOLDER_PATH)
dir.each { |file|
 if file != "." && file != ".."
   Icons.push file
 end
}

# Compile Face array
if File.directory? Dir::getwd + "/Graphics/Faces/"
 Faces = []
 FACE_FOLDER_PATH = Dir::getwd + "/Graphics/Faces/"
 dir = Dir.new(FACE_FOLDER_PATH)
 dir.each { |file|
   if file != "." && file != ".."
     Faces.push file
   end
 }
end

#========================================================================
#   Global Methods
#       Use these methods to quickly modify basic settings or set text
#       to $game_temp.message_text manually
#========================================================================

def message(text)
 $game_system.map_interpreter.message_waiting = true
 $game_temp.message_proc = Proc.new { @message_waiting = false }
 $game_temp.message_text = text
end

def default_color(color)
 # If an integer passed to the method
 if color.class == Fixnum
   case color
   when 0
     $game_system.default_color = TEXT_COLOR_BLACK
   when 1
     $game_system.default_color = Color.new(128, 128, 255, 255)
   when 2
     $game_system.default_color = Color.new(255, 128, 128, 255)
   when 3
     $game_system.default_color = Color.new(128, 255, 128, 255)
   when 4
     $game_system.default_color = Color.new(128, 255, 255, 255)
   when 5
     $game_system.default_color = Color.new(255, 128, 255, 255)
   when 6
     $game_system.default_color = Color.new(255, 255, 128, 255)
   when 7
     $game_system.default_color = Color.new(192, 192, 192, 255)
   when 8
     $game_system.default_color = TEXT_COLOR_WHITE
   else
     $game_system.default_color = TEXT_COLOR_BLACK
   end
 # If a Color class value is passed to the method
 elsif color.class == Color
   $game_sytem.default_color = color
 end
 
 return true
end

def mood_color(color)
 case color
 when 0
   return Color.new(70,130,180,190)
 when 1
   return Color.new(178,34,34,190)
 when 2
   return Color.new(238,174,238,190)
 when 3
   return Color.new(139,136,120,180)
 when 4
   return Color.new(255,215,0,190)
 end
end

def face(name)
 $game_system.face_graphic_name = name
end

def clear_face
 $game_system.face_graphic_name = nil
end

def small_text
 $game_system.message_text_size == TEXT_SIZE_SMALL
end

def medium_text
 $game_system.message_text_size == TEXT_SIZE_MEDIUM
end

def large_text
 $game_system.message_text_size == TEXT_SIZE_LARGE
end

def jumbo_text
 $game_system.message_text_size == TEXT_SIZE_JUMBO
end

def slow_text
 $game_system.message_text_speed == TEXT_SPEED_SLOW
end

def fast_text
 $game_system.message_text_speed == TEXT_SPEED_FAST
end

#========================================================================
#   Game Temp
#
#       @current_event - tracks the current game event for ease of access
#========================================================================

class Game_Temp
 
 attr_accessor :current_event
 attr_accessor :consecutive_gold_window
 
 alias old_initialize initialize
 
 def initialize
   old_initialize
   @current_event = nil
   @consecutive_gold_window = false
 end
 
end

#========================================================================
#   Game System
#
#       Stores message text options
#       Use $game_system to view and change values
#========================================================================

class Game_System
 attr_accessor :message_text_mode
 attr_accessor :message_bubble_bounce
 attr_accessor :invisible_position
 attr_accessor :message_text_outline
 attr_accessor :message_text_speed
 attr_accessor :message_text_size
 attr_accessor :message_text_font
 attr_accessor :message_skip_disabled
 attr_accessor :face_graphic_type
 attr_accessor :face_graphic_name
 attr_accessor :message_text_skip
 attr_accessor :default_color
 attr_accessor :message_text_outline_color
 
 alias old_initialize initialize
 
 def initialize
   old_initialize
   @message_text_mode = TEXT_MODE_BUBBLE
   @message_bubble_bounce = BUBBLE_BOUNCE_ON
   @invisible_position = INVISIBLE_POSITION_TOP
   @message_text_outline = TEXT_NORMAL
   @message_text_speed = TEXT_SPEED_FAST
   @message_text_size = TEXT_SIZE_SMALL
   @message_text_font = TEXT_FONT_DEFAULT
   @message_text_skip = TEXT_SKIP_NORMAL
   @message_skip_disabled = false
   @face_graphic_type = FACE_GRAPHIC_BOX
   @face_graphic_name = nil
   @default_color = TEXT_COLOR_BLACK
   @message_text_outline_color = TEXT_COLOR_WHITE
   
 end
 
end

#========================================================================
#   Game Player
#
#        The only change is in the condition --if Input.trigger?(Input::C)--
#        The change allows for $game_temp.message text to be manually
#          altered and still function properly
#========================================================================

class Game_Player
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Remember whether or not moving in local variables
   last_moving = moving?
   # If moving, event running, move route forcing, and message window
   # display are all not occurring
   unless moving? or $game_system.map_interpreter.running? or
          @move_route_forcing or $game_temp.message_window_showing
     # Move player in the direction the directional button is being pressed
     case Input.dir4
     when 2
       move_down
     when 4
       move_left
     when 6
       move_right
     when 8
       move_up
     end
   end
   # Remember coordinates in local variables
   last_real_x = @real_x
   last_real_y = @real_y
   super
   # If character moves down and is positioned lower than the center
   # of the screen
   if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
     # Scroll map down
     $game_map.scroll_down(@real_y - last_real_y)
   end
   # If character moves left and is positioned more let on-screen than
   # center
   if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
     # Scroll map left
     $game_map.scroll_left(last_real_x - @real_x)
   end
   # If character moves right and is positioned more right on-screen than
   # center
   if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
     # Scroll map right
     $game_map.scroll_right(@real_x - last_real_x)
   end
   # If character moves up and is positioned higher than the center
   # of the screen
   if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
     # Scroll map up
     $game_map.scroll_up(last_real_y - @real_y)
   end
   # If not moving
   unless moving?
     # If player was moving last time
     if last_moving
       # Event determinant is via touch of same position event
       result = check_event_trigger_here([1,2])
       # If event which started does not exist
       if result == false
         # Disregard if debug mode is ON and ctrl key was pressed
         unless $DEBUG and Input.press?(Input::CTRL)
           # Encounter countdown
           if @encounter_count > 0
             @encounter_count -= 1
           end
         end
       end
     end
     #-----------------------------------------------------------------
     #  Allows messages to display without interruption when directly
     #  assigned to $game_temp.message_text
     #-----------------------------------------------------------------
     # If C button was pressed
     if Input.trigger?(Input::C) && $game_temp.message_text == nil
       # Same position and front event determinant
       check_event_trigger_here([0])
       check_event_trigger_there([0,1,2])
     end
   end
 end
end

#========================================================================
#   Interpreter
#
#       Edit forces the interpreter to wait to update until all messages
#         currently on screen have finished writing
#========================================================================


class Interpreter
 
 attr_accessor :list
 attr_accessor :index
 attr_accessor :message_waiting
 
 alias old_update update
 
 def update
   
   #if $scene.message_window != nil && $scene.message_window.finished != nil
   if $game_temp.message_text != nil
     return
   else
     old_update
     $game_temp.current_event = @event_id
   end
 end
 
 def command_101
   # If other text has been set to message_text
   if $game_temp.message_text != nil
     # End
     return false
   end
   # Check for consecutive gold window calls
   temp_index = @index+1
   loop do
     case @list[temp_index].code
     when 401
       temp_index += 1
     when 101
       break
     else
       break
     end
   end
   
   # Search for consecutive message window with /g formatter
   text = nil
   
   # Iterate through max possible message size
   for i in 0...3
     # Check for existence of list element before checking code
     if @list[temp_index+i] != nil
       # Search for /g
       if @list[temp_index+i].code == 101 or @list[temp_index+i].code == 401
         text = @list[temp_index+i].parameters[0].slice(/\\[Gg]/)
         if text != nil
           # Allows for gold window to continue after first message
           $game_temp.consecutive_gold_window = true
           break
         end
       end
     end
   end
   # Turns consecutive flag off if need be
   if $game_temp.consecutive_gold_window == true && text == nil
     $game_temp.consecutive_gold_window = false
   end
   # Set message end waiting flag and callback
   @message_waiting = true
   $game_temp.message_proc = Proc.new { @message_waiting = false }
   # Set message text on first line
   $game_temp.message_text = @list[@index].parameters[0] + "\n"
   line_count = 1
   # Loop
   loop do
     # If next event command text is on the second line or after
     if @list[@index+1].code == 401
       # Add the second line or after to message_text
       $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
       line_count += 1
     # If event command is not on the second line or after
     else        
       # If next event command is show choices
       if @list[@index+1].code == 102
         # Make sure choice appellation is allowed
         for choice in @list[@index+1].parameters[0]
           if choice.slice(/\\[Nn][Cc]/)
             $separate_choices = true
             break
           end
         end
         if $separate_choices == true
           return
         end
         # Advance index
         @index += 1
         # Choices setup
         $game_temp.choice_start = line_count
         #Insert 5 spaces for indenting choices
         for i in 0...@list[@index].parameters[0].size
           if @list[@index].parameters[0][i].slice(0,5) != '     '
             @list[@index].parameters[0][i].insert(0,'     ')
           end
         end
         setup_choices(@list[@index].parameters)
       # If next event command is input number
       elsif @list[@index+1].code == 103
         # If number input window fits on screen
         if line_count < 4
           # Advance index
           @index += 1
           # Number input setup
           $game_temp.num_input_start = line_count
           $game_temp.num_input_variable_id = @list[@index].parameters[0]
           $game_temp.num_input_digits_max = @list[@index].parameters[1]
         end
       end
       # Continue
       return true
     end
     # Advance index
     @index += 1
   end
 end
end

#========================================================================
#   Spriteset Map
#
#       Edit allows access to the character_sprites variable
#       Use $game_map.character_sprites to access
#========================================================================

class Spriteset_Map

 attr_accessor :character_sprites  
 
end

class Scene_Map
 
 attr_accessor :spriteset
 attr_accessor :message_window
 
end

#========================================================================
#   Window Base
#
#       Edit allows for color 8 (black)
#========================================================================

class Window_Base < Window
 
 #--------------------------------------------------------------------------
 # * Get Text Color
 #     n : text color number (0-7)
 #--------------------------------------------------------------------------
 def text_color(n)
   case n
   when 0
     return Color.new(250, 250, 250, 255)
   when 1
     return Color.new(45, 45, 255, 255)
   when 2
     return Color.new(255, 45, 45, 255)
   when 3
     return Color.new(45, 255, 45, 255)
   when 4
     return Color.new(45, 215, 215, 255)
   when 5
     return Color.new(255, 45, 255, 255)
   when 6
     return Color.new(230, 230, 15, 255)
   when 7
     return Color.new(125, 125, 125, 255)
   when 8
     return Color.new(0, 0, 0)
   else
     normal_color
   end
 end
 
end

#==============================================================================
# ** Window_Gold
#------------------------------------------------------------------------------
#  The gold window has been modified to use an icon and some outlined text
#==============================================================================

class Window_Gold_New < Window_Base
 def initialize
   @current_gold = $game_party.gold
   
   @icon = Sprite.new
   @icon.opacity = 0
   @icon.bitmap = Bitmap.new('Graphics/Icons/032-Item01')
   @icon.ox = @icon.bitmap.width/2
   @icon.oy = @icon.bitmap.height/2
   @icon.x,@icon.y = 624,460
   
   draw_gold
 end
 
 def update
   refresh
   @icon.opacity += 12 if @icon.opacity < 192
   @gold.opacity += 12 if @gold.opacity < 192
 end
 
 def refresh
   if @current_gold != $game_party.gold
     @current_gold = $game_party.gold
     @gold.bitmap.clear
     draw_gold
   end
 end
 
 def draw_gold
   @gold = Sprite.new
   @gold.opacity = 0
   @gold.bitmap = Bitmap.new(100,32)
   @gold.ox,@gold.oy = @gold.bitmap.width/2,@gold.bitmap.height/2
   @gold.x = 560
   @gold.y = 465
   @gold.z = 50
   @gold.bitmap.font.size = 18
   @gold.bitmap.font.bold = true
   @gold.bitmap.font.color = text_color(8)
   @gold.bitmap.draw_text(22,0,75,30,$game_party.gold.to_s,2)
   @gold.bitmap.draw_text(22,2,75,30,$game_party.gold.to_s,2)
   @gold.bitmap.draw_text(21,1,75,30,$game_party.gold.to_s,2)
   @gold.bitmap.draw_text(23,1,75,30,$game_party.gold.to_s,2)
   @gold.bitmap.font.color = text_color(6)
   @gold.bitmap.draw_text(22,1,75,30,@current_gold.to_s,2)
 end
 
 def fade_out
   @icon.opacity -= 48
   @gold.opacity -= 48
 end
 
 def dispose
   @icon.bitmap.dispose
   @icon.dispose
   @gold.bitmap.dispose
   @gold.dispose
 end
 
end

#==============================================================================
# ** Window_InputNumber
#------------------------------------------------------------------------------
#  This window is for inputting numbers, and is used within the
#  message window.
#==============================================================================

class Window_InputNumber < Window_Base
 
 attr_accessor :x
 attr_accessor :y
 
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     digits_max : digit count
 #--------------------------------------------------------------------------
 def initialize(digits_max,x=0,y=0,indent=0)
   @digits_max = digits_max
   @number = 0
   @x = x
   @y = y
   @indent = indent
   @count = 0
   @move_right = true
   # Calculate character width for drawing and tracking cursor movement
   dummy_bitmap = Bitmap.new(32, 32)
   dummy_bitmap.font.size = $game_system.message_text_size
   dummy_bitmap.font.name = $game_system.message_text_font
   @width = (dummy_bitmap.text_size('0').width\
       + dummy_bitmap.text_size(' ').width)
   @x = @x - (@width*@digits_max)
   dummy_bitmap.dispose
   @index = 0
   # Create number display bitmap
   @number_window = Sprite.new
   @number_window.x = @x
   @number_window.y = @y
   @number_window.z = 15
   @number_window.bitmap = Bitmap.new(@width*@digits_max, 40)
   @number_window.bitmap.font.color = TEXT_COLOR_BLACK
   @number_window.bitmap.font.size = $game_system.message_text_size
   @number_window.bitmap.font.name = $game_system.message_text_font
   # Create the cursor to track input position
   create_cursor
 end
 #--------------------------------------------------------------------------
 # * Get Number
 #--------------------------------------------------------------------------
 def number
   return @number
 end
 #--------------------------------------------------------------------------
 # * Set Number
 #     number : new number
 #--------------------------------------------------------------------------
 def number=(number)
   @number = [[number, 0].max, 10 ** @digits_max - 1].min
   refresh
 end
 #--------------------------------------------------------------------------
 # * Create Cursor
 #--------------------------------------------------------------------------
 def create_cursor
   @cursor = Sprite.new
   @cursor.bitmap = Bitmap.new(32,5)
   @cursor.x = @number_window.x
   @cursor.y = @number_window.y\
             + @number_window.bitmap.text_size('0').height + 3
   @cursor.z = 16
   @cursor.opacity = 185
   width = @number_window.bitmap.text_size('0').width + 2
   @cursor.bitmap.fill_rect(0,0,width,2,text_color(1))
 end
 #--------------------------------------------------------------------------
 # * Cursor Update
 #--------------------------------------------------------------------------
 def update_cursor
   @count += 1
   if @count % 10 == 0
     if @move_right == true
       @cursor.x += 1
     else
       @cursor.x -= 1
     end
     if @count == 20
       if @move_right == true
         @move_right = false
       else
         @move_right = true
       end
       @count = 0
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   update_position
   # If up or down directional button was pressed
   if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
     $game_system.se_play($data_system.cursor_se)
     # Get current place number and change it to 0
     place = 10 ** (@digits_max - 1 - @index)
     n = @number / place % 10
     @number -= n * place
     # If up add 1, if down substract 1
     n = (n + 1) % 10 if Input.repeat?(Input::UP)
     n = (n + 9) % 10 if Input.repeat?(Input::DOWN)
     # Reset current place number
     @number += n * place
     refresh
   end
   # Cursor right
   if Input.repeat?(Input::RIGHT)
     if @digits_max >= 2
       $game_system.se_play($data_system.cursor_se)
       @index = (@index + 1) % @digits_max
       @cursor.x += @width
       if @index == 0
         @cursor.x = @number_window.x
       end
     end
   end
   # Cursor left
   if Input.repeat?(Input::LEFT)
     if @digits_max >= 2
       $game_system.se_play($data_system.cursor_se)
       @index = (@index + @digits_max - 1) % @digits_max
       @cursor.x -= @width
       if @index == @digits_max - 1
         @cursor.x += @width * @digits_max
       end
     end
   end
   update_cursor
 end

 #--------------------------------------------------------------------------
 # * Dispose
 #--------------------------------------------------------------------------

 def dispose
   @number_window.bitmap.clear
   @number_window = nil
   @cursor.bitmap.clear
   @cursor = nil
 end
 
 #--------------------------------------------------------------------------
 # * Update Position for Bubble Movement
 #--------------------------------------------------------------------------
 
 def update_position
   if @number_window.x != @x
     @number_window.x = @x
     @cursor.x = @number_window.x + (@index * @width)
   end
   if @number_window.y != @y
     @number_window.y = @y
     @cursor.y = @number_window.y\
               + @number_window.bitmap.text_size('0').height + 3
   end    
 end
 
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   @number_window.bitmap.clear
   s = sprintf("%0*d", @digits_max, @number)
   for i in 0...@digits_max
     @number_window.bitmap.draw_text(i * @width, 0, 32, 32, s[i,1])
   end
 end
end

#========================================================================
#   Window Message
#
#       Controls message displayed from the show text event command
#
#       This modified version also allows for a message to be displayed
#         from a script.  Simply change $game_temp.message_text to
#         whatever text you want to display.  Remember that outside
#         of the message entry box in the event commands, you will have
#         to manuall insert the newline character "\n".)
#========================================================================

class Window_Message < Window_Base
 
 attr_accessor :contents_showing
 attr_accessor :finished
 attr_accessor :fade_in
 attr_accessor :fade_out
 attr_accessor :message
 attr_accessor :enter_pressed
 
 #--------------------------------------------------------------------------
 # * Object Initialization
 #
 #       Prepare message variables, then wait for re_initialize
 #--------------------------------------------------------------------------
 def initialize(sub=false, text=nil)
   # Bubble message variables
   @enter_pressed = false
   @text_height = 0
   @fade_in = false
   @event = 0
   @contents_showing = false
   @finished = nil
   @position = ''
   @active = false
   @lines = 0
   @up = 0
   @count = 0
   @cursor_count = 0
   @cursor_move_right = nil
   @wait = 0
   @wait_add = 0
   @pause = false
   @index = 0
   @sub = sub
   @face = nil
   @face_extension_x = 0
   @face_extension_y = 0
   @thought = false
   @bubble_color = nil
   @hp = nil
   if @sub == false
     @sub_number = nil
     @sub_windows = []
   end
   @indent = false
   @text = text
 end
 #--------------------------------------------------------------------------
 # * Re_Initialize
 #
 #       Call when actual text processing occurs
 #--------------------------------------------------------------------------
   def re_initialize
     
     if $game_temp.message_text != nil
       # Prevent improper cursor indention on choices
       @indent = false
       if $game_system.face_graphic_name != nil
         @face = $game_system.face_graphic_name
       else
         @face = nil
       end
       @face_extension_x = 0
       @face_extension_y = 0
       
       temp = Sprite.new
       temp = Bitmap.new(32,32)
       # Set @text to whatever text will display
       # For sub messages this will already be set
       if @text == nil
         @text = $game_temp.message_text
       end
       
       # Change \ escaped characters to character codes for processing
       prep_text
       
       # Determine number of lines in the message
       @lines = 0
       @text.each_line {|line|
         @lines += 1
       }
       
       temp_text = @text.clone
       # Get rid of any non displayed elements to determine the
       #   appropriate message box size
       
       def get_digits(integer)
         if integer < 10
           return 1
         elsif integer >= 10
           return 2
         elsif integer >= 100
           return 3
         end
       end
       
       while temp_text.slice(/\001\[([0-9]+)\]/)
         temp_text.slice!(/\001\[([0-9]+)\]/)
       end
       
       while temp_text.slice(/\002/)
         temp_text.slice!(/\002/)
       end
       
       while temp_text.slice(/\004\[([0-9]+)\]/)
         temp_text.slice!(/\004\[([0-9]+)\]/)
       end
       
       while temp_text.slice(/\005\[([0-9]+)\]/) != nil
         temp_text.slice!(/\005\[([0-9]+)\]/)
       end
       
       while temp_text.slice(/\006/)
         temp_text.slice!(/\006/)
       end
       
       while temp_text.slice(/\007\[([0-9]+)\]/)
         temp_text.slice!(/\007\[([0-9]+)\]/)
       end
       
       while temp_text.slice(/\011/) != nil
         temp_text.slice!(/\011/)
       end
               
       while temp_text.slice(/\015\[([0-9]+)\]/)
         temp_text.slice!(/\015\[([0-9]+)\]/)
         @face = Faces[$1.to_i]
       end
       
       # Make sure @thought is false unless specified true
       @thought = false
       while temp_text.slice(/\017/)
         temp_text.slice!(/\017/)
         @thought = true
         @text.slice!(/\017/)
       end
       
       # Change @bubble_color to keep default color unless specified other color
       @bubble_color = nil
       while temp_text.slice(/\018\[([0-9]+)\]/)
         temp_text.slice!(/\018\[([0-9]+)\]/)
         @bubble_color = mood_color($1.to_i)
         @text.slice!(/\018\[([0-9]+)\]/)
       end
       
       # Determine message bubble size
       bitmap = Sprite.new
       bitmap.bitmap = Bitmap.new(32,32)
       bitmap.bitmap.font.name = $game_system.message_text_font
       bitmap.bitmap.font.size = $game_system.message_text_size
       @text_rect = Rect.new(0,0,0,0)
       @line_width = []
       i = 0
       temp_text.each_line {|line|
         temp = bitmap.bitmap.text_size(line)
         @line_width[i] = temp.width
         if temp.width > @text_rect.width
           @text_rect.width = temp.width
         end
         @text_height = temp.height
         i += 1
       }
       
       # Add space for number input if necessary
       if $game_temp.num_input_variable_id > 0 && @sub == false
         @lines += 1
       end

       @text_rect.height = @text_height * @lines
       
       total_size = 0
       longest_line = 0
       current_line_height = @text_height
       @line_height_correction = [0,0,0,0]
       line = 0
       skip = 0
       
       for i in 0...temp_text.size
         # Check for bold toggling and icon insertion
         if temp_text[i] == 3
           bitmap.bitmap.font.bold == false ? bitmap.bitmap.font.bold = true : bitmap.bitmap.font.bold = false
         end
         # Check for icon insertion and add 24 pixels to this line's width
         if temp_text[i] == 12
           # Add sufficient width for an icon to be inserted in the text
           total_size += 24
           # Adjust the height of the text box if necessary
           if current_line_height < 24
             current_line_height = 24
             @text_rect.height += (24 - @text_height)
             @line_height_correction[line] = (24 - @text_height)
           end
           # Set variable to skip over icon text in sizing operations
           skip = 4
         end
         # Check for face graphic
         if temp_text[i] == 13
           temp_text.slice(/\015\[([0-9]+)\]/)
           skip = 4
           @face = Faces[$1.to_i]
         end
         # Check for new line character
         if temp_text[i] == 10
           total_size = 0
           current_line_height = @text_height
           line += 1
         end
         # Do not size characters relating to an icon
         if skip == 0
           total_size += bitmap.bitmap.text_size(temp_text.slice(i,1)).width
         else
           skip -= 1
         end
         # Make sure longest line sets the bubble width value
         longest_line = total_size if total_size > longest_line
       end
       
       # Insert facce graphic name if none explicit in message and
       # one is stored in $game_system
       if $game_system.face_graphic_name != nil && temp_text.slice(/\015\[([0-9]+)\]/) == nil
         @face = $game_system.face_graphic_name
       end
       # Account for face graphic in message box graphic
       if @face != nil
         determine_face_extension
       else
         @face_extension_x = 0
         @face_extension_y = 0
       end
       
       if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
         @text_rect.width = longest_line
       else
         @text_rect.width = longest_line + @face_extension_x
       end

       # Set start values for text drawing
       @x=@y=0
       # Determine message position and create the message bubble
       #(only if $game_system.message_text_mode == TEXT_MODE_BUBBLE        
       if $game_system.message_text_mode != TEXT_MODE_INVISIBLE
         # Check for existence of necessary Bubble files if mode is set to Bubble
         if $game_system.message_text_mode == TEXT_MODE_BUBBLE
           # Correct text mode if files do not exist
           if File.exist?("Graphics/Pictures/Message_Bubble.png") == false || \
             File.exist?("Graphics/Pictures/Pointer2.png") == false
             $game_system.message_text_mode = TEXT_MODE_WINDOWSKIN
             default_color(8)
           end
         end            
         determine_position
         create_bubble
       else
         @bubble_correction_y = 0
         @message_box = Sprite.new
         @message_box.bitmap = Bitmap.new(@text_rect.width+25, @text_rect.height+26)
         @message_box.ox = @message_box.bitmap.width/2
         @message_box.oy = @message_box.bitmap.height/2
         @message_box.x = $game_system.invisible_position[0]
         @message_box.y = $game_system.invisible_position[1]
         if @message_box.y - @message_box.bitmap.height/2 < 0
           @message_box.y += @message_box.bitmap.height/2
         elsif @message_box.y + @message_box.bitmap.height/2 > 480
           @message_box.y -= @message_box.bitmap.height/2
         end
       end
       # Create message sprite for drawing actual text
       @message = Sprite.new
       @message.x = @message_box.x
       @message.y = @message_box.y
       if @sub == false
         @message.z += 1
       end
       @message.ox = @message_box.ox
       @message.oy = @message_box.oy
       @message.bitmap = \
         Bitmap.new(@message_box.bitmap.width,@message_box.bitmap.height)
       @message.bitmap.font.size = $game_system.message_text_size
       @message.bitmap.font.color = TEXT_COLOR_BLACK
       @speed = $game_system.message_text_speed
       @text_color = $game_system.default_color
     end
   end
 #--------------------------------------------------------------------------
 # * Dispose
 #--------------------------------------------------------------------------
 def dispose
   terminate_message
   $game_temp.message_window_showing = false
   if @input_number_window != nil
     @input_number_window.dispose
   end
 end
 
 #--------------------------------------------------------------------------
 # * Subs Finished?
 #
 #       Checks to see if all sub messages have finished writing
 #--------------------------------------------------------------------------
 def subs_finished?
   abort_flag = true
   count = 0
   for sub in @sub_windows
     count += 1 if (sub.finished == true && sub.enter_pressed == false)
     if sub.finished && sub.enter_pressed
       sub.enter_pressed = false
     end
   end
   abort_flag = false if count == @sub_windows.size
   if abort_flag == true
     return false
   else
     return true
   end
 end
 
 #--------------------------------------------------------------------------
 # * Erase Subs
 #
 #       Erases any existing subb messages
 #--------------------------------------------------------------------------
 def erase_subs
   if @sub_windows != nil
     for sub in @sub_windows
       sub.fade_out = true
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Terminate Message
 #--------------------------------------------------------------------------
 def terminate_message
   # Call message callback
   if @message != nil
     @message_box.bitmap.clear
     @message.z -= 1
     @message.bitmap.clear
   end
   if @cursor != nil
     @cursor.bitmap.clear
     @cursor.dispose
     @cursor = nil
   end
   if $game_temp.message_proc != nil
     $game_temp.message_proc.call
   end
   # Clear variables related to text, choices, and number input
   $game_temp.message_text = nil
   $game_temp.message_proc = nil
   $game_temp.choice_start = 99
   $game_temp.choice_max = 0
   $game_temp.choice_cancel_type = 0
   $game_temp.choice_proc = nil
   $game_temp.num_input_start = 99
   $game_temp.num_input_variable_id = 0
   $game_temp.num_input_digits_max = 0
   # Dispose of gold window
   if @gold_window != nil && $game_temp.consecutive_gold_window == false
     @gold_window.dispose
     @gold_window = nil
   end
   @contents_showing = false
   @finished = nil
   @active = false
   $game_temp.message_window_showing = false
   @text = nil
   if @sub == false
     erase_subs
     temp = subs_finished?
     if temp == true
       for i in 0...@sub_windows.size
         @sub_windows[i] = nil
       end
       @sub_windows = []
     end
   end
   @sub_number = nil
 end
 #--------------------------------------------------------------------------
 # * Draw_Message
 #--------------------------------------------------------------------------
 def draw_message
   
   if @pause == true
     return
   end
   
   if @text == nil
     return
   end
   
   # Indent if choice and following message text
   index = $game_system.map_interpreter.index - 2
   code = $game_system.map_interpreter.list[index].code

   # Check for choice following a line of text
   if @y == $game_temp.choice_start && (code == 101 || code == 401) \
     && @indent == false && $separate_choices == false
     @indent = true
     #@x = 16 + @face_extension_x
   end
   
   if @wait == 0

     # Set correction for icon insertion
     y_correction = 0
     for i in 0..@y
       if @line_height_correction[i] != nil
         y_correction += @line_height_correction[i]
       end
     end
     # Set offset value dependant on text mode
     if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
       offset = 10
     elsif $game_system.message_text_mode == TEXT_MODE_BUBBLE
       offset = 13
     else
       offset = 0
     end

     y = @text_y + (@text_height * @y) + @bubble_correction_y + y_correction
     
     # Insert face graphic if included
     if @text.slice!(/\015\[([0-9]+)\]/) || @face != nil
       draw_face
     end
     
     # Check for formatting options character from text
     @c = @text[0,1].slice(/./m)
     case @c
     # If \\
     when "\000"
       # Return to original text
       @c = "\\"
       @text.sub!("\000") {"\\"}
       return
     # If \C[n]
     when "\001"
       # Change text color
       @text.sub!(/\[([0-9]+)\]/, "")
       color = $1.to_i
       if color >= 0 and color <= 8
         @message.bitmap.font.color = text_color(color)
         @text_color = text_color(color)
       end
       @text.slice!("\001")
       # go to next text
       return
     # If \G
     when "\002"
       # Make gold window
       if @gold_window == nil
         @gold_window = Window_Gold_New.new
         #@gold_window.x = 560 - @gold_window.width
         if $game_temp.in_battle
         #  @gold_window.y = 192
         else
         #  @gold_window.y = 0
         end
         #@gold_window.opacity = @message.opacity
         #@gold_window.back_opacity = 200
       end
       @text.slice!("\002")
       # go to next text
       return
     # If \B
     when "\003"
       if @message.bitmap.font.bold == false
         @message.bitmap.font.bold = true
       else
         @message.bitmap.font.bold = false
       end
       @text.slice!("\003")
       return
     # If sub window is being called
     when "\004"
       @text.slice!("\004")
       @text.sub!(/\[([0-9]+)\]/, "")
       if @sub == false
         @sub_number = $1
         event_key = $game_temp.current_event
         # Find the cooresponding slave window
         # Must immediately follow master window and be
         # in consecutive order
         num = 0
         index = 0
         if $game_system.map_interpreter.list[$game_system.map_interpreter.index].code == 101 \
           && num != @sub_number.to_i
           for i in $game_system.map_interpreter.index\
             ...$game_system.map_interpreter.list.size
             if $game_system.map_interpreter.list[i].code == 101
               num = $game_system.map_interpreter.list[i].parameters[0].slice(/\\[Ss]\[([0-9]+)\]/)
               num = num.slice(/([0-9]+)/).to_i if num!= nil
               if num != nil
                 if num != @sub_number.to_i
                   num += 1
                 end
                 index = i
               end
               if num == @sub_number.to_i
                 break
               end
             end
           end
         else
           index = $game_system.map_interpreter.index
         end
         $game_system.map_interpreter.index = index
         # Save original index value for later
         original_index = $game_system.map_interpreter.index
         lines = 1
         if $game_system.map_interpreter.list[index].code == 101
           # Loop until the cooresponding \s[x] character is found
           loop do
             # Break if there is nothing more to sort through
             if $game_system.map_interpreter.list[index] == nil
               break
             end
             # Check the \s[x] for a match with the initial match in master message
             temp = $game_system.map_interpreter.list[index].parameters.clone
             number = temp[0].slice(/\\[Ss]\[([0-9]+)\]/)
             if number != nil
               number = number.slice(/[0-9]+/)
             end
             # If the proper match is found, create sub window
             if number == @sub_number
               # Create message text for sub message
               # Make sure sub message begins at first line
               while $game_system.map_interpreter.list[index].code != 101
                 index -= 1
               end
               text = $game_system.map_interpreter.list[index].parameters[0].clone
               if $game_system.map_interpreter.list[index+1].code == 401
                 text = text + "\n"
                 lines += 1
               end
               # Continue to add text if there is something to be added
               if $game_system.map_interpreter.list[index+1].code == 401
                 # Loop until all sub message text is added
                 loop do
                   index += 1
                   text = text + $game_system.map_interpreter.list[index].parameters[0].clone
                   if $game_system.map_interpreter.list[index+1].code == 401
                     text = text + "\n"
                     lines += 1
                   else
                     break
                   end
                 end
               end
               # If last sub window, set event index
               if @text.slice("\004") == nil
                 $game_system.map_interpreter.index = index + 1
               end
               # Create actual sub window object and place it into
               # @sub_windows array for update and disposal
               sub = Window_Message.new(true,text)
               @sub_windows.push sub
               break
             else
               index += 1
             end
           end # end loop
         return
         end # end if code == 101
       end
     # When \w[x]
     when "\005"
       @text.slice!(/\005\[([0-9]+)\]/)
       @wait_add = $1.to_i
       @wait += @wait_add
       @wait_add = 0
       return
     # When \p
     when "\006"
       @text.slice!("\006")
       if @enter_pressed == false
         @pause = true
       end
       return
     # When \q
     when "\011"
       terminate_message
       return
     # When \i[x]
     when "\014"  
       @text.slice!(/\014\[([0-9]+)\]/)
       icon = Sprite.new
       icon.opacity = 0
       icon.bitmap = Bitmap.new("Graphics/Icons/#{Icons[$1.to_i]}")
       true_y = @text_y + (@y * @text_height) + y_correction #+ y + @face_extension_y - (@text_rect.height + 25)
       @message.bitmap.blt(offset+@x+@face_extension_x,true_y,icon.bitmap,Rect.new(0,0,24,24))
       @x += 24
     # When \h[x]
     when "\016"
       @text.slice!(/\016\[([0-9]+)\]/)
       @hp = $game_party.actors[$1.to_i].hp
     end
     
     # Get 1 character from text
     @c = @text.slice!(/./m)

     if @c == nil
       @finished = true
       if $game_temp.choice_max > 0
         @cursor_move_right = true
         @index = 0
         create_cursor
         $separate_choices = false
       elsif $game_temp.num_input_variable_id > 0 && @sub == false
         digits_max = $game_temp.num_input_digits_max
         number = $game_variables[$game_temp.num_input_variable_id]
         x = @message.x + @message.bitmap.width/2 - 13
         y = @message.y - @message.bitmap.height/2\
             + @text_height * (@y) + @bubble_correction_y
         @input_number_window = Window_InputNumber.new(digits_max,x,y,@face_extension_x)
         @input_number_window.number = number
       end
       return
     end
     # If new line text
     if @c == "\n"
       # Add 1 to y
       @y += 1
       @x = 0
       # Indent if choice
       if @y >= $game_temp.choice_start
         @x = 0
       end
       # go to next text
       return
     end
     # Draw text    
     @message.bitmap.font.name = $game_system.message_text_font
     # Set exact y value for drawing
     if @face_extension_y != 0
       true_y = y + @face_extension_y - (@text_rect.height + 25)
     else
       true_y = y
     end
     
     true_y = @text_y + @y*@text_height + y_correction
     
     if $game_system.message_text_outline == TEXT_OUTLINE
       if $game_system.message_text_outline == TEXT_OUTLINE
         @message.bitmap.font.color = $game_system.message_text_outline_color
       elsif @message.bitmap.font.color != $game_system.default_color
         @message.bitmap.font.color = $game_system.default_color
       end
       # Correct character writing position for lower case "f"
       # due to Monotype Corsiva text writing glitch
       temp = @x
       if  @c == 'f' && $game_system.message_text_font == TEXT_FONT_CORSIVA
         @x -= 2
       end
       @message.bitmap.draw_text(offset+@x+@face_extension_x+1,true_y,40,32,@c)
       @message.bitmap.draw_text(offset+@x+@face_extension_x-1,true_y,40,32,@c)
       @message.bitmap.draw_text(offset+@x+@face_extension_x,true_y+1,40,32,@c)
       @message.bitmap.draw_text(offset+@x+@face_extension_x,true_y-1,40,32,@c)
       
       # Correct any change made to @x so that text is written
       # in the proper place
       if  @x != temp
         @x = temp
       end
       
     end
     
     @message.bitmap.font.color = @text_color
     
     # Correct character writing position for lower case "f"
     # due to Monotype Corsiva text writing glitch
     temp = @x
     if @c == 'f' && $game_system.message_text_font == TEXT_FONT_CORSIVA
       @x -= 2
     end
     @message.bitmap.draw_text(offset+@x+@face_extension_x,true_y,40,32,@c)
     # Correct any change made to @x so that text is written
     # in the proper place
     if @x != temp && $game_system.message_text_font == TEXT_FONT_CORSIVA
       @x = temp
     end
     # Add x to drawn text width
     @x += @message.bitmap.text_size(@c).width
     @wait = $game_system.message_text_speed
     @wait_add = 0
   else
     @wait -= 1
   end
 end
 
 #--------------------------------------------------------------------------
 # * Determine Face Extension
 #     This method determines how much distance needs to be added to the
 #     face graphic
 #--------------------------------------------------------------------------
 def determine_face_extension
   sprite = Sprite.new
   sprite.opacity = 0
   sprite.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
   # Set extension value in horizontal direction
   if @face != nil
     @face_extension_x = sprite.bitmap.width
     if $game_system.face_graphic_type == FACE_GRAPHIC_BOX
       @face_extension_x += 5
     end
     if sprite.bitmap.height > @text_rect.height
       @face_extension_y = sprite.bitmap.height - @text_rect.height
     end
   end
   sprite.bitmap.dispose
   sprite = nil
 end
 
 #--------------------------------------------------------------------------
 # * Draw Face Graphics
 #--------------------------------------------------------------------------
 def draw_face
   sprite = Sprite.new
   sprite.opacity = 0
   sprite.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
   rect = Rect.new(0,0,sprite.bitmap.width,sprite.bitmap.height)
   if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
     @message.bitmap.blt(0,0,sprite.bitmap,rect)
   else
     y = @text_y + 10
     @message.bitmap.blt(13,y,sprite.bitmap,rect)
   end
   sprite.bitmap.dispose
   sprite = nil
 end
 
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   if @pause == false
     if Input.trigger?(Input::C) && $game_system.message_skip_disabled == false
       @enter_pressed = true
       until @c == nil || @text == nil
         draw_message
       end
       @enter_pressed = false if @sub == false
     else
       if $game_system.message_text_skip != TEXT_SKIP_FULL
         count = $game_system.message_text_skip
         for i in 0...count
           draw_message if (@c != nil || @text != nil)
         end
       else
         if @c == nil && @text != nil
           draw_message
         end
         until @c == nil || @text == nil
           draw_message
         end
       end
     end
   else
     if Input.trigger?(Input::C)
       temp = subs_finished?
       if temp == true
         erase_subs
         @pause = false
       end
     end
     draw_message
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update sub messages if they exist
   if @sub_windows != nil
     for i in 0...@sub_windows.size
       @sub_windows[i].update
     end
   end
   # Update gold window if it exists
   if @gold_window != nil
     @gold_window.update
   end
   # Update bubble graphic
   if @active == true && ($game_system.message_text_mode == TEXT_MODE_BUBBLE \
     || $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN)
     update_bubble
   end
   # If fade in
   if @fade_in
     if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
       max_opacity = 192
     else
       max_opacity = 255
     end
     @message_box.opacity += 24
     if @input_number_window != nil
       @input_number_window.contents_opacity += 24
     end
     if @message_box.opacity == max_opacity
       @fade_in = false
     end
     return
   end
   
   # If fade out
   if @fade_out
     @message_box.opacity -= 48
     @message.opacity -= 48
     if @cursor != nil
       @cursor.opacity -= 48
     end
     if @input_number_window != nil
       @input_number_window.contents_opacity -= 24
     end
     if @gold_window != nil && $game_temp.consecutive_gold_window == false
       @gold_window.fade_out
     end
     if @message_box.opacity == 0 && @message.opacity == 0
       @fade_out = false
       terminate_message if @sub == false
     end
     return
   end
   
   # If inputting number
   if @input_number_window != nil
     @input_number_window.update
     # Confirm
     if Input.trigger?(Input::C)
       $game_system.se_play($data_system.decision_se)
       $game_variables[$game_temp.num_input_variable_id] =
         @input_number_window.number
       $game_map.need_refresh = true
       # Dispose of number input window
       @input_number_window.dispose
       @input_number_window = nil
       
       if @sub_windows != nil
         temp = subs_finished?
         if temp == true
           @fade_out = true
           erase_subs
         end
       end
     end
     return
   end
   # If message is being displayed
   if @contents_showing && @finished == true
     # If choice isn't being displayed, show pause sign
     if $game_temp.choice_max == 0
       @active = true
     else
       update_cursor
     end
     # Cancel
     if Input.trigger?(Input::B)
       if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
         $game_system.se_play($data_system.cancel_se)
         $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
         terminate_message
       end
     end
     # Confirm
     if Input.trigger?(Input::C)
       if $game_temp.choice_max > 0
         $game_system.se_play($data_system.decision_se)
         $game_temp.choice_proc.call(@index)
       end
       if @sub_windows != nil
         temp = subs_finished?
         if temp == true
           @fade_out = true
           erase_subs
         end
       end
     end
     return
   end
   # If display wait message or choice exists when not fading out
   if $game_temp.message_text != nil && @finished == nil
     @contents_showing = true
     $game_temp.message_window_showing = true
     @finished = false
     re_initialize
     Graphics.frame_reset
     if @input_number_window != nil
       @input_number_window.contents_opacity = 0
     end
     @fade_in = true
     return
   elsif @finished == false
     refresh
     return
   end
 end
 #--------------------------------------------------------------------------
 # Create Message Bubble
 #--------------------------------------------------------------------------
 # Remember! The bubble will currently display based on the src_rect of
 # the $character_sprite bitmap...need to work on this...
 
 def create_bubble # Text can be multiple lines
   sprites = $scene.spriteset.character_sprites
   @event_x = sprites[@event].x
   @event_y = sprites[@event].y
   # Draw bubble bitmap to blt from
   bubble = Sprite.new
   if @position.include?('Flipped_Down')
     @bubble_correction_y = 7
   else
     @bubble_correction_y = 0
   end
   # Set basic x and y values for bubble drawing
   # If a face graphic will be drawn
   if @face != nil
     # If face graphic drawn outside bubble
     if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
       base_y = (@face_extension_y + @text_rect.height) - (@text_rect.height + 20)
       # If bubble is flipped horizontally
       if @position.include?('Mirror')
         base_x = 0
       else
         base_x = @face_extension_x
       end
       # If bubble is not flipped vertically
       if not @position.include?('Flipped_Down')
         base_y -= 6
       end
       base_height = @text_rect.height
       height_extension = @face_extension_y
       if $game_system.message_text_mode == TEXT_MODE_BUBBLE
         width_extension = @face_extension_x + 25
       elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
         width_extension = @face_extension_x + 20
       end
     # If face graphic drawn inside bubble
     else
       base_x = 0
       base_y = @bubble_correction_y
       base_height = @face_extension_y + @text_rect.height
       if $game_system.message_text_mode == TEXT_MODE_BUBBLE
         width_extension = 25
         height_extension = 20 + 6
       elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
         width_extension = 20
         height_extension = 20
       end
     end
   else
     base_x = 0
     base_y = @bubble_correction_y
     base_height = @text_rect.height
     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
       height_extension = 20 + 7
       width_extension = 25
     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
       height_extension = 20
       width_extension = 20
     end
   end
   base_width = @text_rect.width
   
   # Set text drawing starting coordinates
   @text_y = base_y
   
   if $game_system.message_text_mode == TEXT_MODE_BUBBLE
     bubble.bitmap = Bitmap.new("Graphics/Pictures/Message_Bubble")
   elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
     bubble.bitmap = Bitmap.new("Graphics/Windowskins/"+$data_system.windowskin_name)
   end
   
   # Make the bubble bitmap the appropriate size
   @message_box = Sprite.new
       
   true_width = base_width + width_extension
   true_height = base_height + height_extension
   @message_box.bitmap = Bitmap.new(true_width,true_height)
   @message_box.ox = @message_box.bitmap.width/2
   @message_box.oy = @message_box.bitmap.height/2
   @message_box.x = sprites[@event].x\
     + @message_box.bitmap.width/2\
     + sprites[@event].src_rect.width/2 - 15
   if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
     @message_box.x -= @face_extension_x
   end
   @message_box.y = sprites[@event].y\
     - ((sprites[@event].src_rect.height/3)*2)\
     - @message_box.oy
   if $game_system.face_graphic_type == FACE_GRAPHIC_FULL \
     && @position.include?('Flipped_Down')
     @message_box.y -= @face_extension_y
   end
   if @sub == false
     @message_box.z += 1
   end
   
   # Set rectangles for graphic block transfers
   if $game_system.message_text_mode == TEXT_MODE_BUBBLE
     upper_left = BUBBLE_UPPER_LEFT
     lower_left = BUBBLE_LOWER_LEFT
     upper_right = BUBBLE_UPPER_RIGHT
     lower_right = BUBBLE_LOWER_RIGHT
     
   elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
     background = Rect.new(base_x+1,base_y+1,base_width+20-2,base_height+20-2)
     source_rect = Rect.new(0,0,128,128)
     @message_box.bitmap.stretch_blt(background,bubble.bitmap,source_rect)
     upper_left = SKIN_UPPER_LEFT
     lower_left = SKIN_LOWER_LEFT
     upper_right = SKIN_UPPER_RIGHT
     lower_right = SKIN_LOWER_RIGHT
   end
   
   # Blt the upper left quadrant of the bubble
   rect = Rect.new(0,0,13,10)    
   @message_box.bitmap.blt(base_x,base_y,bubble.bitmap,upper_left)
   
   # Blt the lower left quadrant of the bubble
   rect.set(0,10,13,9)
   y = base_y + base_height + lower_left.height
   @message_box.bitmap.blt(base_x,y,bubble.bitmap,lower_left)
   
   # Blt the upper right quadrant of the bubble
   rect.set(13,0,12,10)
   x = base_x + base_width + upper_right.width
   @message_box.bitmap.blt(x,base_y,bubble.bitmap,upper_right)
   
   # Blt the lower right quadrant of the bubble
   rect.set(13,10,12,9)
   x = base_x + base_width + lower_right.width
   y = base_y + base_height + upper_right.height
   @message_box.bitmap.blt(x,y,bubble.bitmap,lower_right)
   
   if $game_system.message_text_mode == TEXT_MODE_BUBBLE
     # Fill in the left side gap
     rect.set(0,8,13,1)    
     x = base_x
     y = base_y + upper_left.height
     rect2 = Rect.new(x,y,13,base_height)
     @message_box.bitmap.stretch_blt(rect2,bubble.bitmap,rect)
       
     # Fill in the right side gap
     rect.set(13,8,12,1)
     x = base_x + base_width + upper_right.width
     y = base_y + upper_right.height
     rect2 = Rect.new(x,y,13,base_height)
     @message_box.bitmap.stretch_blt(rect2,bubble.bitmap,rect)
     
     # Fill in the middle gap    
     x = base_x + upper_left.width - 1
     y = base_y
     width = base_width
     height = base_height + upper_left.height + lower_left.height
     rect.set(x,y,1,height)
     rect2.set(x,y,base_width,height)
     @message_box.bitmap.stretch_blt(rect2,@message_box.bitmap,rect)
   
     # Place character pointer either below or above bubble
     if @position.include?('Flipped_Down')
       if @thought == false
         rect.set(15,19,10,8)
       else
         rect.set(25,8,10,8)
       end
       x = base_x + 9
       y = base_y - @bubble_correction_y
       @message_box.bitmap.blt(x,y,bubble.bitmap,rect)
       @message_box.y = sprites[@event].y\
         - ((sprites[@event].src_rect.height/3)*2)\
         + @message_box.oy - @face_extension_y#- (offset_y-@text_rect.height-20)
     else
       if @thought == false
         rect.set(0,19,10,8)
       else
         rect.set(25,0,10,8)
       end
       x = base_x + 9
       y = base_y + base_height + 17
       @message_box.bitmap.blt(x,y,bubble.bitmap,rect)
     end
     if @position.include?('Mirror')
       @message_box.mirror = true
       @message_box.x = sprites[@event].x\
         - sprites[@event].src_rect.width/2\
         - @message_box.bitmap.width/2 + 15 + base_x #+offset_x
     end
   # Fill in rim of a windowskin box
   elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
     
     # Top rim
     dest_rect = Rect.new(base_x+10,base_y,base_width,10)
     source_rect = Rect.new(148,0,24,10)
     @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
     
     # Bottom rim
     dest_rect = Rect.new(base_x+10,base_y+base_height+20-10,base_width,10)
     source_rect = Rect.new(148,54,24,10)
     @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
     
     # Left rim
     dest_rect = Rect.new(base_x,base_y+10,10,base_height)
     source_rect = Rect.new(128,10,10,44)
     @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
     
     # Right rim
     dest_rect = Rect.new(base_x+base_width+20-10,base_y+10,10,base_height)
     source_rect = Rect.new(182,10,10,44)
     @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
     
   end
   # Prepare bubble for up/down animation
   @up = true
   @message_box.opacity = 0
   @fade_in = true
   # Dispose of the blted bubble
   bubble.bitmap.dispose
   bubble = nil
   @contents_showing = true
   @active = true
   
   if @bubble_color.class == Color
     @message_box.color = @bubble_color
   end

 end
 #--------------------------------------------------------------------------
 # * Determine Bubble Position
 #--------------------------------------------------------------------------
 def determine_position(no_text=false)
   
   sprites = $scene.spriteset.character_sprites
   
   @position = ''
   # Check upper screen boundary
   temp = @text_rect.height + 25 + sprites[@event].src_rect.height
   if sprites[@event].y - temp < 0
     @position += 'Flipped_Down'
   end
   temp = @text_rect.width + 45
   if sprites[@event].x\
     + sprites[@event].src_rect.width/2 + temp > 640
     @position += 'Mirror'
   end
   if no_text == false
     if @text.slice(/\007\[([0-9]+)\]/)
       #c = @text.slice(/[0-9]+/).to_i
       @text.slice!(/\007\[([0-9]+)\]/)
       c = $1.to_i
       @position = ''
       if c == 0
         @position = ''
       elsif c == 1
         @position = 'Flipped_Down'
       elsif c == 2
         @position = 'Mirror'
       elsif c == 3
         @position = 'Flipped_Down Mirror'
       end
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Bubble Graphic Update
 #--------------------------------------------------------------------------
 def update_bubble
   
   # Create an easier to use access point to the screen sprites
   sprites = $scene.spriteset.character_sprites
   
   # Bounce bubble
   if $game_system.message_text_mode == TEXT_MODE_BUBBLE \
       && $game_system.message_bubble_bounce == BUBBLE_BOUNCE_ON
     
     @count += 1
     
     if @count % 10 == 0 && @up == true
       @message_box.y -= 1
       if @input_number_window != nil
         @input_number_window.y -= 1
       end
       if @cursor != nil
         @cursor.y -= 1
       end
       if @count == 20
         @count = 0
         @up = false
       end
     elsif @count % 10 == 0 && @up == false
       @message_box.y += 1
       if @input_number_window != nil
         @input_number_window.y += 1
       end
       if @cursor != nil
         @cursor.y += 1
       end
       if @count == 20
         @count = 0
         @up = true
       end
     end
   end
       
   x = @event_x
   y = @event_y
   
   @event_x = sprites[@event].x
   @event_y = sprites[@event].y
   
   if @event_x != x || @event_y != y
           
     if @event_x != x
       @message_box.x = @message_box.x + (@event_x - x)
       if @input_number_window != nil
         @input_number_window.x = @input_number_window.x + (@event_x-x)
       end
       if @cursor != nil
         @cursor.x = @cursor.x + (@event_x - x)
       end
     end
     
     if @event_y - @face_extension_y != y
       @message_box.y = @message_box.y + (@event_y - y)
       if @input_number_window != nil
         @input_number_window.y = @input_number_window.y + (@event_y-y)
       end
       if @cursor != nil
         @cursor.y = @cursor.y + (@event_y - y)
       end
     end
         
     change = false
     # Check upper screen boundary
     temp = @message_box.y - @message_box.bitmap.height/2
     if temp < 0 && (@position.include?('Flipped_Down') == false)
       change = true
     end
     # Check lower screen boundary
     temp = @message_box.y + @message_box.bitmap.height/2
     if temp > 480
       change = true
     end
     # Check right screen boundary
     temp = @message_box.x + @message_box.bitmap.width/2
     if temp > 640
       change = true
     end
     # Check left screen boundary
     temp = @message_box.x - @message_box.bitmap.width/2
     if temp < 0
       change = true
     end
     
     if change == true
       @message_box.bitmap.clear
       determine_position(true)
       create_bubble
       if @cursor != nil
         reset_cursor
       end
       if @position.include?('Flipped_Down')
         get_text
       end
       @message_box.z -= 1
     end
     

   end
   
   @message.y = @message_box.y
   @message.x = @message_box.x      

 end
 
 #--------------------------------------------------------------------------
 # * Get Message Text
 #--------------------------------------------------------------------------

 def get_text
   
   index = $game_system.map_interpreter.index - 1
   until $game_system.map_interpreter.list[index].code == 101
     index -= 1
   end
   old_text = @text.clone
   @text = ""
   @lines.times do
     if $game_system.map_interpreter.list[index].code == 102 \
       || $game_system.map_interpreter.list[index].code == 402
       for i in 0...$game_system.map_interpreter.list[index].parameters.size
         if $game_system.map_interpreter.list[index].parameters[0][i].class == String
           @text = @text + $game_system.map_interpreter.list[index].parameters[0][i].clone + "\n"
         end
       end
     else        
       @text = @text + $game_system.map_interpreter.list[index].parameters[0].clone + "\n"
     end
     index += 1
   end
   
   prep_text
   @message.bitmap.clear
   @x = 0
   @x += 10 if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
   @y = 0
   begin
     draw_message
   end until @text == old_text
 end

 #--------------------------------------------------------------------------
 # * Prepare Text for processing
 #--------------------------------------------------------------------------
 
 def prep_text
   # Determine what event the message will be over
   if @text.slice!(/\\[Ee]\[([0-9]+)\]/) == nil
     @event = -1 # Default to over player
   else
     @event = $1.to_i - 1
   end
   # Control text processing
   begin
     @last_text = @text.clone
     @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
   end until @text == @last_text
   @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
     $game_actors[$1.to_i] != nil ? "#{$game_actors[$1.to_i].name}:"+"\n" : ""
   end
   # Change "\\\\" to "\000" for convenience
   @text.gsub!(/\\\\/) { "\000" }
   # Change "\\C" to "\001" and "\\G" to "\002"
   #   and "\\B" to "\003" and "\\S" to "\004"
   #   and "\\W" to "\005" and "\\p" to "\006"
   #   and "\\F" to "\007" and "\\q" to "\011"
   #   and "\\I" to "\014  and "\\z" to "\015"
   #   and "\\T" to "\017  and "\\m" to "\018"
 
   while @text.slice(/\\[Cc]\[([0-9]+)\]/) != nil
     @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
   end
   @text.gsub!(/\\[Gg]/) { "\002" }
   @text.gsub!(/\\[Bb]/) { "\003" }
   @text.gsub!(/\\[Ss]/) { "\004" }
   while @text.slice(/\\[Ww]\[([0-9]+)\]/) != nil
     @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\005[#{$1}]" }
   end        
   while @text.slice(/\\[Pp]/) != nil
     @text.gsub!(/\\[Pp]/) { "\006" }
   end
   while @text.slice(/\\[Ii]/) != nil
     @text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\014[#{$1}]" }
   end
   while @text.slice(/\\[Zz]/) != nil
     # Check for face directory existence
     if File.directory? Dir::getwd + "/Graphics/Faces/"
       @text.slice(/\\[Zz]\[([0-9]+)\]/)
       # Check for file existence
       if Faces[$1.to_i] != nil
         @text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "\015[#{$1}]" }
       else
         @text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "" }
       end
     else
       @text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "" }
     end
   end
   while @text.slice(/\\[Hh]/) != nil
     @text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\016[#{$1}]" }
   end
   @text.gsub!(/\\[Ff]/) { "\007" }
   @text.gsub!(/\\[Qq]/) { "\011" }
   @text.gsub!(/\\[Tt]/) { "\017" }
   while @text.slice(/\\[Mm]\[([0-9]+)]/)
     @text.gsub!(/\\[Mm]\[([0-9]+)]/) { "\018[#{$1}]" }
   end
   @text.slice!(/\\[Nn][Cc]/)
 end
 #--------------------------------------------------------------------------
 # * Create cursor graphic
 #--------------------------------------------------------------------------
 def create_cursor
   
   if $game_system.message_text_mode == TEXT_MODE_BUBBLE
     @cursor = Sprite.new
     @cursor.bitmap = Bitmap.new("Graphics/Pictures/Pointer2")
     @cursor.ox = @cursor.bitmap.width
     if $separate_choices == false
       indent = @message.bitmap.text_size("    ").width
     else
       indent = @message.bitmap.text_size("    ").width
     end
     
   elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
     template = Sprite.new
     template.opacity = 0
     template.bitmap = Bitmap.new("Graphics/Windowskins/"+$data_system.windowskin_name)
     source_rect = Rect.new(128,64,32,32)
     # Set width of the cursor rectangle
     width = @line_width[@lines-$game_temp.choice_max+@index]
     # Correct for added spaces in choices following main text
     width -= @message.bitmap.text_size('     ').width if @indent == true
     dest_rect = Rect.new(0,0,width,@text_height)
     if @cursor == nil
       @cursor = Sprite.new
     else
       @cursor.bitmap.clear
       @cursor.bitmap.dispose
     end
     @cursor.opacity = 255
     @cursor.bitmap = Bitmap.new(width,@text_height)
     # Upper left
     source_rect = Rect.new(128,64,3,3)
     @cursor.bitmap.blt(0,0,template.bitmap,source_rect)
     # Upper right
     source_rect = Rect.new(157,64,3,3)
     @cursor.bitmap.blt(width-3,0,template.bitmap,source_rect)
     # Lower left
     source_rect = Rect.new(128,93,3,3)
     @cursor.bitmap.blt(0,@text_height-3,template.bitmap,source_rect)
     # Lower right
     source_rect = Rect.new(157,93,3,3)
     @cursor.bitmap.blt(width-3,@text_height-3,template.bitmap,source_rect)
     # Top fill in
     source_rect = Rect.new(131,64,26,3)
     dest_rect = Rect.new(3,0,width-6,3)
     @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
     # Bottom fill in
     source_rect = Rect.new(131,93,26,3)
     dest_rect = Rect.new(3,@text_height-3,width-6,3)
     @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
     # Left fill in
     source_rect = Rect.new(128,67,3,@text_height-6)
     dest_rect = Rect.new(0,3,3,@text_height-6)
     @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
     # Right fill in
     source_rect = Rect.new(157,67,3,@text_height-6)
     dest_rect = Rect.new(width-3,3,3,@text_height-6)
     @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
     # Center fill in
     source_rect = Rect.new(131,67,26,26)
     dest_rect = Rect.new(3,3,width-6,@text_height-6)
     @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
     
     @cursor.ox = 0
     template.bitmap.clear
     template = nil
     indent = @message.bitmap.text_size("  ").width
   end
   
     @cursor.oy = @cursor.bitmap.height/2
     
     if @indent == true
       @cursor.x = @message.x - @message.ox + 14 + @face_extension_x + indent
     else
       @cursor.x = @message.x - @message.ox + @face_extension_x + indent
     end

     y_correction = 0
     @line_height_correction.each { |number|
         y_correction += number
     }
     
     @cursor.y = @message.y - @message.oy + @bubble_correction_y \
       + 10 + @text_height/2 + ((@lines-$game_temp.choice_max+@index)*@text_height)\
       + y_correction
     @cursor.z += 5
     # More accurately place windowskin rectangle
     if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
       @cursor.y -= 1
     end
     # Correct for bad sizing of bitmap draw_text method
     if $game_system.message_text_size == TEXT_SIZE_LARGE
       @cursor.y -= 2
     elsif
       $game_system.message_text_size == TEXT_SIZE_JUMBO
       @cursor.y -= 6
     end
   
 end  
 #--------------------------------------------------------------------------
 # * Reset cursor graphic
 #--------------------------------------------------------------------------
 
 def reset_cursor
   
   @cursor.x = @message_box.x - @message_box.ox + 16
   @cursor.y = @message_box.y - @message_box.oy\
     + ((@lines-$game_temp.choice_max + 1)*@text_height)\
     + @bubble_correction_y
 end
 
 #--------------------------------------------------------------------------
 # * Update cursor graphic
 #--------------------------------------------------------------------------
 def update_cursor
   if $game_system.message_text_mode == TEXT_MODE_BUBBLE
     modulus = 10
   elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
     modulus = 3
   end
   
   @cursor_count += 1
   if @cursor_count % modulus  == 0 && @cursor_move_right == true
     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
       @cursor.x += 1
     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
       @cursor.opacity -= 10
     end
     if @cursor_count == modulus * 5
       @cursor_count = 0
       @cursor_move_right = false
     end
     
   elsif @cursor_count % modulus == 0 && @cursor_move_right == false
     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
       @cursor.x -= 1
     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
       @cursor.opacity += 10
     end
    if @cursor_count == modulus * 5
       @cursor_count = 0
       @cursor_move_right = true
     end
   end
   
   if Input.trigger?(Input::UP)
     if @index != 0
       @cursor.y -= @text_height
       @index -= 1
     else
       @cursor.y += @text_height * ($game_temp.choice_max-1)
       @index = $game_temp.choice_max-1
     end
     if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
       create_cursor
     end
   elsif Input.trigger?(Input::DOWN)
     if @index != $game_temp.choice_max-1
       @cursor.y += @text_height
       @index += 1
     else
       @cursor.y -= @text_height * ($game_temp.choice_max-1)
       @index = 0
     end
     if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
       create_cursor
     end
   end
 end  
 
end
2
  Hello everyone! I'm encountering a very annoying issue and I would be grateful if you could help me through.
 Firstly, before using the VX Engine in my RMXP Project I did not have this problem. I followed Terv's tutorial and succesfully implemented the other engine because the game lagged so much and I had to improve somehow the fps.
 My guess is that this script here cause the problem (because the Zer0 Cms's is the same), but I don't understand why because it doesn't have anything related to the index rectangle:
 
Spoiler: ShowHide
$DEBUG = $TEST = true # Remove this line before releasing your game
module RPG
 module Cache
   @cache = {}
   def self.load_bitmap(folder_name, filename, hue = 0)
     path = folder_name + filename
     if not @cache.include?(path) or @cache[path].disposed?
       if filename != ""
         @cache[path] = Bitmap.new(path)
       else
         @cache[path] = Bitmap.new(32, 32)
       end
     end
     if hue == 0
       @cache[path]
     else
       key = [path, hue]
       if not @cache.include?(key) or @cache[key].disposed?
         @cache[key] = @cache[path].clone
         @cache[key].hue_change(hue)
       end
       @cache[key]
     end
   end
   def self.animation(filename, hue)
     self.load_bitmap("Graphics/Animations/", filename, hue)
   end
   def self.autotile(filename)
     self.load_bitmap("Graphics/Autotiles/", filename)
   end
   def self.battleback(filename)
     self.load_bitmap("Graphics/Battlebacks/", filename)
   end
   def self.battler(filename, hue)
     self.load_bitmap("Graphics/Battlers/", filename, hue)
   end
   def self.character(filename, hue)
     self.load_bitmap("Graphics/Characters/", filename, hue)
   end
   def self.fog(filename, hue)
     self.load_bitmap("Graphics/Fogs/", filename, hue)
   end
   def self.gameover(filename)
     self.load_bitmap("Graphics/Gameovers/", filename)
   end
   def self.icon(filename)
     self.load_bitmap("Graphics/Icons/", filename)
   end
   def self.panorama(filename, hue)
     self.load_bitmap("Graphics/Panoramas/", filename, hue)
   end
   def self.picture(filename)
     self.load_bitmap("Graphics/Pictures/", filename)
   end
   def self.tileset(filename)
     self.load_bitmap("Graphics/Tilesets/", filename)
   end
   def self.title(filename)
     self.load_bitmap("Graphics/Titles/", filename)
   end
   def self.windowskin(filename)
     self.load_bitmap("Graphics/Windowskins/", filename)
   end
   def self.tile(filename, tile_id, hue)
     key = [filename, tile_id, hue]
     if not @cache.include?(key) or @cache[key].disposed?
       @cache[key] = Bitmap.new(32, 32)
       x = (tile_id - 384) % 8 * 32
       y = (tile_id - 384) / 8 * 32
       rect = Rect.new(x, y, 32, 32)
       @cache[key].blt(0, 0, self.tileset(filename), rect)
       @cache[key].hue_change(hue)
     end
     @cache[key]
   end
   def self.clear
     @cache = {}
     GC.start
   end
 end
end

module RPG
 class Sprite < ::Sprite
   @@_animations = []
   @@_reference_count = {}
   def initialize(viewport = nil)
     super(viewport)
     @_whiten_duration = 0
     @_appear_duration = 0
     @_escape_duration = 0
     @_collapse_duration = 0
     @_damage_duration = 0
     @_animation_duration = 0
     @_blink = false
   end
   def dispose
     dispose_damage
     dispose_animation
     dispose_loop_animation
     super
   end
   def whiten
     self.blend_type = 0
     self.color.set(255, 255, 255, 128)
     self.opacity = 255
     @_whiten_duration = 16
     @_appear_duration = 0
     @_escape_duration = 0
     @_collapse_duration = 0
   end
   def appear
     self.blend_type = 0
     self.color.set(0, 0, 0, 0)
     self.opacity = 0
     @_appear_duration = 16
     @_whiten_duration = 0
     @_escape_duration = 0
     @_collapse_duration = 0
   end
   def escape
     self.blend_type = 0
     self.color.set(0, 0, 0, 0)
     self.opacity = 255
     @_escape_duration = 32
     @_whiten_duration = 0
     @_appear_duration = 0
     @_collapse_duration = 0
   end
   def collapse
     self.blend_type = 1
     self.color.set(255, 64, 64, 255)
     self.opacity = 255
     @_collapse_duration = 48
     @_whiten_duration = 0
     @_appear_duration = 0
     @_escape_duration = 0
   end
   def damage(value, critical)
     dispose_damage
     if value.is_a?(Numeric)
       damage_string = value.abs.to_s
     else
       damage_string = value.to_s
     end
     bitmap = Bitmap.new(160, 48)
     bitmap.font.name = "Arial Black"
     bitmap.font.size = 32
     bitmap.font.color.set(0, 0, 0)
     bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
     bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
     bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
     bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
     if value.is_a?(Numeric) and value < 0
       bitmap.font.color.set(176, 255, 144)
     else
       bitmap.font.color.set(255, 255, 255)
     end
     bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
     if critical
       bitmap.font.size = 20
       bitmap.font.color.set(0, 0, 0)
       bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
       bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
       bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
       bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
       bitmap.font.color.set(255, 255, 255)
       bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
     end
     @_damage_sprite = ::Sprite.new(self.viewport)
     @_damage_sprite.bitmap = bitmap
     @_damage_sprite.ox = 80
     @_damage_sprite.oy = 20
     @_damage_sprite.x = self.x
     @_damage_sprite.y = self.y - self.oy / 2
     @_damage_sprite.z = 3000
     @_damage_duration = 40
   end
   def animation(animation, hit)
     dispose_animation
     @_animation = animation
     return if @_animation == nil
     @_animation_hit = hit
     @_animation_duration = @_animation.frame_max
     animation_name = @_animation.animation_name
     animation_hue = @_animation.animation_hue
     bitmap = RPG::Cache.animation(animation_name, animation_hue)
     if @@_reference_count.include?(bitmap)
       @@_reference_count[bitmap] += 1
     else
       @@_reference_count[bitmap] = 1
     end
     @_animation_sprites = []
     if @_animation.position != 3 or not @@_animations.include?(animation)
       for i in 0..15
         sprite = ::Sprite.new(self.viewport)
         sprite.bitmap = bitmap
         sprite.visible = false
         @_animation_sprites.push(sprite)
       end
       unless @@_animations.include?(animation)
         @@_animations.push(animation)
       end
     end
     update_animation
   end
   def loop_animation(animation)
     return if animation == @_loop_animation
     dispose_loop_animation
     @_loop_animation = animation
     return if @_loop_animation == nil
     @_loop_animation_index = 0
     animation_name = @_loop_animation.animation_name
     animation_hue = @_loop_animation.animation_hue
     bitmap = RPG::Cache.animation(animation_name, animation_hue)
     if @@_reference_count.include?(bitmap)
       @@_reference_count[bitmap] += 1
     else
       @@_reference_count[bitmap] = 1
     end
     @_loop_animation_sprites = []
     for i in 0..15
       sprite = ::Sprite.new(self.viewport)
       sprite.bitmap = bitmap
       sprite.visible = false
       @_loop_animation_sprites.push(sprite)
     end
     update_loop_animation
   end
   def dispose_damage
     if @_damage_sprite != nil
       @_damage_sprite.bitmap.dispose
       @_damage_sprite.dispose
       @_damage_sprite = nil
       @_damage_duration = 0
     end
   end
   def dispose_animation
     if @_animation_sprites != nil
       sprite = @_animation_sprites[0]
       if sprite != nil
         @@_reference_count[sprite.bitmap] -= 1
         if @@_reference_count[sprite.bitmap] == 0
           sprite.bitmap.dispose
         end
       end
       for sprite in @_animation_sprites
         sprite.dispose
       end
       @_animation_sprites = nil
       @_animation = nil
     end
   end
   def dispose_loop_animation
     if @_loop_animation_sprites != nil
       sprite = @_loop_animation_sprites[0]
       if sprite != nil
         @@_reference_count[sprite.bitmap] -= 1
         if @@_reference_count[sprite.bitmap] == 0
           sprite.bitmap.dispose
         end
       end
       for sprite in @_loop_animation_sprites
         sprite.dispose
       end
       @_loop_animation_sprites = nil
       @_loop_animation = nil
     end
   end
   def blink_on
     unless @_blink
       @_blink = true
       @_blink_count = 0
     end
   end
   def blink_off
     if @_blink
       @_blink = false
       self.color.set(0, 0, 0, 0)
     end
   end
   def blink?
     @_blink
   end
   def effect?
     @_whiten_duration > 0 or
     @_appear_duration > 0 or
     @_escape_duration > 0 or
     @_collapse_duration > 0 or
     @_damage_duration > 0 or
     @_animation_duration > 0
   end
   def update
     super
     if @_whiten_duration > 0
       @_whiten_duration -= 1
       self.color.alpha = 128 - (16 - @_whiten_duration) * 10
     end
     if @_appear_duration > 0
       @_appear_duration -= 1
       self.opacity = (16 - @_appear_duration) * 16
     end
     if @_escape_duration > 0
       @_escape_duration -= 1
       self.opacity = 256 - (32 - @_escape_duration) * 10
     end
     if @_collapse_duration > 0
       @_collapse_duration -= 1
       self.opacity = 256 - (48 - @_collapse_duration) * 6
     end
     if @_damage_duration > 0
       @_damage_duration -= 1
       case @_damage_duration
       when 38..39
         @_damage_sprite.y -= 4
       when 36..37
         @_damage_sprite.y -= 2
       when 34..35
         @_damage_sprite.y += 2
       when 28..33
         @_damage_sprite.y += 4
       end
       @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
       if @_damage_duration == 0
         dispose_damage
       end
     end
     if @_animation != nil and (Graphics.frame_count % 2 == 0)
       @_animation_duration -= 1
       update_animation
     end
     if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
       update_loop_animation
       @_loop_animation_index += 1
       @_loop_animation_index %= @_loop_animation.frame_max
     end
     if @_blink
       @_blink_count = (@_blink_count + 1) % 32
       if @_blink_count < 16
         alpha = (16 - @_blink_count) * 6
       else
         alpha = (@_blink_count - 16) * 6
       end
       self.color.set(255, 255, 255, alpha)
     end
     @@_animations.clear
   end
   def update_animation
     if @_animation_duration > 0
       frame_index = @_animation.frame_max - @_animation_duration
       cell_data = @_animation.frames[frame_index].cell_data
       position = @_animation.position
       animation_set_sprites(@_animation_sprites, cell_data, position)
       for timing in @_animation.timings
         if timing.frame == frame_index
           animation_process_timing(timing, @_animation_hit)
         end
       end
     else
       dispose_animation
     end
   end
   def update_loop_animation
     frame_index = @_loop_animation_index
     cell_data = @_loop_animation.frames[frame_index].cell_data
     position = @_loop_animation.position
     animation_set_sprites(@_loop_animation_sprites, cell_data, position)
     for timing in @_loop_animation.timings
       if timing.frame == frame_index
         animation_process_timing(timing, true)
       end
     end
   end
   def animation_set_sprites(sprites, cell_data, position)
     for i in 0..15
       sprite = sprites[i]
       pattern = cell_data[i, 0]
       if sprite == nil or pattern == nil or pattern == -1
         sprite.visible = false if sprite != nil
         next
       end
       sprite.visible = true
       sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
       if position == 3
         if self.viewport != nil
           sprite.x = self.viewport.rect.width / 2
           sprite.y = self.viewport.rect.height - 160
         else
           sprite.x = 320
           sprite.y = 240
         end
       else
         sprite.x = self.x - self.ox + self.src_rect.width / 2
         sprite.y = self.y - self.oy + self.src_rect.height / 2
         sprite.y -= self.src_rect.height / 4 if position == 0
         sprite.y += self.src_rect.height / 4 if position == 2
       end
       sprite.x += cell_data[i, 1]
       sprite.y += cell_data[i, 2]
       sprite.z = 2000
       sprite.ox = 96
       sprite.oy = 96
       sprite.zoom_x = cell_data[i, 3] / 100.0
       sprite.zoom_y = cell_data[i, 3] / 100.0
       sprite.angle = cell_data[i, 4]
       sprite.mirror = (cell_data[i, 5] == 1)
       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
       sprite.blend_type = cell_data[i, 7]
     end
   end
   def animation_process_timing(timing, hit)
     if (timing.condition == 0) or
        (timing.condition == 1 and hit == true) or
        (timing.condition == 2 and hit == false)
       if timing.se.name != ""
         se = timing.se
         Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
       end
       case timing.flash_scope
       when 1
         self.flash(timing.flash_color, timing.flash_duration * 2)
       when 2
         if self.viewport != nil
           self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
         end
       when 3
         self.flash(nil, timing.flash_duration * 2)
       end
     end
   end
   def x=(x)
     sx = x - self.x
     if sx != 0
       if @_animation_sprites != nil
         for i in 0..15
           @_animation_sprites[i].x += sx
         end
       end
       if @_loop_animation_sprites != nil
         for i in 0..15
           @_loop_animation_sprites[i].x += sx
         end
       end
     end
     super
   end
   def y=(y)
     sy = y - self.y
     if sy != 0
       if @_animation_sprites != nil
         for i in 0..15
           @_animation_sprites[i].y += sy
         end
       end
       if @_loop_animation_sprites != nil
         for i in 0..15
           @_loop_animation_sprites[i].y += sy
         end
       end
     end
     super
   end
 end
end

module RPG
 class Weather
   def initialize(viewport = nil)
     @type = 0
     @max = 0
     @ox = 0
     @oy = 0
     color1 = Color.new(255, 255, 255, 255)
     color2 = Color.new(255, 255, 255, 128)
     @rain_bitmap = Bitmap.new(7, 56)
     for i in 0..6
       @rain_bitmap.fill_rect(6-i, i*8, 1, 8, color1)
     end
     @storm_bitmap = Bitmap.new(34, 64)
     for i in 0..31
       @storm_bitmap.fill_rect(33-i, i*2, 1, 2, color2)
       @storm_bitmap.fill_rect(32-i, i*2, 1, 2, color1)
       @storm_bitmap.fill_rect(31-i, i*2, 1, 2, color2)
     end
     @snow_bitmap = Bitmap.new(6, 6)
     @snow_bitmap.fill_rect(0, 1, 6, 4, color2)
     @snow_bitmap.fill_rect(1, 0, 4, 6, color2)
     @snow_bitmap.fill_rect(1, 2, 4, 2, color1)
     @snow_bitmap.fill_rect(2, 1, 2, 4, color1)
     @sprites = []
     for i in 1..40
       sprite = Sprite.new(viewport)
       sprite.z = 1000
       sprite.visible = false
       sprite.opacity = 0
       @sprites.push(sprite)
     end
   end
   def dispose
     for sprite in @sprites
       sprite.dispose
     end
     @rain_bitmap.dispose
     @storm_bitmap.dispose
     @snow_bitmap.dispose
   end
   def type=(type)
     return if @type == type
     @type = type
     case @type
     when 1
       bitmap = @rain_bitmap
     when 2
       bitmap = @storm_bitmap
     when 3
       bitmap = @snow_bitmap
     else
       bitmap = nil
     end
     for i in 1..40
       sprite = @sprites[i]
       if sprite != nil
         sprite.visible = (i <= @max)
         sprite.bitmap = bitmap
       end
     end
   end
   def ox=(ox)
     return if @ox == ox;
     @ox = ox
     for sprite in @sprites
       sprite.ox = @ox
     end
   end
   def oy=(oy)
     return if @oy == oy;
     @oy = oy
     for sprite in @sprites
       sprite.oy = @oy
     end
   end
   def max=(max)
     return if @max == max;
     @max = [[max, 0].max, 40].min
     for i in 1..40
       sprite = @sprites[i]
       if sprite != nil
         sprite.visible = (i <= @max)
       end
     end
   end
   def update
     return if @type == 0
     for i in 1..@max
       sprite = @sprites[i]
       if sprite == nil
         break
       end
       if @type == 1
         sprite.x -= 2
         sprite.y += 16
         sprite.opacity -= 8
       end
       if @type == 2
         sprite.x -= 8
         sprite.y += 16
         sprite.opacity -= 12
       end
       if @type == 3
         sprite.x -= 2
         sprite.y += 8
         sprite.opacity -= 8
       end
     x = sprite.x - @ox
     y = sprite.y - @oy
     if sprite.opacity < 64 || x < -50 || x > SCREEN[0] + 150 ||
       y < -300 || y > SCREEN[1] + 32
       sprite.x = rand(SCREEN[0] + 160) - 50 + @ox
       sprite.y = rand(SCREEN[1] + 320) - 200 + @oy
       sprite.opacity = 255
     end
     end
   end
   attr_reader :type
   attr_reader :max
   attr_reader :ox
   attr_reader :oy
 end
end


module RPG
 class Map
   def initialize(width, height)
     @tileset_id = 1
     @width = width
     @height = height
     @autoplay_bgm = false
     @bgm = RPG::AudioFile.new
     @autoplay_bgs = false
     @bgs = RPG::AudioFile.new("", 80)
     @encounter_list = []
     @encounter_step = 30
     @data = Table.new(width, height, 3)
     @events = {}
   end
   attr_accessor :tileset_id
   attr_accessor :width
   attr_accessor :height
   attr_accessor :autoplay_bgm
   attr_accessor :bgm
   attr_accessor :autoplay_bgs
   attr_accessor :bgs
   attr_accessor :encounter_list
   attr_accessor :encounter_step
   attr_accessor :data
   attr_accessor :events
 end
end

module RPG
 class MapInfo
   def initialize
     @name = ""
     @parent_id = 0
     @order = 0
     @expanded = false
     @scroll_x = 0
     @scroll_y = 0
   end
   attr_accessor :name
   attr_accessor :parent_id
   attr_accessor :order
   attr_accessor :expanded
   attr_accessor :scroll_x
   attr_accessor :scroll_y
 end
end

module RPG
 class Event
   def initialize(x, y)
     @id = 0
     @name = ""
     @x = x
     @y = y
     @pages = [RPG::Event::Page.new]
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :x
   attr_accessor :y
   attr_accessor :pages
 end
end

module RPG
 class Event
   class Page
     def initialize
       @condition = RPG::Event::Page::Condition.new
       @graphic = RPG::Event::Page::Graphic.new
       @move_type = 0
       @move_speed = 3
       @move_frequency = 3
       @move_route = RPG::MoveRoute.new
       @walk_anime = true
       @step_anime = false
       @direction_fix = false
       @through = false
       @always_on_top = false
       @trigger = 0
       @list = [RPG::EventCommand.new]
     end
     attr_accessor :condition
     attr_accessor :graphic
     attr_accessor :move_type
     attr_accessor :move_speed
     attr_accessor :move_frequency
     attr_accessor :move_route
     attr_accessor :walk_anime
     attr_accessor :step_anime
     attr_accessor :direction_fix
     attr_accessor :through
     attr_accessor :always_on_top
     attr_accessor :trigger
     attr_accessor :list
   end
 end
end

module RPG
 class Event
   class Page
     class Condition
       def initialize
         @switch1_valid = false
         @switch2_valid = false
         @variable_valid = false
         @self_switch_valid = false
         @switch1_id = 1
         @switch2_id = 1
         @variable_id = 1
         @variable_value = 0
         @self_switch_ch = "A"
       end
       attr_accessor :switch1_valid
       attr_accessor :switch2_valid
       attr_accessor :variable_valid
       attr_accessor :self_switch_valid
       attr_accessor :switch1_id
       attr_accessor :switch2_id
       attr_accessor :variable_id
       attr_accessor :variable_value
       attr_accessor :self_switch_ch
     end
   end
 end
end

module RPG
 class Event
   class Page
     class Graphic
       def initialize
         @tile_id = 0
         @character_name = ""
         @character_hue = 0
         @direction = 2
         @pattern = 0
         @opacity = 255
         @blend_type = 0
       end
       attr_accessor :tile_id
       attr_accessor :character_name
       attr_accessor :character_hue
       attr_accessor :direction
       attr_accessor :pattern
       attr_accessor :opacity
       attr_accessor :blend_type
     end
   end
 end
end

module RPG
 class EventCommand
   def initialize(code = 0, indent = 0, parameters = [])
     @code = code
     @indent = indent
     @parameters = parameters
   end
   attr_accessor :code
   attr_accessor :indent
   attr_accessor :parameters
 end
end

module RPG
 class MoveRoute
   def initialize
     @repeat = true
     @skippable = false
     @list = [RPG::MoveCommand.new]
   end
   attr_accessor :repeat
   attr_accessor :skippable
   attr_accessor :list
 end
end

module RPG
         class MoveCommand
               def initialize(code = 0, parameters = [])
                 @code = code
                 @parameters = parameters
               end
               attr_accessor :code
               attr_accessor :parameters
         end
       end
       
       module RPG
 class Actor
   def initialize
     @id = 0
     @name = ""
     @class_id = 1
     @initial_level = 1
     @final_level = 99
     @exp_basis = 30
     @exp_inflation = 30
     @character_name = ""
     @character_hue = 0
     @battler_name = ""
     @battler_hue = 0
     @parameters = Table.new(6,100)
     for i in 1..99
       @parameters[0,i] = 500+i*50
       @parameters[1,i] = 500+i*50
       @parameters[2,i] = 50+i*5
       @parameters[3,i] = 50+i*5
       @parameters[4,i] = 50+i*5
       @parameters[5,i] = 50+i*5
     end
     @weapon_id = 0
     @armor1_id = 0
     @armor2_id = 0
     @armor3_id = 0
     @armor4_id = 0
     @armor5_id = 0
     @weapon_fix = false
     @armor1_fix = false
     @armor2_fix = false
     @armor3_fix = false
     @armor4_fix = false
     @armor5_fix = false
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :class_id
   attr_accessor :initial_level
   attr_accessor :final_level
   attr_accessor :exp_basis
   attr_accessor :exp_inflation
   attr_accessor :character_name
   attr_accessor :character_hue
   attr_accessor :battler_name
   attr_accessor :battler_hue
   attr_accessor :parameters
   attr_accessor :weapon_id
   attr_accessor :armor1_id
   attr_accessor :armor2_id
   attr_accessor :armor3_id
   attr_accessor :armor4_id
   attr_accessor :armor5_id
   attr_accessor :weapon_fix
   attr_accessor :armor1_fix
   attr_accessor :armor2_fix
   attr_accessor :armor3_fix
   attr_accessor :armor4_fix
   attr_accessor :armor5_fix
 end
end

module RPG
 class Class
   def initialize
     @id = 0
     @name = ""
     @position = 0
     @weapon_set = []
     @armor_set = []
     @element_ranks = Table.new(1)
     @state_ranks = Table.new(1)
     @learnings = []
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :position
   attr_accessor :weapon_set
   attr_accessor :armor_set
   attr_accessor :element_ranks
   attr_accessor :state_ranks
   attr_accessor :learnings
 end
end

module RPG
 class Class
   class Learning
     def initialize
       @level = 1
       @skill_id = 1
     end
     attr_accessor :level
     attr_accessor :skill_id
   end
 end
end

module RPG
 class Skill
   def initialize
     @id = 0
     @name = ""
     @icon_name = ""
     @description = ""
     @scope = 0
     @occasion = 1
     @animation1_id = 0
     @animation2_id = 0
     @menu_se = RPG::AudioFile.new("", 80)
     @common_event_id = 0
     @sp_cost = 0
     @power = 0
     @atk_f = 0
     @eva_f = 0
     @str_f = 0
     @dex_f = 0
     @agi_f = 0
     @int_f = 100
     @hit = 100
     @pdef_f = 0
     @mdef_f = 100
     @variance = 15
     @element_set = []
     @plus_state_set = []
     @minus_state_set = []
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :icon_name
   attr_accessor :description
   attr_accessor :scope
   attr_accessor :occasion
   attr_accessor :animation1_id
   attr_accessor :animation2_id
   attr_accessor :menu_se
   attr_accessor :common_event_id
   attr_accessor :sp_cost
   attr_accessor :power
   attr_accessor :atk_f
   attr_accessor :eva_f
   attr_accessor :str_f
   attr_accessor :dex_f
   attr_accessor :agi_f
   attr_accessor :int_f
   attr_accessor :hit
   attr_accessor :pdef_f
   attr_accessor :mdef_f
   attr_accessor :variance
   attr_accessor :element_set
   attr_accessor :plus_state_set
   attr_accessor :minus_state_set
 end
end

module RPG
 class Item
   def initialize
     @id = 0
     @name = ""
     @icon_name = ""
     @description = ""
     @scope = 0
     @occasion = 0
     @animation1_id = 0
     @animation2_id = 0
     @menu_se = RPG::AudioFile.new("", 80)
     @common_event_id = 0
     @price = 0
     @consumable = true
     @parameter_type = 0
     @parameter_points = 0
     @recover_hp_rate = 0
     @recover_hp = 0
     @recover_sp_rate = 0
     @recover_sp = 0
     @hit = 100
     @pdef_f = 0
     @mdef_f = 0
     @variance = 0
     @element_set = []
     @plus_state_set = []
     @minus_state_set = []
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :icon_name
   attr_accessor :description
   attr_accessor :scope
   attr_accessor :occasion
   attr_accessor :animation1_id
   attr_accessor :animation2_id
   attr_accessor :menu_se
   attr_accessor :common_event_id
   attr_accessor :price
   attr_accessor :consumable
   attr_accessor :parameter_type
   attr_accessor :parameter_points
   attr_accessor :recover_hp_rate
   attr_accessor :recover_hp
   attr_accessor :recover_sp_rate
   attr_accessor :recover_sp
   attr_accessor :hit
   attr_accessor :pdef_f
   attr_accessor :mdef_f
   attr_accessor :variance
   attr_accessor :element_set
   attr_accessor :plus_state_set
   attr_accessor :minus_state_set
 end
end

module RPG
 class Weapon
   def initialize
     @id = 0
     @name = ""
     @icon_name = ""
     @description = ""
     @animation1_id = 0
     @animation2_id = 0
     @price = 0
     @atk = 0
     @pdef = 0
     @mdef = 0
     @str_plus = 0
     @dex_plus = 0
     @agi_plus = 0
     @int_plus = 0
     @element_set = []
     @plus_state_set = []
     @minus_state_set = []
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :icon_name
   attr_accessor :description
   attr_accessor :animation1_id
   attr_accessor :animation2_id
   attr_accessor :price
   attr_accessor :atk
   attr_accessor :pdef
   attr_accessor :mdef
   attr_accessor :str_plus
   attr_accessor :dex_plus
   attr_accessor :agi_plus
   attr_accessor :int_plus
   attr_accessor :element_set
   attr_accessor :plus_state_set
   attr_accessor :minus_state_set
 end
end

module RPG
 class Armor
   def initialize
     @id = 0
     @name = ""
     @icon_name = ""
     @description = ""
     @kind = 0
     @auto_state_id = 0
     @price = 0
     @pdef = 0
     @mdef = 0
     @eva = 0
     @str_plus = 0
     @dex_plus = 0
     @agi_plus = 0
     @int_plus = 0
     @guard_element_set = []
     @guard_state_set = []
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :icon_name
   attr_accessor :description
   attr_accessor :kind
   attr_accessor :auto_state_id
   attr_accessor :price
   attr_accessor :pdef
   attr_accessor :mdef
   attr_accessor :eva
   attr_accessor :str_plus
   attr_accessor :dex_plus
   attr_accessor :agi_plus
   attr_accessor :int_plus
   attr_accessor :guard_element_set
   attr_accessor :guard_state_set
 end
end

module RPG
 class Enemy
   def initialize
     @id = 0
     @name = ""
     @battler_name = ""
     @battler_hue = 0
     @maxhp = 500
     @maxsp = 500
     @str = 50
     @dex = 50
     @agi = 50
     @int = 50
     @atk = 100
     @pdef = 100
     @mdef = 100
     @eva = 0
     @animation1_id = 0
     @animation2_id = 0
     @element_ranks = Table.new(1)
     @state_ranks = Table.new(1)
     @actions = [RPG::Enemy::Action.new]
     @exp = 0
     @gold = 0
     @item_id = 0
     @weapon_id = 0
     @armor_id = 0
     @treasure_prob = 100
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :battler_name
   attr_accessor :battler_hue
   attr_accessor :maxhp
   attr_accessor :maxsp
   attr_accessor :str
   attr_accessor :dex
   attr_accessor :agi
   attr_accessor :int
   attr_accessor :atk
   attr_accessor :pdef
   attr_accessor :mdef
   attr_accessor :eva
   attr_accessor :animation1_id
   attr_accessor :animation2_id
   attr_accessor :element_ranks
   attr_accessor :state_ranks
   attr_accessor :actions
   attr_accessor :exp
   attr_accessor :gold
   attr_accessor :item_id
   attr_accessor :weapon_id
   attr_accessor :armor_id
   attr_accessor :treasure_prob
 end
end

module RPG
 class Enemy
   class Action
     def initialize
       @kind = 0
       @basic = 0
       @skill_id = 1
       @condition_turn_a = 0
       @condition_turn_b = 1
       @condition_hp = 100
       @condition_level = 1
       @condition_switch_id = 0
       @rating = 5
     end
     attr_accessor :kind
     attr_accessor :basic
     attr_accessor :skill_id
     attr_accessor :condition_turn_a
     attr_accessor :condition_turn_b
     attr_accessor :condition_hp
     attr_accessor :condition_level
     attr_accessor :condition_switch_id
     attr_accessor :rating
   end
 end
end

module RPG
 class Troop
   def initialize
     @id = 0
     @name = ""
     @members = []
     @pages = [RPG::BattleEventPage.new]
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :members
   attr_accessor :pages
 end
end

module RPG
 class Troop
   class Member
     def initialize
       @enemy_id = 1
       @x = 0
       @y = 0
       @hidden = false
       @immortal = false
     end
     attr_accessor :enemy_id
     attr_accessor :x
     attr_accessor :y
     attr_accessor :hidden
     attr_accessor :immortal
   end
 end
end

module RPG
 class Troop
   class Page
     def initialize
       @condition = RPG::Troop::Page::Condition.new
       @span = 0
       @list = [RPG::EventCommand.new]
     end
     attr_accessor :condition
     attr_accessor :span
     attr_accessor :list
   end
 end
end

module RPG
 class Troop
   class Page
     class Condition
       def initialize
         @turn_valid = false
         @enemy_valid = false
         @actor_valid = false
         @switch_valid = false
         @turn_a = 0
         @turn_b = 0
         @enemy_index = 0
         @enemy_hp = 50
         @actor_id = 1
         @actor_hp = 50
         @switch_id = 1
       end
       attr_accessor :turn_valid
       attr_accessor :enemy_valid
       attr_accessor :actor_valid
       attr_accessor :switch_valid
       attr_accessor :turn_a
       attr_accessor :turn_b
       attr_accessor :enemy_index
       attr_accessor :enemy_hp
       attr_accessor :actor_id
       attr_accessor :actor_hp
       attr_accessor :switch_id
     end
   end
 end
end

module RPG
 class State
   def initialize
     @id = 0
     @name = ""
     @animation_id = 0
     @restriction = 0
     @nonresistance = false
     @zero_hp = false
     @cant_get_exp = false
     @cant_evade = false
     @slip_damage = false
     @rating = 5
     @hit_rate = 100
     @maxhp_rate = 100
     @maxsp_rate = 100
     @str_rate = 100
     @dex_rate = 100
     @agi_rate = 100
     @int_rate = 100
     @atk_rate = 100
     @pdef_rate = 100
     @mdef_rate = 100
     @eva = 0
     @battle_only = true
     @hold_turn = 0
     @auto_release_prob = 0
     @shock_release_prob = 0
     @guard_element_set = []
     @plus_state_set = []
     @minus_state_set = []
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :animation_id
   attr_accessor :restriction
   attr_accessor :nonresistance
   attr_accessor :zero_hp
   attr_accessor :cant_get_exp
   attr_accessor :cant_evade
   attr_accessor :slip_damage
   attr_accessor :rating
   attr_accessor :hit_rate
   attr_accessor :maxhp_rate
   attr_accessor :maxsp_rate
   attr_accessor :str_rate
   attr_accessor :dex_rate
   attr_accessor :agi_rate
   attr_accessor :int_rate
   attr_accessor :atk_rate
   attr_accessor :pdef_rate
   attr_accessor :mdef_rate
   attr_accessor :eva
   attr_accessor :battle_only
   attr_accessor :hold_turn
   attr_accessor :auto_release_prob
   attr_accessor :shock_release_prob
   attr_accessor :guard_element_set
   attr_accessor :plus_state_set
   attr_accessor :minus_state_set
 end
end

module RPG
 class Animation
   def initialize
     @id = 0
     @name = ""
     @animation_name = ""
     @animation_hue = 0
     @position = 1
     @frame_max = 1
     @frames = [RPG::Animation::Frame.new]
     @timings = []
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :animation_name
   attr_accessor :animation_hue
   attr_accessor :position
   attr_accessor :frame_max
   attr_accessor :frames
   attr_accessor :timings
 end
end

module RPG
 class Animation
   class Frame
     def initialize
       @cell_max = 0
       @cell_data = Table.new(0, 0)
     end
     attr_accessor :cell_max
     attr_accessor :cell_data
   end
 end
end

module RPG
 class Animation
   class Timing
     def initialize
       @frame = 0
       @se = RPG::AudioFile.new("", 80)
       @flash_scope = 0
       @flash_color = Color.new(255,255,255,255)
       @flash_duration = 5
       @condition = 0
     end
     attr_accessor :frame
     attr_accessor :se
     attr_accessor :flash_scope
     attr_accessor :flash_color
     attr_accessor :flash_duration
     attr_accessor :condition
   end
 end
end

module RPG
 class Tileset
   def initialize
     @id = 0
     @name = ""
     @tileset_name = ""
     @autotile_names = [""]*7
     @panorama_name = ""
     @panorama_hue = 0
     @fog_name = ""
     @fog_hue = 0
     @fog_opacity = 64
     @fog_blend_type = 0
     @fog_zoom = 200
     @fog_sx = 0
     @fog_sy = 0
     @battleback_name = ""
     @passages = Table.new(384)
     @priorities = Table.new(384)
     @priorities[0] = 5
     @terrain_tags = Table.new(384)
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :tileset_name
   attr_accessor :autotile_names
   attr_accessor :panorama_name
   attr_accessor :panorama_hue
   attr_accessor :fog_name
   attr_accessor :fog_hue
   attr_accessor :fog_opacity
   attr_accessor :fog_blend_type
   attr_accessor :fog_zoom
   attr_accessor :fog_sx
   attr_accessor :fog_sy
   attr_accessor :battleback_name
   attr_accessor :passages
   attr_accessor :priorities
   attr_accessor :terrain_tags
 end
end

module RPG
 class CommonEvent
   def initialize
     @id = 0
     @name = ""
     @trigger = 0
     @switch_id = 1
     @list = [RPG::EventCommand.new]
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :trigger
   attr_accessor :switch_id
   attr_accessor :list
 end
end

module RPG
 class System
   def initialize
     @magic_number = 0
     @party_members = [1]
     @elements = [nil, ""]
     @switches = [nil, ""]
     @variables = [nil, ""]
     @windowskin_name = ""
     @title_name = ""
     @gameover_name = ""
     @battle_transition = ""
     @title_bgm = RPG::AudioFile.new
     @battle_bgm = RPG::AudioFile.new
     @battle_end_me = RPG::AudioFile.new
     @gameover_me = RPG::AudioFile.new
     @cursor_se = RPG::AudioFile.new("", 80)
     @decision_se = RPG::AudioFile.new("", 80)
     @cancel_se = RPG::AudioFile.new("", 80)
     @buzzer_se = RPG::AudioFile.new("", 80)
     @equip_se = RPG::AudioFile.new("", 80)
     @shop_se = RPG::AudioFile.new("", 80)
     @save_se = RPG::AudioFile.new("", 80)
     @load_se = RPG::AudioFile.new("", 80)
     @battle_start_se = RPG::AudioFile.new("", 80)
     @escape_se = RPG::AudioFile.new("", 80)
     @actor_collapse_se = RPG::AudioFile.new("", 80)
     @enemy_collapse_se = RPG::AudioFile.new("", 80)
     @words = RPG::System::Words.new
     @test_battlers = []
     @test_troop_id = 1
     @start_map_id = 1
     @start_x = 0
     @start_y = 0
     @battleback_name = ""
     @battler_name = ""
     @battler_hue = 0
     @edit_map_id = 1
   end
   attr_accessor :magic_number
   attr_accessor :party_members
   attr_accessor :elements
   attr_accessor :switches
   attr_accessor :variables
   attr_accessor :windowskin_name
   attr_accessor :title_name
   attr_accessor :gameover_name
   attr_accessor :battle_transition
   attr_accessor :title_bgm
   attr_accessor :battle_bgm
   attr_accessor :battle_end_me
   attr_accessor :gameover_me
   attr_accessor :cursor_se
   attr_accessor :decision_se
   attr_accessor :cancel_se
   attr_accessor :buzzer_se
   attr_accessor :equip_se
   attr_accessor :shop_se
   attr_accessor :save_se
   attr_accessor :load_se
   attr_accessor :battle_start_se
   attr_accessor :escape_se
   attr_accessor :actor_collapse_se
   attr_accessor :enemy_collapse_se
   attr_accessor :words
   attr_accessor :test_battlers
   attr_accessor :test_troop_id
   attr_accessor :start_map_id
   attr_accessor :start_x
   attr_accessor :start_y
   attr_accessor :battleback_name
   attr_accessor :battler_name
   attr_accessor :battler_hue
   attr_accessor :edit_map_id
 end
end

module RPG
 class System
   class Words
     def initialize
       @gold = ""
       @hp = ""
       @sp = ""
       @str = ""
       @dex = ""
       @agi = ""
       @int = ""
       @atk = ""
       @pdef = ""
       @mdef = ""
       @weapon = ""
       @armor1 = ""
       @armor2 = ""
       @armor3 = ""
       @armor4 = ""
       @armor5 = ""
       @attack = ""
       @skill = ""
       @guard = ""
       @item = ""
       @equip = ""
     end
     attr_accessor :gold
     attr_accessor :hp
     attr_accessor :sp
     attr_accessor :str
     attr_accessor :dex
     attr_accessor :agi
     attr_accessor :int
     attr_accessor :atk
     attr_accessor :pdef
     attr_accessor :mdef
     attr_accessor :weapon
     attr_accessor :armor1
     attr_accessor :armor2
     attr_accessor :armor3
     attr_accessor :armor4
     attr_accessor :armor5
     attr_accessor :attack
     attr_accessor :skill
     attr_accessor :guard
     attr_accessor :item
     attr_accessor :equip
   end
 end
end

module RPG
 class AudioFile
   def initialize(name = "", volume = 100, pitch = 100)
     @name = name
     @volume = volume
     @pitch = pitch
   end
   attr_accessor :name
   attr_accessor :volume
   attr_accessor :pitch
 end
end

 I've also did a video to exemplify my problem: http://youtu.be/43e0wiIhbmc
 As you can see I can use other menus (in my case slots) but the index rectangle won't move after it scrolls.
 Any help would be appreciate!
3

Hello all mighty scripters!
I appeal to you with one of my bothering issues and I would appreciate very much if someone can guide me to this.
I'm using this script to change my game resolution:
Spoiler: ShowHide
#===============================================================================
# Custom Resolution (RGSS1+Ace engine compatible)
# Author: ForeverZer0
# Version: 0.94
# Date: 6.1.2013
#===============================================================================
#
# Introduction:
#
#   My goal in creating this script was to create a system that allowed the user
#   to set the screen size to something other than 640 x 480, but not have make
#   huge sacrifices in compatibility and performance. Although the script is
#   not simply Plug-and-Play, it is about as close as one can achieve with a
#   script of this nature.
#
# Instructions:
#
#  - Place the "screenshot.dll" from Fantasist's Transition Pack script, which
#    can be found here: http://www.sendspace.com/file/yjd54h in your game folder
#  - Place this script above main, below default scripts.
#  - In my experience, unchecking "Reduce Screen Flickering" actually helps the
#    screen not to flicker. Open menu with F1 while playing and set this to what
#    you get the best results with.
#
# Features:

#  - Totally re-written Tilemap and Plane class. Both classes were written to
#    display the map across any screen size automatically. The Tilemap class
#    is probably even more efficient than the original, which will help offset
#    any increased lag due to using a larger screen size with more sprites
#    being displayed.
#  - Every possible autotile graphic (48 per autotile) will be cached for the
#    next time that tile is used.
#  - Autotile animation has been made as efficient as possible, with a system
#    that stores their coodinates, but only if they change. This greatly reduces
#    the number of iterations at each update.
#  - System creates an external file to save pre-cached data priorities and
#    autotiles. This will decrease any loading times even more, and only takes a
#    second, depending on the number of maps you have.
#  - User defined autotile animation speed. Can change with script calls.
#  - Automatic re-sizing of Bitmaps and Viewports that are 640 x 480 to the
#    defined resolution, unless explicitely over-ridden in the method call.
#    The graphics themselves will not be resized, but any existing scripts that
#    use the normal screen size will already be configured to display different
#    sizes of graphics for transitions, battlebacks, pictures, fogs, etc.
#  - Option to have a log file ouput each time the game is ran, which can alert
#    you to possible errors with map sizes, etc.
#
# Issues/Bugs/Possible Bugs:
#
#   - Graphic related scripts and your graphics will need to be customized to
#     fit the new screen size, so this script is not for everyone.
#   - The Z-axis for the Plane class, which is used for Fogs and Panoramas has
#     been altered. It is now multiplied by 1000. This will likely be a minor
#     issue for most, since this class is very rarely used except for Fogs and
#     Panoramas, which are already far above and below respectfully.
#   - Normal transitions using graphics cannot be used. With the exception of
#     a standard fade, like that used when no graphic is defined will be used.
#     Aside from that, only special transitions from Transition Pack can be
#     used.
#
#  Credits/Thanks:
#    - ForeverZer0, for script.
#    - Creators of the Transition Pack and Screenshot.dll
#    - Selwyn, for base resolution script
#    - KK20, for Version 0.94
#
#===============================================================================
#                             CONFIGURATION
#===============================================================================

  SCREEN = [1024, 576]
  # Define the resolution of the game screen. These values can be anything
  # within reason. Centering, viewports, etc. will all be taken care of, but it
  # is recommended that you use values divisible by 32 for best results.
 
  UPDATE_COUNT = 8
  # Define the number of frames between autotile updates. The lower the number,
  # the faster the animations cycle. This can be changed in-game with the
  # following script call: $game_map.autotile_speed = SPEED
 
  PRE_CACHE_DATA = true
  # The pre-cached file is mandatory for the script to work. As long as this is
  # true, the data will be created each time the game is test-played. This is
  # not always neccessary, only when maps are altered, so you can disable it to
  # help speed up game start-up, and it will use the last created file.
 
  RESOLUTION_LOG = true
  # This will create a log in the Game directory each time the game is ran in
  # DEBUG mode, which will list possible errors with map sizes, etc.
 
#===============================================================================
# ** Resolution
#===============================================================================

class Resolution
 
  attr_reader :version
 
  def initialize
    # Define version.
    @version = 0.93
    # Set instance variables for calling basic Win32 functions.
    ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
    title = "\0" * 256
    ini.call('Game', 'Title', '', title, 256, '.\\Game.ini')
    title.delete!("\0")
    @window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call('RGSS Player', title)
    set_window_long = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
    set_window_pos  = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
    @metrics         = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    # Set default size, displaying error if size is larger than the hardware.
    default_size = self.size
    if default_size[0] < SCREEN[0] || default_size[1] < SCREEN[1]
      print("\"#{title}\" requires a minimum screen resolution of [#{SCREEN[0]} x #{SCREEN[1]}]\r\n\r\n" +
            "\tYour Resolution: [#{default_size[0]} x #{default_size[1]}]")
      exit
    end
    # Apply resolution change.
    x = (@metrics.call(0) - SCREEN[0]) / 2
    y = (@metrics.call(1) - SCREEN[1]) / 2
    set_window_long.call(@window, -16, 0x14CA0000)
    set_window_pos.call(@window, 0, x, y, SCREEN[0] + 6, SCREEN[1] + 26, 0)
    @window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call('RGSS Player', title)
  end
  #--------------------------------------------------------------------------
  def size
    # Returns the screen size of the machine.
    return [@metrics.call(0), @metrics.call(1)]
  end
  #--------------------------------------------------------------------------
  def snapshot(filename = 'Data/snap', quality = 0)
    # FILENAME =   Filename that the picture will be saved as.
    # FILETYPE =   0 = High Quality   1 = Low Quality
    @screen = Win32API.new('screenshot.dll', 'Screenshot', 'LLLLPLL', '')
    @screen.call(0, 0, SCREEN[0], SCREEN[1], filename, @window, quality)
  end
  #--------------------------------------------------------------------------
end

#===============================================================================
# ** Integer
#===============================================================================

class Integer
   
  def gcd(num)
    # Returns the greatest common denominator of self and num.
    min, max = self.abs, num.abs
    while min > 0
      tmp = min
      min = max % min
      max = tmp
    end
    return max
  end
 
  def lcm(num)
    # Returns the lowest common multiple of self and num.
    return [self, num].include?(0) ? 0 : (self / self.gcd(num) * num).abs
  end
end

#===============================================================================
# ** Graphics
#===============================================================================

module Graphics

  class << self
    alias zer0_graphics_transition transition
  end
 
  def self.transition(duration = 8, *args)
    # Call default transition if no instance of the resolution is defined.
    if $resolution == nil
      zer0_graphics_transition(duration, *args)
    else
      # Skip this section and instantly transition graphics if duration is 0.
      if duration > 0
        # Take a snapshot of the the screen, overlaying screen with graphic.
        $resolution.snapshot
        zer0_graphics_transition(0)
        # Create screen instance
        sprite = Sprite.new(Viewport.new(0, 0, SCREEN[0], SCREEN[1]))
        sprite.bitmap = Bitmap.new('Data/snap')
        # Use a simple fade if transition is not defined.
        fade = 255 / duration
        duration.times { sprite.opacity -= fade ; update }
        # Dispose sprite and delete snapshot file.
        [sprite, sprite.bitmap].each {|obj| obj.dispose }
        File.delete('Data/snap')
      end
     zer0_graphics_transition(0)
   end
end
end 

#===============================================================================
# ** RPG::Cache
#===============================================================================

module RPG::Cache
 
  AUTO_INDEX = [
 
  [27,28,33,34],  [5,28,33,34],  [27,6,33,34],  [5,6,33,34],
  [27,28,33,12],  [5,28,33,12],  [27,6,33,12],  [5,6,33,12],
  [27,28,11,34],  [5,28,11,34],  [27,6,11,34],  [5,6,11,34],
  [27,28,11,12],  [5,28,11,12],  [27,6,11,12],  [5,6,11,12],
  [25,26,31,32],  [25,6,31,32],  [25,26,31,12], [25,6,31,12],
  [15,16,21,22],  [15,16,21,12], [15,16,11,22], [15,16,11,12],
  [29,30,35,36],  [29,30,11,36], [5,30,35,36],  [5,30,11,36],
  [39,40,45,46],  [5,40,45,46],  [39,6,45,46],  [5,6,45,46],
  [25,30,31,36],  [15,16,45,46], [13,14,19,20], [13,14,19,12],
  [17,18,23,24],  [17,18,11,24], [41,42,47,48], [5,42,47,48],
  [37,38,43,44],  [37,6,43,44],  [13,18,19,24], [13,14,43,44],
  [37,42,43,48],  [17,18,47,48], [13,18,43,48], [13,18,43,48]
   
  ]
 
  def self.autotile(filename)
    key = "Graphics/Autotiles/#{filename}"
    if !@cache.include?(key) || @cache[key].disposed?
      # Cache the autotile graphic.
      @cache[key] = (filename == '') ? Bitmap.new(128, 96) : Bitmap.new(key)
      # Cache each configuration of this autotile.
      self.format_autotiles(@cache[key], filename)
    end
    return @cache[key]
  end

  def self.format_autotiles(bitmap, filename)
    # Iterate all 48 combinations using the INDEX, and save copy to cache.
    (0...(bitmap.width / 96)).each {|frame|
      # Iterate for each frame in the autotile. (Only for animated ones)
      template = Bitmap.new(256, 192)
      # Create a bitmap to use as a template for creation.
      (0...6).each {|i| (0...8).each {|j| AUTO_INDEX[8*i+j].each {|number|
        number -= 1
        x, y = 16 * (number % 6), 16 * (number / 6)
        rect = Rect.new(x + (frame * 96), y, 16, 16)
        template.blt(32 * j + x % 32, 32 * i + y % 32, bitmap, rect)
      }
      # Use the above created template to create individual tiles.
      index = 8*i+j
      tile = Bitmap.new(32, 32)
      sx, sy = 32 * (index % 8), 32 * (index / 8)
      rect = Rect.new(sx, sy, 32, 32)
      tile.blt(0, 0, template, rect)
      @cache[[filename, index, frame]] = tile
    }}
    # Dispose the template since it will not be used again.
    template.dispose }
  end

  def self.load_autotile(name, tile_id, frame = 0)
    # Returns the autotile for the current map with TILE_ID and FRAME.
    return @cache[[name, tile_id % 48, frame]]
  end
end

#===============================================================================
# ** Tilemap
#===============================================================================

class Tilemap
 
  attr_reader   :map_data, :ox, :oy, :viewport
  attr_accessor :tileset, :autotiles, :priorities
 
  def initialize(viewport)
    # Initialize instance variables to store required data.
    @viewport, @autotiles, @layers, @ox, @oy = viewport, [], [], 0, 0
    # Get priority and autotile data for this tileset from instance of Game_Map.
    @priorities, @animated = $game_map.priorities, $game_map.autotile_data
    # Create a sprite and viewport to use for each priority level.
    (0..5).each {|i|
      @layers[i] = Sprite.new(viewport)
      @layers[i].z = i * 32
    }
  end
   
  def ox=(ox)
    # Set the origin of the X-axis for all the sprites.
    @ox = ox
    @layers.each {|sprite| sprite.ox = @ox }
  end
 
  def oy=(oy)
    # Set the origin of the y-axis for all the sprites.
    @oy = oy
    @layers.each {|sprite| sprite.oy = @oy }
  end
 
  def dispose
    # Dispose all of the sprites and viewports.
    @layers.each {|layer| layer.dispose }
  end
 
  def map_data=(data)
    # Set the map data to an instance variable.
    @map_data = data
    # Clear any sprites' bitmaps if it exists, or create new ones.
    @layers.each_index {|i|
      if @layers[i].bitmap != nil
        # Dispose bitmap and set to nil.
        @layers[i].bitmap = @layers[i].bitmap.dispose
      end
      # Create new bitmap, whose size is the same as the game map.
      @layers[i].bitmap = Bitmap.new($game_map.width*32, $game_map.height*32)
    }
    # Draw bitmaps accordingly.
    refresh
  end
 
  def refresh   
    # Set the animation data from the file if it exists, or create it now.
    @animated = $game_map.autotile_data
    # Iterate through all map layers, starting with the bottom.
    [0,1,2].each {|z| (0...@map_data.ysize).each {|y| (0...@map_data.xsize).each {|x|
      tile_id = @map_data[x, y, z]
      # Go to the next iteration if no bitmap is defined for this tile.
      if tile_id == 0 # No tile
        next
      elsif tile_id < 384 # Autotile
        name = $game_map.autotile_names[(tile_id / 48) - 1]
        bitmap = RPG::Cache.load_autotile(name, tile_id)
      else # Normal Tile
        bitmap = RPG::Cache.tile($game_map.tileset_name, tile_id, 0)
      end
      # Determine what the layer to draw tile, based off priority.
      layer = @priorities[tile_id]
      # Perform a block transfer from the created bitmap to the sprite bitmap.
      @layers[layer].bitmap.blt(x*32, y*32, bitmap, Rect.new(0, 0, 32, 32))
    }}}
  end
 
  def update
    # If made any changes to $game_map.data, the proper graphics will be drawn
    if @map_data.table_changes != nil
      @map_data.table_changes.each{|item|
        x,y,z,tile_id = item
        # Find tile that is going to be replaced
        old_tile_id = @map_data.orig_value.shift
        layer = @priorities[old_tile_id]
        # Clear old tile at this location
        @layers[layer].bitmap.fill_rect(x*32, y*32, 32, 32, Color.new(0,0,0,0))
        # Redraw any tiles below the currently changed layer, if any
        while z > 0
          t_id = @map_data[x,y,z-1]
          layer = @priorities[t_id]
          if t_id == 0 # No tile
            z -= 1
            next
          elsif t_id < 384 # Autotile
            name = $game_map.autotile_names[(t_id / 48) - 1]
            bitmap = RPG::Cache.load_autotile(name, t_id)
          else # Normal Tile
            bitmap = RPG::Cache.tile($game_map.tileset_name, t_id, 0)
          end
          @layers[layer].bitmap.fill_rect(x*32, y*32, 32, 32, Color.new(0,0,0,0))
          @layers[layer].bitmap.blt(x*32, y*32, bitmap, Rect.new(0, 0, 32, 32))
          z -= 1
        end
        # Go to the next iteration if no bitmap is defined for this tile.
        if tile_id == 0 # No tile
          next
        elsif tile_id < 384 # Autotile
          name = $game_map.autotile_names[(tile_id / 48) - 1]
          bitmap = RPG::Cache.load_autotile(name, tile_id)
        else # Normal Tile
          bitmap = RPG::Cache.tile($game_map.tileset_name, tile_id, 0)
        end
        # Determine what the layer to draw tile, based off priority.
        layer = @priorities[tile_id]
        # Perform a block transfer from the created bitmap to the sprite bitmap.
        @layers[layer].bitmap.blt(x*32, y*32, bitmap, Rect.new(0, 0, 32, 32))
      }
      @map_data.table_changes = nil
    end
   
    # Update the sprites.
    if Graphics.frame_count % $game_map.autotile_speed == 0
      # Increase current frame of tile by one, looping by width.
      @animated[0].each_index {|i|
        @animated[2][i] = (@animated[2][i] + 1) % @animated[1][i]
        @animated[3][i].each {|data|
          # Gather data using the stored coordinates from the map data.
          tile_id, x, y = @map_data[data[0], data[1], data[2]], data[0], data[1]
          name, layer = @animated[0][i], @priorities[tile_id]
          # Load the next frame of the autotile and set it to the map.
          bitmap = RPG::Cache.load_autotile(name, tile_id, @animated[2][i])
          @layers[layer].bitmap.fill_rect(x*32, y*32, 32, 32, Color.new(0,0,0,0))
          @layers[layer].bitmap.blt(x*32, y*32, bitmap, Rect.new(0, 0, 32, 32))
        }
      }
    end
  end
 
end

#===============================================================================
# Game_Map
#===============================================================================

class Game_Map
 
  attr_reader :tile_size, :autotile_speed, :autotile_data, :priority_data
 
  alias zer0_load_autotile_data_init initialize
  def initialize
    # Load pre-cached data hashes. They will be referenced during setup.
    file = File.open('Data/PreCacheMapData.rxdata', 'rb')
    @cached_priorities = Marshal.load(file)
    @cached_autotiles = Marshal.load(file)
    file.close
    # Call original method.
    zer0_load_autotile_data_init
    # Store the screen dimensions in tiles to save on calculations later.
    @tile_size = [SCREEN[0], SCREEN[1]].collect {|n| (n / 32.0).ceil }
    @autotile_speed = UPDATE_COUNT
  end
 
  alias zer0_map_edge_setup setup
  def setup(map_id)
    @priority_data = @cached_priorities[map_id]
    @autotile_data = @cached_autotiles[map_id]
    # Call original method.
    zer0_map_edge_setup(map_id)
    # Find the displayed area of the map in tiles. No calcualting every step.
    @map_edge = [self.width - @tile_size[0], self.height - @tile_size[1]]
    @map_edge.collect! {|size| size * 128 }
  end

  def scroll_down(distance)
    # Find point that the map edge meets the screen edge, using custom size.
    @display_y = [@display_y + distance, @map_edge[1]].min
  end

  def scroll_right(distance)
    # Find point that the map edge meets the screen edge, using custom size.
    @display_x = [@display_x + distance, @map_edge[0]].min
  end
 
  def autotile_speed=(speed)
    # Keep the speed above 0 to prevent the ZeroDivision Error.
    @autotile_speed = speed
    @autotile_speed = 1 if @autotile_speed < 1
  end
 
  alias get_map_data data
  def data
    # For the Tilemap class to recognize that tile graphics need changing
    @map.data.make_changes = true
    get_map_data
  end
 
end

#===============================================================================
# ** Game_Character
#===============================================================================

class Game_Character
 
  def screen_z(height = 0)
    if @always_on_top
      # Return high Z value if always on top flag is present.
      return 999
    elsif height != nil && height > 32
      # Iterate through map characters to their positions relative to this one.
      characters = $game_map.events.values
      characters += [$game_player] unless self.is_a?(Game_Player)
      # Find and set any character that is one tile above this one.
      above, z = characters.find {|chr| chr.x == @x && chr.y == @y - 1 }, 0
      if above != nil
        # If found, adjust value by this one's Z, and the other's.
        z = (above.screen_z(48) >= 32 ? 33 : 31)
      end
      # Check for Blizz-ABS and adjust coordinates for the pixel-rate.
        if $BlizzABS && $game_system.pixel_rate > 0
        x = ((@x / $game_system.pixel_rate) / 2.0).to_i
        y = ((@y / $game_system.pixel_rate) / 2.0).to_i
        return $game_map.priority_data[x, y] + z

      end
    end
    return 0
  end
end

#===============================================================================
# ** Game_Player
#===============================================================================

class Game_Player
 
  CENTER_X = ((SCREEN[0] / 2) - 16) * 4    # Center screen x-coordinate * 4
  CENTER_Y = ((SCREEN[1] / 2) - 16) * 4    # Center screen y-coordinate * 4
 
  def center(x, y)
    # Recalculate the screen center based on the new resolution.
    max_x = ($game_map.width - $game_map.tile_size[0]) * 128
    max_y = ($game_map.height - $game_map.tile_size[1]) * 128
    $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
    $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
  end 
end

#===============================================================================
# ** Sprite
#===============================================================================

class Sprite
 
  alias zer0_sprite_resize_init initialize
  def initialize(view = nil)
    # Unless viewport is defined, use the new default viewport size.
    view = Viewport.new(0, 0, SCREEN[0], SCREEN[1]) if view == nil
    # Call original method.
    zer0_sprite_resize_init(view)
  end
end

#===============================================================================
# ** Viewport
#===============================================================================

class Viewport
 
  alias zer0_viewport_resize_init initialize
  def initialize(x=0, y=0, width=SCREEN[0], height=SCREEN[1], override=false)
    if x.is_a?(Rect)
      # If first argument is a Rectangle, just use it as the argument.
      zer0_viewport_resize_init(x)
    elsif [x, y, width, height] == [0, 0, 640, 480] && !override
      # Resize fullscreen viewport, unless explicitly overridden.
      zer0_viewport_resize_init(Rect.new(0, 0, SCREEN[0], SCREEN[1]))
    else
      # Call method normally.
      zer0_viewport_resize_init(Rect.new(x, y, width, height))
    end
  end
 
  def resize(*args)
    # Resize the viewport. Can call with (X, Y, WIDTH, HEIGHT) or (RECT).
    self.rect = args[0].is_a?(Rect) ? args[0] : Rect.new(*args)
  end
end

#===============================================================================
# ** Bitmap
#===============================================================================

class Bitmap
 
  alias zer0_resolution_resize_init initialize
  def initialize(width = 32, height = 32, override = false)
    if width.is_a?(String)
      # Call the filename if the first argument is a String.
      zer0_resolution_resize_init(width)
    elsif [width, height] == [640, 480] && !override
      # Resize fullscreen bitmap unless explicitly overridden.
      zer0_resolution_resize_init(SCREEN[0], SCREEN[1])
    else
      # Call method normally.
      zer0_resolution_resize_init(width, height)
    end
  end
end

#===============================================================================
# ** Plane
#===============================================================================

Object.send(:remove_const, :Plane)
class Plane < Sprite
 
  def z=(z)
    # Change the Z value of the viewport, not the sprite.
    super(z * 1000)
  end
 
  def ox=(ox)
    return if @bitmap == nil
    # Have viewport stay in loop on X-axis.
    super(ox % @bitmap.width)
  end
 
  def oy=(oy)
    return if @bitmap == nil
    # Have viewport stay in loop on Y-axis.
    super(oy % @bitmap.height)
  end
 
  def bitmap
    # Return the single bitmap, before it was tiled.
    return @bitmap
  end
 
  def bitmap=(tile)
    @bitmap = tile
    # Bug fix for changing panoramas
    return if tile.nil?
    # Calculate the number of tiles it takes to span screen in both directions.
    xx = 1 + (SCREEN[0].to_f / tile.width).ceil
    yy = 1 + (SCREEN[1].to_f / tile.height).ceil
    # Create appropriately sized bitmap, then tile across it with source image.
    plane = Bitmap.new(@bitmap.width * xx, @bitmap.height * yy)
    (0..xx).each {|x| (0..yy).each {|y|
      plane.blt(x * @bitmap.width, y * @bitmap.height, @bitmap, @bitmap.rect)
    }}
    # Set the bitmap to the sprite through its super class (Sprite).
    super(plane)
  end
 
  # Redefine methods dealing with coordinates (defined in super) to do nothing.
  def x; end
  def y; end
  def x=(x); end
  def y=(y); end
end

#===============================================================================
# Table
#===============================================================================
class Table
  attr_accessor :make_changes, :table_changes, :orig_value
 
  alias set_method []=
  def []=(x,y=nil,z=nil,v=nil)
    # If making changes to game_map.data
    if @make_changes
      @table_changes = [] if @table_changes.nil?
      @table_changes.push([x,y,z,v])
      @orig_value = [] if @orig_value.nil?
      @orig_value.push(self[x,y,z])
      @make_changes = false
    end
    # Call original method
    if z == nil
      set_method(x,y)
    elsif v == nil
      set_method(x,y,z)
    else
      set_method(x,y,z,v)
    end
  end
end
#===============================================================================
# DEBUG Mode
#===============================================================================

if $DEBUG #if running in debug/testplay mode
  if PRE_CACHE_DATA # If precache configuration is true
    # load all tilesets in database
    tilesets = load_data('Data/Tilesets.rxdata')
    # maps = mapinfos, priority_data and autotile_data are empty hashes
    maps, priority_data, autotile_data = load_data('Data/MapInfos.rxdata'), {}, {}
    # For each map ID
    maps.each_key {|map_id|
      # load map file
      map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
      # map data is loaded (3D-Table)
      data = map.data
      # get the map's tileset
      tileset = tilesets[map.tileset_id]
      # get tileset's priorities (*0 to *5)
      priorities = tileset.priorities
      # get autotiles that tileset uses and load their bitmaps, storing them in cache
      autotiles = tileset.autotile_names.collect {|name| RPG::Cache.autotile(name) }
      animated = [[], [], [], []]
      # for each autotile in array by index (0 to number of autotiles)
      autotiles.each_index {|i|
        width = autotiles[i].width
        # go to next autotile if width is 96 or less (non-animating)
        next unless width > 96
        # [name of autotile, frames of animation, 0, empty array]
        parameters = [tileset.autotile_names[i], width / 96, 0, []]
        # now store these values into variable 'animated'
        [0, 1, 2, 3].each {|j| animated[j].push(parameters[j]) }
      }
      # for each z-index, for each y-coordinate, for each x-coordinate
      [0, 1, 2].each {|z| (0...data.ysize).each {|y| (0...data.xsize).each {|x|
        # get tile_id at (x,y,z)
        tile_id = data[x, y, z]
        # ignore if tile is blank square (top left on tileset)
        next if tile_id == 0
        # if autotile
        if tile_id < 384
          # get autotile name that this tile belongs to
          name = tileset.autotile_names[(tile_id / 48) - 1]
          # find this autotile's array index in 'animated'
          index = animated[0].index(name)
          # skip if not an animated autotile
          next if index == nil
      #---------------------------------------------------------------------
      # Most of the following below has been removed due to graphical errors
      #---------------------------------------------------------------------
   #       above = []
          # Check layers above current z-layer, pushing tile_ids if they exist
   #       ((z+1)...data.zsize).each {|zz| above.push(data[x, y, zz]) }
          # if all the above tile IDs are blank squares, then store this tile ID
          animated[3][index].push([x, y, z]) #if above.all? {|id| id == 0 }
        end
      }}}
      # make a new table that is as tall and as wide as the map's size
      table = Table.new(data.xsize, data.ysize)
      # run through each square on this grid top to bottom, left to right
      (0...table.xsize).each {|x| (0...table.ysize).each {|y|
      # get tile IDs one space north of current tile on all layers (e.g. trees)
        above = [0, 1, 2].collect {|z| data[x, y-1, z] }
        # get priorities of tile IDs we collected, replacing values in 'above'
        above = above.compact.collect {|p| priorities[p] }
        # if any of the priorities collected is 1, then our current spot (x,y)
        # is equal to 32. Else, 0.
        table[x, y] = above.include?(1) ? 32 : 0
      }}
      priority_data[map_id], autotile_data[map_id] = table, animated
      # If project has a lot of maps, this will ensure you will not get a
      # 'Script is hanging' error when caching
      Graphics.update
    }
    file = File.open('Data/PreCacheMapData.rxdata', 'wb')
    Marshal.dump(priority_data, file)
    Marshal.dump(autotile_data, file)
    file.close
    RPG::Cache.clear
  end
 
  if RESOLUTION_LOG
    undersize, mapinfo = [], load_data('Data/MapInfos.rxdata')
    file = File.open('Data/PreCacheMapData.rxdata', 'rb')
    cached_data = Marshal.load(file)
    file.close
    # Create a text file and write the header.
    file = File.open('Resolution Log.txt', 'wb')
    file.write("[RESOLUTION LOG]\r\n\r\n")
    time = Time.now.strftime("%x at %I:%M:%S %p")
    file.write("  Logged on #{time}\r\n\r\n")
    lcm = SCREEN[0].lcm(SCREEN[1]).to_f
    aspect = [(lcm / SCREEN[1]), (lcm / SCREEN[0])].collect {|num| num.round }
    file.write("RESOLUTION:\r\n  #{SCREEN[0].to_i} x #{SCREEN[1].to_i}\r\n")
    file.write("ASPECT RATIO:\r\n  #{aspect[0]}:#{aspect[1]}\r\n")
    file.write("MINIMUM MAP SIZE:\r\n  #{(SCREEN[0] / 32).ceil} x #{(SCREEN[1] / 32).ceil}\r\n\r\n")
    file.write("UNDERSIZED MAPS:\r\n")
    mapinfo.keys.each {|key|
      map = load_data(sprintf("Data/Map%03d.rxdata", key))
      next if map.width*32 >= SCREEN[0] && map.height*32 >= SCREEN[1]
      undersize.push(key)
    }
    unless undersize.empty?
      file.write("The following maps are too small for the defined resolution. They should be adjusted to prevent graphical errors.\r\n\r\n")
      undersize.sort.each {|id| file.write("    MAP[#{id}]:  #{mapinfo[id].name}\r\n") }
      file.write("\r\n")
    else
      file.write('    All maps are sized correctly.')
    end
    file.close
  end
end

# Call the resolution, setting it to a global variable for plug-ins.
$resolution = Resolution.new


The problem is that it does not update/dispose properly my Z-Hud. When I open the menu the Z-Hud dissapear (as it should) but then when I close the menu it wont display the hud back. I am guessing that it isn't very much to modify in the script, but I have no clue where to start.

If this is helpful...I've tried another custom resoultion script: http://pastebin.com/rWLhY7wg . This one seems to dispose/update the Z-hud properly but it has lower framerate.

Thanks in advance!
4
Script Requests / Blizz-Abs Little Add-on
July 28, 2013, 03:41:06 pm
 Hello!
I've tried to make some changes in the Blizz-Abs Script to display the map name above the Blizz-Abs Minimap...but I failed. I'm thinking of a script that allows me to see the map name only when the player choose that the minimap is displayed. I've put a picture to make me more easy to understand :
Spoiler: ShowHide

I would appreciate if someone could help me with this.
5
 Can someone make the default poses (idle,run,atack,jump) for this character? Kind of much to ask for I understand any help would be appreciated.
6
Script Troubleshooting / [Blizz-Abs] Combo Help
August 21, 2012, 10:17:56 am
 Is it possible to make a combo which trigger after you hit the target 3 times (or another number of times)
I'm still trying to figure out how combos works...
7
Recruitment / Looking for mapper/eventer!
August 27, 2011, 01:40:41 pm
   Hello! I'm looking for a man who can do mapping and eventing for my new project (STARTING FROM ALMOST SCRATCH), named "Warrior Fable". By the way english it's not my main language.... :^_^':


  ---STORY---


  The story involves a boy who woke up in a world changed by the dark magician named "Wizir", a world known as quiet and monotonous, it's now corrupted and dangerous. He will try to establish the peace in his world trying to destroy the dark magic forever. Among many adventures and quests he succeeded to save his world.
Pretty simple...


---FEATURES---


  The game will feature:
  - Blizz-ABS (battle system) 8)
  - UMS (message system)
  - Many Blizz-ABS addons
  - Quest Book (with many sidequests)
  - Many monsters
  - Tons of Addons
  - Custom Menu
___________________________________________________________________________


  I need a man for mapping/eventing. In return you may add your own ideas to the game. 

  If you're interested with this game project, please reply.

  Thanks.


  ---SPECIAL THANKS---

  Special thanks to the people who made the following scripts that I'm using for the game:

  - Blizzard
  - game_guy
  - Zeriab
  - Landith
  - Winkio
  - LiTTleDRAgo
  - TerreAqua
  - CCoa
  - Nathmatt
  - ForeverZer0
  - Fantasist, NAMKCOR, Zan
  - I hope I did not forget anyone