scmJS docs

A mod as a folder

scmjs mod unpack writes a mod as a folder like this one:

mymod/
  mod.json              the mod's name, version, authors and licence, and what the folder needs to pack
  README.md
  tables/units.txt …    the unit, weapon, flingy, sprite, image, upgrade, technology, order,
                        sound, portrait and campaign tables, as PyDAT's text
  strings/stat_txt.txt  the string tables, as PyTBL's text (images.txt, sfxdata.txt, unitnames.txt …)
  iscript/iscript.txt   the animation scripts, as PyICE's text (a mod may have several)
  ai/aiscript.txt       the AI scripts, aiscript.bin and bwscript.bin, as PyAI's text
  overlays/unit/terran/marine.lob.txt …   the overlay offsets, as PyLO's text
  graphics/unit/terran/marine.png …       each GRP as a PNG sheet
  sounds/sound/…        the WAV files, as they are
  grafts/Units.txt …    GPTP's .graft files (requirements, buttons), as graftc's text
  maps/…                the mod's maps
  plugins/, Firegraft/  the mod's code and FireGraft files, as they are
  files/…               every other file of the game the mod changes, as it is

The texts are PyMS's own dialects, so a table exported here reads in PyDAT and the other way round, and the same for PyTBL, PyICE, PyAI and PyLO. A few lines start # scmjs:; PyMS reads them as comments, and they keep what the text form cannot say (where the game's own iscript keeps its headers, the order of its table), so the file comes back as it was. Each table entry's header line names it (Unit(0): # Terran Marine), and the AI script names units, upgrades and technologies, with the names from the mod's own string tables, or the game's when the mod has none.

Pictures. Each GRP is one PNG: every frame in a cell of the GRP's size, 17 cells to a row for a unit's facings. The PNG is an indexed picture in a named palette (the jungle tileset's by default, or the one mod.json names; the mod's own tileset\<name>.wpe when it has one, else your game's), with the frame boxes and the palette's name written inside it, so the GRP that comes back is the same bytes. Draw over a sheet in a program that keeps its palette and only the pixels you changed change. A picture saved in full colour is brought to the nearest of the palette's colours when it is packed, and mod pack says how many pixels moved.

What comes back the same. Each file is written as text or a picture only when that text or picture packs back into exactly the same bytes; that check is the packer itself. A file that would not — a GRP another tool encoded, which reads as the same pictures but in other bytes, or a file that is not what its name says — is kept as it is under files/, and mod.json lists it under kept with why. So an unpacked folder packs back into the mod it came from, file for file, and an edit to one text changes that one file. The mod's code goes under plugins/ as it is: its plugin files, the plugins a patcher .exe carries in itself and the libraries its plugins load, so the folder has the mod's hash too.

mod.json holds what a person fills in (name, version, authors, licence, base, the game the mod is for) and what packing needs: each table's file and layout, each string table's text encoding, the palette, where the names came from, the files kept as bytes, the plugins and FireGraft files and whether they were inside the mod's archive, and the sources the folder was made from in their load order (layers). An unpacked mod's names stay as they were (Units.graft, arr\units.datex).

Tables in other layouts. A table may be the game's own size, DatExtend's expanded .dat (PyMS's reading, more entries and a wider flingy column), or GPTP's .datex (more entries again, wider columns, no header). Each is written as text in the same way and packed back in the layout it came in, at the width its text has.

Races a mod adds#

To the game a race is a number: one byte in each player's record, in a map and in a replay. 0 to 7 are the game's own: Zerg, Terran, Protoss, then Independent, Neutral, User Selectable, Random and Inactive. A mod can give its players other numbers, and nothing in its files says what those races are called (the names are in its plugin's code). So the tools keep the number as it is and, until something names it, show it as Race and the number: Race 69 in replay info's player list, in Player Settings and in Statistics.

mod.json names them, under races:

"races": [
  { "id": 69, "name": "Askosi", "letter": "a", "like": 1 }
]

A row with one of the game's numbers, a number an earlier row has, or no name is left out. mod.json is not one of the mod's files, so naming races leaves the mod's hash as it was. It is read in the folder you name or one folder down (a release that keeps the mod in a folder of its own), never in one of the game's folders, as well as in a folder mod unpack wrote, and mod unpack keeps the races when it unpacks a new release over a folder that has them. Beside races, the same file can give the mod's name (up to 80 characters) and its makers' address (link, url or homepage, an http or https address).

mod info lists them, replay info --mod names a player's race by them when the replay does not name it itself, and mod play --race takes one by its name or its number. mod check mentions it when a mod's files suggest races of its own and mod.json names none: strings past the game's own in rez\network.tbl, or a console picture game\<letter>console.pcx or rez\statbtn<letter>.bin under a letter other than z, t, p and n. That is a hint, not a finding: the check fills in no name and fails nothing for it.

In the editor, a data set added from a folder (Help ▸ Game Data… ▸ Add a data set…) takes the races of the mod.json in that folder or one folder down; a plugin can name them too, and a map made with the data set carries them (A map remembers its data set).

Terrain a mod declares#

A mod's tilesets often hold ground the game's tables do not describe: flat ground with no terrain type, buildings and walls drawn across many tiles, another tileset's ground copied in. The editor can find some of it by itself (the Tile palette learns pieces from a folder of maps, the Isometric tab looks for another tileset's terrain), but every mapper has to do that again, and it takes a while. A terrain.json beside mod.json says it once, for everyone who adds the mod:

{
  "format": 1,
  "tilesets": {
    "badlands": {
      "table": "1q2w3e4r5t6y",
      "terrains": [{ "name": "Plating", "group": 2466 }],
      "pieces": [{ "name": "Long ramp", "category": "Ramps", "cols": 2, "rows": 2, "tiles": [35010, 35011, -1, 35027] }],
      "borrow": [{ "source": "install", "pairs": [[1234, 35010], [1235, 35011]] }],
      "borders": [{ "source": "install", "terrain": 2, "ground": 2, "shapes": { "A,A,B,h53|L": [36130, 36131] } }],
      "copies": [{ "terrain": 4, "height": 1, "ground": { "terrain": 3 }, "pieces": [[9216, 39248], [9217, 39249]] }]
    }
  }
}

It is found by mod.json's rule: in the folder you name or one folder down, never in one of the game's folders, and it does not need a mod.json beside it. It is not one of the mod's files, so it leaves the mod's hash as it was. A row the editor cannot use (a name too long, a tile number past the table, a gap where a block's size says a tile) is left out; keys the editor does not know are kept, so a later version of the file can add to it.

The easiest way to make one is the editor's: open a map of the mod with the mod's data in use, learn its pieces and look for its borrowed terrain, then Save as a terrain file… in the Tile palette's pieces view. It writes the tileset in front's section from what the editor lists: the pieces (with the names a plugin or an earlier file gave), the terrains named for the Rect brush, the borrowed-terrain tables and the drawn borders learned from the mod's maps (look for the borrowed terrain before learning: the borders are read only for tilesets whose copies are known), and the copied terrain the Isometric tab lists. Choose an existing terrain.json and its other tilesets' sections are kept. In the editor, the file comes with the mod: a data set added from a folder (Help ▸ Game Data… ▸ Add a data set…) or a mod's folder chosen for a map reads it, and while that data set is in use its pieces are listed under the data set's name, its terrains are in the Rect tab, its borrowed terrain is offered with no search, and its borders are drawn with nothing learned. A plugin that declares the same thing is listed first, and a border the file gives stands ahead of one learned from maps.

mod info says whether a mod has one and what it holds per tileset (the drawn borders and their shapes, and the blocks of copied terrain, counted), mod check lists the rows that would be left out and a section made for another version of the tileset's table, and mod unpack keeps a folder's terrain.json when it unpacks a new release over it.

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.