Gods Level Data Format

From ModdingWiki
Jump to navigation Jump to search

Each level in Gods has a PALFILS.0xn file, where x is the sublevel (A or B) and n the world (1-4), e.g. PALFILS.0B3 for level 3B. Despite the name, these files contain no palette. The logical name the game uses is alfils; the leading P only marks the file as packed with PKWARE DCL Compression.

The file holds most of the level logic that is not in the map itself: the event list that map cells point to, enemy spawners, levers, teleport destinations, trap doors, barriers and the hint texts shown by tablets.

Every decompressed file is exactly 8760 bytes. All values are big-endian.

The files also contain an unused developer banner, Cripal Source Code / Level One of Gods, inside a row of asterisks.

File format

The file is a set of fixed-size tables, one after another. The sizes are hard-coded in the game.

Offset Size Count × size Contents
0x0000 800 100 × 8 Path enemy spawners (see Gods Path Format)
0x0320 4 – Unknown
0x0324 1012 253 × 4 Events
0x0718 1600 100 × 16 Enemy spawners
0x0D58 1100 50 × 22 Enemy group descriptors (type A)
0x11A4 1100 50 × 22 Enemy group descriptors (type B)
0x15F0 384 64 × 6 Levers
0x1770 180 30 × 6 Teleport destinations
0x1824 120 20 × 6 Trap doors
0x189C 700 25 × 28 Barriers
0x1B58 80 40 × 2 Hint keys
0x1BA8 1600 40 × 40 Hint texts
0x21E8 80 – Unused, always zero

Events

When the player touches a map cell whose plane B value v is 3 or more, event number v - 3 is run. Each event is:

Data type Name Description
UINT16BE type What the event does, see below. 0 = empty.
UINT16BE param Argument, usually an index into another table

An event runs once and is then used up. All events are re-armed when the level or sublevel is entered, but not when the player dies.

Type Param Effect
0 – Nothing (empty slot)
1 Spawner (0-99) Start a path enemy group from the table at 0x0000
2 Spawner (0-99) Start an enemy spawner from the table at 0x0718
3 Trigger (0-99) Evaluate a trigger from the map file
4 Group (0-49) Activate a type B enemy group
5 Group (0-49) Activate a type A enemy group
6 – Progress / checkpoint marker
7-10 Barrier (0-24) Activate a barrier from the table at 0x189C
11 – Start a world-specific scripted sequence

Path enemy spawners

Data type Name Description
UINT8 count Number of enemies in the group
UINT8 path Path number in the world's PAT file
UINT16BE stagger Delay between each enemy starting
UINT8 key Unknown purpose, copied to each enemy
UINT8 class Enemy class (sprite and behaviour)
UINT8 fire Two 4-bit shooting parameters (facing mode and fire rate)
UINT8 unknown

Levers

Data type Name Description
UINT16BE x Position in pixels. Negative = unused.
UINT16BE y Position in pixels
UINT16BE state Bit 0: 1 = on

Triggers can test a lever's state with condition types 11 and 12 (see Gods Map Format#Conditions).

Teleport destinations

Data type Name Description
UINT16BE key x position of the teleport stone object that uses this entry
UINT16BE x Destination
UINT16BE y Destination

Trap doors

Data type Name Description
UINT16BE x Position in pixels. Negative = unused.
UINT16BE y Position in pixels
UINT16BE open Initial state

When the level loads, the game writes each trap door's tiles into both map planes. Trigger actions 7 and 8 open and close them.

Hints

The hint table links tablets (map object type 69) to text. When the player reads a tablet, the game searches the 40 keys for the tablet's x position, and shows the matching text. A negative key marks an unused slot.

The texts are 40 NUL-terminated strings of up to 40 bytes each, for example find the gold key to exit this world or repair the mosaic to please the gods.

Source code

From re-gods, the open-source HTML5 port:

Credits

This file format was reverse engineered by VorticonCmdr. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)