0.1.5 • Published 2 years ago

sctoolsdata v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

MIT license npm version

sctoolsdata

A collection of StarCraft internal data used to help process replay and map files.

Usage

This library is available via npm:

npm i --save sctoolsdata

TODO: explain more about how this is used.

Reference

Function:

framesToMs(frames[, speed])

Parameters:

  • frames number\ number of in-game frames per second
  • speed string (default: "fastest")\ game speed (virtually always "fastest")

Returns:

  • number\ the number of milliseconds representing the duration of the game frames

Used to get timestamps of game events for a given game speed. For example, this can be used to display a timestamp for a chat message, or to show the duration of a game.


Function:

getSwatchFromSlotID(id)

Parameters:

  • id number\ slot ID to return the color for

Returns:

  • string\ swatch name for the color associated with that player slot ID

Every player ID has a default color; for example, player 1 is red, player 2 is blue, etc. This function is used to return the color swatch name associated with a given ID.


Function:

getColorFromSwatch(swatch[, returnType])

Parameters:

  • swatch string\ swatch name to return the color value for
  • returnType string<"hex" | "int"> (default: "hex")\ type of value to return; either a hex string or a number

Returns:

  • string | number\ the color value of the given swatch name

This function can be used to get the actual colors to be displayed for a given swatch (e.g. "paleBlue" will return "#b8b8e8").


TODO.

In-game colors

Colors work quite inconsistently in StarCraft. There are two sets of color codes: one for briefing messages (and map names), and one for in-game chat messages. These each have their quirks that can be different between Brood War (v1.16.1 and below) and Remastered.

Here's a list of all colors:

†: In StarCraft, gray is buggy: when it's used in a map name in Brood War, the rest of the name becomes gray as well—this was fixed in Remastered. In in-game text messages, gray will take over the entire rest of the line, both in Brood War and Remastered. This buggy behavior is not completely implemented in this library, and more research is needed to determine every edge case.

‡: Slot IDs 11, 14, 15 and 20 are not selectable as player colors (the color for 11 is used for the neutral player, however). 11 and 15 are still usable as text color. 14 and 20 are duplicates of Pale Yellow and Cerulean.

A few of the player colors are unavailable on certain tilesets:

Game speed

Number of milliseconds per game frame for each game speed.

E.g. for "Fastest", there are approximately 1000 / 42 = ~23.81 frames in a second. This is used to convert the number of game frames into real time.

Name㎳/frameFrames/second% of "Fastest"
Fastest4223.810100.0%
Faster4820.83387.5%
Fast5617.85775.0%
Normal6714.92562.7%
Slow8312.04850.6%
Slower1119.00937.8%
Slowest1675.98825.1%

By far most replays use "Fastest" as the speed, but this map can be used for the rare case that isn't. In the very old days of StarCraft, the ladder speed setting was "Fast" by default, but this got changed to "Fastest" relatively early on.

License

MIT license