Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** RGSS.Windows
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # Methods created for window classes
- #
- # Method List:
- # ------------
- #
- # Window_Base
- # -----------
- # rect=
- # rect
- #
- # Window_Selectable
- # -----------------
- # oh
- #
- # Rewrote Methods:
- # ----------------
- #
- # Window_Selectable
- # -----------------
- # top_row
- # top_row=(top_row)
- # page_row_max
- # update_cursor_rect
- #==============================================================================
- MACL::Loaded << 'RGSS.Windows'
- #==============================================================================
- # ** Window_Base
- #==============================================================================
- class Window_Base
- #--------------------------------------------------------------------------
- # * Name : Set Window Rect
- # Info : Sets rect size of window
- # Author : SephirothSpawn
- # Call Info : Rect Object
- #--------------------------------------------------------------------------
- def rect=(r)
- self.x, self.y, self.width, self.height = r.x, r.y, r.width, r.height
- end
- #--------------------------------------------------------------------------
- # * Name : Window Rect
- # Info : Gets rect size of window
- # Author : SephirothSpawn
- # Call Info : None
- #--------------------------------------------------------------------------
- def rect
- return Rect.new(self.x, self.y, self.width, self.height)
- end
- end
- #==============================================================================
- # ** Window_Selectable
- #==============================================================================
- class Window_Selectable
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_writer :oh
- #--------------------------------------------------------------------------
- # * Text Cursor Height
- #--------------------------------------------------------------------------
- def oh
- return @oh.nil? ? 32 : @oh
- end
- #--------------------------------------------------------------------------
- # * Get Top Row
- #--------------------------------------------------------------------------
- def top_row
- # Divide y-coordinate of window contents transfer origin by 1 row
- # height of self.oh
- return self.oy / self.oh
- end
- #--------------------------------------------------------------------------
- # * Set Top Row
- # row : row shown on top
- #--------------------------------------------------------------------------
- def top_row=(row)
- # If row is less than 0, change it to 0
- # If row exceeds row_max - 1, change it to row_max - 1
- row = [[row, 0].max, row_max - 1].min
- # Multiply 1 row height by 32 for y-coordinate of window contents
- # transfer origin
- self.oy = row * self.oh
- end
- #--------------------------------------------------------------------------
- # * Get Number of Rows Displayable on 1 Page
- #--------------------------------------------------------------------------
- def page_row_max
- # Subtract a frame height of 32 from the window height, and divide it by
- # 1 row height of self.oh
- return (self.height - 32) / self.oh
- end
- #--------------------------------------------------------------------------
- # * Update Cursor Rectangle
- #--------------------------------------------------------------------------
- def update_cursor_rect
- # If cursor position is less than 0
- if @index < 0
- self.cursor_rect.empty
- return
- end
- # Get current row
- row = @index / @column_max
- # If current row is before top row
- if row < self.top_row
- # Scroll so that current row becomes top row
- self.top_row = row
- end
- # If current row is more to back than back row
- if row > self.top_row + (self.page_row_max - 1)
- # Scroll so that current row becomes back row
- self.top_row = row - (self.page_row_max - 1)
- end
- # Calculate cursor width
- cursor_width = self.width / @column_max - 32
- # Calculate cursor coordinates
- x = @index % @column_max * (cursor_width + 32)
- y = @index / @column_max * self.oh - self.oy
- if self.active == true
- # Update cursor rectangle
- self.cursor_rect.set(x, y, cursor_width, self.oh)
- end
- end
- end
- #==============================================================================
- # ** Classes.Array_2D By: Selwyn
- #------------------------------------------------------------------------------
- # Two Dimensional Array
- #
- # - by default, resizing the array will destroy the data it contains.
- # - calling any of the following methods of the Array class might mess up
- # the data's indexes, so be careful before using them.
- #
- # unshift uniq! slice! shift reverse! replace reject!
- # push << pop map! flatten! fill delete_if delete_at
- # delete concat compact! collect!
- #
- #==============================================================================
- MACL::Loaded << 'Classes.Array_2D'
- #==============================================================================
- # ** Array_2D
- #==============================================================================
- class Array_2D
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :xsize
- attr_reader :ysize
- #-------------------------------------------------------------------------
- # * Name : Object Initialization
- # Info : Creates a new 2D Array Object
- # Author : Selwyn
- # Call Info : Two Arguments Integer xsize, ysize - dimensions
- #-------------------------------------------------------------------------
- def initialize(xsize, ysize)
- @xsize = xsize
- @ysize = ysize
- make_array
- end
- #-------------------------------------------------------------------------
- # * Name : Element Reference
- # Info : Gets an Element returns Element At ID or X,Y
- # Author : Selwyn
- # Call Info : One-Two Arguments
- # One - Integer id - id of the element to get
- # Two - Integer x,y - X and Y.
- #-------------------------------------------------------------------------
- def [](*args)
- case args.size
- when 1
- return @data[args[0]]
- when 2
- return @data[id(*args)]
- end
- end
- #-------------------------------------------------------------------------
- # * Name : Element Assignment
- # Info : Assigns an Object to Element
- # Author : Selwyn
- # Call Info : Two-Three Arguments
- # Two Integer id - id of the Element to set
- # Object obj - object assigned to id
- # Three Integer x,y - X and Y.
- # Object obj - object assigned to id.
- #-------------------------------------------------------------------------
- def []=(*args)
- case args.size
- when 2
- @data[args[0]] = args[1]
- when 3
- @data[id(args[0], args[1])] = args[2]
- end
- end
- #-------------------------------------------------------------------------
- # * Name : Set X Size
- # Info : Sets Width of 2D Array
- # Author : Selwyn
- # Call Info : One or Two - Integer xsize - new size
- # Boolean clear - clears array
- #-------------------------------------------------------------------------
- def xsize=(xsize, clear = true)
- @xsize = xsize
- make_array if clear
- end
- #-------------------------------------------------------------------------
- # * Name : Set Y Size
- # Info : Sets Height of 2D Array
- # Author : Selwyn
- # Call Info : One or Two - Integer ysize - new size
- # Boolean clear - clears array
- #-------------------------------------------------------------------------
- def ysize=(ysize, clear = true)
- @ysize = ysize
- make_array if clear
- end
- #-------------------------------------------------------------------------
- # * Name : Set Size
- # Info : Sets Dimensions of 2D Array
- # Author : Selwyn
- # Call Info : Two or Three - Integer xsize, ysize - Dimensions
- # Boolean clear - clears array
- #-------------------------------------------------------------------------
- def resize(xsize, ysize, clear = true)
- @xsize = xsize
- @ysize = ysize
- make_array if clear
- end
- #-------------------------------------------------------------------------
- # * Name : Make Array
- # Info : Creates Data Array
- # Author : Selwyn
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def make_array
- max = id(@xsize, @ysize)
- @data = nil
- @data = Array.new(max)
- end
- #-------------------------------------------------------------------------
- # * Name : ID
- # Info : Retunrs id of element
- # Author : Selwyn
- # Call Info : Two Arguments Integer X and Y
- #-------------------------------------------------------------------------
- def id(x, y)
- return x + y * (@xsize + 1)
- end
- #-------------------------------------------------------------------------
- # * Name : Coord
- # Info : Gets Coordinates returns Array - [x, y]
- # Author : Selwyn
- # Call Info : One Integer ID, Id to get coordinates from
- #-------------------------------------------------------------------------
- def coord(id)
- x = id % (@xsize + 1)
- y = id / (@xsize + 1)
- return x, y
- end
- #--------------------------------------------------------------------------
- # * All other Array methods
- #--------------------------------------------------------------------------
- def method_missing(symbol, *args)
- @data.method(symbol).call(*args)
- end
- end
- #==============================================================================
- # ** Classes.Background_Sprite By: Trickster
- #------------------------------------------------------------------------------
- # This class is for displaying a sprite used as a background it inherits from
- # class Sprite. Allows for the programmer to specify a bitmap and a viewport
- # when creating a sprite and the sprite will automatically adjust itself to
- # fir the viewport specified.
- #==============================================================================
- MACL::Loaded << 'Classes.Background_Sprite'
- #==============================================================================
- # ** Background_Sprite
- #==============================================================================
- class Background_Sprite < Sprite
- #-------------------------------------------------------------------------
- # Name : Initialize
- # Info : Object initialization
- # Author : Trickster
- # Call Info : Zero to Two Arguments
- # Bitmap bitmap bitmap to be loaded
- # Viewport viewport viewport used with the sprite
- #-------------------------------------------------------------------------
- def initialize(bitmap = Bitmap.new(32,32), viewport = nil)
- super(viewport)
- self.bitmap = bitmap
- adjust
- end
- #-------------------------------------------------------------------------
- # Name : Set Bitmap
- # Info : Sets the Sprite's Bitmap
- # Author : Trickster
- # Call Info : One Argument Bitmap bitmap the bitmap to be loaded
- #-------------------------------------------------------------------------
- def bitmap=(bitmap)
- super(bitmap)
- adjust
- end
- #-------------------------------------------------------------------------
- # Name : Set Viewport
- # Info : Sets the Sprite's Viewport
- # Author : Trickster
- # Call Info : One Argument Viewport viewport the viewport to use
- #-------------------------------------------------------------------------
- def viewport=(viewport)
- super(viewport)
- adjust
- end
- #-------------------------------------------------------------------------
- # Name : Adjust (Private)
- # Info : Adjusts the Zoom Level
- # Author : Trickster
- # Call Info : No Arguments (can't be called outside this class)
- #-------------------------------------------------------------------------
- private
- def adjust
- if viewport != nil
- x, y = viewport.rect.x, viewport.rect.y
- width, height = viewport.rect.width, viewport.rect.height
- else
- x, y, width, height = 0, 0, 640, 480
- end
- src_rect.set(x, y, width, height)
- self.x = x
- self.y = y
- self.zoom_x = width / bitmap.width.to_f
- self.zoom_y = height / bitmap.height.to_f
- end
- end
- #==============================================================================
- # ** Classes.Level Generation V4 By Trickster and SephirothSpawn
- #------------------------------------------------------------------------------
- # Format for Calling this class
- # Level_Generation.new(min, mid, max, minL, midL, maxL, early, late, steady,
- # curve1, curve2, int)
- #
- # Where:
- # min - the minimum value of the stat
- # mid - the middle value at midL
- # max - the maximum value of the stat
- # minL - the minimum level
- # midL - the middle level (stat will be mid here)
- # maxL - the maximum level
- # early - the early influence
- # late - the late influence
- # steady - the steady influence
- # curve1 - the early->late influence
- # curve2 - the late->early influence
- # int - if true returns integers
- #
- # Notes:
- #
- # The Default Values for the Curve Options
- # minL = 1, midL = 50, maxL = 99, influence options = 0, int = true
- #
- # You must set at least one of the curve options to a number other than 0
- #
- # Using the Steady Curve Option will throw off the middle value option, since
- # the steady curve grows steadily and its middle value will always occur on the
- # middle level, that is, (maxL - minL) / 2.
- #==============================================================================
- MACL::Loaded << 'Classes.Level_Generation'
- #==============================================================================
- # ** Level_Generation
- #==============================================================================
- class Level_Generation
- #-------------------------------------------------------------------------
- # * Name : Initialize
- # Info : Object Initialization
- # Author : Trickster
- # Call Info : Three to Twelve Arguments
- # Numeric Min, Mid, Max - Minimum Middle and Maximum Value
- # Numeric Min1, Mid1, Max1 - Min, Mid, and Max Level (1, 50, 99)
- #-------------------------------------------------------------------------
- def initialize(min, mid, max, minl = 1, midl = 50, maxl = 99, early = 0,
- late = 0, steady = 0, curve1 = 0, curve2 = 0, int = true)
- # Set Instance Variables
- @min = min.to_f
- @mid = mid.to_f
- @max = max.to_f
- @minl = minl.to_f
- @midl = midl.to_f
- @maxl = maxl.to_f
- @early = early
- @late = late
- @steady = steady
- @curve1 = curve1
- @curve2 = curve2
- @int = int
- # Error Checking
- error_checking
- # Calculate constants
- calculate_constants
- end
- #-------------------------------------------------------------------------
- # * Name : Get Initial Level
- # Info : Initial Level
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def initial_level
- return @minl.to_i
- end
- #-------------------------------------------------------------------------
- # * Name : Get Final Level
- # Info : Final Level
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def final_level
- return @maxl.to_i
- end
- #-------------------------------------------------------------------------
- # * Name : Export
- # Info : Exports Object to Text File to YourProject/File.txt
- # Author : Trickster
- # Call Info : One or Two Argument - String File Filename to Save to
- # Boolean ints - Flag for Integer Arguments Sent (min - maxl)
- # Comments : Output Sample (Not Accurate with Curve)
- #
- # min = 100, mid = 150, max = 200
- # minl = 1, midl = 50, maxl = 99
- # early = 0, late = 0, steady = 1, curve1 = 0, cruve2 = 0
- #
- # 1 = 100
- # 2 = 102
- # [...]
- #-------------------------------------------------------------------------
- def export(file_name, ints = true)
- # Create File
- file = File.open("#{file_name}.txt", 'w')
- # Export Stat and Level Values
- if ints
- file.print("min = #{@min.to_i}, mid = #{@mid.to_i}, max = #{@max.to_i}\n")
- else
- file.print("min = #{@min.to_i}, mid = #{@mid.to_i}, max = #{@max.to_i}\n")
- end
- file.print("minl = #{@minl.to_i}, midl = #{@midl.to_i}, maxl = #{@maxl.to_i}\n")
- # Setup Arrays
- keys = %w( early late steady curve1 curve2 )
- values = @early, @late, @steady, @curve1, @curve2
- # Setup Text
- text = ''
- # Setup Local Variable Counter
- counter = 0
- # Run Through Keys with Values (MACL)
- keys.each_with_array(*values) do |key, value|
- # Skip if value is 0
- next if value == 0
- # Add to text
- text += counter == 0 ? "#{key} = #{value}" : ", #{key} = #{value}"
- # Increate Counter
- counter += value
- end
- # Print Text
- file.print(text)
- # Add two new lines
- file.print("\n\n")
- # Print Values for each level
- self.each {|level, value| file.print("#{level} = #{value}\n")}
- # Close File
- file.close
- end
- #-------------------------------------------------------------------------
- # * Name : Generate Table
- # Info : Generates Hash Table for levels (format: level => stat_value)
- # Author : Trickster (Mods By SephirothSpawn)
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def generate_table(data_type = 0)
- # Organizes Key (For Use in Saving Table)
- key = @min,@mid,@max,@minl,@midl,@maxl,@early,@late,@steady,@curve1,@curve2
- # Loads Tables
- tables = load_tables
- # If Key Already Saved Return Saved table
- return tables[key] if tables.has_key?(key)
- # Create Hash table
- table = Hash.new(0) if data_type == 0
- table = Table.new(@maxl + 1) if data_type == 1
- # Run Through Each Level
- self.each {|level, value| table[level] = value}
- # Saves Table
- save_table(table)
- # Return Created Table
- return table
- end
- #-------------------------------------------------------------------------
- # * Name : Save Table
- # Info : Saves Table Data into LevelGeneration.rxdata
- # Author : SephirothSpawn
- # Call Info : Hash Table
- #-------------------------------------------------------------------------
- def save_table(table)
- # Sets Up Key
- key = @min,@mid,@max,@minl,@midl,@maxl,@early,@late,@steady,@curve1,@curve2
- # Collects Saved Tables
- tables = load_tables
- # Saves Table to Data File
- tables[key] = table
- # Resaves Tables to File
- save_data(tables, 'Data/LevelGeneration.rxdata')
- end
- #-------------------------------------------------------------------------
- # * Name : Load Tables
- # Info : Loads Table Data From LevelGeneration.rxdata
- # : A Hash in this forum table_parameters => hash_table
- # Author : SephirothSpawn
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def load_tables
- # Test For Saved Solution File
- unless FileTest.exist?('Data/LevelGeneration.rxdata')
- # Creates LevelGeneration RXdata File
- save_data({}, 'Data/LevelGeneration.rxdata')
- end
- # Returns Saved Tables
- return load_data('Data/LevelGeneration.rxdata')
- end
- #-------------------------------------------------------------------------
- # * Name : Each
- # Info : Iterator Method, Calculates Value for each level
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def each
- # Get Minimum level and Maximum Level
- minimum, maximum = @minl.to_i, @maxl.to_i
- # Run Through Minimum and Maximum and Yield Level and Value
- (minimum..maximum).each {|level| yield(level, get_stat(level))}
- end
- #-------------------------------------------------------------------------
- # * Name : Element Reference
- # Info : Gets Stat for level
- # Author : Trickster
- # Call Info : One Argument Integer Level, Level to get stat from
- #-------------------------------------------------------------------------
- def [](level)
- return get_stat(level)
- end
- #-------------------------------------------------------------------------
- # * Name : Get Stat
- # Info : Gets Stat for level
- # Author : Trickster
- # Call Info : One Argument Integer Level, Level to get stat from
- #-------------------------------------------------------------------------
- def get_stat(level)
- return @int ? @min.to_i : @min if level <= @minl
- return @int ? @max.to_i : @max if level >= @maxl
- # Setup Total
- total = 0
- # Get Values for Every Stat if greater than 0
- total += @late * late_curve(level) if @late > 0
- total += @early * early_curve(level) if @early > 0
- total += @steady * steady_curve(level) if @steady > 0
- total += @curve1 * early_late_curve(level) if @curve1 > 0
- total += @curve2 * late_early_curve(level) if @curve2 > 0
- # Get Average
- total /= @late + @early + @steady + @curve1 + @curve2
- # Limit Value
- total = level < @midl ? [total, @mid].min : [total, @mid].max
- # Further Limit Value
- total = [[total, @min].max, @max].min
- # Return Value
- return @int ? total.to_i : total
- end
- #-------------------------------------------------------------------------
- # * Name : Calculate Constants (Private)
- # Info : Calculates Constants "infimi", "infi", and "inmi"
- # Author : Trickster
- # Call Info : No Arguments
- # Can not be called outside class
- #-------------------------------------------------------------------------
- private
- def calculate_constants
- # Calculate "infi" and "inmi"
- @inmi = (@mid - @min) / (@midl - @minl)
- @infi = (@max - @min) / (@maxl - @minl)
- # Calculate "infimi"
- @infimi = (@infi - @inmi) / (@maxl - @midl)
- end
- #-------------------------------------------------------------------------
- # * Name : Late Curve (Private)
- # Info : Late Curve Influence, Formula
- # Author : Trickster
- # Call Info : One Argument Integer Level, Level to get stat from
- # Can not be called outside class
- #-------------------------------------------------------------------------
- def late_curve(level)
- # Calculate "A"
- a_num = @infimi * (3 * @minl + @midl) + @inmi
- a_den = (@maxl - @minl) * (@midl - @minl)
- a = - a_num / a_den
- # Return Value
- return curve(a, level)
- end
- #-------------------------------------------------------------------------
- # * Name : Early Curve (Private)
- # Info : Early Curve Influence, Formula
- # Author : Trickster
- # Call Info : One Argument Integer Level, Level to get stat from
- # Can not be called outside class
- #-------------------------------------------------------------------------
- def early_curve(level)
- # Calculate "A"
- a_num = @infimi * (2 * @maxl + @minl + @midl) + @inmi
- a_den = (@maxl - @midl) * (@maxl - @minl)
- a = - a_num / a_den
- # Return Value
- return curve(a, level)
- end
- #-------------------------------------------------------------------------
- # * Name : Early -> Late Curve (Private)
- # Info : Early Late Curve Formula (Curve 1)
- # Author : Trickster
- # Call Info : One Argument Integer Level, Level to get stat from
- # Can not be called outside class
- #-------------------------------------------------------------------------
- def early_late_curve(level)
- # Calculate "A"
- a = @infimi / (@maxl + @minl - 2 * @midl)
- # Return Value
- return curve(a, level)
- end
- #-------------------------------------------------------------------------
- # * Name : Late -> Early Curve (Private)
- # Info : Late Early Curve Formula (Curve 2)
- # Author : Trickster
- # Call Info : One Argument Integer Level, Level to get stat from
- # Can not be called outside class
- #-------------------------------------------------------------------------
- def late_early_curve(level)
- # If Less than Mid Level
- if level < @midl
- # Return Late Curve for level
- return late_curve(level)
- # If Greater than Mid Level
- elsif level > @midl
- # Return Early Curve for Level
- return early_curve(level)
- # If at Mid Level
- elsif level == @midl
- # Return Mid Value
- return @mid
- end
- end
- #-------------------------------------------------------------------------
- # * Name : Steady Curve (Private)
- # Info : Steady Curve Influence, Formula
- # Author : Trickster
- # Call Info : One Argument Integer Level, Level to get stat from
- # Can not be called outside class
- #-------------------------------------------------------------------------
- def steady_curve(level)
- ch_level = @maxl - @minl
- ch_stat = @max - @min
- base = ch_stat / ch_level * level
- mod = @max * @minl - @min * @maxl
- base2 = mod / ch_level
- return base - base2
- end
- #-------------------------------------------------------------------------
- # * Name : Curve (Private)
- # Info : Curve Formula
- # Author : Trickster
- # Call Info : Two Arguments Numeric A, "A" Influence
- # Integer Level, Level to get stat from
- # Can not be called outside class
- #-------------------------------------------------------------------------
- def curve(a, level)
- # Calculate "B"
- b = @infimi - a * (@minl + @midl + @maxl)
- # Calculate "C"
- c = @inmi - a * (@midl ** 2 + @minl * @midl + @minl ** 2) - b * (@midl + @minl)
- # Calculate "D"
- d = @min - (a * @minl ** 3 + b * @minl ** 2 + c * @minl)
- # Calculate Stat
- stat = a * level ** 3 + b * level ** 2 + c * level + d
- # Return Stat
- return stat
- end
- #-------------------------------------------------------------------------
- # * Name : Error Checking (Private)
- # Info : Checks For Errors
- # Author : Trickster
- # Call Info : No Arguments
- # Can not be called outside class
- #-------------------------------------------------------------------------
- def error_checking
- if @late + @early + @steady + @curve1 + @curve2 == 0
- raise(GeneratorError, "No Influences Have Been Defined")
- elsif @minl == @midl or @minl == @maxl or @midl == @maxl
- raise(GeneratorError, "Can't Use Same Level for Min, Mid, or Max Level")
- end
- end
- #-------------------------------------------------------------------------
- # * Generator Error
- #-------------------------------------------------------------------------
- class GeneratorError < StandardError; end
- end
- #==============================================================================
- # ** Classes.Linked_List By: Zeriab
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # This class represents a double linked list. Has a reference to the tail
- # and the head of the list.
- #
- # Method List:
- # ------------
- # []=
- # add
- # insert
- # push
- # <<
- # unshift
- # delete
- # pop
- # shift
- # get
- # []
- # size=
- # insert_element
- # insert_element_tail
- # delete_element
- # search
- # get_element
- #
- # Linked_List::Element
- # --------------------
- # value=
- # value
- # previous_element=
- # previous_element
- # next_element=
- # next_element
- #==============================================================================
- MACL::Loaded << 'Classes.Linked_list'
- #==============================================================================
- # ** Linked_List
- #==============================================================================
- class Linked_List
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :head
- attr_accessor :tail
- attr_reader :size
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- self.size = 0
- end
- #--------------------------------------------------------------------------
- # * []=
- # Change the value of the nth element in the list
- # Return true if the change succeeds otherwise false
- #--------------------------------------------------------------------------
- def []=(n, value)
- # Return nil if the list is empty
- element = get_element(n)
- if element.nil?
- return false
- else
- element.value = value
- return true
- end
- end
- #--------------------------------------------------------------------------
- # * Add
- # Add an object to the list (HEAD)
- #--------------------------------------------------------------------------
- def add(value)
- element = Linked_List::Element.new
- element.value = value
- insert_element(element)
- self.size += 1
- end
- # Synonyms
- def insert(value) add(value) end
- def push(value) add(value) end
- def <<(value) add(value) end
- #--------------------------------------------------------------------------
- # * Unshift
- # Add an object to the back of the list (TAIL)
- #--------------------------------------------------------------------------
- def unshift(value)
- element = Linked_List::Element.new
- element.value = value
- insert_element_tail(element)
- self.size += 1
- end
- #--------------------------------------------------------------------------
- # * Delete
- # Delete an object from the list
- # Return the deleted object
- # Return nil if the deletion has no effect on the list.
- #--------------------------------------------------------------------------
- def delete(value)
- element = self.search(value)
- if element.nil?
- return nil
- else
- self.delete_element(element)
- self.size -= 1
- return element.value
- end
- end
- #--------------------------------------------------------------------------
- # * Pop
- # Delete and return the head of the list.
- #--------------------------------------------------------------------------
- def pop
- # Return nil if the list is empty
- if self.head.nil?
- return nil
- end
- self.size -= 1
- return delete_element(self.head).value
- end
- #--------------------------------------------------------------------------
- # * Shift
- # Delete and return the tail of the list.
- #--------------------------------------------------------------------------
- def shift
- # Return nil if the list is empty
- if self.head.nil?
- return nil
- end
- self.size -= 1
- return delete_element(self.tail).value
- end
- #--------------------------------------------------------------------------
- # * Get
- # Get the object at the nth element in the list
- #--------------------------------------------------------------------------
- def get(n)
- # Return nil if the list is empty
- element = get_element(n)
- if element.nil?
- return nil
- end
- return element.value
- end
- # Synonyms
- def [](n) get(n) end
- #--------------------------------------------------------------------------
- # * Private Method
- #--------------------------------------------------------------------------
- private
- #--------------------------------------------------------------------------
- # * Size
- # Sets the size of the list
- #--------------------------------------------------------------------------
- def size=(value)
- @size = value if value >= 0
- end
- #--------------------------------------------------------------------------
- # * Insert Element
- # Insert an element into the list.
- # Assumes 'element' is a Linked_List::Element.
- #--------------------------------------------------------------------------
- def insert_element(element)
- if head.nil?
- self.head = element
- self.tail = element
- return
- end
- element.next_element = self.head
- self.head.previous_element = element
- self.head = element
- element.previous_element = nil
- end
- #--------------------------------------------------------------------------
- # * Insert Element Tail
- # Insert an element into the list at the tail.
- # Assumes 'element' is a Linked_List::Element.
- #--------------------------------------------------------------------------
- def insert_element_tail(element)
- if head.nil?
- self.head = element
- self.tail = element
- return
- end
- element.previous_element = self.tail
- self.tail.next_element = element
- self.tail = element
- element.next_element = nil
- end
- #--------------------------------------------------------------------------
- # * Delete Element
- # Delete the given element from the list
- # Assumes 'element' is a Linked_List::Element.
- #--------------------------------------------------------------------------
- def delete_element(element)
- if element.next_element.nil?
- self.tail = element.previous_element
- else
- element.next_element.previous_element = element.previous_element
- end
- if element.previous_element.nil?
- self.head = element.next_element
- else
- element.previous_element.next_element = element.next_element
- end
- return element
- end
- #--------------------------------------------------------------------------
- # * Search
- # Search for an element with the specified value.
- # Return the first element found with the corresponding value
- # Return nil if no element is found.
- #--------------------------------------------------------------------------
- def search(value)
- # If the head is nil the list is empty
- if self.head.nil?
- return nil
- end
- # Start with the head
- element = self.head
- loop do
- # Check if the element has the correct value
- if element.value == value
- return element
- end
- # Return nil if the tail has been reached
- if element == self.tail
- return nil
- end
- # Look at the next element in the list
- element = element.next_element
- end
- end
- #--------------------------------------------------------------------------
- # * Get Element
- # Get the object at the nth element in the list
- #--------------------------------------------------------------------------
- def get_element(n)
- # Return nil if the list is empty
- if self.head.nil?
- return nil
- end
- element = self.head
- for i in 0...n
- if self.tail == element
- return nil
- end
- element = element.next_element
- end
- return element
- end
- end
- #==============================================================================
- # ** Linked_List::Element
- #==============================================================================
- class Linked_List::Element
- attr_accessor :value
- attr_accessor :previous_element
- attr_accessor :next_element
- end
- #==============================================================================
- # ** Classes.Random By: Trickster
- #------------------------------------------------------------------------------
- # A Random class for generating objects
- #==============================================================================
- MACL::Loaded << 'Classes.Random'
- #==============================================================================
- # ** Random
- #==============================================================================
- class Random
- #-------------------------------------------------------------------------
- # * Name : Initialize
- # Info : Object Initialization
- # Author : Trickster
- # Call Info : Variable Amount
- # If a Range every object within the Range is added
- # If a Numeric adds that object is added
- # If a String then that string is added
- # If an Array then all values within the array are added
- #-------------------------------------------------------------------------
- def initialize(*args)
- # Setup Data
- @data = []
- # Push Arguments to List
- push(*args)
- end
- #-------------------------------------------------------------------------
- # * Name : Generate
- # Info : Generates an Object
- # returns An Object if number is 1 and Array of Objects if
- # number is > 1
- # Author : Trickster
- # Call Info : Zero to One
- # Integer number Number of objects to generate (Defaults to 1)
- #-------------------------------------------------------------------------
- def generate(number = 1)
- # Create Array
- random = []
- # If Number is greater than 1
- if number > 1
- # Push Object Number Times
- number.times {random << @data[rand(@data.size)]}
- # Return Random Objects
- return random
- else
- # Retunr Random Object
- return @data[rand(@data.size)]
- end
- end
- #-------------------------------------------------------------------------
- # * Name : Generate!
- # Info : Generates and Deletes Object
- # returns An Object if number is 1 and Array of Objects if
- # number is > 1
- # Author : Trickster
- # Call Info : Zero to One
- # Integer number Number of objects to generate (Defaults to 1)
- #-------------------------------------------------------------------------
- def generate!(number = 1)
- # Create Array
- random = []
- # If Number is greater than 1
- if number > 1
- # Run Through Number times
- number.times {random << @data.delete_at(rand(@data.size)) if !empty?}
- # Return Array of Random
- return random
- else
- # Return Random Object And Delete
- return @data.delete_at(rand(@data.size))
- end
- end
- #-------------------------------------------------------------------------
- # * Name : Push
- # Info : Push Objects to be generated
- # Author : Trickster
- # Call Info : Variable Amount
- # If a Range every object within the Range is added
- # If a Numeric adds that object is added
- # If a String then that string is added
- # If an Array then all values within the array are added
- #-------------------------------------------------------------------------
- def push(*args)
- # Run Through Arguments Sent
- args.each do |argument|
- # Branch By Arguments Class
- case argument
- when Range
- # Add All Values of Range
- @data += argument.to_a
- when Hash
- # Add All Key Value Pairs Of Hash
- @data += argument.to_a
- when Array
- # Add Array
- @data += argument
- else
- # Push Argument
- @data << argument
- end
- end
- end
- #-------------------------------------------------------------------------
- # * Name : Empty?
- # Info : Generator Empty? returns true if Data is empty false otherwise
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def empty?
- return @data.empty?
- end
- #--------------------------------------------------------------------------
- # * All Other Array methods
- #--------------------------------------------------------------------------
- def method_missing(symbol, *args)
- @data.method(symbol).call(*args)
- end
- end
- #==============================================================================
- # ** Classes.Scene_Base (2.1.1) By SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to act as a parent class for all scenes. It
- # provides 2 major purposes :
- #
- # 1) Give the Main Processing Method a Common Structure
- # 2) Automatically Update & Dispose All Spritesets, Sprites, Windows or
- # any other instance variable that responds to :update or :dispose
- #
- # This is a script for developers, not non-scripters. If you do not
- # plan to create scenes in RMXP, this isn't needed.
- #------------------------------------------------------------------------------
- # * Note : This script is only for non-SDK users or SDK users that do not use
- # the 2.0+ version of the SDK.
- #==============================================================================
- MACL::Loaded << 'Classes.Scene_Base'
- #==============================================================================
- # ** Scene Base
- #==============================================================================
- class Scene_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- @previous_scene = $scene.class
- end
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- main_variable # Main Variable Initialization
- main_spriteset # Main Spriteset Initialization
- main_sprite # Main Sprite Initialization
- main_window # Main Window Initialization
- main_audio # Main Audio Initialization
- main_transition # Main Transition Initialization
- loop do # Scene Loop
- main_loop # Main Loop
- break if main_break? # Break If Breakloop Test
- end # End Scene Loop
- Graphics.freeze # Prepare for transition
- main_dispose # Main Dispose
- main_end # Main End
- end
- #--------------------------------------------------------------------------
- # * Main Processing : Variable Initialization
- #--------------------------------------------------------------------------
- def main_variable ; end
- #--------------------------------------------------------------------------
- # * Main Processing : Spriteset Initialization
- #--------------------------------------------------------------------------
- def main_spriteset ; end
- #--------------------------------------------------------------------------
- # * Main Processing : Sprite Initialization
- #--------------------------------------------------------------------------
- def main_sprite ; end
- #--------------------------------------------------------------------------
- # * Main Processing : Window Initialization
- #--------------------------------------------------------------------------
- def main_window ; end
- #--------------------------------------------------------------------------
- # * Main Processing : Audio Initialization
- #--------------------------------------------------------------------------
- def main_audio ; end
- #--------------------------------------------------------------------------
- # * Main Processing : Transition
- #--------------------------------------------------------------------------
- def main_transition
- Graphics.transition
- end
- #--------------------------------------------------------------------------
- # * Main Processing : Loop
- #--------------------------------------------------------------------------
- def main_loop
- Graphics.update # Update game screen
- Input.update # Update input information
- main_update # Update scene objects
- update # Update Processing
- end
- #--------------------------------------------------------------------------
- # * Main Processing : Break Loop Test
- #--------------------------------------------------------------------------
- def main_break?
- return $scene != self # Abort loop if sceen is changed
- end
- #--------------------------------------------------------------------------
- # * Main Processing : Disposal
- #--------------------------------------------------------------------------
- def main_dispose
- # Passes Through All Instance Variables
- self.instance_variables.each do |object_name|
- # Evaluates Object
- object = eval object_name
- # Pass Object To Auto Dispose
- auto_dispose(object)
- end
- end
- #--------------------------------------------------------------------------
- # * Main Processing : Ending
- #--------------------------------------------------------------------------
- def main_end ; end
- #--------------------------------------------------------------------------
- # * Main Processing : Update
- #--------------------------------------------------------------------------
- def main_update
- # Passes Through All Instance Variables
- self.instance_variables.each do |object_name|
- # Evaluates Object
- object = eval object_name
- # Pass Object To Auto Update
- auto_update(object)
- end
- end
- #--------------------------------------------------------------------------
- # * Main Processing : Auto Update
- #--------------------------------------------------------------------------
- def auto_update(object)
- # Return If Object isn't a Hash, Array or Respond to Update
- return unless object.is_a?(Hash) || object.is_a?(Array) ||
- object.respond_to?(:update)
- # If Hash Object
- if object.is_a?(Hash)
- object.each do |key, value|
- # Pass Key & Value to Auto Update
- auto_update(key) ; auto_update(value)
- end
- return
- end
- # If Array Object
- if object.is_a?(Array)
- # Pass All Object to Auto Update
- object.each {|obj| auto_update(obj)}
- return
- end
- # If Responds to Dispose
- if object.respond_to?(:dispose)
- # If Responds to Disposed? && is Disposed or Responds to Disable
- # Dispose and dispose is disabled
- if (object.respond_to?(:disposed?) && object.disposed?) ||
- (object.respond_to?(:disable_dispose?) && object.disable_dispose?)
- # Return
- return
- end
- end
- # If Responds to Update
- if object.respond_to?(:update)
- # If Responds to Disable Update & Update Disabled
- if object.respond_to?(:disable_update?) && object.disable_update?
- # Return
- return
- end
- # Update Object
- object.update
- end
- end
- #--------------------------------------------------------------------------
- # * Main Processing : Auto Dispose
- #--------------------------------------------------------------------------
- def auto_dispose(object)
- # Return If Object isn't a Hash, Array or Respond to Dispose
- return unless object.is_a?(Hash) || object.is_a?(Array) ||
- object.respond_to?(:dispose)
- # If Hash Object
- if object.is_a?(Hash)
- object.each do |key, value|
- # Pass Key & Value to Auto Dispose
- auto_dispose(key) ; auto_dispose(value)
- end
- return
- end
- # If Array Object
- if object.is_a?(Array)
- # Pass All Object to Auto Dispose
- object.each {|obj| auto_dispose(obj)}
- return
- end
- # If Responds to Dispose
- if object.respond_to?(:dispose)
- # If Responds to Disposed? && is Disposed or Responds to Disable
- # Dispose and dispose is disabled
- if (object.respond_to?(:disposed?) && object.disposed?) ||
- (object.respond_to?(:disable_dispose?) && object.disable_dispose?)
- # Return
- return
- end
- # Dispose Object
- object.dispose
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update ; end
- end
- #==============================================================================
- # ** Classes.Sprite_ActorCharGraphic (V2.0) By Trickster
- #------------------------------------------------------------------------------
- # A Sprite Class that represents an actor character graphic. Also Handles a few
- # Graphical methods and animation. The Z coordinate is, by default,
- # in between the window and its contents for easy integration in a window.
- #==============================================================================
- MACL::Loaded << 'Classes.Sprite_ActorCharGraphic'
- #==============================================================================
- # ** Sprite_ActorCharGraphic
- #==============================================================================
- class Sprite_ActorCharGraphic < Sprite
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :speed
- attr_accessor :animate
- attr_reader :frame
- attr_reader :pose
- #-------------------------------------------------------------------------
- # * Name : Object Initialization
- # Info : Creates a New Instance of this Class
- # Author : Trickster
- # Call Info : Three or Seven Arguments
- # Game_Actor actor, Actor's Sprite to Display
- # Integer X and Y, Position to Display
- # Integer Speed, Speed of animation (Def 1)
- # Integer Frame, Starting frame (Def. nil)
- # String/Integer Pose, Pose Type/Pose Index (Def. nil)
- # Viewport viewport, Viewport used (Def. nil)
- #-------------------------------------------------------------------------
- def initialize(actor, x, y, speed = 1, frame = 0, pose = 0, viewport = nil)
- # Call Sprite#initialize and Send Viewport
- super(viewport)
- # Setup Instance Variables
- @actor, @speed = actor, speed
- # Setup Position
- self.x = x
- self.y = y
- self.z = 101
- # Setup Bitmap
- self.bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
- # Setup Other Variables
- @name, @hue, @animate = @actor.character_name, @actor.character_hue, false
- # Setup Pose if string sent
- pose = MACL::Poses.index(pose) if pose.is_a?(String)
- # Setup Pose and Frame
- self.pose, self.frame = pose, frame
- # Setup Counter Instance Variable
- @count = 0
- end
- #-------------------------------------------------------------------------
- # * Name : Set Graphic
- # Info : Sets Graphic to (Frame, Pose)
- # Author : Trickster
- # Call Info : Two Arguments
- # Integer Frame, Frame
- # String/Integer Pose, Pose Type/Pose Index
- #-------------------------------------------------------------------------
- def set_graphic(pose, frame)
- # Set Pose and Frame
- self.pose, self.frame = pose, frame
- end
- #-------------------------------------------------------------------------
- # * Name : Set Pose
- # Info : Sets The Pose
- # Author : Trickster
- # Call Info : One Argument, String/Integer Pose Pose Type/Pose Index
- #-------------------------------------------------------------------------
- def pose=(pose)
- # Turn pose into an integer if string sent
- pose = MACL::Poses.index(pose) if pose.is_a?(String)
- # Return if pose is nil or same pose
- return if pose == nil or pose == @pose
- # Set Y Coordinate of Source Rectangle
- src_rect.y = bitmap.height / MACL::Poses.size * pose
- # Set Height of Source Rectangle
- src_rect.height = bitmap.height / MACL::Poses.size
- # Set Pose
- @pose = pose
- end
- #-------------------------------------------------------------------------
- # * Name : Set Frame
- # Info : Sets the Frame
- # Author : Trickster
- # Call Info : One Argument, Integer Frame, Frame to set
- #-------------------------------------------------------------------------
- def frame=(frame)
- # Return if frame is nil or same frame
- return if frame == nil or frame == @frame
- # Set X Coordinate of Source Rectangle
- src_rect.x = bitmap.width / MACL::Frames * frame
- # Set Height of Source Rectangle
- src_rect.width = bitmap.width / MACL::Frames
- # Set Frame
- @frame = frame
- end
- #-------------------------------------------------------------------------
- # * Name : Frame Update
- # Info : Update Animation if enabled, Updates Graphic
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def update
- # Call Sprite Update
- super
- # Update Graphic
- update_graphic
- # Return if not animated
- return if not @animate or @speed == 0
- # Increase Counter
- @count += 1
- # Return if speed frames have not passed
- return if @count % @speed != 0
- # Set Frame Restrict to [0, frames)
- self.frame = (self.frame + 1) % MACL::Frames
- end
- #-------------------------------------------------------------------------
- # * Name : Update Graphic (Private)
- # Info : Private Method, Updates Actor Graphic
- # Author : Trickster
- # Call Info : No Arguements, can not be called outside this class
- #-------------------------------------------------------------------------
- private
- def update_graphic
- # Return if no changes made
- return if @name == @actor.character_name and @hue == @actor.character_hue
- # Update Name and Hue
- @name, @hue = @actor.character_name, @actor.character_hue
- # Set New Bitmap
- self.bitmap = RPG::Cache.character(@name, @hue)
- end
- end
- #==============================================================================
- # ** Classes.Sprite_WindowText By Trickster
- #------------------------------------------------------------------------------
- # A specialized sprite class that is to be placed onto a window
- #==============================================================================
- MACL::Loaded << 'Classes.Sprite_WindowText'
- #==============================================================================
- # ** Sprite_WindowText
- #==============================================================================
- class Sprite_WindowText < Sprite
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :text
- attr_reader :width
- #-------------------------------------------------------------------------
- # * Name : Object Initialization
- # Info : Creates a New Window Text Sprite
- # Author : Trickster
- # Call Info : Zero to Five Integer X and Y Defines Position
- # String Text - Text to be Drawn
- # Font font - font to be used
- # Viewport - Viewport of the sprite
- #-------------------------------------------------------------------------
- def initialize(x = 0, y = 0, text = '', font = Font.new, viewport = nil)
- # Call Sprite#initialize and send viewport
- super(viewport)
- # Set Coordinates
- self.x, self.y = x, y
- # Set Bitmap
- self.bitmap = Bitmap.new(32, 32)
- # Set Text
- @text = text
- # Set Font
- @font = font
- # Set Bitmap font
- bitmap.font = @font
- # Setup Tagging Type
- @sprite_type = 'border'
- # Setup Text
- setup_text
- end
- #-------------------------------------------------------------------------
- # * Name : Set Text
- # Info : Changes Text and Updates Sprite
- # Author : Trickster
- # Call Info : One Argument String Text - new text
- #-------------------------------------------------------------------------
- def text=(text)
- # Return if same text
- return if @text == text
- # Set New Text
- @text = text
- # Setup Text
- setup_text
- end
- #-------------------------------------------------------------------------
- # * Name : Width
- # Info : Changes width and Updates Sprite
- # Author : Trickster
- # Call Info : One Argument Integer width - new width
- #-------------------------------------------------------------------------
- def width=(width)
- # Return if same width
- return if @width == width
- # Set New Width
- @width = width
- # Setup Text
- setup_text
- end
- #-------------------------------------------------------------------------
- # * Name : Setup Text (Private)
- # Info : Set up Text Bitmap
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- private
- def setup_text
- # Get Size of Text
- size = bitmap.text_size(@text).width
- # Dispose Previous Bitmap
- bitmap.dispose if bitmap != nil and size != bitmap.width
- # Create Bitmap
- self.bitmap = Bitmap.new(@width.nil? ? (size == 0 ? 32 : size) : @width, 32)
- # Set Font
- self.bitmap.font = @font
- # Draw Text onto bitmap
- self.bitmap.draw_text(0, 0, size, 32, @text)
- end
- end
- #==============================================================================
- # ** Classes.Table_Object By: Selwyn
- #------------------------------------------------------------------------------
- # Three Dimensional Array for any Object.
- #
- # - resizing any dimension will destroy the data.
- # - negative values for x, y, z can be used.
- # e.g. table[-1, -1, -1] will return the last object of the table
- #
- #==============================================================================
- MACL::Loaded << 'Classes.Table_Object'
- class Table_Object
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :xsize
- attr_reader :ysize
- attr_reader :zsize
- #--------------------------------------------------------------------------
- # * Name : Object Initialization
- # Info : Creates a new Object Table Object
- # Author : Selwyn
- # Call Info : Two-Three Arguments
- # Two - Integer xsize, ysize - dimensions
- # Three - Integer xsize, ysize, zsize - dimensions
- #--------------------------------------------------------------------------
- def initialize(xsize, ysize, zsize = 0)
- @xsize = xsize
- @ysize = ysize
- @zsize = zsize
- @data = []
- @indexes = []
- make_array
- end
- #--------------------------------------------------------------------------
- # * Name : Element Reference
- # Info : Gets an Element returns Element At ID or X,Y,Z
- # Author : Selwyn
- # Call Info : One-Two-Three Arguments
- # One - Integer id - id of the element to get
- # Two - Integer x,y - X and Y.
- # Three - Integer x,y,z - X, Y and Z.
- #--------------------------------------------------------------------------
- def [](*args)
- case args.size
- when 1
- return @data[args[0]]
- when 2, 3
- return @data[id(*args)]
- end
- end
- #--------------------------------------------------------------------------
- # * Name : Element Assignment
- # Info : Assigns an Object to Element
- # Author : Selwyn
- # Call Info : Two-Three-Four Arguments
- # Two Integer id - id of the Element to set
- # Object obj - object assigned to id
- # Three Integer x,y - X and Y.
- # Object obj - object assigned to id.
- # Four Integer x,y,z - X, Y and Z.
- # Object obj - object assigned to id.
- #--------------------------------------------------------------------------
- def []=(*args)
- case args.size
- when 2
- @data[args[0]] = args[1]
- when 3
- @data[id(args[0], args[1])] = args[2]
- when 4
- @data[id(args[0], args[1], args[2])] = args[3]
- end
- end
- #--------------------------------------------------------------------------
- # * Name : Set X Size
- # Info : Sets Width of the Table
- # Author : Selwyn
- # Call Info : One Argument Integer xsize - new size
- #--------------------------------------------------------------------------
- def xsize=(xsize)
- @xsize = xsize
- make_array
- end
- #--------------------------------------------------------------------------
- # * Name : Set Y Size
- # Info : Sets Height of the Table
- # Author : Selwyn
- # Call Info : One Argument Integer ysize - new size
- #--------------------------------------------------------------------------
- def ysize=(ysize)
- @ysize = ysize
- make_array
- end
- #--------------------------------------------------------------------------
- # * Name : Set Z Size
- # Info : Sets Depth of the Table
- # Author : Selwyn
- # Call Info : One Argument Integer zsize - new size
- #--------------------------------------------------------------------------
- def zsize=(zsize)
- @zsize = zsize
- make_array
- end
- #--------------------------------------------------------------------------
- # * Name : Set Size
- # Info : Sets Dimensions of the Table
- # Author : Selwyn
- # Call Info : Two or Three - Integer xsize, ysize, zsize - Dimensions
- #--------------------------------------------------------------------------
- def resize(xsize, ysize, zsize = 0)
- @xsize = xsize
- @ysize = ysize
- @zsize = zsize
- make_array
- end
- #--------------------------------------------------------------------------
- # * Name : Make Array
- # Info : Creates Data Array
- # Author : Selwyn
- # Call Info : No Arguments
- #--------------------------------------------------------------------------
- def make_array
- max = @xsize * @ysize * (@zsize + 1)
- @data = nil
- @data = Array.new(max)
- @indexes = []
- if @zsize > 0
- for i in 0...max
- xy = i % (@xsize * @ysize)
- x = xy % @xsize
- y = xy / @xsize
- z = (i - xy) / (@xsize * @ysize)
- @indexes << [x, y, z]
- end
- else
- for i in 0...max
- @indexes << [i % @xsize, i / @xsize]
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Name : ID
- # Info : Returns id of element
- # Author : Selwyn
- # Call Info : Two or Three Arguments Integer X and Y and Z
- #--------------------------------------------------------------------------
- def id(x, y, z = 0)
- x %= @xsize; y %= @ysize; z %= @zsize
- return (x + y * @xsize) + (@xsize * @ysize * z)
- end
- #--------------------------------------------------------------------------
- # * Name : Coord
- # Info : Gets Coordinates - Array [x, y(, z)]
- # Author : Selwyn
- # Call Info : One Integer ID, Id to get coordinates from
- #--------------------------------------------------------------------------
- def coord(id)
- #xy = id % (@xsize * @ysize)
- #x = xy % @xsize
- #y = xy / @xsize
- #z = (id - xy) / (@xsize * @ysize)
- return @indexes[id]
- end
- #--------------------------------------------------------------------------
- # * Name : Clear
- # Info : Clears the Table
- # Author : Selwyn
- # Call Info : No Arguments
- #--------------------------------------------------------------------------
- def clear
- @data.clear
- end
- #--------------------------------------------------------------------------
- # * Name : Size
- # Info : Returns the Table size
- # Author : Selwyn
- # Call Info : No Arguments
- #--------------------------------------------------------------------------
- def size
- @data.size
- end
- #--------------------------------------------------------------------------
- # * Name : ID Index
- # Info : Returns the ID position of the object in the Table
- # Author : Selwyn
- # Call Info : Object object
- #--------------------------------------------------------------------------
- def id_index(object)
- return @data.index(object)
- end
- #--------------------------------------------------------------------------
- # * Name : Coord Index
- # Info : Returns the Coordinates of the object in the Table
- # Author : Selwyn
- # Call Info : Object object
- #--------------------------------------------------------------------------
- def coord_index(object)
- return coord(@data.index(object))
- end
- end
- #==============================================================================
- # ** Classes.Window ReadFile (1.01) By SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to allow you to open a text file and display
- # the lines on a window. It can read the lines directly and draw the text
- # or it can evaluate it as direct code.
- #
- # As an added feature, there is a feature that will allow you to open the
- # window on the map with a simple call script and dispose of the window
- # just as easy.
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Creating Window Object
- # - <object> = Window_ReadFile.new(x, y, w, h, filename, complex, ls)
- #
- # x, y, w & h - Window Size
- # filename - filename
- # complex - true (lines evaluated as direct script) or
- # false (lines draws as text)
- # ls - linespacing (usually 24 or 32)
- #
- # Opening Window On Map
- # - $scene.open_readfile_w(x, y, w, h, filename, complex, ls)
- #==============================================================================
- MACL::Loaded << 'Classes.Window_ReadFile'
- #==============================================================================
- # ** Window_ReadFile
- #==============================================================================
- class Window_ReadFile < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #
- # If complex is true, each line is read as direct code (For scripters)
- # If complex is false, each line will be directly read and drawn
- #
- # Line Spacing is the Space Between Lines (Only Needed for non-complex)
- #--------------------------------------------------------------------------
- def initialize(x, y, w, h, filename, complex = true, line_spacing = 24)
- # Creates Window
- super(x, y, w, h)
- # Opens File
- lines = IO.readlines(filename)
- # If Complex
- if complex
- # Passes Through Each Line of Code - Evaluates Line
- lines.each { |line| eval line }
- # If Simple
- else
- # Creates Bitmap
- self.contents = Bitmap.new(width - 32, lines.size * line_spacing)
- # Passes Through Each Line
- for i in 0...lines.size
- rect = Rect.new(0, i * line_spacing, contents.width, line_spacing)
- self.contents.draw_text(rect, lines[i])
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- super
- # If Active
- if self.active
- # If Up is Pressed
- if Input.press?(Input::UP)
- self.oy -= 4 if self.oy > 0
- # If Down is Pressed
- elsif Input.press?(Input::DOWN)
- self.oy += 4 if self.oy < self.contents.height - 64
- end
- end
- end
- end
- #==============================================================================
- # ** Scene_Map
- #==============================================================================
- class Scene_Map
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_wndrf_scnmap_update, :update
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # If ReadFile Window Present
- unless @readfile_window.nil?
- # Update Readfile
- update_seph_readfilewindow
- return
- end
- # Original Update
- seph_wndrf_scnmap_update
- end
- #--------------------------------------------------------------------------
- # * Frame Update : ReadFile Window
- #--------------------------------------------------------------------------
- def update_seph_readfilewindow
- # If B Button is Pressed
- if Input.trigger?(Input::B)
- # Play Cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Delete ReadFile Window
- @readfile_window.dispose
- @readfile_window = nil
- end
- end
- #--------------------------------------------------------------------------
- # * Open ReadFile Window
- #--------------------------------------------------------------------------
- def open_readfile_w(x, y, w, h, f, c = true, ls = 24)
- # Creates ReadFile Window
- @readfile_window = Window_ReadFile.new(x, y, w, h, f, c, ls)
- end
- end
- #==============================================================================
- # ** Classes.Window_Scrollable By: Trickster
- #------------------------------------------------------------------------------
- # This window class contains scroll functions. To use create a window,
- # inheriting From this class set <window>.contents_rect to the rect of all the
- # text, speed to the speed of scrolling, and horizontal/vertical_scroll to
- # true to allow scrolling, for a practical example on how to use see my
- # Advanced Mission script
- #==============================================================================
- MACL::Loaded << 'Classes.Window_Scrollable'
- #==============================================================================
- # ** Window_Scrollable
- #==============================================================================
- class Window_Scrollable < Window_Base
- #-------------------------------------------------------------------------
- # * Public Instance Variables
- #-------------------------------------------------------------------------
- attr_accessor :speed
- attr_accessor :contents_rect
- attr_writer :horizontal_scroll
- attr_writer :vertical_scroll
- #-------------------------------------------------------------------------
- # * Name : Initialize
- # Info : Object Initialization
- # Author : Trickster
- # Call Info : Four Arguments
- # Integer X and Y, Define Starting Position
- # Width and Height, Define Width and Height of the Window
- #-------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @contents_rect = Rect.new(0,0,width,height)
- @speed = 0
- @horizontal_scroll = false
- @vertical_scroll = false
- end
- #-------------------------------------------------------------------------
- # * Name : Vertical?
- # Info : Can window's contents move Vertically?
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def vertical?
- return false if self.contents == nil
- return self.contents.height > self.height - 32
- end
- #-------------------------------------------------------------------------
- # * Name : Horizontal?
- # Info : Can window's contents move Horizontally
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def horizontal?
- return false if self.contents == nil
- return self.contents.width > self.width - 32
- end
- #-------------------------------------------------------------------------
- # * Name : Update
- # Info : Frame Update
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def update
- super
- return if not self.active
- if Input.repeat?(Input::UP)
- if self.oy > @contents_rect.y and @vertical_scroll and vertical?
- self.oy = [self.oy - speed, @contents_rect.y].max
- end
- end
- if Input.repeat?(Input::LEFT)
- if self.ox > @contents_rect.x and @horizantal_scroll and horizantal?
- self.ox = [self.ox - speed, @contents_rect.x].max
- end
- end
- if Input.repeat?(Input::DOWN)
- if self.oy < @contents_rect.height - (self.height - 32) and @vertical_scroll and vertical?
- self.oy = [self.oy + speed, @contents_rect.height].min
- end
- end
- if Input.repeat?(Input::RIGHT)
- if self.ox < @contents_rect.width - (self.width - 32) and @horizantal_scroll and horizantal?
- self.ox = [self.ox - speed, @contents_rect.width].min
- end
- end
- end
- end
- #==============================================================================
- # ** Classes.Window_SelectableCommand By: Trickster
- #------------------------------------------------------------------------------
- # This window deals with general command choices. Also Includes a Cursor
- # Height Parameter which controls the Cursor's Height.
- #==============================================================================
- MACL::Loaded << 'Classes.Window_SelectableCommand'
- #==============================================================================
- # ** Window_SelectableCommand
- #==============================================================================
- class Window_SelectableCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :command
- attr_accessor :cursor_height
- #-------------------------------------------------------------------------
- # * Initialize
- #-------------------------------------------------------------------------
- def initialize(width, commands)
- # Compute window height from command quantity
- super(0, 0, width, commands.size * 32 + 32)
- # Setup Item Max and Commands
- @commands, @item_max = commands, commands.size
- # Sets Up Cursor Height
- @cursor_height = 32
- # Setup Index
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # * Get Top Row
- #--------------------------------------------------------------------------
- def top_row
- # Divide y-coordinate of window contents transfer origin by 1 row
- # height of @cursor_height
- return self.oy / @cursor_height
- end
- #--------------------------------------------------------------------------
- # * Set Top Row
- #--------------------------------------------------------------------------
- def top_row=(row)
- # If row is less than 0, change it to 0
- if row < 0
- row = 0
- end
- # If row exceeds row_max - 1, change it to row_max - 1
- if row > row_max - 1
- row = row_max - 1
- end
- # Multiply 1 row height by 32 for y-coordinate of window contents
- # transfer origin
- self.oy = row * @cursor_height
- end
- #--------------------------------------------------------------------------
- # * Get Number of Rows Displayable on 1 Page
- #--------------------------------------------------------------------------
- def page_row_max
- # Subtract a frame height of 32 from the window height, and divide it by
- # 1 row height of @cursor_height
- return (self.height - 32) / @cursor_height
- end
- #--------------------------------------------------------------------------
- # * Command
- #--------------------------------------------------------------------------
- def command(index = self.index)
- return @commands[index]
- end
- #-------------------------------------------------------------------------
- # * Set Commands
- #-------------------------------------------------------------------------
- def commands=(commands)
- # Return if Commands Are Same
- return if @commands == commands
- # Reset Commands
- @commands = commands
- # Resets Item Max
- item_max = @item_max
- @item_max = @commands.size
- # If Item Max Changes
- unless item_max == @item_max
- # Deletes Existing Contents (If Exist)
- self.contents.dispose unless self.contents.nil?
- # Recreates Contents
- self.contents = Bitmap.new(width - 32, @item_max * 32)
- end
- # Refresh Window
- refresh
- end
- #-------------------------------------------------------------------------
- # * Refresh
- #-------------------------------------------------------------------------
- def refresh
- # Clear Contents
- self.contents.clear
- # Setup Item Max
- @item_max.times {|i| draw_item(i, normal_color)}
- end
- #-------------------------------------------------------------------------
- # * Draw Item
- #-------------------------------------------------------------------------
- def draw_item(index, color)
- # Setup Font Color
- self.contents.font.color = color
- # Setup Rect
- rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
- # Erase At Rect
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- # Draw Command
- self.contents.draw_text(rect, @commands[index])
- end
- #-------------------------------------------------------------------------
- # * Disable Item
- #-------------------------------------------------------------------------
- def disable_item(index)
- # Draw In Disabled Color
- draw_item(index, disabled_color)
- end
- #--------------------------------------------------------------------------
- # * Update Cursor Rectangle
- #--------------------------------------------------------------------------
- def update_cursor_rect
- # If cursor position is less than 0 or not active
- if @index < 0 or not self.active
- self.cursor_rect.empty
- return
- end
- # Get current row
- row = @index / @column_max
- # If current row is before top row
- if row < self.top_row
- # Scroll so that current row becomes top row
- self.top_row = row
- end
- # If current row is more to back than back row
- if row > self.top_row + (self.page_row_max - 1)
- # Scroll so that current row becomes back row
- self.top_row = row - (self.page_row_max - 1)
- end
- # Calculate cursor width
- cursor_width = self.width / @column_max - 32
- # Calculate cursor coordinates
- x = @index % @column_max * (cursor_width + 32)
- y = @index / @column_max * @cursor_height - self.oy
- # Update cursor rectangle
- self.cursor_rect.set(x, y, cursor_width, @cursor_height)
- end
- end
- #===============================================================================
- # * Classes.Zoomed_Sprite By: Trickster
- #-------------------------------------------------------------------------------
- # This class is for displaying a zoomed in sprite. It inherits from
- # class Sprite. Allows for the programmer to specify a zoom level when creating
- # Sprites and also width and height methods that get the width and height of
- # the Sprite and not the Bitmap
- #===============================================================================
- MACL::Loaded << 'Classes.Zoomed_Sprite'
- #==============================================================================
- # ** Zoomed_Sprite
- #==============================================================================
- class Zoomed_Sprite < Sprite
- #-------------------------------------------------------------------------
- # * Name : Initialize
- # Info : Object Initialization
- # Author : Trickster
- # Call Info : Zero to Two Arguments
- # Float Zoom_Level, the level of zooming (Defaults to 1.0)
- # Viewport viewport, the viewport used (Defaults to whole screen)
- #-------------------------------------------------------------------------
- def initialize(zoom_level = 1.0, viewport = nil)
- super(viewport)
- self.zoom_x = zoom_level
- self.zoom_y = zoom_level
- end
- #-------------------------------------------------------------------------
- # Name : Get Width
- # Info : Gets the width of the sprite or 0 if no bitmap
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def width
- return 0 if bitmap.nil?
- return self.bitmap.width * self.zoom_x
- end
- #-------------------------------------------------------------------------
- # Name : Get Height
- # Info : Gets the height of the sprite or 0 if no bitmap
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def height
- return 0 if bitmap.nil?
- return self.bitmap.height * self.zoom_y
- end
- end
- #==============================================================================
- # ** Modules.Battle Simulator (1.0) By SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to let you create custom troops easily and test
- # them or default test battles.
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Starting Battle Simulator vs. Single Enemy
- # - BattleSimulator.start_enemy_battle(enemy_id)
- #
- # Starting Battle Simulator vs. Multiple Enemies
- # - BattleSimulator.start_custom_troop_battle([enemy_id, ...])
- #------------------------------------------------------------------------------
- # * Changing Battle Simulator Settings
- #
- # Enemy EXP Drop Percent (Defaults to 100%)
- # - $game_system.battle_simulator.exp_percent = n
- #
- # Enemy Gold Drop Percent (Defaults to 100%)
- # - $game_system.battle_simulator.gold_percent = n
- #
- # Enemy Treasure Drop Probability
- # - $game_system.battle_simulator.drop_percent = n
- #==============================================================================
- MACL::Loaded << 'Modules.Battle Simulator'
- #==============================================================================
- # ** BattleSimulator
- #==============================================================================
- module BattleSimulator
- #--------------------------------------------------------------------------
- # * Flags
- #--------------------------------------------------------------------------
- @delete_last_troop = false
- @previous_scene = $scene.class
- #--------------------------------------------------------------------------
- # * Start Enemy Battle
- #--------------------------------------------------------------------------
- def self.start_enemy_battle(enemy_id)
- # Start Custom Troop Battle
- self.start_custom_troop_battle([enemy_id])
- end
- #--------------------------------------------------------------------------
- # * Start Custom Troop Battle
- #--------------------------------------------------------------------------
- def self.start_custom_troop_battle(enemies)
- # Create Dummy Troop
- new_troop = RPG::Troop.new
- new_troop.id = $data_troops.size
- new_troop.name = 'Battle Simulator'
- new_troop.members = []
- # Pass Through Enemies
- for i in 0...enemies.size
- # Create Member Page
- member = RPG::Troop::Member.new
- member.enemy_id = enemies[i]
- member.x = 640 / (enemies.size + 1) * (i + 1)
- member.y = 320 - rand(40)
- new_troop.members << member
- end
- # Add Troop to Data Troop
- $data_troops << new_troop
- # Set Flags
- @delete_last_troop = true
- # Start Troop Battle
- self.start_troop_battle(new_troop.id)
- end
- #--------------------------------------------------------------------------
- # * Start Troop Battle
- #--------------------------------------------------------------------------
- def self.start_troop_battle(troop_id)
- # Change Battle Simulator Settings
- $game_system.battle_simulator.on = true
- # Memorize map BGM and stop BGM
- $game_temp.map_bgm = $game_system.playing_bgm
- $game_system.bgm_stop
- # Play battle start SE
- $game_system.se_play($data_system.battle_start_se)
- # Play battle BGM
- $game_system.bgm_play($game_system.battle_bgm)
- # Straighten player position
- $game_player.straighten
- # Memorize Scene
- @previous_scene = $scene.class
- # Set Battle Troop ID
- $game_temp.battle_troop_id = troop_id
- # Switch to battle screen
- $scene = Scene_Battle.new
- end
- #--------------------------------------------------------------------------
- # * End Battle
- #
- # Result - 0 : Win ; 1 : Lose ; 2 : Escape
- #--------------------------------------------------------------------------
- def self.end_battle(result = 0)
- # Change Battle Simulator Settings
- $game_system.battle_simulator.on = false
- # Delete Troop if Flag set
- $data_troops.pop if @delete_last_troop
- # Turn Delete Last Troop Flag Off
- @delete_last_troop = false
- # Return to Previous Scene
- @previous_scene = @previous_scene.new
- end
- end
- #============================================================================
- # ** Game_System::Battle Simulator
- #============================================================================
- class Game_System::Battle_Simulator
- #------------------------------------------------------------------------
- # * Public Instance Variables
- #------------------------------------------------------------------------
- attr_accessor :on
- attr_accessor :exp_percent
- attr_accessor :gold_percent
- attr_accessor :drop_percent
- #------------------------------------------------------------------------
- # * Object Initialization
- #------------------------------------------------------------------------
- def initialize
- @on, @exp_percent, @gold_percent, @drop_percent = false, 100, 100, 100
- end
- end
- #==============================================================================
- # ** Game_System
- #==============================================================================
- class Game_System
- #------------------------------------------------------------------------
- # * Public Instance Variables
- #------------------------------------------------------------------------
- attr_accessor :battle_simulator
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :macl_gmsys_init, :initialize
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- # Original Initialization
- macl_gmsys_init
- # Set game system settings
- @battle_simulator = Game_System::Battle_Simulator.new
- end
- end
- #==============================================================================
- # ** Game_Temp
- #==============================================================================
- class Game_Temp
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_battlesimulator_gmtmp_bcl, :battle_can_lose
- #--------------------------------------------------------------------------
- # * Battle can lose test
- #--------------------------------------------------------------------------
- def battle_can_lose
- result = $game_temp.nil? ? false : $game_system.battle_simulator.on
- return seph_battlesimulator_gmtmp_bcl || result
- end
- end
- #==============================================================================
- # ** Game_Enemy
- #==============================================================================
- class Game_Enemy
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_battlesimulator_gmeny_exp, :exp
- alias_method :seph_battlesimulator_gmeny_gld, :gold
- alias_method :seph_battlesimulator_gmeny_tsp, :treasure_prob
- #--------------------------------------------------------------------------
- # * Get EXP
- #--------------------------------------------------------------------------
- def exp
- n = seph_battlesimulator_gmeny_exp
- if $game_system.battle_simulator.on
- n = Integer(n * ($game_system.battle_simulator.exp_percent / 100.0))
- end
- return n
- end
- #--------------------------------------------------------------------------
- # * Get Gold
- #--------------------------------------------------------------------------
- def gold
- n = seph_battlesimulator_gmeny_gld
- if $game_system.battle_simulator.on
- n = Integer(n * ($game_system.battle_simulator.gold_percent / 100.0))
- end
- return n
- end
- #--------------------------------------------------------------------------
- # * Get Treasure Appearance Probability
- #--------------------------------------------------------------------------
- def treasure_prob
- n = seph_battlesimulator_gmeny_tsp
- if $game_system.battle_simulator.on
- n = Integer(n * ($game_system.battle_simulator.drop_percent / 100.0))
- end
- return n
- end
- end
- #==============================================================================
- # ** Modules.Bitmap File Dump (1.01) By SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to let you save bitmaps as information files
- #------------------------------------------------------------------------------
- # * Instructions
- #
- # Make Sure there is a folder in your game folder named 'Saved Bitmaps'
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Saving Bitmap :
- # - BitmapDump.save_bitmap(<bitmap>, 'filename')
- #
- # Loading Bitmap :
- # - BitmapDump.load_bitmap('filename')
- #==============================================================================
- MACL::Loaded << 'Modules.BitmapFileDump'
- #==============================================================================
- # ** BitmapDump
- #==============================================================================
- module BitmapDump
- #--------------------------------------------------------------------------
- # * Directory
- #--------------------------------------------------------------------------
- Directory = 'Graphics/Saved Images'
- #--------------------------------------------------------------------------
- # * Save Bitmap
- #--------------------------------------------------------------------------
- def self.save_bitmap(bitmap, filename)
- # Creates Color Values Table
- red = Table.new(bitmap.width, bitmap.height)
- green = Table.new(bitmap.width, bitmap.height)
- blue = Table.new(bitmap.width, bitmap.height)
- alpha = Table.new(bitmap.width, bitmap.height)
- # Collects Bimap Pixels and saves
- for i in 0...bitmap.width
- for j in 0...bitmap.height
- color = bitmap.get_pixel(i, j)
- red[i, j] = color.red
- green[i, j] = color.green
- blue[i, j] = color.blue
- alpha[i, j] = color.alpha
- end
- end
- # Saves File
- file = File.open(Directory + filename + '.rxdata', 'wb')
- Marshal.dump([red, green, blue, alpha], file)
- file.close
- end
- #--------------------------------------------------------------------------
- # * Save Bitmap
- #--------------------------------------------------------------------------
- def self.read_bitmap(filename)
- # Opens File
- file = File.open(Directory + filename + '.rxdata', "rb")
- colors = Marshal.load(file)
- file.close
- # Assigns Color Tables
- red, green, blue, alpha = colors[0], colors[1], colors[2], colors[3],
- colors[4]
- bitmap = Bitmap.new(red.xsize, red.ysize)
- # Sets Bitmap Pixels
- for i in 0...bitmap.width
- for j in 0...bitmap.height
- bitmap.set_pixel(i, j, Color.new(red[i, j], green[i, j], blue[i, j],
- alpha[i, j]))
- end
- end
- # Returns Bitmap
- return bitmap
- end
- end
- #==============================================================================
- # ** Modules.Curve Generator Module (4.0) By Trickster & SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to generate a curve of numbers given certain
- # values. As of now, their are 3 formulas for you to choose from : Point-
- # slope; Early & Late; Early / Steady / Late + Curves.
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Generating Curve :
- # - curve = Curve_Generator.generate_curve(type, <args>)
- #
- # Type : 0 - Point Slope
- # 1 - Early / Late
- # 2 - Early / Steady / Late + Curves
- #
- # Args :
- #
- # Type 0 : min_level, max_level, start value, inflation
- # Type 1 : min_level, max_level, min_value, max_value, early, late
- # Type 2 : min level, mid_level, max level, min value, mid_value,
- # max value, early, late, steady, curve 1, curve 2, integer
- #
- # This will return a hash : { level => value, ... }
- #==============================================================================
- MACL::Loaded << 'Modules.Curve_Generator'
- #==============================================================================
- # ** Curve_Generator
- #==============================================================================
- module Curve_Generator
- #--------------------------------------------------------------------------
- # * Generate Curve
- #
- # Type : 0 - Point Slope
- # 1 - Early / Late
- # 2 - Early / Steady / Late + Curves
- #
- # Args :
- #
- # Type 0 : min_level, max_level, start value, inflation
- # Type 1 : min_level, max_level, min_value, max_value, early, late
- # Type 2 : min level, mid_level, max level, min value, mid_value,
- # max value, early, late, steady, curve 1, curve 2, integer
- #--------------------------------------------------------------------------
- def self.generate_curve(type, *args)
- # Collects Saved Tables
- tables = self.load_tables
- # Check for Previously Generated Table
- if tables.has_key?(type) && tables[type].has_key?(args)
- # Return Previously Generated Table
- return tables[type][args]
- end
- # Branch Point By Type
- case type
- when 0 # Point Slope
- table = Point_Slope.generate_curve(*args)
- when 1 # Early / Late
- table = Early_Late.generate_curve(*args)
- when 2 # Early / Stead / Late + Curves
- table = ESL_Curves.generate_curve(*args)
- end
- # Set 0 Defaults
- table.default = 0
- # Saves Table Information
- self.save_table(type, args, table)
- # Return Curve Information
- return table
- end
- #-------------------------------------------------------------------------
- # * Save Table
- #-------------------------------------------------------------------------
- def self.save_table(type, args, table)
- # Collects Saved Tables
- tables = self.load_tables
- # Creates Hash of Type (If non present)
- tables[type] = {} unless tables.has_key?(type)
- # Saves Table Data
- tables[type][args] = table
- # Resaves Tables to File
- save_data(tables, 'Data/Curve Generator.rxdata')
- end
- #-------------------------------------------------------------------------
- # * Load Tables
- #-------------------------------------------------------------------------
- def self.load_tables
- # Test For Saved Table File
- unless FileTest.exist?('Data/Curve Generator.rxdata')
- # Creates Curve Generator Rxdata File
- save_data({}, 'Data/Curve Generator.rxdata')
- end
- # Returns Saved Tables
- return load_data('Data/Curve Generator.rxdata')
- end
- #============================================================================
- # ** Point Slope
- #============================================================================
- module Point_Slope
- #------------------------------------------------------------------------
- # * Generate Curve
- #
- # Args : min_level, max_level, start value, inflation
- #------------------------------------------------------------------------
- def self.generate_curve(min_l, max_level, start_value, inflation)
- # Creates Table
- table = {}
- # Fills Table
- for level in min_l..max_l
- table[level] = start_value + inflation * level
- end
- # Return Table
- return table
- end
- end
- #============================================================================
- # ** Early Late
- #============================================================================
- module Early_Late
- #------------------------------------------------------------------------
- # * Generate Curve
- #------------------------------------------------------------------------
- def self.generate_curve(min_l, max_l, min_v, max_v, e = 1.0, l = 1.0)
- # Creates Table
- table = {}
- # Fills Table
- for level in min_l..max_l
- # Assigns Value
- table[i] = self.calculate_value(i, min_l.to_f, max_l.to_f,
- min_v.to_f, max_v.to_f, e.to_f, l.to_f)
- end
- # Return Table
- return table
- end
- #------------------------------------------------------------------------
- # * Late Curve
- #------------------------------------------------------------------------
- def self.late_curve(level, min_level, max_level, min, max)
- diff = min_level - max_level
- stat = min - max
- num = stat * level ** 2 - 2 * min_level * stat * level + min_level ** 2 *
- max - 2 * min_level * max_level * min + min * min_level ** 2
- denom = diff ** 2
- return num / denom
- end
- #------------------------------------------------------------------------
- # * Early Curve
- #------------------------------------------------------------------------
- def self.early_curve(level, min_level, max_level, min, max)
- diff = max_level - min_level
- stat = max - @min
- num = -stat * level ** 2 + 2 * max_level * stat * level + min_level **
- 2 * max - 2 * min_level * max_level * max + min * max_level ** 2
- denom = diff ** 2
- return num / denom
- end
- #------------------------------------------------------------------------
- # * Steady Curve
- #------------------------------------------------------------------------
- def self.steady_curve(level, min_level, max_level, min, max)
- ch_level = max_level - min_level
- ch_stat = max - min
- base = ch_stat / ch_level * level
- mod = max * min_level - min * max_level
- base2 = mod / ch_level
- return base - base2
- end
- #------------------------------------------------------------------------
- # * Calculate Value
- #------------------------------------------------------------------------
- def self.calculate_value(level, min_level, max_level, min, max, e, l)
- return min if level < min_level
- return max if max_level < level
- if e == l
- stat = self.steady_curve(level, min_level, max_level, min, max)
- else
- early_ = self.early_curve(level, min_level, max_level, min, max)
- late_ = self.late_curve(level, min_level, max_level, min, max)
- stat = (e * early_ + l * late_) / (e + l)
- end
- stat = Integer([[stat, min].max, max].min)
- return stat
- end
- end
- #============================================================================
- # ** ESL_Curves
- #============================================================================
- module ESL_Curves
- #------------------------------------------------------------------------
- # * Generate Curve
- #------------------------------------------------------------------------
- def self.generate_curve(mn_v, md_v, mx_v, mn_l, md_l, mx_l, e = 0, l = 0,
- s = 0, c1 = 0, c2 = 0, i = true)
- # Saves Values
- @min_value, @mid_value, @max_value = mn_v, md_v, mx_v
- @min_level, @mid_level, @max_level = mn_l, md_l, mx_l
- @early , @late , @steady = e , l , s
- @curve1 , @curve2 , @integer = c1 , c2 , i
- # Error Checking
- self.error_checking
- # Calculate constants
- self.calculate_constants
- # Returns Table
- return self.generate_table
- end
- #-----------------------------------------------------------------------
- # * Error Checking
- #-----------------------------------------------------------------------
- def self.error_checking
- if @late + @early + @steady + @curve1 + @curve2 == 0
- raise(StandardError, "No Influences Have Been Defined")
- elsif @min_level == @mid_level || @min_level == @max_level ||
- @mid_level == @max_level
- raise(StandardError, "Can't Use Same Level for Min, Mid, or Max Level")
- end
- end
- #-----------------------------------------------------------------------
- # * Calculate Constants
- #-----------------------------------------------------------------------
- def self.calculate_constants
- # Calculate "infi" and "inmi"
- @inmi = (@mid_value - @min_value) / (@mid_level - @min_level)
- @infi = (@max_value - @min_value) / (@max_level - @min_level)
- # Calculate "infimi"
- @infimi = (@infi - @inmi) / (@max_level - @mid_level)
- end
- #-----------------------------------------------------------------------
- # * Generate Table
- #-----------------------------------------------------------------------
- def self.generate_table
- # Create Hash table
- table = {}
- # Run Through Each Level
- self.each {|level, value| table[level] = value}
- # Return Created Table
- return table
- end
- #-----------------------------------------------------------------------
- # * Each Interator
- #-----------------------------------------------------------------------
- def self.each
- # Get Minimum level and Maximum Level
- minimum, maximum = @min_level.to_i, @max_level.to_i
- # Run Through Minimum and Maximum and Yield Level and Value
- (minimum..maximum).each {|level| yield(level, self.get_stat(level))}
- end
- #-----------------------------------------------------------------------
- # * Get Stat
- #-----------------------------------------------------------------------
- def self.get_stat(level)
- return @integer ? @min_value.to_i : @min_value if level <= @min_level
- return @integer ? @max_value.to_i : @max_value if level >= @max_level
- # Setup Total
- total = 0
- # Get Values for Every Stat if greater than 0
- total += @early * self.early_curve(level) if @early > 0
- total += @late * self.late_curve(level) if @late > 0
- total += @steady * self.steady_curve(level) if @steady > 0
- total += @curve1 * self.early_late_curve(level) if @curve1 > 0
- total += @curve2 * self.late_early_curve(level) if @curve2 > 0
- # Get Average
- total /= @late + @early + @steady + @curve1 + @curve2
- # Limit Value
- total = level < @mid_level ?
- [total, @mid_value].min : [total, @mid_value].max
- # Further Limit Value
- total = [[total, @min_value].max, @max_value].min
- # Return Value
- return @integer ? total.to_i : total
- end
- #-----------------------------------------------------------------------
- # * Late Curve
- #-----------------------------------------------------------------------
- def self.late_curve(level)
- # Calculate "A"
- a_num = @infimi * (3 * @min_level + @mid_level) + @inmi
- a_den = (@max_level - @min_level) * (@mid_level - @min_level)
- a = - a_num / a_den
- # Return Value
- return curve(a, level)
- end
- #-----------------------------------------------------------------------
- # * Early Curve
- #-----------------------------------------------------------------------
- def self.early_curve(level)
- # Calculate "A"
- a_num = @infimi * (2 * @max_level + @min_level + @mid_level) + @inmi
- a_den = (@max_level - @mid_level) * (@max_level - @min_level)
- a = - a_num / a_den
- # Return Value
- return curve(a, level)
- end
- #-----------------------------------------------------------------------
- # * Early Late Curve
- #-----------------------------------------------------------------------
- def self.early_late_curve(level)
- # Calculate "A"
- a = @infimi / (@max_level + @min_level - 2 * @mid_level)
- # Return Value
- return curve(a, level)
- end
- #-----------------------------------------------------------------------
- # * Late Early Curve
- #-----------------------------------------------------------------------
- def self.late_early_curve(level)
- # If Less than Mid Level
- if level < @mid_level
- # Return Late Curve for level
- return late_curve(level)
- # If Greater than Mid Level
- elsif level > @mid_level
- # Return Early Curve for Level
- return early_curve(level)
- # If at Mid Level
- elsif level == @mid_level
- # Return Mid Value
- return @mid_value
- end
- end
- #-----------------------------------------------------------------------
- # * Steady Curve
- #-----------------------------------------------------------------------
- def self.steady_curve(level)
- ch_level = @max_level - @min_level
- ch_stat = @max_value - @min_value
- base = ch_stat / ch_level * level
- mod = @max_value * @min_level - @min_level * @max_level
- base2 = mod / ch_level
- return base - base2
- end
- #-----------------------------------------------------------------------
- # * Curve
- #-----------------------------------------------------------------------
- def self.curve(a, level)
- # Calculate "B"
- b = @infimi - a * (@min_level + @mid_level + @max_level)
- # Calculate "C"
- c = @inmi - a * (@mid_level ** 2 + @min_level * @mid_level +
- @min_level ** 2) - b * (@mid_level + @min_level)
- # Calculate "D"
- d = @min_value - (a * @min_level ** 3 + b * @min_level ** 2 + c *
- @min_level)
- # Calculate Stat
- stat = a * level ** 3 + b * level ** 2 + c * level + d
- # Return Stat
- return stat
- end
- end
- end
- #==============================================================================
- # ** Modules.Event Spawner (2.02) By SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to allow you to create events via scripts. It
- # will create events immeditately, and can save created events perm. on the
- # map after creation, or appear once. You can also clone events, performing
- # modifications via Event Spawner module, or immeditely end the clone
- # event process and move the new event to a position.
- #------------------------------------------------------------------------------
- # * Instructions :
- #
- # THIS SCRIPT IS COMPLEX!!! I TOOK HOURS OF COMMENTING, RUNNING THROUGH
- # ALL EVENT CODES & PARAMETERS (600+ LINES), AND MAKING THIS SCRIPT EASIER
- # TO USE. PLEASE READ THE CREATION & EVENT COMMAND CODES & PARAMETERS
- # BEFORE ASKING FOR SUPPORT!
- #
- # If you are ever unsure of a event layout, insert this at the top of event
- # commands
- #
- # Call Script :
- #
- # for event_command in $game_map.events[event_id].list
- # p [event_command.code, event_command.parameters, event_command.indent]
- # end
- #
- # Write down the code, parameters & indention, and use the add event command
- # function to create event commands.
- #
- # To see instructions on creating events, refer to creation instrucitons.
- # To see event command codes & parameters, refer to event command c & p.
- #------------------------------------------------------------------------------
- # * Making Events Without Huge Call Scripts :
- #
- # This script has a built-in sub-module that will create events with a
- # simple 1-line call script, rather than creating a 15 line call script.
- #
- # To create a simple event spawn, search for the Presets module, directly
- # below the Event_Spawner module heading.
- #
- # Create a method name, which should match the event you are creating. For
- # example; if you were creating a event on your map that will show a simple
- # text message, you can use a name such as
- #
- # def self.sample_event_text
- #
- # Make sure to put the self. in from of your method name, or it will not
- # read the method and you will have an error.
- #
- # Basic Syntax For Method Naming
- #
- # def self.<event_name>
- #
- # Feel free to use method arguments as well (If you don't understand this,
- # do not worry about it)
- #
- #
- # Once your method is defined, you can now put what you would put in your
- # call script here in the method name.
- #
- # Finish you method by adding a end and you are finished.
- #
- #
- # Example Preset Event:
- #
- # def self.sample_event_a
- # Event_Spawner.create_event(3, 5, 'Sample Event A')
- # Event_Spawner.set_page_graphic({'c_name' => '002-Fighter02'})
- # Event_Spawner.add_event_command(101, ['I am a spawned event'])
- # Event_Spawner.end_event
- # end
- #
- # ~ Creates an event at 3, 5 named Sample Event A
- # ~ Sets 1st Page Graphic Character Name to 002-Fighter02
- # ~ Creates Event Command : Show Message (Code 101)
- # ~ Ends Event
- #
- # To call your event preset, use
- #
- # Event_Spawner.Presets.<method_name>
- #
- # (This Basically Serves as nothing more than call scripts in the script
- # itself, rather than the events.)
- #------------------------------------------------------------------------------
- # * Event Creation Instructions :
- #
- #
- # **** Basic Event Creation Procedure ****
- #
- # 1) Create Event
- # 2) Set Page Graphics & Conditions
- # 3) Set Page Conditions
- # 4) Add New Page (If Needed)
- # 5) Repeat Steps 2-4 as needed
- # 6) End Event
- #
- #
- # **** Syntax Instructions *****
- #
- # Creating Event
- # - Event_Spawner.create_event(x = 0, y = 0, name = '')
- #
- # Adding Event Command
- # - Event_Spawner.add_event_command(code, parameters = [], indent = 0)
- #
- # Setting Page Condition
- # - Event_Spawner.set_page_condition({<parameters>})
- # 'switch1' => switch_id
- # 'switch2' => switch_id
- # 'selfswitch' => 'A', 'B', 'C' or 'D'
- # 'variable' => [variable_id, value]
- #
- # Setting Page Graphic
- # - Event_Spawner.set_page_graphic(
- # 'tileid' => id
- # 'c_name' => 'character_filename'
- # 'c_hue' => 0..360
- # 'dir' => 2 : Down, 4 : Left, 6 : Right, 8 : Up
- # 'pattern' => 0..3
- # 'opacity' => 0..255
- # 'blend' => 0 : Normal, 1 : Addition, 2 : Subtraction
- #
- # Setting Page Trigger
- # - Event_Spawner.set_page_trigger(trigger)
- # 0 : Action Button, 1 : Contact With Player, 2 - Contact With Event
- # 3 : Autorun, 4 : Parallel Processing
- #
- # Set Page Move Settings
- # - Event_Spawner.set_page_move_settings({<parameters>})
- # 'type' => 0 : fixed, 1 : random, 2 : approach, 3 : custom).
- # 'speed' => 1 : slowest ... 6 : fastest
- # 'freq' => 1 : lowest ... 6 : highest
- # 'route' => RPG::MoveRoute (See Generate Move Route)
- #
- # Generate Move Route
- # - Event_Spawner.generate_move_route(list = [], repeat, skippable)
- # See Method Heading For List Parameters
- #------------------------------------------------------------------------------
- # * Event Command Code & Parameters
- #
- # ~~ Show Text
- # - Code : 101 (Lines After First Line : 401)
- # - Parameters : ['Text Line']
- #
- # ~~ Show Choices
- # - Code : 102
- # - Parameters : Did not comment on yet
- #
- # ~~ When [**]
- # - Code : 402
- # - Parameters : Did not comment on yet
- #
- # ~~ When Cancel
- # - Code : 403
- # - Parameters : Did not comment on yet
- #
- # ~~ Input Number
- # - Code : 103
- # - Parameters : Did not comment on yet
- # ~~ Change Text Options
- # - Code : 104
- # - Parameters : [ <message_position>, <message_frame> ]
- #
- # <message_position> - (0 : Up, 1 : Middle, 2 : Down)
- # <message_frame> - (0 : Visible, 1 : Invisible)
- #
- # ~~ Button Input Processing
- # - Code : 105
- # - Parameters : [ variable_id ]
- #
- # ~~ Wait
- # - Code : 106
- # - Parameters : [ frames ]
- #
- # ~~ Comment :
- # - Code : 108 (Lines After First Line - 408)
- # - Parameters : [ 'Comment Text' ]
- #
- # ~~ Conditional Branch
- # - Code : 111
- # - Parameters : Did not comment on yet
- #
- # ~~ Else
- # - Code : 411
- # - Parameters : Did not comment on yet
- #
- # ~~ Loop
- # - Code : 112
- # - Parameters : Did not comment on yet
- #
- # ~~ Repeat Above
- # - Code : 413
- # - Parameters : Did not comment on yet
- #
- # ~~ Break Loop
- # - Code : 113
- # - Parameters : Did not comment on yet
- #
- # ~~ Exit Event Processing
- # - Code : 115
- # - Parameters : []
- #
- # ~~ Erase Event
- # - Code : 116
- # - Parameters : []
- #
- # ~~ Call Common Event
- # - Code : 117
- # - Parameters : [ common_event_id ]
- #
- # ~~ Label
- # - Code : 118
- # - Parameters : [ 'label_name' ]
- #
- # ~~ Jump to Label
- # - Code : 119
- # - Parameters : [ 'label_name' ]
- #
- # ~~ Control Switches
- # - Code : 121
- # - Parameters : [ start_variable, end_variable, <boolean> ]
- #
- # <boolean> - (0 : On, 1 : Off)
- #
- # ~~ Control Variables
- # - Code : 122
- # - Parameters : [ start_var_id, end_var_id, <opperation>, <opperand>, <p> ]
- #
- # <opperation> - (0: Set, 1: +, 2: -, 3: *, 4: /, 5: %)
- # <opperand> - (0: Constant, 1: Variable, 2: Random Number, 3: Item,
- # 4: Hero, 5: Monster, 6: Sprite, 7: Other)
- # <p>
- # When <opperand> is Constant (0)
- # - n
- # When <opperand> is Variable (1)
- # - variable_id
- # When <opperand> is Random Number (2)
- # - lower, higher
- # When <opperand> is Item (3)
- # - item_id
- # When <opperand> is Hero (4)
- # - hero_id, <stat> (See <stat> Below)
- # When <opperand> is Monster (5)
- # - monster_id, <stat> (See <stat> Below)
- # When <opperand> is Sprite (6)
- # - <event_id>, <tile>
- #
- # <event_id> - (-1: Player, 0: This Event, 1-X: Event ID)
- # <tile> - (0: X Tile, 1: Y Tile, 2: Face, 3: Screen X, 4: Screen Y,
- # 5:Terrain)
- # When <opperand> is Other (7)
- # - (0: Map ID, 1: Party Size, 2: Money, 3: # of Steps,
- # 4: Timer in Secs, 5: # of Saves)
- #
- # <stat> - (0: HP, 1: SP, 2: Max HP, 3: Max SP, 4: Str,
- # 5: Dex, 6: Agi, 7: Int, 8: Atk, 9: PDef, 10: MDef, 11: Eva)
- # ~~ Control Self Switch
- # - Code : 123
- # - Parameters : [ 'switch_letter', <boolean> ]
- #
- # <boolean> - (0 : On, 1 : Off)
- #
- # ~~ Control Timer
- # - Code : 124
- # - Parameters : [ <boolean>, seconds ]
- #
- # <boolean> - (0 : On, 1 : Off)
- #
- # ~~ Change Gold
- # - Code : 125
- # - Parameters : [ <operation>, <type>, <operand> ]
- #
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change Items
- # - Code : 126
- # - Parameters : [ item_id, <operation>, <type>, <operand> ]
- #
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change Weapons
- # - Code : 127
- # - Parameters :[ weapon_id, <operation>, <type>, <operand> ]
- #
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change Armor
- # - Code : 128
- # - Parameters :[ armor_id, <operation>, <type>, <operand> ]
- #
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change Party Member
- # - Code : 129
- # - Parameters : [ actor_id, <operation>, <reset> ]
- #
- # <operation> - (0 : Add, 1 : Remove)
- # <reset> - (0 : Leave As Is, 1 : Reset Actor Information)
- #
- # ~~ Change Windowskin
- # - Code : 131
- # - Parameters : [ 'windowskin_name' ]
- #
- # ~~ Change Battle BGM
- # - Code : 132
- # - Parameters : [ 'battle_bgm' ]
- #
- # ~~ Change Battle End ME
- # - Code : 133
- # - Parameters : [ 'battle_me' ]
- #
- # ~~ Change Save Access
- # - Code : 134
- # - Parameters : [ <boolean> ]
- #
- # <boolean> - (0 : On, 1 : Off)
- #
- # ~~ Change Menu Access
- # - Code : 135
- # - Parameters : [ <boolean> ]
- #
- # <boolean> - (0 : On, 1 : Off)
- #
- # ~~ Change Encounter
- # - Code : 136
- # - Parameters : [ <boolean> ]
- #
- # <boolean> - (0 : On, 1 : Off)
- #
- # ~~ Transfer Player
- # - Code : 201
- # - Parameters : [ <type>, <map_id>, <x>, <y>, <direction> ]
- #
- # <type> - (0 : Constant, 1 : Game Variable)
- # <map_id> - number or variable_id
- # <x> - number or variable_id
- # <x> - number or variable_id
- # <direction> - (2 : Down, 4 : Left, 6 : Right, 8 : Up)
- #
- # ~~ Set Event Location
- # - Code : 202
- # - Parameters : [ <target_event>, <type>, <params>, <direction> ]
- #
- # <target_event> - (-1 : Player, 0 : Current Event, N : Event ID)
- # <type> - (0 : Constant, 1 : Variables, 2 : Switch With Event)
- # <params>
- # When type is Constant (0) - target_x, target_y
- # When type is Variables (1) - x_variable, y_variable
- # When type is Switch Event (2) - event_id
- # <direction> - (2 : Down, 4 : Left, 6 : Right, 8 : Up)
- #
- # ~~ Scroll Map
- # - Code : 203
- # - Parameters : [ <direction>, distance, speed ]
- #
- # <direction> - (2 : Down, 4 : Left, 6 : Right, 8 : Up)
- #
- # ~~ Change Map Settings
- # - Code : 204
- # - Parameters : [ <type>, <params> ]
- #
- # <type> - (0 : Panorama, 1 : Fog, 2 : Battleback)
- # <params>
- # When type is Panorama (0) - name, hue
- # When type is Fog (1) - name, hue, opacity, blend_type, zoom, sx, sy
- # When type is Battleback (2) - name
- #
- # ~~ Change Fog Color Tone
- # - Code : 205
- # - Parameters : [ tone, duration ]
- #
- # ~~ Change Fog Opacity
- # - Code : 206
- # - Parameters : [ opacity, duration ]
- #
- # ~~ Show Animation
- # - Code : 207
- # - Parameters : [ <target_event>, animation_id ]
- #
- # <target_event> - (-1 : Player, 0 : Current Event, N : Event ID)
- #
- # ~~ Change Transparent Flag
- # - Code : 208
- # - Parameters : [ <boolean> ]
- #
- # <boolean> - (0 : Transparent, 1 : Non-Transparent)
- #
- # ~~ Set Move Route
- # - Code : 209
- # - Parameters : [ <target_event>, RPG::MoveRoute ]
- #
- # <target_event> - (-1 : Player, 0 : Current Event, N : Event ID)
- #
- # ~~ Wait for Move's Completion
- # - Code : 210
- # - Parameters : []
- #
- # ~~ Prepare for Transition
- # - Code : 221
- # - Parameters : []
- #
- # ~~ Execute Transition
- # - Code : 222
- # - Parameters : [ transition_name ]
- #
- # ~~ Change Screen Color Tone
- # - Code : 223
- # - Parameters : [ tone, duration ]
- #
- # ~~ Screen Flash
- # - Code : 224
- # - Parameters : [ color, duration ]
- #
- # ~~ Screen Shake
- # - Code : 225
- # - Parameters : [ power, speed, duration ]
- #
- # ~~ Show Picture
- # - Code : 231
- # - Parameters : [ pic_id, name orgin, <type>, <x>, <y>,
- # zoom_x, zoom_y, opacity, blend_type ]
- #
- # <type> - (0 : Constant, 1 : Variables)
- # <x> - number or variable_id
- # <y> - number or variable_id
- #
- # ~~ Move Picture
- # - Code : 232
- # - Parameters : [ pic_id, name orgin, <type>, <x>, <y>,
- # zoom_x, zoom_y, opacity, blend_type ]
- #
- # <type> - (0 : Constant, 1 : Variables)
- # <x> - number or variable_id
- # <y> - number or variable_id
- #
- # ~~ Rotate Picture
- # - Code : 233
- # - Parameters : [ pic_id, angel ]
- #
- # ~~ Change Picture Color Tone
- # - Code : 234
- # - Parameters : [ pic_id, tone, duration ]
- #
- # ~~ Erase Picture
- # - Code : 235
- # - Parameters : [ pic_id ]
- #
- # ~~ Set Weather Effects
- # - Code : 236
- # - Parameters : [ <type>, power, duration ]
- #
- # <type> - (0 : None, 1 : Rain, 2: Storm; 3: Snow)
- #
- # ~~ Play BGM
- # - Code : 241
- # - Parameters : [ RPG::AudioFile ]
- #
- # ~~ Fade Out BGM
- # - Code : 242
- # - Parameters : [ time ]
- #
- # ~~ Play BGS
- # - Code : 245
- # - Parameters : [ RPG::AudioFile ]
- #
- # ~~ Fade Out BGS
- # - Code : 246
- # - Parameters : [ time ]
- #
- # ~~ Memorize BGM/BGS
- # - Code : 247
- # - Parameters : []
- #
- # ~~ Restore BGM/BGS
- # - Code : 248
- # - Parameters : []
- #
- # ~~ Play ME
- # - Code : 249
- # - Parameters : [ RPG::AudioFile ]
- #
- # ~~ Play SE
- # - Code : 250
- # - Parameters : [ RPG::AudioFile ]
- #
- # ~~ Stop SE
- # - Code : 251
- # - Parameters : []
- #
- # ~~ Battle Processing
- # - Code : 301
- # - Parameters : [ troop_id, can_escape_boolean, can_lose_boolean ]
- #
- # ~~ If Win
- # - Code : 601
- # - Parameters : []
- #
- # ~~ If Escape
- # - Code : 602
- # - Parameters : []
- #
- # ~~ If Lose
- # - Code : 603
- # - Parameters : []
- #
- # ~~ Shop Processing
- # - Code : 302 (For Additional Shop Item Setup - 605)
- # - Parameters : [ [ <item_type>, item_id] ]
- #
- # <item_type> - (0 : Item, 1 : Weapon, 2 : Armor)
- #
- # ~~ Name Input Processing
- # - Code : 303
- # - Parameters : [ actor_id, max_characters ]
- #
- # ~~ Change HP
- # - Code : 311
- # - Parameters : [ <actors>, <operation>, <type>, <operand> ]
- #
- # <actors> - (0 : All Party Actors, N : Actor ID)
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change SP
- # - Code : 312
- # - Parameters : [ <actors>, <operation>, <type>, <operand> ]
- #
- # <actors> - (0 : All Party Actors, N : Actor ID)
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change State
- # - Code : 313
- # - Parameters : [ <actors>, <operation>, state_id ]
- #
- # <actors> - (0 : All Party Actors, N : Actor ID)
- # <operation> - (0 : Add State, 1 : Remove State)
- #
- # ~~ Recover All
- # - Code : 314
- # - Parameters :[ <actors> ]
- #
- # <actors> - (0 : All Party Actors, N : Actor ID)
- #
- # ~~ Change EXP
- # - Code : 315
- # - Parameters : [ <actors>, <operation>, <type>, <operand> ]
- #
- # <actors> - (0 : All Party Actors, N : Actor ID)
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change Level
- # - Code : 316
- # - Parameters : [ <actors>, <operation>, <type>, <operand> ]
- #
- # <actors> - (0 : All Party Actors, N : Actor ID)
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change Parameters
- # - Code : 317
- # - Parameters : [ <actors>, <parameter>, <operation>, <type>, <operand> ]
- #
- # <actors> - (0 : All Party Actors, N : Actor ID)
- # <parameter> - (0 : MaxHP, 1 : MaxSP, 2 : Str, 3 : Dex, 4 : Agi, 4 : Int)
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change Skills
- # - Code : 318
- # - Parameters : [ actor_id, <operation>, skill_id ]
- #
- # <operation> - (0 : Learn Skill, 1 : Forget Skill)
- #
- # ~~ Change Equipment
- # - Code : 319
- # - Parameters : [ actor_id, <equip_type>, equipment_id ]
- #
- # <equip_type> : (0 : Weapon, 1 : Shield, 2 : Head, 3 : Body, 4 : Acc)
- #
- # ~~ Change Actor Name
- # - Code : 320
- # - Parameters : [ actor_id, 'name' ]
- #
- # ~~ Change Actor Class
- # - Code : 321
- # - Parameters : [ actor_id, class_id ]
- #
- # ~~ Change Actor Graphic
- # - Code : 322
- # - Parameters : [ actor_id, character_name, character_hue,
- # battler_name, battler_hue ]
- #
- # ~~ Change Enemy HP
- # - Code : 331
- # - Parameters : [ <enemies>, <operation>, <type>, <operand> ]
- #
- # <enemies> - (0 : All Enemies, N : Enemy Index)
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change Enemy SP
- # - Code : 332
- # - Parameters : [ <enemies>, <operation>, <type>, <operand> ]
- #
- # <enemies> - (0 : All Enemies, N : Enemy Index)
- # <operation> - (0 : Increase, 1 : Decrease)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id
- #
- # ~~ Change Enemy State
- # - Code : 333
- # - Parameters : [ <enemies>, <operation>, state_id ]
- #
- # <enemies> - (0 : All Enemies, N : Enemy Index)
- # <operation> - (0 : Add State, 1 : Remove State)
- #
- # ~~ Enemy Recover All
- # - Code : 334
- # - Parameters : [ <enemies> ]
- #
- # <enemies> - (0 : All Enemies, N : Enemy Index)
- #
- # ~~ Enemy Appearance
- # - Code : 335
- # - Parameters : [ <enemies> ]
- #
- # <enemies> - (0 : All Enemies, N : Enemy Index)
- #
- # ~~ Enemy Transform
- # - Code : 336
- # - Parameters : [ enemy_index, target_enemy_id ]
- #
- # ~~ Show Battle Animation
- # - Code : 337
- # - Parameters : [ <target_troop>, <battlers>, animation_id ]
- #
- # <target_troop> - (0 : Enemies, 1 : Actors)
- # <battlers> - (0 : Entire Troop, N : Index)
- #
- # ~~ Deal Damage
- # - Code : 338
- # - Parameters : [ <target_troop>, <battlers>, <type>, <operand> ]
- #
- # <target_troop> - (0 : Enemies, 1 : Actors)
- # <battlers> - (0 : Entire Troop, N : Index)
- # <type> - (0: Constant 1: Variable)
- # <operand> - number or variable_id]
- #
- # ~~ Force Action
- # - Code : 339
- # - Parameters : [ <target_group>, <battlers>, <kind>, <basic>,
- # <target>, <forcing> ]
- #
- # <target_troop> - (0 : Enemies, 1 : Actors)
- # <battlers> - (0 : Entire Troop, N : Index)
- # <kind> - (0 : Attack/Guard, 1: Skill)
- # <basic>
- # When Kind is 0 - (0 : Attack, 1 : Guard)
- # When Kind is 1 - skill_id
- # <target> - (-2 : Last Target, -1 : Random Target, N : Target Index)
- # <forcing> - (0 : Execute Instead Of Next Move, 1 : Force Now)
- #
- # ~~ Abort Battle
- # - Code : 340
- # - Parameters : []
- #
- # ~~ Call Menu Screen
- # - Code : 351
- # - Parameters : []
- #
- # ~~ Call Save Screen
- # - Code : 352
- # - Parameters : []
- #
- # ~~ Game Over
- # - Code : 353
- # - Parameters : []
- #
- # ~~ Return to Title Screen
- # - Code : 354
- # - Parameters : []
- #
- # ~~ Script
- # - Code : 355 (Lines After First line - 655)
- # - Parameters : [ 'script text' ]
- #==============================================================================
- MACL::Loaded << 'Modules.Event Spawner'
- #==============================================================================
- # ** Event_Spawner
- #==============================================================================
- module Event_Spawner
- #--------------------------------------------------------------------------
- # * Event
- #--------------------------------------------------------------------------
- def self.event
- return @event
- end
- #--------------------------------------------------------------------------
- # * Create Event
- #--------------------------------------------------------------------------
- def self.create_event(x = 0, y = 0, name = '')
- # Creates New Event
- @event = RPG::Event.new(x, y)
- @event.name = name
- # Generates ID
- id = 1
- id += 1 while $game_map.events.keys.include?(id)
- id += 1 while self.saved_events($game_map.map_id).keys.include?(id)
- @event.id = id
- end
- #--------------------------------------------------------------------------
- # * Add Event Command (See Script Heading for Event Command Details)
- #--------------------------------------------------------------------------
- def self.add_event_command(code, parameters = [], indent = 0)
- # Creates New Event Command
- event_command = RPG::EventCommand.new
- # Sets Code, Parameters & Indent
- event_command.code = code
- event_command.parameters = parameters
- event_command.indent = indent
- # Adds Event Command To Page List
- self.get_current_page.list.insert(-2, event_command)
- end
- #--------------------------------------------------------------------------
- # * Set Page Condition
- #
- # 'switch1' => switch_id
- # 'switch2' => switch_id
- # 'selfswitch' => 'A', 'B', 'C' or 'D'
- # 'variable' => [variable_id, value]
- #--------------------------------------------------------------------------
- def self.set_page_condition(parameters = {})
- # Gets Last Page Condition Settings
- page_c = self.get_current_page.condition
- # If 'switch1' Found
- if parameters.has_key?('switch1')
- # Turns Switch 1 On & Sets ID
- page_c.switch1_valid = true
- page_c.switch1_id = parameters['switch1']
- end
- # If 'switch2' Found
- if parameters.has_key?('switch2')
- # Turns Switch 2 On & Sets ID
- page_c.switch2_valid = true
- page_c.switch2_id = parameters['switch1']
- end
- # If 'selfswitch' Found
- if parameters.has_key?('selfswitch')
- # Turns Self Switch ON & Sets Switch Variable
- page_c.self_switch_valid = true
- page_c.self_switch_ch = parameters['selfswitch']
- end
- # If 'variable' Found
- if parameters.has_key?('variable')
- # Turns Variable On, Sets Variable ID & Sets Value
- page_c.variable_valid = true
- page_c.variable_id = parameters['variable'][0]
- page_c.variable_value = parameters['variable'][1]
- end
- end
- #--------------------------------------------------------------------------
- # * Set Page Graphic
- #
- # 'tileid' => id
- # 'c_name' => 'character_filename'
- # 'c_hue' => 0..360
- # 'dir' => 2 : Down, 4 : Left, 6 : Right, 8 : Up
- # 'pattern' => 0..3
- # 'opacity' => 0..255
- # 'blend' => 0 : Normal, 1 : Addition, 2 : Subtraction
- #--------------------------------------------------------------------------
- def self.set_page_graphic(parameters = {})
- # Gets Last Page Graphic Settings
- page_g = self.get_current_page.graphic
- # Tile ID
- if parameters.has_key?('tileid')
- page_g.tile_id = parameters['tileid']
- end
- # Character Name
- if parameters.has_key?('c_name')
- page_g.character_name = parameters['c_name']
- end
- # Character Hue
- if parameters.has_key?('c_hue')
- page_g.character_hue = parameters['c_hue']
- end
- # Direction
- if parameters.has_key?('dir')
- page_g.direction = parameters['dir']
- end
- # Pattern
- if parameters.has_key?('pattern')
- page_g.pattern = parameters['pattern']
- end
- # Opacity
- if parameters.has_key?('opacity')
- page_g.opacity = parameters['opacity']
- end
- # Blend Type
- if parameters.has_key?('blend')
- page_g.blend_type = parameters['blend']
- end
- end
- #--------------------------------------------------------------------------
- # * Set Page Trigger
- #
- # 0 - Action Button
- # 1 - Contact With Player
- # 2 - Contact With Event
- # 3 - Autorun
- # 4 - Parallel Processing
- #--------------------------------------------------------------------------
- def self.set_page_trigger(trigger = 0)
- # Sets Last Page Trigger
- self.get_current_page.trigger = trigger
- end
- #--------------------------------------------------------------------------
- # * Set Page Move Settings
- #
- # 'type' => 0 : fixed, 1 : random, 2 : approach, 3 : custom).
- # 'speed' => 1 : slowest ... 6 : fastest
- # 'freq' => 1 : lowest ... 6 : highest
- # 'route' => RPG::MoveRoute (See Generate Move Route)
- #--------------------------------------------------------------------------
- def self.set_page_move_settings(parameters = {})
- # Gets Last Page
- page = self.get_current_page
- # Type
- if parameters.has_key?('type')
- page.move_type = parameters['type']
- end
- # Speed
- if parameters.has_key?('speed')
- page.move_speed = parameters['speed']
- end
- # Frequency
- if parameters.has_key?('freq')
- page.move_frequency = parameters['freq']
- end
- # Route
- if parameters.has_key?('route')
- if parameters['route'].is_a?(RPG::MoveRoute)
- page.move_route = parameters['route']
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Set Page Options
- #
- # 'walk_anime' => true or false
- # 'step_anime' => true or false
- # 'direction_fix' => true or false
- # 'through' => true or false
- # 'always_on_top' => true or false
- #--------------------------------------------------------------------------
- def self.set_page_options(parameters = {})
- # Gets Last Page
- page = self.get_current_page
- # Walk Animation
- if parameters.has_key?('walk_anime')
- page.walk_anime = parameters['walk_anime']
- end
- # Step Animation
- if parameters.has_key?('step_anime')
- page.step_anime = parameters['step_anime']
- end
- # Direction Fix
- if parameters.has_key?('direction_fix')
- page.direction_fix = parameters['direction_fix']
- end
- # Through
- if parameters.has_key?('through')
- page.through = parameters['through']
- end
- # Always On Top
- if parameters.has_key?('always_on_top')
- page.always_on_top = parameters['always_on_top']
- end
- end
- #--------------------------------------------------------------------------
- # * Add New Page
- #--------------------------------------------------------------------------
- def self.add_page
- @event.pages << RPG::Event::Page.new
- end
- #--------------------------------------------------------------------------
- # * Generate Move Route
- #
- # list = [ <move_command>, ... ]
- #
- # <move_command> : [code, parameters]
- #
- # If no parameters required :
- #
- # <move_command> : code
- #--------------------------------------------------------------------------
- def self.generate_move_route(list = [], repeat = true, skippable = false)
- # Creates New Move Route
- move_route = RPG::MoveRoute.new
- # Sets Repeat & Skipable
- move_route.repeat = repeat
- move_route.skippable = skippable
- # Passes Through List
- for move_command in list
- if move_command.is_a?(Array)
- code, parameters = move_command[0], move_command[1]
- else
- code, parameters = move_command, []
- end
- # Crates New MoveCommand
- move_command = RPG::MoveCommand.new
- # Adds MoveCommand to List
- move_route << move_command
- # Sets MoveCommand Properties
- move_command.parameters = parameters
- move_command.code = code
- end
- # Add Blank Move Command
- move_route << RPG::MoveCommand.new
- # Return Move Route
- return move_route
- end
- #--------------------------------------------------------------------------
- # * End Event
- #--------------------------------------------------------------------------
- def self.end_event(save_event = false)
- # Stop If nil Event Created
- return if @event.nil?
- # Add Event to Map & Spriteset Data
- $game_map.add_event(@event)
- # If Save Event Data
- if save_event
- # Creates Map Event Data (If none Present)
- unless @saved_events.has_key?((map_id = $game_map.map_id))
- @saved_events[map_id] = {}
- end
- # Saves Event Data
- @saved_events[map_id][@event.id] = @event
- end
- # Clear Event Data
- @event = nil
- end
- #--------------------------------------------------------------------------
- # * Clone Event
- #--------------------------------------------------------------------------
- def self.clone_event(target_id, new_x, new_y, new_name,
- end_event = false, save_event = false)
- # Stops If Event Not Found
- return unless $game_map.events.has_key?(target_id)
- # Gets Event Data
- @event = $game_map.events[target_id].event
- # Changes X, Y & name
- @event.x = new_x
- @event.y = new_y
- @event.name = new_name
- # Generates New ID
- id = 1
- id += 1 while $game_map.events.keys.include?(id)
- id += 1 while self.saved_events($game_map.map_id).keys.include?(id)
- @event.id = id
- # If End Event
- if end_event
- # Ends Event Creation
- self.end_event(save_event)
- end
- end
- #--------------------------------------------------------------------------
- # * Saved Events { map_id => { event_id => name }, ... }
- #--------------------------------------------------------------------------
- @saved_events = {}
- #--------------------------------------------------------------------------
- # * Saved Events (Read)
- #--------------------------------------------------------------------------
- def self.saved_events(map_id = nil)
- # If Map ID not Defined
- if map_id.nil?
- # Return All Saved Event Data
- return @saved_events
- end
- # If Map Data Saved
- if @saved_events.has_key?(map_id)
- # Return Map Saved Event Data
- return @saved_events[map_id]
- end
- # Return Blank Hash
- return {}
- end
- #--------------------------------------------------------------------------
- # * Saved Events (Write)
- #--------------------------------------------------------------------------
- def self.saved_events=(saved_events)
- @saved_events = saved_events
- end
- #--------------------------------------------------------------------------
- # * Current Page
- #--------------------------------------------------------------------------
- def self.get_current_page
- return @event.pages.last
- end
- end
- #==============================================================================
- # ** Game_Map
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_eventspawner_gmap_setup, :setup
- #--------------------------------------------------------------------------
- # * Setup
- #--------------------------------------------------------------------------
- def setup(map_id)
- # Original Map Setup
- seph_eventspawner_gmap_setup(map_id)
- # Passes Through All Saved Events
- Event_Spawner.saved_events(@map_id).values.each do |event|
- # Add Event
- add_event(event)
- end
- end
- end
- #==============================================================================
- # ** Scene_Save
- #==============================================================================
- class Scene_Save
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_eventspawner_scnsave_wsd, :write_save_data
- #--------------------------------------------------------------------------
- # * Write Save Data
- #--------------------------------------------------------------------------
- def write_save_data(file)
- # Original Write Data
- seph_eventspawner_scnsave_wsd(file)
- # Saves Saved Event Data
- Marshal.dump(Event_Spawner.saved_events, file)
- end
- end
- #==============================================================================
- # ** Scene_Load
- #==============================================================================
- class Scene_Load
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_eventspawner_scnload_rsd, :read_save_data
- #--------------------------------------------------------------------------
- # * Read Save Data
- #--------------------------------------------------------------------------
- def read_save_data(file)
- # Original Write Data
- seph_eventspawner_scnload_rsd(file)
- # Load Saved Event Data
- Event_Spawner.saved_events = Marshal.load(file)
- end
- end
- #==============================================================================
- # ** Modules.Game_Data (1.0) By SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This modules lets you add new $game_data objects to your game with a simple
- # call script within your script.
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Adding new $game_data object
- # - Game_Data.add_game_data('variable_name', 'Class_Name')
- #
- # Example : Adding new Game_Database to your $game datas.
- #
- # - Game_Data.add_game_data('$game_database', 'Game_Database')
- #==============================================================================
- MACL::Loaded << 'Modules.Game_Data'
- #==============================================================================
- # ** Game_Data
- #==============================================================================
- module Game_Data
- #--------------------------------------------------------------------------
- # * Instance Variable Setup
- #--------------------------------------------------------------------------
- @additions = []
- @variable_names = []
- #--------------------------------------------------------------------------
- # * Additions
- #--------------------------------------------------------------------------
- def self.additions
- return @additions
- end
- #--------------------------------------------------------------------------
- # * Add Game Data
- #--------------------------------------------------------------------------
- def self.add_game_data(global_variable_name, game_object_class)
- # If Variable Name Used
- if @variable_names.include?(global_variable_name)
- # Print Error
- p global_variable_name + ' already used. Please use a different ' +
- 'variable name.'
- return
- end
- # Add Addition
- @additions << [global_variable_name, game_object_class]
- end
- end
- #==============================================================================
- # ** Scene_Title
- #==============================================================================
- class Scene_Title
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_macladdgamedata_scnttl_cng, :command_new_game
- #--------------------------------------------------------------------------
- # * Command: New Game
- #--------------------------------------------------------------------------
- def command_new_game
- # Original Command: New Game
- seph_macladdgamedata_scnttl_cng
- # Pass Through Game Data List
- Game_Data.additions.each {|vg| eval "#{vg[0]} = #{vg[1]}.new"}
- end
- end
- #==============================================================================
- # ** Scene_Save
- #==============================================================================
- class Scene_Save
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_macladdgamedata_scnsv_wsd, :write_save_data
- #--------------------------------------------------------------------------
- # * Write Save Data
- #--------------------------------------------------------------------------
- def write_save_data(file)
- # Original Write Save Data
- seph_macladdgamedata_scnsv_wsd(file)
- # Pass Through Game Data List
- Game_Data.additions.each {|vg| eval "Marshal.dump(#{vg[0]}, file)"}
- end
- end
- #==============================================================================
- # ** Scene_Load
- #==============================================================================
- class Scene_Load
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_macladdgamedata_scnld_rsd, :read_save_data
- #--------------------------------------------------------------------------
- # * Read Save Data
- #--------------------------------------------------------------------------
- def read_save_data(file)
- # Original Read Save Data
- seph_macladdgamedata_scnld_rsd(file)
- # Pass Through Game Data List
- Game_Data.additions.each {|vg| eval "#{vg[0]} = Marshal.load(file)"}
- end
- end
- #==============================================================================
- # ** Modules.Interpreter (1.0) By SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to allow you to call event commands and custom
- # commands with a simple call script funcion. Most event commands are
- # included and several non-event commands were created.
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Show Text
- # - MInterpreter.show_text('line 1', 'line 2', 'line 3', 'line 4')
- # Erase Event
- # - MInterpreter.erase_event(event_id)
- # Call Common Event
- # - MInterpreter.common_event(event_id)
- # Control Switches
- # - MInterpreter.control_switches( { switch_id => state, ... } )
- # Control Variables
- # - MInterpreter.control_variables( { variable_id => value, ... } )
- # Control Self Switches
- # - MInterpreter.control_selfsw( { <key> => state, ... } )
- # Control Time
- # - MInterpreter.change_timer(state = false, seconds = 0)
- # Change Gold
- # - MInterpreter.change_gold( value )
- # Change Items
- # - MInterpreter.change_items( { item_id => n, ... } )
- # Change Weapons
- # - MInterpreter.change_weapons( { weapon_id => n, ... } )
- # Change Armors
- # - MInterpreter.change_armors( { armor_id => n, ... } )
- # Change Party Members
- # - MInterpreter.change_party(actor_id, add = true, initialize = true)
- # Change Windowskin
- # - MInterpreter.change_windowskin(filename = $game_system.windowskin_name)
- # Change Battle BGM
- # - MInterpreter.change_btlbgm(filename, volume = 100, pitch = 100)
- # Change Save Access
- # - MInterpreter.save_access(state = true)
- # Change Menu Access
- # - MInterpreter.menu_access(state = true)
- # Change Encounter
- # - MInterpreter.encounter(state = true)
- # Transfer Player
- # - MInterpreter.transfer_player(map_id, x, y, direction, fading = true)
- # Set Event Location
- # - MInterpreter.set_event_location(target_event_id, parameters, direction)
- # Scroll Map
- # - MInterpreter.scroll_map(direction, distance, speed)
- # Change Panorama
- # - MInterpreter.change_panorama(filename = current, hue = current)
- # Change Fog
- # - MInterpreter.change_fog(filename, hue, opacity, blend, zoom, sx, sy)
- # Change Fog Color
- # - MInterpreter.change_fog_color(tone, duration)
- # Change Fog Opacity
- # - MInterpreter.change_fog_opacity(opacity, duration)
- # Change Panorama
- # - MInterpreter.change_battleback(filename = current)
- # Show Animation
- # - MInterpreter.show_animation(target_id, animation_id)
- # Change Transparent Flag
- # - MInterpreter.change_player_transparent(state = true)
- # Execute Transition
- # - MInterpreter.execute_transition(filename = '')
- # Change Screen Color
- # - MInterpreter.change_screen_color(color, duration)
- # Screen Flash
- # - MInterpreter.flash_screen(color, duration)
- # Screen Shake
- # - MInterpreter.shake_screen(power, speed, duration)
- # Show Picture
- # - MInterpreter.show_picture(picture_number, filename, origin, x, y,
- # zoom_x, zoom_y, opacity, blend_type)
- # Move Picture
- # - MInterpreter.move_picture(picture_number, duration, origin, x, y,
- # zoom_x, zoom_y, opacity, blend_type)
- # Rotate Picture
- # - MInterpreter.rotate_picture(picture_number, speed)
- # Change Picture Tone
- # - MInterpreter.change_picture_tone(picture_number, tone, duration)
- # Erase Picture
- # - MInterpreter.erase_picture(picture_number)
- # Set Weather Effects
- # - MInterpreter.set_weather_effects(type, power, time)
- # Play BGM
- # - MInterpreter.play_bgm(filename, volume = 100, pitch = 100)
- # Fade Out BGM
- # - MInterpreter.fade_bgm(seconds = 0)
- # Play BGS
- # - MInterpreter.play_bgs(filename, volume = 100, pitch = 100)
- # Fade Out BGS
- # - MInterpreter.fade_bgm(seconds = 0)
- # Memorize BGM/BGS
- # - MInterpreter.memorize_bgms
- # Restore BGM/BGS
- # - MInterpreter.restore_bgms
- # Play ME
- # - MInterpreter.play_me(filename, volume = 100, pitch = 100)
- # Play SE
- # - MInterpreter.play_se(filename, volume = 100, pitch = 100)
- # Stop SE
- # - MInterpreter.stop_se
- # Battle Processing
- # - MInterpreter.battle_proc(troop_id, can_escape = true, can_lose = true)
- # Shop Processing
- # - MInterpreter.shop_proc(*goods)
- # Name Input Processing
- # - MInterpreter.name_input_proc(actor_id, max_chrs = 8)
- # Change Actor Stat
- # - MInterpreter.change_actor_stat(actor_id, stat_name, value)
- # Gain Actor Skills
- # - MInterpreter.gain_actor_skills(actor_id, *skill_ids)
- # Lose Actor Skills
- # - MInterpreter.lose_actor_skills(actor_id, *skill_ids)
- # Gain Actor States
- # - MInterpreter.gain_actor_states(actor_id, *skill_ids)
- # Lose Actor States
- # - MInterpreter.lose_actor_states(actor_id, *skill_ids)
- # Change Actor Equipment
- # - MInterpreter.change_actor_equip(actor_id, type, id)
- # Change Event Graphic
- # - MInterpreter.change_event_graphic(target_id, character_name, hue = 0)
- # Change Actor Character Graphic
- # - MInterpreter.change_actor_cgraphic(actor_id, character_name, hue = 0)
- # Change Actor Battler Graphic
- # - MInterpreter.change_actor_bgraphic(actor_id, battler_name, hue = 0)
- # Recover All
- # - MInterpreter.recover_all(actor_id, ...) (0 for actor id for all party)
- # Call Scene
- # - MInterpreter.call_scene(scene_name)
- # Save To Index
- # - MInterpreter.save_index(index = 0)
- # Save To Filename
- # - MInterpreter.save_filename(filename = 'Save File')
- # Load From Index
- # - MInterpreter.load_index(index = 0)
- # Load From Filename
- # - MInterpreter.load_filename(filename = 'Save File')
- #==============================================================================
- MACL::Loaded << 'Modules.Interpreter Module'
- #==============================================================================
- # ** Interpreter Module
- #==============================================================================
- module MInterpreter
- #--------------------------------------------------------------------------
- # * Show Text
- #
- # MInterpreter.show_text('line 1', 'line 2', 'line 3', 'line 4')
- #--------------------------------------------------------------------------
- def self.show_text(*text_lines)
- # Clear Message Text
- $game_temp.message_text = ''
- # Pass Through Each Line
- text_lines.each {|line| $game_temp.message_text += line + "\n"}
- end
- #--------------------------------------------------------------------------
- # * Erase Event
- #
- # MInterpreter.erase_event(event_id)
- #--------------------------------------------------------------------------
- def self.erase_event(event_id)
- # If Event Found
- if $game_map.events.has_key?(event_id)
- # Erase Event
- $game_map.events[event_id].erase
- end
- end
- #--------------------------------------------------------------------------
- # * Call Common Event
- #
- # MInterpreter.common_event(event_id)
- #--------------------------------------------------------------------------
- def self.common_event(c_event_id)
- # If Common Event Exist
- unless $data_common_events[c_event_id].nil?
- # If in Battle
- if $game_temp.in_battle
- # Run Common Event
- common_event = $data_common_events[c_event_id]
- $game_system.battle_interpreter.setup(common_event.list)
- # If Somewhere Else
- else
- # Set Temp Common Event ID
- $game_temp.common_event_id = c_event_id
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Control Switches
- #
- # MInterpreter.control_switches( { switch_id => state, ... } )
- #--------------------------------------------------------------------------
- def self.control_switches(switches)
- # Pass Through Every Switch and Set State
- switches.each { |switch_id, state| $game_switches[switch_id] = state }
- end
- #--------------------------------------------------------------------------
- # * Control Variables
- #
- # MInterpreter.control_variables( { variable_id => value, ... } )
- #--------------------------------------------------------------------------
- def self.control_variables(vars)
- # Pass Through Every Switch and State
- vars.each { |variable_id, value| $game_variables[variable_id] = value }
- end
- #--------------------------------------------------------------------------
- # * Control Self Switches
- #
- # MInterpreter.control_selfsw( { <key> => state, ... } )
- #
- # <key> = [map_id, event_id, letter] ( letter : 'A', 'B', 'C', 'D' )
- #--------------------------------------------------------------------------
- def self.control_selfsw(switches)
- # Pass Through Every Switch and State
- control_selfsw.each { |key, state| $game_self_switches[key] = state }
- end
- #--------------------------------------------------------------------------
- # * Control Time
- #
- # MInterpreter.change_timer(state = false, seconds = 0)
- #--------------------------------------------------------------------------
- def self.change_timer(state = false, seconds = 0)
- # Se Timer State
- $game_system.timer_working = state
- # Set Timer
- $game_system.timer = seconds * Graphics.frame_rate
- end
- #--------------------------------------------------------------------------
- # * Change Gold
- #
- # MInterpreter.change_gold( value )
- #--------------------------------------------------------------------------
- def self.change_gold(value)
- # Gain Gold
- $game_party.gain_gold(value)
- end
- #--------------------------------------------------------------------------
- # * Change Items
- #
- # MInterpreter.change_items( { item_id => n, ... } )
- #--------------------------------------------------------------------------
- def self.change_items(items)
- # Pass Through Each Item List
- items.each { |item_id, n| $game_party.gain_item(item_id, n) }
- end
- #--------------------------------------------------------------------------
- # * Change Weapons
- #
- # MInterpreter.change_weapons( { weapon_id => n, ... } )
- #--------------------------------------------------------------------------
- def self.change_weapons(weapons)
- # Pass Through Each Item List
- weapons.each { |weapon_id, n| $game_party.gain_weapon(weapon_id, n) }
- end
- #--------------------------------------------------------------------------
- # * Change Armors
- #
- # MInterpreter.change_armors( { armor_id => n, ... } )
- #--------------------------------------------------------------------------
- def self.change_armors(armors)
- # Pass Through Each Item List
- armors.each { |armor_id, n| $game_party.gain_armor(armor_id, n) }
- end
- #--------------------------------------------------------------------------
- # * Change Party Members
- #
- # MInterpreter.change_party(actor_id, add = true, initialize = true)
- #--------------------------------------------------------------------------
- def self.change_armors(actor_id, add = true, initialize = true)
- # Return if Nil Actor
- return if $data_actors[actor_id].nil?
- # Setup Actor If Initialize
- $game_actors[actor_id].setup(actor_id) if initialize
- # Add or Remove Actor
- add ? $game_party.add_actor(actor_id) :
- $game_party.remove_actor(actor_id)
- end
- #--------------------------------------------------------------------------
- # * Change Windowskin
- #
- # MInterpreter.change_windowskin(filename = $game_system.windowskin_name)
- #--------------------------------------------------------------------------
- def self.change_windowskin(filename = $game_system.windowskin_name)
- # Set Windowskin Filename
- $game_system.windowskin_name = filename
- end
- #--------------------------------------------------------------------------
- # * Change Battle BGM
- #
- # MInterpreter.change_btlbgm(filename, volume = 100, pitch = 100)
- #--------------------------------------------------------------------------
- def self.change_btlbgm(filename, volume = 100, pitch = 100)
- # Create AudioFile
- audiofile = RPG::AudioFile.new(filename, volume, pitch)
- # Set Battle BGM
- $game_system.battle_bgm = audiofile
- end
- #--------------------------------------------------------------------------
- # * Change Save Access
- #
- # MInterpreter.save_access(state = true)
- #--------------------------------------------------------------------------
- def self.save_access(state = true)
- # Change Save Disabled Flag
- $game_system.save_disabled = !state
- end
- #--------------------------------------------------------------------------
- # * Change Menu Access
- #
- # MInterpreter.menu_access(state = true)
- #--------------------------------------------------------------------------
- def self.menu_access(state = true)
- # Change Menu Disabled Flag
- $game_system.menu_disabled = !state
- end
- #--------------------------------------------------------------------------
- # * Change Encounter
- #
- # MInterpreter.encounter(state = true)
- #--------------------------------------------------------------------------
- def self.encounter(state = true)
- # Change Encounter Disabled Flag
- $game_system.encounter_disabled = !state
- end
- #--------------------------------------------------------------------------
- # * Transfer Player
- #
- # MInterpreter.transfer_player(map_id, x, y, direction, fading = true)
- #
- # Direction : 2 - Down, 4 - Left, 6 - Right, 8 - Up
- #--------------------------------------------------------------------------
- def self.transfer_player(m, x, y, d = $game_player.direction, f = true)
- # Set player move destination
- $game_temp.player_new_map_id = m
- $game_temp.player_new_x = x
- $game_temp.player_new_y = y
- $game_temp.player_new_direction = d
- # Transition
- if f
- # Prepare for transition
- Graphics.freeze
- # Set transition processing flag
- $game_temp.transition_processing = true
- $game_temp.transition_name = ''
- end
- end
- #--------------------------------------------------------------------------
- # * Set Event Location
- #
- # MInterpreter.set_event_location(target_event_id, parameters, direction)
- #
- # Target Event ID = 0 - Player or n - Event ID
- # Parameters = [event_id] or [x, y]
- # Direction : 2 - Down, 4 - Left, 6 - Right, 8 - Up
- #--------------------------------------------------------------------------
- def self.set_event_location(target_id, parameters, dir = 2)
- # Get Character
- character = target_id == 0 ? $game_player : $game_map.events[target_id]
- # Return if Nil
- return if character.nil?
- # If Switching Event Locations
- if parameters.size == 1
- # Get Other Character
- other_character = parameters[0] == 0 ? $game_player :
- $game_map.events[parameters[0]]
- # Return if Nil Character
- return if other_character.nil?
- # Clone Current Position
- old_x, old_y = character.x, character.y
- # Exchange Locations
- character.move_to(other_character.x, other_character.y)
- other_character.move_to(old_x, old_y)
- # Stop Method Execution
- return
- end
- # Moves Event
- character.move_to(parameters[0], parameters[1])
- end
- #--------------------------------------------------------------------------
- # * Scroll Map
- #
- # MInterpreter.scroll_map(direction, distance, speed)
- #--------------------------------------------------------------------------
- def self.scroll_map(direction, distance, speed)
- $game_map.start_scroll(direction, distance, speed)
- end
- #--------------------------------------------------------------------------
- # * Change Panorama
- #
- # MInterpreter.change_panorama(filename = current, hue = current)
- #--------------------------------------------------------------------------
- def self.change_panorama(filename = $game_map.panorama_name,
- hue = $game_map.panorama_hue)
- # Change Settings
- $game_map.panorama_name = filename
- $game_map.panorama_hue = hue
- end
- #--------------------------------------------------------------------------
- # * Change Fog
- #
- # MInterpreter.change_fog(filename, hue, opacity, blend, zoom, sx, sy)
- #
- # * Any Non-Defined will keep current settings
- #--------------------------------------------------------------------------
- def self.change_fog(filename = $game_map.fog_name, hue = $game_map.fog_hue,
- opacity = $game_map.fog_opacity, blend = $game_map.fog_blend_type,
- zoom = $game_map.fog_zoom, sx = $game_map.fog_sx, sy = $game_map.fog_sy)
- # Change Fog Settings
- $game_map.fog_name = filename
- $game_map.fog_hue = hue
- $game_map.fog_opacity = opacity
- $game_map.fog_blend_type = blend
- $game_map.fog_zoom = zoom
- $game_map.fog_sx = sx
- $game_map.fog_sy = sy
- end
- #--------------------------------------------------------------------------
- # * Change Fog Color
- #
- # MInterpreter.change_fog_color(tone, duration)
- #--------------------------------------------------------------------------
- def self.change_fog_color(tone, duration)
- # Start color tone change
- $game_map.start_fog_tone_change(tone, duration * 2)
- end
- #--------------------------------------------------------------------------
- # * Change Fog Opacity
- #
- # MInterpreter.change_fog_opacity(opacity, duration)
- #--------------------------------------------------------------------------
- def self.change_fog_opacity(opacity, duration)
- # Start opacity level change
- $game_map.start_fog_opacity_change(opacity, duration * 2)
- end
- #--------------------------------------------------------------------------
- # * Change Panorama
- #
- # MInterpreter.change_battleback(filename = current)
- #--------------------------------------------------------------------------
- def self.change_battleback(filename = $game_map.battleback_name)
- # Change Settings
- $game_map.battleback_name = filename
- $game_temp.battleback_name = filename
- end
- #--------------------------------------------------------------------------
- # * Show Animation
- #
- # MInterpreter.show_animation(target_id, animation_id)
- #--------------------------------------------------------------------------
- def self.show_animation(target_id, animation_id)
- # Get Character
- character = target_id == 0 ? $game_player : $game_map.events[target_id]
- # Return if Nil
- return if character.nil?
- # Set animation ID
- character.animation_id = animation_id
- end
- #--------------------------------------------------------------------------
- # * Change Transparent Flag
- #
- # MInterpreter.change_player_transparent(state = true)
- #--------------------------------------------------------------------------
- def self.change_player_transparent(state = true)
- # Change player transparent flag
- $game_player.transparent = state
- end
- #--------------------------------------------------------------------------
- # * Execute Transition
- #
- # MInterpreter.execute_transition(filename = '')
- #--------------------------------------------------------------------------
- def self.execute_transition(filename = '')
- # Return If transition processing flag is already set
- return if $game_temp.transition_processing
- # Prepare for transition
- Graphics.freeze
- # Set transition processing flag
- $game_temp.transition_processing = true
- $game_temp.transition_name = filename
- end
- #--------------------------------------------------------------------------
- # * Change Screen Color
- #
- # MInterpreter.change_screen_color(color, duration)
- #--------------------------------------------------------------------------
- def self.change_screen_color(color, duration)
- # Start changing color tone
- $game_screen.start_tone_change(color, duration * 2)
- end
- #--------------------------------------------------------------------------
- # * Screen Flash
- #
- # MInterpreter.flash_screen(color, duration)
- #--------------------------------------------------------------------------
- def self.flash_screen(color, duration)
- # Start flash
- $game_screen.start_flash(color, duration * 2)
- end
- #--------------------------------------------------------------------------
- # * Screen Shake
- #
- # MInterpreter.shake_screen(power, speed, duration)
- #--------------------------------------------------------------------------
- def self.shake_screen(power, speed, duration)
- # Start shake
- $game_screen.start_shake(power, speed, duration)
- end
- #--------------------------------------------------------------------------
- # * Show Picture
- #
- # MInterpreter.show_picture(picture_number, filename, origin, x, y,
- # zoom_x, zoom_y, opacity, blend_type)
- #
- # origin : 0 - Upper Left, 1 - Center
- # blend_type : 0 - normal, 1 - addition, 2 - subtraction
- #--------------------------------------------------------------------------
- def self.show_picture(picture_number, filename, origin, x, y, zoom_x,
- zoom_y, opacity, blend_type)
- # Get picture number
- picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
- # Show picture
- $game_screen.pictures[picture_number].show(picture_number, filename,
- origin, x, y, zoom_x, zoom_y, opacity, blend_type)
- end
- #--------------------------------------------------------------------------
- # * Move Picture
- #
- # MInterpreter.move_picture(picture_number, duration, origin, x, y,
- # zoom_x, zoom_y, opacity, blend_type)
- #
- # origin : 0 - Upper Left, 1 - Center
- # blend_type : 0 - normal, 1 - addition, 2 - subtraction
- #--------------------------------------------------------------------------
- def self.move_picture(picture_number, duration, origin, x, y, zoom_x,
- zoom_y, opacity, blend_type)
- # Get picture number
- picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
- # Move picture
- $game_screen.pictures[number].move(duration * 2, origin,
- x, y, zoom_x, zoom_y, opacity, blend_type)
- end
- #--------------------------------------------------------------------------
- # * Rotate Picture
- #
- # MInterpreter.rotate_picture(picture_number, speed)
- #--------------------------------------------------------------------------
- def self.rotate_picture(picture_number, speed)
- # Get picture number
- picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
- # Set rotation speed
- $game_screen.pictures[picture_number].rotate(speed)
- end
- #--------------------------------------------------------------------------
- # * Change Picture Tone
- #
- # MInterpreter.change_picture_tone(picture_number, tone, duration)
- #--------------------------------------------------------------------------
- def self.change_picture_tone(picture_number, tone, duration)
- # Get picture number
- picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
- # Start changing color tone
- $game_screen.pictures[picture_number].start_tone_change(tone, duration)
- end
- #--------------------------------------------------------------------------
- # * Erase Picture
- #
- # MInterpreter.erase_picture(picture_number)
- #--------------------------------------------------------------------------
- def self.erase_picture(picture_number)
- # Get picture number
- picture_number = picture_number + ($game_temp.in_battle ? 50 : 0)
- # Erase picture
- $game_screen.pictures[picture_number].erase
- end
- #--------------------------------------------------------------------------
- # * Set Weather Effects
- #
- # MInterpreter.set_weather_effects(type, power, time)
- #--------------------------------------------------------------------------
- def self.set_weather_effects(type, power, time)
- # Set Weather Effects
- $game_screen.weather(type, power, time)
- end
- #--------------------------------------------------------------------------
- # * Play BGM
- #
- # MInterpreter.play_bgm(filename, volume = 100, pitch = 100)
- #--------------------------------------------------------------------------
- def self.play_bgm(filename, volume = 100, pitch = 100)
- # Create AudioFile
- audiofile = RPG::AudioFile.new(filename, volume, pitch)
- # Play BGM
- $game_system.bgm_play(audiofile)
- end
- #--------------------------------------------------------------------------
- # * Fade Out BGM
- #
- # MInterpreter.fade_bgm(seconds = 0)
- #--------------------------------------------------------------------------
- def self.fade_bgm(seconds = 0)
- # Fade out BGM
- $game_system.bgm_fade(seconds)
- end
- #--------------------------------------------------------------------------
- # * Play BGS
- #
- # MInterpreter.play_bgs(filename, volume = 100, pitch = 100)
- #--------------------------------------------------------------------------
- def self.play_bgs(filename, volume = 100, pitch = 100)
- # Create AudioFile
- audiofile = RPG::AudioFile.new(filename, volume, pitch)
- # Play BGS
- $game_system.bgs_play(audiofile)
- end
- #--------------------------------------------------------------------------
- # * Fade Out BGS
- #
- # MInterpreter.fade_bgm(seconds = 0)
- #--------------------------------------------------------------------------
- def self.fade_bgm(seconds = 0)
- # Fade out BGS
- $game_system.bgs_fade(seconds)
- end
- #--------------------------------------------------------------------------
- # * Memorize BGM/BGS
- #
- # MInterpreter.memorize_bgms
- #--------------------------------------------------------------------------
- def self.memorize_bgms
- # Memorize BGM/BGS
- $game_system.bgm_memorize
- $game_system.bgs_memorize
- end
- #--------------------------------------------------------------------------
- # * Restore BGM/BGS
- #
- # MInterpreter.restore_bgms
- #--------------------------------------------------------------------------
- def self.restore_bgms
- # Restore BGM/BGS
- $game_system.bgm_restore
- $game_system.bgs_restore
- end
- #--------------------------------------------------------------------------
- # * Play ME
- #
- # MInterpreter.play_me(filename, volume = 100, pitch = 100)
- #--------------------------------------------------------------------------
- def self.play_me(filename, volume = 100, pitch = 100)
- # Create AudioFile
- audiofile = RPG::AudioFile.new(filename, volume, pitch)
- # Play ME
- $game_system.me_play(audiofile)
- end
- #--------------------------------------------------------------------------
- # * Play SE
- #
- # MInterpreter.play_se(filename, volume = 100, pitch = 100)
- #--------------------------------------------------------------------------
- def self.play_se(filename, volume = 100, pitch = 100)
- # Create AudioFile
- audiofile = RPG::AudioFile.new(filename, volume, pitch)
- # Play ME
- $game_system.me_play(audiofile)
- end
- #--------------------------------------------------------------------------
- # * Stop SE
- #
- # MInterpreter.stop_se
- #--------------------------------------------------------------------------
- def self.stop_se
- # Stop SE
- Audio.se_stop
- end
- #--------------------------------------------------------------------------
- # * Battle Processing
- #
- # MInterpreter.battle_proc(troop_id, can_escape = true, can_lose = true)
- #--------------------------------------------------------------------------
- def self.battle_proc(troop_id, can_escape = true, can_lose = true)
- # If not invalid troops
- if $data_troops[troop_id] != nil
- # Set battle abort flag
- $game_temp.battle_abort = true
- # Set battle calling flag
- $game_temp.battle_calling = true
- $game_temp.battle_troop_id = troop_id
- $game_temp.battle_can_escape = can_escape
- $game_temp.battle_can_lose = can_lose
- end
- end
- #--------------------------------------------------------------------------
- # * Shop Processing
- #
- # MInterpreter.shop_proc(*goods)
- #
- # Goods = [kind, id] (Kind : 0 - Item, 1 - Weapon, 2 - Armor)
- #--------------------------------------------------------------------------
- def self.shop_proc(*goods)
- # Set battle abort flag
- $game_temp.battle_abort = true
- # Set shop calling flag
- $game_temp.shop_calling = true
- # Set goods list on new item
- $game_temp.shop_goods = goods
- end
- #--------------------------------------------------------------------------
- # * Name Input Processing
- #
- # MInterpreter.name_input_proc(actor_id, max_chrs = 8)
- #--------------------------------------------------------------------------
- def self.name_input_proc(actor_id, max_chrs = 8)
- # If not invalid actors
- if $data_actors[actor_id] != nil
- # Set battle abort flag
- $game_temp.battle_abort = true
- # Set name input calling flag
- $game_temp.name_calling = true
- $game_temp.name_actor_id = actor_id
- $game_temp.name_max_char = max_chrs
- end
- end
- #--------------------------------------------------------------------------
- # * Change Actor Stat
- #
- # MInterpreter.change_actor_stat(actor_id, stat_name, value)
- #
- # stat_name : 'hp', 'sp', 'level', 'exp', 'str', 'dex', 'agi', 'int',
- # 'class_id' (May use anything that is has a writable method)
- #--------------------------------------------------------------------------
- def self.change_actor_stat(actor_id, stat_name, value)
- # Get Actor
- actor = $game_actors[actor_id]
- # Return if nil actor
- return if actor.nil?
- # Alter Stat
- eval "actor.#{stat_name} += value"
- end
- #--------------------------------------------------------------------------
- # * Gain Actor Skills
- #
- # MInterpreter.gain_actor_skills(actor_id, *skill_ids)
- #--------------------------------------------------------------------------
- def self.gain_actor_skills(actor_id, *skill_ids)
- # Get Actor
- actor = $game_actors[actor_id]
- # Return if nil actor
- return if actor.nil?
- # Gain All Skills
- skill_ids.each {|s| actor.learn_skill(s)}
- end
- #--------------------------------------------------------------------------
- # * Lose Actor Skills
- #
- # MInterpreter.lose_actor_skills(actor_id, *skill_ids)
- #--------------------------------------------------------------------------
- def self.lose_actor_skills(actor_id, *skill_ids)
- # Get Actor
- actor = $game_actors[actor_id]
- # Return if nil actor
- return if actor.nil?
- # Lose All Skills
- skill_ids.each {|s| actor.forget_skill(s)}
- end
- #--------------------------------------------------------------------------
- # * Gain Actor States
- #
- # MInterpreter.gain_actor_states(actor_id, *skill_ids)
- #--------------------------------------------------------------------------
- def self.gain_actor_states(actor_id, *state_ids)
- # Get Actor
- actor = $game_actors[actor_id]
- # Return if nil actor
- return if actor.nil?
- # Gain All States
- state_ids.each {|s| actor.add_state(s)}
- end
- #--------------------------------------------------------------------------
- # * Lose Actor States
- #
- # MInterpreter.lose_actor_states(actor_id, *skill_ids)
- #--------------------------------------------------------------------------
- def self.lose_actor_states(actor_id, *state_ids)
- # Get Actor
- actor = $game_actors[actor_id]
- # Return if nil actor
- return if actor.nil?
- # Remove All States
- skill_ids.each {|s| actor.remove_state(s)}
- end
- #--------------------------------------------------------------------------
- # * Change Actor Equipment
- #
- # MInterpreter.change_actor_equip(actor_id, type, id)
- #
- # Type : 0 - Weapon, 1 - Shield, 2 - Head, 3 - Body, 4 - Accessory
- #--------------------------------------------------------------------------
- def self.change_actor_equip(actor_id, type, id)
- # Get actor
- actor = $game_actors[actor_id]
- # Return if nil actor
- return if actor.nil?
- # Change Equipment
- actor.equip(type, id)
- end
- #--------------------------------------------------------------------------
- # * Change Event Graphic
- #
- # MInterpreter.change_event_graphic(target_id, character_name, hue = 0)
- #
- # Replace character_name with n to set tile id
- #--------------------------------------------------------------------------
- def self.change_event_graphic(target_id, character_name, hue = 0)
- # Get Character
- character = $game_map.events[target_id]
- # Return if Nil Character
- return if character.nil?
- # If Setting Tile ID
- if character_name.is_a?(Fixnum)
- character.tile_id = character_name
- character.character_name = ''
- character.character_hue = hue
- return
- end
- # Set Character Name & Hue
- character.character_name = character_name
- character.character_hue = hue
- end
- #--------------------------------------------------------------------------
- # * Change Actor Character Graphic
- #
- # MInterpreter.change_actor_cgraphic(actor_id, character_name, hue = 0)
- #--------------------------------------------------------------------------
- def self.change_actor_cgraphic(actor_id, character_name, hue = 0)
- # Get Actor
- actor = $game_actors[actor_id]
- # Return if Nil Actor
- return if actor.nil?
- # Set Character Name & Hue
- actor.character_name = character_name
- actor.character_hue = hue
- end
- #--------------------------------------------------------------------------
- # * Change Actor Battler Graphic
- #
- # MInterpreter.change_actor_bgraphic(actor_id, battler_name, hue = 0)
- #--------------------------------------------------------------------------
- def self.change_actor_bgraphic(actor_id, battler_name, hue = 0)
- # Get Actor
- actor = $game_actors[actor_id]
- # Return if Nil Actor
- return if actor.nil?
- # Set Character Name & Hue
- actor.battler_name = battler_name
- actor.battler_hue = hue
- end
- #--------------------------------------------------------------------------
- # * Recover All
- #
- # MInterpreter.recover_all(actor_id, ...) (0 for actor id for all party)
- #--------------------------------------------------------------------------
- def self.recover_all(*actor_ids)
- # Pass Through Defined Actors
- actor_ids.each do |actor_id|
- # If Actor ID is 0
- if actor_id == 0
- # Recover Party
- $game_party.actors.each {|actor| actor.recover_all}
- next
- end
- # Actor Recover All unless actor not found
- $game_actors[actor_id].recover_all unless $game_actors[actor_id].nil?
- end
- end
- #--------------------------------------------------------------------------
- # * Call Scene
- #
- # MInterpreter.call_scene(scene_name)
- #--------------------------------------------------------------------------
- def self.call_scene(scene = Scene_Menu)
- # Change Scene
- $scene = scene.new
- end
- #--------------------------------------------------------------------------
- # * Save To Index
- #
- # MInterpreter.save_index(index = 0)
- #--------------------------------------------------------------------------
- def self.save_index(index = 0)
- # Create Dummy Save Object
- dummy = Scene_Save.new
- # Create File
- file = File.open(dummy.make_filename(index), "wb")
- # Write File
- dummy.write_save_data(file)
- # Close File
- file.close
- end
- #--------------------------------------------------------------------------
- # * Save To Filename
- #
- # MInterpreter.save_filename(filename = 'Save File')
- #--------------------------------------------------------------------------
- def self.save_filename(filename = 'Save File')
- # Create Dummy Save Object
- dummy = Scene_Save.new
- # Create File
- file = File.open(filename, "wb")
- # Write File
- dummy.write_save_data(file)
- # Close File
- file.close
- end
- #--------------------------------------------------------------------------
- # * Load From Index
- #
- # MInterpreter.load_index(index = 0)
- #--------------------------------------------------------------------------
- def self.load_index(index = 0)
- # Create Dummy Load Object
- dummy = Scene_Load.new
- # Create File
- file = File.open(dummy.make_filename(index), "rb")
- # Read Data
- dummy.read_save_data(file)
- # Close File
- file.close
- end
- #--------------------------------------------------------------------------
- # * Load From Filename
- #
- # MInterpreter.load_filename(filename = 'Save File')
- #--------------------------------------------------------------------------
- def self.load_filename(filename = 'Save File')
- # Create Dummy Load Object
- dummy = Scene_Load.new
- # Create File
- file = File.open(filename, "rb")
- # Read Data
- dummy.read_save_data(file)
- # Close File
- file.close
- end
- end
- #==============================================================================
- # ** Game_Character
- #==============================================================================
- class Game_Character
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :tile_id # tile ID (invalid if 0)
- attr_accessor :character_name # character file name
- attr_accessor :character_hue # character hue
- end
- #==============================================================================
- # ** Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :character_name # character file name
- attr_accessor :character_hue # character hue
- attr_accessor :battler_name # battler file name
- attr_accessor :battler_hue # battler hue
- end
- #==============================================================================
- # ** Modules.Keyboard Input (6.1) By Near Fantastica
- # Additions By Wachunaga & SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # The Keyboard Input Module is designed to function as the default Input
- # module does. It is better then other methods keyboard input because as a
- # key is tested it is not removed form the list. so you can test the same
- # key multiple times the same loop. This script automatically updates itself
- # with the input module.
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Test if Key is Triggered :
- # - if Keyboard.trigger?(Keyboard::<Keyboard_constant>)
- #
- # Test if Key is Pressed :
- # - if Keyboard.pressed?(Keyboard::<Keyboard_constant>)
- #==============================================================================
- MACL::Loaded << 'Modules.Keyboard Module'
- #==============================================================================
- # ** Keyboard
- #==============================================================================
- module Keyboard
- #--------------------------------------------------------------------------
- # * Constants (These Are Your Keyboard Keys)
- #--------------------------------------------------------------------------
- Mouse_Left = 1 ; Mouse_Right = 2
- Back = 8 ; Tab = 9
- Enter = 13 ; Shift = 16
- Ctrl = 17 ; Alt = 18
- Capslock = 20 ; Esc = 27
- Space = 32 ; End = 35
- Home = 36 ; Left = 37
- Right = 39
- Del = 46 ; Collon = 186
- Equal = 187 ; Comma = 188
- Underscore = 189 ; Dot = 190
- Backslash = 191 ; Tilde = 192
- Lb = 219 ; Rb = 221
- Forwardslash = 220 ; Quote = 222
- Numberkeys = {} ; Numberkeys[0] = 48
- Numberkeys[1] = 49 ; Numberkeys[2] = 50
- Numberkeys[3] = 51 ; Numberkeys[4] = 52
- Numberkeys[5] = 53 ; Numberkeys[6] = 54
- Numberkeys[7] = 55 ; Numberkeys[8] = 56
- Numberkeys[9] = 57
- Numberpad = {} ; Numberpad[0] = 45
- Numberpad[1] = 35 ; Numberpad[2] = 40
- Numberpad[3] = 34 ; Numberpad[4] = 37
- Numberpad[5] = 12 ; Numberpad[6] = 39
- Numberpad[7] = 36 ; Numberpad[8] = 38
- Numberpad[9] = 33
- Numpad = {} ; Numpad[0] = 96
- Numpad[1] = 97 ; Numpad[2] = 98
- Numpad[3] = 99 ; Numpad[4] = 100
- Numpad[5] = 101 ; Numpad[6] = 102
- Numpad[7] = 103 ; Numpad[8] = 104
- Numpad[9] = 105
- Letters = {} ; Letters['A'] = 65
- Letters['B'] = 66 ; Letters['C'] = 67
- Letters['D'] = 68 ; Letters['E'] = 69
- Letters['F'] = 70 ; Letters['G'] = 71
- Letters['H'] = 72 ; Letters['I'] = 73
- Letters['J'] = 74 ; Letters['K'] = 75
- Letters['L'] = 76 ; Letters['M'] = 77
- Letters['N'] = 78 ; Letters['O'] = 79
- Letters['P'] = 80 ; Letters['Q'] = 81
- Letters['R'] = 82 ; Letters['S'] = 83
- Letters['T'] = 84 ; Letters['U'] = 85
- Letters['V'] = 86 ; Letters['W'] = 87
- Letters['X'] = 88 ; Letters['Y'] = 89
- Letters['Z'] = 90
- Fkeys = {} ; Fkeys[1] = 112
- Fkeys[2] = 113 ; Fkeys[3] = 114
- Fkeys[4] = 115 ; Fkeys[5] = 116
- Fkeys[6] = 117 ; Fkeys[7] = 118
- Fkeys[8] = 119 ; Fkeys[9] = 120
- Fkeys[10] = 121 ; Fkeys[11] = 122
- Fkeys[12] = 123
- #--------------------------------------------------------------------------
- # * Text Representation
- #--------------------------------------------------------------------------
- TR = {}
- TR[Tab] = [' ', ' ']
- TR[Enter] = ['/n', '/n']
- TR[Collon] = [';', ':']
- TR[Equal] = ['=', '+']
- TR[Comma] = [',', '<']
- TR[Underscore] = ['-', '_']
- TR[Dot] = ['.', '>']
- TR[Backslash] = ['/', '?']
- TR[Tilde] = ['`', '~']
- TR[Forwardslash] = ["\\", "|"]
- TR[Quote] = ["'", '"']
- TR[Numberkeys[0]] = ['0', ')']
- TR[Numberkeys[1]] = ['1', '!']
- TR[Numberkeys[2]] = ['2', '@']
- TR[Numberkeys[3]] = ['3', '#']
- TR[Numberkeys[4]] = ['4', '$']
- TR[Numberkeys[5]] = ['5', '^%']
- TR[Numberkeys[6]] = ['6', '^']
- TR[Numberkeys[7]] = ['7', '&']
- TR[Numberkeys[8]] = ['8', '*']
- TR[Numberkeys[9]] = ['9', '(']
- Letters.values.each do |key|
- TR[key] = [key.chr.downcase, key.chr.upcase]
- end
- #--------------------------------------------------------------------------
- # * API Declaration
- #--------------------------------------------------------------------------
- State = Win32API.new('user32','GetKeyState', ['i'],'i')
- Key = Win32API.new('user32','GetAsyncKeyState', ['i'],'i')
- #--------------------------------------------------------------------------
- # * Clear Key & Pressed
- #--------------------------------------------------------------------------
- @keys = [] ; @pressed = [] ; @lock = []
- @disabled_keys = [] ; @disabled_timer = {}
- @delay = {} ; @disabled_tr = [] ; @text_window = nil ; @text_max = 10
- #--------------------------------------------------------------------------
- # * Get Key State (Test Pressed)
- #--------------------------------------------------------------------------
- def self.getstate(key)
- return !State.call(key).between?(0, 1)
- end
- #--------------------------------------------------------------------------
- # * Test Key (Test Trigger)
- #--------------------------------------------------------------------------
- def self.testkey(key)
- return Key.call(key) & 0x01 == 1
- end
- #--------------------------------------------------------------------------
- # * Test Lock (Test Trigger)
- #--------------------------------------------------------------------------
- def self.testlock(key)
- return State.call(key) & 0x01 == 1
- end
- #--------------------------------------------------------------------------
- # * Trigger? Test
- #--------------------------------------------------------------------------
- def self.trigger?(key)
- return @keys.include?(key)
- end
- #--------------------------------------------------------------------------
- # * Pressed? Test
- #--------------------------------------------------------------------------
- def self.pressed?(key)
- return @pressed.include?(key)
- end
- #--------------------------------------------------------------------------
- def self.lock?(key)
- return @lock.include?(key)
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def self.update
- # Clears Keys & Pressed
- @keys, @pressed, @lock = [], [], []
- # Pass Through Timer List
- @disabled_timer.each do |key, timer|
- # Next if nil timer or key not-disabled
- next if timer.nil? || !@disabled_keys.include?(key)
- # If Greater than 0 Timer
- if timer > 0
- timer -= 1
- next
- end
- # Enable Key
- @disabled_keys.delete(key) if @disabled_keys.include?(key)
- # Set Timer to Nil
- @disabled_timer[key] = nil
- end
- # Test All Keys
- for key in [Mouse_Left, Mouse_Right, Back, Tab, Enter, Shift, Ctrl, Alt,
- Capslock, Esc, Space, End, Home, Left, Right, Del, Collon,
- Equal, Comma, Underscore, Dot, Backslash, Tilde, Lb, Rb,
- Forwardslash, Quote] + Numberkeys.values + Numberpad.values +
- Numpad.values + Letters.values + Fkeys.values
- # Skip If Key Disabled
- next if @disabled_keys.include?(key)
- # Add Key to Triggered Array if Triggered
- @keys.push(key) if self.testkey(key)
- # Add Key to Pressed Array if Pressed
- @pressed.push(key) if self.getstate(key)
- end
- # Add Lock Key If Capslock
- @lock.push(Keyboard::Capslock) if Keyboard.testlock(Keyboard::Capslock)
- # Update Text Window Text If Text Window Present
- self.update_text if @text_window != nil && @text_window.active
- end
- #--------------------------------------------------------------------------
- # * Update Text
- #--------------------------------------------------------------------------
- def self.update_text
- # Return if Nil Text Window
- return if @text_window.nil?
- # Gets Text Window Text
- text = @text_window.text.dup
- # Backspace Pressed
- text.pop if self.trigger?(Back)
- # If Text Size is Less Than Text Max
- if text.size < @text_max
- # Pass Through Triggered Array
- (@keys + @pressed).each do |key|
- # If TR has Key
- if TR.has_key?(key)
- # If Delay Has Key
- if @delay.has_key?(key)
- # Subtract Delay Count and Return (if greater than 0)
- if @delay[key] > 0
- @delay[key] -= 1
- next
- end
- end
- # Skip if TR Key Disabled
- next if @disabled_tr.include?(key)
- # If Shiftcase
- if ( self.lock?(Capslock) && !self.pressed?(Shift)) ||
- (!self.lock?(Capslock) && self.pressed?(Shift))
- text += TR[key][1]
- # If Regular Case
- else
- text += TR[key][0]
- end
- # Start Delay Count
- @delay[key] = 6
- end
- end
- end
- # Sets Text Window Text
- @text_window.text = text
- end
- #--------------------------------------------------------------------------
- # * Read Disabled TR
- #--------------------------------------------------------------------------
- def self.disabled_tr
- return disabled_tr
- end
- #--------------------------------------------------------------------------
- # * Set Disabled TR
- #--------------------------------------------------------------------------
- def self.disabled_tr=(disabled_tr)
- @disabled_tr = disabled_tr
- end
- #--------------------------------------------------------------------------
- # * Read Text Window
- #--------------------------------------------------------------------------
- def self.text_window
- return text_window
- end
- #--------------------------------------------------------------------------
- # * Set Text Window
- #--------------------------------------------------------------------------
- def self.text_window=(text_window)
- @text_window = text_window
- end
- #--------------------------------------------------------------------------
- # * Read Text Max
- #--------------------------------------------------------------------------
- def self.text_max
- return text_max
- end
- #--------------------------------------------------------------------------
- # * Set Text Max
- #--------------------------------------------------------------------------
- def self.text_max=(text_max)
- @text_max = text_max
- end
- #------------------------------------------------------------------------
- # * Disable Key
- #------------------------------------------------------------------------
- def self.disable_key(constant, frames = nil)
- # Add Key to Disabled List
- @disabled_keys << constant unless @disabled_keys.include?(constant)
- # Set Disabled Counter if non-nil
- @disabled_timer[constant] = frames unless frames.nil?
- end
- #------------------------------------------------------------------------
- # * Enable Key
- #------------------------------------------------------------------------
- def self.enable_key(constant)
- # Remove Constant From List
- @disabled_keys.delete(constant)
- # Set Nil Timer
- @disabled_timer[constant] = nil
- end
- end
- #==============================================================================
- # ** Input
- #==============================================================================
- module Input
- class << self
- #------------------------------------------------------------------------
- # * Alias Listings
- #------------------------------------------------------------------------
- unless self.method_defined?(:seph_keyboard_input_update)
- alias_method :seph_keyboard_input_update, :update
- end
- #------------------------------------------------------------------------
- # * Frame Update
- #------------------------------------------------------------------------
- def update
- # Original Update
- seph_keyboard_input_update
- # Update Keyboard
- Keyboard.update
- end
- end
- end
- #==============================================================================
- # ** Modules.Mouse Input (7.0) By Near Fantastica & SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # The Mouse Input Module defines mouse input. It will retrieve the cursor
- # x and y position, as well as grid locations. This script updates
- # itself when the input module updates.
- #------------------------------------------------------------------------------
- # * Customization :
- #
- # Turning Windows Cursor off when opening Game
- # - Hide_Mouse_Cursor = true (turn off) or false (leave alone)
- #
- # Mouse triggers that cause Input triggers
- # - Mouse_to_Input_Triggers = { mouse_key => Input::KeyConstant, ... }
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Get Mouse Position :
- # - position = Mouse.position
- #
- # Get Mouse Grid Position :
- # - grid_position = Mouse.grid
- #
- # Trigger Status
- # - Mouse.trigger?
- #
- # Repeat Status
- # - Mouse.repeat?
- #==============================================================================
- MACL::Loaded << 'Modules.Mouse Module'
- #==============================================================================
- # ** Mouse
- #==============================================================================
- module Mouse
- #--------------------------------------------------------------------------
- # * Show Windows Cursor Setting
- #--------------------------------------------------------------------------
- Hide_Mouse_Cursor = false
- #--------------------------------------------------------------------------
- # * Mouse to Input Triggers
- #
- # key => Input::KeyCONSTANT (key: 0 - Left, 1 - Middle, 2 - Right)
- #--------------------------------------------------------------------------
- Mouse_to_Input_Triggers = {0 => Input::C, 1 => Input::B, 2 => Input::A}
- #--------------------------------------------------------------------------
- # * API Declaration
- #--------------------------------------------------------------------------
- GAKS = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
- GSM = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
- Cursor_Pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
- Show_Cursor = Win32API.new('user32', 'ShowCursor', 'l', 'l')
- Scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
- Client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
- Findwindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
- Readini = Win32API.new('kernel32', 'GetPrivateProfileStringA',
- %w(p p p p l p), 'l')
- Show_Cursor.call(Hide_Mouse_Cursor ? 0 : 1)
- @triggers = [[0, 1], [0, 2], [0, 4]]
- #--------------------------------------------------------------------------
- # * Mouse Grid Position
- #--------------------------------------------------------------------------
- def self.grid
- # Return Nil if Position is Nil
- return nil if @pos.nil?
- # Return X & Y Locations
- x = (@pos[0] + $game_map.display_x / 4) / 32
- y = (@pos[1] + $game_map.display_y / 4) / 32
- return [x, y]
- end
- #--------------------------------------------------------------------------
- # * Mouse Position
- #--------------------------------------------------------------------------
- def self.position
- return @pos == nil ? [0, 0] : @pos
- end
- #--------------------------------------------------------------------------
- # * Mouse Global Position
- #--------------------------------------------------------------------------
- def self.global_pos
- # Packs 0 Position
- pos = [0, 0].pack('ll')
- # Returns Unpacked Cursor Position Call
- return Cursor_Pos.call(pos) == 0 ? nil : pos.unpack('ll')
- end
- #--------------------------------------------------------------------------
- # * Mouse Position
- #--------------------------------------------------------------------------
- def self.pos
- # Gets X & Y Position
- x, y = self.screen_to_client(*self.global_pos)
- # Gets Width & Height of Game Window
- width, height = self.client_size
- # Begins Test
- begin
- # Return X & Y or Nil Depending on Mouse Position
- if (x >= 0 && y >= 0 && x < width && y < height)
- return x, y
- end
- return nil
- rescue
- # Return nil
- return nil
- end
- end
- #--------------------------------------------------------------------------
- # * Update Mouse Position
- #--------------------------------------------------------------------------
- def self.update
- # Update Position
- @pos = self.pos
- # Update Triggers
- for i in @triggers
- # Gets Async State
- n = GAKS.call(i[1])
- # If 0 or 1
- if [0, 1].include?(n)
- i[0] = (i[0] > 0 ? i[0] * -1 : 0)
- else
- i[0] = (i[0] > 0 ? i[0] + 1 : 1)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Trigger?
- # id : 0:Left, 1:Right, 2:Center
- #--------------------------------------------------------------------------
- def self.trigger?(id = 0)
- return @triggers[id][0] == 1
- end
- #--------------------------------------------------------------------------
- # * Repeat?
- # id : 0:Left, 1:Right, 2:Center
- #--------------------------------------------------------------------------
- def self.repeat?(id = 0)
- if @triggers[id][0] <= 0
- return false
- else
- return @triggers[id][0] % 5 == 1 && @triggers[id][0] % 5 != 2
- end
- end
- #--------------------------------------------------------------------------
- # * Screen to Client
- #--------------------------------------------------------------------------
- def self.screen_to_client(x, y)
- # Return nil if X & Y empty
- return nil unless x and y
- # Pack X & Y
- pos = [x, y].pack('ll')
- # Return Unpacked Position or Nil
- return Scr2cli.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
- end
- #--------------------------------------------------------------------------
- # * Hwnd
- #--------------------------------------------------------------------------
- def self.hwnd
- # Finds Game Name
- game_name = "\0" * 256
- Readini.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
- game_name.delete!("\0")
- # Finds Window
- return Findwindow.call('RGSS Player', game_name)
- end
- #--------------------------------------------------------------------------
- # * Client Size
- #--------------------------------------------------------------------------
- def self.client_size
- # Packs Empty Rect
- rect = [0, 0, 0, 0].pack('l4')
- # Gets Game Window Rect
- Client_rect.call(self.hwnd, rect)
- # Unpacks Right & Bottom
- right, bottom = rect.unpack('l4')[2..3]
- # Returns Right & Bottom
- return right, bottom
- end
- end
- #==============================================================================
- # ** Input
- #==============================================================================
- class << Input
- #------------------------------------------------------------------------
- # * Alias Listings
- #------------------------------------------------------------------------
- unless self.method_defined?(:seph_mouse_input_update)
- alias_method :seph_mouse_input_update, :update
- alias_method :seph_mouse_input_trigger?, :trigger?
- alias_method :seph_mouse_input_repeat?, :repeat?
- end
- #------------------------------------------------------------------------
- # * Frame Update
- #------------------------------------------------------------------------
- def update
- # Update Mouse
- Mouse.update
- # Original Update
- seph_mouse_input_update
- end
- #--------------------------------------------------------------------------
- # * Trigger? Test
- #--------------------------------------------------------------------------
- def trigger?(constant)
- # Return true if original test is true
- return true if seph_mouse_input_trigger?(constant)
- # If Mouse Position isn't Nil
- unless Mouse.pos.nil?
- # If Mouse Trigger to Input Trigger Has Constant
- if Mouse::Mouse_to_Input_Triggers.has_value?(constant)
- # Return True if Mouse Triggered
- mouse_trigger = Mouse::Mouse_to_Input_Triggers.index(constant)
- return true if Mouse.trigger?(mouse_trigger)
- end
- end
- # Return False
- return false
- end
- #--------------------------------------------------------------------------
- # * Repeat? Test
- #--------------------------------------------------------------------------
- def repeat?(constant)
- # Return true if original test is true
- return true if seph_mouse_input_repeat?(constant)
- # If Mouse Position isn't Nil
- unless Mouse.pos.nil?
- # If Mouse Trigger to Input Trigger Has Constant
- if Mouse::Mouse_to_Input_Triggers.has_value?(constant)
- # Return True if Mouse Triggered
- mouse_trigger = Mouse::Mouse_to_Input_Triggers.index(constant)
- return true if Mouse.repeat?(mouse_trigger)
- end
- end
- # Return False
- return false
- end
- end
- #==============================================================================
- # ** Modules.Moveable V1.0 By Trickster
- #------------------------------------------------------------------------------
- # Objects mixing in this module will have the ability to move. Includes methods
- # for checking if the object is moving, and to move relative to its current
- # position and to stop movement. Classes mixing in this module must call the
- # update_move method within the update method for this module to be sucessfully
- # implemented. Also contains and keeps track of useful information such as the
- # angle of movement (in degrees) The only methods that need to be implemented
- # when using this as a mixin are the x and y methods.
- #
- # move_x move_y move relative_move
- # relative_move_x relative_move_y stop_x
- # stop_y stop moving? update_move
- #==============================================================================
- MACL::Loaded << 'Modules.Moveable'
- module Moveable
- #-------------------------------------------------------------------------
- # * Name : Move X
- # Info : Starts Moving On X Axis
- # Author : Trickster
- # Call Info : One-Two Arguments
- # Integer X - Destination X
- # Integer Speed - Movement X Speed (Default 1)
- #-------------------------------------------------------------------------
- def move_x(x, x_speed = 1)
- # Not Moving if no speed or negative speed
- return if x_speed <= 0 or @moving_x
- # Set Destination Points speed and move count set moving flag
- @destination_x = x
- # Set Move Speed X
- @move_speed_x = x_speed
- # Set Moving Flag
- @moving_x = true
- # Get the distance + (negative if to left or up positive if down or right)
- @distance_x = (@destination_x - self.x).to_f
- # Setup Move Save X variable (For low speeds)
- @move_save_x = 0
- # Setup Old X (For Stopping)
- @old_x = self.x
- # If No Distance Y
- if @distance_y.nil?
- # Set Distance to Distance X
- @distance = @distance_x
- else
- # Get slant distance (hypotenuse of the triangle ((xf,yi) (xi,yf) (xf,yf))
- @distance = Math.sqrt(@distance_x ** 2 + @distance_y ** 2)
- end
- # Update Move Angle
- update_move_angle
- end
- #-------------------------------------------------------------------------
- # * Name : Move Y
- # Info : Starts Moving On Y Axis
- # Author : Trickster
- # Call Info : One-Two Arguments
- # Integer Y - Destination Y
- # Integer Speed - Movement Y Speed (Default 1)
- #-------------------------------------------------------------------------
- def move_y(y, y_speed = 1)
- # Not Moving if no speed or negative speed
- return if y_speed <= 0 or @moving_y
- # Set Destination Points speed and move count set moving flag
- @destination_y = y
- # Set Move Speed Y
- @move_speed_y = y_speed
- # Set Moving Flag
- @moving_y = true
- # Get the distance + (negative if to left or up positive if down or right)
- @distance_y = (@destination_y - self.y).to_f
- # Setup Move Save Y variable (For low speeds)
- @move_save_y = 0
- # Setup Old X (For Stopping)
- @old_y = self.y
- # If No Distance X
- if @distance_x.nil?
- # Set Distance to Distance Y
- @distance = @distance_y
- else
- # Get slant distance (hypotenuse of the triangle ((xf,yi) (xi,yf) (xf,yf))
- @distance = Math.sqrt(@distance_x ** 2 + @distance_y ** 2)
- end
- # Update Move Angle
- update_move_angle
- end
- #-------------------------------------------------------------------------
- # * Name : Move
- # Info : Starts Moving
- # Author : Trickster
- # Call Info : Two-Three Arguments
- # Integer X and Y - Destination Position
- # Integer XSpeed and YSpeed - Movement Speed (Default 1)
- #-------------------------------------------------------------------------
- def move(x, y, x_speed = 1, y_speed = x_speed)
- move_x(x, x_speed)
- move_y(y, y_speed)
- end
- #-------------------------------------------------------------------------
- # * Name : Relative Move
- # Info : Starts Moving Relative to Current Position
- # Author : Trickster
- # Call Info : Two-Three Arguments
- # Integer CX and CY - How far to move from current positon
- # Integer Speed - Movement Speed (Default 1)
- #-------------------------------------------------------------------------
- def relative_move(cx, cy, x_speed = 1, y_speed = x_speed)
- # Add To X and Y (Relative Move)
- move(self.x + cx, self.y + cy, x_speed, y_speed)
- end
- #-------------------------------------------------------------------------
- # * Name : Relative Move X
- # Info : Starts Moving on X Axis Relative to Current Position
- # Author : Trickster
- # Call Info : One-Two Arguments
- # Integer CX - How far to move on x axis
- # Integer Speed - Movement Speed (Default 1)
- #-------------------------------------------------------------------------
- def relative_move_x(cx, speed = 1)
- # Move to Current Position + X (Relative Move)
- move_x(self.x + cx, speed)
- end
- #-------------------------------------------------------------------------
- # * Name : Relative Move Y
- # Info : Starts Moving on Y Axis Relative to Current Position
- # Author : Trickster
- # Call Info : One-Two Arguments
- # Integer CY - How far to move on y axis
- # Integer Speed - Movement Speed (Default 1)
- #-------------------------------------------------------------------------
- def relative_move_y(cy, speed = 1)
- # Move to Current Position + Y (Relative Move)
- move_y(self.y + cy, speed)
- end
- #-------------------------------------------------------------------------
- # * Name : Stop
- # Info : Stops Movement
- # Author : Trickster
- # Call Info : Zero to Two Arguments Boolean ReturnX, ReturnY
- # If True returns to starting position (def false)
- #-------------------------------------------------------------------------
- def stop(returnx = false, returny = false)
- stop_x(returnx)
- stop_y(returny)
- end
- #-------------------------------------------------------------------------
- # * Name : Stop X
- # Info : Stops Movement on X Axis
- # Author : Trickster
- # Call Info : Zero to One Arguments Boolean ReturnX
- # If True returns to starting X (def false)
- #-------------------------------------------------------------------------
- def stop_x(returnx = false)
- # Set Moving X to false
- @moving_x = false
- # Set Destination X
- @destination_x = nil
- # Set X to Old X if return to start
- self.x = @old_x if returnx
- # Update Move Angle
- update_move_angle
- end
- #-------------------------------------------------------------------------
- # * Name : Stop Y
- # Info : Stops Movement on Y Axis
- # Author : Trickster
- # Call Info : Zero to One Arguments Boolean ReturnY
- # If True returns to starting Y (def false)
- #-------------------------------------------------------------------------
- def stop_y(returny = false)
- # Set Moving Y to false
- @moving_y = false
- # Set Destination Y
- @destination_y = nil
- # Set Y to Old Y if return to start
- self.y = @old_y if returny
- # Update Move Angle
- update_move_angle
- end
- #-------------------------------------------------------------------------
- # * Name : Update Move Angle
- # Info : Updates Angle of Movement
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def update_move_angle
- # Calculate angle of movement which is later used to determine direction
- # If X distance is 0 (Prevent Infinity Error)
- if @distance_x.to_i == 0
- # The Angle is sign(distance_y) * - p / 2 (90ï½° or 270ï½°)
- @move_angle = @distance_y.sign * Math::PI / 2
- # If Y distance is 0 (Prevent Incorrect Direction for later)
- elsif @distance_y.to_i == 0
- # The Angle is sign(distance_x) - 1 * p / 2 (0ï½° or 180ï½°)
- @move_angle = (@distance_x.sign - 1) * Math::PI / 2
- else
- # The Angle is the Arctangent of @distance_y / @distance_x (slope)
- # Returns [-p,p]
- @move_angle = Math.atan2(@distance_y, @distance_x.to_f)
- end
- # Convert the angle to degrees
- @move_angle *= 180 / Math::PI
- end
- #-------------------------------------------------------------------------
- # * Name : Move Angle
- # Info : Returns Angle of Movement
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def move_angle
- return moving? ? move_angle : nil
- end
- #-------------------------------------------------------------------------
- # * Name : Moving?
- # Info : Is Object Moving
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def moving?
- return @moving_x || @moving_y
- end
- #-------------------------------------------------------------------------
- # * Name : Update Move
- # Info : Updates Movement
- # Author : Trickster
- # Call Info : No Arguments
- # Comment : Must be called every frame in the object using this module
- # as a mixin
- #-------------------------------------------------------------------------
- def update_move
- # If not moving
- return if not moving?
- # If Moving in X Axis
- if @moving_x
- # move increase x = the cosine of the arctangent of the dist x over dist y
- # move increase x = cos(arctan(disty/distx)) simplified by trigonometry
- # to distance_x / slant_distance, the sprite moves (move speed)
- # along the slanted line (if it is slanted)
- movinc_x = @move_speed_x * @distance_x.abs / @distance
- # Get Distance Remaining
- remain_x = @destination_x - self.x
- # Get Move X - the sign of the distance left + move increase or the
- # remaining distance left if it will go past that point
- move_x = remain_x.sign * [movinc_x, remain_x.abs].min
- # Save Remainder in Move Save X
- @move_save_x += move_x.abs % 1 * move_x.sign
- # Increase X By Move X and Remainder
- self.x += move_x.to_i + @move_save_x.to_i
- # Set to Floating Portion
- @move_save_x -= @move_save_x.to_i
- # If At Destination X
- if self.x == @destination_x
- # Set Moving X to false
- @moving_x = false
- # Set Destination X
- @destination_x = nil
- end
- end
- # If Moving in Y Axis
- if @moving_y
- # same reasoning with y increase except it is the sine of the arctangent
- # move increase y = sin(arctan(disty/distx)) simplified by trigonometry
- # to distance_y / slant_distance
- movinc_y = @move_speed_y * @distance_y.abs / @distance
- # Get distance remaining
- remain_y = @destination_y - self.y
- # Get Move Y - the sign of the distance left + move increase or the
- # remaining distance left if it will go past that point
- move_y = remain_y.sign * [movinc_y, remain_y.abs].min
- # Save Remainder in Move Save Y
- @move_save_y += move_y.abs % 1 * move_y.sign
- # Increase Y By Move Y and Remainder
- self.y += move_y.to_i + @move_save_y.to_i
- # Set to Floating Portion
- @move_save_y -= @move_save_y.to_i
- # If At Destination Y
- if self.y == @destination_y
- # Set Moving Y to false
- @moving_y = false
- # Set Destination Y
- @destination_y = nil
- end
- end
- end
- end
- class Sprite
- #--------------------------------------------------------------------------
- # * Mixin Module Moveable
- #--------------------------------------------------------------------------
- include Moveable
- #--------------------------------------------------------------------------
- # * Update Alias
- #--------------------------------------------------------------------------
- if @trick_movingsprite_update.nil?
- alias_method :trick_movingsprite_update, :update
- @trick_movingsprite_update = true
- end
- def update
- trick_movingsprite_update
- update_move if moving_implemented?
- end
- #-------------------------------------------------------------------------
- # * Name : Moving Implemented?
- # Info : Implements Moving if it returns true false otherwise
- # Author : Trickster
- # Call Info : No Arguments
- # Comments : In Custom Sprite Classes make this method return false
- # To Implement your own movement functions or just to disable
- #-------------------------------------------------------------------------
- def moving_implemented?
- return true
- end
- end
- class Window
- #--------------------------------------------------------------------------
- # * Mixin Module Moveable
- #--------------------------------------------------------------------------
- include Moveable
- #--------------------------------------------------------------------------
- # * Update Alias
- #--------------------------------------------------------------------------
- if @trick_movingwindow_update.nil?
- alias_method :trick_movingwindow_update, :update
- @trick_movingwindow_update = true
- end
- def update
- trick_movingwindow_update
- update_move if moving_implemented?
- end
- #-------------------------------------------------------------------------
- # * Name : Moving Implemented?
- # Info : Implements Moving if it returns true false otherwise
- # Author : Trickster
- # Call Info : No Arguments
- # Comments : In Custom Window Classes make this method return false
- # To Implement your own movement functions or just to disable
- #-------------------------------------------------------------------------
- def moving_implemented?
- return true
- end
- end
- #==============================================================================
- # ** Modules.Screenshot Module (2.0) By Andreas21 & Cybersam
- #------------------------------------------------------------------------------
- # * Requirements :
- #
- # Screenshot.dll (Located in Game Directory)
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to automatically take a screenshot of your game
- # and save the file in the pictures folder.
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Taking a Screenshot
- # - Screenshot.shot('filename', image_type)
- #
- # image_type : 0 - bmp, 1 - jpg, 2 - png
- #==============================================================================
- # Test if Screenshot Dll Found
- begin
- test = Win32API.new('screenshot', 'Screenshot', %w(l l l l p l l), '')
- include_screenshot_module = true
- rescue
- include_screenshot_module = false
- end
- # If Screenshot DLL Found
- if include_screenshot_module
- MACL::Loaded << 'Modules.Screenshot Module'
- #==============================================================================
- # ** Screenshot
- #==============================================================================
- module Screenshot
- #--------------------------------------------------------------------------
- # * File Directory
- #--------------------------------------------------------------------------
- Dir = 'Graphics/Pictures/'
- #--------------------------------------------------------------------------
- # * API Refrence
- #--------------------------------------------------------------------------
- Screen = Win32API.new('screenshot', 'Screenshot',
- %w(l l l l p l l), '')
- Readini = Win32API.new('kernel32', 'GetPrivateProfileStringA',
- %w(p p p p l p), 'l')
- Findwindow = Win32API.new('user32', 'FindWindowA',
- %w(p p), 'l')
- #--------------------------------------------------------------------------
- # * Shot
- #
- # image_type : 0 - bmp, 1 - jpg, 2 - png
- #--------------------------------------------------------------------------
- def shot(filename = 'screenshot', image_type = 2)
- # Adds File Extension
- filename += image_type == 0 ? '.bmp' : image_type == 1 ? '.jpg' : '.png'
- # Create True Filename
- file_name = Dir + filename
- # Make Screenshot
- Screen.call(0, 0, 640, 480, file_name, handel, image_type)
- end
- #--------------------------------------------------------------------------
- # * Handel (Finds Game Window)
- #--------------------------------------------------------------------------
- def handel
- game_name = "\0" * 256
- Readini.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
- game_name.delete!("\0")
- return Findwindow.call('RGSS Player', game_name)
- end
- end
- end
- #==============================================================================
- # ** Modules.View Range (5.0) By Near Fantastica & SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # The View Range Module is used to test objects position in comparision with
- # another object. It can test if an object is within a defined circular
- # range of another object or a rectangular defined region. It can also tell
- # you this distances between objects.
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Test if object is within defined range from another object :
- # - VR.in_range?(object1, object2, range)
- # - VR.in_range?(object1x, object1y, object2x, object2y, range)
- #
- # Test if object is within defined rectanlge :
- # - VR.in_rect_range?(object, <args>)
- # - VR.in_rect_range?(x, y, <args>)
- #
- # args can either be : x, y, width, height or Rect.new(x, y, width, height)
- #
- # Test range between objects :
- # - range = VR.range(object1, object2, <integer>)
- # - range = VR.range(object1x, object1y, object2x, object2y, <integer>)
- #
- # integer : if true, returns integer ; if false, returns float
- #==============================================================================
- MACL::Loaded << 'Modules.View Range'
- #==============================================================================
- # ** View Range
- #==============================================================================
- module VR
- #----------------------------------------------------------------------------
- # * Within Range Test
- #----------------------------------------------------------------------------
- def VR.in_range?(*args)
- # If 3 Arguments (Element, Object, Range)
- if args.size == 3
- x = (args[0].x - args[1].x) ** 2
- y = (args[0].y - args[1].y) ** 2
- r = args[2]
- # If 5 Arguments (Elementx, Elementy, Objectx, Objecty, Range)
- elsif args.size == 5
- x = (args[0] - args[2]) ** 2
- y = (args[1] - args[3]) ** 2
- r = args[4]
- else
- p 'Wrong Defined Number of Arguments'
- return
- end
- return (x + y) <= (r * r)
- end
- #----------------------------------------------------------------------------
- # * Within Rect Range Test
- #----------------------------------------------------------------------------
- def VR.in_rect_range?(*args)
- # If 2 Arguments (Object, Rect)
- if args.size == 2
- x_, y_ = args[0].x, args[0].y
- x, y, w, h = args[1].x, args[1].y, args[1].width, args[1].height
- # If 3 Arguments (Objectx, Objecty, Rect)
- elsif args.size == 3
- x_, y_ = args[0], args[1]
- x, y, w, h = args[2].x, args[2].y, args[2].width, args[2].height
- # If 5 Arguments (Object, Rectx, Recty, Rectwidth, Rectheight)
- elsif args.size == 5
- x_, y_ = args[0].x, args[0].y
- x, y, w, h = args[1], args[2], args[3], args[4]
- # If 6 Arguments (Objectx, Objecty, Rectx, Recty, Rectwidth, Rectheight)
- elsif args.size == 6
- x_, y_, x, y, w, h = *args
- else
- p 'Wrong Defined Number of Arguments'
- return
- end
- # Return Object Within Rect
- return x_.between?(x, x + w) && y_.between?(y, y + h)
- end
- #----------------------------------------------------------------------------
- # * Range
- #----------------------------------------------------------------------------
- def VR.range(*args)
- # If 2 Arguments (Element, Object)
- if args.size == 2
- x = (args[0].x - args[1].x) * (args[0].x - args[1].x)
- y = (args[0].y - args[1].y) * (args[0].y - args[1].y)
- integer = true
- # If 3 Arguments (Element, Object, Integer
- elsif args.size == 3
- x = (args[0].x - args[1].x) * (args[0].x - args[1].x)
- y = (args[0].y - args[1].y) * (args[0].y - args[1].y)
- integer = args[2]
- # If 4 Arguments (Elementx, Elementy, Objectx, Objecty)
- elsif args.size == 4
- x = (args[0] - args[2]) * (args[0] - args[2])
- y = (args[1] - args[3]) * (args[1] - args[3])
- integer = true
- # If 5 Arguments (Elementx, Elementy, Objectx, Objecty, integer)
- elsif args.size == 5
- x = (args[0] - args[2]) * (args[0] - args[2])
- y = (args[1] - args[3]) * (args[1] - args[3])
- integer = args[4]
- else
- p 'Wrong Defined Number of Arguments'
- return
- end
- r = Math.sqrt(x + y)
- return integer ? r.to_i : r
- end
- end
- #==============================================================================
- # ** Modules.Zlib
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # Adds PNG_File class to save Bitmap's to PNG Files
- #
- # Class List:
- # -----------
- # Png_File
- #==============================================================================
- MACL::Loaded << 'Modules.Zlib'
- #==============================================================================
- # ** Zlib
- #==============================================================================
- module Zlib
- #============================================================================
- # ** Png_File
- #============================================================================
- class Png_File < GzipWriter
- #--------------------------------------------------------------------------
- # * Make PNG
- #--------------------------------------------------------------------------
- def make_png(bitmap, mode = 0)
- # Save Bitmap & Mode
- @bitmap, @mode = bitmap, mode
- # Create & Save PNG
- self.write(make_header)
- self.write(make_ihdr)
- self.write(make_idat)
- self.write(make_iend)
- end
- #--------------------------------------------------------------------------
- # * Make Header
- #--------------------------------------------------------------------------
- def make_header
- return [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a].pack('C*')
- end
- #--------------------------------------------------------------------------
- # * Make IHDR
- #--------------------------------------------------------------------------
- def make_ihdr
- ih_size = [13].pack("N")
- ih_sign = 'IHDR'
- ih_width = [@bitmap.width].pack('N')
- ih_height = [@bitmap.height].pack('N')
- ih_bit_depth = [8].pack('C')
- ih_color_type = [6].pack('C')
- ih_compression_method = [0].pack('C')
- ih_filter_method = [0].pack('C')
- ih_interlace_method = [0].pack('C')
- string = ih_sign + ih_width + ih_height + ih_bit_depth + ih_color_type +
- ih_compression_method + ih_filter_method + ih_interlace_method
- ih_crc = [Zlib.crc32(string)].pack('N')
- return ih_size + string + ih_crc
- end
- #--------------------------------------------------------------------------
- # * Make IDAT
- #--------------------------------------------------------------------------
- def make_idat
- header = "\x49\x44\x41\x54"
- data = @mode == 0 ? make_bitmap_data0 : make_bitmap_data1
- data = Zlib::Deflate.deflate(data, 8)
- crc = [Zlib.crc32(header + data)].pack('N')
- size = [data.length].pack('N')
- return size + header + data + crc
- end
- #--------------------------------------------------------------------------
- # * Make Bitmap Data 0
- #--------------------------------------------------------------------------
- def make_bitmap_data0
- gz = Zlib::GzipWriter.open('hoge.gz')
- t_Fx = 0
- w = @bitmap.width
- h = @bitmap.height
- data = []
- for y in 0...h
- data.push(0)
- for x in 0...w
- t_Fx += 1
- if t_Fx % 10000 == 0
- Graphics.update
- end
- if t_Fx % 100000 == 0
- s = data.pack("C*")
- gz.write(s)
- data.clear
- end
- color = @bitmap.get_pixel(x, y)
- red = color.red
- green = color.green
- blue = color.blue
- alpha = color.alpha
- data.push(red)
- data.push(green)
- data.push(blue)
- data.push(alpha)
- end
- end
- s = data.pack("C*")
- gz.write(s)
- gz.close
- data.clear
- gz = Zlib::GzipReader.open('hoge.gz')
- data = gz.read
- gz.close
- File.delete('hoge.gz')
- return data
- end
- #--------------------------------------------------------------------------
- # * Make Bitmap Data Mode 1
- #--------------------------------------------------------------------------
- def make_bitmap_data1
- w = @bitmap.width
- h = @bitmap.height
- data = []
- for y in 0...h
- data.push(0)
- for x in 0...w
- color = @bitmap.get_pixel(x, y)
- red = color.red
- green = color.green
- blue = color.blue
- alpha = color.alpha
- data.push(red)
- data.push(green)
- data.push(blue)
- data.push(alpha)
- end
- end
- return data.pack("C*")
- end
- #--------------------------------------------------------------------------
- # * Make IEND
- #--------------------------------------------------------------------------
- def make_iend
- ie_size = [0].pack('N')
- ie_sign = 'IEND'
- ie_crc = [Zlib.crc32(ie_sign)].pack('N')
- return ie_size + ie_sign + ie_crc
- end
- end
- end
- #==============================================================================
- # ** Systems.Animated Gradient Bars Base By Trickster
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # This Set of Classes, is the base for drawing animated gradient bars, in which
- # the bars smoothly scroll to a value. See the individual classes for more info.
- # Bar Images are to be located in Graphics/Gradients
- #
- # Class List:
- # ------------
- # Sprite_GradientBack
- # Sprite_GradientBar
- #==============================================================================
- MACL::Loaded << 'Systems.Animated Gradient Bars Base'
- #==============================================================================
- # ** Sprite_GradientBack By Trickster
- #------------------------------------------------------------------------------
- # This class just draws the background of the Gradient Bar. It is used within
- # Sprite_GradientBar and can be refered to by <Sprite_GradientBar>.background.
- # This Sprite Consists of a Border and a Background.
- #==============================================================================
- class Sprite_GradientBack < Sprite
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :width
- attr_reader :height
- attr_reader :max_width
- attr_reader :max_height
- attr_reader :border
- attr_reader :background
- attr_accessor :bx
- attr_accessor :by
- #-------------------------------------------------------------------------
- # * Name : Initialize
- # Info : Object Initialization
- # Author : Trickster
- # Call Info : Two to Seven Arguments
- # Integer X, Y - Defines the Position
- # Integer Max_Width, Max_Height - Defines Max Dimensions (def none)
- # String border, background - Border and Background files
- # Viewport viewport - The Viewport defaults to nil
- #-------------------------------------------------------------------------
- def initialize(x, y, max_width = nil, max_height = nil, border = 'Back',
- background = 'Back2', viewport = nil)
- # Call Sprite and Send Viewport
- super(viewport)
- # Set Position
- self.x, self.y = x, y
- # Setup Border
- self.bx, self.by = 1, 1
- # Setup Maximum Dimensions
- @max_width, @max_height = max_width, max_height
- # Setup Files
- @border, @background = border, background
- # Setup Dimensions
- setup_dimensions
- # Setup Bitmap
- self.bitmap = Bitmap.new(@width, @height)
- # Refresh
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Setup Dimensions
- # Info : Sets up Dimensions for the Bar
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def setup_dimensions
- # Gets Back Bitmap
- bitmap = RPG::Cache.gradient(@border)
- # Get Width
- @width = max_width.nil? ? bitmap.width : [bitmap.width, max_width].min
- # Get Height
- @height = max_height.nil? ? bitmap.height : [bitmap.height, max_height].min
- end
- #-------------------------------------------------------------------------
- # * Name : Set Width
- # Info : Sets the Bitmap's Width, Refreshes the sprite
- # Author : Trickster
- # Call Info : One Argument, Integer Width - New Width
- #-------------------------------------------------------------------------
- def width=(width)
- # Restrict to (0, max_width]
- width = [width, max_width].min
- # Return if same
- return if @width == width
- # Dispose Old Bitmap
- bitmap.dispose
- # Set Width
- @width = width
- # Set New Bitmap
- self.bitmap = Bitmap.new(@width, @height)
- # Refresh
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Set Height
- # Info : Sets the Bitmap's Height, Refreshes the sprite
- # Author : Trickster
- # Call Info : One Argument, Integer Height - New Height
- #-------------------------------------------------------------------------
- def height=(height)
- # Restrict to (0, max_height]
- height = [height, max_height].min
- # Return if same
- return if @height == height
- # Dispose Old Bitmap
- bitmap.dispose
- # Set Height
- @height = height
- # Set New Bitmap
- self.bitmap = Bitmap.new(@width, @height)
- # Refresh
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Set Gradient File
- # Info : Sets New Gradient Type, Refreshes the sprite
- # Author : Trickster
- # Call Info : One Argument, String File - File to load
- #-------------------------------------------------------------------------
- def border=(border)
- @border = border
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Set Gradient File
- # Info : Sets New Gradient Type, Refreshes the sprite
- # Author : Trickster
- # Call Info : One Argument, String File - File to load
- #-------------------------------------------------------------------------
- def background=(background)
- @background = background
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Refresh
- # Info : Refreshes the sprite
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def refresh
- # Clear Bitmap
- bitmap.clear
- # Draw Gradient Bar Back
- bitmap.draw_trick_gradient_bar_back(0, 0, width, height, @border,
- @background, bx, by)
- end
- end
- #==============================================================================
- # ** Sprite_GradientBar By Trickster
- #-----------------------------------------------------------------------------
- # This class draws a sprite whose bitmap is a gradient bar, it uses my gradient
- # bar sytle (by use of outside pictures). The Pictures can be found in the folder
- # Graphics/Gradients. When the value pointed to by the gradient bar changes the
- # The Bar will smoothly decrease or increase to match the value. Classes that
- # inherit from this class must redefine the method update calling super if needed
- # (for flash effects), or you may use this as a base for other gradient bar
- # sprites. See also classes Sprite_ActorHpBar and Sprite_ActorSpBar for examples.
- # Best used if you create a separate class that inherits from this one.
- #==============================================================================
- class Sprite_GradientBar < Sprite
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :file
- attr_reader :width
- attr_reader :height
- attr_reader :max_width
- attr_reader :max_height
- attr_accessor :background
- attr_accessor :speed
- attr_accessor :bx
- attr_accessor :by
- #-------------------------------------------------------------------------
- # * Name : Initialize
- # Info : Object Initialization
- # Author : Trickster
- # Call Info : Six to Eight Arguments
- # Integer X, Y - Defines the Position
- # Integer Width, Height - Defines Dimensions (or nil for default)
- # Integer/Proc Min, Max - Defines Current and Maximum values for
- # drawing
- # Integer Speed - Update Rate, Every (speed) frames defaults to 1
- # String border, background - Border and Background Files
- # Viewport viewport - The Viewport defaults to nil
- #-------------------------------------------------------------------------
- def initialize(x, y, max_width, max_height, min = 1, max = 1, speed = 1,
- border = 'Back', background = 'Back2', viewport = nil)
- # Call Sprite and sent viewport
- super(viewport)
- # Setup Background
- self.background = Sprite_GradientBack.new(x, y, max_width, max_height, border,
- background, viewport)
- # Setup Instance Variables
- @max_width, @max_height = max_width, max_height
- # Setup Dimensions
- setup_dimensions
- # Setup Bitmap
- self.bitmap = Bitmap.new(@width, @height)
- # Setup Position
- self.x, self.y, self.z = x, y, 101
- # Setup Border Dimensions
- self.bx, self.by = 1, 1
- # Setup Instance Variables
- @min = min.is_a?(Proc) ? min : proc {min}
- # Get Last
- @last = @min.call
- # Get Maximum
- @max = max.is_a?(Proc) ? max : proc {max}
- # Get Speed
- @speed = speed
- # Get File
- @file = '001-Primary01'
- # Setup Counter
- @count = 0
- end
- #-------------------------------------------------------------------------
- # * Name : Setup Dimensions
- # Info : Sets up Dimensions for the Bar
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def setup_dimensions
- # Gets Back Bitmap
- bitmap = background.bitmap
- # Get Width
- @width = max_width.nil? ? bitmap.width : [bitmap.width, max_width].min
- # Get Height
- @height = max_height.nil? ? bitmap.height : [bitmap.height, max_height].min
- end
- #-------------------------------------------------------------------------
- # * Name : Dispose
- # Info : Disposes the sprite and the background
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def dispose
- # Dispose Sprite
- super
- # Dispose Background
- background.dispose
- end
- #-------------------------------------------------------------------------
- # * Name : Update
- # Info : Frane Update, Updates Bar Animation (changes in value)
- # Author : Trickster
- # Call Info : No Arguments
- # Comment: Classes inheriting from this class must redefine this method
- # and call super if needed (for flash effects)
- #-------------------------------------------------------------------------
- def update
- # Call Update
- super
- # Return if this class isn't Sprite_GradientBar
- return if self.class != Sprite_GradientBar
- # Increase Counter
- @count += 1
- # Return if no speed or not speed frames has passed
- return if @speed == 0 or @count % @speed != 0
- # Get Value
- val = @min.call
- # Return if same
- return if @last == value
- # Add + - 1 to Last
- @last += (val - @last).sign
- # Refresh
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Set Slanted Flag
- # Info : Sets Slanted Flag, Refreshes the sprite
- # Author : Trickster
- # Call Info : One Argument, Boolean bool - true - slanted false - otherwise
- #-------------------------------------------------------------------------
- def slanted=(bool)
- # Set Slanted Flag
- @slanted = bool
- # Refresh
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Set X
- # Info : Sets the X Coordinate, updates x coordinate of the background
- # Author : Trickster
- # Call Info : One Argument, Integer X - X Coordinate
- #-------------------------------------------------------------------------
- def x=(x)
- # Call Sprite X
- super(x)
- # Set X for Background
- background.x = x
- end
- #-------------------------------------------------------------------------
- # * Name : Set Y
- # Info : Sets the Y Coordinate, updates y coordinate of the background
- # Author : Trickster
- # Call Info : One Argument, Integer Y - Y Coordinate
- #-------------------------------------------------------------------------
- def y=(y)
- # Call Sprite Y
- super(y)
- # Set Y For Background
- background.y = y
- end
- #-------------------------------------------------------------------------
- # * Name : Set Z
- # Info : Sets the Z Coordinate, updates z coordinate of the background
- # Author : Trickster
- # Call Info : One Argument, Integer Z - Z Coordinate
- #-------------------------------------------------------------------------
- def z=(z)
- # Call Sprite Z
- super(z)
- # Set Background Z to Z - 1
- background.z = z - 1
- end
- #-------------------------------------------------------------------------
- # * Name : Set Width
- # Info : Sets the Bitmap's Width, Refreshes the sprite
- # Author : Trickster
- # Call Info : One Argument, Integer Width - New Width
- #-------------------------------------------------------------------------
- def width=(width)
- # Restrict to (0, max_width]
- width = [width, max_width].min
- # Return if same
- return if @width == width
- # Set Width
- @width = width
- # Dispose Old Bitmap
- bitmap.dispose
- # Set New Bitmap
- self.bitmap = Bitmap.new(@width, @height)
- # Set Background Width
- background.width = @width
- # Refresh
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Set Height
- # Info : Sets the Bitmap's Height, Refreshes the sprite
- # Author : Trickster
- # Call Info : One Argument, Integer Height - New Height
- #-------------------------------------------------------------------------
- def height=(height)
- # Restrict to (0, max_height]
- height = [height, max_height].min
- # Return if same
- return if @height == height
- # Dispose Old Bitmap
- bitmap.dispose
- # Set Height
- @height = height
- # Set New Bitmap
- self.bitmap = Bitmap.new(@width, @height)
- # Set Background Height
- background.height = @height
- # Refresh
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Set Visibility
- # Info : Sets the visibility, updates visibility of the background
- # Author : Trickster
- # Call Info : One Argument, Boolean bool - true: visible false: invisible
- #-------------------------------------------------------------------------
- def visible=(bool)
- # Call Sprite Visible
- super(bool)
- # Set Visibility
- background.visible = bool
- end
- #-------------------------------------------------------------------------
- # * Name : Set Gradient File
- # Info : Sets New Gradient Type, Refreshes the sprite
- # Author : Trickster
- # Call Info : One Argument, String File - File to load
- #-------------------------------------------------------------------------
- def file=(file)
- # Set File
- @file = file
- # Refresh
- refresh
- end
- #-------------------------------------------------------------------------
- # * Name : Set Border
- # Info : Sets Gradient Bars Border
- # Author : Trickster
- # Call Info : One Argument, String File - File to load
- #-------------------------------------------------------------------------
- def set_border(file)
- # Set Border
- background.border = file
- end
- #-------------------------------------------------------------------------
- # * Name : Set Background
- # Info : Sets Gradient Bars Background
- # Author : Trickster
- # Call Info : One Argument, String File - File to load
- #-------------------------------------------------------------------------
- def set_background(file)
- # Set Background's Background
- background.background = file
- end
- #-------------------------------------------------------------------------
- # * Name : Refresh
- # Info : Refreshes the sprite
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def refresh
- # Clear Bitmap
- bitmap.clear
- # Get Max
- max = @max.call == 0 ? 1 : @max.call
- # Get Border
- border = background.border
- # Draw Bar Substance
- bitmap.draw_trick_gradient_bar_sub(0, 0, @last, max, file, width, height,
- border, bx, by, @slanted)
- end
- end
- #==============================================================================
- # ** Systems.Loading Data From Text Files V4.0 By Trickster
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # This Utility module loads data from text files, the text file loaded must
- # be setup like so.
- #
- # something some_value
- # parameter value
- # parameter value
- # parameter value
- #
- # Also has support for comments and block comments within the text file,
- # commented data will be ignored within the file. This also parses the values
- # loaded into the data type it is supposed to be, for example if a value was
- # 50 then it will be loaded as 50 and not "50". This effect works on Strings,
- # Integers, Floats, Ranges, Arrays, Hashes, Regexp, Symbols, TrueClass,
- # FalseClass, NilClass, and Classes (by calling the new operator example
- # Color.new(0, 0, 0) will be loaded as a color object). Also includes error
- # checking and will catch Syntax Errors, missing ] for Array, missing } for
- # Hash, Range errors, and Regexp Errors and will also point to the line and
- # the data that is on the line if an unexcepted error is found within the file.
- #
- # Method List:
- # ------------
- # Trickster.load_data_from_txt
- #
- # Classes:
- # --------
- # Trickster::File_LoadRxdata
- #==============================================================================
- MACL::Loaded << 'Systems.Loading Data From Text Files'
- #==============================================================================
- # ** Trickster
- #==============================================================================
- module Trickster
- #============================================================================
- # ** File_LoadRxdata
- #============================================================================
- class File_LoadRxdata < File
- #-------------------------------------------------------------------------
- # * Public Instance Variables
- #-------------------------------------------------------------------------
- attr_reader :line
- #-------------------------------------------------------------------------
- # * Name : Format Readline
- # Info : Gets Next Line returns An Array of information on next line
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def format_readline
- # Get Line
- data = self.readline
- # Make a Copy
- @line = data.dup
- # Split it
- data = data.split
- # Return Data
- return data
- end
- #-------------------------------------------------------------------------
- # * Name : Requirements
- # Info : Required Data Needed to be loaded
- # Author : Trickster
- # Call Info : Four Arguments
- # Array Data, Data Loaded
- # Array Required, Data Required to be loaded
- # Array Properties, Names to be loaded
- # Boolean Elements, True if Indexes False for Parameters
- #-------------------------------------------------------------------------
- def requirements(data, required, properties, elements)
- required.each do |i|
- if (i < properties.size and (data[i].nil? and elements) or
- (data.is_a?(Hash) and data[properties[i]].nil? and not elements))
- Kernel.print("Error Loading Data \n#{properties[i]} is not defined")
- exit
- end
- end
- end
- #-------------------------------------------------------------------------
- # * Name : Incorrect Name Error
- # Info : Generates Incorrect Defining Name Message
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def error_incorrect_name
- Kernel.print("Error at Line #{lineno}\nIncorrect parameter\nLine: #{line}")
- exit
- end
- #-------------------------------------------------------------------------
- # * Name : Array Error
- # Info : Generates Missing ] for Array Message
- # Author : Trickster
- # Call Info : One Argument, Integer Extra, Line Number
- #-------------------------------------------------------------------------
- def error_array(extra)
- Kernel.print("Error at Line #{extra}\nMissing ']' for Array\nLine: #{line}")
- exit
- end
- #-------------------------------------------------------------------------
- # * Name : Hash Error (Syntax Error)
- # Info : Generates Missing } for Hash Message
- # Author : Trickster
- # Call Info : One Argument, Integer Extra, Line Number
- #-------------------------------------------------------------------------
- def error_hash(extra)
- Kernel.print("Error at Line #{extra}\nMissing '}' for Hash\nLine: #{line}")
- exit
- end
- #-------------------------------------------------------------------------
- # * Name : Syntax Error
- # Info : Generates Syntax Error Message
- # Author : Trickster
- # Call Info : One Argument Integer Extra, Line number
- #-------------------------------------------------------------------------
- def error_syntax(extra)
- Kernel.print("Error at Line #{extra}\nSyntax Error\nLine: #{line}")
- exit
- end
- #-------------------------------------------------------------------------
- # * Name : Range Error
- # Info : Generates Error Message
- # Author : Trickster
- # Call Info : One Argument Integer Extra, Line number
- #-------------------------------------------------------------------------
- def error_range(extra)
- Kernel.print("Error at Line #{extra}\nError with Range\nLine: #{line}")
- exit
- end
- #-------------------------------------------------------------------------
- # Name : Regexp Fail Error
- # Info : Generates Error Message
- # Author : Trickster
- # Call Info : One Argument Integer Extra, Line number
- #-------------------------------------------------------------------------
- def error_regexp_fail(extra)
- Kernel.print("Error at Line #{extra}\nRegexp Failed\nLine: #{line}")
- exit
- end
- #-------------------------------------------------------------------------
- # * Name : Load Next Line
- # Info : Reads Next Line of Data and returns false if End of File,
- # true if Empty or Commented else the Data
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def load_next_line
- # Return False if End of File
- return false if self.eof?
- # Get Data
- data = self.format_readline
- # Set Comment Flag if text is =begin
- @comment = true if data[0] == '=begin'
- # If text is =end
- if data[0] == '=end'
- # Unset Comment Flag
- @comment = false
- # True
- return true
- end
- # Return true if comment or nothing
- return true if data == [] or data[0].include?('#') or @comment
- # Return Data
- return data
- end
- #-------------------------------------------------------------------------
- # * Name : Test Type
- # Info : Tests Data Type and returns sata in the correct format
- # Author : Trickster
- # Call Info : Three to Four Arguments
- # String data, String to be check
- # String Line, Line where data was extracted
- # Integer Lineno, Line number
- # Integer Multi, Multi Lines for error checking
- # Comment : Checks for almost all data types
- #-------------------------------------------------------------------------
- def test_type(data, line, lineno, multi = 0)
- # Make a copy of the data
- temp = data.dup
- # Set extra text if an error is found
- extra = (multi > 0) ? "s #{lineno}-#{lineno+multi}" : " #{lineno}"
- # If a nil reference
- if test_nilclass?(temp)
- # Set Data to Nil
- data = nil
- # If True
- elsif test_trueclass?(temp)
- # Set to True
- data = true
- # If False
- elsif test_falseclass?(temp)
- # Set to false
- data = false
- # If an array
- elsif test_array?(temp)
- # Error Array if it doesn't include ]
- self.error_array(extra) unless temp.include?(']')
- # Evaluate Data
- data = eval_data(data, extra)
- # If a hash
- elsif test_hash?(temp)
- # Error Hash if it doesn't include }
- self.error_hash(extra) unless temp.include?('}')
- # Evaluate Data
- data = eval_data(data, extra)
- # If a number (Integer)
- elsif test_integer?(temp)
- # Convert to Integer
- data = data.to_i
- # If a number (Float)
- elsif test_float?(temp)
- # Convert to Float
- data = data.to_f
- # If a Range
- elsif test_range?(temp)
- begin
- # Evaluate Data
- data = eval_data(data, extra)
- rescue
- # Print Range Error
- self.error_range(extra)
- end
- # If a Regexp
- elsif test_regexp?(temp)
- begin
- # Evaluate Data
- data = eval_data(data, extra)
- rescue RegexpError
- # If Regexp Error then print Error
- self.error_regexp_fail
- end
- # If a Symbol
- elsif test_symbol?(temp)
- # Evaluate Data
- data = eval_data(data, extra)
- # If an Instance of a Class
- elsif test_class?(temp)
- # Evaluate Data
- data = eval_data(data, extra)
- # Elsif a string
- elsif test_string?(temp)
- # Just Delete First and Last Index
- data = data[1...(data.size-1)]
- end
- # Return Data
- return data
- end
- #-------------------------------------------------------------------------
- # * Name : Test NilClass
- # Info : Tests if Data is nil
- # Author : Trickster
- # Call Info : String data - data to check
- #-------------------------------------------------------------------------
- def test_nilclass?(data)
- return data == 'nil'
- end
- #-------------------------------------------------------------------------
- # * Name : Test TrueClass
- # Info : Tests if Data is true
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_trueclass?(data)
- return data == 'true'
- end
- #-------------------------------------------------------------------------
- # * Name : Test FalseClass
- # Info : Tests if Data is false
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_falseclass?(data)
- return data == 'false'
- end
- #-------------------------------------------------------------------------
- # * Name : Test Array
- # Info : Tests if Data is an array (starts with [)
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_array?(data)
- return data[0, 1] == '['
- end
- #-------------------------------------------------------------------------
- # * Name : Test Hash
- # Info : Tests if Data is a hash (starts with { and has =>)
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_hash?(data)
- return data[0, 1] == '{' && data.include?('=>') && data
- end
- #-------------------------------------------------------------------------
- # * Name : Test Integer
- # Info : Tests if Data is an integer (if to_i.to_s == data)
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_integer?(data)
- return data.to_i.to_s == data
- end
- #-------------------------------------------------------------------------
- # * Name : Test Float
- # Info : Tests if Data is a float (if to_f.to_s == data)
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_float?(data)
- return data.to_f.to_s == data
- end
- #-------------------------------------------------------------------------
- # * Name : Test Range
- # Info : Tests if Data is a range (includes .. or ...
- # and first and last are integers and when .. or ... is removed
- # is an integer)
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_range?(data)
- # Create Copy
- copy = data.dup
- # Return false if no .. or ...
- return false unless copy.include?('..') or copy.include?('...')
- # Substitute .. or ... from data
- copy.sub!(/\.{2,3}/, '')
- # Return false if leftovers is not a int
- return false if not test_integer?(copy)
- # Return first and last characters are integers
- return test_integer?(data[0,1]) && test_integer?(data[-1,1])
- end
- #-------------------------------------------------------------------------
- # * Name : Test Regexp
- # Info : Tests if Data is a regexp (first and last are /)
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_regexp?(data)
- return data[0, 1] == '/' && data[-1, 1] == '/'
- end
- #-------------------------------------------------------------------------
- # * Name : Test Symbol
- # Info : Tests if Data is a symbol (first is :)
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_symbol?(data)
- return data[0, 1] == ':'
- end
- #-------------------------------------------------------------------------
- # * Name : Test Class
- # Info : Tests if Data is a class (has .new)
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_class?(data)
- return data.include?('.new')
- end
- #-------------------------------------------------------------------------
- # * Name : Test String
- # Info : Tests if Data is a string (first and last are ")
- # Author : Trickster
- # Call Info : String data - data to Check
- #-------------------------------------------------------------------------
- def test_string?(data)
- return data[0] == 34 && data[-1] == 34
- end
- #-------------------------------------------------------------------------
- # * Name : Eval Data
- # Info : calls eval on data and catches Syntax Errors
- # Author : Trickster
- # Call Info : String data, extra - data to Check, error info
- #-------------------------------------------------------------------------
- def eval_data(data, extra = '')
- begin
- # Evaluate Data
- data = eval(data)
- rescue SyntaxError
- # If Syntax Error then print Error
- self.error_syntax(extra)
- end
- end
- end
- #-------------------------------------------------------------------------
- # * Name : Load Data From Text file
- # Info : Loads data from a text file
- # returns an array/hash with the data from text file
- # Author : Trickster
- # Call Info : Two to Five Arguments
- # String File_name, file name to load from
- # Array Properties, Defining Values
- # Array Required, An Array of Indexes that must be loaded
- # defaults to index 0
- # Array Multilined, An Array of Indexes that read from multilines
- # defaults to nothing, note: for strings only
- # Integer Elements, If 0 Elements are arrays (Default)
- # If 1 Elements are hashes Key = id
- # Else Elements are hashes Key = parameter
- #-------------------------------------------------------------------------
- def self.load_data_from_txt(file_name, properties, required = [0],
- multi_lined = [], elements = 0)
- # Initialize local variables
- final_data = []
- data_txt = elements == 0 ? [] : {}
- index = 1
- # Load File
- file = Trickster::File_LoadRxdata.open(file_name)
- # Loop until End of File (EOF)
- until file.eof?
- # Get line data
- data = file.format_readline
- # Get Line
- line = file.line
- # Set Comment Flag if text is =begin
- @comment = true if data[0] == '=begin'
- # If text is =end
- if data[0] == '=end'
- # Unset Comment Flag
- @comment = false
- # Next
- next
- end
- # Next if no data or commented line
- next if data == [] or data[0].include?('#') or @comment
- # Get id from the properties
- id = properties.index(data[0])
- # If a new id
- if id == 0 and not data_txt.empty?
- # Check requirements and return error if not fulfilled
- file.requirements(data_txt, required, properties, [0,1].include?(elements))
- # Finished reading a piece of data
- final_data[index] = data_txt.dup
- # Increase index and reset data
- index += 1
- data_txt.clear
- elsif id == nil
- # Incorrent Defining name error message
- file.error_incorrect_name
- end
- # Remove defining name and join together
- data.delete_at(0)
- data = data.join(' ')
- # Get line number
- lineno = file.lineno
- # Start multi line information checking
- multi = 1
- if multi_lined.include?(id)
- # Load next line
- next_line = file.load_next_line
- # Get first data
- first = next_line.is_a?(Array) ? next_line[0] : ""
- # Reset flag
- flag = false
- # While an invalid property and the file is not eof? or data loaded
- while (properties.index(first) == nil and (next_line != false or next_line.is_a?(Array)))
- # While was excuted once
- flag = true
- position = file.pos
- # add to data if an array
- if next_line.is_a?(Array)
- # Get property data
- first = next_line[0]
- if properties.index(first) == nil
- data += ' ' + next_line.join(' ')
- end
- end
- # Load next line and reset first
- next_line = file.load_next_line
- first = ""
- # increase multi line count
- multi += 1
- # break if file.eof? continue if line was a comment
- break if next_line == false
- next if next_line == true
- first = next_line[0]
- end
- if flag
- file.pos = position
- end
- if next_line.is_a?(Array)
- if properties.index(first) == nil
- data += next_line.join(' ')
- end
- end
- end
- data = file.test_type(data, line, lineno, multi)
- data_txt[id] = data if [0,1].include?(elements)
- data_txt[properties[id]] = data if not [0,1].include?(elements)
- end
- # Reached End of File Get last data if any
- if not data_txt.empty?
- # Check requirements and return error if not fulfilled
- file.requirements(data_txt, required, properties, [0,1].include?(elements))
- # Finished reading a piece of data
- final_data[index] = data_txt.dup
- # Increase index and reset data
- index += 1
- data_txt.clear
- end
- # Close File
- file.close
- # return all data compacted
- return final_data.compact
- end
- end
- #==============================================================================
- # ** Systems.Pathfinding By Near Fantastica (Edits By SephirothSpawn)
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # This system allows the player and events draw a path from one point to
- # another in the shortest route possible.
- #
- # Method List:
- # ------------
- #
- # Game_Character
- # ------
- # map
- # runpath
- # run_path
- # find_path
- # clear_path
- # setup_map
- #
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # Make Player run path
- # - $game_player.run_path(x, y)
- #
- # Make Event run path
- # - $game_map.events[event_id].run_path(x, y)
- #==============================================================================
- MACL::Loaded << 'Systems.Pathfinding'
- #==============================================================================
- # ** Game_Character
- #==============================================================================
- class Game_Character
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :map
- attr_accessor :runpath
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :nf_pathfinding_gmchr_init, :initialize
- alias_method :nf_pathfinding_gmchr_upda, :update
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- # Clear Path
- clear_path
- # Original Initialization
- nf_pathfinding_gmchr_init
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Run Pathfind if Runpath
- run_path if @runpath
- # Original Update
- nf_pathfinding_gmchr_upda
- end
- #--------------------------------------------------------------------------
- # * Frame Update : Run Pathfinding
- #--------------------------------------------------------------------------
- def run_path
- # Return If Moving
- return if self.moving?
- # Gets Current Step
- step = @map[@x, @y]
- # If No More Stes
- if step == 1
- # Clear Pathfinding Flags
- clear_path
- return
- end
- # If Random Direction Patterns is 0
- if rand(2) == 0
- move_right if @map[@x + 1, @y] == step - 1 && step != 0
- move_down if @map[@x, @y + 1] == step - 1 && step != 0
- move_left if @map[@x - 1, @y] == step - 1 && step != 0
- move_up if @map[@x, @y - 1] == step - 1 && step != 0
- else
- move_up if @map[@x, @y - 1] == step - 1 && step != 0
- move_left if @map[@x - 1, @y] == step - 1 && step != 0
- move_down if @map[@x, @y + 1] == step - 1 && step != 0
- move_right if @map[@x + 1, @y] == step - 1 && step != 0
- end
- end
- #--------------------------------------------------------------------------
- # * Find Pathing
- #--------------------------------------------------------------------------
- def find_path(x,y)
- # Gets Result
- result = setup_map(@x, @y, x, y)
- # Sets Pathfinding Flags
- @runpath = result[0]
- @map = result[1]
- @map[sx, sy] = result[2] if result[2] != nil
- end
- #--------------------------------------------------------------------------
- # * Clear Pathing
- #--------------------------------------------------------------------------
- def clear_path
- @map = nil
- @runpath = false
- end
- #--------------------------------------------------------------------------
- # * Setup Map
- #--------------------------------------------------------------------------
- def setup_map(sx, sy, ex, ey)
- # Creates Map
- map = Table.new($game_map.width, $game_map.height)
- # Starts Step Counters
- map[ex,ey] = 1
- # Creates New and Old Positions
- old_positions = []
- new_positions = []
- old_positions.push([ex, ey])
- # Starts Creating New Nodes
- 2.upto(100) do |step|
- loop do
- # Break If No old Positins
- break if old_positions[0].nil?
- # Gets First Position
- x, y = old_positions.shift
- # Return if Finished
- return [true, map, step] if (x == sx and y + 1 == sy) &&
- (x == sx and y - 1 == sy) &&
- (x - 1 == sx and y == sy) &&
- (x + 1 == sx and y == sy)
- # Add Position if Down Passable
- if $game_player.passable?(x, y, 2) and map[x, y + 1] == 0
- map[x, y + 1] = step
- new_positions.push([x, y + 1])
- end
- # Add Position if Left Passable
- if $game_player.passable?(x, y, 4) and map[x - 1, y] == 0
- map[x - 1,y] = step
- new_positions.push([x - 1, y])
- end
- # Add Position if Right Passable
- if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
- map[x + 1,y] = step
- new_positions.push([x + 1,y])
- end
- # Add Position if Up Passable
- if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
- map[x, y - 1] = step
- new_positions.push([x, y - 1])
- end
- end
- # Changes Positions
- old_positions = new_positions
- new_positions = []
- end
- # Return If Path Not Found
- return [false, nil, nil]
- end
- end
- #==============================================================================
- # ** Game_Map
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :nf_pathfinding_gmmap_setup, :setup
- #--------------------------------------------------------------------------
- def setup(map_id)
- # Orignal Setup
- nf_pathfinding_gmmap_setup(map_id)
- # Clear Player Path
- $game_player.clear_path
- end
- end
- #==============================================================================
- # ** Game_Player
- #==============================================================================
- class Game_Player
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :nf_pathfinding_gmplyr_update, :update
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Clear Path if Direciton Pressed
- $game_player.clear_path if Input.dir4 != 0
- # Original Update
- nf_pathfinding_gmplyr_update
- end
- end
- #==============================================================================
- # ** Systems.Quick Animations (3.01) By SephirothSpawn
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to act as a GIF animation player. Because GIF
- # images aren't actually able to play in RMXP (without API), this script
- # either uses a series of images in a directory numbered OR an animation
- # like image with multiple frames placed side by side.
- #------------------------------------------------------------------------------
- # * Instructions :
- #
- # * Creating Animated Sprite
- #
- # object = Sprite_Animation.new({<parameters>})
- #
- # * Creating Animated Plane
- #
- # object = Plane_Animation.new({<parameters>})
- #
- # * Parameters
- #
- # 'type' => 'A' or 'B'
- # - Type of Animation (A : Directory of images, B : Spriteset)
- # 'loop' => true or false
- # - loop (true : loops, false : plays then disposes)
- # 'fs' => n
- # - frameskip (number of frames to go to next frame)
- # 'vp' => Viewport
- # - viewport (sprite viewport)
- #
- # Required For Type A
- # 'dir' => 'Graphics/...'
- # - directory of images
- #
- # Required For Type B
- # 'frames' => n
- # - number of frames on spriteset
- # 'bitmap' => 'filename'
- # - filename in pictures folder
- #------------------------------------------------------------------------------
- # * Credits :
- #
- # Thanks Trickster for Animation Type 2 Suggestion
- #==============================================================================
- MACL::Loaded << 'Systems.Quick Animations'
- #==============================================================================
- # ** Sprite_Animation
- #==============================================================================
- class Sprite_Animation < Sprite
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(parameters = {})
- # Assigns Defaults (If Non-Defined)
- @type = parameters.has_key?('type') ? parameters['type'] : 'A'
- @loop = parameters.has_key?('loop') ? parameters['loop'] : true
- @frameskip = parameters.has_key?('fs') ? parameters['fs'] : 10
- @dir = parameters.has_key?('dir') ? parameters['dir'] : nil
- @frames = parameters.has_key?('frames') ? parameters['frames'] : 1
- viewport = parameters.has_key?('vp') ? parameters['vp'] : nil
- bitmap = parameters.has_key?('bitmap') ? parameters['bitmap'] : ''
- # Creates Viewport
- super(viewport)
- # Sets Index
- @index = -1
- # Sets Specialized Parameters
- if @type.upcase == 'B'
- # Sets Frame Number & Sets Bitmap
- self.bitmap = RPG::Cache.picture(bitmap)
- end
- # Update
- update
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- # Stop Unless Proceed Frame
- return unless Graphics.frame_count % @frameskip == 0
- # Increase Index
- @index += 1
- # Branch By Type
- if @type.upcase == 'A'
- # Update Type A
- update_type_a
- elsif @type.upcase == 'B'
- # Update Type B
- update_type_b
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update : Type A
- #--------------------------------------------------------------------------
- def update_type_a
- # Begin
- begin
- # Load Bitmap
- self.bitmap = RPG::Cache.load_bitmap(@dir, @index.to_s)
- # If Bitmap Cannot Be Found
- rescue
- # If Looping
- if @loop
- # Reset Index
- @index = - 1
- update
- else
- # Dispose Image
- self.dispose
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update : Type B
- #--------------------------------------------------------------------------
- def update_type_b
- # If Passed Last Frame
- if @index == @frames
- # If Loop Image
- if @loop
- # Reset Index & Update Bitmap
- @index = -1
- update
- # If No Loop
- else
- # Delete Image
- self.dispose
- return
- end
- end
- # Updates Src Rect
- x = (w = self.bitmap.width / @frames) * @index
- self.src_rect.set(x, 0, w, self.bitmap.height)
- end
- end
- #==============================================================================
- # ** Plane_Animation
- #==============================================================================
- class Plane_Animation < Plane
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(parameters = {})
- # Assigns Defaults (If Non-Defined)
- @type = parameters.has_key?('type') ? parameters['type'] : 'A'
- @loop = parameters.has_key?('loop') ? parameters['loop'] : true
- @frameskip = parameters.has_key?('fs') ? parameters['fs'] : 10
- @dir = parameters.has_key?('dir') ? parameters['dir'] : nil
- @frames = parameters.has_key?('frames') ? parameters['frames'] : 1
- viewport = parameters.has_key?('vp') ? parameters['vp'] : nil
- bitmap = parameters.has_key?('bitmap') ? parameters['bitmap'] : ''
- # Creates Viewport
- super(viewport)
- # Sets Index
- @index = -1
- # Sets Specialized Parameters
- if @type.upcase == 'B'
- # Sets Frame Number & Sets Bitmap
- @_bitmap = RPG::Cache.picture(bitmap)
- end
- # Update
- update
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Stop Unless Proceed Frame
- return unless Graphics.frame_count % @frameskip == 0
- # Increase Index
- @index += 1
- # Branch By Type
- if @type.upcase == 'A'
- # Update Type A
- update_type_a
- elsif @type.upcase == 'B'
- # Update Type B
- update_type_b
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update : Type A
- #--------------------------------------------------------------------------
- def update_type_a
- # Begin
- begin
- # Load Bitmap
- self.bitmap = RPG::Cache.load_bitmap(@dir, @index.to_s)
- # If Bitmap Cannot Be Found
- rescue
- # If Looping
- if @loop
- # Reset Index
- @index = - 1
- update
- else
- # Dispose Image
- self.dispose
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update : Type B
- #--------------------------------------------------------------------------
- def update_type_b
- # If Passed Last Frame
- if @index == @frames
- # If Loop Image
- if @loop
- # Reset Index & Update Bitmap
- @index = -1
- update
- # If No Loop
- else
- # Delete Image
- self.dispose
- return
- end
- end
- # Updates Bitmap
- b = Bitmap.new((w = @_bitmap.width) / @frames, (h = @_bitmap.height))
- b.blt(0, 0, @_bitmap, Rect.new(w / @frames * @index, 0, b.width, h))
- self.bitmap = b
- end
- end
- #==============================================================================
- # ** Systems.Scrolling Sprites By: Trickster
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # Classes Associated with Scrolling Sprites
- #
- # Class List:
- # ------------
- # Scroll_Sprite
- # Sprite_Scrollable
- #==============================================================================
- MACL::Loaded << 'Systems.Scrolling Sprites'
- #==============================================================================
- # ** Scroll_Sprite By: Trickster
- #------------------------------------------------------------------------------
- # Custom Sprite Class That Has Scroll Functions
- #==============================================================================
- class Scroll_Sprite < Sprite
- #-------------------------------------------------------------------------
- # Name : Initialize
- # Info : Object Initialization
- # Author : Trickster
- # Call Info : Four to Five Arguments
- # Integer X and Y, define position
- # Integer Width and Height, define width and height of the sprite
- # Viewport viewport viewport to be used defaults to whole screen
- #-------------------------------------------------------------------------
- def initialize(x, y, width, height, viewport = nil)
- super(viewport)
- self.x = x
- self.y = y
- self.width = width
- self.height = height
- end
- #-------------------------------------------------------------------------
- # Name : Set Source X
- # Info : Sets Source X of Display
- # Author : Trickster
- # Call Info : One Argument, Integer ox Offset X Starting Point
- #-------------------------------------------------------------------------
- def sx=(ox)
- src_rect.x = ox
- end
- #-------------------------------------------------------------------------
- # Name : Set Source Y
- # Info : Sets Source Y of Display
- # Author : Trickster
- # Call Info : One Argument, Integer oy Offset Y Starting Point
- #-------------------------------------------------------------------------
- def sy=(oy)
- src_rect.y = oy
- end
- #-------------------------------------------------------------------------
- # Name : Set Source Width
- # Info : Sets Source Width of Display
- # Author : Trickster
- # Call Info : One Argument, Integer width The Sprite's Width
- #-------------------------------------------------------------------------
- def width=(width)
- src_rect.width = width
- @width = width
- end
- #-------------------------------------------------------------------------
- # Name : Set Source Height
- # Info : Sets Source Height of Display
- # Author : Trickster
- # Call Info : One Argument, Integer height The Sprite's Height
- #-------------------------------------------------------------------------
- def height=(height)
- src_rect.height = height
- @height = height
- end
- #-------------------------------------------------------------------------
- # * Name : Get Source X
- # Info : Gets Source X of Display
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def sx
- return src_rect.x
- end
- #-------------------------------------------------------------------------
- # * Name : Get Source Y
- # Info : Gets Source Y of Display
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def sy
- return src_rect.y
- end
- #-------------------------------------------------------------------------
- # * Name : Get Source Width
- # Info : Gets Source Width of Display
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def width
- return src_rect.width
- end
- #-------------------------------------------------------------------------
- # * Name : Get Source Height
- # Info : Gets Source Height of Display
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def height
- return src_rect.height
- end
- #-------------------------------------------------------------------------
- # * Name : Set Bitmap
- # Info : Sets the Sprite's Bitmap
- # Author : Trickster
- # Call Info : One Argument, Bitmap bitmap the bitmap to be loaded
- #-------------------------------------------------------------------------
- def bitmap=(bitmap)
- super(bitmap)
- src_rect.width = @width
- src_rect.height = @height
- end
- end
- #==============================================================================
- # ** Sprite_Scrollable By: Trickster
- #------------------------------------------------------------------------------
- # This sprite class contains scroll functions. Inherits from Scroll Sprite.
- # for a practical example of how to use see, Window Scrollable and
- # my Advanced Mission script
- #==============================================================================
- class Sprite_Scrollable < Scroll_Sprite
- #-------------------------------------------------------------------------
- # * Public Instance Variables
- #-------------------------------------------------------------------------
- attr_accessor :speed
- attr_accessor :bitmap_rect
- attr_writer :horizontal_scroll
- attr_writer :vertical_scroll
- #-------------------------------------------------------------------------
- # * Name : Initialize
- # Info : Object Initialization
- # Author : Trickster
- # Call Info : Four Arguments
- # Integer X and Y define position
- # Integer Width and Height defines the Source Width and Height
- #-------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x,y,width,height)
- @bitmap_rect = Rect.new(0,0,width,height)
- @speed = 0
- @horizontal_scroll = false
- @vertical_scroll = false
- end
- #-------------------------------------------------------------------------
- # * Name : Normal Text Color
- # Info : The Normal Text Color - (255,255,255,255)
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def normal_color
- return Color.new(255, 255, 255, 255)
- end
- #-------------------------------------------------------------------------
- # * Name : Disabled Text Color
- # Info : The Disable Text Color- (255,255,255,128)
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def disabled_color
- return Color.new(255, 255, 255, 128)
- end
- #-------------------------------------------------------------------------
- # * Name : System Text Color
- # Info : The System Text Color (192,224,255,255)
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def system_color
- return Color.new(192, 224, 255, 255)
- end
- #-------------------------------------------------------------------------
- # * Name : Vertical?
- # Info : Can sprite be scrolled vertically?
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def vertical?
- return false if self.bitmap == nil
- return self.bitmap.height > self.height
- end
- #-------------------------------------------------------------------------
- # * Name : Horizontal?
- # Info : Can sprite be scrolled horizontally?
- # Author : Trickster
- # Call Info : No Arguments
- #-------------------------------------------------------------------------
- def horizontal?
- return false if self.bitmap == nil
- return self.bitmap.width > self.width
- end
- #-------------------------------------------------------------------------
- # * Name : Update
- # Info : Frame Update
- # Author : Trickster
- # Call Info : No Arguments
- # Comment : Allows the Sprite To Scroll with direction keys
- # if scrolling is enabled
- #-------------------------------------------------------------------------
- def update
- super
- if Input.repeat?(Input::UP)
- if self.sy > @bitmap_rect.y and @vertical_scroll and vertical?
- self.sy = [self.sy - speed, @bitmap_rect.y].max
- end
- end
- if Input.repeat?(Input::LEFT)
- if self.sx > @bitmap_rect.x and @horizontal_scroll and horizontal?
- self.sx = [self.sx - speed, @bitmap_rect.x].max
- end
- end
- if Input.repeat?(Input::DOWN)
- if self.sy < @bitmap_rect.height - self.height and @vertical_scroll and vertical?
- self.sy = [self.sy + speed, @bitmap_rect.height].min
- end
- end
- if Input.repeat?(Input::RIGHT)
- if self.sx < @bitmap_rect.width - self.width and @horizontal_scroll and horizontal?
- self.sx = [self.sx - speed, @bitmap_rect.width].min
- end
- end
- end
- end
- #==============================================================================
- # ** Stat Bonus Base
- #------------------------------------------------------------------------------
- # SephirothSpawn
- # Version 1
- # 2007-01-26
- #------------------------------------------------------------------------------
- # * Version History :
- #
- # Version 1 ---------------------------------------------------- (2007-01-26)
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This script was designed to create methods for adding direct and percent
- # modifications to the actors stats. This is a tool for scripters. The basic
- # stat formula is as follows :
- #
- # stat = (base_stat + direct_mod) * percent mod
- #------------------------------------------------------------------------------
- # * Instructions :
- #
- # Place The Script Below the SDK and Above Main.
- # To learn to use the system, refer to syntax.
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # The following stats can recieve a bonus :
- # - maxhp, maxsp, str, dex, agi, int, atk, mdef, pdef, eva, hit
- #
- # Basic Outline to using methods :
- #
- # alias_method :<yourname>_<scriptname>_statmod_<statname>, :<statmethod>
- # def <statmethod>
- # n = <yourname>_<scriptname>_statmod_<statname>
- # n += (your formula for adding bonuses here)
- # return n
- # end
- #
- # Direct Bonus Methods :
- # - direct_maxhp_bonus - direct_str_bonus - direct_agi_bonus
- # - direct_maxsp_bonus - direct_dex_bonus - direct_int_bonus
- # - direct_atk_bonus - direct_pdef_bonus - direct_mdef_bonus
- # - direct_eva_bonus - direct_hit_bonus
- #
- # Percent Bonus Methds :
- # - percent_maxhp_bonus - percent_str_bonus - percent_agi_bonus
- # - percent_maxsp_bonus - percent_dex_bonus - percent_int_bonus
- # - percent_atk_bonus - percent_pdef_bonus - percent_mdef_bonus
- # - percent_eva_bonus - percent_hit_bonus
- #
- # All methods are located in Game_Actor & Game_Enemy
- #
- # ** Example : Adding 5 Points to maxhp for actor 5
- #
- # class Game_Actor < Game_Battler
- # alias_method :seph_example_statmod_dhpb, :direct_maxhp_bonus
- # def direct_maxhp_bonus
- # n = seph_example_statmod_dhpb
- # n += 5 if @actor_id == 5
- # return n
- # end
- # end
- #==============================================================================
- MACL::Loaded << 'Systems.Stat Bonus Base'
- #==============================================================================
- # ** Game_Actor
- #==============================================================================
- class Game_Actor
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_statbonusbase_bmaxhp, :base_maxhp
- alias_method :seph_statbonusbase_bmaxsp, :base_maxsp
- alias_method :seph_statbonusbase_bstr, :base_str
- alias_method :seph_statbonusbase_bdex, :base_dex
- alias_method :seph_statbonusbase_bagi, :base_agi
- alias_method :seph_statbonusbase_bint, :base_int
- alias_method :seph_statbonusbase_batk, :base_atk
- alias_method :seph_statbonusbase_bpdef, :base_pdef
- alias_method :seph_statbonusbase_bmdef, :base_mdef
- alias_method :seph_statbonusbase_beva, :base_eva
- alias_method :seph_statbonusbase_hit, :hit
- #--------------------------------------------------------------------------
- # * Get Maximum HP
- #--------------------------------------------------------------------------
- def base_maxhp
- # Gets Orginal Value
- n = seph_statbonusbase_bmaxhp
- # Adds Direct Stat Bonus
- n += direct_maxhp_bonus
- # Adds Percent Stat Bonus
- n *= (percent_maxhp_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_maxhp_bonus ; return 0 ; end
- def percent_maxhp_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Maximum SP
- #--------------------------------------------------------------------------
- def base_maxsp
- # Gets Orginal Value
- n = seph_statbonusbase_bmaxsp
- # Adds Direct Stat Bonus
- n += direct_maxsp_bonus
- # Adds Percent Stat Bonus
- n *= (percent_maxsp_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_maxsp_bonus ; return 0 ; end
- def percent_maxsp_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Strength
- #--------------------------------------------------------------------------
- def base_str
- # Gets Orginal Value
- n = seph_statbonusbase_bstr
- # Adds Direct Stat Bonus
- n += direct_str_bonus
- # Adds Percent Stat Bonus
- n *= (percent_str_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_str_bonus ; return 0 ; end
- def percent_str_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Dexterity
- #--------------------------------------------------------------------------
- def base_dex
- # Gets Orginal Value
- n = seph_statbonusbase_bdex
- # Adds Direct Stat Bonus
- n += direct_dex_bonus
- # Adds Percent Stat Bonus
- n *= (percent_dex_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_dex_bonus ; return 0 ; end
- def percent_dex_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Agility
- #--------------------------------------------------------------------------
- def base_agi
- # Gets Orginal Value
- n = seph_statbonusbase_bagi
- # Adds Direct Stat Bonus
- n += direct_agi_bonus
- # Adds Percent Stat Bonus
- n *= (percent_agi_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_agi_bonus ; return 0 ; end
- def percent_agi_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Intelligence
- #--------------------------------------------------------------------------
- def base_int
- # Gets Orginal Value
- n = seph_statbonusbase_bint
- # Adds Direct Stat Bonus
- n += direct_int_bonus
- # Adds Percent Stat Bonus
- n *= (percent_int_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_int_bonus ; return 0 ; end
- def percent_int_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Attack Power
- #--------------------------------------------------------------------------
- def base_atk
- # Gets Orginal Value
- n = seph_statbonusbase_batk
- # Adds Direct Stat Bonus
- n += direct_atk_bonus
- # Adds Percent Stat Bonus
- n *= (percent_atk_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_atk_bonus ; return 0 ; end
- def percent_atk_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Physical Defense
- #--------------------------------------------------------------------------
- def base_pdef
- # Gets Orginal Value
- n = seph_statbonusbase_bpdef
- # Adds Direct Stat Bonus
- n += direct_pdef_bonus
- # Adds Percent Stat Bonus
- n *= (percent_pdef_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_pdef_bonus ; return 0 ; end
- def percent_pdef_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Magic Defense
- #--------------------------------------------------------------------------
- def base_mdef
- # Gets Orginal Value
- n = seph_statbonusbase_bmdef
- # Adds Direct Stat Bonus
- n += direct_mdef_bonus
- # Adds Percent Stat Bonus
- n *= (percent_mdef_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_mdef_bonus ; return 0 ; end
- def percent_mdef_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Evasion Correction
- #--------------------------------------------------------------------------
- def base_eva
- # Gets Orginal Value
- n = seph_statbonusbase_beva
- # Adds Direct Stat Bonus
- n += direct_eva_bonus
- # Adds Percent Stat Bonus
- n *= (percent_eva_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_eva_bonus ; return 0 ; end
- def percent_eva_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Hit
- #--------------------------------------------------------------------------
- def hit
- # Gets Orginal Value
- n = seph_statbonusbase_hit
- # Adds Direct Stat Bonus
- n += direct_hit_bonus
- # Adds Percent Stat Bonus
- n *= (percent_hit_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_hit_bonus ; return 0 ; end
- def percent_hit_bonus ; return 0 ; end
- end
- #==============================================================================
- # ** Game_Enemy
- #==============================================================================
- class Game_Enemy
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias_method :seph_statbonusbase_bmaxhp, :base_maxhp
- alias_method :seph_statbonusbase_bmaxsp, :base_maxsp
- alias_method :seph_statbonusbase_bstr, :base_str
- alias_method :seph_statbonusbase_bdex, :base_dex
- alias_method :seph_statbonusbase_bagi, :base_agi
- alias_method :seph_statbonusbase_bint, :base_int
- alias_method :seph_statbonusbase_batk, :base_atk
- alias_method :seph_statbonusbase_bpdef, :base_pdef
- alias_method :seph_statbonusbase_bmdef, :base_mdef
- alias_method :seph_statbonusbase_beva, :base_eva
- alias_method :seph_statbonusbase_hit, :hit
- #--------------------------------------------------------------------------
- # * Get Maximum HP
- #--------------------------------------------------------------------------
- def base_maxhp
- # Gets Orginal Value
- n = seph_statbonusbase_bmaxhp
- # Adds Direct Stat Bonus
- n += direct_maxhp_bonus
- # Adds Percent Stat Bonus
- n *= (percent_maxhp_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_maxhp_bonus ; return 0 ; end
- def percent_maxhp_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Maximum SP
- #--------------------------------------------------------------------------
- def base_maxsp
- # Gets Orginal Value
- n = seph_statbonusbase_bmaxsp
- # Adds Direct Stat Bonus
- n += direct_maxsp_bonus
- # Adds Percent Stat Bonus
- n *= (percent_maxsp_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_maxsp_bonus ; return 0 ; end
- def percent_maxsp_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Strength
- #--------------------------------------------------------------------------
- def base_str
- # Gets Orginal Value
- n = seph_statbonusbase_bstr
- # Adds Direct Stat Bonus
- n += direct_str_bonus
- # Adds Percent Stat Bonus
- n *= (percent_str_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_str_bonus ; return 0 ; end
- def percent_str_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Dexterity
- #--------------------------------------------------------------------------
- def base_dex
- # Gets Orginal Value
- n = seph_statbonusbase_bdex
- # Adds Direct Stat Bonus
- n += direct_dex_bonus
- # Adds Percent Stat Bonus
- n *= (percent_dex_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_dex_bonus ; return 0 ; end
- def percent_dex_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Agility
- #--------------------------------------------------------------------------
- def base_agi
- # Gets Orginal Value
- n = seph_statbonusbase_bagi
- # Adds Direct Stat Bonus
- n += direct_agi_bonus
- # Adds Percent Stat Bonus
- n *= (percent_agi_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_agi_bonus ; return 0 ; end
- def percent_agi_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Intelligence
- #--------------------------------------------------------------------------
- def base_int
- # Gets Orginal Value
- n = seph_statbonusbase_bint
- # Adds Direct Stat Bonus
- n += direct_int_bonus
- # Adds Percent Stat Bonus
- n *= (percent_int_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_int_bonus ; return 0 ; end
- def percent_int_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Attack Power
- #--------------------------------------------------------------------------
- def base_atk
- # Gets Orginal Value
- n = seph_statbonusbase_batk
- # Adds Direct Stat Bonus
- n += direct_atk_bonus
- # Adds Percent Stat Bonus
- n *= (percent_atk_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_atk_bonus ; return 0 ; end
- def percent_atk_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Physical Defense
- #--------------------------------------------------------------------------
- def base_pdef
- # Gets Orginal Value
- n = seph_statbonusbase_bpdef
- # Adds Direct Stat Bonus
- n += direct_pdef_bonus
- # Adds Percent Stat Bonus
- n *= (percent_pdef_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_pdef_bonus ; return 0 ; end
- def percent_pdef_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Magic Defense
- #--------------------------------------------------------------------------
- def base_mdef
- # Gets Orginal Value
- n = seph_statbonusbase_bmdef
- # Adds Direct Stat Bonus
- n += direct_mdef_bonus
- # Adds Percent Stat Bonus
- n *= (percent_mdef_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_mdef_bonus ; return 0 ; end
- def percent_mdef_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Basic Evasion Correction
- #--------------------------------------------------------------------------
- def base_eva
- # Gets Orginal Value
- n = seph_statbonusbase_beva
- # Adds Direct Stat Bonus
- n += direct_eva_bonus
- # Adds Percent Stat Bonus
- n *= (percent_eva_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_eva_bonus ; return 0 ; end
- def percent_eva_bonus ; return 0 ; end
- #--------------------------------------------------------------------------
- # * Get Hit
- #--------------------------------------------------------------------------
- def hit
- # Gets Orginal Value
- n = seph_statbonusbase_hit
- # Adds Direct Stat Bonus
- n += direct_hit_bonus
- # Adds Percent Stat Bonus
- n *= (percent_hit_bonus + 100) / 100.0
- # Returns Stat
- return n
- end
- def direct_hit_bonus ; return 0 ; end
- def percent_hit_bonus ; return 0 ; end
- end
- #==============================================================================
- # ** Systems.String Operators By: Trickster
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # Classes that perform Operations on strings
- #
- # Class List:
- # ------------
- # Increaser_String
- # Range_String
- #==============================================================================
- MACL::Loaded << 'Systems.String Operators'
- #==============================================================================
- # ** Increaser String By: Trickster
- #------------------------------------------------------------------------------
- # This utility class represents stat bonuses in a string
- # Only recognizes the stats maxhp,maxsp,str,dex,agi,int,pdef,mdef,eva,atk
- # entries are separated by commas and increase amounts are shown by the
- # operators stat:xN/N+N-N
- # When Conveterted to a hash, becomes one in this format {'effect' => [+,*]}
- #==============================================================================
- class Increaser_String
- #-------------------------------------------------------------------------
- # * Name : To_Hash
- # Info : Returns A Hash in this format, {'effect' => [+,*]}
- # Author : Trickster
- # Call Info : One Argument, String string string to be converted
- #-------------------------------------------------------------------------
- def self.to_hash(string)
- # Make a Copy of the string
- string = string.dup
- # Create Hash
- hash = {}
- # Run Through all strings splitted by ,
- string.split(',').each do |effect|
- # Get Index
- index = effect.index(':')
- # Get Size
- size = effect.size
- # Get Stat Name
- stat = effect[0, index]
- # Get Modifiers
- modifiers = effect[index+1, (size-index+1)]
- # Get Amounts
- amounts = modifiers.gsub(/\+|\*|-|\//, ' ').split(' ')
- # Get Operations
- operations = modifiers.gsub(/[0-9]|\./, ' ').split(' ')
- # Initialize Amounts
- plus_amount, times_amount = 0, 1
- # Run Through Each Index
- amounts.each_with_index do |amount, index|
- # Get Operation
- operation = operations[index]
- # Branch by operation
- case operation
- when '+'
- plus_amount += amount.to_f
- when '-'
- plus_amount -= amount.to_f
- when '*'
- times_amount *= amount.to_f
- when '/'
- times_amount /= amount.to_f
- end
- end
- # Set Hash At Stat To Plus Amount and Times Amount
- hash[stat] = plus_amount, times_amount
- end
- # Return Hash
- return hash
- end
- end
- #==============================================================================
- # ** Range String By: Trickster
- #------------------------------------------------------------------------------
- # This utility class represents a range of integers and
- # recognizes num-num2 num ^num, entries are separated by commas.
- # Where num-num2 gets all numbers from num1 to num2
- # num gets that number
- # and ^num removes num from the range
- #==============================================================================
- class Range_String
- #-------------------------------------------------------------------------
- # * Name : To_A
- # Info : To Array - An Array of Integers
- # Author : Trickster
- # Call Info : One Argument String string the string to convert
- #-------------------------------------------------------------------------
- def self.to_a(string)
- # Create An Array
- array = []
- # Create Deleted Array
- deleted = []
- # Run through each range
- string.split(',').each do |range|
- # If - is included
- if range.include?('-')
- # Get Index
- index = range.index('-')
- # Get Size
- size = range.size
- # Get First Number
- first = range[0, index].to_i
- # Get Last Number
- last = range[index + 1, size - (index + 1)].to_i
- # Add To Array
- array += (first..last).to_a
- # Elsif ^ Is included
- elsif range.include?('^')
- # Add to Deleted
- deleted << range.to_i
- # Else
- else
- # Add to Array
- array << range.to_i
- end
- end
- # Return Array with Deleted Entries Removed
- return array - deleted
- end
- end
- #==============================================================================
- # ** Systems.Window Sprites By: Trickster
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # This set allows for sprite objects to be tagged onto a window.
- #
- # Method List:
- # ------------
- # Sprite
- # ------
- # tag
- # in_rect?
- #
- # Support Methods:
- # -------------
- # Window_Base
- # -----------
- # initialize
- # dispose
- # update
- # x=
- # y=
- # z=
- # ox=
- # oy=
- # width=
- # height=
- # contents_opacity=
- # back_opacity=
- # opacity=
- # visible=
- #
- # Sprite
- # ------
- # initialize
- #==============================================================================
- MACL::Loaded << 'Systems.Window Sprites'
- class Window_Base
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- if @trick_sprites_windowbase.nil?
- alias_method :trick_sprites_base_x=, :x=
- alias_method :trick_sprites_base_y=, :y=
- alias_method :trick_sprites_base_z=, :z=
- alias_method :trick_sprites_base_ox=, :ox=
- alias_method :trick_sprites_base_oy=, :oy=
- alias_method :trick_sprites_base_width=, :width=
- alias_method :trick_sprites_base_height=, :height=
- alias_method :trick_sprites_base_contents_opacity=, :contents_opacity=
- alias_method :trick_sprites_base_back_opacity=, :back_opacity=
- alias_method :trick_sprites_base_opacity=, :opacity=
- alias_method :trick_sprites_base_visible=, :visible=
- @trick_sprites_windowbase = true
- end
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias_method :trick_sprites_base_initialize, :initialize
- def initialize(x, y, width, height)
- # Setup Sprites Array
- @window_sprites = []
- # The Usual
- trick_sprites_base_initialize(x, y, width, height)
- end
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- alias_method :trick_sprites_base_dispose, :dispose
- def dispose
- # The Usual
- trick_sprites_base_dispose
- # Dispose all Sprites
- @window_sprites.each {|sprite| sprite.dispose}
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- alias_method :trick_sprites_base_update, :update
- def update
- # The Usual
- trick_sprites_base_update
- # Update
- @window_sprites.each {|sprite| sprite.update}
- end
- #--------------------------------------------------------------------------
- # * Set X
- #--------------------------------------------------------------------------
- def x=(x)
- # Run through each window sprite
- @window_sprites.each do |sprite|
- # If Has Method sprite type
- if sprite.respond_to?(:sprite_type)
- # Branch by Type
- case sprite.sprite_type
- when 'content', 'content2', 'cover', 'background', 'background2'
- # Include Scroll Calculation Set X
- sprite.x = sprite.x - self.x + x + ox
- when 'border'
- # Exclude Scroll Calculation Set X
- sprite.x = sprite.x - self.x + x
- end
- else
- # Default is Content Sprite
- sprite.x = sprite.x - self.x + x + ox
- end
- end
- # The Usual
- self.trick_sprites_base_x = x
- end
- #--------------------------------------------------------------------------
- # * Set Y
- #--------------------------------------------------------------------------
- def y=(y)
- # Update All Y's
- @window_sprites.each do |sprite|
- # If Has Method sprite type
- if sprite.respond_to?(:sprite_type)
- # Branch by Type
- case sprite.sprite_type
- when 'content', 'content2', 'cover', 'background', 'background2'
- # Include Scroll Calculation Set Y
- sprite.y = sprite.y - self.y + y + oy
- when 'border'
- # Exclude Scroll Calculation Set Y
- sprite.y = sprite.y - self.y + y
- end
- else
- # Default is Content Sprite
- sprite.y = sprite.y - self.y + y + oy
- end
- end
- # The Usual
- self.trick_sprites_base_y = y
- end
- #--------------------------------------------------------------------------
- # * Set Z
- #--------------------------------------------------------------------------
- def z=(z)
- # Update All Z's
- @window_sprites.each do |sprite|
- # If Has Method sprite type
- if sprite.respond_to?(:sprite_type)
- # Branch By Sprite Type
- case sprite.sprite_type
- when 'content'
- sprite.z = self.z + 1
- when 'content2'
- sprite.z = self.z + 2
- when 'cover', 'border'
- sprite.z = self.z + 3
- when 'background'
- sprite.z = self.z
- when 'background2'
- sprite.z = self.z - 1
- end
- else
- # Default is content
- sprite.z = self.z + 1
- end
- end
- # The Usual
- self.trick_sprites_base_z = z
- end
- #--------------------------------------------------------------------------
- # * Set Origin X
- #--------------------------------------------------------------------------
- def ox=(ox)
- # Get Ox Change
- cx = self.ox - ox
- # Run Through Each Sprite
- @window_sprites.each do |sprite|
- # If Has Method sprite type
- if sprite.respond_to?(:sprite_type)
- # Branch By Sprite Type
- case sprite.sprite_type
- when 'content', 'content2', 'cover', 'background', 'background2'
- # Add to X
- sprite.x += cx
- # Setup Visibility
- sprite.visible = sprite.x.between?(x + 16, x + width - 16) && visible
- end
- else
- # Add to X
- sprite.x += cx
- # Setup Visibility
- sprite.visible = sprite.x.between?(x + 16, x + width - 16) && visible
- end
- end
- # The Usual
- self.trick_sprites_base_ox = ox
- end
- #--------------------------------------------------------------------------
- # * Set Origin Y
- #--------------------------------------------------------------------------
- def oy=(oy)
- # Get Oy Change
- cy = self.oy - oy
- # Run Through Each Sprite
- @window_sprites.each do |sprite|
- # If Has Method sprite type
- if sprite.respond_to?(:sprite_type)
- # Branch By Sprite Type
- case sprite.sprite_type
- when 'content', 'content2', 'cover', 'background', 'background2'
- # Add to Y
- sprite.y += cy
- # Setup Visibility
- sprite.visible = sprite.y.between?(y + 16, y + height - 16) && visible
- end
- else
- # Add to Y
- sprite.y += cy
- # Setup Visibility
- sprite.visible = sprite.y.between?(y + 16, y + height - 16) && visible
- end
- end
- # The Usual
- self.trick_sprites_base_oy = oy
- end
- #--------------------------------------------------------------------------
- # * Set Width
- #--------------------------------------------------------------------------
- def width=(width)
- # Run Through Each Sprite
- @window_sprites.each do |sprite|
- # If Has Method sprite type
- if sprite.respond_to?(:sprite_type)
- # Branch By Sprite Type
- case sprite.sprite_type
- when 'content', 'content2', 'cover', 'background', 'background2'
- # Setup Visibility
- sprite.visible = sprite.x.between?(x + 16, x + width - 16) && visible
- end
- else
- # Setup Visibility
- sprite.visible = sprite.x.between?(x + 16, x + width - 16) && visible
- end
- end
- # The Usual
- self.trick_sprites_base_width = width
- end
- #--------------------------------------------------------------------------
- # * Set Height
- #--------------------------------------------------------------------------
- def height=(height)
- # Run Through Each Sprite
- @window_sprites.each do |sprite|
- # If Has Method sprite type
- if sprite.respond_to?(:sprite_type)
- # Branch By Sprite Type
- case sprite.sprite_type
- when 'content', 'content2', 'cover', 'background', 'background2'
- # Setup Visibility
- sprite.visible = sprite.y.between?(y + 16, y + height - 16) && visible
- end
- else
- # Setup Visibility
- sprite.visible = sprite.y.between?(y + 16, y + height - 16) && visible
- end
- end
- # The Usual
- self.trick_sprites_base_height = height
- end
- #--------------------------------------------------------------------------
- # * Set Contents Opacity
- #--------------------------------------------------------------------------
- def contents_opacity=(opacity)
- # Run Through Each Sprite and Setup Opacity
- @window_sprites.each do |sprite|
- # If Has Method sprite type
- if sprite.respond_to?(:sprite_type)
- # Branch By Sprite Type
- case sprite.sprite_type
- when 'content', 'content2', 'cover'
- # Setup Opacity
- sprite.opacity = opacity
- end
- else
- # Setup Opacity
- sprite.opacity = opacity
- end
- end
- # The Usual
- self.trick_sprites_base_contents_opacity = opacity
- end
- #--------------------------------------------------------------------------
- # * Set Back Opacity
- #--------------------------------------------------------------------------
- def back_opacity=(opacity)
- # Run Through Each Sprite and Setup Opacity
- @window_sprites.each do |sprite|
- # Skip if not Has Method sprite type
- next if not sprite.respond_to?(:sprite_type)
- # Branch By Sprite Type
- case sprite.sprite_type
- when 'background', 'background2'
- # Setup Opacity
- sprite.opacity = opacity
- end
- end
- # The Usual
- self.trick_sprites_base_back_opacity = opacity
- end
- #--------------------------------------------------------------------------
- # * Set Opacity
- #--------------------------------------------------------------------------
- def opacity=(opacity)
- # Run Through Each Sprite and Setup Opacity
- @window_sprites.each do |sprite|
- # Skip if not Has Method sprite type
- next if not sprite.respond_to?(:sprite_type)
- # Branch By Sprite Type
- case sprite.sprite_type
- when 'border', 'tagged'
- # Setup Opacity
- sprite.opacity = opacity
- end
- end
- # The Usual
- self.trick_sprites_base_opacity = opacity
- end
- #--------------------------------------------------------------------------
- # * Set Visibility
- #--------------------------------------------------------------------------
- def visible=(bool)
- # Get Rect
- rect = Rect.new(x + 16, y + 16, width - 32, height - 32)
- # Run Through Each Sprite
- @window_sprites.each do |sprite|
- # If Has Method sprite type
- if sprite.respond_to?(:sprite_type)
- # Branch By Sprite Type
- case sprite.sprite_type
- when 'content', 'content2', 'cover', 'background', 'background2'
- sprite.visible = bool && sprite.in_rect?(rect)
- when 'border', 'tagged'
- sprite.visible = visible
- end
- else
- sprite.visible = bool && sprite.in_rect?(rect)
- end
- end
- # Update Visibility
- self.trick_sprites_base_visible = bool
- end
- end
- class Sprite
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_writer :sprite_type
- #--------------------------------------------------------------------------
- # * Sprite Type
- #--------------------------------------------------------------------------
- def sprite_type
- return @sprite_type.nil? ? 'content' : @sprite_type
- end
- #--------------------------------------------------------------------------
- # * Tag
- #--------------------------------------------------------------------------
- def tag(window)
- # Get Attributes
- x, y, width, height = window.x, window.y, window.width, window.height
- # Setup Rect
- rect = Rect.new(x + 16, y + 16, width - 32, height - 32)
- # Branch by Sprite Type
- case sprite_type
- when 'content'
- # Set Visibility
- self.visible = in_rect?(rect) && window.visible
- # Set Z Between Window
- self.z = window.z + 1
- # Setup Opacity
- self.opacity = window.contents_opacity
- when 'content2'
- # Set Visibility
- self.visible = in_rect?(rect) && window.visible
- # Set Z Between Window
- self.z = window.z + 2
- # Setup Opacity
- self.opacity = window.contents_opacity
- when 'cover'
- # Set Visibility
- self.visible = in_rect?(rect) && window.visible
- # Set Z Between Window
- self.z = window.z + 3
- # Setup Opacity
- self.opacity = window.contents_opacity
- when 'border'
- # Set Visibility
- self.visible = window.visible
- # Set Z Between Window
- self.z = window.z + 3
- # Setup Opacity
- self.opacity = window.opacity
- when 'background'
- # Set Visibility
- self.visible = in_rect?(rect) && window.visible
- # Set Z at Window
- self.z = window.z
- # Setup Opacity
- self.opacity = window.back_opacity
- when 'background2'
- # Set Visibility
- self.visible = in_rect?(rect) && window.visible
- # Set Z at Window
- self.z = window.z - 1
- # Setup Opacity
- self.opacity = window.back_opacity
- when 'tagged'
- # Set Visibility
- self.visible = window.visible
- # Setup Opacity
- self.opacity = window.opacity
- end
- end
- #--------------------------------------------------------------------------
- # * In Rect?
- #--------------------------------------------------------------------------
- def in_rect?(*rect)
- # If 1 Argument Sent
- if rect.size == 1
- # Get Rect
- rect = rect[0]
- # Return in rect state
- return (x.between?(rect.x, rect.x + rect.width) &&
- y.between?(rect.y, rect.y + rect.height))
- else
- # Get variables sent
- x, y, width, height = rect
- # If In Rect
- return self.x.between?(x, x + width) && self.y.between?(y, y + height)
- end
- end
- end
Add Comment
Please, Sign In to add comment