scmJS docs

The commands

Every scmjs mod command that reads a mod takes it in any of its forms: a folder (a release's, or one mod unpack wrote), an .mpq, a self-executing .exe (MPQDraft's or FireGraft's patcher, read and never run) or a .zip. The commands read your copy of StarCraft when they find one, as the commands that need StarCraft do, for the game's own files under the mod. They work without it and tell you what they could not look at.

What a mod is#

scmjs mod info "Cosmonarchy BW"
Cosmonarchy BW
A mod for StarCraft 1.16.1, from a folder of the game's files

  Files            7,767 · 931.2 MB
  Kinds            11 tables (748 KB), 13 scripts (2.0 MB), 3,895 pictures (254.1 MB), 3,525 sounds (553.1 MB), …
  Tables           flingy.datex, images.datex, mapdata.datex, orders.datex, portdata.datex, sfxdata.dat, …
  Extended         flingy.datex: 1,000 entries (the game's 209), GPTP's .datex layout
                   …
                   units.datex: 3,000 entries (the game's 228), GPTP's .datex layout
  Plugins          aise.qdp (1.0 MB), aize_debug.qdp (1.1 MB), gptp.qdp (5.9 MB), …, _qdp-hotloader.qdp (358 KB) — kept, not run
  FireGraft        1161.fgd (555 KB), Cosmonarchy BW.fgp (98 KB) — kept, not applied
  Exe              Cosmonarchy BW.exe: FireGraft's patcher with 1 plugin (qdp-hotloader.qdp, id fc724f8c, 358 KB), its archive at byte 804,352
  Layers           mpq then Cosmonarchy BW.exe
  Hash             c94acdf31982fa4b
  Without plugins  db23a1f9dd8cef66 (a page that runs none of the plugins)
  Earlier hash     20e1c6d89ae2af75 (by the rule before 2026-11-11, when only plugin files had lines)
  Older hash       1c41a2d7701fe842 (with sound\cm\desktop.ini, sound\desktop.ini, which the hash leaves out)

▲ A library of the mod's code: discord_game_sdk.dll. A plugin of the mod may need it; it is in the mod's hash, and nothing here loads it.

▲ temp.mpq is _qdp-hotloader.qdp's own packing of its folder of files (it names it): the folder is laid in its place, at 500000.

It takes a folder (the game's paths at its root or in a folder under it, as a release keeps them under mpq/), an .mpq, a mod's .exe or a .zip. A folder's own archives, exes and zips are read too, and every source is laid where the mod's loader would lay it, the later winning: archives as MPQDraft's patcher takes them first, then the archive of a FireGraft patcher, and loose files over all of them. A plugin that loads a folder of plugins (Cosmonarchy's hot loader) lays its folder of files below FireGraft's archive, and an archive it packs that folder into is read as that folder. Layers lists them in that order. A self-executing exe is read for the archive appended to it, never run: MPQDraft's self-executing MPQ, FireGraft's patcher, or a program with an archive after it in neither form. FireGraft's patcher can carry plugins of its own after the program, and mod info lists them in the order the patcher loads them, each by the name it gives itself and its id (GPTP.qdp, id 1b4d69b6; some ids are four letters, EUDE). Some patchers keep the archive's tables in front of its header and write nonsense in its size fields; the archive is read the way the game reads it all the same. An exe that holds no archive, or a patcher laid out in a way not known here, is refused with the reason rather than shown as a mod of no files.

A library (.dll) in the mod's plugins folder, or beside the exe that holds the mod, is named in a ▲ line: a plugin of the mod may load it, or need it to load at all (Burning Ground's GPTP takes its sound functions from the fmod.dll that ships beside it). It is part of the mod's code and has a line in its hash. A .dll anywhere else is left out.

A mod is named by the name in its mod.json, else after the one program at the top of the folder you name that holds the mod (a release's launcher), else after the folder or file itself. Two plugins with the same file name are one too many: the first in the folder's order is the mod's, and the other is left out. A folder whose name starts with a dot (.git) is a tool's and is never read.

A zip's stored and deflated members are read; a zip64 or encrypted zip is not. An archive's list of its files is taken as its files; an archive with no list is searched for the names the game reads, the names its own image, sound and portrait tables give, and the names the game's own three tables give. A name the list holds and the archive does not (Cosmonarchy's loader lists six tileset files it never packed) is left out and said.

A copy of the game in the folder is not the mod. Some downloads carry the whole game the mod runs on beside the mod itself; a folder that holds a StarDat.mpq is taken for such a copy, and its own archives (StarDat.mpq, BrooDat.mpq, patch_rt.mpq, StarCraft.mpq, BroodWar.mpq) and everything under its Maps folder are left out; a ▲ line names the archives among them. Anything else in it, a mod's own archive or exe put there for one, is read as before. A folder that holds only a copy of the game is refused. An archive named as one of the game's own outside such a copy, such as a patch_rt.mpq, the form some older mods ship in, is the mod's, and stands in for the game's archive of that name.

Hash and Without plugins are the mod's hash. An Earlier hash line follows them when the mod's hash by the rule before 11 November 2026 was another (a mod with a patcher's own plugins, a library, or a FireGraft project found only through FireGraft's own list), and an Older hash line when the mod holds files an operating system left in its folders (desktop.ini, Thumbs.db, .DS_Store): the hash it had while those counted. A replay or a kept mod from before those dates names the mod by them. A mod's mod.json adds a line for the races it names, and its terrain.json one for what it declares.

The command takes several mods at once. --json prints the same as data; each mod has file and path, the path as you typed it. Reading a large mod, an .exe or a .zip of hundreds of megabytes, takes several seconds, and a line on standard error says it is reading. Something that holds none of the game's files is not a mod: the command names what it is instead (a map, a replay, an empty folder, an .exe with no archive in it) and exits with 2. A mod.json that is not JSON, a damaged archive and a patcher laid out in an unknown way are each reported with the file and the reason.

A folder to edit#

scmjs mod unpack MyMod.mpq mymod
✔ My Mod: 1,018 files · 41.3 MB · → mymod
  As text        11 tables, 6 string tables, 1 iscript, 2 AI scripts, 96 overlay files
  As pictures    832 GRPs (the jungle palette)
  As they are    70 other files
  Names          from the mod's string tables

--palette badlands draws the sheets in another tileset's palette. The folder is the mod's source from then on, so unpacking into a folder an earlier unpack wrote stops rather than write over your edits. --force replaces that folder whole: nothing of it is kept but its dot files and folders, such as .git, so no file of the old release lingers in the new. The races the old folder's mod.json named are kept. A folder that holds something other than a mod folder is refused either way; an empty one is fine.

An edit is a change to a line of text. This is the Marine's rifle in mymod/tables/weapons.txt, with its damage raised from 6 to 7:

Weapon(0):  # Gauss Rifle
	…
	damage_amount 7

Back into an MPQ#

scmjs mod pack mymod                    # mymod.mpq beside the folder
scmjs mod pack mymod -o MyMod.mpq --compression pkware
scmjs mod pack mymod --folder samase/   # the files loose in the game's paths

The MPQ has a file list and is compressed with zlib by default (pkware is what Blizzard's own tools wrote, none stores the files). The same folder packs into the same bytes every time. A sound under sounds/ that is not a WAV (an Ogg, an MP3) is converted to one with ffmpeg, when ffmpeg is on your PATH. Files outside the known folders are left out and named. A mistake in a folder's text stops the pack, with the file's path from where you ran the command and its line: mymod/tables/units.txt:26: ….

Option What it does
-o <file.mpq> The MPQ to write; its folder is made when it is not there. -o - writes the MPQ to standard output, and the command's own lines go to standard error
--compression zlib (the default), pkware or none
--folder <out> Loose files in the game's paths instead of an MPQ, as samase reads them. Not with -o

Looking for mistakes#

scmjs mod check mymod
My Mod · ✖ 2 errors (over StarCraft 1.16.1 (2 archives))
  ✖ units 1 (Terran Ghost) ground_weapon: points at weapons 200, past the 130 entries weapons.dat has
  ✖ images 5 grp_file: names unit\custom\nothere.grp, which is in neither the mod nor the game: the game stops when it draws it

Errors are what makes the game stop or draw nothing: a reference past its table (a unit's weapon, flingy or subunit, a flingy's sprite, a sprite's image), a string past its string table, an image with no GRP or overlay file, an image whose animation script is missing, a button set or requirement for something the tables do not have. Warnings are what is probably a mistake: a weapon or animation script the mod added that nothing uses, a sound row the mod changed whose file is nowhere, units with the same name, tables in both DatExtend's and GPTP's layouts. What the mod leaves as the game had it is not judged; the game has leftovers of its own. The check runs over your copy of the game when it finds one; without one, references to the game's own files are not looked at, and it says so. It exits 1 when there is an error.

Two more things are checked when the mod has them. A terrain.json gets a warning for each row the editor would leave out, for a section made for another version of the tileset's tile table, and for rows naming tiles the table has no picture for (Terrain a mod declares). And when the mod's files suggest races of its own and its mod.json names none, one line says so; it is a hint and fails nothing (Races a mod adds).

A changelog#

scmjs mod diff mymod             # what the mod changes in the game
scmjs mod diff v1.mpq mymod      # what changed between two versions
StarCraft 1.16.1 (2 archives) → mymod · 6 changes

Tables
  Terran Marine: ground weapon damage 6 → 7
  unit 228 added: Terran Maverick
  sound 69 → Bullet\TGoFir00.wav

Animation scripts
  iscript: Terran Marine's GndAttkRpt animation changed

Pictures
  3 pictures changed, 1 added

A weapon's change is told through the units that carry it, a sound row's by the file it plays, an animation script's by the unit drawn with it and the animation that changed. With one mod, the other side is your copy of the game, and the command exits with 0. With two, it exits with 1 when they differ and 0 when they are the same, as map diff does.

Starting a mod#

scmjs mod new mymod --name "My Mod"

writes mod.json and a README of one paragraph. Put the game's files you change under files/ at their paths (files/arr/units.dat), or the texts in their folders, and pack. Starting from an existing mod is mod unpack.

scmjs mod new mymod --tables units,weapons

starts it with the game's own tables, read from your copy of StarCraft and written as text as mod unpack writes a mod's (tables/units.txt, with the game's names beside each entry); --tables all writes all eleven. As they are they pack back into the game's own bytes, so the mod changes nothing until you edit them.

Check, then pack#

scmjs mod build mymod -o MyMod.mpq

runs mod check and, when it finds no error, mod pack with the same options. --ignore-errors packs anyway (--force, its old name, still works).

My Mod · ✔ nothing found (over StarCraft: Remastered 1.23.10.13515)
✔ MyMod.mpq: 2 files · zlib · 8.0 KB

Playing it#

scmjs mod play mymod --map "(2)Ridge.scx"
scmjs mod play "Cosmonarchy BW" --map "(4)Exodus 1.0.scx" --bot cosmonarchy-example --race terran
scmjs mod play "Cosmonarchy BW" --map "(4)Exodus 1.0.scx" --bot mybot/out/mybot.scmbot --start

mod play opens the play page in your browser and hands it every file of the mod, its plugins and FireGraft files with them, and the mod's hash. The page keeps the files that differ from your copy of the game, in your browser; nothing is uploaded. The hand-over from the command line has the message the page is sent.

Option What it does
--map <map> Starts this map with the mod. A mod with plugins plays the map with its own settings
--bot <key or file> Puts a community bot on the other side: one of the play page's bots by its key (cosmonarchy-example, mcrave, ualbertabot, example), or a .scmbot file you built. The map waits on the page's setup screen with the bot in the row beside yours, and you press Start Game
--race The bot's race where the map leaves it open: zerg, terran, protoss or random, or a race the mod's mod.json names, by its name or its number. Needs --bot
--start Starts the game at once instead of waiting on the setup screen. Needs --bot; a map alone always starts at once
--json The result as JSON on standard output; the page's address and its messages go to standard error

The command prints what the page told it. With a bot, the last line is the bot's row on the setup screen, which says whether the bot was made for the mod, plays vanilla data, or was made for another mod:

Cosmonarchy BW: 7,767 files to hand over (and 10 plugins and FireGraft files) · 931.2 MB · hash c94acdf31982fa4b
ℹ Opening the play page with Cosmonarchy BW in your browser
  If nothing opens, go to http://127.0.0.1:33525/58aab12d25f4b5a8cf293c11
ℹ The play page is ready: the mod is handed over
ℹ The play page is ready again: the mod is handed over again
✔ On the play page's setup screen: press Start Game
  Bot  Cosmonarchy Example — made for Cosmonarchy BW

The page's own bots need a scmjs.dev account: the page asks you to sign in, and the command prints that it is waiting. A file of your own needs no account. A bot the page does not have, or a map with no place for it, is an error and the command exits with 1. The command waits five minutes for the page. With BROWSER=none it opens no browser, prints the address and waits for you or a script to open it.

The mod's hash#

A mod goes by a hash of sixteen hex digits, worked out the same way by the play page, scmjs mod info, the editor's data sets and the tools that read a replay of the mod, so one mod has one hash everywhere: all of them read mods with the same library, @scm-js/mod. It covers every file the mod provides: each file it lays over the game, loose under its game folders or inside its archives (an .mpq, or the archive inside a FireGraft or MPQDraft loader .exe), and the file that wins where two layers give one; its FireGraft project (.fgp), whether a folder holds it, an archive lists it, or only FireGraft's own list in an archive with no list of its files names it; and every module of its code: each plugin it carries as a file, each plugin a patcher .exe carries in itself, and each library its plugins load (a .dll in its plugins folder, or beside the program that holds the mod). Two people whose code differs never hold the "same" mod. It is never compared with anyone's copy of the game, so two people with different copies give the same mod the same hash, and a release unpacked into a folder and packed again keeps it. A release folder and its .exe named alone have the same hash: what sits beside the exe is a read-me or a library, never a file of the game. Left out are what is not the mod's files: a file an archive lists and does not hold, a folder's read-mes and programs with no archive, a plugin inside an archive (no loader loads one from there), and FireGraft's database (.fgd). A page that does not run the code plays something else, so beside the hash there is one without the lines of the code; mod info prints both, and a page that runs none of it presents that one.

How it is worked out. Each file is one line, name<TAB>sha256 of the file's bytes. The lines are sorted by name and joined with newlines, and the hash is the first sixteen hex digits of the SHA-256 of that text. A game file's name is the game's, in lower case with backslashes (arr\weapons.dat). A module of the mod's code is plugins\ and its file name, in lower case (plugins\gptp.qdp, plugins\fmod.dll). The FireGraft project's is its file name, in lower case (cosmonarchy bw.fgp).

Files an operating system leaves in folders are not the mod's. Windows Explorer writes desktop.ini and Thumbs.db into folders it has shown, the macOS Finder .DS_Store, and a mod's loader that packs its folder into an archive packs them in too. The game never asks for them, and not every way of reading a folder hands them over: a browser's folder picker never shows desktop.ini or Thumbs.db, while a dropped folder and the command line do. So they have no line in the hash, wherever they lie, and the same mod has the same hash however it was read. They are, by name in any case:

Name What leaves it
desktop.ini Windows Explorer, a folder's view and icon
Thumbs.db, ehthumbs.db, ehthumbs_vista.db Windows Explorer and Media Center, thumbnails
.DS_Store, Icon followed by a carriage return the macOS Finder, a folder's view and icon
a name that starts with ._, and everything under a folder __MACOSX macOS, the second half of a file on a disk that is not its own, and the folder its zips keep those in
.directory KDE's file manager, a folder's view

A file whose name only holds one of these (mydesktop.ini, thumbs.db.txt) is a file of the mod like any other. So is every other file a browser's folder picker does not show. Chrome hides more than the two names above: shortcuts (.lnk, .url, .scf), names Windows keeps for devices (aux.wav, con.grp), and names that begin or end with a space or ~ or end with a dot; on Windows its list of file types it does not hand to a page adds .ini, .cfg, .dll and .manifest. Those may be a mod's own (a plugin's config.ini), so they keep their lines: a mod read through the folder picker is short of them, and its hash says so by being another. Read such a mod with scmjs, or drop its folder on the editor or the play page: a dropped folder is read whole.

Replays that name a mod by an older hash. The rule has changed twice. Until 9 November 2026 the files an operating system leaves in folders had lines; until 11 November 2026, of a mod's code only the plugins it carries as files had lines (not a patcher's own plugins, not a library, not a FireGraft project found only through FireGraft's own list). A mod those changes touch had another hash before them, and a replay saved then, or a mod a browser kept, names it by that hash. Wherever hashes are compared they are still taken, where they can be worked out: mod info prints them as Older hash and Earlier hash, the replay commands accept both (and the hash the play page gave for one day in between, with lines for every module of the code but not a project found only through FireGraft's list), and the play page finds a mod it kept under an older hash by the new one and plays an older replay with it. A route that never saw the files cannot work one out: a folder chosen with the browser's folder picker has no older hash, so an older replay is not matched to it. Drop the folder on the play page instead.

Testing with it#

scmjs mod test mymod ridge.scx
scmjs map test ridge.scx --mod mymod
scmjs map trace ridge.scx --mod MyMod.mpq

mod test is map test with the mod's files laid over the game's; map test, map trace and map cost take --mod. The game engine's runners are fetched from the play page once like any command that plays the game; with an engine older than the one a command needs, the command names the version it needs and stops. These commands lay the mod's files only and run none of its plugins; its plugins and FireGraft project run beside a bot in scmjs bot run and bot ladder (a bot on a mod). A scenario with a bot on the other side is not there yet: map test plays the person's seat and the map's own computers.

The first line under the run counts the mod's files the game read; --json has the same under mod. A mod that changes animation scripts, pictures, overlays or the sound table makes the game read its startup data again, which opens every unit picture the image table names. On a Remastered copy the command reads those pictures out of your installation and lays them under the mod, so such a mod runs there as on a 1.16.1 copy. They are the classic pictures, the same in both.

Replays of modded games#

A replay holds the players' commands, not the files the game read. Played back with other files, the same commands make another game: a unit costs something else, a building is somewhere else, and the replay goes its own way. So a replay of a mod says which mod it was. scmJS adds a short section at the end of the file, after what the game wrote, that holds the mod's name, its hash (with its plugins, or without them when the page ran none), its makers' link, the plugins that ran and the FireGraft patch applied. StarCraft itself does not read it: 1.16.1 plays the file as it would the same file without it, and Remastered steps over it as over any section it does not know. The replay package's read-me has the bytes.

What reads it:

The play page writes the section into every replay it saves of a game of a mod: Save Replay, and Watch the Replay and Analyse in the Editor at the end of a game. A replay StarCraft itself recorded with a mod has no such section. On the play page, choose the mod under Mods first; the page then asks whether to watch the replay with the mod or without it. Such replays are expected to play, but none has been checked yet.

A bot for your mod#

scmjs mod header "Cosmonarchy BW"
scmjs mod header "Cosmonarchy BW" --out mybot --bot
scmjs mod header "Cosmonarchy BW" --js

A community bot made for a mod names the mod's units, weapons, upgrades and technologies, which BWAPI's own names (Terran_SCV) do not cover. mod header writes them for it in two files: <Mod>.h, C++ for a BWAPI bot built with scmbot, and <Mod>.ids.json, the same ids and names for bots and tools in other languages. <Mod> is the mod's name made an identifier (Cosmonarchy_BW), or --namespace. Every name the mod has is there, not only the ones it added, since a mod may rename everything.

#include "Cosmonarchy_BW.h"
namespace cosmo = Cosmonarchy_BW;
// …
if (unit->getType() == cosmo::UnitTypes::Terran_Ministry) unit->train(cosmo::UnitTypes::Terran_Mason);

The header is one namespace. It holds MOD_NAME and MOD_HASH (the mod's hash, as mod info prints it), the units in UnitTypes (each a BWAPI::UnitType made from its id), the weapons in WeaponTypes, the upgrades in UpgradeTypes and the technologies in TechTypes. The same ids are there as plain numbers (constexpr int) in Ids::Units, Ids::Weapons, Ids::Upgrades and Ids::Techs. The JSON is { "mod": { "name", "hash" }, "units": [{ "id", "name", "identifier" }], "weapons", "upgrades", "techs" }. On Cosmonarchy BW the header names 621 units, 330 weapons, 67 upgrades and 54 technologies. The header says it was generated, from which mod and hash and on what day; run the command again rather than edit it.

Option What it does
--out <folder> Where the files go; this folder by default
--bot --out is a bot's folder, one with scmbot.json, which gains "mod": { "name", "hash" } (and "link" when the mod's mod.json has one). The next scmjs bot build writes the mod into the .scmbot file, and bot run and bot ladder then say whether the game's mod is the one the bot was made for
--js <Mod>.mjs in place of the header, for a JavaScript bot. Not with --bot, since it writes no scmbot.json
--namespace <name> The C++ namespace and the files' name
--starcraft <folder> The copy of the game whose tables are read for any the mod does not have

When the bot plays, the runners and the play page's setup screen say "made for" the mod when the game's mod is the one its .scmbot file names by hash, "plays vanilla data" for a bot made for no mod, and warn (the game still plays) for a bot made for another. To try a bot on the mod without a page, scmjs bot run mybot/out/mybot.scmbot "(4)Exodus 1.0.scx" --mod "Cosmonarchy BW" plays it with the mod's plugins, and scmjs bot ladder … --mod plays a ladder on the mod (a bot on a mod). The scmbot repository's examples/cosmonarchy/ folder holds a small bot for Cosmonarchy written against such a header, which mines, builds Stockades and attacks with Mavericks.

How a name becomes an identifier. Every name is the mod's.

A bot written in JavaScript needs no header: in the mod's game it is told the mod's name and hash, and its tables call every unit by the mod's name, the same ones the header uses (Terran_Mason). --js writes them as a JavaScript module all the same, for an editor's completion and for ids pinned to one version of the mod: MOD_NAME, MOD_HASH, and UnitTypes, WeaponTypes, UpgradeTypes and TechTypes by name (UnitTypes.Terran_Mason is 7), with the JSON beside it. Its names follow the same rules with one difference: a C++ keyword stays as it is (max, not _max), since any word may name a member of a JavaScript object. Bots for mods in the bot guide has an example made for Cosmonarchy.

For AI tools#

scmjs mcp has the mod commands as tools: mod_info, mod_check, mod_diff, mod_unpack, mod_pack, mod_new, mod_header and mod_play. An AI tool can unpack a mod, change a table's text and pack it again, as you would, write the header for a bot, and hand the mod with a map and a bot to the play page in your browser, which it says the link to and what the page answered. map_trace and map_cost take a mod. See AI tools.

scmJS 0.18.0 · Generated from the repository. The source is under the MIT license, which does not cover what ATTRIBUTION.md lists. StarCraft and Brood War are trademarks of Blizzard Entertainment; this project ships none of their data.