Script needed for skipping Battle BGM.. Can anyone please help?

Started by littletomdj, October 11, 2011, 12:08:14 pm

Previous topic - Next topic

littletomdj

Hi, I'm an absolute beginner! (only been using RMXP for a week & only been registered here for 4 hours)
Sorry if this isn't posted in the right place, I'm asking stupid questions or anything else..  :facepalm:

So that been said, here's my questions.

A) I need a script that stops the battle music. (I know you can do this by deleting the following lines in Setup_Map under * Battle Call.)

168 $game_temp.map_bgm = $game_system.playing_bgm
    $game_system.bgm_stop
172 $game_system.bgm_play($game_system.battle_bgm


But that's a permanent effect. I want the rule to apply on some maps, but not others.

B) Also as the music in my game is often long pieces of audio (as opposed to MIDI) I don't want the map music to restart at the end of each battle, I want it to continue from where it left off (or just randomly from any point (just so long as you're not just hearing the first 10 seconds of intro over & over))

I'm sure script like this has been posted in the past, I've found dead links & the following script for VX.. (I thought I'd paste it just incase it's easy for someone to mod it to work for XP.)
 
Spoiler: ShowHide
#==============================================================================
# ** Make BGM unchange 1.01 by ERZENGEL <erzvx@live.de>
#==============================================================================

DURING = 9  # if the switch with ID 9 is on the BGM won't change at the battle

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

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Switch to Battle Screen
  #--------------------------------------------------------------------------
  def call_battle
    unless $game_switches[DURING]
      @spriteset.update
      Graphics.update
      $game_player.make_encounter_count
      $game_player.straighten
      $game_temp.map_bgm = RPG::BGM.last
      $game_temp.map_bgs = RPG::BGS.last
      RPG::BGM.stop
      RPG::BGS.stop
      Sound.play_battle_start
      $game_system.battle_bgm.play
      $game_temp.next_scene = nil
      $scene = Scene_Battle.new
    else
      @spriteset.update
      Graphics.update
      $game_player.make_encounter_count
      $game_player.straighten
      Sound.play_battle_start
      $game_temp.next_scene = nil
      $scene = Scene_Battle.new
    end
  end
end

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

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * End Battle
  #     result : Results (0: win, 1: escape, 2:lose)
  #--------------------------------------------------------------------------
  def battle_end(result)
    if result == 2 and not $game_troop.can_lose
      call_gameover
    else
      $game_party.clear_actions
      $game_party.remove_states_battle
      $game_troop.clear
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call(result)
        $game_temp.battle_proc = nil
      end
      unless $BTEST
        unless $game_switches[DURING]
          $game_temp.map_bgm.play
          $game_temp.map_bgs.play
        end
      end
      $scene = Scene_Map.new
      @message_window.clear
      Graphics.fadeout(30)
    end
    $game_temp.in_battle = false
  end
  #--------------------------------------------------------------------------
  # * Victory Processing
  #--------------------------------------------------------------------------
  def process_victory
    unless $game_switches[DURING]
      @info_viewport.visible = false
      @message_window.visible = true
      RPG::BGM.stop
      $game_system.battle_end_me.play
      unless $BTEST
        $game_temp.map_bgm.play
        $game_temp.map_bgs.play
      end
      display_exp_and_gold
      display_drop_items
      display_level_up
      battle_end(0)
    else
      @info_viewport.visible = false
      @message_window.visible = true
      display_exp_and_gold
      display_drop_items
      display_level_up
      battle_end(0)
    end
  end
end


I'd be really greatful for some help on this!  :)

...oh and sorry if I double posted (I got an error last time??)  :???:

MarkHest

For the first question: This can be done easily by turning off the BGM with an event, yes? (You can do the same with the Victory ME)

but if you meant that you want the BGM on the map to continue playing IN the battles then there's a clever solution.
In case you did not know BGS plays during battles while BGM halts during battles. You can import a song as a BGS and play the song as BGS instead of BGM. This way the music will continue during battles.
(note that you can do the same with BGS. By importing a BGS and BGM the BGS will instead halt during battles)
With a little cleverness, scripts aren't always needed!  ;)


As for the second question, i sent you a PM that will send you here: http://forum.chaos-project.com/index.php/topic,19.0.html
Just read the first thing blizzard wrote about BGM.



By the way, this topic should have been created here: http://forum.chaos-project.com/index.php/board,30.0.html
Keep that in mind when you look for further scripting help. :)
   

G_G

You'd need an audio library that can do this, like FMod, and a heavy rewrite of the Audio module in order to pause music and resume where it is. As opposed to the first question, there are event commands that play, stop, and change the battle music.

littletomdj

Dang!! I knew I'd put my question in the wrong place...  :facepalm:
This is the first time I've ever been on a forum/chat site ever too... sooo yeah... please don't hate me.
MarkHest sent me an e-mail which pointed to reasons why you can't pause audio in RMXP.
Thanks a a a again.  :)
I've got half a feeling that I wasn't supposed to respond? Tell me if I did bad!  :facepalm:
He also gave me some answers to questions I'd asked in this topic, but misunderstood a couple of others.
This is the bulk of my response to that.

What I really need is a way to switch how the audio functions from map to map.

So if you're on map A; Map BGM will play through battles & no battle/fanfare BGM will play.
And if you're on map B; Map BGM will cut out & Battle/fanfare BGM will play (as it normally does).

This sounds like such an easy thing to do (if you knew how to script).  :P
Blizzard said that the problem was because the RMXP's audio engine couldn't locate points in a track.
Basically it's skipping & pausing music that's the difficulty. I can live without that!

I doubt it would be that difficult to get the Battle BGM music playing after the encounter has ended or stopping/switching both the Battle BGM & Map BGM after an encounter (or any combination of that)
I've already found a script that changes the BGM half way through a battle if a certain action is selected. I've even seen threads with dead links for script that does just that.

The main thing is that when I said "turn off" battle BGM I didn't mean that I wanted it to stop playback, I meant that I wanted that process to be ignored entirely.

(I feel like I'm being a pest already) repeated  :facepalm:'s

G_G

No you can respond, its fine. ^_^ I remember when I was on my first forum, I was 100x worse than you, don't fret about it. :3 As for your issue, there are two event commands on the first page of events. Its called "Change Battle BGM" and "Change Battle End ME". Whenever you're on Map A use those commands and change them to "(None)". Whenever you're on Map B you'll want them to change back.

Blizzard

Your best bet is just to wait a little bit longer for ARC. ARC's RGSS part of the engine supports pausing and resuming without problems.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

littletomdj

Damn... That first bit was EASY! Can't believe I missed that! Thanks Game_Guy!!

I'm starting to think the second question could be solved without the need for a script too.
I won't keep asing about this because I'm a way off doin it anyway... but just to sew this topic up.

A good analogy of of what I'm thinking would be Chocobo encounters in final fantasy.

You wander around the map with your "regular map BGM"
You bump into random enemies and get your "regular battle BGM"
But then you randomly bump into a chocobo & you get your "special chocobo battle BGM"
Finally once you've caught your chocobo the map BGM flips to your "Wahey I've caught a chocobo BGM"  :D