• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • It's time to vote for your favorite Pokémon Battle Revolution protagonist in our new weekly protagonist poll! Click here to cast your vote and let us know which PBR protagonist you like most.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Switching between two overworld BGMs

  • 226
    Posts
    9
    Years
    • Seen Feb 20, 2025
    Hello,

    I am facing an annoying "detail" I cannot manage to fix.
    Let's say I am on Map 1 and a background music, BGM1, is playing.

    Now, when a global switch is turned on, BGM2 should be playing instead of BGM1.

    Forcing the game to play BGM2 is easy since you have a direct command for that, but you cannot actually replace the Map BGM directly. So when a battle ends, or if the player saves the game, leaves and comes back, he will heard BGM1 again.

    Using a parallel process event to force the game to play BGM2 is not great because it will play BGM2 during battles as well.
    I thought about an autorun, but I cannot figure out exactly how I should trigger it.

    Anyone already solved a similar problem in their own games? Thanks.
     
    Last edited:
    Try using this script call to override the default BGM: $game_system.setDefaultBGM("yourBGM")

    Thenwhen you'll be getting out of the map you could use:
    $game_system.setDefaultBGM("nil")

    I haven't tested it though.
     
    Try using this script call to override the default BGM: $game_system.setDefaultBGM("yourBGM")

    With this method, BGM2 indeed replaces BGM1.

    If you quit and load the game, BGM2 will play instead of BGM1, which is nice.

    However, if you encounter a wild Pokemon, BGM2 will keep playing instead of the battle music.

    So it's not exactly working.
     
    So I found the part in the scripts playing the background music.
    I noticed there was a way to use a different BGM at night.
    So I tried to copy this method to use a different BGM when a global switch is on.
    For some reason, it doesn't work though (the music doesn't play)... Any advice?

    def autoplayAsCue
    if @map.autoplay_bgm
    if $game_switches[63]=true &&
    FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "z")
    pbCueBGM(@map.bgm.name+"z",1.0,@map.bgm.volume,@map.bgm.pitch)
    else
    pbCueBGM(@map.bgm,1.0)
    end

    if PBDayNight.isNight?(pbGetTimeNow) &&
    FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "n")
    pbCueBGM(@map.bgm.name+"n",1.0,@map.bgm.volume,@map.bgm.pitch)
    else
    pbCueBGM(@map.bgm,1.0)
    end
    end
    if @map.autoplay_bgs
    pbBGSPlay(@map.bgs)
    end
    end

    I did the same at "def autoplay" and i also adjusted "def autofade (mapid)" in Scene_Map.
     
    @HarmonyConcept:
    Your code doesn't work because when checking for the night BMG you either set it to the regular BMG or the night BMG. You should change it to an elsif (if global switch, elsif night, else)
    Code:
    def autoplayAsCue
        if @map.autoplay_bgm
            if $game_switches[63]==true &&
                  FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "z")
                pbCueBGM(@map.bgm.name+"z",1.0,@map.bgm.volume,@map.bgm.pitch)
            elsif PBDayNight.isNight?(pbGetTimeNow) &&
                  FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "n")
                pbCueBGM(@map.bgm.name+"n",1.0,@map.bgm.volume,@map.bgm.pitch)
            else
                pbCueBGM(@map.bgm,1.0)
            end
        end
        if @map.autoplay_bgs
            pbBGSPlay(@map.bgs)
        end
    end

    @OP: Another solution would be to not set a default BGM and use an autorun event to set the correct BGM when entering the map (and erase the event afterwards).

    EDIT: Added the code.
     
    Last edited:
    Woops, missed that one XD (also fixed in the code placed above).
     
    Would I be able to use this to pull something like ALBW off, and make it so that the Pokemon League's music changes based on how many of the E4 you've defeated?
     
    Back
    Top