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

"I, Giorno Giovanna, have a dream". In all seriousness, spatial BGM feature is now complete for my audio plugin.
Stream will be live shortly with some game development followed by the return of the Interactive Text Adventure after a short hiatus! Feel free to drop by!
Lately, I've taken to smashing random nouns/verbs together as insults. It's sort of amusing how many people don't really know how to respond to that. You bottle shaker!
Would be nice to pick color code that is not exclusively for message event
The Ace attorney series are so great games... But at the same time such a travesty.

Forum statistics

Threads
103,243
Messages
998,316
Members
134,733
Latest member
Shadowgrahp
Top