src/script.c and src/scrcmd.c.
Script files
Scripts in
data/event_scripts.s use pokeemerald’s custom preproc macro format. poryscript is recommended for writing new scripts — it compiles a higher-level language to the binary script format and has a VS Code extension.Script command table
data/script_cmd_table.inc assigns each opcode a constant name and a C handler. For example:
data/script_cmd_table.inc. Handler implementations live in src/scrcmd.c.
Specials table
data/specials.inc defines gSpecials, the table of C functions that scripts can invoke via the special command. Each entry is assigned an index automatically using def_special. A selection of real entries:
Basic script syntax
Scripts are label-terminated lists of commands in ARM assembly syntax:Common script commands
Control flow
Control flow
Player and NPC interaction
Player and NPC interaction
Items and Pokémon
Items and Pokémon
Flags and variables
Flags and variables
MSGBOX types
Map scripts
Map scripts run automatically at specific lifecycle points. Attach them in the map’s.inc file using:
Using poryscript
poryscript compiles a higher-level scripting language to the binary format expected by pokeemerald. It removes boilerplate and makes branching logic readable.1
Install poryscript
Download the latest release binary from the poryscript releases page and place it in your
PATH, or in the repository root.2
Write a .pory file
3
Compile to script binary
#include the output file from data/event_scripts.s.4
Install the VS Code extension
Search for poryscript in the VS Code Extensions panel, or install
karathan.poryscript directly. It provides syntax highlighting and snippets.