Monochrome map (.bit, .lev)
From Worms Knowledge Base
Monochrome map files (*.lev and *.bit) represent a particular type of terrain playable as a battlefield in Worms Armageddon. Until Deadcode added colour .PNG maps support to the game in 2004, the only other type of map in the game was the IMG file, manifested in a finite library of graphics the Team17 artists had drawn. Although it would be wrong to say that the Monochrome format was the only one possible in network play (to this day, some IMG terrains such as GunBox appear on a pulldown bar as options), it has always been by far the most widely used.
Monochrome maps break down into two types, commonly referred to by their respective extensions: LEV maps (*.lev), and BIT maps (*.bit). For the purposes of this entry they will be referred to as such. The formats have a large amount in common; they both represent an area of 1920x696 pixels in monochrome (black and white), with white representing terrain and black equating to empty space. The only difference between the formats is how this bitmap is represented: a LEV map contains a seed (sort of like a unique ID number) that Worms' terrain generator uses to draw the land. Because of how the generator creates terrain, any randomly generated landscape can be represented by a 4 byte long number, and can be redrawn exactly the same using only that number. A BIT map does not store such a seed; since the image is custom drawn, the actual black and white image is saved in the file. The rest of the data in a monochrome map is information such as what type the terrain should be, how many objects and bridges should occur, where they should be placed, how high the water should be... almost equivalent to the settings available in the W:A ingame map editor. This data ends up taking up 40 bytes of space. A LEV map is always 40 bytes in size. Since a BIT map is nothing more than a LEV map with an image appended to it, it can range in size from under 100 bytes to over 100 KB, depending on the complexity of the image.
File Format Specifications
The LEV file contains 40 bytes, while a BIT file contains these same 40 bytes as a header, followed by a 1-bit monochrome image compressed in the LEADTools proprietary CMP format. Currently the specifications for the CMP format are copyrighted and secret, and the only practical method to encode or decode a CMP image is by using LEAD's own imaging libraries - the very ones that come with Worms (or possibly a newer version, but that would require purchasing a software license). This is how current 3rd-party software operates. The specifications for generating terrain from a seed are currently known only by Team17, which is why no external viewers of LEV maps exist today.
It should be noted that these 40 bytes are common to all Worms Armageddon maps, even colour ones. When W:A saves a PNG image, it adds a chunk called "w2lv" or "waLV" which contains these 40 (or 41) bytes of data. Many of the values are irrelevant in a colour map (and some are, to a degree, in a BIT map), but they occur anyway to preserve this structure's format. This list of the values occurring in the header is by offset, in hexadecimal.
- 0x00 - Land Seed - The seed Worms uses to draw the terrain, in a LEV file. This value has no effect in a BIT or PNG file because actual image data is loaded instead. However, if a LEV map is edited and saved as a BIT or PNG, this value (along with 0x0C - Style) can tell you how to generate the original LEV.
- 0x04 - Object Seed - The seed Worms uses to determine where to position objects and bridges on the landscape, should they be drawn. In a PNG file, or a BIT or LEV file where "Objects on Terrain" and "Bridges" are both set to zero, the value of this field still has an effect; it determines where Worms, Mines, Oil Drums and girder holes will be automatically placed.
- 0x08 - Cavern - Whether Worms treats the map like a cavern, with a ceiling, or an island. A value of 0 means island, while a nonzero value means a cavern.
- 0x0C - Style - This parameter is related to the Land Seed and refers to one of the 8 types of maps (such as single island, double island, single cavern, double tunnel cavern). The same Land Seed can generate 8 different terrains, based on this parameter.
- 0x10 - No Indestructible Borders - A setting of 0 puts an indestructible border on all sides of the map and forces it to behave like a cavern. A nonzero setting is equivalent to "off".
- 0x14 - Object Percentage - A value from 0 to 100 decimal determining whether objects will occur on the terrain. The objects are different for each soil type, and their placement depends upon the Object Seed. The in-game editor allows modification of this value by selecting an image from "1" to "10". These images correspond to the values (and thus percentages) 0, 11, 22, 33, 44, 55, 66, 77, 88, and 100. Worms is capable of loading, interpreting, and saving other percentages, but these are the only ones offered by the internal editor.
- 0x18 - Bridge Percentage - A value from 0 to 100, exactly like the Object Percentage, which determines how likely bridges are to occur on the terrain. The same rules apply. It should be noted that in W:A v3.0 and prior (and in the current versions of WWP) there was a bug that caused this value to be saved and loaded improperly as though it were set to zero. This error was carried over into the BITmonkey map viewer. W:A v3.5 has corrected this bug.
- 0x1C - Water Level - A value from 0 to 99 representing how many pixels above the bottom of the map the water level begins at. Values above 99 will be converted to 99 by the game upon load. It is worth noting that the water can be set to 100 pixels in-game, and even saved with the value 100; however, it converts to 99 upon load.
- 0x20 - Soil Texture Index - A value from 0 to 28, corresponding to the different types of soil selectable (Beach, Art, Cheese, Construction, etc). The Tools terrain fell out of the game in v3.0, replaced with Tribal, meaning that values of both 26 and 27 corresponded to Tribal, and 28 to Urban. In v3.5, Deadcode removed the duplicate Tribal, making Urban=27. In v220.127.116.11, Deadcode added the Tools terrain back into the game (matching WWP's list of terrain indexes) and split this DWORD value into two 2-byte WORDs. 0x20 contains the Soil Texture Index, and 0x22 contains a signed Version. A Version of 0 indicates compatibility with v3.5. A Version of 1 tells the game that Tools=26, Tribal=27 and Urban=28. A Version of -1 emulates v3.0's more severe floor and ceiling trimming and two identical Tribal terrains. The Version is not used for any other terrain at this time, and the setting is for compatibility purposes.
- 0x24 - Water Colour - An artifact from the original v1.0 of W:A, this value allows selection of one of the several water colours. 0 is equivalent to Blue, and no other values will have effects at this time.
W:A 18.104.22.168 adds an extra byte (which was extended to a 16-bit word in W:A 22.214.171.124) to this structure, which is only used for colour (PNG) maps:
- 0x28 - Worm Places - the number of worm places (aka "placement holes") for this map, where Worms, Mines, Oil Drums and girder holes will be automatically placed.
In order to operate on such files, 3rd-party software must access the Lead Tools redistributable run-time libraries, shipped with Worms Armageddon and Worms World Party.
It is possible to convert a .bit or .lev map to a textured .png map as follows:
- Load the map in the map editor
- Left-click, then right-click the Preview button (labeled as #4 in the Map Editor Guide)
- Click Save to save the map to a .png file
You can convert a .bit map to a monochrome .png (for editing) by right-clicking the the Preview button in the map editor. To convert a monochrome .png back into a .bit map, left-click the Preview button (you will be prompted to discard colour information).