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

12 done, 4-5 started. Now that the weekend is over, things will sloooowwwww down again proabably.
when you're completely done with someone's crap lol...
Ami
--- Survival For RPGist Part 3 ---

F.Healer: Here it is,I made the Simple Sandwich
Survivalist
: it's so Delicious!
Chef: Here you Go! My Gourmet Steak.
Survivalist: It's Super Delicious,Too!
F.Mage: I Made it for you!
F.Healer: Uhh...Charcoal?
F.Mage No,It's a Toast!
Chef: Did you Let it in 10 Minutes?
F.Mage: Maybe?

Forum statistics

Threads
103,033
Messages
996,817
Members
134,507
Latest member
juegostudios
Top