Show posts

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

Messages - ThallionDarkshine

1
RMXP Script Database / Re: [XP] Memory Font Loader
December 20, 2017, 09:54:47 am
So I seem to have found a bug with this on Windows 8.1. After the call to
SendMessage
, the game freezes. Have you tried with just
SendNotifyMessage
? From what I can tell in the docs,
SendMessage
blocks until all windows process the notification, whereas
SendNotifyMessage
returns immediately... I tried removing the
SendMessage
call, and the game appears to run fine. Is there a reason you're making both calls?
2
RMXP Script Database / Re: [XP] Dynamic Gardening
December 19, 2017, 11:21:56 pm
I was talking with Ruffsta to see what he wanted, and implemented it how he told me. He hasn't complained at all about that aspect of its functionality, so I assume it's working correctly.
3
RMXP Script Database / Re: [XP] Dynamic Gardening
December 19, 2017, 04:23:31 am
At the request of Ruffsta, I modified the script to allow the player to choose between planting 1 or 2 seeds when planting seeds. In addition, I fixed a minor bug with the help window displaying the incorrect content.

Single/Double Planting Script
Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Dynamic Gardening
# Authors: ForeverZer0, Twb6543, ThallionDarkshine
# Date: 7.17.2011
# Version: v.3.3
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#                            VERSION HISTORY
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#  v.1.1  (4.15.2010)
#   - Improved coding
#   - No longer uses game variables, events use self-switches instead
#   - Added ability to create different graphics for every plant, without
#     having to use more event pages
#   - Much less tedious setting up multiple events and changing the every
#     condition variable.
#  v.2.0  (10.10.2010)
#   - Total re-write. Code has been vastly improved and is much more efficient.
#   - Event setup has been simplified. Now requires only a single comment, and
#     does not require multiple pages.
#   - Added configurability for the number of stages each item requires.
#   - The timers no longer use Game_System to constantly update, but simply
#     compare themselves with the Graphics.frame_count when the event exists
#     on the current map, which also allows the plants to grow during scenes
#     other than Scene_Map and Scene_Battle.
#   - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has
#     been improved.
#   - Added item icons to the help window display.
# v.3.0  (5.13.2011)
#   - Restructured code completely
#   - Increased compatibility and performance
#   - Fixed bug with final graphic not behaving correctly
# v.3.1  (7.14.2011) by Twb6543
#   - Changed Script to allow for Single Seeds
#   - Added the ability to set default values
# v.3.2 (7.17.2011) by Twb6543
#   - Changed Script to fix bugs in the last release
#   - Fixed Bugs from version 3.0 (May not be completely fixed but I(Twb6543)
#     believe that it is mostly fixed)
# v.3.3 (12.19.2017) by ThallionDarkshine
#   - Modified script to allow players to choose between single and double seed
#     when planting seeds.
#   - Fixed a bug where help window would not update correctly.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   This system allows the player to plant seeds, which will eventually grow
#   into plants that can be harvested for items. The system is very similar in
#   nature to that found in Legend of Mana. Seed's can be combined in different
#   ways, which will effect the total growth duration, the number of stages the
#   plant passes through, the graphics used, and of course the final result.
#
# Features:
#
#  - Totally configurable growth rates, results, and graphics for every plant.
#  - Can use arrays of items for each result, so the final item is not
#    neccessarily the same every time.
#  - Each plant timer is independent, and its progress is saved with the game.
#  - Easy setup. Need only a single comment in one of the event's pages.
#
# Instructions:
#   
#  - Place script below Debug and above Main
#  - Configure the options below (instructions are with each setting)
#  - Create an event, setting the graphic to whatever you want. This will be the
#    graphics used when nothing is growing on the plant.
#  - At the very top event's page, place a comment that reads "Garden Event",
#    omitting the quotation marks.
#  - As long as the page's conditions are met, this event can be clicked on to
#    initiate the Garden scene, and can grow plants.
#  - Note that plants can be harvested early, but they will yield nothing until
#    they are ripe.
#
# Note:
#
#  - Any method modified or added in 3.1 or 3.2 has an headed attached to it.
#  - The header will be "Double and Single Seed" or
#    "Double and Single Seed Method" for modified Methods.
#  - The header will be "Double and Single Seed New Method" for new Methods.
#  - Headers may also have extra information.
#  - The Code for Scene_Garden and Window_Seed can definitely be optimised
#    but as I(Twb6543) finally squashed the bug preventing release of v 3.2
#    I do not want to change anything with out a bit of forethought.
#
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
#===============================================================================
# ** Garden
#===============================================================================

module Garden
 
  SEED_IDS = [1, 2, 3, 4, 5, 6, 7, 8]
  # IDs of the items in the database that are seeds. Add them into the array in
  # the order of value/rarity in your game this currently includes any single
  # seeds
 
  HARVEST_SE = '056-Right02'
  # This is the SE that will be played when the player harvests the plant.
 
  SEED_DISPLAY = true
  # If true, all seeds will be displayed in the seed window, including those
  # that the player does not have, though they will be disabled. If false, only
  # seeds that that the player currently has will be displayed.
 
  # Define the growth rates here. (the average of both seeds will be used)
  def self.growth_rate(seed)
    return case seed
    # when SEED_ID then SECONDS
    when 1 then 10
    when 2 then 12
    when 3 then 15
    when 4 then 20
    when 5 then 23
    when 6 then 25
    when 7 then 30
    when 8 then 35
    else
      10 # Default Value to return if no speed is specified
    end
  end
 
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to
# grow, only how many times the graphic changes.
#
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
  def self.number_stages(result)
    case result
    when 8..16
      return 4
    when 17..24
      return 5
    else
      return 3
    end
  end
 
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.

# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have
# the SEED_IDS array in order of value/rarity. You can find the total number of
# cases you will need by subtracting 1 from the total number of different seeds
# in SEED_IDS, and multiplying that number by 2.
#
#   EX. Player uses one each of the first and last seed in the SEED_IDS array,
#       and there are 8 total seeds in the array...
#
#       FIRST_SEED = 2
#       LAST_SEED = 5         2 + 5 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------

  #-------------------------------#
  #   - Double and Single Seed -  #
  #-------------------------------#
  #  Now with Else/Defualt Clause #
  #-------------------------------#
  def self.produce(seed)
    return case seed
    when 0 then [9, 10]      # Only if both seed are the lowest seeds
    when 1 then [10, 11]
    when 2 then [12, 13]
    when 3 then [13, 14]
    when 4 then [14, 15]
    when 5 then [15, 16]
    when 6 then [16, 17]      # Every combination in between
    when 7 then [17, 18]
    when 8 then [18, 19]
    when 9 then [19, 20]
    when 10 then [20, 21]
    when 11 then [21, 22]
    when 12 then [22, 23]
    when 13 then [23, 24]
    when 14 then [24]         # Only if both seeds are the highest seeds
    else
      [9] # Default Value to return, Brackets are important,
          # May contain more than one value e.g [9,10] or [9,10,11,12,13]
    end
  end
 
  #------------------------------------------#
  #   - Double and Single Seed New Method -  #
  #------------------------------------------#
  #   Table set up much in the same way as   #
  #  .produce, however items come from seed  #
  #        _ID_  not position in array       #
  #------------------------------------------#
  #  Also the ids are taken from SINGLE_IDS  #
  #                   Array                  #
  #------------------------------------------#
  def self.produce_single(seed)
    return case seed
    when 25 then [9, 10]      # Only if seed is item with Id 25
    else
      [9] # Default Value to return, Brackets are important,
          # May contain more than one value e.g [9,10] or [9,10,11,12,13]
    end
  end
 
#-------------------------------------------------------------------------------
#  Define graphics for the final results, and each stage. Follow the below
#  template to set it up.
#
#   when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
#   ITEM_ID = The ID number of the item in your database
#   STAGE = The stage during which to display the graphic
#
#   FILENAME = The name of the character file the needed graphic is on
#   X = The x-coordinate of the correct picture on the charset (1 - 4)
#   Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
#           ← X →             Ex.   If the needed graphic was in the bottom
#         1  2  3  4                left corner:   X = 1    Y = 4
#       ┌──┬──┬──┬──┐                   
#     1 │  │  │  │  │
#       ├──┼──┼──┼──┤
#  ↑  2 │  │  │  │  │
#  Y    ├──┼──┼──┼──┤
#  ↓  3 │  │  │  │  │
#       ├──┼──┼──┼──┤
#     4 │  │  │  │  │
#       └──┴──┴──┴──┘
#-------------------------------------------------------------------------------

  def self.stage_graphics(stage)
    return case stage
    when 0 then ['Plants1', 1, 1]
    when 1 then ['Plants1', 2, 3]
    when 2 then ['Plants1', 2, 1]
    when 3 then ['Plants1', 4, 2]
    when 4 then ['Plants1', 2, 4]
    end
  end

  def self.final_graphic(item)
    return case item   
    when 9 then  ['Garden Plants', 1, 1]
    when 10 then ['Garden Plants', 2, 4]
    when 11 then ['Garden Plants', 3, 4]
    when 12 then ['Garden Plants', 4, 4]
    when 13 then ['Garden Plants', 1, 4]
    when 14 then ['Garden Plants', 2, 2]
    when 15 then ['Garden Plants', 3, 2]   
    when 16 then ['Garden Plants', 4, 2]
    when 17 then ['Garden Plants', 1, 2]
    when 18 then ['Garden Plants', 2, 3]
    when 19 then ['Garden Plants', 3, 3]
    when 20 then ['Garden Plants', 4, 3]
    when 21 then ['Garden Plants', 1, 3]
    when 22 then ['Garden Plants', 2, 1]
    when 23 then ['Garden Plants', 3, 1]
    when 24 then ['Garden Plants', 4, 1]
    end
  end
 
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  #              ! Warning !             #
  #                                      #
  # This rearranges the order of the def #
  #  variables to allow for Single Seed  #
  #--------------------------------------#
  def self.plant_seeds(event_id, seed1, seed2=nil)
    # Create a new instance of a Garden::Plant
    if seed2 != nil
      # Double Seed Method
      plant = self::Plant.new(event_id, seed1, seed2)
      if $game_system.garden[$game_map.map_id] == nil
        $game_system.garden[$game_map.map_id] = [plant]
      else
        $game_system.garden[$game_map.map_id].push(plant)
      end
    else
      #Single Seed Method
      plant = self::Plant.new(event_id, seed1)
      if $game_system.garden[$game_map.map_id] == nil
        $game_system.garden[$game_map.map_id] = [plant]
      else
        $game_system.garden[$game_map.map_id].push(plant)
      end
    end
     
  end
 
  def self.harvest(id)
    # Find the appropriate plant.
    plant = $game_system.garden[$game_map.map_id].find {|plant| plant.id == id }
    return nil if plant == nil
    # Return the result, and delete plant data from array.
    result = plant.produce
    plant.restore_event
    $game_system.garden[$game_map.map_id] -= [plant]
    return result
  end

#===============================================================================
# ** Garden::Plant
#===============================================================================

  class Plant
   
    attr_reader :id, :ripe
   
    #--------------------------------------#
    #   - Double and Single Seed Method -  #
    #--------------------------------------#
    def initialize(id, seed1, seed2=nil)
      if seed2 != nil
        # Initialize needed instance variables.
        @id, @seed1, @seed2, @single = id, seed1, seed2, false
      else
        # Initialize needed instance variables.
        @id, @seed1, @single = id, seed1, true
      end
      @ripe, @stage = false, -1
      # Run setup method, using data in Garden config for this plant's seeds
       setup
    end
   
    #--------------------------------------#
    #   - Double and Single Seed Method -  #
    #--------------------------------------#
    #   Similar to old method but adds a   #
    #       check for the single flag      #
    #--------------------------------------#
    def setup
      # Store original graphic, direction, and pattern in variable.
      event = $game_map.events[@id]
      @original_event = [event.character_name, event.direction, event.pattern]
      # Calculate the total duration of the seed combination.
      if @single == true # If single then only the duration of that seed
        @duration = Garden.growth_rate(@seed1)
      else # IF double then duration of both seeds
        @duration = (Garden.growth_rate(@seed1) + Garden.growth_rate(@seed2))
      end
      # Find the produce that this combination will grow into
      if @single == true
        @produce = Garden.produce_single(@seed1)
        # Get a random produce from case Seed1 id
        @produce = @produce[rand(@produce.size)]
      else
        comb = Garden::SEED_IDS.index(@seed1) + Garden::SEED_IDS.index(@seed2)
        @produce = Garden.produce(comb)
        @produce = @produce[rand(@produce.size)]
      end
      # Get the number of stages this plant will use, then setup counts for it
      number, count = Garden.number_stages(@produce), 0
      dur = (@duration / number.to_f).to_i
      @stages = (0...number).to_a
      @stages.collect! {|i| $game_system.garden_counter + (i * dur) }
      # Refresh the plant to apply changes
      refresh
    end
   
    def refresh
      unless @ripe
        # Initialize local variable that will determine if graphic needs redrawn.
        previous = @stage
        count = @stages.find_all {|rate| $game_system.garden_counter <= rate }
        @stage = (@stages.size - count.size)
        @ripe = (@stage >= @stages.size - 1)
        # Redraw bitmap if needed.
        change_graphic(@ripe) if previous != @stage
      end
    end
   
    def change_graphic(final)
      # Set local variable to this plant's event
      event = $game_map.events[@id]
      data = final ? Garden.final_graphic(@produce) :
        Garden.stage_graphics(@stage)
      # Apply graphical change by simply altering event's stance and source
      event.character_name = data[0] # If you get an error on this line it means
      # that the final or stage graphics have not been set up properly or that
      # there is missing data in the config for a certain (pair of) item(s).
      event.direction = (2 * data[2])
      event.pattern = (data[1] - 1)
      event.refresh
    end
   
    def restore_event
      # Restore event to original state before planting.
      event = $game_map.events[@id]
      event.character_name = @original_event[0]
      event.direction = @original_event[1]
      event.pattern = @original_event[2]
    end
   
    def produce
      # Return nil if not yet ripe, else return an item ID.
      return (@ripe ? @produce : nil)
    end
  end
end

#===============================================================================
# ** Game_System
#===============================================================================

class Game_System
 
  attr_accessor :garden, :garden_counter
 
  alias zer0_garden_init initialize
  def initialize
    # Initialize variables used for the garden system.
    @garden_counter = 0
    @garden = {}
    zer0_garden_init
  end
 
  alias zer0_garden_upd update
  def update
    # Increase garden counter and check if update is needed every second.
    if (Graphics.frame_count % 40) == 0
      @garden_counter += 1
      # Check if current map has any plants on it. If so, refresh them.
      if @garden[$game_map.map_id] != nil && !@garden[$game_map.map_id].empty?
        @garden[$game_map.map_id].each {|plant| plant.refresh }
      end
    end
    zer0_garden_upd
  end
end

#===============================================================================
# ** Game_Event
#===============================================================================

class Game_Event
 
  attr_accessor :character_name, :direction, :pattern
 
  alias zer0_garden_event_refresh refresh
  def refresh
    # Normal refresh method.
    zer0_garden_event_refresh
    # Set flag for this event being a garden event.
    @garden_event = (@page != nil && @page.list[0].code == 108 &&
      @page.list[0].parameters[0] == 'Garden Event')
  end
 
  alias zer0_garden_upd update
  def update
    # Skip update method foe this event if it is a plant.
    @garden_event ? return : zer0_garden_upd
  end
 
  alias zer0_garden_event_start start
  def start
    # Redefine the 'start' method if Garden Event flag is present.
    if @garden_event
      plants, harvest = $game_system.garden[$game_map.map_id], false
      # Check if plant exists, and if so check if it is ripe.
      pick = plants != nil ? (plants.find {|obj| obj.id == @id }) != nil : false
      $scene = Scene_Garden.new(@id, pick)
    else
      zer0_garden_event_start
    end
  end
end
 
#===============================================================================
# ** Game_Map
#===============================================================================

class Game_Map
 
  alias zer0_garden_setup setup
  def setup(map_id)
    zer0_garden_setup(map_id)
    # Refresh each plant when map is set up
    if $game_system.garden[@map_id] != nil
      $game_system.garden[@map_id].each {|obj| obj.change_graphic(obj.ripe) }
    end
  end
end

#===============================================================================
# * Window_Seed
#===============================================================================

class Window_Seed < Window_Selectable
 
  def initialize
    super(160, 304, 320, 160)
    self.index = 0
    refresh
  end
 
  def refresh
    # Clear the bitmap.
    self.contents = self.contents.dispose if self.contents != nil
    # Determine what seeds to display.
    @seeds = Garden::SEED_IDS.collect {|id| $data_items[id] }
    unless Garden::SEED_DISPLAY
      @seeds.reject! {|seed| $game_party.item_number(seed.id) < 1 }
    end
    @item_max = @seeds.size
    # Draw the items on the bitmap.
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, @item_max * 32)
      @seeds.each_index {|i|
        item = @seeds[i]
        number = $game_party.item_number(item.id)
        self.contents.font.color = number > 0 ? normal_color : disabled_color
        opacity = number > 0 ? 255 : 128
        # Find icon bitmap and set it to window, and draw the text.
        bitmap = RPG::Cache.icon(item.icon_name)
        self.contents.blt(4, i*32+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(32, i*32, 288, 32, item.name)
        self.contents.draw_text(-32, i*32, 288, 32, ':', 2)
        self.contents.draw_text(-4, i*32, 288, 32, number.to_s, 2)
      }
    end
  end
 
  def seed
    # Returns currently highlighted seed item.
    return @seeds[self.index]
  end
end

#===============================================================================
# * Scene_Garden
#===============================================================================

class Scene_Garden
 
  def initialize(id, harvest)
    @event_id, @harvest = id, harvest
    # Play SE to give impression that scene never changed.
    $game_system.se_play($data_system.decision_se)
    $game_player.straighten
    garden = $game_system.garden[$game_map.map_id]
    if garden != nil
      @plant = garden.find {|plant| plant.id == id }
    end
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def main
    # Create map sprite and required windows.
    @map, @help_window = Spriteset_Map.new, Window_Help.new
    # Create Confirmation window.
    @confirm_window = Window_Command.new(128, ['Yes', 'No'])
    @confirm_window.x, @confirm_window.y = 496, 336
    # Initialize sprites array. Used to handle all the sprites together.
    @sprites = [@map, @help_window, @confirm_window]
    # Create seed window if plant is not being harvested.
    unless @harvest
      @seed_window = Window_Seed.new
      @sprites.push(@seed_window)
      @seed_window.active = @seed_window.visible = false
      # Create Seed Count window
      @seed_count_window = Window_Command.new(192, ['Yes, plant 1 seed', 'Yes, plant 2 seeds', "No"])
      @seed_count_window.x, @seed_count_window.y = 640 - 192 - 16, 480 - 3 * 24 - 96
      @sprites.push(@seed_count_window)
      @confirm_window.visible = @confirm_window.active = false
      @help_window.set_text('Plant seeds here?')
    else
      @data = $game_system.garden[$game_map.map_id][@event_id]
      if @plant != nil && @plant.ripe
        text = 'This plant is ripe. Would you like to harvest it?'
      else
        text = 'Nothing is growing yet on this plant. Harvest it anyway?'
      end
      @help_window.set_text(text)
    end
    # Transition instantly then start main loop.
    Graphics.transition(0)
    loop { Graphics.update; Input.update; update; break if $scene != self }
    # Dispose of all the sprites.
    @sprites.each {|sprite| sprite.dispose }
    # Have map refresh to update any changes made.
    $game_map.need_refresh = true
  end
 
  def update
    @sprites.each {|sprite| sprite.update }
    # Branch update method depending on what window is active.
    if @confirm_window.active
      update_confirm
    elsif @seed_count_window != nil && @seed_count_window.active
      update_seed_count_select
    elsif @seed_window != nil && @seed_window.active
      update_seed_select
    end
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def update_confirm
    if Input.trigger?(Input::B)
      # Branch by what action is being canceled.
      if @harvest
        back_to_map
      else
        cancel_seed_selection
      end
    elsif Input.trigger?(Input::C)
      # Branch by what action is being confirmed.
      if @harvest
        if @confirm_window.index == 0
          item_id = Garden.harvest(@event_id)
          if item_id != nil
            @confirm_window.active = @confirm_window.visible = false
            # Gain item, play the harvest SE, then return to the map.
            $game_party.gain_item(item_id, 1)
            $game_system.se_play(RPG::AudioFile.new(Garden::HARVEST_SE, 80, 100))
            show_results($data_items[item_id])
            $scene = Scene_Map.new
          else
            back_to_map
          end
        else
          back_to_map
        end
      else
        # If asking if player would like to plant seeds at this location.
        if @seed1 == nil
          back_to_map
          return
        else # If confirming seed selection.
          if @confirm_window.index == 0
            # Plant seeds and return to map.
            @single = @seed_count_window.index == 0
            # This is how Twb6543 reloaded the single command (in case of index
            # movement)
            if @single == true && @seed2 == nil
              # If Single only
              Garden.plant_seeds(@event_id, @seed1.id)
            else
              # If Double or Includes Double Seed
              Garden.plant_seeds(@event_id, @seed1.id, @seed2.id)
            end
            $scene = Scene_Map.new
          else # If canceling seed selection
            cancel_seed_selection
            return
          end
        end
        $game_system.se_play($data_system.decision_se)
      end
    end
  end
 
  def update_seed_count_select
    if Input.trigger?(Input::B)
      back_to_map
    elsif Input.trigger?(Input::C)
      case @seed_count_window.index
      when 0
        @seed_window.active = @seed_window.visible = true
        @seed_count_window.active = @seed_count_window.visible = false
        @help_window.set_text('Which seed would you like to plant?')
      when 1
        @seed_window.active = @seed_window.visible = true
        @seed_count_window.active = @seed_count_window.visible = false
        @help_window.set_text('Which seeds would you like to plant?')
      when 2
        back_to_map
        return
      end
      $game_system.se_play($data_system.decision_se)
    end
  end
 
  def show_results(result)
    @help_window.contents.clear
    # Display the message in the help window.
    @help_window.draw_item_name(result, 0, 0)
    cw = @help_window.contents.text_size(result.name).width + 32
    @help_window.contents.draw_text(cw, 0, 608, 32, ' received!')
    # Call Input.update to the clear key press.
    Input.update
    # Loop until it is pressed again.
    until Input.trigger?(Input::C)
      Graphics.update; Input.update; update
    end
  end
 
  #------------------------------------------#
  #   - Double and Single Seed New Method -  #
  #------------------------------------------#
  def cancel_seed_selection
    # Play cancel SE, reset seeds, and activate/deactivate windows.
    $game_system.se_play($data_system.cancel_se)
    $game_party.gain_item(@seed1.id, 1) unless @seed1.nil? # Added to re add the seeds
    $game_party.gain_item(@seed2.id, 1) unless @seed2.nil? # Added to re add the seeds
    @seed_window.active = @seed_window.visible = true
    @seed_window.refresh
    @confirm_window.active = @confirm_window.visible = false
    @help_window.set_text('Which seeds would you like to plant?')
    @seed1 = @seed2 = nil
  end
 
  def back_to_map
    # Play cancel SE and return to map.
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Map.new
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def update_seed_select
    if Input.trigger?(Input::B)
      # If first seed is selected, go back to re-select, else return to map.
      if @seed1 != nil
        cancel_seed_selection
      else
        back_to_map
      end
    elsif Input.trigger?(Input::C)
      # Play Cancle SE if displayed and party has none.
      if $game_party.item_number(@seed_window.seed.id) < 1
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @single = @seed_count_window.index == 0
      # Can use @idsingle = @seed_window.seed.id
      if @single == true && @seed1 == nil
        # Set first seed then continue
        @seed1 = @seed_window.seed
        $game_party.lose_item(@seed1.id, 1)
        @seed_window.active = false
        @confirm_window.active = @confirm_window.visible = true
      elsif @single == true && @seed1 != nil
        # Set second seed then continue
        @seed2, @seed_window.active = @seed_window.seed, false
        $game_party.lose_item(@seed2.id, 1)
        @confirm_window.active = @confirm_window.visible = true
      else # 2 seeds
        # Set first seed if not defined, else set the second seed and continue.
        if @seed1 == nil
          @seed1 = @seed_window.seed
          $game_party.lose_item(@seed1.id, 1)
        else
          @seed2, @seed_window.active = @seed_window.seed, false
          $game_party.lose_item(@seed2.id, 1)
          @confirm_window.active = @confirm_window.visible = true
        end
      end
      # Refresh seed window to show changes in inventory.
      set_help
      @seed_window.refresh
    end
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def set_help
    # Clear help window.
    @help_window.contents.clear
    # Draw items
    @single = @seed_count_window.index == 0
    if @single == true && @seed2 == nil
      text = 'Plant this seed?'
    else
      text = @seed2 != nil ? 'Plant these two seeds?' : 'Select second seed...'
    end
    @help_window.set_text(text)
    @help_window.draw_item_name(@seed1, 224, 0)
    if @seed2 != nil
      cw = @help_window.contents.text_size(@seed1.name).width + 320
      @help_window.draw_item_name(@seed2, cw, 0)
    end
  end
end


Original script w/bugfix
Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Dynamic Gardening
# Author: ForeverZer0, ThallionDarkshine
# Date: 5.13.2011
# Version: v.3.01
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#                            VERSION HISTORY
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#  v.1.1  (4.15.2010)
#   - Improved coding
#   - No longer uses game variables, events use self-switches instead
#   - Added ability to create different graphics for every plant, without
#     having to use more event pages
#   - Much less tedious setting up multiple events and changing the every
#     condition variable.
#  v.2.0  (10.10.2010)
#   - Total re-write. Code has been vastly improved and is much more efficient.
#   - Event setup has been simplified. Now requires only a single comment, and
#     does not require multiple pages.
#   - Added configurability for the number of stages each item requires.
#   - The timers no longer use Game_System to constantly update, but simply
#     compare themselves with the Graphics.frame_count when the event exists
#     on the current map, which also allows the plants to grow during scenes
#     other than Scene_Map and Scene_Battle.
#   - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has
#     been improved.
#   - Added item icons to the help window display.
# v.3.0  (5.13.2011)
#   - Restructured code completely
#   - Increased compatibility and performance
#   - Fixed bug with final graphic not behaving correctly
# v.3.01 (12.19.2017) by ThallionDarkshine
#   - Fixed bug with help window not updating correctly.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   This system allows the player to plant seeds, which will eventually grow
#   into plants that can be harvested for items. The system is very similar in
#   nature to that found in Legend of Mana. Seed's can be combined in different
#   ways, which will effect the total growth duration, the number of stages the
#   plant passes through, the graphics used, and of course the final result.
#
# Features:
#
#  - Totally configurable growth rates, results, and graphics for every plant.
#  - Can use arrays of items for each result, so the final item is not
#    neccessarily the same every time.
#  - Each plant timer is independent, and its progress is saved with the game.
#  - Easy setup. Need only a single comment in one of the event's pages.
#
# Instructions:
#   
#  - Place script below Debug and above Main
#  - Configure the options below (instructions are with each setting)
#  - Create an event, setting the graphic to whatever you want. This will be the
#    graphics used when nothing is growing on the plant.
#  - At the very top event's page, place a comment that reads "Garden Event",
#    omitting the quotation marks.
#  - As long as the page's conditions are met, this event can be clicked on to
#    initiate the Garden scene, and can grow plants.
#  - Note that plants can be harvested early, but they will yield nothing until
#    they are ripe.
#
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
#===============================================================================
# ** Garden
#===============================================================================

module Garden
 
  SEED_IDS = [1, 2, 3, 4, 5, 6, 7, 8]
  # IDs of the items in the database that are seeds. Add them into the array in
  # the order of value/rarity in your game
 
  HARVEST_SE = '056-Right02'
  # This is the SE that will be played when the player harvests the plant.
 
  SEED_DISPLAY = true
  # If true, all seeds will be displayed in the seed window, including those
  # that the player does not have, though they will be disabled. If false, only
  # seeds that that the player currently has will be displayed.
 
  # Define the growth rates here. (the average of both seeds will be used)
  def self.growth_rate(seed)
    return case seed
    # when SEED_ID then SECONDS
    when 1 then 10
    when 2 then 12
    when 3 then 15
    when 4 then 20
    when 5 then 23
    when 6 then 25
    when 7 then 30
    when 8 then 35
    end
  end
 
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to
# grow, only how many times the graphic changes.
#
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
  def self.number_stages(result)
    case result
    when 8..16
      return 4
    when 17..24
      return 5
    else
      return 3
    end
  end
 
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.

# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have
# the SEED_IDS array in order of value/rarity. You can find the total number of
# cases you will need by subtracting 1 from the total number of different seeds
# in SEED_IDS, and multiplying that number by 2.
#
#   EX. Player uses one each of the first and last seed in the SEED_IDS array,
#       and there are 8 total seeds in the array...
#
#       FIRST_SEED = 2
#       LAST_SEED = 5         2 + 5 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------

  def self.produce(seed)
    return case seed
    when 0 then [9, 10]      # Only if both seed are the lowest seeds
    when 1 then [10, 11]
    when 2 then [12, 13]
    when 3 then [13, 14]
    when 4 then [14, 15]
    when 5 then [15, 16]
    when 6 then [16, 17]      # Every combination in between
    when 7 then [17, 18]
    when 8 then [18, 19]
    when 9 then [19, 20]
    when 10 then [20, 21]
    when 11 then [21, 22]
    when 12 then [22, 23]
    when 13 then [23, 24]
    when 14 then [24]         # Only if both seeds are the highest seeds
    end
  end
 
#-------------------------------------------------------------------------------
#  Define graphics for the final results, and each stage. Follow the below
#  template to set it up.
#
#   when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
#   ITEM_ID = The ID number of the item in your database
#   STAGE = The stage during which to display the graphic
#
#   FILENAME = The name of the character file the needed graphic is on
#   X = The x-coordinate of the correct picture on the charset (1 - 4)
#   Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
#           ? X ?             Ex.   If the needed graphic was in the bottom
#         1  2  3  4                left corner:   X = 1    Y = 4
#       +-----------+                   
#     1 ¦  ¦  ¦  ¦  ¦
#       +--+--+--+--¦
#  ?  2 ¦  ¦  ¦  ¦  ¦
#  Y    +--+--+--+--¦
#  ?  3 ¦  ¦  ¦  ¦  ¦
#       +--+--+--+--¦
#     4 ¦  ¦  ¦  ¦  ¦
#       +-----------+
#-------------------------------------------------------------------------------

  def self.stage_graphics(stage)
    return case stage
    when 0 then ['Plants1', 1, 1]
    when 1 then ['Plants1', 2, 3]
    when 2 then ['Plants1', 2, 1]
    when 3 then ['Plants1', 4, 2]
    when 4 then ['Plants1', 2, 4]
    end
  end

  def self.final_graphic(item)
    return case item   
    when 9 then  ['Garden Plants', 1, 1]
    when 10 then ['Garden Plants', 2, 4]
    when 11 then ['Garden Plants', 3, 4]
    when 12 then ['Garden Plants', 4, 4]
    when 13 then ['Garden Plants', 1, 4]
    when 14 then ['Garden Plants', 2, 2]
    when 15 then ['Garden Plants', 3, 2]   
    when 16 then ['Garden Plants', 4, 2]
    when 17 then ['Garden Plants', 1, 2]
    when 18 then ['Garden Plants', 2, 3]
    when 19 then ['Garden Plants', 3, 3]
    when 20 then ['Garden Plants', 4, 3]
    when 21 then ['Garden Plants', 1, 3]
    when 22 then ['Garden Plants', 2, 1]
    when 23 then ['Garden Plants', 3, 1]
    when 24 then ['Garden Plants', 4, 1]
    end
  end
 
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  def self.plant_seeds(seed1, seed2, event_id)
    # Create a new instance of a Garden::Plant
    plant = self::Plant.new(event_id, seed1, seed2)
    if $game_system.garden[$game_map.map_id] == nil
      $game_system.garden[$game_map.map_id] = [plant]
    else
      $game_system.garden[$game_map.map_id].push(plant)
    end
  end
 
  def self.harvest(id)
    # Find the appropriate plant.
    plant = $game_system.garden[$game_map.map_id].find {|plant| plant.id == id }
    return nil if plant == nil
    # Return the result, and delete plant data from array.
    result = plant.produce
    plant.restore_event
    $game_system.garden[$game_map.map_id] -= [plant]
    return result
  end

#===============================================================================
# ** Garden::Plant
#===============================================================================

  class Plant
   
    attr_reader :id, :ripe
   
    def initialize(id, seed1, seed2)
      # Initialize needed instance variables.
      @id, @seed1, @seed2 = id, seed1, seed2
      @ripe, @stage = false, -1
      # Run setup method, using data in Garden config for this plant's seeds
      setup
    end
   
    def setup
      # Store original graphic, direction, and pattern in variable.
      event = $game_map.events[@id]
      @original_event = [event.character_name, event.direction, event.pattern]
      # Calculate the total duration of the seed combination.
      @duration = (Garden.growth_rate(@seed1) + Garden.growth_rate(@seed2))
      # Find the produce that this combination will grow into
      comb = Garden::SEED_IDS.index(@seed1) + Garden::SEED_IDS.index(@seed2)
      @produce = Garden.produce(comb)
      @produce = @produce[rand(@produce.size)]
      # Get the number of stages this plant will use, then setup counts for it
      number, count = Garden.number_stages(@produce), 0
      dur = (@duration / number.to_f).to_i
      @stages = (0...number).to_a
      @stages.collect! {|i| $game_system.garden_counter + (i * dur) }
      # Refresh the plant to apply changes
      refresh
    end
   
    def refresh
      unless @ripe
        # Initialize local variable that will determine if graphic needs redrawn.
        previous = @stage
        count = @stages.find_all {|rate| $game_system.garden_counter <= rate }
        @stage = (@stages.size - count.size)
        @ripe = (@stage >= @stages.size - 1)
        # Redraw bitmap if needed.
        change_graphic(@ripe) if previous != @stage
      end
    end
   
    def change_graphic(final)
      # Set local variable to this plant's event
      event = $game_map.events[@id]
      data = final ? Garden.final_graphic(@produce) :
        Garden.stage_graphics(@stage)
      # Apply graphical change by simply altering event's stance and source
      event.character_name = data[0]
      event.direction = (2 * data[2])
      event.pattern = (data[1] - 1)
      event.refresh
    end
   
    def restore_event
      # Restore event to original state before planting.
      event = $game_map.events[@id]
      event.character_name = @original_event[0]
      event.direction = @original_event[1]
      event.pattern = @original_event[2]
    end
   
    def produce
      # Return nil if not yet ripe, else return an item ID.
      return (@ripe ? @produce : nil)
    end
  end
end

#===============================================================================
# ** Game_System
#===============================================================================

class Game_System
 
  attr_accessor :garden, :garden_counter
 
  alias zer0_garden_init initialize
  def initialize
    # Initialize variables used for the garden system.
    @garden_counter = 0
    @garden = {}
    zer0_garden_init
  end
 
  alias zer0_garden_upd update
  def update
    # Increase garden counter and check if update is needed every second.
    if (Graphics.frame_count % 40) == 0
      @garden_counter += 1
      # Check if current map has any plants on it. If so, refresh them.
      if @garden[$game_map.map_id] != nil && !@garden[$game_map.map_id].empty?
        @garden[$game_map.map_id].each {|plant| plant.refresh }
      end
    end
    zer0_garden_upd
  end
end

#===============================================================================
# ** Game_Event
#===============================================================================

class Game_Event
 
  attr_accessor :character_name, :direction, :pattern
 
  alias zer0_garden_event_refresh refresh
  def refresh
    # Normal refresh method.
    zer0_garden_event_refresh
    # Set flag for this event being a garden event.
    @garden_event = (@page != nil && @page.list[0].code == 108 &&
      @page.list[0].parameters[0] == 'Garden Event')
  end
 
  alias zer0_garden_upd update
  def update
    # Skip update method foe this event if it is a plant.
    @garden_event ? return : zer0_garden_upd
  end
 
  alias zer0_garden_event_start start
  def start
    # Redefine the 'start' method if Garden Event flag is present.
    if @garden_event
      plants, harvest = $game_system.garden[$game_map.map_id], false
      # Check if plant exists, and if so check if it is ripe.
      pick = plants != nil ? (plants.find {|obj| obj.id == @id }) != nil : false
      $scene = Scene_Garden.new(@id, pick)
    else
      zer0_garden_event_start
    end
  end
end
 
#===============================================================================
# ** Game_Map
#===============================================================================

class Game_Map
 
  alias zer0_garden_setup setup
  def setup(map_id)
    zer0_garden_setup(map_id)
    # Refresh each plant when map is set up
    if $game_system.garden[@map_id] != nil
      $game_system.garden[@map_id].each {|obj| obj.change_graphic(obj.ripe) }
    end
  end
end

#===============================================================================
# * Window_Seed
#===============================================================================

class Window_Seed < Window_Selectable
 
  def initialize
    super(160, 304, 320, 160)
    self.index = 0
    refresh
  end
 
  def refresh
    # Clear the bitmap.
    self.contents = self.contents.dispose if self.contents != nil
    # Determine what seeds to display.
    @seeds = Garden::SEED_IDS.collect {|id| $data_items[id] }
    unless Garden::SEED_DISPLAY
      @seeds.reject! {|seed| $game_party.item_number(seed.id) < 1 }
    end
    @item_max = @seeds.size
    # Draw the items on the bitmap.
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, @item_max * 32)
      @seeds.each_index {|i|
        item = @seeds[i]
        number = $game_party.item_number(item.id)
        self.contents.font.color = number > 0 ? normal_color : disabled_color
        opacity = number > 0 ? 255 : 128
        # Find icon bitmap and set it to window, and draw the text.
        bitmap = RPG::Cache.icon(item.icon_name)
        self.contents.blt(4, i*32+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(32, i*32, 288, 32, item.name)
        self.contents.draw_text(-32, i*32, 288, 32, ':', 2)
        self.contents.draw_text(-4, i*32, 288, 32, number.to_s, 2)
      }
    end
  end
 
  def seed
    # Returns currently highlighted seed item.
    return @seeds[self.index]
  end
end

#===============================================================================
# * Scene_Garden
#===============================================================================

class Scene_Garden
 
  def initialize(id, harvest)
    @event_id, @harvest = id, harvest
    # Play SE to give impression that scene never changed.
    $game_system.se_play($data_system.decision_se)
    $game_player.straighten
    garden = $game_system.garden[$game_map.map_id]
    if garden != nil
      @plant = garden.find {|plant| plant.id == id }
    end
  end
 
  def main
    # Create map sprite and required windows.
    @map, @help_window = Spriteset_Map.new, Window_Help.new
    # Create Confirmation window.
    @confirm_window = Window_Command.new(128, ['Yes', 'No'])
    @confirm_window.x, @confirm_window.y = 496, 336
    # Initialize sprites array. Used to handle all the sprites together.
    @sprites = [@map, @help_window, @confirm_window]
    # Create seed window if plant is not being harvested.
    unless @harvest
      @seed_window = Window_Seed.new
      @sprites.push(@seed_window)
      @seed_window.active = @seed_window.visible = false
      @help_window.set_text('Plant seeds here?')
    else
      @data = $game_system.garden[$game_map.map_id][@event_id]
      if @plant != nil && @plant.ripe
        text = 'This plant is ripe. Would you like to harvest it?'
      else
        text = 'Nothing is growing yet on this plant. Harvest it anyway?'
      end
      @help_window.set_text(text)
    end
    # Transition instantly then start main loop.
    Graphics.transition(0)
    loop { Graphics.update; Input.update; update; break if $scene != self }
    # Dispose of all the sprites.
    @sprites.each {|sprite| sprite.dispose }
    # Have map refresh to update any changes made.
    $game_map.need_refresh = true
  end
 
  def update
    @sprites.each {|sprite| sprite.update }
    # Branch update method depending on what window is active.
    if @confirm_window.active
      update_confirm
    elsif @seed_window != nil && @seed_window.active
      update_seed_select
    end
  end
 
  def update_confirm
    if Input.trigger?(Input::B)
      # Branch by what action is being canceled.
      if @harvest
        back_to_map
      else
        @seed1 == nil ? back_to_map : cancel_seed_selection
      end
    elsif Input.trigger?(Input::C)
      # Branch by what action is being confirmed.
      if @harvest
        if @confirm_window.index == 0
          item_id = Garden.harvest(@event_id)
          if item_id != nil
            @confirm_window.active = @confirm_window.visible = false
            # Gain item, play the harvest SE, then return to the map.
            $game_party.gain_item(item_id, 1)
            $game_system.se_play(RPG::AudioFile.new(Garden::HARVEST_SE, 80, 100))
            show_results($data_items[item_id])
            $scene = Scene_Map.new
          else
            back_to_map
          end
        else
          back_to_map
        end
      else
        # If asking if player would like to plant seeds at this location.
        if @seed1 == nil
          if @confirm_window.index == 0
            @seed_window.active = @seed_window.visible = true
            @confirm_window.active = @confirm_window.visible = false
            @help_window.set_text('Which seeds would you like to plant?')
          else
            back_to_map
            return
          end
        else # If confirming seed selection.
          if @confirm_window.index == 0
            # Plant seeds and return to map.
            Garden.plant_seeds(@seed1.id, @seed2.id, @event_id)
            $scene = Scene_Map.new
          else # If canceling seed selection
            cancel_seed_selection
            return
          end
        end
        $game_system.se_play($data_system.decision_se)
      end
    end
  end
 
  def show_results(result)
    @help_window.contents.clear
    # Display the message in the help window.
    @help_window.draw_item_name(result, 0, 0)
    cw = @help_window.contents.text_size(result.name).width + 32
    @help_window.contents.draw_text(cw, 0, 608, 32, ' received!')
    # Call Input.update to the clear key press.
    Input.update
    # Loop until it is pressed again.
    until Input.trigger?(Input::C)
      Graphics.update; Input.update; update
    end
  end
 
  def cancel_seed_selection
    # Play cancel SE, reset seeds, and activate/deactivate windows.
    $game_system.se_play($data_system.cancel_se)
    $game_party.gain_item(@seed1.id, 1) unless @seed1.nil? # Added to re add the seeds
    $game_party.gain_item(@seed2.id, 1) unless @seed2.nil? # Added to re add the seeds
    @seed_window.active = @seed_window.visible = true
    @seed_window.refresh
    @confirm_window.active = @confirm_window.visible = false
    @help_window.set_text('Which seeds would you like to plant?')
    @seed1 = @seed2 = nil
  end
 
  def back_to_map
    # Play cancel SE and return to map.
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Map.new
  end
 
  def update_seed_select
    if Input.trigger?(Input::B)
      # If first seed is selected, go back to re-select, else return to map.
      if @seed1 != nil
        cancel_seed_selection
      else
        back_to_map
      end
    elsif Input.trigger?(Input::C)
      # Play Cancle SE if displayed and party has none.
      if $game_party.item_number(@seed_window.seed.id) < 1
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      # Set first seed if not defined, else set the second seed and continue.
      if @seed1 == nil
        @seed1 = @seed_window.seed
        $game_party.lose_item(@seed1.id, 1)
      else
        @seed2, @seed_window.active = @seed_window.seed, false
        $game_party.lose_item(@seed2.id, 1)
        @confirm_window.active = @confirm_window.visible = true
      end
      # Refresh seed window to show changes in inventory.
      set_help
      @seed_window.refresh
    end
  end
 
  def set_help
    # Clear help window.
    @help_window.contents.clear
    # Draw items
    text = @seed2 != nil ? 'Plant these two seeds?' : 'Select second seed...'
    @help_window.set_text(text)
    @help_window.draw_item_name(@seed1, 224, 0)
    if @seed2 != nil
      cw = @help_window.contents.text_size(@seed1.name).width + 320
      @help_window.draw_item_name(@seed2, cw, 0)
    end
  end
end
4
Update to v1.1! Several minor bugs have been fixed, and everything now works the way it says in the instructions. The weather effects themselves are now handled independently from the time system, so speeding up or slowing down the time system will not, for instance, cause thunder to happen constantly. In addition, the weather durations are now handled through the time system, and configured individually for each weather effect. You can now define a variable to hold the current weather index, allowing you to more easily check the current weather from events. The demo has also been updated to showcase some of the new features.
5
Sorry Blizz... I haven't been into scripting all that much over the past few years. This script started off pretty well, but as time went on I tried to add too many cool things and the code just got more and more convoluted. It's looking as though this error may go back to whatever the thing was with script calls that return false, though I'm not sure why I'm returning a boolean from advance in the first place. I'll poke around the script and see if I can fix it at all.

Edit - And I believe I have fixed the error, though I'm still not entirely satisfied with the state of this script. If I ever get the chance I'll see if I can revamp it and make it look nice again.

Edit2 - Although from what I can see all of the features seem to work.
6
Yeah, there were a few minor compatibility issues that I found, mostly that your project name contained a '0' lol, but they're all fixed now.
7
So I've managed to modify the Transition Pack script to ensure compatibility with this addon pack. I think this is a very cool script that would go well with the rest of these addons. I'll be updating the main topic with it shortly. Here's the script:
Spoiler: ShowHide


#==============================================================================
# ** Transition Pack
#------------------------------------------------------------------------------
# by Fantasist
# extra transitions by ForeverZero
# edited by ThallionDarkshine
# Version: 0.22
# Date: 5 March 2014
#------------------------------------------------------------------------------
# Description:
#
#     This script adds some exotic transitions which can't be attained by
#   regular transition graphics.
#------------------------------------------------------------------------------
# Compatibility:
#
#     This script replaces Scene_Map#transfer_player method.
#==============================================================================
# Instructions:
#
#     This script NEEDS "screenshot.dll"! Place it in the game folder.
#     Place this script below Scene_Debug and above Main. To use this, instead
#   of calling a scene directly like this:
#
#           $scene = Scene_Something.new
#
#   call it like this:
#
#           $scene = Transition.new(Scene_Something.new)
#
#     Before calling it, you can change "$game_temp.transition_type" to
#   activate the transiton.
#
#     As of version 1.11 and above, the battle, menu, name, shop and save scenes
#   automatically use the predefined transition effects, so all you have to do
#   is call the scenes using the event command.
#
#     You can also call a certain effect like this:
#
#           Transition.new(NEXT_SCENE, EFFECT_TYPE, EFFECT_TYPE_ARGUMENTS)
#
#
#   Here is the list of transitions (as of version 1.11):
#
#    -1 - Uses the default effect (in most cases, simple transition)
#     0 - Zoom In
#     1 - Zoom Out
#     2 - Shred Horizontal
#     3 - Shred Vertical
#     4 - Fade
#     5 - Explode
#     6 - Explode (Chaos Project Style)
#     7 - Transpose (by Blizzard)
#     8 - Shutter
#     9 - Drop Off
#
#   For Scripters:
#
#     For adding new transitions, check the method Transition#call_effect.
#   Simply add a new case for "type" and add your method. Don't forget to
#   add the *args version, it makes it easier to pass arguments when calling
#   transitions. Check out the call_effect method for reference.
#------------------------------------------------------------------------------
# Configuration:
#
#     Scroll down a bit and you'll see the configuration.
#
#   BATTLE_EFFECT: Effect to be used for calling battles
#   SHOP_EFFECT: Effect to be used for calling the Shop scene
#   NAME_EFFECT: Effect to be used for calling the Name scene
#   MENU_EFFECT: Effect to be used for calling the Menu scene
#   SAVE_EFFECT: Effect to be used for calling the Save scene
#
#   - Set to any number (-1 to 9) to use the respective effect.
#   - Set to "nil" to use the effect defined in "$game_temp.transition_type".
#   - Use an array to use any random effect. For example, setting BATTLE_EFFECT
#     to [1, 3, 6, 8, 9] will use any of those effects each time the battle
#     scene is called.
#
#   Explosion_Sound: Filename of the SE for Explosion transitions
#       Clink_Sound: Filename of the SE for Drop Off transition
#------------------------------------------------------------------------------
# Issues:
#
#     None that I know of.
#------------------------------------------------------------------------------
# Credits and Thanks:
#
#   Fantasist, for making this script
#   Blizzard, for the Transpose effect
#   shdwlink1993, for keeping the demo for so long
#   Ryexander, for helping me with an important scripting aspect
#   Memor-X, for pointing out some bugs
#------------------------------------------------------------------------------
# Notes:
#
#     If you have any problems, suggestions or comments, you can find me at:
#
#  - forum.chaos-project.com
#
#   Enjoy ^_^
#==============================================================================

#==============================================================================
# ** Screen Module
#------------------------------------------------------------------------------
#  This module handles taking screenshots for the transitions.
#==============================================================================
module Screen
 
  @screen = Win32API.new 'screenshot.dll', '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'
  #--------------------------------------------------------------------------
  # * Snap (take screenshot)
  #--------------------------------------------------------------------------
  def self.snap(file_name='scrn_tmp', file_type=0)
    game_name = "\0" * 256
    @readini.call('Game', 'Title', '', game_name, 255, '.\Game.ini')
    game_name.delete!("\0")
    window = @findwindow.call('RGSS Player', game_name)
    @screen.call(0, 0, 640, 480, file_name, window, file_type)
  end
end

#==============================================================================
# ** Transition
#------------------------------------------------------------------------------
#  This scene handles transition effects while switching to another scene.
#==============================================================================
class Transition
  attr_reader :started
 
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # * CONFIG BEGIN
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  BATTLE_EFFECT = [6, 7, 8, 9, 14, 17] # randomly choose from any of those
  BATTLE_USE_BACK = true
  SHOP_EFFECT = [16, 17, 18]
  SHOP_USE_BACK = true
  NAME_EFFECT = nil # uses default effect set in $game_temp.transition_type
  NAME_USE_BACK = false
  MENU_EFFECT = 16
  MENU_USE_BACK = true
  SAVE_EFFECT = -1 # disable effect/use default
  SAVE_USE_BACK = false
 
 
  Explosion_Sound = nil
      Clink_Sound = nil
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # * CONFIG END
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  #--------------------------------------------------------------------------
  # * Call Effect
  #     type : Transition type
  #     args : Arguments for specified transition type
  #--------------------------------------------------------------------------
  def call_effect(type, args)
    # if "type" is an array, choose a random element.
    if type.is_a?(Array)
      type = type[rand(type.size)]
    end
    # Call appropriate method with or without arguments depending
    # on values of type and args.
    no_args = args.nil? || args == []
    if no_args
      case type
      when 0 then zoom_in
      when 1 then zoom_out
      when 2 then shred_h
      when 3 then shred_v
      when 4 then fade
      when 5 then explode
      when 6 then explode_cp
      when 7 then transpose
      when 8 then shutter
      when 9 then drop_off
      when 10 then ff_IV_style
      when 11 then downward_spiral
      when 12 then blackhole
      when 13 then wave_distort
      when 14 then radial_break
      when 15 then double_zoom
      when 16 then cover
      when 17 then uncover
      when 18 then shift
      end
    else
      case type
      when 0 then zoom_in(*args)
      when 1 then zoom_out(*args)
      when 2 then shred_h(*args)
      when 3 then shred_v(*args)
      when 4 then fade(*args)
      when 5 then explode(*args)
      when 6 then explode_cp(*args)
      when 7 then transpose(*args)
      when 8 then shutter(*args)
      when 9 then drop_off(*args)
      when 10 then ff_IV_style(*args)
      when 11 then downward_spiral(*args)
      when 12 then blackhole(*args)
      when 13 then wave_distort(*args)
      when 14 then radial_break(*args)
      when 15 then double_zoom(*args)
      when 16 then cover(*args)
      when 17 then uncover(*args)
      when 18 then shift(*args)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Initialize
  #     next_scene : Instance of the scene to transition into
  #           type : Transition type
  #          *args : Arguments for specified transition type
  #--------------------------------------------------------------------------
  def initialize(next_scene=Scene_Menu.new, type=nil, show_next=nil, *args)
    @next_scene = next_scene
    @args = args
    # If transition type is specified, use it.
    # Otherwise, use default.
    @type = type.nil? ? $game_temp.transition_type : type
    @show_next = show_next.nil? ? $game_temp.use_back : show_next
  end
  #--------------------------------------------------------------------------
  # * Main
  #--------------------------------------------------------------------------
  def main
    if @type == -1
      $scene = @next_scene
      return
    end
    @started = true
    # Take screenshot and prepare sprite
    path = ENV['appdata'] + "\\scrn_tmp"
    Screen.snap(path)
    @sprite = Sprite.new
    @sprite.bitmap = Bitmap.new(path)
    @sprite.x = @sprite.ox = @sprite.bitmap.width / 2
    @sprite.y = @sprite.oy = @sprite.bitmap.height / 2
    @sprite.z = 100000
    @sprite.disposable = true
    @next_scene.main if @show_next == true
    # Activate effect
    Graphics.transition(0)
    call_effect(@type, @args)
    # Freeze screen and clean up and switch scene
    Graphics.freeze
    @sprite.bitmap.dispose unless @sprite.bitmap.nil?
    @sprite.dispose unless @sprite.nil?
    $skip_trans = @show_next
    #File.delete(path)
    $scene = @next_scene
    $game_system.disposables.each { |el| el.dispose }
    $game_system.disposables = []
  end
  #--------------------------------------------------------------------------
  # * Play SE
  #     filename : Filename of the SE file in Audio/SE folder
  #        pitch : Pitch of sound (50 - 100)
  #       volume : Volume of sound (0 - 100)
  #--------------------------------------------------------------------------
  def play_se(filename, pitch=nil, volume=nil)
    se = RPG::AudioFile.new(filename)
    se.pitch  = pitch unless pitch.nil?
    se.volume = volume unless volume.nil?
    Audio.se_play('Audio/SE/' + se.name, se.volume, se.pitch)
  end
 
  def tile_sprites(tilesize)
    tiles = []
    # Iterate through main sprite, creating sprites for each square.
    (0...@sprite.bitmap.width / tilesize).each {|x|
      (0...@sprite.bitmap.height / tilesize).each {|y|
        sprite = Sprite.new(@sprite.viewport)
        sprite.x, sprite.y = x*tilesize, y*tilesize
        sprite.bitmap = Bitmap.new(tilesize, tilesize)
        rect = Rect.new(sprite.x, sprite.y, tilesize, tilesize)
        sprite.bitmap.blt(0, 0, @sprite.bitmap, rect)
        tiles.push(sprite)
      }
    }
    @sprite.opacity = 0
    return tiles
  end
 
  def double_zoom(frames = 30, zoom1 = 12, zoom2 = 32)
    # Calculate the stages. Account for final zoom being longer.
    stage3 = (frames * (zoom1.to_f / zoom2)).round
    stages = [(frames - stage3) / 2, (frames - stage3) / 2, stage3]
    # Calculate the zoom rates to apply each frame, for each stage.
    zoom_rates, opacity_rate = [zoom1-1, -zoom1+1, zoom2], (255 / frames.to_f)
    zoom_rates.each_index {|i| zoom_rates[i] /= stages[i].to_f }
    # Initialize local variable to keep track of current stage being executed.
    current_stage = 0
    3.times do
      # Iterate each stage, using the calculated rates for each one.
      stages[current_stage].times do
        @sprite.zoom_x += zoom_rates[current_stage]
        @sprite.zoom_y += zoom_rates[current_stage]
        @sprite.opacity -= opacity_rate
        Graphics.update
      end
      current_stage += 1
    end
  end


 
  #==========================================================================
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # ** Effect Library
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  #==========================================================================
 
  #--------------------------------------------------------------------------
  # * Zoom In
  #     frames : Effect duration in frames
  #   max_zoom : The max amount the screen zooms out
  #--------------------------------------------------------------------------
  def zoom_in(frames=20, max_zoom=12)
    # Calculate difference b/w current and target
    # zooms (1 and max_zoom)
    zoom_diff = max_zoom - 1
    # Calculate unit values
    unit_zoom = zoom_diff.to_f / frames
    unit_opacity = (255.0 / frames).ceil
    # Apply unit values to sprite
    frames.times do
      @sprite.zoom_x += unit_zoom
      @sprite.zoom_y += unit_zoom
      @sprite.opacity -= unit_opacity
      Graphics.update
    end
  end
  #--------------------------------------------------------------------------
  # * Zoom Out
  #     frames : Effect duration in frames
  #--------------------------------------------------------------------------
  def zoom_out(frames=20)
    # Calculate unit values
    unit_zoom = 1.0 / frames
    unit_opacity = (255.0 / frames).ceil
    # Apply unit values to sprite
    frames.times do
      @sprite.zoom_x -= unit_zoom
      @sprite.zoom_y -= unit_zoom
      @sprite.opacity -= unit_opacity
      Graphics.update
    end
  end
  #--------------------------------------------------------------------------
  # * Shred Horizontal
  #      thickness : Shred thickness
  #       slowness : How slow the screens move out
  #    start_speed : Speed of first step in pixels
  #--------------------------------------------------------------------------
  def shred_h(thickness=4, slowness=4, start_speed=8)
    t = thickness
    # Shred screen
    sprite2 = Sprite.new(@sprite.viewport)
    sprite2.bitmap = Bitmap.new(@sprite.bitmap.width, @sprite.bitmap.height)
    sprite2.x = sprite2.ox = sprite2.bitmap.width / 2
    sprite2.y = sprite2.oy = sprite2.bitmap.height / 2
    for i in 0..(480/t)
      sprite2.bitmap.blt(0, i*t*2, @sprite.bitmap, Rect.new(0, i*t*2, 640, t))
      @sprite.bitmap.fill_rect(0, i*t*2, 640, t, Color.new(0, 0, 0, 0))
    end
    # Make sure starting step is not zero
    start_speed = slowness if start_speed < slowness
    # Move sprites
    dist = 640 - @sprite.x + start_speed
    loop do
      x_diff = (dist - (640 - @sprite.x)) / slowness
      @sprite.x += x_diff
      sprite2.x -= x_diff
      Graphics.update
      break if @sprite.x >= 640 + 320
    end
    sprite2.bitmap.dispose
    sprite2.dispose
  end
  #--------------------------------------------------------------------------
  # * Shred Vertical
  #      thickness : Shred thickness
  #       slowness : How slow the screens move out
  #    start_speed : Speed of first step in pixels
  #--------------------------------------------------------------------------
  def shred_v(thickness=4, slowness=4, start_speed=8)
    t = thickness
    # Shred screen
    sprite2 = Sprite.new(@sprite.viewport)
    sprite2.bitmap = Bitmap.new(@sprite.bitmap.width, @sprite.bitmap.height)
    sprite2.x = sprite2.ox = sprite2.bitmap.width / 2
    sprite2.y = sprite2.oy = sprite2.bitmap.height / 2
    # Shred bitmap
    for i in 0..(640/t)
      sprite2.bitmap.blt(i*t*2, 0, @sprite.bitmap, Rect.new(i*t*2, 0, t, 480))
      @sprite.bitmap.fill_rect(i*t*2, 0, t, 480, Color.new(0, 0, 0, 0))
    end
    # Make sure starting step is not zero
    start_speed = slowness if start_speed < slowness
    # Move sprites
    dist = 480 - @sprite.y + start_speed
    loop do
      y_diff = (dist - (480 - @sprite.y)) / slowness
      @sprite.y += y_diff
      sprite2.y -= y_diff
      Graphics.update
      break if @sprite.y >= 480 + 240
    end
    sprite2.bitmap.dispose
    sprite2.dispose
  end
  #--------------------------------------------------------------------------
  # * Shred Grid
  #      thickness : Shred thickness
  #       slowness : How slow the screens move out
  #    start_speed : Speed of first step in pixels
  #       priority : Which direction comes first (0 - vertical, 1 - horizontal)
  #--------------------------------------------------------------------------
  def shred_g(thickness=4, slowness=4, start_speed=8, priority = 0)
    t = thickness
    # Shred screen
    sprite2 = Sprite.new(@sprite.viewport)
    sprite2.bitmap = Bitmap.new(@sprite.bitmap.width, @sprite.bitmap.height)
    sprite2.x = sprite2.ox = sprite2.bitmap.width / 2
    sprite2.y = sprite2.oy = sprite2.bitmap.height / 2
    sprite3 = Sprite.new(@sprite.viewport)
    sprite3.bitmap = Bitmap.new(@sprite.bitmap.width, @sprite.bitmap.height)
    sprite3.x = sprite3.ox = sprite3.bitmap.width / 2
    sprite3.y = sprite3.oy = sprite3.bitmap.height / 2
    sprite4 = Sprite.new(@sprite.viewport)
    sprite4.bitmap = @sprite.bitmap.clone
    sprite4.x = sprite4.ox = sprite4.bitmap.width / 2
    sprite4.y = sprite4.oy = sprite4.bitmap.height / 2
    #sprite2.visible = sprite3.visible = sprite4.visible = false
    # Shred bitmap
    if priority == 0
      for i in 0..(640/t)
        sprite2.bitmap.blt(i*t*2, 0, @sprite.bitmap, Rect.new(i*t*2, 0, t, 480))
        @sprite.bitmap.fill_rect(i*t*2, 0, t, 480, Color.new(0, 0, 0, 0))
        sprite4.bitmap.fill_rect(i*t*2, 0, t, 480, Color.new(0, 0, 0, 0))
        sprite2.z = 4
        sprite3.z = 3
        @sprite.z = 2
        sprite4.z = 1
      end
      for i in 0..(480/t)
        sprite3.bitmap.blt(0, i*t*2, @sprite.bitmap, Rect.new(0, i*t*2, 640, t))
        @sprite.bitmap.fill_rect(0, i*t*2, 640, t, Color.new(0, 0, 0, 0))
        sprite4.bitmap.fill_rect(0, i*t*2, 640, t, Color.new(0, 0, 0, 0))
      end
    else
      for i in 0..(480/t)
        sprite3.bitmap.blt(0, i*t*2, @sprite.bitmap, Rect.new(0, i*t*2, 640, t))
        @sprite.bitmap.fill_rect(0, i*t*2, 640, t, Color.new(0, 0, 0, 0))
        sprite4.bitmap.fill_rect(0, i*t*2, 640, t, Color.new(0, 0, 0, 0))
        sprite3.z = 4
        sprite2.z = 3
        @sprite.z = 2
        sprite4.z = 1
      end
      for i in 0..(640/t)
        sprite2.bitmap.blt(i*t*2, 0, @sprite.bitmap, Rect.new(i*t*2, 0, t, 480))
        @sprite.bitmap.fill_rect(i*t*2, 0, t, 480, Color.new(0, 0, 0, 0))
        sprite4.bitmap.fill_rect(i*t*2, 0, t, 480, Color.new(0, 0, 0, 0))
      end
    end
    # Make sure starting step is not zero
    start_speed = slowness if start_speed < slowness
    # Move sprites
    disty = 480 - sprite4.y + start_speed
    distx = 640 - @sprite.y + start_speed
    loop do
      y_diff = (disty - (480 - sprite4.y)) / slowness
      x_diff = (distx - (640 - @sprite.x)) / slowness
      sprite4.y += y_diff
      sprite2.y -= y_diff
      @sprite.x += x_diff
      sprite3.x -= x_diff
      Graphics.update
      break if @sprite.x >= 640 + 320
    end
    sprite2.bitmap.dispose
    sprite2.dispose
    sprite3.bitmap.dispose
    sprite3.dispose
    sprite4.bitmap.dispose
    sprite4.dispose
  end
 
  def custom_tile_sprites(size_x, size_y, conditions, properties, centered = true)
    raise "Tile Error: not the same amount of conditions and properties" if conditions.length != properties.length
    tiles = []
    # Iterate through main sprite, creating sprites for each square.
    (0...@sprite.bitmap.width / size_x).each {|col|
      (0...@sprite.bitmap.height / size_y).each {|row|
        sprite = Sprite.new(@sprite.viewport)
        sprite.x += col*size_x
        sprite.y += row*size_y
        sprite.bitmap = Bitmap.new(size_x, size_y)
        rect = Rect.new(sprite.x, sprite.y, size_x, size_y)
        sprite.bitmap.blt(0, 0, @sprite.bitmap, rect)
        for i in 0...conditions.length
          if conditions[i].call(col, row)
            properties[i].each { |prop|
              sprite.send("#{prop[0]}=", prop[1])
              #sprite.zoom_x = 1
              #sprite.zoom_y = 1
            }
            break
          end
        end
        if centered
          sprite.ox = size_x / 2
          sprite.oy = size_y / 2
          sprite.x += size_x / 2
          sprite.y += size_y / 2
        end
        tiles.push(sprite)
      }
    }
    @sprite.opacity = 0
    return tiles
  end
 
  def effect3(size_x = 640, size_y = 4)
    tiles = custom_tile_sprites(size_x, size_y, [proc { true }], [{}])
    # Make sure starting step is not zero
    #start_speed = slowness if start_speed < slowness
   
    frames = 0
   
    while (tiles.select { |i| i.visible == true }).length > 0
      selected_length = (tiles.select { |i| i.visible == true }).length
      frames += 1
      for i in tiles
        i.visible = false if rand(selected_length / 4) == 0
      end
      Graphics.update
    end
   
    tiles.each { |tile|
      tile.bitmap.dispose
      tile.dispose
    }
  end
 
  def effect2(fade_length = 10, size_x = 20, size_y = 20)
    tiles = custom_tile_sprites(size_x, size_y, [proc { true }], [{}])
    # Make sure starting step is not zero
    #start_speed = slowness if start_speed < slowness
   
    frames = 0
    opac_diff = 255 / fade_length
   
    while (tiles.select { |i| i.visible == true }).length > 0
      selected_length = (tiles.select { |i| i.visible == true }).length
      frames += 1
      for i in tiles
        i.opacity -= opac_diff if (i.opacity != 255 and i.opacity > 0) or rand(selected_length / 4) == 0
        i.visible = false if i.opacity <= 0 and i.visible
      end
      Graphics.update
    end
   
    tiles.each { |tile|
      tile.bitmap.dispose
      tile.dispose
    }
  end
 
  def cover(dir = 0, duration = 40)
    frames = 0
    x_mod = case dir;when 7,0,1 then -640; when 3,4,5 then 640;else 0;end
    y_mod = case dir;when 1,2,3 then -480; when 5,6,7 then 480;else 0;end
    s_pos = []
    d_pos = []
    $game_system.disposables.each { |i|
      if i.respond_to?(:x=) and i.respond_to?(:y=)
        d_pos.push([i.x, i.y])
        i.x += x_mod
        i.y += y_mod
        s_pos.push([i.x, i.y])
      elsif i.is_a?(Tilemap)
        d_pos.push([i.ox, i.oy])
        i.ox -= x_mod
        i.oy -= y_mod
        s_pos.push([i.ox, i.oy])
      else
        d_pos.push([0, 0])
        s_pos.push([0, 0])
      end
      i.z = 100000 if i.respond_to?(:z=)
    }
    loop do
      frames += 1
      $game_system.disposables.each_with_index { |i, ind|
        if i.respond_to?(:x=) and i.respond_to?(:y=)
          ts_pos = s_pos[ind]
          td_pos = d_pos[ind]
          i.x = (ts_pos[0] * (duration - frames) + td_pos[0] * frames) / duration
          i.y = (ts_pos[1] * (duration - frames) + td_pos[1] * frames) / duration
        elsif i.is_a?(Tilemap)
          ts_pos = s_pos[ind]
          td_pos = d_pos[ind]
          i.ox = (ts_pos[0] * (duration - frames) + td_pos[0] * frames) / duration
          i.oy = (ts_pos[1] * (duration - frames) + td_pos[1] * frames) / duration
        end
        i.z = 100000 if i.respond_to?(:z=)
      }
      Graphics.update
      break if frames == duration
    end
  end
 
  def uncover(dir = 0, duration = 40)
    frames = 0
    x_mod = case dir;when 7,0,1 then -640; when 3,4,5 then 640;else 0;end
    y_mod = case dir;when 1,2,3 then -480; when 5,6,7 then 480;else 0;end
    s_pos = [@sprite.x, @sprite.y]
    d_pos = [s_pos[0] + x_mod, s_pos[1] + y_mod]
    loop do
      frames += 1
      @sprite.x = (s_pos[0] * (duration - frames) + d_pos[0] * frames) / duration
      @sprite.y = (s_pos[1] * (duration - frames) + d_pos[1] * frames) / duration
      Graphics.update
      break if frames == duration
    end
  end
 
  def shift(dir = 0, duration = 40)
    frames = 0
    x_mod = case dir;when 0 then -640; when 2 then 640;else 0;end
    y_mod = case dir;when 1 then -480; when 3 then 480;else 0;end
    s_pos = []
    d_pos = []
    $game_system.disposables.each { |i|
      if i.respond_to?(:x=) and i.respond_to?(:y=)
        d_pos.push([i.x, i.y])
        i.x += x_mod
        i.y += y_mod
        s_pos.push([i.x, i.y])
      else
        d_pos.push([0, 0])
        s_pos.push([0, 0])
      end
      i.z = 100000 if i.respond_to?(:z=)
    }
    s_pos.push([@sprite.x, @sprite.y])
    d_pos.push([@sprite.x - x_mod, @sprite.y - y_mod])
    @sprite.x, @sprite.y = *s_pos.last
    loop do
      frames += 1
      $game_system.disposables.each_with_index { |i, ind|
        if i.respond_to?(:x=) and i.respond_to?(:y=)
          ts_pos = s_pos[ind]
          td_pos = d_pos[ind]
          i.x = (ts_pos[0] * (duration - frames) + td_pos[0] * frames) / duration
          i.y = (ts_pos[1] * (duration - frames) + td_pos[1] * frames) / duration
        end
        i.z = 100000 if i.respond_to?(:z=)
      }
      ts_pos = s_pos.last
      td_pos = d_pos.last
      @sprite.x = (ts_pos[0] * (duration - frames) + td_pos[0] * frames) / duration
      @sprite.y = (ts_pos[1] * (duration - frames) + td_pos[1] * frames) / duration
      Graphics.update
      break if frames == duration
    end
  end
 
  #--------------------------------------------------------------------------
  # * Fade
  #     target_color : Color to fade to
  #           frames : Effect duration in frames
  #--------------------------------------------------------------------------
  def fade(target_color=Color.new(255, 255, 255), frames=10)
    loop do
      r = (@sprite.color.red   * (frames - 1) + target_color.red)   / frames
      g = (@sprite.color.green * (frames - 1) + target_color.green) / frames
      b = (@sprite.color.blue  * (frames - 1) + target_color.blue)  / frames
      a = (@sprite.color.alpha * (frames - 1) + target_color.alpha) / frames
      @sprite.color.red   = r
      @sprite.color.green = g
      @sprite.color.blue  = b
      @sprite.color.alpha = a
      frames -= 1
      Graphics.update
      break if frames <= 0
    end
    Graphics.freeze
  end
  #--------------------------------------------------------------------------
  # * Explode
  #     explosion_sound : The SE filename to use for explosion sound
  #--------------------------------------------------------------------------
  def explode(explosion_sound=Explosion_Sound)
    shake_count = 2
    shakes = 40
    tone = 0
    shakes.times do
      @sprite.ox = 320 + (rand(2) == 0 ? -1 : 1) * shake_count
      @sprite.oy = 240 + (rand(2) == 0 ? -1 : 1) * shake_count
      shake_count += 0.2
      tone += 128/shakes
      @sprite.tone.set(tone, tone, tone)
      Graphics.update
    end
    @sprite.ox, @sprite.oy = 320, 240
    Graphics.update
    bitmap = @sprite.bitmap.clone
    viewport = @sprite.viewport
    @sprite.bitmap.dispose
    @sprite.dispose
    # Slice bitmap and create nodes (sprite parts)
    hor = []
    20.times do |i|
      ver = []
      15.times do |j|
        # Set node properties
        s = Sprite.new(viewport)
        s.ox, s.oy = 8 + rand(25), 8 + rand(25)
        s.x, s.y = s.ox + 32 * i, s.oy + 32 * j
        s.bitmap = Bitmap.new(32, 32)
        s.bitmap.blt(0, 0, bitmap, Rect.new(i * 32, j * 32, 32, 32))
        s.tone.set(128, 128, 128)
        # Set node physics
        angle  = (rand(2) == 0 ? -1 : 1) * (4 + rand(4) * 10)
        zoom_x = (rand(2) == 0 ? -1 : 1) * (rand(2) + 1).to_f / 100
        zoom_y = (rand(2) == 0 ? -1 : 1) * (rand(2) + 1).to_f / 100
        (zoom_x > zoom_y) ? (zoom_y = -zoom_x) : (zoom_x = -zoom_y)
        x_rand = (2 + rand(2) == 0 ? -2 : 2)
        y_rand = (1 + rand(2) == 0 ? -1 : 1)
        # Store node and it's physics
        ver.push([s, angle, zoom_x, zoom_y, x_rand, y_rand])
      end
      hor.push(ver)
    end
    bitmap.dispose
    # Play sound
    play_se(explosion_sound) if explosion_sound != nil
    # Move pics
    40.times do |k|
      hor.each_with_index do |ver, i|
        ver.each_with_index do |data, j|
          # Get node and it's physics
          s, angle, zoom_x, zoom_y = data[0], data[1], data[2], data[3]
          x_rand, y_rand = data[4], data[5]
          # Manipulate nodes
          s.x += (i - 10) * x_rand
          s.y += (j - 8) * y_rand + (k - 20)/2
          s.zoom_x += zoom_x
          s.zoom_y += zoom_y
          tone = s.tone.red - 8
          s.tone.set(tone, tone, tone)
          s.opacity -= 13 if k > 19
          s.angle += angle % 360
        end
      end
      Graphics.update
    end
    # Dispose
    for ver in hor
      for data in ver
        data[0].bitmap.dispose
        data[0].dispose
      end
    end
    hor = nil
  end
  #--------------------------------------------------------------------------
  # * Explode (Chaos Project Style)
  #     explosion_sound : The SE filename to use for explosion sound
  #--------------------------------------------------------------------------
  def explode_cp(explosion_sound=Explosion_Sound)
    bitmap = @sprite.bitmap.clone
    viewport = @sprite.viewport
    @sprite.bitmap.dispose
    @sprite.dispose
    # Slice bitmap and create nodes (sprite parts)
    hor = []
    20.times do |i|
      ver = []
      15.times do |j|
        # Set node properties
        s = Sprite.new(viewport)
        s.ox = s.oy = 16
        s.x, s.y = s.ox + 32 * i, s.oy + 32 * j
        s.bitmap = Bitmap.new(32, 32)
        s.bitmap.blt(0, 0, bitmap, Rect.new(i * 32, j * 32, 32, 32))
        # Set node physics
        angle  = (rand(2) == 0 ? -1 : 1) * rand(8)
        zoom_x = (rand(2) == 0 ? -1 : 1) * (rand(2) + 1).to_f / 100
        zoom_y = (rand(2) == 0 ? -1 : 1) * (rand(2) + 1).to_f / 100
        # Store node and it's physics
        ver.push([s, angle, zoom_x, zoom_y])
      end
      hor.push(ver)
    end
    bitmap.dispose
    # Play sound
    play_se(explosion_sound) if explosion_sound != nil
    # Move pics
    40.times do |k|
      hor.each_with_index do |ver, i|
        ver.each_with_index do |data, j|
          # Get node and it's physics
          s, angle, zoom_x, zoom_y = data[0], data[1], data[2], data[3]
          # Manipulate node
          s.x += i - 9
          s.y += j - 8 + k
          s.zoom_x += zoom_x
          s.zoom_y += zoom_y
          s.angle += angle % 360
        end
      end
      Graphics.update
    end
    # Dispose
    for ver in hor
      for data in ver
        data[0].bitmap.dispose
        data[0].dispose
      end
    end
    hor = nil
  end
  #--------------------------------------------------------------------------
  # * Transpose (bt Blizzard)
  #     frames : Effect duration in frames
  #   max_zoom : The max amount the screen zooms out
  #      times : Number of times screen is zoomed (times * 3 / 2)
  #--------------------------------------------------------------------------
  def transpose(frames=80, max_zoom=12, times=3)
    max_zoom -= 1 # difference b/w zooms
    max_zoom = max_zoom.to_f / frames / times # unit zoom
    unit_opacity = (255.0 / frames).ceil
    spr_opacity = (255.0 * times / 2 / frames).ceil
    @sprites = []
    (times * 3 / 2).times {
      s = Sprite.new(@sprite.viewport)
      s.x, s.y, s.ox, s.oy = 320, 240, 320, 240
      s.bitmap = @sprite.bitmap
      s.blend_type = 1
      s.opacity = 128
      s.visible = false
      @sprites.push(s)}
    count = 0
    loop {
        @sprites[count].visible = true
        count += 1 if count < times * 3 / 2 - 1
        (frames / times / 2).times {
            @sprites.each {|s|
                break if !s.visible
                s.zoom_x += max_zoom
                s.zoom_y += max_zoom
                s.opacity -= spr_opacity}
            @sprite.opacity -= unit_opacity
        Graphics.update}
        break if @sprite.opacity == 0}
    @sprites.each {|s| s.dispose}
  end
  #--------------------------------------------------------------------------
  # * Shutter
  #       open_gap : How much the shutters open before moving away
  #       flip_dir : Whether or not the direction of shutters if reversed
  #       slowness : How slow the screens move out
  #    start_speed : Speed of first step in pixels
  #--------------------------------------------------------------------------
  def shutter(flip_dir=true, open_gap=16, slowness=4, start_speed=8)
    # Shred screen
    sprite2 = Sprite.new(@sprite.viewport)
    sprite2.bitmap = Bitmap.new(@sprite.bitmap.width, @sprite.bitmap.height)
    sprite2.x = sprite2.ox = sprite2.bitmap.width / 2
    sprite2.y = sprite2.oy = sprite2.bitmap.height / 2
    if flip_dir
      ver_step = 1
      sprite2.bitmap.blt(0, 240, @sprite.bitmap, Rect.new(0, 240, 640, 240))
      @sprite.bitmap.fill_rect(0, 240, 640, 240, Color.new(0, 0, 0, 0))
    else
      ver_step = -1
      sprite2.bitmap.blt(0, 0, @sprite.bitmap, Rect.new(0, 0, 640, 240))
      @sprite.bitmap.fill_rect(0, 0, 640, 240, Color.new(0, 0, 0, 0))
    end
    # Move the shutters apart
    open_gap.times do
      @sprite.y -= ver_step
      sprite2.y += ver_step
      Graphics.update
    end
    # Make sure starting step is not zero
    start_speed = slowness if start_speed < slowness
    # Move sprites
    dist = 640 - @sprite.x + start_speed
    loop do
      x_diff = (dist - (640 - @sprite.x)) / slowness
      @sprite.x += x_diff
      sprite2.x -= x_diff
      Graphics.update
      break if @sprite.x >= 640 + 320
    end
    sprite2.bitmap.dispose
    sprite2.dispose
  end
  #--------------------------------------------------------------------------
  # * Drop Off
  #     clink_sound : The SE filename to use for clinking sound
  #--------------------------------------------------------------------------
  def drop_off(clink_sound=Clink_Sound)
    bitmap = @sprite.bitmap.clone
    viewport = @sprite.viewport
    @sprite.bitmap.dispose
    @sprite.dispose
    # Slice bitmap and create nodes (sprite parts)
    max_time = 0
    hor = []
    10.times do |i|
      ver = []
      8.times do |j|
        # Set node properties
        s = Sprite.new(viewport)
        s.ox = rand(32)
        s.oy = 0
        s.x = s.ox + 64 * i
        s.y = s.oy + 64 * j
        s.bitmap = Bitmap.new(64, 64)
        s.bitmap.blt(0, 0, bitmap, Rect.new(i * 64, j * 64, 64, 64))
        # Set node physics
        angle = rand(4) * 2
        angle *= rand(2) == 0 ? -1 : 1
        start_time = rand(30)
        max_time = start_time if max_time < start_time
        # Store node and it's physics
        ver.push([s, angle, start_time])
      end
      hor.push(ver)
    end
    bitmap.dispose
    # Play sound
    play_se(clink_sound) if clink_sound != nil
    # Move pics
    (40 + max_time).times do |k|
      hor.each_with_index do |ver, i|
        ver.each_with_index do |data, j|
          # Get node and it's physics
          s, angle, start_time = data[0], data[1], data[2]
          # Manipulate node
          if k > start_time
            tone = s.tone.red - 6
            s.tone.set(tone, tone, tone)
            s.y += k - start_time
            s.angle += angle % 360
          elsif k == start_time
            tone = 128
            s.tone.set(tone, tone, tone)
            $game_system.se_play(Clink_Sound) if clink_sound != nil
          end
        end
      end
      Graphics.update
    end
    # Dispose
    for ver in hor
      for data in ver
        data[0].bitmap.dispose
        data[0].dispose
      end
    end
    hor = nil
  end
 
  def ff_IV_style(zoom1 = 1.2, zoom2 = 32)
    # Set number of frames and zoom rates for each stage.
    stages = [4, 4, 4, 4, 20]
    zooms = [zoom1, -zoom1, zoom1, -zoom1, zoom2]
    zooms.each_index {|i| zooms[i] /= stages[i].to_f }
    current_stage = 0
    5.times do
      # Begin processing.
      stages[current_stage].times do
        @sprite.zoom_x += zooms[current_stage]
        @sprite.zoom_y += zooms[current_stage]
        @sprite.opacity -= 12 if current_stage == 4
        Graphics.update
      end
      # Increase current stage.
      current_stage += 1
    end
  end

  def downward_spiral(frames = 40, rotation_speed = 15)
    # Calculate the zoom to subtract each frame.
    zoom, opacity = 1.0 / frames, 128.0 / frames
    frames.times do
      # Begin processing.
      @sprite.zoom_x -= zoom
      @sprite.zoom_y -= zoom
      @sprite.opacity -= opacity
      @sprite.angle += rotation_speed
      Graphics.update
    end
  end

  def blackhole(speed = 4, tilesize = 12, source = [320, 240])
    # Initialize squares array to hold each sprite.
    tiles = tile_sprites(tilesize)
    # Make each sprite slightly smaller than full size.
    tiles.each {|tile| tile.zoom_x = tile.zoom_y = 0.85 }
    # Begin looping until all sprites have been disposed.
    until tiles.compact == []
      # Iterate each tiles.
      tiles.each_index {|i|
        next if tiles[i] == nil
        # Get distance of this sprite from the source for each axis.
        sx = source[0] - tiles[i].x
        sy = source[1] - tiles[i].y
        # Calculate total distance and set base speed for each axis.
        dist = Math.hypot(sx, sy).to_f
        move_x = (dist / (sx == 0 ? 1 : sx))
        move_y = (dist / (sy == 0 ? 1 : sy))
        # Add a little randomness to the mix.
        move_x += move_x < 0 ? -rand(speed) : rand(speed)
        move_y += move_y < 0 ? -rand(speed) : rand(speed)
        # Apply movement.
        tiles[i].x += move_x
        tiles[i].y += move_y
        tiles[i].angle += rand(20)
        # If tile is within its own size from source, dispose it.
        if sx.abs <= tilesize && sy.abs <= tilesize
           tiles[i].bitmap.dispose
           tiles[i] = tiles[i].dispose
        end
      }
      Graphics.update
    end
  end

  def wave_distort(frames = 60, direction = 2, power = 0.4)
    radius, tiles = 0, tile_sprites(16)
    # Define starting point for zoom, depending on direction.
    origin = case direction
    when 2 then [@sprite.bitmap.width / 2, @sprite.bitmap.height]
    when 4 then [0, @sprite.bitmap.height / 2]
    when 6 then [@sprite.bitmap.width, @sprite.bitmap.height / 2]
    when 8 then [@sprite.bitmap.width / 2, 0]
    end
    # Initialize local variable for the rate the radius will increase.
    rate = Math.hypot(@sprite.bitmap.width, @sprite.bitmap.height) / frames
    # Begin processing.
    frames.times do
      # Iterate through each tile, calculating distance from focal point.
      tiles.each {|tile|
        dist = Math.hypot((origin[0] - tile.x), (origin[1] - tile.y))
        # Zoom tile on one axis, depending on direction.
        next if radius < dist
        [4, 6].include?(direction) ? tile.zoom_x += power : tile.zoom_y += power
      }
      # Increase radius for next iteration.
      radius += rate
      Graphics.update
    end
    # Dispose each bitmap and sprite used for the tiles.
    tiles.each {|tile| tile.bitmap.dispose; tile.dispose }
  end

 
  def radial_break(frames = 60, tilesize = 16, direction = 4, speed = 9)
    radius, tiles = 0, tile_sprites(tilesize)
    # Define starting point for zoom, depending on direction.
    origin = case direction
    when 2 then [@sprite.bitmap.width / 2, @sprite.bitmap.height]
    when 4 then [0, @sprite.bitmap.height / 2]
    when 6 then [@sprite.bitmap.width, @sprite.bitmap.height / 2]
    when 8 then [@sprite.bitmap.width / 2, 0]
    end
    # Initialize local variable for the rate the radius will increase.
    rate = Math.hypot(@sprite.bitmap.width, @sprite.bitmap.height) / frames
    # Begin processing.
    until tiles == []
      tiles.compact!
      # Iterate through each tile, calculating distance from focal point.
      tiles.each_index {|i|
        # Get distance of this sprite from the source for each axis.
        sx = origin[0] - tiles[i].x
        sy = origin[1] - tiles[i].y
        dist = Math.hypot(sx, sy).to_f
        # Zoom tile on one axis, depending on direction.
        next if radius < dist
        # Calculate total distance and set base speed for each axis.
        move_x = (dist / (sx == 0 ? 1 : sx))
        move_y = (dist / (sy == 0 ? 1 : sy))
        # Add a little randomness to the mix.
        move_x += move_x < 0 ? -rand(speed) : rand(speed)
        move_y += move_y < 0 ? -rand(speed) : rand(speed)
        # Half distance of one axis, depending on rate.
        [2, 8].include?(direction) ? move_x /= 2 : move_y /= 2
        # Apply movement.
        tiles[i].x += move_x
        tiles[i].y += move_y
        angle = (tiles[i].object_id % 2 == 0) ? rand(25) : -rand(25)
        tiles[i].angle += (angle + 5)
        # If tile is within its own size from source, dispose it.
        if sx.abs <= tilesize || sy.abs <= tilesize
           tiles[i].bitmap.dispose
           tiles[i] = tiles[i].dispose
        end
      }
      # Increase radius for next iteration.
      radius += rate / 2
      Graphics.update
    end
  end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  Added transition_type attribute which controls transition shown.
#==============================================================================
class Game_Temp 
  attr_accessor :transition_type
  attr_accessor :use_back
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias transpack_game_temp_init initialize
  def initialize
    @transition_type = 0
    @use_back = false
    transpack_game_temp_init
  end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  Scene_Map modded to use the transition effect when battle begins.
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * Battle Call
  #--------------------------------------------------------------------------
  alias transpack_call_battle call_battle
  def call_battle
    transpack_call_battle
    $scene = Transition.new($scene, Transition::BATTLE_EFFECT, Transition::BATTLE_USE_BACK)
  end
  #--------------------------------------------------------------------------
  # * Shop Call
  #--------------------------------------------------------------------------
  alias transpack_call_shop call_shop
  def call_shop
    transpack_call_shop
    $scene = Transition.new($scene, Transition::SHOP_EFFECT, Transition::SHOP_USE_BACK, rand(4))
  end
  #--------------------------------------------------------------------------
  # * Name Input Call
  #--------------------------------------------------------------------------
  alias transpack_call_name call_name
  def call_name
    transpack_call_name
    $scene = Transition.new($scene, Transition::NAME_EFFECT, Transition::NAME_USE_BACK)
  end
  #--------------------------------------------------------------------------
  # * Menu Call
  #--------------------------------------------------------------------------
  alias transpack_call_menu call_menu
  def call_menu
    transpack_call_menu
    $scene = Transition.new($scene, Transition::MENU_EFFECT, Transition::MENU_USE_BACK, rand(8))
  end
  #--------------------------------------------------------------------------
  # * Save Call
  #--------------------------------------------------------------------------
  alias transpack_call_save call_save
  def call_save
    transpack_call_save
    $scene = Transition.new($scene, Transition::SAVE_EFFECT, Transition::SAVE_USE_BACK)
  end
  #--------------------------------------------------------------------------
  # * Player Place Move
  #--------------------------------------------------------------------------
  def transfer_player
    # Clear player place move call flag
    $game_temp.player_transferring = false
    # If move destination is different than current map
    if $game_map.map_id != $game_temp.player_new_map_id
      # Set up a new map
      $game_map.setup($game_temp.player_new_map_id)
    end
    # Set up player position
    $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
    # Set player direction
    case $game_temp.player_new_direction
    when 2  # down
      $game_player.turn_down
    when 4  # left
      $game_player.turn_left
    when 6  # right
      $game_player.turn_right
    when 8  # up
      $game_player.turn_up
    end
    # Straighten player position
    $game_player.straighten
    # Update map (run parallel process event)
    $game_map.update
    # Remake sprite set
    @spriteset.dispose
    @spriteset = Spriteset_Map.new
    # If processing transition
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      $scene = Transition.new($scene)
    end
    # Run automatic change for BGM and BGS set on the map
    $game_map.autoplay
    # Frame reset
    Graphics.frame_reset
    # Update input information
    Input.update
  end
end

class Game_System
  attr_accessor :disposables
 
  alias transition_init initialize
  def initialize
    transition_init
    @disposables = []
  end
end

module Modifier
  def self.included(mod)
    mod.module_eval {
      alias_method :tdks_trans_updt, :update
      define_method(:update) {
        return tdks_trans_updt() unless $scene.is_a?(Transition) or $skip_trans
      }
    }
  end
end

class Scene_Title;include Modifier;end
class Scene_Map;include Modifier;end
class Scene_Menu;include Modifier;end
class Scene_Item;include Modifier;end
class Scene_Skill;include Modifier;end
class Scene_Equip;include Modifier;end
class Scene_Status;include Modifier;end
class Scene_Save;include Modifier;end
class Scene_Load;include Modifier;end
class Scene_End;include Modifier;end
class Scene_Battle;include Modifier;end
class Scene_Shop;include Modifier;end
class Scene_Name;include Modifier;end
class Scene_Gameover;include Modifier;end
class Scene_Debug;include Modifier;end

module Disposable
  def self.included(mod)
    mod.module_eval {
      attr_accessor :disposable
   
      alias_method :tdks_trans_init, :initialize
      define_method(:initialize) { |*args|
        tdks_trans_init(*args)
        @disposable = false
      }
   
      alias_method :tdks_trans_disp, :dispose
      define_method(:dispose) {
        if $scene.is_a?(Transition) and (($scene.started and !@disposable)) and !self.is_a?(Sprite_Battler)
          if respond_to?(:z=)
            self.z -= 1000
          end
          if self.is_a?(Spriteset_Map) or self.is_a?(Spriteset_Battle)
            tdks_trans_disp
          end
          if (self.is_a?(Sprite) or self.is_a?(Plane)) and self.viewport != nil
            self.tone = self.viewport.tone.clone
            self.color = self.viewport.color.clone
          end
          if self.is_a?(Viewport)
            self.tone = Tone.new(0, 0, 0)
            self.color = Color.new(0, 0, 0, 0)
          end
          $game_system.disposables.push(self)
          return nil
        elsif self.is_a?(Window_Base) && self.disposed?
        else
          tdks_trans_disp
        end
      }
    }
  end
end

class Tilemap
  include Disposable
 
  alias tdks_trans_tileset tileset
  def tileset
    return tdks_trans_tileset unless self.disposed?
    return Bitmap.new(1, 1)
  end
 
  alias tdks_trans_autotiles autotiles
  def autotiles
    return tdks_trans_autotiles unless self.disposed?
    return Array.new(7) { Bitmap.new(1, 1) }
  end
end

class Plane
  include Disposable
end

class Sprite
  include Disposable
end

class Viewport
  include Disposable
end

class Window_Base
  include Disposable
end

class Bitmap
  include Disposable
end

class Spriteset_Map
  include Disposable
end

class Spriteset_Battle
  include Disposable
end

module RPG
  class Weather
    include Disposable
  end
end

module Graphics
  class << self
    alias new_transition transition unless method_defined?(:new_transition)
    alias new_update update unless method_defined?(:new_update)
  end
 
  def self.transition(*args)
    args.push(10) if args.length == 0
    args[0] = 0 if $scene.is_a?(Transition) or $skip_trans
    $skip_trans = nil if $skip_trans
    self.new_transition(*args)
  end
 
  def self.update
    self.new_update
    if $scene.is_a?(Transition) and $scene.started
      $game_system.disposables.each { |disp| disp.update if !(disp.is_a?(Tilemap) or disp.is_a?(Spriteset_Map) or disp.is_a?(Spriteset_Battle)) and disp.respond_to?(:update) }
    end
  end
end


There's just one issue. For whatever reason, whenever the game title contains a '0', the screenshot dll will take a screenshot of the upper left side of the screen instead of the game. So if you want to use the transition pack in your game, stay away from titles containing '0'.

Edit - Fixed the issue.
8
RMXP Script Database / Re: [XP] Event Templates
December 01, 2014, 08:37:57 am
Oops, I'm really sorry about that. I fixed the script, and if you have any more trouble with it I will upload a demo (I'm at school on a chrome book right now so i can't atm).
9
RMXP Script Database / Re: [XP] Event Templates
December 01, 2014, 06:36:05 am
You need to enclose the name of the event in quotation marks so the interpreter knows that it is a string rather than searching for a constant with that name. So you would call it like so:
Code: rgss
create_event_from_template("EV001",1,1)


Edit - Oh, and it should go above main.
10
You're welcome  :)
11
Script Troubleshooting / Re: Bar de stamina + ABS BLIZZ
November 28, 2014, 06:42:50 pm
Well what key are you trying to use ingame to be the run key? Your setup would by default use the 'A' key. If you want to actually use the 'X' key, use Input::Key['X'] instead of Input::X.
12
Script Troubleshooting / Re: Bar de stamina + ABS BLIZZ
November 28, 2014, 03:20:57 pm
Alright, I think i found the error. By extending your modification of Game_Player from Game_Character, I believe you may completely overwrite the class, making it basically an exact copy of Game_Character. This takes away all the methods BABS has added into the Game_Player class.
So, to fix it all you have to do is change this line:
Code: rgss
class Game_Player < Game_Character

to this:
Code: rgss
class Game_Player


And also, one thing I noticed while reading through your script is that instead of just using an else statement, in many places you use and elseif with the exact opposite condition of the if. This is completely redundant, because if the first statement does not catch it, then the opposite of the condition must be true.
13
With one small script, you can allow the user to specify different transitions to accompany the transformation of their character. In place of the code that you used to change the actor's graphic, just use a set move route on the player with this script line in it:
Code: rgss
player=$scene.instance_variable_get(:@spriteset).instance_variable_get(:@actor_sprites)[0];oplayer=Sprite.new(enemy.viewport);oplayer.x,oplayer.y,oplayer.ox,oplayer.oy,oplayer.zoom_x,oplayer.zoom_y=player.x,player.y,player.ox,player.oy,player.zoom_x,player.zoom_y;oplayer.bitmap=player.bitmap;player.battler.instance_variable_set(:@battler_name,NEW_GRAPHIC);player.battler.instance_variable_set(:@battler_hue,0);player.update;Transitions.transition_out(oplayer, TRANSITION_TYPE, DURATION, ARGUMENTS);Transitions.transition_in(player,TRANSITION_TYPE, DURATION, ARGUMENTS)


The capitalized words other than Sprite and Transitions are places where you subsitute in a certain value in place of the capitalized word.
NEW_GRAPHIC -> the filename of the new graphic
TRANSITION_TYPE, DURATION, ARGUMENTS -> one of the various transition setups listed below

And when you want the character to detransform, just do the same thing, only with the name of the original file subsituted in for NEW_GRAPHIC.

Here are the possible values for to paste in in place of "TRANSITION_TYPE, DURATION, ARGUMENT" in the line of code above, taken from the instructions in my script.
Here are the ones for transitioning the old graphic out:

   # Slicing Animations (Animation #0)
   #   parameters: (amount_movement)
   0, 40
   0, 20
   0, 20, [0.6]
   # Fading Animations (Animation #1)
   #   parameters: none
   1, 20
   1, 30
   # Zooming Animations (Animation #2)
   #   parameters: (x_zoom, y_zoom) or (zoom)
   2, 30
   2, 20, [1.2]
   2, 30, [1, 0]
   2, 30, [0, 1]
   2, 30, [1.8, 0.2]
   2, 30, [0.2, 1.8]
   2, 30, [0.2]
   # Zooming and Spinning Animations (Animation #3)
   #   parameters: (x_zoom, y_zoom, spin_degrees) or (zoom, spin_degrees)
   3, 20
   3, 40, [1.8, 0.2, 720]
   3, 40, [0.2, 810]
   3, 40, [0.2, 1.8, 720]
   # 3D Spin Animations (Animation #4)
   #   parameters: (zoom, num_rotations)
   4, 40
   4, 40, [0, 4]
   4, 40, [0.5, 6]
   4, 30, [0.7, 2]
   # Slide-In Animations (Animation #5)
   #   parameters: (slide_direction)
   5, 24
   5, 24, [-1]
   # Fold Animations (Animation #6)
   #   parameters: none
   6, 30
   # Shaking Animations (Animation #7)
   #   parameters: (x_strength, x_speed, y_strength, y_speed) or (x_intensity, y_intensity)
   7, 40
   7, 40, [6..9, 4..7]
   # Ripple/Distort Animations (Animation #8)
   #   parameters: (x_amplitude, x_wavelength, num_x_ripples, y_amplitude, y_wavelength, num_y_ripples) or (x_amount, num_x_ripples, y_amount, num_y_ripples)
   8, 40
   8, 40, [40, 10, 0.5, 10, 10, 2]
   8, 40, [10, 10, 2, 40, 10, 0.5]
   8, 40, [10, 40, 2, 10, 10, 2]
   8, 40, [10, 10, 2, 10, 40, 2]
   8, 40, [10, 10, 3, 10, 10, 2]
   8, 40, [10, 10, 2, 10, 10, 3]
   8, 10, [10, 40, 0.5, 10, 10, 0.5]
   8, 10, [10, 10, 0.5, 10, 40, 0.5]
   # Dissolve to Sprite Animations (Animation #9)
   #   parameters: (fade_duration)
   #            or (fade_duration, x_size, y_size, negative?, tint_amount,
   #                tint_red, tint_green, tint_blue)
   #            or (fade_duration, x_size, y_size, negative?, tint_amount,
   #                tint_red, tint_green, tint_blue, grayscale_amount)
   #   note - use a float for x_size or y_size to specify it as a fraction
   #     example - 1.0 for the width of the sprite, 0.5 for half the width, and so on
   9, 40
   9, 40, [10, 1.0, 1, false, 50, 200, 50, 50]
   9, 40, [10, 5, 5, true, 50, 100, 200, 200]
   9, 40, [10, 1, 1.0, false, 0, 0, 0, 0, 100]
   # Dissolve Animations (Animation #10)
   10, 40
   10, 40, [1, 1.0]
   10, 40, [5, 5]
   10, 20, [10, 10]
   # Transition Graphic Animations (Animation #11)
   #   parameters: (transition_graphic_name, fade_duration)
   #     fade_duration - how long it takes for each individual pixel of the
   #       sprite to fade out
   11, 100
   11, 40, ['001-Blind01', 5]

And here are those for transitioning the new one in:

     # Fading Animations (Animation #0)
     #   parameters: none
     0, 20
     0, 30
     # Zooming Animations (Animation #1)
     #   parameters: (x_zoom, y_zoom) or (zoom)
     1, 30
     1, 20, [1.2]
     1, 30, [1, 0]
     1, 30, [0, 1]
     1, 30, [1.8, 0.2]
     1, 30, [0.2, 1.8]
     1, 30, [0.2]
     # Zooming and Spinning Animations (Animation #2)
     #   parameters: (x_zoom, y_zoom, spin_degrees) or (zoom, spin_degrees)
     2, 20
     2, 40, [1.8, 0.2, 720]
     2, 40, [0.2, 810]
     2, 40, [0.2, 1.8, 720]
     # 3D Spin Animations (Animation #3)
     #   parameters: (horizontal?, zoom, num_rotations)
     3, 40
     3, 40, [true, 0, 4]
     3, 40, [true, 0.5, 6]
     3, 30, [true, 0.7, 2]
     # Shaking Animations (Animation #6)
     #   parameters: (x_strength, x_speed, y_strength, y_speed) or (x_intensity, y_intensity)
     6, 40
     6, 40, [6..9, 4..7]
     # Transition Graphic Animations (Animation #7)
     #   parameters: (transition_graphic_name, fade_duration)
     #     fade_duration - how long it takes for each individual pixel of the
     #       sprite to fade out
     7, 100
     7, 40, ['001-Blind01', 5]
14
Saving and loading custom data structures from files in c++ is a lot more difficult than in ruby (especially if you want them to be readable from ruby). I was pretty sure that there was a library for c++ to save and load files made with Marshal.dump. However, I don't remember the name of it at the moment. My advice would be to create a custom file format for the different types of data you need to manipulate and create loading and saving methods in c++ and ruby.
15
Code: ruby

  def main
    # Make command window
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = journal_switch ? 'Journal' : '????' #<--- name used here
    s5 = "Save"
    s6 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    @command_window.disable_item(3) unless journal_switch
  ...
16
RPG Maker Scripts / Re: I made a DLL! Now what?
May 03, 2014, 07:13:21 pm
If anyone is interested, to pass arrays to a dll, you simply create a ruby array, and call the pack method to pack it into something that can be passed to a win32api method. Ex.
Code: ruby
Array.new(10) { 0.0 }.pack("f*")

When receiving an array value in the dll, you take it in as a pointer to whatever type you are sending in. For example, for the array from the ruby example, the cpp type would be
Code: cpp
float*



Also, for passing bitmaps, you simply pass
Code: ruby
bmp.__id__

If you left shift this value after it is passed into the dll, you get a pointer to a windows bitmap that is defined by the following structure:
Code: cpp

typedef struct {
   DWORD flags;
   DWORD klass;
   void (*dmark) (void*);
   void (*dfree) (void*);
   double *data; //red is index 1, green is index 2, blue 3, alpha 0
} RGSSCOLOR;

typedef struct{
   DWORD unk1;
   DWORD unk2;
   BITMAPINFOHEADER *infoheader;
   RGSSCOLOR *firstRow;
   RGBQUAD *lastRow;
} RGSSBMINFO;

typedef struct{
   DWORD unk1;
   DWORD unk2;
   RGSSBMINFO *bminfo;
} BITMAPSTRUCT;

typedef struct{
   DWORD flags;
   DWORD klass;
   void (*dmark) (void*);
   void (*dfree) (void*);
   BITMAPSTRUCT *bm;
} RGSSBITMAP;


Edit - Oops, most of this is completely covered by KK20's links.
17
what other scripts are you using? I can't find any issues in the demo.
18
It seems that the demo link is broken. Could you post the script so i could look into the problem?
19
New Projects / Re: Spawn of Darkness
April 19, 2014, 12:09:51 am
Well, I haven't posted here in ages. I just got back in the game-making spirit again, and started back up working on this project. However, I still have lots of trouble with storyline stuff and all that, so basically over the past few years I've gotten done some of the more technical balancing work. I completely redid the story: the main post will be updated with the new information shortly. However, what I feel is the only thing that I really accomplished over this time is finishing creating a tree of elemental skills, all with cool particle animations. These animations include some of Mascarpone and Zekanillos' best animations. I am now in the process of creating custom icons for each of the skills. If anyone would like to check the animations out, a link should be up shortly to download a file containing the animations set up in a project (my internet sucks so it's taking forever to upload).

Edit - Here is a project with all the animations from my game, organized into the tiers and elements.
20
Script Troubleshooting / Re: [XP] Blizzard's bestiary
January 04, 2014, 12:28:27 pm
also, on entry 10 you have the period outside of the quotes. that could be causing the syntax error on line 547