Hopefully this will be more popular than my last script.
This allows to have multiple battle bgm (one is selected randomly each battle) you could for example use it to play character's battle themes only while they are in the party.
And you can alter the possible choices in game as often as you like.
To add music the code is:
$game_party.music.push("MusicName")
Please note you do not need the file extention
To remove music the code is:
$game_party.music.delete("MusicName")
Please note you do not need the file extention
You probably want a default music at the start of the game, or default selection to do so change the line:
@music = []
to something like
@music = ['Theme01', 'Theme02', 'Theme04']
Any questions or comments?
This allows to have multiple battle bgm (one is selected randomly each battle) you could for example use it to play character's battle themes only while they are in the party.
And you can alter the possible choices in game as often as you like.
Thanks to Trickster for making this script better.
Code:
class Game_Party
attr_accessor :music
alias pre_music_initialize initialize
def initialize
pre_music_initialize
@music = []
end
end
class Scene_Map
def call_battle
# 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 and stop BGM
$game_temp.map_bgm = $game_system.playing_bgm
$game_system.bgm_stop
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
file = $game_party.music[rand($game_party.music.size)]
audio_file = RPG::AudioFile.new(file)
$game_system.bgm_play(audio_file)
# Straighten player position
$game_player.straighten
# Switch to battle screen
$scene = Scene_Battle.new
end
end
Code:
class Game_Party
attr_accessor :music
alias pre_music_initialize initialize
def initialize
pre_music_initialize
@music = []
end
end
class Scene_Map
def call_battle
# 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 and stop BGM
$game_temp.map_bgm = $game_system.playing_bgm
$game_system.bgm_stop
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play2($game_party.music[rand($game_party.music.size)])
# Straighten player position
$game_player.straighten
# Switch to battle screen
$scene = Scene_Battle.new
end
end
class Game_System
def bgm_play2(bgm)
@playing_bgm = bgm
if bgm != nil and bgm != ""
Audio.bgm_play("Audio/BGM/" + bgm, 100, 100)
else
Audio.bgm_stop
end
Graphics.frame_reset
end
end
To add music the code is:
$game_party.music.push("MusicName")
Please note you do not need the file extention
To remove music the code is:
$game_party.music.delete("MusicName")
Please note you do not need the file extention
You probably want a default music at the start of the game, or default selection to do so change the line:
@music = []
to something like
@music = ['Theme01', 'Theme02', 'Theme04']
Any questions or comments?