Scriptable Layers (Metroid Prime)
This article is for the scriptable layers format from Metroid Prime. See Scriptable Layers (File Format) for other revisions of this format.
Scriptable layers are a data section found in the MREA format, denoted by the fourCC identifier SCLY
. It contains script object instances which are used to set the object layout of each room. Rooms can contain multiple layers, with each being able to be toggled on and off independently, allowing for the layout of a room to be updated after significant ingame events, which is done using a SpecialFunction object. Each instance has a large number of parameters that can be toggled to customize the appearance and behavior of that instance, and they're capable of sending messages to other objects, allowing for fairly complex interactions between objects to be scripted.
Format
Header
Offset | Type | Size | Description |
---|---|---|---|
0x0 | char[4] | 4 | Magic; always SCLY
|
0x4 | long | 4 | Unknown |
0x8 | long | 4 | Layer count (LC) |
0xC | long[LC] | 4 × LC | Layer sizes array (sizes are always a multiple of 32) |
Script Layers
The size of each layer is always a multiple of 32; the end of the layer is 0-padded. Note that the layers don't actually start on a multiple of 32, so they're not 32-byte-aligned within the file; they're just aligned relative to the start of the layer data.
An important note is that every layer also has a name and a default "active" flag that determines whether or not the layer is enabled on a new file, but this data is stored in a completely different resource, in the MLVL format.
Offset | Type | Size | Description |
---|---|---|---|
0x0 | char | 1 | Unknown |
0x1 | long | 4 | Object count |
Script Object Instances
Object instances share a common header, followed by a big binary blob of property data that varies depending on the object type.
Type | Size | Description |
---|---|---|
char | 1 | Object type |
long | 4 | Instance size (relative to after size value) |
long | 4 | Instance ID |
long | 4 | Connection count (CC) |
Connections[CC] | 0xC × CC | Connections |
long | 4 | Property count |
char[] | - | Property data |
Connections
The connections part allows for inter-object scripting to be set up. Objects can enter a wide variety of different states, and they can be scripted to send messages to other objects when these states are activated. The actual struct for each connection simply sets a state, a message type, and a target object.
Offset | Type | Description |
---|---|---|
0x0 | long | State |
0x4 | long | Message |
0x8 | long | Target Object ID |
See also
- For a list of all script objects and their parameters, or a list of state/message types, see: List of Script Objects (Metroid Prime)