Skip to main content

Overview

The Pokémon class system in Pokémon Essentials BES handles individual Pokémon data, stats, moves, and battle mechanics. The primary class is PokeBattle_Pokemon, which stores all data for a single Pokémon. Source: Data/EditorScripts/031_PokeBattle_Pokemon.rb

PokeBattle_Pokemon

The main class for storing Pokémon data. Accessible via $Trainer.party for the player’s party.

Core Attributes

Stats (Read-Only)

totalhp
Integer
The Pokémon’s maximum HP
attack
Integer
Current Attack stat
defense
Integer
Current Defense stat
speed
Integer
Current Speed stat
spatk
Integer
Current Special Attack stat
spdef
Integer
Current Special Defense stat

Individual Values & Effort Values

iv
Array<Integer>
Array of 6 Individual Values for HP, Attack, Defense, Speed, Special Attack, and Special DefenseRange: 0-31 for each stat
ev
Array<Integer>
Array of 6 Effort ValuesLimits:
  • Maximum 252 per stat (EVSTATLIMIT)
  • Maximum 510 total (EVLIMIT)

Basic Information

species
Integer
Species (National Pokédex number)
name
String
Nickname of the Pokémon
level
Integer
Current level (calculated from experience)Range: 1-100
exp
Integer
Current experience points
happiness
Integer
Current happiness/friendship valueRange: 0-255

Battle State

hp
Integer
Current HP
status
Integer
Status condition (see PBStatuses)Values:
  • 0 - None
  • 1 - Sleep
  • 2 - Poison
  • 3 - Burn
  • 4 - Paralysis
  • 5 - Freeze
statusCount
Integer
Sleep turn counter or Toxic flag

Moves

moves
Array<PBMove>
Array of up to 4 moves (PBMove objects)
firstmoves
Array<Integer>
The moves known when this Pokémon was first obtained

Items & Equipment

item
Integer
Held item ID
itemRecycle
Integer
Consumed held item (used in battle only)
itemInitial
Integer
Initial held item (used in battle only)
ballused
Integer
Poké Ball type used to catch this Pokémon

Trainer Information

personalID
Integer
32-bit Personal ID (determines gender, shininess, etc.)
trainerID
Integer
32-bit Trainer ID (upper 16 bits = secret ID)
ot
String
Original Trainer’s name
otgender
Integer
Original Trainer’s genderValues: 0=male, 1=female, 2=mixed, 3=unknown

Special Flags

abilityflag
Integer
Forces the first/second/hidden ability (0/1/2)
genderflag
Integer
Forces male (0) or female (1)
natureflag
Integer
Forces a particular nature
shinyflag
Boolean
Forces shininess (true/false)

Constructor

initialize

def initialize(species, level, player=nil, withMoves=true)
Creates a new Pokémon.
species
Integer|String|Symbol
required
Pokémon species (ID, name, or constant)
level
Integer
required
Initial level (1-100)
player
PokeBattle_Trainer
default:"nil"
Original trainer (defaults to current player if nil)
withMoves
Boolean
default:"true"
Whether to initialize with level-up moves
Example:
# Create a level 25 Pikachu
pokemon = PokeBattle_Pokemon.new(:PIKACHU, 25, $Trainer)

# Create without moves
pokemon = PokeBattle_Pokemon.new(25, 50, $Trainer, false)
Source: 031_PokeBattle_Pokemon.rb:884-981

Level & Experience

level

def level
def level=(value)
Gets or sets the Pokémon’s level. Setting the level adjusts experience points. Example:
pokemon.level = 50
puts pokemon.level  # => 50
puts pokemon.exp    # => (experience for level 50)
Source: 031_PokeBattle_Pokemon.rb:121-131

isEgg?

def isEgg?
Returns whether this Pokémon is an egg. Returns: true if @eggsteps > 0 Source: 031_PokeBattle_Pokemon.rb:134-136

growthrate

def growthrate
Returns the Pokémon’s growth rate (experience curve). Returns: Integer (0-5) representing growth rate type Source: 031_PokeBattle_Pokemon.rb:141-147

Gender & Nature

gender

def gender
Returns the Pokémon’s gender. Returns: 0 (male), 1 (female), or 2 (genderless) Source: 031_PokeBattle_Pokemon.rb:162-177

isMale? / isFemale? / isGenderless?

def isMale?
def isFemale?
def isGenderless?
Convenience methods for checking gender. Example:
if pokemon.isMale?
  puts "It's a boy!"
elsif pokemon.isFemale?
  puts "It's a girl!"
else
  puts "It's genderless!"
end
Source: 031_PokeBattle_Pokemon.rb:197-209

nature

def nature
Returns the Pokémon’s nature ID. Returns: Integer (0-24) Calculation: @personalID % 25 (unless overridden by @natureflag) Source: 031_PokeBattle_Pokemon.rb:297-300

setNature

def setNature(value)
Sets the Pokémon’s nature and recalculates stats.
value
Integer|String|Symbol
required
Nature to set
Example:
pokemon.setNature(:ADAMANT)
pokemon.setNature(0)  # Hardy
Source: 031_PokeBattle_Pokemon.rb:316-322

Ability

ability

def ability
Returns the ID of this Pokémon’s current ability. Source: 031_PokeBattle_Pokemon.rb:235-248

hasAbility?

def hasAbility?(value=0)
Checks if the Pokémon has a specific ability.
value
Integer|String|Symbol
default:"0"
Ability to check (0 = check if has any ability)
Example:
if pokemon.hasAbility?(:STATIC)
  puts "Has Static ability!"
end
Source: 031_PokeBattle_Pokemon.rb:251-261

hasHiddenAbility?

def hasHiddenAbility?
Returns whether this Pokémon has its hidden ability. Source: 031_PokeBattle_Pokemon.rb:268-271

Shininess

isShiny?

def isShiny?
Returns whether this Pokémon is shiny. Algorithm: XORs personal ID with trainer ID and checks against SHINYPOKEMONCHANCE Source: 031_PokeBattle_Pokemon.rb:328-335

makeShiny / makeNotShiny

def makeShiny
def makeNotShiny
Forces the Pokémon to be shiny or not shiny. Example:
pokemon.makeShiny
puts pokemon.isShiny?  # => true
Source: 031_PokeBattle_Pokemon.rb:338-345

Types

type1 / type2

def type1
def type2
Returns the Pokémon’s first or second type. Returns: Integer (type ID from PBTypes) Source: 031_PokeBattle_Pokemon.rb:396-411

hasType?

def hasType?(type)
Checks if the Pokémon has a specific type.
type
Integer|String|Symbol
required
Type to check
Example:
if pokemon.hasType?(:ELECTRIC)
  puts "Electric type!"
end
Source: 031_PokeBattle_Pokemon.rb:387-393

Move Management

numMoves

def numMoves
Returns the number of moves the Pokémon knows. Returns: Integer (0-4) Source: 031_PokeBattle_Pokemon.rb:417-423

hasMove?

def hasMove?(move)
Checks if the Pokémon knows a specific move.
move
Integer|String|Symbol
required
Move to check
Example:
if pokemon.hasMove?(:THUNDERBOLT)
  puts "Knows Thunderbolt!"
end
Source: 031_PokeBattle_Pokemon.rb:426-435

pbLearnMove

def pbLearnMove(move)
Silently teaches a move to the Pokémon. Erases the first move if necessary.
move
Integer|String|Symbol
required
Move to learn
Example:
pokemon.pbLearnMove(:THUNDERBOLT)
Source: 031_PokeBattle_Pokemon.rb:476-503

pbDeleteMove

def pbDeleteMove(move)
Removes a specific move from the Pokémon. Source: 031_PokeBattle_Pokemon.rb:506-519

pbDeleteMoveAtIndex

def pbDeleteMoveAtIndex(index)
Removes the move at a specific index (0-3). Source: 031_PokeBattle_Pokemon.rb:522-531

resetMoves

def resetMoves
Resets moves to the default moves for the Pokémon’s level. Source: 031_PokeBattle_Pokemon.rb:456-473

Items

hasItem?

def hasItem?(value=0)
Checks if the Pokémon is holding an item.
value
Integer|String|Symbol
default:"0"
Item to check (0 = check if holding any item)
Example:
if pokemon.hasItem?(:LEFTOVERS)
  puts "Holding Leftovers!"
end
Source: 031_PokeBattle_Pokemon.rb:627-637

setItem

def setItem(value)
Gives an item to the Pokémon. Example:
pokemon.setItem(:LEFTOVERS)
Source: 031_PokeBattle_Pokemon.rb:640-645

Healing

heal

def heal
Fully heals the Pokémon (HP, status, and PP). Source: 031_PokeBattle_Pokemon.rb:761-766

healHP

def healHP
Restores HP to maximum. Source: 031_PokeBattle_Pokemon.rb:736-739

healStatus

def healStatus
Cures status conditions. Source: 031_PokeBattle_Pokemon.rb:742-746

healPP

def healPP(index=-1)
Restores PP for moves.
index
Integer
default:"-1"
Move index to heal (-1 = all moves)
Source: 031_PokeBattle_Pokemon.rb:749-758

Stat Calculation

calcStats

def calcStats
Recalculates all stats based on base stats, IVs, EVs, level, and nature. Formula:
  • HP: ((base*2 + IV + (EV/4)) * level / 100) + level + 10
  • Other stats: (((base*2 + IV + (EV/4)) * level / 100) + 5) * nature_modifier / 100
Source: 031_PokeBattle_Pokemon.rb:847-877

Usage Examples

Creating a Pokémon

# Create a basic Pokémon
pokemon = PokeBattle_Pokemon.new(:PIKACHU, 25, $Trainer)

# Create with specific properties
pokemon = PokeBattle_Pokemon.new(:CHARIZARD, 50, $Trainer)
pokemon.setAbility(1)  # Second ability
pokemon.setNature(:ADAMANT)
pokemon.makeShiny
pokemon.setItem(:CHARCOAL)

Modifying Stats

pokemon = PokeBattle_Pokemon.new(:PIKACHU, 50, $Trainer)

# Set IVs (perfect IVs)
for i in 0...6
  pokemon.iv[i] = 31
end

# Add EVs
pokemon.ev[PBStats::SPEED] = 252
pokemon.ev[PBStats::SPATK] = 252
pokemon.ev[PBStats::HP] = 6

# Recalculate stats
pokemon.calcStats

Move Management

pokemon = PokeBattle_Pokemon.new(:PIKACHU, 50, $Trainer)

# Delete all moves
pokemon.pbDeleteAllMoves

# Teach specific moves
pokemon.pbLearnMove(:THUNDERBOLT)
pokemon.pbLearnMove(:QUICKATTACK)
pokemon.pbLearnMove(:IRONTAIL)
pokemon.pbLearnMove(:GRASSKNOT)

# Check if knows a move
if pokemon.hasMove?(:THUNDERBOLT)
  puts "Knows Thunderbolt!"
end

Battle State

# Damage the Pokémon
pokemon.hp -= 50

# Apply status
pokemon.status = PBStatuses::BURN

# Check if fainted
if pokemon.hp == 0
  puts "#{pokemon.name} fainted!"
end

# Heal
pokemon.heal

Constants

EVLIMIT = 510        # Maximum total EVs
EVSTATLIMIT = 252    # Maximum EVs per stat
Source: 031_PokeBattle_Pokemon.rb:55-56
  • PBMove: Represents individual moves
  • PokeBattle_Trainer: Trainer class that holds Pokémon parties
  • PBSpecies: Species constant definitions
  • PBTypes: Type constant definitions
  • PBNatures: Nature constant definitions

See Also

Build docs developers (and LLMs) love