FANDOM



Below is a list of the script sections which contain all the code for Pokémon Essentials (Version 16.1). Each section gives a brief description of its purpose and lists the major methods and classes defined in each section. If there is a main article pertaining to the scripts purpose, it will be linked.

The list of methods and classes is not exhaustive (as that would take up a lot of space) but are representative. For coders looking for a particular method in the library, please use the Ctrl+Shift+F function in RMXP's Script Editor to do a "find all".

Settings

This section is a collection of constants that define various things the user can easily turn on and off. The options available are some of the most common things users would want to change. They include switches and constants for:

  • Screen size
  • Pokemon level cap, egg level, shiny and pokerus chances
  • Overworld Mechanics: poison, fishing, diving, berries
  • Infinite TMs
  • Day/Night Shading
  • Signposts (the route name that appears on-screen)
  • Battle Mechanics: physical/special split, Gen 6 battle and EXP mechanics, scaled EXP, critical capture
  • Badge boosts, Badge requirements for HM use.
  • Bag pocket names, size limits, and sorting. (pbPocketNames)
  • Storage system size, and creator name (pbStorageCreator)
  • Pokedex mechanics (pbDexNames)
  • Money limits
  • Rival names in battle
  • Roaming pokemon settings
  • Poké Radar settings
  • Region map extras
  • Contest settings
  • Assigning global switches, common events, and animations to Essentials mechanics.
  • Languages for internationalization.
  • Whether to allow the user to use the keyboard instead of the on-screen keyboard to enter text.


RGSS2Compatibility

These scripts support the use of RGSS2 players in Pokémon Essentials. Note that this is not the same as Essentials being compatible with RPG Maker VX - only the RGSS2 player is compatible.


RPG__Sprite

Defines
SpriteAnimation

This section contains the basic definition of what a sprite is. Practically everything visual in the game depends on this.


Win32API

This section connects the game with Window's API, which allows it to do things like reposition the main window and set the window title.


Sockets

Defines
pbPostData
pbDownloadData
pbHttpRequest
pbDownloadToString
pbDownloadToFile
pbPostToString
pbPostToFile
Main article: Internet

This section handles how the game can connect to the Internet and retrieve information. This is used by Essentials' Mystery Gift function.


DebugConsole

Defines
Console::setup_console
Console::readInput
Console::readInput2
Console::get_input
Kernel.echo
Kernel.echoln

This section defines the debug console built into Essentials. To use the console, open up the debug menu in-game (F9) and select the "Open Debug Console" option at the bottom of the list. This console cannot be typed into (usually), but it will output logging information. To log to the console, use Kernel.echo(string) or Kernel.echoln(string).


Game_Temp

This section defines Game_Temp, which handles all temporary data. This data is NOT saved in a save game. Use $game_temp to access the global instance of this class. Most all of the data kept in this class is used by Essentials internally; chances are slim that you'll need to touch this data.

Game_System

Defines
$game_system.timer
$game_system.save_disabled
$game_system.menu_disabled
$game_system.encounter_disabled
$game_system.save_count
$game_system.bgm_play(bgm)
$game_system.bgm_memorize
$game_system.bgm_restore
$game_system.me_play(me)
$game_system.bgs_play(bgs)
$game_system.bgs_stop
$game_system.bgs_fade(time)
$game_system.se_play(se)

This section defines Game_System, which handles various system data which is saved in the save file. Use $game_system to access the global instance of this class. There are functions which play music and sound effects in this class.


Game_Switches

Main article: Events#Global_Switches

This section defines Game_Switches, which handles the game's Global Switches. Use $game_switches to access the global instance of this class. You cannot have more than 5000 switches.

Note: Script Switches do not have the results of their scripts stored in them. For example, $game_switches[15] (switch 15, defined as "s:PBDayNight.isNight?(pbGetTimeNow)") will always contain false regardless of the time of day.


Game_Variables

Main article: Events

This section defines Game_Variables, which handles the game's Global Variables. Use $game_variables to access the global instance of this class. You cannot have more than 5000 variables.


Game_SelfSwitches

Main article: Events

This section defines Game_SelfSwitches, which handles the game's event Self Switches. Use $game_self_switches to access the global instance of this class. Keys into this hashmap are an array, of the form [mapid, eventid, switchname].

You should use the function pbSetSelfSwitch(eventid,switch,value) to set self-switches of other events on the current map.


Game_Screen

Defines
$game_screen.start_tone_change
$game_screen.start_flash
$game_screen.start_shake
$game_screen.weather

This section defines Game_Screen, which handles visual effects such as changing the colour tone of the screen or flashing. Use $game_screen to access the global instance of this class.


Game_Picture

This section defines Game_Picture, which handles displaying pictures. Instances of this class are used in Game_Screen.


Game_Map

Defines
$game_map.name
$game_map.map_id

This section defines Game_Map, which contains the basic definition of a game map. Use $game_map to access the current map's instance.


Game_Map_Resolution

This section extends Game_Map to allow Essentials to scale up the game, and includes display corrections for when the map is set to snap to edges (i.e. the screen stops scrolling).


Game_Map_Autoscroll

Defines
autoscroll(x,y,speed)
autoscroll_player(speed)

This section extends Game_Map to allow easier map scrolling for cutscenes. The functions listed to the right are defined in the Interpreter, and thus will work unadorned from event scripts.

This section handles additional map scrolling features. These additional features include:

  • Scrolling to a given map location or to the player.
  • Following a moving character.
  • Setting the speed at which the scrolling occurs.
  • Scrolling diagonally.

The supported commands are as follows:

autoscroll(x,y) Scrolls to the given coordinates (at a default speed of 4). Diagonal scrolling occurs automatically. The coordinates can be variables as well as numbers (e.g. setting the variables to equal the coordinates of an NPC means the screen will follow that NPC).
autoscroll(x,y,speed) As above, but you can also define the scroll speed (between 1 and 6).
autoscroll_player(speed) Scrolls to (and follows) the player at the given speed (between 1 and 6).

The above commands must be on a single line in an event's "Script" command, and must be the first line in that command.


Game_CommonEvent

This section defines Game_CommonEvent, which handles common events. Common events are those listed in the Database.


Game_Character

Defines
Game_Character
  .moving?
  .jumping?
  .moveto(x,y)
  .move_{direction}
  .turn_{direction}
  .move_towards_player
  .move_away_from_player
  .jump(x_plus,y_plus)

This section defines Game_Character, which handles various aspects of game events, including basic definition, forced move routes, centring the screen on the player, and bushes.


Game_Event

Defines
Game_Event
  .map_id
  .name
  .id
  .tsOn?(c)
  .tsOff?(c)
  .setTempSwitch{On|Off}(c)
  .switchIsOn?(id)

This section defines Game_Event, a subclass of Game_Character, which handles the basic details of events.

This class defines a concept of "TempSwitches", which are switches which are kept in the instance of the Game_Event only, and not saved off even between map changes. Thus Temporary switches are reset when the player leaves the map and comes back. Doors in the Essentials example project use temporary switches to play the animation of the player leaving a house once and only once upon map load. (Hint: If you're having trouble making the exit animation on doors play when you're moving a player between rooms on the same map, set the temporary switches of the doors on the map back off as part of the transition.)

The .switchIsOn?(id) function defined in this class is responsible for executing Script Switches and returning the result to the event's condition evaluation process.


Game_Player

Defines
$game_player.move_{direction}
$game_player.pbHasDependentEvents?
$game_player.pbTriggeredTrainerEvents
$game_player.pbTriggeredCounterEvents
$game_player.center(x,y)

This section defines Game_Player, a subclass of Game_Character, which handles the player character, including movement, checking whether a trainer can spot the player from a distance, tile passabilities, map scrolling and interacting with events. Use $game_player to access the global instance of this class.

The function pbTriggeredTrainerEvents checks all events named "Trainer(##)" on the current map to see if they can reach the player. The function pbTriggeredCounterEvents checks all events named "Counter(##)" on the current map to see if they are facing the player. Both methods return all events that pass their respective checks in an array.


Walk_Run

Defines
$game_player.pbCanRun?
$game_player.pbIsRunning?
Main article: Getting around

This section extends Game_Player to how the player runs and cycles, including defining where these can be done and how quickly the player moves when they do so. It also defines the player's walking speed.


Sprite_Character

This section defines BushBitmap and Sprite_Character. They handle how bush tiles are displayed, and the display of an event's sprite.


Sprite_Picture

This section defines Sprite_Picture, which handles the display of sprite pictures (stored in "Graphics/Pictures/").


Sprite_Timer

This section defines Sprite_Timer, which handles showing a window displaying a timer, usually one that counts down to 0.


Sprite_Resizer

Defines
pbSetResizeFactor
pbConfigureFullScreen

This section extends several classes which allow the game to zoom the game to a 0.5, 1.5, and 2.0 times the size of normal.


Spriteset_Map

This section defines ReflectedSprite and ClippableSprite, which handle reflecting sprites in still water (terrain tag 6 tiles). It also defines Spriteset_Map, which handles displaying maps.


Tilemap_XP

This section defines CustomTilemap, as well as several supporting classes, which reimplement XP's Tilemap class with functionality for scaling and specialized autotiles. (?)


Tilemap_Perspective

Defines
ScreenPosHelper::pbScreenZoom{X|Y}
ScreenPosHelper::pbScreen{X|Y|Z}
ScreenPosHelper::bmHeight
bltMinimapAutotile
getPassabilityMinimap
Main article: Perspective mode

This section defines Draw_Tilemap along with a few helper methods, which deal with showing maps in perspective mode


TilemapLoader

This section defines TilemapLoader, which is a proxy class for the various kinds of TileMap classes defined in previous sections.


TileDrawingHelper

This section defines TileDrawingHelper, which handles how autotile graphics are arranged, and how to draw them and regular tiles.


AnimationSprite

Defines
Spriteset_Map
  .addUserSprite
  .addUserAnimation

This section defines AnimationSprite, which is used to display one-off animations on the map (like grass rustling). This section extends Spriteset_Map to use AnimationSprite.


ParticleEngine

Main article: Particle effects

This section defines Particle_Engine and helper classes, which handle the display of particle effects, such as those on Route 3 in the Essentials example project. It defines the effects "fire", "smoke", "teleport", "spirit", "explosion", "aura", "soot", "sootsmoke", "rocket", "fixteleport", "smokescreen", "flare", "splash", and "starteleport". This section extends the Game_Event class to support these particle effects.


DynamicShadows

This section defines Sprite_Shadow, which displays the dynamic sprite shadows created when walking near a shadow source (as seen on Cycling Road in the Essentials example project). This section extends Sprite_Character, Game_Event, and Spriteset_Map to support this.


Interpreter

Defines
pbExecuteScript
get_character

This section defines Interpreter, which handles the running of game events. This class defines how the game runs every command you can put in an event. See the execute_command function to find which command_### function applies to which event command.


Event

Defines
Event
  .trigger
  +=proc
  -=proc

This section defines Event, which is an event listener structure (and not related to RMXP events). Given an instance of the Event class evt, you can register a callback to be run by using:

evt+=proc {|sender,params|
  # Your code here
}

Procedures can be deregistered by using -=, and the callback list can be triggered using the trigger(args) and trigger2(args) methods. This is used by item effects, encounter generation, player step reactions, etc.

The class HandlerHash is also defined in this section.


File_Mixins

Defines
FileInputMixin
FileOutputMixin
File
StringInput
StringOutput

This section defines several functions for file IO.


Intl_Messages

Defines
pbAddScriptTexts
pbAddRgssScriptTexts
pbSetTextMessages
pbGetText
pbCompileText
pbLoadMessages
_INTL(*arg)
_ISPRINTF(*arg)
_I(str)
_MAPINTL(mapid,*arg)
_MAPISPRINTF(mapid,*arg)

This section defines Messages, MessageTypes, OrderedHash, and several functions for internationalization.


PBDebug

This section defines PBDebug, which handles logging to files.


Audio

Defines
safeExists?(f)
Audio.bgm_play
Audio.bgm_fade
Audio.bgm_stop
Audio.me_play
Audio.me_fade
Audio.me_stop
Audio.bgs_play
Audio.bgs_fade
Audio.bgs_stop

This section defines the Audio module, which handles the playing of audio files.


AudioPlay

Defines
pbBGMPlay(param)
pbBGMFade
pbBGMStop
pbMEPlay(param)
pbMEFade
pbMEStop
pbBGSPlay(param)
pbBGSFade
pbBGSStop
pbSEPlay(param)
pbSEFade
pbSEStop
pbPlayCursorSE
pbPlayDecisionSE
pbPlayCancelSE
pbPlayBuzzerSE

This section defines several global functions for playing audio. These functions are likely what you want to use if you want to play audio from a script.


AudioUtilities

Defines
Audio.noise
Audio.envelopeDuration
Audio.oscillateDouble
Audio.oscillate
Audio.frac
Audio.sine
Audio.doubleSine
Audio.noise2
Audio.square
Audio.dtmf
Audio.beep
Audio.triangle
Audio.triangle2
Audio.playTone
Audio.saw
ringtone(duration)
backspace
callwaiting
callheld
loudFastBusy
tone{CountyCode}
beginRecord
getRecorderSample
stopRecord
endRecord

This section extends the Audio module to include ways to generate sounds and notes on the fly. Helper methods include ways to create tones you would hear on a phone. It also defines functions for recording audio and saving it off, used in Essentials' implementation of the Chatter move.


BitmapCache

Defines
WeakRef
WeakHashtable
Cache
BitmapWrapper
BitmapCache.load_bitmap

This section defines the BitmapCache module, which handles caching loaded image files.


Window

This section defines the Window class, which is the base class for text windows, command lists, etc. The code to draw the windows from a small bitmap is defined in this section.


SpriteWindow

Defines
MessageConfig
GifLibrary
AnimatedBitmap
SpriteWrapper
AnimatedSprite
IconSprite
ColoredPlane
AnimatedPlane
SpriteWindowCursorRect
SpriteWindow
SpriteWindow_Base
SpriteWindow_Selectable
SpriteWindow_SelectableEx
Window_DrawableCommand
Window_CommandPokemon
Window_AdvancedCommandPokemon
Window_UnformattedTextPokemon
Window_AdvancedTextPokemon
Window_InputNumberPokemon
Window_CommandPokemonEx
Window_AdvancedCommandPokemonEx
IconWindow
PictureWindow
pbGetTileBitmap
pbGetAnimation
pbGetTileset
pbGetAutotile
pbFadeOutIn
pbFadeOutAndHide
pbFadeInAndShow
pbResolveBitmap
addBackgroundPlane
pbSetSystemFont
pbRgssExists?
pbRgssOpen

This section defines many classes and methods which Essentials uses to draw its UI windows, and its animated sprites. It also defines a few methods for opening data files.

  • The MessageConfig module defined at the top of the file defines many of the default colors and fonts used by the system.
  • The AnimatedBitmap proxy class is used by much of the library to display almost everything, from pokemon's icons in the party screen, to battlers in battle, to items in the bag, to cards in Triple Triad.
  • The SpriteWindow class is the base for every window used by Essentials' UI. It has many subclasses that serve many different purposes.
  • The pbFadeOutIn method is used in several places to fade out to a new submenu, such as when you go into the party screen from the pause menu.


DrawText

Defines
getLineBrokenChunks
renderLineBrokenChunks
renderLineBrokenChunksWithShadow
getFormattedText
drawBitmapBuffer
Main article: Messages

This section defines several methods which handle the drawing of text to the screen, as well as the effects of the various message modifiers (colour changes, repositioning, displaying extra things, etc).


Messages

Defines
pbMapInterpreterRunning?
pbMapInterpreter
pbGlobalLock
pbGlobalUnlock
pbChooseNumber
Kernel.pbMessage
Kernel.pbMessageChooseNumber
Kernel.pbConfirmMessage
Kernel.pbConfirmMessageSerious
pbPositionFaceWindow
pbPositionNearMsgWindow
pbGetMapNameFromId
Kernel.pbMessageDisplay
Main article: Messages

This section defines many of the methods Essentials uses to display messages to the player.

  • Kernel.pbMessage is the most basic message display, and the one you most often will use when displaying a message from a script. It is the method called internally when you use a Text Command in an event.
  • Kernel.pbConfirmMessage and pbConfirmMessageSerious display a Yes/No (or in the case of -Serious, a No/Yes) choice to the player.
  • Kernel.pbMessageChooseNumber will ask the player to enter a number.
  • Kernel.pbMessageDisplay is the eventual call of all of the above. This is where the message you passed has all of its modifiers and text replacements processed.


TextEntry

Defines
Window_TextEntry
Window_MultilineTextEntry
Window_TextEntry_Keyboard
PokemonEntryScene
PokemonEntryScene2
getLineBrokenText
Kernel.pbFreeText
Kernel.pbMessageFreeText
pbEnterText
pbEnterPlayerName
pbEnterPokemonName
pbEnterBoxName
pbEnterNPCName

This section defines several methods and classes which handle the various text entry methods available in Essentials.


EventScene

Defines
PictureEx
PictureSprite
EventScene
setPictureSprite
pbEventScreen

This section defines the EventScene class, which is the base class for scenes that are not menus and not maps, such as the Intro splash screens, and the screen displaying the controls when starting the game. It also defines pbEventScreen(evtScene), which displays a subclass of the EventScene.


Scene_Map

This section defines the Scene_Map class, which is defines the scenes while the player character is walking around in the overworld. This class is where transferring the player, updating the map, input handling while in the overworld is handled.


Scene_Intro

Main article: Game intro

This section defines the IntroEventScene and Scene_Intro classes, which handle the intro and splash screens that appear at the start of a game.


Scene_Controls

This section defines the ButtonEventScene class, which handle the display of the controls screen, usually provided at the start of a new game when the professor asks if there is any help he can give.


Scene_Movie

This section defines the Scene_Movie class, which handles the playing of AVI movie files in-game. Movies must be in a folder "Movies" in the main game directory. Use the following code to load a movie scene:

$scene = Scene_Movie.new("MovieName")

When the movie is done or the player presses B, the game will return to the overworld view (the Scene_Map).


Scene_Credits

Main article: Credits

This section defines the Scene_Credits class, which handles the display of the credits.

To insert your own credits, edit the lines that say "Credits go here". To play the credits, use the following script:

$scene = Scene_Credits.new

All graphics used by this script are in the "Graphics/Titles" folder. You can add or change the images used by editing the CreditsBackgroundList at the top of this script section. The credits are displayed with a scrolling effect.


Transitions

This section overrides Graphics.transition to define several transition effects that occur just before a battle starts.

Tip: If you're experiencing issues with the fade effect when using Graphics.transition comment out lines 95 and 96 in this section:

elsif dc==""
  @@transition=FadeTransition.new(duration)

Doing so will revert the fade effect to the stock RMXP fade effect.


MiscData

Defines
PhoneDatabase
PhoneMsgType
PokemonMetadata
pbLoadMetadata
pbGetMetadata
pbLoadPhoneData
pbOpenDexData
pbDexDataOffset
Main article: Metadata

This section defines the PokemonMetadata module, which defines the various metadata that Essentials looks for in the metadata.txt PBS file. This section also defines a class for Phone metadata and several methods to get map metadata.


PBMove

Main article: Moves

This section defines PBMoveData and PBMove classes, which handles moves, both reading the move data from the data files and defining the properties of a move (e.g. type, PP, etc.).


PBStatuses

This section defines the PBStatuses module, which is where permanent (i.e. out of battle) Pokémon statuses are enumerated. This does not include confusion/infatuation/etc. which are all "volatile" in-battle conditions which a Pokémon can have in addition to a permanent status.

The effects of these statuses are not included here. The Pokérus status is also not defined here, as it is an unrelated effect.


PBTypes_Extra

This section extends the PBTypes class, which handles data regarding elemental types, including their Physical/Special category and type effectiveness calculations.


PBNatures

This section defines the PBNatures module, which enumerates the ID numbers and names of Pokémon natures. The effects of natures are not included here.


PBExperience

This section defines the PBExperience module, which lists the experience thresholds for each level for each growth type. The thresholds for levels below 100 are listed as individual numbers in an array, whereas those for level 101 and above have formulae for calculating them.


PBStats

This section defines the PBStats module, which enumerates the eight stats that all Pokémon have. This includes HP, Attack, Defense, Speed, Special Attack, and Special Defense, as well as the two in-battle stats, Accuracy and Evasion.


PBRibbons

This section defines the PBRibbons module, which enumerates the ID numbers, names and descriptions of ribbons.


PBEggGroups

This section defines the PBEggGroups module, which enumerates the ID numbers and names of the various egg groups.


PBColors

This section defines the PBColors module, which enumerates the IDs and names of the Pokedex color categories.


PBEnvironment

This section defines the PBEnvironment module, which enumerates the different environment types. These environment types are used to determine the appropriate backdrops for battles, as well as some move effects.


PBEffects

This section defines the PBEffects module, which enumerates all the variables used for lingering effects of attacks/abilities/items (e.g. Choice Band, Disable, Protect, Flinch, Toxic). Their effects are not included here.


PBWeather

This section defines the PBWeather module, which enumerates all the possible in-battle weather types. The effects of in-battle weather are not included here.


PBTargets

This section defines the PBTargets module, which enumerates all possible target combinations for a given move.


PokeBattle_ActiveSide

This section defines the PokeBattle_ActiveSide and PokeBattle_ActiveField classes, which contain the variables used for lingering move effects that affect all Pokémon on the battle field or just one side of a battle (i.e. the player's side or the opposing side). Their effects are not included here.


PokeBattle_DamageState

This section defines the PokeBattle_DamageState class, which is used in the PokeBattler_Battler class (see below) to keep track of several different flags used in battle for damage calculation, including the last amount of hp lost, whether the last hit was a critical, whether a substitute too the damage, etc.


PokeBattle_Battler

Defines
PokeBattle_Battler
  .battle
  .pokemon
  .hasMega?
  .isMega?
  .pbThis
  .pbHasMove?
  .hasWorkingAbility
  .hasWorkingItem
  .pbReduceHP
  .pbRecoverHP
  .pbFaint
  .pbObedienceCheck?
  .pbTryUseMove
  .pbUseMove

This section defines the PokeBattle_Battler class.

A battler is a separate entity to a Pokémon. This allows the battler to be changed in dramatic ways (e.g. using Transform) without affecting the Pokémon it is based on.

This section defines all the in-battle properties a battler has. This includes species, level, moves, stats, etc. (copied from the Pokémon), as well as things like whether it is fainted, what its last used move was, the stat modifier stages, and which other battlers will gain experience from it when it is defeated.

It also contains various functions that affect individual battlers, including one that faints the battler, one that determines the battler's modified speed, ones that affect status, one that describes what happens when a held item is consumed, ones that modify attack targets based on various effects, one that determines whether the battler will obey the trainer (and what happens if they don't), and ones that describe how a move is used.

It also contains methods that describe form-changing during battle.


PokeBattle_BattlerEffects

Defines
PokeBattle_Battler
  .pbSleep
  .pbPoison
  .pbBurn
  .pbParalyze
  .pbFreeze
  .pbConfuse
  .pbAttract
  .pbFlinch
  .pbIncreaseStat
  .pbReduceStat

This section extends the PokeBattle_Battler class to handle various in-battle effects, such as whether a battler can be given a particular status (also checks immunities to that status), inflicting statuses, status effects, and stat stage modifications.


PokeBattle_Move

Defines
PokeBattle_Move
  .battle
  .pp
  .totalpp
  .pbType
  .pbIsPhysical?
  .pbTargetsMultiple?
  .canThawUser?
  .ignoresSubstitute?
  .pbTypeModifier
  .pbIsCritical?
  .pbCalcDamage
  .pbEffect
Main article: Moves

This section defines the PokeBattle_Move class, which is the base class for all move classes. It handles moves in battle, including effectiveness calculations, accuracy check, power modifications, critical hit chance and damage calculation.


PokeBattle_MoveEffects

Main article: Function codes

This section defines hundreds of subclasses of PokeBattle_Move, one for each move. Usually each of these subclasses override the pbEffect method to implement the how the given move works and animates in battle.

Notably implemented first in the section are:

  • PokeBattle_UnimplementedMove - a error handler move class for moves which are defined in the PBS file but don't have a subclass defined for them. Damaging moves do damage and nothing else, while status moves always fail.
  • PokeBattle_FailedMove - A superclass for moves that always fail.
  • PokeBattle_Confusion - A class which implements the pseudo-move used by a battler against itself when it hurts itself in confusion.
  • PokeBattle_Struggle - An implementation for Struggle, should the move not be defined in the PBS file.


PokeBattle_Battle

Defines
PokeBattle_NullBattlePeer
PokeBattle_BattlePeer
PokeBattle_SuccessState
PokeBattle_BattleCommon
PokeBattle_Battle
  .pbIsUnlosableItem
  .pbPlayer
  .pbGetMegaRingName
  .pbMegaEvolve
  .pbFindNextUnfainted
  .pbAddToPlayerParty
  .pbCanChooseMove?
  .pbCanSwitch?
  .pbSendOut
  .pbGainExpOne
  .pbRun
  .pbLearnMove
  .pbJudge
  .pbDisplay
  .pbStartBattle
  .pbCommandPhase
  .pbAttackPhase
  .pbEndOfRoundPhase
  .pbEndOfBattle
Main article: Battles

This section defines the PokeBattle_Battle class, which handles the main battle process, from starting the battle through processing the phases (command, attack and end-of-round) to calculating the result and awarding Exp/money.

Two methods defined in PokeBattle_Battle, pbRandom and pbAIRandom, are called whenever the battle needs a random number to use. By default, they simply call Ruby's rand() method, but they can be easily overridden to use another random number generator, if desired.

The method pbJudge is called after every step of battle where a pokemon can get damaged. It determines which side of the battle won, if any side has won yet.

The method pbGainExpOne has code to celebrate a level up, and the method pbLearnMove is called to ask the player which move will be forgotten for a new move learned.


PokeBattle_AI

Defines
PBTrainerAI.minimumSkill=1
PBTrainerAI.mediumSkill=32
PBTrainerAI.highSkill=48
PBTrainerAI.bestSkill=100
PokeBattle_Battle
  .pbGetMoveScore
  .pbRoughDamage
  .pbChooseMoves
  .pbEnemyShouldUseItem?
  .pbEnemyShouldWithdraw?
Main article: Battle AI

This section extends the PokeBattle_Battle class to add several methods for the AI to use in determining what enemy trainers should do in battle. The pbGetMoveScore consists of a gigantic case statement with function codes for every move, and individually weights the viability of the given move.

This section also defines PBTrainerAI, which enumerates the thresholds for AI skill levels (given for a trainer class in the trainertypes.txt file). 0 is defined as a wild pokemon; 1-31 is for basic, inexperienced trainers; 32-47 for trainers with some skill; 48-99 for trainers with high skill, and 100 for expert trainers like gym leaders and the E4.


PokeBattle_SceneConstants

This section defines the PokeBattle_SceneConstants module, which contains various values which are used to determine the layout and appearance of the battle screen.


PokeBattle_Scene

Main article: Battles

This section defines the PokeBattle_Scene class and several helper classes, which handle all the visual features of the battle screen, including the command menus, information boxes, all the sprites, and various animations (Pokémon being called out/returned, throwing Poké Balls, fainting, HP/EXP bars, etc.).

Note: This section used to be called PokeBattle_ActualScene prior to version 16 of Essentials.


PokeBattle_AnimationPlayer

This section defines a few classes that handle the displaying of animations that were defined in the Database or the Animation Editor, and the conversion of the former to the latter. The vast majority of these animations are those used in battle.


PokeBattle_SafariZone

Main article: Safari Zone

This section defines the PokeBattle_SafariZone and PokeBattle_FakeBattler classes, which handle the battle process for Safari Zone battles (instead of PokeBattle_Battle).


PokeBattle_BattlePalace

This section defines the PokeBattle_BattlePalace class, a subclass of PokeBattle_Battle, which allows Battle Frontier-style Battle Palace battles, where pokemon choose their own moves based on their nature.


PokeBattle_BattleArena

This section defines the PokeBattle_BattleArena class, a subclass of PokeBattle_Battle, which allows Battle Frontier-style Battle Arena battles, where two pokemon fight for three rounds and are then judged on their mind, body, and skill rankings.


PokeBattle_BattleRecord

Defines
PokeBattle_RecordedBattle
PokeBattle_RecordedBattlePalace
PokeBattle_RecordedBattleArena
PokeBattle_BattlePlayer
PokeBattle_BattlePalacePlayer
PokeBattle_BattleArenaPlayer

This section defines several subclasses which allow Essentials to record and play back recorded battles. This is used in the PBattle_OrgBattle section to record the organized battles.


PokeBattle_OtherScenes

This section contains classes which defined simple, debug implementation of a battle scene. It is mainly used for debugging purposes.

Note: This section used to be called PokeBattle_Scene prior to version 16 of Essentials.


PokeBattle_BattlePeer

This section defines the PokeBattle_RealBattlePeer class, which handles the storing of newly-caught Pokémon in either the party or Pokémon storage.


PokeBattle_Clauses

This section extends the PokeBattle_Battle and PokeBattle_Battler classes, as well as a few move classes, to handle various battle rules that can be applied to battles, e.g. in the Battle Factory and various Stadium cups. This includes things like the "sleepclause", the "evasionclause", the "selfkoclause", etc.


PBTerrain

Defines
PBTerrain.isWater?
PBTerrain.isGrass?
PBTerrain.isLedge?
PBTerrain.isIce?
PBTerrain.isBridge?
PBTerrain.hasReflections?

This section defines the PBTerrain module, which enumerates the available terrain tags that can be used on a tileset.


PField_Field

Defines
DarknessSprite
LocationWindow
LightEffect
EncounterModifier
Events
  .onAction
  .onStartBattle
  .onEndBattle
  .onMapCreate
  .onMapChange
  .onMapChanging
  .onStepTaken
  .onLeaveTile
  .onStepTakenFieldMovement
  .onStepTakenTransferPossible
  .onMapUpdate
  .onWildBattleOverride
  .onWildBattleEnd
  .onWildPokemonCreate
  .onTrainerPartyLoad
  .onMapSceneChange
  .onSpritesetCreate
pbBattleAnimation
pbGenerateWildPokemon
pbWildBattle
pbCheckAllFainted
pbEvolutionCheck
Kernel.pbPickup
Kernel.pbSlideOnIce
Kernel.pbUpdateVehicle
Kernel.pbStartOver
Kernel.pbItemBall
pbRecord
pbEventFacesPlayer?
pbFacingTile
Kernel.pbMoveTowardPlayer

This section contains the bulk of the code for various things done in the field (that is, the overworld). These include:

  • Circle of darkness (for dark caves where Flash hasn't been used yet).
  • Location signpost window (showing the map's name when stepping onto a new map).
  • Light effects (for sprites that illuminate areas - shadows being cast are defined elsewhere).
  • The animation used to fade the screen before a battle.
  • Generating wild Pokémon and battles with them (both single and double).
  • The Pickup ability.
  • Jumping over a ledge.
  • Events that automatically occur:
    • When a battle is started.
    • When the player takes a step (poison and happiness gain, sliding on ice, animating tall grass).
    • When the player enters a different map (change the weather, display the location window, etc.).
    • When the map scene changes (e.g. Flash is used, automatically mount the bicycle).
    • When the map updates (i.e. every frame).
  • Setting the last visited Poké Center location.
  • Starting/finishing surfing and cycling.
  • Fishing.
  • Whiting out after having all party Pokémon faint, and returning to the last Poké Center visited.
  • The animation for entering a cave.
  • Registering and deregistering a partner trainer.
  • Recording sound.
  • Interacting with an item ball, and receiving an item from an NPC.
  • Boulder movements.


PField_FieldWeather

Main article: Weather

This section defines the PBFieldWeather module, which enumerates all the types of field weather available. It also extends the RPG::Weather class to handle the animations for out-of-battle weather. All other aspects of weather are handled elsewhere.


PField_Metadata

This section defines the PokemonGlobalMetadata class, which is stored in $PokemonGlobal. This class stores a lot of miscellaneous data, including things like if the player is surfing or cycling, the player's step count, the players last pokemon center, the daycare, the mailbox, the item pc storage, etc.


PField_MapFactory

This section defines the MapFactoryHelper module and the PokemonMapFactory class. They handle loading and displaying map connections, and collisions across connection boundaries.


PField_HiddenMoves

Defines
Kernel.pbCanUseHiddenMove?
Kernel.pbUseHiddenMove
Kernel.pbHiddenMoveEvent
pbHiddenMoveAnimation
Kernel.pbCut
Kernel.pbHeadbutt
Kernel.pbRockSmash
Kernel.pbStrength
Kernel.pbSurf
Kernel.pbWaterfall
Kernel.pbDive
Kernel.pbTransferUnderwater
Kernel.pbTransferSurfing
Main article: Using moves outside battle

This section defines the HiddenMoveHandlers module, which handles using moves outside battle. The bulk of this section contains handlers and methods for each of the field moves, including handlers for using them from the menu and using them by interacting with events or particular terrain tags.

Handlers added to HiddenMoveHandlers::CanUseMove and HiddenMoveHandlers::UseMove will be called when the player selects a move from the party menu, while the various Kernel.* methods defined are to be called from events.

This section also defines Kernel.pbTransferSurfing and Kernel.pbTransferUnderwater. If a doorway uses the normal transfer command, it automatically cancels any surfing or diving animations for the player. Thus, if the player can only travel through a given doorway while surfing or diving, you must use these respective methods to keep the player in the state of surfing or diving when they arrive on the other side of the transfer.


PField_Encounters

Main article: Encounters

This section defines the EncounterTypes module, which enumerates the encounter types and rates. It also defines the PokemonEncounters class, which handles other information relating to wild Pokémon encounters, including generating them.


PField_EncounterModifiers

Main article: Encounters

This section is for procedures which change wild Pokémon encounters in some way. An existing example is one which makes the wild Pokémon shiny if a certain Global Switch is ON.


PField_RoamingPokemon

Defines
pbResetAllRoamers
pbRoamPokemon
pbRoamingPokemonBattle
Main article: Roaming Pokémon

This section defines several methods which handle roaming Pokémon. It keeps track of all roaming Pokémon, changes their positions when a new map is entered, and triggers a battle with a roamer if appropriate.


PField_RandomDungeons

Defines
AntiRandom
DungeonMaze
Maze
Dungeon
pbRandomRoomTile
Main article: Dungeons

This section defines several classes to handle the generation of random dungeon maps.


PField_BerryPlants

Defines
pbBerryPlant
pbPickBerry
BerryPlantSprite
BerryPlantMoistureSprite
Main article: Berry planting

This section defines the pbBerryPlant method, along with helper classes, which handle the berry planting process.


PField_DayCare

Defines
pbEggGenerated?
pbDayCareDeposited
pbDayCareDeposit
pbDayCareGetLevelGain
pbDayCareGetDeposited
pbDayCareWithdraw
pbDayCareChoose
pbDayCareGenerateEgg
Main article: Day Care
Main article: Breeding

This section defines several methods which handle the Day Care system, both the storing of Pokémon to be trained and the breeding aspect. It contains scripts that determine whether or not breeding should take place, generate eggs when appropriate, give experience to stored Pokémon, teach moves to Pokémon as they level up while in training, etc.


PField_DependentEvents

Defines
pbRemoveDependencies
pbAddDependency
pbRemoveDependency
pbAddDependency2
pbGetDependency
pbRemoveDependency2
DependentEvents
  .pbEnsureEvent
  .pbFollowEventAcrossMaps
  .updateDependentEvents
DependentEventSprites
Main article: Partner trainer

This section defines the DependentEvents class, which handles dependent events.


PField_Time

Defines
pbGetTimeNow
PBDayNight.isDay?
PBDayNight.isNight?
PBDayNight.isMorning?
PBDayNight.isAfternoon?
PBDayNight.isEvening?
PBDayNight.getShade
pbDayNightTint
moonphase
zodiac
pbIsWeekday
pbIsMonth
pbIsSeason
pbIsSpring
Main article: Time

This section defines the PBDayNight module, which handles the day/night system in Essentials. It also contains some methods that calculate various astrological features (e.g. the moon's phase, the zodiac sign), and methods that check the current day, month, and season.


PokeBattle_Trainer

Defines
PokeBattle_Trainer
  .getForeignID
  .outfit
  .pokemonParty
  .ablePokemonParty
  .firstAblePokemon
  .lastPokemon
Main article: Player

This section defines the PokeBattle_Trainer class, which handles a trainer's information, including their name, badges owned, money, their current party, the Pokédex completion and so on. The player is the primary example of this class, and the only persistent instance (stored in $Trainer). But a PokeBattle_Trainer instance is created for every trainer participant when a battle begins.


PTrainer_NPCTrainers

Defines
pbLoadTrainer
pbTrainerCheck
pbMissingTrainer
pbTrainerBattle
pbDoubleTrainerBattle
TrainerWalkingCharSprite
Main article: Trainers

This section defines several methods which handle enemy trainers, most notably the trainer battle methods. pbLoadTrainer loads and check individual trainers and their teams (from the PBS file "trainers.txt"). Debug features such as the ability to add a new trainer are also defined here.


PItem_Items

Defines
pbIsHiddenMove?
pbGetPocket
pbIsMachine?
pbIsMail?
pbIsSnagBall?
pbIsKeyItem?
pbIsMegaStone?
pbChangeLevel
pbItemRestoreHP
pbHPItem
pbRaiseEffortValues
pbRestorePP
pbBikeCheck
pbClosestHiddenItem
pbLearnMove
pbUseItem
ItemHandlers.addUseFromBag
ItemHandlers.addUseInField
ItemHandlers.addUseOnPokemon
ItemHandlers.addBattleUseOnBattler
ItemHandlers.addBattleUseOnPokemon
Main article: Items

This section defines several methods which handle various generic effects an item can have (e.g. modify HP/PP), as well as teaching a move to a Pokémon. It also contains a few useful methods that can be used to decide what kind of item something is (e.g. one you shouldn't toss, a mail item, etc.).


PItem_ItemEffects

Main article: Item effects

This section defines over a hundred handlers implementing the effects of each item that can be actively used (i.e. not held items).


PItem_PokeBalls

Defines
BallHandlers::IsUnconditional
BallHandlers::ModifyCatchRate
BallHandlers::OnCatch
BallHandlers::OnFailCatch
pbBallTypeToBall
pbGetBallType
$BallTypes
Main article: Items

This section defines the handlers for modifying the various Poké Balls, or handling their effects. This file also has the mapping from ball type to PBItem enum.


PItem_PokeRadar

Defines
pbCanUsePokeRadar?
pbUsePokeRadar
pbPokeRadarHighlightGrass
pbPokeRadarGetShakingGrass
pbPokeRadarGetEncounter
Main article: Poké Radar

This section defines methods and item handlers to operate the Poké Radar, including using the item, making grass shake and changing the probability that the chained Pokémon are shiny.


PItem_Mail

Defines
PokemonMail
pbMoveToMailbox
pbStoreMail
pbDisplayMail

This section defines the PokemonMail class, as well as several helper methods to use and move mail around.


PItem_Sprites

This section defines the ItemIconSprite class, which handles displaying the item icon in the bag or mart screen. Interestingly, the icons can be animated if the icon is a 48 pixel tall image that has its animation frames laid out horizontally (48 pixels wide for each frame).


PokeBattle_Pokemon

Defines
PokeBattle_Pokemon
  .isForeign?
  .timeReceived
  .isEgg?
  .isMale?
  .makeMale
  .setAbility
  .hasHiddenAbility?
  .isShiny?
  .makeShiny
  .makeNotShiny
  .givePokerus
  .hasType?
  .knowsMove?
  .resetMoves
  .pbLearnMove
  .pbRecordFirstMoves
  .hasRibbon?
  .hasItem?
  .unownShape
  .heal
  .calcStats
Main article: Pokémon

This section defines the PokeBattle_Pokemon class, which (despite its name) defines a Pokémon outside of battle.


Pokemon_MultipleForms

Defines
PokeBattle_Pokemon
  .form
  .forceForm
MultipleForms
pbSpindaSpots
Main article: Multiple forms

This section extends the PokeBattle_Pokemon class and defines the MultipleForms module to handle the multiple forms some Pokémon can have, and defines all the stats and other information for each form that differs from its base form.


Pokemon_MegaEvolution

Main article: Mega Evolution

This section extends the PokeBattle_Pokemon class to add mega forms to all appropriate pokemon, by adding handlers to the the MultipleForms module defined above.


Pokemon_ShadowPokemon

Defines
pbPurify
pbRelicStoneScreen
pbRelicStone
pbIsPurifiable?
pbRaiseHappinessAndReduceHeart
PokeBattle_Pokemon
  .hypermode
  .heartStage
  .makeShadow
pbReadyToPurify
PokeBattle_Battler
  .pbHyperMode
  .pbHyperModeObedience
Main article: Shadow Pokémon

This section handles everything related to Shadow Pokémon. This section defines the heart gauges on pokemon, defines the Relic Stone, adds handlers for scent items, defines the effects of Hyper Mode (actually Pokemon XD-style "Reverse Mode", but misnamed "Hyper Mode"), and defines classes for every shadow move introduced in XD.

The Purify Chamber is handled in its own section.


Pokemon_Evolution

Defines
PBEvolution
SpriteMetafile
SpriteMetafilePlayer
PokemonEvolutionScene
pbGetEvolvedFormData
pbGetPreviousForm
pbGetMinimumLevel
pbGetBabySpecies
pbSaveSpriteState
pbRestoreSpriteState
pbSaveSpriteStateAndBitmap
pbRestoreSpriteStateAndBitmap
pbCheckEvolution
Main article: Evolution

This section defines the PBEvolution module, which enumerates all of the various evolution methods available (including 5 "custom" methods). It also defines PokemonEvolutionScene, which plays the evolution animation scene, and the pbCheckEvolution method, which checks if the pokemon can evolve now.


Pokemon_Chatter

This section defines the pbChatter, which handles the out-of-battle part of the move Chatter, which is the ability to record a new sound for it to use.


Pokemon_Sprites

Defines
PokemonSprite
PokemonBattlerSprite
PokemonIconSprite
PokemonSpeciesIconSprite
getBattleSpriteMetricOffset
adjustBattleSpriteY
pbPositionPokemonSprite
pbSpriteSetCenter
showShadow?

This section defines four sprite classes for displaying pokemon. It also defines methods that handle adjusting the height of battler sprites according to the three metrics defined for that species in the PBS file "pokemon.txt".


PScreen_PauseMenu

Main article: Pause menu

This section defines PokemonMenu_Scene and PokemonMenu, which handles the Pause menu. There is code in here to modify the menu when the player is in the Safari Zone or a Bug Catching Contest.


PScreen_Pokedex

Defines
Window_DexesList
Scene_PokedexMenu
Window_CommandPokemonWhiteArrow
Window_Pokedex
Window_ComplexCommandPokemon
PokemonPokedexScene
PokemonPokedex
Main article: Pokédex

This section defines PokemonPokedexScene, which handles the Pokédex screens, namely everything except the Area and Forms pages.


PScreen_PokedexNestForm

Defines
pbFindEncounter
PokemonNestMapScene
PokemonNestMap
PokedexFormScene
PokedexForm
Main article: Pokédex

This section defines PokemonNestMapScene and PokedexFormScene, which handles (respectfully) the Area and Forms pages of the Pokédex.


PScreen_Party

Defines
PokeSelectionPlaceholderSprite
PokeSelectionConfirmCancelSprite
PokeSelectionCancelSprite
PokeSelectionConfirmSprite
ChangelingSprite
PokeSelectionSprite
PokemonScreen_Scene
PokemonScreen
Main article: Party

This section defines PokemonScreen, which handles the party screen and choosing Pokémon from the party.


PScreen_Summary

Defines
MoveSelectionSprite
PokemonSummaryScene
PokemonSummary
Main article: Summary screens

This section defines PokemonSummaryScene, which handles the Pokémon summary screens, accessible from the Party screen and Pokémon storage. Data relevant to the selected Pokémon is displayed across five pages.


PScreen_Bag

Defines
Window_PokemonBag
PokemonBag_Scene
PokemonBagScreen
PokemonBag
Window_PokemonItemStorage
ItemStorageScene
WithdrawItemScene
TossItemScene
PCItemStorage
UIHelper
Main article: Bag

This section defines the PokemonBag and PCItemStorage classes, which hold the items the player is carrying (stored in $PokemonBag and $PokemonGlobal.pcItemStorage, respectfully). This section also defines the PokemonBagScreen and ItemStorageScene classes, which handle the Bag screen and item storage screen, respectfully.


PScreen_Pokegear

Defines
PokegearButton
Scene_Pokegear
Main article: Pokégear

This section defines the Scene_Pokegear class, which handles the Pokégear's main screen, i.e. the list of applications it has.


PScreen_RegionMap

Defines
MapBottomSprite
PokemonRegionMapScene
PokemonRegionMap
pbShowMap
Main article: Region map

This section defines the PokemonRegionMapScene screen, which handles displaying the region map. It is used when examining a map (from the Pokégear, the Town Map item, or a map on a wall) or when using Fly. This section defines the pbShowMap method, which can be called from an event to display a wall map.


PScreen_Phone

Defines
Window_PhoneList
PokemonPhoneScene
pbRandomPhoneTrainer
pbPhoneRegisterNPC
pbPhoneRegister
pbPhoneRegisterBattle
pbPhoneDeleteContact
pbPhoneReadyToBattle?
pbCallTrainer
pbSetReadyToBattle
pbPhoneGenerateCall
pbEncounterSpecies
pbTrainerMapName
pbTrainerSpecies
pbPhoneCall
Main article: Phone

This section defines the PokemonPhoneScene and several methods which handle the phone, including registering trainers, generating random phone calls, deciding when the trainers become available for rematches, and the phone screen.


PScreen_Jukebox

Main article: Jukebox

This section defines the Scene_Jukebox class, which handles the Jukebox application of the Pokégear.


PScreen_TrainerCard

Main article: Trainer card

This section defines the PokemonTrainerCardScene and PokemonTrainerCard classes, which handle the Trainer card screen.


PScreen_Load

Defines
PokemonLoadPanel
PokemonLoadScene
PokemonLoad
FontInstaller
Main article: Saving and loading

This section defines the PokemonLoad class. This class handles loading data from the save file, as well as displaying the Continue/New Game screen, starting a new game, and deleting a save file.

This section also contains the FontInstaller class, which checks whether the necessary fonts are installed, and attempts to install them if they are not.


PScreen_Save

Defines
PokemonSaveScene
pbEmergencySave
pbSave
PokemonSave
Main article: Saving and loading

This section defines the pbSave method, which handles saving the game.


PScreen_Options

Defines
Window_PokemonOption
EnumOption
NumberOption
SliderOption
PokemonSystem
PokemonOptionScene
PokemonOption
Main article: Options screen

This section defines PokemonOptionScene, which handles the Options screen. This screen includes settings for the window skin, font, text speed, etc. It also lists the available message box skins and fonts.

Lines 512 to 526 and specially marked with comments in this section: if you do not want your players to be able to change the size of the game from the default "Medium" (that is, 2 times the size of pokemon's graphics), you should comment out or delete that section.


PScreen_Storage

Main article: Pokémon storage
Main article: PC
Defines
PokemonBox
PokemonStorage
PokemonStorageWithParty
PokemonStorageScreen
Interpolator
PokemonBoxArrow
PokemonBoxPartySprite
MosaicPokemonSprite
AutoMosaicPokemonSprite
PokemonBoxSprite
PokemonStorageScene
RegionalStorage
TrainerPC
StorageSystemPC
Kernel.pbGetStorageCreator
pbPCItemStorage
pbPCMailbox
pbTrainerPC
pbPokeCenterPC
PokemonPCList.registerPC

This section defines PokemonStorage and PokemonBox, which contain pokemon stored in the storage system. It also defines various classes to implement the storage screen, and a class to handle Regional Pokémon storage.

At the bottom of this section, there are scripts that handle what happens when the PC is used (i.e. the menus and mail storage).

Note: This section adds the Storage System PC and Trainer PC to the Pokemon Center PC list that is displayed when the player turns on a PC. It does this by creating classes for each, with the methods shouldShow?, name, and access defined, and passing a new instance of that class to PokemonPCList.registerPC.


PScreen_EggHatching

Defines
PokemonEggHatchScene
PokemonEggHatchScreen
pbHatchAnimation
pbHatch

This section contains all the scripts relating to the hatching of eggs, including the animation that plays when an egg hatches and the timer which reduces the number of steps left before an egg hatches.


PScreen_Trading

Defines
PokemonTradeScene
pbStartTrade
pbTradeCheckEvolution
Main article: Trading Pokémon

This section defines the pbStartTrade method, which handles the Pokémon trade screen. It also contains a check for whether the newly received Pokémon should evolve because of the trade.


PScreen_MoveRelearner

Defines
MoveRelearnerScene
MoveRelearnerScreen
pbEachNaturalMove
pbGetRelearnableMoves
pbRelearnMoveScreen
Main article: Special NPCs

This section defines the pbRelearnMoveScreen method, which handles the Move Relearner feature. It handles the teaching part only; usually there is a price to pay for this feature, and that should be implemented separately.


PScreen_PurifyChamber

Defines
PurifyChamberSet
PurifyChamber
PurifyChamberPC
PurifyChamberHelper
PurifyChamberScreen
Window_PurifyChamberSets
DirectFlowDiagram
FlowDiagram
PurifyChamberSetView
PurifyChamberScene
pbPurifyChamber
Main article: Shadow Pokémon

This section defines the pbPurifyChamber method, and many support classes, which handle the Purify Chamber for Shadow Pokémon. This section adds the Purify Chamber option to the PC in the same way as outlined in PScreen_Storage.


PScreen_Mart

Defines
PokemonMartAdapter
RpgxpMartAdapter
Window_PokemonMart
PokemonMartScene
PokemonMartScreen
pbPokemonMart
Main article: Poké Mart

This section defines the pbPokemonMart method, which handles the Poké Mart screen.


PScreen_MysteryGift

Defines
MYSTERYGIFTURL
pbEditMysteryGift
pbCreateMysteryGift
pbManageMysteryGifts
pbRefreshMGCommands
pbDownloadMysteryGift
pbReceiveMysteryGift
Main article: Mystery Gift

This section handles the Mystery Gift system. The methods defined here are called by the load screen, defined above.

Tip: The MYSTERYGIFTURL constant, defined at the top of this file, is the URL the game will check for the mystery gift. This url must point to the raw text file and not a landing page generated by an uploading service. You can test to see if the game will accept the mystery gift file by putting the url you have into a browser's incognito mode / private browsing mode window. If you can load up the text file in that window without logging into anything or clicking through anything, then the game will be able to access the text file successfully itself.


PScreen_HallOfFame

Defines
HallOfFameScene
HallOfFameScreen
HallOfFamePC
pbHallOfFameEntry
pbHallOfFamePC

This section defines the HallOfFameScene class, which contains all the scripts related to the Hall of Fame. This section adds the Hall of Fame option to the PC in the same way as outlined in PScreen_Storage.


PBattle_Safari

Defines
SafariState
pbInSafari?
pbSafariState
pbSafariBattle
Main article: Safari Zone

This section handles the Safari Zone, except the Safari Zone battles themselves. It keeps track of steps taken, Balls remaining, etc.


PBattle_BugContest

Defines
BugContestState
pbBugContestScore
pbBugContestState
pbInBugContest?
PokeBattle_BugContestBattle
Kernel.pbBugContestStartOver
pbBugContestBattle
Main article: Bug Catching Contest

This section handles all aspects of Bug Catching Contests, including battles, keeping track of time, Park Balls, and judging.


PBattle_OrgBattle

Defines
PBPokemon
BattleChallengeType
BattleChallengeData
BattleChallenge
BattleFactoryData
pbHasEligible?
pbIsBanned?
pbGetBTTrainers
pbGetBTPokemon
pbRecordLastBattle
pbPlayBattle
pbPlayLastBattle
pbBattleChallenge
pbBattleChallengeTrainer
pbBattleFactoryPokemon
pbGenerateBattleTrainer
pbOrganizedBattleEx

This section defines several methods and classes related to organized Battle Frontier-style battles. This includes:

  • Methods to record a battle challenge battle.
  • Methods to create a Battle Challenge or Battle Factory battle
  • Methods to determine if a trainer has eligible pokemon.


PBattle_OrgBattleRules

Defines
LevelAdjustment
LevelBalanceAdjustment
SinglePlayerCappedLevelAdjustment
OpenLevelAdjustment
TotalLevelAdjustment
AblePokemonRestriction
SpeciesRestriction
BannedSpeciesRestriction
BannedItemRestriction
StandardRestriction
MaximumLevelRestriction
WeightRestriction
HeightRestriction
ItemsDisallowedClause
SameSpeciesClause
BabyRestriction
LittleCupRestriction
NicknameClause
PokemonRuleSet
BattleType
BattleRule
PokemonChallengeRules
StandardRules
pbPikaCupRules
pbFancyCupRules
pbBattleTowerRules
pbBattleFactoryRules

This section defines dozens of classes related to rules and restrictions on organized battles, as well as method to combine these classes into a ruleset for use in challenges and tournaments. It also has a commented out section at the bottom which outlines various rulesets previously used by real world Tournaments put on by the Pokemon Company in the past.


PBattle_OrgBattleGenerator

Defines
BaseStatRestriction
NonlegendaryRestriction
InverseRestriction
SingleMatch
MatchHistory
PlayerRating
RuledTeam
pbRandomMove
addMove
pbGetLegalMoves2
baseStatTotal
withRestr
pbArrangeByTier
pbRandomPokemonFromRule
pbRuledBattle
pbTrainerInfo
pbGenerateChallenge
pbWriteCup

This section defines several methods and classes related to generating random trainers to adhere to a given ruleset for an organized battle.


PBattle_BattleSwap

Defines
BattleSwapScene
BattleSwapScreen

This section defines the BattleSwapScreen and BattleSwapScene classes, which implement the pokemon rental screen used for the Battle Frontier-style Battle Factory.


PMinigame_Duel

Defines
DuelWindow
PokemonDuel
pbDuel
Main article: Mini-games

This section defines the pbDuel method and PokemonDuel class, which handles the overworld Duel mini-game.


PMinigame_TripleTriad

Defines
TriadCard
TriadSquare
TriadScene
TriadScreen
TriadStorage
pbBuyTriads
pbSellTriads
pbTriadList
pbTriadDuel
pbGiveTriadCard
Main article: Triple Triad

This section defines methods and classes which handle the Triple Triad card mini-game.


PMinigame_SlotMachine

Defines
SlotMachineReel
SlotMachineScore
SlotMachineScene
SlotMachine
pbSlotMachine
Main article: Mini-games

This section defines the pbSlotMachine method, which handles the Slot Machine mini-game.


PMinigame_VoltorbFlip

Defines
VoltorbFlip
VoltorbFlipScreen
pbVoltorbFlip
Main article: Mini-games

This section defines the pbVoltorbFlip method, which handles the Voltorb Flip mini-game.


PMinigame_Lottery

Defines
pbSetLotteryNumber
pbLottery
Main article: Mini-games

This section defines the pbLottery method, which handles the lottery mini-game.


PMinigame_Mining

Defines
MiningGameCounter
MiningGameTile
MiningGameCursor
MiningGameScene
MiningGame
pbMiningGame
Main article: Mini-games

This section defines the pbMiningGame method, which handles the Mining mini-game.


PMinigame_TilePuzzles

Defines
TilePuzzleCursor
TilePuzzleScene
TilePuzzle
pbTilePuzzle
Main article: Mini-games

This section defines the pbTilePuzzle method, which handles the Tile Puzzle game.


PSystem_Controls

Defines
Input
Mouse
Main article: Controls

This section redefines the Input module, which handles the game controls and translating them from a keyboard press into an input. It also contains some mouse support.


PSystem_System

Defines
pbSafeLoad
pbChooseLanguage
pbSetUpSystem
pbScreenCapture
pbDebugF7

This section defines a few small methods which set up the game.


PSystem_Utilities

Defines
LinearCongRandom
ItemStorageHelper
pbEachCombination
pbGetMyDocumentsFolder
pbGetLanguage
toFahrenheit
toCelsius
pbIsJsonString
pbParseJson
MiniXmlReader
pbChangePlayer
pbGetPlayerGraphic
pbTrainerName
pbSuggestTrainerName
pbGetUserName
getRandomName
pbTimeEvent
pbTimeEventValid
isConst?
getConst
getID
pbFadeOutInWithMusic
getWaveDataUI
beginRecordUI
pbHideVisibleObjects
pbLoadRpgxpScene
pbCommonEvent
pbPokemonBitmapFile
pbLoadPokemonBitmap
pbLoadPokemonBitmapSpecies
pbLoadSpeciesBitmap
pbLoadPokemonIcon
pbPokemonIconFile
pbItemIconFile
pbTrainerCharFile
pbTrainerSpriteFile
pbPlayerSpriteFile
pbResolveAudioSE
pbCryFrameLength
pbPlayCry
pbGetWildBattleBGM
pbGetTrainerBattleBGM
pbGetTrainerVictoryME
pbNickname
pbStorePokemon
pbNicknameAndStore
pbAddPokemon
pbAddPokemonSilent
pbAddToParty
pbAddForeignPokemon
pbGenerateEgg
pbSeenForm
pbHealAll
pbAllFainted
pbBalancedLevel
pbSize
pbHasEgg?
pbChoosePokemon
pbChooseAblePokemon
pbChoosePokemonForTrade
pbHasSpecies?
pbHasFatefulSpecies?
pbCheckMove
pbGetRegionalNumber
pbGetCurrentRegion
pbGetNationalNumber
pbUnlockDex
pbTextEntry
pbMoveTutorChoose
pbChooseMove
pbPokemonScreen
pbSaveScreen
pbRecordTrainer

This section contains a number of extra methods that don't fit elsewhere. These include:

  • Methods that gather information from the player's computer.
  • The LinearCongRandom class, which is an implementation of the RNG system used by the actual pokemon core series (but is unused in Essentials by default).
  • Methods to parse JSON and XML.
  • Convenience methods to define and name the player character, or get information about the player character.
  • Various utility methods, including those for Event timing and getting Constants.
    • pbGet and pbSet: the preferred way to get and set global variables.
    • pbExclaim and pbNoticePlayer: used for events that spot the player at a distance.
    • Methods that load Pokémon sprites and icons.
    • Various sound- and music-related methods.
    • Methods that add Pokémon in various ways, and stores/nicknames them.
  • The pbCreatePokemon method, which generates the Demo Party available from the Debug menu.
  • Methods involved with party manipulation.
  • A method that calculates a balanced version of a given party of Pokémon.
  • Methods that let the player choose a Pokémon from their party.
  • Methods that check if a pokemon in the player's party has a move.
  • Methods that return the Regional/National Dex numbers of a species, and one that compiles a Regional Dex list.
  • Move Tutor methods.


Debug

Defines
PokemonDataCopy
PokemonDataWrapper
CommandList
Scene_Debug
pbMapTree
pbCompileTextUI
pbWarpToMap
pbDebugMenu
pbDebugScreen
pbDebugSetVariable
Main article: Debug mode

This section defines the pbDebugMenu methods, which defines the Debug menu that can be accessed from the Pause menu.


TilesetEditor

Defines
pbTilesetWrapper
PokemonTilesetScene
pbTilesetScreen

This section handles the Debug mode option that allows you to change the terrain tags of tiles in a tileset.


BattleAnimationsEditor

Defines
Window_Menu
UIControl
Label
Button
Checkbox
TextField
Slider
OptionalSlider
TextSlider
OptionalTextSlider
ControlWindow
Clipboard
AnimationWindow
SpriteFrame
AnimationCanvas
pbSpriteHitTest
pbTrackPopupMenu
pbChooseNum
pbSetTone
pbCellProperties
pbTimingList
pbSelectAnim
pbAnimationsOrganiser
Main article: Attack animations

This section defines dozens of UI classes and methods that are used in the Animation Editor, which is used for creating animations of moves being used in battle.


Editor

Defines
GraphicsLister
MusicFileLister
MapScreenScene
MapLister
ItemLister
TrainerTypeLister
TrainerBattleLister
LimitProperty
ReadOnlyProperty
BooleanProperty
BGMProperty
TypeProperty
NatureProperty
PlayerProperty
MapProperty
pbIsOldSpecialType?
MakeshiftConsts.get
pbSavePokemonData
pbSaveItems
pbSaveTrainerTypes
pbSaveTownMap
pbSavePhoneData
pbSaveBTTrainers
pbFastInspect
pbSaveAllData
pbChooseSpecies
pbChooseItemList
pbCommands3
pbListScreen
pbPropertyList
pbEncounterEditorMap
pbTrainerTypeEditor
createRegionMap
pbEditorScreen
Main article: Debug mode

This section defines many UI elements to handle the in-game Debug Mode editors, allowing you to edit the contents of some of the PBS files.


Compiler

Defines
FileLineData
TrainerChecker
pbPrintException
pbEachFileSectionEx
pbCheckByte
csvfield!
pbGetCsvRecord
pbGetConst
parseTrainer
pbAddScript
pbWriteDefaultTypes
pbCompileTypes
pbCompileConnections
pbCompileItems
pbCompilePokemonData
pbCompileMachines
pbCompileTrainers
pbCompileMetadata
pbCompileAnimations
pbUpdateDoor
pbCompileAllData

This section handles the compiling of all information in the PBS files into a set of data the game can actually use.

Note: This section defines pbFixEventUse, which is responsible for going through your maps and events and fixing many minor common errors developers make in their coding, including things like replacing door transfers with properly done door events, normalizing the use of "\b" and "\r" in text, replacing "pbItemBall" with "pbReceiveItem" on non-item events, deleting superfluous exit commands, etc.

This section also defines pbConvertToItemEvent, which will turn a simple events named a certain way into full item ball events. For example, if you make a new event simply named "Item:POTION" or "HiddenItem:POTION", the compile will turn the event into a full Item Ball or Hidden Item event which will give the player one potion.

This section also defines pbConvertToTrainerEvent, which will turn an event into a trainer, as outlined by the Trainers page.

Basically, if something changes in your project after you do a test run of your game without your doing it (for better or worse), it is likely the fault of the Compiler script section.


Main

This section defines the entry point of the game. It is what starts the game running and brings up the title screen. This section must always be the last script section.

If you are adding any extensions to the game from a tutorial on this wiki or a thread in the community forum, they will more often than not tell you to place it right above this section. This is because scripts placed lower will override scripts placed in higher script sections, but scripts placed below Main will never run, as Main is where the main game loop runs.


Compiled Scripts

There are some classes and methods which are not defined in script sections, but are compiled directly from from PBS files by the Compiler. The following are classes you won't find defined in the Script Editor. All of these classes simply enumerate their values. They don't have any logic, but they'll usually have a method to get the printable name of the enum.

PBTypes

This is the list of types, defined in types.txt. The script compiles to the following, from the unmodified example project:

 class PBTypes
   NORMAL=0
   #[...all defined types...]
   DARK=17
   def PBTypes.getName(id)
     return pbGetMessage(MessageTypes::Types,id)
   end
   def PBTypes.getCount; return 18; end
   def PBTypes.maxValue; return 17; end
 end

PBAbilities

This is the list of all abilities, defined in abilities.txt. The script compiles to the following, from the unmodified example project:

 class PBAbilities
   STENCH=1
   #[...all defined abilities...]
   TERAVOLT=164
   def PBAbilities.getName(id)
     return pbGetMessage(MessageTypes::Abilities,id)
   end
   def PBAbilities.getCount
     return 164
   end
   def PBAbilities.maxValue
     return 164
   end
 end

PBMoves

This is a list of all moves, defined in moves.txt. The script compiles to the following, from the unmodified example project:

 class PBMoves
   MEGAHORN=1
   #[...all defined moves...]
   WITHDRAW=559
   def PBMoves.getName(id)
     return pbGetMessage(MessageTypes::Moves,id)
   end
   def PBMoves.getCount
     return 559
   end
   def PBMoves.maxValue
     return 559
   end
 end

PBItems

This is a list of all items, defined in items.txt. The script compiles to the following, from the unmodified example project:

 class PBItems
   REPEL=1
   #[...all defined items...]
   SHINYCHARM=525
   def PBItems.getName(id)
     return pbGetMessage(MessageTypes::Items,id)
   end
   def PBItems.getNamePlural(id)
     return pbGetMessage(MessageTypes::ItemPlurals,id)
   end
   def PBItems.getCount
     return 525
   end
   def PBItems.maxValue
     return 525
   end
 end

PBSpecies

This is the list of pokemon species, defined from pokemon.txt. Note that the PBSpecies enum corresponds to the national pokedex number of the pokemon species, and thus you can use PBSpecies::QUILAVA as a constant for Quilava's national dex number. The script compiles to the following, from the unmodified example project:

 module PBSpecies
   BULBASAUR=1
   IVYSAUR=2
   #[...all defined pokemon...]
   MELOETTA=648
   GENESECT=649
   def PBSpecies.getName(id)
     return pbGetMessage(MessageTypes::Species,id)
   end
   def PBSpecies.getCount
     return 649
   end
   def PBSpecies.maxValue
     return 649
   end
 end

PBTrainers

This is a list of all trainer types, defined in trainertypes.txt. The script compiles to the following, from the unmodified example project:

 class PBTrainers
   POKEMONTRAINER_Red=0
   #[...all defined trainer types...]
   CHAMPION=71
   def PBTrainers.getName(id)
     return pbGetMessage(MessageTypes::TrainerTypes,id)
   end
   def PBTrainers.getCount
     return 72
   end
   def PBTrainers.maxValue
     return 71
   end
 end

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.