Zerbu 40 Posted January 6, 2012 Toggle Battle BGM Change Introduction This script allows you to enable or disable automatic BGM and BGS change when entering battle. Instructions To turn automatic BGM change on or off: ze_tbbgmc(:change_bgm, true) - change BGM on ze_tbbgmc(:change_bgm, false) - change BGM off To turn automatic BGS change on or off: ze_tbbgmc(:change_bgs, true) - change BGS on ze_tbbgmc(:change_bgs, false) - change BGS off Script #============================================================================ # Zerbu Engine - Toggle Battle BGM Change #---------------------------------------------------------------------------- # This script allows you to enable or disable automatic BGM and BGS change # when entering battle. #---------------------------------------------------------------------------- # To turn automatic BGM change on or off: # ze_tbbgmc(:change_bgm, true) - change BGM on # ze_tbbgmc(:change_bgm, false) - change BGM off #---------------------------------------------------------------------------- # To turn automatic BGS change on or off: # ze_tbbgmc(:change_bgs, true) - change BGS on # ze_tbbgmc(:change_bgs, false) - change BGS off #============================================================================ #============================================================================ # ZE_Toggle_Battle_BGM_Change #============================================================================ class ZE_Toggle_Battle_BGM_Change #-------------------------------------------------------------------------- # new method: initialize #-------------------------------------------------------------------------- def initialize #--- @data = { #---------------------------------------------------------------------- # Options #---------------------------------------------------------------------- # This option will enable or disable automatic BGM change. #---------------------------------------------------------------------- :CHANGE_BGM => true, #---------------------------------------------------------------------- # This option will set whether or not the BGS will stop playing when # entering battle. #---------------------------------------------------------------------- :CHANGE_BGS => true, } #--- end #-------------------------------------------------------------------------- # new method: [] #-------------------------------------------------------------------------- def [](setting) #--- @data[setting] || false #--- end #-------------------------------------------------------------------------- # new method: []= #-------------------------------------------------------------------------- def []=(setting, value) #--- @data[setting] = value #--- end end #============================================================================ # DataManager #============================================================================ module DataManager class << self #------------------------------------------------------------------------ # alias method: create_game_objects #------------------------------------------------------------------------ alias ze_tbbgmc_create_game_objects create_game_objects def create_game_objects #--- ze_tbbgmc_create_game_objects $ze_tbbgmc = ZE_Toggle_Battle_BGM_Change.new #--- end #------------------------------------------------------------------------ # alias method: make_save_contents #------------------------------------------------------------------------ alias ze_tbbgmc_make_save_contents make_save_contents def make_save_contents #--- contents = ze_tbbgmc_make_save_contents contents[:ze_tbbgmc] = $ze_tbbgmc contents #--- end #------------------------------------------------------------------------ # alias method: extract_save_contents #------------------------------------------------------------------------ alias ze_tbbgmc_extract_save_contents extract_save_contents def extract_save_contents(contents) #--- ze_tbbgmc_extract_save_contents(contents) $ze_tbbgmc = contents[:ze_tbbgmc] ? contents[:ze_tbbgmc] : ze_tbbgmc.new #--- end end end #============================================================================ # BattleManager #============================================================================ module BattleManager class << self #-------------------------------------------------------------------------- # overwrite method: play_battle_bgm #-------------------------------------------------------------------------- def play_battle_bgm #--- if $ze_tbbgmc[:CHANGE_BGM] $game_system.battle_bgm.play end #--- if $ze_tbbgmc[:CHANGE_BGS] RPG::BGS.stop end #--- end end end #============================================================================ # Game_Interpreter #============================================================================ class Game_Interpreter #-------------------------------------------------------------------------- # new method: ze_tbbgmc #-------------------------------------------------------------------------- def ze_tbbgmc(setting, value) #--- $ze_tbbgmc[setting.upcase] = value #--- end end Share this post Link to post Share on other sites
Nohta 15 Posted January 7, 2012 Goodbye, BGS workaround! (Translation: Awesome work! Now I don't have to use a BGS to change the music in battle and keep it playing when returning to the map (while hoping my event commands to stop the map BGM in time to prevent weird spots in the music)! You just made my day. ^^) Share this post Link to post Share on other sites
Akane 0 Posted July 20, 2012 (edited) How does this work then? Have I got to do a script call or something? Before battle or in it? Hope you have the time to get back to me, this would be very useful in my game. Edited July 20, 2012 by Akane Share this post Link to post Share on other sites