Notes for Pokemon Essentials

Peter O. (http://upokecenter.com/projects/pokestarter/)

For advanced topics, see the Advanced Topics page.

Contents

Controls

Common Questions

How do I create a Pokemon Mart?

To create a Pokemon Mart, give the event a Script event command with "pbPokemonMart([X])", where X is a list of the items available for purchase there. See 10678 for details.

Check the girl event next to the PC on Test Map 2 to see an example.

Upgrading from previous versions

Since September 2007, there have been many releases of Pokemon Essentials (see the history), so it may be helpful to learn how to upgrade to a new version. If you modified the scripts in Pokemon Essentials, then you should keep them separate as you replace them with the newer versions. Also, keep this in mind (posted by Flameguru):

Simple...well, maybe not. Here I go!

First, make a copy of your entire projects folder. Then go into your games Data Folder. Copy over all of the Map Files, MapInfos, and the Tilesets data files.

If you used any custom Tilesets or charsets or even pictures copy them over too, same for audio.

Then go into the merged project and make an event and make it control switches. Then copy all of your switches from your game to the merged project.

It's kind of confusing but it only takes 20 minutes max and it's what i have been doing this whole time

Problem when opening project

If you are using RPG Tsukuuru XP in Japanese and you cannot open the project, then open Game.rxproj in Notepad and change "RPGXP 1.02" to "RPGXP 1.01" or, if necessary "RPGXP 1.00", then save the file.

Configuration Files

Many aspects of the game can be customized by editing the .txt files contained in the PBS folder:

For all configuration files, comment lines begin with a "#". Each file must be saved in UTF-8.

The file townmapgen.html in this distribution is designed for editing region maps.

Data Compilation

The configuration text files will be compiled into an internal format when the game is run from RPG Maker XP or when the $DEBUG global variable is set. Normally this is done only if the text files have changed after the last run of the game. However, you can force compilation by holding CTRL as the game loads.

PBS/connections.txt

Pokemon Essentials supports maps that connect to each other seamlessly. This file defines connection points of maps with others in the game. However, an easier way to edit map connections is to use the "Visual Editor" option on the Pokemon Essentials editor (editor.exe).

PBS/encounters.txt

This text file is for placing encounter data for each map. However, an easier way to edit Pokemon encounters is to use the "Set Encounters" option on the Pokemon Essentials editor (editor.exe). That method is also preferred.

PBS/metadata.txt

This text file describes metadata on each map in the game. However, an easier way to edit metadata is to use the "Set Metadata" option on the Pokemon Essentials editor (editor.exe). That method is also preferred.

PBS/pokemon.txt

This text file describes each Pokemon in the game. The file is divided into sections, and each section's title is the Pokemon's number (in the National Pokedex order) enclosed by two square brackets like this: [120]

Each section can have any number of entries. The entry's name and the entry's value are separated by an equal sign (=).

Here are the possible entry types:

There should be five different image files for new Pokemon (XXX is the Pokemon's number):

PBS/moves.txt

This file stores data on each move in the game. It will be converted to a runtime format when you run a playtest of the game from RPG Maker XP. Each line contains data on one move and is divided into fields separated by commas:

PBS/items.txt

This file stores data on each item in the game. It will be converted to a runtime format when you run a playtest of the game from RPG Maker XP. For examples, see 25290. Each line contains data on one item and is divided into fields separated by commas:

Also, an icon of the item must be placed in the Graphics/Icons folder with a filename of itemXXX.png, where XXX is the ID number of the item, left-padded with zeros. The icon's dimensions must be 48x48.

Comment lines begin with "#". This file, however, doesn't allow comments at the end of the line.

Implementing New Items

The following describes an advanced scripting feature.

New items are implemented by registering item handlers with the game system. Fields 7 and 8 of items.txt give the moments where an item can be used. These fields determine which handlers an item should implement. There are five different item handlers for an item, corresponding to the moments where items are used:

The following gives some guidance on the item handlers that an item should implement depending on its usability.

Field 7 (usability outside of battle)

Field 8 (usability in battle)

The following shows some examples of item handlers for a hypothetical item called "Cake", which restores 30 HP to a Pokemon. For completeness, it implements all five item handlers.

# Handlers implemented
ItemHandlers.addUseFromBag(
 PBItems::CAKE,
 proc{|item,pokemon,scene|
  pbHPItem(pokemon,30,scene)
 }
)
ItemHandlers.addBattleUseOnBattler(
 PBItems::CAKE,
 proc{|item,pokemon,battler,scene|
  pbBattleHPItem(pokemon,battler,30,scene)
 }
)
# Handlers not implemented
ItemHandlers.addUseFromBag(
 PBItems::CAKE,
 proc{|item| 0; }
)
ItemHandlers.addUseInField(
 PBItems::CAKE,
 proc{|item| 
  Kernel.pbMessage(_INTL("Can't use that here."))
 }
)
ItemHandlers.addBattleUseOnPokemon(
 PBItems::CAKE,
 proc{|item,battler,scene| false; }
)

PBS/trainernames.txt

This file stores data on each trainer type. However, an easier way to edit trainer types is to use the "Trainer Types" option on the Pokemon Essentials editor (editor.exe). That method is also preferred.

PBS/trainers.txt

This text file stores data on each Trainer in the game. However, an easier way to edit trainers and trainer battles is to use the "Edit Trainers" option on the Pokemon Essentials editor (editor.exe). That method is also preferred.

PBS/tm.txt

Very simple file. It consists of a list of moves and the species that can learn each move. Used in TMs/HMs.

Town Map Generator (townmapgen.html)

The Town Map editor is designed to make editing the region map easier.

When the editor is started, it loads the file at Graphics/Pictures/Map.png. You can replace that file with the map of your game's region, keeping in mind that the map should be drawn in terms of 16x16 tiles. The example map in the distribution is the map of Hoenn; and filling the map will give you a good idea on how the Town Map Editor works.

Start by clicking any point on the map; for instance a city. Once you have done so, fill in details about the point:

After completing the fields, click Save. You will notice that the point is added to the text below the Save button. This text is meant to be pasted to townmap.txt after you are done with the editor. You can put the text in a new or existing section of the file. (Sections begin with a number within brackets, for example: [1])

The next time you use the map editor, you can paste a section from townmap.txt (without the section heading) onto the big text box and click Load to resume editing.

Points of Interest

The "Point of Interest" setting is meant to describe an entrance to a cave, the location of an important zone (preferably one with RPGXP maps of its own), or anything interesting within the main location described by the point. Examples:

0,0,"FUCHSIA CITY","SAFARI ZONE",,
2,2,"ROUTE 111","DESERT",,
4,3,"ROUTE 220","LOST TOWER",,
6,6,"LAVENDER CITY","POKeMON TOWER",,
8,8,"EVER GRANDE CITY","VICTORY ROAD",,

However, that setting should not be used to name a building within a city or town, as in these cases:

0,0,"SAFFRON CITY","SILPH CO.",,
5,0,"RUSTBORO CITY","DEVON CORPORATION",,
3,3,"VEILSTONE CITY","GAME CORNER",,

In most cases, however, the Point of Interest setting is left blank, since the number of points of interest is generally small within a game.

Animations

The battle system allows the animations to be customized. Currently, almost all of the animations are of the move Tackle. There are two ways to add move animations-- using RPG Maker XP or using the in-game 35703.

Animation Editor

The Animation Editor is designed for creating Pokemon battle animations. A separate editor is necessary because the animations for many moves require the attacker and the target to be manipulated.

The Animation Editor is located on the game's Debug menu.

Quick Start

The controls at the bottom left of the window are important ones when working with the editor. The "Frame:" control changes the number of frames; "Set Animation Bitmap" changes the bitmap used for animations; "Frames:X" lets you set the number of frames; and you can rename or add more animations by clicking List of Animations.

The animation palette is located just above the name window. Click the left and right arrows to scroll the palette, and click on an object in the palette to select it. Clicking on the canvas will then place the object on it as a cell. To select an existing cell, click on it. You can then move it, press L to lock it, preventing movement, or press P to open its properties.

Animations will be saved in the file Data/PkmnAnimations.rxdata.

Editor Features

Here are descriptions of the editor's controls:

The animation palette is located just above the name window. Click the left and right arrows to scroll the palette, and click on an object in the palette to select it. Clicking on the canvas will then place the object on it as a cell.

To select a cell, simply click on it. Holding Alt will enable finer selection of cels on the screen. If a frame is selected, the following actions are available:

Battle Animations

There are several rules to keep in mind when making battle animations in RPG Maker XP.

Game Screens

Title Screen

The game's title screen can be changed by replacing the files Pic_1.png , Pic_2.png , and Start.png . Each of these files is found in the directory Graphics/Titles.

Essentially, though, the title screen just calls the game-loading screen. Here is an example of a very simple title scene:

 class Scene_Xxxx
   def main
     # Prepare scene
     Graphics.transition
     while $scene != self
        Graphics.update
        Input.update
        update
     end     
     Graphics.freeze
     # Dispose sprites
   end
   def update
     if Input.trigger?(Input::C)
       # Close scene here
       sscene=PokemonLoadScene.new
       sscreen=PokemonLoad.new(sscene)
       sscreen.pbStartLoadScreen # Will change scene if appropriate
     end
   end
 end

The title's music can be changed with the "Title BGM" setting in the System tab of the database.

Intro Screen

The introduction screen when the game starts is found in the map titled Intro. This map should be where the starting position is placed. It also contains an event with an autorun trigger. The event may appear long, but that's only because it's a representative appearance of the intro screen only. The most fundamental introduction event looks like the following:

@>Comment: Initializes the player character.
@>Script: pbChangePlayer(0)
@>Comment: opens the name entry screen and initializes the 
 :         : Trainer object
@>Script: pbTrainerName
@>Comment: Displays the player's name
@>Text: Hello, \PN.
@>Comment: Stops autorun event
@>Control Self Switch: A =ON
@>Comment: Transfers player to start position
@>Transfer Player:[011: Test Map], (009, 009), Down
@>

Of course, it can be expanded to include multiple player characters and to show the character on screen:

@>Text: Are you a boy or a girl?
@>Show Choices: BOY, GIRL
 : When [BOY]
  @>Comment: initializes player 0 (PlayerA)
  @>Script: pbChangePlayer(0)
  @>
 : When [GIRL]
  @>Comment: initializes player 1 (PlayerB)
  @>Script: pbChangePlayer(1)
  @>
 : Branch End
@>Comment: Shows the character's picture
@>Script: pbShowPicture(2,pbGetPlayerGraphic,
 :      : 1,230,160)
@>Text: Choose a name.
@>Comment: opens the name entry screen and initializes the 
 :         : Trainer object
@>Script: pbTrainerName
@>Comment: Displays the player's name
@>Text: Hello, \PN.
@>Comment: erases the character's picture
@>Erase Picture: 2
@>Comment: Stops autorun event
@>Control Self Switch: A =ON
@>Comment: Transfers player to start position
@>Transfer Player:[011: Test Map], (009, 009), Down
@>

In the Pokemon Essentials editor, under "GLOBAL" within "Set Metadata", you can enter data for each player character in the settings PlayerA, PlayerB, etc.

Backgrounds

The various screens use the following backgrounds:

Finding the Coordinates of a Tile

The status bar on the bottom of RPG Maker XP contains information about the map. Here is an example of a status bar:

011: Test Map (30 x 28)

The middle of the status bar shows the map ID (011), the name of the map (Test Map), and the width and height of the map (30 x 28)

Now move your mouse over the map. Notice how another area on the status bar changes. This shows the X and Y coordinates of the point where the mouse currently is. Example: 013, 014 means that the mouse is pointing to the tile at X coordinate 13 and Y coordinate 14.

New Window Skin Format

Pokemon Essentials supports a new window skin format that allows different-sized window borders and different placement of text than usual. It involves a PNG file and a text file. The PNG file shows the look of a window at its minimum possible size. The corners and sides of the image will be adjusted to match the size of the window. An optional TXT file with the same name describes the sizes of the sides, corners, and borders. If the file is not given, it is assumed that the center 16x16 square is the center of the window and the window's sides and corners make up the rest of the image.

Events

Pokemon Essentials comes with many predefined events for your use, and also contains many new ways to define special kinds of events that otherwise wouldn't be possible with RPG Maker XP alone. This section will discuss the game's predefined events, the switches and variables used in the game, and details on implementing 49581. The rest of the section discusses 49643 and a way to save the game via an event.

Predefined Events

The following are definitions of events used in Pokemon games. These events include trees, boulders, Headbutt trees, cracked rocks, and doors. Other common kinds of events are items and 49949.

Trees

Events that can be cut using the hidden move Cut are named Tree, have an Action Button trigger, and have the following structure:

Conditional Branch:  Script:  Kernel.pbCut
 Script: pbEraseThisEvent
Branch End

An animation for the tree being cut is possible by modifying the event just before "Script: pbEraseThisEvent".

Boulders

Events that can be pushed using Strength are named Boulder, have a Player Touch Trigger, and consist of the single event command "Script: pbPushThisBoulder".

Headbutt Trees

Trees that a Pokemon can use Headbutt on are named HeadbuttTree, have an Action Button Trigger, and consist of the single event command "Script: pbHeadbutt".

Cracked Rocks

Rocks that can be smashed are named Rock, have an Action Button trigger, and have the following structure.

Conditional Branch:  Script:  Kernel.pbRockSmash
 Script: pbEraseThisEvent
 Script: pbRockSmashRandomEncounter
Branch End

Doors

Doors have two event pages, with the following structure:

Event Page 1

No conditions, Player Touch trigger

The graphic should be of a closed door.

@>Set Move Route: This event (Ignore If Can't Move)
 :              : $>SE: 'Entering Door', 80, 100
 :              : $>Wait: 2 frame(s)
 :              : $>Turn Right
 :              : $>Wait: 2 frame(s)
 :              : $>Turn Up
 :              : $>Wait: 2 frame(s)
 :              : $>Turn Left
 :              : $>Wait: 2 frame(s)
@>Wait for Move's Completion
@>Set Move Route: Player (Ignore If Can't Move)
 :              : $>Through ON
 :              : $>Move Up
 :              : $>Through OFF
@>Wait for Move's Completion
			@>Change Screen Color Tone: (-255,-255,-255,0), @6
@>Wait: 6 frame(s)
@>Transfer Player:[001: Pokemon Center], (004, 007), Up, No Fade
@>Change Screen Color Tone: (0,0,0,0), @6
@>
		

The emphasized event commands are also useful for normal player transfers that don't involve doors.

Event Page 2

Condition 'Switch "s:tsOff?("A")" is ON', Autorun trigger

The graphic should be of a closed door.

Conditional Branch:  Script:  get_character(0).onEvent?
  Set Move Route: This event (Ignore If Can't Move)
  :             : $>Turn Left
  Set Move Route: Player (Ignore If Can't Move)
  :             : $>Move Down
  Wait for Move's Completion
  Set Move Route: This event (Ignore If Can't Move)
  :             : $>Wait: 2 frame(s)
  :             : $>Turn Up
  :             : $>Wait: 2 frame(s)
  :             : $>Turn Right
  :             : $>Wait: 2 frame(s)
  :             : $>Turn Down
  :             : $>Wait: 2 frame(s)
  Wait for Move's Completion
Branch End
Script: setTempSwitchOn("A")

This event page checks whether a player is on the door, and if so, moves the player one space down and closes the door. Therefore, event commands that cause the player to exit a building should have their destination placed on the door and not next to it.

The door character image file should be arranged so that the first row shows a closed door, the second row an open door, the third row a partially closed door, and the fourth row a partially open door.

Cut Scenes

Pokemon Essentials contains a way to skip or cancel certain events designated as "cut scenes" by pressing F5. This feature can be useful if a player wants to skip the dialogue and advance the story.

To make an event a cut scene, add to the event a Comment event command consisting of the text "Cut Scene". When the player presses F5, the event's self switch A will be set to ON. Therefore, the event should have another event page with the Autorun trigger and the condition "Self Switch A is ON". The event page should have the effect of canceling the effect of the cut scene, perhaps by moving the player directly to the next destination or doing any other necessary cleanup.

Switches and Variables

Script-Based Switches

The event system in Pokemon Essentials supports script-based switches, where an arbitrary script is evaluated. The switch is true as long as the condition on the switch's name remains true. Script-based switches are distinguished from regular switches using the prefix "s:". Be aware that due to the size limit on a switch's name, it may be necessary to use this kind of switch to call other methods that return a true or false value. Methods on script-based switches are called within the context of the Game_Event class.

Temporary Self-Switches

Each event in the game comes with a set of temporary self switches. This set is cleared whenever a map is entered. To check whether a temporary self switch is on, use a switch named "s:tsOn?(X)" where X is one of "A", "B", "C", or "D". To check whether it's off, use a switch named "s:tsOff?(X)". To turn a temporary self switch on or off, use a script like:

get_character(0).setTempSwitchOn("A")

or:

get_character(0).setTempSwitchOff("A")

Temporary self switches are currently used in doors, but they have other uses where stand-alone stateful events are desired.

Variables

Variables 1 through 25 are reserved for internal use by the game system. They are defined as follows:

Event-Specific Variables

Each event in the game comes with its own variable, which can be used for any purpose. To retrieve a variable, call the script function "getVariable", and to set the value of the current event's variable, call the script function "setVariable(X)", where X is the value to set to the variable. To check the variable's value in an event page's condition, use the event function "variable" to help you. For example, to check whether the event's variable is equal to 1, you would use a switch named: "s:variable==1".

Time-Sensitive Events

Thanks to temporary self-switches and event-specific variables, it is possible to implement events that are active only once each day. For an example, see the event on the northeast side of the Pokemon Center. Here is the basic structure of such events:

Event Page 1

No conditions, any trigger

-- Do something here
Script:  pbSetEventTime      

The script pbSetEventTime sets the event's variable to the current time, so that later the game can check whether the event "expires" and returns to normal. pbSetEventTime can also be used to set other events' variables to the current time. For example, pbSetEventTime(2) sets this event and the event numbered 2 on this map.

Event Page 2

Condition "Self Switch A is ON", any trigger

-- Do something here

This event page is used in cases when the event is currently "inactive"; for example, in the case of a tree that grows berries every day, there could be a message here that the tree is empty.

Event Page 3

Condition 'Switch "s:expired?&&tsOff?("A")" is ON', Autorun trigger

Control Self Switch: A =OFF
Script:  setTempSwitchOn("A")

This event page checks whether the event has expired and becomes active again.

Counter Events

A counter event is one that is triggered when the player is a number of spaces away from the event's visibility range, even if there is no counter tile separating them.

To make one, name it Counter(X), where X is the maximum distance for the event to trigger, and use the Event Touch trigger.

Side Stairs

Side stairs (stairs on the side of a cliff) were introduced in Pokemon Diamond and Pearl. To make such an event, consider the following diagram.

......||------
......||------
......|A------
......BA------
......B|------
......||------

In this diagram,"." represents flat ground; "-" represents rocky ground; and "|" represents cliffs. The letters A and B represent side stair events. Use the following event for the A events.

@>Set Move Route: Player
 :              : $>Move Lower Left
 :              : $>Move Left

And use the following event for the B events.

@>Set Move Route: Player
 :              : $>Move Upper Right
 :              : $>Move Right

Event Commands

The following event commands have no effect in Pokemon Essentials:

The following event commands have been redefined in Pokemon Essentials:

Saving the Game

To save the game, use pbSaveScreen:

Conditional Branch:  Script:  Kernel.pbSaveScreen
  -- The game was saved
Else
  -- The game was not saved
End

Items

Item Events

To create an item event, give it the following name: Item:XXX, where XXX is the internal name of the item (generally, the name of the item in all uppercase letters, with no spaces). For example, Item:POTION creates a Potion item, and Item:FULLHEAL creates a Full Heal item.

To create a hidden item event, give it the following name: HiddenItem:XXX, where XXX is the internal name of the item (generally, the name of the item in all uppercase letters, with no spaces).

Both types of item events will be converted to real events when you run the game from RPG Maker XP.

Item Management

Checking for Items

The PokemonBag class has a function, pbQuantity, that you can use to check for the existence or amount of an item in the Bag. Here's how to use it:

Conditional branch for checking for the existence of an item:

$PokemonBag.pbQuantity(PBItems::POTION)>0

Script example: Printing the number of items

itemname=PBItems.getName(PBItems::POTION)
itemqty=$PokemonBag.pbQuantity(PBItems::POTION)
print("#{itemqty}x #{itemname}")

Adding/Removing Items

To add an item:

Conditional Branch:  Script:  $PokemonBag.pbStoreItem(::PBItems::POTION)
  -- The item was added
Else
  -- The item couldn't be added
Branch End

This is the most generic of all functions that add items.

To add an item received from a person, use event commands like the following.

Conditional Branch:  Script:  Kernel.pbReceiveItem(::PBItems::POTION)
  -- The item was added
Else
  -- The item couldn't be added
Branch End

It is not to be used as a replacement for Kernel.pbItemBall.

To delete an item, use this as a Script event command:

 $PokemonBag.pbDeleteItem(
    PBItems::POTION
   )

To add more than one item at once, use this as a Script event command:

5.times do
  $PokemonBag.pbStoreItem(
     PBItems::POKeBALL
  )
end

or this newer syntax:

$PokemonBag.pbStoreItem(
     PBItems::POKeBALL, 5
)

Adding New Items

New items are added by editing items.txt in the PBS folder. Here are examples of entries in that file.

Key Items

500,LABKEY,LAB KEY,5,0,"This is a custom Key Item.",0,0

The first number, 500, is the item's ID, and the number 5 stands for the Key Items pocket.

Technical Machines

298,TM10,TM10,3,3000,"An attack that varies in type and intensity depending on the user.",3,0,,HIDDENPOWER

The number 3000 specifies the price. The last field here, HIDDENPOWER, identifies this item's move. When creating a new TM, also edit tm.txt in the PBS folder to add the list of species who can learn the move. Here's an example for the move Softboiled.

[SOFTBOILED]
CHANSEY,BLISSEY,HAPPINY,TOGEPI,TOGETIC,TOGEKISS

Hidden Machine

340,HM02,HM02,3,0,"A 2-turn move that hits on the 2nd turn. Use it to fly to any known town.",4,0,,FLY

Practically the same as above, except with a 4 after the description.

Regular Item

16,ICEHEAL,ICE HEAL,1,250,"A spray-type medicine. It defrosts a frozen POKeMON.",1,1

For items stored in the items pocket. For details on the last two numbers, see fields 7 and 8 in the items.txt section.

Pokemon Mart

To set up the Pokemon Mart, use the following Script event command (you don't type the word "Script:"):

@>Script: pbPokemonMart([
 :      : PBItems::POKeBALL,
 :      : PBItems::POTION,
 :      : PBItems::ANTIDOTE,
 :      : PBItems::TM20,
 :      : PBItems::TM21,
 :      : PBItems::TM22,
 :      : PBItems::ICEHEAL,
 :      : PBItems::REPEL,
 :      : PBItems::ESCAPEROPE])
@>

Within the brackets is a list of items to be found in the Pokemon Mart, separated by commas. Note that each item begins with PBItems::.

Checking for Pokemon

The script function pbHasSpecies? checks for a Pokemon in the player's party. Example:

Conditional Branch:  Script:  pbHasSpecies?(::PBSpecies::CELEBI)
  -- The Pokemon Celebi is in the party
Else
  -- The Pokemon Celebi is not in the party
Branch End

PC

To open the PC, use the following Script event command.

Script:  pbPokeCenterPC

It is to be used on any event with a PC.

For the player's PC, use the following Script event command instead.

Script:  pbTrainerPC

Wild Pokemon Battles

To generate a wild Pokemon battle, call pbWildBattle(X,Y,V,C) where X is the species number of the Pokemon, and Y is its level. See PBSpecies for species IDs. The optional parameter V represents the number of a variable to store the result of the battle (1=won; 3=escaped; 4=caught), and the optional parameter C is true if the player can escape from the battle.

To change the kinds of wild Pokemon found in an area, you can use the "Set Encounters" option in the Pokemon Essentials Editor (editor.exe). After doing so, it is enough to put grass tiles (or other tiles with terrain tag 2) on the map for wild Pokemon to appear there -- no events are necessary. Pokemon Essentials supports two different encounter types: Land and Cave. For Land encounter types, wild Pokemon will appear only on the grass. For Cave encounter types, wild Pokemon will appear anywhere. Several other encounter types are also supported.

Trainers

Trainer events have a name of "Trainer(X)", where X is the maximum range of vision of the Trainer, that is, the number of spaces that the Trainer can "see". For example, if the event is named "Trainer(4)", the event will trigger if the player is at least 4 spaces away from it.

A Trainer event usually consists of these Comment event commands:

Comment: Battle: Battle me now!
Comment: Type: CAMPER
Comment: Name: Cindy
Comment: EndSpeech: A very good battle, indeed.
Comment: EndBattle: Thanks for the battle.\mI enjoyed it.

The game will convert these comments to appropriate event commands automatically when the game is run from RPG Maker XP. Also, the game will automatically detect whether a Trainer is added when a battle with that Trainer would begin. If not, you will be given the chance to define the Pokemon that the Trainer has. The meanings of each supported comment are defined below.

Behind the Scenes

Please note that the instructions above are sufficient for simple Trainer battles. Using the method shown below is appropriate only for more complex battles, such as Gym Leader battles.

If you inspect the generated event commands, you will see that Trainer events normally consist of two event pages. The first has an Event Touch trigger and has the following structure:

Text:  I challenge you!
Conditional Branch: Script: pbTrainerBattle(PBTrainers::LEADER_Roxanne,"Roxanne",_I("Excellent.  You have earned the Stone Badge."))
  -- here you can add event commands to be run when the player wins, but this is not necessary
  Script: $Trainer.badges[0]=true
  Text:  \PN received the Stone Badge!
  Text:  The Stone Badge proves you can succeed in the Pokemon League.
  Control Self Switch:  A =ON
Branch End

Notice the parameters to pbTrainerBattle. Here is a list of the parameters:

You can play music when a Trainer wants to battle by adding a "Play ME" event command as the first on the list of commands. Also, the Trainer event need not be named "Trainer(X)" if it only needs to be talked to in order to start a battle, as is the case for Gym Leaders and other special Trainers.

The second event page has a condition of "Self Switch A is ON", and usually contains text that the Trainer says after the battle is over. The trigger must be other than Event Touch.

The game system will automatically handle the case when two Trainers come into contact with the player at the same time; in that case, a multi battle will begin if the player has at least two Pokemon.

For Trainer battles that span two events (as is the case with many double battles), the other event's self switch should be turned on when the player wins. You can use the pbSetSelfSwitch function for this.

Double Trainer Battles

To invoke a battle against two different Trainers, use the pbDoubleTrainerBattle function.

@> Conditional Branch: Script: pbDoubleTrainerBattle(PBTrainers::CAMPER,"Andrew",0,_I("ABC"),PBTrainers::CAMPER,"Andrew",0,_I("DEF"))
  @> -- Event commands to be run when the player wins
  @>
 : Else
  @> -- Event commands to be run when the player loses.  For example:
  @> Exit Event Processing
  @>
 : Branch End

The function's parameters are as follows:

The important thing to note here is that each Trainer mentioned must have three or fewer Pokemon.

Nightly Trainers

The following example event shows not only how to make Trainers that fight only at night, but also how to make Trainers that are active only at certain moments or under certain conditions (using the first conditional branch at the top of both event pages.)

Event Page 1

@>Conditional Branch: Script: Time.now.hour<6||Time.now.hour>=20
  @>Text: Halt!  Who goes there?
  @>Conditional Branch: Script: pbTrainerBattle(PBTrainers::POKeMANIAC,"Andrew",_I("Whoops..."),false,0)
    @>Control Self Switch: A =ON
    @>
   : Branch End
  @>
 : Else
  @>Text: I'm on guard for suspicious activity.
  @>
 : Branch End
@>

Event Page 2

@>Conditional Branch: Script: Time.now.hour<6||Time.now.hour>=20
  @>Text: Oh, sorry.  You may proceed.
  @>
 : Else
  @>Text: I'm on guard for suspicious activity.
  @>
 : Branch End
@>

Partner Trainers

In Pokemon Essentials, a partner trainer can be registered so that he or she will appear as the player's partner in Pokemon battles. To register a partner, use a Script event command:

pbRegisterPartner(PBTrainers::PkMnTRAINER_Cheryl,"Cheryl",0)

The first parameter is the internal name of the partner's trainer type, and the second parameter is the partner's name. The parameter shown here as 0 is optional, it indicates which party to use for the partner trainer. To define the partner, choose "Edit Trainers" from the Pokemon Essentials Editor (editor.exe).

The partner will be registered as long as the player remains on the same map. To deregister the partner, use a Script event command:

pbDeregisterPartner

Special rules apply when the player is accompanied by a partner. First, the entire party will be healed at the end of the battle; and second, all opposing trainers must have at least two Pokemon with them. It is interesting, though, to make sure two opposing trainers face each other on the map.

This feature can be used in combination with 78177.

The back of the trainer is to be placed in Graphics/Pictures/ and has a filename of trbackXXX.png, where XXX is the trainer type's ID number. Trainer backs for partner trainers and other trainers are defined in the same way.

Editing Trainers and Battles

The easiest way to edit trainers and trainer types is to use the options "Edit Trainers" and "Trainer Types" options on the debug menu (press F9 during a game) or the Pokemon Essentials editor (editor.exe). Both options offer an intuitive way of editing Trainer battles and Trainer types.

Terrain Tags

The following terrain tags are defined:

More may be defined in the future. However, RPGXP's tileset editor only supports seven terrain tags. That's why Pokemon Essentials contains a built-in terrain tag editor. It can be accessed from the "Debug" option in the game menu.

Trainer Object

PokeBattle_Trainer.new has two parameters: the first is the trainer name, and the second identifies the trainer type (such as PBTrainers::YOUNGSTER). The $Trainer object identifies the player. Here are some properties of the $Trainer object:

Adding a Pokemon

For an easy way to add a Pokemon, call pbAddPokemon(X,Y) where X is the species number of the Pokemon, and Y is its level. You can modify that function, which is located in PokemonUtilities, to remove the messages. Adding a Pokemon may fail, so this statement should appear in a "Conditional Branch" event command.

Adding an Egg

You can use the function pbGenerateEgg to add an egg to the Trainer's party. Here's an example.

@>Conditional Branch: Script: $Trainer.party.length>=6
  @>Text: You have no room to store the Egg...
  @>
 : Else
  @>Script: Kernel.pbGenerateEgg(
   :      :   PBSpecies::TOGEPI,5
   :      : )
  @>Text: Received a Pokemon Egg.
  @>
 : Branch End
@>

Removing a Pokemon

To remove a Pokemon from the party, use the script $Trainer.party.delete_at(X) where X is the Pokemon's position (starting at 0). For example, to remove the first Pokemon in the party, use 0 for X.

Graphical Effects

Water Reflection

Any tile with terrain tag 6 will display a reflection of any events on it.

Light Sources

Any event can serve as a light source. To make an event a light source, name the event either "Light" or "OutdoorLight". The difference between them is that an event named "OutdoorLight" will change its intensity according to the time of day.

Shadows

Any event can draw a shadow on the player. To make an event a shadow source, add a Comment event command consisting of the text "begin Shadow Source". You can add up to four additional Comment event commands for extra parameters of the shadow, like this:

Comment:  begin Shadow Source
Comment:  anglemin 180
Comment:  anglemax 360
Comment:  distancemax 350
Comment:  opacity 100

To allow a shadow to appear on an event, add a Comment event command consisting of the text "begin Shadow".

Particle Engine

Pokemon Essentials includes a particle engine for enabling special graphical effects with particles. To add a particle effect to an event, add to the event a Comment event command consisting of the text "Particle Engine Type" and add another Comment event command consisting of one of the following: fire, smoke, teleport, spirit, aura, soot, sootsmoke, rocket, fixteleport, smokescreen, flare, splash, or starteleport.

Transitions

In addition to normal transitions, Pokemon Essentials also supports special transitions that are not possible with transition bitmaps alone. Most of them require the file rubyscreen.dll, included with the distribution, since a screen capture of the game is required for them. These transitions activate when a special pseudofile is entered into the Graphics.transition function. For example, for the Breaking Glass transition, which breaks the screen into pieces, the file would be "Graphics/Transitions/BreakingGlass". That file need not exist, but it can be used as a map and/or battle transition if that file does exist. Even if the file exists, it can even be zero-length and it will still work.

The following transitions are available:

RotatingPieces, BreakingGlass, Mosaic, Splash, ScrollDown, ScrollUp, ScrollLeft, ScrollRight, RandomStripeV, RandomStripeH, ScrollDownRight, ScrollDownLeft, ScrollUpLeft, ScrollUpRight

Each special transition is contained in an object similar to that of Sprite -- it contains initialize, update, dispose, and disposed?. Here are the four methods of a transition object.

New transitions are added to the judge_special_transition method, located in the script section Transitions, within the list of "elsif" lines within that method. For example, a transition named "mytransition" would be added like this:

    elsif dc=="mytransition"
      @@transition=MyTransition.new(duration)

You can look at the different transition objects in SpriteWindow to get an idea of how to create your own.

GIF Support

There is a special class defined, called GifSprite, which can load GIF image files and animate them. A GIF sprite can be created using GifSprite.new(X) where X is the GIF's filename. File extensions can be omitted. The GifSprite's "update" method must be called in order to animate the sprite. See GifSprite in the script section PokemonUtilities for the class's definition.

Message System

This is the syntax used by the message system:

It is not necessary or recommended to put spaces after a message command; such spaces will be reflected in the message when it is rendered. For example, "\bText" is preferred over "\b Text".

Using the Message System in Other Projects

To use the message system in other RPGXP projects, copy the script sections BitmapCache, DrawText, SpriteWindow, and PokemonMessages and put them just before the last script in the script editor. In addition, create a new script section that consists of the following code:

def _INTL(*args); return args[0]; end
def _ISPRINTF(*args); return args[0]; end
def _MAPINTL(*args); return args[1]; end
module Graphics
  def self.width; return 640; end
  def self.height; return 480; end
end

Also, copy the following files to your project:

After doing so, the new message system will be ready to use.

Background Music

The background music for specific types of Trainers can be set from the debug menu's "Trainer Types" option, under Battle BGM, Battle End ME, and Battle Intro ME. You may, for example, want to use one kind of music for Elite Four members and Gym Leaders.

Default Background Music

The default battle music can be changed by going to the "Set Metadata" option within the debug menu or Pokemon Essentials Editor, and choosing "GLOBAL". There are four possible settings for background music: TrainerBattleBGM, WildBattleBGM, TrainerVictoryME, and WildVictoryME. The names are pretty self-explanatory. The BGM (background music) files mentioned here are to be placed in the Audio/BGM/ directory, and the ME (music effects) files to the Audio/ME/ directory.

Changing the Battle Music

You can change the background music to be played during a battle by using the "Change Battle BGM" and "Change Battle End ME" event commands. These settings apply only to the next Pokemon battle.

Nightly Music

To specify a different BGM file to play at night, add an "n" to the filename before the file extension. For example, the nightly version of "song.mid" would be "songn.mid". This will apply only to BGM files played on the map.

Localization and Translation

All the text in Pokemon Essentials can be translated to a different language using the "Extract Text/Compile Text" feature.

To use this feature, open the Pokemon Essentials editor (editor.exe) and select "Extract text". This function will save a file called "intl.txt" within the game folder. Open the file, then translate every second line of the file. For example, if one part of the file reads:

Good day.
Good day.

you could translate it by changing it to:

Good day.
Guten Tag.

After you are done translating, select "Compile Text" from the Debug menu. This function will convert the text to another file called "intl.dat" within the game folder. Rename that file and put it into the Data folder of the project, then close and restart the game.

The languages that the game uses can be found in the LANGUAGES array of the PokemonSystem script section. That script defines an array called LANGUAGES that contains two sample languages and message files, which are commented out. Each entry in the array includes the name of the language followed by the message data file's filename (like intl.dat), located in the Data folder. Please note that the mentioned files don't really exist.

Map Making Considerations

Avoiding Black Regions Near Map Edge

In general, the border of a map needs to be wide enough so that the player can remain centered without any black spots on the edges. That means 7 tiles on the left and right edges of the map and six tiles on the top and bottom edges. You can easily add more room to a map using the following steps:

On the other hand, this behavior of a black area outside the map is desired for indoor maps.

Can still surf on water even with a bridge over it

Water tiles have terrain tag 7, but due to the way the RPGXP map system works, tiles without terrain tags are ignored in determining what terrain tag an area has. In this case, bridge tiles have no terrain tag, but since a water tile is underneath it, the bridge is inappropriately considered to have terrain tag 7 and could thus be surfed on. To work around this, define a terrain tag for bridges (the neutral terrain tag 13 is designed for this purpose). To do so, open the game from RPG Maker XP, then open the in-game menu and select "Debug", then "Edit Terrain Tags." (Setting terrain tags higher than 7 is not possible in RPG Maker XP.)

Game freezes during movement

This usually happens when a move route is defined on an event and a "Wait for Move's Completion" event command follows it, but the event to be moved is prevented from moving. This problem is not limited to Pokemon Essentials, though. To solve this problem, check the following in order, testing after each step.

Common Mistakes

Debugging

Playtesting Functions

In playtests (when the $DEBUG global variable is set), the following functions are available:

Debug Menu

The debug menu contains features useful for debugging or configuring a Pokemon game. It can be accessed by pressing F9 during a playtest or by choosing "Debug" from the game's main menu.

Pokedex

Use $Trainer.pokedex=true to add the Pokedex.

Town Map

Use pbShowMap to show the Town Map.

Pokegear

Use $Trainer.pokegear=true to add the Pokegear.

Running Shoes

Use $PokemonGlobal.runningShoes=true to give Running Shoes to the player.

Badges

To add a Gym Badge, use $Trainer.badges[X]=true where X is a number from 0 through 7 (though it is safe to assume that more Badges are possible). It is normally set after the player defeats a Gym Leader.

The constants found in the PokemonField script section (like BADGEFORCUT) determine which Badge enables which hidden move.

The image for all Badges is located at Graphics/Pictures/badges.png.

Phone

The Pokegear phone supports the storage of Trainers' phone numbers and enabling rematches. A Trainer's phone number can be added if there are multiple battles for the same Trainer event.

The possible dialogue from a phone can be edited in PBS/phone.txt. It contains four sections:

Trainer Card

The Trainer Card's image is found in Graphics/Pictures/trcard.png , and the background is found in Graphics/Pictures/trcardbg.png .

Name Rater and Move Deleter

Looking at the events for the Move Deleter and Name Rater can be very instructive when learning to call such tasks as choosing a Pokemon or choosing a move.

Coin Case and Game Coins

$PokemonGlobal.coins in a script retrieves the current number of coins. Example:

Text:  Here are some coins.
Script:  $PokemonGlobal.coins+=10
Text:  Obtained 10 game coins!

(It may be useful here to add code to enforce a maximum number of coins:)

Script:  $PokemonGlobal.coins+=10
:     :  if $PokemonGlobal.coins>9999
:     :     $PokemonGlobal.coins=9999
:     :  end

However, a player can't obtain Coins without a Coin Case, so that case should be checked first.

Conditional Branch:  Script:  $PokemonBag.pbQuantity(PBItems::COINCASE)==0
  Text:  Oops!  Forgot the Coin Case!
  Exit Event Processing
Branch End

Another example:

Script:  $game_variables[1]=
:     :    $PokemonGlobal.coins
Text:  You have \v[1] game coin(s).

Dependent Events

The game system supports dependent events. Dependent events are those that follow the player character whenever the player moves. To add a dependent event, use this script:

Kernel.pbAddDependency(
get_character(0))

To remove a dependent event, use this script:

Kernel.pbRemoveDependency(
get_character(0))

All dependencies are removed when the player leaves the map.

Move Tutors

The game system allows the creation of "move tutor" events, like in Pokemon FireRed and LeafGreen. To use it, call the script function pbMoveTutorChoose(PBMoves::X, Y) where X is the name of a move, and Y is a list of species that can use that move. An example of its use follows. The move tutor here teaches the move Softboiled.

@>Conditional Branch: Script: pbMoveTutorChoose(PBMoves::SOFTBOILED,::SOFTBOILEDLIST)
  @>Text: Move learned.
  @>
 : Else
  @>Text: Move not learned.
  @>
 : Branch End

The script code in the conditional branch refers to the array called "::SOFTBOILEDLIST", which is a list of species that can learn Softboiled. It can appear in a new script section like this:

::SOFTBOILEDLIST=[
PBSpecies::CHANSEY,
PBSpecies::HAPPINY,
PBSpecies::BLISSEY,
PBSpecies::TOGEPI,
PBSpecies::TOGETIC,
PBSpecies::TOGEKISS
]

Bicycle

Use the script "pbMountBike" and "pbDismountBike" to mount and dismount the bicycle.

Miscellaneous

To define the back of a Trainer, for use in battles, create a graphic file with a size of 128x128 and the file must be located in Graphics/Pictures. This graphic file is not specific to a player but rather to a trainer type. The trainer back has a filename of trbackXXX.png where XXX is the trainer type's ID. Alternatively, the file can have a size of 512x128, where each 128x128 block is a single frame of a 4-frame animation. See the example at Graphics/Pictures/trback000.png.

To change the player in script, use pbChangePlayer(X) where X is one of 0, 1, 2, or 3 and refers to players A, B, C, or D. The PlayerA setting is required while the other three settings are optional.

The fishing animation is a five-frame animation. It resembles the 16-frame character sprites, but only the first five frames are used. It must be placed in Graphics/Characters/ and must have a filename of "fishingXXX.png", where XXX is a trainer type's ID. Example: fishing000.png. See below for the layout of the frames.

Frame1   Frame2   Frame3   Frame4

Frame5   ------   ------   ------

------   ------   ------   ------

------   ------   ------   ------

In the Custom and Perspective map views, the day/night tinting will be disabled for any event named "RegularTone".

Suggestions for Customizing Scripts

For further scripting ideas, see the advanced topics.

Displaying a Player-Supplied Name for a Trainer

To make the player supply a name for trainer, you can use this Script event command within an event (assuming that 25 is the variable you want to use):

$game_variables[25]=
pbEnterText("Gary",1,7)

"Gary", here, is the trainer's default name.

Then modify the script section PokemonTrainers by adding the lines in bold (the following is from lines 14 to 16), assuming that the Trainer's trainer type is RIVAL and the Trainer's name is "???":

   name=pbGetMessageFromHash(MessageTypes::TrainerNames,name)
   if trainerid==PBTrainers::RIVAL && trainername=="???"
     name=$game_variables[25] # Replace 25 with the variable number for the name
   end
   opponent=PokeBattle_Trainer.new(name,thistrainerid)

The code above replaces the name "???" with the name the player gave.

The advantage of this approach is that the Trainer's new name can be displayed in any Text event command using the command "\v[25]".

Shiny Wild Pokemon

To allow shiny wild battles, you first need to define a switch for shiny Pokemon, say, 50. Now, put a new script section just before the last one in the script editor. In that script, enter the following:

Events.onWildPokemonCreate+=proc {|sender,e|
  pokemon=e[0]
  if $game_switches[50]
    pokemon.makeShiny
  end
}

Then, enable the switch (in this case, 50) before a wild battle with a shiny Pokemon, and disable the switch when the battle is over. Example:

Control Switches: [0050: Shiny] = ON
Script: pbWildBattle(
          ::PBSpecies::GYARADOS,30,1)
Control Switches: [0050: Shiny] = OFF

Allowing a Player to Lose a Trainer Battle

Here is an example of a battle where the player stays at the same position whether he or she loses or wins a Trainer battle.

Conditional Branch: Script: pbTrainerBattle(PBTrainers::LEADER_Roxanne,"Roxanne",_I("Excellent."),false,0,true)
  -- here you can add event commands to be run when the player wins the battle
Else
  -- here you can add event commands to be run when the player loses the battle
Branch End

Pokemon Types

The script section PBTypes contains instructions for adding new Pokemon types. To incorporate an icon of the new type, edit the file Graphics/Pictures/types.png.

Controlling Events with Scripts

The script section PokemonMessages contains several functions for controlling events with scripts. This includes applying move routes, waiting, and so on. For an example of their use, see the script section PokemonDuel.

pbWait(x)

Waits x frames, where a frame is 1/40 of a second. While waiting, processes the rest of the scene.

pbShake(power,speed,x)

Shakes the screen x frames, where a frame is 1/20 of a second. The shake has power "power" and speed "speed". Returns immediately.

pbFlash(color,x)

Flashes the screen x frames, where a frame is 1/20 of a second. in the specified color (Color).

pbToneChangeAll(tone,duration)

Sets the screen color tone ("tone", Tone) on the screen and all pictures. Fades the tone in for duration frames, where a frame is 1/20 of a second.

pbMoveRoute(event,commands)

Runs a move route on an event (Game_Character). To get the player, use "$game_player". To get an event, use "$game_map.events[X]" where X is the event ID. "event" can be nil. "commands" is an array of move route commands, with each command followed by a set of parameters for that command. Here is an example of a move route defined for a player:

    pbMoveRoute($game_player,[
      PBMoveRoute::ChangeSpeed,2, 
      PBMoveRoute::Backward
    ])

Notice that the ChangeSpeed command is followed by a number specifying the speed. The Backward command has no parameters, however. Here is a list of possible commands. Most are self-explanatory.

The function adds a ThroughOn command at the beginning and a ThroughOff command at the end of the move route. This function returns immediately and does not wait for the move route to complete. This function's return value is the generated move route (RPG::MoveRoute).

History

August 30, 2008

Moved advanced topics to a separate "Advanced Topics" file, made editing metadata.txt deprecated

August 8, 2008

Added more speech frames

Improved localization (translation) support

Added section on scenes to the notes

Made editing trainers.txt, encounters.txt, and trainernames.txt deprecated

July 10, 2008

More message system improvements

Toned down the nighttime color

Performance improvement with thread priorities

July 1, 2008

June 24, 2008

Added a very simple Pokemon lab example

Prevented throwing an error if the player has no Pokemon

Added support for common battle animations: "Common:StatUp", "Common:StatDown", "Common:Burn", "Common:Frozen", "Common:Poison", "Common:Sleep", "Common:Paralysis", and "Common:Confusion"

Made Audio.dll optional

Improved sandstorm animation a little

June 1, 2008

Added a very simple Gym example

Added support for Recover All event command

Miscellaneous fixes and improvements

May 25, 2008

May 21, 2008

Improved on the message system and added instructions for incorporating the message system into other projects.

May 15, 2008

New name entry system, implemented "Area" feature of the Pokedex.

May 2, 2008

April 26, 2008

Implemented Poke Radar; rewrote Bitmap Caches to avoid memory problems; made Trainer Pokemon stronger than wild Pokemon. Implemented Spinda's Spots; improved battle AI in Pokemon-switching decisions.

March 1, 2008

Another maintenance release. Included an editor for easy access to the game settings without opening RPG Maker XP.

February 19, 2008

Just a maintenance release, no features were added. Code was changed and scripts added to make Pokemon Essentials compatible with RGSS 2, and moved trainer, item, and species constants to a separate data file, to prevent problems that can occur when a project is saved. Also, the Audio DLL was modified to help fix a bug in playback.

February 11, 2008

February 3, 2008

January 24, 2008

January 19, 2008

January 14, 2008

January 6, 2008

January 1, 2008

December 28, 2007

December 24, 2007

December 19, 2007

December 14, 2007

December 9, 2007

December 3, 2007

November 23, 2007

November 13, 2007

November 6, 2007

October 30, 2007

October 26, 2007

October 23, 2007

October 20, 2007

October 14, 2007

October 6, 2007

October 2, 2007

September 28, 2007

September 15, 2007

A Pokedex screen, a Pokemon Mart screen, evolution support, a finished summary screen, as well as the Name Rater and Move Deleter. Also a method to add custom items to the game.

September 7, 2007

First release