Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
joman195

Multiple Message Window won't work.

Question

I am using this script:

#==============================================================================
# ** Multiple Message Windows (SDK)
#------------------------------------------------------------------------------
# Wachunga
# 1.5
# 2006-11-17
#==============================================================================

=begin

 This custom message system adds numerous features on top of the default
 message system, the most notable being the ability to have multiple message
 windows open at once. The included features are mostly themed around turning
 messages into speech (and thought) balloons, but default-style messages are
 of course still possible.

 Note:
 This version of the script uses the SDK, available from:
 http://www.rmxp.org/forums/showthread.php?t=1802

 FEATURES

 New in 1.5:
 * \C[#ffffff] for hexadecimal color
 * \C for return to default color
 * display name of item, weapon, armor or skill
   * \N[in] = display name of item with id n (note the "I")
   * \N[Wn] = display name of weapon with id n (note the "W")
   * \N[An] = display name of armor with id n (note the "A")
   * \N[sn] = display name of skill with id n (note the "S")
 * display icon of item, weapon, armor or skill
   * \I[in] = display icon of item with id n (note the "I")
   * \I[Wn] = display icon of weapon with id n (note the "W")
   * \I[An] = display icon of armor with id n (note the "A")
   * \I[sn] = display icon of skill with id n (note the "S")
 * display icon and name of item, weapon, armor or skill
   * \I&N[in] = display icon and name of item with id n (note the "I")
   * \I&N[Wn] = display icon and name of weapon with id n (note the "W")
   * \I&N[An] = display icon and name of armor with id n (note the "A")
   * \I&N[sn] = display icon and name of skill with id n (note the "S")
 * new windowskins available
 * speech windowskin now definable separately from default windowskin
 * fixed bold bug where degree sign would occasionally appear
 * input number window now shares parent window's font
 * changed \Var[n] back to default of \V[n]

 New in 1.1:
 * message.autocenter for automatically centering text within messages
 * \N[en] for displaying name of enemy with id n (note the "e")
 * \MAP for displaying the name of the current map

 At a glance:
 * multiple message windows
 * speech balloons
   * position over player/event (follows movement and scrolling)
   * optional message tail (for speech or thought balloons)
   * can specify location relative to player/event (up, down, left, right)
 * thought balloons
   * can use different windowskin, message tail and font color
 * letter-by-letter mode
   * variable speed (and delays)
   * skippable on button press
 * autoresize messages
 * player movement allowed during messages
   * if speaker moves offscreen, message closes (like ChronoTrigger)
 * everything also works during battle
 * settings configurable at anytime  

 Full list of options:

 (Note that all are case *insensitive*.)

 =============================================================================
  Local (specified in message itself and resets at message end)
 =============================================================================
 - \L = letter-by-letter mode toggle
 - \S[n] = set speed at which text appears in letter-by-letter mode
 - \D[n] = set delay (in frames) before next text appears
 - \P[n] = position message over event with id n
           * use n=0 for player
           * in battle, use n=a,b,c,d for actors (e.g. \P[a] for first actor)
             and n=1,...,n for enemies (e.g. \P[1] for first enemy)
             where order is actually the reverse of troop order (in database)
 - \P = position message over current event (default for floating messages)
 - \^ = message appears directly over its event
 - \v = message appears directly below its event
 - \< = message appears directly to the left of its event
 - \> = message appears directly to the right of its event
 - \B = bold text
 - \I = italic text
 - \C[#xxxxxx] = change to color specified by hexadecimal (eg. ffffff = white)
 - \C = change color back to default
 - \! = message autoclose
 - \? = wait for user input before continuing
 - \+ = make message appear at same time as preceding one
        * note: must be at the start of message to work
 - \@ = thought balloon
 - \N[En] = display name of enemy with id n (note the "E")
 - \N[in] = display name of item with id n (note the "I")
 - \N[Wn] = display name of weapon with id n (note the "W")
 - \N[An] = display name of armor with id n (note the "A")
 - \N[sn] = display name of skill with id n (note the "S")
 - \I[in] = display icon of item with id n (note the "I")
 - \I[Wn] = display icon of weapon with id n (note the "W")
 - \I[An] = display icon of armor with id n (note the "A")
 - \I[sn] = display icon of skill with id n (note the "S")
 - \I&N[in] = display icon and name of item with id n (note the "I")
 - \I&N[Wn] = display icon and name of weapon with id n (note the "W")
 - \I&N[An] = display icon and name of armor with id n (note the "A")
 - \I&N[sn] = display icon and name of skill with id n (note the "S")
 - \MAP = display the name of the current map

 These are, of course, in addition to the default options:
 - \V[n] = display value of variable n
 - \N[n] = display name of actor with id n
 - \C[n] = change color to n
 - \G = display gold window
 - \\ = show the '\' character

 =============================================================================
  Global (specified below or by Call Script and persist until changed)
 =============================================================================
 Miscellaneous:
 - message.move_during = true/false
   * allow/disallow player to move during messages
 - message.show_pause = true/false
   * show/hide "waiting for player" pause graphic
 - message.autocenter = true/false
   * enable/disable automatically centering text within messages

 Speech/thought balloon related:
 - message.resize = true/false
   * enable/disable automatic resizing of messages (only as big as necessary)
 - message.floating = true/false
   * enable/disable positioning messages above current event by default
     (i.e. equivalent to including \P in every message)
 - message.location = TOP, BOTTOM, LEFT or RIGHT
   * set default location for floating messages relative to their event
 - message.show_tail = true/false
   * show/hide message tail for speech/thought balloons

 Letter-by-letter related:
 - message.letter_by_letter = true/false
   * enable/disable letter-by-letter mode (globally)
 - message.text_speed = 0-20
   * set speed at which text appears in letter-by-letter mode (globally)
 - message.skippable = true/false
   * allow/disallow player to skip to end of message with button press

 Font:
 - message.font_name = font
   * set font to use for text, overriding all defaults
     (font can be any TrueType from Windows/Fonts folder)
 - message.font_size = size
   * set size of text  (default 22), overriding all defaults
 - message.font_color = color
   * set color of text, overriding all defaults
   * you can use same 0-7 as for \C[n] or "#xxxxxx" for hexadecimal

 Note that the default thought and shout balloon windowskins don't
 stretch to four lines very well (unfortunately).

 Thanks:
 XRXS code for self-close and wait for input
 Slipknot for a convenient approach to altering settings in-game
 SephirothSpawn for bitmap rotate method

=end

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Multiple Message Windows', 'Wachunga', 1.5, '2006-11-17')

#------------------------------------------------------------------------------
# * Begin SDK Enabled Check
#------------------------------------------------------------------------------
if SDK.state('Multiple Message Windows') == true

#==============================================================================
# Settings
#==============================================================================

 #----------------------------------------------------------------------------
 # Windowskins
 #----------------------------------------------------------------------------
 # Note: all files must be in the Graphics/Windowskins/ folder
 # Tip: tails don't look right on windowskins with gradient backgrounds

 # filenames of tail and windowskin used for speech balloons
 FILENAME_SPEECH_TAIL = "white-tail_speech.png"
 FILENAME_SPEECH_WINDOWSKIN = "white-windowskin_speech.png"

 # filenames of tail and windowskin used for thought balloons
 FILENAME_THOUGHT_TAIL = "white-tail_thought.png"
 FILENAME_THOUGHT_WINDOWSKIN = "white-windowskin_thought.png" 

 #----------------------------------------------------------------------------
 # Fonts
 #----------------------------------------------------------------------------
 # Note: if floating or resize (i.e. "speech balloons") are disabled,
 # Font.default_name, Font.default_size and Font.default_color are used
 # (you can change these in Main)
 # During gameplay, you can use message.font_name etc to override all defaults

 # defaults for speech text
 SPEECH_FONT_COLOR = "#000000"
 SPEECH_FONT_NAME = "Komika Slim"
 SPEECH_FONT_SIZE = 20

 # defaults for thought text
 THOUGHT_FONT_COLOR = "#000000"
 THOUGHT_FONT_NAME = "Komika Slick"
 THOUGHT_FONT_SIZE = 20

 # note that you can use an array of fonts for SPEECH_FONT_NAME, etc.
 # e.g. ['Komika Slim', 'Arial']
 # (if Verdana is not available, MS PGothic will be used instead)

 #----------------------------------------------------------------------------
 # Misc
 #----------------------------------------------------------------------------
 # If using a specialty windowskin (e.g. the default thought balloon one),
 # you can force the window width to always be a multiple of the number
 # specified in this constant (even when using the resize feature).
 # This allows, for example, the windowskin frame to be designed to
 # repeat every 16 pixels so that the frame never looks cut off.
 THOUGHT_WIDTH_MULTIPLE = 16
 # (set to 0 if you're not using any such windowskins)

class Game_Message

 # Any of the below can be changed by a Call Script event during gameplay.
 # E.g. turn letter-by-letter mode off with: message.letter_by_letter = false

 attr_accessor :move_during
 attr_accessor :letter_by_letter
 attr_accessor :text_speed
 attr_accessor :skippable
 attr_accessor :resize
 attr_accessor :floating
 attr_accessor :autocenter
 attr_accessor :show_tail
 attr_accessor :show_pause
 attr_accessor :location
 attr_accessor :font_name
 attr_accessor :font_size
 attr_accessor :font_color

 def initialize
   # whether or not messages appear one letter at a time
   @letter_by_letter = true
   # note: can also change within a single message with \L

   # the default speed at which text appears in letter-by-letter mode
   @text_speed = 1
   # note: can also change within a single message with \S[n]

   # whether or not players can skip to the end of (letter-by-letter) messages
   @skippable = true

   # whether or not messages are automatically resized based on the message
   @resize = true

   # whether or not message windows are positioned above
   # characters/events by default, i.e. without needing \P every message
   # (only works if resize messages enabled -- otherwise would look very odd)
   @floating = true

   # whether or not to automatically center lines within the message
   @autocenter = true

   # whether or not event-positioned messages have a tail(for speech balloons)
   # (only works if floating and resized messages enabled -- otherwise would
   # look very odd indeed)
   @show_tail = true

   # whether or not to display "waiting for user input" pause graphic 
   # (probably want this disabled for speech balloons)
   @show_pause = false

   # whether the player is permitted to move while messages are displayed
   @move_during = true

   # the default location for floating messages (relative to the event)
   # note that an off-screen message will be "flipped" automatically
   @location = TOP

   # font details
   # overrides all defaults; leave nil to just use defaults (e.g. as above)
   @font_name = nil
   @font_size = nil
   @font_color = nil
 end
end

#==============================================================================
# Private constants (don't edit)
#==============================================================================

 # used for message.location
 TOP = 8
 BOTTOM = 2
 LEFT = 4
 RIGHT = 6

#------------------------------------------------------------------------------

class Window_Message < Window_Selectable

 def initialize(msgindex) 
   super(80, 304, 480, 160)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.visible = false
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   self.z = 9000 + msgindex * 5 # permits messages to overlap legibly
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   @fade_in = false
   @fade_out = false
   @contents_showing = false
   @cursor_width = 0
   self.active = false
   self.index = -1
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   @msgindex = msgindex
   @tail = Sprite.new
   @tail.bitmap =
     if @msgindex == 0
       RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
     else
       # don't use cached version or else all tails
       # are rotated when multiple are visible at once
       Bitmap.new("Graphics/Windowskins/"+FILENAME_SPEECH_TAIL)
     end
   # keep track of orientation of tail bitmap
   if @tail.bitmap.orientation == nil
     @tail.bitmap.orientation = 0
   end
   # make origin the center, not top left corner
   @tail.ox = @tail.bitmap.width/2
   @tail.oy = @tail.bitmap.height/2
   @tail.z = 9999
   @tail.visible = false
   if $game_system.message.floating and $game_system.message.resize
     @windowskin = FILENAME_SPEECH_WINDOWSKIN
   else
     # use windowskin specified in database
     @windowskin = $game_system.windowskin_name
   end
   if $game_system.message.floating and $game_system.message.resize
     # if used as speech balloons, use constants
     @font_name = SPEECH_FONT_NAME
     @font_color = check_color(SPEECH_FONT_COLOR)
     @font_size = SPEECH_FONT_SIZE
   else
     # use defaults
     @font_name = Font.default_name
     @font_color = Font.default_color
     @font_size = Font.default_size
   end
   # override defaults if necessary
   if $game_system.message.font_name != nil
     @font_name = $game_system.message.font_name
   end
   if $game_system.message.font_color != nil
     @font_color = check_color($game_system.message.font_color)
   end
   if $game_system.message.font_size != nil
     @font_size = $game_system.message.font_size
   end
   @update_text = true
   @letter_by_letter = $game_system.message.letter_by_letter
   @text_speed = $game_system.message.text_speed
   # id of character for speech balloons
   @float_id = nil
   # location of box relative to speaker
   @location = $game_system.message.location
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
 end

 def dispose
   terminate_message
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # have to check all windows before claiming that no window is showing
   if $game_temp.message_text.compact.empty?
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
     $game_temp.message_window_showing = false
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   if @input_number_window != nil
     @input_number_window.dispose
   end
   super
 end

 def terminate_message
   self.active = false
   self.pause = false
   self.index = -1
   self.contents.clear
   # Clear showing flag
   @contents_showing = false

   # Clear variables related to text, choices, and number input
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   @tail.visible = false
   # note that these variables are now indexed arrays
   $game_temp.message_text[@msgindex] = nil
   # Call message callback
   if $game_temp.message_proc[@msgindex] != nil
     # make sure no message boxes are displaying
     if $game_temp.message_text.compact.empty?
       $game_temp.message_proc[@msgindex].call
     end
     $game_temp.message_proc[@msgindex] = nil
   end
   @update_text = true
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   $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
   # Open gold window
   if @gold_window != nil
     @gold_window.dispose
     @gold_window = nil
   end
 end

 def refresh
   self.contents.clear
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   @x = @y = 0 # now instance variables
   @float_id = nil
   @location = $game_system.message.location
   if $game_system.message.floating and $game_system.message.resize
     @windowskin = FILENAME_SPEECH_WINDOWSKIN
   else
     # use windowskin specified in database
     @windowskin = $game_system.windowskin_name
   end
   if $game_system.message.floating and $game_system.message.resize
     # if used as speech balloons, use constants
     @font_name = SPEECH_FONT_NAME
     @font_color = check_color(SPEECH_FONT_COLOR)
     @font_size = SPEECH_FONT_SIZE
   else
     # use default font
     @font_name = Font.default_name
     @font_color = Font.default_color
     @font_size = Font.default_size
   end
   # override font defaults
   if $game_system.message.font_name != nil
     @font_name = $game_system.message.font_name
   end
   if $game_system.message.font_color != nil
     @font_color = check_color($game_system.message.font_color)
   end
   if $game_system.message.font_size != nil
     @font_size = $game_system.message.font_size
   end
   @line_widths = nil
   @wait_for_input = false
   @tail.bitmap =
     if @msgindex == 0
       RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
     else
       Bitmap.new("Graphics/Windowskins/"+FILENAME_SPEECH_TAIL)
     end
   RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
   @tail.bitmap.orientation = 0 if @tail.bitmap.orientation == nil
   @text_speed = $game_system.message.text_speed
   @letter_by_letter = $game_system.message.letter_by_letter
   @delay = @text_speed
   @player_skip = false
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   @cursor_width = 0
   # Indent if choice
   if $game_temp.choice_start == 0
     @x = 8
   end
   # If waiting for a message to be displayed
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   if $game_temp.message_text[@msgindex] != nil
     @text = $game_temp.message_text[@msgindex] # now an instance variable
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
     # 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 : ""
     end
     # Change "\\\\" to "\000" for convenience
     @text.gsub!(/\\\\/) { "\000" }
     @text.gsub!(/\\[Gg]/) { "\002" }
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
     # display icon of item, weapon, armor or skill
     @text.gsub!(/\\[ii]\[([iiWwAaSs][0-9]+)\]/) { "\013[#{$1}]" }
     # display name of enemy, item, weapon, armor or skill
     @text.gsub!(/\\[Nn]\[([EeIiWwAaSs])([0-9]+)\]/) do
       case $1.downcase
         when "e"
           entity = $data_enemies[$2.to_i]
         when "i"
           entity = $data_items[$2.to_i]
         when "w"
           entity = $data_weapons[$2.to_i]
         when "a"
           entity = $data_armors[$2.to_i]
         when "s"
           entity = $data_skills[$2.to_i]
       end
       entity != nil ? entity.name : ""
     end
     # display icon and name of item, weapon, armor or skill
     @text.gsub!(/\\[ii]&[Nn]\[([iiWwAaSs])([0-9]+)\]/) do
       case $1.downcase
         when "e"
           entity = $data_enemies[$2.to_i]
         when "i"
           entity = $data_items[$2.to_i]
         when "w"
           entity = $data_weapons[$2.to_i]
         when "a"
           entity = $data_armors[$2.to_i]
         when "s"
           entity = $data_skills[$2.to_i]
       end
       entity != nil ? "\013[#{$1+$2}] " + entity.name : ""
     end      
     # display name of current map
     @text.gsub!(/\\[Mm][Aa][Pp]/) { $game_map.name }
     # change font color
     @text.gsub!(/\\[Cc]\[([0-9]+|#[0-9A-Fa-f]{6,6})\]/) { "\001[#{$1}]" }
     # return to default color
     @text.gsub!(/\\[Cc]/) { "\001" }
     # toggle letter-by-letter mode
     @text.gsub!(/\\[Ll]/) { "\003" }
     # change text speed (for letter-by-letter)
     @text.gsub!(/\\[ss]\[([0-9]+)\]/) { "\004[#{$1}]" }
     # insert delay
     @text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\005[#{$1}]" }
     # self close message
     @text.gsub!(/\\[!]/) { "\006" }
     # wait for button input
     @text.gsub!(/\\[?]/) { "\007" }
     # bold
     @text.gsub!(/\\[bb]/) { "\010" }
     # italic
     @text.gsub!(/\\[ii]/) { "\011" }
     # thought balloon
     if @text.gsub!(/\\[@]/, "") != nil
       @windowskin = FILENAME_THOUGHT_WINDOWSKIN
       @font_name = THOUGHT_FONT_NAME
       @font_size = THOUGHT_FONT_SIZE
       @font_color = check_color(THOUGHT_FONT_COLOR)
       @tail.bitmap = 
         if @msgindex == 0
           RPG::Cache.windowskin(FILENAME_THOUGHT_TAIL)
         else
           Bitmap.new("Graphics/Windowskins/"+FILENAME_THOUGHT_TAIL)
         end
       @tail.bitmap.orientation = 0 if @tail.bitmap.orientation == nil
     end
     # Get rid of "\\+" (multiple messages)
     @text.gsub!(/\\[+]/, "")
     # Get rid of "\\^", "\\v", "\\<", "\\>" (relative message location)
     if @text.gsub!(/\\\^/, "") != nil
       @location = 8
     elsif @text.gsub!(/\\[Vv]/, "") != nil
       @location = 2
     elsif @text.gsub!(/\\[<]/, "") != nil
       @location = 4
     elsif @text.gsub!(/\\[>]/, "") != nil
       @location = 6
     end
     # Get rid of "\\P" (position window to given character)
     if @text.gsub!(/\\[Pp]\[([0-9]+)\]/, "") != nil
       @float_id = $1.to_i
     elsif @text.gsub!(/\\[Pp]\[([a-zA-Z])\]/, "") != nil and
         $game_temp.in_battle
       @float_id = $1.downcase
     elsif @text.gsub!(/\\[Pp]/, "") != nil or
       ($game_system.message.floating and $game_system.message.resize) and
       !$game_temp.in_battle
       @float_id = $game_system.map_interpreter.event_id
     end
     if $game_system.message.resize or $game_system.message.autocenter
       # calculate length of lines
       text = @text.clone
       temp_bitmap = Bitmap.new(1,1)
       temp_bitmap.font.name = @font_name
       temp_bitmap.font.size = @font_size
       @line_widths = [0,0,0,0]
       for i in 0..3
         line = text.split(/\n/)[3-i]
         if line == nil
           next
         end
         line.gsub!(/[\001-\007](\[[#A-Fa-f0-9]+\])?/, "")
         line.gsub!(/\013\[[iiWwAaSs][0-9]+\]/, "\013")
         line.chomp.split(//).each do |c|
           case c
             when "\000"
               c = "\\"
             when "\010"
               # bold
               temp_bitmap.font.bold = !temp_bitmap.font.bold
               next
             when "\011"
               # italics
               temp_bitmap.font.italic = !temp_bitmap.font.italic
               next
             when "\013"
               # icon
               @line_widths[3-i] += 24
               next
           end
           @line_widths[3-i] += temp_bitmap.text_size(c).width
         end
         if (3-i) >= $game_temp.choice_start
           # account for indenting
           @line_widths[3-i] += 8 unless $game_system.message.autocenter
         end
       end
       if $game_temp.num_input_variable_id > 0
         # determine cursor_width as in Window_InputNumber
         # (can't get from @input_number_window because it doesn't exist yet)
         cursor_width = temp_bitmap.text_size("0").width + 8
         # use this width to calculate line width (+8 for indent)
         input_number_width = cursor_width*$game_temp.num_input_digits_max
         input_number_width += 8 unless $game_system.message.autocenter
         @line_widths[$game_temp.num_input_start] = input_number_width
       end
       temp_bitmap.dispose
     end
     resize
     reposition if @float_id != nil
     self.contents.font.name = @font_name
     self.contents.font.size = @font_size
     self.contents.font.color = @font_color
     self.windowskin = RPG::Cache.windowskin(@windowskin)
     # autocenter first line if enabled
     # (subsequent lines are done as "\n" is encountered)
     if $game_system.message.autocenter and @text != ""
       @x = (self.width-40)/2 - @line_widths[0]/2
     end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   end
 end

 #--------------------------------------------------------------------------
 # * Resize Window
 #-------------------------------------------------------------------------- 
 def resize
   if !$game_system.message.resize
     # reset to defaults
     self.width = 480
     self.height = 160
     self.contents = Bitmap.new(width - 32, height - 32)
     self.x = 80 # undo any centering
     return
   end
   max_x = @line_widths.max
   max_y = 4
   @line_widths.each do |line|
     max_y -= 1 if line == 0 and max_y > 1
   end
   if $game_temp.choice_max  > 0
     # account for indenting
     max_x += 8 unless $game_system.message.autocenter
   end
   new_width = max_x + 40
   if @windowskin == FILENAME_THOUGHT_WINDOWSKIN and THOUGHT_WIDTH_MULTIPLE >0
     # force window width to be a multiple of THOUGHT_WIDTH_MULTIPLE
     # so that specialty windowskins (e.g. thought balloon) look right
     if new_width % THOUGHT_WIDTH_MULTIPLE != 0
       new_width += THOUGHT_WIDTH_MULTIPLE-(new_width%THOUGHT_WIDTH_MULTIPLE)
     end
   end
   self.width = new_width
   self.height = max_y * 32 + 32
   self.contents = Bitmap.new(width - 32, height - 32)
   self.x = 320 - (self.width/2) # center
 end

 #--------------------------------------------------------------------------
 # * Reposition Window
 #-------------------------------------------------------------------------- 
 def reposition
   if $game_temp.in_battle
     if "abcd".include?(@float_id) # must be between a and d
       @float_id = @float_id[0] - 97 # a = 0, b = 1, c = 2, d = 3
       return if $scene.spriteset.actor_sprites[@float_id] == nil
       sprite = $scene.spriteset.actor_sprites[@float_id]
     else
       @float_id -= 1 # account for, e.g., player entering 1 for index 0
       return if $scene.spriteset.enemy_sprites[@float_id] == nil
       sprite = $scene.spriteset.enemy_sprites[@float_id]
     end
     char_height = sprite.height
     char_width = sprite.width
     char_x = sprite.x
     char_y = sprite.y - char_height/2
   else # not in battle...
     char = (@float_id == 0 ? $game_player : $game_map.events[@float_id])
     if char == nil
       # no such character
       @float_id = nil
       return 
     end
     # close message (and stop event processing) if speaker is off-screen
     if char.screen_x <= 0 or char.screen_x >= 640 or
        char.screen_y <= 0 or char.screen_y > 480
       terminate_message
       $game_system.map_interpreter.command_115
       return
     end
     char_height = RPG::Cache.character(char.character_name,0).height / 4
     char_width = RPG::Cache.character(char.character_name,0).width / 4
     # record coords of character's center
     char_x = char.screen_x
     char_y = char.screen_y - char_height/2
   end
   params = [char_height, char_width, char_x, char_y]
   # position window and message tail
   vars = new_position(params)
   x = vars[0]
   y = vars[1]
   # check if any window locations need to be "flipped"
   if @location == 4 and x < 0
     # switch to right
     @location = 6
     vars = new_position(params)
     x = vars[0]
     if (x + self.width) > 640
       # right is no good either...
       if y >= 0
         # switch to top
         @location = 8
         vars = new_position(params)
       else
         # switch to bottom
         @location = 2
         vars = new_position(params)
       end
     end
   elsif @location == 6 and (x + self.width) > 640
     # switch to left
     @location = 4
     vars = new_position(params)
     x = vars[0]
     if x < 0
       # left is no good either...
       if y >= 0
         # switch to top
         @location = 8
         vars = new_position(params)
       else
         # switch to bottom
         @location = 2
         vars = new_position(params)
       end
     end
   elsif @location == 8 and y < 0
     # switch to bottom
     @location = 2
     vars = new_position(params)
     y = vars[1]
     if (y + self.height) > 480
       # bottom is no good either...
       # note: this will probably never occur given only 3 lines of text
       x = vars[0]
       if x >= 0
         # switch to left
         @location = 4
         vars = new_position(params)
       else
         # switch to right
         @location = 6
         vars = new_position(params)
       end
     end
   elsif @location == 2 and (y + self.height) > 480
     # switch to top
     @location = 8
     vars = new_position(params)
     y = vars[1]
     if y < 0
       # top is no good either...
       # note: this will probably never occur given only 3 lines of text
       x = vars[0]
       if x >= 0
         # switch to left
         @location = 4
         vars = new_position(params)
       else
         # switch to right
         @location = 6
         vars = new_position(params)
       end
     end
   end
   x = vars[0]
   y = vars[1]
   tail_x = vars[2]
   tail_y = vars[3]    
   # adjust windows if near edge of screen
   if x < 0
     x = 0
   elsif (x + self.width) > 640
     x = 640 - self.width
   end
   if y < 0
     y = 0
   elsif (y + self.height) > 480
     y = 480 - self.height
   elsif $game_temp.in_battle and @location == 2 and (y > (320 - self.height))
     # when in battle, prevent enemy messages from overlapping battle status
     # (note that it could still happen from actor messages, though)
     y = 320 - self.height
     tail_y = y
   end
   # finalize positions
   self.x = x
   self.y = y
   @tail.x = tail_x
   @tail.y = tail_y
 end

 #--------------------------------------------------------------------------
 # * Determine New Window Position
 #--------------------------------------------------------------------------  
 def new_position(params)
   char_height = params[0]
   char_width = params[1]
   char_x = params[2]
   char_y = params[3]
   if @location == 8
     # top
     x = char_x - self.width/2
     y = char_y - char_height/2 - self.height - @tail.bitmap.height/2
     @tail.bitmap.rotation(0)
     tail_x = x + self.width/2 
     tail_y = y + self.height
   elsif @location == 2
     # bottom
     x = char_x - self.width/2
     y = char_y + char_height/2 + @tail.bitmap.height/2
     @tail.bitmap.rotation(180)
     tail_x = x + self.width/2
     tail_y = y
   elsif @location == 4
     # left
     x = char_x - char_width/2 - self.width - @tail.bitmap.width/2
     y = char_y - self.height/2
     @tail.bitmap.rotation(270)
     tail_x = x + self.width
     tail_y = y + self.height/2
   elsif @location == 6
     # right
     x = char_x + char_width/2 + @tail.bitmap.width/2
     y = char_y - self.height/2
     @tail.bitmap.rotation(90)
     tail_x = x
     tail_y = y + self.height/2
   end
   return [x,y,tail_x,tail_y]
 end

 #--------------------------------------------------------------------------
 # * Update Text
 #--------------------------------------------------------------------------  
 def update_text
   if @text != nil
     # Get 1 text character in c (loop until unable to get text)
     while ((c = @text.slice!(/./m)) != nil)
       # If \\
       if c == "\000"
         # Return to original text
         c = "\\"
       end
       # If \C[n] or \C[#xxxxxx] or \C
       if c == "\001"
         # Change text color
         @text.sub!(/\[([0-9]+|#[0-9A-Fa-f]{6,6})\]/, "")
         if $1 != nil
           self.contents.font.color = check_color($1)
         else
           # return to default color
           if $game_system.message.font_color != nil
             color = check_color($game_system.message.font_color)
           elsif $game_system.message.floating and $game_system.message.resize
             color = check_color(SPEECH_FONT_COLOR)
           else
             # use defaults
             color = Font.default_color
           end
           self.contents.font.color = color
         end
         # go to next text
         next
       end
       # If \G
       if c == "\002"
         # Make gold window
         if @gold_window == nil
           @gold_window = Window_Gold.new
           @gold_window.x = 560 - @gold_window.width
           if $game_temp.in_battle
             @gold_window.y = 192
           else
             @gold_window.y = self.y >= 128 ? 32 : 384
           end
           @gold_window.opacity = self.opacity
           @gold_window.back_opacity = self.back_opacity
         end
         # go to next text
         next
       end
       # If \L
       if c == "\003"
         # toggle letter-by-letter mode
         @letter_by_letter = !@letter_by_letter
         # go to next text
         next
       end
       # If \S[n]
       if c == "\004"
         @text.sub!(/\[([0-9]+)\]/, "")
         speed = $1.to_i
         if speed >= 0
           @text_speed = speed
           # reset player skip after text speed change
           @player_skip = false            
         end
         return
       end
       # If \D[n]
       if c == "\005"
         @text.sub!(/\[([0-9]+)\]/, "")
         delay = $1.to_i
         if delay >= 0
           @delay += delay
           # reset player skip after delay
           @player_skip = false
         end
         return
       end   
       # If \!
       if c == "\006"
         # close message and return from method
         terminate_message
         return
       end
       # If \?
       if c == "\007"
         @wait_for_input = true
         return
       end
       if c == "\010"
         # bold
         self.contents.font.bold = !self.contents.font.bold
         return
       end
       if c == "\011"
         # italics
         self.contents.font.italic = !self.contents.font.italic
         return
       end
       if c == "\013"
         # display icon of item, weapon, armor or skill
         @text.sub!(/\[([iiWwAaSs])([0-9]+)\]/, "")
         case $1.downcase
           when "i"
             item = $data_items[$2.to_i]
           when "w"
             item = $data_weapons[$2.to_i]
           when "a"
             item = $data_armors[$2.to_i]
           when "s"
             item = $data_skills[$2.to_i]
         end
         if item == nil
           return
         end
         bitmap = RPG::Cache.icon(item.icon_name)
         self.contents.blt(4+@x, 32*@y+4, bitmap, Rect.new(0, 0, 24, 24))
         @x += 24
         #self.contents.draw_text(x + 28, y, 212, 32, item.name)
         return
       end
       # If new line text
       if c == "\n"
         # Update cursor width if choice
         if @y >= $game_temp.choice_start
           width = $game_system.message.autocenter ? @line_widths[@y]+8 : @x
           @cursor_width = [@cursor_width, width].max
         end
         # Add 1 to y
         @y += 1
         if $game_system.message.autocenter and @text != ""
           @x = (self.width-40)/2 - @line_widths[@y]/2
         else
           @x = 0
           # Indent if choice
           if @y >= $game_temp.choice_start
             @x = 8
           end
         end
         # go to next text
         next
       end
       # Draw text
       self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
       # Add x to drawn text width
       @x += self.contents.text_size( c ).width
       # add text speed to time to display next character
       @delay += @text_speed unless !@letter_by_letter or @player_skip
       return if @letter_by_letter and !@player_skip
     end
   end
   # If choice
   if $game_temp.choice_max > 0
     @item_max = $game_temp.choice_max
     self.active = true
     self.index = 0
   end
   # If number input
   if $game_temp.num_input_variable_id > 0
     digits_max = $game_temp.num_input_digits_max
     number = $game_variables[$game_temp.num_input_variable_id]
     @input_number_window = Window_InputNumber.new(digits_max)
     @input_number_window.set_font(@font_name, @font_size, @font_color)
     @input_number_window.number = number
     @input_number_window.x =
       if $game_system.message.autocenter
         offset = (self.width-40)/2-@line_widths[$game_temp.num_input_start]/2
         self.x + offset + 4
       else
         self.x + 8
       end
     @input_number_window.y = self.y + $game_temp.num_input_start * 32
   end
   @update_text = false
 end

 def reset_window
   if $game_temp.in_battle
     self.y = 16
   else
     case $game_system.message_position
     when 0  # up
       self.y = 16
     when 1  # middle
       self.y = 160
     when 2  # down
       self.y = 304
     end
   end
   if $game_system.message_frame == 0
     self.opacity = 255
   else
     self.opacity = 0
   end
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # transparent speech balloons don't look right, so keep opacity at 255
   # self.back_opacity = 160
   @tail.opacity = 255
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
 end

 def update
   super
   # If fade in
   if @fade_in
     self.contents_opacity += 24
     if @input_number_window != nil
       @input_number_window.contents_opacity += 24
     end
     if self.contents_opacity == 255
       @fade_in = false
     end
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
     # return
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   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
       terminate_message
     end
     return
   end
   # If message is being displayed
   if @contents_showing
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
     # Confirm or cancel finishes waiting for input or message
     if Input.trigger?(Input::C) or Input.trigger?(Input::B)
       if @wait_for_input
         @wait_for_input = false
         self.pause = false
       elsif $game_system.message.skippable
         @player_skip = true
       end
     end
     if need_reposition?
       reposition # update message position for character/screen movement
       if @contents_showing == false
         # i.e. if char moved off screen
         return 
       end
     end
     if @update_text and !@wait_for_input
       if @delay == 0
         update_text
       else
         @delay -= 1
       end
       return
     end

     # If choice isn't being displayed, show pause sign
     if !self.pause and ($game_temp.choice_max == 0 or @wait_for_input)
       self.pause = true unless !$game_system.message.show_pause
     end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
     # 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
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
       # personal preference: cancel button should also continue
       terminate_message 
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
     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(self.index)
       end
       terminate_message
     end
     return
   end
   # If display wait message or choice exists when not fading out
   if @fade_out == false and $game_temp.message_text[@msgindex] != nil
     @contents_showing = true
     $game_temp.message_window_showing = true
     reset_window
     refresh
     Graphics.frame_reset
     self.visible = true
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
     if show_message_tail?
       @tail.visible = true
     elsif @tail.visible
       @tail.visible = false
     end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
     self.contents_opacity = 0
     if @input_number_window != nil
       @input_number_window.contents_opacity = 0
     end
     @fade_in = true
     return
   end
   # If message which should be displayed is not shown, but window is visible
   if self.visible
     @fade_out = true
     self.opacity -= 96
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
     @tail.opacity -= 96 if @tail.opacity > 0 
     if need_reposition?
       reposition # update message position for character/screen movement
     end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
     if self.opacity == 0 
       self.visible = false
       @fade_out = false
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
       @tail.visible = false if @tail.visible
       # have to check all windows before claiming that no window is showing
       if $game_temp.message_text.compact.empty?
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
         $game_temp.message_window_showing = false  
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
       end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
     end
     return
   end
 end

 #--------------------------------------------------------------------------
 # * Repositioning Determination
 #--------------------------------------------------------------------------
 def need_reposition?
   if !$game_temp.in_battle and $game_system.message.floating and
       $game_system.message.resize and @float_id != nil
     if $game_system.message.move_during and @float_id == 0 and
         (($game_player.last_real_x != $game_player.real_x) or
         ($game_player.last_real_y != $game_player.real_y))
         # player with floating message moved
         # (note that relying on moving? leads to "jumpy" message boxes)
         return true
     elsif ($game_map.last_display_y != $game_map.display_y) or
        ($game_map.last_display_x != $game_map.display_x)
       # player movement or scroll event caused the screen to scroll
       return true
     else
       char = $game_map.events[@float_id]
       if char != nil and 
         ((char.last_real_x != char.real_x) or
         (char.last_real_y != char.real_y))
         # character moved
         return true
       end
     end    
   end
   return false
 end

 #--------------------------------------------------------------------------
 # * Show Message Tail Determination
 #--------------------------------------------------------------------------
 def show_message_tail?
   if $game_system.message.show_tail and $game_system.message.floating and
     $game_system.message.resize and $game_system.message_frame == 0 and
     @float_id != nil
     return true
   end
   return false
 end

 def update_cursor_rect
   if @index >= 0
     n = $game_temp.choice_start + @index
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
     if $game_system.message.autocenter
       x = 4 + (self.width-40)/2 - @cursor_width/2
     else
       x = 8
     end
     self.cursor_rect.set(x, n * 32, @cursor_width, 32)
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   else
     self.cursor_rect.empty
   end
 end

end

#------------------------------------------------------------------------------

class Game_Character
 attr_reader   :last_real_x                   # last map x-coordinate
 attr_reader   :last_real_y                   # last map y-coordinate
 alias wachunga_game_char_update update
 def update
   @last_real_x = @real_x
   @last_real_y = @real_y
   wachunga_game_char_update
 end
end

#------------------------------------------------------------------------------

class Game_Player < Game_Character

 alias wachunga_mmw_game_player_update update
 def update
  # The conditions are changed so the player can move around while messages
  # are showing (if move_during is true), but not if user is making a
  # choice or inputting a number
  # Note that this check overrides the default one (later in the method)
  # because it is more general
   unless moving? or
     @move_route_forcing or
     ($game_system.map_interpreter.running? and
     !$game_temp.message_window_showing) or
     ($game_temp.message_window_showing and
     !$game_system.message.move_during) or 
     ($game_temp.choice_max > 0 or $game_temp.num_input_digits_max > 0)
     update_player_movement
   end
   wachunga_mmw_game_player_update    
 end

end

#------------------------------------------------------------------------------

class Game_Temp
 alias wachunga_mmw_game_temp_initialize initialize
 def initialize
   wachunga_mmw_game_temp_initialize
   @message_text = [] 
   @message_proc = [] 
 end
end

#------------------------------------------------------------------------------

class Sprite_Battler < RPG::Sprite
 # necessary for positioning messages relative to battlers
 attr_reader :height
 attr_reader :width
end

#------------------------------------------------------------------------------

class Scene_Battle
 # necessary for accessing actor/enemy sprites in battle
 attr_reader :spriteset
end

#------------------------------------------------------------------------------

class Spriteset_Battle
 # necessary for accessing actor/enemy sprites in battle
 attr_reader :actor_sprites
 attr_reader :enemy_sprites
end

#------------------------------------------------------------------------------

class Scene_Map

 def main_draw
   # Make sprite set
   @spriteset = Spriteset_Map.new
   # Make message window
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   @message_window = []
   @message_window[0] = Window_Message.new(0)
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # Transition run
   Graphics.transition
 end

 alias wachunga_mmw_scene_map_main_dispose main_dispose
 def main_dispose
   wachunga_mmw_scene_map_main_dispose
   for mw in @message_window
     mw.dispose
   end
 end

 def update_graphics
   # Update sprite set
   @spriteset.update
   # Update message window
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   for mw in @message_window
     mw.update
   end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
 end

 #--------------------------------------------------------------------------
 # * New Message Window Addition
 #--------------------------------------------------------------------------
 def new_message_window(index)
   if @message_window[index] != nil
     # clear message windows at and after this index
     last_index = @message_window.size - 1
     last_index.downto(index) do |i|
       if @message_window[i] != nil
         @message_window[i].dispose
         @message_window[i] = nil
       end
     end
     @message_window.compact!
   end
   @message_window.push(Window_Message.new(index))
 end

end

#------------------------------------------------------------------------------

class Scene_Battle

 def main_windows
   # Make other windows
   @party_command_window = Window_PartyCommand.new
   @help_window = Window_Help.new
   @help_window.back_opacity = 160
   @help_window.visible = false
   @status_window = Window_BattleStatus.new
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   @message_window = [] 
   @message_window[0] = Window_Message.new(0) 
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
 end

 def main_dispose
   # Dispose of windows
   @actor_command_window.dispose
   @party_command_window.dispose
   @help_window.dispose
   @status_window.dispose
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   for mw in @message_window
     mw.dispose
   end 
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   @skill_window.dispose unless @skill_window == nil
   @item_window.dispose unless @item_window == nil
   @result_window.dispose unless @result_window == nil
   # Dispose of sprite set
   @spriteset.dispose
 end

 def update_objects
   # Update windows
   @help_window.update
   @party_command_window.update
   @actor_command_window.update
   @status_window.update
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   for mw in @message_window
     mw.update
   end 
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # Update sprite set
   @spriteset.update
 end

 #--------------------------------------------------------------------------
 # * New Message Window Addition
 #--------------------------------------------------------------------------
 def new_message_window(index)
   if @message_window[index] != nil
     # clear message windows at and after this index
     last_index = @message_window.size - 1
     last_index.downto(index) do |i|
       if @message_window[i] != nil
         @message_window[i].dispose
         @message_window[i] = nil
       end
     end
     @message_window.compact!
   end
   @message_window.push(Window_Message.new(index))
 end

end

#------------------------------------------------------------------------------

class Game_System
 attr_reader :message

 alias wachunga_mmw_game_system_init initialize
 def initialize
   wachunga_mmw_game_system_init
   @message = Game_Message.new
 end
end

#------------------------------------------------------------------------------

class Interpreter
 attr_reader :event_id

 alias wachunga_mmw_interp_setup setup
 def setup(list, event_id)
   wachunga_mmw_interp_setup(list, event_id)
   # index of window for the message
   @msgindex = 0
   # whether multiple messages are displaying
   @multi_message = false
 end

 def setup_choices(parameters)
   # Set choice item count to choice_max
   $game_temp.choice_max = parameters[0].size
   # Set choice to message_text
   for text in parameters[0]
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
     # just add index for array
     $game_temp.message_text[@msgindex] += text + "\n"
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   end
   # Set cancel processing
   $game_temp.choice_cancel_type = parameters[1]
   # Set callback
   current_indent = @list[@index].indent
   $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
 end

 #--------------------------------------------------------------------------
 # * Show Text
 #--------------------------------------------------------------------------
 def command_101
   # If other text has been set to message_text
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   if $game_temp.message_text[@msgindex] != nil
     if @multi_message
       @msgindex += 1
       $scene.new_message_window(@msgindex)
     else
       # End
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
       return false
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
     end
   end
   @msgindex = 0 if !@multi_message
   @multi_message = false
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # Set message end waiting flag and callback
   @message_waiting = true
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # just adding indexes
   $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
   # Set message text on first line
   $game_temp.message_text[@msgindex] = @list[@index].parameters[0] + "\n"
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   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
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
       # just adding index
       $game_temp.message_text[@msgindex]+=@list[@index+1].parameters[0]+"\n"
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
       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
         # If choices fit on screen
         if @list[@index+1].parameters[0].size <= 4 - line_count
           # Advance index
           @index += 1
           # Choices setup
           $game_temp.choice_start = line_count
           setup_choices(@list[@index].parameters)
         end
       # 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
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
       # start multimessage if next line is "Show Text" starting with "\\+"
       elsif @list[@index+1].code == 101
         if @list[@index+1].parameters[0][0..1]=="\\+"
           @multi_message = true
           @message_waiting = false
         end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
       end
       # Continue
       return true
     end
     # Advance index
     @index += 1
   end
 end

 #--------------------------------------------------------------------------
 # * Show Choices
 #--------------------------------------------------------------------------
 def command_102
   # If text has been set to message_text
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # just adding index
   if $game_temp.message_text[@msgindex] != nil
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
     # End
     return false
   end
   # Set message end waiting flag and callback
   @message_waiting = true
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # adding more indexes
   $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
   # Choices setup
   $game_temp.message_text[@msgindex] = ""
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   $game_temp.choice_start = 0
   setup_choices(@parameters)
   # Continue
   return true
 end

 #--------------------------------------------------------------------------
 # * Input Number
 #--------------------------------------------------------------------------
 def command_103
   # If text has been set to message_text
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # just adding index
   if $game_temp.message_text[@msgindex] != nil
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
     # End
     return false
   end
   # Set message end waiting flag and callback
   @message_waiting = true
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   # adding more indexes
   $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
   # Number input setup
   $game_temp.message_text[@msgindex] = ""
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
   $game_temp.num_input_start = 0
   $game_temp.num_input_variable_id = @parameters[0]
   $game_temp.num_input_digits_max = @parameters[1]
   # Continue
   return true
 end

 #--------------------------------------------------------------------------
 # * Script
 #--------------------------------------------------------------------------
 # Fix for RMXP bug: call script boxes that return false hang the game
 # See, e.g., http://rmxp.org/forums/showthread.php?p=106639  
 #--------------------------------------------------------------------------
 def command_355
   # Set first line to script
   script = @list[@index].parameters[0] + "\n"
   # Loop
   loop do
     # If next event command is second line of script or after
     if @list[@index+1].code == 655
       # Add second line or after to script
       script += @list[@index+1].parameters[0] + "\n"
     # If event command is not second line or after
     else
       # Abort loop
       break
     end
     # Advance index
     @index += 1
   end
   # Evaluation
   result = eval(script)
   # If return value is false
   if result == false
     # End
#------------------------------------------------------------------------------
# Begin Edit
#------------------------------------------------------------------------------
     #return false
#------------------------------------------------------------------------------
# End Edit
#------------------------------------------------------------------------------
   end
   # Continue
   return true
 end

 def message
   $game_system.message
 end

end

#------------------------------------------------------------------------------

class Game_Map
 attr_accessor :last_display_x                # last display x-coord * 128
 attr_accessor :last_display_y                # last display y-coord * 128

 alias wachunga_mmw_game_map_update update
 def update
   @last_display_x = @display_x
   @last_display_y = @display_y
   wachunga_mmw_game_map_update
 end

 def name
   return load_data('Data/MapInfos.rxdata')[@map_id].name
 end
end

#------------------------------------------------------------------------------

class Bitmap

 attr_accessor :orientation

 #--------------------------------------------------------------------------
 # * Rotation Calculation
 #--------------------------------------------------------------------------
 def rotation(target)
   return if not [0, 90, 180, 270].include?(target) # invalid orientation
   if @rotation != target
     degrees = target - @orientation
     if degrees < 0
       degrees += 360
     end
     rotate(degrees)
   end    
 end

 #--------------------------------------------------------------------------
 # * Rotate Square (Clockwise)
 #--------------------------------------------------------------------------
 def rotate(degrees = 90)
   # method originally by SephirothSpawn
   # would just use Sprite.angle but its rotation is buggy
   # (see http://www.rmxp.org/forums/showthread.php?t=12044)
   return if not [90, 180, 270].include?(degrees)
   copy = self.clone
   if degrees == 90
     # Passes Through all Pixels on Dummy Bitmap
     for i in 0...self.height
       for j in 0...self.width
         self.set_pixel(width - i - 1, j, copy.get_pixel(j, i))
       end
     end
   elsif degrees == 180
     for i in 0...self.height
       for j in 0...self.width
         self.set_pixel(width - j - 1, height - i - 1, copy.get_pixel(j, i))
       end
     end      
   elsif degrees == 270
     for i in 0...self.height
       for j in 0...self.width
         self.set_pixel(i, height - j - 1, copy.get_pixel(j, i))
       end
     end
   end
   @orientation = (@orientation + degrees) % 360
 end

end

#------------------------------------------------------------------------------

class Window_Base

 #--------------------------------------------------------------------------
 # * Check Color
 #     color : color to check
 #--------------------------------------------------------------------------
 def check_color(color)
   if color.type == Color
     # already a Color object
     return color
   elsif color[0].chr == "#"
     # specified as hexadecimal
     r = color[1..2].hex
     g = color[3..4].hex
     b = color[5..6].hex
     return Color.new(r,g,b)
   else
     # specified as integer (0-7)
     color = color.to_i
     if color >= 0 and color <= 7
       return text_color(color)
     end
   end
   return normal_color
 end

end

#------------------------------------------------------------------------------

class Window_InputNumber < Window_Base

 def set_font(fname, fsize, fcolor)
   return if fname == nil and fsize == nil and fcolor == nil
   # Calculate cursor width from number width
   dummy_bitmap = Bitmap.new(32, 32)
   dummy_bitmap.font.name = fname
   dummy_bitmap.font.size = fsize
   @cursor_width = dummy_bitmap.text_size("0").width + 8
   dummy_bitmap.dispose
   self.width = @cursor_width * @digits_max + 32
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = fname
   self.contents.font.size = fsize
   self.contents.font.color = check_color(fcolor)
   refresh
   update_cursor_rect
 end

 def refresh
   self.contents.clear
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   #self.contents.font.color = normal_color
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
   s = sprintf("%0*d", @digits_max, @number)
   for i in 0...@digits_max
     self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])
   end
 end

end

#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
end

 

 

and it requires SDK:

#==============================================================================
# ** RMXP Standard Development Kit (SDK)
#------------------------------------------------------------------------------
# Build Date - 2005-11-22
# Version 1.0 - Near Fantastica - 2005-11-22
# Version 1.1 - SephirothSpawn - 2005-12-18 - (Near Fantastica)
# Version 1.2 - Near Fantastica - 2005-12-18
# Version 1.3 - Wachunga - 2005-12-19
# Version 1.4 - Prexus - 2006-03-02
# Version 1.5 - Jimme Reashu - 2006-03-25 - (Near Fantastica)
#------------------------------------------------------------------------------
=begin
 1.0 - Outline

 The Standard Development Kit (SDK) aims to increase compatibility between
 RGSS scripts by:

 a) defining a set of scripting standards (see section 3)
 b) restructuring often-used default classes and methods (see section 4)
 c) providing a scripting tools module (see section 5)
#------------------------------------------------------------------------------
 2.0 - Modifications to the RMXP Standard Development Kit

 Since edits to the SDK may cause massive capability errors, any and all
 modifications must first be approved by a member of the RMXP SDK Team. 

 The author of any modifications must be sure to update all relevant
 documentation. This also includes the header, where the author is to put
 the next version number with his or her name and the name of the approval
 member (from the SDK Team) under the latest version in the following format.

 Version # - Name - Date - (Approval Member Name)
#------------------------------------------------------------------------------
 3.0 - Coding Standards

 To be compliant with the SDK, a script must compy with the following
 coding standards:

 3.1 - Commenting
 3.2 - Classes
 3.3 - Variables
 3.4 - Aliases
 3.5 - Strings
 3.6 - Line Length
 3.7 - White Space
 3.8 - Constants
 3.9 - Parentheses
#------------------------------------------------------------------------------
 3.1 - Commenting

 Scripts must begin with the following header:

 #==============================================================================
 # ** Script Name
 #------------------------------------------------------------------------------
 # Your Name
 # Version
 # Date
 #==============================================================================

 All classes and methods must have a comment describing the process or what
 was added. All code added to methods that can not be aliased must be
 formatted as follows:

 #------------------------------------------------------------------------------
 # Begin Script Name Edit
 #------------------------------------------------------------------------------
 [Code]  
 #------------------------------------------------------------------------------
 # End Script Name Edit
 #------------------------------------------------------------------------------

 Single line comments should precede the described block of code and should be
 indented at the same level. Code that is not self-documenting should be
 commented.

 However, very short comments can appear on the same line as the described
 code, but should be shifted far enough to separate them from the statements.
 If more than one short comment appears in a chunk of code, they should all be
 indented to the same tab setting. Attribute declarations should always have a
 trailing comment.
#------------------------------------------------------------------------------
 3.2 - Classes

 All classes must be named consistently with the default code, namely:

   Data - Any class that holds data
   Game - Any class that processes data
   Sprite - Any class that defines a sprite
   Spriteset - Any class that defines multiple sprites
   Window - Any class that defines a window
   Arrow - Any class that defines an arrow
   Scene - Any class that defines a scene
#------------------------------------------------------------------------------
 3.3 - Variables

 All variable names must be reasonably descriptive. Use of class and global
 variables should be limited. Any variable used by the default system can not
 have its use changed.
#------------------------------------------------------------------------------
 3.4 - Aliases

 Aliasing a method is preferable to overriding it; an alias should be used
 whenever possible to increase compatibility with other scripts. All alias
 names must have the following format:

 yourname_scriptname_classname_methodname
#------------------------------------------------------------------------------
 3.5 – Strings

 Strings should normally be defined with single quotes ('example'); this
 decreases the processing time of the engine. Double quotes are useful when
 using the following features:
 a) substitutions, i.e. sequences that start with a backslash character
    (e.g. \n for the newline character)
 b) expression interpolation, i.e. #{ expression } is replaced by the value
    of expression
#------------------------------------------------------------------------------
 3.6 - Line Length

 Lines should not cause the the viewer to have to scroll sideways to view them
 in the script editor. When the line needs to be broken, it should follow the
 following guidelines, in preferential order:

   Break after a comma.
   Break before an operator.
   Prefer higher-level breaks to lower-level breaks.
   Align the new line with the beginning of the expression at the same level 
   on the previous line.

 If the above rules lead to confusing code or to code that’s squished up 
 against the right margin, just indent 4 spaces instead.
#------------------------------------------------------------------------------
 3.7 - White Space

 A blank line(s) should be used in the following places:

   Between sections of a source file
   Between class and module definitions
   Between attributes and the class definition
   Between methods
   Between the local variables in a method and its first statement
   Before a block or single-line comment
   Between logical sections inside a method to improve readability

 Blank spaces should be used in the following places:

   A keyword followed by a parenthesis, e.g. if (some_boolean_statements)
   After commas in argument lists, e.g. def method (arg1, arg2, ...)
   All binary operators except '.', e.g. a + b; c = 1
#------------------------------------------------------------------------------
 3.8 - Constants

 New numerical values should not be "hard-coded", except for -1, 0, and 1,
 which can appear in for loops as counter values. Instead, these numerical
 values should be made into constant variables and these used instead.
#------------------------------------------------------------------------------
 3.9 - Parentheses

 It is generally a good idea to use parentheses liberally in expressions 
 involving mixed operators to avoid operator precedence problems. Even if 
 the operator precedence seems clear to you, it might not be to others -— you 
 shouldn’t assume that other programmers know precedence as well as you do.
#------------------------------------------------------------------------------
 4.0 - Engine Updates

 The following is a list of classes and methods that have been updated by the
 SDK to help improve compatibility:

   Game_Map - setup
   Game_Map - update
   Game_Character - update
   Game_Event - refresh
   Game_Player - update
   Sprite_Battler - update
   Spriteset_Map - initialize
   Spriteset_Map - update
   Scene_Tile - main
   Scene_Map - main
   Scene_Map - update
   Scene_Save - write_save_data
   Scene_Load - read_save_data
   Scene_Menu - initialize    
   Scene_Menu - main
   Scene_Menu - update & command input
   Scene_Battle - main
   Scene_Battle - update
   Scene_Battle - update_phase3_basic_command 
   Scene_Battle - make_basic_action_result
#------------------------------------------------------------------------------
 5.0 - SDK Tools

 The following tools are included in the SDK to help improve the development
 process:

 5.1 - Logging Scripts
 5.2 - Enabling/Disabling Scripts
 5.3 - Script Dependencies
 5.4 - Standard Text Box Input
 5.5 - Standard Event Comment Input
#------------------------------------------------------------------------------
 5.1 – Logging Scripts

 All SDK-compliant scripts should be logged. This is done by calling the
 SDK.log(script, name, ver, date) method, where

 script = script name
 name = your name
 ver = version
 date = date last updated
#------------------------------------------------------------------------------
 5.2 – Enabling/Disabling Scripts

 When a script is logged it is also enabled. A script can be enabled and
 disabled using the following calls:

 SDK.enable('Script Name') 
 SDK.disable('Script Name')

 All non-default scripts (and code added to default scripts) must be enclosed
 in an if statement that checks whether or not they have been enabled, as
 follows:

 #--------------------------------------------------------------------------
 # Begin SDK Enabled Check
 #--------------------------------------------------------------------------
 if SDK.state('Script Name') == true
   [script or Code]
 end
 #--------------------------------------------------------------------------
 # End SDK Enabled Test
 #--------------------------------------------------------------------------

 Keep in mind that this if statement can not continue on to other pages and
 every page needs its own if statement testing the state of the script. As
 well every script should have its own test.
#------------------------------------------------------------------------------
 5.3 – Script Dependencies

 Any script that requires (i.e. has a dependency on) another script can check
 if that dependency is met provided that the required script is set up before
 the script in question. This would be done in the following way:

 p 'Script Name not found' if SDK.state('Script Name') != true
#------------------------------------------------------------------------------
 5.4 – Standard Text Box Input

 Any script that requires input from a database text field should use the
 following:

 SDK.text_box_input(element, index)

 where:
 element = an object of the text field
 index = the index in which your script call falls

 The text field should be formatted in the following way:

 "Default value | script call | script call"
#------------------------------------------------------------------------------
 5.5 – Standard Event Comment Input

 Any script that requires input from an event comment should use the 
 following:

 SDK.event_comment_input(event, elements, trigger)

 where:
 event = an object of the event
 elements = the number of elements the method is to process
 trigger = the text value triggering the script to start processing

 or 

 SDK.event_comment_input(page, elements, trigger)

 where:
 page = an object of the event.page
 elements = the number of elements the method is to process
 trigger = the text value triggering the script to start processing

 The method returns nil if the trigger can not be found; otherwise, it
 returns a list of the parameters from the event.
#==============================================================================
=end

module SDK
 @list = {}
 @enabled = {}
 #--------------------------------------------------------------------------
 # * Logs a custom script
 #--------------------------------------------------------------------------
 def self.log(script, name, ver, date)
   @list[script] = [name,ver,date]
   @enabled[script] = true
 end
 #--------------------------------------------------------------------------
 # * Returns a list of custom scripts
 #--------------------------------------------------------------------------
 def self.print(script = '')
   if script == ''
     return @list
   else
     return @list[script]
   end
 end
 #--------------------------------------------------------------------------
 # * Writes a list of the custom scripts to a file
 #--------------------------------------------------------------------------
 def self.write
   file = File.open('Scripts List.txt', 'wb')
   for key in @list.keys
     file.write("#{@list[key][0]} : #{key} Version #{@list[key][1]}\n")
   end
   file.close
 end
 #--------------------------------------------------------------------------
 # * Returns the state of the passed script
 #--------------------------------------------------------------------------
 def self.state(script)
   return @enabled[script]
 end
 #--------------------------------------------------------------------------
 # * Enables the passed script
 #--------------------------------------------------------------------------
 def self.enable(script)
   @enabled[script] = true
 end
 #--------------------------------------------------------------------------
 # * Disables the passed script
 #--------------------------------------------------------------------------
 def self.disable(script)
   @enabled[script] = false
 end
 #--------------------------------------------------------------------------
 # * Evals text from an input source
 #--------------------------------------------------------------------------
 def self.text_box_input(element, index)
   return if index == 0
   commands = element.split('|')
   eval(commands[index])
 end
 #--------------------------------------------------------------------------
 # * Returns a list of parameters from an event's comments
 #--------------------------------------------------------------------------
 def self.event_comment_input(*args)
   parameters = []
   list = *args[0].list
   elements = *args[1]
   trigger = *args[2]
   return nil if list == nil
   return nil unless list.is_a?(Array)
   for item in list
     next if item.code != 108
     if item.parameters[0] == trigger
       start = list.index(item) + 1
       finish = start + elements
       for id in start...finish
         next if !list[id]
         parameters.push(list[id].parameters[0])
       end
       return parameters
     end
   end
   return nil
 end
end

#==============================================================================
# ** Object
#------------------------------------------------------------------------------
# automatic_dispose looks after disposing all windows and sprites in a scene
# when called.
#==============================================================================

class Object
 #--------------------------------------------------------------------------
 # * Automatic Dispose
 #--------------------------------------------------------------------------
 def automatic_dispose
   self.instance_variables.each do |item|
     eval("#{item}.dispose if (#{item}.is_a?(Sprite) or #{item}.is_a?(Window_Base)) and (!#{item}.disposed?)")
   end
 end
end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles the map. It includes scrolling and passable determining
#  functions. Refer to "$game_map" for the instance of this class.
#==============================================================================

class Game_Map
 #--------------------------------------------------------------------------
 # * Setup
 #     map_id : map ID
 #--------------------------------------------------------------------------
 def setup(map_id)
   setup_map_id(map_id)
   setup_load
   setup_tileset
   setup_display
   setup_refresh
   setup_events
   setup_common_events
   setup_fog
   setup_scroll
 end
 #--------------------------------------------------------------------------
 # * Setup Map ID
 #--------------------------------------------------------------------------
 def setup_map_id(map_id)
   # Put map ID in @map_id memory
   @map_id = map_id
 end
 #--------------------------------------------------------------------------
 # * Load Map Data
 #--------------------------------------------------------------------------
 def setup_load
   # Load map from file and set @map
   @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
 end
 #--------------------------------------------------------------------------
 # * Setup Tileset
 #--------------------------------------------------------------------------
 def setup_tileset
   # set tile set information in opening instance variables
   tileset = $data_tilesets[@map.tileset_id]
   @tileset_name = tileset.tileset_name
   @autotile_names = tileset.autotile_names
   @panorama_name = tileset.panorama_name
   @panorama_hue = tileset.panorama_hue
   @fog_name = tileset.fog_name
   @fog_hue = tileset.fog_hue
   @fog_opacity = tileset.fog_opacity
   @fog_blend_type = tileset.fog_blend_type
   @fog_zoom = tileset.fog_zoom
   @fog_sx = tileset.fog_sx
   @fog_sy = tileset.fog_sy
   @battleback_name = tileset.battleback_name
   @passages = tileset.passages
   @priorities = tileset.priorities
   @terrain_tags = tileset.terrain_tags
 end
 #--------------------------------------------------------------------------
 # * Setup Display
 #--------------------------------------------------------------------------
 def setup_display
   # Initialize displayed coordinates
   @display_x = 0
   @display_y = 0
 end
 #--------------------------------------------------------------------------
 # * Setup Refresh
 #--------------------------------------------------------------------------
 def setup_refresh
   # Clear refresh request flag
   @need_refresh = false
 end
 #--------------------------------------------------------------------------
 # * Setup Events
 #--------------------------------------------------------------------------
 def setup_events
   # Set map event data
   @events = {}
   for i in @map.events.keys
     @events[i] = Game_Event.new(@map_id, @map.events[i])
   end
 end
 #--------------------------------------------------------------------------
 # * Setup Common Events
 #--------------------------------------------------------------------------
 def setup_common_events
   # Set common event data
   @common_events = {}
   for i in 1...$data_common_events.size
     @common_events[i] = Game_CommonEvent.new(i)
   end
 end
 #--------------------------------------------------------------------------
 # * Setup Fog
 #--------------------------------------------------------------------------
 def setup_fog
   # Initialize all fog information
   @fog_ox = 0
   @fog_oy = 0
   @fog_tone = Tone.new(0, 0, 0, 0)
   @fog_tone_target = Tone.new(0, 0, 0, 0)
   @fog_tone_duration = 0
   @fog_opacity_duration = 0
   @fog_opacity_target = 0
 end
 #--------------------------------------------------------------------------
 # * Setup Scroll
 #--------------------------------------------------------------------------
 def setup_scroll
   # Initialize scroll information
   @scroll_direction = 2
   @scroll_rest = 0
   @scroll_speed = 4
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   update_refresh
   update_scrolling
   update_events
   update_common_events
   update_fog_scroll
   update_fog_colour
   update_fog
 end
 #--------------------------------------------------------------------------
 # * Refresh Game Map
 #--------------------------------------------------------------------------
 def update_refresh
   # Refresh map if necessary
   if $game_map.need_refresh
     refresh
   end
 end
 #--------------------------------------------------------------------------
 # * Update Scrolling
 #--------------------------------------------------------------------------
 def update_scrolling
   # If scrolling
   if @scroll_rest > 0
     # Change from scroll speed to distance in map coordinates
     distance = 2 ** @scroll_speed
     # Execute scrolling
     case @scroll_direction
     when 2  # Down
       scroll_down(distance)
     when 4  # Left
       scroll_left(distance)
     when 6  # Right
       scroll_right(distance)
     when 8  # Up
       scroll_up(distance)
     end
     # Subtract distance scrolled
     @scroll_rest -= distance
   end
 end
 #--------------------------------------------------------------------------
 # * Update Events
 #--------------------------------------------------------------------------
 def update_events
   # Update map event
   for event in @events.values
     event.update
   end
 end
 #--------------------------------------------------------------------------
 # * Update Common Events
 #--------------------------------------------------------------------------
 def update_common_events
   # Update common event
   for common_event in @common_events.values
     common_event.update
   end
 end
 #--------------------------------------------------------------------------
 # * Update Fog Scroll
 #--------------------------------------------------------------------------
 def update_fog_scroll
   # Manage fog scrolling
   @fog_ox -= @fog_sx / 8.0
   @fog_oy -= @fog_sy / 8.0
 end
 #--------------------------------------------------------------------------
 # * Update Fog Color
 #--------------------------------------------------------------------------
 def update_fog_colour
   # Manage change in fog color tone
   if @fog_tone_duration >= 1
     d = @fog_tone_duration
     target = @fog_tone_target
     @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
     @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
     @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
     @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
     @fog_tone_duration -= 1
   end
 end
 #--------------------------------------------------------------------------
 # * Update Fog
 #--------------------------------------------------------------------------
 def update_fog
   # Manage change in fog opacity level
   if @fog_opacity_duration >= 1
     d = @fog_opacity_duration
     @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
     @fog_opacity_duration -= 1
   end
 end
end

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   unless update_wait == true
     update_movement_type
     update_animation
     return if update_force? == true
     return if update_event_execution? == true
     update_movement
   end
 end
 #--------------------------------------------------------------------------
 # * Update Movement Type
 #--------------------------------------------------------------------------
 def update_movement_type
   # Branch with jumping, moving, and stopping
   if jumping?
     update_jump
   elsif moving?
     update_move
   else
     update_stop
   end
 end
 #--------------------------------------------------------------------------
 # * Update Animation
 #--------------------------------------------------------------------------
 def update_animation
   # If animation count exceeds maximum value
   # * Maximum value is move speed * 1 taken from basic value 18
   if @anime_count > 18 - @move_speed * 2
     # If stop animation is OFF when stopping
     if not @step_anime and @stop_count > 0
       # Return to original pattern
       @pattern = @original_pattern
     # If stop animation is ON when moving
     else
       # Update pattern
       @pattern = (@pattern + 1) % 4
     end
     # Clear animation count
     @anime_count = 0
   end
 end
 #--------------------------------------------------------------------------
 # * Update Wait
 #--------------------------------------------------------------------------
 def update_wait
   # Reduce wait count
   @wait_count -= 1 if @wait_count > 0
   return (@wait_count > 0)
 end
 #--------------------------------------------------------------------------
 # * Update Force
 #--------------------------------------------------------------------------
 def update_force?
   # If move route is forced
   if @move_route_forcing
     # Custom move
     move_type_custom
     return true
   end
   return false
 end
 #--------------------------------------------------------------------------
 # * Update Event Execution
 #--------------------------------------------------------------------------
 def update_event_execution?
   # When waiting for event execution or locked
   if @starting or lock?
     # Not moving by self
     return true
   end
   return false
 end
 #--------------------------------------------------------------------------
 # * Update Movement
 #--------------------------------------------------------------------------
 def update_movement
   # If stop count exceeds a certain value (computed from move frequency)
   if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
     # Branch by move type
     case @move_type
     when 1  # Random
       move_type_random
     when 2  # Approach
       move_type_toward_player
     when 3  # Custom
       move_type_custom
     end
   end
 end
end

#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page 
#  switching via condition determinants, and running parallel process events.
#  It's used within the Game_Map class.
#==============================================================================

class Game_Event < Game_Character
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   # Initialize local variable: new_page
   new_page = nil
   # If not temporarily erased
   unless @erased
     new_page = refresh_trigger_conditions
   end
   # If event page is the same as last time
   if new_page == @page
     # End method
     return
   end
   # Set @page as current event page
   @page = new_page
   # Clear starting flag
   clear_starting
   # If no page fulfills conditions
   if @page == nil
     # Reset values
     refresh_reset
     # End method
     return
   end
   # Set page variables
   refresh_set_page
   # Check parallel processing
   refresh_check_process
   # Auto event start determinant
   check_event_trigger_auto
 end
 #--------------------------------------------------------------------------
 # * Refresh Trigger Conditions
 #--------------------------------------------------------------------------
 def refresh_trigger_conditions
   # Check in order of large event pages
   for page in @event.pages.reverse
     # Make possible referrence for event condition with c
     c = page.condition
     # Switch 1 condition confirmation
     if c.switch1_valid
       if $game_switches[c.switch1_id] == false
         next
       end
     end
     # Switch 2 condition confirmation
     if c.switch2_valid
       if $game_switches[c.switch2_id] == false
         next
       end
     end
     # Variable condition confirmation
     if c.variable_valid
       if $game_variables[c.variable_id] < c.variable_value
         next
       end
     end
     # Self switch condition confirmation
     if c.self_switch_valid
       key = [@map_id, @event.id, c.self_switch_ch]
       if $game_self_switches[key] != true
         next
       end
     end
     # Set local variable: new_page
     new_page = page
     # Remove loop
     break
   end
   # Return new page
   return new_page
 end
 #--------------------------------------------------------------------------
 # * Refresh Reset
 #--------------------------------------------------------------------------
 def refresh_reset
   # Set each instance variable
   @tile_id = 0
   @character_name = ""
   @character_hue = 0
   @move_type = 0
   @through = true
   @trigger = nil
   @list = nil
   @interpreter = nil
 end
 #--------------------------------------------------------------------------
 # * Refresh Set Page
 #--------------------------------------------------------------------------
 def refresh_set_page
   # Set each instance variable
   @tile_id = @page.graphic.tile_id
   @character_name = @page.graphic.character_name
   @character_hue = @page.graphic.character_hue
   if @original_direction != @page.graphic.direction
     @direction = @page.graphic.direction
     @original_direction = @direction
     @prelock_direction = 0
   end
   if @original_pattern != @page.graphic.pattern
     @pattern = @page.graphic.pattern
     @original_pattern = @pattern
   end
   @opacity = @page.graphic.opacity
   @blend_type = @page.graphic.blend_type
   @move_type = @page.move_type
   @move_speed = @page.move_speed
   @move_frequency = @page.move_frequency
   @move_route = @page.move_route
   @move_route_index = 0
   @move_route_forcing = false
   @walk_anime = @page.walk_anime
   @step_anime = @page.step_anime
   @direction_fix = @page.direction_fix
   @through = @page.through
   @always_on_top = @page.always_on_top
   @trigger = @page.trigger
   @list = @page.list
   @interpreter = nil
 end
 #--------------------------------------------------------------------------
 # * Refresh Check Process
 #--------------------------------------------------------------------------
 def refresh_check_process
   # If trigger is [parallel process]
   if @trigger == 4
     # Create parallel process interpreter
     @interpreter = Interpreter.new
   end
 end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================

class Game_Player < Game_Character
 #--------------------------------------------------------------------------
 # * 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
     update_player_movement
   end
   # Remember coordinates in local variables
   last_real_x = @real_x
   last_real_y = @real_y
   super
   # Scroll map
   update_scroll_down(last_real_y)
   update_scroll_left(last_real_x)
   update_scroll_right(last_real_x)
   update_scroll_up(last_real_y)
   # If not moving
   unless moving?
     # If player was moving last time
     if last_moving
       update_encounter
     end
     update_action_trigger
   end
 end
 #--------------------------------------------------------------------------
 # * Player Movement Update
 #--------------------------------------------------------------------------
 def update_player_movement
   # 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
 #--------------------------------------------------------------------------
 # * Scroll Down
 #--------------------------------------------------------------------------
 def update_scroll_down(last_real_y)
   # 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
 end
 #--------------------------------------------------------------------------
 # * Scroll Left
 #--------------------------------------------------------------------------
 def update_scroll_left(last_real_x)
   # 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
 end
 #--------------------------------------------------------------------------
 # * Scroll Right
 #--------------------------------------------------------------------------
 def update_scroll_right(last_real_x)
   # 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
 end
 #--------------------------------------------------------------------------
 # * Scroll Up
 #--------------------------------------------------------------------------
 def update_scroll_up(last_real_y)
   # 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
 end
 #--------------------------------------------------------------------------
 # * Update Action Trigger
 #--------------------------------------------------------------------------
 def update_action_trigger
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Same position and front event determinant
     check_event_trigger_here([0])
     check_event_trigger_there([0,1,2])
   end
 end
 #--------------------------------------------------------------------------
 # * Scroll Encounter
 #--------------------------------------------------------------------------
 def update_encounter
   # 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
end

#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
#  This sprite is used to display the battler.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Battler
 #--------------------------------------------------------------------------
 # * Update
 #--------------------------------------------------------------------------
 def update
   super
   # If battler is nil
   if @battler == nil
     remove_battler
     return
   end
   # If file name or hue are different than current ones
   redraw_battler
   # If animation ID is different than current one
   loop_anim
   # If actor which should be displayed
   adjust_actor_opacity
   # Blink
   adjust_blink
   # If invisible
   adjust_visibility
   # If visible
   if @battler_visible
     # Escape
     sprite_escape
     # White flash
     sprite_white_flash
     # Animation
     sprite_animation
     # Damage
     sprite_damage
     # Collapse
     sprite_collapse
   end
   # Set sprite coordinates
   self.x = @battler.screen_x
   self.y = @battler.screen_y
   self.z = @battler.screen_z
 end
 #--------------------------------------------------------------------------
 # * Remove Battler
 #--------------------------------------------------------------------------
 def remove_battler      
   self.bitmap = nil
   loop_animation(nil)
 end
 #--------------------------------------------------------------------------
 # * Redraw Battler
 #--------------------------------------------------------------------------
 def redraw_battler
   if @battler.battler_name != @battler_name or
       @battler.battler_hue != @battler_hue
     # Get and set bitmap
     @battler_name = @battler.battler_name
     @battler_hue = @battler.battler_hue
     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
     @width = bitmap.width
     @height = bitmap.height
     self.ox = @width / 2
     self.oy = @height
     # Change opacity level to 0 when dead or hidden
     if @battler.dead? or @battler.hidden
       self.opacity = 0
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Loop Sprite Animation
 #--------------------------------------------------------------------------
 def loop_anim
   if @battler.damage == nil and
       @battler.state_animation_id != @state_animation_id
     @state_animation_id = @battler.state_animation_id
     loop_animation($data_animations[@state_animation_id])
   end
 end
 #--------------------------------------------------------------------------
 # * Adjust Actor Opacity
 #--------------------------------------------------------------------------
 def adjust_actor_opacity
   if @battler.is_a?(Game_Actor) and @battler_visible
     # Bring opacity level down a bit when not in main phase
     if $game_temp.battle_main_phase
       self.opacity += 3 if self.opacity < 255
     else
       self.opacity -= 3 if self.opacity > 207
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Adjust Blink
 #--------------------------------------------------------------------------
 def adjust_blink
   if @battler.blink
     blink_on
   else
     blink_off
   end
 end
 #--------------------------------------------------------------------------
 # * Adjust Visibility
 #--------------------------------------------------------------------------
 def adjust_visibility
   unless @battler_visible
     # Appear
     if not @battler.hidden and not @battler.dead? and
        (@battler.damage == nil or @battler.damage_pop)
       appear
       @battler_visible = true
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Sprite: Escape
 #--------------------------------------------------------------------------
 def sprite_escape
   if @battler.hidden
     $game_system.se_play($data_system.escape_se)
     escape
     @battler_visible = false
   end
 end
 #--------------------------------------------------------------------------
 # * Sprite: White Flash
 #--------------------------------------------------------------------------
 def sprite_white_flash
   if @battler.white_flash
     whiten
     @battler.white_flash = false
   end
 end
 #--------------------------------------------------------------------------
 # * Sprite: Animation
 #--------------------------------------------------------------------------
 def sprite_animation
   if @battler.animation_id != 0
     animation = $data_animations[@battler.animation_id]
     animation(animation, @battler.animation_hit)
     @battler.animation_id = 0
   end
 end
 #--------------------------------------------------------------------------
 # * Sprite: Damage
 #--------------------------------------------------------------------------
 def sprite_damage
   if @battler.damage_pop
     damage(@battler.damage, @battler.critical)
     @battler.damage = nil
     @battler.critical = false
     @battler.damage_pop = false
   end
 end
 #--------------------------------------------------------------------------
 # * Sprite: Collapse
 #--------------------------------------------------------------------------
 def sprite_collapse
   if @battler.damage == nil and @battler.dead?
     if @battler.is_a?(Game_Enemy)
       $game_system.se_play($data_system.enemy_collapse_se)
     else
       $game_system.se_play($data_system.actor_collapse_se)
     end
     collapse
     @battler_visible = false
   end
 end
end

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc.
#  It's used within the Scene_Map class.
#==============================================================================

class Spriteset_Map
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   init_viewports
   init_tilemap
   init_panorama
   init_fog
   init_characters
   init_player
   init_weather
   init_pictures
   init_timer
   # Frame update
   update
 end
 #--------------------------------------------------------------------------
 # * Viewport Initialization
 #--------------------------------------------------------------------------
 def init_viewports
   # Make viewports
   @viewport1 = Viewport.new(0, 0, 640, 480)
   @viewport2 = Viewport.new(0, 0, 640, 480)
   @viewport3 = Viewport.new(0, 0, 640, 480)
   @viewport2.z = 200
   @viewport3.z = 5000
 end
 #--------------------------------------------------------------------------
 # * Tilemap Initialization
 #--------------------------------------------------------------------------
 def init_tilemap
   # Make tilemap
   @tilemap = Tilemap.new(@viewport1)
   @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
   for i in 0..6
     autotile_name = $game_map.autotile_names[i]
     @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
   end
   @tilemap.map_data = $game_map.data
   @tilemap.priorities = $game_map.priorities
 end
 #--------------------------------------------------------------------------
 # * Panorama Initialization
 #--------------------------------------------------------------------------
 def init_panorama
   # Make panorama plane
   @panorama = Plane.new(@viewport1)
   @panorama.z = -1000
 end
 #--------------------------------------------------------------------------
 # * Fog Initialization
 #--------------------------------------------------------------------------
 def init_fog
   # Make fog plane
   @fog = Plane.new(@viewport1)
   @fog.z = 3000
 end
 #--------------------------------------------------------------------------
 # * Character Sprite Initialization
 #--------------------------------------------------------------------------
 def init_characters
   # Make character sprites
   @character_sprites = []
   for i in $game_map.events.keys.sort
     sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
     @character_sprites.push(sprite)
   end
 end
 #--------------------------------------------------------------------------
 # * Player Initialization
 #--------------------------------------------------------------------------
 def init_player
   @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
 end
 #--------------------------------------------------------------------------
 # * Weather Initialization
 #--------------------------------------------------------------------------
 def init_weather
   # Make weather
   @weather = RPG::Weather.new(@viewport1)
 end
 #--------------------------------------------------------------------------
 # * Picture Initialization
 #--------------------------------------------------------------------------
 def init_pictures
   # Make picture sprites
   @picture_sprites = []
   for i in 1..50
     @picture_sprites.push(Sprite_Picture.new(@viewport2,
       $game_screen.pictures[i]))
   end
 end
 #--------------------------------------------------------------------------
 # * Timer Initialization
 #--------------------------------------------------------------------------
 def init_timer
   # Make timer sprite
   @timer_sprite = Sprite_Timer.new
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   update_panorama
   update_fog
   update_tilemap
   update_panorama_plane
   update_fog_plane
   update_character_sprites
   update_weather
   update_picture_sprites
   # Update timer sprite
   @timer_sprite.update
   # Set screen color tone and shake position
   @viewport1.tone = $game_screen.tone
   @viewport1.ox = $game_screen.shake
   # Set screen flash color
   @viewport3.color = $game_screen.flash_color
   # Update viewports
   @viewport1.update
   @viewport3.update
 end
 #--------------------------------------------------------------------------
 # * Update Panorama
 #--------------------------------------------------------------------------
 def update_panorama
   # If panorama is different from current one
   if @panorama_name != $game_map.panorama_name or
      @panorama_hue != $game_map.panorama_hue
     @panorama_name = $game_map.panorama_name
     @panorama_hue = $game_map.panorama_hue
     if @panorama.bitmap != nil
       @panorama.bitmap.dispose
       @panorama.bitmap = nil
     end
     if @panorama_name != ""
       @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
     end
     Graphics.frame_reset
   end
 end
 #--------------------------------------------------------------------------
 # * Update Fog
 #--------------------------------------------------------------------------
 def update_fog
   # If fog is different than current fog
   if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
     @fog_name = $game_map.fog_name
     @fog_hue = $game_map.fog_hue
     if @fog.bitmap != nil
       @fog.bitmap.dispose
       @fog.bitmap = nil
     end
     if @fog_name != ""
       @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
     end
     Graphics.frame_reset
   end
 end
 #--------------------------------------------------------------------------
 # * Update Tilemap
 #--------------------------------------------------------------------------
 def update_tilemap
   # Update tilemap
   @tilemap.ox = $game_map.display_x / 4
   @tilemap.oy = $game_map.display_y / 4
   @tilemap.update
 end
 #--------------------------------------------------------------------------
 # * Update Panorama Plane
 #--------------------------------------------------------------------------
 def update_panorama_plane
   # Update panorama plane
   @panorama.ox = $game_map.display_x / 8
   @panorama.oy = $game_map.display_y / 8
 end
 #--------------------------------------------------------------------------
 # * Update Fog Plane
 #--------------------------------------------------------------------------
 def update_fog_plane
   # Update fog plane
   @fog.zoom_x = $game_map.fog_zoom / 100.0
   @fog.zoom_y = $game_map.fog_zoom / 100.0
   @fog.opacity = $game_map.fog_opacity
   @fog.blend_type = $game_map.fog_blend_type
   @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
   @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
   @fog.tone = $game_map.fog_tone
 end
 #--------------------------------------------------------------------------
 # * Update Character Sprites
 #--------------------------------------------------------------------------
 def update_character_sprites
   # Update character sprites
   for sprite in @character_sprites
     sprite.update
   end
 end
 #--------------------------------------------------------------------------
 # * Update Weather
 #--------------------------------------------------------------------------
 def update_weather
   # Update weather graphic
   @weather.type = $game_screen.weather_type
   @weather.max = $game_screen.weather_max
   @weather.ox = $game_map.display_x / 4
   @weather.oy = $game_map.display_y / 4
   @weather.update
 end
 #--------------------------------------------------------------------------
 # * Update Picture Sprites
 #--------------------------------------------------------------------------
 def update_picture_sprites
   # Update picture sprites
   for sprite in @picture_sprites
     sprite.update
   end
 end
end

#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs title screen processing.
#==============================================================================

class Scene_Title
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   return if main_battle_test?
   main_database
   main_background
   main_menu
   main_test_continue
   main_audio
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     main_loop
     break if main_scenechange?
   end
   # Prepare for transition
   Graphics.freeze
   main_dispose
 end
 #--------------------------------------------------------------------------
 # * Battle Test Check
 #--------------------------------------------------------------------------
 def main_battle_test?
   # If battle test
   if $BTEST
     battle_test
     return true
   end
   return false
 end
 #--------------------------------------------------------------------------
 # * Load Database
 #--------------------------------------------------------------------------
 def main_database
   # Load database
   $data_actors        = load_data("Data/Actors.rxdata")
   $data_classes       = load_data("Data/Classes.rxdata")
   $data_skills        = load_data("Data/Skills.rxdata")
   $data_items         = load_data("Data/Items.rxdata")
   $data_weapons       = load_data("Data/Weapons.rxdata")
   $data_armors        = load_data("Data/Armors.rxdata")
   $data_enemies       = load_data("Data/Enemies.rxdata")
   $data_troops        = load_data("Data/Troops.rxdata")
   $data_states        = load_data("Data/States.rxdata")
   $data_animations    = load_data("Data/Animations.rxdata")
   $data_tilesets      = load_data("Data/Tilesets.rxdata")
   $data_common_events = load_data("Data/CommonEvents.rxdata")
   $data_system        = load_data("Data/System.rxdata")
   # Make system object
   $game_system = Game_System.new
 end
 #--------------------------------------------------------------------------
 # * Background Initialization
 #--------------------------------------------------------------------------
 def main_background
   # Make title graphic
   @sprite = Sprite.new
   @sprite.bitmap = RPG::Cache.title($data_system.title_name)
 end
 #--------------------------------------------------------------------------
 # * Main Menu Initialization
 #--------------------------------------------------------------------------
 def main_menu
   # Make command window
   s1 = "New Game"
   s2 = "Continue"
   s3 = "Shutdown"
   @command_window = Window_Command.new(192, [s1, s2, s3])
   @command_window.back_opacity = 160
   @command_window.x = 320 - @command_window.width / 2
   @command_window.y = 288
 end
 #--------------------------------------------------------------------------
 # * Main Test Initialization
 #--------------------------------------------------------------------------
 def main_test_continue
   # Continue enabled determinant
   # Check if at least one save file exists
   # If enabled, make @continue_enabled true; if disabled, make it false
   @continue_enabled = false
   for i in 0..3
     if FileTest.exist?("Save#{i+1}.rxdata")
       @continue_enabled = true
     end
   end
   # If continue is enabled, move cursor to "Continue"
   # If disabled, display "Continue" text in gray
   if @continue_enabled
     @command_window.index = 1
   else
     @command_window.disable_item(1)
   end
 end
 #--------------------------------------------------------------------------
 # * Main Audio Initialization
 #--------------------------------------------------------------------------
 def main_audio
   # Play title BGM
   $game_system.bgm_play($data_system.title_bgm)
   # Stop playing ME and BGS
   Audio.me_stop
   Audio.bgs_stop
 end
 #--------------------------------------------------------------------------
 # * Main Loop
 #--------------------------------------------------------------------------
 def main_loop
   # Update game screen
   Graphics.update
   # Update input information
   Input.update
   # Frame update
   update
 end
 #--------------------------------------------------------------------------
 # * Main Scene Scene Change
 #--------------------------------------------------------------------------
 def main_scenechange?
   # Abort loop if screen is changed
   if $scene != self
     return true
   end
   return false
 end
 #--------------------------------------------------------------------------
 # * Main Dispose
 #--------------------------------------------------------------------------
 def main_dispose
   automatic_dispose
 end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   main_draw    
   # Main loop
   loop do
     main_loop
     break if main_scenechange?
   end
   main_dispose
   main_tiletrigger
 end
 #--------------------------------------------------------------------------
 # * Main Draw
 #--------------------------------------------------------------------------
 def main_draw
   # Make sprite set
   @spriteset = Spriteset_Map.new
   # Make message window
   @message_window = Window_Message.new
   # Transition run
   Graphics.transition
 end
 #--------------------------------------------------------------------------
 # * Main Loop
 #--------------------------------------------------------------------------
 def main_loop
   # Update game screen
   Graphics.update
   # Update input information
   Input.update
   # Frame update
   update
 end
 #--------------------------------------------------------------------------
 # * Main Scene Change
 #--------------------------------------------------------------------------
 def main_scenechange?
   # Abort loop if screen is changed
   if $scene != self
     return true
   end
   return false
 end
 #--------------------------------------------------------------------------
 # * Main Dispose
 #--------------------------------------------------------------------------
 def main_dispose
   Graphics.freeze
   @spriteset.dispose
   automatic_dispose
 end
 #--------------------------------------------------------------------------
 # * Main Tiletrigger
 #--------------------------------------------------------------------------
 def main_tiletrigger
   # If switching to title screen
   if $scene.is_a?(Scene_Title)
     # Fade out screen
     Graphics.transition
     Graphics.freeze
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Loop
   loop do
     update_systems
     # Abort loop if player isn't place moving
     unless $game_temp.player_transferring
       break
     end
     # Run place move
     transfer_player
     # Abort loop if transition processing
     if $game_temp.transition_processing
       break
     end
   end
   update_graphics
   return if update_game_over? == true
   return if update_to_title? == true
   # If transition processing
   if $game_temp.transition_processing
     # Clear transition processing flag
     $game_temp.transition_processing = false
     # Execute transition
     if $game_temp.transition_name == ""
       Graphics.transition(20)
     else
       Graphics.transition(40, "Graphics/Transitions/" +
         $game_temp.transition_name)
     end
   end
   # If showing message window
   if $game_temp.message_window_showing
     return
   end
   # If encounter list isn't empty, and encounter count is 0
   if $game_player.encounter_count == 0 and $game_map.encounter_list != []
     # If event is running or encounter is not forbidden
     unless $game_system.map_interpreter.running? or
            $game_system.encounter_disabled
       # Confirm troop
       n = rand($game_map.encounter_list.size)
       troop_id = $game_map.encounter_list[n]
       # If troop is valid
       if $data_troops[troop_id] != nil
         # Set battle calling flag
         $game_temp.battle_calling = true
         $game_temp.battle_troop_id = troop_id
         $game_temp.battle_can_escape = true
         $game_temp.battle_can_lose = false
         $game_temp.battle_proc = nil
       end
     end
   end
   update_call_menu
   update_call_debug
   # If player is not moving
   unless $game_player.moving?
     update_scene
   end
 end
 #--------------------------------------------------------------------------
 # * Update Systems
 #--------------------------------------------------------------------------
 def update_systems
   # Update map, interpreter, and player order
     # (this update order is important for when conditions are fulfilled 
     # to run any event, and the player isn't provided the opportunity to
     # move in an instant)
     $game_map.update
     $game_system.map_interpreter.update
     $game_player.update
     # Update system (timer), screen
     $game_system.update
     $game_screen.update
 end
 #--------------------------------------------------------------------------
 # * Update Graphics
 #--------------------------------------------------------------------------
 def update_graphics
   # Update sprite set
   @spriteset.update
   # Update message window
   @message_window.update
 end
 #--------------------------------------------------------------------------
 # * Update Game Over
 #--------------------------------------------------------------------------
 def update_game_over?
    # If game over
   if $game_temp.gameover
     # Switch to game over screen
     $scene = Scene_Gameover.new
     return true
   end
   return false
 end
 #--------------------------------------------------------------------------
 # * Update To Title
 #--------------------------------------------------------------------------
 def update_to_title?
   # If returning to title screen
   if $game_temp.to_title
     # Change to title screen
     $scene = Scene_Title.new
     return true
   end
   return false
 end
 #--------------------------------------------------------------------------
 # * Update Menu Call
 #--------------------------------------------------------------------------
 def update_call_menu
   # If B button was pressed
   if Input.trigger?(Input::B)
     # If event is running, or menu is not forbidden
     unless $game_system.map_interpreter.running? or
            $game_system.menu_disabled
       # Set menu calling flag or beep flag
       $game_temp.menu_calling = true
       $game_temp.menu_beep = true
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Update Debug Call
 #--------------------------------------------------------------------------
 def update_call_debug
   # If debug mode is ON and F9 key was pressed
   if $DEBUG and Input.press?(Input::F9)
     # Set debug calling flag
     $game_temp.debug_calling = true
   end
 end
 #--------------------------------------------------------------------------
 # * Update Scene
 #--------------------------------------------------------------------------
 def update_scene
   # Run calling of each screen
   if $game_temp.battle_calling
      call_battle
    elsif $game_temp.shop_calling
      call_shop
    elsif $game_temp.name_calling
      call_name
    elsif $game_temp.menu_calling
      call_menu
    elsif $game_temp.save_calling
      call_save
    elsif $game_temp.debug_calling
      call_debug
    end
 end
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_Menu
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     menu_index : command cursor's initial position
 #--------------------------------------------------------------------------
 def initialize(menu_index = 0)
   @menu_index = menu_index
   commands_init
 end
 #--------------------------------------------------------------------------
 # * Set Commands
 #--------------------------------------------------------------------------
 def commands_init
   @commands = []
   s1 = $data_system.words.item
   s2 = $data_system.words.skill
   s3 = $data_system.words.equip
   s4 = "Status"
   s5 = "Save"
   s6 = "End Game"
   @commands.push(s1, s2, s3, s4, s5, s6).flatten!
 end
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   main_command_window
   main_windows
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     main_loop
     break if main_scenechange?
   end
   # Refresh map
   $game_map.refresh
   # Prepare for transition
   Graphics.freeze
   main_dispose
 end
 #--------------------------------------------------------------------------
 # * Main Command Window
 #--------------------------------------------------------------------------
 def main_command_window
   @command_window = Window_Command.new(160, @commands)
   @command_window.index = @menu_index
   @command_window.height = 224
   # If number of party members is 0
   if $game_party.actors.size == 0
     # Disable items, skills, equipment, and status
     @command_window.disable_item(0)
     @command_window.disable_item(1)
     @command_window.disable_item(2)
     @command_window.disable_item(3)
   end
   # If save is forbidden
   if $game_system.save_disabled
     # Disable save
     @command_window.disable_item(4)
   end
 end
 #--------------------------------------------------------------------------
 # * Main Command Window
 #--------------------------------------------------------------------------
 def main_windows
   # Make play time window
   @playtime_window = Window_PlayTime.new
   @playtime_window.x = 0
   @playtime_window.y = 224
   # Make steps window
   @steps_window = Window_Steps.new
   @steps_window.x = 0
   @steps_window.y = 320
   # Make gold window
   @gold_window = Window_Gold.new
   @gold_window.x = 0
   @gold_window.y = 416
   # Make status window
   @status_window = Window_MenuStatus.new
   @status_window.x = 160
   @status_window.y = 0
  end
 #--------------------------------------------------------------------------
 # * Main Loop
 #--------------------------------------------------------------------------
  def main_loop 
    # Update game screen
    Graphics.update
    # Update input information
    Input.update
    # Frame update
    update
  end
 #--------------------------------------------------------------------------
 # * Scene Change
 #--------------------------------------------------------------------------
 def main_scenechange?
   # Abort loop if screen is changed
   if $scene != self
     return true
   end
   return false
 end
 #--------------------------------------------------------------------------
 # * Main Dispose
 #--------------------------------------------------------------------------
 def main_dispose
   # Dispose of windows
   @command_window.dispose
   @playtime_window.dispose
   @steps_window.dispose
   @gold_window.dispose
   @status_window.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @command_window.update
   @playtime_window.update
   @steps_window.update
   @gold_window.update
   @status_window.update
   # If command window is active: call update_command
   if @command_window.active
     update_command
     return
   end
   # If status window is active: call update_status
   if @status_window.active
     update_status
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when command window is active)
 #--------------------------------------------------------------------------
 def update_command
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Switch to map screen
     $scene = Scene_Map.new
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     update_command_check
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when status window is active)
 #--------------------------------------------------------------------------
 def update_status
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Make command window active
     @command_window.active = true
     @status_window.active = false
     @status_window.index = -1
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     buzzer_check
     update_status_check unless buzzer_check
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Buzzer Check
 #--------------------------------------------------------------------------
 def buzzer_check
   # If command other than save or end game, and party members = 0
   if $game_party.actors.size == 0 and @command_window.index < 4
     # Play buzzer SE
     $game_system.se_play($data_system.buzzer_se)
     return true
   end
 end
 #--------------------------------------------------------------------------
 # * Update Command Check
 #--------------------------------------------------------------------------
 def update_command_check
   # Loads Current Command
   command = @commands[@command_window.index]
   # Checks Commands
   if command == $data_system.words.item
     command_item
   elsif command == $data_system.words.skill
     command_start_skill
   elsif command == $data_system.words.equip
     command_start_equip
   elsif command == 'Status'
     command_start_status
   elsif command == 'Save'
     command_save
   elsif command == 'End Game'
     command_endgame
   end
 end
 #--------------------------------------------------------------------------
 # * Update Status Check
 #--------------------------------------------------------------------------
 def update_status_check
   # Loads Current Command
   command = @commands[@command_window.index]
   # Checks Command By Name
   if command == $data_system.words.skill
     command_skill
   elsif command == $data_system.words.equip
     command_equip
   elsif command == 'Status'
     command_status
   end
 end
 #--------------------------------------------------------------------------
 # * Command Item
 #--------------------------------------------------------------------------
 def command_item
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Switch to item screen
   $scene = Scene_Item.new
 end
 #--------------------------------------------------------------------------
 # * Command Start Skill
 #--------------------------------------------------------------------------
 def command_start_skill
   activate_status
 end
 #--------------------------------------------------------------------------
 # * Command Skill
 #--------------------------------------------------------------------------
 def command_skill
   # If this actor's action limit is 2 or more
   if $game_party.actors[@status_window.index].restriction >= 2
     # Play buzzer SE
     $game_system.se_play($data_system.buzzer_se)
     return
   end
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Switch to skill screen
   $scene = Scene_Skill.new(@status_window.index)
 end
 #--------------------------------------------------------------------------
 # * Command Start Equip
 #--------------------------------------------------------------------------
 def command_start_equip
   activate_status
 end
 #--------------------------------------------------------------------------
 # * Command Equip
 #--------------------------------------------------------------------------
 def command_equip
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Switch to equipment screen
   $scene = Scene_Equip.new(@status_window.index)
 end
 #--------------------------------------------------------------------------
 # * Command Start Status
 #--------------------------------------------------------------------------
 def command_start_status
   activate_status
 end
 #--------------------------------------------------------------------------
 # * Command Status
 #--------------------------------------------------------------------------
 def command_status
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Switch to status screen
   $scene = Scene_Status.new(@status_window.index)
 end
 #--------------------------------------------------------------------------
 # * Command Save
 #--------------------------------------------------------------------------
 def command_save
   # If saving is forbidden
   if $game_system.save_disabled
     # Play buzzer SE
     $game_system.se_play($data_system.buzzer_se)
     return
   end
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Switch to save screen
   $scene = Scene_Save.new
 end
 #--------------------------------------------------------------------------
 # * Command End Game
 #--------------------------------------------------------------------------
 def command_endgame
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Switch to end game screen
   $scene = Scene_End.new
 end
 #--------------------------------------------------------------------------
 # * Activate Status Window
 #--------------------------------------------------------------------------
 def activate_status
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Make status window active
   @command_window.active = false
   @status_window.active = true
   @status_window.index = 0
 end
end

#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
#  This class performs save screen processing.
#==============================================================================

class Scene_Save < Scene_File
 #--------------------------------------------------------------------------
 # * Write Save Data
 #     file : write file object (opened)
 #--------------------------------------------------------------------------
 def write_save_data(file)
   write_characters(file)
   write_frame(file)
   write_setup(file)
   write_data(file)
 end
 #--------------------------------------------------------------------------
 # * Make Character Data
 #--------------------------------------------------------------------------
 def write_characters(file)
   # Make character data for drawing save file
   characters = []
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     characters.push([actor.character_name, actor.character_hue])
   end
   # Write character data for drawing save file
   Marshal.dump(characters, file)
 end
 #--------------------------------------------------------------------------
 # * Write Frame Count
 #--------------------------------------------------------------------------
 def write_frame(file)
   # Wrire frame count for measuring play time
   Marshal.dump(Graphics.frame_count, file)
 end
 #--------------------------------------------------------------------------
 # * Write Setup
 #--------------------------------------------------------------------------
 def write_setup(file)
   # Increase save count by 1
   $game_system.save_count += 1
   # Save magic number
   # (A random value will be written each time saving with editor)
   $game_system.magic_number = $data_system.magic_number
 end
 #--------------------------------------------------------------------------
 # * Write Data
 #--------------------------------------------------------------------------
 def write_data(file)
   # Write each type of game object
   Marshal.dump($game_system, file)
   Marshal.dump($game_switches, file)
   Marshal.dump($game_variables, file)
   Marshal.dump($game_self_switches, file)
   Marshal.dump($game_screen, file)
   Marshal.dump($game_actors, file)
   Marshal.dump($game_party, file)
   Marshal.dump($game_troop, file)
   Marshal.dump($game_map, file)
   Marshal.dump($game_player, file)
 end
end

#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
#  This class performs load screen processing.
#==============================================================================

class Scene_Load < Scene_File
 #--------------------------------------------------------------------------
 # * Read Save Data
 #     file : file object for reading (opened)
 #--------------------------------------------------------------------------
 def read_save_data(file)
   read_characters(file)
   read_frame(file)
   read_data(file)
   read_edit
   read_refresh
 end
 #--------------------------------------------------------------------------
 # * Read Character Data
 #--------------------------------------------------------------------------
 def read_characters(file)
   # Read character data for drawing save file
   characters = Marshal.load(file)
 end
 #--------------------------------------------------------------------------
 # * Read Frame Count
 #--------------------------------------------------------------------------
 def read_frame(file)
   # Read frame count for measuring play time
   Graphics.frame_count = Marshal.load(file)
 end
 #--------------------------------------------------------------------------
 # * Read Data
 #--------------------------------------------------------------------------
 def read_data(file)
   # Read each type of game object
   $game_system        = Marshal.load(file)
   $game_switches      = Marshal.load(file)
   $game_variables     = Marshal.load(file)
   $game_self_switches = Marshal.load(file)
   $game_screen        = Marshal.load(file)
   $game_actors        = Marshal.load(file)
   $game_party         = Marshal.load(file)
   $game_troop         = Marshal.load(file)
   $game_map           = Marshal.load(file)
   $game_player        = Marshal.load(file)
 end
 #--------------------------------------------------------------------------
 # * Read Edit
 #--------------------------------------------------------------------------
 def read_edit
   # If magic number is different from when saving
   # (if editing was added with editor)
   if $game_system.magic_number != $data_system.magic_number
     # Load map
     $game_map.setup($game_map.map_id)
     $game_player.center($game_player.x, $game_player.y)
   end
 end
 #--------------------------------------------------------------------------
 # * Refresh Game Party
 #--------------------------------------------------------------------------
 def read_refresh
   # Refresh party members
   $game_party.refresh
 end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     menu_index : command cursor's initial position
 #--------------------------------------------------------------------------
 def initialize
   commands_init
 end
 #--------------------------------------------------------------------------
 # * Set Commands
 #--------------------------------------------------------------------------
 def commands_init
   @commands = []
   s1 = $data_system.words.attack
   s2 = $data_system.words.skill
   s3 = $data_system.words.guard
   s4 = $data_system.words.item
   @commands.push(s1, s2, s3, s4).flatten!
 end
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   main_temp
   main_troop
   main_command
   main_windows
   main_spriteset
   main_transition
   # Start pre-battle phase
   start_phase1
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     main_loop
     break if main_scenechange?
   end
   # Refresh map
   $game_map.refresh
   # Prepare for transition
   Graphics.freeze
   main_dispose
   main_end
 end
 #--------------------------------------------------------------------------
 # * Game Temp Variable Setup
 #--------------------------------------------------------------------------
 def main_temp
   # Initialize each kind of temporary battle data
   $game_temp.in_battle = true
   $game_temp.battle_turn = 0
   $game_temp.battle_event_flags.clear
   $game_temp.battle_abort = false
   $game_temp.battle_main_phase = false
   $game_temp.battleback_name = $game_map.battleback_name
   $game_temp.forcing_battler = nil
   # Initialize battle event interpreter
   $game_system.battle_interpreter.setup(nil, 0)
 end
 #--------------------------------------------------------------------------
 # * Troop Setup
 #--------------------------------------------------------------------------
 def main_troop
   # Prepare troop
   @troop_id = $game_temp.battle_troop_id
   $game_troop.setup(@troop_id)
 end
 #--------------------------------------------------------------------------
 # * Main Command Setup
 #--------------------------------------------------------------------------
 def main_command
   @actor_command_window = Window_Command.new(160, @commands)
   @actor_command_window.height = 160
   @actor_command_window.y = 160
   @actor_command_window.back_opacity = 160
   @actor_command_window.active = false
   @actor_command_window.visible = false
 end
 #--------------------------------------------------------------------------
 # * Scene Window Setup
 #--------------------------------------------------------------------------
 def main_windows
   # Make other windows
   @party_command_window = Window_PartyCommand.new
   @help_window = Window_Help.new
   @help_window.back_opacity = 160
   @help_window.visible = false
   @status_window = Window_BattleStatus.new
   @message_window = Window_Message.new
 end
 #--------------------------------------------------------------------------
 # * Spriteset Setup
 #--------------------------------------------------------------------------
 def main_spriteset
   # Make sprite set
   @spriteset = Spriteset_Battle.new
   # Initialize wait count
   @wait_count = 0
 end
 #--------------------------------------------------------------------------
 # * Main Transition
 #--------------------------------------------------------------------------
 def main_transition
   # Execute transition
   if $data_system.battle_transition == ""
     Graphics.transition(20)
   else
     Graphics.transition(40, "Graphics/Transitions/" +
       $data_system.battle_transition)
   end
 end
 #--------------------------------------------------------------------------

 # * Main Loop
 #--------------------------------------------------------------------------
 def main_loop
   # Update game screen
   Graphics.update
   # Update input information
   Input.update
   # Frame update
   update
 end
 #--------------------------------------------------------------------------
 # * Scene Change
 #--------------------------------------------------------------------------
 def main_scenechange?
   # Abort loop if screen is changed
   if $scene != self
     return true
   end
   return false
 end
 #--------------------------------------------------------------------------
 # * Main Dispose
 #--------------------------------------------------------------------------
 def main_dispose
   # Dispose of windows
   @actor_command_window.dispose
   @party_command_window.dispose
   @help_window.dispose
   @status_window.dispose
   @message_window.dispose
   @skill_window.dispose unless @skill_window == nil
   @item_window.dispose unless @item_window == nil
   @result_window.dispose unless @result_window == nil
   # Dispose of sprite set
   @spriteset.dispose
 end
 #--------------------------------------------------------------------------
 # * Main End
 #--------------------------------------------------------------------------
 def main_end
   # If switching to title screen
   if $scene.is_a?(Scene_Title)
     # Fade out screen
     Graphics.transition
     Graphics.freeze
   end
   # If switching from battle test to any screen other than game over screen
   if $BTEST and not $scene.is_a?(Scene_Gameover)
     $scene = nil
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   update_event
   update_system
   update_objects
   update_transition
   # If message window is showing
   if $game_temp.message_window_showing
     return
   end
   # If effect is showing
   if @spriteset.effect?
     return
   end
   update_scene_exit
   update_abort
   update_waiting
   update_phase
 end
 #--------------------------------------------------------------------------
 # * Event Update
 #--------------------------------------------------------------------------
 def update_event
   # If battle event is running
   if $game_system.battle_interpreter.running?
     # Update interpreter
     $game_system.battle_interpreter.update
     # If a battler which is forcing actions doesn't exist
     if $game_temp.forcing_battler == nil
       # If battle event has finished running
       unless $game_system.battle_interpreter.running?
         # Rerun battle event set up if battle continues
         unless judge
           setup_battle_event
         end
       end
       # If not after battle phase
       if @phase != 5
         # Refresh status window
         @status_window.refresh
       end
     end
   end
 end
 #--------------------------------------------------------------------------
 # * System Update
 #--------------------------------------------------------------------------
 def update_system
   # Update system (timer) and screen
   $game_system.update
   $game_screen.update
   # If timer has reached 0
   if $game_system.timer_working and $game_system.timer == 0
     # Abort battle
     $game_temp.battle_abort = true
   end
 end
 #--------------------------------------------------------------------------
 # * Windows and Sprites Update
 #--------------------------------------------------------------------------
 def update_objects
   # Update windows
   @help_window.update
   @party_command_window.update
   @actor_command_window.update
   @status_window.update
   @message_window.update
   # Update sprite set
   @spriteset.update
 end
 #--------------------------------------------------------------------------
 # * Transition Update
 #--------------------------------------------------------------------------
 def update_transition
   # If transition is processing
   if $game_temp.transition_processing
     # Clear transition processing flag
     $game_temp.transition_processing = false
     # Execute transition
     if $game_temp.transition_name == ""
       Graphics.transition(20)
     else
       Graphics.transition(40, "Graphics/Transitions/" +
         $game_temp.transition_name)
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Scene Exit Update
 #--------------------------------------------------------------------------
 def update_scene_exit
   # If game over
   if $game_temp.gameover
     # Switch to game over screen
     $scene = Scene_Gameover.new
     return
   end
   # If returning to title screen
   if $game_temp.to_title
     # Switch to title screen
     $scene = Scene_Title.new
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Abort Update
 #--------------------------------------------------------------------------
 def update_abort
   # If battle is aborted
   if $game_temp.battle_abort
     # Return to BGM used before battle started
     $game_system.bgm_play($game_temp.map_bgm)
     # Battle ends
     battle_end(1)
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Waiting Update
 #--------------------------------------------------------------------------
 def update_waiting
   # If waiting
   if @wait_count > 0
     # Decrease wait count
     @wait_count -= 1
     return
   end
   # If battler forcing an action doesn't exist,
   # and battle event is running
   if $game_temp.forcing_battler == nil and
      $game_system.battle_interpreter.running?
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Phase Update
 #--------------------------------------------------------------------------
 def update_phase
   # Branch according to phase
   case @phase
   when 1  # pre-battle phase
     update_phase1
   when 2  # party command phase
     update_phase2
   when 3  # actor command phase
     update_phase3
   when 4  # main phase
     update_phase4
   when 5  # after battle phase
     update_phase5
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (actor command phase : basic command)
 #--------------------------------------------------------------------------
 def update_phase3_basic_command
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Go to command input for previous actor
     phase3_prior_actor
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     check_commands
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Check Commands
 #--------------------------------------------------------------------------
 def check_commands
   # Loads Current Command
   command = @commands[@actor_command_window.index]
   # Branches Possible Commands
   if command == $data_system.words.attack
     update_phase3_command_attack
   elsif command == $data_system.words.skill
     update_phase3_command_skill
   elsif command == $data_system.words.guard
     update_phase3_command_guard
   elsif command == $data_system.words.item
     update_phase3_command_item
   end
 end
 #--------------------------------------------------------------------------
 # * Command : Attack
 #--------------------------------------------------------------------------
 def update_phase3_command_attack
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Set action
   @active_battler.current_action.kind = 0
   @active_battler.current_action.basic = 0
   # Start enemy selection
   start_enemy_select
 end
 #--------------------------------------------------------------------------
 # * Command : Skill
 #--------------------------------------------------------------------------
 def update_phase3_command_skill
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Set action
   @active_battler.current_action.kind = 1
   # Start skill selection
   start_skill_select
 end
 #--------------------------------------------------------------------------
 # * Command : Guard
 #--------------------------------------------------------------------------
 def update_phase3_command_guard
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Set action
   @active_battler.current_action.kind = 0
   @active_battler.current_action.basic = 1
   # Go to command input for next actor
   phase3_next_actor
 end
 #--------------------------------------------------------------------------
 # * Command : Item
 #--------------------------------------------------------------------------
 def update_phase3_command_item
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Set action
   @active_battler.current_action.kind = 2
   # Start item selection
   start_item_select
 end
 #--------------------------------------------------------------------------
 # * Make Basic Action Results
 #--------------------------------------------------------------------------
 def make_basic_action_result
   # If attack
   if @active_battler.current_action.basic == 0
     make_basic_action_result_attack
     return
   end
   # If guard
   if @active_battler.current_action.basic == 1
     make_basic_action_result_guard
     return
   end
   # If escape
   if @active_battler.is_a?(Game_Enemy) and
      @active_battler.current_action.basic == 2
     make_basic_action_result_escape
     return
   end
   # If doing nothing
   if @active_battler.current_action.basic == 3
     make_basic_action_result_nothing
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Make Basic Action Results - Attack
 #--------------------------------------------------------------------------
 def make_basic_action_result_attack
   # Set anaimation ID
   @animation1_id = @active_battler.animation1_id
   @animation2_id = @active_battler.animation2_id
   # If action battler is enemy
   if @active_battler.is_a?(Game_Enemy)
     if @active_battler.restriction == 3
       target = $game_troop.random_target_enemy
     elsif @active_battler.restriction == 2
       target = $game_party.random_target_actor
     else
       index = @active_battler.current_action.target_index
       target = $game_party.smooth_target_actor(index)
     end
   end
   # If action battler is actor
   if @active_battler.is_a?(Game_Actor)
     if @active_battler.restriction == 3
       target = $game_party.random_target_actor
     elsif @active_battler.restriction == 2
       target = $game_troop.random_target_enemy
     else
       index = @active_battler.current_action.target_index
       target = $game_troop.smooth_target_enemy(index)
     end
   end
   # Set array of targeted battlers
   @target_battlers = [target]
   # Apply normal attack results
   for target in @target_battlers
     target.attack_effect(@active_battler)
   end
 end
 #--------------------------------------------------------------------------
 # * Make Basic Action Results - Guard
 #--------------------------------------------------------------------------
 def make_basic_action_result_guard
   # Display "Guard" in help window
   @help_window.set_text($data_system.words.guard, 1)
 end
 #--------------------------------------------------------------------------
 # * Make Basic Action Results - Escape
 #--------------------------------------------------------------------------
 def make_basic_action_result_escape
   # Display "Escape" in help window
   @help_window.set_text("Escape", 1)
   # Escape
   @active_battler.escape
 end
 #--------------------------------------------------------------------------
 # * Make Basic Action Results - Nothing
 #--------------------------------------------------------------------------
 def make_basic_action_result_nothing
   # Clear battler being forced into action
   $game_temp.forcing_battler = nil
   # Shift to step 1
   @phase4_step = 1
 end
end

 

and it works on one of my computers but when I switched my project over to the other this happened.

30078849.png

plz help.

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

There is no way to help if you don't describe your specific error. You just said it didn't work. : /

Share this post


Link to post
Share on other sites
  • 0

I don't get an error what happens is when I moved the project from 1 computer to the other the text stopped showing.

Share this post


Link to post
Share on other sites
  • 0

Could be a font Issue if it worked on 1 computer and not another.

The other one might not have the font required.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...