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 when a file repeats
it, whether a map can do without it, 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. The facts in the table at the top of each page (size, repeats, required, read by) and the value and flag tables come from the code the editor reads and writes maps with. The byte layouts are checked by its tests against the same code, which re-encodes Blizzard's own maps byte for byte. The community's older reference is wiki.staredit.net/wiki/Scenario.chk, which this one agrees with except where a page says otherwise.
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 repeated sections and
odd lengths to the program using it.
- The containerA scenario is a flat run of sections, with no header of its own.
- Protected mapsStarcraft itself reads maps different than how editors do, which allows one to 'protect' a map by modifying it in a special way.
- SectionsThe sections are listed here in the order StarEdit writes them.
- 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.
- TECxTECS for Brood War: the same tables, for 44 abilities.
- CRGBStarCraft: Remastered's player colours.
- In the source