Backgrounds and music

*For the main page about battles, see Battles.*

This page describes how the **backgrounds and music** are set for a battle.

## Backgrounds

The background is what appears behind the Pokémon in a battle. It is composed of four separate images:

* `XXX_bg.png` - The far background, which can be a tiled image.
* `XXX_base0.png` - The circle of land under the player's Pokémon.
* `XXX_base1.png` - The circle of land under the opposing Pokémon.
* `XXX_message.png` - The background behind the command/message bar.

"`XXX`" is a word or phrase (see below). These images are all kept in the folder "Graphics/Battlebacks".

### Deciding which background to use

In the script section **Scene\_Initialize** is `def pbCreateBackdropSprites`. This method determines which background pictures to use for a given battle.

As mentioned above, the filenames of the background, the bases and the bar contain a certain word or phrase ("`XXX`"). This word/phrase is constructed from up to three parts: the backdrop, the base and the time. They are used as follows:

* Background: "`XXX`" is in the form "backdrop\_time" or "backdrop" (the first one that corresponds to an existing graphic)
* Bases: "`XXX`" is in the form "backdrop\_base\_time" or "backdrop\_base" or "base\_time" or "base" (the first one that corresponds to an existing graphic)
* Message bar: "`XXX`" is in the form "backdrop\_time" or "backdrop" (the first one that corresponds to an existing graphic)

Note that each of these three kinds of graphics are checked separately. It is possible for the background to have an "`XXX`" in the form of "backdrop\_time", but the message bar to have an "`XXX`" in the form of "backdrop" (rather than "backdrop\_time") if there is no message bar graphic with that particular name. For the two bases, only the "base0" (the player's base) graphics are checked for; it is assumed that the "base0" and "base1" graphics are always paired up (i.e. that they either both exist for a given "`XXX`" or that neither of them do).

The following table describes in more detail what the backdrop, base and time parts will actually be:

 base
This depends on the battle's environment (as determined in `def pbGetEnvironment`, and can be "grass", "sand", "water", "puddle" or "ice" by default. If the battle's environment doesn't correspond to any of these phrases, it will be blank instead.
 time

This can be difficult to understand, as there are several steps involved in determining the phrases and checks for whether graphics exist.

### Examples

If the backdrop phrase is "field", the player is surfing, and it is the evening, then the following graphics are used:

* `field_eve_bg.png`
* `field_water_eve_base0.png`
* `field_water_eve_base1.png`
* `field_eve_message.png`

If the backdrop phrase is "mountain", there is no special environment that would affect the battle's appearance (i.e. base is ""), and it is the day, then the following graphics are used:

* `mountain_bg.png`
* `mountain_base0.png`
* `mountain_base1.png`
* `mountain_message.png`

If the backdrop phrase is "indoor1", there is no special environment that would affect the battle's appearance (i.e. base is ""), and it is night, then the following graphics *would be* used:

* `indoor1_night_bg.png`
* `indoor1_night_base0.png`
* `indoor1_night_base0.png`
* `indoor1_night_message.png`

However, if there are no files that exist with those names (which is typically the case for indoor backgrounds, which won't have evening/night versions), then the following will be used instead:

* `indoor1_bg.png`
* `indoor1_base0.png`
* `indoor1_base0.png`
* `indoor1_message.png`

## Music

The background music played during battles is defined by the map metadata values "WildBattleBGM" and "TrainerBattleBGM". There are also three map-specific metadata values called "WildVictoryBGM", "TrainerVictoryBGM" and "WildCaptureME", which are the music/jingle played upon the player winning a battle/catching a Pokémon.

If there is no map-specific music defined for a map, there are global metadata values of the same names that will be used instead.

The above can be overridden by defining battle music and/or a victory jingle for a trainer type. When battling a trainer of that trainer type, their specific background music will be used instead of what was defined in the map/global metadata.

Finally, all of the above can be overridden for a single battle (the very next one, regardless of whether it's a wild or a trainer battle) by putting either/both of the following lines of code in a Script event command before the call to that battle:

* `$PokemonGlobal.nextBattleBGM = "epicbattle17"` - This sets the background music to the named track.
* `$PokemonGlobal.nextBattleVictoryBGM = "winmusic3"` - This sets the victory music to the named track.
* `$PokemonGlobal.nextBattleCaptureME = "catchjingle"` - This sets the capture success jingle to the named ME.