Documentation

General

Constants

Constants are variables that can reused through out a script. Most useful when you're repeatedly using the same value.

const answer = 42
const text = "question"
const songs = random_song(1, 5)

Using Constants

Here, instead of copy and pasting random_song(1, 6) over and over again, you can give it a name to use instead.

This also means you can make changes in one place and have it apply everywhere the constant was used.

const customSongs = random_song(1, 6)

encounter["Yukiko's Castle"]:
  music = customSongs
end

encounter["Void Quest"]:
  music = customSongs
end

encounter["Hollow Forest"]:
  music = customSongs
end

Collections

Collections are text files that contain a list of numbers, usually some sort of ID. For example, the included collections contain lists of encounter IDs.

/Resources/Persona 4 Golden PC x64/collections/Bosses.enc
// Bosses
// Shadow (spoiler)
512
// Shadow (spoiler)
513
// Shadow (spoiler)
514
// Shadow (spoiler)
515
...

Using Collections

Collections let you make changes to multiple items at once, instead of one by one. For example, you can change the music for all boss battles by using the Bosses collection.

encounter["Bosses"]:
  music = 42
end

Find all available collections here.

Functions

song(name)

song("reach out to the truth")

Reference a song by its name instead of its Song ID.

random_song(minSongId, maxSongId)

random_song(1, 10)

Randomly play a song ID from minSongId up to, and including, maxSongId.

battle_bgm(normal, advantage[, disadvantage])

battle_bgm(song("time to make history"), song("reach out to the truth"))

Plays music depending on the battle's context. Encounters only.

Encounters (Battles)

Battles, also known as Encounters, can have the battle music and victory music changed. Both can also be changed depending on the battle's context.

The battle's context can be: a normal battle, player's advantage, player's disadvantage (enemy advantage). For example, Persona 4 Golden plays Time to Make History for normal battles, and Reach Out to the Truth for player advantage.

Encounter Block

To change a battle's music, you start by creating an Encounter Block.
encounter[]:
end

Between the [ ] brackets, you set what encounter you are editing. You can use an encounter's ID:

encounter[100]

or a collection of encounter IDs:

encounter["Bosses"]

Encounter Commands

Inside the block, you can then set the encounter(s)'s music using commands:

encounter["Bosses"]:
  music = 42
end

For example, the code above will set all boss battles to play song ID 42.

Difference between music and context_bgm?

Using music will always play that music, no matter the context. Using advantage_bgm will only play that music if the battle context is advantage.

Available Commands
music
victory_music
normal_bgm
victory_normal_bgm
advantage_bgm
victory_advantage_bgm
disadvantage_bgm
victory_disadvantage_bgm

Global BGM

Override a song across the entire game.

This can be used to replace normal/advantage BGM easily, randomize a specific song, have a P5R costume-like effect, and who knows what else.

Global BGM Block

Between the [ ] brackets, set the Song ID to replace. Then use music to set the music you want to play instead.
global_bgm[42]:
  music = 24
end

Floors (Persona 4 Golden and Persona 3 Portable)

Set what music is used on a floor in the TV World or Tartarus.

Floor Block

Between the [ ] brackets, set the Floor ID or a collection of Floor IDs you want to edit. Then use music to set the BGM used on those floor(s).
floor[100]:
  music = 42
end

Events (Persona 4 Golden)

Change when and what BGM is used during events by using the Event Block. Event BGM editing is a bit more advanced but Persona Music Script simplifies the process greatly.

Setup for Event Editing

First you need to know the Major ID and Minor ID of the event you want to edit, including what frames to make changes on. BGME Framework includes a useful feature for showing this information in the console.

Enable Event Information

In Reloaded, select BGME Framework and click Configure Mod. In the config window, change the logging level to Debug.

Hot Reload

Changes to events require new files to be built. BGME Framework handles building these files but this is only done at the start of the game, by default. If you want changes to events to update in real-time, enable Hot Reload in BGME Framework and CRI FileSystem V2 Hook.

Creating an Event

Start by creating a constant, then set it to the event you want to edit using: event(majorId, minorId).
const introLimoEvent = event(101, 1)

Event Block

Between the [ ] brackets, place your event constant.

Event Blocks only have one command: frame_#, where # is the frame number you want to set the music for. The example shown will play Song ID 42 on frame 100.

const introLimoEvent = event(101, 1)
event[introLimoEvent]:
  frame_100 = 42
end
Using Frame BGM

There's also a special type of BGM just for frames, called frame_bgm. This BGM lets you use some useful BGM effects, like transitions and stops.

const introLimoEvent = event(101, 1)
event[introLimoEvent]:
  // Options:
  // BGM_ALL STOP
  // BGM_FADE_IN
  // BGM_FADE_OUT
  // BGM_PLAY
  // BGM_VOLUME_DOWN
  // BGM_VOLUME_UP
  // BGM_ALL_STOP
  frame_100 = frame_bgm(BGM_PLAY, 42)
end