[XP] Fantasist's Transition Pack Edit

Started by ThallionDarkshine, December 13, 2012, 08:57:14 pm

Previous topic - Next topic

ThallionDarkshine

December 13, 2012, 08:57:14 pm Last Edit: May 28, 2015, 05:16:54 pm by ThallionDarkshine
Transition Pack Edit
Authors: Fantasist, ForeverZero, ThallionDarkshine
Version: 0.22
Type: Transition Script
Key Term: Misc Add-on



Introduction

You know Fantasist's awesome transition pack, allowing you to have really cool transitions. Well, in Chaos Project (the game) I saw that blizz had modified his version of the script to transition directly to the new scene. I modified Fantasist's script, adding a few transitions along with support for showing the new scene in the background.


Features


  • Extra-cool Transitions

  • Show next scene in the background during the transition




Screenshots




Demo

None yet.


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



Instructions

In the script.


Compatibility

None known, except transitions to Scene_Map showing the background won't work because of the way Tilemap is written.


Credits and Thanks


  • Fantasist

  • ForeverZero

  • ThallionDarkshine




Author's Notes

Note, you need this dll for this script to work.

LiTTleDRAgo


Blizzard

December 14, 2012, 02:27:59 am #2 Last Edit: December 14, 2012, 02:31:35 am by Blizzard
Let me try something.

EDIT: I thought the character limit may be a problem (though, I set it to 200k the last if I remember right), but it wasn't. Your Internet connection may have had a hic-up for a moment while you were submitting your post, Thal.
BTW, I gave you 10 levels. You always posts scripts and stuff, but people forget to level you up. :)
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Heretic86

The script appears fragmented.  Well, for me and my shitty browser / computer anyway.

The last thing I get in the code snippet box ends right in the middle of a definition.

  #--------------------------------------------------------------------------
  # * Player Place Move
  #--------------------------------------------------------------------------
  def transfer_player
    # Clear player place move call flag
    $game_temp.


That is the very last line of code that I am able to grab.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ThallionDarkshine

Alright, I fixed it.

@blizz - Thanks, I just looked through all my random test projects and was like, "People might like these scripts"

G_G

Nice job Thallion. Might wanna add a download for the screenshot.dll though. Not everyone has it/knows how to get it. :3 *levels up*

Heretic86

December 14, 2012, 10:46:00 am #6 Last Edit: December 20, 2012, 10:55:38 pm by Heretic86
Quote from: gameus on December 14, 2012, 07:49:31 am
Nice job Thallion. Might wanna add a download for the screenshot.dll though. Not everyone has it/knows how to get it. :3 *levels up*


That would be me.  Need the screenshot.dll link or bundle in a demo.

Screenshot.dll Download Here
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

fenryo

Hope this will not be a necropost. Just want to say thank you

Memor-X

when i was working on Black Core i had to fix up a work around to allow this....ofcause i completely forgot what the hell i did but it's good to have a script which does this for me rather than going though code and looking for what i did and add it in every time

finalholylight

How can I change transition effect during the game, example: when player battles with boss, I changes current transition effect to other transition effect.

Heretic86

Quote from: finalholylight on December 20, 2012, 10:41:40 am
How can I change transition effect during the game, example: when player battles with boss, I changes current transition effect to other transition effect.


Use an Event Script:
Transition::BATTLE_EFFECT=1

Just copy and paste that into your Event Script.  Replace 1 with your desired effect for that boss.  In that same Event, after you call your Battle, you'll probably want to do the same thing and set it back to what you had previously.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ThallionDarkshine

Actually that wouldn't work, seeing as BATTLE_EFFECT is a constant. I actually added that feature in, I just never got around to posting it. I'll put it up in the morning.

Heretic86

It shouldnt work, however Ruby allows constants to be changed on the fly.  There are some stipulations about changing the value of a constant, but for the purposes described here, we might as well consider consts to be the same thing as a variable.  Yeah, it does defeat the purpose of a constant, doesnt it?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ThallionDarkshine

Really. That's weird then, I think I actually tried to do that with one of my other scripts, but couldn't get it to work. Well, anyways, your method's much better that mine.

Heretic86

January 01, 2013, 05:05:47 am #14 Last Edit: January 01, 2013, 04:13:01 pm by Heretic86
I think it may have to do with modules not being frozen, according to ruby-doc.org

There are apparently a few changes I need to make the XRXS rewrite to be compatible with this.  So XRXS Battle isnt working with this script just yet.

So, what would it take to implement some form of "Shatter" transition, I.E. Final Fantasy X?

---

Edit: Found a minor bug.  When the Troop has a Text Command in its Battle Events, @message_window appears during the transition, then fades in again after the transition completes.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ThallionDarkshine

Alright, thanks for pointing that out. I'll try to fix that.

And i have no clue how to make a shatter transition. Can you link to/post a screenie/video of what that would look like?

Heretic86

Quote from: ThallionDarkshine on January 01, 2013, 11:35:56 pm
Alright, thanks for pointing that out. I'll try to fix that.

And i have no clue how to make a shatter transition. Can you link to/post a screenie/video of what that would look like?


I tried taking a crack at that bug when I initially thought it was another compatability issue with the XRXS Battle System, but it wasnt.  For the record, I havent posted the update for XRXS yet, but thats off the point.  What I think is happening is that when main is called, message processing happens which causes @message_window.visible to be set to true, causing the glitch.

As far as the "Shatter" Transition, there is another version for VX, but I guarantee it wont be compatible.

http://rmrk.net/index.php/topic,38589.0.html

Imagine it this way.  You are looking at your screen and it gets hit with something.  The screen breaks into several large glass shards that fall (rotate and move) away.  In the VX link there, the guy that wrote it said he isnt an artist.  He does accomplish the effect, but what his non artistic eye missed is that when things fall away, they accelerate.  I havent read through the transition effect script enough to know how it is pulled off, but you might be able to use an image to create the initial shatter, then treat each "Shard" as a sprite and mess with them falling away.

For a quick reference of Final Fantasy X, watch the first 20 seconds of this video to see what I mean.

http://www.youtube.com/watch?v=MAGW3QmVIcY
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ThallionDarkshine

January 26, 2013, 06:24:46 am #17 Last Edit: May 28, 2015, 04:38:12 pm by ThallionDarkshine
Actually, it wasn't even in main. It was the update method that messed it up. So now I made a module and included it to all the default scenes to override the update method during transitions.

Edit - Update to version 0.21. This update is just a quick bugfix to stop a stack level too deep error when the user enters Scene_Load or Scene_Save.

Edit2 - Update to version 0.22. This update is another quick bugfix to prevent some compatibility errors and an invalid screenshot for any games whose titles contain the '0' character.