LiTTleDRAgo

[RGSS] Method & Class Library (MACL) Part 2

May 20th, 2013
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 328.84 KB | None | 0 0
  1. #==============================================================================
  2. # ** RGSS.Windows
  3. #------------------------------------------------------------------------------
  4. # Description:
  5. # ------------
  6. # Methods created for window classes
  7. #  
  8. # Method List:
  9. # ------------
  10. #
  11. #   Window_Base
  12. #   -----------
  13. #   rect=
  14. #   rect
  15. #
  16. #   Window_Selectable
  17. #   -----------------
  18. #   oh
  19. #
  20. # Rewrote Methods:
  21. # ----------------
  22. #
  23. #   Window_Selectable
  24. #   -----------------
  25. #   top_row
  26. #   top_row=(top_row)
  27. #   page_row_max
  28. #   update_cursor_rect
  29. #==============================================================================
  30.  
  31. MACL::Loaded << 'RGSS.Windows'
  32.  
  33. #==============================================================================
  34. # ** Window_Base
  35. #==============================================================================
  36.  
  37. class Window_Base
  38.   #--------------------------------------------------------------------------
  39.   # * Name      : Set Window Rect
  40.   #   Info      : Sets rect size of window
  41.   #   Author    : SephirothSpawn
  42.   #   Call Info : Rect Object
  43.   #--------------------------------------------------------------------------
  44.   def rect=(r)
  45.     self.x, self.y, self.width, self.height = r.x, r.y, r.width, r.height
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # * Name      : Window Rect
  49.   #   Info      : Gets rect size of window
  50.   #   Author    : SephirothSpawn
  51.   #   Call Info : None
  52.   #--------------------------------------------------------------------------
  53.   def rect
  54.     return Rect.new(self.x, self.y, self.width, self.height)
  55.   end
  56. end
  57.  
  58. #==============================================================================
  59. # ** Window_Selectable
  60. #==============================================================================
  61.  
  62. class Window_Selectable
  63.   #--------------------------------------------------------------------------
  64.   # * Public Instance Variables
  65.   #--------------------------------------------------------------------------
  66.   attr_writer :oh
  67.   #--------------------------------------------------------------------------
  68.   # * Text Cursor Height
  69.   #--------------------------------------------------------------------------
  70.   def oh
  71.     return @oh.nil? ? 32 : @oh
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # * Get Top Row
  75.   #--------------------------------------------------------------------------
  76.   def top_row
  77.     # Divide y-coordinate of window contents transfer origin by 1 row
  78.     # height of self.oh
  79.     return self.oy / self.oh
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Set Top Row
  83.   #     row : row shown on top
  84.   #--------------------------------------------------------------------------
  85.   def top_row=(row)
  86.     # If row is less than 0, change it to 0
  87.     # If row exceeds row_max - 1, change it to row_max - 1
  88.     row = [[row, 0].max, row_max - 1].min
  89.     # Multiply 1 row height by 32 for y-coordinate of window contents
  90.     # transfer origin
  91.     self.oy = row * self.oh
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Get Number of Rows Displayable on 1 Page
  95.   #--------------------------------------------------------------------------
  96.   def page_row_max
  97.     # Subtract a frame height of 32 from the window height, and divide it by
  98.     # 1 row height of self.oh
  99.     return (self.height - 32) / self.oh
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # * Update Cursor Rectangle
  103.   #--------------------------------------------------------------------------
  104.   def update_cursor_rect
  105.     # If cursor position is less than 0
  106.     if @index < 0
  107.       self.cursor_rect.empty
  108.       return
  109.     end
  110.     # Get current row
  111.     row = @index / @column_max
  112.     # If current row is before top row
  113.     if row < self.top_row
  114.       # Scroll so that current row becomes top row
  115.       self.top_row = row
  116.     end
  117.     # If current row is more to back than back row
  118.     if row > self.top_row + (self.page_row_max - 1)
  119.       # Scroll so that current row becomes back row
  120.       self.top_row = row - (self.page_row_max - 1)
  121.     end
  122.     # Calculate cursor width
  123.     cursor_width = self.width / @column_max - 32
  124.     # Calculate cursor coordinates
  125.     x = @index % @column_max * (cursor_width + 32)
  126.     y = @index / @column_max * self.oh - self.oy
  127.     if self.active == true
  128.       # Update cursor rectangle
  129.       self.cursor_rect.set(x, y, cursor_width, self.oh)
  130.     end
  131.   end
  132. end
  133.  
  134. #==============================================================================
  135. # ** Classes.Array_2D                                                By: Selwyn
  136. #------------------------------------------------------------------------------
  137. # Two Dimensional Array
  138. #  
  139. #   - by default, resizing the array will destroy the data it contains.
  140. #   - calling any of the following methods of the Array class might mess up
  141. #     the data's indexes, so be careful before using them.
  142. #
  143. #    unshift   uniq!   slice!   shift   reverse!   replace   reject!
  144. #    push   <<    pop   map!   flatten!   fill   delete_if   delete_at
  145. #    delete   concat   compact!   collect!
  146. #
  147. #==============================================================================
  148.  
  149. MACL::Loaded << 'Classes.Array_2D'
  150.  
  151. #==============================================================================
  152. # ** Array_2D
  153. #==============================================================================
  154.  
  155. class Array_2D
  156.   #--------------------------------------------------------------------------
  157.   # * Public Instance Variables
  158.   #--------------------------------------------------------------------------
  159.   attr_reader   :xsize
  160.   attr_reader   :ysize
  161.   #-------------------------------------------------------------------------
  162.   # * Name      : Object Initialization
  163.   #   Info      : Creates a new 2D Array Object
  164.   #   Author    : Selwyn
  165.   #   Call Info : Two Arguments Integer xsize, ysize - dimensions
  166.   #-------------------------------------------------------------------------
  167.   def initialize(xsize, ysize)
  168.     @xsize = xsize
  169.     @ysize = ysize
  170.     make_array
  171.   end
  172.   #-------------------------------------------------------------------------
  173.   # * Name      : Element Reference
  174.   #   Info      : Gets an Element returns Element At ID or X,Y
  175.   #   Author    : Selwyn
  176.   #   Call Info : One-Two Arguments
  177.   #               One - Integer id - id of the element to get
  178.   #               Two - Integer x,y - X and Y.
  179.   #-------------------------------------------------------------------------
  180.   def [](*args)
  181.     case args.size
  182.     when 1
  183.       return @data[args[0]]
  184.     when 2
  185.       return @data[id(*args)]
  186.     end
  187.   end
  188.   #-------------------------------------------------------------------------
  189.   # * Name      : Element Assignment
  190.   #   Info      : Assigns an Object to Element
  191.   #   Author    : Selwyn
  192.   #   Call Info : Two-Three Arguments
  193.   #               Two Integer id - id of the Element to set
  194.   #                  Object obj - object assigned to id
  195.   #               Three Integer x,y - X and Y.
  196.   #                  Object obj - object assigned to id.
  197.   #-------------------------------------------------------------------------
  198.   def []=(*args)
  199.     case args.size
  200.     when 2
  201.       @data[args[0]] = args[1]
  202.     when 3
  203.       @data[id(args[0], args[1])] = args[2]
  204.     end
  205.   end
  206.   #-------------------------------------------------------------------------
  207.   # * Name      : Set X Size
  208.   #   Info      : Sets Width of 2D Array
  209.   #   Author    : Selwyn
  210.   #   Call Info : One or Two - Integer xsize - new size
  211.   #               Boolean clear - clears array
  212.   #-------------------------------------------------------------------------
  213.   def xsize=(xsize, clear = true)
  214.     @xsize = xsize
  215.     make_array if clear
  216.   end
  217.   #-------------------------------------------------------------------------
  218.   # * Name      : Set Y Size
  219.   #   Info      : Sets Height of 2D Array
  220.   #   Author    : Selwyn
  221.   #   Call Info : One or Two - Integer ysize - new size
  222.   #               Boolean clear - clears array
  223.   #-------------------------------------------------------------------------
  224.   def ysize=(ysize, clear = true)
  225.     @ysize = ysize
  226.     make_array if clear
  227.   end
  228.   #-------------------------------------------------------------------------
  229.   # * Name      : Set Size
  230.   #   Info      : Sets Dimensions of 2D Array
  231.   #   Author    : Selwyn
  232.   #   Call Info : Two or Three - Integer xsize, ysize - Dimensions
  233.   #               Boolean clear - clears array
  234.   #-------------------------------------------------------------------------
  235.   def resize(xsize, ysize, clear = true)
  236.     @xsize = xsize
  237.     @ysize = ysize
  238.     make_array if clear
  239.   end
  240.   #-------------------------------------------------------------------------
  241.   # * Name      : Make Array
  242.   #   Info      : Creates Data Array
  243.   #   Author    : Selwyn
  244.   #   Call Info : No Arguments
  245.   #-------------------------------------------------------------------------
  246.   def make_array
  247.     max = id(@xsize, @ysize)
  248.     @data = nil
  249.     @data = Array.new(max)
  250.   end
  251.   #-------------------------------------------------------------------------
  252.   # * Name      : ID
  253.   #   Info      : Retunrs id of element
  254.   #   Author    : Selwyn
  255.   #   Call Info : Two Arguments Integer X and Y
  256.   #-------------------------------------------------------------------------
  257.   def id(x, y)
  258.     return x + y * (@xsize + 1)
  259.   end
  260.   #-------------------------------------------------------------------------
  261.   # * Name      : Coord
  262.   #   Info      : Gets Coordinates returns Array - [x, y]
  263.   #   Author    : Selwyn
  264.   #   Call Info : One Integer ID, Id to get coordinates from
  265.   #-------------------------------------------------------------------------
  266.   def coord(id)
  267.     x = id % (@xsize + 1)
  268.     y = id / (@xsize + 1)
  269.     return x, y
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # * All other Array methods
  273.   #--------------------------------------------------------------------------
  274.   def method_missing(symbol, *args)
  275.     @data.method(symbol).call(*args)
  276.   end
  277. end
  278.  
  279. #==============================================================================
  280. # ** Classes.Background_Sprite                                     By: Trickster
  281. #------------------------------------------------------------------------------
  282. #  This class is for displaying a sprite used as a background it inherits from
  283. #  class Sprite. Allows for the programmer to specify a bitmap and a viewport
  284. #  when creating a sprite and the sprite will automatically adjust itself to
  285. #  fir the viewport specified.
  286. #==============================================================================
  287.  
  288. MACL::Loaded << 'Classes.Background_Sprite'
  289.  
  290. #==============================================================================
  291. # ** Background_Sprite
  292. #==============================================================================
  293.  
  294. class Background_Sprite < Sprite
  295.   #-------------------------------------------------------------------------
  296.   #   Name      : Initialize
  297.   #   Info      : Object initialization
  298.   #   Author    : Trickster
  299.   #   Call Info : Zero to Two Arguments
  300.   #               Bitmap bitmap bitmap to be loaded
  301.   #               Viewport viewport viewport used with the sprite
  302.   #-------------------------------------------------------------------------
  303.   def initialize(bitmap = Bitmap.new(32,32), viewport = nil)
  304.     super(viewport)
  305.     self.bitmap = bitmap
  306.     adjust
  307.   end
  308.   #-------------------------------------------------------------------------
  309.   #   Name      : Set Bitmap
  310.   #   Info      : Sets the Sprite's Bitmap
  311.   #   Author    : Trickster
  312.   #   Call Info : One Argument Bitmap bitmap the bitmap to be loaded
  313.   #-------------------------------------------------------------------------
  314.   def bitmap=(bitmap)
  315.     super(bitmap)
  316.     adjust
  317.   end
  318.   #-------------------------------------------------------------------------
  319.   #   Name      : Set Viewport
  320.   #   Info      : Sets the Sprite's Viewport
  321.   #   Author    : Trickster
  322.   #   Call Info : One Argument Viewport viewport the viewport to use
  323.   #-------------------------------------------------------------------------
  324.   def viewport=(viewport)
  325.     super(viewport)
  326.     adjust
  327.   end
  328.   #-------------------------------------------------------------------------
  329.   #   Name      : Adjust (Private)
  330.   #   Info      : Adjusts the Zoom Level
  331.   #   Author    : Trickster
  332.   #   Call Info : No Arguments (can't be called outside this class)
  333.   #-------------------------------------------------------------------------
  334.   private
  335.   def adjust
  336.     if viewport != nil
  337.       x, y = viewport.rect.x, viewport.rect.y
  338.       width, height = viewport.rect.width, viewport.rect.height
  339.     else
  340.       x, y, width, height = 0, 0, 640, 480
  341.     end
  342.     src_rect.set(x, y, width, height)
  343.     self.x = x
  344.     self.y = y
  345.     self.zoom_x = width / bitmap.width.to_f
  346.     self.zoom_y = height / bitmap.height.to_f
  347.   end
  348. end
  349.  
  350. #==============================================================================
  351. # ** Classes.Level Generation V4                By Trickster and SephirothSpawn
  352. #------------------------------------------------------------------------------
  353. # Format for Calling this class
  354. # Level_Generation.new(min, mid, max, minL, midL, maxL, early, late, steady,
  355. #  curve1, curve2, int)
  356. #
  357. # Where:
  358. # min    - the minimum value of the stat
  359. # mid    - the middle value at midL
  360. # max    - the maximum value of the stat
  361. # minL   - the minimum level
  362. # midL   - the middle level (stat will be mid here)
  363. # maxL   - the maximum level
  364. # early  - the early influence
  365. # late   - the late influence
  366. # steady - the steady influence
  367. # curve1 - the early->late influence
  368. # curve2 - the late->early influence
  369. # int    - if true returns integers
  370. #
  371. # Notes:
  372. #
  373. # The Default Values for the Curve Options
  374. # minL = 1, midL = 50, maxL = 99, influence options = 0, int = true
  375. #
  376. # You must set at least one of the curve options to a number other than 0
  377. #
  378. # Using the Steady Curve Option will throw off the middle value option, since
  379. # the steady curve grows steadily and its middle value will always occur on the
  380. # middle level, that is, (maxL - minL) / 2.
  381. #==============================================================================
  382.  
  383. MACL::Loaded << 'Classes.Level_Generation'
  384.  
  385. #==============================================================================
  386. # ** Level_Generation
  387. #==============================================================================
  388.  
  389. class Level_Generation
  390.   #-------------------------------------------------------------------------
  391.   # * Name      : Initialize
  392.   #   Info      : Object Initialization
  393.   #   Author    :  Trickster
  394.   #   Call Info : Three to Twelve Arguments
  395.   #               Numeric Min, Mid, Max - Minimum Middle and Maximum Value
  396.   #               Numeric Min1, Mid1, Max1 - Min, Mid, and Max Level (1, 50, 99)
  397.   #-------------------------------------------------------------------------
  398.   def initialize(min, mid, max, minl = 1, midl = 50, maxl = 99, early = 0,
  399.                  late = 0, steady = 0, curve1 = 0, curve2 = 0, int = true)
  400.     # Set Instance Variables
  401.     @min   = min.to_f
  402.     @mid   = mid.to_f
  403.     @max   = max.to_f
  404.     @minl  = minl.to_f
  405.     @midl  = midl.to_f
  406.     @maxl  = maxl.to_f
  407.     @early = early
  408.     @late  = late
  409.     @steady = steady
  410.     @curve1 = curve1
  411.     @curve2 = curve2
  412.     @int = int
  413.     # Error Checking
  414.     error_checking
  415.     # Calculate constants
  416.     calculate_constants
  417.   end
  418.   #-------------------------------------------------------------------------
  419.   # * Name      : Get Initial Level
  420.   #   Info      : Initial Level
  421.   #   Author    : Trickster
  422.   #   Call Info : No Arguments
  423.   #-------------------------------------------------------------------------
  424.   def initial_level
  425.     return @minl.to_i
  426.   end
  427.   #-------------------------------------------------------------------------
  428.   # * Name      : Get Final Level
  429.   #   Info      : Final Level
  430.   #   Author    : Trickster
  431.   #   Call Info : No Arguments
  432.   #-------------------------------------------------------------------------
  433.   def final_level
  434.     return @maxl.to_i
  435.   end
  436.   #-------------------------------------------------------------------------
  437.   # * Name      : Export
  438.   #   Info      : Exports Object to Text File to YourProject/File.txt
  439.   #   Author    : Trickster
  440.   #   Call Info : One or Two Argument - String File Filename to Save to
  441.   #               Boolean ints - Flag for Integer Arguments Sent (min - maxl)  
  442.   #   Comments  : Output Sample (Not Accurate with Curve)
  443.   #
  444.   #   min = 100, mid = 150, max = 200
  445.   #   minl = 1, midl = 50, maxl = 99
  446.   #   early = 0, late = 0, steady = 1, curve1 = 0, cruve2 = 0
  447.   #
  448.   #   1 = 100
  449.   #   2 = 102
  450.   #   [...]
  451.   #-------------------------------------------------------------------------
  452.   def export(file_name, ints = true)
  453.     # Create File
  454.     file = File.open("#{file_name}.txt", 'w')
  455.     # Export Stat and Level Values
  456.     if ints
  457.       file.print("min = #{@min.to_i}, mid = #{@mid.to_i}, max = #{@max.to_i}\n")
  458.     else
  459.       file.print("min = #{@min.to_i}, mid = #{@mid.to_i}, max = #{@max.to_i}\n")
  460.     end
  461.     file.print("minl = #{@minl.to_i}, midl = #{@midl.to_i}, maxl = #{@maxl.to_i}\n")
  462.     # Setup Arrays
  463.     keys = %w( early late steady curve1 curve2 )
  464.     values = @early, @late, @steady, @curve1, @curve2
  465.     # Setup Text
  466.     text = ''
  467.     # Setup Local Variable Counter
  468.     counter = 0
  469.     # Run Through Keys with Values (MACL)
  470.     keys.each_with_array(*values) do |key, value|
  471.       # Skip if value is 0
  472.       next if value == 0
  473.       # Add to text
  474.       text += counter == 0 ? "#{key} = #{value}" : ", #{key} = #{value}"
  475.       # Increate Counter
  476.       counter += value
  477.     end
  478.     # Print Text
  479.     file.print(text)
  480.     # Add two new lines
  481.     file.print("\n\n")
  482.     # Print Values for each level
  483.     self.each {|level, value| file.print("#{level} = #{value}\n")}
  484.     # Close File
  485.     file.close
  486.   end
  487.   #-------------------------------------------------------------------------
  488.   # * Name      : Generate Table
  489.   #   Info      : Generates Hash Table for levels (format: level => stat_value)
  490.   #   Author    : Trickster (Mods By SephirothSpawn)
  491.   #   Call Info : No Arguments
  492.   #-------------------------------------------------------------------------
  493.   def generate_table(data_type = 0)
  494.     # Organizes Key (For Use in Saving Table)
  495.     key = @min,@mid,@max,@minl,@midl,@maxl,@early,@late,@steady,@curve1,@curve2
  496.     # Loads Tables
  497.     tables = load_tables
  498.     # If Key Already Saved Return Saved table
  499.     return tables[key] if tables.has_key?(key)
  500.     # Create Hash table
  501.     table = Hash.new(0) if data_type == 0
  502.     table = Table.new(@maxl + 1) if data_type == 1
  503.     # Run Through Each Level
  504.     self.each {|level, value| table[level] = value}
  505.     # Saves Table
  506.     save_table(table)
  507.     # Return Created Table
  508.     return table
  509.   end
  510.   #-------------------------------------------------------------------------
  511.   # * Name      : Save Table
  512.   #   Info      : Saves Table Data into LevelGeneration.rxdata
  513.   #   Author    : SephirothSpawn
  514.   #   Call Info : Hash Table
  515.   #-------------------------------------------------------------------------
  516.   def save_table(table)
  517.     # Sets Up Key
  518.     key = @min,@mid,@max,@minl,@midl,@maxl,@early,@late,@steady,@curve1,@curve2
  519.     # Collects Saved Tables
  520.     tables = load_tables
  521.     # Saves Table to Data File
  522.     tables[key] = table
  523.     # Resaves Tables to File
  524.     save_data(tables, 'Data/LevelGeneration.rxdata')    
  525.   end
  526.   #-------------------------------------------------------------------------
  527.   # * Name      : Load Tables
  528.   #   Info      : Loads Table Data From LevelGeneration.rxdata
  529.   #             : A Hash in this forum table_parameters => hash_table
  530.   #   Author    : SephirothSpawn
  531.   #   Call Info : No Arguments
  532.   #-------------------------------------------------------------------------
  533.   def load_tables
  534.     # Test For Saved Solution File
  535.     unless FileTest.exist?('Data/LevelGeneration.rxdata')
  536.       # Creates LevelGeneration RXdata File
  537.       save_data({}, 'Data/LevelGeneration.rxdata')
  538.     end
  539.     # Returns Saved Tables
  540.     return load_data('Data/LevelGeneration.rxdata')
  541.   end
  542.   #-------------------------------------------------------------------------
  543.   # * Name      : Each
  544.   #   Info      : Iterator Method, Calculates Value for each level
  545.   #   Author    : Trickster
  546.   #   Call Info : No Arguments
  547.   #-------------------------------------------------------------------------
  548.   def each
  549.     # Get Minimum level and Maximum Level
  550.     minimum, maximum = @minl.to_i, @maxl.to_i
  551.     # Run Through Minimum and Maximum and Yield Level and Value
  552.     (minimum..maximum).each {|level| yield(level, get_stat(level))}
  553.   end
  554.   #-------------------------------------------------------------------------
  555.   # * Name      : Element Reference
  556.   #   Info      : Gets Stat for level
  557.   #   Author    : Trickster
  558.   #   Call Info : One Argument Integer Level, Level to get stat from
  559.   #-------------------------------------------------------------------------
  560.   def [](level)
  561.     return get_stat(level)
  562.   end
  563.   #-------------------------------------------------------------------------
  564.   # * Name      : Get Stat
  565.   #   Info      : Gets Stat for level
  566.   #   Author    : Trickster
  567.   #   Call Info : One Argument Integer Level, Level to get stat from
  568.   #-------------------------------------------------------------------------
  569.   def get_stat(level)
  570.     return @int ? @min.to_i : @min if level <= @minl
  571.     return @int ? @max.to_i : @max if level >= @maxl
  572.     # Setup Total
  573.     total = 0
  574.     # Get Values for Every Stat if greater than 0
  575.     total += @late * late_curve(level) if @late > 0
  576.     total += @early * early_curve(level) if @early > 0
  577.     total += @steady * steady_curve(level) if @steady > 0
  578.     total += @curve1 * early_late_curve(level) if @curve1 > 0
  579.     total += @curve2 * late_early_curve(level) if @curve2 > 0
  580.     # Get Average
  581.     total /= @late + @early + @steady + @curve1 + @curve2
  582.     # Limit Value
  583.     total = level < @midl ? [total, @mid].min : [total, @mid].max
  584.     # Further Limit Value
  585.     total = [[total, @min].max, @max].min
  586.     # Return Value
  587.     return @int ? total.to_i : total
  588.   end
  589.   #-------------------------------------------------------------------------
  590.   # * Name      : Calculate Constants (Private)
  591.   #   Info      : Calculates Constants "infimi", "infi", and "inmi"
  592.   #   Author    : Trickster
  593.   #   Call Info : No Arguments
  594.   #               Can not be called outside class
  595.   #-------------------------------------------------------------------------
  596.   private
  597.   def calculate_constants
  598.     # Calculate "infi" and "inmi"
  599.     @inmi = (@mid - @min) / (@midl - @minl)
  600.     @infi = (@max - @min) / (@maxl - @minl)
  601.     # Calculate "infimi"
  602.     @infimi = (@infi - @inmi) / (@maxl - @midl)
  603.   end
  604.   #-------------------------------------------------------------------------
  605.   # * Name      : Late Curve (Private)
  606.   #   Info      : Late Curve Influence, Formula
  607.   #   Author    : Trickster
  608.   #   Call Info : One Argument Integer Level, Level to get stat from
  609.   #               Can not be called outside class
  610.   #-------------------------------------------------------------------------
  611.   def late_curve(level)
  612.     # Calculate "A"
  613.     a_num = @infimi * (3 * @minl + @midl) + @inmi
  614.     a_den = (@maxl - @minl) * (@midl - @minl)
  615.     a = - a_num / a_den
  616.     # Return Value
  617.     return curve(a, level)
  618.   end
  619.   #-------------------------------------------------------------------------
  620.   # * Name      : Early Curve (Private)
  621.   #   Info      : Early Curve Influence, Formula
  622.   #   Author    : Trickster
  623.   #   Call Info : One Argument Integer Level, Level to get stat from
  624.   #               Can not be called outside class
  625.   #-------------------------------------------------------------------------
  626.   def early_curve(level)
  627.     # Calculate "A"
  628.     a_num = @infimi * (2 * @maxl + @minl + @midl) + @inmi
  629.     a_den = (@maxl - @midl) * (@maxl - @minl)
  630.     a = - a_num / a_den
  631.     # Return Value
  632.     return curve(a, level)
  633.   end
  634.   #-------------------------------------------------------------------------
  635.   # * Name      : Early -> Late Curve (Private)
  636.   #   Info      : Early Late Curve Formula (Curve 1)
  637.   #   Author    : Trickster
  638.   #   Call Info : One Argument Integer Level, Level to get stat from
  639.   #               Can not be called outside class
  640.   #-------------------------------------------------------------------------
  641.   def early_late_curve(level)
  642.     # Calculate "A"
  643.     a = @infimi / (@maxl + @minl - 2 * @midl)
  644.     # Return Value
  645.     return curve(a, level)
  646.   end
  647.   #-------------------------------------------------------------------------
  648.   # * Name      : Late -> Early Curve (Private)
  649.   #   Info      : Late Early Curve Formula (Curve 2)
  650.   #   Author    : Trickster
  651.   #   Call Info : One Argument Integer Level, Level to get stat from
  652.   #               Can not be called outside class
  653.   #-------------------------------------------------------------------------
  654.   def late_early_curve(level)
  655.     # If Less than Mid Level
  656.     if level < @midl
  657.       # Return Late Curve for level
  658.       return late_curve(level)
  659.     # If Greater than Mid Level
  660.     elsif level > @midl
  661.       # Return Early Curve for Level
  662.       return early_curve(level)
  663.     # If at Mid Level
  664.     elsif level == @midl
  665.       # Return Mid Value
  666.       return @mid
  667.     end
  668.   end
  669.   #-------------------------------------------------------------------------
  670.   # * Name      : Steady Curve (Private)
  671.   #   Info      : Steady Curve Influence, Formula
  672.   #   Author    : Trickster
  673.   #   Call Info : One Argument Integer Level, Level to get stat from
  674.   #               Can not be called outside class
  675.   #-------------------------------------------------------------------------
  676.   def steady_curve(level)
  677.     ch_level = @maxl - @minl
  678.     ch_stat = @max - @min
  679.     base = ch_stat / ch_level * level
  680.     mod = @max * @minl - @min * @maxl
  681.     base2 = mod / ch_level
  682.     return base - base2
  683.   end
  684.   #-------------------------------------------------------------------------
  685.   # * Name      : Curve (Private)
  686.   #   Info      : Curve Formula
  687.   #   Author    : Trickster
  688.   #   Call Info : Two Arguments Numeric A, "A" Influence
  689.   #               Integer Level, Level to get stat from
  690.   #               Can not be called outside class
  691.   #-------------------------------------------------------------------------
  692.   def curve(a, level)
  693.     # Calculate "B"
  694.     b = @infimi - a * (@minl + @midl + @maxl)
  695.     # Calculate "C"
  696.     c = @inmi - a * (@midl ** 2 + @minl * @midl + @minl ** 2) - b * (@midl + @minl)
  697.     # Calculate "D"
  698.     d = @min - (a * @minl ** 3 + b * @minl ** 2 + c * @minl)
  699.     # Calculate Stat
  700.     stat = a * level ** 3 + b * level ** 2 + c * level + d
  701.     # Return Stat
  702.     return stat
  703.   end
  704.   #-------------------------------------------------------------------------
  705.   # * Name      : Error Checking (Private)
  706.   #   Info      : Checks For Errors
  707.   #   Author    : Trickster
  708.   #   Call Info : No Arguments
  709.   #               Can not be called outside class
  710.   #-------------------------------------------------------------------------
  711.   def error_checking
  712.     if @late + @early + @steady + @curve1 + @curve2 == 0
  713.       raise(GeneratorError, "No Influences Have Been Defined")
  714.     elsif @minl == @midl or @minl == @maxl or @midl == @maxl
  715.       raise(GeneratorError, "Can't Use Same Level for Min, Mid, or Max Level")
  716.     end
  717.   end
  718.   #-------------------------------------------------------------------------
  719.   # * Generator Error
  720.   #-------------------------------------------------------------------------
  721.   class GeneratorError < StandardError; end
  722. end
  723.  
  724. #==============================================================================
  725. # ** Classes.Linked_List                                             By: Zeriab
  726. #------------------------------------------------------------------------------
  727. # Description:
  728. # ------------
  729. # This class represents a double linked list. Has a reference to the tail
  730. # and the head of the list.
  731. #  
  732. # Method List:
  733. # ------------
  734. # []=
  735. # add
  736. # insert
  737. # push
  738. # <<
  739. # unshift
  740. # delete
  741. # pop
  742. # shift
  743. # get
  744. # []
  745. # size=
  746. # insert_element
  747. # insert_element_tail
  748. # delete_element
  749. # search
  750. # get_element
  751. #
  752. #  Linked_List::Element
  753. #  --------------------
  754. #  value=
  755. #  value
  756. #  previous_element=
  757. #  previous_element
  758. #  next_element=
  759. #  next_element
  760. #==============================================================================
  761.  
  762. MACL::Loaded << 'Classes.Linked_list'
  763.  
  764. #==============================================================================
  765. # ** Linked_List
  766. #==============================================================================
  767.  
  768. class Linked_List
  769.   #--------------------------------------------------------------------------
  770.   # * Public Instance Variables
  771.   #--------------------------------------------------------------------------
  772.   attr_accessor :head
  773.   attr_accessor :tail
  774.   attr_reader   :size
  775.   #--------------------------------------------------------------------------
  776.   # * Object Initialization
  777.   #--------------------------------------------------------------------------
  778.   def initialize
  779.     self.size = 0
  780.   end
  781.   #--------------------------------------------------------------------------
  782.   # * []=
  783.   # Change the value of the nth element in the list
  784.   # Return true if the change succeeds otherwise false
  785.   #--------------------------------------------------------------------------
  786.   def []=(n, value)
  787.     # Return nil if the list is empty
  788.     element = get_element(n)
  789.     if element.nil?
  790.       return false
  791.     else
  792.       element.value = value
  793.       return true
  794.     end
  795.   end
  796.   #--------------------------------------------------------------------------
  797.   # * Add
  798.   # Add an object to the list (HEAD)
  799.   #--------------------------------------------------------------------------
  800.   def add(value)
  801.     element = Linked_List::Element.new
  802.     element.value = value
  803.     insert_element(element)
  804.     self.size += 1
  805.   end
  806.   # Synonyms
  807.   def insert(value) add(value) end
  808.   def push(value)   add(value) end
  809.   def <<(value)     add(value) end
  810.   #--------------------------------------------------------------------------
  811.   # * Unshift
  812.   # Add an object to the back of the list (TAIL)
  813.   #--------------------------------------------------------------------------
  814.   def unshift(value)
  815.     element = Linked_List::Element.new
  816.     element.value = value
  817.     insert_element_tail(element)
  818.     self.size += 1
  819.   end
  820.   #--------------------------------------------------------------------------
  821.   # * Delete
  822.   # Delete an object from the list
  823.   # Return the deleted object
  824.   # Return nil if the deletion has no effect on the list.
  825.   #--------------------------------------------------------------------------
  826.   def delete(value)
  827.     element = self.search(value)
  828.     if element.nil?
  829.       return nil
  830.     else
  831.       self.delete_element(element)
  832.       self.size -= 1
  833.       return element.value
  834.     end
  835.   end
  836.   #--------------------------------------------------------------------------
  837.   # * Pop
  838.   # Delete and return the head of the list.
  839.   #--------------------------------------------------------------------------
  840.   def pop
  841.     # Return nil if the list is empty
  842.     if self.head.nil?
  843.       return nil
  844.     end
  845.     self.size -= 1
  846.     return delete_element(self.head).value
  847.   end
  848.   #--------------------------------------------------------------------------
  849.   # * Shift
  850.   # Delete and return the tail of the list.
  851.   #--------------------------------------------------------------------------
  852.   def shift
  853.     # Return nil if the list is empty
  854.     if self.head.nil?
  855.       return nil
  856.     end
  857.     self.size -= 1
  858.     return delete_element(self.tail).value
  859.   end
  860.   #--------------------------------------------------------------------------
  861.   # * Get
  862.   # Get the object at the nth element in the list
  863.   #--------------------------------------------------------------------------
  864.   def get(n)
  865.     # Return nil if the list is empty
  866.     element = get_element(n)
  867.     if element.nil?
  868.       return nil
  869.     end
  870.     return element.value
  871.   end
  872.   # Synonyms
  873.   def [](n) get(n) end
  874.   #--------------------------------------------------------------------------
  875.   # * Private Method
  876.   #--------------------------------------------------------------------------
  877.   private
  878.   #--------------------------------------------------------------------------
  879.   # * Size
  880.   # Sets the size of the list
  881.   #--------------------------------------------------------------------------
  882.   def size=(value)
  883.     @size = value if value >= 0
  884.   end
  885.   #--------------------------------------------------------------------------
  886.   # * Insert Element
  887.   # Insert an element into the list.
  888.   # Assumes 'element' is a Linked_List::Element.
  889.   #--------------------------------------------------------------------------
  890.   def insert_element(element)
  891.     if head.nil?
  892.       self.head = element
  893.       self.tail = element
  894.       return
  895.     end
  896.     element.next_element = self.head
  897.     self.head.previous_element = element
  898.     self.head = element
  899.     element.previous_element = nil
  900.   end
  901.   #--------------------------------------------------------------------------
  902.   # * Insert Element Tail
  903.   # Insert an element into the list at the tail.
  904.   # Assumes 'element' is a Linked_List::Element.
  905.   #--------------------------------------------------------------------------
  906.   def insert_element_tail(element)
  907.     if head.nil?
  908.       self.head = element
  909.       self.tail = element
  910.       return
  911.     end
  912.     element.previous_element = self.tail
  913.     self.tail.next_element = element
  914.     self.tail = element
  915.     element.next_element = nil
  916.   end
  917.   #--------------------------------------------------------------------------
  918.   # * Delete Element
  919.   # Delete the given element from the list
  920.   # Assumes 'element' is a Linked_List::Element.
  921.   #--------------------------------------------------------------------------
  922.   def delete_element(element)
  923.     if element.next_element.nil?
  924.       self.tail = element.previous_element
  925.     else
  926.       element.next_element.previous_element = element.previous_element
  927.     end
  928.     if element.previous_element.nil?
  929.       self.head = element.next_element
  930.     else
  931.       element.previous_element.next_element = element.next_element
  932.     end
  933.     return element
  934.   end
  935.   #--------------------------------------------------------------------------
  936.   # * Search
  937.   # Search for an element with the specified value.
  938.   # Return the first element found with the corresponding value
  939.   # Return nil if no element is found.
  940.   #--------------------------------------------------------------------------
  941.   def search(value)
  942.     # If the head is nil the list is empty
  943.     if self.head.nil?
  944.       return nil
  945.     end
  946.     # Start with the head
  947.     element = self.head
  948.     loop do
  949.       # Check if the element has the correct value
  950.       if element.value == value
  951.         return element
  952.       end
  953.       # Return nil if the tail has been reached
  954.       if element == self.tail
  955.         return nil
  956.       end
  957.       # Look at the next element in the list
  958.       element = element.next_element
  959.     end
  960.   end
  961.   #--------------------------------------------------------------------------
  962.   # * Get Element
  963.   # Get the object at the nth element in the list
  964.   #--------------------------------------------------------------------------
  965.   def get_element(n)
  966.     # Return nil if the list is empty
  967.     if self.head.nil?
  968.       return nil
  969.     end
  970.     element = self.head
  971.     for i in 0...n
  972.       if self.tail == element
  973.         return nil
  974.       end
  975.       element = element.next_element
  976.     end
  977.     return element
  978.   end
  979. end
  980.  
  981. #==============================================================================
  982. # ** Linked_List::Element
  983. #==============================================================================
  984.  
  985. class Linked_List::Element
  986.   attr_accessor :value
  987.   attr_accessor :previous_element
  988.   attr_accessor :next_element
  989. end
  990.  
  991. #==============================================================================
  992. # ** Classes.Random                                               By: Trickster
  993. #------------------------------------------------------------------------------
  994. #  A Random class for generating objects
  995. #==============================================================================
  996.  
  997. MACL::Loaded << 'Classes.Random'
  998.  
  999. #==============================================================================
  1000. # ** Random
  1001. #==============================================================================
  1002.  
  1003. class Random
  1004.   #-------------------------------------------------------------------------
  1005.   # * Name      : Initialize
  1006.   #   Info      : Object Initialization
  1007.   #   Author    : Trickster
  1008.   #   Call Info : Variable Amount
  1009.   #               If a Range every object within the Range is added
  1010.   #               If a Numeric adds that object is added
  1011.   #               If a String then that string is added
  1012.   #               If an Array then all values within the array are added
  1013.   #-------------------------------------------------------------------------
  1014.   def initialize(*args)
  1015.     # Setup Data
  1016.     @data = []
  1017.     # Push Arguments to List
  1018.     push(*args)
  1019.   end
  1020.   #-------------------------------------------------------------------------
  1021.   # * Name      : Generate
  1022.   #   Info      : Generates an Object
  1023.   #               returns An Object if number is 1 and Array of Objects if
  1024.   #               number is > 1
  1025.   #   Author    : Trickster
  1026.   #   Call Info : Zero to One
  1027.   #               Integer number Number of objects to generate (Defaults to 1)
  1028.   #-------------------------------------------------------------------------
  1029.   def generate(number = 1)
  1030.     # Create Array
  1031.     random = []
  1032.     # If Number is greater than 1
  1033.     if number > 1
  1034.       # Push Object Number Times
  1035.       number.times {random << @data[rand(@data.size)]}
  1036.       # Return Random Objects
  1037.       return random
  1038.     else
  1039.       # Retunr Random Object
  1040.       return @data[rand(@data.size)]
  1041.     end
  1042.   end
  1043.   #-------------------------------------------------------------------------
  1044.   # * Name      : Generate!
  1045.   #   Info      : Generates and Deletes Object
  1046.   #               returns An Object if number is 1 and Array of Objects if
  1047.   #               number is > 1
  1048.   #   Author    : Trickster
  1049.   #   Call Info : Zero to One
  1050.   #               Integer number Number of objects to generate (Defaults to 1)
  1051.   #-------------------------------------------------------------------------
  1052.   def generate!(number = 1)
  1053.     # Create Array
  1054.     random = []
  1055.     # If Number is greater than 1
  1056.     if number > 1
  1057.       # Run Through Number times
  1058.       number.times {random << @data.delete_at(rand(@data.size)) if !empty?}
  1059.       # Return Array of Random
  1060.       return random
  1061.     else
  1062.       # Return Random Object And Delete
  1063.       return @data.delete_at(rand(@data.size))
  1064.     end
  1065.   end
  1066.   #-------------------------------------------------------------------------
  1067.   # * Name      : Push
  1068.   #   Info      : Push Objects to be generated
  1069.   #   Author    : Trickster
  1070.   #   Call Info : Variable Amount
  1071.   #               If a Range every object within the Range is added
  1072.   #               If a Numeric adds that object is added
  1073.   #               If a String then that string is added
  1074.   #               If an Array then all values within the array are added
  1075.   #-------------------------------------------------------------------------
  1076.   def push(*args)
  1077.     # Run Through Arguments Sent
  1078.     args.each do |argument|
  1079.       # Branch By Arguments Class
  1080.       case argument
  1081.       when Range
  1082.         # Add All Values of Range
  1083.         @data += argument.to_a
  1084.       when Hash
  1085.         # Add All Key Value Pairs Of Hash
  1086.         @data += argument.to_a
  1087.       when Array
  1088.         # Add Array
  1089.         @data += argument
  1090.       else
  1091.         # Push Argument
  1092.         @data << argument
  1093.       end
  1094.     end
  1095.   end
  1096.   #-------------------------------------------------------------------------
  1097.   # * Name      : Empty?
  1098.   #   Info      : Generator Empty? returns true if Data is empty false otherwise
  1099.   #   Author    : Trickster
  1100.   #   Call Info : No Arguments
  1101.   #-------------------------------------------------------------------------
  1102.   def empty?
  1103.     return @data.empty?
  1104.   end
  1105.   #--------------------------------------------------------------------------
  1106.   # * All Other Array methods
  1107.   #--------------------------------------------------------------------------
  1108.   def method_missing(symbol, *args)
  1109.     @data.method(symbol).call(*args)
  1110.   end
  1111. end
  1112.  
  1113. #==============================================================================
  1114. # ** Classes.Scene_Base (2.1.1)                               By SephirothSpawn
  1115. #------------------------------------------------------------------------------
  1116. # * Description :
  1117. #
  1118. #   This script was designed to act as a parent class for all scenes. It
  1119. #   provides 2 major purposes :
  1120. #
  1121. #    1) Give the Main Processing Method a Common Structure
  1122. #    2) Automatically Update & Dispose All Spritesets, Sprites, Windows or
  1123. #       any other instance variable that responds to :update or :dispose
  1124. #
  1125. #   This is a script for developers, not non-scripters. If you do not
  1126. #   plan to create scenes in RMXP, this isn't needed.
  1127. #------------------------------------------------------------------------------
  1128. # * Note : This script is only for non-SDK users or SDK users that do not use
  1129. #          the 2.0+ version of the SDK.
  1130. #==============================================================================
  1131.  
  1132. MACL::Loaded << 'Classes.Scene_Base'
  1133.  
  1134. #==============================================================================
  1135. # ** Scene Base
  1136. #==============================================================================
  1137.  
  1138. class Scene_Base
  1139.   #--------------------------------------------------------------------------
  1140.   # * Object Initialization
  1141.   #--------------------------------------------------------------------------
  1142.   def initialize
  1143.     @previous_scene = $scene.class
  1144.   end  
  1145.   #--------------------------------------------------------------------------
  1146.   # * Main Processing
  1147.   #--------------------------------------------------------------------------
  1148.   def main
  1149.     main_variable                 # Main Variable Initialization
  1150.     main_spriteset                # Main Spriteset Initialization
  1151.     main_sprite                   # Main Sprite Initialization
  1152.     main_window                   # Main Window Initialization
  1153.     main_audio                    # Main Audio Initialization
  1154.     main_transition               # Main Transition Initialization
  1155.     loop do                       # Scene Loop
  1156.       main_loop                   # Main Loop
  1157.       break if main_break?        # Break If Breakloop Test
  1158.     end                           # End Scene Loop
  1159.     Graphics.freeze               # Prepare for transition
  1160.     main_dispose                  # Main Dispose
  1161.     main_end                      # Main End
  1162.   end
  1163.   #--------------------------------------------------------------------------
  1164.   # * Main Processing : Variable Initialization
  1165.   #--------------------------------------------------------------------------
  1166.   def main_variable   ; end
  1167.   #--------------------------------------------------------------------------
  1168.   # * Main Processing : Spriteset Initialization
  1169.   #--------------------------------------------------------------------------
  1170.   def main_spriteset  ; end
  1171.   #--------------------------------------------------------------------------
  1172.   # * Main Processing : Sprite Initialization
  1173.   #--------------------------------------------------------------------------
  1174.   def main_sprite     ; end
  1175.   #--------------------------------------------------------------------------
  1176.   # * Main Processing : Window Initialization
  1177.   #--------------------------------------------------------------------------
  1178.   def main_window     ; end
  1179.   #--------------------------------------------------------------------------
  1180.   # * Main Processing : Audio Initialization
  1181.   #--------------------------------------------------------------------------
  1182.   def main_audio      ; end
  1183.   #--------------------------------------------------------------------------
  1184.   # * Main Processing : Transition
  1185.   #--------------------------------------------------------------------------
  1186.   def main_transition
  1187.     Graphics.transition
  1188.   end
  1189.   #--------------------------------------------------------------------------
  1190.   # * Main Processing : Loop
  1191.   #--------------------------------------------------------------------------
  1192.   def main_loop
  1193.     Graphics.update             # Update game screen
  1194.     Input.update                # Update input information
  1195.     main_update                 # Update scene objects
  1196.     update                      # Update Processing
  1197.   end
  1198.   #--------------------------------------------------------------------------
  1199.   # * Main Processing : Break Loop Test
  1200.   #--------------------------------------------------------------------------
  1201.   def main_break?
  1202.     return $scene != self # Abort loop if sceen is changed
  1203.   end
  1204.   #--------------------------------------------------------------------------
  1205.   # * Main Processing : Disposal
  1206.   #--------------------------------------------------------------------------
  1207.   def main_dispose
  1208.     # Passes Through All Instance Variables
  1209.     self.instance_variables.each do |object_name|
  1210.       # Evaluates Object
  1211.       object = eval object_name
  1212.       # Pass Object To Auto Dispose
  1213.       auto_dispose(object)
  1214.     end
  1215.   end
  1216.   #--------------------------------------------------------------------------
  1217.   # * Main Processing : Ending
  1218.   #--------------------------------------------------------------------------
  1219.   def main_end        ; end
  1220.   #--------------------------------------------------------------------------
  1221.   # * Main Processing : Update
  1222.   #--------------------------------------------------------------------------
  1223.   def main_update
  1224.     # Passes Through All Instance Variables
  1225.     self.instance_variables.each do |object_name|
  1226.       # Evaluates Object
  1227.       object = eval object_name
  1228.       # Pass Object To Auto Update
  1229.       auto_update(object)
  1230.     end
  1231.   end
  1232.   #--------------------------------------------------------------------------
  1233.   # * Main Processing : Auto Update
  1234.   #--------------------------------------------------------------------------
  1235.   def auto_update(object)
  1236.     # Return If Object isn't a Hash, Array or Respond to Update
  1237.     return unless object.is_a?(Hash) || object.is_a?(Array) ||
  1238.                   object.respond_to?(:update)
  1239.     # If Hash Object
  1240.     if object.is_a?(Hash)
  1241.       object.each do |key, value|
  1242.         # Pass Key & Value to Auto Update
  1243.         auto_update(key) ; auto_update(value)
  1244.       end
  1245.       return
  1246.     end
  1247.     # If Array Object
  1248.     if object.is_a?(Array)
  1249.       # Pass All Object to Auto Update
  1250.       object.each {|obj| auto_update(obj)}
  1251.       return
  1252.     end
  1253.     # If Responds to Dispose
  1254.     if object.respond_to?(:dispose)
  1255.       # If Responds to Disposed? && is Disposed or Responds to Disable
  1256.       # Dispose and dispose is disabled
  1257.       if (object.respond_to?(:disposed?) && object.disposed?) ||
  1258.          (object.respond_to?(:disable_dispose?) && object.disable_dispose?)
  1259.         # Return
  1260.         return
  1261.       end
  1262.     end
  1263.     # If Responds to Update
  1264.     if object.respond_to?(:update)
  1265.       # If Responds to Disable Update & Update Disabled
  1266.       if object.respond_to?(:disable_update?) && object.disable_update?
  1267.         # Return
  1268.         return
  1269.       end
  1270.       # Update Object
  1271.       object.update
  1272.     end
  1273.   end
  1274.   #--------------------------------------------------------------------------
  1275.   # * Main Processing : Auto Dispose
  1276.   #--------------------------------------------------------------------------
  1277.   def auto_dispose(object)
  1278.     # Return If Object isn't a Hash, Array or Respond to Dispose
  1279.     return unless object.is_a?(Hash) || object.is_a?(Array) ||
  1280.                   object.respond_to?(:dispose)
  1281.     # If Hash Object
  1282.     if object.is_a?(Hash)
  1283.       object.each do |key, value|
  1284.         # Pass Key & Value to Auto Dispose
  1285.         auto_dispose(key) ; auto_dispose(value)
  1286.       end
  1287.       return
  1288.     end
  1289.     # If Array Object
  1290.     if object.is_a?(Array)
  1291.       # Pass All Object to Auto Dispose
  1292.       object.each {|obj| auto_dispose(obj)}
  1293.       return
  1294.     end
  1295.     # If Responds to Dispose
  1296.     if object.respond_to?(:dispose)
  1297.       # If Responds to Disposed? && is Disposed or Responds to Disable
  1298.       # Dispose and dispose is disabled
  1299.       if (object.respond_to?(:disposed?) && object.disposed?) ||
  1300.          (object.respond_to?(:disable_dispose?) && object.disable_dispose?)
  1301.         # Return
  1302.         return
  1303.       end
  1304.       # Dispose Object
  1305.       object.dispose
  1306.     end
  1307.   end
  1308.   #--------------------------------------------------------------------------
  1309.   # * Frame Update
  1310.   #--------------------------------------------------------------------------
  1311.   def update          ; end
  1312. end
  1313.  
  1314. #==============================================================================
  1315. # ** Classes.Sprite_ActorCharGraphic (V2.0)                        By Trickster
  1316. #------------------------------------------------------------------------------
  1317. # A Sprite Class that represents an actor character graphic. Also Handles a few
  1318. # Graphical methods and animation. The Z coordinate is, by default,
  1319. # in between the window and its contents for easy integration in a window.
  1320. #==============================================================================
  1321.  
  1322. MACL::Loaded << 'Classes.Sprite_ActorCharGraphic'
  1323.  
  1324. #==============================================================================
  1325. # ** Sprite_ActorCharGraphic
  1326. #==============================================================================
  1327.  
  1328. class Sprite_ActorCharGraphic < Sprite
  1329.   #--------------------------------------------------------------------------
  1330.   # * Public Instance Variables
  1331.   #--------------------------------------------------------------------------
  1332.   attr_accessor :speed
  1333.   attr_accessor :animate
  1334.   attr_reader   :frame
  1335.   attr_reader   :pose
  1336.   #-------------------------------------------------------------------------
  1337.   # * Name      : Object Initialization
  1338.   #   Info      : Creates a New Instance of this Class
  1339.   #   Author    : Trickster
  1340.   #   Call Info : Three or Seven Arguments
  1341.   #               Game_Actor actor, Actor's Sprite to Display
  1342.   #               Integer X and Y, Position to Display
  1343.   #               Integer Speed, Speed of animation (Def 1)
  1344.   #               Integer Frame, Starting frame (Def. nil)
  1345.   #               String/Integer Pose, Pose Type/Pose Index (Def. nil)
  1346.   #               Viewport viewport, Viewport used (Def. nil)
  1347.   #-------------------------------------------------------------------------
  1348.   def initialize(actor, x, y, speed = 1, frame = 0, pose = 0, viewport = nil)
  1349.     # Call Sprite#initialize and Send Viewport
  1350.     super(viewport)
  1351.     # Setup Instance Variables
  1352.     @actor, @speed = actor, speed
  1353.     # Setup Position
  1354.     self.x = x
  1355.     self.y = y
  1356.     self.z = 101
  1357.     # Setup Bitmap
  1358.     self.bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  1359.     # Setup Other Variables
  1360.     @name, @hue, @animate = @actor.character_name, @actor.character_hue, false
  1361.     # Setup Pose if string sent
  1362.     pose = MACL::Poses.index(pose) if pose.is_a?(String)
  1363.     # Setup Pose and Frame
  1364.     self.pose, self.frame = pose, frame
  1365.     # Setup Counter Instance Variable
  1366.     @count = 0
  1367.   end
  1368.   #-------------------------------------------------------------------------
  1369.   # * Name      : Set Graphic
  1370.   #   Info      : Sets Graphic to (Frame, Pose)
  1371.   #   Author    : Trickster
  1372.   #   Call Info : Two Arguments
  1373.   #               Integer Frame, Frame
  1374.   #               String/Integer Pose, Pose Type/Pose Index
  1375.   #-------------------------------------------------------------------------
  1376.   def set_graphic(pose, frame)
  1377.     # Set Pose and Frame
  1378.     self.pose, self.frame = pose, frame
  1379.   end
  1380.   #-------------------------------------------------------------------------
  1381.   # * Name      : Set Pose
  1382.   #   Info      : Sets The Pose
  1383.   #   Author    : Trickster
  1384.   #   Call Info : One Argument, String/Integer Pose Pose Type/Pose Index
  1385.   #-------------------------------------------------------------------------
  1386.   def pose=(pose)
  1387.     # Turn pose into an integer if string sent
  1388.     pose = MACL::Poses.index(pose) if pose.is_a?(String)
  1389.     # Return if pose is nil or same pose
  1390.     return if pose == nil or pose == @pose
  1391.     # Set Y Coordinate of Source Rectangle
  1392.     src_rect.y = bitmap.height / MACL::Poses.size * pose
  1393.     # Set Height of Source Rectangle
  1394.     src_rect.height = bitmap.height / MACL::Poses.size
  1395.     # Set Pose
  1396.     @pose = pose
  1397.   end
  1398.   #-------------------------------------------------------------------------
  1399.   # * Name      : Set Frame
  1400.   #   Info      : Sets the Frame
  1401.   #   Author    : Trickster
  1402.   #   Call Info : One Argument, Integer Frame, Frame to set
  1403.   #-------------------------------------------------------------------------
  1404.   def frame=(frame)
  1405.     # Return if frame is nil or same frame
  1406.     return if frame == nil or frame == @frame
  1407.     # Set X Coordinate of Source Rectangle
  1408.     src_rect.x = bitmap.width / MACL::Frames * frame
  1409.     # Set Height of Source Rectangle
  1410.     src_rect.width = bitmap.width / MACL::Frames
  1411.     # Set Frame
  1412.     @frame = frame
  1413.   end
  1414.   #-------------------------------------------------------------------------
  1415.   # * Name      : Frame Update
  1416.   #   Info      : Update Animation if enabled, Updates Graphic
  1417.   #   Author    : Trickster
  1418.   #   Call Info : No Arguments
  1419.   #-------------------------------------------------------------------------
  1420.   def update
  1421.     # Call Sprite Update
  1422.     super
  1423.     # Update Graphic
  1424.     update_graphic
  1425.     # Return if not animated
  1426.     return if not @animate or @speed == 0
  1427.     # Increase Counter
  1428.     @count += 1
  1429.     # Return if speed frames have not passed
  1430.     return if @count % @speed != 0
  1431.     # Set Frame Restrict to [0, frames)
  1432.     self.frame = (self.frame + 1) % MACL::Frames
  1433.   end
  1434.   #-------------------------------------------------------------------------
  1435.   # * Name      : Update Graphic (Private)
  1436.   #   Info      : Private Method, Updates Actor Graphic
  1437.   #   Author    : Trickster
  1438.   #   Call Info : No Arguements, can not be called outside this class
  1439.   #-------------------------------------------------------------------------
  1440.   private
  1441.   def update_graphic
  1442.     # Return if no changes made
  1443.     return if @name == @actor.character_name and @hue == @actor.character_hue
  1444.     # Update Name and Hue
  1445.     @name, @hue = @actor.character_name, @actor.character_hue
  1446.     # Set New Bitmap
  1447.     self.bitmap = RPG::Cache.character(@name, @hue)
  1448.   end
  1449. end
  1450.  
  1451. #==============================================================================
  1452. # ** Classes.Sprite_WindowText                                     By Trickster
  1453. #------------------------------------------------------------------------------
  1454. #  A specialized sprite class that is to be placed onto a window
  1455. #==============================================================================
  1456.  
  1457. MACL::Loaded << 'Classes.Sprite_WindowText'
  1458.  
  1459. #==============================================================================
  1460. # ** Sprite_WindowText
  1461. #==============================================================================
  1462.  
  1463. class Sprite_WindowText < Sprite
  1464.   #--------------------------------------------------------------------------
  1465.   # * Public Instance Variables
  1466.   #--------------------------------------------------------------------------
  1467.   attr_reader :text
  1468.   attr_reader :width
  1469.   #-------------------------------------------------------------------------
  1470.   # * Name      : Object Initialization
  1471.   #   Info      : Creates a New Window Text Sprite
  1472.   #   Author    : Trickster
  1473.   #   Call Info : Zero to Five Integer X and Y Defines Position
  1474.   #               String Text - Text to be Drawn
  1475.   #               Font font - font to be used
  1476.   #               Viewport - Viewport of the sprite
  1477.   #-------------------------------------------------------------------------
  1478.   def initialize(x = 0, y = 0, text = '', font = Font.new, viewport = nil)
  1479.     # Call Sprite#initialize and send viewport
  1480.     super(viewport)
  1481.     # Set Coordinates
  1482.     self.x, self.y = x, y
  1483.     # Set Bitmap
  1484.     self.bitmap = Bitmap.new(32, 32)
  1485.     # Set Text
  1486.     @text = text
  1487.     # Set Font
  1488.     @font = font
  1489.     # Set Bitmap font
  1490.     bitmap.font = @font
  1491.     # Setup Tagging Type
  1492.     @sprite_type = 'border'
  1493.     # Setup Text
  1494.     setup_text
  1495.   end
  1496.   #-------------------------------------------------------------------------
  1497.   # * Name      : Set Text
  1498.   #   Info      : Changes Text and Updates Sprite
  1499.   #   Author    : Trickster
  1500.   #   Call Info : One Argument String Text - new text
  1501.   #-------------------------------------------------------------------------
  1502.   def text=(text)
  1503.     # Return if same text
  1504.     return if @text == text
  1505.     # Set New Text
  1506.     @text = text
  1507.     # Setup Text
  1508.     setup_text
  1509.   end
  1510.   #-------------------------------------------------------------------------
  1511.   # * Name      : Width
  1512.   #   Info      : Changes width and Updates Sprite
  1513.   #   Author    : Trickster
  1514.   #   Call Info : One Argument Integer width - new width
  1515.   #-------------------------------------------------------------------------
  1516.   def width=(width)
  1517.     # Return if same width
  1518.     return if @width == width
  1519.     # Set New Width
  1520.     @width = width
  1521.     # Setup Text
  1522.     setup_text
  1523.   end
  1524.   #-------------------------------------------------------------------------
  1525.   # * Name      : Setup Text (Private)
  1526.   #   Info      : Set up Text Bitmap
  1527.   #   Author    : Trickster
  1528.   #   Call Info : No Arguments
  1529.   #-------------------------------------------------------------------------
  1530.   private
  1531.   def setup_text
  1532.     # Get Size of Text
  1533.     size = bitmap.text_size(@text).width
  1534.     # Dispose Previous Bitmap
  1535.     bitmap.dispose if bitmap != nil and size != bitmap.width
  1536.     # Create Bitmap
  1537.     self.bitmap = Bitmap.new(@width.nil? ? (size == 0 ? 32 : size) : @width, 32)
  1538.     # Set Font
  1539.     self.bitmap.font = @font
  1540.     # Draw Text onto bitmap
  1541.     self.bitmap.draw_text(0, 0, size, 32, @text)
  1542.   end
  1543. end
  1544.  
  1545. #==============================================================================
  1546. # ** Classes.Table_Object                                                    By: Selwyn
  1547. #------------------------------------------------------------------------------
  1548. # Three Dimensional Array for any Object.
  1549. #  
  1550. #   - resizing any dimension will destroy the data.
  1551. #   - negative values for x, y, z can be used.
  1552. #       e.g. table[-1, -1, -1] will return the last object of the table
  1553. #
  1554. #==============================================================================
  1555.  
  1556. MACL::Loaded << 'Classes.Table_Object'
  1557.  
  1558. class Table_Object
  1559.   #--------------------------------------------------------------------------
  1560.   # * Public Instance Variables
  1561.   #--------------------------------------------------------------------------
  1562.   attr_reader   :xsize
  1563.   attr_reader   :ysize
  1564.   attr_reader   :zsize
  1565.   #--------------------------------------------------------------------------
  1566.   # * Name      : Object Initialization
  1567.   #   Info      : Creates a new Object Table Object
  1568.   #   Author    : Selwyn
  1569.   #   Call Info : Two-Three Arguments
  1570.   #               Two - Integer xsize, ysize - dimensions
  1571.   #               Three - Integer xsize, ysize, zsize - dimensions
  1572.   #--------------------------------------------------------------------------
  1573.   def initialize(xsize, ysize, zsize = 0)
  1574.     @xsize = xsize
  1575.     @ysize = ysize
  1576.     @zsize = zsize
  1577.     @data = []
  1578.     @indexes = []
  1579.     make_array
  1580.   end
  1581.   #--------------------------------------------------------------------------
  1582.   # * Name      : Element Reference
  1583.   #   Info      : Gets an Element returns Element At ID or X,Y,Z
  1584.   #   Author    : Selwyn
  1585.   #   Call Info : One-Two-Three Arguments
  1586.   #               One - Integer id - id of the element to get
  1587.   #               Two - Integer x,y - X and Y.
  1588.   #               Three - Integer x,y,z - X, Y and Z.
  1589.   #--------------------------------------------------------------------------
  1590.   def [](*args)
  1591.     case args.size
  1592.     when 1
  1593.       return @data[args[0]]
  1594.     when 2, 3
  1595.       return @data[id(*args)]
  1596.     end
  1597.   end
  1598.   #--------------------------------------------------------------------------
  1599.   # * Name      : Element Assignment
  1600.   #   Info      : Assigns an Object to Element
  1601.   #   Author    : Selwyn
  1602.   #   Call Info : Two-Three-Four Arguments
  1603.   #               Two Integer id - id of the Element to set
  1604.   #                   Object obj - object assigned to id
  1605.   #               Three Integer x,y - X and Y.
  1606.   #                     Object obj - object assigned to id.
  1607.   #               Four Integer x,y,z - X, Y and Z.
  1608.   #                     Object obj - object assigned to id.
  1609.   #--------------------------------------------------------------------------
  1610.   def []=(*args)
  1611.     case args.size
  1612.     when 2
  1613.       @data[args[0]] = args[1]
  1614.     when 3
  1615.       @data[id(args[0], args[1])] = args[2]
  1616.     when 4
  1617.       @data[id(args[0], args[1], args[2])] = args[3]
  1618.     end
  1619.   end
  1620.   #--------------------------------------------------------------------------
  1621.   # * Name      : Set X Size
  1622.   #   Info      : Sets Width of the Table
  1623.   #   Author    : Selwyn
  1624.   #   Call Info : One Argument Integer xsize - new size
  1625.   #--------------------------------------------------------------------------
  1626.   def xsize=(xsize)
  1627.     @xsize = xsize
  1628.     make_array
  1629.   end
  1630.   #--------------------------------------------------------------------------
  1631.   # * Name      : Set Y Size
  1632.   #   Info      : Sets Height of the Table
  1633.   #   Author    : Selwyn
  1634.   #   Call Info : One Argument Integer ysize - new size
  1635.   #--------------------------------------------------------------------------
  1636.   def ysize=(ysize)
  1637.     @ysize = ysize
  1638.     make_array
  1639.   end
  1640.   #--------------------------------------------------------------------------
  1641.   # * Name      : Set Z Size
  1642.   #   Info      : Sets Depth of the Table
  1643.   #   Author    : Selwyn
  1644.   #   Call Info : One Argument Integer zsize - new size
  1645.   #--------------------------------------------------------------------------
  1646.   def zsize=(zsize)
  1647.     @zsize = zsize
  1648.     make_array
  1649.   end
  1650.   #--------------------------------------------------------------------------
  1651.   # * Name      : Set Size
  1652.   #   Info      : Sets Dimensions of the Table
  1653.   #   Author    : Selwyn
  1654.   #   Call Info : Two or Three - Integer xsize, ysize, zsize - Dimensions
  1655.   #--------------------------------------------------------------------------
  1656.   def resize(xsize, ysize, zsize = 0)
  1657.     @xsize = xsize
  1658.     @ysize = ysize
  1659.     @zsize = zsize
  1660.     make_array
  1661.   end
  1662.   #--------------------------------------------------------------------------
  1663.   # * Name      : Make Array
  1664.   #   Info      : Creates Data Array
  1665.   #   Author    : Selwyn
  1666.   #   Call Info : No Arguments
  1667.   #--------------------------------------------------------------------------
  1668.   def make_array
  1669.     max = @xsize * @ysize * (@zsize + 1)
  1670.     @data = nil
  1671.     @data = Array.new(max)
  1672.     @indexes = []
  1673.     if @zsize > 0
  1674.       for i in 0...max
  1675.         xy = i % (@xsize * @ysize)
  1676.         x = xy % @xsize
  1677.         y = xy / @xsize
  1678.         z = (i - xy) / (@xsize * @ysize)
  1679.         @indexes << [x, y, z]
  1680.       end
  1681.     else
  1682.       for i in 0...max
  1683.         @indexes << [i % @xsize, i / @xsize]
  1684.       end
  1685.     end
  1686.   end
  1687.   #--------------------------------------------------------------------------
  1688.   # * Name      : ID
  1689.   #   Info      : Returns id of element
  1690.   #   Author    : Selwyn
  1691.   #   Call Info : Two or Three Arguments Integer X and Y and Z
  1692.   #--------------------------------------------------------------------------
  1693.   def id(x, y, z = 0)
  1694.     x %= @xsize; y %= @ysize; z %= @zsize
  1695.     return (x + y * @xsize) + (@xsize * @ysize * z)
  1696.   end
  1697.   #--------------------------------------------------------------------------
  1698.   # * Name      : Coord
  1699.   #   Info      : Gets Coordinates - Array [x, y(, z)]
  1700.   #   Author    : Selwyn
  1701.   #   Call Info : One Integer ID, Id to get coordinates from
  1702.   #--------------------------------------------------------------------------
  1703.   def coord(id)
  1704.     #xy = id % (@xsize * @ysize)
  1705.     #x = xy % @xsize
  1706.     #y = xy / @xsize
  1707.     #z = (id - xy) / (@xsize * @ysize)
  1708.     return @indexes[id]
  1709.   end
  1710.   #--------------------------------------------------------------------------
  1711.   # * Name      : Clear
  1712.   #   Info      : Clears the Table
  1713.   #   Author    : Selwyn
  1714.   #   Call Info : No Arguments
  1715.   #--------------------------------------------------------------------------
  1716.   def clear
  1717.     @data.clear
  1718.   end
  1719.   #--------------------------------------------------------------------------
  1720.   # * Name      : Size
  1721.   #   Info      : Returns the Table size
  1722.   #   Author    : Selwyn
  1723.   #   Call Info : No Arguments
  1724.   #--------------------------------------------------------------------------
  1725.   def size
  1726.     @data.size
  1727.   end
  1728.   #--------------------------------------------------------------------------
  1729.   # * Name      : ID Index
  1730.   #   Info      : Returns the ID position of the object in the Table
  1731.   #   Author    : Selwyn
  1732.   #   Call Info : Object object
  1733.   #--------------------------------------------------------------------------
  1734.   def id_index(object)
  1735.     return @data.index(object)
  1736.   end
  1737.   #--------------------------------------------------------------------------
  1738.   # * Name      : Coord Index
  1739.   #   Info      : Returns the Coordinates of the object in the Table
  1740.   #   Author    : Selwyn
  1741.   #   Call Info : Object object
  1742.   #--------------------------------------------------------------------------
  1743.   def coord_index(object)
  1744.     return coord(@data.index(object))
  1745.   end
  1746. end
  1747.  
  1748. #==============================================================================
  1749. # ** Classes.Window ReadFile (1.01)                           By SephirothSpawn
  1750. #------------------------------------------------------------------------------
  1751. # * Description :
  1752. #
  1753. #   This script was designed to allow you to open a text file and display
  1754. #   the lines on a window. It can read the lines directly and draw the text
  1755. #   or it can evaluate it as direct code.
  1756. #
  1757. #   As an added feature, there is a feature that will allow you to open the
  1758. #   window on the map with a simple call script and dispose of the window
  1759. #   just as easy.
  1760. #------------------------------------------------------------------------------
  1761. # * Syntax :
  1762. #
  1763. #   Creating Window Object
  1764. #    - <object> = Window_ReadFile.new(x, y, w, h, filename, complex, ls)
  1765. #
  1766. #      x, y, w & h  - Window Size
  1767. #      filename     - filename
  1768. #      complex      - true (lines evaluated as direct script) or
  1769. #                     false (lines draws as text)
  1770. #      ls           - linespacing (usually 24 or 32)
  1771. #
  1772. #   Opening Window On Map
  1773. #    - $scene.open_readfile_w(x, y, w, h, filename, complex, ls)
  1774. #==============================================================================
  1775.  
  1776. MACL::Loaded << 'Classes.Window_ReadFile'
  1777.  
  1778. #==============================================================================
  1779. # ** Window_ReadFile
  1780. #==============================================================================
  1781.  
  1782. class Window_ReadFile < Window_Base
  1783.   #--------------------------------------------------------------------------
  1784.   # * Object Initialization
  1785.   #
  1786.   #   If complex is true, each line is read as direct code (For scripters)
  1787.   #   If complex is false, each line will be directly read and drawn
  1788.   #
  1789.   #   Line Spacing is the Space Between Lines (Only Needed for non-complex)
  1790.   #--------------------------------------------------------------------------
  1791.   def initialize(x, y, w, h, filename, complex = true, line_spacing = 24)
  1792.     # Creates Window
  1793.     super(x, y, w, h)
  1794.     # Opens File
  1795.     lines = IO.readlines(filename)
  1796.     # If Complex
  1797.     if complex
  1798.       # Passes Through Each Line of Code - Evaluates Line
  1799.       lines.each { |line| eval line }
  1800.     # If Simple
  1801.     else
  1802.       # Creates Bitmap
  1803.       self.contents = Bitmap.new(width - 32, lines.size * line_spacing)
  1804.       # Passes Through Each Line
  1805.       for i in 0...lines.size
  1806.         rect = Rect.new(0, i * line_spacing, contents.width, line_spacing)
  1807.         self.contents.draw_text(rect, lines[i])
  1808.       end
  1809.     end
  1810.   end
  1811.   #--------------------------------------------------------------------------
  1812.   # * Update
  1813.   #--------------------------------------------------------------------------
  1814.   def update
  1815.     super
  1816.     # If Active
  1817.     if self.active
  1818.       # If Up is Pressed
  1819.       if Input.press?(Input::UP)
  1820.         self.oy -= 4 if self.oy > 0
  1821.       # If Down is Pressed
  1822.       elsif Input.press?(Input::DOWN)
  1823.         self.oy += 4 if self.oy < self.contents.height - 64
  1824.       end
  1825.     end
  1826.   end
  1827. end
  1828.  
  1829. #==============================================================================
  1830. # ** Scene_Map
  1831. #==============================================================================
  1832.  
  1833. class Scene_Map
  1834.   #--------------------------------------------------------------------------
  1835.   # * Alias Listings
  1836.   #--------------------------------------------------------------------------
  1837.   alias_method :seph_wndrf_scnmap_update, :update
  1838.   #--------------------------------------------------------------------------
  1839.   # * Frame Update
  1840.   #--------------------------------------------------------------------------
  1841.   def update
  1842.     # If ReadFile Window Present
  1843.     unless @readfile_window.nil?
  1844.       # Update Readfile
  1845.       update_seph_readfilewindow
  1846.       return
  1847.     end
  1848.     # Original Update
  1849.     seph_wndrf_scnmap_update
  1850.   end
  1851.   #--------------------------------------------------------------------------
  1852.   # * Frame Update : ReadFile Window
  1853.   #--------------------------------------------------------------------------
  1854.   def update_seph_readfilewindow
  1855.     # If B Button is Pressed
  1856.     if Input.trigger?(Input::B)
  1857.       # Play Cancel SE
  1858.       $game_system.se_play($data_system.cancel_se)
  1859.       # Delete ReadFile Window
  1860.       @readfile_window.dispose
  1861.       @readfile_window = nil
  1862.     end
  1863.   end
  1864.   #--------------------------------------------------------------------------
  1865.   # * Open ReadFile Window
  1866.   #--------------------------------------------------------------------------
  1867.   def open_readfile_w(x, y, w, h, f, c = true, ls = 24)
  1868.     # Creates ReadFile Window
  1869.     @readfile_window = Window_ReadFile.new(x, y, w, h, f, c, ls)
  1870.   end
  1871. end
  1872.  
  1873. #==============================================================================
  1874. # ** Classes.Window_Scrollable                                    By: Trickster
  1875. #------------------------------------------------------------------------------
  1876. #  This window class contains scroll functions. To use create a window,
  1877. #  inheriting From this class set <window>.contents_rect to the rect of all the
  1878. #  text, speed to the speed of scrolling, and horizontal/vertical_scroll to
  1879. #  true to allow scrolling, for a practical example on how to use see my
  1880. #  Advanced Mission script
  1881. #==============================================================================
  1882.  
  1883. MACL::Loaded << 'Classes.Window_Scrollable'
  1884.  
  1885. #==============================================================================
  1886. # ** Window_Scrollable
  1887. #==============================================================================
  1888.  
  1889. class Window_Scrollable < Window_Base
  1890.   #-------------------------------------------------------------------------
  1891.   # * Public Instance Variables
  1892.   #-------------------------------------------------------------------------
  1893.   attr_accessor :speed
  1894.   attr_accessor :contents_rect
  1895.   attr_writer   :horizontal_scroll
  1896.   attr_writer   :vertical_scroll
  1897.   #-------------------------------------------------------------------------
  1898.   # * Name      : Initialize
  1899.   #   Info      : Object Initialization
  1900.   #   Author    : Trickster
  1901.   #   Call Info : Four Arguments
  1902.   #              Integer X and Y, Define Starting Position
  1903.   #              Width and Height, Define Width and Height of the Window
  1904.   #-------------------------------------------------------------------------
  1905.   def initialize(x, y, width, height)
  1906.     super(x, y, width, height)
  1907.     @contents_rect = Rect.new(0,0,width,height)
  1908.     @speed = 0
  1909.     @horizontal_scroll = false
  1910.     @vertical_scroll = false
  1911.   end
  1912.   #-------------------------------------------------------------------------
  1913.   # * Name      : Vertical?
  1914.   #   Info      : Can window's contents move Vertically?
  1915.   #   Author    : Trickster
  1916.   #   Call Info : No Arguments
  1917.   #-------------------------------------------------------------------------
  1918.   def vertical?
  1919.     return false if self.contents == nil
  1920.     return self.contents.height > self.height - 32
  1921.   end
  1922.   #-------------------------------------------------------------------------
  1923.   # * Name      : Horizontal?
  1924.   #   Info      : Can window's contents move Horizontally
  1925.   #   Author    : Trickster
  1926.   #   Call Info : No Arguments
  1927.   #-------------------------------------------------------------------------
  1928.   def horizontal?
  1929.     return false if self.contents == nil
  1930.     return self.contents.width > self.width - 32
  1931.   end
  1932.   #-------------------------------------------------------------------------
  1933.   # * Name      : Update
  1934.   #   Info      : Frame Update
  1935.   #   Author    : Trickster
  1936.   #   Call Info : No Arguments
  1937.   #-------------------------------------------------------------------------
  1938.   def update
  1939.     super
  1940.     return if not self.active
  1941.     if Input.repeat?(Input::UP)
  1942.       if self.oy > @contents_rect.y and @vertical_scroll and vertical?
  1943.         self.oy = [self.oy - speed, @contents_rect.y].max
  1944.       end
  1945.     end
  1946.     if Input.repeat?(Input::LEFT)
  1947.       if self.ox > @contents_rect.x and @horizantal_scroll and horizantal?
  1948.         self.ox = [self.ox - speed, @contents_rect.x].max
  1949.       end
  1950.     end
  1951.     if Input.repeat?(Input::DOWN)
  1952.       if self.oy < @contents_rect.height - (self.height - 32) and @vertical_scroll and vertical?
  1953.         self.oy = [self.oy + speed, @contents_rect.height].min
  1954.       end
  1955.     end
  1956.     if Input.repeat?(Input::RIGHT)
  1957.       if self.ox < @contents_rect.width - (self.width - 32)  and @horizantal_scroll and horizantal?
  1958.         self.ox = [self.ox - speed, @contents_rect.width].min
  1959.       end
  1960.     end
  1961.   end
  1962. end
  1963.  
  1964. #==============================================================================
  1965. # ** Classes.Window_SelectableCommand                             By: Trickster
  1966. #------------------------------------------------------------------------------
  1967. #  This window deals with general command choices. Also Includes a Cursor
  1968. #  Height Parameter which controls the Cursor's Height.
  1969. #==============================================================================
  1970.  
  1971. MACL::Loaded << 'Classes.Window_SelectableCommand'
  1972.  
  1973. #==============================================================================
  1974. # ** Window_SelectableCommand
  1975. #==============================================================================
  1976.  
  1977. class Window_SelectableCommand < Window_Selectable
  1978.   #--------------------------------------------------------------------------
  1979.   # * Public Instance Variables
  1980.   #--------------------------------------------------------------------------
  1981.   attr_reader     :command
  1982.   attr_accessor   :cursor_height
  1983.   #-------------------------------------------------------------------------
  1984.   # * Initialize
  1985.   #-------------------------------------------------------------------------
  1986.   def initialize(width, commands)
  1987.     # Compute window height from command quantity
  1988.     super(0, 0, width, commands.size * 32 + 32)
  1989.     # Setup Item Max and Commands
  1990.     @commands, @item_max = commands, commands.size
  1991.     # Sets Up Cursor Height
  1992.     @cursor_height = 32
  1993.     # Setup Index
  1994.     self.index = 0
  1995.   end
  1996.   #--------------------------------------------------------------------------
  1997.   # * Get Top Row
  1998.   #--------------------------------------------------------------------------
  1999.   def top_row
  2000.     # Divide y-coordinate of window contents transfer origin by 1 row
  2001.     # height of @cursor_height
  2002.     return self.oy / @cursor_height
  2003.   end
  2004.   #--------------------------------------------------------------------------
  2005.   # * Set Top Row
  2006.   #--------------------------------------------------------------------------
  2007.   def top_row=(row)
  2008.     # If row is less than 0, change it to 0
  2009.     if row < 0
  2010.       row = 0
  2011.     end
  2012.     # If row exceeds row_max - 1, change it to row_max - 1
  2013.     if row > row_max - 1
  2014.       row = row_max - 1
  2015.     end
  2016.     # Multiply 1 row height by 32 for y-coordinate of window contents
  2017.     # transfer origin
  2018.     self.oy = row * @cursor_height
  2019.   end
  2020.   #--------------------------------------------------------------------------
  2021.   # * Get Number of Rows Displayable on 1 Page
  2022.   #--------------------------------------------------------------------------
  2023.   def page_row_max
  2024.     # Subtract a frame height of 32 from the window height, and divide it by
  2025.     # 1 row height of @cursor_height
  2026.     return (self.height - 32) / @cursor_height
  2027.   end
  2028.   #--------------------------------------------------------------------------
  2029.   # * Command
  2030.   #--------------------------------------------------------------------------
  2031.   def command(index = self.index)
  2032.     return @commands[index]
  2033.   end
  2034.   #-------------------------------------------------------------------------
  2035.   # * Set Commands
  2036.   #-------------------------------------------------------------------------
  2037.   def commands=(commands)
  2038.     # Return if Commands Are Same
  2039.     return if @commands == commands
  2040.     # Reset Commands
  2041.     @commands = commands
  2042.     # Resets Item Max
  2043.     item_max = @item_max
  2044.     @item_max = @commands.size
  2045.     # If Item Max Changes
  2046.     unless item_max == @item_max
  2047.       # Deletes Existing Contents (If Exist)
  2048.       self.contents.dispose unless self.contents.nil?
  2049.       # Recreates Contents
  2050.       self.contents = Bitmap.new(width - 32, @item_max * 32)
  2051.     end
  2052.     # Refresh Window
  2053.     refresh
  2054.   end
  2055.   #-------------------------------------------------------------------------
  2056.   # * Refresh
  2057.   #-------------------------------------------------------------------------
  2058.   def refresh
  2059.     # Clear Contents
  2060.     self.contents.clear
  2061.     # Setup Item Max
  2062.     @item_max.times {|i| draw_item(i, normal_color)}
  2063.   end
  2064.   #-------------------------------------------------------------------------
  2065.   # * Draw Item
  2066.   #-------------------------------------------------------------------------
  2067.   def draw_item(index, color)
  2068.     # Setup Font Color
  2069.     self.contents.font.color = color
  2070.     # Setup Rect
  2071.     rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
  2072.     # Erase At Rect
  2073.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  2074.     # Draw Command
  2075.     self.contents.draw_text(rect, @commands[index])
  2076.   end
  2077.   #-------------------------------------------------------------------------
  2078.   # * Disable Item
  2079.   #-------------------------------------------------------------------------
  2080.   def disable_item(index)
  2081.     # Draw In Disabled Color
  2082.     draw_item(index, disabled_color)
  2083.   end
  2084.   #--------------------------------------------------------------------------
  2085.   # * Update Cursor Rectangle
  2086.   #--------------------------------------------------------------------------
  2087.   def update_cursor_rect
  2088.     # If cursor position is less than 0 or not active
  2089.     if @index < 0 or not self.active
  2090.       self.cursor_rect.empty
  2091.       return
  2092.     end
  2093.     # Get current row
  2094.     row = @index / @column_max
  2095.     # If current row is before top row
  2096.     if row < self.top_row
  2097.       # Scroll so that current row becomes top row
  2098.       self.top_row = row
  2099.     end
  2100.     # If current row is more to back than back row
  2101.     if row > self.top_row + (self.page_row_max - 1)
  2102.       # Scroll so that current row becomes back row
  2103.       self.top_row = row - (self.page_row_max - 1)
  2104.     end
  2105.     # Calculate cursor width
  2106.     cursor_width = self.width / @column_max - 32
  2107.     # Calculate cursor coordinates
  2108.     x = @index % @column_max * (cursor_width + 32)
  2109.     y = @index / @column_max * @cursor_height - self.oy
  2110.     # Update cursor rectangle
  2111.     self.cursor_rect.set(x, y, cursor_width, @cursor_height)
  2112.   end
  2113. end
  2114.  
  2115. #===============================================================================
  2116. # * Classes.Zoomed_Sprite                                          By: Trickster
  2117. #-------------------------------------------------------------------------------
  2118. #  This class is for displaying a zoomed in sprite. It inherits from
  2119. #  class Sprite. Allows for the programmer to specify a zoom level when creating
  2120. #  Sprites and also width and height methods that get the width and height of
  2121. #  the Sprite and not the Bitmap
  2122. #===============================================================================
  2123.  
  2124. MACL::Loaded << 'Classes.Zoomed_Sprite'
  2125.  
  2126. #==============================================================================
  2127. # ** Zoomed_Sprite
  2128. #==============================================================================
  2129.  
  2130. class Zoomed_Sprite < Sprite
  2131.   #-------------------------------------------------------------------------
  2132.   # * Name      : Initialize
  2133.   #   Info      : Object Initialization
  2134.   #   Author    : Trickster
  2135.   #   Call Info : Zero to Two Arguments
  2136.   #               Float Zoom_Level, the level of zooming (Defaults to 1.0)
  2137.   #               Viewport viewport, the viewport used (Defaults to whole screen)
  2138.   #-------------------------------------------------------------------------
  2139.   def initialize(zoom_level = 1.0, viewport = nil)
  2140.     super(viewport)
  2141.     self.zoom_x = zoom_level
  2142.     self.zoom_y = zoom_level
  2143.   end
  2144.   #-------------------------------------------------------------------------
  2145.   #   Name      : Get Width
  2146.   #   Info      : Gets the width of the sprite or 0 if no bitmap
  2147.   #   Author    : Trickster
  2148.   #   Call Info : No Arguments
  2149.   #-------------------------------------------------------------------------
  2150.   def width
  2151.     return 0 if bitmap.nil?
  2152.     return self.bitmap.width * self.zoom_x
  2153.   end
  2154.   #-------------------------------------------------------------------------
  2155.   #   Name      : Get Height
  2156.   #   Info      : Gets the height of the sprite or 0 if no bitmap
  2157.   #   Author    : Trickster
  2158.   #   Call Info : No Arguments
  2159.   #-------------------------------------------------------------------------
  2160.   def height
  2161.     return 0 if bitmap.nil?
  2162.     return self.bitmap.height * self.zoom_y
  2163.   end
  2164. end
  2165.  
  2166. #==============================================================================
  2167. # ** Modules.Battle Simulator (1.0)                           By SephirothSpawn
  2168. #------------------------------------------------------------------------------
  2169. # * Description :
  2170. #
  2171. #   This script was designed to let you create custom troops easily and test
  2172. #   them or default test battles.
  2173. #------------------------------------------------------------------------------
  2174. # * Syntax :
  2175. #
  2176. #   Starting Battle Simulator vs. Single Enemy
  2177. #    - BattleSimulator.start_enemy_battle(enemy_id)
  2178. #
  2179. #   Starting Battle Simulator vs. Multiple Enemies
  2180. #    - BattleSimulator.start_custom_troop_battle([enemy_id, ...])
  2181. #------------------------------------------------------------------------------
  2182. # * Changing Battle Simulator Settings
  2183. #
  2184. #   Enemy EXP Drop Percent (Defaults to 100%)
  2185. #    - $game_system.battle_simulator.exp_percent = n
  2186. #
  2187. #   Enemy Gold Drop Percent (Defaults to 100%)
  2188. #    - $game_system.battle_simulator.gold_percent = n
  2189. #
  2190. #   Enemy Treasure Drop Probability
  2191. #    - $game_system.battle_simulator.drop_percent = n
  2192. #==============================================================================
  2193.  
  2194. MACL::Loaded << 'Modules.Battle Simulator'
  2195.  
  2196. #==============================================================================
  2197. # ** BattleSimulator
  2198. #==============================================================================
  2199.  
  2200. module BattleSimulator
  2201.   #--------------------------------------------------------------------------
  2202.   # * Flags
  2203.   #--------------------------------------------------------------------------
  2204.   @delete_last_troop     = false
  2205.   @previous_scene        = $scene.class
  2206.   #--------------------------------------------------------------------------
  2207.   # * Start Enemy Battle
  2208.   #--------------------------------------------------------------------------
  2209.   def self.start_enemy_battle(enemy_id)
  2210.     # Start Custom Troop Battle
  2211.     self.start_custom_troop_battle([enemy_id])
  2212.   end
  2213.   #--------------------------------------------------------------------------
  2214.   # * Start Custom Troop Battle
  2215.   #--------------------------------------------------------------------------
  2216.   def self.start_custom_troop_battle(enemies)
  2217.     # Create Dummy Troop
  2218.     new_troop = RPG::Troop.new
  2219.     new_troop.id = $data_troops.size
  2220.     new_troop.name = 'Battle Simulator'
  2221.     new_troop.members = []
  2222.     # Pass Through Enemies
  2223.     for i in 0...enemies.size
  2224.       # Create Member Page
  2225.       member = RPG::Troop::Member.new
  2226.       member.enemy_id = enemies[i]
  2227.       member.x = 640 / (enemies.size + 1) * (i + 1)
  2228.       member.y = 320 - rand(40)
  2229.       new_troop.members << member
  2230.     end
  2231.     # Add Troop to Data Troop
  2232.     $data_troops << new_troop
  2233.     # Set Flags
  2234.     @delete_last_troop   = true
  2235.     # Start Troop Battle
  2236.     self.start_troop_battle(new_troop.id)
  2237.   end
  2238.   #--------------------------------------------------------------------------
  2239.   # * Start Troop Battle
  2240.   #--------------------------------------------------------------------------
  2241.   def self.start_troop_battle(troop_id)
  2242.     # Change Battle Simulator Settings
  2243.     $game_system.battle_simulator.on = true
  2244.     # Memorize map BGM and stop BGM
  2245.     $game_temp.map_bgm = $game_system.playing_bgm
  2246.     $game_system.bgm_stop
  2247.     # Play battle start SE
  2248.     $game_system.se_play($data_system.battle_start_se)
  2249.     # Play battle BGM
  2250.     $game_system.bgm_play($game_system.battle_bgm)
  2251.     # Straighten player position
  2252.     $game_player.straighten
  2253.     # Memorize Scene
  2254.     @previous_scene = $scene.class
  2255.     # Set Battle Troop ID
  2256.     $game_temp.battle_troop_id = troop_id
  2257.     # Switch to battle screen
  2258.     $scene = Scene_Battle.new
  2259.   end
  2260.   #--------------------------------------------------------------------------
  2261.   # * End Battle
  2262.   #
  2263.   #   Result - 0 : Win ; 1 : Lose ; 2 : Escape
  2264.   #--------------------------------------------------------------------------
  2265.   def self.end_battle(result = 0)
  2266.     # Change Battle Simulator Settings
  2267.     $game_system.battle_simulator.on = false
  2268.     # Delete Troop if Flag set
  2269.     $data_troops.pop if @delete_last_troop
  2270.     # Turn Delete Last Troop Flag Off
  2271.     @delete_last_troop = false
  2272.     # Return to Previous Scene
  2273.     @previous_scene = @previous_scene.new
  2274.   end
  2275. end
  2276.  
  2277. #============================================================================
  2278. # ** Game_System::Battle Simulator
  2279. #============================================================================
  2280.  
  2281. class Game_System::Battle_Simulator
  2282.   #------------------------------------------------------------------------
  2283.   # * Public Instance Variables
  2284.   #------------------------------------------------------------------------
  2285.   attr_accessor :on
  2286.   attr_accessor :exp_percent
  2287.   attr_accessor :gold_percent
  2288.   attr_accessor :drop_percent
  2289.   #------------------------------------------------------------------------
  2290.   # * Object Initialization
  2291.   #------------------------------------------------------------------------
  2292.   def initialize
  2293.     @on, @exp_percent, @gold_percent, @drop_percent = false, 100, 100, 100
  2294.   end
  2295. end
  2296.  
  2297. #==============================================================================
  2298. # ** Game_System
  2299. #==============================================================================
  2300.  
  2301. class Game_System
  2302.   #------------------------------------------------------------------------
  2303.   # * Public Instance Variables
  2304.   #------------------------------------------------------------------------
  2305.   attr_accessor :battle_simulator
  2306.   #--------------------------------------------------------------------------
  2307.   # * Alias Listings
  2308.   #--------------------------------------------------------------------------
  2309.   alias_method :macl_gmsys_init,  :initialize
  2310.   #--------------------------------------------------------------------------
  2311.   # * Object Initialization
  2312.   #--------------------------------------------------------------------------
  2313.   def initialize
  2314.     # Original Initialization
  2315.     macl_gmsys_init
  2316.     # Set game system settings
  2317.     @battle_simulator = Game_System::Battle_Simulator.new
  2318.   end
  2319. end
  2320.  
  2321. #==============================================================================
  2322. # ** Game_Temp
  2323. #==============================================================================
  2324.  
  2325. class Game_Temp
  2326.   #--------------------------------------------------------------------------
  2327.   # * Alias Listings
  2328.   #--------------------------------------------------------------------------
  2329.   alias_method :seph_battlesimulator_gmtmp_bcl, :battle_can_lose
  2330.   #--------------------------------------------------------------------------
  2331.   # * Battle can lose test
  2332.   #--------------------------------------------------------------------------
  2333.   def battle_can_lose
  2334.     result = $game_temp.nil? ? false : $game_system.battle_simulator.on
  2335.     return seph_battlesimulator_gmtmp_bcl || result
  2336.   end
  2337. end
  2338.  
  2339. #==============================================================================
  2340. # ** Game_Enemy
  2341. #==============================================================================
  2342.  
  2343. class Game_Enemy
  2344.   #--------------------------------------------------------------------------
  2345.   # * Alias Listings
  2346.   #--------------------------------------------------------------------------
  2347.   alias_method :seph_battlesimulator_gmeny_exp, :exp
  2348.   alias_method :seph_battlesimulator_gmeny_gld, :gold
  2349.   alias_method :seph_battlesimulator_gmeny_tsp, :treasure_prob
  2350.   #--------------------------------------------------------------------------
  2351.   # * Get EXP
  2352.   #--------------------------------------------------------------------------
  2353.   def exp
  2354.     n = seph_battlesimulator_gmeny_exp
  2355.     if $game_system.battle_simulator.on
  2356.       n = Integer(n * ($game_system.battle_simulator.exp_percent / 100.0))
  2357.     end
  2358.     return n
  2359.   end
  2360.   #--------------------------------------------------------------------------
  2361.   # * Get Gold
  2362.   #--------------------------------------------------------------------------
  2363.   def gold
  2364.     n = seph_battlesimulator_gmeny_gld
  2365.     if $game_system.battle_simulator.on
  2366.       n = Integer(n * ($game_system.battle_simulator.gold_percent / 100.0))
  2367.     end
  2368.     return n
  2369.   end
  2370.   #--------------------------------------------------------------------------
  2371.   # * Get Treasure Appearance Probability
  2372.   #--------------------------------------------------------------------------
  2373.   def treasure_prob
  2374.     n = seph_battlesimulator_gmeny_tsp
  2375.     if $game_system.battle_simulator.on
  2376.       n = Integer(n * ($game_system.battle_simulator.drop_percent / 100.0))
  2377.     end
  2378.     return n
  2379.   end
  2380. end
  2381.  
  2382. #==============================================================================
  2383. # ** Modules.Bitmap File Dump (1.01)                          By SephirothSpawn
  2384. #------------------------------------------------------------------------------
  2385. # * Description :
  2386. #
  2387. #   This script was designed to let you save bitmaps as information files
  2388. #------------------------------------------------------------------------------
  2389. # * Instructions
  2390. #
  2391. #   Make Sure there is a folder in your game folder named 'Saved Bitmaps'
  2392. #------------------------------------------------------------------------------
  2393. # * Syntax :
  2394. #
  2395. #   Saving Bitmap :
  2396. #    - BitmapDump.save_bitmap(<bitmap>, 'filename')
  2397. #
  2398. #   Loading Bitmap :
  2399. #    - BitmapDump.load_bitmap('filename')
  2400. #==============================================================================
  2401.  
  2402. MACL::Loaded << 'Modules.BitmapFileDump'
  2403.  
  2404. #==============================================================================
  2405. # ** BitmapDump
  2406. #==============================================================================
  2407.  
  2408. module BitmapDump
  2409.   #--------------------------------------------------------------------------
  2410.   # * Directory
  2411.   #--------------------------------------------------------------------------
  2412.   Directory = 'Graphics/Saved Images'
  2413.   #--------------------------------------------------------------------------
  2414.   # * Save Bitmap
  2415.   #--------------------------------------------------------------------------
  2416.   def self.save_bitmap(bitmap, filename)
  2417.     # Creates Color Values Table
  2418.     red = Table.new(bitmap.width, bitmap.height)
  2419.     green = Table.new(bitmap.width, bitmap.height)
  2420.     blue = Table.new(bitmap.width, bitmap.height)
  2421.     alpha = Table.new(bitmap.width, bitmap.height)
  2422.     # Collects Bimap Pixels and saves
  2423.     for i in 0...bitmap.width
  2424.       for j in 0...bitmap.height
  2425.         color = bitmap.get_pixel(i, j)
  2426.         red[i, j] = color.red
  2427.         green[i, j] = color.green
  2428.         blue[i, j] = color.blue
  2429.         alpha[i, j] = color.alpha
  2430.       end
  2431.     end
  2432.     # Saves File
  2433.     file = File.open(Directory + filename + '.rxdata', 'wb')
  2434.       Marshal.dump([red, green, blue, alpha], file)
  2435.     file.close
  2436.   end
  2437.   #--------------------------------------------------------------------------
  2438.   # * Save Bitmap
  2439.   #--------------------------------------------------------------------------
  2440.   def self.read_bitmap(filename)
  2441.     # Opens File
  2442.     file = File.open(Directory + filename + '.rxdata', "rb")
  2443.       colors = Marshal.load(file)
  2444.     file.close
  2445.     # Assigns Color Tables
  2446.     red, green, blue, alpha = colors[0], colors[1], colors[2], colors[3],
  2447.                               colors[4]
  2448.     bitmap = Bitmap.new(red.xsize, red.ysize)
  2449.     # Sets Bitmap Pixels
  2450.     for i in 0...bitmap.width
  2451.       for j in 0...bitmap.height
  2452.         bitmap.set_pixel(i, j, Color.new(red[i, j], green[i, j], blue[i, j],
  2453.                                          alpha[i, j]))
  2454.       end
  2455.     end
  2456.     # Returns Bitmap
  2457.     return bitmap
  2458.   end
  2459. end
  2460.  
  2461. #==============================================================================
  2462. # ** Modules.Curve Generator Module (4.0)         By Trickster & SephirothSpawn
  2463. #------------------------------------------------------------------------------
  2464. # * Description :
  2465. #
  2466. #   This script was designed to generate a curve of numbers given certain
  2467. #   values. As of now, their are 3 formulas for you to choose from : Point-
  2468. #   slope; Early & Late; Early / Steady / Late + Curves.
  2469. #------------------------------------------------------------------------------
  2470. # * Syntax :
  2471. #
  2472. #   Generating Curve :
  2473. #    - curve = Curve_Generator.generate_curve(type, <args>)
  2474. #
  2475. #   Type : 0 - Point Slope
  2476. #          1 - Early / Late
  2477. #          2 - Early / Steady / Late + Curves
  2478. #
  2479. #   Args :
  2480. #
  2481. #    Type 0 : min_level, max_level, start value, inflation
  2482. #    Type 1 : min_level, max_level, min_value, max_value, early, late
  2483. #    Type 2 : min level, mid_level, max level, min value, mid_value,
  2484. #             max value, early, late, steady, curve 1, curve 2, integer
  2485. #
  2486. #   This will return a hash : { level => value, ... }
  2487. #==============================================================================
  2488.  
  2489. MACL::Loaded << 'Modules.Curve_Generator'
  2490.  
  2491. #==============================================================================
  2492. # ** Curve_Generator
  2493. #==============================================================================
  2494.  
  2495. module Curve_Generator
  2496.   #--------------------------------------------------------------------------
  2497.   # * Generate Curve
  2498.   #
  2499.   #   Type : 0 - Point Slope
  2500.   #          1 - Early / Late
  2501.   #          2 - Early / Steady / Late + Curves
  2502.   #
  2503.   #   Args :
  2504.   #
  2505.   #    Type 0 : min_level, max_level, start value, inflation
  2506.   #    Type 1 : min_level, max_level, min_value, max_value, early, late
  2507.   #    Type 2 : min level, mid_level, max level, min value, mid_value,
  2508.   #             max value, early, late, steady, curve 1, curve 2, integer
  2509.   #--------------------------------------------------------------------------
  2510.   def self.generate_curve(type, *args)
  2511.     # Collects Saved Tables
  2512.     tables = self.load_tables
  2513.     # Check for Previously Generated Table
  2514.     if tables.has_key?(type) && tables[type].has_key?(args)
  2515.       # Return Previously Generated Table
  2516.       return tables[type][args]
  2517.     end
  2518.     # Branch Point By Type
  2519.     case type
  2520.     when 0 # Point Slope
  2521.       table = Point_Slope.generate_curve(*args)
  2522.     when 1 # Early / Late
  2523.       table = Early_Late.generate_curve(*args)
  2524.     when 2 # Early / Stead / Late + Curves
  2525.       table = ESL_Curves.generate_curve(*args)
  2526.     end
  2527.     # Set 0 Defaults
  2528.     table.default = 0
  2529.     # Saves Table Information
  2530.     self.save_table(type, args, table)
  2531.     # Return Curve Information
  2532.     return table
  2533.   end
  2534.   #-------------------------------------------------------------------------
  2535.   # * Save Table
  2536.   #-------------------------------------------------------------------------
  2537.   def self.save_table(type, args, table)
  2538.     # Collects Saved Tables
  2539.     tables = self.load_tables
  2540.     # Creates Hash of Type (If non present)
  2541.     tables[type] = {} unless tables.has_key?(type)
  2542.     # Saves Table Data
  2543.     tables[type][args] = table
  2544.     # Resaves Tables to File
  2545.     save_data(tables, 'Data/Curve Generator.rxdata')    
  2546.   end
  2547.   #-------------------------------------------------------------------------
  2548.   # * Load Tables
  2549.   #-------------------------------------------------------------------------
  2550.   def self.load_tables
  2551.     # Test For Saved Table File
  2552.     unless FileTest.exist?('Data/Curve Generator.rxdata')
  2553.       # Creates Curve Generator Rxdata File
  2554.       save_data({}, 'Data/Curve Generator.rxdata')
  2555.     end
  2556.     # Returns Saved Tables
  2557.     return load_data('Data/Curve Generator.rxdata')
  2558.   end  
  2559.  
  2560.   #============================================================================
  2561.   # ** Point Slope
  2562.   #============================================================================
  2563.  
  2564.   module Point_Slope
  2565.     #------------------------------------------------------------------------
  2566.     # * Generate Curve
  2567.     #
  2568.     #   Args : min_level, max_level, start value, inflation
  2569.     #------------------------------------------------------------------------
  2570.     def self.generate_curve(min_l, max_level, start_value, inflation)
  2571.       # Creates Table
  2572.       table = {}
  2573.       # Fills Table
  2574.       for level in min_l..max_l
  2575.         table[level] = start_value + inflation * level
  2576.       end
  2577.       # Return Table
  2578.       return table
  2579.     end
  2580.   end
  2581.  
  2582.   #============================================================================
  2583.   # ** Early Late
  2584.   #============================================================================
  2585.  
  2586.   module Early_Late
  2587.     #------------------------------------------------------------------------
  2588.     # * Generate Curve
  2589.     #------------------------------------------------------------------------
  2590.     def self.generate_curve(min_l, max_l, min_v, max_v, e = 1.0, l = 1.0)
  2591.       # Creates Table
  2592.       table = {}
  2593.       # Fills Table
  2594.       for level in min_l..max_l
  2595.         # Assigns Value
  2596.         table[i] = self.calculate_value(i, min_l.to_f, max_l.to_f,
  2597.                    min_v.to_f, max_v.to_f, e.to_f, l.to_f)
  2598.       end
  2599.       # Return Table
  2600.       return table
  2601.     end
  2602.     #------------------------------------------------------------------------
  2603.     # * Late Curve
  2604.     #------------------------------------------------------------------------
  2605.     def self.late_curve(level, min_level, max_level, min, max)
  2606.       diff = min_level - max_level
  2607.       stat = min - max
  2608.       num = stat * level ** 2 - 2 * min_level * stat * level + min_level ** 2 *
  2609.             max - 2 * min_level * max_level * min + min * min_level ** 2
  2610.       denom = diff ** 2
  2611.       return num / denom
  2612.     end
  2613.     #------------------------------------------------------------------------
  2614.     # * Early Curve
  2615.     #------------------------------------------------------------------------
  2616.     def self.early_curve(level, min_level, max_level, min, max)
  2617.       diff = max_level - min_level
  2618.       stat = max - @min
  2619.       num = -stat * level ** 2 + 2 * max_level * stat * level + min_level **
  2620.             2 * max - 2 * min_level * max_level * max + min * max_level ** 2
  2621.       denom = diff ** 2
  2622.       return num / denom    
  2623.     end
  2624.     #------------------------------------------------------------------------
  2625.     # * Steady Curve
  2626.     #------------------------------------------------------------------------
  2627.     def self.steady_curve(level, min_level, max_level, min, max)
  2628.       ch_level = max_level - min_level
  2629.       ch_stat = max - min
  2630.       base = ch_stat / ch_level * level
  2631.       mod = max * min_level - min * max_level
  2632.       base2 = mod / ch_level
  2633.       return base - base2
  2634.     end
  2635.     #------------------------------------------------------------------------
  2636.     # * Calculate Value
  2637.     #------------------------------------------------------------------------
  2638.     def self.calculate_value(level, min_level, max_level, min, max, e, l)
  2639.       return min if level < min_level
  2640.       return max if max_level < level
  2641.       if e == l
  2642.         stat = self.steady_curve(level, min_level, max_level, min, max)
  2643.       else
  2644.         early_ = self.early_curve(level, min_level, max_level, min, max)
  2645.         late_ = self.late_curve(level, min_level, max_level, min, max)
  2646.         stat = (e * early_ + l * late_) / (e + l)
  2647.       end
  2648.       stat = Integer([[stat, min].max, max].min)
  2649.       return stat
  2650.     end
  2651.   end
  2652.      
  2653.   #============================================================================
  2654.   # ** ESL_Curves
  2655.   #============================================================================
  2656.  
  2657.   module ESL_Curves
  2658.     #------------------------------------------------------------------------
  2659.     # * Generate Curve
  2660.     #------------------------------------------------------------------------
  2661.     def self.generate_curve(mn_v, md_v, mx_v, mn_l, md_l, mx_l, e = 0, l = 0,
  2662.                             s = 0, c1 = 0, c2 = 0, i = true)
  2663.       # Saves Values
  2664.       @min_value, @mid_value, @max_value = mn_v, md_v, mx_v
  2665.       @min_level, @mid_level, @max_level = mn_l, md_l, mx_l
  2666.       @early    , @late     , @steady    = e   , l   , s
  2667.       @curve1   , @curve2   , @integer   = c1  , c2  , i
  2668.       # Error Checking
  2669.       self.error_checking
  2670.       # Calculate constants
  2671.       self.calculate_constants
  2672.       # Returns Table
  2673.       return self.generate_table
  2674.     end
  2675.     #-----------------------------------------------------------------------
  2676.     # * Error Checking
  2677.     #-----------------------------------------------------------------------
  2678.     def self.error_checking
  2679.       if @late + @early + @steady + @curve1 + @curve2 == 0
  2680.         raise(StandardError, "No Influences Have Been Defined")
  2681.       elsif @min_level == @mid_level || @min_level == @max_level ||
  2682.             @mid_level == @max_level
  2683.         raise(StandardError, "Can't Use Same Level for Min, Mid, or Max Level")
  2684.       end
  2685.     end
  2686.     #-----------------------------------------------------------------------
  2687.     # * Calculate Constants
  2688.     #-----------------------------------------------------------------------
  2689.     def self.calculate_constants
  2690.       # Calculate "infi" and "inmi"
  2691.       @inmi = (@mid_value - @min_value) / (@mid_level - @min_level)
  2692.       @infi = (@max_value - @min_value) / (@max_level - @min_level)
  2693.       # Calculate "infimi"
  2694.       @infimi = (@infi - @inmi) / (@max_level - @mid_level)
  2695.     end
  2696.     #-----------------------------------------------------------------------
  2697.     # * Generate Table
  2698.     #-----------------------------------------------------------------------
  2699.     def self.generate_table
  2700.       # Create Hash table
  2701.       table = {}
  2702.       # Run Through Each Level
  2703.       self.each {|level, value| table[level] = value}
  2704.       # Return Created Table
  2705.       return table
  2706.     end
  2707.     #-----------------------------------------------------------------------
  2708.     # * Each Interator
  2709.     #-----------------------------------------------------------------------
  2710.     def self.each
  2711.       # Get Minimum level and Maximum Level
  2712.       minimum, maximum = @min_level.to_i, @max_level.to_i
  2713.       # Run Through Minimum and Maximum and Yield Level and Value
  2714.       (minimum..maximum).each {|level| yield(level, self.get_stat(level))}
  2715.     end
  2716.     #-----------------------------------------------------------------------
  2717.     # * Get Stat
  2718.     #-----------------------------------------------------------------------
  2719.     def self.get_stat(level)
  2720.       return @integer ? @min_value.to_i : @min_value if level <= @min_level
  2721.       return @integer ? @max_value.to_i : @max_value if level >= @max_level
  2722.       # Setup Total
  2723.       total = 0
  2724.       # Get Values for Every Stat if greater than 0
  2725.       total += @early  * self.early_curve(level)      if @early > 0
  2726.       total += @late   * self.late_curve(level)       if @late > 0
  2727.       total += @steady * self.steady_curve(level)     if @steady > 0
  2728.       total += @curve1 * self.early_late_curve(level) if @curve1 > 0
  2729.       total += @curve2 * self.late_early_curve(level) if @curve2 > 0
  2730.       # Get Average
  2731.       total /= @late + @early + @steady + @curve1 + @curve2
  2732.       # Limit Value
  2733.       total = level < @mid_level ?
  2734.         [total, @mid_value].min : [total, @mid_value].max
  2735.       # Further Limit Value
  2736.       total = [[total, @min_value].max, @max_value].min
  2737.       # Return Value
  2738.       return @integer ? total.to_i : total
  2739.     end
  2740.     #-----------------------------------------------------------------------
  2741.     # * Late Curve
  2742.     #-----------------------------------------------------------------------
  2743.     def self.late_curve(level)
  2744.       # Calculate "A"
  2745.       a_num = @infimi * (3 * @min_level + @mid_level) + @inmi
  2746.       a_den = (@max_level - @min_level) * (@mid_level - @min_level)
  2747.       a = - a_num / a_den
  2748.       # Return Value
  2749.       return curve(a, level)
  2750.     end
  2751.     #-----------------------------------------------------------------------
  2752.     # * Early Curve
  2753.     #-----------------------------------------------------------------------
  2754.     def self.early_curve(level)
  2755.       # Calculate "A"
  2756.       a_num = @infimi * (2 * @max_level + @min_level + @mid_level) + @inmi
  2757.       a_den = (@max_level - @mid_level) * (@max_level - @min_level)
  2758.       a = - a_num / a_den
  2759.       # Return Value
  2760.       return curve(a, level)
  2761.     end
  2762.     #-----------------------------------------------------------------------
  2763.     # * Early Late Curve
  2764.     #-----------------------------------------------------------------------
  2765.     def self.early_late_curve(level)
  2766.       # Calculate "A"
  2767.       a = @infimi / (@max_level + @min_level - 2 * @mid_level)
  2768.       # Return Value
  2769.       return curve(a, level)
  2770.     end
  2771.     #-----------------------------------------------------------------------
  2772.     # * Late Early Curve
  2773.     #-----------------------------------------------------------------------
  2774.     def self.late_early_curve(level)
  2775.       # If Less than Mid Level
  2776.       if level < @mid_level
  2777.         # Return Late Curve for level
  2778.         return late_curve(level)
  2779.       # If Greater than Mid Level
  2780.       elsif level > @mid_level
  2781.         # Return Early Curve for Level
  2782.         return early_curve(level)
  2783.       # If at Mid Level
  2784.       elsif level == @mid_level
  2785.         # Return Mid Value
  2786.         return @mid_value
  2787.       end
  2788.     end
  2789.     #-----------------------------------------------------------------------
  2790.     # * Steady Curve
  2791.     #-----------------------------------------------------------------------
  2792.     def self.steady_curve(level)
  2793.       ch_level = @max_level - @min_level
  2794.       ch_stat = @max_value - @min_value
  2795.       base = ch_stat / ch_level * level
  2796.       mod = @max_value * @min_level - @min_level * @max_level
  2797.       base2 = mod / ch_level
  2798.       return base - base2
  2799.     end
  2800.     #-----------------------------------------------------------------------
  2801.     # * Curve
  2802.     #-----------------------------------------------------------------------
  2803.     def self.curve(a, level)
  2804.       # Calculate "B"
  2805.       b = @infimi - a * (@min_level + @mid_level + @max_level)
  2806.       # Calculate "C"
  2807.       c = @inmi - a * (@mid_level ** 2 + @min_level * @mid_level +
  2808.           @min_level ** 2) - b * (@mid_level + @min_level)
  2809.       # Calculate "D"
  2810.       d = @min_value - (a * @min_level ** 3 + b * @min_level ** 2 + c *
  2811.           @min_level)
  2812.       # Calculate Stat
  2813.       stat = a * level ** 3 + b * level ** 2 + c * level + d
  2814.       # Return Stat
  2815.       return stat
  2816.     end
  2817.   end
  2818. end
  2819.  
  2820. #==============================================================================
  2821. # ** Modules.Event Spawner (2.02)                             By SephirothSpawn
  2822. #------------------------------------------------------------------------------
  2823. # * Description :
  2824. #
  2825. #   This script was designed to allow you to create events via scripts. It
  2826. #   will create events immeditately, and can save created events perm. on the
  2827. #   map after creation, or appear once. You can also clone events, performing
  2828. #   modifications via Event Spawner module, or immeditely end the clone
  2829. #   event process and move the new event to a position.
  2830. #------------------------------------------------------------------------------
  2831. # * Instructions :
  2832. #
  2833. #   THIS SCRIPT IS COMPLEX!!! I TOOK HOURS OF COMMENTING, RUNNING THROUGH
  2834. #   ALL EVENT CODES & PARAMETERS (600+ LINES), AND MAKING THIS SCRIPT EASIER
  2835. #   TO USE. PLEASE READ THE CREATION & EVENT COMMAND CODES & PARAMETERS
  2836. #   BEFORE ASKING FOR SUPPORT!
  2837. #
  2838. #   If you are ever unsure of a event layout, insert this at the top of event
  2839. #   commands
  2840. #
  2841. #   Call Script :
  2842. #
  2843. #     for event_command in $game_map.events[event_id].list
  2844. #       p [event_command.code, event_command.parameters, event_command.indent]
  2845. #     end
  2846. #
  2847. #   Write down the code, parameters & indention, and use the add event command
  2848. #   function to create event commands.
  2849. #
  2850. #   To see instructions on creating events, refer to creation instrucitons.
  2851. #   To see event command codes & parameters, refer to event command c & p.
  2852. #------------------------------------------------------------------------------
  2853. # * Making Events Without Huge Call Scripts :
  2854. #
  2855. #   This script has a built-in sub-module that will create events with a
  2856. #   simple 1-line call script, rather than creating a 15 line call script.
  2857. #
  2858. #   To create a simple event spawn, search for the Presets module, directly
  2859. #   below the Event_Spawner module heading.
  2860. #
  2861. #   Create a method name, which should match the event you are creating. For
  2862. #   example; if you were creating a event on your map that will show a simple
  2863. #   text message, you can use a name such as
  2864. #
  2865. #   def self.sample_event_text
  2866. #
  2867. #   Make sure to put the self. in from of your method name, or it will not
  2868. #   read the method and you will have an error.
  2869. #
  2870. #   Basic Syntax For Method Naming
  2871. #
  2872. #     def self.<event_name>
  2873. #
  2874. #   Feel free to use method arguments as well (If you don't understand this,
  2875. #   do not worry about it)
  2876. #
  2877. #
  2878. #   Once your method is defined, you can now put what you would put in your
  2879. #   call script here in the method name.
  2880. #
  2881. #   Finish you method by adding a end and you are finished.
  2882. #
  2883. #
  2884. #   Example Preset Event:
  2885. #
  2886. #    def self.sample_event_a
  2887. #      Event_Spawner.create_event(3, 5, 'Sample Event A')
  2888. #      Event_Spawner.set_page_graphic({'c_name' => '002-Fighter02'})
  2889. #      Event_Spawner.add_event_command(101, ['I am a spawned event'])
  2890. #      Event_Spawner.end_event
  2891. #    end
  2892. #
  2893. #   ~ Creates an event at 3, 5 named Sample Event A
  2894. #   ~ Sets 1st Page Graphic Character Name to 002-Fighter02
  2895. #   ~ Creates Event Command : Show Message (Code 101)
  2896. #   ~ Ends Event
  2897. #
  2898. #   To call your event preset, use
  2899. #
  2900. #   Event_Spawner.Presets.<method_name>
  2901. #
  2902. #   (This Basically Serves as nothing more than call scripts in the script
  2903. #    itself, rather than the events.)
  2904. #------------------------------------------------------------------------------
  2905. # * Event Creation Instructions :
  2906. #
  2907. #
  2908. #   **** Basic Event Creation Procedure ****
  2909. #
  2910. #   1) Create Event
  2911. #   2) Set Page Graphics & Conditions
  2912. #   3) Set Page Conditions
  2913. #   4) Add New Page (If Needed)
  2914. #   5) Repeat Steps 2-4 as needed
  2915. #   6) End Event
  2916. #
  2917. #
  2918. #   **** Syntax Instructions *****
  2919. #
  2920. #   Creating Event
  2921. #    - Event_Spawner.create_event(x = 0, y = 0, name = '')
  2922. #
  2923. #   Adding Event Command
  2924. #    - Event_Spawner.add_event_command(code, parameters = [], indent = 0)
  2925. #
  2926. #   Setting Page Condition
  2927. #    - Event_Spawner.set_page_condition({<parameters>})
  2928. #      'switch1'    => switch_id
  2929. #      'switch2'    => switch_id
  2930. #      'selfswitch' => 'A', 'B', 'C' or 'D'
  2931. #      'variable'   => [variable_id, value]
  2932. #
  2933. #   Setting Page Graphic
  2934. #    - Event_Spawner.set_page_graphic(
  2935. #      'tileid'  => id
  2936. #      'c_name'  => 'character_filename'
  2937. #      'c_hue'   => 0..360
  2938. #      'dir'     => 2 : Down, 4 : Left, 6 : Right, 8 : Up
  2939. #      'pattern' => 0..3
  2940. #      'opacity' => 0..255
  2941. #      'blend'   => 0 : Normal, 1 : Addition, 2 : Subtraction
  2942. #
  2943. #   Setting Page Trigger
  2944. #    - Event_Spawner.set_page_trigger(trigger)
  2945. #      0 : Action Button, 1 : Contact With Player, 2 - Contact With Event
  2946. #      3 : Autorun,       4 : Parallel Processing
  2947. #
  2948. #   Set Page Move Settings
  2949. #    - Event_Spawner.set_page_move_settings({<parameters>})
  2950. #      'type'  => 0 : fixed, 1 : random, 2 : approach, 3 : custom).
  2951. #      'speed' => 1 : slowest ... 6 : fastest
  2952. #      'freq'  => 1 : lowest  ... 6 : highest
  2953. #      'route' => RPG::MoveRoute (See Generate Move Route)
  2954. #
  2955. #   Generate Move Route
  2956. #    - Event_Spawner.generate_move_route(list = [], repeat, skippable)
  2957. #      See Method Heading For List Parameters
  2958. #------------------------------------------------------------------------------
  2959. # * Event Command Code & Parameters
  2960. #
  2961. #  ~~ Show Text
  2962. #    - Code       : 101 (Lines After First Line : 401)
  2963. #    - Parameters : ['Text Line']
  2964. #
  2965. #  ~~ Show Choices
  2966. #    - Code       : 102
  2967. #    - Parameters : Did not comment on yet
  2968. #
  2969. #  ~~ When [**]
  2970. #    - Code       : 402
  2971. #    - Parameters : Did not comment on yet
  2972. #
  2973. #  ~~ When Cancel
  2974. #    - Code       : 403
  2975. #    - Parameters : Did not comment on yet
  2976. #
  2977. #  ~~ Input Number
  2978. #    - Code       : 103
  2979. #    - Parameters : Did not comment on yet
  2980. #  ~~ Change Text Options
  2981. #    - Code       : 104
  2982. #    - Parameters : [ <message_position>, <message_frame> ]
  2983. #
  2984. #      <message_position> - (0 : Up, 1 : Middle, 2 : Down)
  2985. #      <message_frame>    - (0 : Visible, 1 : Invisible)
  2986. #
  2987. #  ~~ Button Input Processing
  2988. #    - Code       : 105
  2989. #    - Parameters : [ variable_id ]
  2990. #
  2991. #  ~~ Wait
  2992. #    - Code       : 106
  2993. #    - Parameters : [ frames ]
  2994. #
  2995. #  ~~ Comment :
  2996. #    - Code       : 108 (Lines After First Line - 408)
  2997. #    - Parameters : [ 'Comment Text' ]
  2998. #
  2999. #  ~~ Conditional Branch
  3000. #    - Code       : 111
  3001. #    - Parameters : Did not comment on yet
  3002. #
  3003. #  ~~ Else
  3004. #    - Code       : 411
  3005. #    - Parameters : Did not comment on yet
  3006. #
  3007. #  ~~ Loop
  3008. #    - Code       : 112
  3009. #    - Parameters : Did not comment on yet
  3010. #
  3011. #  ~~ Repeat Above
  3012. #    - Code       : 413
  3013. #    - Parameters : Did not comment on yet
  3014. #
  3015. #  ~~ Break Loop
  3016. #    - Code       : 113
  3017. #    - Parameters : Did not comment on yet
  3018. #
  3019. #  ~~ Exit Event Processing
  3020. #    - Code       : 115
  3021. #    - Parameters : []
  3022. #
  3023. #  ~~ Erase Event
  3024. #    - Code       : 116
  3025. #    - Parameters : []
  3026. #
  3027. #  ~~ Call Common Event
  3028. #    - Code       : 117
  3029. #    - Parameters : [ common_event_id ]
  3030. #
  3031. #  ~~ Label
  3032. #    - Code       : 118
  3033. #    - Parameters : [ 'label_name' ]
  3034. #
  3035. #  ~~ Jump to Label
  3036. #    - Code       : 119
  3037. #    - Parameters : [ 'label_name' ]
  3038. #
  3039. #  ~~ Control Switches
  3040. #    - Code       : 121
  3041. #    - Parameters : [ start_variable, end_variable, <boolean> ]
  3042. #
  3043. #    <boolean> - (0 : On, 1 : Off)
  3044. #
  3045. #  ~~ Control Variables
  3046. #    - Code       : 122
  3047. #    - Parameters : [ start_var_id, end_var_id, <opperation>, <opperand>, <p> ]
  3048. #
  3049. #    <opperation> - (0: Set, 1: +, 2: -, 3: *, 4: /, 5: %)
  3050. #    <opperand> - (0: Constant, 1: Variable, 2: Random Number, 3: Item,
  3051. #                  4: Hero, 5: Monster, 6: Sprite, 7: Other)
  3052. #    <p>
  3053. #       When <opperand> is Constant (0)
  3054. #        - n
  3055. #       When <opperand> is Variable (1)
  3056. #        - variable_id
  3057. #       When <opperand> is Random Number (2)
  3058. #        - lower, higher
  3059. #       When <opperand> is Item (3)
  3060. #        - item_id
  3061. #       When <opperand> is Hero (4)
  3062. #        - hero_id, <stat> (See <stat> Below)
  3063. #       When <opperand> is Monster (5)
  3064. #        - monster_id, <stat> (See <stat> Below)
  3065. #       When <opperand> is Sprite (6)
  3066. #        - <event_id>, <tile>
  3067. #
  3068. #        <event_id> - (-1: Player, 0: This Event, 1-X: Event ID)
  3069. #        <tile> - (0: X Tile, 1: Y Tile, 2: Face, 3: Screen X, 4: Screen Y,
  3070. #                  5:Terrain)
  3071. #       When <opperand> is Other (7)
  3072. #        - (0: Map ID, 1: Party Size, 2: Money, 3: # of Steps,
  3073. #           4: Timer in Secs, 5: # of Saves)
  3074. #
  3075. #        <stat> - (0: HP, 1: SP, 2: Max HP, 3: Max SP, 4: Str,
  3076. #                  5: Dex, 6: Agi, 7: Int, 8: Atk, 9: PDef, 10: MDef, 11: Eva)
  3077. #  ~~ Control Self Switch
  3078. #    - Code       : 123
  3079. #    - Parameters : [ 'switch_letter', <boolean> ]
  3080. #
  3081. #    <boolean> - (0 : On, 1 : Off)
  3082. #
  3083. #  ~~ Control Timer
  3084. #    - Code       : 124
  3085. #    - Parameters : [ <boolean>, seconds ]
  3086. #
  3087. #    <boolean> - (0 : On, 1 : Off)
  3088. #
  3089. #  ~~ Change Gold
  3090. #    - Code       : 125
  3091. #    - Parameters : [ <operation>, <type>, <operand> ]
  3092. #
  3093. #    <operation> - (0 : Increase, 1 : Decrease)
  3094. #    <type> - (0: Constant 1: Variable)
  3095. #    <operand> - number or variable_id
  3096. #
  3097. #  ~~ Change Items
  3098. #    - Code       : 126
  3099. #    - Parameters : [ item_id, <operation>, <type>, <operand> ]
  3100. #
  3101. #    <operation> - (0 : Increase, 1 : Decrease)
  3102. #    <type> - (0: Constant 1: Variable)
  3103. #    <operand> - number or variable_id
  3104. #
  3105. #  ~~ Change Weapons
  3106. #    - Code       : 127
  3107. #    - Parameters :[ weapon_id, <operation>, <type>, <operand> ]
  3108. #
  3109. #    <operation> - (0 : Increase, 1 : Decrease)
  3110. #    <type> - (0: Constant 1: Variable)
  3111. #    <operand> - number or variable_id
  3112. #
  3113. #  ~~ Change Armor
  3114. #    - Code       : 128
  3115. #    - Parameters :[ armor_id, <operation>, <type>, <operand> ]
  3116. #
  3117. #    <operation> - (0 : Increase, 1 : Decrease)
  3118. #    <type> - (0: Constant 1: Variable)
  3119. #    <operand> - number or variable_id
  3120. #
  3121. #  ~~ Change Party Member
  3122. #    - Code       : 129
  3123. #    - Parameters : [ actor_id, <operation>, <reset> ]
  3124. #
  3125. #    <operation> - (0 : Add, 1 : Remove)
  3126. #    <reset> - (0 : Leave As Is, 1 : Reset Actor Information)
  3127. #
  3128. #  ~~ Change Windowskin
  3129. #    - Code       : 131
  3130. #    - Parameters : [ 'windowskin_name' ]
  3131. #
  3132. #  ~~ Change Battle BGM
  3133. #    - Code       : 132
  3134. #    - Parameters : [ 'battle_bgm' ]
  3135. #
  3136. #  ~~ Change Battle End ME
  3137. #    - Code       : 133
  3138. #    - Parameters : [ 'battle_me' ]
  3139. #
  3140. #  ~~ Change Save Access
  3141. #    - Code       : 134
  3142. #    - Parameters : [ <boolean> ]
  3143. #
  3144. #    <boolean> - (0 : On, 1 : Off)
  3145. #
  3146. #  ~~ Change Menu Access
  3147. #    - Code       : 135
  3148. #    - Parameters : [ <boolean> ]
  3149. #
  3150. #    <boolean> - (0 : On, 1 : Off)
  3151. #
  3152. #  ~~ Change Encounter
  3153. #    - Code       : 136
  3154. #    - Parameters : [ <boolean> ]
  3155. #
  3156. #    <boolean> - (0 : On, 1 : Off)
  3157. #
  3158. #  ~~ Transfer Player
  3159. #    - Code       : 201
  3160. #    - Parameters : [ <type>, <map_id>, <x>, <y>, <direction> ]
  3161. #
  3162. #    <type> - (0 : Constant, 1 : Game Variable)
  3163. #    <map_id> - number or variable_id
  3164. #    <x> - number or variable_id
  3165. #    <x> - number or variable_id
  3166. #    <direction> - (2 : Down, 4 : Left, 6 : Right, 8 : Up)
  3167. #
  3168. #  ~~ Set Event Location
  3169. #    - Code       : 202
  3170. #    - Parameters : [ <target_event>, <type>, <params>, <direction> ]
  3171. #
  3172. #    <target_event> - (-1 : Player, 0 : Current Event, N : Event ID)
  3173. #    <type> - (0 : Constant, 1 : Variables, 2 : Switch With Event)
  3174. #    <params>
  3175. #     When type is Constant (0) - target_x, target_y
  3176. #     When type is Variables (1) - x_variable, y_variable
  3177. #     When type is Switch Event (2) - event_id
  3178. #    <direction> - (2 : Down, 4 : Left, 6 : Right, 8 : Up)
  3179. #
  3180. #  ~~ Scroll Map
  3181. #    - Code       : 203
  3182. #    - Parameters : [ <direction>, distance, speed ]
  3183. #
  3184. #    <direction> - (2 : Down, 4 : Left, 6 : Right, 8 : Up)
  3185. #
  3186. #  ~~ Change Map Settings
  3187. #    - Code       : 204
  3188. #    - Parameters : [ <type>, <params> ]
  3189. #
  3190. #    <type> - (0 : Panorama, 1 : Fog, 2 : Battleback)
  3191. #    <params>
  3192. #     When type is Panorama (0) - name, hue
  3193. #     When type is Fog (1) - name, hue, opacity, blend_type, zoom, sx, sy
  3194. #     When type is Battleback (2) - name
  3195. #
  3196. #  ~~ Change Fog Color Tone
  3197. #    - Code       : 205
  3198. #    - Parameters : [ tone, duration ]
  3199. #
  3200. #  ~~ Change Fog Opacity
  3201. #    - Code       : 206
  3202. #    - Parameters : [ opacity, duration ]
  3203. #
  3204. #  ~~ Show Animation
  3205. #    - Code       : 207
  3206. #    - Parameters : [ <target_event>, animation_id ]
  3207. #
  3208. #    <target_event> - (-1 : Player, 0 : Current Event, N : Event ID)
  3209. #
  3210. #  ~~ Change Transparent Flag
  3211. #    - Code       : 208
  3212. #    - Parameters : [ <boolean> ]
  3213. #
  3214. #    <boolean> - (0 : Transparent, 1 : Non-Transparent)
  3215. #
  3216. #  ~~ Set Move Route
  3217. #    - Code       : 209
  3218. #    - Parameters : [ <target_event>, RPG::MoveRoute ]
  3219. #
  3220. #    <target_event> - (-1 : Player, 0 : Current Event, N : Event ID)
  3221. #
  3222. #  ~~ Wait for Move's Completion
  3223. #    - Code       : 210
  3224. #    - Parameters : []
  3225. #
  3226. #  ~~ Prepare for Transition
  3227. #    - Code       : 221
  3228. #    - Parameters : []
  3229. #
  3230. #  ~~ Execute Transition
  3231. #    - Code       : 222
  3232. #    - Parameters : [ transition_name ]
  3233. #
  3234. #  ~~ Change Screen Color Tone
  3235. #    - Code       : 223
  3236. #    - Parameters : [ tone, duration ]
  3237. #
  3238. #  ~~ Screen Flash
  3239. #    - Code       : 224
  3240. #    - Parameters : [ color, duration ]
  3241. #
  3242. #  ~~ Screen Shake
  3243. #    - Code       : 225
  3244. #    - Parameters : [ power, speed, duration ]
  3245. #
  3246. #  ~~ Show Picture
  3247. #    - Code       : 231
  3248. #    - Parameters : [ pic_id, name orgin, <type>, <x>, <y>,
  3249. #                     zoom_x, zoom_y, opacity, blend_type ]
  3250. #
  3251. #    <type> - (0 : Constant, 1 : Variables)
  3252. #    <x> - number or variable_id
  3253. #    <y> - number or variable_id
  3254. #
  3255. #  ~~ Move Picture
  3256. #    - Code       : 232
  3257. #    - Parameters : [ pic_id, name orgin, <type>, <x>, <y>,
  3258. #                     zoom_x, zoom_y, opacity, blend_type ]
  3259. #
  3260. #    <type> - (0 : Constant, 1 : Variables)
  3261. #    <x> - number or variable_id
  3262. #    <y> - number or variable_id
  3263. #
  3264. #  ~~ Rotate Picture
  3265. #    - Code       : 233
  3266. #    - Parameters : [ pic_id, angel ]
  3267. #
  3268. #  ~~ Change Picture Color Tone
  3269. #    - Code       : 234
  3270. #    - Parameters : [ pic_id, tone, duration ]
  3271. #
  3272. #  ~~ Erase Picture
  3273. #    - Code       : 235
  3274. #    - Parameters : [ pic_id ]
  3275. #
  3276. #  ~~ Set Weather Effects
  3277. #    - Code       : 236
  3278. #    - Parameters : [ <type>, power, duration ]
  3279. #
  3280. #    <type> - (0 : None, 1 : Rain, 2: Storm; 3: Snow)
  3281. #
  3282. #  ~~ Play BGM
  3283. #    - Code       : 241
  3284. #    - Parameters : [ RPG::AudioFile ]
  3285. #
  3286. #  ~~ Fade Out BGM
  3287. #    - Code       : 242
  3288. #    - Parameters : [ time ]
  3289. #
  3290. #  ~~ Play BGS
  3291. #    - Code       : 245
  3292. #    - Parameters : [ RPG::AudioFile ]
  3293. #
  3294. #  ~~ Fade Out BGS
  3295. #    - Code       : 246
  3296. #    - Parameters : [ time ]
  3297. #
  3298. #  ~~ Memorize BGM/BGS
  3299. #    - Code       : 247
  3300. #    - Parameters : []
  3301. #
  3302. #  ~~ Restore BGM/BGS
  3303. #    - Code       : 248
  3304. #    - Parameters : []
  3305. #
  3306. #  ~~ Play ME
  3307. #    - Code       : 249
  3308. #    - Parameters : [ RPG::AudioFile ]
  3309. #
  3310. #  ~~ Play SE
  3311. #    - Code       : 250
  3312. #    - Parameters : [ RPG::AudioFile ]
  3313. #
  3314. #  ~~ Stop SE
  3315. #    - Code       : 251
  3316. #    - Parameters : []
  3317. #
  3318. #  ~~ Battle Processing
  3319. #    - Code       : 301
  3320. #    - Parameters : [ troop_id, can_escape_boolean, can_lose_boolean ]
  3321. #
  3322. #  ~~ If Win
  3323. #    - Code       : 601
  3324. #    - Parameters : []
  3325. #
  3326. #  ~~ If Escape
  3327. #    - Code       : 602
  3328. #    - Parameters : []
  3329. #
  3330. #  ~~ If Lose
  3331. #    - Code       : 603
  3332. #    - Parameters : []
  3333. #
  3334. #  ~~ Shop Processing
  3335. #    - Code       : 302 (For Additional Shop Item Setup - 605)
  3336. #    - Parameters : [ [ <item_type>, item_id] ]
  3337. #
  3338. #    <item_type> - (0 : Item, 1 : Weapon, 2 : Armor)
  3339. #
  3340. #  ~~ Name Input Processing
  3341. #    - Code       : 303
  3342. #    - Parameters : [ actor_id, max_characters ]
  3343. #
  3344. #  ~~ Change HP
  3345. #    - Code       : 311
  3346. #    - Parameters : [ <actors>, <operation>, <type>, <operand> ]
  3347. #
  3348. #    <actors> - (0 : All Party Actors, N : Actor ID)
  3349. #    <operation> - (0 : Increase, 1 : Decrease)
  3350. #    <type> - (0: Constant 1: Variable)
  3351. #    <operand> - number or variable_id
  3352. #
  3353. #  ~~ Change SP
  3354. #    - Code       : 312
  3355. #    - Parameters : [ <actors>, <operation>, <type>, <operand> ]
  3356. #
  3357. #    <actors> - (0 : All Party Actors, N : Actor ID)
  3358. #    <operation> - (0 : Increase, 1 : Decrease)
  3359. #    <type> - (0: Constant 1: Variable)
  3360. #    <operand> - number or variable_id
  3361. #
  3362. #  ~~ Change State
  3363. #    - Code       : 313
  3364. #    - Parameters : [ <actors>, <operation>, state_id ]
  3365. #
  3366. #    <actors> - (0 : All Party Actors, N : Actor ID)
  3367. #    <operation> - (0 : Add State, 1 : Remove State)
  3368. #
  3369. #  ~~ Recover All
  3370. #    - Code       : 314
  3371. #    - Parameters :[ <actors> ]
  3372. #
  3373. #    <actors> - (0 : All Party Actors, N : Actor ID)
  3374. #
  3375. #  ~~ Change EXP
  3376. #    - Code       : 315
  3377. #    - Parameters : [ <actors>, <operation>, <type>, <operand> ]
  3378. #
  3379. #    <actors> - (0 : All Party Actors, N : Actor ID)
  3380. #    <operation> - (0 : Increase, 1 : Decrease)
  3381. #    <type> - (0: Constant 1: Variable)
  3382. #    <operand> - number or variable_id
  3383. #
  3384. #  ~~ Change Level
  3385. #    - Code       : 316
  3386. #    - Parameters : [ <actors>, <operation>, <type>, <operand> ]
  3387. #
  3388. #    <actors> - (0 : All Party Actors, N : Actor ID)
  3389. #    <operation> - (0 : Increase, 1 : Decrease)
  3390. #    <type> - (0: Constant 1: Variable)
  3391. #    <operand> - number or variable_id
  3392. #
  3393. #  ~~ Change Parameters
  3394. #    - Code       : 317
  3395. #    - Parameters : [ <actors>, <parameter>, <operation>, <type>, <operand> ]
  3396. #
  3397. #    <actors> - (0 : All Party Actors, N : Actor ID)
  3398. #    <parameter> - (0 : MaxHP, 1 : MaxSP, 2 : Str, 3 : Dex, 4 : Agi, 4 : Int)
  3399. #    <operation> - (0 : Increase, 1 : Decrease)
  3400. #    <type> - (0: Constant 1: Variable)
  3401. #    <operand> - number or variable_id
  3402. #
  3403. #  ~~ Change Skills
  3404. #    - Code       : 318
  3405. #    - Parameters : [ actor_id, <operation>, skill_id ]
  3406. #
  3407. #    <operation> - (0 : Learn Skill, 1 : Forget Skill)
  3408. #
  3409. #  ~~ Change Equipment
  3410. #    - Code       : 319
  3411. #    - Parameters : [ actor_id, <equip_type>, equipment_id ]
  3412. #
  3413. #    <equip_type> : (0 : Weapon, 1 : Shield, 2 : Head, 3 : Body, 4 : Acc)
  3414. #
  3415. #  ~~ Change Actor Name
  3416. #    - Code       : 320
  3417. #    - Parameters : [ actor_id, 'name' ]
  3418. #
  3419. #  ~~ Change Actor Class
  3420. #    - Code       : 321
  3421. #    - Parameters : [ actor_id, class_id ]
  3422. #
  3423. #  ~~ Change Actor Graphic
  3424. #    - Code       : 322
  3425. #    - Parameters : [ actor_id, character_name, character_hue,
  3426. #                               battler_name, battler_hue ]
  3427. #
  3428. #  ~~ Change Enemy HP
  3429. #    - Code       : 331
  3430. #    - Parameters : [ <enemies>, <operation>, <type>, <operand> ]
  3431. #
  3432. #    <enemies> - (0 : All Enemies, N : Enemy Index)
  3433. #    <operation> - (0 : Increase, 1 : Decrease)
  3434. #    <type> - (0: Constant 1: Variable)
  3435. #    <operand> - number or variable_id
  3436. #
  3437. #  ~~ Change Enemy SP
  3438. #    - Code       : 332
  3439. #    - Parameters : [ <enemies>, <operation>, <type>, <operand> ]
  3440. #
  3441. #    <enemies> - (0 : All Enemies, N : Enemy Index)
  3442. #    <operation> - (0 : Increase, 1 : Decrease)
  3443. #    <type> - (0: Constant 1: Variable)
  3444. #    <operand> - number or variable_id
  3445. #
  3446. #  ~~ Change Enemy State
  3447. #    - Code       : 333
  3448. #    - Parameters : [ <enemies>, <operation>, state_id ]
  3449. #
  3450. #    <enemies> - (0 : All Enemies, N : Enemy Index)
  3451. #    <operation> - (0 : Add State, 1 : Remove State)
  3452. #
  3453. #  ~~ Enemy Recover All
  3454. #    - Code       : 334
  3455. #    - Parameters : [ <enemies> ]
  3456. #
  3457. #    <enemies> - (0 : All Enemies, N : Enemy Index)
  3458. #
  3459. #  ~~ Enemy Appearance
  3460. #    - Code       : 335
  3461. #    - Parameters : [ <enemies> ]
  3462. #
  3463. #    <enemies> - (0 : All Enemies, N : Enemy Index)
  3464. #
  3465. #  ~~ Enemy Transform
  3466. #    - Code       : 336
  3467. #    - Parameters : [ enemy_index, target_enemy_id ]
  3468. #
  3469. #  ~~ Show Battle Animation
  3470. #    - Code       : 337
  3471. #    - Parameters : [ <target_troop>, <battlers>, animation_id ]
  3472. #
  3473. #    <target_troop> - (0 : Enemies, 1 : Actors)
  3474. #    <battlers> - (0 : Entire Troop, N : Index)
  3475. #
  3476. #  ~~ Deal Damage
  3477. #    - Code       : 338
  3478. #    - Parameters : [ <target_troop>, <battlers>, <type>, <operand> ]
  3479. #
  3480. #    <target_troop> - (0 : Enemies, 1 : Actors)
  3481. #    <battlers> - (0 : Entire Troop, N : Index)
  3482. #    <type> - (0: Constant 1: Variable)
  3483. #    <operand> - number or variable_id]
  3484. #
  3485. #  ~~ Force Action
  3486. #    - Code       : 339
  3487. #    - Parameters : [ <target_group>, <battlers>, <kind>, <basic>,
  3488. #                     <target>, <forcing> ]
  3489. #
  3490. #    <target_troop> - (0 : Enemies, 1 : Actors)
  3491. #    <battlers> - (0 : Entire Troop, N : Index)
  3492. #    <kind> - (0 : Attack/Guard, 1: Skill)
  3493. #    <basic>
  3494. #      When Kind is 0 - (0 : Attack, 1 : Guard)
  3495. #      When Kind is 1 - skill_id
  3496. #    <target> - (-2 : Last Target, -1 : Random Target, N : Target Index)
  3497. #    <forcing> - (0 : Execute Instead Of Next Move, 1 : Force Now)
  3498. #
  3499. #  ~~ Abort Battle
  3500. #    - Code       : 340
  3501. #    - Parameters : []
  3502. #
  3503. #  ~~ Call Menu Screen
  3504. #    - Code       : 351
  3505. #    - Parameters : []
  3506. #
  3507. #  ~~ Call Save Screen
  3508. #    - Code       : 352
  3509. #    - Parameters : []
  3510. #
  3511. #  ~~ Game Over
  3512. #    - Code       : 353
  3513. #    - Parameters : []
  3514. #
  3515. #  ~~ Return to Title Screen
  3516. #    - Code       : 354
  3517. #    - Parameters : []
  3518. #
  3519. #  ~~ Script
  3520. #    - Code       : 355 (Lines After First line - 655)
  3521. #    - Parameters : [ 'script text' ]
  3522. #==============================================================================
  3523.  
  3524. MACL::Loaded << 'Modules.Event Spawner'
  3525.  
  3526. #==============================================================================
  3527. # ** Event_Spawner
  3528. #==============================================================================
  3529.  
  3530. module Event_Spawner
  3531.   #--------------------------------------------------------------------------
  3532.   # * Event
  3533.   #--------------------------------------------------------------------------
  3534.   def self.event
  3535.     return @event
  3536.   end
  3537.   #--------------------------------------------------------------------------
  3538.   # * Create Event
  3539.   #--------------------------------------------------------------------------
  3540.   def self.create_event(x = 0, y = 0, name = '')
  3541.     # Creates New Event
  3542.     @event = RPG::Event.new(x, y)
  3543.     @event.name = name
  3544.     # Generates ID
  3545.     id = 1
  3546.     id += 1 while $game_map.events.keys.include?(id)
  3547.     id += 1 while self.saved_events($game_map.map_id).keys.include?(id)
  3548.     @event.id = id
  3549.   end
  3550.   #--------------------------------------------------------------------------
  3551.   # * Add Event Command (See Script Heading for Event Command Details)
  3552.   #--------------------------------------------------------------------------
  3553.   def self.add_event_command(code, parameters = [], indent = 0)
  3554.     # Creates New Event Command
  3555.     event_command = RPG::EventCommand.new
  3556.     # Sets Code, Parameters & Indent
  3557.     event_command.code = code
  3558.     event_command.parameters = parameters
  3559.     event_command.indent = indent
  3560.     # Adds Event Command To Page List
  3561.     self.get_current_page.list.insert(-2, event_command)
  3562.   end
  3563.   #--------------------------------------------------------------------------
  3564.   # * Set Page Condition
  3565.   #
  3566.   #   'switch1'    => switch_id
  3567.   #   'switch2'    => switch_id
  3568.   #   'selfswitch' => 'A', 'B', 'C' or 'D'
  3569.   #   'variable'   => [variable_id, value]
  3570.   #--------------------------------------------------------------------------
  3571.   def self.set_page_condition(parameters = {})
  3572.     # Gets Last Page Condition Settings
  3573.     page_c = self.get_current_page.condition
  3574.     # If 'switch1' Found
  3575.     if parameters.has_key?('switch1')
  3576.       # Turns Switch 1 On & Sets ID
  3577.       page_c.switch1_valid = true
  3578.       page_c.switch1_id    = parameters['switch1']
  3579.     end
  3580.     # If 'switch2' Found
  3581.     if parameters.has_key?('switch2')
  3582.       # Turns Switch 2 On & Sets ID
  3583.       page_c.switch2_valid = true
  3584.       page_c.switch2_id    = parameters['switch1']
  3585.     end
  3586.     # If 'selfswitch' Found
  3587.     if parameters.has_key?('selfswitch')
  3588.       # Turns Self Switch ON & Sets Switch Variable
  3589.       page_c.self_switch_valid = true
  3590.       page_c.self_switch_ch    = parameters['selfswitch']
  3591.     end
  3592.     # If 'variable' Found
  3593.     if parameters.has_key?('variable')
  3594.       # Turns Variable On, Sets Variable ID & Sets Value
  3595.       page_c.variable_valid = true
  3596.       page_c.variable_id    = parameters['variable'][0]
  3597.       page_c.variable_value = parameters['variable'][1]
  3598.     end
  3599.   end
  3600.   #--------------------------------------------------------------------------
  3601.   # * Set Page Graphic
  3602.   #
  3603.   #   'tileid'  => id
  3604.   #   'c_name'  => 'character_filename'
  3605.   #   'c_hue'   => 0..360
  3606.   #   'dir'     => 2 : Down, 4 : Left, 6 : Right, 8 : Up
  3607.   #   'pattern' => 0..3
  3608.   #   'opacity' => 0..255
  3609.   #   'blend'   => 0 : Normal, 1 : Addition, 2 : Subtraction
  3610.   #--------------------------------------------------------------------------
  3611.   def self.set_page_graphic(parameters = {})
  3612.     # Gets Last Page Graphic Settings
  3613.     page_g = self.get_current_page.graphic
  3614.     # Tile ID
  3615.     if parameters.has_key?('tileid')
  3616.       page_g.tile_id = parameters['tileid']
  3617.     end
  3618.     # Character Name
  3619.     if parameters.has_key?('c_name')
  3620.       page_g.character_name = parameters['c_name']
  3621.     end
  3622.     # Character Hue
  3623.     if parameters.has_key?('c_hue')
  3624.       page_g.character_hue = parameters['c_hue']
  3625.     end
  3626.     # Direction
  3627.     if parameters.has_key?('dir')
  3628.       page_g.direction = parameters['dir']
  3629.     end
  3630.     # Pattern
  3631.     if parameters.has_key?('pattern')
  3632.       page_g.pattern = parameters['pattern']
  3633.     end
  3634.     # Opacity
  3635.     if parameters.has_key?('opacity')
  3636.       page_g.opacity = parameters['opacity']
  3637.     end
  3638.     # Blend Type
  3639.     if parameters.has_key?('blend')
  3640.       page_g.blend_type = parameters['blend']
  3641.     end
  3642.   end
  3643.   #--------------------------------------------------------------------------
  3644.   # * Set Page Trigger
  3645.   #
  3646.   #   0 - Action Button
  3647.   #   1 - Contact With Player
  3648.   #   2 - Contact With Event
  3649.   #   3 - Autorun
  3650.   #   4 - Parallel Processing
  3651.   #--------------------------------------------------------------------------
  3652.   def self.set_page_trigger(trigger = 0)
  3653.     # Sets Last Page Trigger
  3654.     self.get_current_page.trigger = trigger
  3655.   end
  3656.   #--------------------------------------------------------------------------
  3657.   # * Set Page Move Settings
  3658.   #
  3659.   #   'type'  => 0 : fixed, 1 : random, 2 : approach, 3 : custom).
  3660.   #   'speed' => 1 : slowest ... 6 : fastest
  3661.   #   'freq'  => 1 : lowest  ... 6 : highest
  3662.   #   'route' => RPG::MoveRoute (See Generate Move Route)
  3663.   #--------------------------------------------------------------------------
  3664.   def self.set_page_move_settings(parameters = {})
  3665.     # Gets Last Page
  3666.     page = self.get_current_page
  3667.     # Type
  3668.     if parameters.has_key?('type')
  3669.       page.move_type = parameters['type']
  3670.     end
  3671.     # Speed
  3672.     if parameters.has_key?('speed')
  3673.       page.move_speed = parameters['speed']
  3674.     end
  3675.     # Frequency
  3676.     if parameters.has_key?('freq')
  3677.       page.move_frequency = parameters['freq']
  3678.     end
  3679.     # Route
  3680.     if parameters.has_key?('route')
  3681.       if parameters['route'].is_a?(RPG::MoveRoute)
  3682.         page.move_route = parameters['route']
  3683.       end
  3684.     end
  3685.   end
  3686.   #--------------------------------------------------------------------------
  3687.   # * Set Page Options
  3688.   #
  3689.   #   'walk_anime'    => true or false
  3690.   #   'step_anime'    => true or false
  3691.   #   'direction_fix' => true or false
  3692.   #   'through'       => true or false
  3693.   #   'always_on_top' => true or false
  3694.   #--------------------------------------------------------------------------
  3695.   def self.set_page_options(parameters = {})
  3696.     # Gets Last Page
  3697.     page = self.get_current_page
  3698.     # Walk Animation
  3699.     if parameters.has_key?('walk_anime')
  3700.       page.walk_anime = parameters['walk_anime']
  3701.     end
  3702.     # Step Animation
  3703.     if parameters.has_key?('step_anime')
  3704.       page.step_anime = parameters['step_anime']
  3705.     end
  3706.     # Direction Fix
  3707.     if parameters.has_key?('direction_fix')
  3708.       page.direction_fix = parameters['direction_fix']
  3709.     end
  3710.     # Through
  3711.     if parameters.has_key?('through')
  3712.       page.through = parameters['through']
  3713.     end
  3714.     # Always On Top
  3715.     if parameters.has_key?('always_on_top')
  3716.       page.always_on_top = parameters['always_on_top']
  3717.     end
  3718.   end
  3719.   #--------------------------------------------------------------------------
  3720.   # * Add New Page
  3721.   #--------------------------------------------------------------------------
  3722.   def self.add_page
  3723.     @event.pages << RPG::Event::Page.new
  3724.   end
  3725.   #--------------------------------------------------------------------------
  3726.   # * Generate Move Route
  3727.   #
  3728.   #   list = [ <move_command>, ... ]
  3729.   #
  3730.   #   <move_command> : [code, parameters]
  3731.   #
  3732.   #   If no parameters required :
  3733.   #
  3734.   #   <move_command> : code
  3735.   #--------------------------------------------------------------------------
  3736.   def self.generate_move_route(list = [], repeat = true, skippable = false)
  3737.     # Creates New Move Route
  3738.     move_route = RPG::MoveRoute.new
  3739.     # Sets Repeat & Skipable
  3740.     move_route.repeat    = repeat
  3741.     move_route.skippable = skippable
  3742.     # Passes Through List
  3743.     for move_command in list
  3744.       if move_command.is_a?(Array)
  3745.         code, parameters = move_command[0], move_command[1]
  3746.       else
  3747.         code, parameters = move_command, []
  3748.       end
  3749.       # Crates New MoveCommand
  3750.       move_command = RPG::MoveCommand.new
  3751.       # Adds MoveCommand to List
  3752.       move_route << move_command
  3753.       # Sets MoveCommand Properties
  3754.       move_command.parameters = parameters
  3755.       move_command.code = code
  3756.     end
  3757.     # Add Blank Move Command
  3758.     move_route << RPG::MoveCommand.new
  3759.     # Return Move Route
  3760.     return move_route
  3761.   end
  3762.   #--------------------------------------------------------------------------
  3763.   # * End Event
  3764.   #--------------------------------------------------------------------------
  3765.   def self.end_event(save_event = false)
  3766.     # Stop If nil Event Created
  3767.     return if @event.nil?
  3768.     # Add Event to Map & Spriteset Data
  3769.     $game_map.add_event(@event)
  3770.     # If Save Event Data
  3771.     if save_event
  3772.       # Creates Map Event Data (If none Present)
  3773.       unless @saved_events.has_key?((map_id = $game_map.map_id))
  3774.         @saved_events[map_id] = {}
  3775.       end
  3776.       # Saves Event Data
  3777.       @saved_events[map_id][@event.id] = @event
  3778.     end
  3779.     # Clear Event Data
  3780.     @event = nil
  3781.   end
  3782.   #--------------------------------------------------------------------------
  3783.   # * Clone Event
  3784.   #--------------------------------------------------------------------------
  3785.   def self.clone_event(target_id, new_x, new_y, new_name,
  3786.       end_event = false, save_event = false)
  3787.     # Stops If Event Not Found
  3788.     return unless $game_map.events.has_key?(target_id)
  3789.     # Gets Event Data
  3790.     @event = $game_map.events[target_id].event
  3791.     # Changes X, Y & name
  3792.     @event.x    = new_x
  3793.     @event.y    = new_y
  3794.     @event.name = new_name
  3795.     # Generates New ID
  3796.     id = 1
  3797.     id += 1 while $game_map.events.keys.include?(id)
  3798.     id += 1 while self.saved_events($game_map.map_id).keys.include?(id)
  3799.     @event.id = id
  3800.     # If End Event
  3801.     if end_event
  3802.       # Ends Event Creation
  3803.       self.end_event(save_event)
  3804.     end
  3805.   end
  3806.   #--------------------------------------------------------------------------
  3807.   # * Saved Events { map_id => { event_id => name }, ... }
  3808.   #--------------------------------------------------------------------------
  3809.   @saved_events = {}
  3810.   #--------------------------------------------------------------------------
  3811.   # * Saved Events (Read)
  3812.   #--------------------------------------------------------------------------
  3813.   def self.saved_events(map_id = nil)
  3814.     # If Map ID not Defined
  3815.     if map_id.nil?
  3816.       # Return All Saved Event Data
  3817.       return @saved_events
  3818.     end
  3819.     # If Map Data Saved
  3820.     if @saved_events.has_key?(map_id)
  3821.       # Return Map Saved Event Data
  3822.       return @saved_events[map_id]
  3823.     end
  3824.     # Return Blank Hash
  3825.     return {}
  3826.   end
  3827.   #--------------------------------------------------------------------------
  3828.   # * Saved Events (Write)
  3829.   #--------------------------------------------------------------------------
  3830.   def self.saved_events=(saved_events)
  3831.     @saved_events = saved_events
  3832.   end
  3833.   #--------------------------------------------------------------------------
  3834.   # * Current Page
  3835.   #--------------------------------------------------------------------------
  3836.   def self.get_current_page
  3837.     return @event.pages.last
  3838.   end
  3839. end
  3840.  
  3841. #==============================================================================
  3842. # ** Game_Map
  3843. #==============================================================================
  3844.  
  3845. class Game_Map
  3846.   #--------------------------------------------------------------------------
  3847.   # * Alias Listings
  3848.   #--------------------------------------------------------------------------
  3849.   alias_method :seph_eventspawner_gmap_setup, :setup
  3850.   #--------------------------------------------------------------------------
  3851.   # * Setup
  3852.   #--------------------------------------------------------------------------
  3853.   def setup(map_id)
  3854.     # Original Map Setup
  3855.     seph_eventspawner_gmap_setup(map_id)
  3856.     # Passes Through All Saved Events
  3857.     Event_Spawner.saved_events(@map_id).values.each do |event|
  3858.       # Add Event
  3859.       add_event(event)
  3860.     end
  3861.   end
  3862. end
  3863.  
  3864. #==============================================================================
  3865. # ** Scene_Save
  3866. #==============================================================================
  3867.  
  3868. class Scene_Save
  3869.   #--------------------------------------------------------------------------
  3870.   # * Alias Listings
  3871.   #--------------------------------------------------------------------------
  3872.   alias_method :seph_eventspawner_scnsave_wsd, :write_save_data
  3873.   #--------------------------------------------------------------------------
  3874.   # * Write Save Data
  3875.   #--------------------------------------------------------------------------
  3876.   def write_save_data(file)
  3877.     # Original Write Data
  3878.     seph_eventspawner_scnsave_wsd(file)
  3879.     # Saves Saved Event Data
  3880.     Marshal.dump(Event_Spawner.saved_events, file)
  3881.   end
  3882. end
  3883.  
  3884. #==============================================================================
  3885. # ** Scene_Load
  3886. #==============================================================================
  3887.  
  3888. class Scene_Load
  3889.   #--------------------------------------------------------------------------
  3890.   # * Alias Listings
  3891.   #--------------------------------------------------------------------------
  3892.   alias_method :seph_eventspawner_scnload_rsd, :read_save_data
  3893.   #--------------------------------------------------------------------------
  3894.   # * Read Save Data
  3895.   #--------------------------------------------------------------------------
  3896.   def read_save_data(file)
  3897.     # Original Write Data
  3898.     seph_eventspawner_scnload_rsd(file)
  3899.     # Load Saved Event Data
  3900.     Event_Spawner.saved_events = Marshal.load(file)
  3901.   end
  3902. end
  3903.  
  3904. #==============================================================================
  3905. # ** Modules.Game_Data (1.0)                                  By SephirothSpawn
  3906. #------------------------------------------------------------------------------
  3907. # * Description :
  3908. #
  3909. #   This modules lets you add new $game_data objects to your game with a simple
  3910. #   call script within your script.
  3911. #------------------------------------------------------------------------------
  3912. # * Syntax :
  3913. #
  3914. #   Adding new $game_data object
  3915. #    - Game_Data.add_game_data('variable_name', 'Class_Name')
  3916. #
  3917. #   Example : Adding new Game_Database to your $game datas.
  3918. #
  3919. #    - Game_Data.add_game_data('$game_database', 'Game_Database')
  3920. #==============================================================================
  3921.  
  3922. MACL::Loaded << 'Modules.Game_Data'
  3923.  
  3924. #==============================================================================
  3925. # ** Game_Data
  3926. #==============================================================================
  3927.  
  3928. module Game_Data
  3929.   #--------------------------------------------------------------------------
  3930.   # * Instance Variable Setup
  3931.   #--------------------------------------------------------------------------
  3932.   @additions = []
  3933.   @variable_names = []
  3934.   #--------------------------------------------------------------------------
  3935.   # * Additions
  3936.   #--------------------------------------------------------------------------
  3937.   def self.additions
  3938.     return @additions
  3939.   end
  3940.   #--------------------------------------------------------------------------
  3941.   # * Add Game Data
  3942.   #--------------------------------------------------------------------------
  3943.   def self.add_game_data(global_variable_name, game_object_class)
  3944.     # If Variable Name Used
  3945.     if @variable_names.include?(global_variable_name)
  3946.       # Print Error
  3947.       p global_variable_name + ' already used. Please use a different ' +
  3948.         'variable name.'
  3949.       return
  3950.     end
  3951.     # Add Addition
  3952.     @additions << [global_variable_name, game_object_class]
  3953.   end
  3954. end
  3955.  
  3956. #==============================================================================
  3957. # ** Scene_Title
  3958. #==============================================================================
  3959.  
  3960. class Scene_Title
  3961.   #--------------------------------------------------------------------------
  3962.   # * Alias Listings
  3963.   #--------------------------------------------------------------------------
  3964.   alias_method :seph_macladdgamedata_scnttl_cng, :command_new_game
  3965.   #--------------------------------------------------------------------------
  3966.   # * Command: New Game
  3967.   #--------------------------------------------------------------------------
  3968.   def command_new_game
  3969.     # Original Command: New Game
  3970.     seph_macladdgamedata_scnttl_cng
  3971.     # Pass Through Game Data List
  3972.     Game_Data.additions.each {|vg| eval "#{vg[0]} = #{vg[1]}.new"}
  3973.   end
  3974. end
  3975.  
  3976. #==============================================================================
  3977. # ** Scene_Save
  3978. #==============================================================================
  3979.  
  3980. class Scene_Save
  3981.   #--------------------------------------------------------------------------
  3982.   # * Alias Listings
  3983.   #--------------------------------------------------------------------------
  3984.   alias_method :seph_macladdgamedata_scnsv_wsd, :write_save_data
  3985.   #--------------------------------------------------------------------------
  3986.   # * Write Save Data
  3987.   #--------------------------------------------------------------------------
  3988.   def write_save_data(file)
  3989.     # Original Write Save Data
  3990.     seph_macladdgamedata_scnsv_wsd(file)
  3991.     # Pass Through Game Data List
  3992.     Game_Data.additions.each {|vg| eval "Marshal.dump(#{vg[0]}, file)"}
  3993.   end
  3994. end
  3995.  
  3996. #==============================================================================
  3997. # ** Scene_Load
  3998. #==============================================================================
  3999.  
  4000. class Scene_Load
  4001.   #--------------------------------------------------------------------------
  4002.   # * Alias Listings
  4003.   #--------------------------------------------------------------------------
  4004.   alias_method :seph_macladdgamedata_scnld_rsd, :read_save_data
  4005.   #--------------------------------------------------------------------------
  4006.   # * Read Save Data
  4007.   #--------------------------------------------------------------------------
  4008.   def read_save_data(file)
  4009.     # Original Read Save Data
  4010.     seph_macladdgamedata_scnld_rsd(file)
  4011.     # Pass Through Game Data List
  4012.     Game_Data.additions.each {|vg| eval "#{vg[0]} = Marshal.load(file)"}
  4013.   end
  4014. end
  4015.  
  4016. #==============================================================================
  4017. # ** Modules.Interpreter (1.0)                         By SephirothSpawn
  4018. #------------------------------------------------------------------------------
  4019. # * Description :
  4020. #
  4021. #   This script was designed to allow you to call event commands and custom
  4022. #   commands with a simple call script funcion. Most event commands are
  4023. #   included and several non-event commands were created.
  4024. #------------------------------------------------------------------------------
  4025. # * Syntax :
  4026. #
  4027. #   Show Text
  4028. #    - MInterpreter.show_text('line 1', 'line 2', 'line 3', 'line 4')
  4029. #   Erase Event
  4030. #    - MInterpreter.erase_event(event_id)
  4031. #   Call Common Event
  4032. #    - MInterpreter.common_event(event_id)
  4033. #   Control Switches
  4034. #    - MInterpreter.control_switches( { switch_id => state, ... } )
  4035. #   Control Variables
  4036. #    - MInterpreter.control_variables( { variable_id => value, ... } )
  4037. #   Control Self Switches
  4038. #    - MInterpreter.control_selfsw( { <key> => state, ... } )
  4039. #   Control Time
  4040. #    - MInterpreter.change_timer(state = false, seconds = 0)
  4041. #   Change Gold
  4042. #    - MInterpreter.change_gold( value )
  4043. #   Change Items
  4044. #    - MInterpreter.change_items( { item_id => n, ... } )
  4045. #   Change Weapons
  4046. #    - MInterpreter.change_weapons( { weapon_id => n, ... } )
  4047. #   Change Armors
  4048. #    - MInterpreter.change_armors( { armor_id => n, ... } )
  4049. #   Change Party Members
  4050. #    - MInterpreter.change_party(actor_id, add = true, initialize = true)
  4051. #   Change Windowskin
  4052. #    - MInterpreter.change_windowskin(filename = $game_system.windowskin_name)
  4053. #   Change Battle BGM
  4054. #    - MInterpreter.change_btlbgm(filename, volume = 100, pitch = 100)
  4055. #   Change Save Access
  4056. #    - MInterpreter.save_access(state = true)
  4057. #   Change Menu Access
  4058. #    - MInterpreter.menu_access(state = true)
  4059. #   Change Encounter
  4060. #    - MInterpreter.encounter(state = true)
  4061. #   Transfer Player
  4062. #    - MInterpreter.transfer_player(map_id, x, y, direction, fading = true)
  4063. #   Set Event Location
  4064. #    - MInterpreter.set_event_location(target_event_id, parameters, direction)
  4065. #   Scroll Map
  4066. #    - MInterpreter.scroll_map(direction, distance, speed)
  4067. #   Change Panorama
  4068. #    - MInterpreter.change_panorama(filename = current, hue = current)
  4069. #   Change Fog
  4070. #    - MInterpreter.change_fog(filename, hue, opacity, blend, zoom, sx, sy)
  4071. #   Change Fog Color
  4072. #    - MInterpreter.change_fog_color(tone, duration)
  4073. #   Change Fog Opacity
  4074. #    - MInterpreter.change_fog_opacity(opacity, duration)
  4075. #   Change Panorama
  4076. #    - MInterpreter.change_battleback(filename = current)
  4077. #   Show Animation
  4078. #    - MInterpreter.show_animation(target_id, animation_id)
  4079. #   Change Transparent Flag
  4080. #    - MInterpreter.change_player_transparent(state = true)
  4081. #   Execute Transition
  4082. #    - MInterpreter.execute_transition(filename = '')
  4083. #   Change Screen Color
  4084. #    - MInterpreter.change_screen_color(color, duration)
  4085. #   Screen Flash
  4086. #    - MInterpreter.flash_screen(color, duration)
  4087. #   Screen Shake
  4088. #    - MInterpreter.shake_screen(power, speed, duration)
  4089. #   Show Picture
  4090. #    - MInterpreter.show_picture(picture_number, filename, origin, x, y,
  4091. #      zoom_x, zoom_y, opacity, blend_type)
  4092. #   Move Picture
  4093. #    - MInterpreter.move_picture(picture_number, duration, origin, x, y,
  4094. #      zoom_x, zoom_y, opacity, blend_type)
  4095. #   Rotate Picture
  4096. #    - MInterpreter.rotate_picture(picture_number, speed)
  4097. #   Change Picture Tone
  4098. #    - MInterpreter.change_picture_tone(picture_number, tone, duration)
  4099. #   Erase Picture
  4100. #    - MInterpreter.erase_picture(picture_number)
  4101. #   Set Weather Effects
  4102. #    - MInterpreter.set_weather_effects(type, power, time)
  4103. #   Play BGM
  4104. #    - MInterpreter.play_bgm(filename, volume = 100, pitch = 100)
  4105. #   Fade Out BGM
  4106. #    - MInterpreter.fade_bgm(seconds = 0)
  4107. #   Play BGS
  4108. #    - MInterpreter.play_bgs(filename, volume = 100, pitch = 100)
  4109. #   Fade Out BGS
  4110. #    - MInterpreter.fade_bgm(seconds = 0)
  4111. #   Memorize BGM/BGS
  4112. #    - MInterpreter.memorize_bgms
  4113. #   Restore BGM/BGS
  4114. #    - MInterpreter.restore_bgms
  4115. #   Play ME
  4116. #    - MInterpreter.play_me(filename, volume = 100, pitch = 100)
  4117. #   Play SE
  4118. #    - MInterpreter.play_se(filename, volume = 100, pitch = 100)
  4119. #   Stop SE
  4120. #    - MInterpreter.stop_se
  4121. #   Battle Processing
  4122. #    - MInterpreter.battle_proc(troop_id, can_escape = true, can_lose = true)
  4123. #   Shop Processing
  4124. #    - MInterpreter.shop_proc(*goods)
  4125. #   Name Input Processing
  4126. #    - MInterpreter.name_input_proc(actor_id, max_chrs = 8)
  4127. #   Change Actor Stat
  4128. #    - MInterpreter.change_actor_stat(actor_id, stat_name, value)
  4129. #   Gain Actor Skills
  4130. #    - MInterpreter.gain_actor_skills(actor_id, *skill_ids)
  4131. #   Lose Actor Skills
  4132. #    - MInterpreter.lose_actor_skills(actor_id, *skill_ids)
  4133. #   Gain Actor States
  4134. #    - MInterpreter.gain_actor_states(actor_id, *skill_ids)
  4135. #   Lose Actor States
  4136. #    - MInterpreter.lose_actor_states(actor_id, *skill_ids)
  4137. #   Change Actor Equipment
  4138. #    - MInterpreter.change_actor_equip(actor_id, type, id)
  4139. #   Change Event Graphic
  4140. #    - MInterpreter.change_event_graphic(target_id, character_name, hue = 0)
  4141. #   Change Actor Character Graphic
  4142. #    - MInterpreter.change_actor_cgraphic(actor_id, character_name, hue = 0)
  4143. #   Change Actor Battler Graphic
  4144. #    - MInterpreter.change_actor_bgraphic(actor_id, battler_name, hue = 0)
  4145. #   Recover All
  4146. #    - MInterpreter.recover_all(actor_id, ...) (0 for actor id for all party)
  4147. #   Call Scene
  4148. #    - MInterpreter.call_scene(scene_name)
  4149. #   Save To Index
  4150. #    - MInterpreter.save_index(index = 0)
  4151. #   Save To Filename
  4152. #    - MInterpreter.save_filename(filename = 'Save File')
  4153. #   Load From Index
  4154. #    - MInterpreter.load_index(index = 0)
  4155. #   Load From Filename
  4156. #    - MInterpreter.load_filename(filename = 'Save File')
  4157. #==============================================================================
  4158.  
  4159. MACL::Loaded << 'Modules.Interpreter Module'
  4160.  
  4161. #==============================================================================
  4162. # ** Interpreter Module
  4163. #==============================================================================
  4164.  
  4165. module MInterpreter
  4166.   #--------------------------------------------------------------------------
  4167.   # * Show Text
  4168.   #
  4169.   #   MInterpreter.show_text('line 1', 'line 2', 'line 3', 'line 4')
  4170.   #--------------------------------------------------------------------------
  4171.   def self.show_text(*text_lines)
  4172.     # Clear Message Text
  4173.     $game_temp.message_text = ''
  4174.     # Pass Through Each Line
  4175.     text_lines.each {|line| $game_temp.message_text += line + "\n"}
  4176.   end
  4177.   #--------------------------------------------------------------------------
  4178.   # * Erase Event
  4179.   #
  4180.   #   MInterpreter.erase_event(event_id)
  4181.   #--------------------------------------------------------------------------
  4182.   def self.erase_event(event_id)
  4183.     # If Event Found
  4184.     if $game_map.events.has_key?(event_id)
  4185.       # Erase Event
  4186.       $game_map.events[event_id].erase
  4187.     end
  4188.   end
  4189.   #--------------------------------------------------------------------------
  4190.   # * Call Common Event
  4191.   #
  4192.   #   MInterpreter.common_event(event_id)
  4193.   #--------------------------------------------------------------------------
  4194.   def self.common_event(c_event_id)
  4195.     # If Common Event Exist
  4196.     unless $data_common_events[c_event_id].nil?
  4197.       # If in Battle
  4198.       if $game_temp.in_battle
  4199.         # Run Common Event
  4200.         common_event = $data_common_events[c_event_id]
  4201.         $game_system.battle_interpreter.setup(common_event.list)
  4202.       # If Somewhere Else
  4203.       else
  4204.         # Set Temp Common Event ID
  4205.         $game_temp.common_event_id = c_event_id
  4206.       end
  4207.     end
  4208.   end
  4209.   #--------------------------------------------------------------------------
  4210.   # * Control Switches
  4211.   #
  4212.   #   MInterpreter.control_switches( { switch_id => state, ... } )
  4213.   #--------------------------------------------------------------------------
  4214.   def self.control_switches(switches)
  4215.     # Pass Through Every Switch and Set State
  4216.     switches.each { |switch_id, state| $game_switches[switch_id] = state }
  4217.   end
  4218.   #--------------------------------------------------------------------------
  4219.   # * Control Variables
  4220.   #
  4221.   #   MInterpreter.control_variables( { variable_id => value, ... } )
  4222.   #--------------------------------------------------------------------------
  4223.   def self.control_variables(vars)
  4224.     # Pass Through Every Switch and State
  4225.     vars.each { |variable_id, value| $game_variables[variable_id] = value }
  4226.   end
  4227.   #--------------------------------------------------------------------------
  4228.   # * Control Self Switches
  4229.   #
  4230.   #   MInterpreter.control_selfsw( { <key> => state, ... } )
  4231.   #
  4232.   #   <key> = [map_id, event_id, letter] ( letter : 'A', 'B', 'C', 'D' )
  4233.   #--------------------------------------------------------------------------
  4234.   def self.control_selfsw(switches)
  4235.     # Pass Through Every Switch and State
  4236.     control_selfsw.each { |key, state| $game_self_switches[key] = state }
  4237.   end
  4238.   #--------------------------------------------------------------------------
  4239.   # * Control Time
  4240.   #
  4241.   #   MInterpreter.change_timer(state = false, seconds = 0)
  4242.   #--------------------------------------------------------------------------
  4243.   def self.change_timer(state = false, seconds = 0)
  4244.     # Se Timer State
  4245.     $game_system.timer_working = state
  4246.     # Set Timer
  4247.     $game_system.timer = seconds * Graphics.frame_rate
  4248.   end
  4249.   #--------------------------------------------------------------------------
  4250.   # * Change Gold
  4251.   #
  4252.   #   MInterpreter.change_gold( value )
  4253.   #--------------------------------------------------------------------------
  4254.   def self.change_gold(value)
  4255.     # Gain Gold
  4256.     $game_party.gain_gold(value)
  4257.   end
  4258.   #--------------------------------------------------------------------------
  4259.   # * Change Items
  4260.   #
  4261.   #   MInterpreter.change_items( { item_id => n, ... } )
  4262.   #--------------------------------------------------------------------------
  4263.   def self.change_items(items)
  4264.     # Pass Through Each Item List
  4265.     items.each { |item_id, n| $game_party.gain_item(item_id, n) }
  4266.   end
  4267.   #--------------------------------------------------------------------------
  4268.   # * Change Weapons
  4269.   #
  4270.   #   MInterpreter.change_weapons( { weapon_id => n, ... } )
  4271.   #--------------------------------------------------------------------------
  4272.   def self.change_weapons(weapons)
  4273.     # Pass Through Each Item List
  4274.     weapons.each { |weapon_id, n| $game_party.gain_weapon(weapon_id, n) }
  4275.   end
  4276.   #--------------------------------------------------------------------------
  4277.   # * Change Armors
  4278.   #
  4279.   #   MInterpreter.change_armors( { armor_id => n, ... } )
  4280.   #--------------------------------------------------------------------------
  4281.   def self.change_armors(armors)
  4282.     # Pass Through Each Item List
  4283.     armors.each { |armor_id, n| $game_party.gain_armor(armor_id, n) }
  4284.   end
  4285.   #--------------------------------------------------------------------------
  4286.   # * Change Party Members
  4287.   #
  4288.   #   MInterpreter.change_party(actor_id, add = true, initialize = true)
  4289.   #--------------------------------------------------------------------------
  4290.   def self.change_armors(actor_id, add = true, initialize = true)
  4291.     # Return if Nil Actor
  4292.     return if $data_actors[actor_id].nil?
  4293.     # Setup Actor If Initialize
  4294.     $game_actors[actor_id].setup(actor_id) if initialize
  4295.     # Add or Remove Actor
  4296.     add ? $game_party.add_actor(actor_id) :
  4297.           $game_party.remove_actor(actor_id)
  4298.   end
  4299.   #--------------------------------------------------------------------------
  4300.   # * Change Windowskin
  4301.   #
  4302.   #   MInterpreter.change_windowskin(filename = $game_system.windowskin_name)
  4303.   #--------------------------------------------------------------------------
  4304.   def self.change_windowskin(filename = $game_system.windowskin_name)
  4305.     # Set Windowskin Filename
  4306.     $game_system.windowskin_name = filename
  4307.   end
  4308.   #--------------------------------------------------------------------------
  4309.   # * Change Battle BGM
  4310.   #
  4311.   #   MInterpreter.change_btlbgm(filename, volume = 100, pitch = 100)
  4312.   #--------------------------------------------------------------------------
  4313.   def self.change_btlbgm(filename, volume = 100, pitch = 100)
  4314.     # Create AudioFile
  4315.     audiofile = RPG::AudioFile.new(filename, volume, pitch)
  4316.     # Set Battle BGM
  4317.     $game_system.battle_bgm = audiofile
  4318.   end
  4319.   #--------------------------------------------------------------------------
  4320.   # * Change Save Access
  4321.   #
  4322.   #   MInterpreter.save_access(state = true)
  4323.   #--------------------------------------------------------------------------
  4324.   def self.save_access(state = true)
  4325.     # Change Save Disabled Flag
  4326.     $game_system.save_disabled = !state
  4327.   end
  4328.   #--------------------------------------------------------------------------
  4329.   # * Change Menu Access
  4330.   #
  4331.   #   MInterpreter.menu_access(state = true)
  4332.   #--------------------------------------------------------------------------
  4333.   def self.menu_access(state = true)
  4334.     # Change Menu Disabled Flag
  4335.     $game_system.menu_disabled = !state
  4336.   end
  4337.   #--------------------------------------------------------------------------
  4338.   # * Change Encounter
  4339.   #
  4340.   #   MInterpreter.encounter(state = true)
  4341.   #--------------------------------------------------------------------------
  4342.   def self.encounter(state = true)
  4343.     # Change Encounter Disabled Flag
  4344.     $game_system.encounter_disabled = !state
  4345.   end
  4346.   #--------------------------------------------------------------------------
  4347.   # * Transfer Player
  4348.   #
  4349.   #   MInterpreter.transfer_player(map_id, x, y, direction, fading = true)
  4350.   #
  4351.   #   Direction : 2 - Down, 4 - Left, 6 - Right, 8 - Up
  4352.   #--------------------------------------------------------------------------
  4353.   def self.transfer_player(m, x, y, d = $game_player.direction, f = true)
  4354.     # Set player move destination
  4355.     $game_temp.player_new_map_id    = m
  4356.     $game_temp.player_new_x         = x
  4357.     $game_temp.player_new_y         = y
  4358.     $game_temp.player_new_direction = d
  4359.     # Transition
  4360.     if f
  4361.       # Prepare for transition
  4362.       Graphics.freeze
  4363.       # Set transition processing flag
  4364.       $game_temp.transition_processing = true
  4365.       $game_temp.transition_name = ''
  4366.     end
  4367.   end
  4368.   #--------------------------------------------------------------------------
  4369.   # * Set Event Location
  4370.   #
  4371.   #   MInterpreter.set_event_location(target_event_id, parameters, direction)
  4372.   #
  4373.   #   Target Event ID = 0 - Player or n - Event ID
  4374.   #   Parameters      = [event_id] or [x, y]
  4375.   #   Direction : 2 - Down, 4 - Left, 6 - Right, 8 - Up
  4376.   #--------------------------------------------------------------------------
  4377.   def self.set_event_location(target_id, parameters, dir = 2)
  4378.     # Get Character
  4379.     character = target_id == 0 ? $game_player : $game_map.events[target_id]
  4380.     # Return if Nil
  4381.     return if character.nil?
  4382.     # If Switching Event Locations
  4383.     if parameters.size == 1
  4384.       # Get Other Character
  4385.       other_character = parameters[0] == 0 ? $game_player :
  4386.         $game_map.events[parameters[0]]
  4387.       # Return if Nil Character
  4388.       return if other_character.nil?
  4389.       # Clone Current Position
  4390.       old_x, old_y = character.x, character.y
  4391.       # Exchange Locations
  4392.       character.move_to(other_character.x, other_character.y)
  4393.       other_character.move_to(old_x, old_y)
  4394.       # Stop Method Execution
  4395.       return
  4396.     end
  4397.     # Moves Event
  4398.     character.move_to(parameters[0], parameters[1])
  4399.   end
  4400.   #--------------------------------------------------------------------------
  4401.   # * Scroll Map
  4402.   #
  4403.   #   MInterpreter.scroll_map(direction, distance, speed)
  4404.   #--------------------------------------------------------------------------
  4405.   def self.scroll_map(direction, distance, speed)
  4406.     $game_map.start_scroll(direction, distance, speed)
  4407.   end
  4408.   #--------------------------------------------------------------------------
  4409.   # * Change Panorama
  4410.   #
  4411.   #   MInterpreter.change_panorama(filename = current, hue = current)
  4412.   #--------------------------------------------------------------------------
  4413.   def self.change_panorama(filename = $game_map.panorama_name,
  4414.                            hue      = $game_map.panorama_hue)
  4415.     # Change Settings
  4416.     $game_map.panorama_name = filename
  4417.     $game_map.panorama_hue  = hue
  4418.   end
  4419.   #--------------------------------------------------------------------------
  4420.   # * Change Fog
  4421.   #
  4422.   #   MInterpreter.change_fog(filename, hue, opacity, blend, zoom, sx, sy)
  4423.   #
  4424.   #   * Any Non-Defined will keep current settings
  4425.   #--------------------------------------------------------------------------
  4426.   def self.change_fog(filename = $game_map.fog_name, hue = $game_map.fog_hue,
  4427.       opacity = $game_map.fog_opacity, blend = $game_map.fog_blend_type,
  4428.       zoom = $game_map.fog_zoom, sx = $game_map.fog_sx, sy = $game_map.fog_sy)
  4429.     # Change Fog Settings
  4430.     $game_map.fog_name       = filename
  4431.     $game_map.fog_hue        = hue
  4432.     $game_map.fog_opacity    = opacity
  4433.     $game_map.fog_blend_type = blend
  4434.     $game_map.fog_zoom       = zoom
  4435.     $game_map.fog_sx         = sx
  4436.     $game_map.fog_sy         = sy
  4437.   end
  4438.   #--------------------------------------------------------------------------
  4439.   # * Change Fog Color
  4440.   #
  4441.   #   MInterpreter.change_fog_color(tone, duration)
  4442.   #--------------------------------------------------------------------------
  4443.   def self.change_fog_color(tone, duration)
  4444.     # Start color tone change
  4445.     $game_map.start_fog_tone_change(tone, duration * 2)
  4446.   end
  4447.   #--------------------------------------------------------------------------
  4448.   # * Change Fog Opacity
  4449.   #
  4450.   #   MInterpreter.change_fog_opacity(opacity, duration)
  4451.   #--------------------------------------------------------------------------
  4452.   def self.change_fog_opacity(opacity, duration)
  4453.     # Start opacity level change
  4454.     $game_map.start_fog_opacity_change(opacity, duration * 2)
  4455.   end
  4456.   #--------------------------------------------------------------------------
  4457.   # * Change Panorama
  4458.   #
  4459.   #   MInterpreter.change_battleback(filename = current)
  4460.   #--------------------------------------------------------------------------
  4461.   def self.change_battleback(filename = $game_map.battleback_name)
  4462.     # Change Settings
  4463.     $game_map.battleback_name  = filename
  4464.     $game_temp.battleback_name = filename
  4465.   end
  4466.   #--------------------------------------------------------------------------
  4467.   # * Show Animation
  4468.   #
  4469.   #   MInterpreter.show_animation(target_id, animation_id)
  4470.   #--------------------------------------------------------------------------
  4471.   def self.show_animation(target_id, animation_id)
  4472.     # Get Character
  4473.     character = target_id == 0 ? $game_player : $game_map.events[target_id]
  4474.     # Return if Nil
  4475.     return if character.nil?
  4476.     # Set animation ID
  4477.     character.animation_id = animation_id
  4478.   end
  4479.   #--------------------------------------------------------------------------
  4480.   # * Change Transparent Flag
  4481.   #
  4482.   #   MInterpreter.change_player_transparent(state = true)
  4483.   #--------------------------------------------------------------------------
  4484.   def self.change_player_transparent(state = true)
  4485.     # Change player transparent flag
  4486.     $game_player.transparent = state
  4487.   end
  4488.   #--------------------------------------------------------------------------
  4489.   # * Execute Transition
  4490.   #
  4491.   #   MInterpreter.execute_transition(filename = '')
  4492.   #--------------------------------------------------------------------------
  4493.   def self.execute_transition(filename = '')
  4494.     # Return If transition processing flag is already set
  4495.     return if $game_temp.transition_processing
  4496.     # Prepare for transition
  4497.     Graphics.freeze
  4498.     # Set transition processing flag
  4499.     $game_temp.transition_processing = true
  4500.     $game_temp.transition_name = filename
  4501.   end
  4502.   #--------------------------------------------------------------------------
  4503.   # * Change Screen Color
  4504.   #
  4505.   #   MInterpreter.change_screen_color(color, duration)
  4506.   #--------------------------------------------------------------------------
  4507.   def self.change_screen_color(color, duration)
  4508.     # Start changing color tone
  4509.     $game_screen.start_tone_change(color, duration * 2)
  4510.   end
  4511.   #--------------------------------------------------------------------------
  4512.   # * Screen Flash
  4513.   #
  4514.   #   MInterpreter.flash_screen(color, duration)
  4515.   #--------------------------------------------------------------------------
  4516.   def self.flash_screen(color, duration)
  4517.     # Start flash
  4518.     $game_screen.start_flash(color, duration * 2)
  4519.   end
  4520.   #--------------------------------------------------------------------------
  4521.   # * Screen Shake
  4522.   #
  4523.   #   MInterpreter.shake_screen(power, speed, duration)
  4524.   #--------------------------------------------------------------------------
  4525.   def self.shake_screen(power, speed, duration)
  4526.     # Start shake
  4527.     $game_screen.start_shake(power, speed, duration)
  4528.   end
  4529.   #--------------------------------------------------------------------------
  4530.   # * Show Picture
  4531.   #
  4532.   #   MInterpreter.show_picture(picture_number, filename, origin, x, y,
  4533.   #   zoom_x, zoom_y, opacity, blend_type)
  4534.   #
  4535.   #   origin     : 0 - Upper Left, 1 - Center
  4536.   #   blend_type : 0 - normal, 1 - addition, 2 - subtraction
  4537.   #--------------------------------------------------------------------------
  4538.   def self.show_picture(picture_number, filename, origin, x, y, zoom_x,
  4539.       zoom_y, opacity, blend_type)
  4540.     # Get picture number
  4541.     picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
  4542.     # Show picture
  4543.     $game_screen.pictures[picture_number].show(picture_number, filename,
  4544.       origin, x, y, zoom_x, zoom_y, opacity, blend_type)
  4545.   end
  4546.   #--------------------------------------------------------------------------
  4547.   # * Move Picture
  4548.   #
  4549.   #   MInterpreter.move_picture(picture_number, duration, origin, x, y,
  4550.   #   zoom_x, zoom_y, opacity, blend_type)
  4551.   #
  4552.   #   origin     : 0 - Upper Left, 1 - Center
  4553.   #   blend_type : 0 - normal, 1 - addition, 2 - subtraction
  4554.   #--------------------------------------------------------------------------
  4555.   def self.move_picture(picture_number, duration, origin, x, y, zoom_x,
  4556.       zoom_y, opacity, blend_type)
  4557.     # Get picture number
  4558.     picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
  4559.     # Move picture
  4560.     $game_screen.pictures[number].move(duration * 2, origin,
  4561.       x, y, zoom_x, zoom_y, opacity, blend_type)
  4562.   end
  4563.   #--------------------------------------------------------------------------
  4564.   # * Rotate Picture
  4565.   #
  4566.   #   MInterpreter.rotate_picture(picture_number, speed)
  4567.   #--------------------------------------------------------------------------
  4568.   def self.rotate_picture(picture_number, speed)
  4569.     # Get picture number
  4570.     picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
  4571.     # Set rotation speed
  4572.     $game_screen.pictures[picture_number].rotate(speed)
  4573.   end
  4574.   #--------------------------------------------------------------------------
  4575.   # * Change Picture Tone
  4576.   #
  4577.   #   MInterpreter.change_picture_tone(picture_number, tone, duration)
  4578.   #--------------------------------------------------------------------------
  4579.   def self.change_picture_tone(picture_number, tone, duration)
  4580.     # Get picture number
  4581.     picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
  4582.     # Start changing color tone
  4583.     $game_screen.pictures[picture_number].start_tone_change(tone, duration)
  4584.   end
  4585.   #--------------------------------------------------------------------------
  4586.   # * Erase Picture
  4587.   #
  4588.   #   MInterpreter.erase_picture(picture_number)
  4589.   #--------------------------------------------------------------------------
  4590.   def self.erase_picture(picture_number)
  4591.     # Get picture number
  4592.     picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
  4593.     # Erase picture
  4594.     $game_screen.pictures[picture_number].erase
  4595.   end
  4596.   #--------------------------------------------------------------------------
  4597.   # * Set Weather Effects
  4598.   #
  4599.   #   MInterpreter.set_weather_effects(type, power, time)
  4600.   #--------------------------------------------------------------------------
  4601.   def self.set_weather_effects(type, power, time)
  4602.     # Set Weather Effects
  4603.     $game_screen.weather(type, power, time)
  4604.   end
  4605.   #--------------------------------------------------------------------------
  4606.   # * Play BGM
  4607.   #
  4608.   #   MInterpreter.play_bgm(filename, volume = 100, pitch = 100)
  4609.   #--------------------------------------------------------------------------
  4610.   def self.play_bgm(filename, volume = 100, pitch = 100)
  4611.     # Create AudioFile
  4612.     audiofile = RPG::AudioFile.new(filename, volume, pitch)
  4613.     # Play BGM
  4614.     $game_system.bgm_play(audiofile)
  4615.   end
  4616.   #--------------------------------------------------------------------------
  4617.   # * Fade Out BGM
  4618.   #
  4619.   #   MInterpreter.fade_bgm(seconds = 0)
  4620.   #--------------------------------------------------------------------------
  4621.   def self.fade_bgm(seconds = 0)
  4622.     # Fade out BGM
  4623.     $game_system.bgm_fade(seconds)
  4624.   end
  4625.   #--------------------------------------------------------------------------
  4626.   # * Play BGS
  4627.   #
  4628.   #   MInterpreter.play_bgs(filename, volume = 100, pitch = 100)
  4629.   #--------------------------------------------------------------------------
  4630.   def self.play_bgs(filename, volume = 100, pitch = 100)
  4631.     # Create AudioFile
  4632.     audiofile = RPG::AudioFile.new(filename, volume, pitch)
  4633.     # Play BGS
  4634.     $game_system.bgs_play(audiofile)
  4635.   end
  4636.   #--------------------------------------------------------------------------
  4637.   # * Fade Out BGS
  4638.   #
  4639.   #   MInterpreter.fade_bgm(seconds = 0)
  4640.   #--------------------------------------------------------------------------
  4641.   def self.fade_bgm(seconds = 0)
  4642.     # Fade out BGS
  4643.     $game_system.bgs_fade(seconds)
  4644.   end
  4645.   #--------------------------------------------------------------------------
  4646.   # * Memorize BGM/BGS
  4647.   #
  4648.   #   MInterpreter.memorize_bgms
  4649.   #--------------------------------------------------------------------------
  4650.   def self.memorize_bgms
  4651.     # Memorize BGM/BGS
  4652.     $game_system.bgm_memorize
  4653.     $game_system.bgs_memorize
  4654.   end
  4655.   #--------------------------------------------------------------------------
  4656.   # * Restore BGM/BGS
  4657.   #
  4658.   #   MInterpreter.restore_bgms
  4659.   #--------------------------------------------------------------------------
  4660.   def self.restore_bgms
  4661.     # Restore BGM/BGS
  4662.     $game_system.bgm_restore
  4663.     $game_system.bgs_restore
  4664.   end
  4665.   #--------------------------------------------------------------------------
  4666.   # * Play ME
  4667.   #
  4668.   #   MInterpreter.play_me(filename, volume = 100, pitch = 100)
  4669.   #--------------------------------------------------------------------------
  4670.   def self.play_me(filename, volume = 100, pitch = 100)
  4671.     # Create AudioFile
  4672.     audiofile = RPG::AudioFile.new(filename, volume, pitch)
  4673.     # Play ME
  4674.     $game_system.me_play(audiofile)
  4675.   end
  4676.   #--------------------------------------------------------------------------
  4677.   # * Play SE
  4678.   #
  4679.   #   MInterpreter.play_se(filename, volume = 100, pitch = 100)
  4680.   #--------------------------------------------------------------------------
  4681.   def self.play_se(filename, volume = 100, pitch = 100)
  4682.     # Create AudioFile
  4683.     audiofile = RPG::AudioFile.new(filename, volume, pitch)
  4684.     # Play ME
  4685.     $game_system.me_play(audiofile)
  4686.   end
  4687.   #--------------------------------------------------------------------------
  4688.   # * Stop SE
  4689.   #
  4690.   #   MInterpreter.stop_se
  4691.   #--------------------------------------------------------------------------
  4692.   def self.stop_se
  4693.     # Stop SE
  4694.     Audio.se_stop
  4695.   end
  4696.   #--------------------------------------------------------------------------
  4697.   # * Battle Processing
  4698.   #
  4699.   #   MInterpreter.battle_proc(troop_id, can_escape = true, can_lose = true)
  4700.   #--------------------------------------------------------------------------
  4701.   def self.battle_proc(troop_id, can_escape = true, can_lose = true)
  4702.     # If not invalid troops
  4703.     if $data_troops[troop_id] != nil
  4704.       # Set battle abort flag
  4705.       $game_temp.battle_abort = true
  4706.       # Set battle calling flag
  4707.       $game_temp.battle_calling = true
  4708.       $game_temp.battle_troop_id = troop_id
  4709.       $game_temp.battle_can_escape = can_escape
  4710.       $game_temp.battle_can_lose = can_lose
  4711.     end
  4712.   end
  4713.   #--------------------------------------------------------------------------
  4714.   # * Shop Processing
  4715.   #
  4716.   #   MInterpreter.shop_proc(*goods)
  4717.   #
  4718.   #   Goods = [kind, id]   (Kind : 0 - Item, 1 - Weapon, 2 - Armor)
  4719.   #--------------------------------------------------------------------------
  4720.   def self.shop_proc(*goods)
  4721.     # Set battle abort flag
  4722.     $game_temp.battle_abort = true
  4723.     # Set shop calling flag
  4724.     $game_temp.shop_calling = true
  4725.     # Set goods list on new item
  4726.     $game_temp.shop_goods = goods
  4727.   end
  4728.   #--------------------------------------------------------------------------
  4729.   # * Name Input Processing
  4730.   #
  4731.   #   MInterpreter.name_input_proc(actor_id, max_chrs = 8)
  4732.   #--------------------------------------------------------------------------
  4733.   def self.name_input_proc(actor_id, max_chrs = 8)
  4734.     # If not invalid actors
  4735.     if $data_actors[actor_id] != nil
  4736.       # Set battle abort flag
  4737.       $game_temp.battle_abort = true
  4738.       # Set name input calling flag
  4739.       $game_temp.name_calling = true
  4740.       $game_temp.name_actor_id = actor_id
  4741.       $game_temp.name_max_char = max_chrs
  4742.     end
  4743.   end
  4744.   #--------------------------------------------------------------------------
  4745.   # * Change Actor Stat
  4746.   #
  4747.   #   MInterpreter.change_actor_stat(actor_id, stat_name, value)
  4748.   #
  4749.   #   stat_name : 'hp', 'sp', 'level', 'exp', 'str', 'dex', 'agi', 'int',
  4750.   #               'class_id' (May use anything that is has a writable method)
  4751.   #--------------------------------------------------------------------------
  4752.   def self.change_actor_stat(actor_id, stat_name, value)
  4753.     # Get Actor
  4754.     actor = $game_actors[actor_id]
  4755.     # Return if nil actor
  4756.     return if actor.nil?
  4757.     # Alter Stat
  4758.     eval "actor.#{stat_name} += value"
  4759.   end
  4760.   #--------------------------------------------------------------------------
  4761.   # * Gain Actor Skills
  4762.   #
  4763.   #   MInterpreter.gain_actor_skills(actor_id, *skill_ids)
  4764.   #--------------------------------------------------------------------------
  4765.   def self.gain_actor_skills(actor_id, *skill_ids)
  4766.     # Get Actor
  4767.     actor = $game_actors[actor_id]
  4768.     # Return if nil actor
  4769.     return if actor.nil?
  4770.     # Gain All Skills
  4771.     skill_ids.each {|s| actor.learn_skill(s)}
  4772.   end
  4773.   #--------------------------------------------------------------------------
  4774.   # * Lose Actor Skills
  4775.   #
  4776.   #   MInterpreter.lose_actor_skills(actor_id, *skill_ids)
  4777.   #--------------------------------------------------------------------------
  4778.   def self.lose_actor_skills(actor_id, *skill_ids)
  4779.     # Get Actor
  4780.     actor = $game_actors[actor_id]
  4781.     # Return if nil actor
  4782.     return if actor.nil?
  4783.     # Lose All Skills
  4784.     skill_ids.each {|s| actor.forget_skill(s)}
  4785.   end
  4786.   #--------------------------------------------------------------------------
  4787.   # * Gain Actor States
  4788.   #
  4789.   #   MInterpreter.gain_actor_states(actor_id, *skill_ids)
  4790.   #--------------------------------------------------------------------------
  4791.   def self.gain_actor_states(actor_id, *state_ids)
  4792.     # Get Actor
  4793.     actor = $game_actors[actor_id]
  4794.     # Return if nil actor
  4795.     return if actor.nil?
  4796.     # Gain All States
  4797.     state_ids.each {|s| actor.add_state(s)}
  4798.   end
  4799.   #--------------------------------------------------------------------------
  4800.   # * Lose Actor States
  4801.   #
  4802.   #   MInterpreter.lose_actor_states(actor_id, *skill_ids)
  4803.   #--------------------------------------------------------------------------
  4804.   def self.lose_actor_states(actor_id, *state_ids)
  4805.     # Get Actor
  4806.     actor = $game_actors[actor_id]
  4807.     # Return if nil actor
  4808.     return if actor.nil?
  4809.     # Remove All States
  4810.     skill_ids.each {|s| actor.remove_state(s)}
  4811.   end
  4812.   #--------------------------------------------------------------------------
  4813.   # * Change Actor Equipment
  4814.   #
  4815.   #   MInterpreter.change_actor_equip(actor_id, type, id)
  4816.   #
  4817.   #   Type : 0 - Weapon, 1 - Shield, 2 - Head, 3 - Body, 4 - Accessory
  4818.   #--------------------------------------------------------------------------
  4819.   def self.change_actor_equip(actor_id, type, id)
  4820.     # Get actor
  4821.     actor = $game_actors[actor_id]
  4822.     # Return if nil actor
  4823.     return if actor.nil?
  4824.     # Change Equipment
  4825.     actor.equip(type, id)
  4826.   end
  4827.   #--------------------------------------------------------------------------
  4828.   # * Change Event Graphic
  4829.   #
  4830.   #   MInterpreter.change_event_graphic(target_id, character_name, hue = 0)
  4831.   #
  4832.   #   Replace character_name with n to set tile id
  4833.   #--------------------------------------------------------------------------
  4834.   def self.change_event_graphic(target_id, character_name, hue = 0)
  4835.     # Get Character
  4836.     character = $game_map.events[target_id]
  4837.     # Return if Nil Character
  4838.     return if character.nil?
  4839.     # If Setting Tile ID
  4840.     if character_name.is_a?(Fixnum)
  4841.       character.tile_id = character_name
  4842.       character.character_name = ''
  4843.       character.character_hue  = hue
  4844.       return
  4845.     end
  4846.     # Set Character Name & Hue
  4847.     character.character_name = character_name
  4848.     character.character_hue  = hue
  4849.   end
  4850.   #--------------------------------------------------------------------------
  4851.   # * Change Actor Character Graphic
  4852.   #
  4853.   #   MInterpreter.change_actor_cgraphic(actor_id, character_name, hue = 0)
  4854.   #--------------------------------------------------------------------------
  4855.   def self.change_actor_cgraphic(actor_id, character_name, hue = 0)
  4856.     # Get Actor
  4857.     actor = $game_actors[actor_id]
  4858.     # Return if Nil Actor
  4859.     return if actor.nil?
  4860.     # Set Character Name & Hue
  4861.     actor.character_name = character_name
  4862.     actor.character_hue  = hue
  4863.   end
  4864.   #--------------------------------------------------------------------------
  4865.   # * Change Actor Battler Graphic
  4866.   #
  4867.   #   MInterpreter.change_actor_bgraphic(actor_id, battler_name, hue = 0)
  4868.   #--------------------------------------------------------------------------
  4869.   def self.change_actor_bgraphic(actor_id, battler_name, hue = 0)
  4870.     # Get Actor
  4871.     actor = $game_actors[actor_id]
  4872.     # Return if Nil Actor
  4873.     return if actor.nil?
  4874.     # Set Character Name & Hue
  4875.     actor.battler_name = battler_name
  4876.     actor.battler_hue  = hue
  4877.   end
  4878.   #--------------------------------------------------------------------------
  4879.   # * Recover All
  4880.   #
  4881.   #   MInterpreter.recover_all(actor_id, ...) (0 for actor id for all party)
  4882.   #--------------------------------------------------------------------------
  4883.   def self.recover_all(*actor_ids)
  4884.     # Pass Through Defined Actors
  4885.     actor_ids.each do |actor_id|
  4886.       # If Actor ID is 0
  4887.       if actor_id == 0
  4888.         # Recover Party
  4889.         $game_party.actors.each {|actor| actor.recover_all}
  4890.         next
  4891.       end
  4892.       # Actor Recover All unless actor not found
  4893.       $game_actors[actor_id].recover_all unless $game_actors[actor_id].nil?
  4894.     end
  4895.   end
  4896.   #--------------------------------------------------------------------------
  4897.   # * Call Scene
  4898.   #
  4899.   #   MInterpreter.call_scene(scene_name)
  4900.   #--------------------------------------------------------------------------
  4901.   def self.call_scene(scene = Scene_Menu)
  4902.     # Change Scene
  4903.     $scene = scene.new
  4904.   end
  4905.   #--------------------------------------------------------------------------
  4906.   # * Save To Index
  4907.   #
  4908.   #   MInterpreter.save_index(index = 0)
  4909.   #--------------------------------------------------------------------------
  4910.   def self.save_index(index = 0)
  4911.     # Create Dummy Save Object
  4912.     dummy = Scene_Save.new
  4913.     # Create File
  4914.     file = File.open(dummy.make_filename(index), "wb")
  4915.     # Write File
  4916.     dummy.write_save_data(file)
  4917.     # Close File
  4918.     file.close
  4919.   end
  4920.   #--------------------------------------------------------------------------
  4921.   # * Save To Filename
  4922.   #
  4923.   #   MInterpreter.save_filename(filename = 'Save File')
  4924.   #--------------------------------------------------------------------------
  4925.   def self.save_filename(filename = 'Save File')
  4926.     # Create Dummy Save Object
  4927.     dummy = Scene_Save.new
  4928.     # Create File
  4929.     file = File.open(filename, "wb")
  4930.     # Write File
  4931.     dummy.write_save_data(file)
  4932.     # Close File
  4933.     file.close
  4934.   end
  4935.   #--------------------------------------------------------------------------
  4936.   # * Load From Index
  4937.   #
  4938.   #   MInterpreter.load_index(index = 0)
  4939.   #--------------------------------------------------------------------------
  4940.   def self.load_index(index = 0)
  4941.     # Create Dummy Load Object
  4942.     dummy = Scene_Load.new
  4943.     # Create File  
  4944.     file = File.open(dummy.make_filename(index), "rb")
  4945.     # Read Data
  4946.     dummy.read_save_data(file)
  4947.     # Close File
  4948.     file.close
  4949.   end
  4950.   #--------------------------------------------------------------------------
  4951.   # * Load From Filename
  4952.   #
  4953.   #   MInterpreter.load_filename(filename = 'Save File')
  4954.   #--------------------------------------------------------------------------
  4955.   def self.load_filename(filename = 'Save File')
  4956.     # Create Dummy Load Object
  4957.     dummy = Scene_Load.new
  4958.     # Create File  
  4959.     file = File.open(filename, "rb")
  4960.     # Read Data
  4961.     dummy.read_save_data(file)
  4962.     # Close File
  4963.     file.close
  4964.   end
  4965. end
  4966.  
  4967. #==============================================================================
  4968. # ** Game_Character
  4969. #==============================================================================
  4970.  
  4971. class Game_Character
  4972.   #--------------------------------------------------------------------------
  4973.   # * Public Instance Variables
  4974.   #--------------------------------------------------------------------------
  4975.   attr_accessor :tile_id                  # tile ID (invalid if 0)
  4976.   attr_accessor :character_name           # character file name
  4977.   attr_accessor :character_hue            # character hue
  4978. end
  4979.  
  4980. #==============================================================================
  4981. # ** Game_Actor
  4982. #==============================================================================
  4983.  
  4984. class Game_Actor < Game_Battler
  4985.   #--------------------------------------------------------------------------
  4986.   # * Public Instance Variables
  4987.   #--------------------------------------------------------------------------
  4988.   attr_accessor :character_name           # character file name
  4989.   attr_accessor :character_hue            # character hue
  4990.   attr_accessor :battler_name             # battler file name
  4991.   attr_accessor :battler_hue              # battler hue
  4992. end
  4993.  
  4994. #==============================================================================
  4995. # ** Modules.Keyboard Input (6.1)                            By Near Fantastica
  4996. #                                       Additions By Wachunaga & SephirothSpawn
  4997. #------------------------------------------------------------------------------
  4998. # * Description :
  4999. #
  5000. #   The Keyboard Input Module is designed to function as the default Input
  5001. #   module does. It is better then other methods keyboard input because as a
  5002. #   key is tested it is not removed form the list. so you can test the same
  5003. #   key multiple times the same loop. This script automatically updates itself
  5004. #   with the input module.
  5005. #------------------------------------------------------------------------------
  5006. # * Syntax :
  5007. #
  5008. #   Test if Key is Triggered :
  5009. #    - if Keyboard.trigger?(Keyboard::<Keyboard_constant>)
  5010. #
  5011. #   Test if Key is Pressed :
  5012. #    - if Keyboard.pressed?(Keyboard::<Keyboard_constant>)
  5013. #==============================================================================
  5014.  
  5015. MACL::Loaded << 'Modules.Keyboard Module'
  5016.  
  5017. #==============================================================================
  5018. # ** Keyboard
  5019. #==============================================================================
  5020.  
  5021. module Keyboard
  5022.   #--------------------------------------------------------------------------
  5023.   # * Constants (These Are Your Keyboard Keys)
  5024.   #--------------------------------------------------------------------------
  5025.   Mouse_Left      = 1       ; Mouse_Right     = 2
  5026.   Back            = 8       ; Tab             = 9
  5027.   Enter           = 13      ; Shift           = 16
  5028.   Ctrl            = 17      ; Alt             = 18
  5029.   Capslock        = 20      ; Esc             = 27
  5030.   Space           = 32      ; End             = 35
  5031.   Home            = 36      ; Left            = 37
  5032.   Right           = 39
  5033.   Del             = 46      ; Collon          = 186
  5034.   Equal           = 187     ; Comma           = 188
  5035.   Underscore      = 189     ; Dot             = 190
  5036.   Backslash       = 191     ; Tilde           = 192
  5037.   Lb              = 219     ; Rb              = 221
  5038.   Forwardslash    = 220     ; Quote           = 222
  5039.   Numberkeys      = {}      ; Numberkeys[0]   = 48
  5040.   Numberkeys[1]   = 49      ; Numberkeys[2]   = 50
  5041.   Numberkeys[3]   = 51      ; Numberkeys[4]   = 52
  5042.   Numberkeys[5]   = 53      ; Numberkeys[6]   = 54
  5043.   Numberkeys[7]   = 55      ; Numberkeys[8]   = 56
  5044.   Numberkeys[9]   = 57
  5045.   Numberpad       = {}      ; Numberpad[0]    = 45
  5046.   Numberpad[1]    = 35      ; Numberpad[2]    = 40
  5047.   Numberpad[3]    = 34      ; Numberpad[4]    = 37
  5048.   Numberpad[5]    = 12      ; Numberpad[6]    = 39
  5049.   Numberpad[7]    = 36      ; Numberpad[8]    = 38
  5050.   Numberpad[9]    = 33
  5051.   Numpad = {}               ; Numpad[0] = 96
  5052.   Numpad[1] = 97            ; Numpad[2] = 98
  5053.   Numpad[3] = 99            ; Numpad[4] = 100
  5054.   Numpad[5] = 101           ; Numpad[6] = 102
  5055.   Numpad[7] = 103           ; Numpad[8] = 104
  5056.   Numpad[9] = 105
  5057.   Letters         = {}      ; Letters['A']    = 65
  5058.   Letters['B']    = 66      ; Letters['C']    = 67
  5059.   Letters['D']    = 68      ; Letters['E']    = 69
  5060.   Letters['F']    = 70      ; Letters['G']    = 71
  5061.   Letters['H']    = 72      ; Letters['I']    = 73
  5062.   Letters['J']    = 74      ; Letters['K']    = 75
  5063.   Letters['L']    = 76      ; Letters['M']    = 77
  5064.   Letters['N']    = 78      ; Letters['O']    = 79
  5065.   Letters['P']    = 80      ; Letters['Q']    = 81
  5066.   Letters['R']    = 82      ; Letters['S']    = 83
  5067.   Letters['T']    = 84      ; Letters['U']    = 85
  5068.   Letters['V']    = 86      ; Letters['W']    = 87
  5069.   Letters['X']    = 88      ; Letters['Y']    = 89
  5070.   Letters['Z']    = 90
  5071.   Fkeys           = {}      ; Fkeys[1]        = 112
  5072.   Fkeys[2]        = 113     ; Fkeys[3]        = 114
  5073.   Fkeys[4]        = 115     ; Fkeys[5]        = 116
  5074.   Fkeys[6]        = 117     ; Fkeys[7]        = 118
  5075.   Fkeys[8]        = 119     ; Fkeys[9]        = 120
  5076.   Fkeys[10]       = 121     ; Fkeys[11]       = 122
  5077.   Fkeys[12]       = 123
  5078.   #--------------------------------------------------------------------------
  5079.   # * Text Representation
  5080.   #--------------------------------------------------------------------------
  5081.   TR = {}
  5082.   TR[Tab]           = ['     ', '     ']
  5083.   TR[Enter]         = ['/n', '/n']
  5084.   TR[Collon]        = [';', ':']
  5085.   TR[Equal]         = ['=', '+']
  5086.   TR[Comma]         = [',', '<']
  5087.   TR[Underscore]    = ['-', '_']
  5088.   TR[Dot]           = ['.', '>']
  5089.   TR[Backslash]     = ['/', '?']
  5090.   TR[Tilde]         = ['`', '~']
  5091.   TR[Forwardslash]  = ["\\", "|"]
  5092.   TR[Quote]         = ["'", '"']
  5093.   TR[Numberkeys[0]] = ['0', ')']
  5094.   TR[Numberkeys[1]] = ['1', '!']
  5095.   TR[Numberkeys[2]] = ['2', '@']
  5096.   TR[Numberkeys[3]] = ['3', '#']
  5097.   TR[Numberkeys[4]] = ['4', '$']
  5098.   TR[Numberkeys[5]] = ['5', '^%']
  5099.   TR[Numberkeys[6]] = ['6', '^']
  5100.   TR[Numberkeys[7]] = ['7', '&']
  5101.   TR[Numberkeys[8]] = ['8', '*']
  5102.   TR[Numberkeys[9]] = ['9', '(']
  5103.   Letters.values.each do |key|
  5104.     TR[key] = [key.chr.downcase, key.chr.upcase]
  5105.   end
  5106.   #--------------------------------------------------------------------------
  5107.   # * API Declaration
  5108.   #--------------------------------------------------------------------------
  5109.   State   = Win32API.new('user32','GetKeyState',      ['i'],'i')
  5110.   Key     = Win32API.new('user32','GetAsyncKeyState', ['i'],'i')
  5111.   #--------------------------------------------------------------------------
  5112.   # * Clear Key & Pressed
  5113.   #--------------------------------------------------------------------------
  5114.   @keys = [] ; @pressed = [] ; @lock = []
  5115.   @disabled_keys = [] ; @disabled_timer = {}
  5116.   @delay = {} ; @disabled_tr = [] ; @text_window = nil ; @text_max = 10
  5117.   #--------------------------------------------------------------------------
  5118.   # * Get Key State (Test Pressed)
  5119.   #--------------------------------------------------------------------------
  5120.   def self.getstate(key)
  5121.     return !State.call(key).between?(0, 1)
  5122.   end
  5123.   #--------------------------------------------------------------------------
  5124.   # * Test Key (Test Trigger)
  5125.   #--------------------------------------------------------------------------
  5126.   def self.testkey(key)
  5127.     return Key.call(key) & 0x01 == 1
  5128.   end
  5129.   #--------------------------------------------------------------------------
  5130.   # * Test Lock (Test Trigger)
  5131.   #--------------------------------------------------------------------------
  5132.   def self.testlock(key)
  5133.     return State.call(key) & 0x01 == 1
  5134.   end
  5135.   #--------------------------------------------------------------------------
  5136.   # * Trigger? Test
  5137.   #--------------------------------------------------------------------------
  5138.   def self.trigger?(key)
  5139.     return @keys.include?(key)
  5140.   end
  5141.   #--------------------------------------------------------------------------
  5142.   # * Pressed? Test
  5143.   #--------------------------------------------------------------------------
  5144.   def self.pressed?(key)
  5145.     return @pressed.include?(key)
  5146.   end
  5147.   #--------------------------------------------------------------------------
  5148.   def self.lock?(key)
  5149.     return @lock.include?(key)
  5150.   end
  5151.   #--------------------------------------------------------------------------
  5152.   # * Update
  5153.   #--------------------------------------------------------------------------
  5154.   def self.update
  5155.     # Clears Keys & Pressed
  5156.     @keys, @pressed, @lock = [], [], []
  5157.     # Pass Through Timer List
  5158.     @disabled_timer.each do |key, timer|
  5159.       # Next if nil timer or key not-disabled
  5160.       next if timer.nil? || !@disabled_keys.include?(key)
  5161.       # If Greater than 0 Timer
  5162.       if timer > 0
  5163.         timer -= 1
  5164.         next
  5165.       end
  5166.       # Enable Key
  5167.       @disabled_keys.delete(key) if @disabled_keys.include?(key)
  5168.       # Set Timer to Nil
  5169.       @disabled_timer[key] = nil
  5170.     end
  5171.     # Test All Keys
  5172.     for key in [Mouse_Left, Mouse_Right, Back, Tab, Enter, Shift, Ctrl, Alt,
  5173.                 Capslock, Esc, Space, End, Home, Left, Right, Del, Collon,
  5174.                 Equal, Comma, Underscore, Dot, Backslash, Tilde, Lb, Rb,
  5175.                 Forwardslash, Quote] + Numberkeys.values + Numberpad.values +
  5176.                 Numpad.values + Letters.values + Fkeys.values
  5177.       # Skip If Key Disabled
  5178.       next if @disabled_keys.include?(key)
  5179.       # Add Key to Triggered Array if Triggered
  5180.       @keys.push(key)    if self.testkey(key)
  5181.       # Add Key to Pressed Array if Pressed
  5182.       @pressed.push(key) if self.getstate(key)
  5183.     end
  5184.     # Add Lock Key If Capslock
  5185.     @lock.push(Keyboard::Capslock) if Keyboard.testlock(Keyboard::Capslock)
  5186.     # Update Text Window Text If Text Window Present
  5187.     self.update_text if @text_window != nil && @text_window.active
  5188.   end
  5189.   #--------------------------------------------------------------------------
  5190.   # * Update Text
  5191.   #--------------------------------------------------------------------------
  5192.   def self.update_text
  5193.     # Return if Nil Text Window
  5194.     return if @text_window.nil?
  5195.     # Gets Text Window Text
  5196.     text = @text_window.text.dup
  5197.     # Backspace Pressed
  5198.     text.pop if self.trigger?(Back)
  5199.     # If Text Size is Less Than Text Max
  5200.     if text.size < @text_max
  5201.       # Pass Through Triggered Array
  5202.       (@keys + @pressed).each do |key|
  5203.         # If TR has Key
  5204.         if TR.has_key?(key)
  5205.           # If Delay Has Key
  5206.           if @delay.has_key?(key)
  5207.             # Subtract Delay Count and Return (if greater than 0)
  5208.             if @delay[key] > 0
  5209.               @delay[key] -= 1
  5210.               next
  5211.             end
  5212.           end
  5213.           # Skip if TR Key Disabled
  5214.           next if @disabled_tr.include?(key)
  5215.           # If Shiftcase
  5216.           if ( self.lock?(Capslock) && !self.pressed?(Shift)) ||
  5217.              (!self.lock?(Capslock) &&  self.pressed?(Shift))
  5218.             text += TR[key][1]
  5219.           # If Regular Case
  5220.           else
  5221.             text += TR[key][0]
  5222.           end
  5223.           # Start Delay Count
  5224.           @delay[key] = 6
  5225.         end
  5226.       end
  5227.     end
  5228.     # Sets Text Window Text
  5229.     @text_window.text = text
  5230.   end
  5231.   #--------------------------------------------------------------------------
  5232.   # * Read Disabled TR
  5233.   #--------------------------------------------------------------------------
  5234.   def self.disabled_tr
  5235.     return disabled_tr
  5236.   end
  5237.   #--------------------------------------------------------------------------
  5238.   # * Set Disabled TR
  5239.   #--------------------------------------------------------------------------
  5240.   def self.disabled_tr=(disabled_tr)
  5241.     @disabled_tr = disabled_tr
  5242.   end
  5243.   #--------------------------------------------------------------------------
  5244.   # * Read Text Window
  5245.   #--------------------------------------------------------------------------
  5246.   def self.text_window
  5247.     return text_window
  5248.   end
  5249.   #--------------------------------------------------------------------------
  5250.   # * Set Text Window
  5251.   #--------------------------------------------------------------------------
  5252.   def self.text_window=(text_window)
  5253.     @text_window = text_window
  5254.   end
  5255.   #--------------------------------------------------------------------------
  5256.   # * Read Text Max
  5257.   #--------------------------------------------------------------------------
  5258.   def self.text_max
  5259.     return text_max
  5260.   end
  5261.   #--------------------------------------------------------------------------
  5262.   # * Set Text Max
  5263.   #--------------------------------------------------------------------------
  5264.   def self.text_max=(text_max)
  5265.     @text_max = text_max
  5266.   end
  5267.   #------------------------------------------------------------------------
  5268.   # * Disable Key
  5269.   #------------------------------------------------------------------------
  5270.   def self.disable_key(constant, frames = nil)
  5271.     # Add Key to Disabled List
  5272.     @disabled_keys << constant unless @disabled_keys.include?(constant)
  5273.     # Set Disabled Counter if non-nil
  5274.     @disabled_timer[constant] = frames unless frames.nil?
  5275.   end
  5276.   #------------------------------------------------------------------------
  5277.   # * Enable Key
  5278.   #------------------------------------------------------------------------
  5279.   def self.enable_key(constant)
  5280.     # Remove Constant From List
  5281.     @disabled_keys.delete(constant)
  5282.     # Set Nil Timer
  5283.     @disabled_timer[constant] = nil
  5284.   end
  5285. end
  5286.  
  5287. #==============================================================================
  5288. # ** Input
  5289. #==============================================================================
  5290.  
  5291. module Input
  5292.   class << self
  5293.     #------------------------------------------------------------------------
  5294.     # * Alias Listings
  5295.     #------------------------------------------------------------------------
  5296.     unless self.method_defined?(:seph_keyboard_input_update)
  5297.       alias_method :seph_keyboard_input_update,   :update
  5298.     end
  5299.     #------------------------------------------------------------------------
  5300.     # * Frame Update
  5301.     #------------------------------------------------------------------------
  5302.     def update
  5303.       # Original Update
  5304.       seph_keyboard_input_update
  5305.       # Update Keyboard
  5306.       Keyboard.update
  5307.     end
  5308.   end
  5309. end
  5310.  
  5311. #==============================================================================
  5312. # ** Modules.Mouse Input (7.0)              By Near Fantastica & SephirothSpawn
  5313. #------------------------------------------------------------------------------
  5314. # * Description :
  5315. #
  5316. #   The Mouse Input Module defines mouse input. It will retrieve the cursor
  5317. #   x and y position, as well as grid locations. This script updates
  5318. #   itself when the input module updates.
  5319. #------------------------------------------------------------------------------
  5320. # * Customization :
  5321. #
  5322. #   Turning Windows Cursor off when opening Game
  5323. #    - Hide_Mouse_Cursor = true (turn off) or false (leave alone)
  5324. #
  5325. #   Mouse triggers that cause Input triggers
  5326. #    - Mouse_to_Input_Triggers = { mouse_key => Input::KeyConstant, ... }
  5327.  
  5328. #------------------------------------------------------------------------------
  5329. # * Syntax :
  5330. #
  5331. #   Get Mouse Position :
  5332. #    - position = Mouse.position
  5333. #
  5334. #   Get Mouse Grid Position :
  5335. #    - grid_position = Mouse.grid
  5336. #
  5337. #   Trigger Status
  5338. #    - Mouse.trigger?
  5339. #
  5340. #   Repeat Status
  5341. #    - Mouse.repeat?
  5342. #==============================================================================
  5343.  
  5344. MACL::Loaded << 'Modules.Mouse Module'
  5345.  
  5346. #==============================================================================
  5347. # ** Mouse
  5348. #==============================================================================
  5349.  
  5350. module Mouse
  5351.   #--------------------------------------------------------------------------
  5352.   # * Show Windows Cursor Setting
  5353.   #--------------------------------------------------------------------------
  5354.   Hide_Mouse_Cursor = false
  5355.   #--------------------------------------------------------------------------
  5356.   # * Mouse to Input Triggers
  5357.   #
  5358.   #   key => Input::KeyCONSTANT (key: 0 - Left, 1 - Middle, 2 - Right)
  5359.   #--------------------------------------------------------------------------
  5360.   Mouse_to_Input_Triggers = {0 => Input::C, 1 => Input::B, 2 => Input::A}
  5361.   #--------------------------------------------------------------------------
  5362.   # * API Declaration
  5363.   #--------------------------------------------------------------------------
  5364.   GAKS          = Win32API.new('user32',    'GetAsyncKeyState', 'i',     'i')
  5365.   GSM           = Win32API.new('user32',    'GetSystemMetrics', 'i',     'i')
  5366.   Cursor_Pos    = Win32API.new('user32',    'GetCursorPos',     'p',     'i')
  5367.   Show_Cursor   = Win32API.new('user32',    'ShowCursor',       'l',     'l')
  5368.   Scr2cli       = Win32API.new('user32',    'ScreenToClient',   %w(l p), 'i')
  5369.   Client_rect   = Win32API.new('user32',    'GetClientRect',    %w(l p), 'i')
  5370.   Findwindow    = Win32API.new('user32',    'FindWindowA',      %w(p p), 'l')
  5371.   Readini       = Win32API.new('kernel32',  'GetPrivateProfileStringA',
  5372.                                %w(p p p p l p), 'l')
  5373.   Show_Cursor.call(Hide_Mouse_Cursor ? 0 : 1)
  5374.   @triggers     =   [[0, 1], [0, 2], [0, 4]]
  5375.   #--------------------------------------------------------------------------
  5376.   # * Mouse Grid Position
  5377.   #--------------------------------------------------------------------------
  5378.   def self.grid
  5379.     # Return Nil if Position is Nil
  5380.     return nil if @pos.nil?
  5381.     # Return X & Y Locations
  5382.     x = (@pos[0] + $game_map.display_x / 4) / 32
  5383.     y = (@pos[1] + $game_map.display_y / 4) / 32
  5384.     return [x, y]
  5385.   end
  5386.   #--------------------------------------------------------------------------
  5387.   # * Mouse Position
  5388.   #--------------------------------------------------------------------------
  5389.   def self.position
  5390.     return @pos == nil ? [0, 0] : @pos
  5391.   end
  5392.   #--------------------------------------------------------------------------
  5393.   # * Mouse Global Position
  5394.   #--------------------------------------------------------------------------
  5395.   def self.global_pos
  5396.     # Packs 0 Position
  5397.     pos = [0, 0].pack('ll')
  5398.     # Returns Unpacked Cursor Position Call
  5399.     return Cursor_Pos.call(pos) == 0 ? nil : pos.unpack('ll')
  5400.   end
  5401.   #--------------------------------------------------------------------------
  5402.   # * Mouse Position
  5403.   #--------------------------------------------------------------------------
  5404.   def self.pos
  5405.     # Gets X & Y Position
  5406.     x, y = self.screen_to_client(*self.global_pos)
  5407.     # Gets Width & Height of Game Window
  5408.     width, height = self.client_size
  5409.     # Begins Test
  5410.     begin
  5411.       # Return X & Y or Nil Depending on Mouse Position
  5412.       if (x >= 0 && y >= 0 && x < width && y < height)
  5413.         return x, y
  5414.       end
  5415.       return nil
  5416.     rescue
  5417.       # Return nil
  5418.       return nil
  5419.     end
  5420.   end
  5421.   #--------------------------------------------------------------------------
  5422.   # * Update Mouse Position
  5423.   #--------------------------------------------------------------------------
  5424.   def self.update
  5425.     # Update Position
  5426.     @pos = self.pos
  5427.     # Update Triggers
  5428.     for i in @triggers
  5429.       # Gets Async State
  5430.       n = GAKS.call(i[1])
  5431.       # If 0 or 1
  5432.       if [0, 1].include?(n)
  5433.         i[0] = (i[0] > 0 ? i[0] * -1 : 0)
  5434.       else
  5435.         i[0] = (i[0] > 0 ? i[0] + 1 : 1)
  5436.       end
  5437.     end
  5438.   end
  5439.   #--------------------------------------------------------------------------
  5440.   # * Trigger?
  5441.   #     id : 0:Left, 1:Right, 2:Center
  5442.   #--------------------------------------------------------------------------
  5443.   def self.trigger?(id = 0)
  5444.     return @triggers[id][0] == 1
  5445.   end
  5446.   #--------------------------------------------------------------------------
  5447.   # * Repeat?
  5448.   #     id : 0:Left, 1:Right, 2:Center
  5449.   #--------------------------------------------------------------------------
  5450.   def self.repeat?(id = 0)
  5451.     if @triggers[id][0] <= 0
  5452.       return false
  5453.     else
  5454.       return @triggers[id][0] % 5 == 1 && @triggers[id][0] % 5 != 2
  5455.     end
  5456.   end
  5457.   #--------------------------------------------------------------------------
  5458.   # * Screen to Client
  5459.   #--------------------------------------------------------------------------
  5460.   def self.screen_to_client(x, y)
  5461.     # Return nil if X & Y empty
  5462.     return nil unless x and y
  5463.     # Pack X & Y
  5464.     pos = [x, y].pack('ll')
  5465.     # Return Unpacked Position or Nil
  5466.     return Scr2cli.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  5467.   end
  5468.   #--------------------------------------------------------------------------
  5469.   # * Hwnd
  5470.   #--------------------------------------------------------------------------
  5471.   def self.hwnd
  5472.     # Finds Game Name
  5473.     game_name = "\0" * 256
  5474.     Readini.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
  5475.     game_name.delete!("\0")
  5476.     # Finds Window
  5477.     return Findwindow.call('RGSS Player', game_name)
  5478.   end
  5479.   #--------------------------------------------------------------------------
  5480.   # * Client Size
  5481.   #--------------------------------------------------------------------------
  5482.   def self.client_size
  5483.     # Packs Empty Rect
  5484.     rect = [0, 0, 0, 0].pack('l4')
  5485.     # Gets Game Window Rect
  5486.     Client_rect.call(self.hwnd, rect)
  5487.     # Unpacks Right & Bottom
  5488.     right, bottom = rect.unpack('l4')[2..3]
  5489.     # Returns Right & Bottom
  5490.     return right, bottom
  5491.   end
  5492. end
  5493.  
  5494. #==============================================================================
  5495. # ** Input
  5496. #==============================================================================
  5497.  
  5498. class << Input
  5499.   #------------------------------------------------------------------------
  5500.   # * Alias Listings
  5501.   #------------------------------------------------------------------------
  5502.   unless self.method_defined?(:seph_mouse_input_update)
  5503.     alias_method :seph_mouse_input_update,   :update
  5504.     alias_method :seph_mouse_input_trigger?, :trigger?
  5505.     alias_method :seph_mouse_input_repeat?,  :repeat?
  5506.   end
  5507.   #------------------------------------------------------------------------
  5508.   # * Frame Update
  5509.   #------------------------------------------------------------------------
  5510.   def update
  5511.     # Update Mouse
  5512.     Mouse.update
  5513.     # Original Update
  5514.     seph_mouse_input_update
  5515.   end
  5516.   #--------------------------------------------------------------------------
  5517.   # * Trigger? Test
  5518.   #--------------------------------------------------------------------------
  5519.   def trigger?(constant)
  5520.     # Return true if original test is true
  5521.     return true if seph_mouse_input_trigger?(constant)
  5522.     # If Mouse Position isn't Nil
  5523.     unless Mouse.pos.nil?
  5524.       # If Mouse Trigger to Input Trigger Has Constant
  5525.       if Mouse::Mouse_to_Input_Triggers.has_value?(constant)
  5526.         # Return True if Mouse Triggered
  5527.         mouse_trigger = Mouse::Mouse_to_Input_Triggers.index(constant)
  5528.         return true if Mouse.trigger?(mouse_trigger)
  5529.       end
  5530.     end
  5531.     # Return False
  5532.     return false
  5533.   end
  5534.   #--------------------------------------------------------------------------
  5535.   # * Repeat? Test
  5536.   #--------------------------------------------------------------------------
  5537.   def repeat?(constant)
  5538.     # Return true if original test is true
  5539.     return true if seph_mouse_input_repeat?(constant)
  5540.     # If Mouse Position isn't Nil
  5541.     unless Mouse.pos.nil?
  5542.       # If Mouse Trigger to Input Trigger Has Constant
  5543.       if Mouse::Mouse_to_Input_Triggers.has_value?(constant)
  5544.         # Return True if Mouse Triggered
  5545.         mouse_trigger = Mouse::Mouse_to_Input_Triggers.index(constant)
  5546.         return true if Mouse.repeat?(mouse_trigger)
  5547.       end
  5548.     end
  5549.     # Return False
  5550.     return false
  5551.   end
  5552. end
  5553. #==============================================================================
  5554. # ** Modules.Moveable V1.0                                         By Trickster
  5555. #------------------------------------------------------------------------------
  5556. # Objects mixing in this module will have the ability to move. Includes methods
  5557. # for checking if the object is moving, and to move relative to its current
  5558. # position and to stop movement. Classes mixing in this module must call the
  5559. # update_move method within the update method for this module to be sucessfully
  5560. # implemented. Also contains and keeps track of useful information such as the
  5561. # angle of movement (in degrees) The only methods that need to be implemented
  5562. # when using this as a mixin are the x and y methods.
  5563. #  
  5564. #  move_x    move_y    move    relative_move  
  5565. #  relative_move_x   relative_move_y   stop_x
  5566. #  stop_y    stop    moving?   update_move
  5567. #==============================================================================
  5568.  
  5569. MACL::Loaded << 'Modules.Moveable'
  5570.  
  5571. module Moveable
  5572.   #-------------------------------------------------------------------------
  5573.   # * Name      : Move X
  5574.   #   Info      : Starts Moving On X Axis
  5575.   #   Author    : Trickster
  5576.   #   Call Info : One-Two Arguments
  5577.   #               Integer X - Destination X
  5578.   #               Integer Speed - Movement X Speed (Default 1)
  5579.   #-------------------------------------------------------------------------
  5580.   def move_x(x, x_speed = 1)
  5581.     # Not Moving if no speed or negative speed
  5582.     return if x_speed <= 0 or @moving_x
  5583.     # Set Destination Points speed and move count set moving flag
  5584.     @destination_x = x
  5585.     # Set Move Speed X
  5586.     @move_speed_x = x_speed
  5587.     # Set Moving Flag
  5588.     @moving_x = true
  5589.     # Get the distance + (negative if to left or up positive if down or right)
  5590.     @distance_x = (@destination_x - self.x).to_f
  5591.     # Setup Move Save X variable (For low speeds)
  5592.     @move_save_x = 0
  5593.     # Setup Old X (For Stopping)
  5594.     @old_x = self.x
  5595.     # If No Distance Y
  5596.     if @distance_y.nil?
  5597.       # Set Distance to Distance X
  5598.       @distance = @distance_x
  5599.     else
  5600.       # Get slant distance (hypotenuse of the triangle ((xf,yi) (xi,yf) (xf,yf))
  5601.       @distance = Math.sqrt(@distance_x ** 2 + @distance_y ** 2)
  5602.     end
  5603.     # Update Move Angle
  5604.     update_move_angle
  5605.   end
  5606.   #-------------------------------------------------------------------------
  5607.   # * Name      : Move Y
  5608.   #   Info      : Starts Moving On Y Axis
  5609.   #   Author    : Trickster
  5610.   #   Call Info : One-Two Arguments
  5611.   #               Integer Y - Destination Y
  5612.   #               Integer Speed - Movement Y Speed (Default 1)
  5613.   #-------------------------------------------------------------------------
  5614.   def move_y(y, y_speed = 1)
  5615.     # Not Moving if no speed or negative speed
  5616.     return if y_speed <= 0 or @moving_y
  5617.     # Set Destination Points speed and move count set moving flag
  5618.     @destination_y = y
  5619.     # Set Move Speed Y
  5620.     @move_speed_y = y_speed
  5621.     # Set Moving Flag
  5622.     @moving_y = true
  5623.     # Get the distance + (negative if to left or up positive if down or right)
  5624.     @distance_y = (@destination_y - self.y).to_f
  5625.     # Setup Move Save Y variable (For low speeds)
  5626.     @move_save_y = 0
  5627.     # Setup Old X (For Stopping)
  5628.     @old_y = self.y
  5629.     # If No Distance X
  5630.     if @distance_x.nil?
  5631.       # Set Distance to Distance Y
  5632.       @distance = @distance_y
  5633.     else
  5634.       # Get slant distance (hypotenuse of the triangle ((xf,yi) (xi,yf) (xf,yf))
  5635.       @distance = Math.sqrt(@distance_x ** 2 + @distance_y ** 2)
  5636.     end
  5637.     # Update Move Angle
  5638.     update_move_angle
  5639.   end
  5640.   #-------------------------------------------------------------------------
  5641.   # * Name      : Move
  5642.   #   Info      : Starts Moving
  5643.   #   Author    : Trickster
  5644.   #   Call Info : Two-Three Arguments
  5645.   #               Integer X and Y - Destination Position
  5646.   #               Integer XSpeed and YSpeed - Movement Speed (Default 1)
  5647.   #-------------------------------------------------------------------------
  5648.   def move(x, y, x_speed = 1, y_speed = x_speed)
  5649.     move_x(x, x_speed)
  5650.     move_y(y, y_speed)
  5651.   end
  5652.   #-------------------------------------------------------------------------
  5653.   # * Name      : Relative Move
  5654.   #   Info      : Starts Moving Relative to Current Position
  5655.   #   Author    : Trickster
  5656.   #   Call Info : Two-Three Arguments
  5657.   #               Integer CX and CY - How far to move from current positon
  5658.   #               Integer Speed - Movement Speed (Default 1)
  5659.   #-------------------------------------------------------------------------
  5660.   def relative_move(cx, cy, x_speed = 1, y_speed = x_speed)
  5661.     # Add To X and Y (Relative Move)
  5662.     move(self.x + cx, self.y + cy, x_speed, y_speed)
  5663.   end
  5664.   #-------------------------------------------------------------------------
  5665.   # * Name      : Relative Move X
  5666.   #   Info      : Starts Moving on X Axis Relative to Current Position
  5667.   #   Author    : Trickster
  5668.   #   Call Info : One-Two Arguments
  5669.   #               Integer CX - How far to move on x axis
  5670.   #               Integer Speed - Movement Speed (Default 1)
  5671.   #-------------------------------------------------------------------------
  5672.   def relative_move_x(cx, speed = 1)
  5673.     # Move to Current Position + X (Relative Move)
  5674.     move_x(self.x + cx, speed)
  5675.   end
  5676.   #-------------------------------------------------------------------------
  5677.   # * Name      : Relative Move Y
  5678.   #   Info      : Starts Moving on Y Axis Relative to Current Position
  5679.   #   Author    : Trickster
  5680.   #   Call Info : One-Two Arguments
  5681.   #               Integer CY - How far to move on y axis
  5682.   #               Integer Speed - Movement Speed (Default 1)
  5683.   #-------------------------------------------------------------------------
  5684.   def relative_move_y(cy, speed = 1)
  5685.     # Move to Current Position + Y (Relative Move)
  5686.     move_y(self.y + cy, speed)
  5687.   end
  5688.   #-------------------------------------------------------------------------
  5689.   # * Name      : Stop
  5690.   #   Info      : Stops Movement
  5691.   #   Author    : Trickster
  5692.   #   Call Info : Zero to Two Arguments Boolean ReturnX, ReturnY
  5693.   #               If True returns to starting position (def false)
  5694.   #-------------------------------------------------------------------------
  5695.   def stop(returnx = false, returny = false)
  5696.     stop_x(returnx)
  5697.     stop_y(returny)
  5698.   end
  5699.   #-------------------------------------------------------------------------
  5700.   # * Name      : Stop X
  5701.   #   Info      : Stops Movement on X Axis
  5702.   #   Author    : Trickster
  5703.   #   Call Info : Zero to One Arguments Boolean ReturnX
  5704.   #               If True returns to starting X (def false)
  5705.   #-------------------------------------------------------------------------
  5706.   def stop_x(returnx = false)
  5707.     # Set Moving X to false
  5708.     @moving_x = false
  5709.     # Set Destination X
  5710.     @destination_x = nil
  5711.     # Set X to Old X if return to start
  5712.     self.x = @old_x if returnx
  5713.     # Update Move Angle
  5714.     update_move_angle
  5715.   end
  5716.   #-------------------------------------------------------------------------
  5717.   # * Name      : Stop Y
  5718.   #   Info      : Stops Movement on Y Axis
  5719.   #   Author    : Trickster
  5720.   #   Call Info : Zero to One Arguments Boolean ReturnY
  5721.   #               If True returns to starting Y (def false)
  5722.   #-------------------------------------------------------------------------
  5723.   def stop_y(returny = false)
  5724.     # Set Moving Y to false
  5725.     @moving_y = false
  5726.     # Set Destination Y
  5727.     @destination_y = nil
  5728.     # Set Y to Old Y if return to start
  5729.     self.y = @old_y if returny
  5730.     # Update Move Angle
  5731.     update_move_angle
  5732.   end
  5733.   #-------------------------------------------------------------------------
  5734.   # * Name      : Update Move Angle
  5735.   #   Info      : Updates Angle of Movement
  5736.   #   Author    : Trickster
  5737.   #   Call Info : No Arguments
  5738.   #-------------------------------------------------------------------------
  5739.   def update_move_angle
  5740.     # Calculate angle of movement which is later used to determine direction
  5741.     # If X distance is 0 (Prevent Infinity Error)
  5742.     if @distance_x.to_i == 0
  5743.       # The Angle is sign(distance_y) * - p / 2 (90ï½° or 270ï½°)
  5744.       @move_angle = @distance_y.sign * Math::PI / 2
  5745.     # If Y distance is 0 (Prevent Incorrect Direction for later)
  5746.     elsif @distance_y.to_i == 0
  5747.       # The Angle is sign(distance_x) - 1 * p / 2 (0ï½° or 180ï½°)
  5748.       @move_angle = (@distance_x.sign - 1) * Math::PI / 2
  5749.     else
  5750.       # The Angle is the Arctangent of @distance_y / @distance_x (slope)
  5751.       # Returns [-p,p]
  5752.       @move_angle = Math.atan2(@distance_y, @distance_x.to_f)
  5753.     end
  5754.     # Convert the angle to degrees
  5755.     @move_angle *= 180 / Math::PI
  5756.   end
  5757.   #-------------------------------------------------------------------------
  5758.   # * Name      : Move Angle
  5759.   #   Info      : Returns Angle of Movement
  5760.   #   Author    : Trickster
  5761.   #   Call Info : No Arguments
  5762.   #-------------------------------------------------------------------------
  5763.   def move_angle
  5764.     return moving? ? move_angle : nil
  5765.   end
  5766.   #-------------------------------------------------------------------------
  5767.   # * Name      : Moving?
  5768.   #   Info      : Is Object Moving
  5769.   #   Author    : Trickster
  5770.   #   Call Info : No Arguments
  5771.   #-------------------------------------------------------------------------
  5772.   def moving?
  5773.     return @moving_x || @moving_y
  5774.   end
  5775.   #-------------------------------------------------------------------------
  5776.   # * Name      : Update Move
  5777.   #   Info      : Updates Movement
  5778.   #   Author    : Trickster
  5779.   #   Call Info : No Arguments
  5780.   #   Comment   : Must be called every frame in the object using this module
  5781.   #               as a mixin
  5782.   #-------------------------------------------------------------------------
  5783.   def update_move
  5784.     # If not moving
  5785.     return if not moving?
  5786.     # If Moving in X Axis
  5787.     if @moving_x
  5788.       # move increase x = the cosine of the arctangent of the dist x over dist y
  5789.       # move increase x = cos(arctan(disty/distx)) simplified by trigonometry
  5790.       # to distance_x / slant_distance, the sprite moves (move speed)
  5791.       # along the slanted line (if it is slanted)
  5792.       movinc_x = @move_speed_x * @distance_x.abs / @distance
  5793.       # Get Distance Remaining
  5794.       remain_x = @destination_x - self.x
  5795.       # Get Move X - the sign of the distance left + move increase or the
  5796.       # remaining distance left if it will go past that point
  5797.       move_x = remain_x.sign * [movinc_x, remain_x.abs].min
  5798.       # Save Remainder in Move Save X
  5799.       @move_save_x += move_x.abs % 1 * move_x.sign
  5800.       # Increase X By Move X and Remainder
  5801.       self.x += move_x.to_i + @move_save_x.to_i
  5802.       # Set to Floating Portion
  5803.       @move_save_x -= @move_save_x.to_i
  5804.       # If At Destination X
  5805.       if self.x == @destination_x
  5806.         # Set Moving X to false
  5807.         @moving_x = false
  5808.         # Set Destination X
  5809.         @destination_x = nil
  5810.       end
  5811.     end
  5812.     # If Moving in Y Axis
  5813.     if @moving_y
  5814.       # same reasoning with y increase except it is the sine of the arctangent
  5815.       # move increase y = sin(arctan(disty/distx)) simplified by trigonometry
  5816.       # to distance_y / slant_distance
  5817.       movinc_y = @move_speed_y * @distance_y.abs / @distance
  5818.       # Get distance remaining
  5819.       remain_y = @destination_y - self.y
  5820.       # Get Move Y - the sign of the distance left + move increase or the
  5821.       # remaining distance left if it will go past that point
  5822.       move_y = remain_y.sign * [movinc_y, remain_y.abs].min
  5823.       # Save Remainder in Move Save Y
  5824.       @move_save_y += move_y.abs % 1 * move_y.sign
  5825.       # Increase Y By Move Y and Remainder
  5826.       self.y += move_y.to_i + @move_save_y.to_i
  5827.       # Set to Floating Portion
  5828.       @move_save_y -= @move_save_y.to_i
  5829.       # If At Destination Y
  5830.       if self.y == @destination_y
  5831.         # Set Moving Y to false
  5832.         @moving_y = false
  5833.         # Set Destination Y
  5834.         @destination_y = nil
  5835.       end
  5836.     end
  5837.   end
  5838. end
  5839.  
  5840. class Sprite
  5841.   #--------------------------------------------------------------------------
  5842.   # * Mixin Module Moveable
  5843.   #--------------------------------------------------------------------------
  5844.   include Moveable
  5845.   #--------------------------------------------------------------------------
  5846.   # * Update Alias
  5847.   #--------------------------------------------------------------------------
  5848.   if @trick_movingsprite_update.nil?
  5849.     alias_method :trick_movingsprite_update, :update
  5850.     @trick_movingsprite_update = true
  5851.   end
  5852.   def update
  5853.     trick_movingsprite_update
  5854.     update_move if moving_implemented?
  5855.   end
  5856.   #-------------------------------------------------------------------------
  5857.   # * Name      : Moving Implemented?
  5858.   #   Info      : Implements Moving if it returns true false otherwise
  5859.   #   Author    : Trickster
  5860.   #   Call Info : No Arguments
  5861.   #   Comments  : In Custom Sprite Classes make this method return false
  5862.   #               To Implement your own movement functions or just to disable
  5863.   #-------------------------------------------------------------------------
  5864.   def moving_implemented?
  5865.     return true
  5866.   end
  5867. end
  5868.  
  5869. class Window
  5870.   #--------------------------------------------------------------------------
  5871.   # * Mixin Module Moveable
  5872.   #--------------------------------------------------------------------------
  5873.   include Moveable
  5874.   #--------------------------------------------------------------------------
  5875.   # * Update Alias
  5876.   #--------------------------------------------------------------------------
  5877.   if @trick_movingwindow_update.nil?
  5878.     alias_method :trick_movingwindow_update, :update
  5879.     @trick_movingwindow_update = true
  5880.   end
  5881.   def update
  5882.     trick_movingwindow_update
  5883.     update_move if moving_implemented?
  5884.   end
  5885.   #-------------------------------------------------------------------------
  5886.   # * Name      : Moving Implemented?
  5887.   #   Info      : Implements Moving if it returns true false otherwise
  5888.   #   Author    : Trickster
  5889.   #   Call Info : No Arguments
  5890.   #   Comments  : In Custom Window Classes make this method return false
  5891.   #               To Implement your own movement functions or just to disable
  5892.   #-------------------------------------------------------------------------
  5893.   def moving_implemented?
  5894.     return true
  5895.   end
  5896. end
  5897.  
  5898. #==============================================================================
  5899. # ** Modules.Screenshot Module (2.0)                    By Andreas21 & Cybersam
  5900. #------------------------------------------------------------------------------
  5901. # * Requirements :
  5902. #
  5903. #   Screenshot.dll (Located in Game Directory)
  5904. #------------------------------------------------------------------------------
  5905. # * Description :
  5906. #
  5907. #   This script was designed to automatically take a screenshot of your game
  5908. #   and save the file in the pictures folder.
  5909. #------------------------------------------------------------------------------
  5910. # * Syntax :
  5911. #
  5912. #   Taking a Screenshot
  5913. #    - Screenshot.shot('filename', image_type)
  5914. #
  5915. #    image_type : 0 - bmp, 1 - jpg, 2 - png
  5916. #==============================================================================
  5917.  
  5918. # Test if Screenshot Dll Found
  5919. begin
  5920.   test = Win32API.new('screenshot', 'Screenshot', %w(l l l l p l l), '')
  5921.   include_screenshot_module = true
  5922. rescue
  5923.   include_screenshot_module = false
  5924. end
  5925.  
  5926. # If Screenshot DLL Found
  5927. if include_screenshot_module
  5928.  
  5929. MACL::Loaded << 'Modules.Screenshot Module'
  5930.  
  5931. #==============================================================================
  5932. # ** Screenshot
  5933. #==============================================================================
  5934.  
  5935. module Screenshot
  5936.   #--------------------------------------------------------------------------
  5937.   # * File Directory
  5938.   #--------------------------------------------------------------------------
  5939.   Dir = 'Graphics/Pictures/'
  5940.   #--------------------------------------------------------------------------
  5941.   # * API Refrence
  5942.   #--------------------------------------------------------------------------
  5943.   Screen     = Win32API.new('screenshot', 'Screenshot',
  5944.     %w(l l l l p l l), '')
  5945.   Readini    = Win32API.new('kernel32',   'GetPrivateProfileStringA',
  5946.     %w(p p p p l p), 'l')
  5947.   Findwindow = Win32API.new('user32',     'FindWindowA',
  5948.     %w(p p), 'l')
  5949.   #--------------------------------------------------------------------------
  5950.   # * Shot
  5951.   #
  5952.   #   image_type : 0 - bmp, 1 - jpg, 2 - png
  5953.   #--------------------------------------------------------------------------
  5954.   def shot(filename = 'screenshot', image_type = 2)
  5955.     # Adds File Extension
  5956.     filename += image_type == 0 ? '.bmp' : image_type == 1 ? '.jpg' : '.png'
  5957.     # Create True Filename
  5958.     file_name = Dir + filename
  5959.     # Make Screenshot
  5960.     Screen.call(0, 0, 640, 480, file_name, handel, image_type)
  5961.   end
  5962.   #--------------------------------------------------------------------------
  5963.   # * Handel (Finds Game Window)
  5964.   #--------------------------------------------------------------------------
  5965.   def handel
  5966.     game_name = "\0" * 256
  5967.     Readini.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
  5968.     game_name.delete!("\0")
  5969.     return Findwindow.call('RGSS Player', game_name)
  5970.   end
  5971. end
  5972.  
  5973. end
  5974.  
  5975. #==============================================================================
  5976. # ** Modules.View Range (5.0)               By Near Fantastica & SephirothSpawn
  5977. #------------------------------------------------------------------------------
  5978. # * Description :
  5979. #
  5980. #   The View Range Module is used to test objects position in comparision with
  5981. #   another object. It can test if an object is within a defined circular
  5982. #   range of another object or a rectangular defined region. It can also tell
  5983. #   you this distances between objects.
  5984. #------------------------------------------------------------------------------
  5985. # * Syntax :
  5986. #
  5987. #   Test if object is within defined range from another object :
  5988. #    - VR.in_range?(object1, object2, range)
  5989. #    - VR.in_range?(object1x, object1y, object2x, object2y, range)
  5990. #
  5991. #   Test if object is within defined rectanlge :
  5992. #    - VR.in_rect_range?(object, <args>)
  5993. #    - VR.in_rect_range?(x, y, <args>)
  5994. #
  5995. #    args can either be : x, y, width, height or Rect.new(x, y, width, height)
  5996. #
  5997. #   Test range between objects :
  5998. #    - range = VR.range(object1, object2, <integer>)
  5999. #    - range = VR.range(object1x, object1y, object2x, object2y, <integer>)
  6000. #
  6001. #    integer : if true, returns integer ; if false, returns float
  6002. #==============================================================================
  6003.  
  6004. MACL::Loaded << 'Modules.View Range'
  6005.  
  6006. #==============================================================================
  6007. # ** View Range
  6008. #==============================================================================
  6009.  
  6010. module VR
  6011.   #----------------------------------------------------------------------------
  6012.   # * Within Range Test
  6013.   #----------------------------------------------------------------------------
  6014.   def VR.in_range?(*args)
  6015.     # If 3 Arguments (Element, Object, Range)
  6016.     if args.size == 3
  6017.       x = (args[0].x - args[1].x) ** 2
  6018.       y = (args[0].y - args[1].y) ** 2
  6019.       r = args[2]
  6020.     # If 5 Arguments (Elementx, Elementy, Objectx, Objecty, Range)
  6021.     elsif args.size == 5
  6022.       x = (args[0] - args[2]) ** 2
  6023.       y = (args[1] - args[3]) ** 2
  6024.       r = args[4]
  6025.     else
  6026.       p 'Wrong Defined Number of Arguments'
  6027.       return
  6028.     end
  6029.     return (x + y) <= (r * r)
  6030.   end
  6031.   #----------------------------------------------------------------------------
  6032.   # * Within Rect Range Test
  6033.   #----------------------------------------------------------------------------
  6034.   def VR.in_rect_range?(*args)
  6035.     # If 2 Arguments (Object, Rect)
  6036.     if args.size == 2
  6037.       x_, y_ = args[0].x, args[0].y
  6038.       x, y, w, h = args[1].x, args[1].y, args[1].width, args[1].height
  6039.     # If 3 Arguments (Objectx, Objecty, Rect)
  6040.     elsif args.size == 3
  6041.       x_, y_ = args[0], args[1]
  6042.       x, y, w, h = args[2].x, args[2].y, args[2].width, args[2].height
  6043.     # If 5 Arguments (Object, Rectx, Recty, Rectwidth, Rectheight)
  6044.     elsif args.size == 5
  6045.       x_, y_ = args[0].x, args[0].y
  6046.       x, y, w, h = args[1], args[2], args[3], args[4]
  6047.     # If 6 Arguments (Objectx, Objecty, Rectx, Recty, Rectwidth, Rectheight)
  6048.     elsif args.size == 6
  6049.       x_, y_, x, y, w, h = *args
  6050.     else
  6051.       p 'Wrong Defined Number of Arguments'
  6052.       return
  6053.     end
  6054.     # Return Object Within Rect
  6055.     return x_.between?(x, x + w) && y_.between?(y, y + h)
  6056.   end
  6057.   #----------------------------------------------------------------------------
  6058.   # * Range
  6059.   #----------------------------------------------------------------------------
  6060.   def VR.range(*args)
  6061.     # If 2 Arguments (Element, Object)
  6062.     if args.size == 2
  6063.       x = (args[0].x - args[1].x) * (args[0].x - args[1].x)
  6064.       y = (args[0].y - args[1].y) * (args[0].y - args[1].y)
  6065.       integer = true
  6066.     # If 3 Arguments (Element, Object, Integer
  6067.     elsif args.size == 3
  6068.       x = (args[0].x - args[1].x) * (args[0].x - args[1].x)
  6069.       y = (args[0].y - args[1].y) * (args[0].y - args[1].y)
  6070.       integer = args[2]
  6071.     # If 4 Arguments (Elementx, Elementy, Objectx, Objecty)
  6072.     elsif args.size == 4
  6073.       x = (args[0] - args[2]) * (args[0] - args[2])
  6074.       y = (args[1] - args[3]) * (args[1] - args[3])
  6075.       integer = true
  6076.     # If 5 Arguments (Elementx, Elementy, Objectx, Objecty, integer)
  6077.     elsif args.size == 5
  6078.       x = (args[0] - args[2]) * (args[0] - args[2])
  6079.       y = (args[1] - args[3]) * (args[1] - args[3])
  6080.       integer = args[4]
  6081.     else
  6082.       p 'Wrong Defined Number of Arguments'
  6083.       return
  6084.     end
  6085.     r = Math.sqrt(x + y)
  6086.     return integer ? r.to_i : r
  6087.   end
  6088. end
  6089.  
  6090. #==============================================================================
  6091. # ** Modules.Zlib
  6092. #------------------------------------------------------------------------------
  6093. # Description:
  6094. # ------------
  6095. # Adds PNG_File class to save Bitmap's to PNG Files
  6096. #  
  6097. # Class List:
  6098. # -----------
  6099. # Png_File
  6100. #==============================================================================
  6101.  
  6102. MACL::Loaded << 'Modules.Zlib'
  6103.  
  6104. #==============================================================================
  6105. # ** Zlib    
  6106. #==============================================================================
  6107.  
  6108. module Zlib
  6109.   #============================================================================
  6110.   # ** Png_File    
  6111.   #============================================================================
  6112.  
  6113.   class Png_File < GzipWriter
  6114.     #--------------------------------------------------------------------------
  6115.     # * Make PNG
  6116.     #--------------------------------------------------------------------------
  6117.     def make_png(bitmap, mode = 0)
  6118.       # Save Bitmap & Mode
  6119.       @bitmap, @mode = bitmap, mode
  6120.       # Create & Save PNG
  6121.       self.write(make_header)
  6122.       self.write(make_ihdr)
  6123.       self.write(make_idat)
  6124.       self.write(make_iend)
  6125.     end
  6126.     #--------------------------------------------------------------------------
  6127.     # * Make Header
  6128.     #--------------------------------------------------------------------------
  6129.     def make_header
  6130.       return [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a].pack('C*')
  6131.     end
  6132.     #--------------------------------------------------------------------------
  6133.     # * Make IHDR
  6134.     #--------------------------------------------------------------------------
  6135.     def make_ihdr
  6136.       ih_size               = [13].pack("N")
  6137.       ih_sign               = 'IHDR'
  6138.       ih_width              = [@bitmap.width].pack('N')
  6139.       ih_height             = [@bitmap.height].pack('N')
  6140.       ih_bit_depth          = [8].pack('C')
  6141.       ih_color_type         = [6].pack('C')
  6142.       ih_compression_method = [0].pack('C')
  6143.       ih_filter_method      = [0].pack('C')
  6144.       ih_interlace_method   = [0].pack('C')
  6145.       string = ih_sign + ih_width + ih_height + ih_bit_depth + ih_color_type +
  6146.                ih_compression_method + ih_filter_method + ih_interlace_method
  6147.       ih_crc = [Zlib.crc32(string)].pack('N')
  6148.       return ih_size + string + ih_crc
  6149.     end
  6150.     #--------------------------------------------------------------------------
  6151.     # * Make IDAT
  6152.     #--------------------------------------------------------------------------
  6153.     def make_idat
  6154.       header  = "\x49\x44\x41\x54"
  6155.       data    = @mode == 0 ? make_bitmap_data0 : make_bitmap_data1
  6156.       data    = Zlib::Deflate.deflate(data, 8)
  6157.       crc     = [Zlib.crc32(header + data)].pack('N')
  6158.       size    = [data.length].pack('N')
  6159.       return size + header + data + crc
  6160.     end
  6161.     #--------------------------------------------------------------------------
  6162.     # * Make Bitmap Data 0
  6163.     #--------------------------------------------------------------------------
  6164.     def make_bitmap_data0
  6165.       gz = Zlib::GzipWriter.open('hoge.gz')
  6166.       t_Fx = 0
  6167.       w = @bitmap.width
  6168.       h = @bitmap.height
  6169.       data = []
  6170.       for y in 0...h
  6171.         data.push(0)
  6172.         for x in 0...w
  6173.           t_Fx += 1
  6174.           if t_Fx % 10000 == 0
  6175.             Graphics.update
  6176.           end
  6177.           if t_Fx % 100000 == 0
  6178.             s = data.pack("C*")
  6179.             gz.write(s)
  6180.             data.clear
  6181.           end
  6182.           color = @bitmap.get_pixel(x, y)
  6183.           red = color.red
  6184.           green = color.green
  6185.           blue = color.blue
  6186.           alpha = color.alpha
  6187.           data.push(red)
  6188.           data.push(green)
  6189.           data.push(blue)
  6190.           data.push(alpha)
  6191.         end
  6192.       end
  6193.       s = data.pack("C*")
  6194.       gz.write(s)
  6195.       gz.close  
  6196.       data.clear
  6197.       gz = Zlib::GzipReader.open('hoge.gz')
  6198.       data = gz.read
  6199.       gz.close
  6200.       File.delete('hoge.gz')
  6201.       return data
  6202.     end
  6203.     #--------------------------------------------------------------------------
  6204.     # * Make Bitmap Data Mode 1
  6205.     #--------------------------------------------------------------------------
  6206.     def make_bitmap_data1
  6207.       w = @bitmap.width
  6208.       h = @bitmap.height
  6209.       data = []
  6210.       for y in 0...h
  6211.         data.push(0)
  6212.         for x in 0...w
  6213.           color = @bitmap.get_pixel(x, y)
  6214.           red = color.red
  6215.           green = color.green
  6216.           blue = color.blue
  6217.           alpha = color.alpha
  6218.           data.push(red)
  6219.           data.push(green)
  6220.           data.push(blue)
  6221.           data.push(alpha)
  6222.         end
  6223.       end
  6224.       return data.pack("C*")
  6225.     end
  6226.     #--------------------------------------------------------------------------
  6227.     # * Make IEND
  6228.     #--------------------------------------------------------------------------
  6229.     def make_iend
  6230.       ie_size = [0].pack('N')
  6231.       ie_sign = 'IEND'
  6232.       ie_crc  = [Zlib.crc32(ie_sign)].pack('N')
  6233.       return ie_size + ie_sign + ie_crc
  6234.     end
  6235.   end
  6236. end
  6237.  
  6238. #==============================================================================
  6239. # ** Systems.Animated Gradient Bars Base                           By Trickster
  6240. #------------------------------------------------------------------------------
  6241. # Description:
  6242. # ------------
  6243. # This Set of Classes, is the base for drawing animated gradient bars, in which
  6244. # the bars smoothly scroll to a value. See the individual classes for more info.
  6245. # Bar Images are to be located in Graphics/Gradients
  6246. #  
  6247. # Class List:
  6248. # ------------
  6249. # Sprite_GradientBack
  6250. # Sprite_GradientBar
  6251. #==============================================================================
  6252.  
  6253. MACL::Loaded << 'Systems.Animated Gradient Bars Base'
  6254.  
  6255. #==============================================================================
  6256. # ** Sprite_GradientBack                                           By Trickster
  6257. #------------------------------------------------------------------------------
  6258. #  This class just draws the background of the Gradient Bar. It is used within
  6259. #  Sprite_GradientBar and can be refered to by <Sprite_GradientBar>.background.
  6260. #  This Sprite Consists of a Border and a Background.
  6261. #==============================================================================
  6262.  
  6263. class Sprite_GradientBack < Sprite
  6264.   #--------------------------------------------------------------------------
  6265.   # * Public Instance Variables
  6266.   #--------------------------------------------------------------------------
  6267.   attr_reader   :width
  6268.   attr_reader   :height
  6269.   attr_reader   :max_width
  6270.   attr_reader   :max_height
  6271.   attr_reader   :border
  6272.   attr_reader   :background
  6273.   attr_accessor :bx
  6274.   attr_accessor :by
  6275.   #-------------------------------------------------------------------------
  6276.   # * Name      : Initialize
  6277.   #   Info      : Object Initialization
  6278.   #   Author    : Trickster
  6279.   #   Call Info : Two to Seven Arguments
  6280.   #               Integer X, Y - Defines the Position
  6281.   #               Integer Max_Width, Max_Height - Defines Max Dimensions (def none)
  6282.   #               String border, background - Border and Background files
  6283.   #               Viewport viewport - The Viewport defaults to nil
  6284.   #-------------------------------------------------------------------------
  6285.   def initialize(x, y, max_width = nil, max_height = nil, border = 'Back',
  6286.     background = 'Back2', viewport = nil)
  6287.     # Call Sprite and Send Viewport
  6288.     super(viewport)
  6289.     # Set Position
  6290.     self.x, self.y = x, y
  6291.     # Setup Border
  6292.     self.bx, self.by = 1, 1
  6293.     # Setup Maximum Dimensions
  6294.     @max_width, @max_height = max_width, max_height
  6295.     # Setup Files
  6296.     @border, @background = border, background
  6297.     # Setup Dimensions
  6298.     setup_dimensions
  6299.     # Setup Bitmap
  6300.     self.bitmap = Bitmap.new(@width, @height)
  6301.     # Refresh
  6302.     refresh
  6303.   end
  6304.   #-------------------------------------------------------------------------
  6305.   # * Name      : Setup Dimensions
  6306.   #   Info      : Sets up Dimensions for the Bar
  6307.   #   Author    : Trickster
  6308.   #   Call Info : No Arguments
  6309.   #-------------------------------------------------------------------------
  6310.   def setup_dimensions
  6311.     # Gets Back Bitmap
  6312.     bitmap = RPG::Cache.gradient(@border)
  6313.     # Get Width
  6314.     @width = max_width.nil? ? bitmap.width : [bitmap.width, max_width].min
  6315.     # Get Height
  6316.     @height = max_height.nil? ? bitmap.height : [bitmap.height, max_height].min
  6317.   end
  6318.   #-------------------------------------------------------------------------
  6319.   # * Name      : Set Width
  6320.   #   Info      : Sets the Bitmap's Width, Refreshes the sprite
  6321.   #   Author    : Trickster
  6322.   #   Call Info : One Argument, Integer Width - New Width
  6323.   #-------------------------------------------------------------------------
  6324.   def width=(width)
  6325.     # Restrict to (0, max_width]
  6326.     width = [width, max_width].min
  6327.     # Return if same
  6328.     return if @width == width
  6329.     # Dispose Old Bitmap
  6330.     bitmap.dispose
  6331.     # Set Width
  6332.     @width = width
  6333.     # Set New Bitmap
  6334.     self.bitmap = Bitmap.new(@width, @height)
  6335.     # Refresh
  6336.     refresh
  6337.   end
  6338.   #-------------------------------------------------------------------------
  6339.   # * Name      : Set Height
  6340.   #   Info      : Sets the Bitmap's Height, Refreshes the sprite
  6341.   #   Author    : Trickster
  6342.   #   Call Info : One Argument, Integer Height - New Height
  6343.   #-------------------------------------------------------------------------
  6344.   def height=(height)
  6345.     # Restrict to (0, max_height]
  6346.     height = [height, max_height].min
  6347.     # Return if same
  6348.     return if @height == height
  6349.     # Dispose Old Bitmap
  6350.     bitmap.dispose
  6351.     # Set Height
  6352.     @height = height
  6353.     # Set New Bitmap
  6354.     self.bitmap = Bitmap.new(@width, @height)
  6355.     # Refresh
  6356.     refresh
  6357.   end
  6358.   #-------------------------------------------------------------------------
  6359.   # * Name      : Set Gradient File
  6360.   #   Info      : Sets New Gradient Type, Refreshes the sprite
  6361.   #   Author    : Trickster
  6362.   #   Call Info : One Argument, String File - File to load
  6363.   #-------------------------------------------------------------------------
  6364.   def border=(border)
  6365.     @border = border
  6366.     refresh
  6367.   end
  6368.   #-------------------------------------------------------------------------
  6369.   # * Name      : Set Gradient File
  6370.   #   Info      : Sets New Gradient Type, Refreshes the sprite
  6371.   #   Author    : Trickster
  6372.   #   Call Info : One Argument, String File - File to load
  6373.   #-------------------------------------------------------------------------
  6374.   def background=(background)
  6375.     @background = background
  6376.     refresh
  6377.   end
  6378.   #-------------------------------------------------------------------------
  6379.   # * Name      : Refresh
  6380.   #   Info      : Refreshes the sprite
  6381.   #   Author    : Trickster
  6382.   #   Call Info : No Arguments
  6383.   #-------------------------------------------------------------------------
  6384.   def refresh
  6385.     # Clear Bitmap
  6386.     bitmap.clear
  6387.     # Draw Gradient Bar Back
  6388.     bitmap.draw_trick_gradient_bar_back(0, 0, width, height, @border,
  6389.       @background, bx, by)
  6390.   end
  6391. end
  6392.  
  6393. #==============================================================================
  6394. # ** Sprite_GradientBar                                            By Trickster
  6395. #-----------------------------------------------------------------------------
  6396. #  This class draws a sprite whose bitmap is a gradient bar, it uses my gradient
  6397. #  bar sytle (by use of outside pictures). The Pictures can be found in the folder
  6398. #  Graphics/Gradients.  When the value pointed to by the gradient bar changes the
  6399. #  The Bar will smoothly decrease or increase to match the value.  Classes that
  6400. #  inherit from this class must redefine the method update calling super if needed
  6401. #  (for flash effects), or you may use this as a base for other gradient bar
  6402. #  sprites. See also classes Sprite_ActorHpBar and Sprite_ActorSpBar for examples.
  6403. #  Best used if you create a separate class that inherits from this one.
  6404. #==============================================================================
  6405.  
  6406. class Sprite_GradientBar < Sprite
  6407.   #--------------------------------------------------------------------------
  6408.   # * Public Instance Variables
  6409.   #--------------------------------------------------------------------------
  6410.   attr_reader   :file
  6411.   attr_reader   :width
  6412.   attr_reader   :height
  6413.   attr_reader   :max_width
  6414.   attr_reader   :max_height
  6415.   attr_accessor :background
  6416.   attr_accessor :speed
  6417.   attr_accessor :bx
  6418.   attr_accessor :by
  6419.   #-------------------------------------------------------------------------
  6420.   # * Name      : Initialize
  6421.   #   Info      : Object Initialization
  6422.   #   Author    : Trickster
  6423.   #   Call Info : Six to Eight Arguments
  6424.   #               Integer X, Y - Defines the Position
  6425.   #               Integer Width, Height - Defines Dimensions (or nil for default)
  6426.   #               Integer/Proc Min, Max - Defines Current and Maximum values for
  6427.   #               drawing
  6428.   #               Integer Speed - Update Rate, Every (speed) frames defaults to 1
  6429.   #               String border, background - Border and Background Files
  6430.   #               Viewport viewport - The Viewport defaults to nil
  6431.   #-------------------------------------------------------------------------
  6432.   def initialize(x, y, max_width, max_height, min = 1, max = 1, speed = 1,
  6433.     border = 'Back', background = 'Back2', viewport = nil)
  6434.     # Call Sprite and sent viewport
  6435.     super(viewport)
  6436.     # Setup Background
  6437.     self.background = Sprite_GradientBack.new(x, y, max_width, max_height, border,
  6438.       background, viewport)
  6439.     # Setup Instance Variables
  6440.     @max_width, @max_height = max_width, max_height
  6441.     # Setup Dimensions
  6442.     setup_dimensions
  6443.     # Setup Bitmap
  6444.     self.bitmap = Bitmap.new(@width, @height)
  6445.     # Setup Position
  6446.     self.x, self.y, self.z = x, y, 101
  6447.     # Setup Border Dimensions
  6448.     self.bx, self.by = 1, 1
  6449.     # Setup Instance Variables
  6450.     @min = min.is_a?(Proc) ? min : proc {min}
  6451.     # Get Last
  6452.     @last = @min.call
  6453.     # Get Maximum
  6454.     @max = max.is_a?(Proc) ? max : proc {max}
  6455.     # Get Speed
  6456.     @speed = speed
  6457.     # Get File
  6458.     @file = '001-Primary01'
  6459.     # Setup Counter
  6460.     @count = 0
  6461.   end
  6462.   #-------------------------------------------------------------------------
  6463.   # * Name      : Setup Dimensions
  6464.   #   Info      : Sets up Dimensions for the Bar
  6465.   #   Author    : Trickster
  6466.   #   Call Info : No Arguments
  6467.   #-------------------------------------------------------------------------
  6468.   def setup_dimensions
  6469.     # Gets Back Bitmap
  6470.     bitmap = background.bitmap
  6471.     # Get Width
  6472.     @width = max_width.nil? ? bitmap.width : [bitmap.width, max_width].min
  6473.     # Get Height
  6474.     @height = max_height.nil? ? bitmap.height : [bitmap.height, max_height].min
  6475.   end
  6476.   #-------------------------------------------------------------------------
  6477.   # * Name      : Dispose
  6478.   #   Info      : Disposes the sprite and the background
  6479.   #   Author    : Trickster
  6480.   #   Call Info : No Arguments
  6481.   #-------------------------------------------------------------------------
  6482.   def dispose
  6483.     # Dispose Sprite
  6484.     super
  6485.     # Dispose Background
  6486.     background.dispose
  6487.   end
  6488.   #-------------------------------------------------------------------------
  6489.   # * Name      : Update
  6490.   #   Info      : Frane Update, Updates Bar Animation (changes in value)
  6491.   #   Author    : Trickster
  6492.   #   Call Info : No Arguments
  6493.   #   Comment:   Classes inheriting from this class must redefine this method
  6494.   #              and call super if needed (for flash effects)
  6495.   #-------------------------------------------------------------------------
  6496.   def update
  6497.     # Call Update
  6498.     super
  6499.     # Return if this class isn't Sprite_GradientBar
  6500.     return if self.class != Sprite_GradientBar
  6501.     # Increase Counter
  6502.     @count += 1
  6503.     # Return if no speed or not speed frames has passed
  6504.     return if @speed == 0 or @count % @speed != 0
  6505.     # Get Value
  6506.     val = @min.call
  6507.     # Return if same
  6508.     return if @last == value
  6509.     # Add + - 1 to Last
  6510.     @last += (val - @last).sign
  6511.     # Refresh
  6512.     refresh
  6513.   end
  6514.   #-------------------------------------------------------------------------
  6515.   # * Name      : Set Slanted Flag
  6516.   #   Info      : Sets Slanted Flag, Refreshes the sprite
  6517.   #   Author    : Trickster
  6518.   #   Call Info : One Argument, Boolean bool - true - slanted false - otherwise
  6519.   #-------------------------------------------------------------------------
  6520.   def slanted=(bool)
  6521.     # Set Slanted Flag
  6522.     @slanted = bool
  6523.     # Refresh
  6524.     refresh
  6525.   end
  6526.   #-------------------------------------------------------------------------
  6527.   # * Name      : Set X
  6528.   #   Info      : Sets the X Coordinate, updates x coordinate of the background
  6529.   #   Author    : Trickster
  6530.   #   Call Info : One Argument, Integer X - X Coordinate
  6531.   #-------------------------------------------------------------------------
  6532.   def x=(x)
  6533.     # Call Sprite X
  6534.     super(x)
  6535.     # Set X for Background
  6536.     background.x = x
  6537.   end
  6538.   #-------------------------------------------------------------------------
  6539.   # * Name      : Set Y
  6540.   #   Info      : Sets the Y Coordinate, updates y coordinate of the background
  6541.   #   Author    : Trickster
  6542.   #   Call Info : One Argument, Integer Y - Y Coordinate
  6543.   #-------------------------------------------------------------------------
  6544.   def y=(y)
  6545.     # Call Sprite Y
  6546.     super(y)
  6547.     # Set Y For Background
  6548.     background.y = y
  6549.   end
  6550.   #-------------------------------------------------------------------------
  6551.   # * Name      : Set Z
  6552.   #   Info      : Sets the Z Coordinate, updates z coordinate of the background
  6553.   #   Author    : Trickster
  6554.   #   Call Info : One Argument, Integer Z - Z Coordinate
  6555.   #-------------------------------------------------------------------------
  6556.   def z=(z)
  6557.     # Call Sprite Z
  6558.     super(z)
  6559.     # Set Background Z to Z - 1
  6560.     background.z = z - 1
  6561.   end
  6562.   #-------------------------------------------------------------------------
  6563.   # * Name      : Set Width
  6564.   #   Info      : Sets the Bitmap's Width, Refreshes the sprite
  6565.   #   Author    : Trickster
  6566.   #   Call Info : One Argument, Integer Width - New Width
  6567.   #-------------------------------------------------------------------------
  6568.   def width=(width)
  6569.     # Restrict to (0, max_width]
  6570.     width = [width, max_width].min
  6571.     # Return if same
  6572.     return if @width == width
  6573.     # Set Width
  6574.     @width = width
  6575.     # Dispose Old Bitmap
  6576.     bitmap.dispose
  6577.     # Set New Bitmap
  6578.     self.bitmap = Bitmap.new(@width, @height)
  6579.     # Set Background Width
  6580.     background.width = @width
  6581.     # Refresh
  6582.     refresh
  6583.   end
  6584.   #-------------------------------------------------------------------------
  6585.   # * Name      : Set Height
  6586.   #   Info      : Sets the Bitmap's Height, Refreshes the sprite
  6587.   #   Author    : Trickster
  6588.   #   Call Info : One Argument, Integer Height - New Height
  6589.   #-------------------------------------------------------------------------
  6590.   def height=(height)
  6591.     # Restrict to (0, max_height]
  6592.     height = [height, max_height].min
  6593.     # Return if same
  6594.     return if @height == height
  6595.     # Dispose Old Bitmap
  6596.     bitmap.dispose
  6597.     # Set Height
  6598.     @height = height
  6599.     # Set New Bitmap
  6600.     self.bitmap = Bitmap.new(@width, @height)
  6601.     # Set Background Height
  6602.     background.height = @height
  6603.     # Refresh
  6604.     refresh
  6605.   end
  6606.   #-------------------------------------------------------------------------
  6607.   # * Name      : Set Visibility
  6608.   #   Info      : Sets the visibility, updates visibility of the background
  6609.   #   Author    : Trickster
  6610.   #   Call Info : One Argument, Boolean bool - true: visible false: invisible
  6611.   #-------------------------------------------------------------------------
  6612.   def visible=(bool)
  6613.     # Call Sprite Visible
  6614.     super(bool)
  6615.     # Set Visibility
  6616.     background.visible = bool
  6617.   end
  6618.   #-------------------------------------------------------------------------
  6619.   # * Name      : Set Gradient File
  6620.   #   Info      : Sets New Gradient Type, Refreshes the sprite
  6621.   #   Author    : Trickster
  6622.   #   Call Info : One Argument, String File - File to load
  6623.   #-------------------------------------------------------------------------
  6624.   def file=(file)
  6625.     # Set File
  6626.     @file = file
  6627.     # Refresh
  6628.     refresh
  6629.   end
  6630.   #-------------------------------------------------------------------------
  6631.   # * Name      : Set Border
  6632.   #   Info      : Sets Gradient Bars Border
  6633.   #   Author    : Trickster
  6634.   #   Call Info : One Argument, String File - File to load
  6635.   #-------------------------------------------------------------------------
  6636.   def set_border(file)
  6637.     # Set Border
  6638.     background.border = file
  6639.   end
  6640.   #-------------------------------------------------------------------------
  6641.   # * Name      : Set Background
  6642.   #   Info      : Sets Gradient Bars Background
  6643.   #   Author    : Trickster
  6644.   #   Call Info : One Argument, String File - File to load
  6645.   #-------------------------------------------------------------------------
  6646.   def set_background(file)
  6647.     # Set Background's Background
  6648.     background.background = file
  6649.   end
  6650.   #-------------------------------------------------------------------------
  6651.   # * Name      : Refresh
  6652.   #   Info      : Refreshes the sprite
  6653.   #   Author    : Trickster
  6654.   #   Call Info : No Arguments
  6655.   #-------------------------------------------------------------------------
  6656.   def refresh
  6657.     # Clear Bitmap
  6658.     bitmap.clear
  6659.     # Get Max
  6660.     max = @max.call == 0 ? 1 : @max.call
  6661.     # Get Border
  6662.     border = background.border
  6663.     # Draw Bar Substance
  6664.     bitmap.draw_trick_gradient_bar_sub(0, 0, @last, max, file, width, height,
  6665.       border, bx, by, @slanted)
  6666.   end
  6667. end
  6668.  
  6669. #==============================================================================
  6670. # ** Systems.Loading Data From Text Files V4.0                     By Trickster
  6671. #------------------------------------------------------------------------------
  6672. # Description:
  6673. # ------------
  6674. # This Utility module loads data from text files, the text file loaded must
  6675. # be setup like so.
  6676. #  
  6677. # something     some_value
  6678. # parameter     value
  6679. # parameter     value
  6680. # parameter     value
  6681. #
  6682. # Also has support for comments and block comments within the text file,
  6683. # commented data will be ignored within the file. This also parses the values
  6684. # loaded into the data type it is supposed to be, for example if a value was
  6685. # 50 then it will be loaded as 50 and not "50". This effect works on Strings,
  6686. # Integers, Floats, Ranges, Arrays, Hashes, Regexp, Symbols, TrueClass,
  6687. # FalseClass, NilClass, and Classes (by calling the new operator example
  6688. # Color.new(0, 0, 0) will be loaded as a color object). Also includes error
  6689. # checking and will catch Syntax Errors, missing ] for Array, missing } for
  6690. # Hash, Range errors, and Regexp Errors and will also point to the line and
  6691. # the data that is on the line if an unexcepted error is found within the file.
  6692. #  
  6693. # Method List:
  6694. # ------------
  6695. # Trickster.load_data_from_txt
  6696. #  
  6697. # Classes:
  6698. # --------
  6699. # Trickster::File_LoadRxdata
  6700. #==============================================================================
  6701.  
  6702. MACL::Loaded << 'Systems.Loading Data From Text Files'
  6703.  
  6704. #==============================================================================
  6705. # ** Trickster    
  6706. #==============================================================================
  6707.  
  6708. module Trickster
  6709.  
  6710.   #============================================================================
  6711.   # ** File_LoadRxdata    
  6712.   #============================================================================
  6713.  
  6714.   class File_LoadRxdata < File
  6715.     #-------------------------------------------------------------------------
  6716.     # * Public Instance Variables
  6717.     #-------------------------------------------------------------------------
  6718.     attr_reader :line
  6719.     #-------------------------------------------------------------------------
  6720.     # * Name      : Format Readline
  6721.     #   Info      : Gets Next Line returns An Array of information on next line
  6722.     #   Author    : Trickster
  6723.     #   Call Info : No Arguments
  6724.     #-------------------------------------------------------------------------
  6725.     def format_readline
  6726.       # Get Line
  6727.       data = self.readline
  6728.       # Make a Copy
  6729.       @line = data.dup
  6730.       # Split it
  6731.       data = data.split
  6732.       # Return Data
  6733.       return data
  6734.     end
  6735.     #-------------------------------------------------------------------------
  6736.     # * Name      : Requirements
  6737.     #   Info      : Required Data Needed to be loaded
  6738.     #   Author    : Trickster
  6739.     #   Call Info : Four Arguments
  6740.     #               Array Data, Data Loaded
  6741.     #               Array Required, Data Required to be loaded
  6742.     #               Array Properties, Names to be loaded
  6743.     #               Boolean Elements, True if Indexes False for Parameters
  6744.     #-------------------------------------------------------------------------
  6745.     def requirements(data, required, properties, elements)
  6746.       required.each do |i|
  6747.         if (i < properties.size and (data[i].nil? and elements) or
  6748.            (data.is_a?(Hash) and data[properties[i]].nil? and not elements))
  6749.           Kernel.print("Error Loading Data \n#{properties[i]} is not defined")
  6750.           exit
  6751.         end
  6752.       end
  6753.     end
  6754.     #-------------------------------------------------------------------------
  6755.     # * Name      : Incorrect Name Error
  6756.     #   Info      : Generates Incorrect Defining Name Message
  6757.     #   Author    : Trickster
  6758.     #   Call Info : No Arguments
  6759.     #-------------------------------------------------------------------------
  6760.     def error_incorrect_name
  6761.       Kernel.print("Error at Line #{lineno}\nIncorrect parameter\nLine: #{line}")
  6762.       exit
  6763.     end
  6764.     #-------------------------------------------------------------------------
  6765.     # * Name      : Array Error
  6766.     #   Info      : Generates Missing ] for Array Message
  6767.     #   Author    : Trickster
  6768.     #   Call Info : One Argument, Integer Extra, Line Number
  6769.     #-------------------------------------------------------------------------
  6770.     def error_array(extra)
  6771.       Kernel.print("Error at Line #{extra}\nMissing ']' for Array\nLine: #{line}")
  6772.       exit
  6773.     end
  6774.     #-------------------------------------------------------------------------
  6775.     # * Name      : Hash Error (Syntax Error)
  6776.     #   Info      : Generates Missing } for Hash Message
  6777.     #   Author    : Trickster
  6778.     #   Call Info : One Argument, Integer Extra, Line Number
  6779.     #-------------------------------------------------------------------------
  6780.     def error_hash(extra)
  6781.       Kernel.print("Error at Line #{extra}\nMissing '}' for Hash\nLine: #{line}")
  6782.       exit
  6783.     end
  6784.     #-------------------------------------------------------------------------
  6785.     # * Name      : Syntax Error
  6786.     #   Info      : Generates Syntax Error Message
  6787.     #   Author    : Trickster
  6788.     #   Call Info : One Argument Integer Extra, Line number
  6789.     #-------------------------------------------------------------------------
  6790.     def error_syntax(extra)
  6791.       Kernel.print("Error at Line #{extra}\nSyntax Error\nLine: #{line}")
  6792.       exit
  6793.     end
  6794.     #-------------------------------------------------------------------------
  6795.     # * Name      : Range Error
  6796.     #   Info      : Generates Error Message
  6797.     #   Author    : Trickster
  6798.     #   Call Info : One Argument Integer Extra, Line number
  6799.     #-------------------------------------------------------------------------
  6800.     def error_range(extra)
  6801.       Kernel.print("Error at Line #{extra}\nError with Range\nLine: #{line}")
  6802.       exit
  6803.     end
  6804.     #-------------------------------------------------------------------------
  6805.     #   Name      : Regexp Fail Error
  6806.     #   Info      : Generates Error Message
  6807.     #   Author    : Trickster
  6808.     #   Call Info : One Argument Integer Extra, Line number
  6809.     #-------------------------------------------------------------------------
  6810.     def error_regexp_fail(extra)
  6811.       Kernel.print("Error at Line #{extra}\nRegexp Failed\nLine: #{line}")
  6812.       exit
  6813.     end
  6814.     #-------------------------------------------------------------------------
  6815.     # * Name      : Load Next Line
  6816.     #   Info      : Reads Next Line of Data and returns false if End of File,
  6817.     #               true if Empty or Commented else the Data
  6818.     #   Author    : Trickster
  6819.     #   Call Info : No Arguments
  6820.     #-------------------------------------------------------------------------
  6821.     def load_next_line
  6822.       # Return False if End of File
  6823.       return false if self.eof?
  6824.       # Get Data
  6825.       data = self.format_readline
  6826.       # Set Comment Flag if text is =begin
  6827.       @comment = true if data[0] == '=begin'
  6828.       # If text is =end
  6829.       if data[0] == '=end'
  6830.         # Unset Comment Flag
  6831.         @comment = false
  6832.         # True
  6833.         return true
  6834.       end
  6835.       # Return true if comment or nothing
  6836.       return true if data == [] or data[0].include?('#') or @comment
  6837.       # Return Data
  6838.       return data
  6839.     end
  6840.     #-------------------------------------------------------------------------
  6841.     # * Name      : Test Type
  6842.     #   Info      : Tests Data Type and returns sata in the correct format
  6843.     #   Author    : Trickster
  6844.     #   Call Info : Three to Four Arguments
  6845.     #               String data, String to be check
  6846.     #               String Line, Line where data was extracted
  6847.     #               Integer Lineno, Line number
  6848.     #               Integer Multi, Multi Lines for error checking
  6849.     #   Comment   : Checks for almost all data types
  6850.     #-------------------------------------------------------------------------
  6851.     def test_type(data, line, lineno, multi = 0)
  6852.       # Make a copy of the data
  6853.       temp = data.dup
  6854.       # Set extra text if an error is found
  6855.       extra = (multi > 0) ? "s #{lineno}-#{lineno+multi}" : " #{lineno}"
  6856.       # If a nil reference
  6857.       if test_nilclass?(temp)
  6858.         # Set Data to Nil
  6859.         data = nil
  6860.       # If True
  6861.       elsif test_trueclass?(temp)
  6862.         # Set to True
  6863.         data = true
  6864.       # If False
  6865.       elsif test_falseclass?(temp)
  6866.         # Set to false
  6867.         data = false
  6868.       # If an array
  6869.       elsif test_array?(temp)
  6870.         # Error Array if it doesn't include ]
  6871.         self.error_array(extra) unless temp.include?(']')
  6872.         # Evaluate Data
  6873.         data = eval_data(data, extra)
  6874.       # If a hash
  6875.       elsif test_hash?(temp)
  6876.         # Error Hash if it doesn't include }
  6877.         self.error_hash(extra) unless temp.include?('}')
  6878.         # Evaluate Data
  6879.         data = eval_data(data, extra)
  6880.       # If a number (Integer)
  6881.       elsif test_integer?(temp)
  6882.         # Convert to Integer
  6883.         data = data.to_i
  6884.       # If a number (Float)
  6885.       elsif test_float?(temp)
  6886.         # Convert to Float
  6887.         data = data.to_f
  6888.       # If a Range
  6889.       elsif test_range?(temp)
  6890.         begin
  6891.           # Evaluate Data
  6892.           data = eval_data(data, extra)
  6893.         rescue
  6894.           # Print Range Error
  6895.           self.error_range(extra)
  6896.         end
  6897.       # If a Regexp
  6898.       elsif test_regexp?(temp)
  6899.         begin
  6900.           # Evaluate Data
  6901.           data = eval_data(data, extra)
  6902.         rescue RegexpError
  6903.           # If Regexp Error then print Error
  6904.           self.error_regexp_fail
  6905.         end
  6906.       # If a Symbol
  6907.       elsif test_symbol?(temp)
  6908.         # Evaluate Data
  6909.         data = eval_data(data, extra)
  6910.       # If an Instance of a Class
  6911.       elsif test_class?(temp)
  6912.         # Evaluate Data
  6913.         data = eval_data(data, extra)
  6914.       # Elsif a string
  6915.       elsif test_string?(temp)
  6916.         # Just Delete First and Last Index
  6917.         data = data[1...(data.size-1)]
  6918.       end
  6919.       # Return Data
  6920.       return data
  6921.     end
  6922.     #-------------------------------------------------------------------------
  6923.     # * Name      : Test NilClass
  6924.     #   Info      : Tests if Data is nil
  6925.     #   Author    : Trickster
  6926.     #   Call Info : String data - data to check
  6927.     #-------------------------------------------------------------------------
  6928.     def test_nilclass?(data)
  6929.       return data == 'nil'
  6930.     end
  6931.     #-------------------------------------------------------------------------
  6932.     # * Name      : Test TrueClass
  6933.     #   Info      : Tests if Data is true
  6934.     #   Author    : Trickster
  6935.     #   Call Info : String data - data to Check
  6936.     #-------------------------------------------------------------------------
  6937.     def test_trueclass?(data)
  6938.       return data == 'true'
  6939.     end
  6940.     #-------------------------------------------------------------------------
  6941.     # * Name      : Test FalseClass
  6942.     #   Info      : Tests if Data is false
  6943.     #   Author    : Trickster
  6944.     #   Call Info : String data - data to Check
  6945.     #-------------------------------------------------------------------------
  6946.     def test_falseclass?(data)
  6947.       return data == 'false'
  6948.     end
  6949.     #-------------------------------------------------------------------------
  6950.     # * Name      : Test Array
  6951.     #   Info      : Tests if Data is an array (starts with [)
  6952.     #   Author    : Trickster
  6953.     #   Call Info : String data - data to Check
  6954.     #-------------------------------------------------------------------------
  6955.     def test_array?(data)
  6956.       return data[0, 1] == '['
  6957.     end
  6958.     #-------------------------------------------------------------------------
  6959.     # * Name      : Test Hash
  6960.     #   Info      : Tests if Data is a hash (starts with { and has =>)
  6961.     #   Author    : Trickster
  6962.     #   Call Info : String data - data to Check
  6963.     #-------------------------------------------------------------------------
  6964.     def test_hash?(data)
  6965.       return data[0, 1] == '{' && data.include?('=>') && data
  6966.     end
  6967.     #-------------------------------------------------------------------------
  6968.     # * Name      : Test Integer
  6969.     #   Info      : Tests if Data is an integer (if to_i.to_s == data)
  6970.     #   Author    : Trickster
  6971.     #   Call Info : String data - data to Check
  6972.     #-------------------------------------------------------------------------
  6973.     def test_integer?(data)
  6974.       return data.to_i.to_s == data
  6975.     end
  6976.     #-------------------------------------------------------------------------
  6977.     # * Name      : Test Float
  6978.     #   Info      : Tests if Data is a float (if to_f.to_s == data)
  6979.     #   Author    : Trickster
  6980.     #   Call Info : String data - data to Check
  6981.     #-------------------------------------------------------------------------
  6982.     def test_float?(data)
  6983.       return data.to_f.to_s == data
  6984.     end
  6985.     #-------------------------------------------------------------------------
  6986.     # * Name      : Test Range
  6987.     #   Info      : Tests if Data is a range (includes .. or ...
  6988.     #               and first and last are integers and when .. or ... is removed
  6989.     #               is an integer)
  6990.     #   Author    : Trickster
  6991.     #   Call Info : String data - data to Check
  6992.     #-------------------------------------------------------------------------
  6993.     def test_range?(data)
  6994.       # Create Copy
  6995.       copy = data.dup
  6996.       # Return false if no .. or ...
  6997.       return false unless copy.include?('..') or copy.include?('...')
  6998.       # Substitute .. or ... from data
  6999.       copy.sub!(/\.{2,3}/, '')
  7000.       # Return false if leftovers is not a int
  7001.       return false if not test_integer?(copy)
  7002.       # Return first and last characters are integers
  7003.       return test_integer?(data[0,1]) && test_integer?(data[-1,1])
  7004.     end
  7005.     #-------------------------------------------------------------------------
  7006.     # * Name      : Test Regexp
  7007.     #   Info      : Tests if Data is a regexp (first and last are /)
  7008.     #   Author    : Trickster
  7009.     #   Call Info : String data - data to Check
  7010.     #-------------------------------------------------------------------------
  7011.     def test_regexp?(data)
  7012.       return data[0, 1] == '/' && data[-1, 1] == '/'
  7013.     end
  7014.     #-------------------------------------------------------------------------
  7015.     # * Name      : Test Symbol
  7016.     #   Info      : Tests if Data is a symbol (first is :)
  7017.     #   Author    : Trickster
  7018.     #   Call Info : String data - data to Check
  7019.     #-------------------------------------------------------------------------
  7020.     def test_symbol?(data)
  7021.       return data[0, 1] == ':'
  7022.     end
  7023.     #-------------------------------------------------------------------------
  7024.     # * Name      : Test Class
  7025.     #   Info      : Tests if Data is a class (has .new)
  7026.     #   Author    : Trickster
  7027.     #   Call Info : String data - data to Check
  7028.     #-------------------------------------------------------------------------
  7029.     def test_class?(data)
  7030.       return data.include?('.new')
  7031.     end
  7032.     #-------------------------------------------------------------------------
  7033.     # * Name      : Test String
  7034.     #   Info      : Tests if Data is a string (first and last are ")
  7035.     #   Author    : Trickster
  7036.     #   Call Info : String data - data to Check
  7037.     #-------------------------------------------------------------------------
  7038.     def test_string?(data)
  7039.       return data[0] == 34 && data[-1] == 34
  7040.     end
  7041.     #-------------------------------------------------------------------------
  7042.     # * Name      : Eval Data
  7043.     #   Info      : calls eval on data and catches Syntax Errors
  7044.     #   Author    : Trickster
  7045.     #   Call Info : String data, extra - data to Check, error info
  7046.     #-------------------------------------------------------------------------
  7047.     def eval_data(data, extra = '')
  7048.       begin
  7049.         # Evaluate Data
  7050.         data = eval(data)
  7051.       rescue SyntaxError
  7052.         # If Syntax Error then print Error
  7053.         self.error_syntax(extra)
  7054.       end
  7055.     end
  7056.   end
  7057.   #-------------------------------------------------------------------------
  7058.   # * Name      : Load Data From Text file
  7059.   #   Info      : Loads data from a text file
  7060.   #               returns an array/hash with the data from text file
  7061.   #   Author    : Trickster
  7062.   #   Call Info : Two to Five Arguments
  7063.   #               String File_name, file name to load from
  7064.   #               Array Properties, Defining Values
  7065.   #               Array Required, An Array of Indexes that must be loaded
  7066.   #                 defaults to index 0
  7067.   #               Array Multilined, An Array of Indexes that read from multilines
  7068.   #                 defaults to nothing, note: for strings only
  7069.   #               Integer Elements, If 0 Elements are arrays (Default)
  7070.   #                                 If 1 Elements are hashes Key = id
  7071.   #                                 Else Elements are hashes Key = parameter
  7072.   #-------------------------------------------------------------------------
  7073.   def self.load_data_from_txt(file_name, properties, required = [0],
  7074.                               multi_lined = [], elements = 0)
  7075.     # Initialize local variables
  7076.     final_data = []
  7077.     data_txt = elements == 0 ? [] : {}
  7078.     index = 1
  7079.     # Load File
  7080.     file = Trickster::File_LoadRxdata.open(file_name)
  7081.     # Loop until End of File (EOF)
  7082.     until file.eof?
  7083.       # Get line data
  7084.       data = file.format_readline
  7085.       # Get Line
  7086.       line = file.line
  7087.       # Set Comment Flag if text is =begin
  7088.       @comment = true if data[0] == '=begin'
  7089.       # If text is =end
  7090.       if data[0] == '=end'
  7091.         # Unset Comment Flag
  7092.         @comment = false
  7093.         # Next
  7094.         next
  7095.       end
  7096.       # Next if no data or commented line
  7097.       next if data == [] or data[0].include?('#') or @comment
  7098.       # Get id from the properties
  7099.       id = properties.index(data[0])
  7100.       # If a new id
  7101.       if id == 0 and not data_txt.empty?
  7102.         # Check requirements and return error if not fulfilled
  7103.         file.requirements(data_txt, required, properties, [0,1].include?(elements))
  7104.         # Finished reading a piece of data
  7105.         final_data[index] = data_txt.dup
  7106.         # Increase index and reset data
  7107.         index += 1
  7108.         data_txt.clear
  7109.       elsif id == nil
  7110.         # Incorrent Defining name error message
  7111.         file.error_incorrect_name
  7112.       end
  7113.       # Remove defining name and join together
  7114.       data.delete_at(0)
  7115.       data = data.join(' ')
  7116.       # Get line number
  7117.       lineno = file.lineno
  7118.       # Start multi line information checking
  7119.       multi = 1
  7120.       if multi_lined.include?(id)
  7121.         # Load next line
  7122.         next_line = file.load_next_line
  7123.         # Get first data
  7124.         first = next_line.is_a?(Array) ? next_line[0] : ""
  7125.         # Reset flag
  7126.         flag = false
  7127.         # While an invalid property and the file is not eof? or data loaded
  7128.         while (properties.index(first) == nil and (next_line != false or next_line.is_a?(Array)))
  7129.           # While was excuted once
  7130.           flag = true
  7131.           position = file.pos
  7132.           # add to data if an array
  7133.           if next_line.is_a?(Array)
  7134.             # Get property data
  7135.             first = next_line[0]
  7136.             if properties.index(first) == nil
  7137.               data += ' ' + next_line.join(' ')
  7138.             end
  7139.           end
  7140.           # Load next line and reset first
  7141.           next_line = file.load_next_line
  7142.           first = ""
  7143.           # increase multi line count
  7144.           multi += 1
  7145.           # break if file.eof? continue if line was a comment
  7146.           break if next_line == false
  7147.           next if next_line == true
  7148.           first = next_line[0]
  7149.         end
  7150.         if flag
  7151.           file.pos = position
  7152.         end
  7153.         if next_line.is_a?(Array)
  7154.           if properties.index(first) == nil
  7155.             data += next_line.join(' ')
  7156.           end
  7157.         end
  7158.       end      
  7159.       data = file.test_type(data, line, lineno, multi)
  7160.       data_txt[id] = data if [0,1].include?(elements)
  7161.       data_txt[properties[id]] = data if not [0,1].include?(elements)
  7162.     end
  7163.     # Reached End of File Get last data if any
  7164.     if not data_txt.empty?
  7165.       # Check requirements and return error if not fulfilled
  7166.       file.requirements(data_txt, required, properties, [0,1].include?(elements))
  7167.       # Finished reading a piece of data
  7168.       final_data[index] = data_txt.dup
  7169.       # Increase index and reset data
  7170.       index += 1
  7171.       data_txt.clear
  7172.     end
  7173.     # Close File
  7174.     file.close
  7175.     # return all data compacted
  7176.     return final_data.compact
  7177.   end
  7178. end
  7179.  
  7180. #==============================================================================
  7181. # ** Systems.Pathfinding           By Near Fantastica (Edits By SephirothSpawn)
  7182. #------------------------------------------------------------------------------
  7183. # Description:
  7184. # ------------
  7185. # This system allows the player and events draw a path from one point to
  7186. # another in the shortest route possible.
  7187. #  
  7188. # Method List:
  7189. # ------------
  7190. #
  7191. #   Game_Character
  7192. #   ------
  7193. #   map
  7194. #   runpath
  7195. #   run_path
  7196. #   find_path
  7197. #   clear_path
  7198. #   setup_map
  7199. #  
  7200. #------------------------------------------------------------------------------
  7201. # * Syntax :
  7202. #
  7203. #   Make Player run path
  7204. #    - $game_player.run_path(x, y)
  7205. #
  7206. #   Make Event run path
  7207. #    - $game_map.events[event_id].run_path(x, y)
  7208. #==============================================================================
  7209.  
  7210. MACL::Loaded << 'Systems.Pathfinding'
  7211.  
  7212. #==============================================================================
  7213. # ** Game_Character
  7214. #==============================================================================
  7215.  
  7216. class Game_Character
  7217.   #--------------------------------------------------------------------------
  7218.   # * Public Instance Variables
  7219.   #--------------------------------------------------------------------------
  7220.   attr_accessor :map
  7221.   attr_accessor :runpath
  7222.   #--------------------------------------------------------------------------
  7223.   # * Alias Listings
  7224.   #--------------------------------------------------------------------------
  7225.   alias_method :nf_pathfinding_gmchr_init, :initialize
  7226.   alias_method :nf_pathfinding_gmchr_upda, :update
  7227.   #--------------------------------------------------------------------------
  7228.   # * Object Initialization
  7229.   #--------------------------------------------------------------------------
  7230.   def initialize
  7231.     # Clear Path
  7232.     clear_path
  7233.     # Original Initialization
  7234.     nf_pathfinding_gmchr_init
  7235.   end
  7236.   #--------------------------------------------------------------------------
  7237.   # * Frame Update
  7238.   #--------------------------------------------------------------------------
  7239.   def update
  7240.     # Run Pathfind if Runpath
  7241.     run_path if @runpath
  7242.     # Original Update
  7243.     nf_pathfinding_gmchr_upda
  7244.   end
  7245.   #--------------------------------------------------------------------------
  7246.   # * Frame Update : Run Pathfinding
  7247.   #--------------------------------------------------------------------------
  7248.   def run_path
  7249.     # Return If Moving
  7250.     return if self.moving?
  7251.     # Gets Current Step
  7252.     step = @map[@x, @y]
  7253.     # If No More Stes
  7254.     if step == 1
  7255.       # Clear Pathfinding Flags
  7256.       clear_path
  7257.       return
  7258.     end
  7259.     # If Random Direction Patterns is 0
  7260.     if rand(2) == 0
  7261.       move_right  if @map[@x + 1, @y] == step - 1 && step != 0
  7262.       move_down   if @map[@x, @y + 1] == step - 1 && step != 0
  7263.       move_left   if @map[@x - 1, @y] == step - 1 && step != 0
  7264.       move_up     if @map[@x, @y - 1] == step - 1 && step != 0
  7265.     else
  7266.       move_up     if @map[@x, @y - 1] == step - 1 && step != 0
  7267.       move_left   if @map[@x - 1, @y] == step - 1 && step != 0
  7268.       move_down   if @map[@x, @y + 1] == step - 1 && step != 0
  7269.       move_right  if @map[@x + 1, @y] == step - 1 && step != 0
  7270.     end
  7271.   end
  7272.   #--------------------------------------------------------------------------
  7273.   # * Find Pathing
  7274.   #--------------------------------------------------------------------------
  7275.   def find_path(x,y)
  7276.     # Gets Result
  7277.     result = setup_map(@x, @y, x, y)
  7278.     # Sets Pathfinding Flags
  7279.     @runpath     = result[0]
  7280.     @map         = result[1]
  7281.     @map[sx, sy] = result[2] if result[2] != nil
  7282.   end
  7283.   #--------------------------------------------------------------------------
  7284.   # * Clear Pathing
  7285.   #--------------------------------------------------------------------------
  7286.   def clear_path
  7287.     @map = nil
  7288.     @runpath = false
  7289.   end
  7290.   #--------------------------------------------------------------------------
  7291.   # * Setup Map
  7292.   #--------------------------------------------------------------------------
  7293.   def setup_map(sx, sy, ex, ey)
  7294.     # Creates Map
  7295.     map = Table.new($game_map.width, $game_map.height)
  7296.     # Starts Step Counters
  7297.     map[ex,ey] = 1
  7298.     # Creates New and Old Positions
  7299.     old_positions = []
  7300.     new_positions = []
  7301.     old_positions.push([ex, ey])
  7302.     # Starts Creating New Nodes
  7303.     2.upto(100) do |step|
  7304.       loop do
  7305.         # Break If No old Positins
  7306.         break if old_positions[0].nil?
  7307.         # Gets First Position
  7308.         x, y = old_positions.shift
  7309.         # Return if Finished
  7310.         return [true, map, step] if (x == sx and y + 1 == sy) &&
  7311.                                     (x == sx and y - 1 == sy) &&
  7312.                                     (x - 1 == sx and y == sy) &&
  7313.                                     (x + 1 == sx and y == sy)
  7314.         # Add Position if Down Passable
  7315.         if $game_player.passable?(x, y, 2) and map[x, y + 1] == 0
  7316.           map[x, y + 1] = step
  7317.           new_positions.push([x, y + 1])
  7318.         end
  7319.         # Add Position if Left Passable
  7320.         if $game_player.passable?(x, y, 4) and map[x - 1, y] == 0
  7321.           map[x - 1,y] = step
  7322.           new_positions.push([x - 1, y])
  7323.         end
  7324.         # Add Position if Right Passable
  7325.         if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
  7326.           map[x + 1,y] = step
  7327.           new_positions.push([x + 1,y])
  7328.         end
  7329.         # Add Position if Up Passable
  7330.         if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
  7331.           map[x, y - 1] = step
  7332.           new_positions.push([x, y - 1])
  7333.         end
  7334.       end
  7335.       # Changes Positions
  7336.       old_positions = new_positions
  7337.       new_positions = []
  7338.     end
  7339.     # Return If Path Not Found
  7340.     return [false, nil, nil]
  7341.   end
  7342. end
  7343.  
  7344. #==============================================================================
  7345. # ** Game_Map
  7346. #==============================================================================
  7347.  
  7348. class Game_Map
  7349.   #--------------------------------------------------------------------------
  7350.   # * Alias Listings
  7351.   #--------------------------------------------------------------------------
  7352.   alias_method :nf_pathfinding_gmmap_setup, :setup
  7353.   #--------------------------------------------------------------------------
  7354.   def setup(map_id)
  7355.     # Orignal Setup
  7356.     nf_pathfinding_gmmap_setup(map_id)
  7357.     # Clear Player Path
  7358.     $game_player.clear_path
  7359.   end
  7360. end
  7361.  
  7362. #==============================================================================
  7363. # ** Game_Player
  7364. #==============================================================================
  7365.  
  7366. class Game_Player
  7367.   #--------------------------------------------------------------------------
  7368.   # * Alias Listings
  7369.   #--------------------------------------------------------------------------
  7370.   alias_method :nf_pathfinding_gmplyr_update, :update
  7371.   #--------------------------------------------------------------------------
  7372.   # * Frame Update
  7373.   #--------------------------------------------------------------------------
  7374.   def update
  7375.     # Clear Path if Direciton Pressed
  7376.     $game_player.clear_path if Input.dir4 != 0
  7377.     # Original Update
  7378.     nf_pathfinding_gmplyr_update
  7379.   end
  7380. end
  7381.  
  7382. #==============================================================================
  7383. # ** Systems.Quick Animations (3.01)                          By SephirothSpawn
  7384. #------------------------------------------------------------------------------
  7385. # * Description :
  7386. #
  7387. #   This script was designed to act as a GIF animation player. Because GIF
  7388. #   images aren't actually able to play in RMXP (without API), this script
  7389. #   either uses a series of images in a directory numbered OR an animation
  7390. #   like image with multiple frames placed side by side.
  7391. #------------------------------------------------------------------------------
  7392. # * Instructions :
  7393. #
  7394. #   * Creating Animated Sprite
  7395. #
  7396. #     object = Sprite_Animation.new({<parameters>})
  7397. #
  7398. #   * Creating Animated Plane
  7399. #
  7400. #     object = Plane_Animation.new({<parameters>})
  7401. #
  7402. #   * Parameters
  7403. #
  7404. #     'type'   => 'A' or 'B'
  7405. #       - Type of Animation (A : Directory of images, B : Spriteset)
  7406. #     'loop'   => true or false
  7407. #       - loop (true : loops, false : plays then disposes)
  7408. #     'fs'     => n
  7409. #       - frameskip (number of frames to go to next frame)
  7410. #     'vp'     => Viewport
  7411. #       - viewport (sprite viewport)
  7412. #
  7413. #     Required For Type A
  7414. #     'dir'    => 'Graphics/...'
  7415. #       - directory of images
  7416. #
  7417. #     Required For Type B
  7418. #     'frames' => n
  7419. #       - number of frames on spriteset
  7420. #     'bitmap' => 'filename'
  7421. #       - filename in pictures folder
  7422. #------------------------------------------------------------------------------
  7423. # * Credits :
  7424. #
  7425. #   Thanks Trickster for Animation Type 2 Suggestion
  7426. #==============================================================================
  7427.  
  7428. MACL::Loaded << 'Systems.Quick Animations'
  7429.  
  7430. #==============================================================================
  7431. # ** Sprite_Animation
  7432. #==============================================================================
  7433.  
  7434. class Sprite_Animation < Sprite
  7435.   #--------------------------------------------------------------------------
  7436.   # * Object Initialization
  7437.   #--------------------------------------------------------------------------
  7438.   def initialize(parameters = {})
  7439.     # Assigns Defaults (If Non-Defined)
  7440.     @type = parameters.has_key?('type')     ? parameters['type']   : 'A'
  7441.     @loop = parameters.has_key?('loop')     ? parameters['loop']   : true
  7442.     @frameskip = parameters.has_key?('fs')  ? parameters['fs']     : 10
  7443.     @dir = parameters.has_key?('dir')       ? parameters['dir']    : nil
  7444.     @frames = parameters.has_key?('frames') ? parameters['frames'] : 1
  7445.     viewport = parameters.has_key?('vp')    ? parameters['vp']     : nil
  7446.     bitmap = parameters.has_key?('bitmap')  ? parameters['bitmap'] : ''
  7447.     # Creates Viewport
  7448.     super(viewport)
  7449.     # Sets Index
  7450.     @index = -1
  7451.     # Sets Specialized Parameters
  7452.     if @type.upcase == 'B'
  7453.       # Sets Frame Number & Sets Bitmap
  7454.       self.bitmap = RPG::Cache.picture(bitmap)
  7455.     end
  7456.     # Update
  7457.     update
  7458.   end
  7459.   #--------------------------------------------------------------------------
  7460.   # * Frame Update
  7461.   #--------------------------------------------------------------------------
  7462.   def update
  7463.     super
  7464.     # Stop Unless Proceed Frame
  7465.     return unless Graphics.frame_count % @frameskip == 0
  7466.     # Increase Index
  7467.     @index += 1
  7468.     # Branch By Type
  7469.     if @type.upcase == 'A'
  7470.       # Update Type A
  7471.       update_type_a
  7472.     elsif @type.upcase == 'B'
  7473.       # Update Type B
  7474.       update_type_b
  7475.     end
  7476.   end
  7477.   #--------------------------------------------------------------------------
  7478.   # * Frame Update : Type A
  7479.   #--------------------------------------------------------------------------
  7480.   def update_type_a
  7481.     # Begin
  7482.     begin
  7483.       # Load Bitmap
  7484.       self.bitmap = RPG::Cache.load_bitmap(@dir, @index.to_s)
  7485.     # If Bitmap Cannot Be Found
  7486.     rescue
  7487.       # If Looping
  7488.       if @loop
  7489.         # Reset Index
  7490.         @index = - 1
  7491.         update
  7492.       else
  7493.         # Dispose Image
  7494.         self.dispose
  7495.       end
  7496.     end
  7497.   end
  7498.   #--------------------------------------------------------------------------
  7499.   # * Frame Update : Type B
  7500.   #--------------------------------------------------------------------------
  7501.   def update_type_b
  7502.     # If Passed Last Frame
  7503.     if @index == @frames
  7504.       # If Loop Image
  7505.       if @loop
  7506.         # Reset Index & Update Bitmap
  7507.         @index = -1
  7508.         update
  7509.       # If No Loop
  7510.       else
  7511.         # Delete Image
  7512.         self.dispose
  7513.         return
  7514.       end
  7515.     end
  7516.     # Updates Src Rect
  7517.     x = (w = self.bitmap.width / @frames) * @index
  7518.     self.src_rect.set(x, 0, w, self.bitmap.height)
  7519.   end
  7520. end
  7521.  
  7522. #==============================================================================
  7523. # ** Plane_Animation
  7524. #==============================================================================
  7525.  
  7526. class Plane_Animation < Plane
  7527.   #--------------------------------------------------------------------------
  7528.   # * Object Initialization
  7529.   #--------------------------------------------------------------------------
  7530.   def initialize(parameters = {})
  7531.     # Assigns Defaults (If Non-Defined)
  7532.     @type = parameters.has_key?('type')     ? parameters['type']   : 'A'
  7533.     @loop = parameters.has_key?('loop')     ? parameters['loop']   : true
  7534.     @frameskip = parameters.has_key?('fs')  ? parameters['fs']     : 10
  7535.     @dir = parameters.has_key?('dir')       ? parameters['dir']    : nil
  7536.     @frames = parameters.has_key?('frames') ? parameters['frames'] : 1
  7537.     viewport = parameters.has_key?('vp')    ? parameters['vp']     : nil
  7538.     bitmap = parameters.has_key?('bitmap')  ? parameters['bitmap'] : ''
  7539.     # Creates Viewport
  7540.     super(viewport)
  7541.     # Sets Index
  7542.     @index = -1
  7543.     # Sets Specialized Parameters
  7544.     if @type.upcase == 'B'
  7545.       # Sets Frame Number & Sets Bitmap
  7546.       @_bitmap = RPG::Cache.picture(bitmap)
  7547.     end
  7548.     # Update
  7549.     update
  7550.   end
  7551.   #--------------------------------------------------------------------------
  7552.   # * Frame Update
  7553.   #--------------------------------------------------------------------------
  7554.   def update
  7555.     # Stop Unless Proceed Frame
  7556.     return unless Graphics.frame_count % @frameskip == 0
  7557.     # Increase Index
  7558.     @index += 1
  7559.     # Branch By Type
  7560.     if @type.upcase == 'A'
  7561.       # Update Type A
  7562.       update_type_a
  7563.     elsif @type.upcase == 'B'
  7564.       # Update Type B
  7565.       update_type_b
  7566.     end
  7567.   end
  7568.   #--------------------------------------------------------------------------
  7569.   # * Frame Update : Type A
  7570.   #--------------------------------------------------------------------------
  7571.   def update_type_a
  7572.     # Begin
  7573.     begin
  7574.       # Load Bitmap
  7575.       self.bitmap = RPG::Cache.load_bitmap(@dir, @index.to_s)
  7576.     # If Bitmap Cannot Be Found
  7577.     rescue
  7578.       # If Looping
  7579.       if @loop
  7580.         # Reset Index
  7581.         @index = - 1
  7582.         update
  7583.       else
  7584.         # Dispose Image
  7585.         self.dispose
  7586.       end
  7587.     end
  7588.   end
  7589.   #--------------------------------------------------------------------------
  7590.   # * Frame Update : Type B
  7591.   #--------------------------------------------------------------------------
  7592.   def update_type_b
  7593.     # If Passed Last Frame
  7594.     if @index == @frames
  7595.       # If Loop Image
  7596.       if @loop
  7597.         # Reset Index & Update Bitmap
  7598.         @index = -1
  7599.         update
  7600.       # If No Loop
  7601.       else
  7602.         # Delete Image
  7603.         self.dispose
  7604.         return
  7605.       end
  7606.     end
  7607.     # Updates Bitmap
  7608.     b = Bitmap.new((w = @_bitmap.width) / @frames, (h = @_bitmap.height))
  7609.     b.blt(0, 0, @_bitmap, Rect.new(w / @frames * @index, 0, b.width, h))
  7610.     self.bitmap = b
  7611.   end
  7612. end
  7613.  
  7614. #==============================================================================
  7615. # ** Systems.Scrolling Sprites                                    By: Trickster
  7616. #------------------------------------------------------------------------------
  7617. # Description:
  7618. # ------------
  7619. # Classes Associated with Scrolling Sprites
  7620. #  
  7621. # Class List:
  7622. # ------------
  7623. # Scroll_Sprite
  7624. # Sprite_Scrollable
  7625. #==============================================================================
  7626.  
  7627. MACL::Loaded << 'Systems.Scrolling Sprites'
  7628.  
  7629. #==============================================================================
  7630. # ** Scroll_Sprite                                                By: Trickster
  7631. #------------------------------------------------------------------------------
  7632. #  Custom Sprite Class That Has Scroll Functions
  7633. #==============================================================================
  7634.  
  7635. class Scroll_Sprite < Sprite
  7636.   #-------------------------------------------------------------------------
  7637.   #   Name      : Initialize
  7638.   #   Info      : Object Initialization
  7639.   #   Author    : Trickster
  7640.   #   Call Info : Four to Five Arguments
  7641.   #               Integer X and Y, define position
  7642.   #               Integer Width and Height, define width and height of the sprite
  7643.   #               Viewport viewport viewport to be used defaults to whole screen
  7644.   #-------------------------------------------------------------------------
  7645.   def initialize(x, y, width, height, viewport = nil)
  7646.     super(viewport)
  7647.     self.x = x
  7648.     self.y = y
  7649.     self.width = width
  7650.     self.height = height
  7651.   end
  7652.   #-------------------------------------------------------------------------
  7653.   #   Name      : Set Source X
  7654.   #   Info      : Sets Source X of Display
  7655.   #   Author    : Trickster
  7656.   #   Call Info : One Argument, Integer ox Offset X Starting Point
  7657.   #-------------------------------------------------------------------------
  7658.   def sx=(ox)
  7659.     src_rect.x = ox
  7660.   end
  7661.   #-------------------------------------------------------------------------
  7662.   #   Name      : Set Source Y
  7663.   #   Info      : Sets Source Y of Display
  7664.   #   Author    : Trickster
  7665.   #   Call Info : One Argument, Integer oy Offset Y Starting Point
  7666.   #-------------------------------------------------------------------------
  7667.   def sy=(oy)
  7668.     src_rect.y = oy
  7669.   end
  7670.   #-------------------------------------------------------------------------
  7671.   #   Name      : Set Source Width
  7672.   #   Info      : Sets Source Width of Display
  7673.   #   Author    : Trickster
  7674.   #   Call Info : One Argument, Integer width The Sprite's Width
  7675.   #-------------------------------------------------------------------------
  7676.   def width=(width)
  7677.     src_rect.width = width
  7678.     @width = width
  7679.   end
  7680.   #-------------------------------------------------------------------------
  7681.   #   Name      : Set Source Height
  7682.   #   Info      : Sets Source Height of Display
  7683.   #   Author    : Trickster
  7684.   #   Call Info : One Argument, Integer height The Sprite's Height
  7685.   #-------------------------------------------------------------------------
  7686.   def height=(height)
  7687.     src_rect.height = height
  7688.     @height = height
  7689.   end
  7690.   #-------------------------------------------------------------------------
  7691.   # * Name      : Get Source X
  7692.   #   Info      : Gets Source X of Display
  7693.   #   Author    : Trickster
  7694.   #   Call Info : No Arguments
  7695.   #-------------------------------------------------------------------------
  7696.   def sx
  7697.     return src_rect.x
  7698.   end
  7699.   #-------------------------------------------------------------------------
  7700.   # * Name      : Get Source Y
  7701.   #   Info      : Gets Source Y of Display
  7702.   #   Author    : Trickster
  7703.   #   Call Info : No Arguments
  7704.   #-------------------------------------------------------------------------
  7705.   def sy
  7706.     return src_rect.y
  7707.   end
  7708.   #-------------------------------------------------------------------------
  7709.   # * Name      : Get Source Width
  7710.   #   Info      : Gets Source Width of Display
  7711.   #   Author    : Trickster
  7712.   #   Call Info : No Arguments
  7713.   #-------------------------------------------------------------------------
  7714.   def width
  7715.     return src_rect.width
  7716.   end
  7717.   #-------------------------------------------------------------------------
  7718.   # * Name      : Get Source Height
  7719.   #   Info      : Gets Source Height of Display
  7720.   #   Author    : Trickster
  7721.   #   Call Info : No Arguments
  7722.   #-------------------------------------------------------------------------
  7723.   def height
  7724.     return src_rect.height
  7725.   end
  7726.   #-------------------------------------------------------------------------
  7727.   # * Name      : Set Bitmap
  7728.   #   Info      : Sets the Sprite's Bitmap
  7729.   #   Author    : Trickster
  7730.   #   Call Info : One Argument, Bitmap bitmap the bitmap to be loaded
  7731.   #-------------------------------------------------------------------------
  7732.   def bitmap=(bitmap)
  7733.     super(bitmap)
  7734.     src_rect.width = @width
  7735.     src_rect.height = @height
  7736.   end
  7737. end
  7738.  
  7739. #==============================================================================
  7740. # ** Sprite_Scrollable                                           By: Trickster
  7741. #------------------------------------------------------------------------------
  7742. #  This sprite class contains scroll functions.  Inherits from Scroll Sprite.
  7743. #  for a practical example of how to use see, Window Scrollable and
  7744. #  my Advanced Mission script
  7745. #==============================================================================
  7746. class Sprite_Scrollable < Scroll_Sprite
  7747.   #-------------------------------------------------------------------------
  7748.   # * Public Instance Variables
  7749.   #-------------------------------------------------------------------------
  7750.   attr_accessor :speed
  7751.   attr_accessor :bitmap_rect
  7752.   attr_writer   :horizontal_scroll
  7753.   attr_writer   :vertical_scroll
  7754.   #-------------------------------------------------------------------------
  7755.   # * Name      : Initialize
  7756.   #   Info      : Object Initialization
  7757.   #   Author    : Trickster
  7758.   #   Call Info : Four Arguments
  7759.   #              Integer X and Y define position
  7760.   #              Integer Width and Height defines the Source Width and Height
  7761.   #-------------------------------------------------------------------------
  7762.   def initialize(x, y, width, height)
  7763.     super(x,y,width,height)
  7764.     @bitmap_rect = Rect.new(0,0,width,height)
  7765.     @speed = 0
  7766.     @horizontal_scroll = false
  7767.     @vertical_scroll = false
  7768.   end
  7769.   #-------------------------------------------------------------------------
  7770.   # * Name      : Normal Text Color
  7771.   #   Info      : The Normal Text Color - (255,255,255,255)
  7772.   #   Author    : Trickster
  7773.   #   Call Info : No Arguments
  7774.   #-------------------------------------------------------------------------
  7775.   def normal_color
  7776.     return Color.new(255, 255, 255, 255)
  7777.   end
  7778.   #-------------------------------------------------------------------------
  7779.   # * Name      : Disabled Text Color
  7780.   #   Info      : The Disable Text Color-  (255,255,255,128)
  7781.   #   Author    : Trickster
  7782.   #   Call Info : No Arguments
  7783.   #-------------------------------------------------------------------------
  7784.   def disabled_color
  7785.     return Color.new(255, 255, 255, 128)
  7786.   end
  7787.   #-------------------------------------------------------------------------
  7788.   # * Name      : System Text Color
  7789.   #   Info      : The System Text Color (192,224,255,255)
  7790.   #   Author    :  Trickster
  7791.   #   Call Info : No Arguments
  7792.   #-------------------------------------------------------------------------
  7793.   def system_color
  7794.     return Color.new(192, 224, 255, 255)
  7795.   end
  7796.   #-------------------------------------------------------------------------
  7797.   # * Name      : Vertical?
  7798.   #   Info      : Can sprite be scrolled vertically?
  7799.   #   Author    : Trickster
  7800.   #   Call Info : No Arguments
  7801.   #-------------------------------------------------------------------------
  7802.   def vertical?
  7803.     return false if self.bitmap == nil
  7804.     return self.bitmap.height > self.height
  7805.   end
  7806.   #-------------------------------------------------------------------------
  7807.   # * Name      : Horizontal?
  7808.   #   Info      : Can sprite be scrolled horizontally?
  7809.   #   Author    :  Trickster
  7810.   #   Call Info : No Arguments
  7811.   #-------------------------------------------------------------------------
  7812.   def horizontal?
  7813.     return false if self.bitmap == nil
  7814.     return self.bitmap.width > self.width
  7815.   end
  7816.   #-------------------------------------------------------------------------
  7817.   # * Name      : Update
  7818.   #   Info      : Frame Update
  7819.   #   Author    : Trickster
  7820.   #   Call Info : No Arguments
  7821.   #   Comment   : Allows the Sprite To Scroll with direction keys
  7822.   #               if scrolling is enabled
  7823.   #-------------------------------------------------------------------------
  7824.   def update
  7825.     super
  7826.     if Input.repeat?(Input::UP)
  7827.       if self.sy > @bitmap_rect.y and @vertical_scroll and vertical?
  7828.         self.sy = [self.sy - speed, @bitmap_rect.y].max
  7829.       end
  7830.     end
  7831.     if Input.repeat?(Input::LEFT)
  7832.       if self.sx > @bitmap_rect.x and @horizontal_scroll and horizontal?
  7833.         self.sx = [self.sx - speed, @bitmap_rect.x].max
  7834.       end
  7835.     end
  7836.     if Input.repeat?(Input::DOWN)
  7837.       if self.sy < @bitmap_rect.height - self.height and @vertical_scroll and vertical?
  7838.         self.sy = [self.sy + speed, @bitmap_rect.height].min
  7839.       end
  7840.     end
  7841.     if Input.repeat?(Input::RIGHT)
  7842.       if self.sx < @bitmap_rect.width - self.width and @horizontal_scroll and horizontal?
  7843.         self.sx = [self.sx - speed, @bitmap_rect.width].min
  7844.       end
  7845.     end
  7846.   end
  7847. end
  7848.  
  7849. #==============================================================================
  7850. # ** Stat Bonus Base
  7851. #------------------------------------------------------------------------------
  7852. # SephirothSpawn
  7853. # Version 1
  7854. # 2007-01-26
  7855. #------------------------------------------------------------------------------
  7856. # * Version History :
  7857. #
  7858. #   Version 1 ---------------------------------------------------- (2007-01-26)
  7859. #------------------------------------------------------------------------------
  7860. # * Description :
  7861. #
  7862. #   This script was designed to create methods for adding direct and percent
  7863. #   modifications to the actors stats. This is a tool for scripters. The basic
  7864. #   stat formula is as follows :
  7865. #
  7866. #   stat = (base_stat + direct_mod) * percent mod
  7867. #------------------------------------------------------------------------------
  7868. # * Instructions :
  7869. #
  7870. #   Place The Script Below the SDK and Above Main.
  7871. #   To learn to use the system, refer to syntax.
  7872. #------------------------------------------------------------------------------
  7873. # * Syntax :
  7874. #
  7875. #   The following stats can recieve a bonus :
  7876. #    - maxhp, maxsp, str, dex, agi, int, atk, mdef, pdef, eva, hit
  7877. #
  7878. #   Basic Outline to using methods :
  7879. #
  7880. #    alias_method :<yourname>_<scriptname>_statmod_<statname>, :<statmethod>
  7881. #    def <statmethod>
  7882. #      n = <yourname>_<scriptname>_statmod_<statname>
  7883. #      n += (your formula for adding bonuses here)
  7884. #      return n
  7885. #    end
  7886. #
  7887. #   Direct Bonus Methods :
  7888. #    - direct_maxhp_bonus  - direct_str_bonus   - direct_agi_bonus
  7889. #    - direct_maxsp_bonus  - direct_dex_bonus   - direct_int_bonus
  7890. #    - direct_atk_bonus    - direct_pdef_bonus  - direct_mdef_bonus
  7891. #    - direct_eva_bonus    - direct_hit_bonus
  7892. #
  7893. #   Percent Bonus Methds :
  7894. #    - percent_maxhp_bonus  - percent_str_bonus   - percent_agi_bonus
  7895. #    - percent_maxsp_bonus  - percent_dex_bonus   - percent_int_bonus
  7896. #    - percent_atk_bonus    - percent_pdef_bonus  - percent_mdef_bonus
  7897. #    - percent_eva_bonus    - percent_hit_bonus
  7898. #
  7899. #   All methods are located in Game_Actor & Game_Enemy
  7900. #
  7901. #   ** Example : Adding 5 Points to maxhp for actor 5
  7902. #
  7903. #   class Game_Actor < Game_Battler
  7904. #     alias_method :seph_example_statmod_dhpb, :direct_maxhp_bonus
  7905. #     def direct_maxhp_bonus
  7906. #       n = seph_example_statmod_dhpb
  7907. #       n += 5 if @actor_id == 5
  7908. #       return n
  7909. #     end
  7910. #   end
  7911. #==============================================================================
  7912.  
  7913. MACL::Loaded << 'Systems.Stat Bonus Base'
  7914.  
  7915. #==============================================================================
  7916. # ** Game_Actor
  7917. #==============================================================================
  7918.  
  7919. class Game_Actor
  7920.   #--------------------------------------------------------------------------
  7921.   # * Alias Listings
  7922.   #--------------------------------------------------------------------------
  7923.   alias_method :seph_statbonusbase_bmaxhp, :base_maxhp
  7924.   alias_method :seph_statbonusbase_bmaxsp, :base_maxsp
  7925.   alias_method :seph_statbonusbase_bstr,   :base_str
  7926.   alias_method :seph_statbonusbase_bdex,   :base_dex
  7927.   alias_method :seph_statbonusbase_bagi,   :base_agi
  7928.   alias_method :seph_statbonusbase_bint,   :base_int
  7929.   alias_method :seph_statbonusbase_batk,   :base_atk
  7930.   alias_method :seph_statbonusbase_bpdef,  :base_pdef
  7931.   alias_method :seph_statbonusbase_bmdef,  :base_mdef
  7932.   alias_method :seph_statbonusbase_beva,   :base_eva
  7933.   alias_method :seph_statbonusbase_hit,    :hit
  7934.   #--------------------------------------------------------------------------
  7935.   # * Get Maximum HP
  7936.   #--------------------------------------------------------------------------
  7937.   def base_maxhp
  7938.     # Gets Orginal Value
  7939.     n = seph_statbonusbase_bmaxhp
  7940.     # Adds Direct Stat Bonus
  7941.     n += direct_maxhp_bonus
  7942.     # Adds Percent Stat Bonus
  7943.     n *= (percent_maxhp_bonus + 100) / 100.0
  7944.     # Returns Stat
  7945.     return n
  7946.   end
  7947.   def direct_maxhp_bonus  ; return 0 ; end
  7948.   def percent_maxhp_bonus ; return 0 ; end
  7949.   #--------------------------------------------------------------------------
  7950.   # * Get Maximum SP
  7951.   #--------------------------------------------------------------------------
  7952.   def base_maxsp
  7953.     # Gets Orginal Value
  7954.     n = seph_statbonusbase_bmaxsp
  7955.     # Adds Direct Stat Bonus
  7956.     n += direct_maxsp_bonus
  7957.     # Adds Percent Stat Bonus
  7958.     n *= (percent_maxsp_bonus + 100) / 100.0
  7959.     # Returns Stat
  7960.     return n
  7961.   end
  7962.   def direct_maxsp_bonus  ; return 0 ; end
  7963.   def percent_maxsp_bonus ; return 0 ; end
  7964.   #--------------------------------------------------------------------------
  7965.   # * Get Strength
  7966.   #--------------------------------------------------------------------------
  7967.   def base_str
  7968.     # Gets Orginal Value
  7969.     n = seph_statbonusbase_bstr
  7970.     # Adds Direct Stat Bonus
  7971.     n += direct_str_bonus
  7972.     # Adds Percent Stat Bonus
  7973.     n *= (percent_str_bonus + 100) / 100.0
  7974.     # Returns Stat
  7975.     return n
  7976.   end
  7977.   def direct_str_bonus  ; return 0 ; end
  7978.   def percent_str_bonus ; return 0 ; end
  7979.   #--------------------------------------------------------------------------
  7980.   # * Get Dexterity
  7981.   #--------------------------------------------------------------------------
  7982.   def base_dex
  7983.     # Gets Orginal Value
  7984.     n = seph_statbonusbase_bdex
  7985.     # Adds Direct Stat Bonus
  7986.     n += direct_dex_bonus
  7987.     # Adds Percent Stat Bonus
  7988.     n *= (percent_dex_bonus + 100) / 100.0
  7989.     # Returns Stat
  7990.     return n
  7991.   end
  7992.   def direct_dex_bonus  ; return 0 ; end
  7993.   def percent_dex_bonus ; return 0 ; end
  7994.   #--------------------------------------------------------------------------
  7995.   # * Get Basic Agility
  7996.   #--------------------------------------------------------------------------
  7997.   def base_agi
  7998.     # Gets Orginal Value
  7999.     n = seph_statbonusbase_bagi
  8000.     # Adds Direct Stat Bonus
  8001.     n += direct_agi_bonus
  8002.     # Adds Percent Stat Bonus
  8003.     n *= (percent_agi_bonus + 100) / 100.0
  8004.     # Returns Stat
  8005.     return n
  8006.   end
  8007.   def direct_agi_bonus  ; return 0 ; end
  8008.   def percent_agi_bonus ; return 0 ; end
  8009.   #--------------------------------------------------------------------------
  8010.   # * Get Basic Intelligence
  8011.   #--------------------------------------------------------------------------
  8012.   def base_int
  8013.     # Gets Orginal Value
  8014.     n = seph_statbonusbase_bint
  8015.     # Adds Direct Stat Bonus
  8016.     n += direct_int_bonus
  8017.     # Adds Percent Stat Bonus
  8018.     n *= (percent_int_bonus + 100) / 100.0
  8019.     # Returns Stat
  8020.     return n
  8021.   end
  8022.   def direct_int_bonus  ; return 0 ; end
  8023.   def percent_int_bonus ; return 0 ; end
  8024.   #--------------------------------------------------------------------------
  8025.   # * Get Basic Attack Power
  8026.   #--------------------------------------------------------------------------
  8027.   def base_atk
  8028.     # Gets Orginal Value
  8029.     n = seph_statbonusbase_batk
  8030.     # Adds Direct Stat Bonus
  8031.     n += direct_atk_bonus
  8032.     # Adds Percent Stat Bonus
  8033.     n *= (percent_atk_bonus + 100) / 100.0
  8034.     # Returns Stat
  8035.     return n
  8036.   end
  8037.   def direct_atk_bonus  ; return 0 ; end
  8038.   def percent_atk_bonus ; return 0 ; end
  8039.   #--------------------------------------------------------------------------
  8040.   # * Get Basic Physical Defense
  8041.   #--------------------------------------------------------------------------
  8042.   def base_pdef
  8043.     # Gets Orginal Value
  8044.     n = seph_statbonusbase_bpdef
  8045.     # Adds Direct Stat Bonus
  8046.     n += direct_pdef_bonus
  8047.     # Adds Percent Stat Bonus
  8048.     n *= (percent_pdef_bonus + 100) / 100.0
  8049.     # Returns Stat
  8050.     return n
  8051.   end
  8052.   def direct_pdef_bonus  ; return 0 ; end
  8053.   def percent_pdef_bonus ; return 0 ; end
  8054.   #--------------------------------------------------------------------------
  8055.   # * Get Basic Magic Defense
  8056.   #--------------------------------------------------------------------------
  8057.   def base_mdef
  8058.     # Gets Orginal Value
  8059.     n = seph_statbonusbase_bmdef
  8060.     # Adds Direct Stat Bonus
  8061.     n += direct_mdef_bonus
  8062.     # Adds Percent Stat Bonus
  8063.     n *= (percent_mdef_bonus + 100) / 100.0
  8064.     # Returns Stat
  8065.     return n
  8066.   end
  8067.   def direct_mdef_bonus  ; return 0 ; end
  8068.   def percent_mdef_bonus ; return 0 ; end
  8069.   #--------------------------------------------------------------------------
  8070.   # * Get Basic Evasion Correction
  8071.   #--------------------------------------------------------------------------
  8072.   def base_eva
  8073.     # Gets Orginal Value
  8074.     n = seph_statbonusbase_beva
  8075.     # Adds Direct Stat Bonus
  8076.     n += direct_eva_bonus
  8077.     # Adds Percent Stat Bonus
  8078.     n *= (percent_eva_bonus + 100) / 100.0
  8079.     # Returns Stat
  8080.     return n
  8081.   end
  8082.   def direct_eva_bonus  ; return 0 ; end
  8083.   def percent_eva_bonus ; return 0 ; end
  8084.   #--------------------------------------------------------------------------
  8085.   # * Get Hit
  8086.   #--------------------------------------------------------------------------
  8087.   def hit
  8088.     # Gets Orginal Value
  8089.     n = seph_statbonusbase_hit
  8090.     # Adds Direct Stat Bonus
  8091.     n += direct_hit_bonus
  8092.     # Adds Percent Stat Bonus
  8093.     n *= (percent_hit_bonus + 100) / 100.0
  8094.     # Returns Stat
  8095.     return n
  8096.   end
  8097.   def direct_hit_bonus  ; return 0 ; end
  8098.   def percent_hit_bonus ; return 0 ; end
  8099. end
  8100.  
  8101. #==============================================================================
  8102. # ** Game_Enemy
  8103. #==============================================================================
  8104.  
  8105. class Game_Enemy
  8106.   #--------------------------------------------------------------------------
  8107.   # * Alias Listings
  8108.   #--------------------------------------------------------------------------
  8109.   alias_method :seph_statbonusbase_bmaxhp, :base_maxhp
  8110.   alias_method :seph_statbonusbase_bmaxsp, :base_maxsp
  8111.   alias_method :seph_statbonusbase_bstr,   :base_str
  8112.   alias_method :seph_statbonusbase_bdex,   :base_dex
  8113.   alias_method :seph_statbonusbase_bagi,   :base_agi
  8114.   alias_method :seph_statbonusbase_bint,   :base_int
  8115.   alias_method :seph_statbonusbase_batk,   :base_atk
  8116.   alias_method :seph_statbonusbase_bpdef,  :base_pdef
  8117.   alias_method :seph_statbonusbase_bmdef,  :base_mdef
  8118.   alias_method :seph_statbonusbase_beva,   :base_eva
  8119.   alias_method :seph_statbonusbase_hit,    :hit
  8120.   #--------------------------------------------------------------------------
  8121.   # * Get Maximum HP
  8122.   #--------------------------------------------------------------------------
  8123.   def base_maxhp
  8124.     # Gets Orginal Value
  8125.     n = seph_statbonusbase_bmaxhp
  8126.     # Adds Direct Stat Bonus
  8127.     n += direct_maxhp_bonus
  8128.     # Adds Percent Stat Bonus
  8129.     n *= (percent_maxhp_bonus + 100) / 100.0
  8130.     # Returns Stat
  8131.     return n
  8132.   end
  8133.   def direct_maxhp_bonus  ; return 0 ; end
  8134.   def percent_maxhp_bonus ; return 0 ; end
  8135.   #--------------------------------------------------------------------------
  8136.   # * Get Maximum SP
  8137.   #--------------------------------------------------------------------------
  8138.   def base_maxsp
  8139.     # Gets Orginal Value
  8140.     n = seph_statbonusbase_bmaxsp
  8141.     # Adds Direct Stat Bonus
  8142.     n += direct_maxsp_bonus
  8143.     # Adds Percent Stat Bonus
  8144.     n *= (percent_maxsp_bonus + 100) / 100.0
  8145.     # Returns Stat
  8146.     return n
  8147.   end
  8148.   def direct_maxsp_bonus  ; return 0 ; end
  8149.   def percent_maxsp_bonus ; return 0 ; end
  8150.   #--------------------------------------------------------------------------
  8151.   # * Get Strength
  8152.   #--------------------------------------------------------------------------
  8153.   def base_str
  8154.     # Gets Orginal Value
  8155.     n = seph_statbonusbase_bstr
  8156.     # Adds Direct Stat Bonus
  8157.     n += direct_str_bonus
  8158.     # Adds Percent Stat Bonus
  8159.     n *= (percent_str_bonus + 100) / 100.0
  8160.     # Returns Stat
  8161.     return n
  8162.   end
  8163.   def direct_str_bonus  ; return 0 ; end
  8164.   def percent_str_bonus ; return 0 ; end
  8165.   #--------------------------------------------------------------------------
  8166.   # * Get Dexterity
  8167.   #--------------------------------------------------------------------------
  8168.   def base_dex
  8169.     # Gets Orginal Value
  8170.     n = seph_statbonusbase_bdex
  8171.     # Adds Direct Stat Bonus
  8172.     n += direct_dex_bonus
  8173.     # Adds Percent Stat Bonus
  8174.     n *= (percent_dex_bonus + 100) / 100.0
  8175.     # Returns Stat
  8176.     return n
  8177.   end
  8178.   def direct_dex_bonus  ; return 0 ; end
  8179.   def percent_dex_bonus ; return 0 ; end
  8180.   #--------------------------------------------------------------------------
  8181.   # * Get Basic Agility
  8182.   #--------------------------------------------------------------------------
  8183.   def base_agi
  8184.     # Gets Orginal Value
  8185.     n = seph_statbonusbase_bagi
  8186.     # Adds Direct Stat Bonus
  8187.     n += direct_agi_bonus
  8188.     # Adds Percent Stat Bonus
  8189.     n *= (percent_agi_bonus + 100) / 100.0
  8190.     # Returns Stat
  8191.     return n
  8192.   end
  8193.   def direct_agi_bonus  ; return 0 ; end
  8194.   def percent_agi_bonus ; return 0 ; end
  8195.   #--------------------------------------------------------------------------
  8196.   # * Get Basic Intelligence
  8197.   #--------------------------------------------------------------------------
  8198.   def base_int
  8199.     # Gets Orginal Value
  8200.     n = seph_statbonusbase_bint
  8201.     # Adds Direct Stat Bonus
  8202.     n += direct_int_bonus
  8203.     # Adds Percent Stat Bonus
  8204.     n *= (percent_int_bonus + 100) / 100.0
  8205.     # Returns Stat
  8206.     return n
  8207.   end
  8208.   def direct_int_bonus  ; return 0 ; end
  8209.   def percent_int_bonus ; return 0 ; end
  8210.   #--------------------------------------------------------------------------
  8211.   # * Get Basic Attack Power
  8212.   #--------------------------------------------------------------------------
  8213.   def base_atk
  8214.     # Gets Orginal Value
  8215.     n = seph_statbonusbase_batk
  8216.     # Adds Direct Stat Bonus
  8217.     n += direct_atk_bonus
  8218.     # Adds Percent Stat Bonus
  8219.     n *= (percent_atk_bonus + 100) / 100.0
  8220.     # Returns Stat
  8221.     return n
  8222.   end
  8223.   def direct_atk_bonus  ; return 0 ; end
  8224.   def percent_atk_bonus ; return 0 ; end
  8225.   #--------------------------------------------------------------------------
  8226.   # * Get Basic Physical Defense
  8227.   #--------------------------------------------------------------------------
  8228.   def base_pdef
  8229.     # Gets Orginal Value
  8230.     n = seph_statbonusbase_bpdef
  8231.     # Adds Direct Stat Bonus
  8232.     n += direct_pdef_bonus
  8233.     # Adds Percent Stat Bonus
  8234.     n *= (percent_pdef_bonus + 100) / 100.0
  8235.     # Returns Stat
  8236.     return n
  8237.   end
  8238.   def direct_pdef_bonus  ; return 0 ; end
  8239.   def percent_pdef_bonus ; return 0 ; end
  8240.   #--------------------------------------------------------------------------
  8241.   # * Get Basic Magic Defense
  8242.   #--------------------------------------------------------------------------
  8243.   def base_mdef
  8244.     # Gets Orginal Value
  8245.     n = seph_statbonusbase_bmdef
  8246.     # Adds Direct Stat Bonus
  8247.     n += direct_mdef_bonus
  8248.     # Adds Percent Stat Bonus
  8249.     n *= (percent_mdef_bonus + 100) / 100.0
  8250.     # Returns Stat
  8251.     return n
  8252.   end
  8253.   def direct_mdef_bonus  ; return 0 ; end
  8254.   def percent_mdef_bonus ; return 0 ; end
  8255.   #--------------------------------------------------------------------------
  8256.   # * Get Basic Evasion Correction
  8257.   #--------------------------------------------------------------------------
  8258.   def base_eva
  8259.     # Gets Orginal Value
  8260.     n = seph_statbonusbase_beva
  8261.     # Adds Direct Stat Bonus
  8262.     n += direct_eva_bonus
  8263.     # Adds Percent Stat Bonus
  8264.     n *= (percent_eva_bonus + 100) / 100.0
  8265.     # Returns Stat
  8266.     return n
  8267.   end
  8268.   def direct_eva_bonus  ; return 0 ; end
  8269.   def percent_eva_bonus ; return 0 ; end
  8270.   #--------------------------------------------------------------------------
  8271.   # * Get Hit
  8272.   #--------------------------------------------------------------------------
  8273.   def hit
  8274.     # Gets Orginal Value
  8275.     n = seph_statbonusbase_hit
  8276.     # Adds Direct Stat Bonus
  8277.     n += direct_hit_bonus
  8278.     # Adds Percent Stat Bonus
  8279.     n *= (percent_hit_bonus + 100) / 100.0
  8280.     # Returns Stat
  8281.     return n
  8282.   end
  8283.   def direct_hit_bonus  ; return 0 ; end
  8284.   def percent_hit_bonus ; return 0 ; end
  8285. end
  8286.  
  8287. #==============================================================================
  8288. # ** Systems.String Operators                                     By: Trickster
  8289. #------------------------------------------------------------------------------
  8290. # Description:
  8291. # ------------
  8292. # Classes that perform Operations on strings
  8293. #  
  8294. # Class List:
  8295. # ------------
  8296. # Increaser_String
  8297. # Range_String
  8298. #==============================================================================
  8299.  
  8300. MACL::Loaded << 'Systems.String Operators'
  8301.  
  8302. #==============================================================================
  8303. # ** Increaser String                                             By: Trickster
  8304. #------------------------------------------------------------------------------
  8305. #  This utility class represents stat bonuses in a string
  8306. #  Only recognizes the stats maxhp,maxsp,str,dex,agi,int,pdef,mdef,eva,atk
  8307. #  entries are separated by commas and increase amounts are shown by the
  8308. #  operators stat:xN/N+N-N
  8309. #  When Conveterted to a hash, becomes one in this format {'effect' => [+,*]}
  8310. #==============================================================================
  8311.  
  8312. class Increaser_String
  8313.   #-------------------------------------------------------------------------
  8314.   # * Name      : To_Hash
  8315.   #   Info      : Returns A Hash in this format, {'effect' => [+,*]}
  8316.   #   Author    : Trickster
  8317.   #   Call Info : One Argument, String string string to be converted
  8318.   #-------------------------------------------------------------------------
  8319.   def self.to_hash(string)
  8320.     # Make a Copy of the string
  8321.     string = string.dup
  8322.     # Create Hash
  8323.     hash = {}
  8324.     # Run Through all strings splitted by ,
  8325.     string.split(',').each do |effect|
  8326.       # Get Index
  8327.       index = effect.index(':')
  8328.       # Get Size
  8329.       size = effect.size
  8330.       # Get Stat Name
  8331.       stat = effect[0, index]
  8332.       # Get Modifiers
  8333.       modifiers = effect[index+1, (size-index+1)]
  8334.       # Get Amounts
  8335.       amounts = modifiers.gsub(/\+|\*|-|\//, ' ').split(' ')
  8336.       # Get Operations
  8337.       operations = modifiers.gsub(/[0-9]|\./, ' ').split(' ')
  8338.       # Initialize Amounts
  8339.       plus_amount, times_amount = 0, 1
  8340.       # Run Through Each Index
  8341.       amounts.each_with_index do |amount, index|
  8342.         # Get Operation
  8343.         operation = operations[index]
  8344.         # Branch by operation
  8345.         case operation
  8346.         when '+'
  8347.           plus_amount += amount.to_f
  8348.         when '-'
  8349.           plus_amount -= amount.to_f
  8350.         when '*'
  8351.           times_amount *= amount.to_f
  8352.         when '/'
  8353.           times_amount /= amount.to_f
  8354.         end
  8355.       end
  8356.       # Set Hash At Stat To Plus Amount and Times Amount
  8357.       hash[stat] = plus_amount, times_amount
  8358.     end
  8359.     # Return Hash
  8360.     return hash
  8361.   end
  8362. end
  8363.  
  8364. #==============================================================================
  8365. # ** Range String                                                 By: Trickster
  8366. #------------------------------------------------------------------------------
  8367. #  This utility class represents a range of integers and
  8368. #  recognizes num-num2 num ^num, entries are separated by commas.
  8369. #  Where num-num2 gets all numbers from num1 to num2
  8370. #  num gets that number
  8371. #  and ^num removes num from the range
  8372. #==============================================================================
  8373. class Range_String
  8374.   #-------------------------------------------------------------------------
  8375.   # * Name      : To_A
  8376.   #   Info      : To Array - An Array of Integers
  8377.   #   Author    : Trickster
  8378.   #   Call Info : One Argument String string the string to convert
  8379.   #-------------------------------------------------------------------------
  8380.   def self.to_a(string)
  8381.     # Create An Array
  8382.     array = []
  8383.     # Create Deleted Array
  8384.     deleted = []
  8385.     # Run through each range
  8386.     string.split(',').each do |range|
  8387.       # If - is included
  8388.       if range.include?('-')
  8389.         # Get Index
  8390.         index = range.index('-')
  8391.         # Get Size
  8392.         size = range.size
  8393.         # Get First Number
  8394.         first = range[0, index].to_i
  8395.         # Get Last Number
  8396.         last = range[index + 1, size - (index + 1)].to_i
  8397.         # Add To Array
  8398.         array += (first..last).to_a
  8399.       # Elsif ^ Is included
  8400.       elsif range.include?('^')
  8401.         # Add to Deleted
  8402.         deleted << range.to_i
  8403.       # Else
  8404.       else
  8405.         # Add to Array
  8406.         array << range.to_i
  8407.       end
  8408.     end
  8409.     # Return Array with Deleted Entries Removed
  8410.     return array - deleted
  8411.   end
  8412. end
  8413.  
  8414. #==============================================================================
  8415. # ** Systems.Window Sprites                                       By: Trickster
  8416. #------------------------------------------------------------------------------
  8417. # Description:
  8418. # ------------
  8419. # This set allows for sprite objects to be tagged onto a window.
  8420. #  
  8421. # Method List:
  8422. # ------------
  8423. # Sprite
  8424. # ------
  8425. # tag
  8426. # in_rect?
  8427. #  
  8428. # Support Methods:
  8429. # -------------
  8430. #   Window_Base
  8431. #   -----------
  8432. #   initialize
  8433. #   dispose
  8434. #   update
  8435. #   x=
  8436. #   y=
  8437. #   z=
  8438. #   ox=
  8439. #   oy=
  8440. #   width=
  8441. #   height=
  8442. #   contents_opacity=
  8443. #   back_opacity=
  8444. #   opacity=
  8445. #   visible=
  8446. #    
  8447. #   Sprite
  8448. #   ------
  8449. #   initialize
  8450. #==============================================================================
  8451.  
  8452. MACL::Loaded << 'Systems.Window Sprites'
  8453.  
  8454. class Window_Base
  8455.   #--------------------------------------------------------------------------
  8456.   # * Alias Listings
  8457.   #--------------------------------------------------------------------------
  8458.   if @trick_sprites_windowbase.nil?
  8459.     alias_method :trick_sprites_base_x=, :x=
  8460.     alias_method :trick_sprites_base_y=, :y=
  8461.     alias_method :trick_sprites_base_z=, :z=
  8462.     alias_method :trick_sprites_base_ox=, :ox=
  8463.     alias_method :trick_sprites_base_oy=, :oy=
  8464.     alias_method :trick_sprites_base_width=, :width=
  8465.     alias_method :trick_sprites_base_height=, :height=
  8466.     alias_method :trick_sprites_base_contents_opacity=, :contents_opacity=
  8467.     alias_method :trick_sprites_base_back_opacity=, :back_opacity=
  8468.     alias_method :trick_sprites_base_opacity=, :opacity=
  8469.     alias_method :trick_sprites_base_visible=, :visible=
  8470.     @trick_sprites_windowbase = true
  8471.   end
  8472.   #--------------------------------------------------------------------------
  8473.   # * Object Initialization
  8474.   #--------------------------------------------------------------------------
  8475.   alias_method :trick_sprites_base_initialize, :initialize
  8476.   def initialize(x, y, width, height)
  8477.     # Setup Sprites Array
  8478.     @window_sprites = []
  8479.     # The Usual
  8480.     trick_sprites_base_initialize(x, y, width, height)
  8481.   end
  8482.   #--------------------------------------------------------------------------
  8483.   # * Dispose
  8484.   #--------------------------------------------------------------------------
  8485.   alias_method :trick_sprites_base_dispose, :dispose
  8486.   def dispose
  8487.     # The Usual
  8488.     trick_sprites_base_dispose
  8489.     # Dispose all Sprites
  8490.     @window_sprites.each {|sprite| sprite.dispose}
  8491.   end
  8492.   #--------------------------------------------------------------------------
  8493.   # * Update
  8494.   #--------------------------------------------------------------------------
  8495.   alias_method :trick_sprites_base_update, :update
  8496.   def update
  8497.     # The Usual
  8498.     trick_sprites_base_update
  8499.     # Update
  8500.     @window_sprites.each {|sprite| sprite.update}
  8501.   end
  8502.   #--------------------------------------------------------------------------
  8503.   # * Set X
  8504.   #--------------------------------------------------------------------------  
  8505.   def x=(x)
  8506.     # Run through each window sprite
  8507.     @window_sprites.each do |sprite|
  8508.       # If Has Method sprite type
  8509.       if sprite.respond_to?(:sprite_type)
  8510.         # Branch by Type
  8511.         case sprite.sprite_type
  8512.         when 'content', 'content2', 'cover', 'background', 'background2'
  8513.           # Include Scroll Calculation Set X
  8514.           sprite.x = sprite.x - self.x + x + ox
  8515.         when 'border'
  8516.           # Exclude Scroll Calculation Set X
  8517.           sprite.x = sprite.x - self.x + x
  8518.         end
  8519.       else
  8520.         # Default is Content Sprite
  8521.         sprite.x = sprite.x - self.x + x + ox
  8522.       end
  8523.     end
  8524.     # The Usual
  8525.     self.trick_sprites_base_x = x
  8526.   end
  8527.   #--------------------------------------------------------------------------
  8528.   # * Set Y
  8529.   #--------------------------------------------------------------------------
  8530.   def y=(y)
  8531.     # Update All Y's
  8532.     @window_sprites.each do |sprite|
  8533.       # If Has Method sprite type
  8534.       if sprite.respond_to?(:sprite_type)
  8535.         # Branch by Type
  8536.         case sprite.sprite_type
  8537.         when 'content', 'content2', 'cover', 'background', 'background2'
  8538.           # Include Scroll Calculation Set Y
  8539.           sprite.y = sprite.y - self.y + y + oy
  8540.         when 'border'
  8541.           # Exclude Scroll Calculation Set Y
  8542.           sprite.y = sprite.y - self.y + y
  8543.         end
  8544.       else
  8545.         # Default is Content Sprite
  8546.         sprite.y = sprite.y - self.y + y + oy
  8547.       end
  8548.     end
  8549.     # The Usual
  8550.     self.trick_sprites_base_y = y
  8551.   end
  8552.   #--------------------------------------------------------------------------
  8553.   # * Set Z
  8554.   #--------------------------------------------------------------------------
  8555.   def z=(z)
  8556.     # Update All Z's
  8557.     @window_sprites.each do |sprite|
  8558.       # If Has Method sprite type
  8559.       if sprite.respond_to?(:sprite_type)
  8560.         # Branch By Sprite Type
  8561.         case sprite.sprite_type
  8562.         when 'content'
  8563.           sprite.z = self.z + 1
  8564.         when 'content2'
  8565.           sprite.z = self.z + 2
  8566.         when 'cover', 'border'
  8567.           sprite.z = self.z + 3
  8568.         when 'background'
  8569.           sprite.z = self.z
  8570.         when 'background2'
  8571.           sprite.z = self.z - 1
  8572.         end
  8573.       else
  8574.         # Default is content
  8575.         sprite.z = self.z + 1
  8576.       end
  8577.     end
  8578.     # The Usual
  8579.     self.trick_sprites_base_z = z
  8580.   end
  8581.   #--------------------------------------------------------------------------
  8582.   # * Set Origin X
  8583.   #--------------------------------------------------------------------------
  8584.   def ox=(ox)
  8585.     # Get Ox Change
  8586.     cx = self.ox - ox
  8587.     # Run Through Each Sprite
  8588.     @window_sprites.each do |sprite|
  8589.       # If Has Method sprite type
  8590.       if sprite.respond_to?(:sprite_type)
  8591.         # Branch By Sprite Type
  8592.         case sprite.sprite_type
  8593.         when 'content', 'content2', 'cover', 'background', 'background2'
  8594.           # Add to X
  8595.           sprite.x += cx
  8596.           # Setup Visibility
  8597.           sprite.visible = sprite.x.between?(x + 16, x + width - 16) && visible
  8598.         end
  8599.       else
  8600.         # Add to X
  8601.         sprite.x += cx
  8602.         # Setup Visibility
  8603.         sprite.visible = sprite.x.between?(x + 16, x + width - 16) && visible
  8604.       end
  8605.     end
  8606.     # The Usual
  8607.     self.trick_sprites_base_ox = ox
  8608.   end
  8609.   #--------------------------------------------------------------------------
  8610.   # * Set Origin Y
  8611.   #--------------------------------------------------------------------------
  8612.   def oy=(oy)
  8613.     # Get Oy Change
  8614.     cy = self.oy - oy
  8615.     # Run Through Each Sprite
  8616.     @window_sprites.each do |sprite|
  8617.       # If Has Method sprite type
  8618.       if sprite.respond_to?(:sprite_type)
  8619.         # Branch By Sprite Type
  8620.         case sprite.sprite_type
  8621.         when 'content', 'content2', 'cover', 'background', 'background2'
  8622.           # Add to Y
  8623.           sprite.y += cy
  8624.           # Setup Visibility
  8625.           sprite.visible = sprite.y.between?(y + 16, y + height - 16) && visible
  8626.         end
  8627.       else
  8628.         # Add to Y
  8629.         sprite.y += cy
  8630.         # Setup Visibility
  8631.         sprite.visible = sprite.y.between?(y + 16, y + height - 16) && visible
  8632.       end
  8633.     end
  8634.     # The Usual
  8635.     self.trick_sprites_base_oy = oy
  8636.   end
  8637.   #--------------------------------------------------------------------------
  8638.   # * Set Width
  8639.   #--------------------------------------------------------------------------
  8640.   def width=(width)
  8641.     # Run Through Each Sprite
  8642.     @window_sprites.each do |sprite|
  8643.       # If Has Method sprite type
  8644.       if sprite.respond_to?(:sprite_type)
  8645.         # Branch By Sprite Type
  8646.         case sprite.sprite_type
  8647.         when 'content', 'content2', 'cover', 'background', 'background2'
  8648.           # Setup Visibility
  8649.           sprite.visible = sprite.x.between?(x + 16, x + width - 16) && visible
  8650.         end
  8651.       else
  8652.         # Setup Visibility
  8653.         sprite.visible = sprite.x.between?(x + 16, x + width - 16) && visible
  8654.       end
  8655.     end
  8656.     # The Usual
  8657.     self.trick_sprites_base_width = width
  8658.   end
  8659.   #--------------------------------------------------------------------------
  8660.   # * Set Height
  8661.   #--------------------------------------------------------------------------
  8662.   def height=(height)
  8663.     # Run Through Each Sprite
  8664.     @window_sprites.each do |sprite|
  8665.       # If Has Method sprite type
  8666.       if sprite.respond_to?(:sprite_type)
  8667.         # Branch By Sprite Type
  8668.         case sprite.sprite_type
  8669.         when 'content', 'content2', 'cover', 'background', 'background2'
  8670.           # Setup Visibility
  8671.           sprite.visible = sprite.y.between?(y + 16, y + height - 16) && visible
  8672.         end
  8673.       else
  8674.         # Setup Visibility
  8675.         sprite.visible = sprite.y.between?(y + 16, y + height - 16) && visible
  8676.       end
  8677.     end
  8678.     # The Usual
  8679.     self.trick_sprites_base_height = height
  8680.   end
  8681.   #--------------------------------------------------------------------------
  8682.   # * Set Contents Opacity
  8683.   #--------------------------------------------------------------------------
  8684.   def contents_opacity=(opacity)
  8685.     # Run Through Each Sprite and Setup Opacity
  8686.     @window_sprites.each do |sprite|
  8687.       # If Has Method sprite type
  8688.       if sprite.respond_to?(:sprite_type)
  8689.         # Branch By Sprite Type
  8690.         case sprite.sprite_type
  8691.         when 'content', 'content2', 'cover'
  8692.           # Setup Opacity
  8693.           sprite.opacity = opacity
  8694.         end
  8695.       else
  8696.         # Setup Opacity
  8697.         sprite.opacity = opacity
  8698.       end
  8699.     end
  8700.     # The Usual
  8701.     self.trick_sprites_base_contents_opacity = opacity
  8702.   end
  8703.   #--------------------------------------------------------------------------
  8704.   # * Set Back Opacity
  8705.   #--------------------------------------------------------------------------
  8706.   def back_opacity=(opacity)
  8707.     # Run Through Each Sprite and Setup Opacity
  8708.     @window_sprites.each do |sprite|
  8709.       # Skip if not Has Method sprite type
  8710.       next if not sprite.respond_to?(:sprite_type)
  8711.       # Branch By Sprite Type
  8712.       case sprite.sprite_type
  8713.       when 'background', 'background2'
  8714.         # Setup Opacity
  8715.         sprite.opacity = opacity
  8716.       end
  8717.     end
  8718.     # The Usual
  8719.     self.trick_sprites_base_back_opacity = opacity
  8720.   end
  8721.   #--------------------------------------------------------------------------
  8722.   # * Set Opacity
  8723.   #--------------------------------------------------------------------------
  8724.   def opacity=(opacity)
  8725.     # Run Through Each Sprite and Setup Opacity
  8726.     @window_sprites.each do |sprite|
  8727.       # Skip if not Has Method sprite type
  8728.       next if not sprite.respond_to?(:sprite_type)
  8729.       # Branch By Sprite Type
  8730.       case sprite.sprite_type
  8731.       when 'border', 'tagged'
  8732.         # Setup Opacity
  8733.         sprite.opacity = opacity
  8734.       end
  8735.     end
  8736.     # The Usual
  8737.     self.trick_sprites_base_opacity = opacity
  8738.   end
  8739.   #--------------------------------------------------------------------------
  8740.   # * Set Visibility
  8741.   #--------------------------------------------------------------------------
  8742.   def visible=(bool)
  8743.     # Get Rect
  8744.     rect = Rect.new(x + 16, y + 16, width - 32, height - 32)
  8745.     # Run Through Each Sprite
  8746.     @window_sprites.each do |sprite|
  8747.       # If Has Method sprite type
  8748.       if sprite.respond_to?(:sprite_type)
  8749.         # Branch By Sprite Type
  8750.         case sprite.sprite_type
  8751.         when 'content', 'content2', 'cover', 'background', 'background2'
  8752.           sprite.visible = bool && sprite.in_rect?(rect)
  8753.         when 'border', 'tagged'
  8754.           sprite.visible = visible
  8755.         end
  8756.       else
  8757.         sprite.visible = bool && sprite.in_rect?(rect)
  8758.       end
  8759.     end
  8760.     # Update Visibility
  8761.     self.trick_sprites_base_visible = bool
  8762.   end
  8763. end
  8764.  
  8765. class Sprite
  8766.   #--------------------------------------------------------------------------
  8767.   # * Public Instance Variables
  8768.   #--------------------------------------------------------------------------
  8769.   attr_writer :sprite_type
  8770.   #--------------------------------------------------------------------------
  8771.   # * Sprite Type
  8772.   #--------------------------------------------------------------------------
  8773.   def sprite_type
  8774.     return @sprite_type.nil? ? 'content' : @sprite_type
  8775.   end
  8776.   #--------------------------------------------------------------------------
  8777.   # * Tag
  8778.   #--------------------------------------------------------------------------
  8779.   def tag(window)
  8780.     # Get Attributes
  8781.     x, y, width, height = window.x, window.y, window.width, window.height
  8782.     # Setup Rect
  8783.     rect = Rect.new(x + 16, y + 16, width - 32, height - 32)
  8784.     # Branch by Sprite Type
  8785.     case sprite_type
  8786.     when 'content'
  8787.       # Set Visibility
  8788.       self.visible = in_rect?(rect) && window.visible
  8789.       # Set Z Between Window
  8790.       self.z = window.z + 1
  8791.       # Setup Opacity
  8792.       self.opacity = window.contents_opacity
  8793.     when 'content2'
  8794.       # Set Visibility
  8795.       self.visible = in_rect?(rect) && window.visible
  8796.       # Set Z Between Window
  8797.       self.z = window.z + 2
  8798.       # Setup Opacity
  8799.       self.opacity = window.contents_opacity
  8800.     when 'cover'
  8801.       # Set Visibility
  8802.       self.visible = in_rect?(rect) && window.visible
  8803.       # Set Z Between Window
  8804.       self.z = window.z + 3
  8805.       # Setup Opacity
  8806.       self.opacity = window.contents_opacity
  8807.     when 'border'
  8808.       # Set Visibility
  8809.       self.visible = window.visible
  8810.       # Set Z Between Window
  8811.       self.z = window.z + 3
  8812.       # Setup Opacity
  8813.       self.opacity = window.opacity
  8814.     when 'background'
  8815.       # Set Visibility
  8816.       self.visible = in_rect?(rect) && window.visible
  8817.       # Set Z at Window
  8818.       self.z = window.z
  8819.       # Setup Opacity
  8820.       self.opacity = window.back_opacity
  8821.     when 'background2'
  8822.       # Set Visibility
  8823.       self.visible = in_rect?(rect) && window.visible
  8824.       # Set Z at Window
  8825.       self.z = window.z - 1
  8826.       # Setup Opacity
  8827.       self.opacity = window.back_opacity
  8828.     when 'tagged'
  8829.       # Set Visibility
  8830.       self.visible = window.visible
  8831.       # Setup Opacity
  8832.       self.opacity = window.opacity
  8833.     end
  8834.   end
  8835.   #--------------------------------------------------------------------------
  8836.   # * In Rect?
  8837.   #--------------------------------------------------------------------------
  8838.   def in_rect?(*rect)
  8839.     # If 1 Argument Sent
  8840.     if rect.size == 1
  8841.       # Get Rect
  8842.       rect = rect[0]
  8843.       # Return in rect state
  8844.       return (x.between?(rect.x, rect.x + rect.width) &&
  8845.       y.between?(rect.y, rect.y + rect.height))
  8846.     else
  8847.       # Get variables sent
  8848.       x, y, width, height = rect
  8849.       # If In Rect
  8850.       return self.x.between?(x, x + width) && self.y.between?(y, y + height)
  8851.     end
  8852.   end
  8853. end
Add Comment
Please, Sign In to add comment