Difference between revisions of "RULE (File Format)"

From Retro Modding Wiki
Jump to: navigation, search
(Created page with "{{todo|Description of the function of RULE files}} This file format was introduced in Metroid Prime 2 and has appeared in every Retro game since. The format is identical in P...")
(No difference)

Revision as of 22:49, 11 November 2016

GravitySuitIcon.png To do:
Description of the function of RULE files

This file format was introduced in Metroid Prime 2 and has appeared in every Retro game since. The format is identical in Prime 2/3/DKCR, other than the shorter asset ID length in Prime 2. In Tropical Freeze, the extension was changed to RSTC and the header was changed, but otherwise the format is the same.

Possible version numbers:

Version Game
1 Metroid Prime 2: Echoes, Metroid Prime 3: Corruption, Donkey Kong Country Returns
2 Donkey Kong Country: Tropical Freeze

Format

Type Count Name Notes
Header 1 Header
u16 1 Rule Count Count of rules in the file.
Rule Rule Count Rule Array Array of rules.

Header

Version 1

Header for RULE files in Metroid Prime 2, Metroid Prime 3, and Donkey Kong Country Returns:

Offset Type Count Name Notes
0x0 u32 1 Magic Always RULE
0x4 u8 1 Version Always 1
0x5 Asset ID (RULE) 1 Parent RULE Parent file which is checked after all conditions in this file have been checked. This allows overriding specific conditions.
End of RULE Header

Version 2

Header for RSTC files in Donkey Kong Country: Tropical Freeze:

Offset Type Count Name Notes
0x0 Form Descriptor 1 RSTC Form Descriptor Data type is RSTC
0x20 Chunk Descriptor 1 RULE Chunk Descriptor Data type is RULE
0x38 End of RSTC Header

Rule

Type Count Name Notes
u16 1 Condition Count Count of conditions in this rule
Condition Condition Count Condition Array Array of conditions
u16 1 Action Count Count of actions in this rule
Action Action Count Action Array Array of actions

Condition

Type Count Name Notes
char 4 Condition ID FourCC
u8 1 Comparison Operator Operator used to compare with Value.
u8 1 Value Type Type of Value.
Value Type 1 Value All types are 32 bits.

Action

Type Count Name Notes
char 4 Action ID FourCC
u8 1 Property Count
[Varies] Property Count Property Array Properties used by this action. All property types are 32 bits. The number and type of properties varies depending on the Action ID FourCC.

Comparison Operator Enum

ID Operator
0 Less than
1 Less than or equal to
2 Equal to
3 Greater than or equal to
4 Greater than

Value Type Enum

Rule values are always 32 bits. These are the possible types:

ID Type
0 bool
1 float
2 int32
3 Unknown; variable type? Used internally but may not actually be used in RULE files.