Show posts

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

Messages - Vexus

1
Script Troubleshooting / Re: Editing Menu
March 20, 2015, 06:54:37 pm
Gonna check it tomorrow as i'm about to go to sleep.

Thanks

I was getting close-ish... sort of.

Spoiler: ShowHide


Created a new bitmap and was going to try mimicking the same idea in the status screen.

[Edit]

I kept what I did so far plus added what you posted on the previous post and it works.

Thanks :)

Now, I either add text directly in the game based on the position of the cursor or make a picture with text in it and align only the picture.
2
Script Troubleshooting / Re: Editing Menu
March 20, 2015, 03:32:44 pm
That....worked!

Thanks haha, adding a picture based on which option is being highlighted shouldn't be much trouble if I mimic the status window script you gave me.

Well, at least that's what I think.

[Edit]

Nope, I don't see how can I make it work.

Any help please?
3
Script Troubleshooting / Re: Editing Menu
March 20, 2015, 07:29:19 am
The go back part works, thanks :)

The other thing however is not working even with that line changed. The text is still not aligning with the cursor itself. I have a feeling there's something wrong in the script itself not overwriting some other script correctly.
4
Script Troubleshooting / Re: Editing Menu
March 19, 2015, 02:31:40 pm
Forgive me but I don't have any clue on how to do that myself so I might as well keep them in the same column.  Is it possible instead of having an option to go back, pressing ESC would send you back to the title screen?

Also would you mind checking what is the problem in the script above? The cursor/text are not getting aligned properly.

Thanks
5
Script Troubleshooting / Re: Editing Menu
March 19, 2015, 10:08:28 am
This has nothing to do with the menu but with the title screen but didn't see any point in making a new thread so.....

I am making a new title scene ontop of the default one and require some help.

I made it so when you click on new game instead of going into to the game, you go into a "new" title screen. This new one so far gives you the option to pick a difficulty or to go back to the title screen.

"Easy, Normal, Hard, Go Back"

Atm they show vertical, I want to show the first 3 horizontal and the fourth option underneath them unless it's too much work. (I'm thinking on adding a picture for each mode to explain what is different)

Once that is done, a help window shouldn't be too much hard to do.

How would I go in achieving this?

Spoiler: ShowHide
#==============================================================================
# ** Scene_Mode
#------------------------------------------------------------------------------
#  This class performs title screen processing.
#==============================================================================

class Scene_Mode
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Make system object
   $game_system = Game_System.new
   # Make title graphic
   @sprite = Sprite.new
   @sprite.bitmap = RPG::Cache.title($data_system.title_name)
   # Make command window
   s1 = "Easy Mode"
   s2 = "Normal Mode"
   s3 = "Hard Mode"
   s4 = "Go Back"
   @command_window = Window_Command.new(192, [s1, s2, s3, s4])
   @command_window.back_opacity = 160
   @command_window.x = 320 - @command_window.width / 2
   @command_window.y = 288
   # Play title BGM
   $game_system.bgm_play($data_system.title_bgm)
   # Stop playing ME and BGS
   Audio.me_stop
   Audio.bgs_stop
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update game screen
     Graphics.update
     # Update input information
     Input.update
     # Frame update
     update
     # Abort loop if screen is changed
     if $scene != self
       break
     end
   end
   # Prepare for transition
   Graphics.freeze
   # Dispose of command window
   @command_window.dispose
   # Dispose of title graphic
   @sprite.bitmap.dispose
   @sprite.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update command window
   @command_window.update
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Branch by command window cursor position
     case @command_window.index
     when 0  # Easy Mode
       command_easy_mode
     when 1  # Normal Mode
       command_normal_mode
     when 2  # Hard Mode
       command_hard_mode
     when 3  # Go Back
       command_go_back
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Command: Easy Mode
 #--------------------------------------------------------------------------
 def command_easy_mode
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Stop BGM
   Audio.bgm_stop
   # Reset frame count for measuring play time
   Graphics.frame_count = 0
   # Make each type of game object
   $game_temp          = Game_Temp.new
   $game_system        = Game_System.new
   $game_switches      = Game_Switches.new
   $game_variables     = Game_Variables.new
   $game_self_switches = Game_SelfSwitches.new
   $game_screen        = Game_Screen.new
   $game_actors        = Game_Actors.new
   $game_party         = Game_Party.new
   $game_troop         = Game_Troop.new
   $game_map           = Game_Map.new
   $game_player        = Game_Player.new
   # Set up initial party
   $game_party.setup_starting_members
   # Set up initial map position
   $game_map.setup($data_system.start_map_id)
   # Move player to initial position
   $game_player.moveto($data_system.start_x, $data_system.start_y)
   # Refresh player
   $game_player.refresh
   # Run automatic change for BGM and BGS set with map
   $game_map.autoplay
   # Update map (run parallel process event)
   $game_map.update
   # Switch to map screen
   $scene = Scene_Map.new
 end
 #--------------------------------------------------------------------------
 # * Command: Normal Mode
 #--------------------------------------------------------------------------
 def command_normal_mode
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Stop BGM
   Audio.bgm_stop
   # Reset frame count for measuring play time
   Graphics.frame_count = 0
   # Make each type of game object
   $game_temp          = Game_Temp.new
   $game_system        = Game_System.new
   $game_switches      = Game_Switches.new
   $game_variables     = Game_Variables.new
   $game_self_switches = Game_SelfSwitches.new
   $game_screen        = Game_Screen.new
   $game_actors        = Game_Actors.new
   $game_party         = Game_Party.new
   $game_troop         = Game_Troop.new
   $game_map           = Game_Map.new
   $game_player        = Game_Player.new
   # Set up initial party
   $game_party.setup_starting_members
   # Set up initial map position
   $game_map.setup($data_system.start_map_id)
   # Move player to initial position
   $game_player.moveto($data_system.start_x, $data_system.start_y)
   # Refresh player
   $game_player.refresh
   # Run automatic change for BGM and BGS set with map
   $game_map.autoplay
   # Update map (run parallel process event)
   $game_map.update
   # Switch to map screen
   $scene = Scene_Title.new
 end
 #--------------------------------------------------------------------------
 # * Command: Hard Mode
 #--------------------------------------------------------------------------
 def command_hard_mode
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Stop BGM
   Audio.bgm_stop
   # Reset frame count for measuring play time
   Graphics.frame_count = 0
   # Make each type of game object
   $game_temp          = Game_Temp.new
   $game_system        = Game_System.new
   $game_switches      = Game_Switches.new
   $game_variables     = Game_Variables.new
   $game_self_switches = Game_SelfSwitches.new
   $game_screen        = Game_Screen.new
   $game_actors        = Game_Actors.new
   $game_party         = Game_Party.new
   $game_troop         = Game_Troop.new
   $game_map           = Game_Map.new
   $game_player        = Game_Player.new
   # Set up initial party
   $game_party.setup_starting_members
   # Set up initial map position
   $game_map.setup($data_system.start_map_id)
   # Move player to initial position
   $game_player.moveto($data_system.start_x, $data_system.start_y)
   # Refresh player
   $game_player.refresh
   # Run automatic change for BGM and BGS set with map
   $game_map.autoplay
   # Update map (run parallel process event)
   $game_map.update
   # Switch to map screen
   $scene = Scene_Title.new
 end
 #--------------------------------------------------------------------------
 # * Command: Go Back
 #--------------------------------------------------------------------------
 def command_go_back
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Stop BGM
   Audio.bgm_stop
   # Reset frame count for measuring play time
   Graphics.frame_count = 0
   # Make each type of game object
   $game_temp          = Game_Temp.new
   $game_system        = Game_System.new
   $game_switches      = Game_Switches.new
   $game_variables     = Game_Variables.new
   $game_self_switches = Game_SelfSwitches.new
   $game_screen        = Game_Screen.new
   $game_actors        = Game_Actors.new
   $game_party         = Game_Party.new
   $game_troop         = Game_Troop.new
   $game_map           = Game_Map.new
   $game_player        = Game_Player.new
   # Set up initial party
   $game_party.setup_starting_members
   # Set up initial map position
   $game_map.setup($data_system.start_map_id)
   # Move player to initial position
   $game_player.moveto($data_system.start_x, $data_system.start_y)
   # Refresh player
   $game_player.refresh
   # Run automatic change for BGM and BGS set with map
   $game_map.autoplay
   # Update map (run parallel process event)
   $game_map.update
   # Switch to map screen
   $scene = Scene_Title.new
 end
end


The coding was taken from scene_title and edited to show those new options and it works. I tried removing redundant lines of codes but don't know if removing anything else would be bad.

[Edit]

This seems to work for horizontal commands but the text on cursor is not working as intended.

Spoiler: ShowHide
#==============================================================================
# Window Horizontal Command
# Created By SephirothSpawn (11.03.05)
# Last Updated: 11.03.05
#==============================================================================

class Window_HorizCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(commands, width = 640, height = 64)
super(0, 0, width, height)
self.contents = Bitmap.new(width - 32, height - 32)
@commands = commands
@item_max = @commands.size
@column_max = @commands.size
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
  draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
#  index : item number
#--------------------------------------------------------------------------
def draw_item(index)
width = self.width - 32
off = width / @item_max
x = 40 + index * off #4
self.contents.draw_text(x, 0, off - 32, 32, @commands[index]) #32, 32
end
#--------------------------------------------------------------------------
# * Disable Item
#  index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end


The first command is aligned "well" while the rest are all to the right like this:

6
General Discussion / Re: Screenshot Thread
March 14, 2015, 01:03:28 pm
A work in progress status screen for a town of salem (The web game) look alike project.

Spoiler: ShowHide


It's not finished yet as I need to do some final touches and would love some pointers from other people on how to make it better.

Say for example:

1] Gear Of Choice - I have no idea what to name this. It's to show what that specific role has a weaponry/etc at his disposal.
It has no use, but I can't think of anything to fill that empty space and it irks me big time!

2] The Picture - I might have to keep on editing the colors to make it more "brownish" to fit with the screen. Or should I keep it as is?

Feel free to add more ideas, I would really love to fill that empty bit.
7
Script Troubleshooting / Re: Status Screen
March 10, 2015, 03:27:00 pm
It works.

Thanks :)

I don't think I require any more scripting help for the time being on the status screen so thanks again.

It's time to see how to make it look good heh.
8
Script Troubleshooting / Re: Status Screen
March 10, 2015, 10:02:19 am
This I guess.

Spoiler: ShowHide
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# Diary Scene
# Author: ForeverZer0
# Version: 1.11
# Date: 1.17.2014
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
# Introduction:
#
#   This is a basic script that will allow you to keep a "diary" or notepad in
#   your game. It is very simple to use, and uses a simple interface for
#   displaying the notes.
#
# Features:
#
#   - Group your notes into "chapters".  
#   - Automatically formats text to fit on each line in a legible format.
#   - Simple script call to add text.
#   - Option to define each note in the script editor, then simply use a script
#     call to add it.
#   - Option to use the map as the background.
#
# Instructions:
#
#   - Place script above main, and below default scripts.
#   - Make configurations below.
#   - To call the scene, use this syntax:  $scene = Scene_Diary.new
#   - To add an entry, use this syntax:
#
#     Diary.add_entry(CHAPTER, TEXT)
#      
#     CHAPTER: An arbitrary integer to define what group to add the note to.
#     TEXT: Either a string which will be the text added to the diary, or an
#           integer which will return the string defined in the configuration
#           below. The second method will make it easier to make long notes
#           without filling up the little script call box.
#
# Author's Notes:
#
#  - Please be sure to report any bugs/issues with the script. Enjoy!
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

module Diary
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#                         BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 MAP_BACKGROUND = true
 # Set to true if you would like the map to show behind the window.
 RETURN_SCENE = Scene_Menu.new(1) # Scene_Map
 # The scene that the game returns to when you exit the diary.
 SCENE_ARGUMENTS = []
 # Define any arguments that may need called with scene if need be. Place them
 # in the array in the order in which they are normally called.
 
 def self.chapter_name(chapter)
   # Define the names of the "chapters".
   # when CHAPTER then "CHAPTER_NAME"
   return case chapter
   when 1 then 'Millenium Fair'
   when 2 then 'What Happened to Marle?'
   end
 end
 
 def self.entry(index)
   # Define the strings that correspond with each index. The index can be called
   # instead of actual text to add an entry.
   # when INDEX then "TEXT"
   return case index
   when 0 then 'I forgot today was the day of the big fair! I was supposed to go and
     see Lucca\'s new invention.'
   when 1 then 'I need to escort Marle around the fair, and maybe play a few games.'
   when 2 then 'Marle was sucked into the vortex. I think it had something to do with
that pendant that she was wearing...'
   when 3 then 'This place is very strange, and everyone talks funny. It\'s all vaguely
the same, yet different. Where am I?'
   when 4 then 'Here\'s how you can skip lines.\n\nThat made a line break. Now to see
your value stored in variable 5: \v[5]'
   end
 end

#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#                           END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
 def self.add_entry(chapter, text)
   # Add the chapter number if it does not exist.
   if $game_party.diary[chapter] == nil
     $game_party.diary[chapter] = []
   end
   if text.is_a?(String)
     # Add the new entry to the end of the chapter.
     $game_party.diary[chapter].push(text)
   elsif text.is_a?(Integer)
     # Get the defined note if the text is a number.
     $game_party.diary[chapter].push(self.entry(text))
   end
 end
end

#===============================================================================
# ** Window_Diary
#===============================================================================

class Window_Diary < Window_Base
 
 attr_reader :lines
 
 def initialize
   super(0, 64, 640, 352) # 0, 64, 640, 416
   self.back_opacity = Diary::MAP_BACKGROUND ? 220 : 220
   self.contents = Bitmap.new(width - 32, height - 32)
   @lines = []
 end
 
 def chapter=(chapter)
   # Reset the current entries.
   entries = $game_party.diary[chapter]
   entries = [''] if entries == nil
   # Divide the current entries into lines based off the text size and length.
   @lines = entries.collect {|text| self.contents.slice_text(text, 608) }
   @lines.flatten!
   refresh
 end
 
 def refresh
   # Dispose bitmap, returning if no lines are defined.
   self.contents.clear
   return if @lines.size == 0
   self.contents.dispose
   # Create bitmap to contain the lines.
   self.contents = Bitmap.new(self.width - 32, @lines.size * 32)
   # Draw each line.
   @lines.each_index {|i| self.contents.draw_text(0, i*32, 608, 32, @lines[i])}
 end
end

#===============================================================================
# ** Bitmap
#===============================================================================
   
class Bitmap
 
 # Blizzard's slice_text method. Updated by KK20 to include
 #  \n     -  New line
 #  \v[ID] -  Variable
 def slice_text(text, width)
   # Replace all instances of \v[n] to the game variable's value
   text.gsub!("\v") {"\\v"}
   text.gsub!("\V") {"\\v"}
   text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
   # Break up the text into lines
   lines = text.split("\\n")
   result = []
   # For each line generated from \n
   lines.each{|text_line|
     # Divide text into each individual word
     words = text_line.split(' ')
     current_text = words.shift
     # If there were less than two words in that line, just push the text
     if words.empty?
       result.push(current_text == nil ? "" : current_text)
       next
     end
     # Evaluate each word and determine when text overflows to a new line
     words.each_index {|i|
       if self.text_size("#{current_text} #{words[i]}").width > width
         result.push(current_text)
         current_text = words[i]
       else
         current_text = "#{current_text} #{words[i]}"
       end
       result.push(current_text) if i >= words.size - 1
     }
   }
   return result
 end
end

#===============================================================================
# ** Scene_Diary
#===============================================================================

class Scene_Diary
 
 def main
   # Create the windows.
   @sprites = [Window_Help.new, Window_Diary.new]
   if Diary::MAP_BACKGROUND
     @sprites.push(Spriteset_Map.new)
     @sprites[0].back_opacity = 220 #160
   end
   # Picture
   @diary = Sprite.new
   @diary.bitmap = RPG::Cache.picture("Hotbarbook.png") rescue nil
   @diary.opacity = 220
   
   @keys = $game_party.diary.keys.sort
   @names = @keys.collect {|chapter| Diary.chapter_name(chapter) }
   # Find current index, setting to first chapter if undefined.
   @index = @keys.index(Diary.chapter_name(@chapter))
   @index = 0 if @index == nil
   # Set the information for each window.
   @sprites[0].set_text(@names[@index] == nil ? '' : @names[@index], 1)
   @sprites[1].chapter = @keys[@index]
   # Transition Graphics.
   Graphics.transition
   # Main loop.
   loop { Graphics.update; Input.update; update; break if $scene != self }
   # Dispose windows.
   Graphics.freeze
   @diary.dispose
   @sprites.each {|sprite| sprite.dispose }
 end
 
 def update
   @diary.update
   # Branch by what input is recieved.
   if Input.repeat?(Input::UP) || Input.trigger?(Input::UP)
     $game_system.se_play($data_system.cursor_se)
     @sprites[1].oy -= 32 if @sprites[1].oy if @sprites[1].oy > 0
   elsif Input.repeat?(Input::DOWN) || Input.trigger?(Input::DOWN)
     $game_system.se_play($data_system.cursor_se)
     @sprites[1].oy += 32 if @sprites[1].oy < (@sprites[1].contents.height-384)
   elsif Input.trigger?(Input::L) || Input.trigger?(Input::R)
     $game_system.se_play($data_system.decision_se)
     # Change the current index.
     @index += Input.trigger?(Input::L) ? -1 : 1
     @index %= @keys.size
     # Display the name of the current chapter in the header.
     @sprites[0].set_text(@names[@index], 1)
     # Change the current chapter.
     @sprites[1].chapter = @keys[@index]
   elsif Input.trigger?(Input::B)
     # Play cancel SE and return to the defined scene.
     #$game_system.se_play($data_system.cancel_se)
     #args, scene = Diary::SCENE_ARGUMENTS, Diary::RETURN_SCENE
     #$scene = (args == []) ? scene.new : scene.new(*args)
     $game_system.se_play($data_system.decision_se)
     $scene = Scene_Menu.new(1)
   end
 end
 
end

#===============================================================================
# ** Game_Party
#===============================================================================

class Game_Party
 
 attr_accessor :diary
 
 alias zer0_diary_init initialize
 def initialize
   zer0_diary_init
   @diary = {}
 end
end


And

Spoiler: ShowHide
#==============================================================================
# ** Multiple Message Windows
#------------------------------------------------------------------------------
# Originally written by Wachunga
# Optimized and De-SDK'ed by ForeverZer0
# Blizz Abs Version by LiTTleDRAgo
# 1.5x
# 2006-11-17
#==============================================================================
=begin

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

- Credit for the original script is 100% Wachunga. Original map and events
  are also Wachunga's original.

- Edits have been made by ForeverZer0 to eliminate the SDK requirement
  and improve coding and performance
- I have added a compatibility switch for Blizzard's simple shaded text if you
  are you using that, because it doesn't look right with message text. The
  switch will disable it whenever a message is showing, but otherwise will
  shade everything else.
- This script must be placed below Blizzard's Tons-of-Add-ons if you are
  using it. If you don't you will get an error. It has something to do with
  the Lagless HUD script. Some bug I couldn't isolate... If you find it, let
  me know, else just keep it under Tons.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  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.5x
 
  * \f[face_image] = display faceset image
                   image must be placed in folder pictures and the size
                   is 80x80

  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)
  =============================================================================
 
  Zer0 Note:
  If you use any of these in another script, etc. and not a script call, you
  will need to place "$game_system." before each command.
 
  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

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

  # Zer0 Edit. Blizzard's Simple Shaded Text just looks kinda funny when used
  # on black text (which is default for MMS). If you are using Shaded Text and
  # do not want it to display for the message windows, set this to true. It will
  # still show for everything else.
 
  Blizzard_Shaded_Text_Fix = true
 
  #----------------------------------------------------------------------------
  # 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 = 'w_tail.png'
  FILENAME_SPEECH_WINDOWSKIN = 'Chat.png'

  # filenames of tail and windowskin used for thought balloons
  FILENAME_THOUGHT_TAIL = 'w_tail.png'
  FILENAME_THOUGHT_WINDOWSKIN = 'wwskin_n.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 = "#FFFFFF"
  SPEECH_FONT_NAME = ['Zephyr']
  SPEECH_FONT_SIZE = 22
 
  # defaults for thought text
  THOUGHT_FONT_COLOR = "#000000"
  THOUGHT_FONT_NAME = ['Sylfaen']
  THOUGHT_FONT_SIZE = 22

  # note that you can use an array of fonts for SPEECH_FONT_NAME, etc.
  # e.g. ['Verdana', 'MS PGothic']
  # (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 = true

    # whether the player is permitted to move while messages are displayed
    @move_during = false
   
    # 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
 
#==============================================================================
# ** Window_Message
#------------------------------------------------------------------------------
#  This message window is used to display text.
#==============================================================================
class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(msgindex=0)
    super(80, 304, 480, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.visible = false
    self.z = 9999 + msgindex * 5 # permits messages to overlap legibly 9000
    @fade_in = false
    @fade_out = false
    @contents_showing = false
    @cursor_width = 0
    self.active = false
    self.index = -1
    @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 && $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 && $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
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    terminate_message
    # have to check all windows before claiming that no window is showing
    if $game_temp.message_text.compact.empty?
      $game_temp.message_window_showing = false
    end
    if @input_number_window != nil
      @input_number_window.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # * Terminate Message
  #--------------------------------------------------------------------------
  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
    @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
    $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
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @x = @y = 0 # now instance variables
    @float_id = nil
    @location = $game_system.message.location
    if $game_system.message.floating && $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 && $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
    @cursor_width = 0
    # Indent if choice
    if $game_temp.choice_start == 0
      @x = 8
    end
    # If waiting for a message to be displayed
    if $game_temp.message_text[@msgindex] != nil
      @text = $game_temp.message_text[@msgindex] # now an instance variable
      # 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]+)\]/) {
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : '' }
      @text.gsub!(/\\[Nn][Aa][Mm][Ee]\[([0-9]+)\]/) {
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : '' }
      # Change "\\\\" to "\000" for convenience
      @text.gsub!(/\\\\/) { "\000" }
      @text.gsub!(/\\[Gg]/) { "\002" }
      # 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]+)\]/) {
        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 : ''   }
      # display icon and name of item, weapon, armor or skill
      @text.gsub!(/\\[Ii]&[Nn]\[([IiWwAaSs])([0-9]+)\]/) {
        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 : ''    }     
      # 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" }
      @text.gsub!(/\\[Ff]\[(.+?)(?:,(\d+))?\]/) { "\014[#{$1}]" }
      # 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 &&
          $game_temp.in_battle
        @float_id = $1.downcase
      elsif @text.gsub!(/\\[Pp]/, '') != nil ||
        ($game_system.message.floating && $game_system.message.resize) &&
        (!$game_temp.in_battle)
        @float_id = $game_system.map_interpreter.event_id
      end
      if $game_system.message.resize || $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]
        (0..3).each  do |i|
          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 && @text != ''
        @x = (self.width-40)/2 - @line_widths[0]/2
      end
    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 {|line| max_y -= 1 if line == 0 && max_y > 1}
    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 && 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 || char.screen_x >= 640 ||
         char.screen_y <= 0 || 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 && 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 && (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 && 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 && (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 && @location == 2 && (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 && $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 c == "\014"
          @text.sub!(/\[(.+?)(?:,(\d+))?\]/, '')
          face = $1.to_s
          if face != ''     
            terminate_face rescue return
            face = RPG::Cache.picture(face)
            bitmap = Bitmap.new(80,80)
            bitmap.stretch_blt(bitmap.rect, face, face.rect)
            @face = Sprite.new
            @face.bitmap = bitmap
            face_position rescue return
          end
          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 && @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 || @player_skip
        return if @letter_by_letter && !@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 = 220 #255
    else
      self.opacity = 0
    end
    # transparent speech balloons don't look right, so keep opacity at 255
    # self.back_opacity = 160
    @tail.opacity = 255
  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
    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
      # Confirm or cancel finishes waiting for input or message
      if Input.trigger?(Input::C) || 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 && !@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 && ($game_temp.choice_max == 0 || @wait_for_input)
        self.pause = true unless !$game_system.message.show_pause
      end
      # Cancel
      if Input.trigger?(Input::B)
        if $game_temp.choice_max > 0 && $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
        # personal preference: cancel button should also continue
        terminate_message
      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 && $game_temp.message_text[@msgindex] != nil
      @contents_showing = true
      $game_temp.message_window_showing = true
      reset_window
      refresh
      Graphics.frame_reset
      self.visible = true
      if show_message_tail?
        @tail.visible = true
      elsif @tail.visible
        @tail.visible = false
      end
      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
      @tail.opacity -= 96 if @tail.opacity > 0
      if need_reposition?
        reposition # update message position for character/screen movement
      end
      if self.opacity == 0
        self.visible = false
        @fade_out = false
        @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?
          $game_temp.message_window_showing = false 
        end
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Repositioning Determination
  #--------------------------------------------------------------------------
  def need_reposition?
    if (!$game_temp.in_battle) && $game_system.message.floating &&
        $game_system.message.resize && @float_id != nil
      if $game_system.message.move_during && @float_id == 0 &&
          (($game_player.last_real_x != $game_player.real_x) ||
          ($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) ||
         ($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 &&
          ((char.last_real_x != char.real_x) ||
          (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 && $game_system.message.floating &&
      $game_system.message.resize && $game_system.message_frame == 0 &&
      @float_id != nil
      return true
    end
    return false
  end
 
  def update_cursor_rect
    if @index >= 0
      n = $game_temp.choice_start + @index
      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)
    else
      self.cursor_rect.empty
    end
  end
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias drg128_term terminate_message unless method_defined?(:drg128_term)
  alias drg128_upd update unless method_defined?(:drg128_upd)
  #--------------------------------------------------------------------------
  # * Face Position
  #--------------------------------------------------------------------------
  def face_position
    return if !@face || @face.disposed?
    @face.oy = (@face.bitmap.height/8)
    @face.x, @face.y = self.x-(@face.bitmap.width+2), self.y   
  end
  #--------------------------------------------------------------------------
  # * Terminate Face
  #--------------------------------------------------------------------------
  def terminate_face
    return unless @face && !@face.disposed?
    @face.dispose
    @face = nil
  end
  #--------------------------------------------------------------------------
  # * Terminate Message
  #--------------------------------------------------------------------------
  def terminate_message
    terminate_face
    drg128_term
  end
  #--------------------------------------------------------------------------
  # * Update Frame
  #--------------------------------------------------------------------------
  def update
    temp = $game_temp.in_battle
    $game_temp.in_battle = $scene.is_a?(Scene_Battle)
    face_position
    drg128_upd
    $game_temp.in_battle = temp
  end
end


class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :last_real_x, :last_real_y   
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias drg128a_upd update unless method_defined?(:drg128a_upd)
  #--------------------------------------------------------------------------
  # * Update Frame
  #--------------------------------------------------------------------------
  def update
    @last_real_x, @last_real_y = @real_x, @real_y
    drg128a_upd
  end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  This class handles temporary data that is not included with save data.
#  Refer to "$game_temp" for the instance of this class.
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias drg128_init initialize unless method_defined?(:drg128_init)
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    drg128_init
    @message_text,@message_proc = [],[]
  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 < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  # necessary for positioning messages relative to battlers
  attr_reader :height, :width
end

#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within
#  the Scene_Battle class.
#==============================================================================
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  # necessary for accessing actor/enemy sprites in battle
  attr_reader :actor_sprites, :enemy_sprites
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================
(0...2).each {|i| eval "
class Scene_#{['Map','Battle'][i]}
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  # necessary for accessing actor/enemy sprites in battle
  attr_reader :spriteset
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias drg128_main main unless method_defined?(:drg128_main)
  alias drg128_upd update unless method_defined?(:drg128_upd)
  #--------------------------------------------------------------------------
  # * New Message Window Addition
  #--------------------------------------------------------------------------
  def new_message_window(index)
    if @multi_message_window[index] != nil
      # clear message windows at and after this index
      last_index = @multi_message_window.size - 1
      last_index.downto(index) { |i|
        if @multi_message_window[i] != nil
          @multi_message_window[i].dispose
          @multi_message_window[i] = nil
        end      }
      @multi_message_window.compact!
    end
    @multi_message_window.push(Window_Message.new(index))
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    @multi_message_window = []                             
    @multi_message_window[0] = Window_Message.new(0)
    drg128_main
    @multi_message_window.each {|mw| mw.dispose}   
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @message_window = Nothing.new if !@message_window.is_a?(Nothing)
    drg128_upd
    @multi_message_window.each {|mw| mw.update}   
  end
end#"}

#==============================================================================
# ** Nothing
#------------------------------------------------------------------------------
#  There is nothing here
#==============================================================================
class Nothing
  def update() end
  def dispose() end
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles data surrounding the system. Backround music, etc.
#  is managed here as well. Refer to "$game_system" for the instance of
#  this class.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :message
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  unless method_defined?(:wachunga_mmw_game_system_init)
    alias wachunga_mmw_game_system_init initialize
    alias zer0_shaded_text_fix_upd update
  end
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    wachunga_mmw_game_system_init
    @message = Game_Message.new
  end
  #--------------------------------------------------------------------------
  # Can Move?
  #--------------------------------------------------------------------------
  def blizzabs_can_move?(type=0)
    player = $BlizzABS.actors[0]
    message_showing = $game_temp.message_window_showing
    interpreter = $game_system.map_interpreter.running?
    return type == 0 ? (((player.ai.act.defend? && player.attacked == 0) ||
          $game_system.turn_button && Input.press?(Input::Turn)) &&
          !player.moving? && !player.move_route_forcing &&
          (!interpreter || message_showing) &&
          (!message_showing || $game_system.message.move_during) &&
          $game_temp.choice_max <= 0 && $game_temp.num_input_digits_max <= 0) :
          (player.move_route_forcing ||  (interpreter && !message_showing) ||
          (message_showing && !$game_system.message.move_during) ||
          ($game_temp.choice_max > 0 || $game_temp.num_input_digits_max > 0))
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  # Zer0 Edit
  def update
    zer0_shaded_text_fix_upd
    if @SHADED_TEXT != nil && Blizzard_Shaded_Text_Fix == true
      if $game_temp.message_window_showing
        @SHADED_TEXT = false
      else
        @SHADED_TEXT = true
      end
    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   
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias drg128b_upd update unless method_defined?(:drg128b_upd)
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    message_showing = $game_temp.message_window_showing
    unless moving? || @move_route_forcing ||
      ($game_system.map_interpreter.running? && !message_showing) ||
      (message_showing && !$game_system.message.move_during) ||
      ($game_temp.choice_max > 0 || $game_temp.num_input_digits_max > 0)
      input = Input.dir4
      if input
        case input
        when 2 then move_down
        when 4 then move_left
        when 6 then move_right
        when 8 then move_up
        end
      end
    end
    drg128b_upd
  end
  #--------------------------------------------------------------------------
  # * Touch Event Starting Determinant
  #--------------------------------------------------------------------------
  # This is a fix if Blizzard's Optimized default scripts are being used
  def check_event_trigger_touch(x, y)
    result = false                         # <--------- MOVED from....
    # If event is running
    if $game_system.map_interpreter.running?
      return result
    end
    #result = false                        # <--------- ...HERE
    # All event loops
    $game_map.events.each_value {|event|
      # If event coordinates and triggers are consistent
      if event.x == x && event.y == y && [1,2].include?(event.trigger)
        # If starting determinant is front event (other than jumping)
        if !event.jumping? && !event.over_trigger?
          event.start
          result = true
        end
      end }
    return result
  end
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :event_id
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias drg128_setup setup unless method_defined?(:drg128_setup)
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(list, event_id)
    drg128_setup(list, event_id)
    # index of window for the message
    @msgindex = 0
    # whether multiple messages are displaying
    @multi_message = false
  end
  #--------------------------------------------------------------------------
  # * Setup Choices
  #--------------------------------------------------------------------------
  def setup_choices(parameters)
    # Set choice item count to choice_max
    $game_temp.choice_max = parameters[0].size
    # Set choice to message_text
    parameters[0].each {|text| $game_temp.message_text[@msgindex] += text + "\n"}
    # 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
    if $game_temp.message_text[@msgindex] != nil
      if @multi_message
        @msgindex += 1
        $scene.new_message_window(@msgindex)
      else
        # End
        return false
      end
    end
    @msgindex = 0 if !@multi_message
    @multi_message = false
    # Set message end waiting flag and callback
    @message_waiting = true
    # 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"
    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
        # just adding index
        $game_temp.message_text[@msgindex]+=@list[@index+1].parameters[0]+"\n"
        line_count += 1
      # If event command is not on the second line or after
      else
        # If next event command is show choices
        if @list[@index+1].code == 102
          # 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
        # 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
        # Continue
        return true
      end
      # Advance index
      @index += 1
    end
  end
  #--------------------------------------------------------------------------
  # * Show Choices
  #--------------------------------------------------------------------------
  def command_102
    # If text has been set to message_text
    # just adding index
    if $game_temp.message_text[@msgindex] != nil
      # End
      return false
    end
    # Set message end waiting flag and callback
    @message_waiting = true
    # adding more indexes
    $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
    # Choices setup
    $game_temp.message_text[@msgindex] = ''
    $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
    # just adding index
    if $game_temp.message_text[@msgindex] != nil
      # End
      return false
    end
    # Set message end waiting flag and callback
    @message_waiting = true
    # adding more indexes
    $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
    # Number input setup
    $game_temp.message_text[@msgindex] = ''
    $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
      #return false
    end
    # Continue
    return true
  end
  #--------------------------------------------------------------------------
  # * Message
  #--------------------------------------------------------------------------
  def message
    message = $game_system.message if $game_system != nil
  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
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :last_display_x,:last_display_y     
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias drg128_upd update unless method_defined?(:drg128_upd)
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @last_display_x = @display_x
    @last_display_y = @display_y
    drg128_upd
  end
  #--------------------------------------------------------------------------
  # * Name
  #--------------------------------------------------------------------------
  def name
    return load_data('Data/MapInfos.rxdata')[@map_id].name
  end
end
#==============================================================================
# ** Bitmap
#------------------------------------------------------------------------------
#  This class is for all in-game bitmap.
#==============================================================================
class Bitmap
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  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
      degrees += 360 if degrees < 0
      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
      (0...self.height).each {|i|
        (0...self.width).each {|j|
          self.set_pixel(width - i - 1, j, copy.get_pixel(j, i))}}
    elsif degrees == 180
      (0...self.height).each {|i|
        (0...self.width).each {|j|
          self.set_pixel(width - j - 1, height - i - 1, copy.get_pixel(j, i))} }     
    elsif degrees == 270
      (0...self.height).each {|i|
        (0...self.width).each {|j|
          self.set_pixel(i, height - j - 1, copy.get_pixel(j, i)) } }
    end
    @orientation = (@orientation + degrees) % 360
  end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================
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 && color <= 7
        return text_color(color)
      end
    end
    return normal_color
  end
end
#==============================================================================
# ** Window_InputNumber
#------------------------------------------------------------------------------
#  This window is for inputting numbers, and is used within the
#  message window.
#==============================================================================
class Window_InputNumber < Window_Base
  #--------------------------------------------------------------------------
  # * Set Font
  #--------------------------------------------------------------------------
  def set_font(fname, fsize, fcolor)
    return if fname == nil && fsize == nil && 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
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    s = sprintf("%0*d", @digits_max, @number)
    (0...@digits_max).each {|i|
      self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1]) }
  end
end
9
Script Troubleshooting / Re: Status Screen
March 09, 2015, 04:27:51 pm
Okay it seems to be working now.

Any clue why /n or \n has no effect?

I'd really like that option for a new line too.
10
Script Troubleshooting / Re: Status Screen
March 09, 2015, 03:54:23 pm
Doesn't seem to want to work with the slice method.

As you have guessed, the text is too long for a single line so I'd need the /n method to cut text in multiple lines.

For the text to show I also had to add:

draw_class_description(@actor, 40, 200)


Spoiler: ShowHide
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Status < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 640, 417)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 220
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_rolepic(@actor, 460, 180)
    draw_actor_face(@actor, 10, 196)
    draw_class_description(@actor, 40, 200)
    self.contents.draw_text(280, 0, 200, 32, @actor.name)#(@actor, 270, 0) #4, 0
    draw_actor_class(@actor, 280, 30) #310, 0
    self.contents.font.color = normal_color
    self.contents.draw_text(210, 0, 140, 32, "Name: ")
    self.contents.draw_text(210, 30, 90, 32, "Role: ")
  end
end
  #--------------------------------------------------------------------------
  # * Picture Face
  #--------------------------------------------------------------------------
  def draw_actor_face(actor, x, y)
    face = RPG::Cache.character("Faces/" + actor.character_name, actor.character_hue)
    fw = face.width
    fh = face.height
    src_rect = Rect.new(0, 0, fw, fh)
    self.contents.blt(x - fw / 23, y - fh, face, src_rect)
  end
  #--------------------------------------------------------------------------
  # * Picture Role
  #--------------------------------------------------------------------------
  def draw_actor_rolepic(actor, x, y)
    rolepic = RPG::Cache.picture(actor.class_name)
    fw = rolepic.width
    fh = rolepic.height
    src_rect = Rect.new(0, 0, fw, fh)
    self.contents.blt(x - fw / 23, y - fh, rolepic, src_rect)
  end
  #--------------------------------------------------------------------------
  # * Role Description
  #--------------------------------------------------------------------------
  def draw_class_description(actor, x, y, width)
    text = case actor.class_id
    when 1 then "Heals one person every night, \n preventing them from dying should they be attacked"
    when 2 then "Checks one player at night and sees if they are a Serial Killer or a member of the Mafia"
    when 3 then "Sheriff"
    when 4 then "Serial Killer"
  end
    self.contents.slice_text(text, width).each{ |line|
    self.contents.draw_text(10,120,640,200,line)
    y += 200
    }
  end
11
Script Troubleshooting / Re: Status Screen
March 08, 2015, 02:14:17 pm
Sweet, thanks :)

I'll try fooling around and if I have any problem I'll post again.

[Edit]

Okay, the picture itself was easy enough following what you told me above but what about a description based on what class you get?
12
Script Troubleshooting / Re: Status Screen
March 08, 2015, 03:30:06 am
[Edit]

After some trial and error I made it work.

self.contents.draw_text(270, 0, 200, 32, @actor.name)


That is correct right?

Another question I had is about wanting to show an additional picture in the status screen with text depending on what class you get. (Atm there are 4)

How would I go in creating something like that?

The current script of window_status is this:

Spoiler: ShowHide
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Status < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 640, 417)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 200
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_face(@actor, 10, 190)
    self.contents.draw_text(270, 0, 200, 32, @actor.name)#(@actor, 270, 0) #4, 0
    draw_actor_class(@actor, 270, 30) #310, 0
    self.contents.font.color = normal_color
    self.contents.draw_text(210, 0, 90, 32, "Name: ")
    self.contents.draw_text(210, 30, 90, 32, "Role: ")
  end
end
  #--------------------------------------------------------------------------
  # * Picture Face
  #--------------------------------------------------------------------------
  def draw_actor_face(actor, x, y)
    face = RPG::Cache.character("Faces/" + actor.character_name, actor.character_hue)
    fw = face.width
    fh = face.height
    src_rect = Rect.new(0, 0, fw, fh)
    self.contents.blt(x - fw / 23, y - fh, face, src_rect)
  end
13
Script Troubleshooting / Status Screen
March 07, 2015, 05:16:09 pm
After a couple of trial and errors I finally opted to change some stuff in the menus to make it look neater.

Now dialog uses a custom script and all menus show the hotbar at the bottom (Each with a different picture as will be shown in one of the pictures I'm uploading). Anyway, I started fooling around the status screen and stumbled on a text limit.

Spoiler: ShowHide


This name kinda fits but I have a longer name that doesn't. I tried changing values but the bigger name doesn't seem to improve...

What should I be changing to increase the text limit for names?

After fixing this tiny issue I got some other questions if you people don't mind.

Thanks

(The face is probably a placeholder, I just wanted to add something so I could adjust the layout)
14
Script Troubleshooting / Re: Editing Menu
February 23, 2015, 10:15:06 am
I tried it in a hurry before going to sleep  :P

Anyway, I tried something similar before but it shows for a split second when the game launches and the picture never shows in any dialogue.
15
Script Troubleshooting / Re: Editing Menu
February 22, 2015, 04:20:51 pm
You asked me how the menu works so I posted the code. I mean, showing a picture wouldn't solve anything heh... When I was trying to show a picture for when dialogue is on the screen, I tried to copy the same lines of code used in that scene menu but alas it doesn't work in window_message as it gives an error.

Scene_Map is default atm. I had no idea it was tied to the window_message. I'm not familiar with the rmxp coding language.

All I was trying to accomplish is, showing a custom picture on the screen whenever you speak with an npc or interact with something. Hiding the window is easy with opacity = 0, showing a picture to have the text show over it was giving me a headache to make it work as I don't have much knowledge on ruby.

I'll check it tomorrow and see if that is what I was trying to accomplish.

Thank you for the help.

[Edit]

Nope, gives me a nomethod error on:

@message_picture.visible = false


If I comment it off gives an error on other lines like:

message_pictue.update


and

Spoiler: ShowHide
    # If showing message window
   if $game_temp.message_window_showing
     @message_picture.visible = true
     return
   else
     @message_picture.visible = false
   end


I am using http://forum.chaos-project.com/index.php/topic,14790.0.html ring choice window script if that has any incompatabilities.
16
Script Troubleshooting / Re: Editing Menu
February 21, 2015, 06:33:34 pm
Quote from: KK20 on February 21, 2015, 04:16:08 pm
What is @menu_back? How are you initializing it? How does your Scene_Map look? How does the menu even work? Why does the menu even need to be visible during dialogue?

All of these things I have no idea. Thus, post a demo or I'm done.


@menu_back is what I guess the code information is stored in:

Spoiler: ShowHide
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================
class Scene_Menu
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    #Invisible Background
    @mapback = Spriteset_Map.new
    #Picture under windowskin
    @menu_back = Sprite.new
    @menu_back.bitmap = RPG::Cache.picture("") rescue nil
    @menu_back.z = 3000 #3000
    @menu_back.opacity = 0
    icons = ['Menu0','Menu1','Menu2']
    @command_window = Window_Item_Command.new(0,64,@menu_index) #0,64
    @help_window = Window_Help.new
    @help_window.opacity = 0
    @help_window.x = 0
    @help_window.y = 415 # 415
    @help_window.z = 3000 #3000
    @command_window.help_window = @help_window
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    @menu_back.dispose
    @command_window.dispose
    @help_window.dispose
    @mapback.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @mapback.update
    @command_window.update
    @help_window.update
    @menu_back.update


- Scene_Map is untouched.

- I mentioned the menu because it has that piece of coding (As shown above) that let's me show a picture instead of using the windowskin when the menu is called. I never said the menu needs to show up when dialogue is on the screen, I just said I'm trying to show a picture instead of the windowskin.

I'm simply asking how can I show a picture when dialogue appears on the screen via scripting.

I could provide a demo if you really need it eventough I see no point. The only script I have in it so far is an edit of the original menu.
17
Script Troubleshooting / Re: Editing Menu
February 21, 2015, 04:09:03 pm
I'm trying to show a picture in window_message when dialogue appears on the screen and this line of code that I use in scene_menu:

@menu_back.bitmap = RPG::Cache.picture("") rescue nil


Doesn't work.

Don't know how can I explain more easy than that.
18
Script Troubleshooting / Re: Editing Menu
February 21, 2015, 05:24:34 am
So no one can guide me on how to show a picture in window_message?

@menu_back.bitmap = RPG::Cache.picture("") rescue nil


This type of code gives me an error since it's in window type not class type.
19
Script Troubleshooting / Re: Editing Menu
February 19, 2015, 10:01:25 am
Well...... That's how it's set atm.

Opacity = 0 and the picture showing underneath. I however, was thinking on making the said picture show only when dialogue appears, just like the picture shows when the menu is called.

And by trying, I meant trying to use something like this in window_message:

@menu_back.bitmap = RPG::Cache.picture("") rescue nil
20
Script Troubleshooting / Re: Editing Menu
February 18, 2015, 03:56:42 pm
Replacing the windowskin with a picture would be so much easier than having to add the picture on every dialogue tough.

I did it successfully for the menu and other windows but I can't seem to understand how to show a picture as background instead of the windowskin when a message appears.