CHK Format

Original article at Staredit Network Wiki


The CHK file is a very dense file found inside the SCM or SCX file (as "staredit\scenario.chk"), which is just a renamed MPQ archive.

In this article, some shorthand will be used for datatypes:

Contents

Sections

The CHK is split into several named chunks (hence the file extension, an abbreviation of CHunK).

Each section begins with an 8-byte header:

Followed by as many bytes as 'Size', in a format described below.

Some things to keep in mind about the CHK section:


"TYPE" - Map Type

Not required.

This section specifies the type of scenario.


"VER " - Format Version

Required for all versions and all game types.
Validation: Must be size of 2 bytes.

This section identifies the file format version.

This is the only version code section to actually be read by StarCraft (of TYPE, VER , IVER, and IVE2). Any other value is invalid in retail StarCraft and is usually a beta version.

Other unsupported versions include:

"IVER" - Map Version

Not required.

This section "additionally identifies" the map version.

Contrary to popular belief, it doesn't get "replaced" by IVE2 in hybrid/Brood War scenarios: both seem to be written by StarEdit but not read by StarCraft.


"IVE2" - Map Version

Not required.

This section "additionally identifies" the map version.

This section does not "replace" IVER in hybrid/Brood War scenarios: both seem to be written by StarEdit but not read by StarCraft.


"VCOD" - Verification Code

Required for all versions and all game types.
Validation: Must be equal to size of the VCOD data in the EXE resource. Must result in valid checksum.

This section has a verification code to make sure this is actually a CHK file.

Opcodes and seeds do not have to match those in EXE resource, as long as the same value is produced.
The only indexes in the seed table that are referenced are those that correspond individual values of OWNR, SIDE, FORC player assignments, and index 0.


"IOWN" - StarEdit Player Types

Not Required.

This section specifies the owner of each player.

This section is separate from OWNR as a staredit value. Staredit does not display "inactive" as a valid option. Italicized settings denote invalid map options, which may involve a buffer overflow.


"OWNR" - StarCraft Player Types

Required for all versions and all game types.
Validation: Must be size of 12 bytes.

This section designates the controller of a particular player. It is exactly the same as the "IOWN" section, except there is an additional value, 0x00 for Inactive.

Italicized settings denote invalid map options, which may involve a buffer overflow.


"ERA " - Tileset

Required for all versions and all game types.
Validation: Must be size of 2 bytes.

This section indicates the tileset of the scenario.

StarCraft masks the tileset indicator's bit value, so bits after the third place (anything after the value "7") are removed. Thus, 9 (1001 in binary) is interpreted as 1 (0001), 10 (1010) as 2 (0010), etc.
Desert, Arctic, and Twilight are Brood War-only tilesets.


"DIM " - Map Dimensions

Required for all versions and all game types.
Validation: Must be size of 4 bytes.

This section contains the dimensions of the map.

The Width/Height of the map is measured in the number of square 32x32p tiles.
Standard Dimensions are 64, 96, 128, 192, and 256.


"SIDE" - Player Races

Required for all versions and all game types.
Validation: Must be size of 12 bytes.

This section contains the species/race of each player.

Italicized settings denote invalid map options. Note Players 9-11 are defaultly Inactive and Player 12 is defaultly Neutral.


"MTXM" - StarCraft Terrain

Required for all versions and all game types.
Validation: Must be less than or equal to 131072 (0x20000) bytes (256 * 256 * 2).

Terrain section that contains a map of the level's appearance. StarEdit disregards this section and instead uses TILE; it is only used in Starcraft.

Notes about MTXM:


"PUNI" - Player Unit Restrictions

Required for all versions. Not required for Melee.
Validation: Must be size of 5700 bytes.

This section contains player unit restrictions: it indicates whether the player can or cannot build a particular unit.


"UPGR" - Upgrade Restrictions

Required for Vanilla and Hybrid (in Original mode). Not required for Melee.
Validation: Must be size of 1748 bytes.
In Brood War scenarios, this section is replaced by "UPGx".

This section contains player upgrade restrictions: it indicates the starting/maximum levels at/to which a player can perform a particular upgrade.

See #List of Upgrade IDs.


"PTEC" - Tech Restrictions

Required for Vanilla and Hybrid (in Original mode). Not required for Melee.
Validation: Must be size of 912 bytes.
In Brood War scenarios, this section is replaced by "PTEx".

This section contains player technology availability restrictions: it indicates whether a player starts off with a particular technology or can research a particular technology.

See #List of Technology IDs.


"UNIT" - Placed Units

Required for all versions and all game types.
Validation: Must be a multiple of 36 bytes.

This section contains all the pre-placed units on the map and their properties. Each unit on the map gets the following structure:

Notes about UNIT:


"ISOM" - Isometric Terrain

Not Required.

This section is required to place isometric terrain on the map. It provides data about the nature of the isometrical "diamonds" (the editing mode of StarEdit).

This section is the only truly unknown section of the .chk format.


"TILE" - StarEdit Terrain

Not Required.

This section will only be different from the MTXM section in tiles where doodads are present.

The values in TILE are normally directly generated from the ISOM section (see "'ISOM' section" above), and thus do not match that of MTXM on doodad tiles.


"DD2 " - StarEdit Sprites (Doodads)

Not Required.

This section contains the doodad map of the level. There are several parts to doodads. The graphical portion is stored in the MTXM section. The second part of the doodad is stored in this section. This section is only used by the map editor.

Each doodad in the map gets the following structure:


"THG2" - StarCraft Sprites

Required for all versions and all game types.
Validation: Must be a multiple of 10 bytes.

The map editor only writes to this section. StarCraft uses this section.

Sprites, usually on doodads, get the following structure.

This section can be split. Additional THG2 sections will add more sprites.


"MASK" - Fog of War Layer

Required for all versions. Not required for Melee.
Validation: This section will always validate.

This section contains the data on fog of war for each player. This is whether at the start of the game that levels of black space that is available.

Any size greater than width*height will be ignored. Any size less will default missing tiles to 0xFF


"STR " - String Data

Required for all versions and all game types.
Validation: Must be at least 1 byte.

This section contains all the strings in the map.

This section can contain more or less then 1024 string offsests and will work in Starcraft.
Note that STR sections can be stacked in a smiliar fashion as MTXM. The exact mechanisms of this are uncertain.


"UPRP" - CUWP Slots

Required for all versions. Not required for Melee.
Validation: Must be size of 1280 bytes.

This section is used whenever the create units with properties trigger is used. Since a slot has to be assigned to the action, this is where each slot is designated.

There are 64 of the following structures regardless of how many are used and it cannot exceed 64.


"UPUS" - CUWP Slots Used

Not Required.

This section goes along with the "UPRP" section. This section just indicates which of the 64 unit properties slot are used.


"MRGN" - Locations

Required for all versions. Not required for Melee.
Validation: 1280 bytes for retail, 5100 bytes for Hybrid and Brood War.

This section contains all the locations that the map uses. In a vanilla map, this section contains 64 locations. In a Hybrid or Brood War map, this section will expand to contain 255 locations.

Each location gets one of the following location entries. The 'Anywhere' location, is ALWAYS location 64.

Note that in typical locations Right is always larger than Left and Bottom is always larger than Top. However, you can reverse one or both of these for Inverted Locations.


"TRIG" - Triggers

Required for all versions. Not required for Melee.
Validation: Must be a multiple of 2400 bytes.

This section contains all the triggers in the map. This along with MBRF is the most complicated section in the entire scenario.chk file. There is too much data packed into too little of a space. Refer to the appendix at the bottom of this page for more information. For easy reference, since each trigger contains 2400 bytes, the amount of triggers can be gotten by taking the section length and dividing by 2400. Every single trigger in the map will have the following format:

This section can be split. Additional TRIG sections will add more triggers.


"MBRF" - Mission Briefings

Required for all versions. Not required for Melee.
Validation: Must be a multiple of 2400 bytes.

This section contains all of the mission briefings shown by the players.

See "TRIG" section for format, as it is exactly the same except for the conditions. In this section the 16 conditions are still there, they are all null except for the very first condition, which only has a condition byte of 13. See #Mission Briefing Actions List for the action bytes for the mission briefing actions.

This section can be split. Additional MBRF sections will add more briefing triggers.


"SPRP" - Scenario Properties

Required for all versions and all game types.
Validation: Must be size of 4 bytes.

A string index of 0 for the map name will default it to its file name. A string index of 0 description will default to a predefined string.


"FORC" - Force Settings

Required for all versions and all game types.
Validation: Must be less than or equal to 20 bytes.

This section specifies the forces and the information about them.

Notes about FORC:


"WAV " - WAV String Indexes

Not Required.

There are 512 wav entires regardless of how many are actually used.


"UNIS" - Unit Settings

Required for Vanilla and Hybrid (in Original mode). Not required for Melee.
Validation: Must be size of 4048 bytes.
In Brood War scenarios, this section is replaced by "UNIx".

This section contains the unit settings for the level:


"UPGS" - Upgrade Settings

Required for Vanilla and Hybrid (in Original mode). Not required for Melee.
Validation: Must be size of 598 bytes.
In Brood War scenarios, this section is replaced by "UPGx".

This section contains upgrade settings:

See #List of Upgrade IDs for upgrade ids.


"TECS" - Tech Settings

Required for Vanilla and Hybrid (in Original mode). Not required for Melee.
Validation: Must be size of 216 bytes.
In Brood War scenarios, this section is replaced by "TECx".

This section contains technology/special abilities settings:

See #List of Technology IDs for technology ids.


"SWNM" - Switch Names

Not Required.

This section contains the strings used for each switch. There are 256 switches, and can't be any more or any less.


"COLR" - Player Colors

Required for Brood War only and all game types.
Validation: Must be size of 8 bytes.

This section indicates what color each player is, but only has effect on Brood War.

Other values can be used but may have different results depending on the tileset. Any color value above 11 is an overflow.


"PUPx" - BW Upgrade Restrictions

Required for Hybrid (in Expansion mode) and Brood War. Not required for Melee.
Validation: Must be size of 2318 bytes.
In Brood War scenarios this section replaces "UPGR".

This section is identical to UPGR section except it uses the Brood War set of 61 upgrades instead of the original 46.


"PTEx" - BW Tech Restrictions

Required for Hybrid (in Expansion mode) and Brood War. Not required for Melee.
Validation: Must be size of 1672 bytes.
In Brood War scenarios this section replaces "PTEC".

This section is identical to PTEC section except it uses the Brood War set of 44 technologies instead of the original 24.


"UNIx" - BW Unit Settings

Required for Hybrid (in Expansion mode) and Brood War. Not required for Melee.
Validation: Must be size of 4168 bytes.
In Brood War scenarios this section replaces "UNIS".

This section is indentical to UNIS section except it uses the Brood War set of 130 weapons instead of the original 100.


"UPGx" - BW Upgrade Settings

Required for Hybrid (in Expansion mode) and Brood War. Not required for Melee.
Validation: Must be size of 794 bytes.
In Brood War scenarios this section replaces "UPGS".

This section the same as UPGS except section except it uses the Brood War set of 61 upgrades instead of the original 46, and there is an unused byte after the first set:


"TECx" - BW Tech Settings

Required for Hybrid (in Expansion mode) and Brood War. Not required for Melee.
Validation: Must be size of 396 bytes.
In Brood War scenarios this section replaces "TECS".

This section is indentical to UNIS section except it uses the Brood War set of 44 technologies instead of the original 24.



Appendix

A set of references and IDs that should help you easier in the trigger section and the technology/player ids, etc:

Trigger Conditions List

Trigger Actions List

Mission Briefing Actions List

Switch States

Numeric Comparisons

Score Types

Resource Types

Alliance Statuses

Unit Orders

Action States

Number Modifiers

Trigger Unit Types

List of Players/Group IDs

List of Technology IDs

List of Upgrade IDs

List of Unit Weapon IDs

Complete Modifier List