Atoa SBS - Incompatible message systems

Hey y'all

I'm trying to make a speech-bubble type message system work with SBS
The only one I found so far that does pretty much precisely what I wanted (bubble speech + functioning speech in combat) is Wachunga MMW

  1. #==============================================================================
  2. # ** Multiple Message Windows
  3. #------------------------------------------------------------------------------
  4. # Wachunga
  5. # 1.1
  6. # 2006-11-10
  7. # See https://github.com/wachunga/rmxp-multip ... ge-windows for details
  8. #==============================================================================
  9.  
  10. #==============================================================================
  11. # Settings
  12. #==============================================================================
  13.  
  14.   # filename of message tail used for speech bubbles
  15.   # must be in the Graphics/Windowskins/ folder
  16.   FILENAME_SPEECH_TAIL = "blue-speech_tail.png"
  17.   # note that gradient windowskins aren't ideal for tails
  18.  
  19.   # filenames of message tail and windowskin used for thought bubbles
  20.   # must also be in the Graphics/Windowskins/ folder
  21.   FILENAME_THOUGHT_TAIL = "white-thought_tail.png"
  22.   FILENAME_THOUGHT_WINDOWSKIN = "white-windowskin.png"
  23.  
  24.   # used for message.location
  25.   TOP = 8
  26.   BOTTOM = 2
  27.   LEFT = 4
  28.   RIGHT = 6
  29.  
  30. class Game_Message
  31.  
  32.   # Any of the below can be changed by a Call Script event during gameplay.
  33.   # E.g. turn letter-by-letter mode off with: message.letter_by_letter = false
  34.  
  35.   attr_accessor :move_during
  36.   attr_accessor :letter_by_letter
  37.   attr_accessor :text_speed
  38.   attr_accessor :skippable
  39.   attr_accessor :resize
  40.   attr_accessor :floating
  41.   attr_accessor :autocenter
  42.   attr_accessor :show_tail
  43.   attr_accessor :show_pause
  44.   attr_accessor :location
  45.   attr_accessor :font_name
  46.   attr_accessor :font_size
  47.   attr_accessor :font_color
  48.   attr_accessor :font_color_thought
  49.  
  50.  
  51.   def initialize
  52.     # whether or not messages appear one letter at a time
  53.     @letter_by_letter = true
  54.     # note: can also change within a single message with \L
  55.  
  56.     # the default speed at which text appears in letter-by-letter mode
  57.     @text_speed = 1
  58.     # note: can also change within a single message with \S[n]
  59.    
  60.     # whether or not players can skip to the end of (letter-by-letter) messages
  61.     @skippable = true
  62.    
  63.     # whether or not messages are automatically resized based on the message
  64.     @resize = true
  65.    
  66.     # whether or not message windows are positioned above
  67.     # characters/events by default, i.e. without needing \P every message
  68.     # (only works if resize messages enabled -- otherwise would look very odd)
  69.     @floating = true
  70.    
  71.     # whether or not to automatically center lines within the message
  72.     @autocenter = true
  73.    
  74.     # whether or not event-positioned messages have a tail (for speech bubbles)
  75.     # (only works if floating and resized messages enabled -- otherwise would
  76.     # look very odd indeed)
  77.     @show_tail = true
  78.    
  79.     # whether or not to display "waiting for user input" pause graphic
  80.     # (probably want this disabled for speech bubbles)
  81.     @show_pause = false
  82.  
  83.     # whether the player is permitted to move while messages are displayed
  84.     @move_during = true
  85.    
  86.     # the default location for floating messages (relative to the event)
  87.     # note that an off-screen message will be "flipped" automatically
  88.     @location = TOP
  89.    
  90.     # name of font to use for text (any TrueType from Windows/Fonts folder)
  91.     @font_name = Font.default_name
  92.     # note that you can use an array of fonts to specify multiple
  93.     # e.g. ['Verdana', 'MS PGothic']
  94.     # (if Verdana is not available, MS PGothic will be used instead)
  95.    
  96.     # font size for text (default is 22)
  97.     @font_size = Font.default_size
  98.    
  99.     # default font color (same 0-7 as for \c[n])
  100.     @font_color = 0
  101.    
  102.     # font color used just for thought bubbles (\@)
  103.     @font_color_thought = 1
  104.   end
  105. end
  106.  
  107. #------------------------------------------------------------------------------
  108.  
  109. class Window_Message < Window_Selectable
  110.  
  111.   def initialize(msgindex)
  112.     super(80, 304, 480, 160)
  113.     self.contents = Bitmap.new(width - 32, height - 32)
  114.     self.visible = false
  115. #------------------------------------------------------------------------------
  116. # Begin Multiple Message Windows Edit
  117. #------------------------------------------------------------------------------
  118.     self.z = 9000 + msgindex * 5 # permits messages to overlap legibly
  119. #------------------------------------------------------------------------------
  120. # End Multiple Message Windows Edit
  121. #------------------------------------------------------------------------------
  122.     @fade_in = false
  123.     @fade_out = false
  124.     @contents_showing = false
  125.     @cursor_width = 0
  126.     self.active = false
  127.     self.index = -1
  128. #------------------------------------------------------------------------------
  129. # Begin Multiple Message Windows Edit
  130. #------------------------------------------------------------------------------
  131.     @msgindex = msgindex
  132.     @tail = Sprite.new
  133.     @tail.bitmap =
  134.       if @msgindex == 0
  135.         RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
  136.       else
  137.         # don't use cached version or else all tails
  138.         # are rotated when multiple are visible at once
  139.         Bitmap.new("Graphics/Windowskins/"+FILENAME_SPEECH_TAIL)
  140.       end
  141.     # keep track of orientation of tail bitmap
  142.     if @tail.bitmap.orientation == nil
  143.       @tail.bitmap.orientation = 0
  144.     end
  145.     # make origin the center, not top left corner
  146.     @tail.ox = @tail.bitmap.width/2
  147.     @tail.oy = @tail.bitmap.height/2
  148.     @tail.z = 9999
  149.     @tail.visible = false
  150.     @windowskin = $game_system.windowskin_name
  151.     @font_color = $game_system.message.font_color
  152.     @update_text = true
  153.     @letter_by_letter = $game_system.message.letter_by_letter
  154.     @text_speed = $game_system.message.text_speed
  155.     # id of character for speech bubbles
  156.     @float_id = nil
  157.     # location of box relative to speaker
  158.     @location = $game_system.message.location
  159. #------------------------------------------------------------------------------
  160. # End Multiple Message Windows Edit
  161. #------------------------------------------------------------------------------
  162.   end
  163.  
  164.   def dispose
  165.     terminate_message
  166. #------------------------------------------------------------------------------
  167. # Begin Multiple Message Windows Edit
  168. #------------------------------------------------------------------------------
  169.     # have to check all windows before claiming that no window is showing
  170.     if $game_temp.message_text.compact.empty?
  171. #------------------------------------------------------------------------------
  172. # End Multiple Message Windows Edit
  173. #------------------------------------------------------------------------------
  174.       $game_temp.message_window_showing = false
  175. #------------------------------------------------------------------------------
  176. # Begin Multiple Message Windows Edit
  177. #------------------------------------------------------------------------------
  178.     end
  179. #------------------------------------------------------------------------------
  180. # End Multiple Message Windows Edit
  181. #------------------------------------------------------------------------------
  182.     if @input_number_window != nil
  183.       @input_number_window.dispose
  184.     end
  185.     super
  186.   end
  187.  
  188.   def terminate_message
  189.     self.active = false
  190.     self.pause = false
  191.     self.index = -1
  192.     self.contents.clear
  193.     # Clear showing flag
  194.     @contents_showing = false
  195.     # Clear variables related to text, choices, and number input
  196. #------------------------------------------------------------------------------
  197. # Begin Multiple Message Windows Edit
  198. #------------------------------------------------------------------------------
  199.     @tail.visible = false
  200.     # note that these variables are now indexed arrays
  201.     $game_temp.message_text[@msgindex] = nil
  202.     # Call message callback
  203.     if $game_temp.message_proc[@msgindex] != nil
  204.       # make sure no message boxes are displaying
  205.       if $game_temp.message_text.compact.empty?
  206.         $game_temp.message_proc[@msgindex].call
  207.       end
  208.       $game_temp.message_proc[@msgindex] = nil
  209.     end
  210.     @update_text = true
  211. #------------------------------------------------------------------------------
  212. # End Multiple Message Windows Edit
  213. #------------------------------------------------------------------------------
  214.     $game_temp.choice_start = 99
  215.     $game_temp.choice_max = 0
  216.     $game_temp.choice_cancel_type = 0
  217.     $game_temp.choice_proc = nil
  218.     $game_temp.num_input_start = 99
  219.     $game_temp.num_input_variable_id = 0
  220.     $game_temp.num_input_digits_max = 0
  221.     # Open gold window
  222.     if @gold_window != nil
  223.       @gold_window.dispose
  224.       @gold_window = nil
  225.     end
  226.   end
  227.  
  228.   def refresh
  229.     self.contents.clear
  230. #------------------------------------------------------------------------------
  231. # Begin Multiple Message Windows Edit
  232. #------------------------------------------------------------------------------
  233.     @x = @y = 0 # now instance variables
  234.     @float_id = nil
  235.     @location = $game_system.message.location
  236.     @windowskin = $game_system.windowskin_name
  237.     @font_color = $game_system.message.font_color
  238.     @line_widths = nil
  239.     @wait_for_input = false
  240.     @tail.bitmap =
  241.       if @msgindex == 0
  242.         RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
  243.       else
  244.         Bitmap.new("Graphics/Windowskins/"+FILENAME_SPEECH_TAIL)
  245.       end
  246.     RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
  247.     @tail.bitmap.orientation = 0 if @tail.bitmap.orientation == nil
  248.     @text_speed = $game_system.message.text_speed
  249.     @letter_by_letter = $game_system.message.letter_by_letter
  250.     @delay = @text_speed
  251.     @player_skip = false
  252. #------------------------------------------------------------------------------
  253. # End Multiple Message Windows Edit
  254. #------------------------------------------------------------------------------
  255.     @cursor_width = 0
  256.     # Indent if choice
  257.     if $game_temp.choice_start == 0
  258.       @x = 8
  259.     end
  260.     # If waiting for a message to be displayed
  261. #------------------------------------------------------------------------------
  262. # Begin Multiple Message Windows Edit
  263. #------------------------------------------------------------------------------
  264.     if $game_temp.message_text[@msgindex] != nil
  265.       @text = $game_temp.message_text[@msgindex] # now an instance variable
  266. #------------------------------------------------------------------------------
  267. # End Multiple Message Windows Edit
  268. #------------------------------------------------------------------------------
  269.       # Control text processing
  270.       begin
  271.         last_text = @text.clone
  272.         @text.gsub!(/\\[Vv][Aa][Rr]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  273.       end until @text == last_text
  274.       @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  275.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  276.       end
  277.       # Change "\\\\" to "\000" for convenience
  278.       @text.gsub!(/\\\\/) { "\000" }
  279.       # Change "\\C" to "\001" and "\\G" to "\002"
  280.       @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  281.       @text.gsub!(/\\[Gg]/) { "\002" }
  282. #------------------------------------------------------------------------------
  283. # Begin Multiple Message Windows Edit
  284. #------------------------------------------------------------------------------
  285.       @text.gsub!(/\\[Nn]\[[Ee]([0-9]+)\]/) do
  286.         $data_enemies[$1.to_i] != nil ? $data_enemies[$1.to_i].name : ""
  287.       end
  288.       # Change "\\MAP" to map name
  289.       @text.gsub!(/\\[Mm][Aa][Pp]/) { $game_map.name }
  290.       # Change "\\L" to "\003" (toggle letter-by-letter)
  291.       @text.gsub!(/\\[Ll]/) { "\003" }
  292.       # Change "\\S" to "\004" (text speed)
  293.       @text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\004[#{$1}]" }
  294.       # Change "\\D" to "\005" (delay)
  295.       @text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\005[#{$1}]" }
  296.       # Change "\\!" to "\006" (self close)
  297.       @text.gsub!(/\\[!]/) { "\006" }
  298.       # Change "\\?" to "\007" (wait for user input)
  299.       @text.gsub!(/\\[?]/) { "\007" }
  300.       # Change "\\B" to "\010" (bold)
  301.       @text.gsub!(/\\[Bb]/) { "\010" }
  302.       # Change "\\I" to "\011" (italic)
  303.       @text.gsub!(/\\[Ii]/) { "\011" }
  304.       # Get rid of "\\@" (thought bubble)
  305.       if @text.gsub!(/\\[@]/, "") != nil
  306.         @windowskin = FILENAME_THOUGHT_WINDOWSKIN
  307.         @font_color = $game_system.message.font_color_thought
  308.         @tail.bitmap =
  309.           if @msgindex == 0
  310.             RPG::Cache.windowskin(FILENAME_THOUGHT_TAIL)
  311.           else
  312.             Bitmap.new("Graphics/Windowskins/"+FILENAME_THOUGHT_TAIL)
  313.           end
  314.         @tail.bitmap.orientation = 0 if @tail.bitmap.orientation == nil
  315.       end      
  316.       # Get rid of "\\+" (multiple messages)
  317.       @text.gsub!(/\\[+]/, "")
  318.       # Get rid of "\\^", "\\v", "\\<", "\\>" (relative message location)
  319.       if @text.gsub!(/\\\^/, "") != nil
  320.         @location = 8
  321.       elsif @text.gsub!(/\\[Vv]/, "") != nil
  322.         @location = 2
  323.       elsif @text.gsub!(/\\[<]/, "") != nil
  324.         @location = 4
  325.       elsif @text.gsub!(/\\[>]/, "") != nil
  326.         @location = 6
  327.       end
  328.       # Get rid of "\\P" (position window to given character)
  329.       if @text.gsub!(/\\[Pp]\[([0-9]+)\]/, "") != nil
  330.         @float_id = $1.to_i
  331.       elsif @text.gsub!(/\\[Pp]\[([a-zA-Z])\]/, "") != nil and
  332.           $game_temp.in_battle
  333.         @float_id = $1.downcase
  334.       elsif @text.gsub!(/\\[Pp]/, "") != nil or
  335.         ($game_system.message.floating and $game_system.message.resize) and
  336.         !$game_temp.in_battle
  337.         @float_id = $game_system.map_interpreter.event_id
  338.       end
  339.       if $game_system.message.resize or $game_system.message.autocenter
  340.         # calculate length of lines
  341.         text = @text.clone
  342.         temp_bitmap = Bitmap.new(1,1)
  343.         temp_bitmap.font.name = $game_system.message.font_name
  344.         temp_bitmap.font.size = $game_system.message.font_size
  345.         @line_widths = [0,0,0,0]
  346.         for i in 0..3
  347.           line = text.split(/\n/)[3-i]
  348.           if line == nil
  349.             next
  350.           end
  351.           line.gsub!(/[\001-\007](\[\w+\])?/, "")
  352.           line.chomp.split(//).each do |c|
  353.             case c
  354.               when "\000"
  355.                 c = "\\"
  356.               when "\010"
  357.                 # bold
  358.                 temp_bitmap.font.bold = !temp_bitmap.font.bold
  359.                 c = ''
  360.               when "\011"
  361.                 # italics
  362.                 temp_bitmap.font.italic = !temp_bitmap.font.italic
  363.                 c = ''
  364.             end
  365.             @line_widths[3-i] += temp_bitmap.text_size(c).width
  366.           end
  367.           if (3-i) >= $game_temp.choice_start
  368.             # account for indenting
  369.             @line_widths[3-i] += 8 unless $game_system.message.autocenter
  370.           end
  371.         end
  372.         if $game_temp.num_input_variable_id > 0
  373.           # determine cursor_width as in Window_InputNumber
  374.           # (can't get from @input_number_window because it doesn't exist yet)
  375.           cursor_width = temp_bitmap.text_size("0").width + 8
  376.           # use this width to calculate line width (+8 for indent)
  377.           input_number_width = cursor_width*$game_temp.num_input_digits_max
  378.           input_number_width += 8 unless $game_system.message.autocenter
  379.           @line_widths[$game_temp.num_input_start] = input_number_width
  380.         end
  381.         temp_bitmap.dispose
  382.       end
  383.       resize
  384.       reposition if @float_id != nil
  385.       self.contents.font.name = $game_system.message.font_name
  386.       self.contents.font.size = $game_system.message.font_size
  387.       self.contents.font.color = text_color(@font_color)
  388.       self.windowskin = RPG::Cache.windowskin(@windowskin)
  389.       # autocenter first line if enabled
  390.       # (subsequent lines are done as "\n" is encountered)
  391.       if $game_system.message.autocenter and @text != ""
  392.         @x = (self.width-40)/2 - @line_widths[0]/2
  393.       end
  394. #------------------------------------------------------------------------------
  395. # End Multiple Message Windows Edit
  396. #------------------------------------------------------------------------------
  397.     end
  398.   end
  399.  
  400.   #--------------------------------------------------------------------------
  401.   # * Resize Window
  402.   #--------------------------------------------------------------------------
  403.   def resize
  404.     if !$game_system.message.resize
  405.       # reset to defaults
  406.       self.width = 480
  407.       self.height = 160
  408.       self.contents = Bitmap.new(width - 32, height - 32)
  409.       self.x = 80 # undo any centering
  410.       return
  411.     end
  412.     max_x = @line_widths.max
  413.     max_y = 4
  414.     @line_widths.each do |line|
  415.       max_y -= 1 if line == 0 and max_y > 1
  416.     end
  417.     if $game_temp.choice_max  > 0
  418.       # account for indenting
  419.       max_x += 8 unless $game_system.message.autocenter
  420.     end
  421.     self.width = max_x + 40
  422.     self.height = max_y * 32 + 32
  423.     self.contents = Bitmap.new(width - 32, height - 32)
  424.     self.x = 320 - (self.width/2) # center
  425.   end
  426.  
  427.   #--------------------------------------------------------------------------
  428.   # * Reposition Window
  429.   #--------------------------------------------------------------------------
  430.   def reposition
  431.     if $game_temp.in_battle
  432.       if "abcd".include?(@float_id) # must be between a and d
  433.         @float_id = @float_id[0] - 97 # a = 0, b = 1, c = 2, d = 3
  434.         return if $scene.spriteset.actor_sprites[@float_id] == nil
  435.         sprite = $scene.spriteset.actor_sprites[@float_id]
  436.       else
  437.         @float_id -= 1 # account for, e.g., player entering 1 for index 0
  438.         return if $scene.spriteset.enemy_sprites[@float_id] == nil
  439.         sprite = $scene.spriteset.enemy_sprites[@float_id]
  440.       end
  441.       char_height = sprite.height
  442.       char_width = sprite.width
  443.       char_x = sprite.x
  444.       char_y = sprite.y - char_height/2
  445.     else # not in battle...
  446.       char = (@float_id == 0 ? $game_player : $game_map.events[@float_id])
  447.       if char == nil
  448.         # no such character
  449.         @float_id = nil
  450.         return
  451.       end
  452.       # close message (and stop event processing) if speaker is off-screen
  453.       if char.screen_x <= 0 or char.screen_x >= 640 or
  454.          char.screen_y <= 0 or char.screen_y > 480
  455.         terminate_message
  456.         $game_system.map_interpreter.command_115
  457.         return
  458.       end
  459.       char_height = RPG::Cache.character(char.character_name,0).height / 4
  460.       char_width = RPG::Cache.character(char.character_name,0).width / 4
  461.       # record coords of character's center
  462.       char_x = char.screen_x
  463.       char_y = char.screen_y - char_height/2
  464.     end
  465.     params = [char_height, char_width, char_x, char_y]
  466.     # position window and message tail
  467.     vars = new_position(params)
  468.     x = vars[0]
  469.     y = vars[1]
  470.     # check if any window locations need to be "flipped"
  471.     if @location == 4 and x < 0
  472.       # switch to right
  473.       @location = 6
  474.       vars = new_position(params)
  475.       x = vars[0]
  476.       if (x + self.width) > 640
  477.         # right is no good either...
  478.         if y >= 0
  479.           # switch to top
  480.           @location = 8
  481.           vars = new_position(params)
  482.         else
  483.           # switch to bottom
  484.           @location = 2
  485.           vars = new_position(params)
  486.         end
  487.       end
  488.     elsif @location == 6 and (x + self.width) > 640
  489.       # switch to left
  490.       @location = 4
  491.       vars = new_position(params)
  492.       x = vars[0]
  493.       if x < 0
  494.         # left is no good either...
  495.         if y >= 0
  496.           # switch to top
  497.           @location = 8
  498.           vars = new_position(params)
  499.         else
  500.           # switch to bottom
  501.           @location = 2
  502.           vars = new_position(params)
  503.         end
  504.       end
  505.     elsif @location == 8 and y < 0
  506.       # switch to bottom
  507.       @location = 2
  508.       vars = new_position(params)
  509.       y = vars[1]
  510.       if (y + self.height) > 480
  511.         # bottom is no good either...
  512.         # note: this will probably never occur given only 3 lines of text
  513.         x = vars[0]
  514.         if x >= 0
  515.           # switch to left
  516.           @location = 4
  517.           vars = new_position(params)
  518.         else
  519.           # switch to right
  520.           @location = 6
  521.           vars = new_position(params)
  522.         end
  523.       end
  524.     elsif @location == 2 and (y + self.height) > 480
  525.       # switch to top
  526.       @location = 8
  527.       vars = new_position(params)
  528.       y = vars[1]
  529.       if y < 0
  530.         # top is no good either...
  531.         # note: this will probably never occur given only 3 lines of text
  532.         x = vars[0]
  533.         if x >= 0
  534.           # switch to left
  535.           @location = 4
  536.           vars = new_position(params)
  537.         else
  538.           # switch to right
  539.           @location = 6
  540.           vars = new_position(params)
  541.         end
  542.       end
  543.     end
  544.     x = vars[0]
  545.     y = vars[1]
  546.     tail_x = vars[2]
  547.     tail_y = vars[3]    
  548.     # adjust windows if near edge of screen
  549.     if x < 0
  550.       x = 0
  551.     elsif (x + self.width) > 640
  552.       x = 640 - self.width
  553.     end
  554.     if y < 0
  555.       y = 0
  556.     elsif (y + self.height) > 480
  557.       y = 480 - self.height
  558.     elsif $game_temp.in_battle and @location == 2 and (y > (320 - self.height))
  559.       # when in battle, prevent enemy messages from overlapping battle status
  560.       # (note that it could still happen from actor messages, though)
  561.       y = 320 - self.height
  562.       tail_y = y
  563.     end
  564.     # finalize positions
  565.     self.x = x
  566.     self.y = y
  567.     @tail.x = tail_x
  568.     @tail.y = tail_y
  569.   end
  570.  
  571.   #--------------------------------------------------------------------------
  572.   # * Determine New Window Position
  573.   #--------------------------------------------------------------------------  
  574.   def new_position(params)
  575.     char_height = params[0]
  576.     char_width = params[1]
  577.     char_x = params[2]
  578.     char_y = params[3]
  579.     if @location == 8
  580.       # top
  581.       x = char_x - self.width/2
  582.       y = char_y - char_height/2 - self.height - @tail.bitmap.height/2
  583.       @tail.bitmap.rotation(0)
  584.       tail_x = x + self.width/2
  585.       tail_y = y + self.height
  586.     elsif @location == 2
  587.       # bottom
  588.       x = char_x - self.width/2
  589.       y = char_y + char_height/2 + @tail.bitmap.height/2
  590.       @tail.bitmap.rotation(180)
  591.       tail_x = x + self.width/2
  592.       tail_y = y
  593.     elsif @location == 4
  594.       # left
  595.       x = char_x - char_width/2 - self.width - @tail.bitmap.width/2
  596.       y = char_y - self.height/2
  597.       @tail.bitmap.rotation(270)
  598.       tail_x = x + self.width
  599.       tail_y = y + self.height/2
  600.     elsif @location == 6
  601.       # right
  602.       x = char_x + char_width/2 + @tail.bitmap.width/2
  603.       y = char_y - self.height/2
  604.       @tail.bitmap.rotation(90)
  605.       tail_x = x
  606.       tail_y = y + self.height/2
  607.     end
  608.     return [x,y,tail_x,tail_y]
  609.   end
  610.      
  611.   #--------------------------------------------------------------------------
  612.   # * Update Text
  613.   #--------------------------------------------------------------------------  
  614.   def update_text
  615.     if @text != nil
  616.       # Get 1 text character in c (loop until unable to get text)
  617.       while ((c = @text.slice!(/./m)) != nil)
  618.         # If \\
  619.         if c == "\000"
  620.           # Return to original text
  621.           c = "\\"
  622.         end
  623.         # If \C[n]
  624.         if c == "\001"
  625.           # Change text color
  626.           @text.sub!(/\[([0-9]+)\]/, "")
  627.           color = $1.to_i
  628.           if color >= 0 and color <= 7
  629.             self.contents.font.color = text_color(color)
  630.           end
  631.           # go to next text
  632.           next
  633.         end
  634.         # If \G
  635.         if c == "\002"
  636.           # Make gold window
  637.           if @gold_window == nil
  638.             @gold_window = Window_Gold.new
  639.             @gold_window.x = 560 - @gold_window.width
  640.             if $game_temp.in_battle
  641.               @gold_window.y = 192
  642.             else
  643.               @gold_window.y = self.y >= 128 ? 32 : 384
  644.             end
  645.             @gold_window.opacity = self.opacity
  646.             @gold_window.back_opacity = self.back_opacity
  647.           end
  648.           # go to next text
  649.           next
  650.         end
  651.         # If \L
  652.         if c == "\003"
  653.           # toggle letter-by-letter mode
  654.           @letter_by_letter = !@letter_by_letter
  655.           # go to next text
  656.           next
  657.         end
  658.         # If \S[n]
  659.         if c == "\004"
  660.           @text.sub!(/\[([0-9]+)\]/, "")
  661.           speed = $1.to_i
  662.           if speed >= 0
  663.             @text_speed = speed
  664.             # reset player skip after text speed change
  665.             @player_skip = false            
  666.           end
  667.           return
  668.         end
  669.         # If \D[n]
  670.         if c == "\005"
  671.           @text.sub!(/\[([0-9]+)\]/, "")
  672.           delay = $1.to_i
  673.           if delay >= 0
  674.             @delay += delay
  675.             # reset player skip after delay
  676.             @player_skip = false
  677.           end
  678.           return
  679.         end  
  680.         # If \!
  681.         if c == "\006"
  682.           # close message and return from method
  683.           terminate_message
  684.           return
  685.         end
  686.         # If \?
  687.         if c == "\007"
  688.           @wait_for_input = true
  689.           return
  690.         end
  691.         if c == "\010"
  692.           # bold
  693.           self.contents.font.bold = !self.contents.font.bold
  694.         end
  695.         if c == "\011"
  696.           # italics
  697.           self.contents.font.italic = !self.contents.font.italic
  698.         end
  699.         # If new line text
  700.         if c == "\n"
  701.           # Update cursor width if choice
  702.           if @y >= $game_temp.choice_start
  703.             width = $game_system.message.autocenter ? @line_widths[@y]+8 : @x
  704.             @cursor_width = [@cursor_width, width].max
  705.           end
  706.           # Add 1 to y
  707.           @y += 1
  708.           if $game_system.message.autocenter and @text != ""
  709.             @x = (self.width-40)/2 - @line_widths[@y]/2
  710.           else
  711.             @x = 0
  712.             # Indent if choice
  713.             if @y >= $game_temp.choice_start
  714.               @x = 8
  715.             end
  716.           end
  717.           # go to next text
  718.           next
  719.         end
  720.         # Draw text
  721.         self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  722.         # Add x to drawn text width
  723.         @x += self.contents.text_size( c ).width
  724.         # add text speed to time to display next character
  725.         @delay += @text_speed unless !@letter_by_letter or @player_skip
  726.         return if @letter_by_letter and !@player_skip
  727.       end
  728.     end
  729.     # If choice
  730.     if $game_temp.choice_max > 0
  731.       @item_max = $game_temp.choice_max
  732.       self.active = true
  733.       self.index = 0
  734.     end
  735.     # If number input
  736.     if $game_temp.num_input_variable_id > 0
  737.       digits_max = $game_temp.num_input_digits_max
  738.       number = $game_variables[$game_temp.num_input_variable_id]
  739.       @input_number_window = Window_InputNumber.new(digits_max)
  740.       @input_number_window.number = number
  741.       @input_number_window.x =
  742.         if $game_system.message.autocenter
  743.           offset = (self.width-40)/2-@line_widths[$game_temp.num_input_start]/2
  744.           self.x + offset + 4
  745.         else
  746.           self.x + 8
  747.         end
  748.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  749.     end
  750.     @update_text = false
  751.   end
  752.  
  753.   #--------------------------------------------------------------------------
  754.   # * Set Window Position and Opacity Level
  755.   #--------------------------------------------------------------------------
  756.   def reset_window
  757.     if $game_temp.in_battle
  758.       self.y = 16
  759.     else
  760.       case $game_system.message_position
  761.       when 0  # up
  762.         self.y = 16
  763.       when 1  # middle
  764.         self.y = 160
  765.       when 2  # down
  766.         self.y = 304
  767.       end
  768.     end
  769.     if $game_system.message_frame == 0
  770.       self.opacity = 255
  771.     else
  772.       self.opacity = 0
  773.     end
  774. #------------------------------------------------------------------------------
  775. # Begin Multiple Message Windows Edit
  776. #------------------------------------------------------------------------------
  777.     # transparent speech bubbles don't look right, so keep opacity at 255
  778.     # self.back_opacity = 160
  779.     @tail.opacity = 255
  780. #------------------------------------------------------------------------------
  781. # End Multiple Message Windows Edit
  782. #------------------------------------------------------------------------------
  783.   end
  784.  
  785.   def update
  786.     super
  787.     # If fade in
  788.     if @fade_in
  789.       self.contents_opacity += 24
  790.       if @input_number_window != nil
  791.         @input_number_window.contents_opacity += 24
  792.       end
  793.       if self.contents_opacity == 255
  794.         @fade_in = false
  795.       end
  796. #------------------------------------------------------------------------------
  797. # Begin Multiple Message Windows Edit
  798. #------------------------------------------------------------------------------
  799.       # return
  800. #------------------------------------------------------------------------------
  801. # End Multiple Message Windows Edit
  802. #------------------------------------------------------------------------------
  803.     end
  804.     # If inputting number
  805.     if @input_number_window != nil
  806.       @input_number_window.update
  807.       # Confirm
  808.       if Input.trigger?(Input::C)
  809.         $game_system.se_play($data_system.decision_se)
  810.         $game_variables[$game_temp.num_input_variable_id] =
  811.           @input_number_window.number
  812.         $game_map.need_refresh = true
  813.         # Dispose of number input window
  814.         @input_number_window.dispose
  815.         @input_number_window = nil
  816.         terminate_message
  817.       end
  818.       return
  819.     end
  820.     # If message is being displayed
  821.     if @contents_showing
  822. #------------------------------------------------------------------------------
  823. # Begin Multiple Message Windows Edit
  824. #------------------------------------------------------------------------------
  825.       # Confirm or cancel finishes waiting for input or message
  826.       if Input.trigger?(Input::C) or Input.trigger?(Input::B)
  827.         if @wait_for_input
  828.           @wait_for_input = false
  829.           self.pause = false
  830.         elsif $game_system.message.skippable
  831.           @player_skip = true
  832.         end
  833.       end
  834.       if need_reposition?
  835.         reposition # update message position for character/screen movement
  836.         if @contents_showing == false
  837.           # i.e. if char moved off screen
  838.           return
  839.         end
  840.       end
  841.       if @update_text and !@wait_for_input
  842.         if @delay == 0
  843.           update_text
  844.         else
  845.           @delay -= 1
  846.         end
  847.         return
  848.       end
  849.  
  850.       # If choice isn't being displayed, show pause sign
  851.       if !self.pause and ($game_temp.choice_max == 0 or @wait_for_input)
  852.         self.pause = true unless !$game_system.message.show_pause
  853.       end
  854. #------------------------------------------------------------------------------
  855. # End Multiple Message Windows Edit
  856. #------------------------------------------------------------------------------
  857.       # Cancel
  858.       if Input.trigger?(Input::B)
  859.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  860.           $game_system.se_play($data_system.cancel_se)
  861.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  862.           terminate_message
  863.         end
  864. #------------------------------------------------------------------------------
  865. # Begin Multiple Message Windows Edit
  866. #------------------------------------------------------------------------------
  867.         # personal preference: cancel button should also continue
  868.         terminate_message
  869. #------------------------------------------------------------------------------
  870. # End Multiple Message Windows Edit
  871. #------------------------------------------------------------------------------
  872.       end
  873.       # Confirm
  874.       if Input.trigger?(Input::C)
  875.         if $game_temp.choice_max > 0
  876.           $game_system.se_play($data_system.decision_se)
  877.           $game_temp.choice_proc.call(self.index)
  878.         end
  879.         terminate_message
  880.       end
  881.       return
  882.     end
  883.     # If display wait message or choice exists when not fading out
  884.     if @fade_out == false and $game_temp.message_text[@msgindex] != nil
  885.       @contents_showing = true
  886.       $game_temp.message_window_showing = true
  887.       reset_window
  888.       refresh
  889.       Graphics.frame_reset
  890.       self.visible = true
  891. #------------------------------------------------------------------------------
  892. # Begin Multiple Message Windows Edit
  893. #------------------------------------------------------------------------------
  894.       if show_message_tail?
  895.         @tail.visible = true
  896.       elsif @tail.visible
  897.         @tail.visible = false
  898.       end
  899. #------------------------------------------------------------------------------
  900. # End Multiple Message Windows Edit
  901. #------------------------------------------------------------------------------
  902.       self.contents_opacity = 0
  903.       if @input_number_window != nil
  904.         @input_number_window.contents_opacity = 0
  905.       end
  906.       @fade_in = true
  907.       return
  908.     end
  909.     # If message which should be displayed is not shown, but window is visible
  910.     if self.visible
  911.       @fade_out = true
  912.       self.opacity -= 48
  913. #------------------------------------------------------------------------------
  914. # Begin Multiple Message Windows Edit
  915. #------------------------------------------------------------------------------
  916.       @tail.opacity -= 48 if @tail.opacity > 0
  917.       if need_reposition?
  918.         reposition # update message position for character/screen movement
  919.       end
  920. #------------------------------------------------------------------------------
  921. # End Multiple Message Windows Edit
  922. #------------------------------------------------------------------------------
  923.       if self.opacity == 0
  924.         self.visible = false
  925.         @fade_out = false
  926. #------------------------------------------------------------------------------
  927. # Begin Multiple Message Windows Edit
  928. #------------------------------------------------------------------------------
  929.         @tail.visible = false if @tail.visible
  930.         # have to check all windows before claiming that no window is showing
  931.         if $game_temp.message_text.compact.empty?
  932. #------------------------------------------------------------------------------
  933. # End Multiple Message Windows Edit
  934. #------------------------------------------------------------------------------
  935.           $game_temp.message_window_showing = false  
  936. #------------------------------------------------------------------------------
  937. # Begin Multiple Message Windows Edit
  938. #------------------------------------------------------------------------------
  939.         end
  940. #------------------------------------------------------------------------------
  941. # End Multiple Message Windows Edit
  942. #------------------------------------------------------------------------------
  943.       end
  944.       return
  945.     end
  946.   end
  947.  
  948.   #--------------------------------------------------------------------------
  949.   # * Repositioning Determination
  950.   #--------------------------------------------------------------------------
  951.   def need_reposition?
  952.     if !$game_temp.in_battle and $game_system.message.floating and
  953.         $game_system.message.resize and @float_id != nil
  954.       if $game_system.message.move_during and @float_id == 0 and
  955.           (($game_player.last_real_x != $game_player.real_x) or
  956.           ($game_player.last_real_y != $game_player.real_y))
  957.           # player with floating message moved
  958.           # (note that relying on moving? leads to "jumpy" message boxes)
  959.           return true
  960.       elsif ($game_map.last_display_y != $game_map.display_y) or
  961.          ($game_map.last_display_x != $game_map.display_x)
  962.         # player movement or scroll event caused the screen to scroll
  963.         return true
  964.       else
  965.         char = $game_map.events[@float_id]
  966.         if char != nil and
  967.           ((char.last_real_x != char.real_x) or
  968.           (char.last_real_y != char.real_y))
  969.           # character moved
  970.           return true
  971.         end
  972.       end    
  973.     end
  974.     return false
  975.   end
  976.  
  977.   #--------------------------------------------------------------------------
  978.   # * Show Message Tail Determination
  979.   #--------------------------------------------------------------------------
  980.   def show_message_tail?
  981.     if $game_system.message.show_tail and $game_system.message.floating and
  982.       $game_system.message.resize and $game_system.message_frame == 0 and
  983.       @float_id != nil
  984.       return true
  985.     end
  986.     return false
  987.   end
  988.  
  989.   def update_cursor_rect
  990.     if @index >= 0
  991.       n = $game_temp.choice_start + @index
  992. #------------------------------------------------------------------------------
  993. # Begin Multiple Message Windows Edit
  994. #------------------------------------------------------------------------------
  995.       if $game_system.message.autocenter
  996.         x = 4 + (self.width-40)/2 - @cursor_width/2
  997.       else
  998.         x = 8
  999.       end
  1000.       self.cursor_rect.set(x, n * 32, @cursor_width, 32)
  1001. #------------------------------------------------------------------------------
  1002. # End Multiple Message Windows Edit
  1003. #------------------------------------------------------------------------------
  1004.     else
  1005.       self.cursor_rect.empty
  1006.     end
  1007.   end
  1008.  
  1009. end
  1010.  
  1011. #------------------------------------------------------------------------------
  1012.  
  1013. class Game_Character
  1014.   attr_reader   :last_real_x                   # last map x-coordinate
  1015.   attr_reader   :last_real_y                   # last map y-coordinate
  1016.   alias wachunga_game_char_update update
  1017.   def update
  1018.     @last_real_x = @real_x
  1019.     @last_real_y = @real_y
  1020.     wachunga_game_char_update
  1021.   end
  1022. end
  1023.  
  1024. #------------------------------------------------------------------------------
  1025.  
  1026. class Game_Player < Game_Character
  1027.  
  1028.   alias wachunga_mmw_game_player_update update
  1029.   def update
  1030.    # The conditions are changed so the player can move around while messages
  1031.    # are showing (if move_during is true), but not if user is making a
  1032.    # choice or inputting a number
  1033.    # Note that this check overrides the default one (later in the method)
  1034.    # because it is more general
  1035.     unless moving? or
  1036.       @move_route_forcing or
  1037.       ($game_system.map_interpreter.running? and
  1038.       !$game_temp.message_window_showing) or
  1039.       ($game_temp.message_window_showing and
  1040.       !$game_system.message.move_during) or
  1041.       ($game_temp.choice_max > 0 or $game_temp.num_input_digits_max > 0)
  1042.       case Input.dir4
  1043.       when 2
  1044.         move_down
  1045.       when 4
  1046.         move_left
  1047.       when 6
  1048.         move_right
  1049.       when 8
  1050.         move_up
  1051.       end
  1052.     end
  1053.     wachunga_mmw_game_player_update    
  1054.   end
  1055.  
  1056. end
  1057.  
  1058. #------------------------------------------------------------------------------
  1059.  
  1060. class Game_Temp
  1061.   alias wachunga_mmw_game_temp_initialize initialize
  1062.   def initialize
  1063.     wachunga_mmw_game_temp_initialize
  1064.     @message_text = []
  1065.     @message_proc = []
  1066.   end
  1067. end
  1068.  
  1069. #------------------------------------------------------------------------------
  1070.  
  1071. class Sprite_Battler < RPG::Sprite
  1072.   # necessary for positioning messages relative to battlers
  1073.   attr_reader :height
  1074.   attr_reader :width
  1075. end
  1076.  
  1077. #------------------------------------------------------------------------------
  1078.  
  1079. class Scene_Battle
  1080.   # necessary for accessing actor/enemy sprites in battle
  1081.   attr_reader :spriteset
  1082. end
  1083.  
  1084. #------------------------------------------------------------------------------
  1085.  
  1086. class Spriteset_Battle
  1087.   # necessary for accessing actor/enemy sprites in battle
  1088.   attr_reader :actor_sprites
  1089.   attr_reader :enemy_sprites
  1090. end
  1091.  
  1092. #------------------------------------------------------------------------------
  1093.  
  1094. class Scene_Map
  1095.  
  1096.   # can't alias these methods unfortunately
  1097.   # (SDK would help compatibility a little)
  1098.  
  1099.   def main
  1100.     # Make sprite set
  1101.     @spriteset = Spriteset_Map.new
  1102.     # Make message window
  1103. #------------------------------------------------------------------------------
  1104. # Begin Multiple Message Windows Edit
  1105. #------------------------------------------------------------------------------
  1106.     @message_window = []
  1107.     @message_window[0] = Window_Message.new(0)
  1108. #------------------------------------------------------------------------------
  1109. # End Multiple Message Windows Edit
  1110. #------------------------------------------------------------------------------
  1111.     # Transition run
  1112.     Graphics.transition
  1113.     # Main loop
  1114.     loop do
  1115.       # Update game screen
  1116.       Graphics.update
  1117.       # Update input information
  1118.       Input.update
  1119.       # Frame update
  1120.       update
  1121.       # Abort loop if screen is changed
  1122.       if $scene != self
  1123.         break
  1124.       end
  1125.     end
  1126.     # Prepare for transition
  1127.     Graphics.freeze
  1128.     # Dispose of sprite set
  1129.     @spriteset.dispose
  1130.     # Dispose of message window
  1131. #------------------------------------------------------------------------------
  1132. # Begin Multiple Message Windows Edit
  1133. #------------------------------------------------------------------------------
  1134.     for mw in @message_window
  1135.       mw.dispose
  1136.     end  
  1137. #------------------------------------------------------------------------------
  1138. # End Multiple Message Windows Edit
  1139. #------------------------------------------------------------------------------
  1140.     # If switching to title screen
  1141.     if $scene.is_a?(Scene_Title)
  1142.       # Fade out screen
  1143.       Graphics.transition
  1144.       Graphics.freeze
  1145.     end
  1146.   end
  1147.  
  1148.  
  1149.   def update
  1150.     # Loop
  1151.     loop do
  1152.       # Update map, interpreter, and player order
  1153.       # (this update order is important for when conditions are fulfilled
  1154.       # to run any event, and the player isn't provided the opportunity to
  1155.       # move in an instant)
  1156.       $game_map.update
  1157.       $game_system.map_interpreter.update
  1158.       $game_player.update
  1159.       # Update system (timer), screen
  1160.       $game_system.update
  1161.       $game_screen.update
  1162.       # Abort loop if player isn't place moving
  1163.       unless $game_temp.player_transferring
  1164.         break
  1165.       end
  1166.       # Run place move
  1167.       transfer_player
  1168.       # Abort loop if transition processing
  1169.       if $game_temp.transition_processing
  1170.         break
  1171.       end
  1172.     end
  1173.     # Update sprite set
  1174.     @spriteset.update
  1175.     # Update message window
  1176. #------------------------------------------------------------------------------
  1177. # Begin Multiple Message Windows Edit
  1178. #------------------------------------------------------------------------------
  1179.     for mw in @message_window
  1180.       mw.update
  1181.     end
  1182. #------------------------------------------------------------------------------
  1183. # End Multiple Message Windows Edit
  1184. #------------------------------------------------------------------------------
  1185.     # If game over
  1186.     if $game_temp.gameover
  1187.       # Switch to game over screen
  1188.       $scene = Scene_Gameover.new
  1189.       return
  1190.     end
  1191.     # If returning to title screen
  1192.     if $game_temp.to_title
  1193.       # Change to title screen
  1194.       $scene = Scene_Title.new
  1195.       return
  1196.     end
  1197.     # If transition processing
  1198.     if $game_temp.transition_processing
  1199.       # Clear transition processing flag
  1200.       $game_temp.transition_processing = false
  1201.       # Execute transition
  1202.       if $game_temp.transition_name == ""
  1203.         Graphics.transition(20)
  1204.       else
  1205.         Graphics.transition(40, "Graphics/Transitions/" +
  1206.           $game_temp.transition_name)
  1207.       end
  1208.     end
  1209.     # If showing message window
  1210.     if $game_temp.message_window_showing
  1211.       return
  1212.     end
  1213.     # If encounter list isn't empty, and encounter count is 0
  1214.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  1215.       # If event is running or encounter is not forbidden
  1216.       unless $game_system.map_interpreter.running? or
  1217.              $game_system.encounter_disabled
  1218.         # Confirm troop
  1219.         n = rand($game_map.encounter_list.size)
  1220.         troop_id = $game_map.encounter_list[n]
  1221.         # If troop is valid
  1222.         if $data_troops[troop_id] != nil
  1223.           # Set battle calling flag
  1224.           $game_temp.battle_calling = true
  1225.           $game_temp.battle_troop_id = troop_id
  1226.           $game_temp.battle_can_escape = true
  1227.           $game_temp.battle_can_lose = false
  1228.           $game_temp.battle_proc = nil
  1229.         end
  1230.       end
  1231.     end
  1232.     # If B button was pressed
  1233.     if Input.trigger?(Input::B)
  1234.       # If event is running, or menu is not forbidden
  1235.       unless $game_system.map_interpreter.running? or
  1236.              $game_system.menu_disabled
  1237.         # Set menu calling flag or beep flag
  1238.         $game_temp.menu_calling = true
  1239.         $game_temp.menu_beep = true
  1240.       end
  1241.     end
  1242.     # If debug mode is ON and F9 key was pressed
  1243.     if $DEBUG and Input.press?(Input::F9)
  1244.       # Set debug calling flag
  1245.       $game_temp.debug_calling = true
  1246.     end
  1247.     # If player is not moving
  1248.     unless $game_player.moving?
  1249.       # Run calling of each screen
  1250.       if $game_temp.battle_calling
  1251.         call_battle
  1252.       elsif $game_temp.shop_calling
  1253.         call_shop
  1254.       elsif $game_temp.name_calling
  1255.         call_name
  1256.       elsif $game_temp.menu_calling
  1257.         call_menu
  1258.       elsif $game_temp.save_calling
  1259.         call_save
  1260.       elsif $game_temp.debug_calling
  1261.         call_debug
  1262.       end
  1263.     end
  1264.   end
  1265.  
  1266.   #--------------------------------------------------------------------------
  1267.   # * New Message Window Addition
  1268.   #--------------------------------------------------------------------------
  1269.   def new_message_window(index)
  1270.     if @message_window[index] != nil
  1271.       # clear message windows at and after this index
  1272.       last_index = @message_window.size - 1
  1273.       last_index.downto(index) do |i|
  1274.         if @message_window[i] != nil
  1275.           @message_window[i].dispose
  1276.           @message_window[i] = nil
  1277.         end
  1278.       end
  1279.       @message_window.compact!
  1280.     end
  1281.     @message_window.push(Window_Message.new(index))
  1282.   end
  1283.  
  1284. end
  1285.  
  1286. #------------------------------------------------------------------------------
  1287.  
  1288. class Scene_Battle
  1289.  
  1290.   # can't alias these methods unfortunately
  1291.   # (SDK would help compatibility a little)
  1292.  
  1293.   def main
  1294.     # Initialize each kind of temporary battle data
  1295.     $game_temp.in_battle = true
  1296.     $game_temp.battle_turn = 0
  1297.     $game_temp.battle_event_flags.clear
  1298.     $game_temp.battle_abort = false
  1299.     $game_temp.battle_main_phase = false
  1300.     $game_temp.battleback_name = $game_map.battleback_name
  1301.     $game_temp.forcing_battler = nil
  1302.     # Initialize battle event interpreter
  1303.     $game_system.battle_interpreter.setup(nil, 0)
  1304.     # Prepare troop
  1305.     @troop_id = $game_temp.battle_troop_id
  1306.     $game_troop.setup(@troop_id)
  1307.     # Make actor command window
  1308.     s1 = $data_system.words.attack
  1309.     s2 = $data_system.words.skill
  1310.     s3 = $data_system.words.guard
  1311.     s4 = $data_system.words.item
  1312.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  1313.     @actor_command_window.y = 160
  1314.     @actor_command_window.back_opacity = 160
  1315.     @actor_command_window.active = false
  1316.     @actor_command_window.visible = false
  1317.     # Make other windows
  1318.     @party_command_window = Window_PartyCommand.new
  1319.     @help_window = Window_Help.new
  1320.     @help_window.back_opacity = 160
  1321.     @help_window.visible = false
  1322.     @status_window = Window_BattleStatus.new
  1323. #------------------------------------------------------------------------------
  1324. # Begin Multiple Message Windows Edit
  1325. #------------------------------------------------------------------------------
  1326.     @message_window = []
  1327.     @message_window[0] = Window_Message.new(0)
  1328. #------------------------------------------------------------------------------
  1329. # End Multiple Message Windows Edit
  1330. #------------------------------------------------------------------------------
  1331.     # Make sprite set
  1332.     @spriteset = Spriteset_Battle.new
  1333.     # Initialize wait count
  1334.     @wait_count = 0
  1335.     # Execute transition
  1336.     if $data_system.battle_transition == ""
  1337.       Graphics.transition(20)
  1338.     else
  1339.       Graphics.transition(40, "Graphics/Transitions/" +
  1340.         $data_system.battle_transition)
  1341.     end
  1342.     # Start pre-battle phase
  1343.     start_phase1
  1344.     # Main loop
  1345.     loop do
  1346.       # Update game screen
  1347.       Graphics.update
  1348.       # Update input information
  1349.       Input.update
  1350.       # Frame update
  1351.       update
  1352.       # Abort loop if screen is changed
  1353.       if $scene != self
  1354.         break
  1355.       end
  1356.     end
  1357.     # Refresh map
  1358.     $game_map.refresh
  1359.     # Prepare for transition
  1360.     Graphics.freeze
  1361.     # Dispose of windows
  1362.     @actor_command_window.dispose
  1363.     @party_command_window.dispose
  1364.     @help_window.dispose
  1365.     @status_window.dispose
  1366. #------------------------------------------------------------------------------
  1367. # Begin Multiple Message Windows Edit
  1368. #------------------------------------------------------------------------------
  1369.     for mw in @message_window
  1370.       mw.dispose
  1371.     end  
  1372. #------------------------------------------------------------------------------
  1373. # End Multiple Message Windows Edit
  1374. #------------------------------------------------------------------------------
  1375.     if @skill_window != nil
  1376.       @skill_window.dispose
  1377.     end
  1378.     if @item_window != nil
  1379.       @item_window.dispose
  1380.     end
  1381.     if @result_window != nil
  1382.       @result_window.dispose
  1383.     end
  1384.     # Dispose of sprite set
  1385.     @spriteset.dispose
  1386.     # If switching to title screen
  1387.     if $scene.is_a?(Scene_Title)
  1388.       # Fade out screen
  1389.       Graphics.transition
  1390.       Graphics.freeze
  1391.     end
  1392.     # If switching from battle test to any screen other than game over screen
  1393.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  1394.       $scene = nil
  1395.     end
  1396.   end
  1397.  
  1398.   def update
  1399.     # If battle event is running
  1400.     if $game_system.battle_interpreter.running?
  1401.       # Update interpreter
  1402.       $game_system.battle_interpreter.update
  1403.       # If a battler which is forcing actions doesn't exist
  1404.       if $game_temp.forcing_battler == nil
  1405.         # If battle event has finished running
  1406.         unless $game_system.battle_interpreter.running?
  1407.           # Rerun battle event set up if battle continues
  1408.           unless judge
  1409.             setup_battle_event
  1410.           end
  1411.         end
  1412.         # If not after battle phase
  1413.         if @phase != 5
  1414.           # Refresh status window
  1415.           @status_window.refresh
  1416.         end
  1417.       end
  1418.     end
  1419.     # Update system (timer) and screen
  1420.     $game_system.update
  1421.     $game_screen.update
  1422.     # If timer has reached 0
  1423.     if $game_system.timer_working and $game_system.timer == 0
  1424.       # Abort battle
  1425.       $game_temp.battle_abort = true
  1426.     end
  1427.     # Update windows
  1428.     @help_window.update
  1429.     @party_command_window.update
  1430.     @actor_command_window.update
  1431.     @status_window.update
  1432. #------------------------------------------------------------------------------
  1433. # Begin Multiple Message Windows Edit
  1434. #------------------------------------------------------------------------------
  1435.     for mw in @message_window
  1436.       mw.update
  1437.     end
  1438. #------------------------------------------------------------------------------
  1439. # End Multiple Message Windows Edit
  1440. #------------------------------------------------------------------------------
  1441.     # Update sprite set
  1442.     @spriteset.update
  1443.     # If transition is processing
  1444.     if $game_temp.transition_processing
  1445.       # Clear transition processing flag
  1446.       $game_temp.transition_processing = false
  1447.       # Execute transition
  1448.       if $game_temp.transition_name == ""
  1449.         Graphics.transition(20)
  1450.       else
  1451.         Graphics.transition(40, "Graphics/Transitions/" +
  1452.           $game_temp.transition_name)
  1453.       end
  1454.     end
  1455.     # If message window is showing
  1456.     if $game_temp.message_window_showing
  1457.       return
  1458.     end
  1459.     # If effect is showing
  1460.     if @spriteset.effect?
  1461.       return
  1462.     end
  1463.     # If game over
  1464.     if $game_temp.gameover
  1465.       # Switch to game over screen
  1466.       $scene = Scene_Gameover.new
  1467.       return
  1468.     end
  1469.     # If returning to title screen
  1470.     if $game_temp.to_title
  1471.       # Switch to title screen
  1472.       $scene = Scene_Title.new
  1473.       return
  1474.     end
  1475.     # If battle is aborted
  1476.     if $game_temp.battle_abort
  1477.       # Return to BGM used before battle started
  1478.       $game_system.bgm_play($game_temp.map_bgm)
  1479.       # Battle ends
  1480.       battle_end(1)
  1481.       return
  1482.     end
  1483.     # If waiting
  1484.     if @wait_count > 0
  1485.       # Decrease wait count
  1486.       @wait_count -= 1
  1487.       return
  1488.     end
  1489.     # If battler forcing an action doesn't exist,
  1490.     # and battle event is running
  1491.     if $game_temp.forcing_battler == nil and
  1492.        $game_system.battle_interpreter.running?
  1493.       return
  1494.     end
  1495.     # Branch according to phase
  1496.     case @phase
  1497.     when 1  # pre-battle phase
  1498.       update_phase1
  1499.     when 2  # party command phase
  1500.       update_phase2
  1501.     when 3  # actor command phase
  1502.       update_phase3
  1503.     when 4  # main phase
  1504.       update_phase4
  1505.     when 5  # after battle phase
  1506.       update_phase5
  1507.     end
  1508.   end
  1509.  
  1510.   #--------------------------------------------------------------------------
  1511.   # * New Message Window Addition
  1512.   #--------------------------------------------------------------------------
  1513.   def new_message_window(index)
  1514.     if @message_window[index] != nil
  1515.       # clear message windows at and after this index
  1516.       last_index = @message_window.size - 1
  1517.       last_index.downto(index) do |i|
  1518.         if @message_window[i] != nil
  1519.           @message_window[i].dispose
  1520.           @message_window[i] = nil
  1521.         end
  1522.       end
  1523.       @message_window.compact!
  1524.     end
  1525.     @message_window.push(Window_Message.new(index))
  1526.   end
  1527.  
  1528. end
  1529.  
  1530. #------------------------------------------------------------------------------
  1531.  
  1532. class Game_System
  1533.   attr_reader :message
  1534.  
  1535.   alias wachunga_mmw_game_system_init initialize
  1536.   def initialize
  1537.     wachunga_mmw_game_system_init
  1538.     @message = Game_Message.new
  1539.   end
  1540. end
  1541.  
  1542. #------------------------------------------------------------------------------
  1543.  
  1544. class Interpreter
  1545.   attr_reader :event_id
  1546.  
  1547.   alias wachunga_mmw_interp_setup setup
  1548.   def setup(list, event_id)
  1549.     wachunga_mmw_interp_setup(list, event_id)
  1550.     # index of window for the message
  1551.     @msgindex = 0
  1552.     # whether multiple messages are displaying
  1553.     @multi_message = false
  1554.   end
  1555.  
  1556.   def setup_choices(parameters)
  1557.     # Set choice item count to choice_max
  1558.     $game_temp.choice_max = parameters[0].size
  1559.     # Set choice to message_text
  1560.     for text in parameters[0]
  1561. #------------------------------------------------------------------------------
  1562. # Begin Multiple Message Windows Edit
  1563. #------------------------------------------------------------------------------
  1564.       # just add index for array
  1565.       $game_temp.message_text[@msgindex] += text + "\n"
  1566. #------------------------------------------------------------------------------
  1567. # End Multiple Message Windows Edit
  1568. #------------------------------------------------------------------------------
  1569.     end
  1570.     # Set cancel processing
  1571.     $game_temp.choice_cancel_type = parameters[1]
  1572.     # Set callback
  1573.     current_indent = @list[@index].indent
  1574.     $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
  1575.   end
  1576.  
  1577.  
  1578.   #--------------------------------------------------------------------------
  1579.   # * Show Text
  1580.   #--------------------------------------------------------------------------
  1581.   def command_101
  1582.     # If other text has been set to message_text
  1583. #------------------------------------------------------------------------------
  1584. # Begin Multiple Message Windows Edit
  1585. #------------------------------------------------------------------------------
  1586.     if $game_temp.message_text[@msgindex] != nil
  1587.       if @multi_message
  1588.         @msgindex += 1
  1589.         $scene.new_message_window(@msgindex)
  1590.       else
  1591.         # End
  1592. #------------------------------------------------------------------------------
  1593. # End Multiple Message Windows Edit
  1594. #------------------------------------------------------------------------------
  1595.         return false
  1596. #------------------------------------------------------------------------------
  1597. # Begin Multiple Message Windows Edit
  1598. #------------------------------------------------------------------------------
  1599.       end
  1600.     end
  1601.     @msgindex = 0 if !@multi_message
  1602.     @multi_message = false
  1603. #------------------------------------------------------------------------------
  1604. # End Multiple Message Windows Edit
  1605. #------------------------------------------------------------------------------
  1606.     # Set message end waiting flag and callback
  1607.     @message_waiting = true
  1608. #------------------------------------------------------------------------------
  1609. # Begin Multiple Message Windows Edit
  1610. #------------------------------------------------------------------------------
  1611.     # just adding indexes
  1612.     $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
  1613.     # Set message text on first line
  1614.     $game_temp.message_text[@msgindex] = @list[@index].parameters[0] + "\n"
  1615. #------------------------------------------------------------------------------
  1616. # End Multiple Message Windows Edit
  1617. #------------------------------------------------------------------------------
  1618.     line_count = 1
  1619.     # Loop
  1620.     loop do
  1621.       # If next event command text is on the second line or after
  1622.       if @list[@index+1].code == 401
  1623.         # Add the second line or after to message_text
  1624. #------------------------------------------------------------------------------
  1625. # Begin Multiple Message Windows Edit
  1626. #------------------------------------------------------------------------------
  1627.         # just adding index
  1628.         $game_temp.message_text[@msgindex]+=@list[@index+1].parameters[0]+"\n"
  1629. #------------------------------------------------------------------------------
  1630. # End Multiple Message Windows Edit
  1631. #------------------------------------------------------------------------------
  1632.         line_count += 1
  1633.       # If event command is not on the second line or after
  1634.       else
  1635.         # If next event command is show choices
  1636.         if @list[@index+1].code == 102
  1637.           # If choices fit on screen
  1638.           if @list[@index+1].parameters[0].size <= 4 - line_count
  1639.             # Advance index
  1640.             @index += 1
  1641.             # Choices setup
  1642.             $game_temp.choice_start = line_count
  1643.             setup_choices(@list[@index].parameters)
  1644.           end
  1645.         # If next event command is input number
  1646.         elsif @list[@index+1].code == 103
  1647.           # If number input window fits on screen
  1648.           if line_count < 4
  1649.             # Advance index
  1650.             @index += 1
  1651.             # Number input setup
  1652.             $game_temp.num_input_start = line_count
  1653.             $game_temp.num_input_variable_id = @list[@index].parameters[0]
  1654.             $game_temp.num_input_digits_max = @list[@index].parameters[1]
  1655.           end
  1656. #------------------------------------------------------------------------------
  1657. # Begin Multiple Message Windows Edit
  1658. #------------------------------------------------------------------------------
  1659.         # start multimessage if next line is "Show Text" starting with "\\+"
  1660.         elsif @list[@index+1].code == 101
  1661.           if @list[@index+1].parameters[0][0..1]=="\\+"
  1662.             @multi_message = true
  1663.             @message_waiting = false
  1664.           end
  1665. #------------------------------------------------------------------------------
  1666. # End Multiple Message Windows Edit
  1667. #------------------------------------------------------------------------------
  1668.         end
  1669.         # Continue
  1670.         return true
  1671.       end
  1672.       # Advance index
  1673.       @index += 1
  1674.     end
  1675.   end
  1676.  
  1677.   #--------------------------------------------------------------------------
  1678.   # * Show Choices
  1679.   #--------------------------------------------------------------------------
  1680.   def command_102
  1681.     # If text has been set to message_text
  1682. #------------------------------------------------------------------------------
  1683. # Begin Multiple Message Windows Edit
  1684. #------------------------------------------------------------------------------
  1685.     # just adding index
  1686.     if $game_temp.message_text[@msgindex] != nil
  1687. #------------------------------------------------------------------------------
  1688. # End Multiple Message Windows Edit
  1689. #------------------------------------------------------------------------------
  1690.       # End
  1691.       return false
  1692.     end
  1693.     # Set message end waiting flag and callback
  1694.     @message_waiting = true
  1695. #------------------------------------------------------------------------------
  1696. # Begin Multiple Message Windows Edit
  1697. #------------------------------------------------------------------------------
  1698.     # adding more indexes
  1699.     $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
  1700.     # Choices setup
  1701.     $game_temp.message_text[@msgindex] = ""
  1702. #------------------------------------------------------------------------------
  1703. # End Multiple Message Windows Edit
  1704. #------------------------------------------------------------------------------
  1705.     $game_temp.choice_start = 0
  1706.     setup_choices(@parameters)
  1707.     # Continue
  1708.     return true
  1709.   end
  1710.  
  1711.   #--------------------------------------------------------------------------
  1712.   # * Input Number
  1713.   #--------------------------------------------------------------------------
  1714.   def command_103
  1715.     # If text has been set to message_text
  1716. #------------------------------------------------------------------------------
  1717. # Begin Multiple Message Windows Edit
  1718. #------------------------------------------------------------------------------
  1719.     # just adding index
  1720.     if $game_temp.message_text[@msgindex] != nil
  1721. #------------------------------------------------------------------------------
  1722. # End Multiple Message Windows Edit
  1723. #------------------------------------------------------------------------------
  1724.       # End
  1725.       return false
  1726.     end
  1727.     # Set message end waiting flag and callback
  1728.     @message_waiting = true
  1729. #------------------------------------------------------------------------------
  1730. # Begin Multiple Message Windows Edit
  1731. #------------------------------------------------------------------------------
  1732.     # adding more indexes
  1733.     $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
  1734.     # Number input setup
  1735.     $game_temp.message_text[@msgindex] = ""
  1736. #------------------------------------------------------------------------------
  1737. # End Multiple Message Windows Edit
  1738. #------------------------------------------------------------------------------
  1739.     $game_temp.num_input_start = 0
  1740.     $game_temp.num_input_variable_id = @parameters[0]
  1741.     $game_temp.num_input_digits_max = @parameters[1]
  1742.     # Continue
  1743.     return true
  1744.   end
  1745.  
  1746.   #--------------------------------------------------------------------------
  1747.   # * Script
  1748.   #--------------------------------------------------------------------------
  1749.   # Fix for RMXP bug: call script boxes that return false hang the game
  1750.   # See, e.g., http://hbgames.org/forums/showthread.php?p=106639  
  1751.   #--------------------------------------------------------------------------
  1752.   def command_355
  1753.     # Set first line to script
  1754.     script = @list[@index].parameters[0] + "\n"
  1755.     # Loop
  1756.     loop do
  1757.       # If next event command is second line of script or after
  1758.       if @list[@index+1].code == 655
  1759.         # Add second line or after to script
  1760.         script += @list[@index+1].parameters[0] + "\n"
  1761.       # If event command is not second line or after
  1762.       else
  1763.         # Abort loop
  1764.         break
  1765.       end
  1766.       # Advance index
  1767.       @index += 1
  1768.     end
  1769.     # Evaluation
  1770.     result = eval(script)
  1771.     # If return value is false
  1772.     if result == false
  1773.       # End
  1774. #------------------------------------------------------------------------------
  1775. # Begin Edit
  1776. #------------------------------------------------------------------------------
  1777.       #return false
  1778. #------------------------------------------------------------------------------
  1779. # End Edit
  1780. #------------------------------------------------------------------------------
  1781.     end
  1782.     # Continue
  1783.     return true
  1784.   end
  1785.  
  1786.   def message
  1787.     $game_system.message
  1788.   end
  1789.  
  1790. end
  1791.  
  1792. #------------------------------------------------------------------------------
  1793.  
  1794. class Game_Map
  1795.   attr_accessor :last_display_x                # last display x-coord * 128
  1796.   attr_accessor :last_display_y                # last display y-coord * 128
  1797.  
  1798.   alias wachunga_mmw_game_map_update update
  1799.   def update
  1800.     @last_display_x = @display_x
  1801.     @last_display_y = @display_y
  1802.     wachunga_mmw_game_map_update
  1803.   end
  1804.  
  1805.   def name
  1806.     return load_data('Data/MapInfos.rxdata')[@map_id].name
  1807.   end
  1808. end
  1809.  
  1810. #------------------------------------------------------------------------------
  1811.  
  1812. class Bitmap
  1813.  
  1814.   attr_accessor :orientation
  1815.  
  1816.   #--------------------------------------------------------------------------
  1817.   # * Rotation Calculation
  1818.   #--------------------------------------------------------------------------
  1819.   def rotation(target)
  1820.     return if not [0, 90, 180, 270].include?(target) # invalid orientation
  1821.     if @rotation != target
  1822.       degrees = target - @orientation
  1823.       if degrees < 0
  1824.         degrees += 360
  1825.       end
  1826.       rotate(degrees)
  1827.     end    
  1828.   end
  1829.  
  1830.   #--------------------------------------------------------------------------
  1831.   # * Rotate Square (Clockwise)
  1832.   #--------------------------------------------------------------------------
  1833.   def rotate(degrees = 90)
  1834.     # method originally by SephirothSpawn
  1835.     # would just use Sprite.angle but its rotation is buggy
  1836.     # (see http://www.hbgames.org/forums/showthread.php?t=12044)
  1837.     return if not [90, 180, 270].include?(degrees)
  1838.     copy = self.clone
  1839.     if degrees == 90
  1840.       # Passes Through all Pixels on Dummy Bitmap
  1841.       for i in 0...self.height
  1842.         for j in 0...self.width
  1843.           self.set_pixel(width - i - 1, j, copy.get_pixel(j, i))
  1844.         end
  1845.       end
  1846.     elsif degrees == 180
  1847.       for i in 0...self.height
  1848.         for j in 0...self.width
  1849.           self.set_pixel(width - j - 1, height - i - 1, copy.get_pixel(j, i))
  1850.         end
  1851.       end      
  1852.     elsif degrees == 270
  1853.       for i in 0...self.height
  1854.         for j in 0...self.width
  1855.           self.set_pixel(i, height - j - 1, copy.get_pixel(j, i))
  1856.         end
  1857.       end
  1858.     end
  1859.     @orientation = (@orientation + degrees) % 360
  1860.   end
  1861.  
  1862. end
  1863.  
  1864.  
Expand to see the code.


But I find that it conflicts with Enu/Atoa's SBS

  1. #==============================================================================
  2. # Sideview Battle System Configurations Version 2.2xp
  3. #==============================================================================
  4. #  Original Script by:
  5. #               Enu (http://rpgex.sakura.ne.jp/home/)
  6. #  Conversion to XP by:
  7. #               Atoa
  8. #  Original translation versions by:
  9. #               Kylock
  10. #  Translation continued by:
  11. #               Mr. Bubble
  12. #  XP version Translation by:
  13. #               cairn
  14. #  Special thanks:
  15. #               Shu (for translation help)
  16. #               Moonlight (for her passionate bug support for this script)
  17. #               NightWalker (for his community support for this script)
  18. #               XRXS (for the script of damage gravity, which was modified and
  19. #                     used as the system's base of damage exibition)
  20. #               Squall (for the FF styled damage script, which was modified
  21. #                       and added to the damage exibition system)
  22. #               KGC (for the STBreaker script, which was the base for the
  23. #                    attribute limit system)
  24. #               Herena Isaberu (for her support in XP version bug fixes)
  25. #               Enu (for making an awesome battle system)
  26. #==============================================================================
  27.  
  28. #==============================================================================
  29. # ■ module N01
  30. #------------------------------------------------------------------------------
  31. #  Sideview Battle System Config
  32. #==============================================================================
  33. module N01
  34.  #--------------------------------------------------------------------------
  35.  # ● Settings
  36.  #--------------------------------------------------------------------------
  37.   # Battle member starting positions
  38.   #                   X   Y     X   Y     X   Y     X   Y
  39.   ACTOR_POSITION = [[230,280],[130,290],[180,200],[220,270]]
  40.  
  41.   # Maximum party members that can fight at the same time.
  42.   # Remember to add/remove coordinates in ACTOR_POSITION if you adjust
  43.   # the MAX_MEMBER value.
  44.   MAX_MEMBER = 4
  45.  
  46.   # Delay time after a battler completes an action in frames.
  47.   ACTION_WAIT = 6
  48.  
  49.   # Delay time before enemy collapse (defeat of enemy) animation in frames.
  50.   COLLAPSE_WAIT = 6
  51.  
  52.   # Delay before victory is processed in frames.
  53.   WIN_WAIT = 30
  54.    
  55.   # Animation ID for any unarmed attack.
  56.   NO_WEAPON = 4
  57.  
  58.   # Damage modifications when using two weapons.  Values are percentages.
  59.   #               1st Wpn, 2nd Wpn
  60.   TWO_SWORDS_STYLE = [100,50]
  61.  
  62.   # Auto-Life State: Revivial Animation ID
  63.   RESURRECTION = 25
  64.  
  65.   # POP Window indicator words.  For no word results, use "".
  66.   POP_MISS    = "Miss"        # Attack missed 
  67.   POP_EVA     = "Evade"       # Attack avoided
  68.   POP_CRI     = "Crit"    # Attack scored a critical hit
  69.  
  70.   # Set to false to remove shadow under actors
  71.   SHADOW = false
  72.  
  73.   # true: Use actor's walking graphic.
  74.   # false: Don't use actor's walking graphic.
  75.   # If false, battler file with "_1" is required since walking file is not used.
  76.   # "_1" and subsequent files ("_2", "_3", etc.) should be uniform in size.
  77.   WALK_ANIME = false
  78.  
  79.   # Number of frames in a battler animation file. (horizontal frames)
  80.   ANIME_PATTERN = 4
  81.  
  82.   # Number of types of battler animation file. (vertical frames)
  83.   ANIME_KIND = 1
  84.  
  85. #==============================================================================
  86. # ■ Single Action Engine
  87. #------------------------------------------------------------------------------
  88. # These are utilized by sequenced actions and have no utility alone.
  89. #==============================================================================
  90.  # A single-action cannot be used by itself unless it is used as part of a
  91.  # sequence.
  92.   ANIME = {
  93.  #--------------------------------------------------------------------------
  94.  # ● Battler Animations
  95.  #--------------------------------------------------------------------------
  96.   # No.    - Battler graphic file used.
  97.   #             0: Normal Battler Graphic.  In the case of Actors, 0 refers to
  98.   #                 default walking graphic.
  99.   #             n: "Character Name + _n", where n refers to the file number
  100.   #                 extension.  An example file would be "$Ralph_1".  These
  101.   #                 files are placed in the Characters folder.
  102.   #                 Use "1" for non-standard battler, like Minkoff's.
  103.   #
  104.   # Row    - Vertical position (row) of cells in battler graphic file. (0~3)
  105.   # Speed  - Refresh rate of animation. Lower numbers are faster.
  106.   # Loop   - [0: "Round-Trip" Loop]    Example: 1 2 3 2 1 2 3 2 1 ...
  107.   #          [1: "One-Way" Loop]       Example: 1 2 3 1 2 3 1 2 3 ...
  108.   #          [2: One Loop, no repeat]  Example: 1 2 3 .
  109.   # Wait   - Time, in frames, before animation loops again.
  110.   #          Does not apply if Loop=2
  111.   # Fixed  - Defines loop behavior or specific fixed cell display.
  112.   #          -2: Reverse Loop Animation
  113.   #          -1: Normal Loop Animation
  114.   #           0: No Loop Animation
  115.   #         0~3: Fixed cell display.  Refers to cell on character sprite
  116.   #              sheet starting where 0 = left-most cell.
  117.   # Z      - Set battler's Z priority.
  118.   # Shadow - Set true to display battler shadow during animation; false to hide.
  119.   # Weapon - Weapon animation to play with battler animation.  For no weapon
  120.   #          animation, use "".
  121.  
  122.   # Action Name          No. Row Speed Loop Wait Fixed  Z Shadow  Weapon
  123.   "WAIT"              => [ 1,  0,  15,   1,   0,  -1,   0, true,"" ],
  124.   "WAIT(FIXED)"       => [ 1,  0,  10,   1,   0,  -1,   0, true,"" ],
  125.   "RIGHT(FIXED)"      => [ 1,  0,  10,   1,   0,  -1,   0, true,"" ],
  126.   "DAMAGE"            => [ 1,  0,   4,   1,   0,   0,   0, true,"" ],
  127.   "ATTACK_FAIL"       => [ 1,  0,  10,   1,   0,   1,   0, true,"" ],
  128.   "MOVE_TO"           => [ 1,  0,  10,   1,   0,  -1,   0, true,"" ],
  129.   "MOVE_AWAY"         => [ 1,  0,   8,   1,   0,  -1,   0, true,"" ],
  130.   "ABOVE_DISPLAY"     => [ 1,  0,   2,   1,   0,  -1, 600, true,"" ],
  131.   "WPN_SWING_V"       => [ 1,  0,  10,   1,   0,  -1,   2, true,"VERT_SWING"],
  132.   "WPN_SWING_VL"      => [ 1,  0,  10,   1,   0,  -1,   2, true,"VERT_SWINGL"],
  133.   "WPN_SWING_VS"      => [ 1,  0,  10,   1,   0,  -1,   2, true,"VERT_SWING"],
  134.   "WPN_SWING_UNDER"   => [ 1,  0,  10,   1,   0,  -1,   2, true,"UNDER_SWING"],
  135.   "WPN_SWING_OVER"    => [ 1,  0,  10,   1,   0,  -1,   2, true,"OVER_SWING"],
  136.   "WPN_RAISED"        => [ 1,  0,  10,   1,   0,  -1,   2, true,"RAISED"],
  137.  
  138.  #--------------------------------------------------------------------------
  139.  # ● Weapon Animations
  140.  #--------------------------------------------------------------------------
  141.   # Weapon Animations can only be used with Battler Animations as seen
  142.   # and defined above.
  143.   #
  144.   # Xa - Distance weapon sprite is moved on the X-axis.
  145.   # Ya - Distance weapon sprite is moved on the Y-axis.  Please note that
  146.   #      the Y-axis is inverted. This means negative values move up, positive
  147.   #      values move down.
  148.   # Za - If true, weapon sprite is displayed over battler sprite.
  149.   #      If false, weapon sprite is displayed behind battler sprite.
  150.   # A1 - Starting angle of weapon sprite rotation.  Negative numbers will
  151.   #      result in counter-clockwise rotation.
  152.   # A2 - Ending angle of weapon sprite rotation.  Rotation will stop here.
  153.   # Or - Rotation Origin - [0: Center] [1: Upper Left] [2: Upper Right]
  154.   #                        [3:Bottom Left] [4:Bottom Right]
  155.   # Inv - Invert - If true, horizontally inverts weapon sprite.
  156.   # Xs - X scale - Stretches weapon sprite horizontally by a factor of X.
  157.   #                Values may be decimals. (0.6, 0.9, etc.)
  158.   # Ys - Y scale - Stretches weapon sprite vertically by a factor of Y.
  159.   #                Values may be decimals. (0.6, 0.9, etc.)
  160.   # Xp - X pitch - For adjusting the X axis. This number changes the initial
  161.   #                X coordinate.
  162.   # Yp - Y pitch - For adjusting the Y axis. This number changes the initial
  163.   #                Y coordinate.
  164.   # Weapon2 - If set to true, Two Weapon Style's Weapon 2 sprite will be used
  165.   #           instead.
  166.  
  167.   # Action Name        Xa   Ya  Za    A1    A2  Or  Inv  Xs  Ys   Xp   Yp Weapon2
  168.   "VERT_SWING"   => [  6,   8,false,-135,  45,  4,false,   1,  1,  -6, -12,false],
  169.   "VERT_SWINGL"  => [  6,   8,false,-135,  45,  4,false,   1,  1,  -6, -12, true],
  170.   "UNDER_SWING"  => [  6,   8,false, 270,  45,  4,false,   1,  1,  -6, -12,false],
  171.   "OVER_SWING"   => [  6,   8,false,  45,-100,  4,false,   1,  1,  -6, -12,false],
  172.   "RAISED"       => [  6,  -4,false,  90, -45,  4,false,   1,  1,  -6, -12,false],
  173.  
  174.  #--------------------------------------------------------------------------
  175.  # ● Battler Movements
  176.  #--------------------------------------------------------------------------
  177.   # Origin - Defines the origin of movement based on an (x,y) coordinate plane.
  178.   #          1 unit = 1 pixel
  179.   #             [0: Battler's Current Position]
  180.   #             [1: Battler's Selected Target]
  181.   #             [2: Screen; (0,0) is at upper-left of screen]
  182.   #             [3: Battle Start Position]
  183.   # X - X-axis pixels from origin.
  184.   # Y - Y-axis pixels from origin.  Please note that the Y-axis is
  185.   #     inverted. This means negative values move up, positive values move down.
  186.   # Time - Travel time.  Larger numbers are slower.  The distance is
  187.   #        divided by one frame of movement.
  188.   # Accel - Positive values accelerates frames.  Negative values decelerates.
  189.   # Jump - Negative values produce a jumping arc.  Positive values produce
  190.   #        a reverse arc.  [0: No jump]
  191.   # Animation - Battler Animation utilized during movement.
  192.  
  193.   #                           Origin  X   Y  Time  Accel Jump Animation
  194.   "NO_MOVE"                 => [  0,   0,   0,  1,   0,   0,  "WAIT(FIXED)"],
  195.   "START_POSITION"          => [  0,  54,   0,  1,   0,   0,  "MOVE_TO"],
  196.   "BEFORE_MOVE"             => [  3,  32,   0, 18,  -1,   0,  "MOVE_TO"],
  197.   "AFTER_MOVE"              => [  0, -32,   0,  8,  -1,   0,  "MOVE_TO"],
  198.   "4_MAN_ATTACK_1"          => [  2, 564, 186, 12,  -1,   0,  "MOVE_TO"],
  199.   "4_MAN_ATTACK_2"          => [  2, 564, 212, 12,  -1,   0,  "MOVE_TO"],
  200.   "4_MAN_ATTACK_3"          => [  2, 504, 174, 12,  -1,   0,  "MOVE_TO"],
  201.   "4_MAN_ATTACK_4"          => [  2, 504, 254, 12,  -1,   0,  "MOVE_TO"],
  202.   "DEAL_DAMAGE"             => [  0,  32,   0,  4,  -1,   0,  "DAMAGE"],
  203.   "EXTRUDE"                 => [  0,  12,   0,  1,   1,   0,  "DAMAGE"],
  204.   "FLEE_SUCCESS"            => [  0, -300,   0,300,   1,   0,  "MOVE_AWAY"],
  205.   "FLEE_FAIL"               => [  0,  -48,   0, 16,   1,   0,  "MOVE_AWAY"],
  206.   "VICTORY_JUMP"            => [  0,   0,   0, 20,   0,  -5,  "MOVE_TO"],
  207.   "MOVING_TARGET"           => [  0,   0,   0, 18,  -1,   0,  "MOVE_TO"],
  208.   "MOVING_TARGET_FAST"      => [  0,   0, -12,  8,   0,  -2,  "MOVE_TO"],
  209.   "PREV_MOVING_TARGET"      => [  0,  24,   0, 12,  -1,   0,  "MOVE_TO"],
  210.   "PREV_MOVING_TARGET_FAST" => [  0,  24,   0,  1,   0,   0,  "MOVE_TO"],
  211.   "MOVING_TARGET_RIGHT"     => [  0,  96,  32, 16,  -1,   0,  "MOVE_TO"],
  212.   "MOVING_TARGET_LEFT"      => [  0,  96, -32, 16,  -1,   0,  "MOVE_TO"],
  213.   "JUMP_TO"                 => [  0, -32,   0,  8,  -1,  -4,  "MOVE_TO"],
  214.   "JUMP_AWAY"               => [  0,  32,   0,  8,  -1,  -4,  "MOVE_AWAY"],
  215.   "JUMP_TO_TARGET"          => [  0,  12, -12, 12,  -1,  -6,  "MOVE_TO"],
  216.   "THROW_ALLY"              => [  0, -24,   0, 16,   0,  -2,  "MOVE_TO"],
  217.   "TRAMPLE"                 => [  0,  12, -32, 12,  -1,  -6,  "ABOVE_DISPLAY"],
  218.   "PREV_JUMP_ATTACK"        => [  0, -32,   0, 12,  -1,  -2,  "WPN_SWING_V"],
  219.   "PREV_STEP_ATTACK"        => [  0,  12,   0, 12,  -1,  -5,  "WPN_SWING_VS"],
  220.   "REAR_SWEEP_ATTACK"       => [  0,  12,   0, 16,   0,  -3,  "WPN_SWING_V"],
  221.   "JUMP_FIELD_ATTACK"       => [  0,   0,   0, 16,   0,  -5,  "WPN_SWING_V"],
  222.   "DASH_ATTACK"             => [  0, -96,   0, 16,   2,   0,  "WPN_SWING_V"],
  223.   "RIGHT_DASH_ATTACK"       => [  0, -96,  32, 16,   2,   0,  "WPN_SWING_V"],
  224.   "LEFT_DASH_ATTACK"        => [  0, -96, -32, 16,   2,   0,  "WPN_SWING_V"],
  225.   "RIGHT_DASH_ATTACK2"      => [  0,-128,  48, 16,   2,   0,  "WPN_SWING_V"],
  226.   "LEFT_DASH_ATTACK2"       => [  0,-128, -48, 16,   2,   0,  "WPN_SWING_V"],
  227.  
  228.  #--------------------------------------------------------------------------
  229.  # ● Battler Float Animations
  230.  #--------------------------------------------------------------------------
  231.   # These types of single-actions defines the movement of battlers from their
  232.   # own shadows.  Please note that it is not possible to move horizontally
  233.   # while floating from a shadow.
  234.   #
  235.   # Type - Always "float".
  236.   # A - Starting float height. Negative values move up.
  237.   #                            Positive values move down.
  238.   # B - Ending float height.  This height is maintained until another action.
  239.   # Time - Duration of movement from point A to point B
  240.   # Animation - Specifies the Battler Animation to be used.
  241.  
  242.   #                   Type     A    B  Time  Animation
  243.   "FLOAT_"      => ["float", -22, -20,  2, "WAIT(FIXED)"],
  244.   "FLOAT_2"     => ["float", -20, -18,  2, "WAIT(FIXED)"],
  245.   "FLOAT_3"     => ["float", -18, -20,  2, "WAIT(FIXED)"],
  246.   "FLOAT_4"     => ["float", -20, -22,  2, "WAIT(FIXED)"],
  247.   "JUMP_STOP"   => ["float",   0, -80,  4, "WAIT(FIXED)"],
  248.   "JUMP_LAND"   => ["float", -80,   0,  4, "WAIT(FIXED)"],
  249.   "LIFT"        => ["float",   0, -30,  4, "WAIT(FIXED)"],
  250.  
  251.  #--------------------------------------------------------------------------
  252.  # ● Battler Position Reset
  253.  #--------------------------------------------------------------------------
  254.   # These types of single-actions define when a battler's turn is over and
  255.   # will reset the battler back to its starting coordinates.  This type of
  256.   # single-action is required in all sequences.  
  257.   #
  258.   # Please note that after a sequence has used this type of single-action,
  259.   # no more damage can be done by the battler since its turn is over.
  260.   #
  261.   # Type - Always "reset"
  262.   # Time - Time it takes to return to starting coordinates.  Movement speed
  263.   #        fluctuates depending on distance from start coordinates.
  264.   # Accel - Positive values accelerate.  Negative values decelerate.
  265.   # Jump - Negative values produce a jumping arc.  Positive values produce
  266.   #        a reverse arc.  [0: No jump]
  267.   # Animation - Specifies the Battler Animation to be used.
  268.  
  269.   #                   Type   Time Accel Jump Animation
  270.   "COORD_RESET"   => ["reset", 16,  0,   0,  "MOVE_TO"],
  271.   "FLEE_RESET"    => ["reset", 16,  0,   0,  "MOVE_AWAY"],
  272.  
  273.  #--------------------------------------------------------------------------
  274.  # ● Forced Battler Actions
  275.  #--------------------------------------------------------------------------
  276.   # These types of single-actions allow forced control of other battlers
  277.   # that you define.
  278.   #
  279.   # Type - Specifies action type.  "SINGLE" or "SEQUENCE"
  280.   #
  281.   # Object -    The battler that will execute the action defined under Action
  282.   #          Name. 0 is for selected target, and any other number is a State
  283.   #          number (1~999), and affects all battlers with the State on them.  
  284.   #             By adding a - (minus sign) followed by a Skill ID number (1~999),
  285.   #          it will define the actors that know the specified skill, besides
  286.   #          the original actor.
  287.   #             If you want to designate an actor by their index ID number,
  288.   #          add 1000 to their index ID number. If the system cannot designate
  289.   #          the index number(such as if actor is dead or ran away), it will
  290.   #          select the nearest one starting from 0.  If a response fails,
  291.   #          the action will be canceled. (Example: Ylva's actor ID is 4.  A
  292.   #          value of 1004 would define Ylva as the Object.)
  293.   #
  294.   # Reset Type - Specifies method of returning the battler to its original
  295.   #                 location.
  296.   # Action Name - Specifies action used.  If Type is SINGLE, then Action Name
  297.   #               must be a single-action function.  If Type is SEQUENCE,
  298.   #               the Action Name must an action sequence name.
  299.  
  300.   #                         Type   Object   Reset Type      Action Name
  301.   "LIGHT_BLOWBACK"    => ["SINGLE",     0,  "COORD_RESET",  "EXTRUDE"],
  302.   "RIGHT_TURN"        => ["SINGLE",     0,  "COORD_RESET",  "CLOCKWISE_TURN"],
  303.   "DROP_DOWN"         => ["SINGLE",     0,  "COORD_RESET",  "Y_SHRINK"],
  304.   "IMPACT_1"          => ["SINGLE",     0,  "COORD_RESET",  "OBJ_TO_SELF"],
  305.   "LIFT_ALLY"         => ["SINGLE",     0,             "",  "LIFT"],
  306.   "ULRIKA_ATTACK"     => ["SEQUENCE",   18, "COORD_RESET",  "ULRIKA_ATTACK_1"],
  307.   "4_MAN_ATK_1"       => ["SEQUENCE", -101, "COORD_RESET",  "4_MAN_ATTACK_1"],
  308.   "4_MAN_ATK_2"       => ["SEQUENCE", -102, "COORD_RESET",  "4_MAN_ATTACK_2"],
  309.   "4_MAN_ATK_3"       => ["SEQUENCE", -103, "COORD_RESET",  "4_MAN_ATTACK_3"],
  310.   "ALLY_FLING"        => ["SEQUENCE", 1000, "COORD_RESET",  "THROW"],
  311.  
  312.  #--------------------------------------------------------------------------
  313.  # ● Target Modification
  314.  #--------------------------------------------------------------------------
  315.   # Changes battler's target in battle.  Original target will still be stored.  
  316.   # Current battler is the only battler capable of causing damage.
  317.   #
  318.   # Type - Always "target"
  319.   #
  320.   # Object -    The battler that will have its target modified.  0 is selected
  321.   #          target, any other number is a State ID number (1~999), and
  322.   #          changes all battlers with that state on them to target the new
  323.   #          designated target.
  324.   #             If you want to designate an actor by their index ID number,
  325.   #          add 1000 to their index ID number. If the system cannot designate
  326.   #          the index number(such as if actor is dead or ran away), it will
  327.   #          select the nearest one starting from 0.  If a response fails,
  328.   #          the action will be canceled. (Example: Ylva's actor ID is 4.  A
  329.   #          value of 1004 would define Ylva as the Object.)
  330.   #
  331.   # Target - New Target. [0=Self]  [1=Self's Target]
  332.   #                      [2=Self's Target After Modification]
  333.   #                      [3=Reset to Previous Target (if 2 was used)]
  334.  
  335.   # Target Mod name            Type   Object  Target
  336.   "REAL_TARGET"           => ["target",    0,  0],
  337.   "TWO_UNIFIED_TARGETS"   => ["target",   18,  1],
  338.   "FOUR_UNIFIED_TARGETS"  => ["target",   19,  1],
  339.   "ALLY_TO_THROW"         => ["target", 1000,  2],
  340.   "THROW_TARGET"          => ["target", 1000,  3],
  341.  
  342.  #--------------------------------------------------------------------------
  343.  # ● Skill Linking
  344.  #--------------------------------------------------------------------------
  345.   # Linking to the next skill will stop any current action.  Linking to the
  346.   # next skill will also require and consume MP/HP cost of that skill.
  347.   #
  348.   # Type - Always "der"
  349.   # Chance - Chance, in percent, to link to the defined skill ID. (0~100)
  350.   # Link - true: actor does not require Skill ID learned to link.
  351.   #        false: actor requires Skill ID learned.
  352.   # Skill ID - ID of the skill that will be linked to.
  353.  
  354.   # Action Name           Type  Chance Link Skill ID
  355.   "LINK_SKILL_91"     => ["der", 100, true,  91],
  356.   "LINK_SKILL_92"     => ["der", 100, true,  92],
  357.  
  358.  #--------------------------------------------------------------------------
  359.  # ● Action Conditions
  360.  #--------------------------------------------------------------------------
  361.   # If the condition is not met, all current actions are canceled.
  362.   #
  363.   # A: Type - always "nece"
  364.   # B: Object - Object that Condition refers to. [0=Self] [1=Target]
  365.   #                                           [2=All Enemies] [3=All Allies]
  366.   # C: Content - [0=State] [1=Parameter] [2=Switch] [3=Variable] [4=Skill]
  367.   #
  368.   # D: Condition - This value is determined by the value you set for Content.
  369.   # [0] State: State ID
  370.   # [1] Parameter: [0=Current HP] [1=Current MP] [2=ATK] [3=DEX] [4=AGI] [5=INT]
  371.   # [2] Switch: Game Switch Number
  372.   # [3] Variable: Game Variable Number
  373.   # [4] Skill: Skill ID
  374.   #
  375.   # E: Supplement - Supplement for the Condition as defined above.
  376.   # [0] State: Amount required.  If number is positive, the condition is how
  377.   #            many have the state, while a negative number are those who
  378.   #            don't have the state.
  379.   # [1] Parameter: If Object is more than one battler, average is used.
  380.   #                Success if Parameter is greater than value.  If Value
  381.   #                is negative, then success if lower.
  382.   # [2] Switch: [true: Switch ON succeeds] [false: Switch OFF succeeds]
  383.   # [3] Variable: Game variable value used to determine if condition is met.  If
  384.   #               supplement value is positive, Game Variable must have more
  385.   #               than the defined amount to succeed.  If supplement value has a
  386.   #               minus symbol (-) attached, Game Variable must have less than
  387.   #               the defined amount to succeed.  (Ex: -250 means the Game
  388.   #               Variable must have a value less than 250 to succeed.)
  389.   # [4] Skill: Required amount of battlers that have the specified skill
  390.   #            ID learned.
  391.  
  392.   #                       Type  Obj  Cont  Cond   Supplement
  393.   #                         A     B   C    D    E
  394.   "2_MAN_ATK_COND"  => ["nece",   3,  0,  18,   1],
  395.   "4_MAN_ATK_COND"  => ["nece",   3,  0,  19,   3],
  396.   "FLOAT_STATE"     => ["nece",   0,  0,  17,   1],
  397.   "CAT_STATE"       => ["nece",   0,  0,  20,   1],
  398.  
  399.  #--------------------------------------------------------------------------
  400.  # ● Battler Rotation
  401.  #--------------------------------------------------------------------------
  402.   # Rotates battler image.  Weapon Animations are not automatically adjusted
  403.   # for Battler Rotation like with Invert settings.
  404.   #
  405.   # Type - always "angle"
  406.   # Time - Duration duration of rotation animation in frames.
  407.   # Start - Starting angle. 0-360 degrees.  Can be negative.
  408.   # End - Ending Angle. 0-360 degrees.  Can be negative.
  409.   # Return - true: End of rotation is the same as end of duration.
  410.   #          false: Rotation animation as defined.
  411.  
  412.   #                           Type   Time Start  End  Return
  413.   "FALLEN"                => ["angle",  1, -90, -90,false],
  414.   "CLOCKWISE_TURN"        => ["angle", 48,   0,-360,false],
  415.   "COUNTERCLOCKWISE_TURN" => ["angle",  6,   0, 360,false],
  416.  
  417.  #--------------------------------------------------------------------------
  418.  # ● Battler Zoom
  419.  #--------------------------------------------------------------------------
  420.   # Stretch and shrink battler sprites with these single-actions.
  421.   #
  422.   # Type - always "zoom"
  423.   # Time - Duration of zoom animation in frames.
  424.   # X - X scale - Stretches battler sprite horizontally by a factor of X.
  425.   #               1.0 is normal size, 0.5 is half size.
  426.   # Y - Y scale - Stretches battler sprite vertically by a factor of Y.
  427.   #               1.0 would be normal size, 0.5 would be half size.
  428.   # Return - true: End of rotation is the same as end of duration.
  429.   #          false: Zoom animation as defined.
  430.   #          Battler zoom is still temporary.
  431.  
  432.   #                   Type  Time   X    Y   Return
  433.   "X_SHRINK"         => ["zoom", 16, 0.5, 1.0, true],
  434.   "Y_SHRINK"         => ["zoom", 16, 1.0, 0.5, true],
  435.  
  436.  #--------------------------------------------------------------------------
  437.  # ● Damage and Database-Assigned Animations
  438.  #--------------------------------------------------------------------------
  439.   # These single-actions deal with animations, particularly with those assigned
  440.   # in the Database for Weapons, Skills and Items.  These are what causes
  441.   # any damage/healing/state/etc. application from Weapons, Skills and Items.
  442.   #
  443.   # A difference between "anime" and "m_a" single-actions is that
  444.   # "anime" triggered animations will move with the Object on the screen.  The
  445.   # Z-axis of animations will always be over battler sprites.  If "OBJ_ANIM"
  446.   # is added at the beginning of the name, it will be both damage and defined
  447.   # animation.
  448.   #
  449.   # Type - always "anime"
  450.   # ID - (-1): Uses assigned animation from game Database.
  451.   #      (-2): Uses equipped Weapon animation as assigned in the Database.
  452.   #   (1~999): Database Animation ID.
  453.   # Object - [0=Self] [1=Target]
  454.   # Invert - If set to true, the animation is inverted horizontally.
  455.   # Wait - true: Sequence will not continue until animation is completed.
  456.   #        false: Sequence will continue regardless of animation length.
  457.   # Weapon2 - true: If wielding two weapons, damage and animation will be
  458.   #                 based off Weapon 2.
  459.  
  460.   #                         Type   ID  Object Invert  Wait  Weapon2
  461.   "OBJ_ANIM"        => ["anime",  -1,  1, false,false, false],
  462.   "OBJ_ANIM_WEIGHT" => ["anime",  -1,  1, false, true, false],
  463.   "OBJ_ANIM_WEAPON" => ["anime",  -2,  1, false,false, false],
  464.   "OBJ_ANIM_L"      => ["anime",  -1,  1, false,false,  true],
  465.   "HIT_ANIM"        => ["anime",  14,  1, false,false, false],
  466.   "KILL_HIT_ANIM"   => ["anime",  67,  1, false,false, false],
  467.    
  468.  #--------------------------------------------------------------------------
  469.  # ● Movement and Display of Animations
  470.  #--------------------------------------------------------------------------
  471.   # These single-actions provide motion options for animations used for
  472.   # effects such as long-ranged attacks and projectiles.  Weapon sprites
  473.   # may also substitute animations.
  474.   #
  475.   # A difference between "m_a" and "anime" single-actions is that "m_a"
  476.   # animations will stay where the Object was even if the Object moved.
  477.   #
  478.   # Type - always "m_a"
  479.   # ID - 1~999: Database Animation ID
  480.   #          0: No animation displayed.
  481.   # Object - Animation's target. [0=Target] [1=Enemy's Area]
  482.   #                              [2=Party's Area] [4=Self]
  483.   # Pass -  [0: Animation stops when it reaches the Object.]
  484.   #         [1: Animation passes through the Object and continues.]
  485.   # Time - Duration of animation travel time and display.  Larger values
  486.   #        decrease travel speed.  Increase this value if the animation
  487.   #        being played is cut short.
  488.   # Arc - Trajectory - Positive values produce a low arc.
  489.   #                    Negative values produce a high arc.
  490.   #                    [0: No Arc]
  491.   # Xp - X Pitch - This value adjusts the initial X coordinate of the
  492.   #                animation. Enemy calculation will be automatically inverted.
  493.   # Yp - Y Pitch - This value adjusts the initial X coordinate of the
  494.   #                animation.
  495.   # Start - Defines origin of animation movement.
  496.   #              [0=Self] [1=Target] [2=No Movement]
  497.   # Z-axis - true: Animation will be over the battler sprite.
  498.   #          false: Animation will be behind battler sprite.
  499.   # Weapon - Insert only "Throwing Weapon Rotation" and
  500.   #          "Throwing Skill Rotation" actions. For no weapon sprite, use "".
  501.  
  502.   #                        Type   ID Object Pass Time Arc  Xp Yp Start Z Weapon
  503.   "START_MAGIC_ANIM"  => ["m_a",  2,   4,  0,  50,   0,  0,  0, 2,false,""],
  504.   "OBJ_TO_SELF"       => ["m_a", 51,   0,  0,  18,   0,  0,  0, 1,false,""],
  505.   "START_WEAPON_THROW"=> ["m_a",  0,   0,  0,  16, -24,  0,  0, 0,false,"WPN_ROTATION"],
  506.   "END_WEAPON_THROW"  => ["m_a",  0,   0,  0,  16,  24,  0,  0, 1,false,"WPN_ROTATION"],
  507.   "STAND_CAST"        => ["m_a",100,   1,  0,  50,   0,  0,  0, 2, true,""],
  508.  
  509.  #--------------------------------------------------------------------------
  510.  # ● Throwing Weapon Rotation
  511.  #--------------------------------------------------------------------------
  512.   # These are used to rotate weapon sprites that are "thrown" with Movement of
  513.   # Animation single-actions.  These must be used while the sprite is in flight.
  514.   # You may assign a different weapon graphic to be thrown in this
  515.   # configuration script under Throwing Weapon Graphic Settings.
  516.   #
  517.   # Start - Starting angle in degrees (0-360)
  518.   # End - Ending angle in degrees. (0-360)
  519.   # Time - Duration, in frames, of a single rotation.  Rotation will continue
  520.   #        until the animation is complete.
  521.  
  522.   #                     Start  Angle  Time
  523.   "WPN_ROTATION"     => [   0, 360,  8],
  524.  
  525.  #--------------------------------------------------------------------------
  526.  # ● Throwing Skill Rotation
  527.  #--------------------------------------------------------------------------
  528.   # Different from Throwing Weapon Rotation. These single-actions are used to
  529.   # rotate weapon sprites that are "thrown" with Movement of Animation single
  530.   # actions. These are specifically used with skills. You may assign a different weapon graphic to be
  531.   # thrown in this configuration script under Throwing Weapon Graphic Settings.  
  532.   #
  533.   # Start - Starting angle in degrees (0-360)
  534.   # End - Ending angle in degrees. (0-360)
  535.   # Time - Duration, in frames, of a single rotation.  Rotation will continue
  536.   #        until the animation is complete.
  537.   # Type - Always "skill".
  538.  
  539.   # Weapon Action Name     Start  End Time  Type
  540.   "WPN_THROW"           => [   0, 360,  8, "skill"],
  541.  
  542.  #--------------------------------------------------------------------------
  543.  # ● Status Balloon Animation
  544.  #--------------------------------------------------------------------------
  545.   # Uses Balloon.png in the System folder.
  546.   #
  547.   # Type - Always "balloon"
  548.   # Row - Determines row from the Balloon.png (0~9)
  549.   # Loop - Balloon loop behavior.  Balloon disappears when loop is
  550.   #        complete. [0="One-Way" Loop] [1="Round-Trip" Loop]
  551.  
  552.   # Emote Name         Type        Row  Loop
  553.   "STATUS-NORMAL"   => ["balloon",   6,  1],
  554.   "STATUS-CRITICAL" => ["balloon",   5,  1],
  555.   "STATUS-SLEEP"    => ["balloon",   9,  1],
  556.  
  557.  #--------------------------------------------------------------------------
  558.  # ● Sound Effect Actions
  559.  #--------------------------------------------------------------------------
  560.   # Type1 - always "sound"
  561.   # Type2 - ["se","bgm","bgs"]
  562.   # Pitch - Value between 50 and 150.
  563.   # Vol - Volume - Value between 0 and 100.
  564.   # Filename - Name of the sound to be played.
  565.  
  566.   #                   Type1  Type2  Pitch Vol   Filename
  567.   "062-Swing01"   => ["sound", "se",  80, 100, "062-Swing01"],
  568.  #--------------------------------------------------------------------------
  569.  # ● Game Speed Modifier
  570.  #--------------------------------------------------------------------------
  571.   # Type - always "fps"
  572.   # Speed - Speed in Frames Per Second.  40 is normal frame rate.
  573.   # Use with care as this function modifies FPS directly and will conversly
  574.   #    affect any active timers or time systems.
  575.  
  576.   #                Type  Speed
  577.   "FPS_SLOW"    => ["fps",  20],
  578.   "FPS_NORMAL"  => ["fps",  40],
  579.  
  580.  #--------------------------------------------------------------------------
  581.  # ● State Granting Effects
  582.  #--------------------------------------------------------------------------
  583.   # Type - always "sta+"
  584.   # Object - [0=Self] [1=Target] [2=All Enemies] [3=All Allies]
  585.   #          [4=All Allies (excluding user)]
  586.   # State ID - State ID to be granted.
  587.  
  588.   #                      Type  Object  State ID
  589.   "2_MAN_TECH_GRANT" => ["sta+",  0,  18],
  590.   "4_MAN_TECH_GRANT" => ["sta+",  0,  19],
  591.   "CATFORM_GRANT"    => ["sta+",  0,  20],
  592.  
  593.  #--------------------------------------------------------------------------
  594.  # ● State Removal Effects
  595.  #--------------------------------------------------------------------------
  596.   # Type - always "sta-"
  597.   # Object - [0=Self] [1=Target] [2=All Enemies] [3=All Allies]
  598.   #          [4=All Allies (excluding user)]
  599.   # State ID - State ID to be removed.
  600.  
  601.   #                    Type  Object  State ID
  602.   "2_MAN_TECH_REVOKE" => ["sta-",  3,  18],
  603.   "4_MAN_TECH_REVOKE" => ["sta-",  3,  19],
  604.  
  605.  #--------------------------------------------------------------------------
  606.  # ● Battler Transformation Effects
  607.  #--------------------------------------------------------------------------
  608.   # Type - always "change"
  609.   # Reset - true: Battler sprite reverts back to default file after battle.
  610.   #         false: Transformation is permanent after battle.
  611.   # Filename - Battler graphics file that will be transformed to.
  612.  
  613.   #                         Type   Reset  Filename
  614.   "TRANSFORM_CAT"     => ["change", true,"007-Fighter07"],
  615.   "TRANSFORM_CANCEL"  => ["change", true,"040-Mage08"],
  616.  
  617.  #--------------------------------------------------------------------------
  618.  # ● Cut-In Image Effects
  619.  #--------------------------------------------------------------------------
  620.   # Only one image can be displayed at a time.
  621.   #
  622.   # X1 - Image's starting X-coordinate.
  623.   # Y1 - Starting Y-coordinate.
  624.   # X2 - Ending X-coordinate.
  625.   # Y2 - Ending Y-coordinate.
  626.   # Time - Length of time from start to end. Higher value is slower.
  627.   # Z-axis - true: Image appears over BattleStatus Window.
  628.   #          false: Image appears behind BattleStatus Window.
  629.   # Filename - File name from .Graphics\Pictures folder.
  630.  
  631.   #                  Type    X1   Y1   X2   Y2 Time Z-axis  Filename
  632.   "CUT_IN_START" => ["pic",-280,  48,   0,  64, 14, false,"016-Thief01"],
  633.   "CUT_IN_END"   => ["pic",   0,  48, 640,  64, 12, false,"016-Thief01"],
  634.  
  635.  #--------------------------------------------------------------------------
  636.  # ● Game Switch Settings
  637.  #--------------------------------------------------------------------------
  638.   # Type - Always "switch"
  639.   # Switch - Switch number from the game database.
  640.   # ON/OFF - [true:Switch ON] [false:Switch OFF]
  641.   #
  642.   #                         Type    Switch  ON/OFF
  643.   "GAME_SWITCH_1_ON"    => ["switch",   1,  true],
  644.  
  645.  #--------------------------------------------------------------------------
  646.  # ● Game Variable Settings
  647.  #--------------------------------------------------------------------------
  648.   # Type - Always "variable"
  649.   # Var - Variable Number from the game database.
  650.   # Oper - [0=Set] [1=Add] [2=Sub] [3=Mul] [4=Div] [5=Mod]
  651.   # X - value of the operation.
  652.   #
  653.   #                         Type       Var   Oper   X
  654.   "GAME_VAR_1_+1"       => ["variable",   1,   1,    1],
  655.  
  656.  #--------------------------------------------------------------------------
  657.  # ● Script Operation Settings
  658.  #--------------------------------------------------------------------------
  659.   # Type - Always "script"
  660.   #
  661.   # Inserts a simple script code into the action sequence. In the sample,
  662.   # where it says p=1 can be replaced with any script. Character strings
  663.   # and anything beyond functions will not work. (?)
  664.   #                    Type    
  665.   "TEST_SCRIPT"   => ["script", "
  666.  
  667.   p = 1
  668.  
  669.   "],
  670.  
  671.  #--------------------------------------------------------------------------
  672.  # ● Special Modifiers - DO NOT CHANGE THESE NAMES
  673.  #--------------------------------------------------------------------------
  674.   # Clear image - Clears images such as Cut-in graphics.
  675.   # Afterimage ON - Activates Afterimage of battler.
  676.   # Afterimage OFF - Deactivates Afterimage.
  677.   # Invert - Invert animation. Use Invert again in a sequence to cancel
  678.   #          because "COORD_RESET" does not reset Invert.
  679.   # Don't Wait - Any actions after Don't Wait is applied are done instantly.  
  680.   #              Apply "Don't Wait" again in a sequence to trigger off.
  681.   # Can Collapse - Triggers collapse of battler when HP is 0.
  682.   #                Required in every damage sequence.
  683.   # Two Wpn Only - The single-action following Two Wpn Only will only execute
  684.   #                if the actor is wielding two weapons.  If the actor is not,
  685.   #                the single-action will be skipped and will move on to the next.
  686.   # One Wpn Only - The single-action following One Wpn Only will only execute
  687.   #                if the actor is wielding one weapon.  If the actor is not,
  688.   #                the single-action will be skipped and will move on to the next.
  689.   # Process Skill - The Return marker for individual processing of a skill.
  690.   # Process Skill End - The End marker for individual processing of a skill.
  691.   # Start Pos Change - Changes the Start Position to wherever the battler
  692.   #                    currently is on screen.
  693.   # Start Pos Return - Returns battler to original Start Position.
  694.   # Cancel Action - Trigger the "end" of battler's turn which will cause the
  695.   #                 the next battler's turn to execute.
  696.   #                 This includes the function of Can Collapse, and no
  697.   #                 additional damage can be dealt by the battler after this.
  698.   # End - This is used when no action is automatically recognized.
  699.   #
  700.   # Note: If you wish to understand how Process Skill and Process Skill End
  701.   #       functions, please examine the "SKILL_ALL" sequence in this Config
  702.   #       and use the Float All skill provided in the demo to see how it works.
  703.  
  704.   "Clear image"       => ["Clear image"],
  705.   "Afterimage ON"     => ["Afterimage ON"],
  706.   "Afterimage OFF"    => ["Afterimage OFF"],
  707.   "Invert"            => ["Invert"],
  708.   "Don't Wait"        => ["Don't Wait"],
  709.   "Can Collapse"      => ["Can Collapse"],
  710.   "Two Wpn Only"      => ["Two Wpn Only"],
  711.   "One Wpn Only"      => ["One Wpn Only"],
  712.   "Process Skill"     => ["Process Skill"],
  713.   "Process Skill End" => ["Process Skill End"],
  714.   "Start Pos Change"  => ["Start Pos Change"],
  715.   "Start Pos Return"  => ["Start Pos Return"],
  716.   "Cancel Action"     => ["Cancel Action"],
  717.   "End"               => ["End"]
  718.  
  719.  #--------------------------------------------------------------------------
  720.  # ● About Wait
  721.  #--------------------------------------------------------------------------
  722.   # When there is only a numerical value as a single-action name, it will be
  723.   # considered a delay, in frames, before the Action Sequence continues.
  724.   # (i.e. "10", "42")  Because of this, single-action function names for the
  725.   # effects defined above cannot be entirely numerical.  Any Battler Animations
  726.   # that have been prompted will persist when Waiting.
  727.   }
  728. #==============================================================================
  729. # ■ Action Sequence
  730. #------------------------------------------------------------------------------
  731. # Action sequences are made of the single-action functions defined above.
  732. #==============================================================================
  733.   # Action Sequences defined here can be used for Actor/Enemy actions below.
  734.   # Sequences are processed left to right in order.
  735.   ACTION = {
  736. #------------------------------- Basic Actions --------------------------------
  737.  
  738.   "BATTLE_START"       => ["START_POSITION","COORD_RESET"],
  739.                          
  740.   "WAIT"               => ["WAIT"],
  741.                          
  742.   "WAIT-CRITICAL"      => ["NO_MOVE","WAIT(FIXED)","STATUS-CRITICAL","22"],
  743.                          
  744.   "WAIT-NORMAL"        => ["NO_MOVE","WAIT(FIXED)","STATUS-NORMAL","22"],
  745.                          
  746.   "WAIT-SLEEP"         => ["NO_MOVE","WAIT(FIXED)","STATUS-SLEEP","22"],
  747.                          
  748.   "WAIT-FLOAT"         => ["WAIT(FIXED)","6","FLOAT_","4",
  749.                           "FLOAT_2","4","FLOAT_3","4",
  750.                           "FLOAT_4","4"],
  751.                          
  752.   "DEAD"               => ["FALLEN","ATTACK_FAIL"],
  753.                          
  754.   "DAMAGE"             => ["DEAL_DAMAGE","COORD_RESET"],
  755.                          
  756.   "FLEE"               => ["FLEE_SUCCESS"],
  757.                          
  758.   "ENEMY_FLEE"         => ["FLEE_SUCCESS","COORD_RESET"],
  759.                          
  760.   "FLEE_FAIL"          => ["FLEE_FAIL","WAIT(FIXED)","8","COORD_RESET"],
  761.                          
  762.   "COMMAND_INPUT"      => ["BEFORE_MOVE"],
  763.                          
  764.   "COMMAND_SELECT"     => ["COORD_RESET"],
  765.                          
  766.   "GUARD_ATTACK"       => ["WAIT(FIXED)","4","FLOAT_STATE","FLOAT_",
  767.                           "2","FLOAT_2","2","FLOAT_3","2",
  768.                           "FLOAT_4","2"],
  769.                          
  770.   "EVADE_ATTACK"       => ["JUMP_AWAY","JUMP_AWAY","WAIT(FIXED)","16",
  771.                           "COORD_RESET"],
  772.                          
  773.   "ENEMY_EVADE_ATTACK" => ["JUMP_AWAY","WAIT(FIXED)","16","COORD_RESET"],
  774.                          
  775.   "VICTORY"            => ["WAIT(FIXED)","16","RIGHT(FIXED)","VICTORY_JUMP",
  776.                           "WAIT(FIXED)","Don't Wait","CAT_STATE",
  777.                           "START_MAGIC_ANIM","TRANSFORM_CANCEL","WAIT(FIXED)","Don't Wait"],
  778.                          
  779.   "RESET_POSITION"     => ["COORD_RESET"],
  780.                          
  781. #---------------------- "Forced Action" Sequences --------------------------
  782.                          
  783.   "ULRIKA_ATTACK_1"    => ["2","MOVING_TARGET_LEFT","WAIT(FIXED)",
  784.                           "START_MAGIC_ANIM","WPN_SWING_UNDER","WPN_RAISED",
  785.                           "48","RIGHT_DASH_ATTACK","64","FLEE_RESET"],
  786.                          
  787.   "4_MAN_ATTACK_1"     => ["2","4_MAN_ATTACK_2","WAIT(FIXED)","START_MAGIC_ANIM",
  788.                           "WPN_SWING_UNDER","WPN_RAISED","90",
  789.                           "LEFT_DASH_ATTACK","96","FLEE_RESET"],
  790.                          
  791.   "4_MAN_ATTACK_2"     => ["2","4_MAN_ATTACK_3","WAIT(FIXED)","START_MAGIC_ANIM",
  792.                           "WPN_SWING_UNDER","WPN_RAISED","60","RIGHT_DASH_ATTACK2","RIGHT_TURN",
  793.                           "OBJ_ANIM","128","FLEE_RESET"],
  794.                          
  795.   "4_MAN_ATTACK_3"     => ["2","4_MAN_ATTACK_4","WAIT(FIXED)","START_MAGIC_ANIM",
  796.                           "WPN_SWING_UNDER","WPN_RAISED","34","LEFT_DASH_ATTACK2","RIGHT_TURN",
  797.                           "OBJ_ANIM","144","FLEE_RESET"],
  798.                          
  799.   "THROW"              => ["CLOCKWISE_TURN","4","MOVING_TARGET_FAST","JUMP_AWAY","4",
  800.                           "WAIT(FIXED)","JUMP_AWAY","WAIT(FIXED)","32"],
  801.                          
  802. #---------------------- Basic Action Oriented ------------------------------
  803.  
  804.   "NORMAL_ATTACK"      => ["PREV_MOVING_TARGET","WPN_SWING_V","OBJ_ANIM_WEIGHT",
  805.                           "12","WPN_SWING_VL","OBJ_ANIM_L","Two Wpn Only","16",
  806.                           "Can Collapse","FLEE_RESET"],
  807.                          
  808.   "ENEMY_UNARMED_ATK"  => ["PREV_MOVING_TARGET","WPN_SWING_V","OBJ_ANIM_WEIGHT",
  809.                           "Can Collapse","FLEE_RESET"],
  810.                          
  811.   "SKILL_USE"          => ["BEFORE_MOVE","WAIT(FIXED)","START_MAGIC_ANIM",
  812.                           "WPN_SWING_UNDER","WPN_RAISED","WPN_SWING_V",
  813.                           "OBJ_ANIM_WEIGHT","Can Collapse","24","COORD_RESET"],
  814.                          
  815.   "SKILL_ALL"          => ["BEFORE_MOVE","START_MAGIC_ANIM","WPN_SWING_UNDER","WPN_RAISED",
  816.                           "Process Skill","WPN_SWING_V","OBJ_ANIM","24",
  817.                           "Process Skill End","Can Collapse","COORD_RESET"],
  818.                          
  819.   "ITEM_USE"           => ["PREV_MOVING_TARGET","WAIT(FIXED)","24","OBJ_ANIM_WEIGHT",
  820.                           "Can Collapse","COORD_RESET"],
  821.                          
  822. #------------------------------ Skill Sequences -------------------------------
  823.  
  824.   "MULTI_ATTACK"       => ["Afterimage ON","PREV_STEP_ATTACK","WPN_SWING_VL","OBJ_ANIM_WEAPON",
  825.                           "WAIT(FIXED)","16","OBJ_ANIM_WEAPON","WPN_SWING_UNDER",
  826.                           "WPN_SWING_OVER","4","JUMP_FIELD_ATTACK","WPN_SWING_VL",
  827.                           "OBJ_ANIM_WEAPON","WAIT(FIXED)","16","OBJ_ANIM_WEAPON",
  828.                           "Invert","WPN_SWING_V","WPN_SWING_VL","12","Invert",
  829.                           "JUMP_FIELD_ATTACK","WPN_SWING_VL","OBJ_ANIM_WEAPON",
  830.                           "JUMP_AWAY","JUMP_AWAY","WAIT(FIXED)",
  831.                           "OBJ_ANIM_WEAPON","DASH_ATTACK","WPN_SWING_VL","Can Collapse",
  832.                           "Afterimage OFF","16","FLEE_RESET"],
  833.                          
  834.   "MULTI_ATTACK_RAND"  => ["PREV_STEP_ATTACK","WPN_SWING_VL","OBJ_ANIM_WEAPON","WAIT(FIXED)","16",
  835.                           "PREV_STEP_ATTACK","WPN_SWING_VL","OBJ_ANIM_WEAPON","WAIT(FIXED)","16",
  836.                           "PREV_STEP_ATTACK","WPN_SWING_VL","OBJ_ANIM_WEAPON","WAIT(FIXED)","16",
  837.                           "PREV_STEP_ATTACK","WPN_SWING_VL","OBJ_ANIM_WEAPON","Can Collapse","COORD_RESET"],
  838.                          
  839.   "RAPID_MULTI_ATTACK"      => ["PREV_MOVING_TARGET","WPN_SWING_V","LIGHT_BLOWBACK","OBJ_ANIM_WEAPON",
  840.                           "PREV_MOVING_TARGET_FAST","WPN_SWING_V","LIGHT_BLOWBACK","WPN_SWING_VL","OBJ_ANIM_WEAPON",
  841.                           "PREV_MOVING_TARGET_FAST","WPN_SWING_V","LIGHT_BLOWBACK","WPN_SWING_VL","OBJ_ANIM_WEAPON",
  842.                           "PREV_MOVING_TARGET_FAST","WPN_SWING_V","LIGHT_BLOWBACK","WPN_SWING_VL","OBJ_ANIM_WEAPON",
  843.                           "PREV_MOVING_TARGET_FAST","WPN_SWING_V","LIGHT_BLOWBACK","WPN_SWING_VL","OBJ_ANIM_WEAPON",
  844.                           "PREV_MOVING_TARGET_FAST","WPN_SWING_V","LIGHT_BLOWBACK","WPN_SWING_VL","OBJ_ANIM_WEAPON",
  845.                           "Can Collapse","12","COORD_RESET"],
  846.                          
  847.   "2-MAN_ATTACK"      => ["2_MAN_ATK_COND","TWO_UNIFIED_TARGETS","ULRIKA_ATTACK",
  848.                           "MOVING_TARGET_RIGHT","WAIT(FIXED)","START_MAGIC_ANIM","WPN_SWING_UNDER",
  849.                           "WPN_RAISED","48","KILL_HIT_ANIM","LEFT_DASH_ATTACK","64","OBJ_ANIM",
  850.                           "Can Collapse","FLEE_RESET","2_MAN_TECH_REVOKE"],
  851.                          
  852.   "2-MAN_ATTACK_ASSIST"=> ["2_MAN_TECH_GRANT"],  
  853.                          
  854.   "4-MAN_ATTACK"       => ["4_MAN_ATK_COND","FOUR_UNIFIED_TARGETS","4_MAN_ATK_1",
  855.                           "4_MAN_ATK_2","4_MAN_ATK_3","4_MAN_ATTACK_1","WAIT(FIXED)",
  856.                           "START_MAGIC_ANIM","WPN_SWING_UNDER","WPN_RAISED","90",
  857.                           "KILL_HIT_ANIM","RIGHT_DASH_ATTACK","64","OBJ_ANIM_WEIGHT",
  858.                           "Can Collapse","FLEE_RESET","4_MAN_TECH_REVOKE"],
  859.                          
  860.   "4-MAN_ATTACK_ASSIST"=> ["4_MAN_TECH_GRANT"],
  861.                          
  862.   "THROW_WEAPON"       => ["BEFORE_MOVE","WPN_SWING_V","062-Swing01","WAIT(FIXED)",
  863.                           "START_WEAPON_THROW","12","OBJ_ANIM_WEAPON","Can Collapse",
  864.                           "END_WEAPON_THROW","COORD_RESET"],
  865.                          
  866.   "MULTI_SHOCK"        => ["JUMP_TO","JUMP_STOP","Process Skill",
  867.                           "REAL_TARGET","WPN_SWING_V","IMPACT_1","8",
  868.                           "OBJ_ANIM_WEAPON","Process Skill End","Can Collapse",
  869.                           "JUMP_LAND","COORD_RESET"],
  870.                          
  871.   "SHOCK_WAVE"         => ["REAL_TARGET","WPN_SWING_V","IMPACT_1","20",
  872.                           "OBJ_ANIM_WEIGHT","Can Collapse"],
  873.                          
  874.   "SKILL_90_SEQUENCE"  => ["PREV_MOVING_TARGET","OBJ_ANIM","WPN_SWING_V",
  875.                           "16","LINK_SKILL_91","COORD_RESET"],
  876.                          
  877.   "SKILL_91_SEQUENCE"  => ["FLEE_FAIL","START_MAGIC_ANIM","WPN_SWING_UNDER","WPN_RAISED",
  878.                           "8","OBJ_ANIM","LINK_SKILL_92","COORD_RESET"],
  879.                          
  880.   "CUT_IN"             => ["WAIT(FIXED)","START_MAGIC_ANIM","CUT_IN_START",
  881.                           "75","CUT_IN_END","8","PREV_MOVING_TARGET",
  882.                           "WPN_SWING_V","OBJ_ANIM_WEIGHT","Can Collapse",
  883.                           "Clear image","FLEE_RESET"],
  884.                          
  885.   "STOMP"              => ["JUMP_TO_TARGET","HIT_ANIM","DROP_DOWN","JUMP_AWAY",
  886.                           "TRAMPLE","HIT_ANIM","DROP_DOWN","JUMP_AWAY",
  887.                           "TRAMPLE","OBJ_ANIM","DROP_DOWN","JUMP_AWAY",
  888.                           "JUMP_AWAY","Can Collapse","WAIT(FIXED)","8","FLEE_RESET"],
  889.                          
  890.   "ALL_ATTACK_1"         => ["BEFORE_MOVE","WAIT(FIXED)","START_MAGIC_ANIM","WPN_SWING_UNDER",
  891.                           "WPN_RAISED","STAND_CAST","WPN_SWING_V","48",
  892.                           "OBJ_ANIM_WEIGHT","Can Collapse","COORD_RESET"],
  893.                          
  894.   "TRANSFORM_CAT"        => ["JUMP_TO","WAIT(FIXED)","START_MAGIC_ANIM","32",
  895.                           "TRANSFORM_CAT","WAIT(FIXED)","CATFORM_GRANT","32","JUMP_AWAY"],                    
  896.                          
  897.   "THROW_FRIEND"      => ["ALLY_TO_THROW","MOVING_TARGET","LIFT_ALLY","4",
  898.                           "062-Swing01","THROW_TARGET","ALLY_FLING",
  899.                           "THROW_ALLY","WAIT(FIXED)","OBJ_ANIM","COORD_RESET",
  900.                           "WAIT(FIXED)","32"],
  901.                          
  902.                          
  903.                          
  904. #-------------------------------------------------------------------------------
  905.   "End"              => ["End"]}
  906. end
  907. #==============================================================================
  908. # ■ Game_Actor
  909. #------------------------------------------------------------------------------
  910. #  Actor Basic Action Settings
  911. #==============================================================================
  912. class Game_Actor < Game_Battler
  913.   #--------------------------------------------------------------------------
  914.   # ● Actor Unarmed Attack Animation Sequence
  915.   #--------------------------------------------------------------------------
  916.   # when 1 <- Actor ID number
  917.   #   return "NORMAL_ATTACK" <- Corresponding action sequence name.
  918.   def non_weapon
  919.     case @actor_id
  920.     when 1 # Actor ID
  921.       return "NORMAL_ATTACK"
  922.     end
  923.     # Default action sequence for all unassigned Actor IDs.
  924.     return "NORMAL_ATTACK"
  925.   end
  926.   #--------------------------------------------------------------------------
  927.   # ● Actor Wait/Idle Animation
  928.   #--------------------------------------------------------------------------
  929.   def normal
  930.     case @actor_id
  931.     when 1
  932.       return "WAIT"
  933.     end
  934.     # Default action sequence for all unassigned Actor IDs.
  935.     return "WAIT"
  936.   end
  937.   #--------------------------------------------------------------------------
  938.   # ● Actor Critical (1/4th HP) Animation
  939.   #--------------------------------------------------------------------------
  940.   def pinch
  941.     case @actor_id
  942.     when 1
  943.       return "WAIT-CRITICAL"
  944.     end
  945.     # Default action sequence for all unassigned Actor IDs.
  946.     return "WAIT-CRITICAL"
  947.   end
  948.   #--------------------------------------------------------------------------
  949.   # ● Actor Guarding Animation
  950.   #--------------------------------------------------------------------------
  951.   def defence
  952.     case @actor_id
  953.     when 1
  954.       return "GUARD_ATTACK"
  955.     end
  956.     # Default action sequence for all unassigned Actor IDs.
  957.     return "GUARD_ATTACK"
  958.   end
  959.   #--------------------------------------------------------------------------
  960.   # ● Actor Damage Taken Animation
  961.   #--------------------------------------------------------------------------
  962.   def damage_hit
  963.     case @actor_id
  964.     when 1
  965.       return "DAMAGE"
  966.     end
  967.     # Default action sequence for all unassigned Actor IDs.
  968.     return "DAMAGE"
  969.   end  
  970.   #--------------------------------------------------------------------------
  971.   # ● Actor Evasion Animation
  972.   #--------------------------------------------------------------------------
  973.   def evasion
  974.     case @actor_id
  975.     when 1
  976.       return "EVADE_ATTACK"
  977.     end
  978.     # Default action sequence for all unassigned Actor IDs.
  979.     return "EVADE_ATTACK"
  980.   end  
  981.   #--------------------------------------------------------------------------
  982.   # ● Actor Command Input Animation
  983.   #--------------------------------------------------------------------------
  984.   def command_b
  985.     case @actor_id
  986.     when 1
  987.       return "COMMAND_INPUT"
  988.     end
  989.     # Default action sequence for all unassigned Actor IDs.
  990.     return "COMMAND_INPUT"
  991.   end
  992.   #--------------------------------------------------------------------------
  993.   # ● Actor Command Selected Animation
  994.   #--------------------------------------------------------------------------
  995.   def command_a
  996.     case @actor_id
  997.     when 1
  998.       return "COMMAND_SELECT"
  999.     end
  1000.     # Default action sequence for all unassigned Actor IDs.
  1001.     return "COMMAND_SELECT"
  1002.   end
  1003.   #--------------------------------------------------------------------------
  1004.   # ● Actor Flee Success Animation
  1005.   #--------------------------------------------------------------------------
  1006.   def run_success
  1007.     case @actor_id
  1008.     when 1
  1009.       return "FLEE"
  1010.     end
  1011.     # Default action sequence for all unassigned Actor IDs.
  1012.     return "FLEE"
  1013.   end
  1014.   #--------------------------------------------------------------------------
  1015.   # ● Actor Flee Failure Animation
  1016.   #--------------------------------------------------------------------------
  1017.   def run_ng
  1018.     case @actor_id
  1019.     when 1
  1020.       return "FLEE_FAIL"
  1021.     end
  1022.     # Default action sequence for all unassigned Actor IDs.
  1023.     return "FLEE_FAIL"
  1024.   end
  1025.   #--------------------------------------------------------------------------
  1026.   # ● Actor Victory Animation
  1027.   #--------------------------------------------------------------------------
  1028.   def win
  1029.     case @actor_id
  1030.     when 1
  1031.       return "VICTORY"
  1032.     end
  1033.     # Default action sequence for all unassigned Actor IDs.
  1034.     return "VICTORY"
  1035.   end
  1036.   #--------------------------------------------------------------------------
  1037.   # ● Actor Battle Start Animation
  1038.   #--------------------------------------------------------------------------  
  1039.   def first_action
  1040.     case @actor_id
  1041.     when 1
  1042.       return "BATTLE_START"
  1043.     end
  1044.     # Default action sequence for all unassigned Actor IDs.
  1045.     return "BATTLE_START"
  1046.   end
  1047.   #--------------------------------------------------------------------------
  1048.   # ● Actor Return Action when actions are interuptted/canceled
  1049.   #--------------------------------------------------------------------------  
  1050.   def recover_action
  1051.     case @actor_id
  1052.     when 1
  1053.       return "RESET_POSITION"
  1054.     end
  1055.    # Default action sequence for all unassigned Actor IDs.
  1056.     return "RESET_POSITION"
  1057.   end
  1058.   #--------------------------------------------------------------------------
  1059.   # ● Actor Shadow
  1060.   #--------------------------------------------------------------------------
  1061.   # return "shadow01" <- Image file name in .Graphics\Characters
  1062.   # return "" <- No shadow used.
  1063.   def shadow
  1064.     case @actor_id
  1065.     when 1
  1066.       return "shadow00"
  1067.     end
  1068.     # Default shadow for all unassigned Actor IDs.
  1069.     return "shadow00"
  1070.   end
  1071.   #--------------------------------------------------------------------------
  1072.   # ● Actor Shadow Adjustment
  1073.   #--------------------------------------------------------------------------
  1074.   # return [ X-Coordinate, Y-Coordinate]
  1075.   def shadow_plus
  1076.     case @actor_id
  1077.     when 1
  1078.       return [ 0, 4]
  1079.     end
  1080.     # Default shadow positioning for all unassigned Actor IDs.
  1081.     return [ 0, 4]
  1082.   end
  1083. end
  1084. #==============================================================================
  1085. # ■ Game_Enemy
  1086. #------------------------------------------------------------------------------
  1087. #  Enemy Basic Action Settings
  1088. #==============================================================================
  1089. class Game_Enemy < Game_Battler
  1090.   #--------------------------------------------------------------------------
  1091.   # ● Enemy Unarmed Attack Animation Sequence
  1092.   #--------------------------------------------------------------------------
  1093.   # when 1 <- EnemyID#
  1094.   #   return "ENEMY_UNARMED_ATK" <- Corresponding action sequence name.
  1095.   def base_action
  1096.     case @enemy_id
  1097.     when 1
  1098.       return "ENEMY_UNARMED_ATK"
  1099.     end
  1100.     # Default action sequence for all unassigned Enemy IDs.
  1101.     return "ENEMY_UNARMED_ATK"
  1102.   end
  1103.   #--------------------------------------------------------------------------
  1104.   # ● Enemy Wait/Idle Animation
  1105.   #--------------------------------------------------------------------------
  1106.   def normal
  1107.     case @enemy_id
  1108.     when 1
  1109.       return "WAIT"
  1110.     end
  1111.     # Default action sequence for all unassigned Enemy IDs.
  1112.     return "WAIT"
  1113.   end
  1114.   #--------------------------------------------------------------------------
  1115.   # ● Enemy Critical (1/4th HP) Animation
  1116.   #--------------------------------------------------------------------------
  1117.   def pinch
  1118.     case @enemy_id
  1119.     when 1
  1120.       return "WAIT"
  1121.     end
  1122.     # Default action sequence for all unassigned Enemy IDs.
  1123.     return "WAIT"
  1124.   end
  1125.   #--------------------------------------------------------------------------
  1126.   # ● Enemy Guarding Animation
  1127.   #--------------------------------------------------------------------------  
  1128.   def defence
  1129.     case @enemy_id
  1130.     when 1
  1131.       return "GUARD_ATTACK"
  1132.     end
  1133.     # Default action sequence for all unassigned Enemy IDs.
  1134.     return "GUARD_ATTACK"
  1135.   end
  1136.   #--------------------------------------------------------------------------
  1137.   # ● Enemy Damage Taken Animation
  1138.   #--------------------------------------------------------------------------
  1139.   def damage_hit
  1140.     case @enemy_id
  1141.     when 1
  1142.       return "DAMAGE"
  1143.     end
  1144.     # Default action sequence for all unassigned Enemy IDs.
  1145.     return "DAMAGE"
  1146.   end
  1147.   #--------------------------------------------------------------------------
  1148.   # ● Enemy Evasion Animation
  1149.   #--------------------------------------------------------------------------
  1150.   def evasion
  1151.     case @enemy_id
  1152.     when 1
  1153.       return "ENEMY_EVADE_ATTACK"
  1154.     end
  1155.     # Default action sequence for all unassigned Enemy IDs.
  1156.     return "ENEMY_EVADE_ATTACK"
  1157.   end
  1158.   #--------------------------------------------------------------------------
  1159.   # ● Enemy Flee Animation
  1160.   #--------------------------------------------------------------------------
  1161.   def run_success
  1162.     case @enemy_id
  1163.     when 1
  1164.       return "ENEMY_FLEE"
  1165.     end
  1166.     # Default action sequence for all unassigned Enemy IDs.
  1167.     return "ENEMY_FLEE"
  1168.   end
  1169.   #--------------------------------------------------------------------------
  1170.   # ● Enemy Battle Start Animation
  1171.   #--------------------------------------------------------------------------  
  1172.   def first_action
  1173.     case @enemy_id
  1174.     when 1
  1175.       return "BATTLE_START"
  1176.     end
  1177.     # Default action sequence for all unassigned Enemy IDs.
  1178.     return "BATTLE_START"
  1179.   end
  1180.   #--------------------------------------------------------------------------
  1181.   # ● Enemy Return Action when action is interuptted/discontinued
  1182.   #--------------------------------------------------------------------------  
  1183.   def recover_action
  1184.     case @enemy_id
  1185.     when 1
  1186.       return "RESET_POSITION"
  1187.     end
  1188.     # Default action sequence for all unassigned Enemy IDs.
  1189.     return "RESET_POSITION"
  1190.   end
  1191.   #--------------------------------------------------------------------------
  1192.   # ● Enemy Shadow
  1193.   #--------------------------------------------------------------------------
  1194.   # return "shadow01" <- Image file name in .Graphics\Characters
  1195.   # return "" <- No shadow used.
  1196.   def shadow
  1197.     case @enemy_id
  1198.     when 1
  1199.       return "shadow01"
  1200.     when 30
  1201.       return ""
  1202.     end
  1203.     # Default shadow for all unassigned Enemy IDs.
  1204.     return "shadow01"
  1205.   end
  1206.   #--------------------------------------------------------------------------
  1207.   # ● Enemy Shadow Adjustment
  1208.   #--------------------------------------------------------------------------
  1209.   # return [ X-Coordinate, Y-Coordinate]
  1210.   def shadow_plus
  1211.     case @enemy_id
  1212.     when 1
  1213.       return [ 0, -8]
  1214.     end
  1215.     # Default shadow positioning for all unassigned Enemy IDs.
  1216.     return [ 0, 0]
  1217.   end
  1218.   #--------------------------------------------------------------------------
  1219.   # ● Enemy Equipped Weapon
  1220.   #--------------------------------------------------------------------------
  1221.   # return 0  (Unarmed/No weapon equipped.)
  1222.   # return 1  (Weapon ID number. (1~999))
  1223.   def weapon
  1224.     case @enemy_id
  1225.     when 1 # Enemy ID
  1226.       return 0 # Weapon ID
  1227.     end
  1228.     # Default weapon for all unassigned Enemy IDs.
  1229.     return 0
  1230.   end
  1231.   #--------------------------------------------------------------------------
  1232.   # ● Enemy Screen Positioning Adjustment
  1233.   #--------------------------------------------------------------------------
  1234.   # return [ 0, 0]  <- [X-coordinate、Y-coordinate]
  1235.   def position_plus
  1236.     case @enemy_id
  1237.     when 1
  1238.       return [0, 0]
  1239.     end
  1240.     # Default positioning for all unassigned Enemy IDs.
  1241.     return [ 0, 0]
  1242.   end
  1243.   #--------------------------------------------------------------------------
  1244.   # ● Enemy Collapse Animation Settings
  1245.   #--------------------------------------------------------------------------
  1246.   # return 1  (Enemy sprite stays on screen after death.)
  1247.   # return 2  (Enemy disappears from the battle like normal.)
  1248.   # return 3  (Special collapse animation.) <- Good for bosses.
  1249.   def collapse_type
  1250.     case @enemy_id
  1251.     when 1
  1252.       return 2
  1253.     when 30
  1254.       return 3
  1255.     end
  1256.     # Default collapse for all unassigned Enemy IDs.
  1257.     return 2
  1258.   end
  1259.   #--------------------------------------------------------------------------
  1260.   # ● Enemy Multiple Action Settings
  1261.   #--------------------------------------------------------------------------
  1262.   # Maximum Actions, Probability, Speed Adjustment
  1263.   # return [ 2, 100, 100]
  1264.   #
  1265.   # Maximum Actions - Maximum number of actions enemy may execute in a turn.
  1266.   # Probability - % value. Chance for a successive action.
  1267.   # Speed Adjustment - % value that decreases enemy's speed after
  1268.   #                       each successive action.
  1269.   def action_time
  1270.     case @enemy_id
  1271.     when 1
  1272.       return [ 1, 100, 100]
  1273.     end
  1274.     # Default action for all unassigned Enemy IDs.
  1275.     return [ 1, 100, 100]
  1276.   end
  1277.   #--------------------------------------------------------------------------
  1278.   # ● Enemy Animated Battler Settings
  1279.   #--------------------------------------------------------------------------
  1280.   # return true - Enemy battler uses same animation frames as actors.
  1281.   # return false - Default enemy battler.
  1282.   # [Settings]
  1283.   # 1.Enemy animated battler file must be in .Graphics\Characters folder.
  1284.   # 2.Enemy battler file names must match between .Graphics\Characters and
  1285.   #   .Graphics/Battlers folders.
  1286.   def anime_on
  1287.     case @enemy_id
  1288.     when 1
  1289.       return false
  1290.     end
  1291.     # Default setting for all unassigned Enemy IDs.
  1292.     return false
  1293.   end
  1294.   #--------------------------------------------------------------------------
  1295.   # ● Enemy Invert Settings
  1296.   #--------------------------------------------------------------------------
  1297.   # return false  <- Normal
  1298.   # return true   <- Inverts enemy image
  1299.   def action_mirror
  1300.     case @enemy_id
  1301.     when 1
  1302.       return false
  1303.     end
  1304.     # Default setting for all unassigned Enemy IDs.
  1305.     return false
  1306.   end
  1307. end
  1308.  
  1309. #==============================================================================
  1310. # ■ module RPG
  1311. #------------------------------------------------------------------------------
  1312. #  State Action Settings
  1313. #==============================================================================
  1314. class RPG::State
  1315.  #--------------------------------------------------------------------------
  1316.  # ● State Affliction Wait Animation Settings
  1317.  #--------------------------------------------------------------------------
  1318.  # when 1  <- State ID number
  1319.  #   return "DEAD"  <- Action sequence when afflicted by specified state.
  1320.   def base_action
  1321.     case @id
  1322.     when 1  # Incapacitated(HP0). Has the highest priority.
  1323.       return "DEAD"
  1324.     when 2,3,4,5,7  
  1325.       return "WAIT-NORMAL"
  1326.     when 6  
  1327.       return "WAIT-SLEEP"
  1328.     when 17  
  1329.       return "WAIT-FLOAT"
  1330.     end
  1331.     # Default action sequence for all unassigned State IDs.
  1332.     return "WAIT"
  1333.   end
  1334.  #--------------------------------------------------------------------------
  1335.  # ● State Enhancement Extension Settings
  1336.  #--------------------------------------------------------------------------
  1337.  # Note about REFLECT and NULL states:
  1338.  #      An item/skill is considered physical if "Physical Attack" is
  1339.  #      checked under "Options" in your Database.  Otherwise, it is magical.
  1340.  #
  1341.  # "AUTOLIFE/50"      - Automatically revives when Incapacitated.
  1342.  #                      Value after "/" is % of MAXHP restored when revived.
  1343.  # "MAGREFLECT/39"    - Reflects magical skills to the original caster.
  1344.  #                      Value after "/" is Animation ID when triggered.
  1345.  # "MAGNULL/39"       - Nullify magical skills and effects.
  1346.  #                      Value after "/" is Animation ID when triggered.
  1347.  # "PHYREFLECT/39"    - Reflects physical skills to the original caster.
  1348.  #                      Value after "/" is Animation ID when triggered.
  1349.  # "PHYNULL/39"       - Nullify physical skills and effects.
  1350.  #                      Value after "/" is Animation ID when triggered.
  1351.  # "COSTABSORB"       - Absorbs the MP (or HP) cost of an incoming skill when
  1352.  #                      affected.  This will not appear as POP Damage.  This
  1353.  #                      function is similar to Celes' "Runic" from FF6.
  1354.  # "ZEROTURNLIFT"     - State is lifted at the end of turn regardless.
  1355.  # "EXCEPTENEMY"      - Enemies will not use animation sequence assigned
  1356.  #                      under State Affliction Wait Animation Settings when
  1357.  #                      afflicted. (Actors still will.)
  1358.  # "NOPOP"            - State name will not appear as POP Damage.
  1359.  # "HIDEICON"         - State icon will not appear in the BattleStatus Window.
  1360.  # "NOSTATEANIME"     - State's caster and enemies will not use animation
  1361.  #                      sequence assigned under State Affliction Wait Animation
  1362.  #                      Settings when afflicted.
  1363.  # "SLIPDAMAGE"       - Apply slip damage.  Assign values under Slip Damage Settings.
  1364.  # "REGENERATION"     - Apply regeneration.  Assign values under Slip Damage Settings.
  1365.  # "NONE"             - No extension. Used as a default.
  1366.   def extension
  1367.     case @id
  1368.     when 1  # Incapacitated State.  Has highest priority.
  1369.       return ["NOPOP","EXCEPTENEMY"]
  1370.     when 2  # Poison
  1371.       return ["SLIPDAMAGE"]
  1372.     when 18 # 2-Man Tech
  1373.       return ["ZEROTURNLIFT","HIDEICON"]
  1374.     when 19 # 4-Man Tech
  1375.       return ["ZEROTURNLIFT","HIDEICON"]
  1376.     when 20 # Cat Transformation
  1377.       return ["HIDEICON","NOSTATEANIME"]
  1378.     end
  1379.     # Default extension for unassigned State IDs.
  1380.     return ["NONE"]
  1381.   end
  1382.  #--------------------------------------------------------------------------
  1383.  # ● Slip Damage Settings
  1384.  #--------------------------------------------------------------------------
  1385.  # Also includes regeneration options.
  1386.  #
  1387.  # when 1 <- State ID. Slip Damage only applies if "SLIPDAMAGE" is assigned above.
  1388.  #      Multiple settings may be applied. Ex)[["hp",0,5,true],["mp",0,5,true]]
  1389.  #                          
  1390.  #        Type, Constant, %, POP?, Allow Death
  1391.  # return [["hp",    0,  10, true,  true]]
  1392.  #
  1393.  # Type       – "hp" or "mp".
  1394.  # Constant   – Set a constant value to apply each turn.
  1395.  #              Positive values are damage.  Negative values are recovery.
  1396.  # %          - Set a percentage value to apply each turn based on MAX HP/MP.
  1397.  #              Positive values are damage. Negative values are recovery.
  1398.  # POP?       - Determines whether or not you want slip damage value to
  1399.  #              appear as POP Damage.
  1400.  # Allow Death - true: Slip damage can kill.
  1401.  #               false: Slip damage will not kill. (Battler will be left at 1 HP)
  1402.   def slip_extension
  1403.     case @id
  1404.     when 2  # Poison
  1405.       return [["hp", 0, 10, true, true]]
  1406.     end
  1407.     return []
  1408.   end
  1409. end
  1410. #==============================================================================
  1411. # ■ module RPG
  1412. #------------------------------------------------------------------------------
  1413. #  Weapon Action Settings
  1414. #==============================================================================
  1415. class RPG::Weapon
  1416.  #--------------------------------------------------------------------------
  1417.  # ● Weapon Animation Sequence Settings
  1418.  #--------------------------------------------------------------------------
  1419.  # Assigns a specific animation sequence when using a weapon.
  1420.  #
  1421.  # when 1 <- Weapon ID number
  1422.  # return "NORMAL_ATTACK" <- Action sequence for assigned Weapon ID.
  1423.   def base_action
  1424.     case @id
  1425.     when 1
  1426.       return "NORMAL_ATTACK"
  1427.     end
  1428.     # Default action sequence for unassigned Weapon IDs.
  1429.     return "NORMAL_ATTACK"
  1430.   end
  1431.  #--------------------------------------------------------------------------
  1432.  # ● Weapon Graphic Assignment Settings
  1433.  #--------------------------------------------------------------------------
  1434.  # Allows use of a seperate weapon graphic besides the one assigned
  1435.  # from Iconset.png
  1436.  #
  1437.  # return "001-Weapon01" <- Weapon image file name.  If "", none is used.
  1438.  #                          File must be in the .Graphics\Characters folder
  1439.  #                          of your project.
  1440.   def graphic
  1441.     case @id
  1442.     when 1
  1443.       return ""
  1444.     end
  1445.     # Default weapon graphic for unassigned Weapon IDs.
  1446.     return ""
  1447.   end
  1448.  #--------------------------------------------------------------------------
  1449.  # ● Throwing Weapon Graphic Settings
  1450.  #--------------------------------------------------------------------------
  1451.  # Allows use of a seperate throwing weapon graphic besides the one assigned
  1452.  # from Iconset.png.  This is useful for arrows when you don't want the bow
  1453.  # to be thrown.
  1454.  #
  1455.  # return "001-Weapon01" <- Weapon image file name.  If "", none is used.
  1456.  #                          File must be in the .Graphics\Characters folder
  1457.  #                          of your project.
  1458.   def flying_graphic
  1459.     case @id
  1460.     when 1
  1461.       return ""
  1462.     end
  1463.     # Default throwing weapon graphic for unassigned Weapon IDs.
  1464.     return ""
  1465.   end
  1466. end  
  1467. #==============================================================================
  1468. # ■ module RPG
  1469. #------------------------------------------------------------------------------
  1470. #  Skill Action Settings
  1471. #==============================================================================
  1472. class RPG::Skill
  1473.  #--------------------------------------------------------------------------
  1474.  # ● Skill ID Sequence Assignments
  1475.  #--------------------------------------------------------------------------
  1476.  # Assign a skill ID from the Database to execute a defined action sequence.
  1477.  # Only action sequence names can be assigned.  Single-action names cannot
  1478.  # be directly assigned here.
  1479.   def base_action
  1480.     case @id
  1481.     when 84
  1482.       return "THROW_WEAPON"
  1483.     when 85
  1484.       return "MULTI_ATTACK"
  1485.     when 86
  1486.       return "RAPID_MULTI_ATTACK"  
  1487.     when 87
  1488.       return "MULTI_SHOCK"  
  1489.     when 88
  1490.       return "SHOCK_WAVE"
  1491.     when 89
  1492.       return "MULTI_ATTACK_RAND"  
  1493.     when 90
  1494.       return "SKILL_90_SEQUENCE"  
  1495.     when 91
  1496.       return "SKILL_91_SEQUENCE"  
  1497.     when 92
  1498.       return "NORMAL_ATTACK"  
  1499.     when 93
  1500.       return "CUT_IN"  
  1501.     when 94
  1502.       return "STOMP"
  1503.     when 95
  1504.       return "ALL_ATTACK_1"
  1505.     when 96
  1506.       return "SKILL_ALL"
  1507.     when 97
  1508.       return "TRANSFORM_CAT"
  1509.     when 98
  1510.       return "2-MAN_ATTACK"
  1511.     when 99
  1512.       return "2-MAN_ATTACK_ASSIST"
  1513.     when 100
  1514.       return "4-MAN_ATTACK"
  1515.     when 101
  1516.       return "4-MAN_ATTACK_ASSIST"
  1517.     when 102
  1518.       return "4-MAN_ATTACK_ASSIST"
  1519.     when 103
  1520.       return "4-MAN_ATTACK_ASSIST"
  1521.     when 104
  1522.       return "THROW_FRIEND"
  1523.     end
  1524.     # Default action sequence for unassigned Skill IDs.
  1525.     return "NORMAL_ATTACK" if self.atk_f > 0
  1526.     return "SKILL_USE"
  1527.   end
  1528.  #--------------------------------------------------------------------------
  1529.  # ● Skill Enhancement Extension Settings
  1530.  #--------------------------------------------------------------------------
  1531.  # Multiple extensions may be applied to a skill ID.
  1532.  # If "CONSUMEHP" is applied along with any other extensions that deal with
  1533.  # MP in a forumla, it will be HP instead.
  1534.  # This script WILL have compatibility issues with KGC_MPCostAlter.
  1535.  #
  1536.  # "NOEVADE"          -Cannot be evaded regardless.
  1537.  # "CONSUMEHP"        -Consumes HP instead of MP.
  1538.  # "%COSTMAX"         -Consumes % of MAXMP.  Example: Actor MAXMP500,
  1539.  #                     10 set in Database, MP50 cost.
  1540.  # "%COSTNOW"         -Consumes % of current MP.
  1541.  # "IGNOREREFLECT"    -Ignores damage reflection states.
  1542.  # "%DAMAGEMAX/30"    -Changes damage formula of skill to:
  1543.  #                     damage = ENEMY MAX HP * [Integer] / 100
  1544.  #                     [Integer] is the number you apply after "/".
  1545.  # "%DAMAGENOW/30"    -Changes damage formula of skill to:
  1546.  #                     damage = ENEMY CURRENT HP * [Integer] / 100
  1547.  #                     [Integer] is the number you apply after "/".
  1548.  # "COSTPOWER"        -Changes damage formula of skill to:
  1549.  #                     damage = base damage * cost / MAX MP
  1550.  #                     The more the skill costs, the more damage it will do.
  1551.  # "HPNOWPOWER"       -Changes damage formula of skill to:
  1552.  #                     damage = base damage * CURRENT HP / MAX HP
  1553.  #                     The less current HP you have, the less damage.
  1554.  # "MPNOWPOWER"       -Changes damage formula of skill to:
  1555.  #                     damage = base damage * CURRENT MP / MAX MP
  1556.  #                     The less current MP you have, the less damage.
  1557.  # "NOHALFMPCOST"     -"Half MP Cost" from armor options will not apply.
  1558.  # "HELPHIDE"         -Help window when casting will not appear.
  1559.  # "TARGETALL"        -Will affect all enemies and allies simultaneously.
  1560.  # "RANDOMTARGET"     -Target is chosen at random.
  1561.  # "OTHERS"           -Skill will not affect caster.
  1562.  # "NOOVERKILL"       -Damage will not be applied after the target reaches zero HP.
  1563.  # "NOFLASH"          -Battler will not flash when taking action.
  1564.  # "FAST"             -Battler will be the first to take action in the turn
  1565.  # "SLOW"             -Battler will be the last to take action in the turn
  1566.  # "SPDAMAGE"         -Damage is dealt to the target's SP instead of HP.
  1567.  # "%DMGABSORB/50"    -Part of the damage is converted into HP/SP to the user
  1568.  #                      of the skill. Recovered % is the number after "/".
  1569.  # "NONE"             -No extension. Used as a default.
  1570.   def extension
  1571.     case @id
  1572.     when 81
  1573.       return ["SPDAMAGE"]
  1574.     when 86
  1575.       return ["NOOVERKILL"]
  1576.     when 89
  1577.       return ["RANDOMTARGET"]
  1578.     when 94
  1579.       return ["NOOVERKILL"]
  1580.     when 96
  1581.       return ["TARGETALL"]
  1582.     when 98
  1583.       return ["NOOVERKILL"]
  1584.     when 99
  1585.       return ["HELPHIDE","NOFLASH","FAST"]
  1586.     when 100
  1587.       return ["NOOVERKILL"]
  1588.     when 101
  1589.       return ["HELPHIDE","NOFLASH","FAST"]
  1590.     when 102
  1591.       return ["HELPHIDE","NOFLASH","FAST"]
  1592.     when 103
  1593.       return ["HELPHIDE","NOFLASH","FAST"]
  1594.     end
  1595.     # Default extensions for unassigned Skill IDs.
  1596.     return ["NONE"]
  1597.   end
  1598.  #--------------------------------------------------------------------------
  1599.  # ● Skill Throwing Weapon Graphic Settings
  1600.  #--------------------------------------------------------------------------
  1601.  # - Allows use of a seperate throwing weapon graphic besides the one assigned
  1602.  #   from Iconset.png.  This section is specifically for skills.
  1603.  #
  1604.  # return "001-Weapon01" <- Weapon image file name.  If "", none is used.
  1605.  #                          File must be in the .Graphics\Characters folder
  1606.  #                          of your project.
  1607.   def flying_graphic
  1608.     case @id
  1609.     when 1
  1610.       return ""
  1611.     end
  1612.     # Default throwing skill graphic for unassigned Weapon IDs.
  1613.     return ""
  1614.   end
  1615. end  
  1616. #==============================================================================
  1617. # ■ module RPG
  1618. #------------------------------------------------------------------------------
  1619. #  Item Action Settings
  1620. #==============================================================================
  1621. class RPG::Item
  1622.  #--------------------------------------------------------------------------
  1623.  # ● Item ID Sequence Assignment
  1624.  #--------------------------------------------------------------------------  
  1625.   def base_action
  1626.     case @id
  1627.     when 1
  1628.       return "ITEM_USE"
  1629.     end
  1630.     # Default action sequence for unassigned Item IDs.
  1631.     return "ITEM_USE"
  1632.   end
  1633.  #--------------------------------------------------------------------------
  1634.  # ● Item Enhancement Extension Settings
  1635.  #--------------------------------------------------------------------------
  1636.  # "NOEVADE"          -Cannot be evaded regardless.
  1637.  # "IGNOREREFLECT"    -Ignores damage reflection states.
  1638.  # "HELPHIDE"         -Help window when casting will not appear.
  1639.  # "TARGETALL"        -Will affect all enemies and allies simultaneously.
  1640.  # "RANDOMTARGET"     -Target is chosen at random.
  1641.  # "OTHERS"           -Item will not affect caster.
  1642.  # "NOOVERKILL"       -Damage will not be applied after the target reaches zero HP.
  1643.  # "NOFLASH"          -Battler will not flash when taking action.
  1644.  # "FAST"             -Battler will be the first to take action in the turn
  1645.  # "SLOW"             -Battler will be the last to take action in the turn
  1646.  # "NONE"             -No extension. Used as a default.
  1647.   def extension
  1648.     case @id
  1649.     when 1
  1650.       return ["NONE"]
  1651.     end
  1652.     # Default extensions for unassigned Item IDs.
  1653.     return ["NONE"]
  1654.   end
  1655. end 
Expand to see the code.

  1. #==============================================================================
  2. # Sideview Battle System XP Configurations Version 2.2xp
  3. #==============================================================================
  4. # These configurations are exclusive for the RPG Maker XP
  5. # These are new configuration constants used so the script can work on RMXP
  6. # These are essential for the script to work well and smoothly
  7. # These were separated from the previous configuration to allow you
  8. # to use the whole configurations already settled for RMVX.
  9. # To avoid conflicts with the script's basic configuration,
  10. # it is recomended to place this script below the other configuration
  11. # Some requested functions present in other script were added here
  12. # as basic functions of the script, to avoid incompatibility.
  13. #==============================================================================
  14.  
  15. module N01
  16.  
  17.   # Character Animation Repeat
  18.   NEW_PATTERN_REPEAT = true
  19.   # true = XP style, the frames will follow this sequence: 1, 2, 3, 4, 1, 2, 3...
  20.   # false = VX style, the frames will follow this sequence: 1, 2, 3, 2, 1, 2, 3...  
  21.  
  22.   # Choose the Damage Alogarithm
  23.   DAMAGE_ALGORITHM_TYPE = 1
  24.   # 0 = Default XP Style, no changes
  25.   # 1 = Default XP Modified, def/mdef reduces damage in % ( 10 def = 1% )
  26.   # 2 = Default VX, Vitality replaces Dexterity, the status Attack, P.Def and
  27.   #     M.Def are totally ignored. (Edit the menus script to remove these status)
  28.   # 3 = Customized, an mix of XP e VX alogarithm, Vitality replaces Dexterity
  29.  
  30.   # Names of the status Evasion and Vitality (Vitality is only used if
  31.   # DAMAGE_ALGORITHM_TYPE > 1
  32.   STAT_EVA = "Evasion"
  33.   STAT_VIT = "Vitality"
  34.    
  35.   # Define here the character's attack power when unarmed.
  36.   UNARMED_ATTACK = 10
  37.  
  38.   # Define here the character's attack animation when unarmed.
  39.   UNARMED_ANIM = 4
  40.  
  41.   # No animated battler, remaining the same way as the enemies.
  42.   # Only let it as true if you want a battle system with completely not animated
  43.   # allies.
  44.   NO_ANIM_BATTLER = false
  45.  
  46.   # Show status effects balloons on the battles?
  47.   BALLOON_ANIM  = true
  48.  
  49.   # Show effects' animations on the battles?
  50.   STATE_ANIM = true
  51.  
  52.   # EXP division by the number of members on party
  53.   EXP_SHARE = true
  54.  
  55.   # Cursor position on the target
  56.   # 0 = customizable
  57.   # 1 = below the target
  58.   # 2 = above the target (adjusts self to the target's height)
  59.   CURSOR_TYPE = 1
  60.  
  61.   # Readjust the cursor's position.
  62.   CURSOR_POSITION = [ 0,  0]
  63.  
  64.   # Command Window Position
  65.   COMMAND_WINDOW_POSITION = [440, 128]
  66.  
  67.   # Show Battler Name window?
  68.   BATTLER_NAME_WINDOW = false
  69.  
  70.   # Effects' icons configuration
  71.   # Icons must have the same name of effect plus "_st"
  72.   # Ex.: Status Venom, must have an icon named "Venom_st"
  73.   Icon_max = 5   # Maximum amount of showed icons
  74.   Icon_X   = 24  # X size of the icon (width)
  75.   Icon_Y   = 24  # Y size of the icon (height)
  76.   X_Adjust = 0   # Readjustment of the X position
  77.   Y_Adjust = 0   # Readjustment of the Y position
  78.  
  79.   # State Cycle times
  80.   STATE_CYCLE_TIME = 4
  81.  
  82.   # Damage Exhibition configuration
  83.   #                Red Green Blue
  84.   HP_DMG_COLOR  = [255, 255, 255] # HP damage color
  85.   HP_REC_COLOR  = [176, 255, 144] # HP cure color
  86.   SP_DMG_COLOR  = [144,  96, 255] # SP damage color
  87.   SP_REC_COLOR  = [255, 144, 255] # SP cure color
  88.   CRT_DMG_COLOR = [255, 144,  96] # Critical damage color
  89.   CRT_TXT_COLOR = [255,  96,   0] # Critical damage text color
  90.   DAMAGE_FONT   = "Arial Black"   # Damage exhibition font
  91.   DMG_F_SIZE    = 32     # Size of the damage exhibition font
  92.   DMG_DURATION  = 40     # Duration, in frames, that the damage stays on screen      
  93.   CRITIC_TEXT   = true   # Show text when critical damage is delt?
  94.   CRITIC_FLASH  = false  # Flash effect when critical damage is dealt?
  95.   MULTI_POP     = false  # Style in which the damage is shown true = normal / false = FF styled
  96.   POP_MOVE      = false  # Moviment for damage exhibition?
  97.   DMG_SPACE     = 12     # Space between the damage digits
  98.   DMG_X_MOVE    = 2      # X movement of the damage (only if POP_MOVE = true)
  99.   DMG_Y_MOVE    = 6      # Y movement of the damage
  100.   DMG_GRAVITY   = 0.98   # Gravity effect, affects on the heeight the damage "jumps"
  101.  
  102.   # Configurations of the Battle Window
  103.   STATUS_OPACITY  = 160  # Opacity of the Battle Window
  104.   MENU_OPACITY    = 160  # Opacity of the Item/Skills window
  105.   HELP_OPACITY    = 160  # Opacity of the Help Window
  106.   COMMAND_OPACITY = 160  # Opacity of the Commands Window
  107.   HIDE_WINDOW     = true # Hide status window when selecting items/skills?
  108.  
  109.   # Name of the sound file used when a dodge occurs.
  110.   # This file must be on the Audio/SE folder of your project
  111.   EVASION_EFFECT = "015-Jump01"
  112.  
  113.   # Message shown when a flee attempt succeeds
  114.   ESCAPE_SUCCESS = "Ran away!!"
  115.  
  116.   # Message shown when a flee attempt fails
  117.   ESCAPE_FAIL = "They're too fast!"
  118.  
  119.   # Allow Ambushes to occur?
  120.   BACK_ATTACK = true
  121.  
  122.   # Define here the Ambush occurance rate
  123.   BACK_ATTACK_RATE = 10
  124.  
  125.   # Define the message shown when an Ambush occurs
  126.   BACK_ATTACK_ALERT = "They got us!"
  127.  
  128.   # Invert the character's position when an ambush occurs?
  129.   BACK_ATTACK_MIRROR = false
  130.  
  131.   # Invert the battle background when an Ambush occurs?
  132.   BACK_ATTACK_BATTLE_BACK_MIRROR = false
  133.  
  134.   # Here you can configurate the system (itens, skills, switchs) to protect
  135.   # the character from Ambushes. The item must be equiped, the skill must be
  136.   # learned, and switches must be ON so the Ambush protection works.
  137.   # Only one of the 3 need to match the requirements to work.
  138.   # In other words, the item can be equiped, but the skill not learned and the
  139.   # switch OFF for the item's effect to take place.
  140.   # For one item/skill/switch only: = [1]
  141.   # For multiple: = [1,2]
  142.  
  143.   # Weapons' ID's
  144.   NON_BACK_ATTACK_WEAPONS = []
  145.   # Shields' ID's
  146.   NON_BACK_ATTACK_ARMOR1 = []
  147.   # Helmets' ID's
  148.   NON_BACK_ATTACK_ARMOR2 = []
  149.   # Armors' ID's
  150.   NON_BACK_ATTACK_ARMOR3 = []
  151.   # Accesories' ID's
  152.   NON_BACK_ATTACK_ARMOR4 = []
  153.   # Skills' ID's
  154.   NON_BACK_ATTACK_SKILLS = []
  155.   # Number of the Switch - when ON, the chance for Ambushes is zero
  156.   NO_BACK_ATTACK_SWITCH = []
  157.   # Number of the Switch - when ON, the chance for Ambushes is 100%
  158.   BACK_ATTACK_SWITCH = []
  159.  
  160.   # Allow Preemptive Attacks to occur?
  161.   PREEMPTIVE =  true
  162.  
  163.   # Define here the occurance rate of Preemptive Attacks
  164.   PREEMPTIVE_RATE = 10
  165.  
  166.   # Define here the message shown when a Preemptive Attack occurs
  167.   PREEMPTIVE_ALERT = "Surprised the enemy!"
  168.  
  169.   # Here you can configurate the system (itens, skills, switchs) to increase
  170.   # the occurance of Preemptive Attacks. The item must be equiped, the skill must
  171.   # be learned, and switches must be ON so the Ambush protection works.
  172.   # Only one of the 3 need to match the requirements to work.
  173.   # In other words, the item can be equiped, but the skill not learned and the
  174.   # switch OFF for the item's effect to take place.
  175.   # For one item/skill/switch only: = [1]
  176.   # For multiple: = [1,2]
  177.  
  178.   # Weapons' ID's
  179.   PREEMPTIVE_WEAPONS = []
  180.   # Shields' ID's
  181.   PREEMPTIVE_ARMOR1 = []
  182.   # Helmets' ID's
  183.   PREEMPTIVE_ARMOR2 = []
  184.   # Armors' ID's
  185.   PREEMPTIVE_ARMOR3 = []
  186.   # Accesories' ID's
  187.   PREEMPTIVE_ARMOR4 = []
  188.   # Skills' ID's
  189.   PREEMPTIVE_SKILLS = []
  190.   # Number of the Switch - when ON, the chance for Preemptive Attacks is zero
  191.   NO_PREEMPTIVE_SWITCH = []
  192.   # Number of the Switch - when ON, the chance for Preemptive Attacks is 100%
  193.   PREEMPTIVE_SWITCH = []
  194.  
  195. end
  196.  
Expand to see the code.

  1. #==============================================================================
  2. # Sideview Battle System Version 2.2xp
  3. #==============================================================================
  4. #==============================================================================
  5. # ■ Sprite_Battler
  6. #==============================================================================
  7. class Sprite_Battler < RPG::Sprite
  8.   #--------------------------------------------------------------------------
  9.   APPEAR    = 3
  10.   DISAPPEAR = 4
  11.   COLLAPSE  = 5
  12.   #--------------------------------------------------------------------------
  13.   include N01
  14.   #--------------------------------------------------------------------------
  15.   def initialize(viewport, battler = nil)
  16.     super(viewport)
  17.     @battler = battler
  18.     @battler_visible = false
  19.     @effect_type = 0
  20.     @effect_duration = 0
  21.     @move_x = 0
  22.     @move_y = 0
  23.     @move_z = 0
  24.     @distanse_x = 0
  25.     @distanse_y = 0
  26.     @moving_x = 0
  27.     @moving_y = 0
  28.     @move_speed_x = 0
  29.     @move_speed_y = 0
  30.     @move_speed_plus_x = 0
  31.     @move_speed_plus_y = 0
  32.     @move_boost_x = 0
  33.     @move_boost_y = 0
  34.     @jump_time = 0
  35.     @jump_time_plus = 0
  36.     @jump_up = 0
  37.     @jump_down = 0
  38.     @jump_size = 0
  39.     @float_time = 0
  40.     @float_up = 0
  41.     @jump_plus = 0
  42.     @angle = 0
  43.     @angling = 0
  44.     @angle_time = 0
  45.     @angle_reset = 0
  46.     @zoom_x = 0
  47.     @zoom_y = 0
  48.     @zooming_x = 0
  49.     @zooming_y = 0
  50.     @zoom_time = 0
  51.     @zoom_reset = 0
  52.     @target_battler = []
  53.     @now_targets = []
  54.     @pattern = 0
  55.     @pattern_back = false
  56.     @wait = 0
  57.     @unloop_wait = 0
  58.     @action = []
  59.     @anime_kind = 0
  60.     @anime_speed = 0
  61.     @frame = 0
  62.     @anime_loop = 0
  63.     @anime_end = false
  64.     @anime_freeze = false
  65.     @anime_freeze_kind = false
  66.     @anime_moving = false
  67.     @base_width = ANIME_PATTERN
  68.     @base_height = ANIME_KIND
  69.     @join = false
  70.     @width = 0
  71.     @height = 0
  72.     @picture_time = 0
  73.     @individual_targets = []
  74.     @balloon_duration = 65
  75.     @reverse = false
  76.     return @battler_visible = false if @battler == nil
  77.     @anime_flug = true if @battler.actor? && !NO_ANIM_BATTLER
  78.     @anime_flug = true if [email protected]? && @battler.anime_on
  79.     @weapon_R = Sprite_Weapon.new(viewport,@battler) if @anime_flug
  80.     make_battler
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   def make_battler
  84.     @battler.base_position
  85.     @battler_hue = @battler.battler_hue
  86.     if @anime_flug
  87.       @battler_name = @battler.battler_name if [email protected]?
  88.       @battler_name = @battler.character_name if @battler.actor?
  89.       @battler_hue = @battler.character_hue if @battler.actor?
  90.       self.mirror = true if [email protected]? && @battler.action_mirror
  91.       self.mirror = false if [email protected]? && @battler.action_mirror and $back_attack
  92.       self.bitmap = RPG::Cache.character(@battler_name, @battler_hue) if WALK_ANIME
  93.       begin
  94.         self.bitmap = RPG::Cache.character(@battler_name + "_1", @battler_hue) unless WALK_ANIME
  95.       rescue
  96.         self.bitmap = RPG::Cache.character(@battler_name, @battler_hue) unless WALK_ANIME
  97.       end
  98.       @width = self.bitmap.width / @base_width
  99.       @height = self.bitmap.height / @base_height
  100.       @sx = @pattern * @width
  101.       @sy = @anime_kind * @height
  102.       self.src_rect.set(@sx, @sy, @width, @height)
  103.     else
  104.       @battler_name = @battler.battler_name
  105.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  106.       @width = bitmap.width
  107.       @height = bitmap.height
  108.     end
  109.     unless @back_attack_flug
  110.       if self.mirror && $back_attack
  111.         self.mirror = false
  112.       elsif $back_attack
  113.         self.mirror = true
  114.       end
  115.       @back_attack_flug = true
  116.     end
  117.     @battler.reset_coordinate
  118.     self.ox = @width / 2
  119.     self.oy = @height * 2 / 3
  120.     update_move
  121.     @move_anime = Sprite_MoveAnime.new(viewport,battler)
  122.     @picture = Sprite.new
  123.     make_shadow if SHADOW
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   def update_battler_graphic
  127.     return if @graphic_change or !WALK_ANIME or @anime_freeze or @battler.dead?
  128.     if @battler.actor? and @anime_flug
  129.       @battler.base_position
  130.       @battler_name = @battler.character_name if @battler.actor?
  131.       @battler_hue = @battler.character_hue if @battler.actor?
  132.       self.bitmap = RPG::Cache.character(@battler_name, @battler_hue)if WALK_ANIME
  133.       begin
  134.         self.bitmap = RPG::Cache.character(@battler_name + "_1", @battler_hue) unless WALK_ANIME
  135.       rescue
  136.         self.bitmap = RPG::Cache.character(@battler_name, @battler_hue) unless WALK_ANIME
  137.       end
  138.       @width = self.bitmap.width / @base_width
  139.       @height = self.bitmap.height / @base_height
  140.       @sx = @pattern * @width
  141.       @sy = @anime_kind * @height
  142.       self.src_rect.set(@sx, @sy, @width, @height)
  143.       self.ox = @width / 2
  144.       self.oy = @height * 2 / 3
  145.     end
  146.     unless @back_attack_flug
  147.       if self.mirror && $back_attack
  148.         self.mirror = false
  149.       elsif $back_attack
  150.         self.mirror = true
  151.       end
  152.       @back_attack_flug = true
  153.     end
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   def make_shadow
  157.     @shadow.dispose if @shadow != nil
  158.     @battler_hue = @battler.battler_hue
  159.     @shadow = Sprite.new(viewport)
  160.     @shadow.z = 200
  161.     @shadow.visible = false
  162.     @shadow.bitmap = RPG::Cache.character(@battler.shadow, @battler_hue)
  163.     @shadow_height = @shadow.bitmap.height
  164.     @shadow_plus_x = @battler.shadow_plus[0] - @width / 2
  165.     @shadow_plus_y = @battler.shadow_plus[1]
  166.     @shadow.zoom_x = @width * 1.0 / @shadow.bitmap.width
  167.     update_shadow
  168.     @skip_shadow = true
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   def dispose
  172.     self.bitmap.dispose if self.bitmap != nil
  173.     @weapon_R.dispose if @weapon_R != nil
  174.     @move_anime.dispose if @move_anime != nil
  175.     @picture.dispose if @picture != nil
  176.     @shadow.dispose if @shadow != nil
  177.     @balloon.dispose if @balloon != nil
  178.     mirage_off
  179.     super
  180.   end  
  181.   #--------------------------------------------------------------------------
  182.   def damage_action(action)
  183.     if action[0] == "absorb"
  184.       action[0] = nil
  185.       now_hp = @battler.hp
  186.       now_sp = @battler.sp
  187.       @battler.hp += action[3] if action[2] == "hp"
  188.       @battler.sp += action[3] if action[2] == "sp"
  189.       @battler.damage = now_hp - @battler.hp if action[2] == "hp"
  190.       @battler.damage = now_sp - @battler.sp if action[2] == "sp"
  191.       @battler.sp_damage = true if @battler.damage != 0 && action[2] == "sp"
  192.       action[2] = false
  193.     end
  194.     unless @battler.evaded or @battler.missed or action[0] == nil
  195.       @battler.animation_id = action[0]
  196.       @battler.animation_hit = true
  197.       @battler.anime_mirror = action[1]
  198.     end
  199.     dmg = @battler.damage
  200.     dmg = 0 unless dmg.is_a?(Numeric)
  201.     start_action(@battler.damage_hit) if dmg > 0 && action[2]
  202.     if @battler.evaded or @battler.missed
  203.       start_action(@battler.evasion) if action[2]
  204.       Audio.se_play("Audio/SE/" + EVASION_EFFECT) if action[2]
  205.     end
  206.     damage_pop
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   def damage_pop
  210.     damage(@battler.damage, @battler.critical, @battler.sp_damage)
  211.     @battler.damage = nil
  212.     @battler.sp_damage = false
  213.     @battler.critical = false
  214.     @battler.damage_pop = false
  215.   end  
  216.   #--------------------------------------------------------------------------
  217.   def first_action
  218.     action = @battler.first_action unless @battler.restriction == 4
  219.     action = $data_states[@battler.state_id].base_action if @battler.states[0] != nil && @battler.restriction == 4
  220.     start_action(action)
  221.     @skip_shadow = false
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   def start_action(kind)
  225.     reset
  226.     stand_by
  227.     @action = ACTION[kind].dup
  228.     active = @action.shift
  229.     @action.push("End")
  230.     @active_action = ANIME[active]
  231.     @wait = active.to_i if @active_action == nil
  232.     action
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   def start_one_action(kind,back)
  236.     reset
  237.     stand_by
  238.     @action = [back]
  239.     @action.push("End")
  240.     @active_action = ANIME[kind]
  241.     action
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   def next_action
  245.     return @wait -= 1 if @wait > 0
  246.     return if @anime_end == false
  247.     return @unloop_wait -= 1 if @unloop_wait > 0
  248.     active = @action.shift
  249.     @active_action = ANIME[active]
  250.     @wait = active.to_i if @active_action == nil
  251.     action
  252.   end
  253.   #--------------------------------------------------------------------------
  254.   def stand_by
  255.     @repeat_action = @battler.normal
  256.     @repeat_action = @battler.pinch if @battler.hp <= @battler.maxhp / 4
  257.     @repeat_action = @battler.defence if @battler.guarding?
  258.     unless @battler.state_id == nil
  259.       for state in @battler.battler_states.reverse
  260.         next if state.extension.include?("NOSTATEANIME")
  261.         next if @battler.is_a?(Game_Enemy) && state.extension.include?("EXCEPTENEMY")
  262.         @repeat_action = state.base_action
  263.       end
  264.     end
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   def push_stand_by
  268.     action = @battler.normal
  269.     action = @battler.pinch if @battler.hp <= @battler.maxhp / 4
  270.     action = @battler.defence if @battler.guarding?
  271.     for state in @battler.battler_states.reverse
  272.       next if state.extension.include?("NOSTATEANIME")
  273.       next if @battler.is_a?(Game_Enemy) && state.extension.include?("EXCEPTENEMY")
  274.       action = state.base_action
  275.     end
  276.     @repeat_action = action
  277.     @action.delete("End")
  278.     act = ACTION[action].dup
  279.     for i in 0...act.size
  280.       @action.push(act[i])
  281.     end  
  282.     @action.push("End")
  283.     @anime_end = true
  284.     @angle = self.angle = 0
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   def reset
  288.     self.zoom_x = self.zoom_y = 1
  289.     self.oy = @height * 2 / 3
  290.     @angle = self.angle = 0
  291.     @anime_end = true
  292.     @non_repeat = false
  293.     @anime_freeze = false
  294.     @unloop_wait = 0
  295.   end  
  296.   #--------------------------------------------------------------------------
  297.   def jump_reset
  298.     @battler.jump = @jump_time = @jump_time_plus = @jump_up = @jump_down = 0
  299.     @jump_size = @jump_plus = @float_time = @float_up = 0
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   def get_target(target)
  303.     return if @battler.individual
  304.     @target_battler = target
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   def send_action(action)
  308.     @battler.play = 0
  309.     @battler.play = action if @battler.active
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   def battler_join
  313.     if @battler.exist? && !@battler_visible
  314.       return if [email protected]? and @battler.is_a?(Game_Enemy)
  315.       if @battler.revival && @anime_flug
  316.         return @battler.revival = false
  317.       elsif @battler.revival && !@anime_flug
  318.         @battler.revival = false
  319.         return self.visible = true
  320.       end  
  321.       @anime_flug = true if @battler.actor? && !NO_ANIM_BATTLER
  322.       @anime_flug = true if [email protected]? && @battler.anime_on
  323.       make_battler
  324.       first_action if [email protected]?
  325.     end
  326.     first_action if @battler.actor? and !@battler_visible
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   def update
  330.     super
  331.     return self.bitmap = nil && loop_animation(nil) if @battler == nil
  332.     battler_join
  333.     next_action
  334.     update_battler_graphic
  335.     update_anime_pattern
  336.     update_target
  337.     update_force_action
  338.     update_move
  339.     update_shadow if @shadow != nil
  340.     @weapon_R.update if @weapon_action
  341.     update_float if @float_time > 0
  342.     update_angle if @angle_time > 0
  343.     update_zoom if @zoom_time > 0
  344.     update_mirage if @mirage_flug
  345.     update_picture if @picture_time > 0
  346.     update_move_anime if @anime_moving
  347.     update_balloon if @balloon_duration <= 64
  348.     damage_pop if @battler.damage_pop
  349.     setup_new_effect
  350.     update_effect
  351.     update_battler_bitmap
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   def update_anime_pattern
  355.     return @frame -= 1 if @frame != 0
  356.     @weapon_R.action if @weapon_action && @weapon_R != nil
  357.     if NEW_PATTERN_REPEAT
  358.       if @pattern_back
  359.         if @anime_loop == 0
  360.           if @reverse
  361.             @pattern -= 1
  362.             @pattern = (@pattern < 0 ? @base_width - 1 : @pattern)
  363.             if @pattern == -1
  364.               @pattern_back = false
  365.               @anime_end = true
  366.             end  
  367.           else
  368.             @pattern += 1
  369.             @pattern = (@pattern > @base_width - 1 ? 0 : @pattern)
  370.             if @pattern == @base_width
  371.               @pattern_back = false
  372.               @anime_end = true
  373.             end
  374.           end
  375.         else
  376.           @anime_end = true
  377.           if @anime_loop == 1
  378.             @pattern = 0 if !@reverse
  379.             @pattern = @base_width - 1 if @reverse
  380.             @pattern_back = false
  381.           end  
  382.         end
  383.       else
  384.         if @reverse
  385.           @pattern -= 1
  386.           @pattern = (@pattern < 0 ? @base_width - 1 : @pattern)
  387.           @pattern_back = true if @pattern == 0
  388.         else
  389.           @pattern += 1
  390.           @pattern = (@pattern > @base_width - 1 ? 0 : @pattern)
  391.           @pattern_back = true if @pattern == @base_width - 1
  392.         end
  393.       end
  394.     else
  395.       if @pattern_back
  396.         if @anime_loop == 0
  397.           if @reverse
  398.             @pattern += 1
  399.             if @pattern == @base_width - 1
  400.               @pattern_back = false
  401.               @anime_end = true
  402.             end
  403.           else  
  404.             @pattern -= 1
  405.             if @pattern == 0
  406.               @pattern_back = false
  407.               @anime_end = true
  408.             end  
  409.           end  
  410.         else
  411.           @anime_end = true
  412.           if @anime_loop == 1
  413.             @pattern = 0 if !@reverse
  414.             @pattern = @base_width - 1 if @reverse
  415.             @pattern_back = false
  416.           end  
  417.         end  
  418.       else
  419.         if @reverse
  420.           @pattern -= 1
  421.           @pattern_back = true if @pattern == 0
  422.         else  
  423.           @pattern += 1
  424.           @pattern_back = true if @pattern == @base_width - 1
  425.         end  
  426.       end
  427.     end
  428.     @frame = @anime_speed
  429.     return if @anime_freeze
  430.     return unless @anime_flug
  431.     @sx = @pattern * @width
  432.     @sy = @anime_kind * @height
  433.     self.src_rect.set(@sx, @sy, @width, @height)
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   def update_target
  437.     return if @battler.force_target == 0
  438.     return if @battler.individual
  439.     @target_battler = @battler.force_target[1]
  440.     @battler.force_target = 0
  441.   end  
  442.   #--------------------------------------------------------------------------
  443.   def update_force_action
  444.     action = @battler.force_action
  445.     return if action == 0
  446.     @battler.force_action = 0
  447.     return if @battler.active
  448.     return collapse_action if action[0] == "N01collapse"
  449.     return start_one_action(action[2],action[1]) if action[0] == "SINGLE"
  450.     start_action(action[2])
  451.     return if action[1] == ""
  452.     @action.delete("End")
  453.     @action.push(action[1])
  454.     @action.push("End")
  455.   end  
  456.   #--------------------------------------------------------------------------
  457.   def update_move
  458.     if @move_speed_plus_x > 0
  459.       @move_x += @moving_x
  460.       @battler.move_x = @move_x
  461.       @move_speed_plus_x -= 1
  462.     elsif @move_speed_x > 0
  463.       if @move_boost_x != 0
  464.         @moving_x += @move_boost_x
  465.       end  
  466.       @move_x += @moving_x
  467.       @battler.move_x = @move_x
  468.       @move_speed_x -= 1
  469.     end
  470.     if @move_speed_plus_y > 0
  471.       @move_y += @moving_y
  472.       @battler.move_y = @move_y
  473.       @move_speed_plus_y -= 1
  474.     elsif @move_speed_y > 0
  475.       if @move_boost_y != 0
  476.         @moving_y += @move_boost_y
  477.       end
  478.       @move_y += @moving_y
  479.       @battler.move_y = @move_y
  480.       @move_speed_y -= 1
  481.     end
  482.     if @jump_up != 0
  483.       @jump_plus += @jump_up
  484.       @battler.jump = @jump_plus
  485.       @jump_up = @jump_up / 2
  486.       @jump_time -= 1
  487.       if @jump_time == 0 or @jump_up == @jump_sign
  488.         @jump_down = @jump_up * 2 * @jump_sign * @jump_sign2
  489.         @jump_time_plus += @jump_time * 2
  490.         @jump_up = 0
  491.         return
  492.       end  
  493.     end
  494.     if @jump_down != 0
  495.       if @jump_time_plus != 0
  496.         @jump_time_plus -= 1
  497.       elsif @jump_down != @jump_size
  498.         @jump_plus += @jump_down
  499.         @battler.jump = @jump_plus
  500.         @jump_down = @jump_down * 2
  501.         if @jump_down == @jump_size
  502.           if @jump_flug
  503.             @jump_flug = false
  504.           else
  505.             @jump_plus += @jump_down
  506.             @battler.jump = @jump_plus
  507.             @jump_down = @jump_size = 0
  508.           end
  509.         end  
  510.       end
  511.     end
  512.     self.x = @battler.position_x
  513.     self.y = @battler.position_y
  514.     self.z = @battler.position_z
  515.   end
  516.   #--------------------------------------------------------------------------
  517.   def update_shadow
  518.     @shadow.opacity = self.opacity
  519.     @shadow.x = self.x + @shadow_plus_x
  520.     @shadow.y = self.y + @shadow_plus_y - @jump_plus
  521.   end
  522.   #--------------------------------------------------------------------------
  523.   def update_float
  524.     @float_time -= 1
  525.     @jump_plus += @float_up
  526.     @battler.jump = @jump_plus
  527.   end  
  528.   #--------------------------------------------------------------------------
  529.   def update_angle
  530.     @angle += @angling
  531.     self.angle = @angle
  532.     @angle_time -= 1
  533.     return @angle = 0 if @angle_time == 0
  534.     self.angle = 0 if @angle_reset
  535.   end  
  536.   #--------------------------------------------------------------------------
  537.   def update_zoom
  538.     @zoom_x += @zooming_x
  539.     @zoom_y += @zooming_y
  540.     self.zoom_x = @zoom_x
  541.     self.zoom_y = @zoom_y
  542.     @zoom_time -= 1
  543.     return if @zoom_time != 0
  544.     @zoom_x = @zoom_y = 0
  545.     self.oy = @height
  546.     self.zoom_x = self.zoom_y = 1 if @zoom_reset
  547.   end  
  548.   #--------------------------------------------------------------------------
  549.   def update_mirage
  550.     mirage(@mirage0) if @mirage_count == 1
  551.     mirage(@mirage1) if @mirage_count == 3
  552.     mirage(@mirage2) if @mirage_count == 5
  553.     @mirage_count += 1
  554.     @mirage_count = 0 if @mirage_count == 6
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   def update_picture
  558.     @picture_time -= 1
  559.     @picture.x += @moving_pic_x
  560.     @picture.y += @moving_pic_y
  561.   end  
  562.   #--------------------------------------------------------------------------
  563.   def update_move_anime
  564.     @move_anime.update
  565.     @anime_moving = false if @move_anime.finish?
  566.     @move_anime.action_reset if @move_anime.finish?
  567.   end  
  568.   #--------------------------------------------------------------------------
  569.   def setup_new_effect
  570.     if @battler.blink
  571.       blink_on
  572.     else
  573.       blink_off
  574.     end
  575.     if @battler.white_flash
  576.       whiten
  577.       @battler.white_flash = false
  578.     end
  579.     effects_update
  580.     if not @battler_visible and @battler.exist?
  581.       @effect_type = APPEAR
  582.       @effect_duration = 16
  583.       @battler_visible = true
  584.     end
  585.     if @battler_visible and @battler.hidden
  586.       @effect_type = DISAPPEAR
  587.       @effect_duration = 32
  588.       @battler_visible = false
  589.     end
  590.     if @battler.collapse
  591.       @effect_type = COLLAPSE
  592.       @effect_duration = 48
  593.       @battler.collapse = false
  594.       @battler_visible = false
  595.     end
  596.     if @battler_visible && @battler.animation_id != 0
  597.       animation = $data_animations[@battler.animation_id]
  598.       @battler.animation_hit = true unless @battler.evaded or @battler.missed
  599.       animation(animation, @battler.animation_hit)
  600.       if @active_battler.is_a?(Game_Enemy)
  601.         if @battler.actor? and @battler.anime_mirror
  602.           @battler.anime_mirror = false
  603.         elsif @battler.actor? and [email protected]_mirror
  604.           @battler.anime_mirror = true
  605.         end
  606.       end
  607.       animation_mirror(@battler.anime_mirror)
  608.       @battler.animation_id = 0
  609.       @battler.anime_mirror = false
  610.     end
  611.   end
  612.   #--------------------------------------------------------------------------
  613.   def effects_update
  614.     if @battler.damage == nil and @battler.state_animation_id != @state_animation_id and STATE_ANIM and @battler_visible
  615.       @state_animation_id = @battler.state_animation_id == nil ? 0 : @battler.state_animation_id
  616.       loop_animation($data_animations[@state_animation_id])
  617.     end
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   def update_effect
  621.     if @effect_duration > 0
  622.       @effect_duration -= 1
  623.       case @effect_type
  624.       when APPEAR
  625.         update_appear
  626.       when DISAPPEAR
  627.         update_disappear
  628.       when COLLAPSE
  629.         update_collapse
  630.       end
  631.     end
  632.   end
  633.   #--------------------------------------------------------------------------
  634.   def update_whiten
  635.     self.blend_type = 0
  636.     self.color.set(255, 255, 255, 128)
  637.     self.opacity = 255
  638.     self.color.alpha = 128 - (16 - @effect_duration) * 10
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   def update_appear
  642.     self.blend_type = 0
  643.     self.color.set(0, 0, 0, 0)
  644.     self.opacity = (16 - @effect_duration) * 16
  645.   end
  646.   #--------------------------------------------------------------------------
  647.   def update_disappear
  648.     self.blend_type = 0
  649.     self.color.set(0, 0, 0, 0)
  650.     self.opacity = 256 - (32 - @effect_duration) * 10
  651.   end
  652.   #--------------------------------------------------------------------------
  653.   def update_collapse
  654.     normal_collapse if @collapse_type == 2
  655.     boss_collapse if @collapse_type == 3
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   def update_balloon
  659.     @balloon_duration -= 1 if @balloon_duration > 0 && !@balloon_back
  660.     @balloon_duration += 1 if @balloon_back
  661.     if @balloon_duration == 64
  662.       @balloon_back = false
  663.       @balloon.visible = false
  664.     elsif @balloon_duration == 0
  665.       @balloon.visible = false if @balloon_loop == 0
  666.       @balloon_back = true if @balloon_loop == 1
  667.     end    
  668.     @balloon.x = self.x
  669.     @balloon.y = self.y
  670.     @balloon.z = self.y
  671.     @balloon.opacity = self.opacity
  672.     sx = 7 * 32 if @balloon_duration < 12
  673.     sx = (7 - (@balloon_duration - 12) / 8) * 32 unless @balloon_duration < 12
  674.     @balloon.src_rect.set(sx, @balloon_id * 32, 32, 32)
  675.     @balloon.visible = false if @battler.dead?
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   def update_battler_bitmap
  679.     return if @graphic_change
  680.     return if @battler.actor?
  681.     if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue
  682.       @battler_name = @battler.battler_name
  683.       @battler_hue = @battler.battler_hue
  684.       make_battler
  685.       self.opacity = 0 if @battler.dead? or @battler.hidden
  686.     end
  687.   end
  688.   #--------------------------------------------------------------------------
  689.   def action
  690.     return if @active_action == nil
  691.     action = @active_action[0]
  692.     return mirroring if action == "Invert"
  693.     return angling if action == "angle"
  694.     return zooming if action == "zoom"
  695.     return mirage_on if action == "Afterimage ON"
  696.     return mirage_off if action == "Afterimage OFF"
  697.     return picture if action == "pic"
  698.     return @picture.visible = false && @picture_time = 0 if action == "Clear image"
  699.     return graphics_change if action == "change"
  700.     return battle_anime if action == "anime"
  701.     return balloon_anime if action == "balloon"
  702.     return sound if action == "sound"
  703.     return $game_switches[@active_action[1]] = @active_action[2] if action == "switch"
  704.     return variable if action == "variable"
  705.     return two_swords if action == "Two Wpn Only"
  706.     return non_two_swords if action == "One Wpn Only"
  707.     return necessary if action == "nece"
  708.     return derivating if action == "der"
  709.     return individual_action if action == "Process Skill"
  710.     return individual_action_end if action == "Process Skill End"
  711.     return non_repeat if action == "Don't Wait"
  712.     return @battler.change_base_position(self.x, self.y) if action == "Start Pos Change"
  713.     return @battler.base_position if action == "Start Pos Return"
  714.     return change_target if action == "target"
  715.     return send_action(action) if action == "Can Collapse"
  716.     return send_action(action) if action == "Cancel Action"
  717.     return state_on if action == "sta+"
  718.     return state_off if action == "sta-"
  719.     return Graphics.frame_rate = @active_action[1] if action == "fps"
  720.     return floating if action == "float"
  721.     return eval(@active_action[1]) if action == "script"
  722.     return force_action if @active_action.size == 4
  723.     return reseting if @active_action.size == 5
  724.     return moving if @active_action.size == 7
  725.     return battler_anime if @active_action.size == 9
  726.     return moving_anime if @active_action.size == 11
  727.     return anime_finish if action == "End"
  728.   end
  729.   #--------------------------------------------------------------------------
  730.   def mirroring  
  731.     if self.mirror
  732.       self.mirror = false
  733.       @weapon_R.mirroring if @anime_flug
  734.     else
  735.       self.mirror = true
  736.       @weapon_R.mirroring if @anime_flug
  737.     end
  738.   end  
  739.   #--------------------------------------------------------------------------
  740.   def angling  
  741.     jump_reset
  742.     @angle_time = @active_action[1]
  743.     start_angle = @active_action[2]
  744.     end_angle = @active_action[3]
  745.     @angle_reset = @active_action[4]
  746.     start_angle *= -1 if $back_attack
  747.     end_angle *= -1 if $back_attack
  748.     start_angle *= -1 if @battler.is_a?(Game_Enemy)
  749.     end_angle *= -1 if @battler.is_a?(Game_Enemy)
  750.     if @angle_time <= 0
  751.       self.angle = end_angle
  752.       return  @angle_time = 0
  753.     end  
  754.     @angling = (end_angle - start_angle) / @angle_time
  755.     @angle = (end_angle - start_angle) % @angle_time + start_angle
  756.   end
  757.   #--------------------------------------------------------------------------
  758.   def zooming  
  759.     jump_reset
  760.     @zoom_time = @active_action[1]
  761.     zoom_x = @active_action[2] - 1
  762.     zoom_y = @active_action[3] - 1
  763.     @zoom_reset = @active_action[4]
  764.     @zoom_x = @zoom_y = 1
  765.     return @zoom_time = 0 if @zoom_time <= 0
  766.     @zooming_x = zoom_x / @zoom_time
  767.     @zooming_y = zoom_y / @zoom_time
  768.   end  
  769.   #--------------------------------------------------------------------------
  770.   def mirage_on
  771.     return if @battler.dead?
  772.     @mirage0 = Sprite.new(self.viewport)
  773.     @mirage1 = Sprite.new(self.viewport)
  774.     @mirage2 = Sprite.new(self.viewport)
  775.     @mirage_flug = true
  776.     @mirage_count = 0
  777.   end  
  778.   #--------------------------------------------------------------------------
  779.   def mirage(body)
  780.     body.bitmap = self.bitmap.dup
  781.     body.x = self.x
  782.     body.y = self.y
  783.     body.ox = self.ox
  784.     body.oy = self.oy
  785.     body.z = self.z
  786.     body.mirror = self.mirror
  787.     body.angle = @angle
  788.     body.opacity = 160
  789.     body.zoom_x = self.zoom_x
  790.     body.zoom_y = self.zoom_y  
  791.     body.src_rect.set(@sx, @sy, @width, @height) if @anime_flug
  792.     body.src_rect.set(0, 0, @width, @height) unless @anime_flug
  793.   end  
  794.   #--------------------------------------------------------------------------
  795.   def mirage_off
  796.     @mirage_flug = false
  797.     @mirage0.dispose if @mirage0 != nil
  798.     @mirage1.dispose if @mirage1 != nil
  799.     @mirage2.dispose if @mirage2 != nil
  800.   end  
  801.   #--------------------------------------------------------------------------
  802.   def picture
  803.     pic_x = @active_action[1]
  804.     pic_y = @active_action[2]
  805.     pic_end_x = @active_action[3]
  806.     pic_end_y = @active_action[4]
  807.     @picture_time = @active_action[5]
  808.     @moving_pic_x = (pic_end_x - pic_x)/ @picture_time
  809.     @moving_pic_y = (pic_end_y - pic_y)/ @picture_time
  810.     plus_x = (pic_end_x - pic_x)% @picture_time
  811.     plus_y = (pic_end_y - pic_y)% @picture_time
  812.     @picture.bitmap = RPG::Cache.picture(@active_action[7])
  813.     @picture.x = pic_x + plus_x
  814.     @picture.y = pic_y + plus_y
  815.     @picture.z = 1
  816.     @picture.z = 1900
  817.     @picture.z = 3000 if @active_action[6]
  818.     @picture.visible = true
  819.   end
  820.   #--------------------------------------------------------------------------
  821.   def graphics_change  
  822.     return if @battler.is_a?(Game_Enemy)
  823.     @battler_name = @active_action[2]
  824.     @bitmap = RPG::Cache.character(@battler_name , @battler_hue) if WALK_ANIME
  825.     @bitmap = RPG::Cache.character(@battler_name + "_1", @battler_hue) unless WALK_ANIME
  826.     @width = @bitmap.width / @base_width
  827.     @height = @bitmap.height / @base_height
  828.     @battler.graphic_change(@active_action[2]) unless @active_action[1]
  829.     @graphic_change = true
  830.   end  
  831.   #--------------------------------------------------------------------------
  832.   def battle_anime
  833.     return if @active_action[5] && [email protected]?
  834.     return if @active_action[5] && @battler.weapons[1] == nil
  835.     if @battler.actor?
  836.       return if !@active_action[5] && @battler.weapons[0] == nil && @battler.weapons[1] != nil
  837.     end
  838.     anime_id = @active_action[1]
  839.     if $back_attack
  840.       mirror = true if @active_action[3] == false
  841.       mirror = false if @active_action[3]
  842.     end
  843.     if anime_id < 0
  844.       if @battler.current_action.kind == 1 && anime_id != -2
  845.         anime_id = $data_skills[@battler.current_action.skill_id].animation2_id
  846.       elsif @battler.current_action.kind == 2 && anime_id != -2
  847.         anime_id = $data_items[@battler.current_action.item_id].animation2_id
  848.       else
  849.         anime_id = NO_WEAPON
  850.         if @battler.actor?
  851.           weapon_id = @battler.weapon_id
  852.           anime_id = UNARMED_ANIM
  853.           anime_id = battler.weapons[0].animation2_id if battler.weapons[0] != nil
  854.           anime_id = battler.weapons[1].animation2_id if @active_action[5]
  855.         else
  856.           weapon_id = @battler.weapon
  857.           anime_id = $data_weapons[weapon_id].animation2_id if weapon_id != 0
  858.         end
  859.       end
  860.       @wait = $data_animations[anime_id].frame_max if $data_animations[anime_id] != nil && @active_action[4]
  861.       waitflug = true
  862.       damage_action = [anime_id, mirror, true]
  863.       return @battler.play = ["OBJ_ANIM",damage_action] if @battler.active
  864.     end
  865.     if @active_action[2] == 0 && $data_animations[anime_id] != nil
  866.       @battler.animation_id = anime_id
  867.       @battler.animation_hit = true
  868.       @battler.anime_mirror = mirror
  869.     elsif $data_animations[anime_id] != nil
  870.       for target in @target_battler
  871.         target.animation_id = anime_id
  872.         target.anime_mirror = mirror
  873.       end  
  874.     end
  875.     @wait = $data_animations[anime_id].frame_max if $data_animations[anime_id] != nil && @active_action[4] && !waitflug
  876.   end
  877.   #--------------------------------------------------------------------------
  878.   def sound  
  879.     pitch = @active_action[2]
  880.     vol =  @active_action[3]
  881.     name = @active_action[4]
  882.     case @active_action[1]
  883.     when "se"
  884.       Audio.se_play("Audio/SE/" + name, vol, pitch)
  885.     when "bgm"
  886.       if @active_action[4] == ""
  887.         now_bgm = RPG::BGM.last
  888.         name = now_bgm.name
  889.       end
  890.       Audio.bgm_play("Audio/BGM/" + name, vol, pitch)
  891.     when "bgs"
  892.       if @active_action[4] == ""
  893.         now_bgs = RPG::BGS.last
  894.         name = now_bgs.name
  895.       end
  896.       Audio.bgs_play("Audio/BGS/" + name, vol, pitch)
  897.     end
  898.   end
  899.   #--------------------------------------------------------------------------
  900.   def balloon_anime
  901.     return if self.opacity == 0
  902.     if @balloon == nil
  903.       @balloon = Sprite.new
  904.       @balloon.bitmap = RPG::Cache.picture("Balloon")
  905.       @balloon.ox = @width / 16
  906.       @balloon.oy = 320 / 10  + @height / 3
  907.     end
  908.     @balloon_id = @active_action[1]
  909.     @balloon_loop = @active_action[2]
  910.     @balloon_duration = 64
  911.     @balloon_back = false
  912.     update_balloon
  913.     @balloon.visible = true
  914.     @balloon.visible = false unless BALLOON_ANIM
  915.   end  
  916.   #--------------------------------------------------------------------------
  917.   def variable
  918.     operand = @active_action[3]
  919.     case @active_action[2]
  920.     when 0
  921.       $game_variables[@active_action[1]] = operand
  922.     when 1
  923.       $game_variables[@active_action[1]] += operand
  924.     when 2
  925.       $game_variables[@active_action[1]] -= operand
  926.     when 3
  927.       $game_variables[@active_action[1]] *= operand
  928.     when 4
  929.       $game_variables[@active_action[1]] /= operand
  930.     when 5
  931.       $game_variables[@active_action[1]] %= operand
  932.     end
  933.   end  
  934.   #--------------------------------------------------------------------------
  935.   def two_swords
  936.     return @action.shift unless @battler.actor?
  937.     return @action.shift if @battler.weapons[1] == nil
  938.     active = @action.shift
  939.     @active_action = ANIME[active]
  940.     @wait = active.to_i if @active_action == nil
  941.     action
  942.   end
  943.   #--------------------------------------------------------------------------
  944.   def non_two_swords
  945.     return unless @battler.actor?
  946.     return @action.shift if @battler.weapons[1] != nil
  947.     active = @action.shift
  948.     @active_action = ANIME[active]
  949.     @wait = active.to_i if @active_action == nil
  950.     action
  951.   end
  952.   #--------------------------------------------------------------------------
  953.   def necessary
  954.     nece1 = @active_action[3]
  955.     nece2 = @active_action[4]
  956.     case @active_action[1]
  957.     when 0
  958.       target = [$game_party.actors[@battler.index]] if @battler.actor?
  959.       target = [$game_troop.enemies[@battler.index]] if @battler.is_a?(Game_Enemy)
  960.     when 1
  961.       target = @target_battler
  962.     when 2
  963.       target = $game_troop.enemies
  964.     when 3
  965.       target = $game_party.actors
  966.     end
  967.     return start_action(@battler.recover_action) if target.size == 0
  968.     case @active_action[2]
  969.     when 0
  970.       state_on = true if nece2 > 0
  971.       state_member = nece2.abs
  972.       if nece2 == 0
  973.         state_member = $game_party.actors.size if @battler.actor?
  974.         state_member = $game_troop.enemies.size if @battler.is_a?(Game_Enemy)
  975.       end  
  976.       for member in target
  977.         state_member -= 1 if member.state?(nece1)
  978.       end
  979.       if state_member == 0 && state_on
  980.         return
  981.       elsif state_member == nece2.abs
  982.         return if state_on == nil
  983.       end  
  984.     when 1  
  985.       num_over = true if nece2 > 0
  986.       num = 0
  987.       for member in target
  988.         case  nece1
  989.         when 0
  990.           num += member.hp
  991.         when 1
  992.           num += member.mp
  993.         when 2
  994.           num += member.atk
  995.         when 3
  996.           num += member.dex
  997.         when 4
  998.           num += member.agi
  999.         when 5
  1000.           num += member.int
  1001.         end
  1002.       end
  1003.       num = num / target.size
  1004.       if num > nece2.abs && num_over
  1005.         return
  1006.       elsif num < nece2.abs
  1007.         return if num_over == nil
  1008.       end
  1009.     when 2
  1010.       if $game_switches[nece1]
  1011.         return if nece2
  1012.       else
  1013.         return unless nece2
  1014.       end  
  1015.     when 3
  1016.       if nece2 > 0
  1017.         return if $game_variables[nece1] > nece2
  1018.       else
  1019.         return unless $game_variables[nece1] > nece2.abs
  1020.       end
  1021.     when 4
  1022.       skill_member = nece2.abs
  1023.       for member in target
  1024.         skill_member -= 1 if member.skill_learn?(nece1)
  1025.         return if skill_member == 0
  1026.       end  
  1027.     end
  1028.     return @action = ["End"] if @non_repeat
  1029.     action = @battler.recover_action
  1030.     action = @battler.defence if @battler.guarding?
  1031.     return start_action(action)
  1032.   end  
  1033.   #--------------------------------------------------------------------------
  1034.   def derivating
  1035.     return unless @active_action[2] && [email protected]_learn?(@active_action[3])
  1036.     return if rand(100) > @active_action[1]
  1037.     @battler.derivation = @active_action[3]
  1038.     @action = ["End"]
  1039.   end
  1040.   #--------------------------------------------------------------------------
  1041.   def individual_action
  1042.     @battler.individual = true
  1043.     @individual_act = @action.dup
  1044.     send_action(["Individual"])
  1045.     @individual_targets = @target_battler.dup
  1046.     @target_battler = [@individual_targets.shift]
  1047.   end
  1048.   #--------------------------------------------------------------------------
  1049.   def individual_action_end
  1050.     return @battler.individual = false if @individual_targets.size == 0
  1051.     @action = @individual_act.dup
  1052.     @target_battler = [@individual_targets.shift]
  1053.   end  
  1054.   #--------------------------------------------------------------------------
  1055.   def non_repeat
  1056.     @repeat_action = []
  1057.     @non_repeat = true
  1058.     anime_finish
  1059.   end  
  1060.   #--------------------------------------------------------------------------
  1061.   def change_target
  1062.     return @target_battler = @now_targets.dup if @active_action[2] == 3
  1063.     target = [@battler] if @active_action[2] == 0
  1064.     target = @target_battler.dup if @active_action[2] != 0
  1065.     if @active_action[2] == 2
  1066.       @now_targets = @target_battler.dup
  1067.       @target_battler = []
  1068.     end  
  1069.     if @active_action[1] >= 1000
  1070.       members = $game_party.actors if @battler.actor?
  1071.       members = $game_troop.enemies unless @battler.actor?
  1072.       index = @active_action[1] - 1000
  1073.       if index < members.size
  1074.         if members[index].exist? && @battler.index != index
  1075.           members[index].force_target = ["N01target_change", target]
  1076.           @target_battler = [members[index]] if @active_action[2] == 2
  1077.           change = true
  1078.         else
  1079.           for member in members
  1080.             next if @battler.index == member.index
  1081.             next unless member.exist?
  1082.             member.force_target = ["N01target_change", target]
  1083.             @target_battler = [member] if @active_action[2] == 2
  1084.             break change = true
  1085.           end
  1086.         end
  1087.       end
  1088.     elsif @active_action[1] > 0
  1089.       for member in $game_party.actors + $game_troop.enemies
  1090.         if member.state?(@active_action[1])
  1091.           member.force_target = ["N01target_change", target]
  1092.           @target_battler.push(member) if @active_action[2] == 2
  1093.           change = true
  1094.         end  
  1095.       end  
  1096.     elsif @active_action[1] < 0
  1097.       skill_id = @active_action[1].abs
  1098.       for actor in $game_party.actors
  1099.         if actor.skill_learn?(skill_id)
  1100.           actor.force_target = ["N01target_change", target]
  1101.           @target_battler.push(target) if @active_action[2] == 2
  1102.           change = true
  1103.         end  
  1104.       end
  1105.     else
  1106.       for member in @target_battler
  1107.         member.force_target = ["N01target_change", target]
  1108.         @target_battler.push(member) if @active_action[2] == 2
  1109.         change = true
  1110.       end
  1111.     end
  1112.     return if change
  1113.     return @action = ["End"] if @non_repeat
  1114.     return start_action(@battler.recover_action)
  1115.   end    
  1116.   #--------------------------------------------------------------------------
  1117.   def state_on
  1118.     state_id = @active_action[2]
  1119.     case @active_action[1]
  1120.     when 0
  1121.       @battler.add_state(state_id)
  1122.     when 1
  1123.       if @target_battler != nil
  1124.         for target in @target_battler
  1125.           target.add_state(state_id)
  1126.         end
  1127.       end
  1128.     when 2
  1129.       for target in $game_troop.enemies
  1130.         target.add_state(state_id)
  1131.       end
  1132.     when 3
  1133.       for target in $game_party.actors
  1134.         target.add_state(state_id)
  1135.       end
  1136.     when 4
  1137.       for target in $game_party.actors
  1138.         if target.index != @battler.index
  1139.           target.add_state(state_id)
  1140.         end  
  1141.       end
  1142.     end
  1143.     start_action(@battler.recover_action) unless @battler.movable?
  1144.   end
  1145.   #--------------------------------------------------------------------------
  1146.   def state_off  
  1147.     state_id = @active_action[2]
  1148.     case @active_action[1]
  1149.     when 0
  1150.       @battler.remove_state(state_id)
  1151.     when 1
  1152.       if @target_battler != nil
  1153.         for target in @target_battler
  1154.           target.remove_state(state_id)
  1155.         end
  1156.       end
  1157.     when 2
  1158.       for target in $game_troop.enemies
  1159.         target.remove_state(state_id)
  1160.       end
  1161.     when 3
  1162.       for target in $game_party.actors
  1163.         target.remove_state(state_id)
  1164.       end
  1165.     when 4
  1166.       for target in $game_party.actors
  1167.         if target.index != @battler.index
  1168.           target.remove_state(state_id)
  1169.         end  
  1170.       end
  1171.     end
  1172.   end  
  1173.   #--------------------------------------------------------------------------
  1174.   def floating  
  1175.     jump_reset
  1176.     @jump_plus = @active_action[1]
  1177.     float_end = @active_action[2]
  1178.     @float_time = @active_action[3]
  1179.     @float_up = (float_end - @jump_plus)/ @float_time
  1180.     @wait = @float_time
  1181.     if @anime_flug
  1182.       move_anime = ANIME[@active_action[4]]
  1183.       if move_anime != nil
  1184.         @active_action = move_anime
  1185.         battler_anime
  1186.         @anime_end = true
  1187.       end
  1188.     end
  1189.     @battler.jump = @jump_plus
  1190.   end      
  1191.   #--------------------------------------------------------------------------
  1192.   def force_action
  1193.     kind = @active_action[0]
  1194.     rebirth = @active_action[2]
  1195.     play = @active_action[3]
  1196.     action = [kind,rebirth,play]
  1197.     if @active_action[1] >= 1000
  1198.       members = $game_party.actors if @battler.actor?
  1199.       members = $game_troop.enemies unless @battler.actor?
  1200.       index = @active_action[1] - 1000
  1201.       if index < members.size
  1202.         if members[index].exist? && @battler.index != index
  1203.           return members[index].force_action = action
  1204.         else
  1205.           for target in members
  1206.             next if @battler.index == target.index
  1207.             next unless target.exist?
  1208.             force = true
  1209.             break target.force_action = action
  1210.           end
  1211.         end
  1212.       end
  1213.       return if force
  1214.       return @action = ["End"] if @non_repeat
  1215.       return start_action(@battler.recover_action)
  1216.     elsif @active_action[1] == 0
  1217.       for target in @target_battler
  1218.         target.force_action = action if target != nil
  1219.       end
  1220.     elsif @active_action[1] > 0
  1221.       for target in $game_party.actors + $game_troop.enemies
  1222.         target.force_action = action if target.state?(@active_action[1])
  1223.       end
  1224.     elsif @active_action[1] < 0  
  1225.       return if @battler.is_a?(Game_Enemy)
  1226.       for actor in $game_party.actors
  1227.         unless actor.id == @battler.id
  1228.           actor.force_action = action if actor.skill_id_learn?(@active_action[1].abs)
  1229.         end
  1230.       end
  1231.     end
  1232.   end
  1233.   #--------------------------------------------------------------------------
  1234.   def reseting
  1235.     jump_reset
  1236.     self.angle = 0
  1237.     @distanse_x   = @move_x * -1
  1238.     @distanse_y   = @move_y * -1
  1239.     @move_speed_x = @active_action[1]
  1240.     @move_speed_y = @move_speed_x
  1241.     @move_boost_x = @active_action[2]
  1242.     @move_boost_y = @move_boost_x
  1243.     @jump         = @active_action[3]
  1244.     move_distance
  1245.     if @anime_flug
  1246.       move_anime = ANIME[@active_action[4]]
  1247.       if move_anime != nil
  1248.         @active_action = move_anime
  1249.         battler_anime
  1250.       end
  1251.       @anime_end = true
  1252.     end
  1253.   end
  1254.   #--------------------------------------------------------------------------
  1255.   def moving  
  1256.     jump_reset
  1257.     xx = @active_action[1]
  1258.     xx *= -1 if $back_attack
  1259.     case @active_action[0]
  1260.     when 0
  1261.       @distanse_x = xx
  1262.       @distanse_y = @active_action[2]
  1263.     when 1
  1264.       if @target_battler == nil
  1265.         @distanse_x = xx
  1266.         @distanse_y = @active_action[2]
  1267.       else
  1268.         target_x = 0
  1269.         target_y = 0
  1270.         time = 0
  1271.         for i in 0...@target_battler.size
  1272.           if @target_battler[i] != nil
  1273.             time += 1
  1274.             target_x += @target_battler[i].position_x
  1275.             target_y += @target_battler[i].position_y
  1276.           end  
  1277.         end
  1278.         if time == 0
  1279.           @distanse_x = xx
  1280.           @distanse_y = @active_action[2]
  1281.         else  
  1282.           target_x = target_x / time
  1283.           target_y = target_y / time
  1284.           @distanse_y = target_y - self.y + @active_action[2]
  1285.           if @battler.actor?
  1286.             @distanse_x = target_x - self.x + xx
  1287.           else
  1288.             @distanse_x = self.x - target_x + xx
  1289.           end  
  1290.         end  
  1291.       end  
  1292.     when 2
  1293.       if @battler.actor?
  1294.         @distanse_x = xx - self.x
  1295.         @distanse_x = 640 + xx - self.x if $back_attack
  1296.       else
  1297.         @distanse_x = self.x - xx
  1298.         @distanse_x = self.x - (Graphics.width + xx) if $back_attack
  1299.       end
  1300.       @distanse_y = @active_action[2] - self.y
  1301.     when 3
  1302.       if @battler.actor?
  1303.         @distanse_x = xx + @battler.base_position_x - self.x
  1304.       else
  1305.         @distanse_x = xx + self.x - @battler.base_position_x
  1306.       end
  1307.       @distanse_y = @active_action[2] + @battler.base_position_y - @battler.position_y
  1308.     end
  1309.     @move_speed_x = @active_action[3]
  1310.     @move_speed_y = @active_action[3]
  1311.     @move_boost_x = @active_action[4]
  1312.     @move_boost_y = @active_action[4]
  1313.     @jump         = @active_action[5]
  1314.     @jump_plus = 0
  1315.     move_distance
  1316.     if @anime_flug
  1317.       move_anime = ANIME[@active_action[6]]
  1318.       if move_anime != nil
  1319.         @active_action = move_anime
  1320.         battler_anime
  1321.       end  
  1322.       @anime_end = true
  1323.     end
  1324.   end
  1325.   #--------------------------------------------------------------------------
  1326.   def move_distance
  1327.     if @move_speed_x == 0
  1328.       @moving_x = 0
  1329.       @moving_y = 0
  1330.     else  
  1331.       @moving_x = @distanse_x / @move_speed_x
  1332.       @moving_y = @distanse_y / @move_speed_y
  1333.       over_x = @distanse_x % @move_speed_x
  1334.       over_y = @distanse_y % @move_speed_y
  1335.       @move_x += over_x
  1336.       @move_y += over_y
  1337.       @battler.move_x = @move_x
  1338.       @battler.move_y = @move_y
  1339.       @distanse_x -= over_x
  1340.       @distanse_y -= over_y
  1341.     end  
  1342.     if @distanse_x == 0
  1343.       @move_speed_x = 0
  1344.     end
  1345.     if @distanse_y == 0
  1346.       @move_speed_y = 0
  1347.     end
  1348.     boost_x = @moving_x
  1349.     move_x = 0
  1350.     if @move_boost_x > 0 && @distanse_x != 0
  1351.       if @distanse_x == 0
  1352.         @move_boost_x = 0
  1353.       elsif @distanse_x < 0
  1354.         @move_boost_x *= -1
  1355.       end
  1356.       for i in 0...@move_speed_x
  1357.         boost_x += @move_boost_x
  1358.         move_x += boost_x
  1359.         over_distance = @distanse_x - move_x
  1360.         if @distanse_x > 0 && over_distance < 0
  1361.           @move_speed_x = i
  1362.           break
  1363.         elsif @distanse_x < 0 && over_distance > 0
  1364.           @move_speed_x = i
  1365.           break
  1366.         end
  1367.       end
  1368.       before = over_distance + boost_x
  1369.       @move_speed_plus_x = (before / @moving_x).abs
  1370.       @move_x += before % @moving_x
  1371.       @battler.move_x = @move_x
  1372.     elsif @move_boost_x < 0 && @distanse_x != 0
  1373.       if @distanse_x == 0
  1374.         @move_boost_x = 0
  1375.       elsif @distanse_x < 0
  1376.         @move_boost_x *= -1
  1377.       end
  1378.       for i in 0...@move_speed_x
  1379.         boost_x += @move_boost_x
  1380.         move_x += boost_x
  1381.         lost_distance = @distanse_x - move_x
  1382.         before = lost_distance
  1383.         if @distanse_x > 0 && boost_x < 0
  1384.           @move_speed_x = i - 1
  1385.           before = lost_distance + boost_x
  1386.           break
  1387.         elsif @distanse_x < 0 && boost_x > 0
  1388.           @move_speed_x= i - 1
  1389.           before = lost_distance + boost_x
  1390.           break
  1391.         end
  1392.       end
  1393.       plus = before / @moving_x
  1394.       @move_speed_plus_x = plus.abs
  1395.       @move_x += before % @moving_x
  1396.       @battler.move_x = @move_x
  1397.     end
  1398.     boost_y = @moving_y
  1399.     move_y = 0
  1400.     if @move_boost_y > 0 && @distanse_y != 0
  1401.       if @distanse_y == 0
  1402.         @move_boost_y = 0
  1403.       elsif @distanse_y < 0
  1404.         @move_boost_y *= -1
  1405.       end
  1406.       for i in 0...@move_speed_y
  1407.         boost_y += @move_boost_y
  1408.         move_y += boost_y
  1409.         over_distance = @distanse_y - move_y
  1410.         if @distanse_y > 0 && over_distance < 0
  1411.           @move_speed_y = i
  1412.           break
  1413.         elsif @distanse_y < 0 && over_distance > 0
  1414.           @move_speed_y = i
  1415.           break
  1416.         end
  1417.       end
  1418.       before = over_distance + boost_y
  1419.       @move_speed_plus_y = (before / @moving_y).abs
  1420.       @move_y += before % @moving_y
  1421.       @battler.move_y = @move_y
  1422.     elsif @move_boost_y < 0 && @distanse_y != 0
  1423.       if @distanse_y == 0
  1424.         @move_boost_y = 0
  1425.       elsif @distanse_y < 0
  1426.         @move_boost_y *= -1
  1427.       end
  1428.       for i in 0...@move_speed_y
  1429.         boost_y += @move_boost_y
  1430.         move_y += boost_y
  1431.         lost_distance = @distanse_y - move_y
  1432.         before = lost_distance
  1433.         if @distanse_y > 0 && boost_y < 0
  1434.           @move_speed_y = i
  1435.           before = lost_distance + boost_y
  1436.           break
  1437.         elsif @distanse_y < 0 && boost_y > 0
  1438.           @move_speed_y = i
  1439.           before = lost_distance + boost_y
  1440.           break
  1441.         end
  1442.       end
  1443.       plus = before / @moving_y
  1444.       @move_speed_plus_y = plus.abs
  1445.       @move_y += before % @moving_y
  1446.       @battler.move_y = @move_y
  1447.     end
  1448.     x = @move_speed_plus_x + @move_speed_x
  1449.     y = @move_speed_plus_y + @move_speed_y
  1450.     if x > y
  1451.       end_time = x
  1452.     else
  1453.       end_time = y
  1454.     end
  1455.     @wait = end_time
  1456.     if @jump != 0
  1457.       if @wait == 0
  1458.         @wait = @active_action[3]
  1459.       end  
  1460.       @jump_time = @wait / 2
  1461.       @jump_time_plus = @wait % 2
  1462.       @jump_sign = 0
  1463.       @jump_sign2 = 0
  1464.       if @jump < 0
  1465.         @jump_sign = -1
  1466.         @jump_sign2 = 1
  1467.         @jump = @jump * -1
  1468.       else
  1469.         @jump_sign = 1
  1470.         @jump_sign2 = -1
  1471.       end
  1472.       @jump_up = 2 ** @jump * @jump_sign
  1473.       if @jump_time == 0
  1474.         @jump_up = 0
  1475.       elsif @jump_time != 1
  1476.         @jump_size = @jump_up * @jump_sign * @jump_sign2
  1477.       else
  1478.         @jump_size = @jump_up * 2 * @jump_sign * @jump_sign2
  1479.         @jump_flug = true
  1480.       end  
  1481.     end
  1482.   end
  1483.   #--------------------------------------------------------------------------
  1484.   def battler_anime
  1485.     @anime_kind  = @active_action[1]
  1486.     @anime_speed = @active_action[2]
  1487.     @anime_loop  = @active_action[3]
  1488.     @unloop_wait = @active_action[4]
  1489.     @anime_end = true
  1490.     @reverse = false
  1491.     if @weapon_R != nil && @active_action[8] != ""
  1492.       weapon_kind = ANIME[@active_action[8]]
  1493.       two_swords_flug = weapon_kind[11]
  1494.       return if two_swords_flug && [email protected]?
  1495.       return if two_swords_flug && @battler.weapons[1] == nil && @battler.actor?
  1496.       if @battler.actor? && @battler.weapons[0] == nil && !two_swords_flug
  1497.         @weapon_R.action_reset
  1498.       elsif @battler.actor? && @battler.weapons[1] == nil && two_swords_flug
  1499.         @weapon_R.action_reset
  1500.       elsif [email protected]? && @battler.weapon == 0
  1501.         @weapon_R.action_reset
  1502.       else
  1503.         @weapon_R.action_reset
  1504.         if @active_action[5] != -1
  1505.           @weapon_R.freeze(@active_action[5])
  1506.         end
  1507.         @weapon_R.weapon_graphics unless two_swords_flug
  1508.         @weapon_R.weapon_graphics(true) if two_swords_flug
  1509.         @weapon_R.weapon_action(@active_action[8],@anime_loop)
  1510.         @weapon_action = true
  1511.         @weapon_R.action
  1512.       end
  1513.     elsif @weapon_R != nil
  1514.       @weapon_R.action_reset
  1515.     end  
  1516.     @anime_end = false
  1517.     if @active_action[5] != -1 && @active_action[5] != -2
  1518.       @anime_freeze = true
  1519.       @anime_end = true
  1520.     elsif @active_action[5] == -2
  1521.       @anime_freeze = false
  1522.       @reverse = true
  1523.       @pattern = @base_width - 1
  1524.       if @weapon_action && @weapon_R != nil
  1525.         @weapon_R.action
  1526.         @weapon_R.update
  1527.       end
  1528.     else  
  1529.       @anime_freeze = false
  1530.       @pattern = 0
  1531.       if @weapon_action && @weapon_R != nil
  1532.         @weapon_R.action
  1533.         @weapon_R.update
  1534.       end
  1535.     end  
  1536.     @pattern_back = false
  1537.     @frame = @anime_speed
  1538.     @battler.move_z = @active_action[6]
  1539.     if @shadow != nil
  1540.       @shadow.visible = true if @active_action[7]
  1541.       @shadow.visible = false unless @active_action[7]
  1542.       @shadow.visible = false if @skip_shadow
  1543.     end
  1544.     file_name = ""
  1545.     unless @active_action[0] == 0
  1546.       file_name = "_" + @active_action[0].to_s
  1547.     end  
  1548.     return unless @anime_flug
  1549.     begin
  1550.       self.bitmap = RPG::Cache.character(@battler_name + file_name, @battler_hue)
  1551.     rescue
  1552.       self.bitmap = RPG::Cache.character(@battler_name, @battler_hue)
  1553.     end
  1554.     @sx = @pattern * @width
  1555.     @sy = @anime_kind * @height
  1556.     @sx = @active_action[5] * @width if @anime_freeze
  1557.     self.src_rect.set(@sx, @sy, @width, @height)
  1558.   end
  1559.   #--------------------------------------------------------------------------
  1560.   def moving_anime
  1561.     @move_anime.action_reset if @anime_moving
  1562.     @anime_moving = true
  1563.     mirror = false
  1564.     mirror = true if $back_attack
  1565.     id = @active_action[1]
  1566.     target = @active_action[2]
  1567.     x = y = mem = 0
  1568.     if target == 0
  1569.       if @target_battler == nil
  1570.         x = self.x
  1571.         y = self.y
  1572.       else
  1573.         if @target_battler[0] == nil
  1574.           x = self.x
  1575.           y = self.y
  1576.         else  
  1577.           x = @target_battler[0].position_x
  1578.           y = @target_battler[0].position_y
  1579.         end  
  1580.       end  
  1581.     elsif target == 1
  1582.       if @battler.actor?
  1583.         for target in $game_troop.enemies
  1584.           x += target.position_x
  1585.           y += target.position_y
  1586.           mem += 1
  1587.         end
  1588.         x = x / mem
  1589.         y = y / mem
  1590.       else
  1591.         for target in $game_party.actors
  1592.           x += target.position_x
  1593.           y += target.position_y
  1594.           mem += 1
  1595.         end
  1596.         x = x / mem
  1597.         y = y / mem
  1598.       end
  1599.     elsif target == 2
  1600.       if @battler.actor?
  1601.         for target in $game_party.actors
  1602.           x += target.position_x
  1603.           y += target.position_y
  1604.           mem += 1
  1605.         end
  1606.         x = x / mem
  1607.         y = y / mem
  1608.       else
  1609.         for target in $game_troop.enemies
  1610.           x += target.position_x
  1611.           y += target.position_y
  1612.           mem += 1
  1613.         end
  1614.         x = x / mem
  1615.         y = y / mem
  1616.       end
  1617.     else
  1618.       x = self.x
  1619.       y = self.y
  1620.     end  
  1621.     plus_x = @active_action[6]
  1622.     plus_y = @active_action[7]
  1623.     plus_x *= -1 if @battler.is_a?(Game_Enemy)
  1624.     distanse_x = x - self.x - plus_x
  1625.     distanse_y = y - self.y - plus_y
  1626.     type = @active_action[3]
  1627.     speed = @active_action[4]
  1628.     orbit = @active_action[5]
  1629.     if @active_action[8] == 0
  1630.       @move_anime.base_x = self.x + plus_x
  1631.       @move_anime.base_y = self.y + plus_y
  1632.     elsif @active_action[8] == 1
  1633.       @move_anime.base_x = x + plus_x
  1634.       @move_anime.base_y = y + plus_y
  1635.       distanse_y = distanse_y * -1
  1636.       distanse_x = distanse_x * -1
  1637.     else
  1638.       @move_anime.base_x = x
  1639.       @move_anime.base_y = y
  1640.       distanse_x = distanse_y = 0
  1641.     end
  1642.     if @active_action[10] == ""
  1643.       weapon = ""  
  1644.     elsif @anime_flug != true
  1645.       weapon = ""  
  1646.     else
  1647.       if @battler.actor?
  1648.         battler = $game_party.actors[@battler.index]
  1649.         weapon_id = battler.weapon_id
  1650.       else  
  1651.         battler = $game_troop.enemies[@battler.index]
  1652.         weapon_id = battler.weapon
  1653.       end  
  1654.       weapon_act = ANIME[@active_action[10]].dup if @active_action[10] != ""
  1655.       if weapon_id != 0 && weapon_act.size == 3
  1656.         weapon_file = $data_weapons[weapon_id].flying_graphic
  1657.         if weapon_file == ""
  1658.           weapon_name = $data_weapons[weapon_id].graphic
  1659.           icon_weapon = false
  1660.           if weapon_name == ""
  1661.             weapon_name = $data_weapons[weapon_id].icon_name
  1662.             icon_weapon = true
  1663.           end  
  1664.         else
  1665.           icon_weapon = false
  1666.           weapon_name = weapon_file
  1667.         end
  1668.         weapon = @active_action[10]
  1669.       elsif weapon_act.size == 3
  1670.         weapon = ""
  1671.       elsif weapon_act != nil && $data_skills[@active_battler.current_action.skill_id] != nil
  1672.         icon_weapon = false
  1673.         weapon_name = $data_skills[@battler.current_action.skill.id].flying_graphic
  1674.         weapon = @active_action[10]
  1675.       end
  1676.     end
  1677.     @move_anime.z = 1
  1678.     @move_anime.z = 1000 if @active_action[9]
  1679.     @move_anime.anime_action(id,mirror,distanse_x,distanse_y,type,speed,orbit,weapon,weapon_name,icon_weapon)
  1680.   end  
  1681.   #--------------------------------------------------------------------------
  1682.   def anime_finish
  1683.     return individual_action_end if @individual_targets.size != 0
  1684.     send_action(@active_action[0]) if @battler.active
  1685.     mirage_off if @mirage_flug
  1686.     start_action(@repeat_action) unless @non_repeat
  1687.   end  
  1688.   #--------------------------------------------------------------------------
  1689.   def collapse_action
  1690.     @non_repeat = true
  1691.     @effect_type = COLLAPSE
  1692.     @collapse_type = @battler.collapse_type unless @battler.actor?
  1693.     @battler_visible = false unless @battler.actor?
  1694.     @effect_duration = COLLAPSE_WAIT + 32 if @collapse_type == 2
  1695.     @effect_duration = 360 if @collapse_type == 3
  1696.   end  
  1697.   #--------------------------------------------------------------------------
  1698.   def normal_collapse
  1699.     if @effect_duration == 31
  1700.       $game_system.se_play($data_system.enemy_collapse_se)
  1701.       self.blend_type = 1
  1702.       self.color.set(255, 64, 64, 255)
  1703.     end
  1704.     self.opacity = 256 - (48 - @effect_duration) * 6 if @effect_duration <= 31
  1705.   end  
  1706.   #--------------------------------------------------------------------------
  1707.   def boss_collapse
  1708.     if @effect_duration == 320
  1709.       Audio.se_play("Audio/SE/124-Thunder02", 100, 80)
  1710.       self.flash(Color.new(255, 255, 255), 60)
  1711.       viewport.flash(Color.new(255, 255, 255), 20)
  1712.     end
  1713.     if @effect_duration == 290
  1714.       Audio.se_play("Audio/SE/124-Thunder02", 100, 80)
  1715.       self.flash(Color.new(255, 255, 255), 60)
  1716.       viewport.flash(Color.new(255, 255, 255), 20)
  1717.     end
  1718.     if @effect_duration == 250
  1719.       Audio.se_play("Audio/SE/049-Explosion02",100, 50)
  1720.       reset
  1721.       self.blend_type = 1
  1722.       self.color.set(255, 128, 128, 128)
  1723.     end
  1724.     if @effect_duration < 250
  1725.       self.src_rect.set(0, @effect_duration - 250, @width, @height - @shadow.bitmap.height / 2)
  1726.       self.x += 10 if @effect_duration % 2 == 0
  1727.       self.opacity = @effect_duration - 20
  1728.       return if @effect_duration < 100
  1729.       Audio.se_play("Audio/SE/049-Explosion02",100, 50) if @effect_duration % 80 == 0
  1730.     end
  1731.   end
  1732. end
Expand to see the code.

  1. #==============================================================================
  2. # Sideview Battle System Version 2.2xp
  3. #==============================================================================
  4. #==============================================================================
  5. # ■ Atoa Module
  6. #==============================================================================
  7. $atoa_script = {} if $atoa_script.nil?
  8. $atoa_script["SBS Tankentai"] = true
  9.  
  10. #==============================================================================
  11. # ■ Scene_Battle
  12. #==============================================================================
  13. class Scene_Battle
  14.   #--------------------------------------------------------------------------
  15.   include N01
  16.   #--------------------------------------------------------------------------
  17.   attr_accessor :spriteset
  18.   #--------------------------------------------------------------------------
  19.   def main
  20.     fix_weapon_init
  21.     start
  22.     create_viewport
  23.     process_transition
  24.     update_battle
  25.     terminate
  26.     fix_weapon_end
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   def start
  30.     @battle_start = true
  31.     $game_temp.in_battle = true
  32.     $game_temp.battle_turn = 0
  33.     $game_temp.battle_event_flags.clear
  34.     $game_temp.battle_abort = false
  35.     $game_temp.battle_main_phase = false
  36.     $game_temp.battleback_name = $game_map.battleback_name
  37.     $game_temp.forcing_battler = nil
  38.     $game_system.battle_interpreter.setup(nil, 0)
  39.     @troop_id = $game_temp.battle_troop_id
  40.     $game_troop.setup(@troop_id)
  41.     for enemy in $game_troop.enemies
  42.       enemy.true_immortal = enemy.immortal
  43.     end
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   def create_viewport
  47.     s1 = $data_system.words.attack
  48.     s2 = $data_system.words.skill
  49.     s3 = $data_system.words.guard
  50.     s4 = $data_system.words.item
  51.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  52.     @actor_command_window.y = 160
  53.     @actor_command_window.back_opacity = 160
  54.     @actor_command_window.active = false
  55.     @actor_command_window.visible = false
  56.     @party_command_window = Window_PartyCommand.new
  57.     @help_window = Window_Help.new
  58.     @help_window.back_opacity = 160
  59.     @help_window.visible = false
  60.     @active_battler_window = Window_NameCommand.new(@active_battler, 240, 64)
  61.     @active_battler_window.visible = false
  62.     @status_window = Window_BattleStatus.new
  63.     @message_window = Window_Message.new
  64.     @spriteset = Spriteset_Battle.new
  65.     @wait_count, @escape_ratio = 0, 50
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   def process_transition
  69.     if $data_system.battle_transition == ""
  70.       Graphics.transition(20)
  71.     else
  72.       Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition)
  73.     end
  74.     start_phase1
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   def update_battle
  78.     loop do
  79.       Graphics.update
  80.       Input.update
  81.       update
  82.       break if $scene != self
  83.     end
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   def terminate
  87.     $game_map.refresh
  88.     Graphics.freeze
  89.     @actor_command_window.dispose
  90.     @party_command_window.dispose
  91.     @help_window.dispose
  92.     @status_window.dispose
  93.     @message_window.dispose
  94.     @skill_window.dispose if @skill_window != nil
  95.     @item_window.dispose if @item_window != nil
  96.     @result_window.dispose if @result_window != nil
  97.     @spriteset.dispose
  98.     if $scene.is_a?(Scene_Title)
  99.       Graphics.transition
  100.       Graphics.freeze
  101.     end
  102.     $scene = nil if $BTEST and not $scene.is_a?(Scene_Gameover)
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   def fix_weapon_init
  106.     for member in $game_party.actors
  107.       if member.weapons[0] == nil and member.weapons[1] != nil
  108.         weapon_to_equip = member.armor1_id
  109.         member.equip(1, 0)
  110.         member.equip(0, weapon_to_equip)
  111.         member.two_swords_change = true
  112.       end
  113.     end  
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   def fix_weapon_end
  117.     for member in $game_party.actors
  118.       if member.two_swords_change
  119.         weapon_to_re_equip = member.weapon_id
  120.         member.equip(0, 0)
  121.         member.equip(1, weapon_to_re_equip)
  122.         member.two_swords_change = false
  123.       end  
  124.     end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   def update_basic
  128.     Graphics.update
  129.     Input.update
  130.     $game_system.update
  131.     $game_screen.update
  132.     @spriteset.update
  133.   end  
  134.   #--------------------------------------------------------------------------
  135.   def update_effects
  136.     for battler in $game_party.actors + $game_troop.enemies
  137.       if battler.exist?
  138.         battler_sprite = @spriteset.actor_sprites[battler.index] if battler.actor?
  139.         battler_sprite = @spriteset.enemy_sprites[battler.index] if battler.is_a?(Game_Enemy)
  140.         battler_sprite.effects_update
  141.       end
  142.     end
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   def wait(duration)
  146.     for i in 0...duration
  147.       update_basic
  148.     end
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   def pop_help(obj)
  152.     @help_window.set_text(obj, 1)
  153.     loop do
  154.       update_basic
  155.       break @help_window.visible = false if Input.trigger?(Input::C)
  156.     end
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   alias start_phase1_n01 start_phase1
  160.   def start_phase1
  161.     for member in $game_party.actors + $game_troop.enemies
  162.       member.dead_anim = member.dead? ? true : false
  163.       @spriteset.set_stand_by_action(member.actor?, member.index) unless member.dead_anim
  164.     end
  165.     start_phase1_n01
  166.     $clear_enemies_actions = false
  167.     if $preemptive
  168.       pop_help(PREEMPTIVE_ALERT)
  169.       $clear_enemies_actions = true
  170.     end
  171.     @battle_start = false unless $back_attack
  172.     return unless $back_attack
  173.     pop_help(BACK_ATTACK_ALERT)
  174.     @battle_start = false
  175.     $game_party.clear_actions
  176.     start_phase4
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   alias start_phase4_n01 start_phase4
  180.   def start_phase4
  181.     start_phase4_n01
  182.     @active_battler_window.visible = false
  183.     if $clear_enemies_actions
  184.       $clear_enemies_actions = false
  185.       $game_troop.clear_actions
  186.     end
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   def judge
  190.     if $game_party.all_dead? or $game_party.actors.size == 0
  191.       if $game_temp.battle_can_lose
  192.         $game_system.bgm_play($game_temp.map_bgm)
  193.         battle_end(2)
  194.         return true
  195.       end
  196.       $game_temp.gameover = true
  197.       return true
  198.     end
  199.     for enemy in $game_troop.enemies
  200.       return false if enemy.exist?
  201.     end
  202.     process_victory
  203.     return true
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   def update_phase2_escape
  207.     enemies_agi = enemies_number = 0
  208.     for enemy in $game_troop.enemies
  209.       if enemy.exist?
  210.         enemies_agi += enemy.agi
  211.         enemies_number += 1
  212.       end
  213.     end
  214.     enemies_agi /= [enemies_number, 1].max
  215.     actors_agi = actors_number = 0
  216.     for actor in $game_party.actors
  217.       if actor.exist?
  218.         actors_agi += actor.agi
  219.         actors_number += 1
  220.       end
  221.     end
  222.     actors_agi /= [actors_number, 1].max
  223.     @success = rand(100) < @escape_ratio * actors_agi / enemies_agi
  224.     @party_command_window.visible = false
  225.     @party_command_window.active = false
  226.     wait(2)
  227.     if @success
  228.       $game_system.se_play($data_system.escape_se)
  229.       for actor in $game_party.actors
  230.         unless actor.dead?
  231.           @spriteset.set_action(true, actor.index, actor.run_success)
  232.         end
  233.       end
  234.       pop_help(ESCAPE_SUCCESS)
  235.       $game_system.bgm_play($game_temp.map_bgm)
  236.       battle_end(1)
  237.     else
  238.       @escape_ratio += 5
  239.       $game_party.clear_actions
  240.       $game_system.se_play($data_system.escape_se)
  241.       for actor in $game_party.actors
  242.         unless actor.dead?
  243.           @spriteset.set_action(true, actor.index,actor.run_ng)
  244.         end
  245.       end
  246.       pop_help(ESCAPE_FAIL)
  247.       start_phase4
  248.     end
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   def process_victory
  252.     for enemy in $game_troop.enemies
  253.       break boss_wait = true if enemy.collapse_type == 3
  254.     end
  255.     wait(440) if boss_wait
  256.     wait(WIN_WAIT) unless boss_wait
  257.     for actor in $game_party.actors
  258.       unless actor.restriction == 4
  259.         @spriteset.set_action(true, actor.index,actor.win)
  260.       end
  261.     end
  262.     start_phase5
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   def start_phase5
  266.     @phase = 5
  267.     $game_system.me_play($game_system.battle_end_me)
  268.     $game_system.bgm_play($game_temp.map_bgm)
  269.     treasures = []
  270.     for enemy in $game_troop.enemies
  271.       gold = gold.nil? ? enemy.gold : gold + enemy.gold
  272.       treasures << treasure_drop(enemy) unless enemy.hidden
  273.     end
  274.     exp = gain_exp
  275.     treasures = treasures.compact
  276.     $game_party.gain_gold(gold)
  277.     for item in treasures
  278.       case item
  279.       when RPG::Item
  280.         $game_party.gain_item(item.id, 1)
  281.       when RPG::Weapon
  282.         $game_party.gain_weapon(item.id, 1)
  283.       when RPG::Armor
  284.         $game_party.gain_armor(item.id, 1)
  285.       end
  286.     end
  287.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  288.     @result_window.add_multi_drops if $atoa_script['Multi Drop']
  289.     @phase5_wait_count = 100
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   def treasure_drop(enemy)
  293.     if rand(100) < enemy.treasure_prob
  294.       treasure = $data_items[enemy.item_id] if enemy.item_id > 0
  295.       treasure = $data_weapons[enemy.weapon_id] if enemy.weapon_id > 0
  296.       treasure = $data_armors[enemy.armor_id] if enemy.armor_id > 0
  297.     end
  298.     return treasure
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   def gain_exp
  302.     exp = exp_gained
  303.     for i in 0...$game_party.actors.size
  304.       actor = $game_party.actors[i]
  305.       if actor.cant_get_exp? == false
  306.         last_level = actor.level
  307.         actor.exp += exp
  308.         if actor.level > last_level
  309.           @status_window.level_up(i)
  310.         end
  311.       end
  312.     end
  313.     return exp
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   def exp_gained
  317.     for enemy in $game_troop.enemies
  318.       exp = exp.nil? ? enemy.exp : exp + enemy.exp
  319.     end
  320.     if EXP_SHARE
  321.       actor_number = 0
  322.       for actor in $game_party.actors
  323.         actor_number += 1 unless actor.cant_get_exp?
  324.       end
  325.       exp = exp / [actor_number, 1].max
  326.     end
  327.     return exp
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   alias acbs_update_phase5 update_phase5
  331.   def update_phase5
  332.     @result_window.update
  333.     acbs_update_phase5
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   alias phase3_next_actor_n01 phase3_next_actor
  337.   def phase3_next_actor
  338.     if @active_battler != nil && @active_battler.inputable?
  339.       @spriteset.set_action(true, @actor_index, @active_battler.command_a)
  340.     end
  341.     @wait_count = 32 if @actor_index == $game_party.actors.size-1
  342.     phase3_next_actor_n01
  343.     if @active_battler != nil && @active_battler.inputable?
  344.       @spriteset.set_action(true, @actor_index,@active_battler.command_b)
  345.     end  
  346.   end  
  347.   #--------------------------------------------------------------------------
  348.   alias phase3_prior_actor_n01 phase3_prior_actor
  349.   def phase3_prior_actor
  350.     if @active_battler != nil && @active_battler.inputable?
  351.       @active_battler.current_action.clear
  352.       @spriteset.set_action(true, @actor_index,@active_battler.command_a)
  353.     end
  354.     phase3_prior_actor_n01
  355.     if @active_battler != nil && @active_battler.inputable?
  356.       @active_battler.current_action.clear
  357.       @spriteset.set_action(true, @actor_index,@active_battler.command_b)
  358.     end
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   alias start_phase2_n01 start_phase2
  362.   def start_phase2
  363.     @active_battler_window.visible = false
  364.     start_phase2_n01
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   alias phase3_setup_command_window_n01 phase3_setup_command_window
  368.   def phase3_setup_command_window
  369.     phase3_setup_command_window_n01
  370.     @actor_command_window.x = COMMAND_WINDOW_POSITION[0]
  371.     @actor_command_window.y = COMMAND_WINDOW_POSITION[1]
  372.     @actor_command_window.z = 2000
  373.     @actor_command_window.index = 0
  374.     @actor_command_window.back_opacity = COMMAND_OPACITY
  375.     @active_battler_window.refresh(@active_battler)
  376.     @active_battler_window.visible = true if BATTLER_NAME_WINDOW
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   alias acbs_update_phase3_basic_command_scenebattle update_phase3_basic_command
  380.   def update_phase3_basic_command
  381.     if Input.trigger?(Input::C)
  382.       case @actor_command_window.commands[@actor_command_window.index]
  383.       when $data_system.words.attack
  384.         $game_system.se_play($data_system.decision_se)
  385.         @active_battler.current_action.kind = 0
  386.         @active_battler.current_action.basic = 0
  387.         @actor_command_window.active = false
  388.         @actor_command_window.visible = false
  389.         start_enemy_select
  390.         return
  391.       when $data_system.words.item
  392.         $game_system.se_play($data_system.decision_se)
  393.         @active_battler.current_action.kind = 2
  394.         start_item_select
  395.         return
  396.       when $data_system.words.guard
  397.         $game_system.se_play($data_system.decision_se)
  398.         @active_battler.current_action.kind = 0
  399.         @active_battler.current_action.basic = 1
  400.         phase3_next_actor
  401.         return
  402.       end
  403.     end
  404.     acbs_update_phase3_basic_command_scenebattle
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   def now_action(battler = @active_battler)
  408.     return if battler.nil?
  409.     @now_action = nil
  410.     case battler.current_action.kind
  411.     when 0
  412.       @now_action = $data_weapons[battler.weapon_id] if battler.current_action.basic == 0
  413.     when 1
  414.       @now_action = $data_skills[battler.current_action.skill_id]
  415.     when 2
  416.       @now_action = $data_items[battler.current_action.item_id]
  417.     end
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   def start_enemy_select
  421.     now_action
  422.     @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2)
  423.     @enemy_arrow.help_window = @help_window
  424.     @actor_command_window.active = false
  425.     @actor_command_window.visible = false
  426.     @active_battler_window.visible = false
  427.     @status_window.visible = true
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   alias start_actor_select_n01 start_actor_select
  431.   def start_actor_select
  432.     now_action
  433.     start_actor_select_n01
  434.     @status_window.visible = true
  435.     @active_battler_window.visible = false
  436.     @actor_arrow.input_right if @now_action.extension.include?("OTHERS")
  437.   end
  438.   #--------------------------------------------------------------------------
  439.   alias update_phase3_actor_select_n01 update_phase3_actor_select
  440.   def update_phase3_actor_select
  441.     @actor_arrow.input_update_target if @now_action.extension.include?("OTHERS") and @actor_arrow.index == @active_battler.index
  442.     update_phase3_actor_select_n01
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   alias update_phase3_n01 update_phase3
  446.   def update_phase3
  447.     if @enemy_arrow_all != nil
  448.       update_phase3_select_all_enemies
  449.       return
  450.     elsif @actor_arrow_all != nil
  451.       update_phase3_select_all_actors
  452.       return
  453.     elsif @battler_arrow_all != nil
  454.       update_phase3_select_all_battlers
  455.       return
  456.     end
  457.     update_phase3_n01
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   alias update_phase3_skill_select_n01 update_phase3_skill_select
  461.   def update_phase3_skill_select
  462.     @status_window.visible = false  if HIDE_WINDOW
  463.     if Input.trigger?(Input::C)
  464.       @skill = @skill_window.skill
  465.       if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
  466.         $game_system.se_play($data_system.buzzer_se)
  467.         return
  468.       end
  469.       @active_battler.current_action.skill_id = @skill.id
  470.       @skill_window.visible = false
  471.       if @skill.extension.include?("TARGETALL")
  472.         $game_system.se_play($data_system.decision_se)
  473.         start_select_all_battlers
  474.         return
  475.       end
  476.       if (@skill.extension.include?("RANDOMTARGET") and @skill.scope <= 2) or @skill.scope == 2
  477.         $game_system.se_play($data_system.decision_se)
  478.         start_select_all_enemies
  479.         return
  480.       end
  481.       if (@skill.extension.include?("RANDOMTARGET") and @skill.scope > 2) or @skill.scope == 4
  482.         $game_system.se_play($data_system.decision_se)
  483.         start_select_all_actors
  484.         return
  485.       end
  486.     end
  487.     update_phase3_skill_select_n01
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   alias update_phase3_item_select_n01 update_phase3_item_select
  491.   def update_phase3_item_select
  492.     @status_window.visible = false if HIDE_WINDOW
  493.     if Input.trigger?(Input::C)
  494.       @item = @item_window.item
  495.       if @item == nil or not $game_party.item_can_use?(@item.id)
  496.         $game_system.se_play($data_system.buzzer_se)
  497.         return
  498.       end
  499.       @active_battler.current_action.item_id = @item.id
  500.       @item_window.visible = false
  501.       if @item.extension.include?("TARGETALL")
  502.         $game_system.se_play($data_system.decision_se)
  503.         start_select_all_battlers
  504.         return
  505.       end
  506.       if @item.extension.include?("RANDOMTARGET") and @item.scope <= 2 or @item.scope == 2
  507.         $game_system.se_play($data_system.decision_se)
  508.         start_select_all_enemies
  509.         return
  510.       end
  511.       if (@item.extension.include?("RANDOMTARGET") and @item.scope > 2) or @item.scope == 4
  512.         $game_system.se_play($data_system.decision_se)
  513.         start_select_all_actors
  514.         return
  515.       end
  516.     end
  517.     update_phase3_item_select_n01
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   def update_phase3_select_all_enemies
  521.     @enemy_arrow_all.update_multi_arrow
  522.     if Input.trigger?(Input::B)
  523.       $game_system.se_play($data_system.cancel_se)
  524.       end_select_all_enemies
  525.       return
  526.     end
  527.     if Input.trigger?(Input::C)
  528.       $game_system.se_play($data_system.decision_se)
  529.       if @skill_window != nil
  530.         end_skill_select
  531.       end
  532.       if @item_window != nil
  533.         end_item_select
  534.       end
  535.       end_select_all_enemies
  536.       phase3_next_actor
  537.       return
  538.     end
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   def update_phase3_select_all_actors
  542.     @actor_arrow_all.update_multi_arrow
  543.     if Input.trigger?(Input::B)
  544.       $game_system.se_play($data_system.cancel_se)
  545.       end_select_all_actors
  546.       return
  547.     end
  548.     if Input.trigger?(Input::C)
  549.       $game_system.se_play($data_system.decision_se)
  550.       if @skill_window != nil
  551.         end_skill_select
  552.       end
  553.       if @item_window != nil
  554.         end_item_select
  555.       end
  556.       end_select_all_actors
  557.       phase3_next_actor
  558.       return
  559.     end
  560.   end      
  561.   #--------------------------------------------------------------------------
  562.   def update_phase3_select_all_battlers
  563.     @battler_arrow_all.update_multi_arrow
  564.     if Input.trigger?(Input::B)
  565.       $game_system.se_play($data_system.cancel_se)
  566.       end_select_all_battlers
  567.       return
  568.     end
  569.     if Input.trigger?(Input::C)
  570.       $game_system.se_play($data_system.decision_se)
  571.       if @skill_window != nil
  572.         end_skill_select
  573.       end
  574.       if @item_window != nil
  575.         end_item_select
  576.       end
  577.       end_select_all_battlers
  578.       phase3_next_actor
  579.       return
  580.     end
  581.   end      
  582.   #--------------------------------------------------------------------------
  583.   def start_select_all_enemies
  584.     now_action
  585.     @status_window.visible = true
  586.     @active_battler_window.visible = false
  587.     @enemy_arrow_all = Arrow_Enemy_All.new(@spriteset.viewport2)
  588.   end
  589.   #--------------------------------------------------------------------------
  590.   def start_select_all_actors
  591.     now_action
  592.     @status_window.visible = true
  593.     @active_battler_window.visible = false
  594.     @actor_arrow_all = Arrow_Actor_All.new(@spriteset.viewport2)
  595.   end
  596.   #--------------------------------------------------------------------------
  597.   def start_select_all_battlers
  598.     now_action
  599.     @status_window.visible = true
  600.     @active_battler_window.visible = false
  601.     @battler_arrow_all = Arrow_Battler_All.new(@spriteset.viewport2)
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   def end_select_all_actors
  605.     @actor_arrow_all.dispose_multi_arrow
  606.     @actor_arrow_all = nil
  607.     @active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
  608.   end
  609.   #--------------------------------------------------------------------------
  610.   def end_select_all_enemies
  611.     @enemy_arrow_all.dispose_multi_arrow
  612.     @enemy_arrow_all = nil
  613.     @active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
  614.   end
  615.   #--------------------------------------------------------------------------
  616.   def end_select_all_battlers
  617.     @battler_arrow_all.dispose_multi_arrow
  618.     @battler_arrow_all = nil
  619.     @active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   alias end_enemy_select_n01 end_enemy_select
  623.   def end_enemy_select
  624.     end_enemy_select_n01
  625.     @active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   alias start_skill_select_n01 start_skill_select
  629.   def start_skill_select
  630.     start_skill_select_n01
  631.     @status_window.visible = false if HIDE_WINDOW
  632.     @active_battler_window.visible = false
  633.   end
  634.   #--------------------------------------------------------------------------
  635.   alias end_skill_select_n01 end_skill_select
  636.   def end_skill_select
  637.     end_skill_select_n01
  638.     @status_window.visible = true
  639.     @active_battler_window.visible = true if BATTLER_NAME_WINDOW
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   alias start_item_select_n01 start_item_select
  643.   def start_item_select
  644.     start_item_select_n01
  645.     @status_window.visible = false if HIDE_WINDOW
  646.     @active_battler_window.visible = false
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   alias end_item_select_n01 end_item_select
  650.   def end_item_select
  651.     end_item_select_n01
  652.     @status_window.visible = true
  653.     @active_battler_window.visible = true if BATTLER_NAME_WINDOW
  654.   end
  655.   #--------------------------------------------------------------------------
  656.   alias make_action_orders_n01 make_action_orders
  657.   def make_action_orders
  658.     make_action_orders_n01
  659.     for battler in @action_battlers
  660.       skill_id = battler.current_action.skill_id
  661.       item_id = battler.current_action.item_id
  662.       next if battler.current_action.kind == 0
  663.       extension = $data_skills[skill_id].extension if skill_id != 0
  664.       extension = $data_items[item_id].extension if item_id != 0
  665.       battler.current_action.speed = 9999 if extension.include?("FAST")
  666.       battler.current_action.speed = -1 if extension.include?("SLOW")
  667.     end
  668.     @action_battlers.sort! {|a,b|
  669.       b.current_action.speed - a.current_action.speed }
  670.     for enemy in $game_troop.enemies
  671.       if enemy.action_time[0] != 1
  672.         action_time = 0
  673.         for i in 1...enemy.action_time[0]
  674.           action_time += 1 if rand(100) < enemy.action_time[1]
  675.         end
  676.         enemy.act_time = action_time
  677.         action_time.times do
  678.           enemy_order_time(enemy)
  679.           action_time -= 1
  680.           break if action_time == 0
  681.         end  
  682.         enemy.adj_speed = nil
  683.       end
  684.     end
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   def enemy_order_time(enemy)
  688.     enemy.make_action_speed2(enemy.action_time[2])
  689.     select_time = 0
  690.     for member in @action_battlers
  691.       select_time += 1
  692.       break @action_battlers.push(enemy) if member.current_action.speed < enemy.adj_speed
  693.       break @action_battlers.push(enemy) if select_time == @action_battlers.size
  694.     end
  695.   end  
  696.   #--------------------------------------------------------------------------
  697.   def update_phase4_step1
  698.     return if @spriteset.effect?
  699.     return @wait_count -= 1 if @wait_count > 0
  700.     @help_window.visible = false
  701.     return if judge
  702.     if $game_temp.forcing_battler == nil
  703.       setup_battle_event
  704.        return if $game_system.battle_interpreter.running?
  705.     end
  706.     if $game_temp.forcing_battler != nil
  707.       @action_battlers.delete($game_temp.forcing_battler)
  708.       @action_battlers.unshift($game_temp.forcing_battler)
  709.     end
  710.     if @action_battlers.size == 0
  711.       turn_ending
  712.       start_phase2
  713.       return
  714.     end
  715.     @animation1_id = 0
  716.     @animation2_id = 0
  717.     @common_event_id = 0
  718.     @active_battler = @action_battlers.shift
  719.     return if @active_battler.index == nil
  720.     @active_battler.remove_states_auto
  721.     @status_window.refresh
  722.     @phase4_step = 2
  723.   end
  724.   #--------------------------------------------------------------------------
  725.   def turn_ending
  726.     for member in $game_party.actors + $game_troop.enemies
  727.       member.current_action.clear
  728.       next unless member.exist?
  729.       member.slip_damage = false
  730.       actor = member.actor?
  731.       for state in member.battler_states
  732.         member.remove_state(state.id) if state.extension.include?("ZEROTURNLIFT")
  733.       end
  734.       damage = 0
  735.       for state in member.battler_states
  736.         next unless state.extension.include?("SLIPDAMAGE")
  737.         for ext in state.slip_extension
  738.           if ext[0] == "hp"
  739.             base_damage = ext[1] + member.maxhp * ext[2] / 100
  740.             damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
  741.             slip_pop = ext[3]
  742.             slip_dead = ext[4]
  743.             slip_damage_flug = true
  744.             member.slip_damage = true
  745.           end
  746.         end  
  747.       end
  748.       if member.slip_damage && member.exist? && !slip_damage_flug
  749.         damage += member.apply_variance(member.maxhp / 10, 10)
  750.         slip_dead = false
  751.         slip_pop = true
  752.         slip_damage_flug = true
  753.         member.slip_damage = true
  754.       end
  755.       damage = member.hp - 1 if damage >= member.hp && slip_dead = false
  756.       member.hp -= damage
  757.       member.damage = damage if damage > 0
  758.       member.perform_collapse if member.dead? && member.slip_damage
  759.       @spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
  760.       @spriteset.set_stand_by_action(actor, member.index) if member.hp <= 0 and not member.dead_anim
  761.       member.dead_anim = member.dead? ? true : false
  762.     end
  763.     @status_window.refresh
  764.     wait(DMG_DURATION / 2) if slip_damage_flug
  765.     slip_damage_flug = false
  766.     for member in $game_party.actors + $game_troop.enemies
  767.       next unless member.exist?
  768.       actor = member.actor?
  769.       damage = 0
  770.       for state in member.battler_states
  771.         next unless state.extension.include?("SLIPDAMAGE")
  772.         for ext in state.slip_extension
  773.           if ext[0] == "mp"
  774.             base_damage = ext[1] + member.maxsp * ext[2] / 100
  775.             damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
  776.             slip_pop = ext[3]
  777.             slip_damage_flug = true
  778.           end
  779.         end
  780.         member.sp_damage = true
  781.         member.sp -= damage
  782.         member.damage = damage if damage > 0
  783.         @spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
  784.       end
  785.     end
  786.     @status_window.refresh
  787.     wait(DMG_DURATION / 2) if slip_damage_flug
  788.     for member in $game_party.actors + $game_troop.enemies
  789.       next unless member.exist?
  790.       actor = member.actor?
  791.       damage = 0
  792.       for state in member.battler_states
  793.         next unless state.extension.include?("REGENERATION")
  794.         for ext in state.slip_extension
  795.           if ext[0] == "hp"
  796.             base_damage = ext[1] + member.maxhp * ext[2] / 100
  797.             damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
  798.             slip_pop = ext[3]
  799.             slip_damage_flug = true
  800.           end
  801.         end
  802.         member.hp -= damage
  803.         member.damage = damage if damage < 0
  804.         @spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
  805.       end  
  806.     end
  807.     @status_window.refresh
  808.     wait(DMG_DURATION / 2) if slip_damage_flug
  809.     for member in $game_party.actors + $game_troop.enemies
  810.       next unless member.exist?
  811.       actor = member.actor?
  812.       damage = 0
  813.       for state in member.battler_states
  814.         next unless state.extension.include?("REGENERATION")
  815.         for ext in state.slip_extension
  816.           if ext[0] == "mp"
  817.             base_damage = ext[1] + member.maxhp * ext[2] / 100
  818.             damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
  819.             slip_pop = ext[3]
  820.             slip_damage_flug = true
  821.           end
  822.         end
  823.         member.sp_damage = true
  824.         member.sp -= damage  
  825.         member.damage = damage if damage < 0
  826.         @spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
  827.       end
  828.     end
  829.     @status_window.refresh
  830.     wait(DMG_DURATION / 2) if slip_damage_flug
  831.   end
  832.   #--------------------------------------------------------------------------
  833.   alias update_phase4_step2_n01 update_phase4_step2
  834.   def update_phase4_step2
  835.     for member in $game_party.actors + $game_troop.enemies
  836.       member.dead_anim = member.dead? ? true : false
  837.     end
  838.     if @active_battler.current_action.kind != 0
  839.       obj = $data_skills[@active_battler.current_action.skill_id] if @active_battler.current_action.kind == 1
  840.       obj = $data_items[@active_battler.current_action.item_id] if @active_battler.current_action.kind == 2
  841.       @active_battler.white_flash = false if obj != nil &&obj.extension.include?("NOFLASH")
  842.     end
  843.     @active_battler.active = true
  844.     update_phase4_step2_n01
  845.     if @active_battler != nil && @active_battler.derivation != 0
  846.       @active_battler.current_action.kind = 1
  847.       @active_battler.current_action.skill_id = @active_battler.derivation
  848.       @action_battlers.unshift(@active_battler)
  849.     end
  850.     if @active_battler != nil && !@active_battler.actor? && @active_battler.act_time != 0
  851.       @active_battler.make_action
  852.       @active_battler.act_time -= 1
  853.     end
  854.     update_phase4_step6
  855.   end
  856.   #--------------------------------------------------------------------------
  857.   alias update_phase4_step6_n01 update_phase4_step6
  858.   def update_phase4_step6
  859.     update_phase4_step6_n01
  860.     @active_battler.active = false if @active_battler != nil
  861.   end
  862.   #--------------------------------------------------------------------------
  863.   def make_basic_action_result
  864.     if @active_battler.current_action.basic == 0
  865.       execute_action_attack
  866.       return
  867.     end
  868.     if @active_battler.current_action.basic == 1
  869.       @help_window.set_text("#{@active_battler.name} defends", 1)
  870.       @help_window.visible = true
  871.       @active_battler.active = false
  872.       @active_battler.defense_pose = true
  873.       @spriteset.set_stand_by_action(@active_battler.actor?, @active_battler.index)
  874.       wait(45)
  875.       @help_window.visible = false
  876.       return
  877.     end
  878.     if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2
  879.       @spriteset.set_action(false, @active_battler.index, @active_battler.run_success)
  880.       $game_system.se_play($data_system.escape_se)
  881.       @active_battler.escape
  882.       pop_help("#{@active_battler.name} escaped...")
  883.       return
  884.     end
  885.     if @active_battler.current_action.basic == 3
  886.       @active_battler.active = false
  887.       $game_temp.forcing_battler = nil
  888.       @phase4_step = 1
  889.       return
  890.     end
  891.   end
  892.   #--------------------------------------------------------------------------
  893.   def execute_action_attack
  894.     if @active_battler.actor?
  895.       if @active_battler.weapon_id == 0
  896.         action = @active_battler.non_weapon
  897.         immortaling
  898.       else  
  899.         action = $data_weapons[@active_battler.weapon_id].base_action
  900.         if $data_weapons[@active_battler.weapon_id].plus_state_set.include?(1)
  901.           for member in $game_party.actors + $game_troop.enemies
  902.             next if member.immortal
  903.             next if member.dead?
  904.             member.dying = true
  905.           end
  906.         else
  907.           immortaling
  908.         end
  909.       end  
  910.     else
  911.       if @active_battler.weapon == 0
  912.         action = @active_battler.base_action
  913.         immortaling
  914.       else
  915.         action = $data_weapons[@active_battler.weapon].base_action
  916.         if $data_weapons[@active_battler.weapon].plus_state_set.include?(1)
  917.           for member in $game_party.actors + $game_troop.enemies
  918.             next if member.immortal
  919.             next if member.dead?
  920.             member.dying = true
  921.           end
  922.         else
  923.           immortaling
  924.         end
  925.       end  
  926.     end
  927.     target_decision
  928.     @spriteset.set_action(@active_battler.actor?, @active_battler.index, action)
  929.     playing_action
  930.   end
  931.   #--------------------------------------------------------------------------
  932.   def make_attack_targets
  933.     @target_battlers = []
  934.     if @active_battler.is_a?(Game_Enemy)
  935.       if @active_battler.restriction == 3
  936.         target = $game_troop.random_target_enemy
  937.       elsif @active_battler.restriction == 2
  938.         target = $game_party.random_target_actor
  939.       else
  940.         index = @active_battler.current_action.target_index
  941.         target = $game_party.smooth_target_actor(index)
  942.       end
  943.     end
  944.     if @active_battler.actor?
  945.       if @active_battler.restriction == 3
  946.         target = $game_party.random_target_actor
  947.       elsif @active_battler.restriction == 2
  948.         target = $game_troop.random_target_enemy
  949.       else
  950.         index = @active_battler.current_action.target_index
  951.         target = $game_troop.smooth_target_enemy(index)
  952.       end
  953.     end
  954.     @target_battlers = [target]
  955.     return @target_battlers
  956.   end
  957.   #--------------------------------------------------------------------------
  958.   def make_skill_action_result
  959.     skill = $data_skills[@active_battler.current_action.skill_id]
  960.     if skill.plus_state_set.include?(1)
  961.       for member in $game_party.actors + $game_troop.enemies
  962.         next if member.immortal
  963.         next if member.dead?
  964.         member.dying = true
  965.       end
  966.     else
  967.       immortaling
  968.     end
  969.     return unless @active_battler.skill_can_use?(skill.id)
  970.     target_decision(skill)
  971.     @active_battler.consum_skill_cost(skill)
  972.     @status_window.refresh
  973.     @spriteset.set_action(@active_battler.actor?, @active_battler.index, skill.base_action)
  974.     @help_window.set_text(skill.name, 1) unless skill.extension.include?("HELPHIDE")
  975.     playing_action
  976.     @common_event_id = skill.common_event_id
  977.   end
  978.   #--------------------------------------------------------------------------
  979.   def make_item_action_result
  980.     item = $data_items[@active_battler.current_action.item_id]
  981.     unless $game_party.item_can_use?(item.id)
  982.       @phase4_step = 1
  983.       return
  984.     end
  985.     if @item.consumable
  986.       $game_party.lose_item(item.id, 1)
  987.     end
  988.     immortaling
  989.     target_decision(item)
  990.     @spriteset.set_action(@active_battler.actor?, @active_battler.index, item.base_action)
  991.     @help_window.set_text(item.name, 1) unless item.extension.include?("HELPHIDE")
  992.     playing_action
  993.     @common_event_id = item.common_event_id
  994.   end
  995.   #--------------------------------------------------------------------------
  996.   def target_decision(obj = nil)
  997.     if obj != nil
  998.       set_target_battlers(obj.scope)
  999.       if obj.extension.include?("TARGETALL")
  1000.         @target_battlers = []
  1001.         if obj.scope != 5 or obj.scope != 6
  1002.           for target in $game_troop.enemies + $game_party.actors
  1003.             @target_battlers.push(target) if target.exist?
  1004.           end
  1005.         else
  1006.           for target in $game_troop.enemies + $game_party.actors
  1007.             @target_battlers.push(target) if target != nil && target.hp0?
  1008.           end
  1009.         end
  1010.       end
  1011.       @target_battlers.delete(@active_battler) if obj.extension.include?("OTHERS")
  1012.       if obj.extension.include?("RANDOMTARGET")
  1013.         randum_targets = @target_battlers.dup
  1014.         @target_battlers = [randum_targets[rand(randum_targets.size)]]
  1015.       end
  1016.     else
  1017.       @target_battlers = make_attack_targets
  1018.     end
  1019.     if @target_battlers.size == 0
  1020.       action = @active_battler.recover_action
  1021.       @spriteset.set_action(@active_battler.actor?, @active_battler.index, action)
  1022.     end
  1023.     @spriteset.set_target(@active_battler.actor?, @active_battler.index, @target_battlers)
  1024.   end  
  1025.   #--------------------------------------------------------------------------
  1026.   def playing_action
  1027.     loop do
  1028.       update_basic
  1029.       update_effects
  1030.       action = @active_battler.play
  1031.       next if action == 0
  1032.       @active_battler.play = 0
  1033.       if action[0] == "Individual"
  1034.         individual
  1035.       elsif action == "Can Collapse"
  1036.         unimmortaling
  1037.       elsif action == "Cancel Action"
  1038.         break action_end
  1039.       elsif action == "End"
  1040.         break action_end
  1041.       elsif action[0] == "OBJ_ANIM"
  1042.         damage_action(action[1])
  1043.       end
  1044.     end
  1045.   end
  1046.   #--------------------------------------------------------------------------
  1047.   def individual
  1048.     @individual_target = @target_battlers
  1049.     @stand_by_target = @target_battlers.dup
  1050.   end
  1051.   #--------------------------------------------------------------------------
  1052.   def immortaling
  1053.     for member in $game_party.actors + $game_troop.enemies
  1054.       member.immortal = true unless member.dead?
  1055.     end  
  1056.   end  
  1057.   #--------------------------------------------------------------------------
  1058.   def unimmortaling
  1059.     return if @active_battler.individual
  1060.     for member in $game_party.actors + $game_troop.enemies
  1061.       member.immortal = false
  1062.       member.add_state(1) if member.dead?
  1063.       if member.dead? and not member.dead_anim
  1064.         member.perform_collapse
  1065.         @spriteset.set_stand_by_action(member.actor?, member.index)
  1066.       end
  1067.       member.dead_anim = member.dead? ? true : false
  1068.       next unless member.dead?
  1069.       resurrection(member)
  1070.     end
  1071.     update_basic
  1072.     @status_window.refresh
  1073.   end
  1074.   #--------------------------------------------------------------------------
  1075.   def resurrection(target)
  1076.     for state in target.battler_states
  1077.       for ext in state.extension
  1078.         name = ext.split('')
  1079.         next unless name[0] == "A"
  1080.         wait(25)
  1081.         name = name.join
  1082.         name.slice!("AUTOLIFE/")
  1083.         target.hp = target.maxhp * name.to_i / 100
  1084.         target.remove_state(1)
  1085.         target.remove_state(state.id)
  1086.         target.animation_id = RESURRECTION
  1087.         target.animation_hit = true
  1088.         target.anime_mirror = true if $back_attack
  1089.         @status_window.refresh
  1090.         wait($data_animations[RESURRECTION].frame_max * 2)
  1091.       end  
  1092.     end
  1093.   end
  1094.   #--------------------------------------------------------------------------
  1095.   def magic_reflection(target, obj)
  1096.     return if obj != nil and $data_skills[@active_battler.current_action.skill_id].int_f == 0
  1097.     for state in target.battler_states
  1098.       for ext in state.extension
  1099.         name = ext.split('')
  1100.         next unless name[0] == "M"
  1101.         if name[3] == "R"
  1102.           name = name.join
  1103.           name.slice!("MAGREFLECT/")
  1104.           target.animation_id = name.to_i
  1105.           target.animation_hit = true
  1106.           target.anime_mirror = true if $back_attack
  1107.           @reflection = true
  1108.         else
  1109.           name = name.join
  1110.           name.slice!("MAGNULL/")
  1111.           target.animation_id = name.to_i
  1112.           target.animation_hit = true
  1113.           target.anime_mirror = true if $back_attack
  1114.           @invalid = true
  1115.         end  
  1116.       end  
  1117.     end
  1118.   end
  1119.   #--------------------------------------------------------------------------
  1120.   def physics_reflection(target, obj)
  1121.     return if obj != nil && $data_skills[@active_battler.current_action.skill_id].str_f == 0
  1122.     for state in target.battler_states
  1123.       for ext in state.extension
  1124.         name = ext.split('')
  1125.         next unless name[0] == "P"
  1126.         if name[3] == "R"
  1127.           name = name.join
  1128.           name.slice!("PHYREFLECT/")
  1129.           target.animation_id = name.to_i
  1130.           target.animation_hit = true
  1131.           target.anime_mirror = true if $back_attack
  1132.           @reflection = true
  1133.         else
  1134.           name = name.join
  1135.           name.slice!("PHYNULL/")
  1136.           target.animation_id = name.to_i
  1137.           target.animation_hit = true
  1138.           target.anime_mirror = true if $back_attack
  1139.           @invalid = true
  1140.         end
  1141.       end  
  1142.     end
  1143.   end
  1144.   #--------------------------------------------------------------------------
  1145.   def absorb_cost(target, obj)
  1146.     for state in target.battler_states
  1147.       if state.extension.include?("COSTABSORB")
  1148.         cost = @active_battler.calc_sp_cost(@active_battler, obj)
  1149.         return target.hp += cost if obj.extension.include?("HPCONSUME")
  1150.         return target.mp += cost
  1151.       end  
  1152.     end
  1153.   end
  1154.   #--------------------------------------------------------------------------
  1155.   def absorb_attack(obj, target, index, actor)
  1156.     for ext in obj.extension
  1157.       return if target.evaded or target.missed or target.damage == 0 or target.damage == nil
  1158.       name = ext.split('')
  1159.       next unless name[3] == "G" and name[1] == "D"
  1160.       name = name.join
  1161.       name.slice!("%DMGABSORB/")
  1162.       kind = "hp" unless target.sp_damage
  1163.       kind = "sp" if target.sp_damage
  1164.       absorb = target.damage * name.to_i / 100
  1165.       @wide_attack = true if obj.scope == 2 or obj.scope == 4 or obj.scope == 6 or obj.extension.include?("TARGETALL")
  1166.       if @wide_attack && @absorb == nil && @target_battlers.size != 1
  1167.         @absorb = absorb
  1168.         @absorb_target_size = @target_battlers.size - 2
  1169.       elsif @absorb != nil && @absorb_target_size > 0
  1170.         @absorb += absorb
  1171.         @absorb_target_size -= 1
  1172.       elsif @absorb != nil
  1173.         @absorb += absorb
  1174.         absorb_action = ["absorb", nil, kind, @absorb]
  1175.         @spriteset.set_damage_action(actor, index, absorb_action)
  1176.         @absorb = nil
  1177.         @absorb_target_size = nil
  1178.         @active_battler.perform_collapse
  1179.       else
  1180.         absorb_action = ["absorb", nil, kind, absorb]
  1181.         @spriteset.set_damage_action(actor, index, absorb_action)
  1182.         @active_battler.perform_collapse
  1183.       end  
  1184.     end
  1185.   end  
  1186.   #--------------------------------------------------------------------------
  1187.   def action_end
  1188.     @individual_target = nil
  1189.     @help_window.visible = false if @help_window != nil && @help_window.visible
  1190.     @active_battler.active = false
  1191.     unimmortaling
  1192.     for member in $game_troop.enemies
  1193.       member.non_dead = false if member.non_dead
  1194.     end
  1195.     if @active_battler.reflex != nil
  1196.       if @active_battler.current_action.kind == 1
  1197.         obj = $data_skills[@active_battler.current_action.skill_id]
  1198.         @active_battler.perfect_skill_effect(@active_battler, obj)
  1199.       elsif @active_battler.current_action.kind == 2
  1200.         obj = $data_items[@active_battler.current_action.item_id]
  1201.         @active_battler.item_effect(@active_battler, obj)
  1202.       else
  1203.         @active_battler.perfect_attack_effect(@active_battler)
  1204.       end
  1205.       pop_damage(@active_battler, obj, @active_battler.reflex)
  1206.       @active_battler.perform_collapse
  1207.       @active_battler.reflex = nil
  1208.       wait(COLLAPSE_WAIT)
  1209.     end
  1210.     if @active_battler.derivation != 0
  1211.       @active_battler.current_action.skill_id = @active_battler.derivation
  1212.       @active_battler.current_action.kind = 1
  1213.       @active_battler.derivation = 0
  1214.       @action_battlers.unshift(@active_battler)
  1215.     else
  1216.       @spriteset.set_stand_by_action(@active_battler.actor?, @active_battler.index)
  1217.       wait(ACTION_WAIT + 20)
  1218.     end
  1219.   end  
  1220.   #--------------------------------------------------------------------------
  1221.   def damage_action(action)
  1222.     @target_battlers = [@individual_target.shift] if @active_battler.individual
  1223.     if @active_battler.current_action.kind == 1
  1224.       obj = $data_skills[@active_battler.current_action.skill_id]
  1225.       for target in @target_battlers
  1226.         return if target == nil
  1227.         if obj.scope == 5 or obj.scope == 6
  1228.           return unless target.dead?
  1229.         else
  1230.           return if target.dead?
  1231.         end
  1232.         if target.hp == 0 && obj.scope != 5 && obj.scope != 6
  1233.           target.perfect_skill_effect(@active_battler, obj)
  1234.         elsif obj.extension.include?("NOEVADE")
  1235.           target.perfect_skill_effect(@active_battler, obj)
  1236.         else
  1237.           magic_reflection(target, obj) unless obj.extension.include?("IGNOREREFLECT")
  1238.           physics_reflection(target, obj) unless obj.extension.include?("IGNOREREFLECT")
  1239.           target.skill_effect(@active_battler, obj) unless @reflection or @invalid
  1240.         end
  1241.         pop_damage(target, obj, action) unless @reflection or @invalid
  1242.         absorb_cost(target, obj)
  1243.         @active_battler.reflex = action if @reflection
  1244.         @reflection = false
  1245.         @invalid = false
  1246.       end
  1247.     elsif @active_battler.current_action.kind == 2
  1248.       obj = $data_items[@active_battler.current_action.item_id]
  1249.       for target in @target_battlers
  1250.         return if target == nil
  1251.         if obj.scope == 5 or obj.scope == 6
  1252.           return unless target.dead?
  1253.         else
  1254.           return if target.dead?
  1255.         end
  1256.         target.revival = true if obj.scope == 5 or obj.scope == 6
  1257.         target.item_effect(obj)
  1258.         pop_damage(target, obj, action)
  1259.       end
  1260.     else
  1261.       for target in @target_battlers
  1262.         return if target == nil or target.dead?
  1263.         physics_reflection(target, nil)
  1264.         target.perfect_attack_effect(@active_battler) if target.hp <= 0
  1265.         target.attack_effect(@active_battler) unless target.hp <= 0 unless @reflection or @invalid
  1266.         pop_damage(target, obj, action) unless @reflection or @invalid
  1267.         @active_battler.reflex = action if @reflection
  1268.         @reflection = false
  1269.         @invalid = false
  1270.       end
  1271.     end
  1272.     return if obj == nil
  1273.     target_decision(obj) if obj.extension.include?("RANDOMTARGET")
  1274.   end
  1275.   #--------------------------------------------------------------------------
  1276.   def pop_damage(target, obj, action)
  1277.     index = @active_battler.index
  1278.     actor = @active_battler.actor?
  1279.     if obj != nil && obj.extension.size != 0
  1280.       absorb_attack(obj, target, index, actor)
  1281.       action[2] = false if obj.extension.include?("NOOVERKILL")
  1282.     end
  1283.     @spriteset.set_damage_action(target.actor?, target.index, action)
  1284.     @status_window.refresh
  1285.   end
  1286. end  
  1287.  
  1288. #==============================================================================
  1289. # ■ Scene_Map
  1290. #==============================================================================
  1291. class Scene_Map
  1292.   #--------------------------------------------------------------------------
  1293.   include N01
  1294.   #--------------------------------------------------------------------------
  1295.   alias call_battle_n01 call_battle
  1296.   #--------------------------------------------------------------------------
  1297.   def call_battle
  1298.     $back_attack = $preemptive = false
  1299.     preemptive_or_back_attack
  1300.     call_battle_n01
  1301.   end
  1302.   #--------------------------------------------------------------------------
  1303.   def preemptive_or_back_attack  
  1304.     enemies_agi = 0
  1305.     for enemy in $game_troop.enemies
  1306.       enemies_agi += enemy.agi
  1307.     end
  1308.     enemies_agi /= [$game_troop.enemies.size, 1].max
  1309.     actors_agi = 0
  1310.     for actor in $game_party.actors
  1311.       actors_agi += actor.agi
  1312.     end
  1313.     actors_agi /= [$game_party.actors.size, 1].max
  1314.     preemptive_plus
  1315.     if actors_agi >= enemies_agi
  1316.       percent_preemptive = PREEMPTIVE_RATE * ($preemptive_plus ? 3 : 1)
  1317.       percent_back_attack = BACK_ATTACK_RATE / 2
  1318.     else
  1319.       percent_preemptive = (PREEMPTIVE_RATE / 2) * ($preemptive_plus ? 3 : 1)
  1320.       percent_back_attack = BACK_ATTACK_RATE
  1321.     end
  1322.     if rand(100) < percent_preemptive
  1323.       $preemptive = true
  1324.     elsif rand(100) < percent_back_attack
  1325.       $back_attack = true
  1326.     end
  1327.     special_back_attack_conditions
  1328.     special_preemptive_conditions
  1329.     $preemptive = false if $back_attack or !PREEMPTIVE
  1330.     $back_attack = false if !BACK_ATTACK
  1331.   end
  1332.   #--------------------------------------------------------------------------
  1333.   def special_back_attack_conditions
  1334.     for i in 0...BACK_ATTACK_SWITCH.size
  1335.       return $back_attack = true if $game_switches[BACK_ATTACK_SWITCH[i]]
  1336.     end
  1337.     for i in 0...NO_BACK_ATTACK_SWITCH.size
  1338.       return $back_attack = false if $game_switches[NON_BACK_ATTACK_SWITCH[i]]
  1339.     end
  1340.     for actor in $game_party.actors
  1341.       return $back_attack = false if NON_BACK_ATTACK_WEAPONS.include?(actor.weapon_id)
  1342.       return $back_attack = false if NON_BACK_ATTACK_ARMOR1.include?(actor.armor1_id)
  1343.       return $back_attack = false if NON_BACK_ATTACK_ARMOR2.include?(actor.armor2_id)
  1344.       return $back_attack = false if NON_BACK_ATTACK_ARMOR3.include?(actor.armor3_id)
  1345.       return $back_attack = false if NON_BACK_ATTACK_ARMOR4.include?(actor.armor4_id)
  1346.       for i in 0...NON_BACK_ATTACK_SKILLS.size
  1347.         return $back_attack = false if actor.skill_id_learn?(NON_BACK_ATTACK_SKILLS[i])
  1348.       end  
  1349.     end
  1350.   end
  1351.   #--------------------------------------------------------------------------
  1352.   def special_preemptive_conditions
  1353.     for i in 0...PREEMPTIVE_SWITCH.size
  1354.       return $preemptive = true if $game_switches[PREEMPTIVE_SWITCH[i]]
  1355.     end
  1356.     for i in 0...NO_PREEMPTIVE_SWITCH.size
  1357.       return $preemptive = false if $game_switches[NON_PREEMPTIVE_SWITCH[i]]
  1358.     end
  1359.   end
  1360.   #--------------------------------------------------------------------------
  1361.   def preemptive_plus
  1362.     $preemptive_plus = false
  1363.     for actor in $game_party.actors
  1364.      return $preemptive_plus = true if PREEMPTIVE_WEAPONS.include?(actor.weapon_id)
  1365.      return $preemptive_plus = true if PREEMPTIVE_ARMOR1.include?(actor.armor1_id)
  1366.      return $preemptive_plus = true if PREEMPTIVE_ARMOR2.include?(actor.armor2_id)
  1367.      return $preemptive_plus = true if PREEMPTIVE_ARMOR3.include?(actor.armor3_id)
  1368.      return $preemptive_plus = true if PREEMPTIVE_ARMOR4.include?(actor.armor4_id)
  1369.       for i in 0...PREEMPTIVE_SKILLS.size
  1370.         return $preemptive_plus = true if actor.skill_id_learn?(PREEMPTIVE_SKILLS[i])
  1371.       end  
  1372.     end
  1373.   end
  1374. end
  1375.  
  1376. #==============================================================================
  1377. # ■ Spriteset_Battle
  1378. #==============================================================================
  1379. class Spriteset_Battle
  1380.   #--------------------------------------------------------------------------
  1381.   attr_reader   :viewport1                
  1382.   attr_reader   :viewport2              
  1383.   attr_accessor :actor_sprites
  1384.   attr_accessor :enemy_sprites
  1385.   #--------------------------------------------------------------------------
  1386.   include N01
  1387.   #--------------------------------------------------------------------------
  1388.   def initialize
  1389.     @viewport1 = Viewport.new(0, 0, 640, 480)
  1390.     @viewport2 = Viewport.new(0, 0, 640, 480)
  1391.     @viewport3 = Viewport.new(0, 0, 640, 480)
  1392.     @viewport4 = Viewport.new(0, 0, 640, 480)
  1393.     @viewport2.z = 101
  1394.     @viewport3.z = 200
  1395.     @viewport4.z = 5000
  1396.     @battleback_sprite = Sprite.new(@viewport1)
  1397.     @battleback_sprite.mirror = true if $back_attack && BACK_ATTACK_BATTLE_BACK_MIRROR
  1398.     @enemy_sprites = []
  1399.     for enemy in $game_troop.enemies
  1400.       @enemy_sprites.push(Sprite_Battler.new(@viewport2, enemy))
  1401.     end
  1402.     @actor_sprites = []
  1403.     for i in 0...$game_party.actors.size
  1404.       @actor_sprites.push(Sprite_Battler.new(@viewport2, $game_party.actors[i]))
  1405.     end
  1406.     @weather = RPG::Weather.new(@viewport1)
  1407.     @picture_sprites = []
  1408.     for i in 51..100
  1409.       @picture_sprites.push(Sprite_Picture.new(@viewport3, $game_screen.pictures[i]))
  1410.     end
  1411.     @timer_sprite = Sprite_Timer.new
  1412.     update
  1413.   end
  1414.   #--------------------------------------------------------------------------
  1415.   def update
  1416.     if $game_party.actors.size > @actor_sprites.size
  1417.       for i in @actor_sprites.size...$game_party.actors.size
  1418.         @actor_sprites.push(Sprite_Battler.new(@viewport2, $game_party.actors[i]))
  1419.       end
  1420.     elsif @actor_sprites.size > $game_party.actors.size
  1421.       for i in 0...@actor_sprites.size
  1422.         @actor_sprites[i].dispose
  1423.       end
  1424.       @actor_sprites = []
  1425.       for i in 0...$game_party.actors.size
  1426.         @actor_sprites.push(Sprite_Battler.new(@viewport2, $game_party.actors[i]))
  1427.       end
  1428.     end
  1429.     for i in 0...$game_party.actors.size
  1430.       @actor_sprites[i].battler = $game_party.actors[i]
  1431.     end
  1432.     if @battleback_name != $game_temp.battleback_name
  1433.       @battleback_name = $game_temp.battleback_name
  1434.       if @battleback_sprite.bitmap != nil
  1435.         @battleback_sprite.bitmap.dispose
  1436.       end
  1437.       @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  1438.       @battleback_sprite.src_rect.set(0, 0, 640, 480)
  1439.     end
  1440.     for sprite in @enemy_sprites + @actor_sprites
  1441.       sprite.update
  1442.     end
  1443.     @weather.type = $game_screen.weather_type
  1444.     @weather.max = $game_screen.weather_max
  1445.     @weather.update
  1446.     for sprite in @picture_sprites
  1447.       sprite.update
  1448.     end
  1449.     @timer_sprite.update
  1450.     @viewport1.tone = $game_screen.tone
  1451.     @viewport1.ox = $game_screen.shake
  1452.     @viewport2.tone = $game_screen.tone
  1453.     @viewport2.ox = $game_screen.shake
  1454.     @viewport4.color = $game_screen.flash_color
  1455.     @viewport1.update
  1456.     @viewport2.update
  1457.     @viewport4.update
  1458.   end
  1459.   #--------------------------------------------------------------------------
  1460.   def set_damage_action(actor, index, action)
  1461.     return if index.nil?
  1462.     @actor_sprites[index].damage_action(action) if actor
  1463.     @enemy_sprites[index].damage_action(action) unless actor
  1464.   end
  1465.   #--------------------------------------------------------------------------
  1466.   def set_damage_pop(actor, index, damage)
  1467.     return if index.nil?
  1468.     @actor_sprites[index].damage_pop if actor
  1469.     @enemy_sprites[index].damage_pop unless actor
  1470.   end
  1471.   #--------------------------------------------------------------------------
  1472.   def set_target(actor, index, target)
  1473.     return if index.nil?
  1474.     @actor_sprites[index].get_target(target) if actor
  1475.     @enemy_sprites[index].get_target(target) unless actor
  1476.   end
  1477.   #--------------------------------------------------------------------------
  1478.   def set_action(actor, index, kind)
  1479.     return if index.nil?
  1480.     @actor_sprites[index].start_action(kind) if actor
  1481.     @enemy_sprites[index].start_action(kind) unless actor
  1482.   end  
  1483.   #--------------------------------------------------------------------------
  1484.   def set_stand_by_action(actor, index)
  1485.     return if index.nil?
  1486.     @actor_sprites[index].push_stand_by if actor
  1487.     @enemy_sprites[index].push_stand_by unless actor
  1488.   end
  1489. end
  1490.  
  1491. #==============================================================================
  1492. # ■ Sprite_MoveAnime
  1493. #==============================================================================
  1494. class Sprite_MoveAnime < RPG::Sprite
  1495.   #--------------------------------------------------------------------------
  1496.   attr_accessor :battler
  1497.   attr_accessor :base_x
  1498.   attr_accessor :base_y
  1499.   #--------------------------------------------------------------------------
  1500.   def initialize(viewport,battler = nil)
  1501.     super(viewport)
  1502.     @battler = battler
  1503.     self.visible = false
  1504.     @base_x = 0
  1505.     @base_y = 0
  1506.     @move_x = 0
  1507.     @move_y = 0
  1508.     @moving_x = 0
  1509.     @moving_y = 0
  1510.     @orbit = 0
  1511.     @orbit_plus = 0
  1512.     @orbit_time = 0
  1513.     @through = false
  1514.     @finish = false
  1515.     @time = 0
  1516.     @angle = 0
  1517.     @angling = 0
  1518.   end
  1519.   #--------------------------------------------------------------------------
  1520.   def anime_action(id,mirror,distanse_x,distanse_y,type,speed,orbit,weapon,icon_index,icon_weapon)
  1521.     @time = speed
  1522.     @moving_x = distanse_x / speed
  1523.     @moving_y = distanse_y / speed
  1524.     @through = true if type == 1
  1525.     @orbit_plus = orbit
  1526.     @orbit_time = @time
  1527.     if weapon != ""
  1528.       action = ANIME[weapon].dup
  1529.       @angle = action[0]
  1530.       end_angle = action[1]
  1531.       time = action[2]
  1532.       @angling = (end_angle - @angle)/ time
  1533.       self.angle = @angle
  1534.       self.mirror = mirror
  1535.       if icon_weapon
  1536.         self.bitmap = RPG::Cache.icon(icon_index)
  1537.         self.ox = 12
  1538.         self.oy = 12
  1539.       else
  1540.         self.bitmap = RPG::Cache.character(icon_index, 0)
  1541.         self.ox = self.bitmap.width / 2
  1542.         self.oy = self.bitmap.height / 2
  1543.       end  
  1544.       self.visible = true
  1545.       self.z = 1000
  1546.     end  
  1547.     self.x = @base_x + @move_x
  1548.     self.y = @base_y + @move_y + @orbit
  1549.     if id != 0 && !icon_weapon
  1550.       animation($data_animations[id],true)
  1551.     elsif id != 0 && icon_weapon
  1552.       loop_animation($data_animations[id])
  1553.     end
  1554.   end  
  1555.   #--------------------------------------------------------------------------  
  1556.   def action_reset
  1557.     @moving_x = @moving_y = @move_x = @move_y = @base_x = @base_y = @orbit = 0
  1558.     @orbit_time = @angling = @angle = 0    
  1559.     @through = self.visible = @finish = false
  1560.     dispose_animation
  1561.   end  
  1562.   #--------------------------------------------------------------------------
  1563.   def finish?
  1564.     return @finish
  1565.   end
  1566.   #--------------------------------------------------------------------------
  1567.   def update
  1568.     super
  1569.     @time -= 1
  1570.     if @time >= 0
  1571.       @move_x += @moving_x
  1572.       @move_y += @moving_y
  1573.       if @time < @orbit_time / 2
  1574.         @orbit_plus = @orbit_plus * 5 / 4
  1575.       elsif @time == @orbit_time / 2
  1576.         @orbit_plus *= -1
  1577.       else
  1578.         @orbit_plus = @orbit_plus * 2 / 3
  1579.       end  
  1580.       @orbit += @orbit_plus
  1581.     end    
  1582.     @time = 100 if @time < 0 && @through
  1583.     @finish = true if @time < 0 && !@through
  1584.     self.x = @base_x + @move_x
  1585.     self.y = @base_y + @move_y + @orbit
  1586.     if self.x < -200 or self.x > 840 or self.y < -200 or self.y > 680
  1587.       @finish = true
  1588.     end
  1589.     if self.visible
  1590.       @angle += @angling
  1591.       self.angle = @angle
  1592.     end  
  1593.   end
  1594. end
  1595.  
  1596. #==============================================================================
  1597. # ■ Sprite_Weapon
  1598. #==============================================================================
  1599. class Sprite_Weapon < RPG::Sprite
  1600.   #--------------------------------------------------------------------------
  1601.   include N01
  1602.   #--------------------------------------------------------------------------
  1603.   attr_accessor :battler
  1604.   #--------------------------------------------------------------------------
  1605.   def initialize(viewport,battler = nil)
  1606.     super(viewport)
  1607.     @battler = battler
  1608.     @action = []
  1609.     @move_x = 0
  1610.     @move_y = 0
  1611.     @move_z = 0
  1612.     @plus_x = 0
  1613.     @plus_y = 0
  1614.     @angle = 0
  1615.     @zoom_x = 1
  1616.     @zoom_y = 1
  1617.     @moving_x = 0
  1618.     @moving_y = 0
  1619.     @angling = 0
  1620.     @zooming_x = 1
  1621.     @zooming_y = 1
  1622.     @freeze = -1
  1623.     @mirroring = false
  1624.     @time = ANIME_PATTERN + 1
  1625.     weapon_graphics
  1626.   end
  1627.   #--------------------------------------------------------------------------
  1628.   def dispose
  1629.     self.bitmap.dispose if self.bitmap != nil
  1630.     super
  1631.   end
  1632.   #--------------------------------------------------------------------------
  1633.   def weapon_graphics(left = false)
  1634.     if @battler.actor?
  1635.       weapon = @battler.weapons[0] unless left
  1636.       weapon = @battler.weapons[1] if left
  1637.     else
  1638.       weapon = $data_weapons[@battler.weapon]
  1639.       @mirroring = true if @battler.action_mirror
  1640.     end
  1641.     return if weapon == nil
  1642.     if weapon.graphic == ""
  1643.       self.bitmap = RPG::Cache.icon(weapon.icon_name)
  1644.       @weapon_width = @weapon_height = 24
  1645.     else
  1646.       self.bitmap = RPG::Cache.icon(weapon.graphic)
  1647.       @weapon_width = self.bitmap.width
  1648.       @weapon_height = self.bitmap.height
  1649.     end
  1650.   end
  1651.   #--------------------------------------------------------------------------
  1652.   def freeze(action)
  1653.     @freeze = action
  1654.   end
  1655.   #--------------------------------------------------------------------------
  1656.   def weapon_action(action,loop)
  1657.     if action == ""
  1658.       self.visible = false
  1659.     elsif @weapon_id == 0
  1660.       self.visible = false
  1661.     else
  1662.       @action = ANIME[action]
  1663.       act0 = @action[0]
  1664.       act1 = @action[1]
  1665.       act2 = @action[2]
  1666.       act3 = @action[3]
  1667.       act4 = @action[4]
  1668.       act5 = @action[5]
  1669.       act6 = @action[6]
  1670.       act7 = @action[7]
  1671.       act8 = @action[8]
  1672.       act9 = @action[9]
  1673.       act10 = @action[10]
  1674.       if @mirroring
  1675.         act0 *= -1
  1676.         act3 *= -1
  1677.         act4 *= -1
  1678.         act9 *= -1
  1679.       end
  1680.       if $back_attack && BACK_ATTACK
  1681.         act0 *= -1
  1682.         act3 *= -1
  1683.         act4 *= -1
  1684.         act9 *= -1
  1685.       end
  1686.       time = ANIME_PATTERN
  1687.       if act2
  1688.         self.z = @battler.position_z + 1
  1689.       else
  1690.         self.z = @battler.position_z - 1
  1691.       end
  1692.       if act6
  1693.         if self.mirror
  1694.           self.mirror = false
  1695.         else
  1696.           self.mirror = true
  1697.         end
  1698.       end
  1699.       if @mirroring
  1700.         if self.mirror
  1701.           self.mirror = false
  1702.         else
  1703.           self.mirror = true
  1704.         end
  1705.       end
  1706.       if $back_attack && BACK_ATTACK
  1707.         if self.mirror
  1708.           self.mirror = false
  1709.         else
  1710.           self.mirror = true
  1711.         end
  1712.       end  
  1713.       @moving_x = act0 / time
  1714.       @moving_y = act1 / time
  1715.       @angle = act3
  1716.       self.angle = @angle
  1717.       @angling = (act4 - act3)/ time
  1718.       @angle += (act4 - act3) % time
  1719.       @zooming_x = (1 - act7) / time
  1720.       @zooming_y = (1 - act8) / time
  1721.       if self.mirror
  1722.         case act5
  1723.         when 1
  1724.           act5 = 2
  1725.         when 2
  1726.           act5 = 1
  1727.         when 3
  1728.           act5 = 4
  1729.         when 4
  1730.           act5 = 3
  1731.         end  
  1732.       end    
  1733.       case act5
  1734.       when 0
  1735.         self.ox = @weapon_width / 2
  1736.         self.oy = @weapon_height / 2
  1737.       when 1
  1738.         self.ox = 0
  1739.         self.oy = 0
  1740.       when 2
  1741.         self.ox = @weapon_width
  1742.         self.oy = 0
  1743.       when 3
  1744.         self.ox = 0
  1745.         self.oy = @weapon_height
  1746.       when 4
  1747.         self.ox = @weapon_width
  1748.         self.oy = @weapon_height
  1749.       end  
  1750.       @plus_x = act9
  1751.       @plus_y = act10
  1752.       @loop = true if loop == 0
  1753.       @angle -= @angling
  1754.       @zoom_x -= @zooming_x
  1755.       @zoom_y -= @zooming_y
  1756.       @move_x -= @moving_x
  1757.       @move_y -= @moving_y
  1758.       @move_z = 1000 if act2
  1759.       if @freeze != -1
  1760.         for i in 0..@freeze + 1
  1761.           @angle += @angling
  1762.           @zoom_x += @zooming_x
  1763.           @zoom_y += @zooming_y
  1764.           @move_x += @moving_x
  1765.           @move_y += @moving_y
  1766.         end
  1767.         @angling = 0
  1768.         @zooming_x = 0
  1769.         @zooming_y = 0
  1770.         @moving_x = 0
  1771.         @moving_y = 0
  1772.       end
  1773.       self.visible = true
  1774.     end
  1775.   end  
  1776.   #--------------------------------------------------------------------------
  1777.   def action_reset
  1778.     @moving_x = @moving_y = @move_x = @move_y = @plus_x = @plus_y = 0
  1779.     @angling = @zooming_x = @zooming_y = @angle = self.angle = @move_z = 0
  1780.     @zoom_x = @zoom_y = self.zoom_x = self.zoom_y = 1
  1781.     self.mirror = self.visible = @loop = false
  1782.     @freeze = -1
  1783.     @action = []
  1784.     @time = ANIME_PATTERN + 1
  1785.   end
  1786.   #--------------------------------------------------------------------------
  1787.   def action_loop
  1788.     @angling *= -1
  1789.     @zooming_x *= -1
  1790.     @zooming_y *= -1
  1791.     @moving_x *= -1
  1792.     @moving_y *= -1
  1793.   end  
  1794.   #--------------------------------------------------------------------------
  1795.   def mirroring
  1796.     return @mirroring = false if @mirroring
  1797.     @mirroring = true
  1798.   end  
  1799.   #--------------------------------------------------------------------------
  1800.   def action
  1801.     return if @time <= 0
  1802.     @time -= 1
  1803.     @angle += @angling
  1804.     @zoom_x += @zooming_x
  1805.     @zoom_y += @zooming_y
  1806.     @move_x += @moving_x
  1807.     @move_y += @moving_y
  1808.     if @loop && @time == 0
  1809.       @time = ANIME_PATTERN + 1
  1810.       action_loop
  1811.     end
  1812.   end  
  1813.   #--------------------------------------------------------------------------
  1814.   def update
  1815.     super
  1816.     self.angle = @angle
  1817.     self.zoom_x = @zoom_x
  1818.     self.zoom_y = @zoom_y
  1819.     self.x = @battler.position_x + @move_x + @plus_x
  1820.     self.y = @battler.position_y + @move_y + @plus_y
  1821.     self.z = @battler.position_z + @move_z - 1
  1822.   end
  1823. end
  1824.  
  1825. #==============================================================================
  1826. # Game_Party
  1827. #==============================================================================
  1828. class Game_Party
  1829.   #--------------------------------------------------------------------------
  1830.   include N01
  1831.   #--------------------------------------------------------------------------
  1832.   def add_actor(actor_id)
  1833.     actor = $game_actors[actor_id]
  1834.     if @actors.size < MAX_MEMBER and not @actors.include?(actor)
  1835.       @actors.push(actor)
  1836.       $game_player.refresh
  1837.     end
  1838.   end
  1839. end
  1840.  
  1841. #==============================================================================
  1842. # ■ RPG::Weapon
  1843. #==============================================================================
  1844. class RPG::Weapon
  1845.   #--------------------------------------------------------------------------
  1846.   def magic?
  1847.     return false
  1848.   end
  1849. end
  1850.  
  1851. #==============================================================================
  1852. # ■ RPG::Skill
  1853. #==============================================================================
  1854. class RPG::Skill
  1855.   #--------------------------------------------------------------------------
  1856.   def magic?
  1857.     return @atk_f == 0 ? true : false
  1858.   end
  1859. end
  1860.  
  1861. #==============================================================================
  1862. # ■ RPG::Item
  1863. #==============================================================================
  1864. class RPG::Item
  1865.   #--------------------------------------------------------------------------
  1866.   def magic?
  1867.     return false
  1868.   end
  1869. end
  1870.  
  1871. #==============================================================================
  1872. # ■ RPG::Cache
  1873. #==============================================================================
  1874. module RPG::Cache
  1875.   def self.faces(filename, hue = 0)
  1876.     self.load_bitmap('Graphics/Faces/', filename, hue)
  1877.   end
  1878. end
  1879.  
  1880. #==============================================================================
  1881. # ■ Game_Battler
  1882. #==============================================================================
  1883. class Game_Battler
  1884.   #--------------------------------------------------------------------------
  1885.   include N01
  1886.   #--------------------------------------------------------------------------
  1887.   attr_accessor :sp_damage
  1888.   attr_accessor :collapse
  1889.   attr_accessor :move_x
  1890.   attr_accessor :move_y
  1891.   attr_accessor :move_z
  1892.   attr_accessor :jump
  1893.   attr_accessor :active
  1894.   attr_accessor :non_dead
  1895.   attr_accessor :slip_damage
  1896.   attr_accessor :derivation
  1897.   attr_accessor :individual
  1898.   attr_accessor :play
  1899.   attr_accessor :force_action
  1900.   attr_accessor :force_target
  1901.   attr_accessor :revival
  1902.   attr_accessor :reflex
  1903.   attr_accessor :absorb
  1904.   attr_accessor :anime_mirror
  1905.   attr_accessor :dying
  1906.   attr_accessor :state_animation_id
  1907.   attr_accessor :dead_anim
  1908.   attr_accessor :missed
  1909.   attr_accessor :evaded
  1910.   attr_accessor :true_immortal
  1911.   attr_accessor :defense_pose
  1912.   attr_reader   :base_position_x
  1913.   attr_reader   :base_position_y  
  1914.   attr_reader   :base_height  
  1915.   #--------------------------------------------------------------------------
  1916.   alias initialize_n01 initialize
  1917.   def initialize
  1918.     initialize_n01
  1919.     @move_x = @move_y = @move_z = @plus_y = @jump = @derivation = @act_time = 0
  1920.     @force_action = @force_target = @base_position_x = @base_position_y = 0
  1921.     @absorb = @play = @now_state = @state_frame = @state_animation_id = 0
  1922.     @active = @non_dead = @individual = @slip_damage = @revival = false
  1923.     @collapse = @sp_damage = @anime_mirror = @dying = false
  1924.     @evaded = @missed = false
  1925.     @anim_states = []
  1926.   end
  1927.   #--------------------------------------------------------------------------
  1928.   def state_id
  1929.     return @states[@states.size - 1]
  1930.   end
  1931.   #--------------------------------------------------------------------------
  1932.   def in_danger
  1933.     return @hp <= self.maxhp / 4
  1934.   end
  1935.   #--------------------------------------------------------------------------
  1936.   def battler_states
  1937.     bat_states = []
  1938.     for i in self.states
  1939.       bat_states.push($data_states[i])
  1940.     end
  1941.     return bat_states
  1942.   end
  1943.   #--------------------------------------------------------------------------
  1944.   def apply_variance(damage, variance)
  1945.     if damage != 0
  1946.       amp = [damage.abs * variance / 100, 0].max
  1947.       damage += rand(amp+1) + rand(amp+1) - amp
  1948.     end
  1949.     return damage
  1950.   end
  1951.   #--------------------------------------------------------------------------
  1952.   def state_animation_id
  1953.     return 0 if @states.empty?
  1954.     return 0 if @states.include?(1)
  1955.     @state_frame -= 1 if @state_frame > 0
  1956.     return @state_animation_id if @state_frame > 0
  1957.     if @anim_states.empty?
  1958.       for state in @states
  1959.         @anim_states << state if $data_states[state].animation_id > 0
  1960.       end
  1961.     end
  1962.     now_state = @anim_states.shift
  1963.     return 0 if now_state.nil?
  1964.     @state_animation_id = $data_states[now_state].animation_id
  1965.     return 0 if $data_animations[@state_animation_id].nil?
  1966.     @state_frame = $data_animations[@state_animation_id].frame_max * STATE_CYCLE_TIME * 2
  1967.     return @state_animation_id
  1968.   end
  1969.   #--------------------------------------------------------------------------
  1970.   def skill_can_use?(skill_id)
  1971.     skill = $data_skills[skill_id]
  1972.     if skill.extension.include?("CONSUMEHP")
  1973.       return false if calc_sp_cost(self, skill) >= self.hp
  1974.     else  
  1975.       return false if calc_sp_cost(self, skill) > self.sp
  1976.     end
  1977.     return false if dead?
  1978.     return false if skill.atk_f == 0 and self.restriction == 1
  1979.     occasion = skill.occasion
  1980.     return (occasion == 0 or occasion == 1) if $game_temp.in_battle
  1981.     return (occasion == 0 or occasion == 2)
  1982.   end  
  1983.   #--------------------------------------------------------------------------
  1984.   def calc_sp_cost(user, skill)
  1985.     cost = skill.sp_cost
  1986.     if skill.extension.include?("%COSTMAX")
  1987.       return user.maxhp * cost / 100 if skill.extension.include?("CONSUMEHP")
  1988.       return user.maxsp * cost / 100
  1989.     elsif skill.extension.include?("%COSTNOW")
  1990.       return user.hp * cost / 100 if skill.extension.include?("CONSUMEHP")
  1991.       return user.sp * cost / 100
  1992.     end
  1993.     return cost
  1994.   end
  1995.   #--------------------------------------------------------------------------
  1996.   def consum_skill_cost(skill)
  1997.     return false unless skill_can_use?(skill.id)
  1998.     cost = calc_sp_cost(self, skill)
  1999.     return self.hp -= cost if skill.extension.include?("CONSUMEHP")
  2000.     return self.sp -= cost
  2001.   end
  2002.   #--------------------------------------------------------------------------
  2003.   def attack_effect(attacker)
  2004.     self.critical = @evaded = @missed = false
  2005.     hit_result = (rand(100) < attacker.hit)
  2006.     set_attack_result(attacker) if hit_result
  2007.     weapon = attacker.actor? ? $data_weapons[attacker.weapon_id] : nil
  2008.     if hit_result
  2009.       set_attack_state_change(attacker)
  2010.     else
  2011.       self.critical = false
  2012.       @missed = true
  2013.     end
  2014.     self.damage = POP_EVA if @evaded
  2015.     self.damage = POP_MISS if @missed
  2016.     return true
  2017.   end
  2018.   #--------------------------------------------------------------------------
  2019.   def perfect_attack_effect(attacker)
  2020.     self.critical = @evaded = @missed = false
  2021.     set_attack_result(attacker)
  2022.     weapon = attacker.actor? ? $data_weapons[attacker.weapon_id] : nil
  2023.     set_attack_state_change(attacker)
  2024.     return true
  2025.   end
  2026.   #--------------------------------------------------------------------------
  2027.   def set_attack_result(attacker)
  2028.     set_attack_damage_value(attacker)
  2029.     if self.damage > 0
  2030.       self.damage /= 2 if self.guarding?
  2031.       set_attack_critical(attacker)
  2032.       set_critical_damage(attacker) if self.critical
  2033.     end
  2034.     apply_variance(15) if self.damage.abs > 0
  2035.     set_attack_hit_value(attacker)
  2036.   end
  2037.   #--------------------------------------------------------------------------
  2038.   def set_attack_damage_value(attacker)
  2039.     case DAMAGE_ALGORITHM_TYPE
  2040.     when 0
  2041.       atk = [attacker.atk - (self.pdef / 2), 0].max
  2042.       str = [20 + attacker.str, 0].max
  2043.     when 1
  2044.       atk = [attacker.atk - ((attacker.atk * self.pdef) / 1000), 0].max
  2045.       str = [20 + attacker.str, 0].max
  2046.     when 2
  2047.       atk = 20
  2048.       str = [(attacker.str * 4) - (self.dex * 2) , 0].max
  2049.     when 3
  2050.       atk = [(10 + attacker.atk) - (self.pdef / 2), 0].max
  2051.       str = [(20 + attacker.str) - (self.dex / 2), 0].max
  2052.     end
  2053.     self.damage = atk * str / 20
  2054.     self.damage = 1 if self.damage == 0 and (rand(100) > 40)
  2055.     self.damage *= elements_correct(attacker.element_set)
  2056.     self.damage /= 100
  2057.   end
  2058.   #--------------------------------------------------------------------------
  2059.   def apply_variance(variance)
  2060.     amp = [self.damage.abs * variance / 100, 1].max
  2061.     self.damage += rand(amp + 1) + rand(amp + 1) - amp
  2062.   end
  2063.   #--------------------------------------------------------------------------
  2064.   def set_attack_hit_value(attacker)
  2065.     atk_hit = DAMAGE_ALGORITHM_TYPE > 1 ? attacker.agi : attacker.dex
  2066.     eva = (8 * self.agi / atk_hit) + self.eva
  2067.     hit = self.damage < 0 ? 100 : 100 - eva
  2068.     hit = self.cant_evade? ? 100 : hit
  2069.     hit_result = (rand(100) < hit)
  2070.     @evaded = true unless hit_result
  2071.   end
  2072.   #--------------------------------------------------------------------------
  2073.   def set_attack_critical(attacker)
  2074.     atk_crt = DAMAGE_ALGORITHM_TYPE > 1 ? attacker.agi : attacker.dex
  2075.     self.critical = rand(100) < 5 * atk_crt / self.agi
  2076.   end
  2077.   #--------------------------------------------------------------------------
  2078.   def set_critical_damage(attacker)
  2079.     self.damage += self.damage
  2080.   end
  2081.   #--------------------------------------------------------------------------
  2082.   def set_attack_state_change(attacker)
  2083.     remove_states_shock
  2084.     effective = apply_damage(attacker)
  2085.     @state_changed = false
  2086.     states_plus(attacker.plus_state_set)
  2087.     states_minus(attacker.minus_state_set)
  2088.     return effective
  2089.   end
  2090.   #--------------------------------------------------------------------------
  2091.   def skill_effect(user, skill)
  2092.     self.critical = @evaded = @missed = false
  2093.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2094.        ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2095.       return false
  2096.     end
  2097.     effective = false
  2098.     effective |= skill.common_event_id > 0
  2099.     hit = skill.hit
  2100.     hit *= set_skill_hit(user, skill)
  2101.     hit_result = (rand(100) < hit)
  2102.     effective |= hit < 100
  2103.     effective |= set_skill_result(user, skill, effective) if hit_result
  2104.     if hit_result
  2105.       effective |= set_skill_state_change(user, skill, effective)
  2106.     else
  2107.       @missed = true unless @evaded
  2108.     end
  2109.     self.damage = nil unless $game_temp.in_battle
  2110.     self.damage = POP_EVA if @evaded
  2111.     self.damage = POP_MISS if @missed
  2112.     return effective
  2113.   end
  2114.   #--------------------------------------------------------------------------
  2115.   def perfect_skill_effect(user, skill)
  2116.     self.critical = @evaded = @missed = false
  2117.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2118.        ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2119.       return false
  2120.     end
  2121.     effective = false
  2122.     effective |= skill.common_event_id > 0
  2123.     effective |= set_skill_result(user, skill, effective)
  2124.     effective |= set_skill_state_change(user, skill, effective)
  2125.     self.damage = nil unless $game_temp.in_battle
  2126.     return effective
  2127.   end
  2128.   #--------------------------------------------------------------------------
  2129.   def set_skill_hit(user, skill)
  2130.     if skill.magic?
  2131.       return 1
  2132.     else
  2133.       return user.hit / 100
  2134.     end
  2135.   end
  2136.   #--------------------------------------------------------------------------
  2137.   def set_skill_result(user, skill, effective)
  2138.     set_skill_damage_value(user, skill)
  2139.     if self.damage > 0
  2140.       self.damage /= 2 if self.guarding?
  2141.     end
  2142.     apply_variance(skill.variance) if skill.variance > 0 and self.damage.abs > 0
  2143.     effective |= set_skill_hit_value(user, skill, effective)
  2144.     return effective
  2145.   end
  2146.   #--------------------------------------------------------------------------
  2147.   def set_skill_damage_value(user, skill)
  2148.     power = set_skill_power(user, skill)
  2149.     if power > 0
  2150.       case DAMAGE_ALGORITHM_TYPE
  2151.       when 0,3
  2152.         power -= (self.pdef * skill.pdef_f) / 200
  2153.         power -= (self.mdef * skill.mdef_f) / 200
  2154.       when 1
  2155.         power -= (power * (self.pdef * skill.pdef_f)) / 100000
  2156.         power -= (power * (self.mdef * skill.mdef_f)) / 100000
  2157.       when 2
  2158.         power -= ((self.dex * 2 * skill.pdef_f) / 100)
  2159.         power -= ((self.int * 1 * skill.mdef_f) / 100)
  2160.       end
  2161.       power = [power, 0].max
  2162.     end
  2163.     rate = set_skill_rate(user, skill) unless DAMAGE_ALGORITHM_TYPE == 2
  2164.     rate = [rate, 0].max
  2165.     self.damage = power * rate / 20
  2166.     self.damage *= elements_correct(skill.element_set)
  2167.     self.damage /= 100
  2168.   end
  2169.   #--------------------------------------------------------------------------
  2170.   def set_skill_power(user, skill)
  2171.     case DAMAGE_ALGORITHM_TYPE
  2172.     when 0,1,3
  2173.       power = skill.power + ((user.atk * skill.atk_f) / 100)
  2174.     when 2
  2175.       user_str = (user.str * 4 * skill.str_f / 100)
  2176.       user_int = (user.int * 2 * skill.int_f / 100)
  2177.       if skill.power > 0
  2178.         power = skill.power + user_str + user_int
  2179.       else
  2180.         power = skill.power - user_str - user_int
  2181.       end
  2182.     end
  2183.     return power
  2184.   end
  2185.   #--------------------------------------------------------------------------
  2186.   def set_skill_rate(user, skill)
  2187.     case DAMAGE_ALGORITHM_TYPE
  2188.     when 0,1,2
  2189.       rate = 20
  2190.     when 3
  2191.       rate = 40
  2192.       rate -= (self.dex / 2 * skill.pdef_f / 200)
  2193.       rate -= ((self.dex + self.int)/ 4 * skill.mdef_f / 200)
  2194.     end
  2195.     rate += (user.str * skill.str_f / 100)
  2196.     rate += (user.dex * skill.dex_f / 100)
  2197.     rate += (user.agi * skill.agi_f / 100)
  2198.     rate += (user.int * skill.int_f / 100)
  2199.     return rate
  2200.   end
  2201.   #--------------------------------------------------------------------------
  2202.   def set_skill_hit_value(user, skill, effective)
  2203.     atk_hit = DAMAGE_ALGORITHM_TYPE > 1 ? user.agi : user.dex
  2204.     eva = 8 * self.agi / atk_hit + self.eva
  2205.     hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
  2206.     hit = self.cant_evade? ? 100 : hit
  2207.     hit_result = (rand(100) < hit)
  2208.     @evaded = true unless hit_result
  2209.     effective |= hit < 100
  2210.     return effective
  2211.   end
  2212.   #--------------------------------------------------------------------------
  2213.   def set_skill_state_change(user, skill, effective = false)
  2214.     if skill.power != 0 and not skill.magic?
  2215.       remove_states_shock
  2216.       effective = true
  2217.     end
  2218.     effective |= apply_damage(user)
  2219.     @state_changed = false
  2220.     effective |= states_plus(skill.plus_state_set)
  2221.     effective |= states_minus(skill.minus_state_set)
  2222.     if skill.power == 0
  2223.       self.damage = ""
  2224.       @missed = true unless @state_changed
  2225.     end
  2226.     return effective
  2227.   end
  2228.   #--------------------------------------------------------------------------
  2229.   def apply_damage(user)
  2230.     return true if @evaded or @missed or not self.damage.is_a?(Numeric)
  2231.     if self.sp_damage
  2232.       last_sp = self.sp
  2233.       self.sp -= self.damage
  2234.       effective = self.sp != last_sp
  2235.     else
  2236.       last_hp = self.hp
  2237.       self.hp -= self.damage
  2238.       effective = self.hp != last_hp
  2239.     end
  2240.     return effective
  2241.   end
  2242.   #--------------------------------------------------------------------------
  2243.   def item_effect(item)
  2244.     self.critical = @evaded = @missed = false
  2245.     if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  2246.        ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  2247.       return false
  2248.     end
  2249.     effective = false
  2250.     effective |= item.common_event_id > 0
  2251.     hit_result = (rand(100) < item.hit)
  2252.     @missed = true unless hit_result
  2253.     effective |= item.hit < 100
  2254.     if hit_result == true
  2255.       effective |= make_item_damage_value(item)
  2256.     else
  2257.       @missed = true
  2258.     end
  2259.     self.damage = nil unless $game_temp.in_battle
  2260.     self.damage = POP_MISS if @missed
  2261.     return effective
  2262.   end
  2263.   #--------------------------------------------------------------------------
  2264.   def perfect_item_effect(item)
  2265.     self.critical = @evaded = @missed = false
  2266.     if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  2267.        ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  2268.       return false
  2269.     end
  2270.     effective = false
  2271.     effective |= item.common_event_id > 0
  2272.     effective |= item.hit < 100
  2273.     effective |= make_item_damage_value(item)
  2274.     self.damage = nil unless $game_temp.in_battle
  2275.     self.damage = POP_MISS if @missed
  2276.     return effective
  2277.   end
  2278.   #--------------------------------------------------------------------------
  2279.   def make_item_damage_value(item)
  2280.     recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  2281.     recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  2282.     if recover_hp < 0
  2283.       recover_hp += self.pdef * item.pdef_f / 20
  2284.       recover_hp += self.mdef * item.mdef_f / 20
  2285.       recover_hp = [recover_hp, 0].min
  2286.     end
  2287.     recover_hp *= elements_correct(item.element_set)
  2288.     recover_hp /= 100
  2289.     recover_sp *= elements_correct(item.element_set)
  2290.     recover_sp /= 100
  2291.     if item.variance > 0 and recover_hp.abs > 0
  2292.       amp = [recover_hp.abs * item.variance / 100, 1].max
  2293.       recover_hp += rand(amp+1) + rand(amp+1) - amp
  2294.     end
  2295.     if item.variance > 0 and recover_sp.abs > 0
  2296.       amp = [recover_sp.abs * item.variance / 100, 1].max
  2297.       recover_sp += rand(amp+1) + rand(amp+1) - amp
  2298.     end
  2299.     recover_hp /= 2 if recover_hp < 0 and self.guarding?
  2300.     self.damage = -recover_hp
  2301.     last_hp = self.hp
  2302.     last_sp = self.sp
  2303.     self.hp += recover_hp
  2304.     self.sp += recover_sp
  2305.     effective |= self.hp != last_hp
  2306.     effective |= self.sp != last_sp
  2307.     @state_changed = false
  2308.     effective |= states_plus(item.plus_state_set)
  2309.     effective |= states_minus(item.minus_state_set)
  2310.     if item.parameter_type > 0 and item.parameter_points != 0
  2311.       case item.parameter_type
  2312.       when 1
  2313.         @maxhp_plus += item.parameter_points
  2314.       when 2
  2315.         @maxsp_plus += item.parameter_points
  2316.       when 3
  2317.         @str_plus += item.parameter_points
  2318.       when 4
  2319.         @dex_plus += item.parameter_points
  2320.       when 5
  2321.         @agi_plus += item.parameter_points
  2322.       when 6
  2323.         @int_plus += item.parameter_points
  2324.       end
  2325.       effective = true
  2326.     end
  2327.     if item.recover_hp_rate == 0 and item.recover_hp == 0
  2328.       self.damage = ""
  2329.       if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  2330.          (item.parameter_type == 0 or item.parameter_points == 0)
  2331.         unless @state_changed
  2332.           @missed = true
  2333.         end
  2334.       end
  2335.     end
  2336.     return effective
  2337.   end
  2338.   #--------------------------------------------------------------------------
  2339.   alias skill_effect_n01 skill_effect
  2340.   def skill_effect(user, skill)
  2341.     now_hp = self.hp
  2342.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2343.        ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2344.       return false
  2345.     end
  2346.     effective = skill_effect_n01(user, skill)
  2347.     return if effective == false
  2348.     check_extension(skill)
  2349.     if @ratio_maxdamage != nil
  2350.       self.damage = self.maxhp * @ratio_maxdamage / 100 unless @sp_damage
  2351.       self.damage = self.maxsp * @ratio_maxdamage / 100 if @sp_damage
  2352.     end
  2353.     if @ratio_nowdamage != nil
  2354.       self.damage = self.hp * @ratio_nowdamage / 100 unless @sp_damage
  2355.       self.damage = self.sp * @ratio_nowdamage / 100 if @sp_damage
  2356.     end
  2357.     if @cost_damage
  2358.       cost = calc_sp_cost(user, skill)
  2359.       if skill.extension.include?("CONSUMEHP")
  2360.         self.damage = self.damage * cost / user.maxhp
  2361.       else
  2362.         self.damage = self.damage * cost / user.maxsp
  2363.       end  
  2364.     end
  2365.     self.damage = self.damage * user.hp / user.maxhp if @nowhp_damage
  2366.     self.damage = self.damage * user.sp / user.maxsp if @nowsp_damage
  2367.     if @sp_damage
  2368.       self.hp = now_hp
  2369.       self.sp -= self.damage
  2370.     elsif @extension
  2371.       self.hp = now_hp
  2372.       self.hp -= self.damage
  2373.     end
  2374.     return true
  2375.   end
  2376.   #--------------------------------------------------------------------------
  2377.   alias perfect_skill_effect_n01 perfect_skill_effect
  2378.   def perfect_skill_effect(user, skill)
  2379.     now_hp = self.hp
  2380.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2381.        ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2382.       return false
  2383.     end
  2384.     effective = perfect_skill_effect_n01(user, skill)
  2385.     return if effective == false
  2386.     check_extension(skill)
  2387.     if @ratio_maxdamage != nil
  2388.       self.damage = self.maxhp * @ratio_maxdamage / 100 unless @sp_damage
  2389.       self.damage = self.maxsp * @ratio_maxdamage / 100 if @sp_damage
  2390.     end
  2391.     if @ratio_nowdamage != nil
  2392.       self.damage = self.hp * @ratio_nowdamage / 100 unless @sp_damage
  2393.       self.damage = self.sp * @ratio_nowdamage / 100 if @sp_damage
  2394.     end
  2395.     if @cost_damage
  2396.       cost = calc_sp_cost(user, skill)
  2397.       if skill.extension.include?("CONSUMEHP")
  2398.         self.damage = self.damage * cost / user.maxhp
  2399.       else
  2400.         self.damage = self.damage * cost / user.maxsp
  2401.       end  
  2402.     end
  2403.     self.damage = self.damage * user.hp / user.maxhp if @nowhp_damage
  2404.     self.damage = self.damage * user.sp / user.maxsp if @nowsp_damage
  2405.     if @sp_damage
  2406.       self.hp = now_hp
  2407.       self.sp -= self.damage
  2408.     elsif @extension
  2409.       self.hp = now_hp
  2410.       self.hp -= self.damage
  2411.     end
  2412.     return true
  2413.   end
  2414.   #--------------------------------------------------------------------------
  2415.   def check_extension(skill)
  2416.     @extension = false
  2417.     @sp_damage = false
  2418.     @cost_damage = false
  2419.     @nowhp_damage = false
  2420.     @nowsp_damage = false
  2421.     @ratio_maxdamage = nil
  2422.     @ratio_nowdamage = nil
  2423.     for ext in skill.extension
  2424.       break if self.damage == "Errou!" or self.damage == "" or self.damage == 0
  2425.       if ext == "SPDAMAGE"
  2426.         next @sp_damage = true
  2427.       elsif ext == "COSTPOWER"  
  2428.         @extension = true
  2429.         next @cost_damage = true
  2430.       elsif ext == "HPNOWPOWER"
  2431.         @extension = true
  2432.         next @nowhp_damage = true
  2433.       elsif ext == "MPNOWPOWER"
  2434.         @extension = true
  2435.         next @nowsp_damage = true
  2436.       else
  2437.         name = ext.split('')
  2438.         if name[7] == "M"
  2439.           name = name.join
  2440.           name.slice!("%DAMAGEMAX/")
  2441.           @extension = true
  2442.           next @ratio_maxdamage = name.to_i
  2443.         elsif name[7] == "N"
  2444.           name = name.join
  2445.           name.slice!("%DAMAGENOW/")
  2446.           @extension = true
  2447.           next @ratio_nowdamage = name.to_i
  2448.         end  
  2449.       end
  2450.     end  
  2451.   end
  2452.   #--------------------------------------------------------------------------
  2453.   def change_base_position(x, y)
  2454.     @base_position_x = x
  2455.     @base_position_y = y
  2456.   end
  2457.   #--------------------------------------------------------------------------
  2458.   def reset_coordinate
  2459.     @move_x = @move_y = @move_z = @jump = @derivation = 0
  2460.     @active = @non_dead = @individual = false    
  2461.   end
  2462. end  
  2463.  
  2464. #==============================================================================
  2465. # ■ Game_Actor
  2466. #==============================================================================
  2467. class Game_Actor < Game_Battler
  2468.   #--------------------------------------------------------------------------
  2469.   attr_reader   :armor5_id
  2470.   attr_reader   :armor6_id
  2471.   attr_reader   :armor7_id
  2472.   attr_accessor :actor_height
  2473.   attr_accessor :two_swords_change
  2474.   #--------------------------------------------------------------------------
  2475.   include N01
  2476.   #--------------------------------------------------------------------------
  2477.   def actor?
  2478.     return true
  2479.   end
  2480.   #--------------------------------------------------------------------------
  2481.   def weapons
  2482.     return [$data_weapons[@weapon_id]]
  2483.   end
  2484.   #--------------------------------------------------------------------------
  2485.   def armors
  2486.     result = []
  2487.     result << $data_armors[@armor1_id]
  2488.     result << $data_armors[@armor2_id]
  2489.     result << $data_armors[@armor3_id]
  2490.     result << $data_armors[@armor4_id]
  2491.     return result
  2492.   end
  2493.   #--------------------------------------------------------------------------
  2494.   def equips
  2495.     return weapons + armors
  2496.   end
  2497.   #--------------------------------------------------------------------------
  2498.   def skill_id_learn?(skill_id)
  2499.     return @skills.include?(skill_id)
  2500.   end
  2501.   #--------------------------------------------------------------------------
  2502.   def exp=(exp)
  2503.     @exp = [exp, 0].max
  2504.     while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
  2505.       @level += 1
  2506.       for j in $data_classes[@class_id].learnings
  2507.         if j.level == @level
  2508.           learn_skill(j.skill_id)
  2509.         end
  2510.       end
  2511.     end
  2512.     while @exp < @exp_list[@level]
  2513.       @level -= 1
  2514.     end
  2515.     @hp = [@hp, self.maxhp].min
  2516.     @sp = [@sp, self.maxsp].min
  2517.   end
  2518.   #--------------------------------------------------------------------------
  2519.   def base_atk
  2520.     n = 0
  2521.     for item in weapons.compact do n += item.atk end
  2522.     n = UNARMED_ATTACK if weapons[0] == nil and weapons[1] == nil
  2523.     return n
  2524.   end
  2525.   #--------------------------------------------------------------------------
  2526.   def base_pdef
  2527.     n = 0
  2528.     for item in equips.compact do n += item.pdef end
  2529.     return n
  2530.   end
  2531.   #--------------------------------------------------------------------------
  2532.   def base_mdef
  2533.     n = 0
  2534.     for item in equips.compact do n += item.mdef end
  2535.     return n
  2536.   end
  2537.   #--------------------------------------------------------------------------
  2538.   def base_eva
  2539.     n = 0
  2540.     for item in armors.compact do n += item.eva end
  2541.     return n
  2542.   end
  2543.   #--------------------------------------------------------------------------
  2544.   def graphic_change(character_name)
  2545.     @character_name = character_name
  2546.   end
  2547.   #--------------------------------------------------------------------------
  2548.   def perform_collapse
  2549.     $game_system.se_play($data_system.actor_collapse_se) if $game_temp.in_battle and dead?
  2550.   end
  2551.   #--------------------------------------------------------------------------
  2552.   def base_position
  2553.     base = ACTOR_POSITION[self.index]
  2554.     @base_position_x = base[0]
  2555.     @base_position_y = base[1]
  2556.     @base_position_x = 640 - base[0] if $back_attack and BACK_ATTACK_MIRROR
  2557.   end
  2558.   #--------------------------------------------------------------------------
  2559.   def actor_height
  2560.     @base_height = 0 if CURSOR_TYPE != 1
  2561.     @base_height = 72 if CURSOR_TYPE == 1
  2562.     return @base_height
  2563.   end
  2564.   #--------------------------------------------------------------------------
  2565.   def position_x
  2566.     return 0 if self.index == nil
  2567.     return @base_position_x + @move_x
  2568.   end
  2569.   #--------------------------------------------------------------------------
  2570.   def position_y
  2571.     return 0 if self.index == nil
  2572.     return @base_position_y + @move_y + @jump
  2573.   end
  2574.   #--------------------------------------------------------------------------
  2575.   def position_z
  2576.     return 0 if self.index == nil
  2577.     return position_y + @move_z - @jump + 200
  2578.   end  
  2579. end
  2580.  
  2581. #==============================================================================
  2582. # ■ Game_Enemy
  2583. #==============================================================================
  2584. class Game_Enemy < Game_Battler
  2585.   #--------------------------------------------------------------------------
  2586.   include N01
  2587.   #--------------------------------------------------------------------------
  2588.   attr_accessor :adj_speed
  2589.   attr_accessor :act_time
  2590.   #--------------------------------------------------------------------------
  2591.   def actor?
  2592.     return false
  2593.   end
  2594.   #--------------------------------------------------------------------------
  2595.   def make_action_speed2(adj)
  2596.     @adj_speed = @current_action.speed if @adj_speed == nil
  2597.     @adj_speed = @adj_speed * adj / 100
  2598.   end
  2599.   #--------------------------------------------------------------------------
  2600.   def perform_collapse
  2601.     @force_action = ["N01collapse"] if $game_temp.in_battle and dead?
  2602.   end
  2603.   #--------------------------------------------------------------------------
  2604.   def element_set2
  2605.     return []
  2606.   end
  2607.   #--------------------------------------------------------------------------
  2608.   def base_position
  2609.     return if self.index == nil
  2610.     bitmap = Bitmap.new("Graphics/Battlers/" + @battler_name) if !self.anime_on
  2611.     bitmap = Bitmap.new("Graphics/Characters/" + @battler_name) if self.anime_on && WALK_ANIME
  2612.     bitmap = Bitmap.new("Graphics/Characters/" + @battler_name + "_1") if self.anime_on && !WALK_ANIME
  2613.     height = bitmap.height
  2614.     @base_position_x = self.screen_x + self.position_plus[0]
  2615.     @base_position_y = self.screen_y + self.position_plus[1] - height / 3 + 32
  2616.     @base_position_x = 640 - self.screen_x - self.position_plus[0] if $back_attack and BACK_ATTACK_MIRROR
  2617.     @base_height = 0 if CURSOR_TYPE == 0
  2618.     @base_height = height / 3 + 64 if CURSOR_TYPE == 1 if !self.anime_on
  2619.     @base_height = height /12 + 64 if CURSOR_TYPE == 1 if self.anime_on
  2620.     @base_height = -(height / 3) if CURSOR_TYPE == 2 if !self.anime_on
  2621.     @base_height = -(height /12) if CURSOR_TYPE == 2 if self.anime_on
  2622.     bitmap.dispose
  2623.   end
  2624.   #--------------------------------------------------------------------------
  2625.   def enemy_height
  2626.     return @base_height
  2627.   end
  2628.   #--------------------------------------------------------------------------
  2629.   def position_x
  2630.     return @base_position_x - @move_x
  2631.   end
  2632.   #--------------------------------------------------------------------------
  2633.   def position_y
  2634.     return @base_position_y + @move_y + @jump
  2635.   end
  2636.   #--------------------------------------------------------------------------
  2637.   def position_z
  2638.     return position_y + @move_z - @jump + 200
  2639.   end
  2640. end
  2641.  
  2642. #==============================================================================
  2643. # Arrow_Base
  2644. #==============================================================================
  2645. class Arrow_Base < Sprite
  2646.   #--------------------------------------------------------------------------
  2647.   include N01
  2648.   #--------------------------------------------------------------------------
  2649.   def update_multi_arrow
  2650.     return if @arrows == nil or @arrows == []
  2651.     for i in [email hidden]
  2652.       @blink_count = (@blink_count + 1) % 40
  2653.       if @blink_count < 20
  2654.         @arrows[i].src_rect.set(128, 96, 32, 32) if @arrows[i] != nil
  2655.       else
  2656.         @arrows[i].src_rect.set(160, 96, 32, 32) if @arrows[i] != nil
  2657.       end
  2658.     end
  2659.   end
  2660.   #--------------------------------------------------------------------------
  2661.   def dispose_multi_arrow
  2662.     for i in [email hidden]
  2663.       @arrows[i].dispose if @arrows[i] != nil
  2664.     end
  2665.   end
  2666. end
  2667.  
  2668. #==============================================================================
  2669. # Arrow_Enemy_All
  2670. #==============================================================================
  2671. class Arrow_Enemy_All < Arrow_Base
  2672.   #--------------------------------------------------------------------------
  2673.   def initialize(viewport)
  2674.     super(viewport)
  2675.     @arrows = []
  2676.     for battler in $game_troop.enemies
  2677.       if battler.exist?
  2678.         @arrows[battler.index] = Arrow_Enemy.new(viewport)
  2679.         @arrows[battler.index].index = battler.index
  2680.       end
  2681.     end
  2682.   end
  2683.   #--------------------------------------------------------------------------
  2684.   def update_multi_arrow
  2685.     super
  2686.     for i in [email hidden]
  2687.       enemy = $game_troop.enemies[i]
  2688.       if enemy  != nil && @arrows[i] != nil && @arrows[i].enemy != nil
  2689.         @arrows[i].x = @arrows[i].enemy.position_x + CURSOR_POSITION[0]
  2690.         @arrows[i].y = @arrows[i].enemy.position_y + CURSOR_POSITION[1] + enemy.enemy_height
  2691.       end
  2692.     end
  2693.   end
  2694. end
  2695.  
  2696. #==============================================================================
  2697. # Arrow_Actor_All
  2698. #==============================================================================
  2699. class Arrow_Actor_All < Arrow_Base
  2700.   #--------------------------------------------------------------------------
  2701.   def initialize(viewport)
  2702.     super(viewport)
  2703.     @arrows = []
  2704.     for battler in $game_party.actors
  2705.       if battler.exist?
  2706.         @arrows[battler.index] = Arrow_Actor.new(viewport)
  2707.         @arrows[battler.index].index = battler.index
  2708.       end
  2709.     end
  2710.   end
  2711.   #--------------------------------------------------------------------------
  2712.   def update_multi_arrow
  2713.     super
  2714.     for i in [email hidden]
  2715.       actor = $game_party.actors[i]
  2716.       if actor  != nil && @arrows[i] != nil && @arrows[i].actor != nil
  2717.         @arrows[i].x = @arrows[i].actor.position_x + CURSOR_POSITION[0]
  2718.         @arrows[i].y = @arrows[i].actor.position_y + CURSOR_POSITION[1] + actor.actor_height
  2719.       end
  2720.     end
  2721.   end
  2722. end
  2723.  
  2724. #==============================================================================
  2725. # Arrow_Battler_All
  2726. #==============================================================================
  2727. class Arrow_Battler_All < Arrow_Base
  2728.   #--------------------------------------------------------------------------
  2729.   def initialize(viewport)
  2730.     super(viewport)
  2731.     @arrows = []
  2732.     s = 0
  2733.     for battler in $game_party.actors + $game_troop.enemies
  2734.       @arrows[s] = Arrow_Actor.new(viewport) if battler.actor?
  2735.       @arrows[s] = Arrow_Enemy.new(viewport) if battler.is_a?(Game_Enemy)
  2736.       @arrows[s].index = battler.index
  2737.       s += 1
  2738.     end
  2739.   end
  2740.   #--------------------------------------------------------------------------
  2741.   def update_multi_arrow
  2742.     super
  2743.     s = 0
  2744.     for i in [email hidden]
  2745.       if @arrows[i].is_a?(Arrow_Actor)
  2746.         actor = $game_party.actors[i]
  2747.         if @arrows[i].actor != nil
  2748.           @arrows[i].x = @arrows[i].actor.position_x + CURSOR_POSITION[0]
  2749.           @arrows[i].y = @arrows[i].actor.position_y + CURSOR_POSITION[1] + actor.actor_height
  2750.           s += 1
  2751.         end
  2752.       elsif @arrows[i].is_a?(Arrow_Enemy)
  2753.         enemy = $game_troop.enemies[i - s]
  2754.         if @arrows[i].enemy != nil or @arrows[i] != nil
  2755.           @arrows[i].x = @arrows[i].enemy.position_x + CURSOR_POSITION[0]
  2756.           @arrows[i].y = @arrows[i].enemy.position_y + CURSOR_POSITION[1] + enemy.enemy_height
  2757.         end
  2758.       end
  2759.     end
  2760.   end
  2761. end
  2762.  
  2763. #==============================================================================
  2764. # ■ Arrow_Enemy
  2765. #==============================================================================
  2766. class Arrow_Enemy < Arrow_Base
  2767.   #--------------------------------------------------------------------------
  2768.   def update
  2769.     super
  2770.     $game_troop.enemies.size.times do
  2771.       break if self.enemy.exist?
  2772.       @index += 1
  2773.       @index %= $game_troop.enemies.size
  2774.     end
  2775.     if Input.repeat?(Input::RIGHT)
  2776.       cursor_up if $back_attack
  2777.       cursor_down unless $back_attack
  2778.     end
  2779.     if Input.repeat?(Input::LEFT)
  2780.       cursor_up unless $back_attack
  2781.       cursor_down if $back_attack
  2782.     end
  2783.     if Input.repeat?(Input::UP)
  2784.       cursor_down
  2785.     end
  2786.     if Input.repeat?(Input::DOWN)
  2787.       cursor_up
  2788.     end
  2789.     if self.enemy != nil
  2790.       self.x = self.enemy.position_x + CURSOR_POSITION[0]
  2791.       self.y = self.enemy.position_y + CURSOR_POSITION[1] + enemy.enemy_height
  2792.     end
  2793.   end
  2794.   #--------------------------------------------------------------------------
  2795.   def cursor_up
  2796.     $game_system.se_play($data_system.cursor_se)
  2797.     $game_troop.enemies.size.times do
  2798.       @index += $game_troop.enemies.size - 1
  2799.       @index %= $game_troop.enemies.size
  2800.       break if self.enemy.exist?
  2801.     end
  2802.   end
  2803.   #--------------------------------------------------------------------------
  2804.   def cursor_down
  2805.     $game_system.se_play($data_system.cursor_se)
  2806.     $game_troop.enemies.size.times do
  2807.       @index += 1
  2808.       @index %= $game_troop.enemies.size
  2809.       break if self.enemy.exist?
  2810.     end
  2811.   end
  2812. end
  2813.  
  2814. #==============================================================================
  2815. # ■ Arrow_Actor
  2816. #==============================================================================
  2817. class Arrow_Actor < Arrow_Base
  2818.   #--------------------------------------------------------------------------
  2819.   def update
  2820.     super
  2821.     if Input.repeat?(Input::RIGHT)
  2822.       cursor_up if $back_attack
  2823.       cursor_down unless $back_attack
  2824.     end
  2825.     if Input.repeat?(Input::LEFT)
  2826.       cursor_up unless $back_attack
  2827.       cursor_down if $back_attack
  2828.     end
  2829.     if Input.repeat?(Input::UP)
  2830.       cursor_up
  2831.     end
  2832.     if Input.repeat?(Input::DOWN)
  2833.       cursor_down
  2834.     end
  2835.     if self.actor != nil
  2836.       self.x = self.actor.position_x + CURSOR_POSITION[0]
  2837.       self.y = self.actor.position_y + CURSOR_POSITION[1] + actor.actor_height
  2838.     end
  2839.   end
  2840.   #--------------------------------------------------------------------------
  2841.   def cursor_up
  2842.     $game_system.se_play($data_system.cursor_se)
  2843.     @index += $game_party.actors.size - 1
  2844.     @index %= $game_party.actors.size
  2845.   end
  2846.   #--------------------------------------------------------------------------
  2847.   def cursor_down
  2848.     $game_system.se_play($data_system.cursor_se)
  2849.     @index += 1
  2850.     @index %= $game_party.actors.size
  2851.   end
  2852.   #--------------------------------------------------------------------------
  2853.   def input_right
  2854.     @index += 1
  2855.     @index %= $game_party.actors.size
  2856.   end
  2857.   #--------------------------------------------------------------------------
  2858.   def input_update_target
  2859.     if Input.repeat?(Input::RIGHT)
  2860.       if @index == self.actor.index    
  2861.         cursor_up if $back_attack
  2862.         cursor_down unless $back_attack
  2863.       end
  2864.     end
  2865.     if Input.repeat?(Input::LEFT)
  2866.       if @index == self.actor.index
  2867.         cursor_up unless $back_attack
  2868.         cursor_down if $back_attack
  2869.       end
  2870.     end
  2871.     if Input.repeat?(Input::UP)
  2872.       cursor_up if @index == self.actor.index
  2873.     end
  2874.     if Input.repeat?(Input::DOWN)
  2875.       cursor_down if @index == self.actor.index
  2876.     end
  2877.     if self.actor != nil
  2878.       self.x = self.actor.screen_x
  2879.       self.y = self.actor.screen_y
  2880.     end
  2881.   end
  2882. end
  2883.  
  2884. #==============================================================================
  2885. # ■ Game_Troop
  2886. #==============================================================================
  2887. class Game_Troop
  2888.   def clear_actions
  2889.     for enemies in @enemies
  2890.       enemies.current_action.clear
  2891.     end
  2892.   end
  2893. end
  2894.  
  2895. #==============================================================================
  2896. # ■ Window_Command
  2897. #==============================================================================
  2898. class Window_Command < Window_Selectable
  2899.   #--------------------------------------------------------------------------
  2900.   attr_accessor :commands
  2901. end
  2902.  
  2903. #==============================================================================
  2904. # ■ Window_Base
  2905. #==============================================================================
  2906. class Window_Base < Window
  2907.   #--------------------------------------------------------------------------
  2908.   include N01
  2909.   #--------------------------------------------------------------------------
  2910.   def draw_actor_state(actor, x, y, width = 0)
  2911.     status_icon = []
  2912.     for i in actor.states
  2913.       if $data_states[i].rating >= 1
  2914.         begin
  2915.           status_icon.push(RPG::Cache.icon($data_states[i].name + "_st"))
  2916.           break if status_icon.size > (Icon_max - 1)
  2917.         rescue
  2918.         end
  2919.       end
  2920.     end
  2921.     for icon in status_icon
  2922.       self.contents.blt(x + X_Adjust, y + Y_Adjust + 4, icon, Rect.new(0, 0, Icon_X, Icon_Y), 255)
  2923.       x += Icon_X + 2
  2924.     end
  2925.   end
  2926.   #--------------------------------------------------------------------------
  2927.   def draw_actor_parameter(actor, x, y, type)
  2928.     case type
  2929.     when 0
  2930.       parameter_name = $data_system.words.atk
  2931.       parameter_value = actor.atk
  2932.     when 1
  2933.       parameter_name = $data_system.words.pdef
  2934.       parameter_value = actor.pdef
  2935.     when 2
  2936.       parameter_name = $data_system.words.mdef
  2937.       parameter_value = actor.mdef
  2938.     when 3
  2939.       parameter_name = $data_system.words.str
  2940.       parameter_value = actor.str
  2941.     when 4
  2942.       parameter_name = (DAMAGE_ALGORITHM_TYPE == 0 ? STAT_VIT : $data_system.words.dex)
  2943.       parameter_value = actor.dex
  2944.     when 5
  2945.       parameter_name = $data_system.words.agi
  2946.       parameter_value = actor.agi
  2947.     when 6
  2948.       parameter_name = $data_system.words.int
  2949.       parameter_value = actor.int
  2950.     when 7
  2951.       parameter_name = STAT_EVA
  2952.       parameter_value = actor.eva
  2953.     end
  2954.     self.contents.font.color = system_color
  2955.     self.contents.draw_text(x, y, 120, 32, parameter_name)
  2956.     self.contents.font.color = normal_color
  2957.     self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
  2958.   end
  2959. end
  2960.  
  2961. #==============================================================================
  2962. # ■ Window_Help
  2963. #==============================================================================
  2964. class Window_Help < Window_Base
  2965.   #--------------------------------------------------------------------------
  2966.   def initialize
  2967.     super(0, 0, 640, 64)
  2968.     self.contents = Bitmap.new(width - 32, height - 32)
  2969.     self.z = 2000 if $game_temp.in_battle
  2970.     self.back_opacity = HELP_OPACITY if $game_temp.in_battle
  2971.   end
  2972.   #--------------------------------------------------------------------------
  2973.   def set_text_update(text, align = 0)
  2974.     self.contents.clear
  2975.     self.contents.font.color = normal_color
  2976.     self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
  2977.     @text = text
  2978.     @align = align
  2979.     @actor = nil
  2980.     self.visible = true
  2981.   end
  2982.   #--------------------------------------------------------------------------
  2983.   def set_enemy(enemy)
  2984.     text = enemy.name
  2985.     set_text_update(text, 1)
  2986.     text_width = self.contents.text_size(text).width
  2987.     x = (text_width + self.width)/2
  2988.     status_icon = []
  2989.     for i in enemy.states
  2990.       if $data_states[i].rating >= 1
  2991.         begin
  2992.           status_icon.push(RPG::Cache.icon($data_states[i].name + "_st"))
  2993.           break if status_icon.size > (Icon_max - 1)
  2994.         rescue
  2995.         end
  2996.       end
  2997.     end
  2998.     for icon in status_icon
  2999.       self.contents.blt(x + X_Adjust, y + Y_Adjust + 4, icon, Rect.new(0, 0, Icon_X, Icon_Y), 255)
  3000.       x += Icon_X + 2
  3001.     end
  3002.   end
  3003. end
  3004.  
  3005. #==============================================================================
  3006. # ■ Window_Skill
  3007. #==============================================================================
  3008. class Window_Skill < Window_Selectable
  3009.   #--------------------------------------------------------------------------
  3010.   def initialize(actor)
  3011.     super(0, 128, 640, 352)
  3012.     @actor = actor
  3013.     @column_max = 2
  3014.     refresh
  3015.     self.index = 0
  3016.     if $game_temp.in_battle
  3017.       self.y = 320
  3018.       self.height = 160
  3019.       self.z = 2100
  3020.       self.back_opacity = MENU_OPACITY
  3021.     end
  3022.   end
  3023.   #--------------------------------------------------------------------------
  3024.   def draw_item(index)
  3025.     skill = @data[index]
  3026.     if @actor.skill_can_use?(skill.id)
  3027.       self.contents.font.color = normal_color
  3028.     else
  3029.       self.contents.font.color = disabled_color
  3030.     end
  3031.     x = 4 + index % 2 * (288 + 32)
  3032.     y = index / 2 * 32
  3033.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  3034.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  3035.     bitmap = RPG::Cache.icon(skill.icon_name)
  3036.     opacity = self.contents.font.color == normal_color ? 255 : 128
  3037.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  3038.     self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  3039.     cost = @actor.calc_sp_cost(@actor, skill)
  3040.     self.contents.draw_text(x + 232, y, 48, 32, cost.to_s, 2)
  3041.   end
  3042. end
  3043.  
  3044. #==============================================================================
  3045. # ■ Window_Item
  3046. #==============================================================================
  3047. class Window_Item < Window_Selectable
  3048.   #--------------------------------------------------------------------------
  3049.   def initialize
  3050.     super(0, 64, 640, 416)
  3051.     @column_max = 2
  3052.     refresh
  3053.     self.index = 0
  3054.     if $game_temp.in_battle
  3055.       self.y = 320
  3056.       self.height = 160
  3057.       self.z = 2100
  3058.       self.back_opacity = MENU_OPACITY
  3059.     end
  3060.   end
  3061. end
  3062.  
  3063. #==============================================================================
  3064. # ■ Window_PartyCommand
  3065. #==============================================================================
  3066. class Window_PartyCommand < Window_Selectable
  3067.   #--------------------------------------------------------------------------
  3068.   alias initialize_n01 initialize
  3069.   #--------------------------------------------------------------------------
  3070.   def initialize
  3071.     initialize_n01
  3072.     self.z = 2000
  3073.   end
  3074. end
  3075.  
  3076. #==============================================================================
  3077. # ■ Window_BattleStatus
  3078. #==============================================================================
  3079. class Window_BattleStatus < Window_Base
  3080.   #--------------------------------------------------------------------------
  3081.   def initialize
  3082.     super(0, 320, 640, 160)
  3083.     self.contents = Bitmap.new(width - 32, height - 32)
  3084.     @level_up_flags = []
  3085.     for i in 0...$game_party.actors.size
  3086.       @level_up_flags.push(false)
  3087.     end
  3088.     self.z = 2000
  3089.     self.opacity = STATUS_OPACITY
  3090.     refresh
  3091.   end
  3092.   #--------------------------------------------------------------------------
  3093.   def update
  3094.     super
  3095.   end
  3096. end
  3097.  
  3098. #==============================================================================
  3099. # ■ Window_NameCommand
  3100. #==============================================================================
  3101. class Window_BattleResult < Window_Base
  3102.   #--------------------------------------------------------------------------
  3103.   def initialize(exp, gold, treasures)
  3104.     @exp = exp
  3105.     @gold = gold
  3106.     @treasures = treasures
  3107.     super(160, 0, 320, @treasures.size * 32 + 64)
  3108.     self.contents = Bitmap.new(width - 32, height - 32)
  3109.     self.y = 160 - height / 2
  3110.     self.back_opacity = 160
  3111.     self.z = 2000
  3112.     self.visible = false
  3113.     refresh
  3114.   end
  3115. end
  3116.  
  3117. #==============================================================================
  3118. # ■ Window_NameCommand
  3119. #==============================================================================
  3120. class Window_NameCommand < Window_Base
  3121.   #--------------------------------------------------------------------------
  3122.   def initialize(actor, x, y)
  3123.     super(x, y, 160, 64)
  3124.     self.contents = Bitmap.new(width - 32, height - 32)
  3125.     self.contents.font.name = Font.default_name
  3126.     self.z = 2000
  3127.     self.back_opacity = COMMAND_OPACITY
  3128.     refresh(actor)
  3129.   end
  3130.   #--------------------------------------------------------------------------
  3131.   def refresh(actor)
  3132.     self.contents.clear
  3133.     self.contents.font.color = normal_color
  3134.     self.contents.draw_text(0, 0, 128, 32, actor.name, 1) if actor != nil
  3135.   end
  3136. end
  3137.  
  3138. #==============================================================================
  3139. # ■ RPG::Sprite
  3140. #==============================================================================
  3141. class RPG::Sprite < ::Sprite
  3142.   #--------------------------------------------------------------------------
  3143.   include N01
  3144.   #--------------------------------------------------------------------------
  3145.   def initialize(viewport = nil)
  3146.     super(viewport)
  3147.     @_whiten_duration = 0
  3148.     @_appear_duration = 0
  3149.     @_escape_duration = 0
  3150.     @_collapse_duration = 0
  3151.     @_damage_duration = 0
  3152.     @_animation_duration = 0
  3153.     @_blink = false
  3154.     @_damage_durations = []
  3155.     @time = 0
  3156.   end
  3157.   #--------------------------------------------------------------------------
  3158.   def appear
  3159.   end
  3160.   #--------------------------------------------------------------------------
  3161.   def escape
  3162.   end
  3163.   #--------------------------------------------------------------------------
  3164.   def collapse
  3165.   end
  3166.   #--------------------------------------------------------------------------
  3167.   def damage(value, critical, sp_damage = nil)
  3168.     dispose_damage(0...@_damage_durations.size)
  3169.     @_damage_sprites = []
  3170.     if value.is_a?(Numeric)
  3171.       damage_string = value.abs.to_s
  3172.     else
  3173.       damage_string = value.to_s
  3174.     end
  3175.     @damage_size = 1 if !MULTI_POP
  3176.     @damage_size = damage_string.size if MULTI_POP
  3177.     for i in 0...@damage_size
  3178.       letter = damage_string[i..i] if MULTI_POP
  3179.       letter = damage_string if !MULTI_POP
  3180.       bitmap = Bitmap.new(160, 48)
  3181.       bitmap.font.name = DAMAGE_FONT
  3182.       bitmap.font.size = DMG_F_SIZE
  3183.       bitmap.font.color.set(0, 0, 0)
  3184.       bitmap.draw_text(-1, 12-1,160, 36, letter, 1)
  3185.       bitmap.draw_text(+1, 12-1,160, 36, letter, 1)
  3186.       bitmap.draw_text(-1, 12+1,160, 36, letter, 1)
  3187.       bitmap.draw_text(+1, 12+1,160, 36, letter, 1)
  3188.       if value.is_a?(Numeric) and value < 0
  3189.         bitmap.font.color.set(HP_REC_COLOR[0],HP_REC_COLOR[1],HP_REC_COLOR[2]) if !sp_damage
  3190.         bitmap.font.color.set(SP_REC_COLOR[0],SP_REC_COLOR[1],SP_REC_COLOR[2]) if sp_damage
  3191.       else
  3192.         bitmap.font.color.set(HP_DMG_COLOR[0],HP_DMG_COLOR[1],HP_DMG_COLOR[2]) if !sp_damage
  3193.         bitmap.font.color.set(SP_DMG_COLOR[0],SP_DMG_COLOR[1],SP_DMG_COLOR[2]) if sp_damage
  3194.         bitmap.font.color.set(CRT_DMG_COLOR[0],CRT_DMG_COLOR[1],CRT_DMG_COLOR[2]) if critical
  3195.       end
  3196.       bitmap.draw_text(0, 12,160, 36, letter, 1)
  3197.       if critical and CRITIC_TEXT and i == 0
  3198.         x_pop = (MULTI_POP ? (damage_string.size - 1) * (DMG_SPACE / 2) : 0)
  3199.         bitmap.font.size = ((DMG_F_SIZE * 2) / 3).to_i
  3200.         bitmap.font.color.set(0, 0, 0)
  3201.         bitmap.draw_text(-1 + x_pop, -1, 160, 20, POP_CRI, 1)
  3202.         bitmap.draw_text(+1 + x_pop, -1, 160, 20, POP_CRI, 1)
  3203.         bitmap.draw_text(-1 + x_pop, +1, 160, 20, POP_CRI, 1)
  3204.         bitmap.draw_text(+1 + x_pop, +1, 160, 20, POP_CRI, 1)
  3205.         bitmap.font.color.set(CRT_TXT_COLOR[0],CRT_TXT_COLOR[1],CRT_TXT_COLOR[2]) if critical
  3206.         bitmap.draw_text(0 + x_pop, 0, 160, 20, POP_CRI, 1)
  3207.       end
  3208.       if critical and CRITIC_FLASH
  3209.         $game_screen.start_flash(Color.new(255, 255, 255, 255),10)
  3210.       end
  3211.       @_damage_sprites[i] = ::Sprite.new(self.viewport)
  3212.       @_damage_sprites[i].bitmap = bitmap
  3213.       @_damage_sprites[i].ox = 80
  3214.       @_damage_sprites[i].oy = 20
  3215.       @_damage_sprites[i].x = self.x + i * DMG_SPACE
  3216.       @_damage_sprites[i].y = self.y - self.oy / 2
  3217.       @_damage_sprites[i].z = DMG_DURATION + 3000 + i * 2
  3218.     end
  3219.   end
  3220.   #--------------------------------------------------------------------------
  3221.   def dispose
  3222.     dispose_damage(0...@_damage_durations.size)
  3223.     dispose_animation
  3224.     dispose_loop_animation
  3225.     if @damage_sprites != nil
  3226.       for damage_sprite in @damage_sprites
  3227.         damage_sprite.dispose
  3228.       end
  3229.     end
  3230.     super
  3231.   end
  3232.   #--------------------------------------------------------------------------
  3233.   def update
  3234.     super
  3235.     @damage_sprites   = [] if @damage_sprites.nil?
  3236.     @damage_durations = [] if @damage_durations.nil?
  3237.     if @_damage_sprites != nil
  3238.       for sprite in @_damage_sprites
  3239.         if sprite != nil and sprite.visible
  3240.           x = DMG_X_MOVE
  3241.           y = DMG_Y_MOVE
  3242.           d = sprite.z - 3000
  3243.           m = self.mirror
  3244.           @damage_sprites.push(Sprite_Damage.new(sprite, x, y, d, m))
  3245.           sprite.visible = false
  3246.         end
  3247.       end
  3248.     end
  3249.     for damage_sprite in @damage_sprites
  3250.       damage_sprite.update
  3251.     end
  3252.     for i in 0...@damage_sprites.size
  3253.       @damage_sprites[i] = nil if @damage_sprites[i].disposed?
  3254.     end
  3255.     @damage_sprites.compact!
  3256.     if @_whiten_duration > 0
  3257.       @_whiten_duration -= 1
  3258.       self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  3259.     end
  3260.     if @_animation != nil and (Graphics.frame_count % 2 == 0)
  3261.       @_animation_duration -= 1
  3262.       update_animation
  3263.     end
  3264.     if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  3265.       update_loop_animation
  3266.       @_loop_animation_index += 1
  3267.       @_loop_animation_index %= @_loop_animation.frame_max
  3268.     end
  3269.     if @_blink
  3270.       @_blink_count = (@_blink_count + 1) % 32
  3271.       if @_blink_count < 16
  3272.         alpha = (16 - @_blink_count) * 6
  3273.       else
  3274.         alpha = (@_blink_count - 16) * 6
  3275.       end
  3276.       self.color.set(255, 255, 255, alpha)
  3277.     end
  3278.     @@_animations.clear
  3279.   end
  3280.   #--------------------------------------------------------------------------
  3281.   def dispose_damage(index)
  3282.     return if @_damage_sprites == nil
  3283.     if @_damage_sprites[index].is_a?(::Sprite) and @_damage_sprites[index].bitmap != nil
  3284.       @_damage_sprites[index].bitmap.dispose
  3285.       @_damage_sprites[index].dispose
  3286.       @_damage_durations[index] = 0
  3287.     end
  3288.   end
  3289.   #--------------------------------------------------------------------------
  3290.   def dispose_animation
  3291.     if @_animation_sprites != nil
  3292.       sprite = @_animation_sprites[0]
  3293.       if sprite != nil
  3294.         @@_reference_count[sprite.bitmap] -= 1
  3295.         if @@_reference_count[sprite.bitmap] == 0
  3296.           sprite.bitmap.dispose
  3297.         end
  3298.       end
  3299.       for sprite in @_animation_sprites
  3300.         sprite.dispose
  3301.       end
  3302.       @_animation_sprites = nil
  3303.       @_animation = nil
  3304.     end
  3305.     @mirror = false
  3306.   end
  3307.   #--------------------------------------------------------------------------
  3308.   def animation_mirror(mirror_effect)
  3309.     @mirror = mirror_effect
  3310.   end
  3311.   #--------------------------------------------------------------------------
  3312.   def animation_set_sprites(sprites, cell_data, position)
  3313.     for i in 0..15
  3314.       sprite = sprites[i]
  3315.       pattern = cell_data[i, 0]
  3316.       if sprite == nil or pattern == nil or pattern == -1
  3317.         sprite.visible = false if sprite != nil
  3318.         next
  3319.       end
  3320.       sprite.visible = true
  3321.       sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  3322.       if position == 3
  3323.         if self.viewport != nil
  3324.           sprite.x = self.viewport.rect.width / 2
  3325.           sprite.y = self.viewport.rect.height - 160
  3326.         else
  3327.           sprite.x = 320
  3328.           sprite.y = 240
  3329.         end
  3330.       else
  3331.         sprite.x = self.x - self.ox + self.src_rect.width / 2
  3332.         sprite.y = self.y - self.oy + self.src_rect.height / 2
  3333.         sprite.y -= self.src_rect.height / 4 if position == 0
  3334.         sprite.y += self.src_rect.height / 4 if position == 2
  3335.       end
  3336.       sprite.x += cell_data[i, 1]
  3337.       sprite.y += cell_data[i, 2]
  3338.       sprite.z = 2000
  3339.       if @mirror
  3340.         sprite.ox = 88
  3341.       else
  3342.         sprite.ox = 104
  3343.       end
  3344.       sprite.oy = 96
  3345.       sprite.zoom_x = cell_data[i, 3] / 100.0
  3346.       sprite.zoom_y = cell_data[i, 3] / 100.0
  3347.       sprite.angle = cell_data[i, 4]
  3348.       sprite.mirror = (cell_data[i, 5] == 1)
  3349.       if @mirror
  3350.         if sprite.mirror
  3351.           sprite.mirror = false
  3352.         else  
  3353.           sprite.mirror = true
  3354.         end
  3355.       end
  3356.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  3357.       sprite.blend_type = cell_data[i, 7]
  3358.     end
  3359.   end
  3360. end
  3361.  
  3362. #==============================================================================
  3363. # ■ Sprite_Damage
  3364. #==============================================================================
  3365. class Sprite_Damage < Sprite
  3366.   #--------------------------------------------------------------------------
  3367.   include N01
  3368.   #--------------------------------------------------------------------------
  3369.   def initialize(sprite, init_x_speed, init_y_speed, duration, mirror)
  3370.     super(nil)
  3371.     self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
  3372.     self.opacity = 255
  3373.     self.x = sprite.x
  3374.     self.y = sprite.y
  3375.     self.z = 3000
  3376.     self.ox = sprite.ox
  3377.     self.oy = sprite.oy
  3378.     @damage_mirror = mirror
  3379.     @now_x_speed = init_x_speed
  3380.     @now_y_speed = init_y_speed
  3381.     @potential_x_energy = 0.0
  3382.     @potential_y_energy = 0.0
  3383.     @duration = duration
  3384.   end
  3385.   #--------------------------------------------------------------------------
  3386.   def update
  3387.     @duration -= 1
  3388.     return unless @duration <= DMG_DURATION
  3389.     super
  3390.     n = self.oy + @now_y_speed
  3391.     if n <= 0
  3392.       @now_y_speed *= -1
  3393.       @now_y_speed /=  2
  3394.       @now_x_speed /=  2
  3395.     end
  3396.     self.oy  = [n, 0].max
  3397.     @potential_y_energy += DMG_GRAVITY
  3398.     speed = @potential_y_energy.floor
  3399.     @now_y_speed        -= speed
  3400.     @potential_y_energy -= speed
  3401.     @potential_x_energy += @now_x_speed if @damage_mirror if POP_MOVE
  3402.     @potential_x_energy -= @now_x_speed if !@damage_mirror if POP_MOVE
  3403.     speed = @potential_x_energy.floor
  3404.     self.ox             += speed
  3405.     @potential_x_energy -= speed
  3406.     case @duration
  3407.     when 1..10
  3408.       self.opacity -= 25
  3409.     when 0
  3410.       self.dispose
  3411.     end
  3412.   end
  3413. end
Expand to see the code.


This is the error message I'm getting
Image

Looking for a fix, I found out someone else had a similar issue years ago, but it was left unresolved.

I'd be willing to switch for another message system entirely...
I actually attempted using another one, Custom Message Script by Hodgeelmf
  1. #==============================================================================
  2. # ** Custom Message Script by Hodgeelmf **
  3. #
  4. #     Version 1.4
  5. #
  6. #       Version History
  7. #         1.0.0 - Basic functionality
  8. #         1.1.0 - Fixed issue with bubble size and bolded text
  9. #               Modified gold window
  10. #               Added /q function
  11. #         1.2.0 - Added Icon display
  12. #               Added Face Graphics
  13. #               Fixed Gold command iteration error (This is what formerly broke
  14. #                                                   the script)
  15. #               Added use of Windowskin Graphic
  16. #               Fixed sub window termination to be more natural
  17. #         1.3.0 - Added thought indicater option
  18. #               Added emotion colors
  19. #         1.4.0 - Fixed glitch when switching from Windowskin to Bubble mode
  20. #               Added function to disable bubble bouncing
  21. #         1.4.1 - Fixed text drawing issue when choices displayed without
  22. #               preceding message text
  23. #                 Created \nc command
  24. #
  25. #       **************UPDATE NOTE*******************
  26. #         This script displays all choices immediately after the text
  27. #         which precedes them.  I have added a command to prevent this
  28. #         should you elect to do so:
  29. #
  30. #               \nc
  31. #
  32. #           I see no reason to turn this into a toggle currently unless
  33. #           there were significant push for it
  34. #
  35. #
  36. #     Necessary updates
  37. #
  38. #       -Add other various functions like display hp, quest, etc.
  39. #
  40. #==============================================================================
  41. =begin
  42.  
  43. Welcome to the Custom Message script!
  44.  
  45. Installation instructions:
  46.  
  47. 1.  Install this script above Main, preferrably directly above
  48. 2.  Download attached graphics (message_bubble and pointer2)
  49.     and place in Graphics/Pictures
  50. 3.  That's it!
  51.  
  52. Message commands:
  53.  
  54. \e[x]   Display message over a map event
  55.  
  56.     By default, bubble messages display over the player's sprite.  Values
  57.     outside of the map events range will display over the player as well.
  58.  
  59. \c[x]   Change message text color (0-8)
  60.  
  61. \n[x]   Insert actor name
  62.  
  63. \v[x]   Insert variable value
  64.  
  65. \b      Toggle bold text
  66.  
  67. \w[x]   Wait control (0-999)
  68.  
  69.     Wait values are determined by frame.  40 FPS is the script rate.
  70.  
  71. \p      Pause control
  72.  
  73.     Forces the player to press enter before continuing.
  74.  
  75. \q      Forced ending
  76.  
  77.     Forces the message winddow to close once the character is encountered.
  78.     Typically best to use directly after a wait timer.
  79.    
  80. \f      Force position
  81.  
  82.     Forces a specific position for the message bubble.
  83.    
  84.     0 - Upper right of the sprite
  85.     1 - Upper left of the sprite
  86.     2 - Lower right of the sprite
  87.     3 - Lower left of the sprite
  88.    
  89. \g      Displays gold window
  90.  
  91.     Fades in the gold window to the bottom right corner of the screen.  To keep
  92.     it displayed after current message, add \g into the next master message.
  93.  
  94. \i[x]   Display icon
  95.  
  96.     Displays an icon from the "Icons" folder.  A constant array, Icons, is
  97.     compiled at runtime to store imported icon names in addition to RTP.
  98.    
  99. \z[x]   Display face graphic (found in Graphics/Faces - you may have to create this
  100.                                                         folder)
  101.  
  102.     Displays a face graphic on the left of the message.  Currently this script
  103.     only supports images with one face (as opposed to a whole faceset).
  104.  
  105. \t     Thought Bubble
  106.  
  107.         Uses thought indicater (ie two dots instead of mouth opening style)
  108.        
  109. \m[x]   Mood Coloring
  110.  
  111.         Changes bubble color to indicate speakers/thinkers mood (0-4)
  112.        
  113. \nc     Do not Display Choices
  114.  
  115.         Keeps choices from being appended to the text preceding them
  116.    
  117. \h[x]  Display Hp
  118.  
  119.     Not functioning at this point
  120.  
  121. \s[x]   Sub window controls (explained below)
  122.  
  123.  
  124.   Master - the message which controls sub windows
  125.   Sub - any message that displays as a part of a master
  126.    
  127.     1. The master message always has a higher z value than any sub messages
  128.     2. Sub message must immediately follow the master message and be in
  129.         consecutive order (ex. sub 0 must be the next event command after
  130.         the master message, sub 1 must be the next event command after
  131.         sub 0, etc.)
  132.     3. Sub messagge numbers do not reset after a master message.  For
  133.         example, if the first master messsage contains two sub messages,
  134.         the second master message with sub messages must begin with sub
  135.         message number 3, and so on.
  136.     4. Use \s[x] where x is the number of the sub message to indicate that
  137.         a particular message is a sub message
  138.     5. Call sub messages in a master message with \s[x] where x is the
  139.         number of the sub message.
  140.     6. There is no limit to the number of sub messages, but since text is
  141.         drawn one letter at a time, too many messages may cause lag.
  142.        
  143.   ***NOTE***
  144.       If any of these commands seem bulky, it is because there is a glitch in
  145.       the run script command in the event editor which does not allow for
  146.       single lines changing global variables to function properly.
  147.        
  148. Script commands (from the Event Editor):
  149.  
  150.   1. Choose message style (bubble, windowskin or invisible)
  151.      
  152.       ***** If you do not have the correct images in Graphics/Pictures
  153.       ***** the script will automatically change to WINDOWSKIN mode and
  154.       ***** change the default text color to white
  155.  
  156.       $game_system.message_text_mode = x
  157.      
  158.       TEXT_MODE_BUBBLE
  159.       TEXT_MODE_INVISIBLE
  160.       TEXT_MODE_WINDOWSKIN
  161.      
  162.   2. Enable or disable bubble bouncing (only applies when in TEXT_MODE_BUBBLE)
  163.  
  164.       $game_system.message_bubble_bounce = x
  165.      
  166.       BUBBLE_BOUNCE_ON
  167.       BUBBLE_BOUNCE_OFF
  168.      
  169.   2. Change position of invisible text
  170.  
  171.       $game_system.invisible_position = x
  172.      
  173.       INVISIBLE_POSITION_TOP
  174.       INVISIBLE_POSITION_MIDDLE
  175.       INVISIBLE_POSITION_BOTTOM
  176.       INVISIBLE_POSITION_BOOK(arbitrary value from one of my projects)
  177.      
  178.   3. Change outline text options
  179.  
  180.       $game_system.message_text_outline = x
  181.      
  182.       TEXT_NORMAL
  183.       TEXT_OUTLINE
  184.      
  185.   4. Change text speed
  186.  
  187.       $game_system.message_text_speed = x
  188.      
  189.       TEXT_SPEED_SLOW
  190.       TEXT_SPEED_MEDIUM
  191.       TEXT_SPEED_FAST
  192.  
  193.   5. Change text skip rate (one letter per frame up to all at once)
  194.      
  195.       $game_system.message_text_skip = x
  196.  
  197.       TEXT_SKIP_NORMAL  (1)
  198.       TEXT_SKIP_DOUBLE  (2)
  199.       TEXT_SKIP_TRIPLE  (3)
  200.       TEXT_SKIP_FULL
  201.  
  202.      
  203.   5. Change text size
  204.  
  205.       $game_system.message_text_size = x
  206.      
  207.       TEXT_SIZE_SMALL
  208.       TEXT_SIZE_MEDIUM
  209.       TEXT_SIZE_LARGE
  210.       TEXT_SIZE_JUMBO
  211.      
  212.   6. Change text font
  213.  
  214.       $game_system.message_text_font = x
  215.      
  216.       TEXT_FONT_DEFAULT
  217.       TEXT_FONT_CORSIVA
  218.      
  219.   7. Color Constants
  220.  
  221.       TEXT_COLOR_BLACK
  222.       TEXT_COLOR_WHITE
  223.      
  224.   8. Face Graphic Functions
  225.  
  226.       $game_system.face_graphic_type = x
  227.      
  228.   9. Face Graphic Constants
  229.  
  230.       FACE_GRAPHIC_FULL - typically a bust which looks better offset to the left
  231.                           and extending abovve the bubble
  232.       FACE_GRAPHIC_BOX -  traditional boxed in face graphics which need to be
  233.                           encased by the bubble to look correct
  234.      
  235.   10. Global Methods (for ease of access)
  236.  
  237.       message(string) - place in script box in event processing
  238.      
  239.       ***** Only place this command once per Event Script Box *****
  240.      
  241.       You may wish to have dialogue or entries that are longer than three
  242.       lines.  This global method allows you to supply a string to
  243.       $game_temp.message_text manually.  The best way to do so is to store
  244.       a message in a variable and pass it to the method.  In this example
  245.       script there is a Game_Messages class which has public methods that
  246.       assign a message to a variable.  For full games, it would be better
  247.       to create a text file to load from.  The best formatter to use is
  248.       %q (ex @message = %q(lots of text...can be multiple lines).  The
  249.       %q formatter mimicks the event dialogue box text editing format
  250.       so you can use single "\" characters instead of using "\\" or not
  251.       being able to use special characters at all.
  252.      
  253.       default_color(x) - set message default color
  254.      
  255.       Input either a number 0 through 8 or a Color object.
  256.      
  257.       face(string) - set default face graphic
  258.      
  259.       Use this method to supply a default face graphic for messages.  This graphic
  260.       has secondary priority to one explicitly declared in a message, so is useful
  261.       for largely unbroken monologues.
  262.      
  263.       clear_face - clears the default face graphic
  264.      
  265.       small_text
  266.       medium_text   - Shortcut methods to change $game_system.message_text_size
  267.       large_text
  268.       jumbo_text
  269.      
  270.       slow_text
  271.       fast_text     - Shortcut methods to change $game_system.messge_text_speed
  272.      
  273.            
  274.      
  275.                                       Enjoy! And remember to credit!
  276.  
  277. =end
  278.  
  279. #========================================================================
  280. #   Game_Messages
  281. #       You can easily create messages to display of any length using this
  282. #       Class or a similar one of your creation.
  283. #========================================================================
  284.  
  285.  
  286. class Game_Messages
  287.  
  288.   # This message is obviously far too long for a bubble message, but it looks
  289.   # quite good with a darkened screen tone
  290.  
  291.   # When loaded into a global variable, these class methods can be called to
  292.   # the event editor with two lines of code.  For your own projects, you will
  293.   # probably want a more sophisticated heirarchy.
  294.   def message_1
  295.     @message = %q(\c[0]\bMessage commands:\b
  296.  
  297. \c[6]\b\\e[x]\c[0]     Display message over a map event\b
  298.                     By default, bubble messages display over the player's sprite.  Values
  299.                     outside of the map events range will display over the player as well.
  300. \c[6]\b\\c[x]\c[0]     Change message text color (0-8)\b
  301. \c[6]\b\\n[x]\c[0]     Insert actor name\b
  302. \c[6]\b\\v[x]\c[0]     Insert variable value\b
  303. \c[6]\b\\\\b\c[0]        Toggle bold text\b
  304. \c[6]\b\\w[x]\c[0]     Wait control (0-999)\b
  305.                     Wait values are determined by frame.  40 FPS is the script rate.
  306. \c[6]\b\\\\p\c[0]        Pause control\b
  307.                     Forces the player to press enter before continuing.
  308. \c[6]\b\\\\q\c[0]        Forced ending\b
  309.                     Forces the message winddow to close once the character is encountered.
  310.                     Typically best to use directly after a wait timer.
  311. \c[6]\b\\\\f[x]\c[0]      Force position\b
  312.                     Forces a specific position for the message bubble.
  313.  
  314.                     \b0\b - Upper right of the sprite
  315.                     \b1\b - Upper left of the sprite
  316.                     \b2\b - Lower right of the sprite
  317.                     \b3\b - Lower left of the sprite
  318. \c[6]\b\\\\g\c[0]        Displays gold window\b
  319.                      Fades in the gold window to the bottom right corner of the screen.  To keep
  320.                      it displayed after current message, add \\\\g into the next master message.
  321. \c[6]\b\\\\i[x]\c[0]      Displays an icon from Graphics/Icons\b
  322. \c[6]\b\\\\z[x]\c[0]      Displays a face graphic from Graphics/Faces\b
  323.                      References an array compiled at runtime from Graphics/Faces.  You will have
  324.                      to create this folder and manually install files.                    
  325. \c[6]\b\\\\s[x]\c[0]     Sub window controls\b (see documentation for full instructions))
  326.   end
  327.  
  328.   def message_2
  329.     @message = %q(          \c[6]\b$game_system Properties\b\c[0]
  330.    
  331.               Change these properties in the Event Editor by using the Script command.  Begin with
  332.               $game_system, then add a "." followed by the property you wish to alter.  In the
  333.               Script command you will need to use two lines.  For example:
  334.              
  335.                           $game_system.message_text_speed =\
  336.                           TEXT_SPEED_FAST
  337.            
  338.           The properties are listed below with available values to the right.  For full
  339.           documentation, refer to the script instructions.
  340.          
  341.               \c[6]\bmessage_text_mode\b\c[0]             TEXT_MODE_INVISIBLE,TEXT_MODE_BUBBLE,TEXT_MODE_WINDOWSKIN
  342.               \c[6]\binvisible_position\b\c[0]                    INVISIBLE_POSITION_TOP,INVISIBLE_POSITION_MIDDLE,
  343.                                                                    INVISIBLE_POSITION_BOTTOM
  344.               \c[6]\bmessage_text_outline\b\c[0]          TEXT_NORMAL,TEXT_OUTLINE
  345.               \c[6]\bmessage_text_speed\b\c[0]           TEXT_SPEED_SLOW,TEXT_SPEED_MEDIUM,TEXT_SPEED_FAST
  346.               \c[6]\bmessage_text_size\b\c[0]               TEXT_SIZE_SMALL,TEXT_SIZE_MEDIUM,TEXT_SIZE_LARGE,
  347.                                                                   TEXT_SIZE_JUMBO
  348.               \c[6]\bmessage_text_font\b\c[0]               TEXT_FONT_DEFAULT, whatever constant you would
  349.                                                                    like to create
  350.               \c[6]\bmessage_text_skip\b\c[0]               TEXT_SKIP_NORMAL,TEXT_SKIP_DOUBLE,TEXT_SKIP_TRIPLE,
  351.                                                                   TEXT_SKIP_QUAD,
  352.                                                                   TEXT_SKIP_QUIN,TEXT_SKIP_FULL
  353.               \c[6]\bmessage_skip_disabled\b\c[0]       true,false
  354.               \c[6]\bface_graphic_type\b\c[0]                  FACE_GRAPHIC_BOX,FACE_GRAPHIC_FULL
  355.               \c[6]\bface_graphic_name\b\c[0]                file name of graphic - without folders
  356.               \c[6]\bdefault_color\b\c[0]                            any Color object
  357.               \c[6]\bmessage_text_outline_color\b\c[0]  any Color object)
  358.  
  359.   end
  360.    
  361. end
  362.  
  363. #========================================================================
  364. #   Global Variables - simplest way to create communication between
  365. #                       Interpreter and Window_Message
  366. #========================================================================
  367.  
  368. $separate_choices = false
  369.  
  370. #========================================================================
  371. #   Constant Declaration
  372. #========================================================================
  373.  
  374. # Stores the class methods for quick custom message access
  375. $game_messages = Game_Messages.new
  376.  
  377. BUBBLE_BOUNCE_ON = 1
  378. BUBBLE_BOUNCE_OFF = 0
  379.  
  380. BUBBLE_UPPER_LEFT = Rect.new(0,0,13,10)
  381. BUBBLE_LOWER_LEFT = Rect.new(0,10,13,9)
  382. BUBBLE_UPPER_RIGHT = Rect.new(13,0,12,10)
  383. BUBBLE_LOWER_RIGHT = Rect.new(13,10,12,9)
  384.  
  385. SKIN_UPPER_LEFT = Rect.new(128,0,10,10)
  386. SKIN_LOWER_LEFT = Rect.new(128,54,10,10)
  387. SKIN_UPPER_RIGHT = Rect.new(182,0,10,10)
  388. SKIN_LOWER_RIGHT = Rect.new(182,54,10,10)
  389.  
  390. TEXT_MODE_BUBBLE = 0
  391. TEXT_MODE_INVISIBLE = 1
  392. TEXT_MODE_WINDOWSKIN = 2
  393.  
  394. INVISIBLE_POSITION_TOP = [320,0]
  395. INVISIBLE_POSITION_MIDDLE = [320,240]
  396. INVISIBLE_POSITION_BOTTOM = [320,480]
  397. INVISIBLE_POSITION_BOOK = [460,35]
  398.  
  399. TEXT_NORMAL = 0
  400. TEXT_OUTLINE = 1
  401.  
  402. TEXT_SPEED_SLOW = 2
  403. TEXT_SPEED_MEDIUM = 1
  404. TEXT_SPEED_FAST = 0
  405.  
  406. TEXT_SKIP_NORMAL = 1
  407. TEXT_SKIP_DOUBLE = 2
  408. TEXT_SKIP_TRIPLE = 3
  409. TEXT_SKIP_QUAD = 4
  410. TEXT_SKIP_QUIN = 5
  411. TEXT_SKIP_FULL = 6
  412.  
  413. TEXT_SIZE_SMALL = 14
  414. TEXT_SIZE_MEDIUM = 16
  415. TEXT_SIZE_LARGE = 18
  416. TEXT_SIZE_JUMBO = 28
  417.  
  418. # Remember to set a common default or fallback font since some users won't have
  419. # them all
  420. TEXT_FONT_DEFAULT = "Arial"
  421. TEXT_FONT_CORSIVA = ["Monotype Corsiva", "Arial"]
  422. TEXT_FONT_BOLI = ["MV Boli", "Arial"]
  423. TEXT_FONT_COMICSANS = ["Comic Sans MS", "Arial"]
  424.  
  425. TEXT_COLOR_BLACK = Color.new(0,0,0)
  426. TEXT_COLOR_WHITE = Color.new(250,250,250)
  427.  
  428. FACE_GRAPHIC_FULL = 0
  429. FACE_GRAPHIC_BOX = 1
  430.  
  431. # Compile Icon array
  432. # RTP icons are best stored manually
  433. Icons = ['001-Weapon01','002-Weapon02','003-Weapon03','004-Weapon04'\
  434. ,'005-Weapon05','006-Weapon06','007-Weapon07','008-Weapon08'\
  435. ,'009-Shield01','010-Head01','011-Head02','012-Head03','013-Body01'\
  436. ,'014-Body02','015-Body03','016-Accessory01','017-Accessory02'\
  437. ,'018-Accessory03','019-Accessory04','020-Accessory05'\
  438. ,'021-Potion01','022-Potion02','023-Potion03','024-Potion04'\
  439. ,'025-Herb01','026-Herb02','027-Herb03','028-Herb04'\
  440. ,'029-Key01','030-Key02','031-Key03','032-Item01'\
  441. ,'033-Item02','034-Item03','035-Item04','036-Item05'\
  442. ,'037-Item06','038-Item07','039-Item08','040-Item09'\
  443. ,'041-Item10','042-Item11','043-Item12','044-Skill01'\
  444. ,'045-Skill02','046-Skill03','047-Skill04','048-Skill05'\
  445. ,'049-Skill06','050-Skill07']
  446.  
  447. # All icons in the icon folder are dynamically added at runtime
  448. ICON_FOLDER_PATH = Dir::getwd + "/Graphics/Icons/"
  449. dir = Dir.new(ICON_FOLDER_PATH)
  450. dir.each { |file|
  451.   if file != "." && file != ".."
  452.     Icons.push file
  453.   end
  454. }
  455.  
  456. # Compile Face array
  457. if File.directory? Dir::getwd + "/Graphics/Faces/"
  458.   Faces = []
  459.   FACE_FOLDER_PATH = Dir::getwd + "/Graphics/Faces/"
  460.   dir = Dir.new(FACE_FOLDER_PATH)
  461.   dir.each { |file|
  462.     if file != "." && file != ".."
  463.       Faces.push file
  464.     end
  465.   }
  466. end
  467.  
  468. #========================================================================
  469. #   Global Methods
  470. #       Use these methods to quickly modify basic settings or set text
  471. #       to $game_temp.message_text manually
  472. #========================================================================
  473.  
  474. def message(text)
  475.   $game_system.map_interpreter.message_waiting = true
  476.   $game_temp.message_proc = Proc.new { @message_waiting = false }
  477.   $game_temp.message_text = text
  478. end
  479.  
  480. def default_color(color)
  481.   # If an integer passed to the method
  482.   if color.class == Fixnum
  483.     case color
  484.     when 0
  485.       $game_system.default_color = TEXT_COLOR_BLACK
  486.     when 1
  487.       $game_system.default_color = Color.new(128, 128, 255, 255)
  488.     when 2
  489.       $game_system.default_color = Color.new(255, 128, 128, 255)
  490.     when 3
  491.       $game_system.default_color = Color.new(128, 255, 128, 255)
  492.     when 4
  493.       $game_system.default_color = Color.new(128, 255, 255, 255)
  494.     when 5
  495.       $game_system.default_color = Color.new(255, 128, 255, 255)
  496.     when 6
  497.       $game_system.default_color = Color.new(255, 255, 128, 255)
  498.     when 7
  499.       $game_system.default_color = Color.new(192, 192, 192, 255)
  500.     when 8
  501.       $game_system.default_color = TEXT_COLOR_WHITE
  502.     else
  503.       $game_system.default_color = TEXT_COLOR_BLACK
  504.     end
  505.   # If a Color class value is passed to the method
  506.   elsif color.class == Color
  507.     $game_sytem.default_color = color
  508.   end
  509.  
  510.   return true
  511. end
  512.  
  513. def mood_color(color)
  514.   case color
  515.   when 0
  516.     return Color.new(70,130,180,190)
  517.   when 1
  518.     return Color.new(178,34,34,190)
  519.   when 2
  520.     return Color.new(238,174,238,190)
  521.   when 3
  522.     return Color.new(139,136,120,180)
  523.   when 4
  524.     return Color.new(255,215,0,190)
  525.   end
  526. end
  527.  
  528. def face(name)
  529.   $game_system.face_graphic_name = name
  530. end
  531.  
  532. def clear_face
  533.   $game_system.face_graphic_name = nil
  534. end
  535.  
  536. def small_text
  537.   $game_system.message_text_size == TEXT_SIZE_SMALL
  538. end
  539.  
  540. def medium_text
  541.   $game_system.message_text_size == TEXT_SIZE_MEDIUM
  542. end
  543.  
  544. def large_text
  545.   $game_system.message_text_size == TEXT_SIZE_LARGE
  546. end
  547.  
  548. def jumbo_text
  549.   $game_system.message_text_size == TEXT_SIZE_JUMBO
  550. end
  551.  
  552. def slow_text
  553.   $game_system.message_text_speed == TEXT_SPEED_SLOW
  554. end
  555.  
  556. def fast_text
  557.   $game_system.message_text_speed == TEXT_SPEED_FAST
  558. end
  559.  
  560. #========================================================================
  561. #   Game Temp
  562. #
  563. #       @current_event - tracks the current game event for ease of access
  564. #========================================================================
  565.  
  566. class Game_Temp
  567.  
  568.   attr_accessor :current_event
  569.   attr_accessor :consecutive_gold_window
  570.  
  571.   alias old_initialize initialize
  572.  
  573.   def initialize
  574.     old_initialize
  575.     @current_event = nil
  576.     @consecutive_gold_window = false
  577.   end
  578.  
  579. end
  580.  
  581. #========================================================================
  582. #   Game System
  583. #
  584. #       Stores message text options
  585. #       Use $game_system to view and change values
  586. #========================================================================
  587.  
  588. class Game_System
  589.   attr_accessor :message_text_mode
  590.   attr_accessor :message_bubble_bounce
  591.   attr_accessor :invisible_position
  592.   attr_accessor :message_text_outline
  593.   attr_accessor :message_text_speed
  594.   attr_accessor :message_text_size
  595.   attr_accessor :message_text_font
  596.   attr_accessor :message_skip_disabled
  597.   attr_accessor :face_graphic_type
  598.   attr_accessor :face_graphic_name
  599.   attr_accessor :message_text_skip
  600.   attr_accessor :default_color
  601.   attr_accessor :message_text_outline_color
  602.  
  603.   alias old_initialize initialize
  604.  
  605.   def initialize
  606.     old_initialize
  607.     @message_text_mode = TEXT_MODE_BUBBLE
  608.     @message_bubble_bounce = BUBBLE_BOUNCE_ON
  609.     @invisible_position = INVISIBLE_POSITION_TOP
  610.     @message_text_outline = TEXT_NORMAL
  611.     @message_text_speed = TEXT_SPEED_FAST
  612.     @message_text_size = TEXT_SIZE_SMALL
  613.     @message_text_font = TEXT_FONT_DEFAULT
  614.     @message_text_skip = TEXT_SKIP_NORMAL
  615.     @message_skip_disabled = false
  616.     @face_graphic_type = FACE_GRAPHIC_BOX
  617.     @face_graphic_name = nil
  618.     @default_color = TEXT_COLOR_BLACK
  619.     @message_text_outline_color = TEXT_COLOR_WHITE
  620.    
  621.   end
  622.  
  623. end
  624.  
  625. #========================================================================
  626. #   Game Player
  627. #
  628. #        The only change is in the condition --if Input.trigger?(Input::C)--
  629. #        The change allows for $game_temp.message text to be manually
  630. #          altered and still function properly
  631. #========================================================================
  632.  
  633. class Game_Player
  634.   #--------------------------------------------------------------------------
  635.   # * Frame Update
  636.   #--------------------------------------------------------------------------
  637.   def update
  638.     # Remember whether or not moving in local variables
  639.     last_moving = moving?
  640.     # If moving, event running, move route forcing, and message window
  641.     # display are all not occurring
  642.     unless moving? or $game_system.map_interpreter.running? or
  643.            @move_route_forcing or $game_temp.message_window_showing
  644.       # Move player in the direction the directional button is being pressed
  645.       case Input.dir4
  646.       when 2
  647.         move_down
  648.       when 4
  649.         move_left
  650.       when 6
  651.         move_right
  652.       when 8
  653.         move_up
  654.       end
  655.     end
  656.     # Remember coordinates in local variables
  657.     last_real_x = @real_x
  658.     last_real_y = @real_y
  659.     super
  660.     # If character moves down and is positioned lower than the center
  661.     # of the screen
  662.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  663.       # Scroll map down
  664.       $game_map.scroll_down(@real_y - last_real_y)
  665.     end
  666.     # If character moves left and is positioned more let on-screen than
  667.     # center
  668.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  669.       # Scroll map left
  670.       $game_map.scroll_left(last_real_x - @real_x)
  671.     end
  672.     # If character moves right and is positioned more right on-screen than
  673.     # center
  674.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  675.       # Scroll map right
  676.       $game_map.scroll_right(@real_x - last_real_x)
  677.     end
  678.     # If character moves up and is positioned higher than the center
  679.     # of the screen
  680.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  681.       # Scroll map up
  682.       $game_map.scroll_up(last_real_y - @real_y)
  683.     end
  684.     # If not moving
  685.     unless moving?
  686.       # If player was moving last time
  687.       if last_moving
  688.         # Event determinant is via touch of same position event
  689.         result = check_event_trigger_here([1,2])
  690.         # If event which started does not exist
  691.         if result == false
  692.           # Disregard if debug mode is ON and ctrl key was pressed
  693.           unless $DEBUG and Input.press?(Input::CTRL)
  694.             # Encounter countdown
  695.             if @encounter_count > 0
  696.               @encounter_count -= 1
  697.             end
  698.           end
  699.         end
  700.       end
  701.       #-----------------------------------------------------------------
  702.       #  Allows messages to display without interruption when directly
  703.       #  assigned to $game_temp.message_text
  704.       #-----------------------------------------------------------------
  705.       # If C button was pressed
  706.       if Input.trigger?(Input::C) && $game_temp.message_text == nil
  707.         # Same position and front event determinant
  708.         check_event_trigger_here([0])
  709.         check_event_trigger_there([0,1,2])
  710.       end
  711.     end
  712.   end
  713. end
  714.  
  715. #========================================================================
  716. #   Interpreter
  717. #
  718. #       Edit forces the interpreter to wait to update until all messages
  719. #         currently on screen have finished writing
  720. #========================================================================
  721.  
  722.  
  723. class Interpreter
  724.  
  725.   attr_accessor :list
  726.   attr_accessor :index
  727.   attr_accessor :message_waiting
  728.  
  729.   alias old_update update
  730.  
  731.   def update
  732.    
  733.     #if $scene.message_window != nil && $scene.message_window.finished != nil
  734.     if $game_temp.message_text != nil
  735.       return
  736.     else
  737.       old_update
  738.       $game_temp.current_event = @event_id
  739.     end
  740.   end
  741.  
  742.   def command_101
  743.     # If other text has been set to message_text
  744.     if $game_temp.message_text != nil
  745.       # End
  746.       return false
  747.     end
  748.     # Check for consecutive gold window calls
  749.     temp_index = @index+1
  750.     loop do
  751.       case @list[temp_index].code
  752.       when 401
  753.         temp_index += 1
  754.       when 101
  755.         break
  756.       else
  757.         break
  758.       end
  759.     end
  760.    
  761.     # Search for consecutive message window with /g formatter
  762.     text = nil
  763.    
  764.     # Iterate through max possible message size
  765.     for i in 0...3
  766.       # Check for existence of list element before checking code
  767.       if @list[temp_index+i] != nil
  768.         # Search for /g
  769.         if @list[temp_index+i].code == 101 or @list[temp_index+i].code == 401
  770.           text = @list[temp_index+i].parameters[0].slice(/\\[Gg]/)
  771.           if text != nil
  772.             # Allows for gold window to continue after first message
  773.             $game_temp.consecutive_gold_window = true
  774.             break
  775.           end
  776.         end
  777.       end
  778.     end
  779.     # Turns consecutive flag off if need be
  780.     if $game_temp.consecutive_gold_window == true && text == nil
  781.       $game_temp.consecutive_gold_window = false
  782.     end
  783.     # Set message end waiting flag and callback
  784.     @message_waiting = true
  785.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  786.     # Set message text on first line
  787.     $game_temp.message_text = @list[@index].parameters[0] + "\n"
  788.     line_count = 1
  789.     # Loop
  790.     loop do
  791.       # If next event command text is on the second line or after
  792.       if @list[@index+1].code == 401
  793.         # Add the second line or after to message_text
  794.         $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
  795.         line_count += 1
  796.       # If event command is not on the second line or after
  797.       else        
  798.         # If next event command is show choices
  799.         if @list[@index+1].code == 102
  800.           # Make sure choice appellation is allowed
  801.           for choice in @list[@index+1].parameters[0]
  802.             if choice.slice(/\\[Nn][Cc]/)
  803.               $separate_choices = true
  804.               break
  805.             end
  806.           end
  807.           if $separate_choices == true
  808.             return
  809.           end
  810.           # Advance index
  811.           @index += 1
  812.           # Choices setup
  813.           $game_temp.choice_start = line_count
  814.           #Insert 5 spaces for indenting choices
  815.           for i in 0...@list[@index].parameters[0].size
  816.             if @list[@index].parameters[0][i].slice(0,5) != '     '
  817.               @list[@index].parameters[0][i].insert(0,'     ')
  818.             end
  819.           end
  820.           setup_choices(@list[@index].parameters)
  821.         # If next event command is input number
  822.         elsif @list[@index+1].code == 103
  823.           # If number input window fits on screen
  824.           if line_count < 4
  825.             # Advance index
  826.             @index += 1
  827.             # Number input setup
  828.             $game_temp.num_input_start = line_count
  829.             $game_temp.num_input_variable_id = @list[@index].parameters[0]
  830.             $game_temp.num_input_digits_max = @list[@index].parameters[1]
  831.           end
  832.         end
  833.         # Continue
  834.         return true
  835.       end
  836.       # Advance index
  837.       @index += 1
  838.     end
  839.   end
  840. end
  841.  
  842. #========================================================================
  843. #   Spriteset Map
  844. #
  845. #       Edit allows access to the character_sprites variable
  846. #       Use $game_map.character_sprites to access
  847. #========================================================================
  848.  
  849. class Spriteset_Map
  850.  
  851.   attr_accessor :character_sprites  
  852.  
  853. end
  854.  
  855. class Scene_Map
  856.  
  857.   attr_accessor :spriteset
  858.   attr_accessor :message_window
  859.  
  860. end
  861.  
  862. #========================================================================
  863. #   Window Base
  864. #
  865. #       Edit allows for color 8 (black)
  866. #========================================================================
  867.  
  868. class Window_Base < Window
  869.  
  870.   #--------------------------------------------------------------------------
  871.   # * Get Text Color
  872.   #     n : text color number (0-7)
  873.   #--------------------------------------------------------------------------
  874.   def text_color(n)
  875.     case n
  876.     when 0
  877.       return Color.new(250, 250, 250, 255)
  878.     when 1
  879.       return Color.new(45, 45, 255, 255)
  880.     when 2
  881.       return Color.new(255, 45, 45, 255)
  882.     when 3
  883.       return Color.new(45, 255, 45, 255)
  884.     when 4
  885.       return Color.new(45, 215, 215, 255)
  886.     when 5
  887.       return Color.new(255, 45, 255, 255)
  888.     when 6
  889.       return Color.new(230, 230, 15, 255)
  890.     when 7
  891.       return Color.new(125, 125, 125, 255)
  892.     when 8
  893.       return Color.new(0, 0, 0)
  894.     else
  895.       normal_color
  896.     end
  897.   end
  898.  
  899. end
  900.  
  901. #==============================================================================
  902. # ** Window_Gold
  903. #------------------------------------------------------------------------------
  904. #  The gold window has been modified to use an icon and some outlined text
  905. #==============================================================================
  906.  
  907. class Window_Gold_New < Window_Base
  908.   def initialize
  909.     @current_gold = $game_party.gold
  910.    
  911.     @icon = Sprite.new
  912.     @icon.opacity = 0
  913.     @icon.bitmap = Bitmap.new('Graphics/Icons/032-Item01')
  914.     @icon.ox = @icon.bitmap.width/2
  915.     @icon.oy = @icon.bitmap.height/2
  916.     @icon.x,@icon.y = 624,460
  917.    
  918.     draw_gold
  919.   end
  920.  
  921.   def update
  922.     refresh
  923.     @icon.opacity += 12 if @icon.opacity < 192
  924.     @gold.opacity += 12 if @gold.opacity < 192
  925.   end
  926.  
  927.   def refresh
  928.     if @current_gold != $game_party.gold
  929.       @current_gold = $game_party.gold
  930.       @gold.bitmap.clear
  931.       draw_gold
  932.     end
  933.   end
  934.  
  935.   def draw_gold
  936.     @gold = Sprite.new
  937.     @gold.opacity = 0
  938.     @gold.bitmap = Bitmap.new(100,32)
  939.     @gold.ox,@gold.oy = @gold.bitmap.width/2,@gold.bitmap.height/2
  940.     @gold.x = 560
  941.     @gold.y = 465
  942.     @gold.z = 50
  943.     @gold.bitmap.font.size = 18
  944.     @gold.bitmap.font.bold = true
  945.     @gold.bitmap.font.color = text_color(8)
  946.     @gold.bitmap.draw_text(22,0,75,30,$game_party.gold.to_s,2)
  947.     @gold.bitmap.draw_text(22,2,75,30,$game_party.gold.to_s,2)
  948.     @gold.bitmap.draw_text(21,1,75,30,$game_party.gold.to_s,2)
  949.     @gold.bitmap.draw_text(23,1,75,30,$game_party.gold.to_s,2)
  950.     @gold.bitmap.font.color = text_color(6)
  951.     @gold.bitmap.draw_text(22,1,75,30,@current_gold.to_s,2)
  952.   end
  953.  
  954.   def fade_out
  955.     @icon.opacity -= 48
  956.     @gold.opacity -= 48
  957.   end
  958.  
  959.   def dispose
  960.     @icon.bitmap.dispose
  961.     @icon.dispose
  962.     @gold.bitmap.dispose
  963.     @gold.dispose
  964.   end
  965.  
  966. end
  967.  
  968. #==============================================================================
  969. # ** Window_InputNumber
  970. #------------------------------------------------------------------------------
  971. #  This window is for inputting numbers, and is used within the
  972. #  message window.
  973. #==============================================================================
  974.  
  975. class Window_InputNumber < Window_Base
  976.  
  977.   attr_accessor :x
  978.   attr_accessor :y
  979.  
  980.   #--------------------------------------------------------------------------
  981.   # * Object Initialization
  982.   #     digits_max : digit count
  983.   #--------------------------------------------------------------------------
  984.   def initialize(digits_max,x=0,y=0,indent=0)
  985.     @digits_max = digits_max
  986.     @number = 0
  987.     @x = x
  988.     @y = y
  989.     @indent = indent
  990.     @count = 0
  991.     @move_right = true
  992.     # Calculate character width for drawing and tracking cursor movement
  993.     dummy_bitmap = Bitmap.new(32, 32)
  994.     dummy_bitmap.font.size = $game_system.message_text_size
  995.     dummy_bitmap.font.name = $game_system.message_text_font
  996.     @width = (dummy_bitmap.text_size('0').width\
  997.         + dummy_bitmap.text_size(' ').width)
  998.     @x = @x - (@width*@digits_max)
  999.     dummy_bitmap.dispose
  1000.     @index = 0
  1001.     # Create number display bitmap
  1002.     @number_window = Sprite.new
  1003.     @number_window.x = @x
  1004.     @number_window.y = @y
  1005.     @number_window.z = 15
  1006.     @number_window.bitmap = Bitmap.new(@width*@digits_max, 40)
  1007.     @number_window.bitmap.font.color = TEXT_COLOR_BLACK
  1008.     @number_window.bitmap.font.size = $game_system.message_text_size
  1009.     @number_window.bitmap.font.name = $game_system.message_text_font
  1010.     # Create the cursor to track input position
  1011.     create_cursor
  1012.   end
  1013.   #--------------------------------------------------------------------------
  1014.   # * Get Number
  1015.   #--------------------------------------------------------------------------
  1016.   def number
  1017.     return @number
  1018.   end
  1019.   #--------------------------------------------------------------------------
  1020.   # * Set Number
  1021.   #     number : new number
  1022.   #--------------------------------------------------------------------------
  1023.   def number=(number)
  1024.     @number = [[number, 0].max, 10 ** @digits_max - 1].min
  1025.     refresh
  1026.   end
  1027.   #--------------------------------------------------------------------------
  1028.   # * Create Cursor
  1029.   #--------------------------------------------------------------------------
  1030.   def create_cursor
  1031.     @cursor = Sprite.new
  1032.     @cursor.bitmap = Bitmap.new(32,5)
  1033.     @cursor.x = @number_window.x
  1034.     @cursor.y = @number_window.y\
  1035.               + @number_window.bitmap.text_size('0').height + 3
  1036.     @cursor.z = 16
  1037.     @cursor.opacity = 185
  1038.     width = @number_window.bitmap.text_size('0').width + 2
  1039.     @cursor.bitmap.fill_rect(0,0,width,2,text_color(1))
  1040.   end
  1041.   #--------------------------------------------------------------------------
  1042.   # * Cursor Update
  1043.   #--------------------------------------------------------------------------
  1044.   def update_cursor
  1045.     @count += 1
  1046.     if @count % 10 == 0
  1047.       if @move_right == true
  1048.         @cursor.x += 1
  1049.       else
  1050.         @cursor.x -= 1
  1051.       end
  1052.       if @count == 20
  1053.         if @move_right == true
  1054.           @move_right = false
  1055.         else
  1056.           @move_right = true
  1057.         end
  1058.         @count = 0
  1059.       end
  1060.     end
  1061.   end
  1062.   #--------------------------------------------------------------------------
  1063.   # * Frame Update
  1064.   #--------------------------------------------------------------------------
  1065.   def update
  1066.     update_position
  1067.     # If up or down directional button was pressed
  1068.     if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
  1069.       $game_system.se_play($data_system.cursor_se)
  1070.       # Get current place number and change it to 0
  1071.       place = 10 ** (@digits_max - 1 - @index)
  1072.       n = @number / place % 10
  1073.       @number -= n * place
  1074.       # If up add 1, if down substract 1
  1075.       n = (n + 1) % 10 if Input.repeat?(Input::UP)
  1076.       n = (n + 9) % 10 if Input.repeat?(Input::DOWN)
  1077.       # Reset current place number
  1078.       @number += n * place
  1079.       refresh
  1080.     end
  1081.     # Cursor right
  1082.     if Input.repeat?(Input::RIGHT)
  1083.       if @digits_max >= 2
  1084.         $game_system.se_play($data_system.cursor_se)
  1085.         @index = (@index + 1) % @digits_max
  1086.         @cursor.x += @width
  1087.         if @index == 0
  1088.           @cursor.x = @number_window.x
  1089.         end
  1090.       end
  1091.     end
  1092.     # Cursor left
  1093.     if Input.repeat?(Input::LEFT)
  1094.       if @digits_max >= 2
  1095.         $game_system.se_play($data_system.cursor_se)
  1096.         @index = (@index + @digits_max - 1) % @digits_max
  1097.         @cursor.x -= @width
  1098.         if @index == @digits_max - 1
  1099.           @cursor.x += @width * @digits_max
  1100.         end
  1101.       end
  1102.     end
  1103.     update_cursor
  1104.   end
  1105.  
  1106.   #--------------------------------------------------------------------------
  1107.   # * Dispose
  1108.   #--------------------------------------------------------------------------
  1109.  
  1110.   def dispose
  1111.     @number_window.bitmap.clear
  1112.     @number_window = nil
  1113.     @cursor.bitmap.clear
  1114.     @cursor = nil
  1115.   end
  1116.  
  1117.   #--------------------------------------------------------------------------
  1118.   # * Update Position for Bubble Movement
  1119.   #--------------------------------------------------------------------------
  1120.  
  1121.   def update_position
  1122.     if @number_window.x != @x
  1123.       @number_window.x = @x
  1124.       @cursor.x = @number_window.x + (@index * @width)
  1125.     end
  1126.     if @number_window.y != @y
  1127.       @number_window.y = @y
  1128.       @cursor.y = @number_window.y\
  1129.                 + @number_window.bitmap.text_size('0').height + 3
  1130.     end    
  1131.   end
  1132.  
  1133.   #--------------------------------------------------------------------------
  1134.   # * Refresh
  1135.   #--------------------------------------------------------------------------
  1136.   def refresh
  1137.     @number_window.bitmap.clear
  1138.     s = sprintf("%0*d", @digits_max, @number)
  1139.     for i in 0...@digits_max
  1140.       @number_window.bitmap.draw_text(i * @width, 0, 32, 32, s[i,1])
  1141.     end
  1142.   end
  1143. end
  1144.  
  1145. #========================================================================
  1146. #   Window Message
  1147. #
  1148. #       Controls message displayed from the show text event command
  1149. #
  1150. #       This modified version also allows for a message to be displayed
  1151. #         from a script.  Simply change $game_temp.message_text to
  1152. #         whatever text you want to display.  Remember that outside
  1153. #         of the message entry box in the event commands, you will have
  1154. #         to manuall insert the newline character "\n".)
  1155. #========================================================================
  1156.  
  1157. class Window_Message < Window_Base
  1158.  
  1159.   attr_accessor :contents_showing
  1160.   attr_accessor :finished
  1161.   attr_accessor :fade_in
  1162.   attr_accessor :fade_out
  1163.   attr_accessor :message
  1164.   attr_accessor :enter_pressed
  1165.  
  1166.   #--------------------------------------------------------------------------
  1167.   # * Object Initialization
  1168.   #
  1169.   #       Prepare message variables, then wait for re_initialize
  1170.   #--------------------------------------------------------------------------
  1171.   def initialize(sub=false, text=nil)
  1172.     # Bubble message variables
  1173.     @enter_pressed = false
  1174.     @text_height = 0
  1175.     @fade_in = false
  1176.     @event = 0
  1177.     @contents_showing = false
  1178.     @finished = nil
  1179.     @position = ''
  1180.     @active = false
  1181.     @lines = 0
  1182.     @up = 0
  1183.     @count = 0
  1184.     @cursor_count = 0
  1185.     @cursor_move_right = nil
  1186.     @wait = 0
  1187.     @wait_add = 0
  1188.     @pause = false
  1189.     @index = 0
  1190.     @sub = sub
  1191.     @face = nil
  1192.     @face_extension_x = 0
  1193.     @face_extension_y = 0
  1194.     @thought = false
  1195.     @bubble_color = nil
  1196.     @hp = nil
  1197.     if @sub == false
  1198.       @sub_number = nil
  1199.       @sub_windows = []
  1200.     end
  1201.     @indent = false
  1202.     @text = text
  1203.   end
  1204.   #--------------------------------------------------------------------------
  1205.   # * Re_Initialize
  1206.   #
  1207.   #       Call when actual text processing occurs
  1208.   #--------------------------------------------------------------------------
  1209.     def re_initialize
  1210.      
  1211.       if $game_temp.message_text != nil
  1212.         # Prevent improper cursor indention on choices
  1213.         @indent = false
  1214.         if $game_system.face_graphic_name != nil
  1215.           @face = $game_system.face_graphic_name
  1216.         else
  1217.           @face = nil
  1218.         end
  1219.         @face_extension_x = 0
  1220.         @face_extension_y = 0
  1221.        
  1222.         temp = Sprite.new
  1223.         temp = Bitmap.new(32,32)
  1224.         # Set @text to whatever text will display
  1225.         # For sub messages this will already be set
  1226.         if @text == nil
  1227.           @text = $game_temp.message_text
  1228.         end
  1229.        
  1230.         # Change \ escaped characters to character codes for processing
  1231.         prep_text
  1232.        
  1233.         # Determine number of lines in the message
  1234.         @lines = 0
  1235.         @text.each_line {|line|
  1236.           @lines += 1
  1237.         }
  1238.        
  1239.         temp_text = @text.clone
  1240.         # Get rid of any non displayed elements to determine the
  1241.         #   appropriate message box size
  1242.        
  1243.         def get_digits(integer)
  1244.           if integer < 10
  1245.             return 1
  1246.           elsif integer >= 10
  1247.             return 2
  1248.           elsif integer >= 100
  1249.             return 3
  1250.           end
  1251.         end
  1252.        
  1253.         while temp_text.slice(/\001\[([0-9]+)\]/)
  1254.           temp_text.slice!(/\001\[([0-9]+)\]/)
  1255.         end
  1256.        
  1257.         while temp_text.slice(/\002/)
  1258.           temp_text.slice!(/\002/)
  1259.         end
  1260.        
  1261.         while temp_text.slice(/\004\[([0-9]+)\]/)
  1262.           temp_text.slice!(/\004\[([0-9]+)\]/)
  1263.         end
  1264.        
  1265.         while temp_text.slice(/\005\[([0-9]+)\]/) != nil
  1266.           temp_text.slice!(/\005\[([0-9]+)\]/)
  1267.         end
  1268.        
  1269.         while temp_text.slice(/\006/)
  1270.           temp_text.slice!(/\006/)
  1271.         end
  1272.        
  1273.         while temp_text.slice(/\007\[([0-9]+)\]/)
  1274.           temp_text.slice!(/\007\[([0-9]+)\]/)
  1275.         end
  1276.        
  1277.         while temp_text.slice(/\011/) != nil
  1278.           temp_text.slice!(/\011/)
  1279.         end
  1280.                
  1281.         while temp_text.slice(/\015\[([0-9]+)\]/)
  1282.           temp_text.slice!(/\015\[([0-9]+)\]/)
  1283.           @face = Faces[$1.to_i]
  1284.         end
  1285.        
  1286.         # Make sure @thought is false unless specified true
  1287.         @thought = false
  1288.         while temp_text.slice(/\017/)
  1289.           temp_text.slice!(/\017/)
  1290.           @thought = true
  1291.           @text.slice!(/\017/)
  1292.         end
  1293.        
  1294.         # Change @bubble_color to keep default color unless specified other color
  1295.         @bubble_color = nil
  1296.         while temp_text.slice(/\018\[([0-9]+)\]/)
  1297.           temp_text.slice!(/\018\[([0-9]+)\]/)
  1298.           @bubble_color = mood_color($1.to_i)
  1299.           @text.slice!(/\018\[([0-9]+)\]/)
  1300.         end
  1301.        
  1302.         # Determine message bubble size
  1303.         bitmap = Sprite.new
  1304.         bitmap.bitmap = Bitmap.new(32,32)
  1305.         bitmap.bitmap.font.name = $game_system.message_text_font
  1306.         bitmap.bitmap.font.size = $game_system.message_text_size
  1307.         @text_rect = Rect.new(0,0,0,0)
  1308.         @line_width = []
  1309.         i = 0
  1310.         temp_text.each_line {|line|
  1311.           temp = bitmap.bitmap.text_size(line)
  1312.           @line_width[i] = temp.width
  1313.           if temp.width > @text_rect.width
  1314.             @text_rect.width = temp.width
  1315.           end
  1316.           @text_height = temp.height
  1317.           i += 1
  1318.         }
  1319.        
  1320.         # Add space for number input if necessary
  1321.         if $game_temp.num_input_variable_id > 0 && @sub == false
  1322.           @lines += 1
  1323.         end
  1324.  
  1325.         @text_rect.height = @text_height * @lines
  1326.        
  1327.         total_size = 0
  1328.         longest_line = 0
  1329.         current_line_height = @text_height
  1330.         @line_height_correction = [0,0,0,0]
  1331.         line = 0
  1332.         skip = 0
  1333.        
  1334.         for i in 0...temp_text.size
  1335.           # Check for bold toggling and icon insertion
  1336.           if temp_text[i] == 3
  1337.             bitmap.bitmap.font.bold == false ? bitmap.bitmap.font.bold = true : bitmap.bitmap.font.bold = false
  1338.           end
  1339.           # Check for icon insertion and add 24 pixels to this line's width
  1340.           if temp_text[i] == 12
  1341.             # Add sufficient width for an icon to be inserted in the text
  1342.             total_size += 24
  1343.             # Adjust the height of the text box if necessary
  1344.             if current_line_height < 24
  1345.               current_line_height = 24
  1346.               @text_rect.height += (24 - @text_height)
  1347.               @line_height_correction[line] = (24 - @text_height)
  1348.             end
  1349.             # Set variable to skip over icon text in sizing operations
  1350.             skip = 4
  1351.           end
  1352.           # Check for face graphic
  1353.           if temp_text[i] == 13
  1354.             temp_text.slice(/\015\[([0-9]+)\]/)
  1355.             skip = 4
  1356.             @face = Faces[$1.to_i]
  1357.           end
  1358.           # Check for new line character
  1359.           if temp_text[i] == 10
  1360.             total_size = 0
  1361.             current_line_height = @text_height
  1362.             line += 1
  1363.           end
  1364.           # Do not size characters relating to an icon
  1365.           if skip == 0
  1366.             total_size += bitmap.bitmap.text_size(temp_text.slice(i,1)).width
  1367.           else
  1368.             skip -= 1
  1369.           end
  1370.           # Make sure longest line sets the bubble width value
  1371.           longest_line = total_size if total_size > longest_line
  1372.         end
  1373.        
  1374.         # Insert facce graphic name if none explicit in message and
  1375.         # one is stored in $game_system
  1376.         if $game_system.face_graphic_name != nil && temp_text.slice(/\015\[([0-9]+)\]/) == nil
  1377.           @face = $game_system.face_graphic_name
  1378.         end
  1379.         # Account for face graphic in message box graphic
  1380.         if @face != nil
  1381.           determine_face_extension
  1382.         else
  1383.           @face_extension_x = 0
  1384.           @face_extension_y = 0
  1385.         end
  1386.        
  1387.         if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
  1388.           @text_rect.width = longest_line
  1389.         else
  1390.           @text_rect.width = longest_line + @face_extension_x
  1391.         end
  1392.  
  1393.         # Set start values for text drawing
  1394.         @x=@y=0
  1395.         # Determine message position and create the message bubble
  1396.         #(only if $game_system.message_text_mode == TEXT_MODE_BUBBLE        
  1397.         if $game_system.message_text_mode != TEXT_MODE_INVISIBLE
  1398.           # Check for existence of necessary Bubble files if mode is set to Bubble
  1399.           if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  1400.             # Correct text mode if files do not exist
  1401.             if File.exist?("Graphics/Pictures/Message_Bubble.png") == false || \
  1402.               File.exist?("Graphics/Pictures/Pointer2.png") == false
  1403.               $game_system.message_text_mode = TEXT_MODE_WINDOWSKIN
  1404.               default_color(8)
  1405.             end
  1406.           end            
  1407.           determine_position
  1408.           create_bubble
  1409.         else
  1410.           @bubble_correction_y = 0
  1411.           @message_box = Sprite.new
  1412.           @message_box.bitmap = Bitmap.new(@text_rect.width+25, @text_rect.height+26)
  1413.           @message_box.ox = @message_box.bitmap.width/2
  1414.           @message_box.oy = @message_box.bitmap.height/2
  1415.           @message_box.x = $game_system.invisible_position[0]
  1416.           @message_box.y = $game_system.invisible_position[1]
  1417.           if @message_box.y - @message_box.bitmap.height/2 < 0
  1418.             @message_box.y += @message_box.bitmap.height/2
  1419.           elsif @message_box.y + @message_box.bitmap.height/2 > 480
  1420.             @message_box.y -= @message_box.bitmap.height/2
  1421.           end
  1422.         end
  1423.         # Create message sprite for drawing actual text
  1424.         @message = Sprite.new
  1425.         @message.x = @message_box.x
  1426.         @message.y = @message_box.y
  1427.         if @sub == false
  1428.           @message.z += 1
  1429.         end
  1430.         @message.ox = @message_box.ox
  1431.         @message.oy = @message_box.oy
  1432.         @message.bitmap = \
  1433.           Bitmap.new(@message_box.bitmap.width,@message_box.bitmap.height)
  1434.         @message.bitmap.font.size = $game_system.message_text_size
  1435.         @message.bitmap.font.color = TEXT_COLOR_BLACK
  1436.         @speed = $game_system.message_text_speed
  1437.         @text_color = $game_system.default_color
  1438.       end
  1439.     end
  1440.   #--------------------------------------------------------------------------
  1441.   # * Dispose
  1442.   #--------------------------------------------------------------------------
  1443.   def dispose
  1444.     terminate_message
  1445.     $game_temp.message_window_showing = false
  1446.     if @input_number_window != nil
  1447.       @input_number_window.dispose
  1448.     end
  1449.   end
  1450.  
  1451.   #--------------------------------------------------------------------------
  1452.   # * Subs Finished?
  1453.   #
  1454.   #       Checks to see if all sub messages have finished writing
  1455.   #--------------------------------------------------------------------------
  1456.   def subs_finished?
  1457.     abort_flag = true
  1458.     count = 0
  1459.     for sub in @sub_windows
  1460.       count += 1 if (sub.finished == true && sub.enter_pressed == false)
  1461.       if sub.finished && sub.enter_pressed
  1462.         sub.enter_pressed = false
  1463.       end
  1464.     end
  1465.     abort_flag = false if count == @sub_windows.size
  1466.     if abort_flag == true
  1467.       return false
  1468.     else
  1469.       return true
  1470.     end
  1471.   end
  1472.  
  1473.   #--------------------------------------------------------------------------
  1474.   # * Erase Subs
  1475.   #
  1476.   #       Erases any existing subb messages
  1477.   #--------------------------------------------------------------------------
  1478.   def erase_subs
  1479.     if @sub_windows != nil
  1480.       for sub in @sub_windows
  1481.         sub.fade_out = true
  1482.       end
  1483.     end
  1484.   end
  1485.   #--------------------------------------------------------------------------
  1486.   # * Terminate Message
  1487.   #--------------------------------------------------------------------------
  1488.   def terminate_message
  1489.     # Call message callback
  1490.     if @message != nil
  1491.       @message_box.bitmap.clear
  1492.       @message.z -= 1
  1493.       @message.bitmap.clear
  1494.     end
  1495.     if @cursor != nil
  1496.       @cursor.bitmap.clear
  1497.       @cursor.dispose
  1498.       @cursor = nil
  1499.     end
  1500.     if $game_temp.message_proc != nil
  1501.       $game_temp.message_proc.call
  1502.     end
  1503.     # Clear variables related to text, choices, and number input
  1504.     $game_temp.message_text = nil
  1505.     $game_temp.message_proc = nil
  1506.     $game_temp.choice_start = 99
  1507.     $game_temp.choice_max = 0
  1508.     $game_temp.choice_cancel_type = 0
  1509.     $game_temp.choice_proc = nil
  1510.     $game_temp.num_input_start = 99
  1511.     $game_temp.num_input_variable_id = 0
  1512.     $game_temp.num_input_digits_max = 0
  1513.     # Dispose of gold window
  1514.     if @gold_window != nil && $game_temp.consecutive_gold_window == false
  1515.       @gold_window.dispose
  1516.       @gold_window = nil
  1517.     end
  1518.     @contents_showing = false
  1519.     @finished = nil
  1520.     @active = false
  1521.     $game_temp.message_window_showing = false
  1522.     @text = nil
  1523.     if @sub == false
  1524.       erase_subs
  1525.       temp = subs_finished?
  1526.       if temp == true
  1527.         for i in 0...@sub_windows.size
  1528.           @sub_windows[i] = nil
  1529.         end
  1530.         @sub_windows = []
  1531.       end
  1532.     end
  1533.     @sub_number = nil
  1534.   end
  1535.   #--------------------------------------------------------------------------
  1536.   # * Draw_Message
  1537.   #--------------------------------------------------------------------------
  1538.   def draw_message
  1539.    
  1540.     if @pause == true
  1541.       return
  1542.     end
  1543.    
  1544.     if @text == nil
  1545.       return
  1546.     end
  1547.    
  1548.     # Indent if choice and following message text
  1549.     index = $game_system.map_interpreter.index - 2
  1550.     code = $game_system.map_interpreter.list[index].code
  1551.  
  1552.     # Check for choice following a line of text
  1553.     if @y == $game_temp.choice_start && (code == 101 || code == 401) \
  1554.       && @indent == false && $separate_choices == false
  1555.       @indent = true
  1556.       #@x = 16 + @face_extension_x
  1557.     end
  1558.    
  1559.     if @wait == 0
  1560.  
  1561.       # Set correction for icon insertion
  1562.       y_correction = 0
  1563.       for i in 0..@y
  1564.         if @line_height_correction[i] != nil
  1565.           y_correction += @line_height_correction[i]
  1566.         end
  1567.       end
  1568.       # Set offset value dependant on text mode
  1569.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  1570.         offset = 10
  1571.       elsif $game_system.message_text_mode == TEXT_MODE_BUBBLE
  1572.         offset = 13
  1573.       else
  1574.         offset = 0
  1575.       end
  1576.  
  1577.       y = @text_y + (@text_height * @y) + @bubble_correction_y + y_correction
  1578.      
  1579.       # Insert face graphic if included
  1580.       if @text.slice!(/\015\[([0-9]+)\]/) || @face != nil
  1581.         draw_face
  1582.       end
  1583.      
  1584.       # Check for formatting options character from text
  1585.       @c = @text[0,1].slice(/./m)
  1586.       case @c
  1587.       # If \\
  1588.       when "\000"
  1589.         # Return to original text
  1590.         @c = "\\"
  1591.         @text.sub!("\000") {"\\"}
  1592.         return
  1593.       # If \C[n]
  1594.       when "\001"
  1595.         # Change text color
  1596.         @text.sub!(/\[([0-9]+)\]/, "")
  1597.         color = $1.to_i
  1598.         if color >= 0 and color <= 8
  1599.           @message.bitmap.font.color = text_color(color)
  1600.           @text_color = text_color(color)
  1601.         end
  1602.         @text.slice!("\001")
  1603.         # go to next text
  1604.         return
  1605.       # If \G
  1606.       when "\002"
  1607.         # Make gold window
  1608.         if @gold_window == nil
  1609.           @gold_window = Window_Gold_New.new
  1610.           #@gold_window.x = 560 - @gold_window.width
  1611.           if $game_temp.in_battle
  1612.           #  @gold_window.y = 192
  1613.           else
  1614.           #  @gold_window.y = 0
  1615.           end
  1616.           #@gold_window.opacity = @message.opacity
  1617.           #@gold_window.back_opacity = 200
  1618.         end
  1619.         @text.slice!("\002")
  1620.         # go to next text
  1621.         return
  1622.       # If \B
  1623.       when "\003"
  1624.         if @message.bitmap.font.bold == false
  1625.           @message.bitmap.font.bold = true
  1626.         else
  1627.           @message.bitmap.font.bold = false
  1628.         end
  1629.         @text.slice!("\003")
  1630.         return
  1631.       # If sub window is being called
  1632.       when "\004"
  1633.         @text.slice!("\004")
  1634.         @text.sub!(/\[([0-9]+)\]/, "")
  1635.         if @sub == false
  1636.           @sub_number = $1
  1637.           event_key = $game_temp.current_event
  1638.           # Find the cooresponding slave window
  1639.           # Must immediately follow master window and be
  1640.           # in consecutive order
  1641.           num = 0
  1642.           index = 0
  1643.           if $game_system.map_interpreter.list[$game_system.map_interpreter.index].code == 101 \
  1644.             && num != @sub_number.to_i
  1645.             for i in $game_system.map_interpreter.index\
  1646.               ...$game_system.map_interpreter.list.size
  1647.               if $game_system.map_interpreter.list[i].code == 101
  1648.                 num = $game_system.map_interpreter.list[i].parameters[0].slice(/\\[Ss]\[([0-9]+)\]/)
  1649.                 num = num.slice(/([0-9]+)/).to_i if num!= nil
  1650.                 if num != nil
  1651.                   if num != @sub_number.to_i
  1652.                     num += 1
  1653.                   end
  1654.                   index = i
  1655.                 end
  1656.                 if num == @sub_number.to_i
  1657.                   break
  1658.                 end
  1659.               end
  1660.             end
  1661.           else
  1662.             index = $game_system.map_interpreter.index
  1663.           end
  1664.           $game_system.map_interpreter.index = index
  1665.           # Save original index value for later
  1666.           original_index = $game_system.map_interpreter.index
  1667.           lines = 1
  1668.           if $game_system.map_interpreter.list[index].code == 101
  1669.             # Loop until the cooresponding \s[x] character is found
  1670.             loop do
  1671.               # Break if there is nothing more to sort through
  1672.               if $game_system.map_interpreter.list[index] == nil
  1673.                 break
  1674.               end
  1675.               # Check the \s[x] for a match with the initial match in master message
  1676.               temp = $game_system.map_interpreter.list[index].parameters.clone
  1677.               number = temp[0].slice(/\\[Ss]\[([0-9]+)\]/)
  1678.               if number != nil
  1679.                 number = number.slice(/[0-9]+/)
  1680.               end
  1681.               # If the proper match is found, create sub window
  1682.               if number == @sub_number
  1683.                 # Create message text for sub message
  1684.                 # Make sure sub message begins at first line
  1685.                 while $game_system.map_interpreter.list[index].code != 101
  1686.                   index -= 1
  1687.                 end
  1688.                 text = $game_system.map_interpreter.list[index].parameters[0].clone
  1689.                 if $game_system.map_interpreter.list[index+1].code == 401
  1690.                   text = text + "\n"
  1691.                   lines += 1
  1692.                 end
  1693.                 # Continue to add text if there is something to be added
  1694.                 if $game_system.map_interpreter.list[index+1].code == 401
  1695.                   # Loop until all sub message text is added
  1696.                   loop do
  1697.                     index += 1
  1698.                     text = text + $game_system.map_interpreter.list[index].parameters[0].clone
  1699.                     if $game_system.map_interpreter.list[index+1].code == 401
  1700.                       text = text + "\n"
  1701.                       lines += 1
  1702.                     else
  1703.                       break
  1704.                     end
  1705.                   end
  1706.                 end
  1707.                 # If last sub window, set event index
  1708.                 if @text.slice("\004") == nil
  1709.                   $game_system.map_interpreter.index = index + 1
  1710.                 end
  1711.                 # Create actual sub window object and place it into
  1712.                 # @sub_windows array for update and disposal
  1713.                 sub = Window_Message.new(true,text)
  1714.                 @sub_windows.push sub
  1715.                 break
  1716.               else
  1717.                 index += 1
  1718.               end
  1719.             end # end loop
  1720.           return
  1721.           end # end if code == 101
  1722.         end
  1723.       # When \w[x]
  1724.       when "\005"
  1725.         @text.slice!(/\005\[([0-9]+)\]/)
  1726.         @wait_add = $1.to_i
  1727.         @wait += @wait_add
  1728.         @wait_add = 0
  1729.         return
  1730.       # When \p
  1731.       when "\006"
  1732.         @text.slice!("\006")
  1733.         if @enter_pressed == false
  1734.           @pause = true
  1735.         end
  1736.         return
  1737.       # When \q
  1738.       when "\011"
  1739.         terminate_message
  1740.         return
  1741.       # When \i[x]
  1742.       when "\014"  
  1743.         @text.slice!(/\014\[([0-9]+)\]/)
  1744.         icon = Sprite.new
  1745.         icon.opacity = 0
  1746.         icon.bitmap = Bitmap.new("Graphics/Icons/#{Icons[$1.to_i]}")
  1747.         true_y = @text_y + (@y * @text_height) + y_correction #+ y + @face_extension_y - (@text_rect.height + 25)
  1748.         @message.bitmap.blt(offset+@x+@face_extension_x,true_y,icon.bitmap,Rect.new(0,0,24,24))
  1749.         @x += 24
  1750.       # When \h[x]
  1751.       when "\016"
  1752.         @text.slice!(/\016\[([0-9]+)\]/)
  1753.         @hp = $game_party.actors[$1.to_i].hp
  1754.       end
  1755.      
  1756.       # Get 1 character from text
  1757.       @c = @text.slice!(/./m)
  1758.  
  1759.       if @c == nil
  1760.         @finished = true
  1761.         if $game_temp.choice_max > 0
  1762.           @cursor_move_right = true
  1763.           @index = 0
  1764.           create_cursor
  1765.           $separate_choices = false
  1766.         elsif $game_temp.num_input_variable_id > 0 && @sub == false
  1767.           digits_max = $game_temp.num_input_digits_max
  1768.           number = $game_variables[$game_temp.num_input_variable_id]
  1769.           x = @message.x + @message.bitmap.width/2 - 13
  1770.           y = @message.y - @message.bitmap.height/2\
  1771.               + @text_height * (@y) + @bubble_correction_y
  1772.           @input_number_window = Window_InputNumber.new(digits_max,x,y,@face_extension_x)
  1773.           @input_number_window.number = number
  1774.         end
  1775.         return
  1776.       end
  1777.       # If new line text
  1778.       if @c == "\n"
  1779.         # Add 1 to y
  1780.         @y += 1
  1781.         @x = 0
  1782.         # Indent if choice
  1783.         if @y >= $game_temp.choice_start
  1784.           @x = 0
  1785.         end
  1786.         # go to next text
  1787.         return
  1788.       end
  1789.       # Draw text    
  1790.       @message.bitmap.font.name = $game_system.message_text_font
  1791.       # Set exact y value for drawing
  1792.       if @face_extension_y != 0
  1793.         true_y = y + @face_extension_y - (@text_rect.height + 25)
  1794.       else
  1795.         true_y = y
  1796.       end
  1797.      
  1798.       true_y = @text_y + @y*@text_height + y_correction
  1799.      
  1800.       if $game_system.message_text_outline == TEXT_OUTLINE
  1801.         if $game_system.message_text_outline == TEXT_OUTLINE
  1802.           @message.bitmap.font.color = $game_system.message_text_outline_color
  1803.         elsif @message.bitmap.font.color != $game_system.default_color
  1804.           @message.bitmap.font.color = $game_system.default_color
  1805.         end
  1806.         # Correct character writing position for lower case "f"
  1807.         # due to Monotype Corsiva text writing glitch
  1808.         temp = @x
  1809.         if  @c == 'f' && $game_system.message_text_font == TEXT_FONT_CORSIVA
  1810.           @x -= 2
  1811.         end
  1812.         @message.bitmap.draw_text(offset+@x+@face_extension_x+1,true_y,40,32,@c)
  1813.         @message.bitmap.draw_text(offset+@x+@face_extension_x-1,true_y,40,32,@c)
  1814.         @message.bitmap.draw_text(offset+@x+@face_extension_x,true_y+1,40,32,@c)
  1815.         @message.bitmap.draw_text(offset+@x+@face_extension_x,true_y-1,40,32,@c)
  1816.        
  1817.         # Correct any change made to @x so that text is written
  1818.         # in the proper place
  1819.         if  @x != temp
  1820.           @x = temp
  1821.         end
  1822.        
  1823.       end
  1824.      
  1825.       @message.bitmap.font.color = @text_color
  1826.      
  1827.       # Correct character writing position for lower case "f"
  1828.       # due to Monotype Corsiva text writing glitch
  1829.       temp = @x
  1830.       if @c == 'f' && $game_system.message_text_font == TEXT_FONT_CORSIVA
  1831.         @x -= 2
  1832.       end
  1833.       @message.bitmap.draw_text(offset+@x+@face_extension_x,true_y,40,32,@c)
  1834.       # Correct any change made to @x so that text is written
  1835.       # in the proper place
  1836.       if @x != temp && $game_system.message_text_font == TEXT_FONT_CORSIVA
  1837.         @x = temp
  1838.       end
  1839.       # Add x to drawn text width
  1840.       @x += @message.bitmap.text_size(@c).width
  1841.       @wait = $game_system.message_text_speed
  1842.       @wait_add = 0
  1843.     else
  1844.       @wait -= 1
  1845.     end
  1846.   end
  1847.  
  1848.   #--------------------------------------------------------------------------
  1849.   # * Determine Face Extension
  1850.   #     This method determines how much distance needs to be added to the
  1851.   #     face graphic
  1852.   #--------------------------------------------------------------------------
  1853.   def determine_face_extension
  1854.     sprite = Sprite.new
  1855.     sprite.opacity = 0
  1856.     sprite.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
  1857.     # Set extension value in horizontal direction
  1858.     if @face != nil
  1859.       @face_extension_x = sprite.bitmap.width
  1860.       if $game_system.face_graphic_type == FACE_GRAPHIC_BOX
  1861.         @face_extension_x += 5
  1862.       end
  1863.       if sprite.bitmap.height > @text_rect.height
  1864.         @face_extension_y = sprite.bitmap.height - @text_rect.height
  1865.       end
  1866.     end
  1867.     sprite.bitmap.dispose
  1868.     sprite = nil
  1869.   end
  1870.  
  1871.   #--------------------------------------------------------------------------
  1872.   # * Draw Face Graphics
  1873.   #--------------------------------------------------------------------------
  1874.   def draw_face
  1875.     sprite = Sprite.new
  1876.     sprite.opacity = 0
  1877.     sprite.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
  1878.     rect = Rect.new(0,0,sprite.bitmap.width,sprite.bitmap.height)
  1879.     if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
  1880.       @message.bitmap.blt(0,0,sprite.bitmap,rect)
  1881.     else
  1882.       y = @text_y + 10
  1883.       @message.bitmap.blt(13,y,sprite.bitmap,rect)
  1884.     end
  1885.     sprite.bitmap.dispose
  1886.     sprite = nil
  1887.   end
  1888.  
  1889.   #--------------------------------------------------------------------------
  1890.   # * Refresh
  1891.   #--------------------------------------------------------------------------
  1892.   def refresh
  1893.     if @pause == false
  1894.       if Input.trigger?(Input::C) && $game_system.message_skip_disabled == false
  1895.         @enter_pressed = true
  1896.         until @c == nil || @text == nil
  1897.           draw_message
  1898.         end
  1899.         @enter_pressed = false if @sub == false
  1900.       else
  1901.         if $game_system.message_text_skip != TEXT_SKIP_FULL
  1902.           count = $game_system.message_text_skip
  1903.           for i in 0...count
  1904.             draw_message if (@c != nil || @text != nil)
  1905.           end
  1906.         else
  1907.           if @c == nil && @text != nil
  1908.             draw_message
  1909.           end
  1910.           until @c == nil || @text == nil
  1911.             draw_message
  1912.           end
  1913.         end
  1914.       end
  1915.     else
  1916.       if Input.trigger?(Input::C)
  1917.         temp = subs_finished?
  1918.         if temp == true
  1919.           erase_subs
  1920.           @pause = false
  1921.         end
  1922.       end
  1923.       draw_message
  1924.     end
  1925.   end
  1926.   #--------------------------------------------------------------------------
  1927.   # * Frame Update
  1928.   #--------------------------------------------------------------------------
  1929.   def update
  1930.     # Update sub messages if they exist
  1931.     if @sub_windows != nil
  1932.       for i in 0...@sub_windows.size
  1933.         @sub_windows[i].update
  1934.       end
  1935.     end
  1936.     # Update gold window if it exists
  1937.     if @gold_window != nil
  1938.       @gold_window.update
  1939.     end
  1940.     # Update bubble graphic
  1941.     if @active == true && ($game_system.message_text_mode == TEXT_MODE_BUBBLE \
  1942.       || $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN)
  1943.       update_bubble
  1944.     end
  1945.     # If fade in
  1946.     if @fade_in
  1947.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  1948.         max_opacity = 192
  1949.       else
  1950.         max_opacity = 255
  1951.       end
  1952.       @message_box.opacity += 24
  1953.       if @input_number_window != nil
  1954.         @input_number_window.contents_opacity += 24
  1955.       end
  1956.       if @message_box.opacity == max_opacity
  1957.         @fade_in = false
  1958.       end
  1959.       return
  1960.     end
  1961.    
  1962.     # If fade out
  1963.     if @fade_out
  1964.       @message_box.opacity -= 48
  1965.       @message.opacity -= 48
  1966.       if @cursor != nil
  1967.         @cursor.opacity -= 48
  1968.       end
  1969.       if @input_number_window != nil
  1970.         @input_number_window.contents_opacity -= 24
  1971.       end
  1972.       if @gold_window != nil && $game_temp.consecutive_gold_window == false
  1973.         @gold_window.fade_out
  1974.       end
  1975.       if @message_box.opacity == 0 && @message.opacity == 0
  1976.         @fade_out = false
  1977.         terminate_message if @sub == false
  1978.       end
  1979.       return
  1980.     end
  1981.    
  1982.     # If inputting number
  1983.     if @input_number_window != nil
  1984.       @input_number_window.update
  1985.       # Confirm
  1986.       if Input.trigger?(Input::C)
  1987.         $game_system.se_play($data_system.decision_se)
  1988.         $game_variables[$game_temp.num_input_variable_id] =
  1989.           @input_number_window.number
  1990.         $game_map.need_refresh = true
  1991.         # Dispose of number input window
  1992.         @input_number_window.dispose
  1993.         @input_number_window = nil
  1994.        
  1995.         if @sub_windows != nil
  1996.           temp = subs_finished?
  1997.           if temp == true
  1998.             @fade_out = true
  1999.             erase_subs
  2000.           end
  2001.         end
  2002.       end
  2003.       return
  2004.     end
  2005.     # If message is being displayed
  2006.     if @contents_showing && @finished == true
  2007.       # If choice isn't being displayed, show pause sign
  2008.       if $game_temp.choice_max == 0
  2009.         @active = true
  2010.       else
  2011.         update_cursor
  2012.       end
  2013.       # Cancel
  2014.       if Input.trigger?(Input::B)
  2015.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  2016.           $game_system.se_play($data_system.cancel_se)
  2017.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  2018.           terminate_message
  2019.         end
  2020.       end
  2021.       # Confirm
  2022.       if Input.trigger?(Input::C)
  2023.         if $game_temp.choice_max > 0
  2024.           $game_system.se_play($data_system.decision_se)
  2025.           $game_temp.choice_proc.call(@index)
  2026.         end
  2027.         if @sub_windows != nil
  2028.           temp = subs_finished?
  2029.           if temp == true
  2030.             @fade_out = true
  2031.             erase_subs
  2032.           end
  2033.         end
  2034.       end
  2035.       return
  2036.     end
  2037.     # If display wait message or choice exists when not fading out
  2038.     if $game_temp.message_text != nil && @finished == nil
  2039.       @contents_showing = true
  2040.       $game_temp.message_window_showing = true
  2041.       @finished = false
  2042.       re_initialize
  2043.       Graphics.frame_reset
  2044.       if @input_number_window != nil
  2045.         @input_number_window.contents_opacity = 0
  2046.       end
  2047.       @fade_in = true
  2048.       return
  2049.     elsif @finished == false
  2050.       refresh
  2051.       return
  2052.     end
  2053.   end
  2054.   #--------------------------------------------------------------------------
  2055.   # Create Message Bubble
  2056.   #--------------------------------------------------------------------------
  2057.   # Remember! The bubble will currently display based on the src_rect of
  2058.   # the $character_sprite bitmap...need to work on this...
  2059.  
  2060.   def create_bubble # Text can be multiple lines
  2061.     sprites = $scene.spriteset.character_sprites
  2062.     @event_x = sprites[@event].x
  2063.     @event_y = sprites[@event].y
  2064.     # Draw bubble bitmap to blt from
  2065.     bubble = Sprite.new
  2066.     if @position.include?('Flipped_Down')
  2067.       @bubble_correction_y = 7
  2068.     else
  2069.       @bubble_correction_y = 0
  2070.     end
  2071.     # Set basic x and y values for bubble drawing
  2072.     # If a face graphic will be drawn
  2073.     if @face != nil
  2074.       # If face graphic drawn outside bubble
  2075.       if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
  2076.         base_y = (@face_extension_y + @text_rect.height) - (@text_rect.height + 20)
  2077.         # If bubble is flipped horizontally
  2078.         if @position.include?('Mirror')
  2079.           base_x = 0
  2080.         else
  2081.           base_x = @face_extension_x
  2082.         end
  2083.         # If bubble is not flipped vertically
  2084.         if not @position.include?('Flipped_Down')
  2085.           base_y -= 6
  2086.         end
  2087.         base_height = @text_rect.height
  2088.         height_extension = @face_extension_y
  2089.         if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2090.           width_extension = @face_extension_x + 25
  2091.         elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2092.           width_extension = @face_extension_x + 20
  2093.         end
  2094.       # If face graphic drawn inside bubble
  2095.       else
  2096.         base_x = 0
  2097.         base_y = @bubble_correction_y
  2098.         base_height = @face_extension_y + @text_rect.height
  2099.         if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2100.           width_extension = 25
  2101.           height_extension = 20 + 6
  2102.         elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2103.           width_extension = 20
  2104.           height_extension = 20
  2105.         end
  2106.       end
  2107.     else
  2108.       base_x = 0
  2109.       base_y = @bubble_correction_y
  2110.       base_height = @text_rect.height
  2111.       if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2112.         height_extension = 20 + 7
  2113.         width_extension = 25
  2114.       elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2115.         height_extension = 20
  2116.         width_extension = 20
  2117.       end
  2118.     end
  2119.     base_width = @text_rect.width
  2120.    
  2121.     # Set text drawing starting coordinates
  2122.     @text_y = base_y
  2123.    
  2124.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2125.       bubble.bitmap = Bitmap.new("Graphics/Pictures/Message_Bubble")
  2126.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2127.       bubble.bitmap = Bitmap.new("Graphics/Windowskins/"+$data_system.windowskin_name)
  2128.     end
  2129.    
  2130.     # Make the bubble bitmap the appropriate size
  2131.     @message_box = Sprite.new
  2132.        
  2133.     true_width = base_width + width_extension
  2134.     true_height = base_height + height_extension
  2135.     @message_box.bitmap = Bitmap.new(true_width,true_height)
  2136.     @message_box.ox = @message_box.bitmap.width/2
  2137.     @message_box.oy = @message_box.bitmap.height/2
  2138.     @message_box.x = sprites[@event].x\
  2139.       + @message_box.bitmap.width/2\
  2140.       + sprites[@event].src_rect.width/2 - 15
  2141.     if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
  2142.       @message_box.x -= @face_extension_x
  2143.     end
  2144.     @message_box.y = sprites[@event].y\
  2145.       - ((sprites[@event].src_rect.height/3)*2)\
  2146.       - @message_box.oy
  2147.     if $game_system.face_graphic_type == FACE_GRAPHIC_FULL \
  2148.       && @position.include?('Flipped_Down')
  2149.       @message_box.y -= @face_extension_y
  2150.     end
  2151.     if @sub == false
  2152.       @message_box.z += 1
  2153.     end
  2154.    
  2155.     # Set rectangles for graphic block transfers
  2156.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2157.       upper_left = BUBBLE_UPPER_LEFT
  2158.       lower_left = BUBBLE_LOWER_LEFT
  2159.       upper_right = BUBBLE_UPPER_RIGHT
  2160.       lower_right = BUBBLE_LOWER_RIGHT
  2161.      
  2162.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2163.       background = Rect.new(base_x+1,base_y+1,base_width+20-2,base_height+20-2)
  2164.       source_rect = Rect.new(0,0,128,128)
  2165.       @message_box.bitmap.stretch_blt(background,bubble.bitmap,source_rect)
  2166.       upper_left = SKIN_UPPER_LEFT
  2167.       lower_left = SKIN_LOWER_LEFT
  2168.       upper_right = SKIN_UPPER_RIGHT
  2169.       lower_right = SKIN_LOWER_RIGHT
  2170.     end
  2171.    
  2172.     # Blt the upper left quadrant of the bubble
  2173.     rect = Rect.new(0,0,13,10)    
  2174.     @message_box.bitmap.blt(base_x,base_y,bubble.bitmap,upper_left)
  2175.    
  2176.     # Blt the lower left quadrant of the bubble
  2177.     rect.set(0,10,13,9)
  2178.     y = base_y + base_height + lower_left.height
  2179.     @message_box.bitmap.blt(base_x,y,bubble.bitmap,lower_left)
  2180.    
  2181.     # Blt the upper right quadrant of the bubble
  2182.     rect.set(13,0,12,10)
  2183.     x = base_x + base_width + upper_right.width
  2184.     @message_box.bitmap.blt(x,base_y,bubble.bitmap,upper_right)
  2185.    
  2186.     # Blt the lower right quadrant of the bubble
  2187.     rect.set(13,10,12,9)
  2188.     x = base_x + base_width + lower_right.width
  2189.     y = base_y + base_height + upper_right.height
  2190.     @message_box.bitmap.blt(x,y,bubble.bitmap,lower_right)
  2191.    
  2192.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2193.       # Fill in the left side gap
  2194.       rect.set(0,8,13,1)    
  2195.       x = base_x
  2196.       y = base_y + upper_left.height
  2197.       rect2 = Rect.new(x,y,13,base_height)
  2198.       @message_box.bitmap.stretch_blt(rect2,bubble.bitmap,rect)
  2199.        
  2200.       # Fill in the right side gap
  2201.       rect.set(13,8,12,1)
  2202.       x = base_x + base_width + upper_right.width
  2203.       y = base_y + upper_right.height
  2204.       rect2 = Rect.new(x,y,13,base_height)
  2205.       @message_box.bitmap.stretch_blt(rect2,bubble.bitmap,rect)
  2206.      
  2207.       # Fill in the middle gap    
  2208.       x = base_x + upper_left.width - 1
  2209.       y = base_y
  2210.       width = base_width
  2211.       height = base_height + upper_left.height + lower_left.height
  2212.       rect.set(x,y,1,height)
  2213.       rect2.set(x,y,base_width,height)
  2214.       @message_box.bitmap.stretch_blt(rect2,@message_box.bitmap,rect)
  2215.    
  2216.       # Place character pointer either below or above bubble
  2217.       if @position.include?('Flipped_Down')
  2218.         if @thought == false
  2219.           rect.set(15,19,10,8)
  2220.         else
  2221.           rect.set(25,8,10,8)
  2222.         end
  2223.         x = base_x + 9
  2224.         y = base_y - @bubble_correction_y
  2225.         @message_box.bitmap.blt(x,y,bubble.bitmap,rect)
  2226.         @message_box.y = sprites[@event].y\
  2227.           - ((sprites[@event].src_rect.height/3)*2)\
  2228.           + @message_box.oy - @face_extension_y#- (offset_y-@text_rect.height-20)
  2229.       else
  2230.         if @thought == false
  2231.           rect.set(0,19,10,8)
  2232.         else
  2233.           rect.set(25,0,10,8)
  2234.         end
  2235.         x = base_x + 9
  2236.         y = base_y + base_height + 17
  2237.         @message_box.bitmap.blt(x,y,bubble.bitmap,rect)
  2238.       end
  2239.       if @position.include?('Mirror')
  2240.         @message_box.mirror = true
  2241.         @message_box.x = sprites[@event].x\
  2242.           - sprites[@event].src_rect.width/2\
  2243.           - @message_box.bitmap.width/2 + 15 + base_x #+offset_x
  2244.       end
  2245.     # Fill in rim of a windowskin box
  2246.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2247.      
  2248.       # Top rim
  2249.       dest_rect = Rect.new(base_x+10,base_y,base_width,10)
  2250.       source_rect = Rect.new(148,0,24,10)
  2251.       @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
  2252.      
  2253.       # Bottom rim
  2254.       dest_rect = Rect.new(base_x+10,base_y+base_height+20-10,base_width,10)
  2255.       source_rect = Rect.new(148,54,24,10)
  2256.       @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
  2257.      
  2258.       # Left rim
  2259.       dest_rect = Rect.new(base_x,base_y+10,10,base_height)
  2260.       source_rect = Rect.new(128,10,10,44)
  2261.       @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
  2262.      
  2263.       # Right rim
  2264.       dest_rect = Rect.new(base_x+base_width+20-10,base_y+10,10,base_height)
  2265.       source_rect = Rect.new(182,10,10,44)
  2266.       @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
  2267.      
  2268.     end
  2269.     # Prepare bubble for up/down animation
  2270.     @up = true
  2271.     @message_box.opacity = 0
  2272.     @fade_in = true
  2273.     # Dispose of the blted bubble
  2274.     bubble.bitmap.dispose
  2275.     bubble = nil
  2276.     @contents_showing = true
  2277.     @active = true
  2278.    
  2279.     if @bubble_color.class == Color
  2280.       @message_box.color = @bubble_color
  2281.     end
  2282.  
  2283.   end
  2284.   #--------------------------------------------------------------------------
  2285.   # * Determine Bubble Position
  2286.   #--------------------------------------------------------------------------
  2287.   def determine_position(no_text=false)
  2288.    
  2289.     sprites = $scene.spriteset.character_sprites
  2290.    
  2291.     @position = ''
  2292.     # Check upper screen boundary
  2293.     temp = @text_rect.height + 25 + sprites[@event].src_rect.height
  2294.     if sprites[@event].y - temp < 0
  2295.       @position += 'Flipped_Down'
  2296.     end
  2297.     temp = @text_rect.width + 45
  2298.     if sprites[@event].x\
  2299.       + sprites[@event].src_rect.width/2 + temp > 640
  2300.       @position += 'Mirror'
  2301.     end
  2302.     if no_text == false
  2303.       if @text.slice(/\007\[([0-9]+)\]/)
  2304.         #c = @text.slice(/[0-9]+/).to_i
  2305.         @text.slice!(/\007\[([0-9]+)\]/)
  2306.         c = $1.to_i
  2307.         @position = ''
  2308.         if c == 0
  2309.           @position = ''
  2310.         elsif c == 1
  2311.           @position = 'Flipped_Down'
  2312.         elsif c == 2
  2313.           @position = 'Mirror'
  2314.         elsif c == 3
  2315.           @position = 'Flipped_Down Mirror'
  2316.         end
  2317.       end
  2318.     end
  2319.   end
  2320.   #--------------------------------------------------------------------------
  2321.   # * Bubble Graphic Update
  2322.   #--------------------------------------------------------------------------
  2323.   def update_bubble
  2324.    
  2325.     # Create an easier to use access point to the screen sprites
  2326.     sprites = $scene.spriteset.character_sprites
  2327.    
  2328.     # Bounce bubble
  2329.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE \
  2330.         && $game_system.message_bubble_bounce == BUBBLE_BOUNCE_ON
  2331.      
  2332.       @count += 1
  2333.      
  2334.       if @count % 10 == 0 && @up == true
  2335.         @message_box.y -= 1
  2336.         if @input_number_window != nil
  2337.           @input_number_window.y -= 1
  2338.         end
  2339.         if @cursor != nil
  2340.           @cursor.y -= 1
  2341.         end
  2342.         if @count == 20
  2343.           @count = 0
  2344.           @up = false
  2345.         end
  2346.       elsif @count % 10 == 0 && @up == false
  2347.         @message_box.y += 1
  2348.         if @input_number_window != nil
  2349.           @input_number_window.y += 1
  2350.         end
  2351.         if @cursor != nil
  2352.           @cursor.y += 1
  2353.         end
  2354.         if @count == 20
  2355.           @count = 0
  2356.           @up = true
  2357.         end
  2358.       end
  2359.     end
  2360.        
  2361.     x = @event_x
  2362.     y = @event_y
  2363.    
  2364.     @event_x = sprites[@event].x
  2365.     @event_y = sprites[@event].y
  2366.    
  2367.     if @event_x != x || @event_y != y
  2368.            
  2369.       if @event_x != x
  2370.         @message_box.x = @message_box.x + (@event_x - x)
  2371.         if @input_number_window != nil
  2372.           @input_number_window.x = @input_number_window.x + (@event_x-x)
  2373.         end
  2374.         if @cursor != nil
  2375.           @cursor.x = @cursor.x + (@event_x - x)
  2376.         end
  2377.       end
  2378.      
  2379.       if @event_y - @face_extension_y != y
  2380.         @message_box.y = @message_box.y + (@event_y - y)
  2381.         if @input_number_window != nil
  2382.           @input_number_window.y = @input_number_window.y + (@event_y-y)
  2383.         end
  2384.         if @cursor != nil
  2385.           @cursor.y = @cursor.y + (@event_y - y)
  2386.         end
  2387.       end
  2388.          
  2389.       change = false
  2390.       # Check upper screen boundary
  2391.       temp = @message_box.y - @message_box.bitmap.height/2
  2392.       if temp < 0 && (@position.include?('Flipped_Down') == false)
  2393.         change = true
  2394.       end
  2395.       # Check lower screen boundary
  2396.       temp = @message_box.y + @message_box.bitmap.height/2
  2397.       if temp > 480
  2398.         change = true
  2399.       end
  2400.       # Check right screen boundary
  2401.       temp = @message_box.x + @message_box.bitmap.width/2
  2402.       if temp > 640
  2403.         change = true
  2404.       end
  2405.       # Check left screen boundary
  2406.       temp = @message_box.x - @message_box.bitmap.width/2
  2407.       if temp < 0
  2408.         change = true
  2409.       end
  2410.      
  2411.       if change == true
  2412.         @message_box.bitmap.clear
  2413.         determine_position(true)
  2414.         create_bubble
  2415.         if @cursor != nil
  2416.           reset_cursor
  2417.         end
  2418.         if @position.include?('Flipped_Down')
  2419.           get_text
  2420.         end
  2421.         @message_box.z -= 1
  2422.       end
  2423.        
  2424.  
  2425.     end
  2426.    
  2427.     @message.y = @message_box.y
  2428.     @message.x = @message_box.x      
  2429.  
  2430.   end
  2431.  
  2432.   #--------------------------------------------------------------------------
  2433.   # * Get Message Text
  2434.   #--------------------------------------------------------------------------
  2435.  
  2436.   def get_text
  2437.    
  2438.     index = $game_system.map_interpreter.index - 1
  2439.     until $game_system.map_interpreter.list[index].code == 101
  2440.       index -= 1
  2441.     end
  2442.     old_text = @text.clone
  2443.     @text = ""
  2444.     @lines.times do
  2445.       if $game_system.map_interpreter.list[index].code == 102 \
  2446.         || $game_system.map_interpreter.list[index].code == 402
  2447.         for i in 0...$game_system.map_interpreter.list[index].parameters.size
  2448.           if $game_system.map_interpreter.list[index].parameters[0][i].class == String
  2449.             @text = @text + $game_system.map_interpreter.list[index].parameters[0][i].clone + "\n"
  2450.           end
  2451.         end
  2452.       else        
  2453.         @text = @text + $game_system.map_interpreter.list[index].parameters[0].clone + "\n"
  2454.       end
  2455.       index += 1
  2456.     end
  2457.    
  2458.     prep_text
  2459.     @message.bitmap.clear
  2460.     @x = 0
  2461.     @x += 10 if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2462.     @y = 0
  2463.     begin
  2464.       draw_message
  2465.     end until @text == old_text
  2466.   end
  2467.  
  2468.   #--------------------------------------------------------------------------
  2469.   # * Prepare Text for processing
  2470.   #--------------------------------------------------------------------------
  2471.  
  2472.   def prep_text
  2473.     # Determine what event the message will be over
  2474.     if @text.slice!(/\\[Ee]\[([0-9]+)\]/) == nil
  2475.       @event = -1 # Default to over player
  2476.     else
  2477.       @event = $1.to_i - 1
  2478.     end
  2479.     # Control text processing
  2480.     begin
  2481.       @last_text = @text.clone
  2482.       @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  2483.     end until @text == @last_text
  2484.     @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  2485.       $game_actors[$1.to_i] != nil ? "#{$game_actors[$1.to_i].name}" : ""
  2486.     end
  2487.     # Change "\\\\" to "\000" for convenience
  2488.     @text.gsub!(/\\\\/) { "\000" }
  2489.     # Change "\\C" to "\001" and "\\G" to "\002"
  2490.     #   and "\\B" to "\003" and "\\S" to "\004"
  2491.     #   and "\\W" to "\005" and "\\p" to "\006"
  2492.     #   and "\\F" to "\007" and "\\q" to "\011"
  2493.     #   and "\\I" to "\014  and "\\z" to "\015"
  2494.     #   and "\\T" to "\017  and "\\m" to "\018"
  2495.  
  2496.     while @text.slice(/\\[Cc]\[([0-9]+)\]/) != nil
  2497.       @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  2498.     end
  2499.     @text.gsub!(/\\[Gg]/) { "\002" }
  2500.     @text.gsub!(/\\[Bb]/) { "\003" }
  2501.     @text.gsub!(/\\[Ss]/) { "\004" }
  2502.     while @text.slice(/\\[Ww]\[([0-9]+)\]/) != nil
  2503.       @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\005[#{$1}]" }
  2504.     end        
  2505.     while @text.slice(/\\[Pp]/) != nil
  2506.       @text.gsub!(/\\[Pp]/) { "\006" }
  2507.     end
  2508.     while @text.slice(/\\[Ii]/) != nil
  2509.       @text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\014[#{$1}]" }
  2510.     end
  2511.     while @text.slice(/\\[Zz]/) != nil
  2512.       # Check for face directory existence
  2513.       if File.directory? Dir::getwd + "/Graphics/Faces/"
  2514.         @text.slice(/\\[Zz]\[([0-9]+)\]/)
  2515.         # Check for file existence
  2516.         if Faces[$1.to_i] != nil
  2517.           @text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "\015[#{$1}]" }
  2518.         else
  2519.           @text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "" }
  2520.         end
  2521.       else
  2522.         @text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "" }
  2523.       end
  2524.     end
  2525.     while @text.slice(/\\[Hh]/) != nil
  2526.       @text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\016[#{$1}]" }
  2527.     end
  2528.     @text.gsub!(/\\[Ff]/) { "\007" }
  2529.     @text.gsub!(/\\[Qq]/) { "\011" }
  2530.     @text.gsub!(/\\[Tt]/) { "\017" }
  2531.     while @text.slice(/\\[Mm]\[([0-9]+)]/)
  2532.       @text.gsub!(/\\[Mm]\[([0-9]+)]/) { "\018[#{$1}]" }
  2533.     end
  2534.     @text.slice!(/\\[Nn][Cc]/)
  2535.   end
  2536.   #--------------------------------------------------------------------------
  2537.   # * Create cursor graphic
  2538.   #--------------------------------------------------------------------------
  2539.   def create_cursor
  2540.    
  2541.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2542.       @cursor = Sprite.new
  2543.       @cursor.bitmap = Bitmap.new("Graphics/Pictures/Pointer2")
  2544.       @cursor.ox = @cursor.bitmap.width
  2545.       if $separate_choices == false
  2546.         indent = @message.bitmap.text_size("    ").width
  2547.       else
  2548.         indent = @message.bitmap.text_size("    ").width
  2549.       end
  2550.      
  2551.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2552.       template = Sprite.new
  2553.       template.opacity = 0
  2554.       template.bitmap = Bitmap.new("Graphics/Windowskins/"+$data_system.windowskin_name)
  2555.       source_rect = Rect.new(128,64,32,32)
  2556.       # Set width of the cursor rectangle
  2557.       width = @line_width[@lines-$game_temp.choice_max+@index]
  2558.       # Correct for added spaces in choices following main text
  2559.       width -= @message.bitmap.text_size('     ').width if @indent == true
  2560.       dest_rect = Rect.new(0,0,width,@text_height)
  2561.       if @cursor == nil
  2562.         @cursor = Sprite.new
  2563.       else
  2564.         @cursor.bitmap.clear
  2565.         @cursor.bitmap.dispose
  2566.       end
  2567.       @cursor.opacity = 255
  2568.       @cursor.bitmap = Bitmap.new(width,@text_height)
  2569.       # Upper left
  2570.       source_rect = Rect.new(128,64,3,3)
  2571.       @cursor.bitmap.blt(0,0,template.bitmap,source_rect)
  2572.       # Upper right
  2573.       source_rect = Rect.new(157,64,3,3)
  2574.       @cursor.bitmap.blt(width-3,0,template.bitmap,source_rect)
  2575.       # Lower left
  2576.       source_rect = Rect.new(128,93,3,3)
  2577.       @cursor.bitmap.blt(0,@text_height-3,template.bitmap,source_rect)
  2578.       # Lower right
  2579.       source_rect = Rect.new(157,93,3,3)
  2580.       @cursor.bitmap.blt(width-3,@text_height-3,template.bitmap,source_rect)
  2581.       # Top fill in
  2582.       source_rect = Rect.new(131,64,26,3)
  2583.       dest_rect = Rect.new(3,0,width-6,3)
  2584.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2585.       # Bottom fill in
  2586.       source_rect = Rect.new(131,93,26,3)
  2587.       dest_rect = Rect.new(3,@text_height-3,width-6,3)
  2588.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2589.       # Left fill in
  2590.       source_rect = Rect.new(128,67,3,@text_height-6)
  2591.       dest_rect = Rect.new(0,3,3,@text_height-6)
  2592.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2593.       # Right fill in
  2594.       source_rect = Rect.new(157,67,3,@text_height-6)
  2595.       dest_rect = Rect.new(width-3,3,3,@text_height-6)
  2596.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2597.       # Center fill in
  2598.       source_rect = Rect.new(131,67,26,26)
  2599.       dest_rect = Rect.new(3,3,width-6,@text_height-6)
  2600.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2601.      
  2602.       @cursor.ox = 0
  2603.       template.bitmap.clear
  2604.       template = nil
  2605.       indent = @message.bitmap.text_size("  ").width
  2606.     end
  2607.    
  2608.       @cursor.oy = @cursor.bitmap.height/2
  2609.      
  2610.       if @indent == true
  2611.         @cursor.x = @message.x - @message.ox + 14 + @face_extension_x + indent
  2612.       else
  2613.         @cursor.x = @message.x - @message.ox + @face_extension_x + indent
  2614.       end
  2615.  
  2616.       y_correction = 0
  2617.       @line_height_correction.each { |number|
  2618.           y_correction += number
  2619.       }
  2620.      
  2621.       @cursor.y = @message.y - @message.oy + @bubble_correction_y \
  2622.         + 10 + @text_height/2 + ((@lines-$game_temp.choice_max+@index)*@text_height)\
  2623.         + y_correction
  2624.       @cursor.z += 5
  2625.       # More accurately place windowskin rectangle
  2626.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2627.         @cursor.y -= 1
  2628.       end
  2629.       # Correct for bad sizing of bitmap draw_text method
  2630.       if $game_system.message_text_size == TEXT_SIZE_LARGE
  2631.         @cursor.y -= 2
  2632.       elsif
  2633.         $game_system.message_text_size == TEXT_SIZE_JUMBO
  2634.         @cursor.y -= 6
  2635.       end
  2636.    
  2637.   end  
  2638.   #--------------------------------------------------------------------------
  2639.   # * Reset cursor graphic
  2640.   #--------------------------------------------------------------------------
  2641.  
  2642.   def reset_cursor
  2643.    
  2644.     @cursor.x = @message_box.x - @message_box.ox + 16
  2645.     @cursor.y = @message_box.y - @message_box.oy\
  2646.       + ((@lines-$game_temp.choice_max + 1)*@text_height)\
  2647.       + @bubble_correction_y
  2648.   end
  2649.  
  2650.   #--------------------------------------------------------------------------
  2651.   # * Update cursor graphic
  2652.   #--------------------------------------------------------------------------
  2653.   def update_cursor
  2654.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2655.       modulus = 10
  2656.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2657.       modulus = 3
  2658.     end
  2659.    
  2660.     @cursor_count += 1
  2661.     if @cursor_count % modulus  == 0 && @cursor_move_right == true
  2662.       if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2663.         @cursor.x += 1
  2664.       elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2665.         @cursor.opacity -= 10
  2666.       end
  2667.       if @cursor_count == modulus * 5
  2668.         @cursor_count = 0
  2669.         @cursor_move_right = false
  2670.       end
  2671.      
  2672.     elsif @cursor_count % modulus == 0 && @cursor_move_right == false
  2673.       if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2674.         @cursor.x -= 1
  2675.       elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2676.         @cursor.opacity += 10
  2677.       end
  2678.      if @cursor_count == modulus * 5
  2679.         @cursor_count = 0
  2680.         @cursor_move_right = true
  2681.       end
  2682.     end
  2683.    
  2684.     if Input.trigger?(Input::UP)
  2685.       if @index != 0
  2686.         @cursor.y -= @text_height
  2687.         @index -= 1
  2688.       else
  2689.         @cursor.y += @text_height * ($game_temp.choice_max-1)
  2690.         @index = $game_temp.choice_max-1
  2691.       end
  2692.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2693.         create_cursor
  2694.       end
  2695.     elsif Input.trigger?(Input::DOWN)
  2696.       if @index != $game_temp.choice_max-1
  2697.         @cursor.y += @text_height
  2698.         @index += 1
  2699.       else
  2700.         @cursor.y -= @text_height * ($game_temp.choice_max-1)
  2701.         @index = 0
  2702.       end
  2703.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2704.         create_cursor
  2705.       end
  2706.     end
  2707.   end  
  2708.  
  2709. end
Expand to see the code.

While that one doesn't crash on entering a battle, it does crash when battle text would be displayed.
I thought of maybe figuring a way to temporarily disable it in gameplay
So, deactivate it before a fight that requires speech, using boring-default-speech, and then reactivate it
But my no-scripting-skills self couldn't figure how to do that without breaking anything.

I'm assuming the issues stem from the fact SBS uses non-default spritesets?... I'm not exactly a scripter, so I just stumble in the dark here. I figured maybe someone else could know how to actually fix this.

Is anyone able to help make this work?

Thank you for your patience.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=78994