Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - Resume BGM after battle

Save-Point

Full Version: Resume BGM after battle
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Since I don't mind scriptcalls (using tons of them already) this seems to be a solution.
Much thanks. :)

Now it only needs to get cold enough in my room to spend more than a few minutes on the PC.
Much stuff to test.^^
You can try "MCI Audio Player" (xp/vx/vxa, support pause and resume a playing file) or "FmodEx" (xp only, support memorize current playing time, and resume an audio at anytime)
You also will add some modifies in "def call_battle" (to pause map bgm) and "def start_phase5" (to resume map bgm after battle) to make things work
Well, in HiddenChest you're supposed to use Audio.bgm_pos to get the current BGM's position... In the default VX Ace engine it only works if it's playing an OGG or WAV file... Confused I guess it might also work with MP3 in HiddenChest. I've compiled a binary executable that already keeps record of the position even if you're playing an XP or VX game. So far it works on Linux and Windows 64 bit versions, but I'm unsure if I'll ever release the latest binaries. Laughing + Tongue sticking out

Code:
class Game_Temp
  def map_bgm=(bgm)
    bgm.pos = Audio.bgm_pos
    Audio.bgm_pos = 0.0
    @map_bgm = bgm
  end
end

class Game_System
  def bgm_play(bgm)
    @playing_bgm = bgm
    if bgm != nil and bgm.name != ""
      bgm.pos ||= 0.0
      Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch, bgm.pos)
    else
      Audio.bgm_stop
      Audio.bgm_pos = 0.0
    end
    Graphics.frame_reset
  end

  def bgs_play(bgs)
    @playing_bgs = bgs
    if bgs != nil and bgs.name != ""
      bgs.pos ||= 0.0
      Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume, bgs.pitch, bgs.pos)
    else
      Audio.bgs_stop
      Audio.bgs_pos = 0.0
    end
    Graphics.frame_reset
  end
end

So far that's all you need to make it remember the position when the battle begins and it's supposed to recall it later on. Again, I'm not saying I'll ever release the latest HiddenChest binaries. Laughing + Tongue sticking out
So this isn't working in the current version that I'm using but only in your HiddenChest version, hidden on your computer?
Fine, here's HiddenChest's binary file for Windows (any?) 64 bit version and the corresponding Ruby binary library. It already includes the changes I made to the Audio module.
http://www.mediafire.com/file/pq6sl4ngw0...t.zip/file
http://www.mediafire.com/file/ma35820zke...2.zip/file
Looks like I'm a bit late to comment on this but I'm using ParaDog's Battle BGM Anti-Reset and it works just fine. One thing is that if you escape from a fight, the battle theme will continue to play until it ends and then the field theme will resume normally.


Code:
#==============================================================================
#????Battle BGM Anti-Reset ver. 1.00???
#??Script by ParaDog
#??http://2d6.parasite.jp/
#------------------------------------------------------------------------------
# Prevents the music from starting over when entering combat if both the field
# map's and battlesystem's BMG are the same.  Likewise, the music will not re-
# set upon escaping combat,  or after victory if the  'battle end ME' has been
# turned off (set to 'None).
#------------------------------------------------------------------------------
# For best results of this system, please set the 'Battle End ME'  to ("None)"
# in either the SYSTEM section or through an event command.
#==============================================================================

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Battle Call
  #--------------------------------------------------------------------------
  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
    # Play battle start SE
    $game_system.se_play($data_system.battle_start_se)
    # Play battle BGM
    #If Switch 1 is ON
    if $game_switches[226] == true
      # Play same battle BGM as the map BGM
      $game_system.battle_bgm = $game_temp.map_bgm
      $game_system.bgm_play($game_system.battle_bgm)
    #If Switch 2 is ON
    elsif $game_switches[227] == true
      # Play the basic battle BGM
      # ! WILL RESET THE MAP BGM AFTER BATTLE ! #
      # I use this for bosses, so that the battle BGM can loop.
      $game_system.bgm_play($game_system.battle_bgm)
    #Else, if Switch 1 and Switch 2 are OFF
    elsif $game_switches[226] == false and $game_switches[227] == false
    #Play battle BGM as ME (won't loop)
    Audio.me_play("Audio/BGM/" + $game_system.battle_bgm.name, $game_system.battle_bgm.volume, $game_system.battle_bgm.pitch)
    end
    # Straighten player position
    $game_player.straighten
    # Switch to battle screen
    $scene = Scene_Battle.new
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  def start_phase5
    # Shift to phase 5
    @phase = 5
    if $game_system.battle_end_me.name != ""
      # Play battle end ME
      $game_system.me_play($game_system.battle_end_me)
    end
    # Return to BGM before battle started
    $game_system.bgm_play($game_temp.map_bgm)
    # Initialize EXP, amount of gold, and treasure
    exp = 0
    gold = 0
    treasures = []
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP and amount of gold obtained
        exp += enemy.exp
        gold += enemy.gold
        # Determine if treasure appears
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end  
    # Treasure is limited to a maximum of 6 items
    treasures = treasures[0..5]
    # Obtaining EXP
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    # Obtaining gold
    $game_party.gain_gold(gold)
    # Obtaining treasure
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # Make battle result window
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    if $game_system.battle_end_me.name != ""
      # Set wait count
      @phase5_wait_count = 100
    else
      # Set wait count
      @phase5_wait_count = 20
    end
  end
end
Well, she's not wanting one that keeps the field music playing in battle. She wants the field music to resume where it left off, thus needing to memorize the music position itself.

Oh, your copy of ParaDog's isn't original. Having translated the original version (and looking at it now), someone added content right after line 30.
Now that you mention it, I -think- I requested an edited version of the original script. What it does is to play the battle themes as BackGround Sounds (BGS) that will not loop, allowing the field music to resume once they end.

The script also allows you to disable the effect and play the battle themes normally. Ideal for boss battles.
I see the edit. Rather than stopping the field music when battle begins, it continues playback of the field music whilst the battle is on-going. However, she wishes the music to pause when battle begins, and resume playback at that point. This doesn't accomplish that effect. But that's because the game engine's audio class doesn't have a pause and resume method.
I see.

I used both MCI Audio Player and FmodEx mentioned by finalholylight back then and eventually ran into issues. MCI glitched if a battle animation had too many sounds, causing the game to slow down and eventually freeze and Fmod sometimes played the resumed field music at a way too low volume or failed to stop playing the battle theme after a fight.

Also, I cooked this demo of ParaDog's script if anyone is interested.
[attachment=1162]
Pages: 1 2 3