Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.

Pokémon Mystery Dungeon: Red Rescue Team/Scripting

From Data Crystal
Jump to navigation Jump to search

This is a sub-page of Pokémon Mystery Dungeon: Red Rescue Team.

Much of the game uses it's own specific scripts to move along the plot and have characters interact.

Every script command is 16 byte (0x10) long. The first two bytes are the command identifier, and the rest are the arguments. The last four bytes in a statement are usually reserved for a pointer if needed.

Command identifier, argument, and pointer are in little-endian form.


Some commands have the same or similar functions as others and jump to the same initial location when they are parsed. Individual command function locations are found through the Main Command Parsing Code.

Notable among these are the commands that are skipped in the Main Command Parsing Code 40, 96, CC, CD, CE, D0, D1, D9, F2, F3, F4, F5, and F6.


Below are described the known script commands:

[01] Warp To Location

The 01 Command fades out the current screen, and warps the player to a new location. It can be activated by changing areas (ex: going from base to pokemon square) or through other events like dialogue.

Format: 01 00 XX XX YY YY YY YY 00 00 00 00 00 00 00 00
X = Time to fade out in frames
Y = Place to warp to

For a list of locations available, refer to the Location ID List in notes page.

[02] Warp To Dungeon

The 02 command warps the player directly into a dungeon.

Format: 02 00 XX XX YY YY 00 00 00 00 00 00 00 00 00 00
X = Time to fade out in frames
Y = Dungeon ID

[03] Warp To Friend Area Map

The 03 command warps the player directly to the friend area map.

Format: 03 00 XX XX YY YY YY YY 00 00 00 00 00 00 00 00
X = Time to fade out in frames
Y = Unknown; Command only works if set to zero or one.

[04] Warp To Dungeon With Map Walking Animation

The 04 command is similar to the 02 command. It warps the player into a dungeon, but plays a map walking animation first.

Format: 04 00 XX XX YY YY 00 00 00 00 00 00 00 00 00 00
X = Time to fade out in frames
Y = Dungeon ID [00 - 2C]

[05] Dungeon Rules Entering Confirm

Hmmm...
To do:
Are there other accessible rules besides saving?

Displays dialogue that asks if it is OK to enter the dungeon with the following rules.

Format: 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

[1B] Trigger Cutscene/Plot Event

You can trigger many scenes in the game with this command.

Format: 1B 00 XX XX 00 00 00 00 00 00 00 00 00 00 00 00
X = Script ID [73 - FC] [101-10A] [14B - 155] 
Possibly Greater Range

[30] Close Textbox

Makes the textbox to disappear.

Format: 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

[32] Basic Textbox

Opens a textbox with a pokepic but without the name of the speaker, or scrolling text.

Format: 32 00 XX XX 00 00 00 00 00 00 00 00 YY YY YY YY
X = Pokepic/Speaker ID
Y = Pointer to text

[33] Basic Scrolling Textbox

Opens a textbox with a pokepic and scrolling text but without the name of the speaker or the text scrolling sound.

Format: 33 00 XX XX 00 00 00 00 00 00 00 00 YY YY YY YY
X = Pokepic/Speaker ID
Y = Pointer to text

[34] Textbox with speaker name

The most widely used text command. Opens a textbox with a pokepic, the name of the speaker, scrolling letters, and the scrolling sound.

Format: 32 00 XX XX 00 00 00 00 00 00 00 00 YY YY YY YY
X = Pokepic/Speaker ID
Y = Pointer to text

[35] Basic Textbox with Sound

Opens a textbox with a pokepic, scrolling letters, and the scrolling sound, but without the name of the speaker.

Format: 35 00 XX XX 00 00 00 00 00 00 00 00 YY YY YY YY
X = Pokepic/Speaker ID
Y = Pointer to text

[36] Quick Close Textbox

Similar to [33] - has pokepic, and scrolling letters, but no sound. Immediately closes after finishing scrolling.

Format: 32 00 XX XX 00 00 00 00 00 00 00 00 YY YY YY YY
X = Pokepic/Speaker ID
Y = Pointer to text

[37] Floaty text

Prints text out in the center of the screen. Generally to be used with a black background (in conjunction with [23] or [23 01]).

Format: 37 00 00 00 00 00 00 00 00 00 00 00 XX XX XX XX
X = Pointer to text

[39] Fading Floaty text

Prints text out in the center of the screen. Fades from black to white upon entrance and then back to black when done.

Format: 39 00 00 00 00 00 00 00 00 00 00 00 XX XX XX XX
X = Pointer to text

[3A] Yes/No Selection Box

Displays text box with Yes or No Selection Box above. Bound to an event.

Format: 32 00 XX XX YY YY 00 00 00 00 00 00 ZZ ZZ ZZ ZZ
X = Event ID
Y = Pokepic/Speaker ID
Z = Pointer to text

[3C] Special Dialogue

3C needs an extra argument in the second byte. It is responsible for some dialogue events.

3C 02 - Wait For A or B Button Press
3C 04 00 00 00 00 00 00 00 00 00 00 XX XX XX XX - Your Name input box. X = Default Name Pointer
3C 05 00 00 00 00 00 00 00 00 00 00 XX XX XX XX - Rescue Team Name input box. X = Default Name Pointer
3C 06 00 00 00 00 00 00 00 00 00 00 XX XX XX XX - Password Box  X = Default Pass Pointer
3C 07,08 - Friend Menu
3C 09 00 00 00 00 00 00 00 00 00 00 XX XX XX XX - Yes/No selection with huge textbox (dungeon rules format) X = pointer to text
3C 0A 00 00 00 00 00 00 00 00 00 00 XX XX XX XX - huge textbox (dungeon rules format) X = pointer to text
3C 0Bavailable for buying Friend Area List
3C 0C - available Dungeon List
3C 0D - Dojo List
3C 0E,0F - Saving
3C 10 - Kangaskhan Storage (with NPC dialogue)
3C 11 - Kangaskhan Storage Storage (menu only)
3C 13 - Felicity Bank
3C 16 - Who would you like to visit, friend menu.
3C 17 - Green Kecleon Shop
3C 18 - Purple Kecleon Shop
3C 19 - Gulpin Link Shop
3C 1A - Luminous Cave
3C 1B - Wigglytuff Friend Shop
3C 1C - Friend Rescue Counter
3C 1E - Thank You Mail Counter
3C 1F - Pelliper Post Office Help Counter
3C 20 - Bulletin Board Job List
3C 21 - Bulletin Board
3C 24 - Makuhita Dojo Enter Dialogue
3C 25 - Makuhita Dojo Success Dialogue
3C 26 - Makuhita Dojo Failure Dialogue
3C 27 - Makuhita Dojo Beat Every Dojo Dialogue
3C 28 - Personality Quiz
3C 2A - Scripting Menu Access
3C 2B 00 00 XX XX - Rescue Reward X = Item Given
3C 2C 00 00 XX XX - Promised Rescue Reward X = Item Given
3C 2D - Team ToolBox A
3C 2E XX XX 00 00 YY YY  - Display Staff Credits Names 00 <= XX <= 1A; YY = Time

[42] Stop music abruptly

Immediately cuts out music.

Format: 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

[43] Fade out music

Fades music out.

Format: 43 00 XX XX 00 00 00 00 00 00 00 00 00 00 00 00
X = time to fade (unit unknown).

[44] Abruptly play music

Stops former song and plays new song.

Format: 44 00 00 00 XX XX 00 00 00 00 00 00 00 00 00 00
X = song to play.

[45] Fade in music

Stops former song and fades new song in.

Format: 44 00 XX XX YY YY 00 00 00 00 00 00 00 00 00 00
X = time to fade (unit unknown).
Y = song to play.

[48] Fade out music

Seems to be a duplicate of command [43]

[4C] Play Sound Effect

Plays a sound effect

Format: 4C 00 00 00 XX XX 00 00 00 00 00 00 00 00 00 00
X = Effect to play. Range: [C8 - DB; 01 C7 - 02 06; 02 58 - 03 AB; Possibly more]

[54] Set Movement Animation

This command sets the animations to use when standing and/or when walking. This only works for cutscenese: when the script execution ends, this command effect also ends.

Values from 1600 will make the game to freeze.

Format: 54 00 XX XX 00 00 00 00 00 00 00 00 00 00 00 00

XXXX    Description
----   -------------
0000,0100 - overworld idle animation when standing
0200 - motionless when standing
0300 - motionless when standing, motionless walking
0400 - overworld idle animation when standing and when walking
0500 - walking animation when standing
0600 - sleeping when standing and walking
0700 - attacking pose when standing and walking
0800 - hurted pose when standing and walking
0900 - vibrating pose when standing and walking
0A00 - motionless when standing, motionless walking
0B00 - hurted pose when standing and walking
0C00 - does phisical attack animation 1
0D00 - does phisical attack animation 2
0E00 - does Tail Whip animation
0F00 - does a spin on the spot
1000 - does Double Team animation
1100 - does jump animation
1200 - does special attack animation
1300 - does a spin on the spot
1400 - does special attack animation endlessly
1500 - does a spin on the spot endlessly
FF00 - motionless when standing, walking and turning

[70] Change Sprite Z Position

This will change sprite height from the ground. Using speed value of 0, or from 80 to FF will freeze the game.

Format: 70 00 XX YY YY YY 00 00 00 00 00 00 00 00 00 00
X = moving speed
Y = target height

[86] Move Camera to Waypoint

Moves the camera to the specified waypoint.

Format: 86 00 XX XX YY YY 00 00 00 00 00 00 00 00 00 00
X = ??
Y = Waypoint #

[C0-CB] Compute various values and compare against Switch Conditions

All of these commands first load or compute a value to then compare them against a series of conditions specified by [CC], [CE] and [CF] commands. Only the values loaded by [C0]-[C5] are currently understood and documented.

[C0] Load Event Flag Variable

Format: C0 00 XX XX 00 00 00 00 00 00 00 00 00 00 00 00
X = Event Flag Variable ID
<\pre>

===[C1] Load Event Flag Variable and Do Calculation with Constant===
<pre>
Format: C1 II XX XX YY YY YY YY 00 00 00 00 00 00 00 00
X = Event Flag Variable ID
Y = Constant for use in calculation
I = kind of calculation

[C2] Load Event Flag Variable and Do Calculation with another Event Flag Variable

Format: C2 II XX XX YY YY 00 00 00 00 00 00 00 00 00 00
X = first Event Flag Variable ID
Y = second Event Flag Variable ID
I = kind of calculation

[C3] Choose random value

Note that the random function used for this is separate from the games main random function, and generates more predictable results.

Format: C3 00 XX XX 00 00 00 00 00 00 00 00 00 00 00 00
X = the random value will always be adjusted to be smaller than this value

[C4] Load first index of Event Flag Variable

[C4] and [C5] are likely meant for the series of two-byte SCENARIO_* Event Flag Variables.

Format: C4 00 XX XX 00 00 00 00 00 00 00 00 00 00 00 00
X = Event Flag Variable ID

[C5] Load second index of Event Flag Variable

See [C4].

Format: C5 00 XX XX 00 00 00 00 00 00 00 00 00 00 00 00
X = Event Flag Variable ID

[CC], [CD], [CE] Switch Conditions

These commands are normally ignored by the interpreter, but some instructions (most notably [C0]-[CB]) will switch the interpreter into a special mode that will process those instructions. They present a series of conditions that some pre-loaded value is compared to (in some ways reminiscent of the switch-case statements found in some programming languages). This special processing mode is exited when either one of the conditions is evaluated to true, or any non-[CC]/[CD]/[CE] instruction is encountered.

[CC] Test Equality Case

If the pre-loaded value is equal to the value in Y, jump to the label X

Format: CC 00 XX XX YY YY YY YY 00 00 00 00 00 00 00 00
X = Label #
Y = Value Constant

[CD] Custom Condition with Constant Case

Performs one out of a variety of tests, with the constant as the second parameter.

Format: CD II XX XX YY YY YY YY 00 00 00 00 00 00 00 00
X = Label #
Y = Value Constant
where II is one of:
00 - ALWAYS_TRUE
01 - ALWAYS_FALSE
02 - IS_EQUAL: will test whether the pre-loaded value is equal to the constant.
03 - IS_BIGGER: will test whether the pre-loaded value is bigger than the constant.
04 - IS_SMALLER: will test whether the pre-loaded value is smaller than the constant.
05 - IS_BIGGER_EQUAL: will test whether the pre-loaded value is bigger or equal than the constant.
06 - IS_SMALLER_EQUAL: will test whether the pre-loaded value is smaller or equal than the constant.
07 - NOT_EQUAL: it is a bit unclear what this operation is supposed to represent, but effectively it tests for non-equality.
08 - BITWISE_AND: this will test whether the bitwise and of the pre-loaded value and the constant is non-zero.
09 - BITWISE_XOR: this will test whether the bitwise xor of the pre-loaded value and the constant is non-zero. Note that this is effectively the same as 07.
0A - IS_BIT_SET: this will test whether a bit in the pre-loaded value is set; The bit is specified by the constant, with 0 = the least significant bit and 31 the most significant bit. The constant is truncated to 8 bit for this.

[CE] Custom Condition with Event Flag Variable

Very similar to [CD], but instead of a constant, the pre-loaded value is compared to the value of a Event Flag Variable.

Format: CD II XX XX YY YY 00 00 00 00 00 00 00 00 00 00
II = Test ID, see [CD]
X = Label #
Y = Event Flag Variable ID

[DB] Pause Script Execution

Indicates a pause to wait before executing the next command.

Format: DB 00 XX XX 00 00 00 00 00 00 00 00 00 00 00 00
X = Delay amount in frames

[E8] Execute Script

This command executes a script (see Function Script: Debug Names). A notable one is X = 7100, which brings up a list of cutscene script to execute.

Format: E8 00 XX XX 00 00 00 00 00 00 00 00 00 00 00 00

XXXX    Description
----   -------------
0000 - Closes the textbox.
0400 - Can cause unregistered dialogue script.
0900 - Text Box: invalidity checked underfoot   but there was nothing to be found.
0B00 - Text Box: Let's go.
0C00 - Talking to pokemon in friend area script.
0D00 - Flag Design change script.
0E00 - Walks randomly diagonally.
0F00 - Like 0E, but disregards laws of physics. Walks over backgrounds.
1100 - Walks in place
1200 - Walks in place and turns.
1300 - Walks in place.
1C00 - Player does non ending sleeping animation
1D00,1E00,1F00 - Makes you walk randomly in four basic directions.
2000 - Player does sleeping animation
2100 - Player does looking around animation
2200 - Player does backwards looking around animation
2300 - Player does backwards double looking around animation
2400 - Player does backwards double looking around animation
2500 - Player hops
2600 - Player hops with sweat
2700 - Player hops twice
2800 - Exclamation point over player
2900 - Question mark over player
2A00 - Sweat/Tear drop over player
2B00 - Shocked thing appears over player
2C00 - Shocked thing appears over player
3000 - Anger mark
3500 - Player does sleeping animation until stopped
3F00 - Save Menu (Does not save on its own)
4000 - Save Menu (Does not save on its own)
4100 - Save Menu Fades to black (Does not save on its own)
4200 - Brings up item storage menu (works)
4300 - Brings up Check Storage/Save menu that leads to 41 and 42 (item storage works, saving doesn't)
4500 - Fades to black, transports player to entrance of map, and fades back in.
4700,4800,4900 - Warps player upwards off of screen (In order of fastest to slowest)
4A00,4B00,4C00 - Warps player down onto screen (In order of fastest to slowest)
4D00,4E00,4F00 - Warps player up, but lets him maintain control.
5100,5200,5300 - Probably the opposite of 4D, 4E, 4F - Warps player back down.
5500,5600,5700,5800 - Plays item recieved sound effect
5900 - Plays other congratulatory sound effect.
5A00 - Fades screen to black, but lets player keep control.
5E00 - Like 5A, but stops music.
5F00 - Stops music
7100 - Cutscene script list selection (unused debug function).
6301, 6401 - Stops script execution and allows to control player. The camera is fixated.
6601 - Warp to friend area map selection.
9501 - Stops script execution and allows to move camera over the area. If Start or Select is pressed, the camera will point to the player sprite and both the sprite and the camera will be controlled by directional keys.
9601 - Stops script execution and allows to move the player sprite and camera over the map. If Start or Select is pressed, the camera will point to the map 0, 0 coordinate.

[E9] Function End, Stop Script Execution After Closing Textbox

This have the same effect as using [30] and then [EF]. Note that the textbox must be called by the function itself, otherwise it will make the game to freeze.

Format: E9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

[EE] Function End, Continue Script Execution

Format: EE 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

[EF] Function End, Stop Script Execution

Format: EF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00