[Resolved][XP] Map BGM not resetting after battle

Hi. So, I need a script (or a way to do this with events, maybe) so that the map BGM doesn't reset when a battle is over. I searched for hours and couldn't find anything...

I'm not asking for a script that does not reset the BGM when using the same one for battles, but for different ones !

Basically, here's an example :

I'm on the map, the music is at... 30sec
Then, a battle occurs, the BGM changes to the battle one.
Battle over, back on the map, the music is still at 30sec (or it continued muted while i'm fighting, I just don't want it to reset).

I'm sorry for my english and I hope it was clear enough.
Unless the audio module is rewritten..... Well, I think sandgolem wrote such script, but it's not available now(no, I don't have it either). cowlol wrote such script that uses FMOD, and poccil also wrote such using some other library file, and it was included in Pokemon Starter Kit(search for that. I forgot where I found it). Unfortunately, both are not compatible with some battle BGM handling scripts(like 'continuing map BGM to battle') without additional editing, and they can screw up MIDI looping, because none of them recognize MIDI controller 111 for loop start determination yet.
Try this one:

Conituous BGM

Paste this script right above main, bellow all other scripts
You will need this .dll on the game folder: http://www.4shared.com/file/63444597/e630eef/audio.html

Note that it's don't work with .ogg bgms, so you will need to convert .ogg bgm to .mp3 or .wma

Credits goes to poccil for the audio rewrite and to me for bug fixes and the code for adding the contiuons feature to battles.
Atoa : Thanks, but I have an error at line 488 (Syntax error occured) "name = parent.keyname + '\' + name". I have no idea what it means ! (for info, I'm not using any other script that deals with BGM and I don't use .ogg)

Landarma : Yes I found the sandgolem and cowlol scripts, but can't download any of them. :/

EDIT : I thought about that, is there no way to edit a script that keeps the map music during battle so that the BGM continues, but is muted, and the battle music is played as a BGS/ME ? I found a script that played the battle BGM as ME, but didn't really work for my game.
the sandgolem script was using melody for battle bgm or something. but not in normal way. what was problem you had with script you used?
Well, the problem is that if I want another script with the map bgm continuing in combat, it just doesn't work. But I think I'm gonna forget the "map bgm continuing in combat" script if there is no solution, cause having the start of a song playing again and again after a battle is really anoying.

By the way, here's what I found (just had to replace the basic Screen_Map by this, credits goes to tinh_mgv) :

  1. #==============================================================================
  2. # ** Scene_Map
  3. #------------------------------------------------------------------------------
  4. #   This class performs map screen processing.
  5. #   Play Battle BGM as ME.
  6. #   tinh_mgv from http://www.makegameviet.com
  7. #==============================================================================
  8.  
  9. class Scene_Map
  10.   #--------------------------------------------------------------------------
  11.   # * Main Processing
  12.   #--------------------------------------------------------------------------
  13.   def main
  14.      # Make sprite set
  15.      @spriteset = Spriteset_Map.new
  16.      # Make message window
  17.      @message_window = Window_Message.new
  18.      # Transition run
  19.      Graphics.transition
  20.      # Main loop
  21.      loop do
  22.         # Update game screen
  23.         Graphics.update
  24.         # Update input information
  25.         Input.update
  26.         # Frame update
  27.         update
  28.         # Abort loop if screen is changed
  29.         if $scene != self
  30.            break
  31.         end
  32.      end
  33.      # Prepare for transition
  34.      Graphics.freeze
  35.      # Dispose of sprite set
  36.      @spriteset.dispose
  37.      # Dispose of message window
  38.      @message_window.dispose
  39.      # If switching to title screen
  40.      if $scene.is_a?(Scene_Title)
  41.         # Fade out screen
  42.         Graphics.transition
  43.         Graphics.freeze
  44.      end
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # * Frame Update
  48.   #--------------------------------------------------------------------------
  49.   def update
  50.      # Loop
  51.      loop do
  52.         # Update map, interpreter, and player order
  53.         # (this update order is important for when conditions are fulfilled
  54.         # to run any event, and the player isn't provided the opportunity to
  55.         # move in an instant)
  56.         $game_map.update
  57.         $game_system.map_interpreter.update
  58.         $game_player.update
  59.         # Update system (timer), screen
  60.         $game_system.update
  61.         $game_screen.update
  62.         # Abort loop if player isn't place moving
  63.         unless $game_temp.player_transferring
  64.            break
  65.         end
  66.         # Run place move
  67.         transfer_player
  68.         # Abort loop if transition processing
  69.         if $game_temp.transition_processing
  70.            break
  71.         end
  72.      end
  73.      # Update sprite set
  74.      @spriteset.update
  75.      # Update message window
  76.      @message_window.update
  77.      # If game over
  78.      if $game_temp.gameover
  79.         # Switch to game over screen
  80.         $scene = Scene_Gameover.new
  81.         return
  82.      end
  83.      # If returning to title screen
  84.      if $game_temp.to_title
  85.         # Change to title screen
  86.         $scene = Scene_Title.new
  87.         return
  88.      end
  89.      # If transition processing
  90.      if $game_temp.transition_processing
  91.         # Clear transition processing flag
  92.         $game_temp.transition_processing = false
  93.         # Execute transition
  94.         if $game_temp.transition_name == ""
  95.            Graphics.transition(20)
  96.         else
  97.            Graphics.transition(40, "Graphics/Transitions/" +
  98.               $game_temp.transition_name)
  99.         end
  100.      end
  101.      # If showing message window
  102.      if $game_temp.message_window_showing
  103.         return
  104.      end
  105.      # If encounter list isn't empty, and encounter count is 0
  106.      if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  107.         # If event is running or encounter is not forbidden
  108.         unless $game_system.map_interpreter.running? or
  109.                    $game_system.encounter_disabled
  110.            # Confirm troop
  111.            n = rand($game_map.encounter_list.size)
  112.            troop_id = $game_map.encounter_list[n]
  113.            # If troop is valid
  114.            if $data_troops[troop_id] != nil
  115.               # Set battle calling flag
  116.               $game_temp.battle_calling = true
  117.               $game_temp.battle_troop_id = troop_id
  118.               $game_temp.battle_can_escape = true
  119.               $game_temp.battle_can_lose = false
  120.               $game_temp.battle_proc = nil
  121.            end
  122.         end
  123.      end
  124.      # If B button was pressed
  125.      if Input.trigger?(Input::B)
  126.         # If event is running, or menu is not forbidden
  127.         unless $game_system.map_interpreter.running? or
  128.                    $game_system.menu_disabled
  129.            # Set menu calling flag or beep flag
  130.            $game_temp.menu_calling = true
  131.            $game_temp.menu_beep = true
  132.         end
  133.      end
  134.      # If debug mode is ON and F9 key was pressed
  135.      if $DEBUG and Input.press?(Input::F9)
  136.         # Set debug calling flag
  137.         $game_temp.debug_calling = true
  138.      end
  139.      # If player is not moving
  140.      unless $game_player.moving?
  141.         # Run calling of each screen
  142.         if $game_temp.battle_calling
  143.            call_battle
  144.         elsif $game_temp.shop_calling
  145.            call_shop
  146.         elsif $game_temp.name_calling
  147.            call_name
  148.         elsif $game_temp.menu_calling
  149.            call_menu
  150.         elsif $game_temp.save_calling
  151.            call_save
  152.         elsif $game_temp.debug_calling
  153.            call_debug
  154.         end
  155.      end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # * Battle Call
  159.   #--------------------------------------------------------------------------
  160.   def call_battle
  161.      # Clear battle calling flag
  162.      $game_temp.battle_calling = false
  163.      # Clear menu calling flag
  164.      $game_temp.menu_calling = false
  165.      $game_temp.menu_beep = false
  166.      # Make encounter count
  167.      $game_player.make_encounter_count
  168.      # Memorize map BGM and stop BGM
  169.      $game_temp.map_bgm = $game_system.playing_bgm
  170.      #$game_system.bgm_stop # Don't stop BGM
  171.      # Play battle start SE
  172.      $game_system.se_play($data_system.battle_start_se)
  173.      # Play Battle BGM as ME
  174.      Audio.me_play("Audio/BGM/" + $game_system.battle_bgm.name, $game_system.battle_bgm.volume, $game_system.battle_bgm.pitch)
  175.      # Straighten player position
  176.      $game_player.straighten
  177.      # Switch to battle screen
  178.      $scene = Scene_Battle.new
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # * Shop Call
  182.   #--------------------------------------------------------------------------
  183.   def call_shop
  184.      # Clear shop call flag
  185.      $game_temp.shop_calling = false
  186.      # Straighten player position
  187.      $game_player.straighten
  188.      # Switch to shop screen
  189.      $scene = Scene_Shop.new
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # * Name Input Call
  193.   #--------------------------------------------------------------------------
  194.   def call_name
  195.      # Clear name input call flag
  196.      $game_temp.name_calling = false
  197.      # Straighten player position
  198.      $game_player.straighten
  199.      # Switch to name input screen
  200.      $scene = Scene_Name.new
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # * Menu Call
  204.   #--------------------------------------------------------------------------
  205.   def call_menu
  206.      # Clear menu call flag
  207.      $game_temp.menu_calling = false
  208.      # If menu beep flag is set
  209.      if $game_temp.menu_beep
  210.         # Play decision SE
  211.         $game_system.se_play($data_system.decision_se)
  212.         # Clear menu beep flag
  213.         $game_temp.menu_beep = false
  214.      end
  215.      # Straighten player position
  216.      $game_player.straighten
  217.      # Switch to menu screen
  218.      $scene = Scene_Menu.new
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # * Save Call
  222.   #--------------------------------------------------------------------------
  223.   def call_save
  224.      # Straighten player position
  225.      $game_player.straighten
  226.      # Switch to save screen
  227.      $scene = Scene_Save.new
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # * Debug Call
  231.   #--------------------------------------------------------------------------
  232.   def call_debug
  233.      # Clear debug call flag
  234.      $game_temp.debug_calling = false
  235.      # Play decision SE
  236.      $game_system.se_play($data_system.decision_se)
  237.      # Straighten player position
  238.      $game_player.straighten
  239.      # Switch to debug screen
  240.      $scene = Scene_Debug.new
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # * Player Place Move
  244.   #--------------------------------------------------------------------------
  245.   def transfer_player
  246.      # Clear player place move call flag
  247.      $game_temp.player_transferring = false
  248.      # If move destination is different than current map
  249.      if $game_map.map_id != $game_temp.player_new_map_id
  250.         # Set up a new map
  251.         $game_map.setup($game_temp.player_new_map_id)
  252.      end
  253.      # Set up player position
  254.      $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
  255.      # Set player direction
  256.      case $game_temp.player_new_direction
  257.      when 2   # down
  258.         $game_player.turn_down
  259.      when 4   # left
  260.         $game_player.turn_left
  261.      when 6   # right
  262.         $game_player.turn_right
  263.      when 8   # up
  264.         $game_player.turn_up
  265.      end
  266.      # Straighten player position
  267.      $game_player.straighten
  268.      # Update map (run parallel process event)
  269.      $game_map.update
  270.      # Remake sprite set
  271.      @spriteset.dispose
  272.      @spriteset = Spriteset_Map.new
  273.      # If processing transition
  274.      if $game_temp.transition_processing
  275.         # Clear transition processing flag
  276.         $game_temp.transition_processing = false
  277.         # Execute transition
  278.         Graphics.transition(20)
  279.      end
  280.      # Run automatic change for BGM and BGS set on the map
  281.      $game_map.autoplay
  282.      # Frame reset
  283.      Graphics.frame_reset
  284.      # Update input information
  285.      Input.update
  286.   end
  287. end
  288.  
Expand to see the code.
Did you download the audio module?

And waas you using another script that deals with the music?

And when you get the error?
Atoa wrote:
Did you download the audio module?

Yes, and I putted it the game folder (where the game.exe is).

Atoa wrote:
And waas you using another script that deals with the music?

No, and I tried with a new project without any script, same error.

Atoa wrote:
And when you get the error?

When I launch the game, before everything.

(And I did put the script between Scene_Debug and Main)
@Micko
I discovered the error
it was caused by the forum xD

the line 488 (and some others) had two "\" bu the forum automatically set it to one.

try this:

Continuos BGM.txt
Works perfectly. It even continues the BGM without restarting it if the battle BGM is the same. Many thanks ! *Credits list updated*
yeah i love you xD this is great. now i can use victory me's and they stop automaticly :thumb:
The audio.dll download link doesn't work.
@zes1
it's workinkg fine...
when i tried the audio.dll link i got this

"The file link that you requested is not valid."

this was after i clicked the link after the 10 secound wait.

if anyone know where to get this please let me know ....thanks
Please re-upload the .dll file :( the link has broken

!
Hix, please re-upload the audio.dll with another alive link
Thanks first

!
I was able to do this by modifying the scripts in the game. I just removed a bunch of the $game_system.bgm_stop from the scripts.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=63395