For a description of what happens in a battle round, see Battle round.
For how computer-controlled Pokémon/trainers make decisions in battle, see Battle AI.
For how to make animations for moves and effects, see Attack animations.
For how a battle's background images and music are chosen, see Backgrounds and music.
For what happens at the end of a battle, see Ending a battle.
For how to repeatedly battle the same trainers, see Rematches.

A Pokémon battle.

This page describes Pokémon battles, and gives an overview of the scripts involved.

Causing a battle to happen

Main article: Event encounters
Main article: Trainers

There are several ways to cause a battle to happen. You could be walking around in tall grass and a wild battle spontaneously occurs, you could walk in front of (or talk to) a trainer and enter a battle against them, or a battle could be scripted to happen when something occurs (such as interacting with something in the overworld).

There are different scripts you can use to make different kinds of battles happen. These include:

pbTrainerBattle(:YOUNGSTER,"Ben",_I("Aww, I lost."))
pbDoubleTrainerBattle(:YOUNGSTER,"Ben",0,_I("Aww, I lost."),:LASS,"Alice",0,_I("I also lost!"))

These scripts are described in more detail on the Event encounters and Trainers pages.

The Pokémon encountered in a wild battle can depend on special conditions, e.g. Roaming Pokémon or forcing a wild Pokémon to be shiny. You can create your own special conditions; see the page Wild encounters for more details.

Battle transition

When a battle occurs, the overworld need to fade to black before the battle starts. This fade to black can be a fancy animation, and is referred to as a battle transition. The main code for the battle transition is def pbBattleAnimation in the script section PField_Field.

Some battle transitions use images from the "Graphics/Transitions" folder (the images it can use are listed in the above-mentioned code). These images cover the entire screen, and describe which parts of them fade to black when (darker areas become black first). There are also some battle transition animations which are coded; these are again named in the above-mentioned code, and can be found coded in the script section Transitions. The choice of which animation to use is random.

If the battle is against a trainer, the battle transition can be made to be a Vs. animation. This requires that certain graphics files exist. See the page Trainers for more information.

Battle environment

A battle's environment is what kind of location the battle is taking place in. This can depend on various factors, including map metadata, the terrain tag of the tile being stood on, whether the player is surfing, and so on.

The environment is chosen just before the start of a battle, by def pbGetEnvironment in the script section PField_Field. The possible environments are defined in the script section PBEnvironment. (Note that not all defined environments are accessible by default; you would need to add your own code to be able to use them.)

The environment is used to decide on the appearance of the battle's background. It also affects the effects of several moves, as well as the efficiency of the Dive Ball. It also affects the forms of Burmy and Wormadam.

The battle screen

The positions of various elements in the battle screen are listed in the script section PokeBattle_SceneConstants. Note that many of these positions are relative to each other; it is recommended that you leave them that way.

The bar at the bottom can be in one of four states: showing the command menu (Fight/Bag/Pokémon/Run), showing the fight menu (the moves known by the Pokémon you're currently choosing an action for), showing messages, or blank (typically the same as showing an empty message).

Command menu

The command menu's code is in class CommandMenuDisplay in the script section PokeBattle_Scene. There is more code in class CommandMenuButtons that displays the buttons. The control of the cursor is done in def pbCommandMenuEx.

If a type with the internal name of SHADOW is defined, and the battle is against a trainer, the "Run" command will be replaced with the "Call" command. This is decided in def pbCommandMenu.

There is also def pbSafariCommandMenu, which decides on the commands available in a Safari Zone battle. Similarly, def pbCommandMenu in the script section PBattle_BugContest decides on the commands available in a Bug Catching Contest battle.

Each unique command is assigned its own value, which is used to decide which button graphic to use for it.

You cannot run from trainer battles. However, if you are playing in Debug mode and you hold Ctrl when you select "Run", you will be able to do so. You can choose whether to treat the battle as a win or a loss for the player.

Fight menu

The fight menu's code is in class FightMenuDisplay in the script section PokeBattle_Scene. There is more code in class FightMenuButtons that displays the visual elements of the menu. The control of the cursor is done in def pbFightMenu.

If the Pokémon you are currently choosing a command for is able to Mega Evolve, an extra icon will appear to indicate this. Rather than clicking on it, however, you will need to press the key indicated to register that you want the Pokémon to Mega Evolve. In Debug mode, holding Ctrl when opening the fight menu will bypass certain checks of whether the Pokémon can Mega Evolve.

Data box

A data box is a panel floating on the screen which contains information about one of the active Pokémon. In a single battle, there will be two of them; in a double battle, there can be up to four.

The appearance of a data box is defined in class PokemonDataBox in the script section PokeBattle_Scene. There is a separate class just above that code for the data box used in Safari Zone battles.

Related tutorials

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.