Better way to make character BGM?

fallent

Villager
Member
Joined
Jul 4, 2020
Messages
15
Reaction score
4
First Language
English
Primarily Uses
RMMV
In the game I'm making, each character has a background music that plays when a conversation happens with them within an event. However, I'd like for the map background music to resume after this event ends. Right now I'm having a switch be turned on after the conversation ends, and then using a parallel event to turn on the original map music.
I'm afraid of too much conditional branches + complications/lag if I continue using this method, does anyone knows a better way to do this?
 

Attachments

Mhin Ra

Veteran
Veteran
Joined
Aug 17, 2015
Messages
61
Reaction score
18
First Language
English
Primarily Uses
RMVXA
I don't change the music at each conversation in my game, but I did have a similar problem around wanting to set 'override' music and then be able to clear it to go back to whatever the map's default music was. What I'm using is fairly complex and does a bunch of other stuff. However, I think the core issue you have is fairly easily solved. Try something like this (paste it in as a new script):

Ruby:
class Game_System
  attr_accessor :lastPlayedBgm, :restoreToBgm
end

class Game_Interpreter
 
  alias :mrLastPlayed_command241 :command_241
  def command_241
    $game_system.lastPlayedBgm = @params[0]
    mrLastPlayed_command241()
  end
 
  def saveBGM
    $game_system.restoreToBgm = $game_system.lastPlayedBgm
  end
 
  def restoreBGM
    $game_message.add("No saved BGM") if $game_system.restoreToBgm == nil
    $game_system.restoreToBgm.play
    $game_system.restoreToBgm = nil
  end
 
end
And then if you write an event like this:

1594142141164.png

You get more or less the effect I think you want. I didn't test it very thoroughly if you do the save and restore in different events (or different maps or save before then restore after a saveGame). But, for the use case you're describing, none of that should matter too much.
 

fallent

Villager
Member
Joined
Jul 4, 2020
Messages
15
Reaction score
4
First Language
English
Primarily Uses
RMMV
Thanks so much!! I'll test it out :D
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I'm sure this question's been asked before, but I can't find an answer: is there any way to run the Steam version of RPGMaker *without* being logged into Steam? It's a frustrating extra step sometimes.
Been seeing bright flashes in the sky for a while, and thought it was my eyes playing tricks on me. Nope! Lightning. Now it's raining heavily. Seeing lightning, but not hearing thunder, is weird.
Small Update for myself:
>Two Dungeon maps are done, Dungeon 3 is in progress. Dungeon 4 needs work.
>4 characters set up out of a possible 6 but those come later.
>Hub area needs work.
>Game completion..., 20-25% maybe?
Does anyone else find writing dialogue hard?
You guys want more tutorials? Well not only are we doing new video tutorials with Driftwood, we've also brought in two contributing authors for the blog to get a new tutorial every week! First one here from @Avery
https://blog.rpgmakerweb.com/tutorials/tutorial-mapping-interior/

Next week we'll get something from @hiddenone

Forum statistics

Threads
100,712
Messages
978,633
Members
132,325
Latest member
ighjku
Top