#==============================================================================
# ** Multiple BGMS
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2007-04-09
# SDK : Version 2.0+, Parts I & II
#------------------------------------------------------------------------------
# * Version History :
#
# Version 1 ---------------------------------------------------- (2007-04-09)
#------------------------------------------------------------------------------
# * Description :
#
# This script was designed to allow you more than 1 bgm for your map and
# battles. You can define multiple bgms for each map ; defined multiple
# bgms for battle depending on : current map and current troop. You may
# control which of these bgms you include in the final list, including the
# original bgm list you can set in rmxp.
#------------------------------------------------------------------------------
# * Instructions :
#
# Place The Script Below the SDK and Above Main.
#------------------------------------------------------------------------------
# * Customization :
#
# Default Settings
#
# Map BGM - Map Defined (By Map ID)
# - @map_bgm_by_map = { map_id => [ RPG::AudioFile, ... ], ... }
#
# Battle BGM - Map Defined (By Map ID)
# - @battle_bgm_by_map = { map_id => [ RPG::AudioFile, ... ], ... }
#
# Battle BGM - Troop Defined (By Troop ID)
# - @battle_bgm_by_troop = { troop_id => [ RPG::AudioFile, ... ], ... }
#------------------------------------------------------------------------------
# * Syntax :
#
# Battle BGM Include List
# - $game_system.include_multi_bbgms = true or false
# (Includes additional bgms for all)
# - $game_system.include_multi_bbgms_map = true or false
# (Includes additional bgms defined by the map)
# - $game_system.include_multi_bbgms_troop = true or false
# (Includes additional bgms defined by the troop)
# - $game_system.include_datasys_bbgm
# (Includes battle bgm set in database)
# - $game_system.include_gmsys_bbgm
# (Includes battle bgm set with events)
#
# Add multiple BGMS to map list when using event command to change BGM
# - $game_system.add_multi_bbgms = true or false
# Remove multiple BGMS to map list when using event command to change BGM
# - $game_system.remove_multi_bbgms = true or false
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Multiple BGMS', 'SephirothSpawn', 1, '2007-04-09')
SDK.check_requirements(2.0, [3])
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Multiple BGMS')
SDK.log_overwrite(:Game_System, :battle_bgm)
#==============================================================================
# ** Multiple_BGMS
#==============================================================================
module Multiple_BGMS
#--------------------------------------------------------------------------
# * Defaults
#
# Map BGM - Map Defined (By Map ID)
# - @map_bgm_by_map = { map_id => [ RPG::AudioFile, ... ], ... }
#
# Battle BGM - Map Defined (By Map ID)
# - @battle_bgm_by_map = { map_id => [ RPG::AudioFile, ... ], ... }
#
# Battle BGM - Troop Defined (By Troop ID)
# - @battle_bgm_by_troop = { troop_id => [ RPG::AudioFile, ... ], ... }
#--------------------------------------------------------------------------
@map_bgm_by_map = {}
@battle_bgm_by_map = {}
@battle_bgm_by_troop = {}
# Defaults Default (Must leave as arrays)
@map_bgm_by_map.default = []
@battle_bgm_by_map.default = []
@battle_bgm_by_troop.default = []
#--------------------------------------------------------------------------
# * Read Map BGMs For Maps
#--------------------------------------------------------------------------
def self.map_bgm_by_map
return @map_bgm_by_map
end
#--------------------------------------------------------------------------
# * Read Battle BGMs For Maps
#--------------------------------------------------------------------------
def self.battle_bgm_by_map
return @battle_bgm_by_map
end
#--------------------------------------------------------------------------
# * Read Battle BGMs From Troops
#--------------------------------------------------------------------------
def self.battle_bgm_by_troop
return @battle_bgm_by_troop
end
#--------------------------------------------------------------------------
# * Write Map BGMs For Maps
#--------------------------------------------------------------------------
def self.map_bgm_by_map=(map_bgm_by_map)
@map_bgm_by_map = map_bgm_by_map
end
#--------------------------------------------------------------------------
# * Write Battle BGMs For Maps
#--------------------------------------------------------------------------
def self.battle_bgm_by_map=(battle_bgm_by_map)
@battle_bgm_by_map = battle_bgm_by_map
end
#--------------------------------------------------------------------------
# * Write Battle BGMs From Troops
#--------------------------------------------------------------------------
def self.battle_bgm_by_troop=(battle_bgm_by_troop)
@battle_bgm_by_troop = battle_bgm_by_troop
end
end
#==============================================================================
# ** RPG::Map
#==============================================================================
class RPG::Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_multibgms_gmsys_apbgm, :autoplay_bgm
alias_method :seph_multibgms_gmsys_bgm, :bgm
#--------------------------------------------------------------------------
# * Autoplay BGM Flag
#--------------------------------------------------------------------------
def autoplay_bgm
return seph_multibgms_gmsys_apbgm ||
Multiple_BGMS.map_bgm_by_map[@id].empty? == false
end
#--------------------------------------------------------------------------
# * Get Map Background Music
#--------------------------------------------------------------------------
def bgm
# Get Original Map Background Music
bgms = [seph_multibgms_gmsys_bgm]
# Add Map Defined Map BGMS
bgms << Multiple_BGMS.map_bgm_by_map[@id]
# Return Random BGM
return bgms.flatten.compact.random
end
end
#==============================================================================
# ** Game_System
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :include_multi_bbgms
attr_accessor :include_multi_bbgms_map
attr_accessor :include_multi_bbgms_troop
attr_accessor :include_datasys_bbgm
attr_accessor :include_gmsys_bbgm
attr_accessor :add_multi_bbgms
attr_accessor :remove_multi_bbgms
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_multibgms_gmsys_init, :initialize
alias_method :seph_multibgms_gmsys_bbgm=, :battle_bgm=
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original Initialization
seph_multibgms_gmsys_init
# Multi BGM Initialize
init_multibgm
end
#--------------------------------------------------------------------------
# * Object Initialization : Multi BGM
#--------------------------------------------------------------------------
def init_multibgm
@include_multi_bbgms = true
@include_multi_bbgms_map = true
@include_multi_bbgms_troop = true
@include_datasys_bbgm = true
@include_gmsys_bbgm = true
@add_multi_bbgms = false
@remove_multi_bbgms = false
end
#--------------------------------------------------------------------------
# * Get Battle Background Music
#--------------------------------------------------------------------------
def battle_bgm
# Start BGM List
bgms = []
# If Include Multi BGM
if @include_multi_bbgms
# Add Map BGMS if Included
if @include_multi_bbgms_map
bgms << Multiple_BGMS.battle_bgm_by_map[$game_map.map_id]
end
# Add Troop BGMS if Included
if @include_multi_bbgms_troop
bgms << Multiple_BGMS.battle_bgm_by_troop[$game_temp.battle_troop_id]
end
end
# Add System Battle BGM if Included
if @include_datasys_bbgm
bgms << $data_system.battle_bgm
end
# Adds Game System Battle BGM if Included
if @include_gmsys_bbgm && @battle_bgm != nil
bgms << @battle_bgm
end
# Return Random BGM
return bgms.flatten.random
end
#--------------------------------------------------------------------------
# * Set Battle Background Music
#--------------------------------------------------------------------------
def battle_bgm=(battle_bgm)
# If Add Map BGM
if @add_multi_bbgms
Multiple_BGMS.battle_bgm_by_map[$game_map.map_id] = battle_bgm
# If Remove Map BGM
elsif @add_multi_bbgms_troop
Multiple_BGMS.battle_bgm_by_map[$game_map.map_id].delete(battle_bgm)
else
# Original Set Battle Background Music
self.seph_multibgms_gmsys_bb = battle_bgm
end
end
end
#==============================================================================
# ** Scene_Save
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_multibgms_scnsv_wd, :write_data
#--------------------------------------------------------------------------
# * Write Data
#--------------------------------------------------------------------------
def write_data(file)
# Original Write Save Data
seph_multibgms_scnsv_wd(file)
# Dump Multiple BGM Settings
Marshal.dump(Multiple_BGMS.map_bgm_by_map, file)
Marshal.dump(Multiple_BGMS.battle_bgm_by_map, file)
Marshal.dump(Multiple_BGMS.battle_bgm_by_troop, file)
end
end
#==============================================================================
# ** Scene_Load
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_multibgms_scnld_rd, :read_data
#--------------------------------------------------------------------------
# * Read Data
#--------------------------------------------------------------------------
def read_data(file)
# Original Read Save Data
seph_multibgms_scnld_rd(file)
# Read Multi BGMs
Multiple_BGMS.map_bgm_by_map = Marshal.load(file)
Multiple_BGMS.battle_bgm_by_map = Marshal.load(file)
Multiple_BGMS.battle_bgm_by_troop = Marshal.load(file)
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end