map music continues during battle
#1
map music continues during battle
by Nakate

Aug 11 2007

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


Hello everyone. I'm pretty sure this is where this goes. It would either be here or in battle systems. I banged together a script real quick that continues to play the current BGM when a battle starts. Say, for example, you have a very climatic scene facing down the last boss, with some really cool music playing. For the sake of it looking cool, you want this BGM to keep playing as the battle starts, and keep playing throughout without interruption. That's essentially what this is made to do. Just insert the following code anywhere above main:

Code:
#==========================================================================
# 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

Regular battles still operate as usual, but if you want to call a battle using this function, in an event call a script, and in it write:
Code:
My_Battle(TROOPID)




Hello everyone. I'm pretty sure this is where this goes. It would either be here or in battle systems. I banged together a script real quick that continues to play the current BGM when a battle starts. Say, for example, you have a very climatic scene facing down the last boss, with some really cool music playing. For the sake of it looking cool, you want this BGM to keep playing as the battle starts, and keep playing throughout without interruption. That's essentially what this is made to do. Just insert the following code anywhere above main:

CODE
#======================================================================
====
# 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


Regular battles still operate as usual, but if you want to call a battle using this function, in an event call a script, and in it write:
CODE
My_Battle(TROOPID)


As is probably obvious, where it says TROOPID, put in the ID of the troop you want this battle to be against. 32, for example, to fight troop #32. This will still play the battle-end ME, but if you'd rather skip that as well, and keep the music playing the entire way through and back onto the map, just set battle-end ME to (none) and the music keeps playing through seamlessly.

The only real flaw I've seen with this is that it tries to "eat" the next command in the event. This can be fixed by simply putting in a wait: 1 after the battle call (Maybe more, I'm not sure how lag and the such affect the script. Regardless, if a wait of 1 doesn't work, make it longer, it eventually will.). A textbox works too, but may look a little off. However, instantaneous commands such as changing the battle BGM do not work, and are executed BEFORE the battle starts. All in all, just put a wait: 1 directly after the call and all will be fine. If I ever figure out how to fix this, I'll be sure to update the script. I suppose I should make a demo or something... give me some time, that will probably be more trouble than I'm expecting.

As a side note, is there any particular reason the codeboxes are always the exact same size, no matter how much is written in them?
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Loop MP3 Music GubiD 0 2,751 04-27-2008, 01:00 PM
Last Post: GubiD
  A really really simple individual special battle commands stupidstormy36 0 2,623 04-22-2008, 01:00 PM
Last Post: stupidstormy36
  In-Battle HP/SP Regeneration legend in his own mind 0 2,531 08-26-2007, 01:00 PM
Last Post: legend in his own mind
  Random Battle Cancel El Conductor 0 2,627 08-14-2007, 01:00 PM
Last Post: El Conductor
  Ending Battle Music Fix Sephirothtds 0 2,537 05-11-2007, 01:00 PM
Last Post: Sephirothtds
  Battle Result Plus Ragnarok Rob 0 2,576 09-23-2006, 01:00 PM
Last Post: Ragnarok Rob



Users browsing this thread: 1 Guest(s)