Main Menu
  • Welcome to The RPG Maker Resource Kit.

[RESERVED] Map BGM Continuation

Started by ChaosSpartan28, December 11, 2007, 02:53:42 AM

0 Members and 1 Guest are viewing this topic.

ChaosSpartan28

Map BGM Continuation
12/10/07




Summary
What I basically want it to do is when you enter a map with a BGM it will play (as normal), but when you encounter an enemy, the BGM mutes but keeps playing while you fight, and when the encounter is over, the BGM is unmuted and it continues playing from where ever it left off.
Features Desired

  • Editable for BGMs and possibly BGSs
  • Doesn't require setup for every map. (would take for ever with what Im doing)




Did you search?
Of course! What am I, a newb... don't answer that.

Where did you search?

What did you search for?

  • BGM... believe me, long lists.

Thanks in advance!
Sig by MacGravel

haloOfTheSun

Back when I still used RPG Maker, this was something I had requested, and Blizzard told me it wasn't possible. =o
:tinysmile:

ChaosSpartan28

LIES!!! Oh come on. It's not like his word is law... though he nows alot more than I do about scripting.

Maybe if someone could attempt it. Please!
Sig by MacGravel

ChaosSpartan28

Well, I actually have this script that allows the BGM to continue as the battle BGM

[spoiler="Proves Blizzard is Wrong... Sorta"]
#==========================================================================
# This funtion playes the map's music during the battle#
# Caution: for some reason, the next line in an event is executed
# when the battle begins. This essentially "eats" the next line.
# As such, be sure to put in a dummy, non-comment command to get
# eaten right after the battle call, such as wait 1.
#==========================================================================
def My_Battle(troopID)   
    # Set battle abort flag   
    $game_temp.battle_abort = true   
    # Set battle calling flag   
    $game_temp.battle_calling = true   
    $game_temp.battle_troop_id = troopID   
    $game_temp.battle_can_escape = false   
    $game_temp.battle_can_lose = false   
    # Set callback   
    current_indent = @list[@index].indent   
    $game_temp.battle_proc = Proc.new { |n| @branch[current_indent] = n }   
    # Clear battle calling flag   
    $game_temp.battle_calling = false   
    # Clear menu calling flag   
    $game_temp.menu_calling = false   
    $game_temp.menu_beep = false   
    # Make encounter count   
    $game_player.make_encounter_count   
    # Memorize map BGM   
    $game_temp.map_bgm = $game_system.playing_bgm   
    # Play battle start SE   
    $game_system.se_play($data_system.battle_start_se)   
    # Straighten player position   
    $game_player.straighten   
    # Switch to battle screen   
    $scene = Scene_Battle.new
end
[/spoiler]

[spoiler="Its call script"]My_Battle(TROOPID)[/spoiler]


So if someone could some how mix that with this script

[spoiler="Multiple BGMs"]#==============================================================================
# ** 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
[/spoiler]

which allows multiple BGMs for maps and battles, maybe it could work.

Thanks!
Sig by MacGravel

modern algebra

Lol, someone wrote a script for Map BGM going into battle instead of just setting Battle BGM to none :P

Anyway, it is possible with BEHEMOTH's SAudio module probably. I will take a look at this later.

ChaosSpartan28

thanx, I'll be waiting. Update me if you find out anything
Sig by MacGravel

ChaosSpartan28

Hey Algebra, just wondering if you found out anything about that module.
Sig by MacGravel