src/overworld.c and composed of maps, tilesets, event objects, scripts, weather, and field move effects.
Map structure
Each in-game map lives in its own subdirectory underdata/maps/. A map consists of:
data/layouts/ and point to the two tilesets the map uses:
Every map uses exactly two tilesets: a primary tileset (terrain, water, ground) and a secondary tileset (buildings, decoration, map-specific tiles). Both are defined under
data/tilesets/.Metatile behaviors
Metatile behaviors control how the player and NPCs interact with each tile. Constants are defined ininclude/metatile_behavior.h as MB_* values.
src/field_player_avatar.c and src/metatile_behavior.c.
Event types
Events are defined per-map in theevents.inc file and fall into four categories:
Object events (NPCs)
Object events (NPCs)
Object events are sprites placed on the map. Each has a movement type, script pointer, flag, and trainer sight range (if applicable).Object event graphics and movement types are defined in
include/constants/event_objects.h and src/event_object_movement.c.Warp events
Warp events
Warp events teleport the player to another map and position when stepped on.Warp processing is handled in
src/overworld.c and src/field_control_avatar.c.Coordinate events
Coordinate events
Coordinate events trigger a script when the player steps on a specific tile. Used for invisible triggers, zone transitions, and forced camera pans.
Background events
Background events
Background events are scriptable tiles the player can interact with by pressing A while facing them (signs, bookshelves, item balls, hidden items).
Field move effects
HM and field move effects are implemented in dedicated source files:
Each file contains the effect’s activation check, animation, and script callback.
Overworld engine
src/overworld.c is the main field game loop. It manages:
- Loading and transitioning between maps
- Player input routing (movement, menu, interaction)
- Field object (NPC) step-cycle updates
- Script context execution each frame
- Camera and background scrolling
1
Map load
On a map transition,
LoadMapFromCameraTransition or LoadMap sets up tileset data, object events, scripts, and BGM.2
Field loop
FieldCB_ContinueScriptHandleMusic runs every frame: it updates objects, checks coordinate events, and steps the script engine.3
Interaction
When the player presses A,
TryInteractWithObjectEvent scans the tile in front of them for a background event or NPC and starts the associated script context.Weather
Weather state is managed by two source files:
Weather types are defined in
include/constants/weather.h as WEATHER_* constants. The current weather is set via the setweather and doweather script commands.