The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: LoganF on December 10, 2011, 11:22:00 AM

Title: Special Transfers
Post by: LoganF on December 10, 2011, 11:22:00 AM
Special Transfers
Version: 0.1
Author: Logan Forrests
Date: December 10, 2011

Version History



Planned Future Versions

The main purpose was to create instant transitions between one map and another. Thus, nothing is planned, as such. However, I'll likely add more transition effects at some point (thus why it's a version 0.1).

Description


By using a script call in the desired transfer event's commands list, you can change the transition effect.

Features


Instructions

Details can be found in the script under Description.

All that is required is to create a Script call within the transfer event calling the appropriate method.

Graphics used as part of the transition effect should be placed in the Graphics\Pictures folder.

Script


Code: [Select]
#==========================================================================
#   Special Transfers
#
#   Author : Logan Forrests
#
#   Date Created   : 10 December 2011
#   Date Finished  : 10 December 2011
#   Last Updated   : 10 December 2011
#   Latest Version : 1.0
#
# Use of this script requires that you provide credit to the above author(s).
#--------------------------------------------------------------------------
# Version History
#--------------------------------------------------------------------------
#
#   v1.0  - 11.10.2011
#       Original release of the script
#
#--------------------------------------------------------------------------
# Description
#--------------------------------------------------------------------------
# By using a script call in the desired transfer event's commands list, you
# can change the transition effect.
#
# Note: No script call will cause the default fade out/fade in screen
#       transition.
#
#   special_transfer([duration[, filename[, vague]]])
#
#   - Allows the transition to occur over a period of frames. No values are
#     necessary if you are happy with the defaults.
#       - duration: number of frames between start and end of the
#                   transition. Default is 30 (1/2 second).
#       - filename: the graphic to use in the transition. The graphic must be
#                   located in the Graphics\Pictures folder of the game.
#                   Default is no graphic.
#       - vague   : sets the ambiguity of the borderline between the graphic's
#                   starting and ending points. The larger the value, the
#                   greater the ambiguity. Default is 40.
#
#   instant_transfer
#
#   - This will perform an instant transition, much like you can do in RMXP.
#   - It actually calls special_transfer with 0 duration meaning it will take
#     0 seconds to transition.
#
#--------------------------------------------------------------------------
# Script Installation
#--------------------------------------------------------------------------
#
# Simply place the script in the Materials section of the Script Editor.
#
#--------------------------------------------------------------------------
# Support
#--------------------------------------------------------------------------
# The script has been written and tested with no other scripts in place.
#
# Should you encounter any issues once this script has been installed, there
# are a number of things you can do:
#
#  - Shift your scripts around: sometimes it's a conflict with other scripts
#    whose properties have not yet been initialized.
#  - Make a new project, add this script first and then add other scripts in
#    one by one running Test Play after adding each script. Make a note of
#    which script you added last. This is likely the conflicting culprit.
#
# If you have success in identifying the script that may be causing a problem,
# or you have had no success in fixing the issue(s), feel free to make contact
# on rmrk.net where I usually hang around or make a post on the relevant
# thread.
# Please provide as much information as you can if you do need support.
# The more info, the quicker I can figure out a fix.
#==========================================================================

class Game_Interpreter

  # Next Transfer is Instant
  #   Calls special_transfer with arguments 0 (frames) and "" (no filename)
  def instant_transfer
    special_transfer(0, "")
  end
 
  # Special Transfer
  #   Sets a special transfer lasting a specified amount of frames.
  #   Can also set a file graphic to be displayed and a vague value (see Help
  #    topic for "Graphics" under "transition" for more information)
  def special_transfer(duration=30, filename="", vague=40)
    $game_temp.it_special_transfer = true
    $game_temp.it_transition_duration = duration
    $game_temp.it_transition_filename = filename
    $game_temp.it_transition_vague = vague
  end
   
end


class Game_Temp
 
  attr_accessor :it_special_transfer       #when true, perform instant transfer
  attr_accessor :it_transition_duration #length of trasition in frames
  attr_accessor :it_transition_filename #filename for transition graphic
  attr_accessor :it_transition_vague    #transition graphic vague ambiguity value

  alias :lfit_init_aj1f :initialize
  def initialize(*args)
    #do original
    lfit_init_aj1f(*args)
    #set new defaults
    lfit_defaults
  end
 
  #Sets the default values of the required script variables
  def lfit_defaults
    @it_special_transfer = false
    @it_transition_duration = 8   #set as Graphics.transition default: Do Not Edit
    @it_transition_filename = ""#set as Graphics.transition default: Do Not Edit
    @it_transition_vague = 40   #set as Graphics.transition default: Do Not Edit
  end
 
end


#Alias: update_transfer_player
class Scene_Map
 
  alias :lfit_updtransplay_wa9v :update_transfer_player
  def update_transfer_player(*args)   
    return unless $game_player.transfer?
    if $game_temp.it_special_transfer == false
      #run original
      lfit_updtransplay_wa9v(*args)
    else
      #do instant transfer
      Graphics.freeze
      @spriteset.dispose              # Dispose of sprite set
      $game_player.perform_transfer   # Execute player transfer
      $game_map.autoplay              # Automatically switch BGM and BGS
      $game_map.update
      @spriteset = Spriteset_Map.new  # Recreate sprite set
      duration = $game_temp.it_transition_duration
      filename = $game_temp.it_transition_filename
      if filename != ""
        filename = "Graphics\\Pictures\\" + $game_temp.it_transition_filename
      end
      vague = $game_temp.it_transition_vague
      Graphics.transition(duration, filename, vague)
      Input.update
    end
    #reset values
    $game_temp.lfit_defaults
  end
 
end

Credit



Support


This thread is the best point of contact for support. Please put as much info as possible in your post.

Known Compatibility Issues

None known.

This script aliases Scene_Map#update_transfer_player.

If the original update_transfer_player has been changed, the default transfer transition effect may not work as it would normally work. Also, if Graphics.transition has been overwritten, there may be issues with that. But since Graphics is a hidden module, it shouldn't be a commonly touched method.

Demo


No demo exists as it should be fairly easy to use.

Author's Notes


I wrote this up quickly to play around with an idea I have involving maps that have instant or near-instant transition effects. It could be done in RMXP but was taken out in VX. So, this script also adds as a way to introduce that process to VX.

Restrictions

Only that my name (LoganForrests) should remain in the script. Other than that, use it as you will. Feel free to expand what this script does and I'll update the OP accordingly.
Title: Re: Special Transfers
Post by: yuyu! on December 10, 2011, 10:04:04 PM
I'm loving that instant transfer. I can see how this could be used to make a map appear like it has changed drastically with a simple instant transfer command!

Awesome script! Great job, Logan! :)
Title: Re: Special Transfers
Post by: Dr. Mc on December 11, 2011, 07:08:38 AM
Wow, cool script! It's easy to use too, great job! :D