#============================================================================== # ** TDS Battle Random BGM # Ver: 1.0 #------------------------------------------------------------------------------ # * Description: # This script allows you to set random BGM to play when the battle starts. #------------------------------------------------------------------------------ # * Features: # Enabling and Disabling Battle Random BGM's. # Setting random BGM's. #------------------------------------------------------------------------------ # * Instructions: # To enable or disable the battle random BGM's used the following in a script # call: # # disable_battle_random_bgm # enable_battle_random_bgm # # (When disabled it will use the default battle BGM) # # # To add a BGM to play randomly when a battle starts use this in a script # call from an event: # # add_random_battle_bgm(Name, Volume, Pitch) # # Name = BGM Filename (Just the name not the directory) # Volume = BGM Volume (0 to 100) (Optional, default is 100) # Pitch = BGM Pitch (50 to 150) (Optional, default is 100) # # Example: # # add_random_battle_bgm("Battle3") or add_random_battle_bgm("Battle3", 80, 50) # # # To remove a BGM from the list of random BGM to play when the battle starts, # use this in a script call from an event: # # remove_random_battle_bgm(Name) # # Name = BGM Filename (Just the name not the directory) # # Example: # # remove_random_battle_bgm("Battle3") #------------------------------------------------------------------------------ # * Notes: # None. #------------------------------------------------------------------------------ # WARNING: # # Do not release, distribute or change my work without my expressed written # consent, doing so violates the terms of use of this work. # # If you really want to share my work please just post a link to the original # site. # # * Not Knowing English or understanding these terms will not excuse you in any # way from the consequenses. #============================================================================== # * Import to Global Hash * #============================================================================== ($imported ||= {})[:TDS_Battle_Random_BGM] = true #============================================================================== # ** TDS #------------------------------------------------------------------------------ # A module containing TDS data structures, mostly script settings. #============================================================================== module TDS #============================================================================ # ** Battle_Random_BGM_Settings #---------------------------------------------------------------------------- # This Module contains battle random BGM settings. #============================================================================ module Battle_Random_BGM_Settings #-------------------------------------------------------------------------- # * Constants (Settings) #-------------------------------------------------------------------------- # Initial list of random battle BGM's (Name, Volume, Pitch) Start_List = [ RPG::BGM.new("Battle1"), RPG::BGM.new("Battle7", 100, 50), RPG::BGM.new("Battle8", 100, 150), ] # If true it will disable random battle BGM's when the game starts Disable_On_Start = false # If true it will allow you to add duplicates to the random battle BGM list Allow_Duplicates = false end end #============================================================================== # ** Game_System #------------------------------------------------------------------------------ # This class handles system data. It saves the disable state of saving and # menus. Instances of this class are referenced by $game_system. #============================================================================== class Game_System #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :battle_random_bgm_disabled # Battle Random BGM Flag attr_accessor :battle_random_bgm_list # Battle Random BGM list #-------------------------------------------------------------------------- # * Alias Listing #-------------------------------------------------------------------------- alias tds_battle_random_bgm_game_system_initialize initialize alias tds_battle_random_bgm_game_system_battle_bgm battle_bgm #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(*args, &block) # Run Original Method tds_battle_random_bgm_game_system_initialize(*args, &block) # Set Battle Random BGM Flag @battle_random_bgm_disabled = TDS::Battle_Random_BGM_Settings::Disable_On_Start # Set Battle Random BGM List @battle_random_bgm_list = TDS::Battle_Random_BGM_Settings::Start_List.dup end #-------------------------------------------------------------------------- # * Get Battle BGM #-------------------------------------------------------------------------- def battle_bgm(*args, &block) # If Using Battle Random BGM return @battle_random_bgm_list.sample if use_battle_random_bgm? # Run Original Method tds_battle_random_bgm_game_system_battle_bgm(*args, &block) end #-------------------------------------------------------------------------- # * Determine if Battle Random BGM's should be used #-------------------------------------------------------------------------- def use_battle_random_bgm? ; !@battle_random_bgm_disabled and !@battle_random_bgm_list.empty? end #-------------------------------------------------------------------------- # * Enable or Disable Battle Random BGM #-------------------------------------------------------------------------- def enable_battle_random_bgm ; @battle_random_bgm_disabled = false end def disable_battle_random_bgm ; @battle_random_bgm_disabled = true end #-------------------------------------------------------------------------- # * Remove Random Battle BGM # name : BGM name #-------------------------------------------------------------------------- def remove_random_battle_bgm(name) ; @battle_random_bgm_list.delete_if {|a| a.name == name} end #-------------------------------------------------------------------------- # * Add Random Battle BGM # name : BGM name #-------------------------------------------------------------------------- def add_random_battle_bgm(name, vol = 100, pitch = 100) # If Duplicates are not allowed in the random BGM list if !TDS::Battle_Random_BGM_Settings::Allow_Duplicates # Return if BGM name is already in list return if @battle_random_bgm_list.any? {|a| a.name == name} end # Add BGM to battle random BGM list @battle_random_bgm_list << RPG::BGM.new(name, vol, pitch) end end #============================================================================== # ** Game_Interpreter #------------------------------------------------------------------------------ # An interpreter for executing event commands. This class is used within the # Game_Map, Game_Troop, and Game_Event classes. #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # * Enable or Disable Battle Random BGM #-------------------------------------------------------------------------- def enable_battle_random_bgm ; $game_system.battle_random_bgm_disabled = false end def disable_battle_random_bgm ; $game_system.battle_random_bgm_disabled = true end #-------------------------------------------------------------------------- # * Remove Random Battle BGM # name : BGM name #-------------------------------------------------------------------------- def remove_random_battle_bgm(name) ; $game_system.remove_random_battle_bgm(name) end #-------------------------------------------------------------------------- # * Add Random Battle BGM # name : BGM name #-------------------------------------------------------------------------- def add_random_battle_bgm(name, vol = 100, pitch = 100) ; $game_system.add_random_battle_bgm(name, vol, pitch) end end