The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Moss. on April 12, 2010, 07:10:08 PM

Title: Optional Battle Music
Post by: Moss. on April 12, 2010, 07:10:08 PM
OH MY GOD ARLEN'S MAKING A GAME.

It's just a joke kind of game, though, and I don't have much time. And I've never used VX (though I have used XP and 2003, and not much has changed.)

ANYWAY, I have my epic field music for my maps, but I don't want battle music. I want the music that's playing on the field to CONTINUE once the battle starts, and CONTINUE TO CONTINUE once the battle is over. With no interruptions.


What crazy script thing do I need to make this work?
Title: Re: Optional Battle Music
Post by: modern algebra on April 12, 2010, 09:12:15 PM
Super lazy way to do it, and not very compatible, but put this in its own slot above Main and above all other custom scripts, but still below the default ones:


#==============================================================================
# ** Scene Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - call_battle
#==============================================================================

class Scene_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Switch to Battle Screen
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def call_battle
    @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
    Sound.play_battle_start
    $game_temp.next_scene = nil
    $scene = Scene_Battle.new
  end
end

#==============================================================================
# ** Scene Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - process_victory
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Victory Processing
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def process_victory
    @info_viewport.visible = false
    @message_window.visible = true
    display_exp_and_gold
    display_drop_items
    display_level_up
    battle_end(0)
  end
end


It won't work if you use some other script that overwrites either method, but if you run into any just tell me and I'll fix them up for you.
Title: Re: Optional Battle Music
Post by: Moss. on April 12, 2010, 09:44:21 PM
Balls awesome. I'm probably not going to use any other scripts in the game, it's going to be really basic, but I'll come back if there's any issues, lol.

Thanks, MA.
Title: Re: Optional Battle Music
Post by: Moss. on April 13, 2010, 08:34:05 PM
Okay, so it works, but now my bgm's aren't looping correctly. There's a gap, a 1/2 second and very noticable gap before it goes from the end to the beginning.

I checked the files. They loop flawlessly in iTunes, Adobe Soundbooth, Logic, and Audacity.

I tried mp3. Still has gaps.
I tried wav. Still has gaps.
I'm about to try .ogg, but I'm not hopeful.

The only thing that remains that could cause this problem is ... this script. :(
Title: Re: Optional Battle Music
Post by: modern algebra on April 13, 2010, 09:45:12 PM
All this script does is take out the lines that would normally stop the field music from playing when entering battle and stop the victory me from playing when exiting battle. I don't see how it could interfere with looping. Do they loop properly when the script isn't included in your game? RMVX doesn't have a very good audio engine, but I did think oggs and midis looped correctly.
Title: Re: Optional Battle Music
Post by: Moss. on April 14, 2010, 12:16:35 AM
Ogg seems to fix the issue. What a horrible bug to leave in a program like this...

Sorry for doubting you, MA. :'(
Title: Re: Optional Battle Music
Post by: modern algebra on April 14, 2010, 01:20:22 AM
haha :) Yeah, it has the worst Audio handling ever. The looping is terrible for some formats as you know. Worse than that, you can't even play a file from a certain point of time, meaning you can't pause and resume files; you have to start them at the beginning every time. Nor are you able to retrieve any properties from the currently playing file, such as title, length, etc... It's a pain.
Title: Re: Optional Battle Music
Post by: Zylos on April 14, 2010, 04:05:24 AM
OGG works very nicely for loops, but it has a bit of delay I've noticed when starting up. Sadly, midi's are the only perfect looping music, but OGG's come the closest for the quality you want.