The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on July 12, 2010, 09:42:22 PM

Title: Override Change BGM/ME
Post by: modern algebra on July 12, 2010, 09:42:22 PM
Override Change BGM/ME
Version: 1.0
Author: modern algebra
Date: July 12, 2010

Version History



Description


This script will override the BGM or ME changes when you activate chosen switches. This is useful, for instance, if for a boss battle you want to start the battle music early and have it directly continue into the battle or if, for a certain battle where the enemy escapes after the battle, you don't want the Victory ME played.

It will also override bgm and me changes through event commands (since you can always turn the switch off immediately beforehand if you don't want it to apply), but it will not override BGMs or MEs in the Gameover scene, as I figure you would not have the opportunity to turn the switches if actors die in battle.

Features


Instructions

The script is very easy to use. Simply paste it into its own slot above Main and below other default or custom scripts. Then, go to lines 48 and 49 to select which switches you want to use to prevent the BGM from changing or to prevent new MEs from playing, respectively. Then when you want to prevent the BGM from changing, simply turn the switch with the ID you chose on. To allow it to change again, turn that switch off. Same thing for preventing MEs from playing.

Script


Code: [Select]
#==============================================================================
#    Override Change BGM/ME
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: July 12, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script will override the BGM or ME changes when you activate chosen
#   switches. This is useful, for instance, if for a boss battle you want to
#   start the battle music early and have it directly continue into the battle
#   or if, for a certain battle where the enemy escapes after the battle, you
#   don't want the Victory ME played.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#   
#    The script is very easy to use. Simply paste it into its own slot above
#   Main and below other default or custom scripts. Then, go to lines 48 and 49
#   to select which switches you want to use to prevent the BGM from changing
#   or to prevent new MEs from playing, respectively. Then when you want to
#   prevent the BGM from changing, simply turn the switch with the ID you chose
#   on. To allow it to change again, turn that switch off. Same thing for
#   preventing MEs from playing.
#==============================================================================

#==============================================================================
# *** RPG
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constant - OVERRIDE_BGM_SWITCH_ID, OVERRIDE_ME_SWITCH_ID
#    modified class - BGM
#      aliased methods - self.stop, self.fade, play
#    modified class - ME
#      aliased method - play
#==============================================================================

module RPG
  #==========================================================================
  #    Configuration
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  OVERRIDE_BGM_SWITCH_ID - set this to the ID of the switch that you
  #   want to use to prevent the BGM from changing.
  #  OVERRIDE_ME_SWITCH_ID - set this to the ID of the switch that you
  #   want to use to prevent MEs from playing
  #
  #  Note that for both of theses it is the ID of the switch you want to use,
  # so if it is 1, then turning the in-game switch with ID 1 on or off will
  # turn that feature on or off.
  #==========================================================================
  OVERRIDE_BGM_SWITCH_ID = 1
  OVERRIDE_ME_SWITCH_ID = 2
  #==========================================================================
  # ** BGM
  #==========================================================================
  class BGM
    # ALiases
    unless self.method_defined? (:odrna_mscovrde_ply_7uj2)
      class << self
        alias malgr_bgmovrid_stp_5th2 stop
        alias maa_ovrridebgm_fde_2rt9 fade
      end
      alias odrna_mscovrde_ply_7uj2 play
    end
    class << self
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Stop
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def stop (*args)
        malgr_bgmovrid_stp_5th2 (*args) unless $game_switches && $game_switches[OVERRIDE_BGM_SWITCH_ID] && !$scene.is_a? (Scene_Gameover)
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Fade
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def fade (*args)
        maa_ovrridebgm_fde_2rt9 (*args) unless $game_switches && $game_switches[OVERRIDE_BGM_SWITCH_ID] && !$scene.is_a? (Scene_Gameover)
      end
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Play
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def play (*args)
      odrna_mscovrde_ply_7uj2 (*args) unless $game_switches && $game_switches[OVERRIDE_BGM_SWITCH_ID] && !$scene.is_a? (Scene_Gameover)
    end
  end
  #==========================================================================
  # ** ME
  #==========================================================================
  class ME
    # Aliases
    unless self.method_defined? (:modrna_rideme_play_6fv1)
      alias modrna_rideme_play_6fv1 play
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Play
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def play (*args)
      modrna_rideme_play_6fv1 (*args) unless $game_switches && $game_switches[OVERRIDE_ME_SWITCH_ID] && !$scene.is_a? (Scene_Gameover)
    end
  end
end

Credit



Thanks


Support


Please post in this topic at RMRK for support. Do not PM me, as then other people can't benefit from the answers.

Known Compatibility Issues

No known compatibility issues.
Title: Re: Override Change BGM/ME
Post by: raithdemis on March 10, 2011, 02:26:47 AM
when i turn the switch off it still plays the map bgm in battle when i don't want it help me please