Custom Battle BGM

In the previous guide, you set all normal battles to use random BGM. But this also had the unintended effect of removing the music used during advantage battles.

This guide will go over how you can add it back, customize the victory screen music, and even add disadvantage music.

Requirements

This guide builds off the previous one: Adding Randomized BGM. If you don't want random BGM then you can just read through it and come back.

Current Music Script

const myRandomBgm = random_song(10000, 10009)

encounter["Normal Battles"]:
  music = myRandomBgm
end

Battle Context

A battle's context is how the player entered the battle. The three types are: normal, with an advantage, or at a disadvantage.

There are two ways to set music depending on the battle's context, the first we'll be using is: battle_bgm(normal, advantage, disadvantage).

Where you see each battle context, you'll slot in the music you want played for that context.

New Music Script

const myRandomBgm = random_song(10000, 10009)
const myRandomBgm2 = random_song(10010, 10019)

encounter["Normal Battles"]:
  music = battle_bgm(myRandomBgm, myRandomBgm2, song("Blooming Villain"))
end

Changes: a new constant with another 10 random songs was added and music was set to use battle_bgm. Let's break down the latter.

Battle BGM

  music = battle_bgm(myRandomBgm, myRandomBgm2, song("Blooming Villain"))
  music = battle_bgm(normal, advantage, disadvantage)

Next to each other, hopefully it's clear how it works.

  • When the battle context is normal, it'll use myRandomBgm.
  • When the battle context is advantage, it'll use myRandomBgm2.
  • When the battle context is disadvantage, it'll play Blooming Villain.
song("Blooming Villain") is a new, but simple, feature. It lets you use in-game songs by name instead of BGM ID. Like collections, wrap the song's name in " " double quotes.

So Far

Now, normal battles will play 10 random songs during normal context, another 10 random songs during advantages, and a song during disadvantages.

But what about Victory music (asked no one)?

Victory Music

While battle_bgm is great if you want to set music during normal/advantage, or all three, it doesn't let you change it for just advantage or just disadvantage.

For Victory music, we'll use the second way to set music depending on context.

The Second Way

const myRandomBgm = random_song(10000, 10009)
const myRandomBgm2 = random_song(10010, 10019)

encounter["Normal Battles"]:
  music = battle_bgm(myRandomBgm, myRandomBgm2, song("Blooming Villain"))
  victory_advantage_bgm = song("Big Bang Burger March")
end

Only one new line, and it reads pretty easy.

  victory_advantage_bgm = song("Big Bang Burger March")

You specify you want to change the victory music, during advantage, and to play the song Big Bang Burger March.

If you wanted to do the same for battle music, you would use advantage_bgm = song("Big Bang Burger March").

Finished

Persona 5 Royal

Remember that new music have their BGM IDs shifted by 10,000 in music scripts. To play music file 100.adx, you would use BGM ID 10100 (100 + 10000) in your music script. For details, see: Using New Music

Edit your script, save, add music, and test.

Continue