The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on October 29, 2009, 02:58:39 PM

Title: Change Battle Transition
Post by: modern algebra on October 29, 2009, 02:58:39 PM
Change Battle Transition
Version: 1.0
Author: modern algebra
Date: October 29, 2009

Version History



Description


This script allows you to change the transition graphic in-game, so you can have multiple different transitions and can even randomize between them.

Features


Instructions

Place this script into the editor above Main and above any other scripts that modify the perform_battle_transition method of Scene_Map. All transition graphics you want to use MUST be in the System folder of Graphics.

For instructions on how to change the battle transitions in-game, see the header and editable regions.

Script


Code: [Select]
#==============================================================================
#    Change Battle Transition
#    Version: 1.0
#    Author: modern algebra
#    Date: October 29, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to change the transition graphic in-game, so you
#   can have multiple different transitions and can even randomize between them
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script into the editor above Main and above any other scripts
#   that modify the perform_battle_transition method of Scene_Map. All
#   transition graphics you want to use MUST be in the System folder of
#   Graphics.
#
#    To change the battle transition, use this code in a call script event
#   command:
#
#      change_battle_transition (new_transition)
#        new_transition : either the name of the file in quotations, or the ID
#          of the graphic as it appears in the TRANSITIONS_ARRAY constant,
#          which can be configured below at line 46. If you set it to a
#          negative number, then it will select a graphic randomly from the
#          TRANSITIONS_ARRAY.
#
#    By default, the battle_transition is set to -1, meaning that it will
#   randomize between the elements of TRANSITIONS_ARRAY
#==============================================================================

#==============================================================================
# ** Game System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constant - TRANSITIONS_ARRAY
#    new accessor variable - battle_transition
#    aliased method - initialize
#==============================================================================

class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Constant
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #  EDITABLE REGION
  #  
  #    TRANSITIONS_ARRAY holds the names of transitions graphics so they can
  #   be accessed by ID. The primary purpose of it is for when you want to
  #   randomize the transition to be chosen, but it can also be useful for
  #   identifying battle transitions simply by ID rather than remembering the
  #   exact name when wanting to change it.
  #
  #    To set it up, simply list them in the array like so:
  #      TRANSITIONS_ARRAY = ["trans 1", "trans 2", ..., "trans n"]
  #    They do not have to have a naming scheme. To be included in this
  #   array is sufficient.
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  TRANSITIONS_ARRAY = ["BattleStart"]
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #  END EDITABLE REGION
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_writer   :battle_transition # The ID of the battle transition
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mara_chngbtltrans_init_9ij3 initialize
  def initialize (*args)
    @battle_transition = -1
    # Run Original Method
    mara_chngbtltrans_init_9ij3 (*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Battle Transition
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def battle_transition
    return @battle_transition if @battle_transition.is_a? (String)
    return TRANSITIONS_ARRAY[@battle_transition] if @battle_transition.between? (0, TRANSITIONS_ARRAY.size - 1)
    return TRANSITIONS_ARRAY[rand(TRANSITIONS_ARRAY.size)]
  end
end

#==============================================================================
# ** Game Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - change_battle_transition
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Change Battle Transition
  #    new_transition : the name or ID of a transition
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def change_battle_transition (new_transition = -1)
    $game_system.battle_transition = new_transition
  end
end

#==============================================================================
# ** Scene Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - perform_battle_transition
#==============================================================================

class Scene_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Execute Pre-battle Transition
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def perform_battle_transition
    Graphics.transition(80, "Graphics/System/#{$game_system.battle_transition}", 80)
    Graphics.freeze
  end
end

Credit



Support


Please post in this topic at rmrk.net if you encounter any problems or have suggestions for improvement. Do not PM me.

Known Compatibility Issues

It overwrites the perform_battle_transition method of Scene_Map, which could potentially cause problems with other scripts. If you run into a problem, try placing this script above the problematic scripts and that will fix it as long as the other scripts alias and do not overwrite that method. Otherwise, contact me with the other script and I will get them to work together.

Demo


A demo would be an insult to your intelligence, or else an insult to my explanation skills.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Change Battle Transition
Post by: Skyselarke on May 29, 2010, 02:25:44 PM
Where can I find transitions that will work with RMVX?
Title: Re: Change Battle Transition
Post by: modern algebra on May 29, 2010, 03:06:48 PM
XP transitions will work with VX, just resize them. Also: http://www.rpgmakervx.net/index.php?showtopic=30118
Title: Re: Change Battle Transition
Post by: Skyselarke on May 29, 2010, 04:40:46 PM
k, Thanks a bunch I'll check it out.  Also, I've been having problems posting and sending messages on here so I was just wondering if you got the 2 I sent ya.
Title: Re: Change Battle Transition
Post by: modern algebra on May 29, 2010, 09:09:17 PM
yeah, I did. I will try to respond to them if I get the time.
Title: Re: Change Battle Transition
Post by: Skyselarke on May 29, 2010, 10:32:07 PM
ok, no problem waiting, just wasn't sure if they were getting through..
Title: Re: Change Battle Transition
Post by: Reggie-Cliff on June 13, 2011, 05:29:14 AM
 8) I love this script, But is there a way to: create my own transition? and I got a slew of other question's that can be scripted but are for the script geniuses.
    I'm a check this when I come home later from college, But you are an awesome scriptor....
Title: Re: Change Battle Transition
Post by: modern algebra on June 13, 2011, 10:03:48 AM
Sure, you can create your own transitions as long as you're graphically inclined. For instance, mitch has made some good ones: http://www.rpgmakervx.net/index.php?showtopic=30118

Title: Re: Change Battle Transition
Post by: Mitsarugi on March 03, 2012, 10:33:33 PM
Sure, you can create your own transitions as long as you're graphically inclined. For instance, mitch has made some good ones: http://www.rpgmakervx.net/index.php?showtopic=30118
Modern Algebra could you change this script so that it works for map transfers to please?
i would like a transition when changing maps , not just the same old fade in/out.

EDIT: nvm found it
Spoiler for:
Code: [Select]
#===============================================================================
#                 RAFAEL_SOL_MAKER's VX TRANSITION SET v1.1
#-------------------------------------------------------------------------------
# Description:   With this script you can use a set of multiple
#                customized transitions in the teleport, or at the beginning or
#                end of battles. You can configure in and out transitions, and a
#                total of six different transitions that can be used. To change
#                the transition graphic in-game use the command:
#               
#                  set_transition (transition, filename)
#
#                Where 'transition' accepts the following values: MAP_IN,
#                MAP_OUT, BATTLE_IN, BATTLE_OUT, BATTLE_END_IN, BATTLE_END_OUT;
#                And 'filename' is the name of the bitmap used for transition,
#                which should be in the folder 'Graphics/Transitions/'.
#                If you prefer to use the fade effect instead, just use a blank
#                filename, a empty quote: "" (can be single or double);
#
#                  set_transition_wait (duration)
#
#                To set the transition's delay time, in frames.
#   
#                OBS.: Also uses a teleport sound effect that can be configured
#                by Sound module. The settings and default values can be found
#                in the configurable module.           
#-------------------------------------------------------------------------------
# How to Use: -
#-------------------------------------------------------------------------------
# Special Thanks: Angel Ivy-chan
#-------------------------------------------------------------------------------
#===============================================================================

module PowerPackVX_General_Configs 
  # TRANSITION BETWEEN THE SCENES
  Transition_In =  'Blind02'    # Map Transition (in)
  Transition_Out = 'Blind02'    # Map Transition (out)
  Battle_In =      'Blind03'    # Battle Transition (in)
  Battle_Out =     'Blind03'    # Battle Transition (out)
  Battle_End_In =  'Blind04'    # Battle End Transition (in)
  Battle_End_Out = 'Blind04'    # Battle End Transition (out) 
  Transition_Wait = 60          # Transition Delay, in Frames 
end

module Cache 
  # Preparation of Transitions in Cache
  def self.transition(filename)
    load_bitmap('Graphics/Transitions/', filename)
  end 
end

module Sound 
  # Teleport's Sound Effect
  def self.play_teleport
    Audio.se_play('Audio/SE/Run', 25, 50)
  end
end

class Game_Interpreter
include PowerPackVX_General_Configs

  MAP_IN =    1       #Transition: Map In
  MAP_OUT =    2      #Transition: Map Out
  BATTLE_IN =   3     #Transition: Battle In
  BATTLE_OUT =   4    #Transition: Battle Out
  BATTLE_END_IN = 5   #Transition: End of Battle In
  BATTLE_END_OUT = 6  #Transition: End of Battle Out
 
  #--------------------------------------------------------------------------
  # Change Transitions Between Scenes
  #-------------------------------------------------------------------------- 
  def set_transition (transition = MAP_IN, filename = '')
    # Selects which transition will be changed
    case transition
      when MAP_IN
        $game_system.map_in = filename
        when MAP_OUT
        $game_system.map_out = filename
      when BATTLE_IN
        $game_system.battle_in = filename
      when BATTLE_OUT
        $game_system.battle_out = filename
      when BATTLE_END_IN
        $game_system.battle_end_in = filename
      when BATTLE_END_OUT
        $game_system.battle_end_out = filename
    end
  end
 
  #--------------------------------------------------------------------------
  # Change the Transition Delay
  #--------------------------------------------------------------------------
  def set_transition_wait (duration = 45)
    $game_system.transition_wait = duration
  end
 
end

class Game_System
include PowerPackVX_General_Configs

  attr_accessor :map_in
  attr_accessor :map_out   
  attr_accessor :battle_in
  attr_accessor :battle_out 
  attr_accessor :battle_end_in
  attr_accessor :battle_end_out 
  attr_accessor :transition_wait
 
  alias solmaker_transition_initialize initialize unless $@
  def initialize
    solmaker_transition_initialize
    load_transitions     
  end
 
  def load_transitions
    @map_in = Transition_In
    @map_out = Transition_Out
    @battle_in  = Battle_In
    @battle_out = Battle_Out
    @battle_end_in  = Battle_End_In
    @battle_end_out = Battle_End_Out
    @transition_wait = Transition_Wait
  end
 
end

class Scene_Map

  def perform_transition
    if Graphics.brightness == 0
      if $game_temp.in_battle == true     
        $game_temp.in_battle = false
        Graphics.freeze
        Graphics.brightness = 255
        filename = ""
        if $game_system.battle_end_in != ""
          filename = 'Graphics/Transitions/' + $game_system.battle_end_in
        end 
        Graphics.transition($game_system.transition_wait, filename) 
      else
        fadein(30) 
      end
    else                             
      Graphics.transition(15)
    end
  end

  def update_transfer_player   
    return unless $game_player.transfer? 
    Sound.play_teleport;
    Graphics.freeze; @spriteset.dispose   
    $game_player.perform_transfer; $game_map.autoplay; $game_map.update
    filename = ""
    if $game_system.map_out != ""
      filename = 'Graphics/Transitions/' + $game_system.map_out
    end
    Graphics.transition($game_system.transition_wait, filename)
    Input.update; Graphics.freeze; @spriteset = Spriteset_Map.new 
    filename = ""
    if $game_system.map_in != ""
      filename = 'Graphics/Transitions/' + $game_system.map_in
    end
    Graphics.transition($game_system.transition_wait, filename)
  end   
   
  def perform_battle_transition   
    filename = ""
    if $game_system.battle_out != ""
      filename = 'Graphics/Transitions/'+ $game_system.battle_out
    end
    Graphics.transition($game_system.transition_wait, filename)
    Graphics.freeze     
  end   

end

class Scene_Battle < Scene_Base

  def perform_transition
    filename = ""
    if $game_system.battle_in != ""
      filename = 'Graphics/Transitions/'+ $game_system.battle_in
    end
    Graphics.transition($game_system.transition_wait, filename)
  end 

  def battle_end(result)
    if result == 2 and not $game_troop.can_lose
      call_gameover
      $game_temp.in_battle = false
    else
      $game_party.clear_actions
      $game_party.remove_states_battle
      $game_troop.clear
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call(result)
        $game_temp.battle_proc = nil
      end     
      @message_window.clear
      Graphics.freeze
      @message_window.visible = false
      @spriteset.dispose
      filename = ""
      if $game_system.battle_end_out != ""
        filename = 'Graphics/Transitions/' + $game_system.battle_end_out
      end   
      Graphics.transition($game_system.transition_wait, filename)
      unless $BTEST
        $game_temp.map_bgm.play
        $game_temp.map_bgs.play
      end
      $scene = Scene_Map.new
      Graphics.brightness = 0     
    end
  end
 
end