#==============================================================================
# Advanced Animated Menu - leader music addon
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 30/05/2025
# Requires: Blackmorning's Advanced Animated Menu
#==============================================================================
# This addon allows the main menu to have a BGM and BGS specific to the current
# leader. If the party formation changes the current leader, then the music will
# change too.
#
# To setup your actor music, add entries to MUSIC[:actor_bgm] and MUSIC[:actor_bgs]
# An entry will be:
# actor_id => [filename, volume, pitch]
# If actor x has no entry, then DEFAULT_BGM and DEFAULT_BGS will be used instead
#==============================================================================
# Terms of use: free for commercial and non-commercial project, crediting me
# is not required, follow Blackmorning's term of uses
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM-AAM-LEADER-MUSIC"] = true
#==============================================================================
# BM
#==============================================================================
module BM
module MENU
#name, volume, pitch
DEFAULT_BGM = ["Theme4",100,100]
DEFAULT_BGS = ["", 100,100]
MUSIC[:actor_bgm] = {
#actor_id => [bgm, volume, pitch]
1 => ["Theme2",100],
2 => ["Battle2",100],
}
MUSIC[:actor_bgs] = {
#actor_id => [bgs, volume, pitch]
1 => ["",100],
}
#--------------------------------------------------------------------------
# new method: get_bgm
#--------------------------------------------------------------------------
def self.get_bgm(actor_id)
return MUSIC[:actor_bgm][actor_id] if MUSIC[:actor_bgm][actor_id]
DEFAULT_BGM
end
#--------------------------------------------------------------------------
# new method: get_bgs
#--------------------------------------------------------------------------
def self.get_bgs(actor_id)
return MUSIC[:actor_bgs][actor_id] if MUSIC[:actor_bgs][actor_id]
DEFAULT_BGS
end
end #MENU
end #BM
#==============================================================================
# Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias tim_aamlm_menu_init initialize
def initialize
tim_aamlm_menu_init
set_menu_music(nil)
end
#--------------------------------------------------------------------------
# new method: set_menu_music
#--------------------------------------------------------------------------
def set_menu_music(actor)
actor_id = 0
actor_id = actor.id if actor
@menu_bgm = RPG::BGM.new(*BM::MENU.get_bgm(actor_id))
@menu_bgs = RPG::BGS.new(*BM::MENU.get_bgs(actor_id))
end
end #Game_Temp
#==============================================================================
# Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# alias method: start
#--------------------------------------------------------------------------
alias tim_aamlm_start start
def start
$game_temp.set_menu_music($game_party.leader)
tim_aamlm_start
end
#--------------------------------------------------------------------------
# alias method: on_formation_ok
#--------------------------------------------------------------------------
alias tim_aamlm_on_formation_ok on_formation_ok
def on_formation_ok
former_leader = $game_party.leader
tim_aamlm_on_formation_ok
if former_leader != $game_party.leader
$game_temp.set_menu_music($game_party.leader)
play_menu_bgm
end
end
end #Scene_Menu