CHK format reference
Every section of a scenario file: its byte layout, what a repeat does, whether the game needs it, the values its fields take.
This reference gives the byte layout of every section of a StarCraft and Brood War
scenario file (scenario.chk), with what each section is for, what the game does with it
when it loads a map, and the values its fields take.
This page describes the format, not any one editor. What scmJS does with a file as a whole (the archive around the scenario, protected maps, what Save keeps and what it can strip) is in Opening and saving maps.
Sources. The byte layouts and the value tables are generated from the code the editor reads and writes maps with, which re-encodes Blizzard's own maps byte for byte. What the game does with a section (whether it reads it, needs it, which lengths it accepts, what a second copy does) describes StarCraft: Brood War 1.16.1, confirmed by loading test maps in the game. StarCraft: Remastered's loader has been studied too, and reads maps much the same way; the differences are listed under Where Remastered differs. Where this page and the community's older reference, wiki.staredit.net/wiki/Scenario.chk, disagree about the game, this page is the one checked against it.
The same layouts are also published as a Kaitai Struct description,
chk.ksy, generated from the same tables as this page. The Kaitai compiler turns
it into a parser for C++, C#, Go, Java, JavaScript, Python and several other languages,
and the Kaitai Web IDE opens a scenario.chk with it and shows
every section field by field. It reads a file as it is laid out, one section after
another, and leaves the rules for lengths and repeated
sections to the program using it.
- The containerA scenario is a flat run of sections, with no header of its own.
- How the game loads a mapStarCraft reads a map up to three times, and each time it reads only the sections it needs then: a short read for the map list, a longer one when a game starts, and one more for the brief…
- Protected mapsStarCraft reads a map differently from how a simple editor does, and a map can be "protected" by building it so that the game reads it correctly while an editor misreads it or gives up.
- SectionsThe sections are listed here in the order StarEdit writes them, and each has a page below in the same order.
- RevisionsThe VER value is the file's revision, and it decides which sections the game reads.
- How the sections fit togetherMost sections stand alone, but many numbers in them point into another section, and a few sections decide the size or the meaning of others.
- TYPEWhich game the file is for.
- VERThe file's revision, which decides which sections the game reads.
- IVERA version stamp older versions of StarEdit wrote.
- IVE2StarEdit's version stamp.
- VCODA verification table the game checks the file against when it loads a map, and refuses the map when the check fails.
- IOWNStarEdit's own copy of OWNR.
- OWNRWho controls each of the 12 player slots: a human, a computer, a rescuable player, a neutral one, or nobody.
- ERAThe tileset.
- DIMThe map's size in tiles.
- SIDEEach player's race.
- MTXMThe terrain the game draws: one 16-bit tile number per tile, including the tiles of placed doodads.
- PUNIWhich unit types each player may build.
- UPGRHow far each player may research each upgrade, and the level they start at, for the 46 upgrades of the original game.
- PTECWhether each player may research each ability, and whether they start with it, for the 24 abilities of the original game.
- UNITThe units placed on the map, 36 bytes each.
- ISOMThe isometric record, which an editor's isometric brush paints with: the lattice of terrain diamonds from which it works out the cliffs and edges between terrain types.
- TILEThe terrain with the doodads left out: what is under each doodad.
- DD2The doodads placed on the map, as objects an editor can select and remove.
- THG2Sprites placed on the map.
- MASKFog of war at the start: which players begin with each tile unexplored.
- STRThe string table.
- STRxThe string table of StarCraft: Remastered: the same as STR with 32-bit numbers, so the table has no 64 KB limit.
- UPRPThe 64 unit properties slots used by the Create Unit with Properties action.
- UPUSWhich of the 64 UPRP slots StarEdit considers in use.
- MRGNThe locations.
- TRIGThe triggers, 2400 bytes each, in the order they run.
- MBRFThe mission briefings, in the same 2400-byte record as a trigger, with their own set of actions.
- SPRPThe scenario's name and description, as string numbers.
- FORCThe four forces: which force each of Players 1 to 8 is in, each force's name, and its settings.
- WAVStarEdit's list of the sounds in the map: the name of each sound file in the archive, as a string number.
- UNISUnit settings for the original game.
- UPGSUpgrade costs and research times for the 46 upgrades of the original game.
- TECSAbility costs, research times and energy costs for the 24 abilities of the original game.
- SWNMThe names of the 256 switches, as string numbers.
- COLRThe colour of each of Players 1 to 8.
- PUPxUPGR for Brood War: the same tables, for 61 upgrades.
- PTExPTEC for Brood War: the same tables, for 44 abilities.
- UNIxUNIS for Brood War: the same tables, with 130 weapons.
- UPGxUPGS for Brood War: the same tables for 61 upgrades, with one unused byte after the first column.
- TECxTECS for Brood War: the same tables, for 44 abilities.
- CRGBStarCraft: Remastered's player colours.
- The isometric record explainedThis part explains the ISOM record: how its words describe a lattice of terrain diamonds, what the values mean, and how an editor's isometric brush turns the lattice into tiles.
- In the source