Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

A quick scripting question for battle victory tunes.

J4iru5

Member

got a question involving battle and victory scripting.

I'm using a ME for a battle victory tune after you win a battle. This ME is different then the default ones, and is much longer in terms of song length. After the battle is over the song keeps playing.
So i wanted to make it stop or fade out after a battle is concluded, so i went to scripting, Scene_Battle, and around lines 581, and 598(Victory Processing).
I wrote $game_system.battle_end_me.stop before the last end in the victory processing script, but in game it says..
undefined method 'stop' for #<RPG::ME:0x136cd50>

Do I write what 'stop' means, and if so how?
Any help would be much appreciated.
 

J4iru5

Member

oh...
ehehhe.. may bad.
i guess i didn't have a bgm to start with.
If it's not too much to ask, is there a way to fade out the ME, instead of ending strait away? Oh, and sry if i seem like a noob... -_-"
 
Heheh, that's what i thought.
To fade out the music you can use this line: Audio.me_fade(time)
Where you replace "time" with the amount of time you want it to take to fade out the music.
The "time" number should probably be something high, atleast over 1000 for the "fade out effect" to be noticeable.
But you can play around with it until you find the exact time that suits you.
Anyway, replace the old script with this:

Code:
class Scene_Battle
  alias_method :me_end_main, :main
  def main
    me_end_main
    Audio.me_fade(2000)
  end
end

If you have any further questions just ask! :thumb:

Over and out - Gando
 
I think i know what's wrong. Your victory song is very long right?
The map BGM won't start playing until the victory music stops playing. And all we have done is to fade out the music, but the song is still playing. So a sollution to the problem could be to create a timer inside Scene_Map.
And make it count down from a certain amount, and when it reaches 0 (this is when the music is totally faded out) we make the victory music stop playing. Replace your old script with this:

Code:
class Scene_Battle
  alias_method :me_end_main, :main
  def main
    me_end_main
    Audio.me_fade(5000)
  end
end

class Scene_Map
  alias timer_update update

  def initialize
    @gando = 200
  end
  def update
    if @gando > 0
      @gando -= 1
    elsif @gando == 0
      Audio.me_stop
    end
    timer_update
  end
end

Replace the number in @gando = 200 to something that suits you better.
The timer will start at 200 and count down by 1 each frame.
Just play around with that number until it stops the music when the music is faded out.
Good luck! :thumb:

Over and out - Gando
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top