The main feature people usually want from a BGM mod, and one of the easiest things to add in any game.
const myRandomBgm = random_song(10000, 10009)
encounter["Normal Battles"]:
music = myRandomBgm
end
With just 4 lines of code, all normal battles now have randomized BGM. Let's break down what each line does.
const myRandomBgm = random_song(10000, 10009)
This line creates a constant named myRandomBgm. Constants are like variables in math: if x = 42, then x + 1 = 43.
In this case, myRandomBgm is being set to equal random_song(10000, 10009)
.
What random_song(10000, 10009)
does is randomly play a BGM ID between 10000,
the
minimum ID, and 10009, the maximum ID.
Now, whenever you use myRandomBgm, it'll randomly play a BGM ID between 10000 and 10009 for a total of 10 possible songs.
encounter["Normal Battles"]:
This is the start of an Encounter Block. Encounter is just another name for battles. Encounter Blocks are what you use to change battle music.
Between the [ ]
brackets, you enter what battle(s) you want to change. In this case,
what we're changing are Normal Battles, which is a Collection. Collections are
just a collection of numbers representing an ID.
If you're starting out, stick to premade battle Collections. More advanced users can use Encounter IDs, if needed.
Notice that Normal Battles is surrounded by " " double quotes. Always surround with double quotes when using collection names.
music = myRandomBgm
Finally, you set the music for the battle(s). Probably the easiest line to understand, nothing to say really.
end
The End (of the Encounter Block). Every type of block needs to be ended by having end
at the end.
Persona 5 RoyalRemember 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
Save your music script, add audio tracks for BGM IDs 10000 to 10009 according to the instructions at: Using New Music, then test in-game.
Continue