Free Hero Mesh

Update of "Level file format"
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview

Artifact ID: 63a2f9a87dc968b27c64b94700942fd538b9fa6a
Page Name:Level file format
Date: 2020-11-23 23:19:04
Original User: anonymous
Parent: e9a31b534623d99be3c26d9029d6ce8b928af299 (diff)
Content

This document describes the file format for level files. The .level file is a Hamster archive, containing lumps CLASS.DEF, *.LVL, and LEVEL.IDX. All numbers (except the lump sizes) are small-endian.

CLASS.DEF

This lump consists of two parts, which are the list of classes and list of user messages; two zero bytes come after the list of classes before the list of user messages.

Each part consists of zero or more records concatenated together. Each record consists of a 16-bit number and then a null-terminated string.

The class section has class numbers (minimum 1) and class names (without the $ prefix). The user message section has user message numbers (minimum 256) and user message names (without the # prefix).

This data is used to determine what class/message the level data refers to, since reordering them in the class definition file may cause them to be internally renumbered, so in this way, first the CLASS.DEF lump is read in order to define the numbers before reading the class definition file, so only the class names that aren't mentioned in the level file will be auto-numbered, and then recorded in the CLASS.DEF lump once an object of that class is added to a level using the level editor.

*.LVL

The lump name starts with the zero-based ID number (instead of an asterisk), which must be from 0 to 65535.

The header of this lump consists of:

After that comes the objects. They should be in order starting at (1,1) and going right, going to the next line after that; within each cell, they go bottom (most density) to top (least density). Each object record consists of:

Normal flag byte:

MRU flag byte:

Either way, bit6 and bit5 should not both be set together. Also, if bit4 is not set for the first object, the Y coordinate is 1, and if bit5 is not set for the first object, the X coordinate is 0 (which is not a valid coordinate, unless bit6 is also set).

The MRU has two layers, one for when some of bit6-bit4 of the flag byte are set, and one for when none of those bits are set.

The data type byte consists of:

After the data type byte will be the misc data; any misc data not defined implicitly has a value of zero. The data is represented as a 16-bit number, in order Misc1, Misc2, Misc3, whichever are present (as specified above).

(Note: In EKS Hero Mesh the data type is used only in the editor. In Free Hero Mesh, data is strongly typed and so the data type is used at run time too.)

After the objects is a byte with value 0xFF to indicate there are no more objects, and then the level strings (if any). The level strings are simply null-terminated strings (which can include formatting controls).

LEVEL.IDX

This lump contains a series of 16-bit numbers, which are the ID numbers of the levels, in the display order.