Map file

From RRU Knowledge Base
Revision as of 16:14, 20 December 2018 by Slimy Slug (talk | contribs) (Modified BLX reference here)

A map file is a file format is used in LEGO Rock Raiders to store the layouts of levels and designate various types of markers used for a variety of functions in-game. Multiple map files are stored in every level's folder. They use the filename extension .map.

Default map files in the Windows version are paired with BLX files in every level's folder. There is speculation as to whether they are an older version of the map format or whether they were something used by the original level editor.

Format specifications

Map files are encoded in hexadecimal code. All numerical values in map files are stored in a little-endian byte order (meaning the least significant byte is stored first - for example, the hexadecimal number 3E8 would be stored as E8 03 instead of 03 E8). Every block in a level is designated by a 16-bit integer (example: 13 00), which the game reads to generate blocks from the leftmost side to the rightmost side, and then back to the leftmost side of the next row down.

Every map file has a file header comprised of four 32-bit integers (known as words) . The first word in every map file is always 4D 41 50 20, which in ASCII spells out MAP followed by a space. The second word records the number of bytes contained in the rest of the file, not counting the first eight bytes contained in the first two words. For instance, a 24x48 map would have a size value of 9A 09 00 00, which means the rest of the file contains 2458 bytes (99A in hexadecimal), and the file's total size would be 2466 bytes. The third and fourth words list the X and Y dimensions of the map respectively, letting the game know how many integers to read before completing a row and moving to the next one below it.

Interestingly, each stored dimensions value is always one greater than the number of blocks actually present in the level in-game - so for instance, a 24x48 map would have a dimensions value of 19 00 00 00 31 00 00 00, as 19 is hexadecimal for 25, and 31 is hexadecimal for 49. This may indicate that either that the vertices are counted rather than the blocks, or that there is an extra row and column of blocks on every map that does not generate in-game[verify]. Either possibility may be due to how the Surface map applies height values to the top left corner of a block rather than its center.

Map types

Nine different map types are used in the Windows version of LEGO Rock Raiders. Though they all use the same encoding, which type they're marked as will determine how they are used in a level. Because of this, not every level uses all map types, and some are used rarely by default. Every level at minimum requires a Predug, Surface, and Terrain map to function without crashing the game.

Block Pointers map

The Block Pointers map, usually found as tuto.map, is the map file type that designates the locations of tutorial blocks.

Tutorial blocks are markers or flags that are used in a level in cooperation with its NPL file. Depending on the objective scripting, flags can be used for a wide variety of functions, such as checking whether blocks are exposed or have been crossed, moving the camera to a specific location at a certain time, or pointing to a wall or floor block that the player needs to interact with. In special cases, it also tells an emerging creature where to travel, and can trigger a scripting function if they stop at a certain flag.

Block Pointers map files can use any hexadecimal values between 01 00 and FF 00 in sequence[verify] to designate tutorial blocks. Values of 00 00 are taken as null.

CryOre map

The CryOre map, usually found as cror.map, is the map file type that designates the locations and amounts of energy crystals and ore in a level (hence the name Crystals and Ore). Note that this only applies to materials found in walls defined in the Terrain map; materials found lying around in open caverns are defined in the Object List file, and materials dug up out of rubble is defined in the PTL file.

CryOre map files use only the following hexadecimal values:

Value Function
00 00 None
01 00 or 03 00 One energy crystals
02 00 or 04 00 One ore
05 00 or 07 00 Three energy crystals
06 00 or 08 00 Three ore
09 00 or 0B 00 Five energy crystals
0A 00 or 0C 00 Five ore
0D 00 or 0F 00 Ten energy crystals
0E 00 or 10 00 Ten ore
11 00 or 13 00 Twenty-five energy crystals
12 00 or 14 00 Twenty-five ore

Values of 15 00 and higher will cause the game to crash when exposed. Odd values will cause the energy crystal notification message to play the instance the game freezes.

Emerge map

The Emerge map, usually found as emrg.map, is the map file type that designates the locations of trigger points and emerge points for emerging creatures. All the trigger points of an identical value are tied to all the emerge points of the value one above that of the trigger point. When a Rock Raider walks or drives over a trigger point, a monster will emerge from the emerge point tied to that trigger.

The emerge point must be on a wall defined in the Terrain map, can be any wall type except for solid rock, and can't be on a corner or have water or lava directly in front of it (even if the designated monster can cross water or lava). If all the walls located on an emerge points of the same number are mined, reinforced, or made into corners via collapsing walls next to them, the trigger point will cease to function. Conversely, a hidden wall that becomes exposed will cause a non-functioning trigger point to start functioning.

Like the Block Pointers map, every emerge block is given a different hexadecimal value in sequential order. Unlike the Block Pointers map, however, the values go up in increments of six instead of one, so that, for example, 02 00 and its trigger 01 00 are the first emerge in the map, but 08 00 and its trigger 07 00 will be the second, instead of 04 00 and 03 00.

Therefore, Emerge map files use the following hexadecimal values:

Value Function
00 00 No Emerging on this block
01 00 and higher in increments of 06 Trigger point on this block
02 00 and higher in increments of 06 Emerging point on this block

Erode map

The Erode map, usually found as erod.map, is the map file that designates the locations of eroding lava and erosion paths. Like the Fallin map, higher values represent more dangerous erosion.

Erode map files use only the following hexadecimal values:

Value Function
00 00 No erosion
01 00 Blocks that only erode on a space adjacent to lava, with 09 00 eroding the fastest and 01 00 eroding the slowest
03 00
05 00
07 00
09 00
02 00 Blocks that begin eroding at the start of the mission, regardless of whether they are next to lava or not, with 0A 00 eroding the fastest and 02 00 eroding the slowest
04 00
06 00
08 00
0A 00

Odd numbers 0B 00 and higher have no effect. Even numbers 0C 00 and higher cause the erosion to progress backwards into the unused first stage, which it remains at until repaired.

Fallin map

The Fallin map, usually found as fall.map, is the map file type that designates the locations of cave-ins. Like the Erode map, higher values represent more dangerous or unstable cave-ins.

Fallin map files use only the following hexadecimal values[verify]:

Value Function
00 00 No cave-ins
01 00, 02 00, 03 00, 04 00, 05 00, 06 00, 07 00, 08 00 Cave-ins, with 01 00 being least dangerous and 08 00 being most dangerous

Path map

The Path map, usually found as path.map, is the map file type that designates the locations of power paths and rubble. Path map items must be in conjunction with a Predug map value of 01 00, meaning that power paths and rubble placed in hidden caverns will not spawn.

Path map files use only the following hexadecimal values:

Value Function
00 00 No power paths or rubble
01 00 Rubble
02 00 Power path

Predug map

The Predug map, usually found as dugg.map, is the map file type that designates whether blocks are walls or cavern terrain, whether a cavern is exposed or hidden, and the locations of slimy slug holes.

Predug map files use only the following hexadecimal values:

Value Function
00 00 Wall
01 00 Exposed cavern
02 00 Hidden cavern
03 00 Slimy slug hole
04 00 Hidden slimy slug hole

Surface map

The Surface map, usually found as high.map (and therefore often called the height map), is the map file type that designates the height of the terrain at each block in a level. Like the Erode map, higher values cause higher increments - in this case, the height of the northwest corner of a specific block. The exact difference between incremental height values is determined by each level's RoughLevel code, which by default is 6 in all levels. As the depth from the ground to the ceiling is a total of 80 in the unmodified game, 13 height units will nearly reach the ceiling[verify].

Surface map files can use any values between 00 00 and FF 00, with the former being the lowest possible terrain and the latter being the highest possible. Most custom map tools only allow heights between 00 00and 2F 00, though manual hex editing allows for far greater values to be set. Such extreme height differences may cause mobile units and the game camera to move unusually. If the height difference is very sudden, sharp hills may disappear and be seen as fog holes in the ground and ceiling in eye and shoulder view, and moving the camera across such hills in top view can cause parts of low ground to disappear as they end up out of draw distance.

Terrain map

The Terrain map, usually found as surf.map (not to be confused with the above Surface map), is the map file type that designates the locations of various walls, as well as ground, water, and lava. The PlayStation version of the game also uses Terrain maps, found as terrain.map.

Terrain map files in the Windows version use only the following hexadecimal values:

Value Function
00 00 Null
01 00 Solid rock
02 00 Hard rock
03 00 Loose rock
04 00 Dirt
05 00 Dirt, was most likely planned to be the unused soil
06 00 Lava
07 00 An unused form of water that displays as a blue sheet floating at the top of the wall. Empty tiles next to it will cause it to sink down to the ground, though it seems to behave differently in eye and shoulder view. It was possibly meant for some sort of flooding mechanic, but was never finished.
08 00 Ore seam
09 00 Water
0A 00 Energy crystal seam
0B 00 Recharge seam

Note that none of the values actually correspond to ground, as a Predug map value of 01 00 (exposed) or 02 00 (hidden) is what actually determines caverns, while any Terrain map value except for 06 00, 07 00[verify], and 09 00 will default to ground when marked as such. Most default maps use dirt 04 00 everywhere that ground is designated; however, custom map tools tend to mark 00 00 where ground is designated.

The following values are not used in map files and do not present correctly in levels (showing as ground stretching up to the ceiling and acting like a wall that can't be drilled but can cause landslides and emerges), but are used on the radar in map view:

Value Function
0C 00 Rubble
0D 00 Reinforced wall
0E 00 Power path
0F 00 Slimy slug hole
10 00 Undiscovered cavern
11 00 Cavern floor

Values of 12 00 and higher will crash the game when moused over.

Terrain map files in the PlayStation version use only the following hexadecimal values:

Value Function
01 00 Ground
02 00 Dirt (loose rock in North American version)
03 00 Loose rock (medium rock in North American version)
04 00 Hard rock
05 00 Solid rock
06 00 Lava
07 00 Water

AI map

The AI map is an unused map type. Specifications are currently unknown.

Modding

To do: Write about various level editors and make articles for them when the forums are back up

All of these can either be opened using a hex-editing program or more preferably using the LRR Map Creator or the Map Tool.