scmJS docs

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.