[XP] Heretic's Collection of Art and 100% Compatible Scripts

Started by Heretic86, November 26, 2013, 09:22:35 am

Previous topic - Next topic

Heretic86

Updated

Added 3 Scripts:

Unlimited Battle Event Page Conditions (Should work with most Page Based Battle Systems, like the Default)
Animation Speed (for Events, Stepping Speed)
Dynamic Lighting Effects - kellessdee

Each script added has a Demo

Battle System Updated, a few minor bugfixes, Bonus Exp, Gold and Items, and set to allow Post Battle Event Pages.  Not too much else has changed.

Version Incompatability:  Just edit the INI file to match your installed version.  1.02 or 1.04

---

Does anyone have any Art, Music or Scripts they'd like to have included with this package?
(Please be reasonable, I cant include incompatible scripts, like alternate Battle Systems)
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.)

Simon Greedwell

Sorry for the necroposting but I've got a problem with the XRXS ATB Battle System. I kept running into an error when the battle party consists of less than 4 members:

Script: 'ATB: Aliases and redefinitions' line 136:NoMethodError Occurred

undefined method 'damage' for nil:NillClass.


Bury with my...money!

Heretic86

Quote from: Simon Greedwell on May 22, 2014, 09:39:25 pm
Sorry for the necroposting but I've got a problem with the XRXS ATB Battle System. I kept running into an error when the battle party consists of less than 4 members:

Script: 'ATB: Aliases and redefinitions' line 136:NoMethodError Occurred

undefined method 'damage' for nil:NillClass.





Okay, I'll take a look.  I have more updates for it anyway (new script features).  Doing anything out of the ordinary when the crash occurs?  Script calls or Evented Battle?  

Quick fix: change that line to read:
    if @battler and @battler.damage == ""


Please let me know if any other bugs.
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.)

Heretic86

UPDATED

Update includes the above mentioned Bugfix.

Updated Cloud Altitude to fix a bug where changing a Scene (Battle or Menu) would cause Game Guy's Unlimited Fogs to disappear.  Note: Fix itself is a little glitchy.

Added Animated Battlers -  Nothing really too fancy, just a very early version of a script that allows Enemies to have a "Step" Animation.  Available as a Standalone Script for animating Front View Battlers.  Expect Bugs.

Added feature to Target Anyone Undead so that a State of Zombie will now cause Heals to harm whoever has the State applied.

NPC's added to demonstrate each new feature, so there are two new NPC's on the Battle System map.
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.)

Simon Greedwell

Quote from: Heretic86 on May 23, 2014, 03:52:04 am
Quote from: Simon Greedwell on May 22, 2014, 09:39:25 pm
Sorry for the necroposting but I've got a problem with the XRXS ATB Battle System. I kept running into an error when the battle party consists of less than 4 members:

Script: 'ATB: Aliases and redefinitions' line 136:NoMethodError Occurred

undefined method 'damage' for nil:NillClass.





Okay, I'll take a look.  I have more updates for it anyway (new script features).  Doing anything out of the ordinary when the crash occurs?  Script calls or Evented Battle? 

Quick fix: change that line to read:
    if @battler and @battler.damage == ""


Please let me know if any other bugs.


I tested it and that seemed to do the trick. Thanks.

I've ran into some incompatibility problems. nothing game-breaking though. I fixed them by rearranging the other scripts I used i.e putting MOG's Damage and Collapse scripts above the RXS ATB Battle System scripts.

Also, there's this thing when using Dargor's large party script that causes the battle scene to switch between the first row (the first 4 battlers) and the second row (the other 4 battlers) constantly. I assumed that's an inevitable thing, seeing how both scripts work.
Bury with my...money!

Heretic86

MASSIVE UPDATE

I'm bumping this up to Release and removing from Beta, which it has been sitting in for a long time.  Mods, if you wouldn't mind adding to the Script Database

Update Includes:
- Nine different Modular Passable scripts, including VEHICLES!  (Boat and Magic Carpet at this time, thats all I have Graphics for)
- Each Modular Passable script has tremendous power.
- Added VX Ace Battle Backgrounds in XP script

DEMO
http://downloads.chaos-project.com/heretic86/HereticsCollectionVer2.exe
(thank you Blizz for hosting this for me!)

So here is a screenshot of the Caterpillar boarding an RPG Maker XP style Vehicle!

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.)

Heretic86

Standard bump.

I plan in putting out an update for the Collection shortly, with a few very minor bugfixes, a touch of more functionality, but more importantly, an example of how to allow Boats to dock on ANY shoreline.  Landing Boats on Shore Tiles works just fine with the previous release, I just never created an example of how to do it so people could use it as a Template to build on.  Its mostly just an Eventing Update with very minor bugfixes in a few scripts.

Edit:  Updated.  The Vehicles Map now links to another map where you can park your Boat on shore tiles, not just docks.  Its just eventing so no reason to grab this update.  Two other script updates for Downhill Ice, fixed a fatal error with an improperly nested if statement, and fixed a Visual Glitch in Magic Compass where the graphic was not initialized to the screen tone. 
End Edit.

This does come with some GOOD NEWS / BAD NEWS.  

I finally got what hopefully will be meaningful work instead of these crap jobs that never last long, but this comes at the price of me having to put Scripting down for a while.  Probably at least until I get settled in.  So I'll have to put new scripts on the backburner for a while.  I wanted to do a Damage Tiles script that would compliment the Hotfoot Tiles script, and possibly Moving Platforms, but i wont be able to do these right away.  So I also have to say sorry that I cant do any Script or Feature Requests right now, but will do my best to offer support for what I have released.

One thing I did want to ask everyone is about everything that is in this collection?  How useful are the Vehicles scripts are to you?  How about Modular Passable?  Any conflicts?  Are these scripts useful to you?  All of the Visual Effects?  I've only received a very very minimal level of feedback on this release even though it was posted on several sites.  

So, would you guys care to give me a bit of FEEDBACK?
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.)

Loveless

I'm extremely late on this. I'll dl and give you some feedback later today or tomorrow.

ThallionDarkshine

May 28, 2015, 04:24:56 pm #48 Last Edit: May 28, 2015, 05:14:55 pm by ThallionDarkshine
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.

Heretic86

Is that the version of the script you want updated in the collection?
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

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.

Heretic86

Im gonna hold off a bit before publishing with this.  I ran a few tests and theres a few things that need to be done.  Nothing too major tho. 

First minor thing I noticed was use of 'alias_method'.  Hitting F12 causes a stack level too deep crash.  Easy fix tho, just put 'unless $@' at the end of each alias_method call.  Just three of them.

Next one is transfer_player replacement.  I see why it had to be replaced, but due to other aliases, I think there might be another way to do this.

alias transpack_transfer_player transfer_player unless $@
def transfer_player
  if $game_temp.transition_type != -1
    (your code with $scene = Transition.new($scene) )
    # Prevent two transitions
    return
  end
  # Old code with Graphics.transition(20)
  transpack_transfer_player
end



There might be another way to do this also, so any feedback from anyone would be appreciated.

From a quick test, everything else seems to work pretty well.  Needs to be really close to main.  Just those two minor issues and I'll publish with the updated code.  Loading a save game causes a crash, so need to either start a new game or change code to set a default value when the variable is nil.  Transitions arent called every frame so you could use a getter method for transition_type with '@transition_type ||= 0' so no peformance hits there.

Side note: a couple of weeks ago, I was trying to get this working on the XP Ace project, and had a few issues that were also easy fixes in Event Transitions Module.  The fix there was to change all the 'when' statements with following colons to remove the colons.  IE, change 'when 1:' to just 'when 1' and Event Transitions works on XP Ace.  Not sure if I'll have time to test the Transitions Pack (not Event Transtions) on XP Ace.  Been hella busy lately.  Few minor things and we will be good to go!

Im definitely quite impressed with this script and am looking forward to plugging into the collection!  Fantastic work!
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.)

G_G

Or instead of modifying the alias methods, you could just put this at the top of your game.

if $game_exists
  Thread.new {system('Game')}
  exit
end
$game_exists = true

Heretic86

Quote from: gameus on June 04, 2015, 12:27:28 pm
Or instead of modifying the alias methods, you could just put this at the top of your game.

if $game_exists
 Thread.new {system('Game')}
 exit
end
$game_exists = true



I know about the F12 Fix.  Its the first script, but I have it commented out cuz its annoying while editing when it conflicts with full screen scripts.

I'll probably upload a minor update this weekend sometime with Thallions Transition Pack, but I have to put together a small demo for 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.)

Heretic86

Updated.  New version includes Thallions Transition Pack script as well as a brief demo.

I made a couple of minor changes to the script to fix F12 crash (just added 'unless $@' to alias calls) and several $game_system options so you can turn on or off Transitions during gameplay.  There was one compatability issue with a method that fully replaced transfer_player that I also fixed.  I just aliased transfer_player and called to the original or other aliases when the Map Transitions are disabled. 

No other changes made to any other scripts.
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.)

Helios

Hi Heretic

I added your "Pathfind (by ForeverZer0)" + "Super Event Sensor" + "Control Self Switches Anywhere" + "More Self-Switches - Gameus" (in that script order, And fixed Command 355 already) into my game, and copied one of your template enemy into my debug map to test it. I replaced the "fade event" part with manual opacity change so I omitted the "Fade Events or Heretic's Caterpillar" part.

When I walk into the sight of that enemy, the game crashes with Pathfind (by ForeverZer0) at line 201: Undefined method "original_move_route".

I removed every other custom script I added, leaving only those scripts I copied from your demo, and the error persists, so conflicting script is unlikely.

Some help please?

Heretic86

Try adding this code in as its own script:

class Game_Character
  attr_accessor :original_move_route
end

Let me know if that doesnt fix 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.)

Helios

Quote from: Heretic86 on June 26, 2015, 05:41:22 am
Try adding this code in as its own script:

class Game_Character
  attr_accessor :original_move_route
end

Let me know if that doesnt fix it.


Yep, that did it. Thanks for your timely help!

EDIT: yet another crash:

I put your fix below Pathfind by ForeverZer0 (also added attr_accessor :original_move_route_index to fix another related crash), and added Lagless Path Finder 1.22 below it since your demo enemies use it.
Then I modified the patrol route of an enemy, copied from the demo.

When the enemy reached his first waypoint, the game crashed:
Pathfind (by ForeverZer0)
Line 693 NoMethod error undefined method [] for nil:NilClass.

The game also crash when the enemy run into walls (seemingly failed to find his way):
Line 802 NoMethod error undefined method [] for nil:NilClass.

The previous test with another enemy worked, but his route is relatively simple (walking in a small square, no obstacles).
This one is a bit longer and mostly diagonal: moving from 55,64 to 22,22 with some walls in the way.

Heretic86

And youre not going over Stairs or Downhill Ice, right?  All pathfinders have problems with stairs and ice.

I had a little better luck with Blizz's Pathfinder since his also includes Waypoints, but that was a change I tried to put into F0's pathfinder with minimal success.  Both scripts play nice with each other (no conflicts) so if one or the other works better for you, just use that one.  The three Mercenaries on the Crumbling King quest use Blizz Pathfind commands as examples.
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.)

RedHorse

Spoiler: ShowHide


this is what i get, the project don't start and crashes, can you please help me?