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 Profile Posts

Got inspired and started writing a simple tower defence battle system last night :o
Good news! I have located an amazing 3D website called SketchFab that has rotatable renderings of famous statues!
Picked up a physical copy of Megadimension Neptunia VII for the PS4 today. It's pretty good. I'm having a lot of fun with it.
The only upside of this remote semester was the plenty of funny photoshop material those facecams provided. Not that I would do that. Ever.

Forum statistics

Threads
100,516
Messages
976,702
Members
132,080
Latest member
nwr
Top