Skip to main content

Move Effects

Move effects in Pokémon Essentials BES are controlled by function codes that determine what happens when a move is used. Each move in PBS/moves.txt has a function code that defines its unique behavior.

Move Data Structure

Each move is defined with the following format in PBS/moves.txt:
ID,InternalName,DisplayName,FunctionCode,Power,Type,Category,Accuracy,TotalPP,EffectChance,Target,Priority,Flags,Description
FunctionCode
hex
Hexadecimal code defining the move’s unique effect (e.g., 000, 0DD, 116)
EffectChance
integer
Percentage chance of secondary effect occurring (0-100)

Common Function Codes

Damage Function Codes

Function Code: 000Basic damaging move with no special effects.Examples:
1,MEGAHORN,Megacuerno,000,120,BUG,Physical,85,10,0,00,0,abef
4,XSCISSOR,Tijera X,000,80,BUG,Physical,100,15,0,00,0,abef
Function Code: 0DDRestores user’s HP equal to damage dealt (typically 50%).Examples:
13,LEECHLIFE,Chupavidas,0DD,80,BUG,Physical,100,10,0,00,0,abef
99,DRAINPUNCH,Puño Drenaje,0DD,75,FIGHTING,Physical,100,10,0,00,0,abefj
Implementation:
# Restores half of damage dealt
heal_amount = damage_dealt / 2
user.hp += heal_amount

Status Effect Function Codes

Function Code: 003Puts the target to sleep.Examples:
39,DARKVOID,Brecha Negra,003,0,DARK,Status,50,10,0,04,0,bce
Function Code: 007Attempts to paralyze the target.Examples:
59,DRAGONBREATH,Dragoaliento,007,60,DRAGON,Special,100,20,30,00,0,bef
64,BOLTSTRIKE,Ataque Fulgor,007,130,ELECTRIC,Physical,85,5,20,00,0,abef
65,THUNDER,Trueno,008,110,ELECTRIC,Special,70,10,30,00,0,bef
83,THUNDERWAVE,Onda Trueno,007,0,ELECTRIC,Status,90,20,0,00,0,bce
Function Code: 00FCauses damage and may make the target flinch.Examples:
25,DARKPULSE,Pulso Umbrío,00F,80,DARK,Special,100,15,20,00,0,bem
28,BITE,Mordisco,00F,60,DARK,Physical,100,25,30,00,0,abei

Stat Modification Function Codes

Function Code: 020Damage move that has a chance to raise the user’s Special Attack.Examples:
78,CHARGEBEAM,Rayo Carga,020,50,ELECTRIC,Special,90,10,70,00,0,bef
Function Code: 043Damage move that may lower the target’s Defense stat.Examples:
24,CRUNCH,Triturar,043,80,DARK,Physical,100,15,20,00,0,abefi
Function Code: 044Damage move that lowers the target’s Speed stat.Examples:
77,ELECTROWEB,Electrotela,044,55,ELECTRIC,Special,95,15,100,04,0,bef
Function Code: 045Damage move that lowers the target’s Special Attack stat.Examples:
10,STRUGGLEBUG,Estoicismo,045,50,BUG,Special,100,20,100,04,0,bef
30,SNARL,Alarido,045,55,DARK,Special,95,15,100,04,0,befk

Multi-Turn and Special Mechanics

Recoil Moves

Function Code: 0FAUser takes recoil damage after attacking.Examples:
66,VOLTTACKLE,Placaje Eléc.,0FD,120,ELECTRIC,Physical,100,15,10,00,0,abef
70,WILDCHARGE,Voltio Cruel,0FA,90,ELECTRIC,Physical,100,15,0,00,0,abef
97,SUBMISSION,Sumisión,0FA,80,FIGHTING,Physical,80,20,0,00,0,abef

Switch-Out Moves

Function Code: 0EEUser switches out after dealing damage.Examples:
6,UTURN,Ida y Vuelta,0EE,70,BUG,Physical,100,20,0,00,0,abef
73,VOLTSWITCH,Voltiocambio,0EE,70,ELECTRIC,Special,100,20,0,00,0,bef
Implementation concept:
# After damage is dealt
if user_side_has_remaining_pokemon?
  force_switch_menu(user)
end
Function Code: 0ECForces the target to switch out.Examples:
58,DRAGONTAIL,Cola Dragón,0EC,60,DRAGON,Physical,90,10,0,00,-6,abef

Multi-Hit Moves

Function Code: 0BDHits exactly twice.Examples:
60,DUALCHOP,Golpe Bis,0BD,40,DRAGON,Physical,90,15,0,00,0,abef
Function Code: 0C0Hits 2-5 times in one turn.Examples:
14,PINMISSILE,Pin Misil,0C0,25,BUG,Physical,95,20,0,00,0,bef

Self-Targeting Moves

Stat Boost Moves

Function Code: 026Raises user’s Attack and Speed.Examples:
63,DRAGONDANCE,Danza Dragón,026,0,DRAGON,Status,0,20,0,10,0,d
Function Code: 029Raises user’s Attack and Accuracy.Examples:
43,HONECLAWS,Afilagarras,029,0,DARK,Status,0,15,0,10,0,d
Function Code: 032Sharply raises user’s Special Attack (2 stages).Examples:
45,NASTYPLOT,Maquinación,032,0,DARK,Status,0,20,0,10,0,d

Special Mechanics

Priority-Based Moves

Function Code: 116Hits first, but fails if target isn’t using an attack.Examples:
26,SUCKERPUNCH,Golpe Bajo,116,70,DARK,Physical,100,5,0,00,1,abef
Implementation:
# Only works if target is preparing an attacking move
if !target_using_attacking_move?
  move_fails()
else
  deal_damage()
end
Function Code: 115Charges first, fails if hit during charge.Examples:
84,FOCUSPUNCH,Puño Certero,115,150,FIGHTING,Physical,100,20,0,00,-3,abfj

Item-Based Moves

Function Code: 0F1Steals target’s held item.Examples:
34,THIEF,Ladrón,0F1,60,DARK,Physical,100,25,0,00,0,abef
Function Code: 0F7Throws held item at target.Examples:
37,FLING,Lanzamiento,0F7,1,DARK,Physical,100,10,0,00,0,bef
Power varies by item thrown.

Move Compilation

Moves are compiled from PBS/moves.txt to Data/moves.dat:
def pbCompileMoves
  records=[]
  movenames=[]
  movedescs=[]
  movedata=[]
  maxValue=0
  
  pbCompilerEachPreppedLine("PBS/moves.txt"){|line,lineno|
    record=pbGetCsvRecord(line,lineno,[0,"vnsxueeuuuxiss",
       nil,nil,nil,nil,nil,PBTypes,["Physical","Special","Status"],
       nil,nil,nil,nil,nil,nil,nil
    ])
    
    # Validate function code
    pbCheckWord(record[3],_INTL("Function code"))
    
    # Pack move data
    movedata[record[0]]=[
       record[3],  # Function code
       record[4],  # Damage
       record[5],  # Type
       record[6],  # Category
       record[7],  # Accuracy
       record[8],  # Total PP
       record[9],  # Effect chance
       record[10], # Target
       record[11], # Priority
       flags,      # Flags
       0           # Contest type (unused)
    ].pack("vCCCCCCvCvC")
  }
end

Move Data Access

In battle, move data is read from Data/moves.dat:
class PBMoveData
  attr_reader :function,:basedamage,:type,:accuracy
  attr_reader :totalpp,:addlEffect,:target,:priority
  attr_reader :flags,:category

  def initialize(moveid)
    movedata=pbRgssOpen("Data/moves.dat")
    movedata.pos=moveid*9  # Each move is 9 bytes
    @function=movedata.fgetb    # Function code
    @basedamage=movedata.fgetb  # Base power
    @type=movedata.fgetb        # Type
    @accuracy=movedata.fgetb    # Accuracy
    @totalpp=movedata.fgetb     # PP
    @addlEffect=movedata.fgetb  # Effect chance
    @target=movedata.fgetb      # Target
    @priority=movedata.fgetsb   # Priority (signed)
    @flags=movedata.fgetb       # Flags
    movedata.close
  end
end

Target Types

The Target field determines who can be targeted:
  • 00: Single adjacent opponent
  • 01: No target (user only)
  • 02: Random opponent
  • 04: All opponents
  • 08: All Pokémon except user
  • 10: User’s side

Creating Custom Move Effects

Custom function codes should be implemented in the battle scripts, typically in PokeBattle_Move classes.
Example structure:
class PokeBattle_Move_XXX < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    # Custom effect logic
    damage = pbCalcDamage(attacker,opponent)
    # Apply secondary effects
    return damage
  end
end
See also:

Build docs developers (and LLMs) love