@scm-js/core 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +449 -1
- package/dist/index.mjs +1002 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @scm-js/core 0.
|
|
2
|
+
* @scm-js/core 0.10.0 — StarCraft maps as the scmJS editor reads and writes them.
|
|
3
3
|
* Generated by `npm run build:core` in github.com/scm-js/scm-js from core/src/index.ts; the guide is docs/core.md.
|
|
4
4
|
*/
|
|
5
5
|
import { Archive, HashEntry, StoredMember } from 'mopaq';
|
|
@@ -370,6 +370,159 @@ export interface ReadonlyTrigger {
|
|
|
370
370
|
readonly players: readonly number[];
|
|
371
371
|
readonly currentAction: number;
|
|
372
372
|
}
|
|
373
|
+
export declare const ConditionType: {
|
|
374
|
+
readonly None: 0;
|
|
375
|
+
readonly CountdownTimer: 1;
|
|
376
|
+
readonly Command: 2;
|
|
377
|
+
readonly Bring: 3;
|
|
378
|
+
readonly Accumulate: 4;
|
|
379
|
+
readonly Kill: 5;
|
|
380
|
+
readonly CommandTheMost: 6;
|
|
381
|
+
readonly CommandTheMostAt: 7;
|
|
382
|
+
readonly MostKills: 8;
|
|
383
|
+
readonly HighestScore: 9;
|
|
384
|
+
readonly MostResources: 10;
|
|
385
|
+
readonly Switch: 11;
|
|
386
|
+
readonly ElapsedTime: 12;
|
|
387
|
+
readonly Briefing: 13;
|
|
388
|
+
readonly Opponents: 14;
|
|
389
|
+
readonly Deaths: 15;
|
|
390
|
+
readonly CommandTheLeast: 16;
|
|
391
|
+
readonly CommandTheLeastAt: 17;
|
|
392
|
+
readonly LeastKills: 18;
|
|
393
|
+
readonly LowestScore: 19;
|
|
394
|
+
readonly LeastResources: 20;
|
|
395
|
+
readonly Score: 21;
|
|
396
|
+
readonly Always: 22;
|
|
397
|
+
readonly Never: 23;
|
|
398
|
+
};
|
|
399
|
+
export declare const ActionType: {
|
|
400
|
+
readonly None: 0;
|
|
401
|
+
readonly Victory: 1;
|
|
402
|
+
readonly Defeat: 2;
|
|
403
|
+
readonly PreserveTrigger: 3;
|
|
404
|
+
readonly Wait: 4;
|
|
405
|
+
readonly PauseGame: 5;
|
|
406
|
+
readonly UnpauseGame: 6;
|
|
407
|
+
readonly Transmission: 7;
|
|
408
|
+
readonly PlayWav: 8;
|
|
409
|
+
readonly DisplayText: 9;
|
|
410
|
+
readonly CenterView: 10;
|
|
411
|
+
readonly CreateUnitWithProperties: 11;
|
|
412
|
+
readonly SetMissionObjectives: 12;
|
|
413
|
+
readonly SetSwitch: 13;
|
|
414
|
+
readonly SetCountdownTimer: 14;
|
|
415
|
+
readonly RunAiScript: 15;
|
|
416
|
+
readonly RunAiScriptAt: 16;
|
|
417
|
+
readonly LeaderboardControl: 17;
|
|
418
|
+
readonly LeaderboardControlAt: 18;
|
|
419
|
+
readonly LeaderboardResources: 19;
|
|
420
|
+
readonly LeaderboardKills: 20;
|
|
421
|
+
readonly LeaderboardPoints: 21;
|
|
422
|
+
readonly KillUnit: 22;
|
|
423
|
+
readonly KillUnitAt: 23;
|
|
424
|
+
readonly RemoveUnit: 24;
|
|
425
|
+
readonly RemoveUnitAt: 25;
|
|
426
|
+
readonly SetResources: 26;
|
|
427
|
+
readonly SetScore: 27;
|
|
428
|
+
readonly MinimapPing: 28;
|
|
429
|
+
readonly TalkingPortrait: 29;
|
|
430
|
+
readonly MuteUnitSpeech: 30;
|
|
431
|
+
readonly UnmuteUnitSpeech: 31;
|
|
432
|
+
readonly LeaderboardComputerPlayers: 32;
|
|
433
|
+
readonly LeaderboardGoalControl: 33;
|
|
434
|
+
readonly LeaderboardGoalControlAt: 34;
|
|
435
|
+
readonly LeaderboardGoalResources: 35;
|
|
436
|
+
readonly LeaderboardGoalKills: 36;
|
|
437
|
+
readonly LeaderboardGoalPoints: 37;
|
|
438
|
+
readonly MoveLocation: 38;
|
|
439
|
+
readonly MoveUnit: 39;
|
|
440
|
+
readonly LeaderboardGreed: 40;
|
|
441
|
+
readonly SetNextScenario: 41;
|
|
442
|
+
readonly SetDoodadState: 42;
|
|
443
|
+
readonly SetInvincibility: 43;
|
|
444
|
+
readonly CreateUnit: 44;
|
|
445
|
+
readonly SetDeaths: 45;
|
|
446
|
+
readonly Order: 46;
|
|
447
|
+
readonly Comment: 47;
|
|
448
|
+
readonly GiveUnits: 48;
|
|
449
|
+
readonly ModifyHitPoints: 49;
|
|
450
|
+
readonly ModifyEnergy: 50;
|
|
451
|
+
readonly ModifyShields: 51;
|
|
452
|
+
readonly ModifyResourceAmount: 52;
|
|
453
|
+
readonly ModifyHangarCount: 53;
|
|
454
|
+
readonly PauseTimer: 54;
|
|
455
|
+
readonly UnpauseTimer: 55;
|
|
456
|
+
readonly Draw: 56;
|
|
457
|
+
readonly SetAllianceStatus: 57;
|
|
458
|
+
readonly DisableDebugMode: 58;
|
|
459
|
+
readonly EnableDebugMode: 59;
|
|
460
|
+
};
|
|
461
|
+
/** The 27 player-group slots of a trigger, and the values conditions/actions store. */
|
|
462
|
+
export declare const PlayerGroup: {
|
|
463
|
+
readonly Player1: 0;
|
|
464
|
+
readonly Player2: 1;
|
|
465
|
+
readonly Player3: 2;
|
|
466
|
+
readonly Player4: 3;
|
|
467
|
+
readonly Player5: 4;
|
|
468
|
+
readonly Player6: 5;
|
|
469
|
+
readonly Player7: 6;
|
|
470
|
+
readonly Player8: 7;
|
|
471
|
+
readonly Player9: 8;
|
|
472
|
+
readonly Player10: 9;
|
|
473
|
+
readonly Player11: 10;
|
|
474
|
+
readonly Player12: 11;
|
|
475
|
+
readonly None: 12;
|
|
476
|
+
readonly CurrentPlayer: 13;
|
|
477
|
+
readonly Foes: 14;
|
|
478
|
+
readonly Allies: 15;
|
|
479
|
+
readonly NeutralPlayers: 16;
|
|
480
|
+
readonly AllPlayers: 17;
|
|
481
|
+
readonly Force1: 18;
|
|
482
|
+
readonly Force2: 19;
|
|
483
|
+
readonly Force3: 20;
|
|
484
|
+
readonly Force4: 21;
|
|
485
|
+
readonly Unused1: 22;
|
|
486
|
+
readonly Unused2: 23;
|
|
487
|
+
readonly Unused3: 24;
|
|
488
|
+
readonly Unused4: 25;
|
|
489
|
+
readonly NonAlliedVictoryPlayers: 26;
|
|
490
|
+
};
|
|
491
|
+
export declare const Comparison: {
|
|
492
|
+
readonly AtLeast: 0;
|
|
493
|
+
readonly AtMost: 1;
|
|
494
|
+
readonly Exactly: 10;
|
|
495
|
+
};
|
|
496
|
+
export declare const SwitchState: {
|
|
497
|
+
readonly Set: 2;
|
|
498
|
+
readonly Cleared: 3;
|
|
499
|
+
};
|
|
500
|
+
export declare const SwitchAction: {
|
|
501
|
+
readonly Set: 4;
|
|
502
|
+
readonly Clear: 5;
|
|
503
|
+
readonly Toggle: 6;
|
|
504
|
+
readonly Randomize: 11;
|
|
505
|
+
};
|
|
506
|
+
export declare const SetModifier: {
|
|
507
|
+
readonly SetTo: 7;
|
|
508
|
+
readonly Add: 8;
|
|
509
|
+
readonly Subtract: 9;
|
|
510
|
+
};
|
|
511
|
+
export declare const ResourceType: {
|
|
512
|
+
readonly Ore: 0;
|
|
513
|
+
readonly Gas: 1;
|
|
514
|
+
readonly OreAndGas: 2;
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* Unit ids beyond units.dat that conditions and actions accept. 228 is "None"; the classes
|
|
518
|
+
* start at 229 — a melee map's own defeat trigger is "commands at most 0 of 231", Buildings.
|
|
519
|
+
*/
|
|
520
|
+
export declare const UnitClass: {
|
|
521
|
+
readonly Any: 229;
|
|
522
|
+
readonly Men: 230;
|
|
523
|
+
readonly Buildings: 231;
|
|
524
|
+
readonly Factories: 232;
|
|
525
|
+
};
|
|
373
526
|
/**
|
|
374
527
|
* A parsed scenario.
|
|
375
528
|
*
|
|
@@ -493,6 +646,16 @@ export declare function setExtendedStrings(scn: Scenario, extended: boolean): vo
|
|
|
493
646
|
* strings themselves are unchanged; the whole table is re-encoded on save.
|
|
494
647
|
*/
|
|
495
648
|
export declare function setTextEncoding(scn: Scenario, encoding: TextEncoding): void;
|
|
649
|
+
/** UNIS and/or UNIx. */
|
|
650
|
+
export declare const unitSettingsSections: (scn: Scenario) => ("TYPE" | "VER " | "IOWN" | "OWNR" | "ERA " | "DIM " | "SIDE" | "MTXM" | "PUNI" | "UPGR" | "PTEC" | "UNIT" | "ISOM" | "TILE" | "DD2 " | "THG2" | "MASK" | "STR " | "UPRP" | "UPUS" | "MRGN" | "TRIG" | "MBRF" | "SPRP" | "FORC" | "WAV " | "UNIS" | "UPGS" | "TECS" | "SWNM" | "COLR" | "PUPx" | "PTEx" | "UNIx" | "UPGx" | "TECx" | "STRx" | "CRGB")[];
|
|
651
|
+
/** UPGS and/or UPGx. */
|
|
652
|
+
export declare const upgradeSettingsSections: (scn: Scenario) => ("TYPE" | "VER " | "IOWN" | "OWNR" | "ERA " | "DIM " | "SIDE" | "MTXM" | "PUNI" | "UPGR" | "PTEC" | "UNIT" | "ISOM" | "TILE" | "DD2 " | "THG2" | "MASK" | "STR " | "UPRP" | "UPUS" | "MRGN" | "TRIG" | "MBRF" | "SPRP" | "FORC" | "WAV " | "UNIS" | "UPGS" | "TECS" | "SWNM" | "COLR" | "PUPx" | "PTEx" | "UNIx" | "UPGx" | "TECx" | "STRx" | "CRGB")[];
|
|
653
|
+
/** UPGR and/or PUPx. */
|
|
654
|
+
export declare const upgradeRestrictionSections: (scn: Scenario) => ("TYPE" | "VER " | "IOWN" | "OWNR" | "ERA " | "DIM " | "SIDE" | "MTXM" | "PUNI" | "UPGR" | "PTEC" | "UNIT" | "ISOM" | "TILE" | "DD2 " | "THG2" | "MASK" | "STR " | "UPRP" | "UPUS" | "MRGN" | "TRIG" | "MBRF" | "SPRP" | "FORC" | "WAV " | "UNIS" | "UPGS" | "TECS" | "SWNM" | "COLR" | "PUPx" | "PTEx" | "UNIx" | "UPGx" | "TECx" | "STRx" | "CRGB")[];
|
|
655
|
+
/** TECS and/or TECx. */
|
|
656
|
+
export declare const techSettingsSections: (scn: Scenario) => ("TYPE" | "VER " | "IOWN" | "OWNR" | "ERA " | "DIM " | "SIDE" | "MTXM" | "PUNI" | "UPGR" | "PTEC" | "UNIT" | "ISOM" | "TILE" | "DD2 " | "THG2" | "MASK" | "STR " | "UPRP" | "UPUS" | "MRGN" | "TRIG" | "MBRF" | "SPRP" | "FORC" | "WAV " | "UNIS" | "UPGS" | "TECS" | "SWNM" | "COLR" | "PUPx" | "PTEx" | "UNIx" | "UPGx" | "TECx" | "STRx" | "CRGB")[];
|
|
657
|
+
/** PTEC and/or PTEx. */
|
|
658
|
+
export declare const techRestrictionSections: (scn: Scenario) => ("TYPE" | "VER " | "IOWN" | "OWNR" | "ERA " | "DIM " | "SIDE" | "MTXM" | "PUNI" | "UPGR" | "PTEC" | "UNIT" | "ISOM" | "TILE" | "DD2 " | "THG2" | "MASK" | "STR " | "UPRP" | "UPUS" | "MRGN" | "TRIG" | "MBRF" | "SPRP" | "FORC" | "WAV " | "UNIS" | "UPGS" | "TECS" | "SWNM" | "COLR" | "PUPx" | "PTEx" | "UNIx" | "UPGx" | "TECx" | "STRx" | "CRGB")[];
|
|
496
659
|
export declare function parseScenario(bytes: Uint8Array): Scenario;
|
|
497
660
|
declare const MODELLED: readonly [
|
|
498
661
|
"TYPE",
|
|
@@ -996,6 +1159,20 @@ export declare function megatileForTile(tileset: Tileset, tileId: number): numbe
|
|
|
996
1159
|
* a rotated copy (see cycle.ts).
|
|
997
1160
|
*/
|
|
998
1161
|
export declare function drawMegatile(tileset: Tileset, megatile: number, dest: Uint8ClampedArray | Uint8Array, destWidth: number, dx: number, dy: number, palette?: Uint8Array): void;
|
|
1162
|
+
export declare function groupBuildable(group: Cv5Group): boolean;
|
|
1163
|
+
export declare const TileFlag: {
|
|
1164
|
+
readonly Walkable: 1;
|
|
1165
|
+
readonly MidGround: 2;
|
|
1166
|
+
readonly HighGround: 4;
|
|
1167
|
+
readonly BlocksView: 8;
|
|
1168
|
+
readonly Ramp: 16;
|
|
1169
|
+
};
|
|
1170
|
+
/**
|
|
1171
|
+
* A megatile's ground height as the game takes it, from its 16 minitiles (the CV5 height
|
|
1172
|
+
* bits are not read): high when at least 12 are high, else mid when high and mid together
|
|
1173
|
+
* are at least 12, else low.
|
|
1174
|
+
*/
|
|
1175
|
+
export declare function megatileHeight(tileset: Tileset, megatile: number): 0 | 1 | 2;
|
|
999
1176
|
/** StarCraft tileset reference data. */
|
|
1000
1177
|
export type TilesetId = "badlands" | "platform" | "install" | "ashworld" | "jungle" | "desert" | "ice" | "twilight";
|
|
1001
1178
|
/**
|
|
@@ -1099,6 +1276,122 @@ export declare function mapStatistics(scn: Scenario, tileset: Tileset | null, te
|
|
|
1099
1276
|
export declare function statisticsText(s: MapStatistics): string;
|
|
1100
1277
|
/** Every built-in dialog, by the id `openDialogAtom` takes; `DialogHost` maps each to its component. */
|
|
1101
1278
|
export type DialogId = "newMap" | "openMap" | "saveAs" | "exportImage" | "mapProperties" | "resizeMap" | "mapRevision" | "playerSettings" | "forceSettings" | "playerColors" | "unitSettings" | "upgradeSettings" | "techSettings" | "stringEditor" | "soundEditor" | "switches" | "locationList" | "unitProperties" | "locationProperties" | "spriteProperties" | "triggerEditor" | "missionBriefing" | "cuwpEditor" | "replaceTerrain" | "autoStarts" | "testMap" | "symmetry" | "gridSettings" | "preferences" | "shortcuts" | "validateMap" | "statistics" | "importTriggers" | "exportTriggers" | "importStrings" | "exportStrings" | "find" | "about" | "confirmClose" | "recovery" | "previousVersions" | "plugins" | "confirmPlugin" | "pluginDialog" | "gameData" | "update" | "whatsNew";
|
|
1279
|
+
/**
|
|
1280
|
+
* The per-tileset tables StarEdit's isometric brush runs on.
|
|
1281
|
+
*
|
|
1282
|
+
* Nothing here can be read off the CV5: it is the numbering StarEdit compiled in, as
|
|
1283
|
+
* reverse-engineered for Chkdraft (src/mapping_core/sc.h, MIT, Justin Forsberg).
|
|
1284
|
+
* Upstream: https://github.com/TheNitesWhoSay/Chkdraft
|
|
1285
|
+
* Full provenance and license notice: ../../ATTRIBUTION.md
|
|
1286
|
+
*
|
|
1287
|
+
* Each
|
|
1288
|
+
* tileset has one row per CV5 terrain type (the `index` field of a tile group):
|
|
1289
|
+
*
|
|
1290
|
+
* - `isomValue` — what the ISOM section stores (shifted left 4) for a diamond of that
|
|
1291
|
+
* type, and the row of the shape-link table the type starts at. Flat terrains
|
|
1292
|
+
* ("solid brushes") take one row; each cliff/edge set takes fourteen (one per shape).
|
|
1293
|
+
* - `linkId` — the identity neighbours are compared by; unrelated to `isomValue`.
|
|
1294
|
+
* - `brush` — position in StarEdit's palette, or -1 for types it does not offer.
|
|
1295
|
+
*
|
|
1296
|
+
* Row 0's `isomValue` is where the shape rows begin. Rows above the half-way point are
|
|
1297
|
+
* edge sets; their `isomValue` is the first of their fourteen shape rows.
|
|
1298
|
+
*
|
|
1299
|
+
* `terrainTypeMap` is the compressed adjacency list: "type A, then the types a search
|
|
1300
|
+
* for a neighbour of A starts at, 0" repeated, ending in 0. See editor/isom.ts.
|
|
1301
|
+
*/
|
|
1302
|
+
export interface IsomTerrainType {
|
|
1303
|
+
/** CV5 group `index`. */
|
|
1304
|
+
index: number;
|
|
1305
|
+
isomValue: number;
|
|
1306
|
+
linkId: number;
|
|
1307
|
+
brush: number;
|
|
1308
|
+
}
|
|
1309
|
+
export interface TileChange {
|
|
1310
|
+
/** Flat index into `scenario.tiles`. */
|
|
1311
|
+
at: number;
|
|
1312
|
+
before: number;
|
|
1313
|
+
after: number;
|
|
1314
|
+
/**
|
|
1315
|
+
* What `scenario.editorTiles` (TILE) held before a terrain change, when that differs
|
|
1316
|
+
* from `before` (the cell was under a doodad). Filled in by `applyChanges` the first
|
|
1317
|
+
* time a change is applied, so undo can put the ground back rather than the doodad tile.
|
|
1318
|
+
*/
|
|
1319
|
+
under?: number;
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Apply a change list, or take it back. Terrain edits (`layer` "terrain") write MTXM and
|
|
1323
|
+
* TILE alike, remembering what TILE held in `under` on first application; doodad edits
|
|
1324
|
+
* ("mtxm") touch only MTXM's contents, leaving TILE as the ground beneath.
|
|
1325
|
+
*/
|
|
1326
|
+
export declare function applyChanges(scn: Scenario, changes: readonly TileChange[], direction?: "do" | "undo", layer?: "terrain" | "mtxm"): void;
|
|
1327
|
+
export interface Links {
|
|
1328
|
+
left: number;
|
|
1329
|
+
top: number;
|
|
1330
|
+
right: number;
|
|
1331
|
+
bottom: number;
|
|
1332
|
+
}
|
|
1333
|
+
/** One quadrant of a shape-link row: the two links on its rect sides, and its identity. */
|
|
1334
|
+
export interface QuadLinks extends Links {
|
|
1335
|
+
linkId: number;
|
|
1336
|
+
}
|
|
1337
|
+
export interface ShapeLinks {
|
|
1338
|
+
/** CV5 `index` of the terrain or edge set this row belongs to; 0 for padding rows. */
|
|
1339
|
+
terrainType: number;
|
|
1340
|
+
quads: [
|
|
1341
|
+
QuadLinks,
|
|
1342
|
+
QuadLinks,
|
|
1343
|
+
QuadLinks,
|
|
1344
|
+
QuadLinks
|
|
1345
|
+
];
|
|
1346
|
+
}
|
|
1347
|
+
export interface IsomTables {
|
|
1348
|
+
era: number;
|
|
1349
|
+
links: ShapeLinks[];
|
|
1350
|
+
terrainTypes: readonly IsomTerrainType[];
|
|
1351
|
+
/** `[a * n + b]`: the terrain to try first when `b` must sit next to `a`. */
|
|
1352
|
+
terrainTypeMap: Uint16Array;
|
|
1353
|
+
/** Link hash of a left-hand CV5 group → the even group indices carrying it. */
|
|
1354
|
+
hashToGroups: Map<number, number[]>;
|
|
1355
|
+
}
|
|
1356
|
+
/** The brush tables for a tileset's graphics, built once per loaded tileset. */
|
|
1357
|
+
export declare function isomTables(tileset: Tileset, era: number): IsomTables;
|
|
1358
|
+
export interface Diamond {
|
|
1359
|
+
x: number;
|
|
1360
|
+
y: number;
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* The diamond under a map pixel — StarEdit's own arithmetic. Diamond (x, y) is centred
|
|
1364
|
+
* on pixel (64x, 32y) and spans 128x64. The result can be off the map; check bounds.
|
|
1365
|
+
*/
|
|
1366
|
+
export declare function diamondAt(px: number, py: number): Diamond;
|
|
1367
|
+
export interface IsomEdit {
|
|
1368
|
+
tiles: TileChange[];
|
|
1369
|
+
/** Changes to `scenario.isom`, indexed by u16. */
|
|
1370
|
+
isom: TileChange[];
|
|
1371
|
+
}
|
|
1372
|
+
/** True when the scenario carries an ISOM section the brush can work on. */
|
|
1373
|
+
export declare function hasIsom(scn: Scenario | null): scn is Scenario & {
|
|
1374
|
+
isom: Uint16Array;
|
|
1375
|
+
};
|
|
1376
|
+
/**
|
|
1377
|
+
* Paint `terrainType` (a CV5 index) with an `extent`-diamond brush centred on `d`.
|
|
1378
|
+
* Mutates `scn.tiles` and `scn.isom`; returns what changed, or null when the terrain is
|
|
1379
|
+
* not one the tileset paints isometrically or `d` is not a diamond.
|
|
1380
|
+
*/
|
|
1381
|
+
export declare function paintIsom(scn: Scenario & {
|
|
1382
|
+
isom: Uint16Array;
|
|
1383
|
+
}, tileset: Tileset, d: Diamond, terrainType: number, extent: number, random?: () => number): IsomEdit | null;
|
|
1384
|
+
/**
|
|
1385
|
+
* Paint `terrainType` (a CV5 index) over any set of diamonds in one stroke: each is set to
|
|
1386
|
+
* the terrain, the neighbours they leave are re-picked as `paintIsom` re-picks the edge of
|
|
1387
|
+
* its brush, and the tiles follow. What `scmjs map generate` lays its ground with, a whole
|
|
1388
|
+
* plateau or lake at a time, so the result does not depend on the order of the diamonds.
|
|
1389
|
+
* Diamonds off the lattice or off the map are skipped; null when the terrain is not one
|
|
1390
|
+
* the tileset paints isometrically.
|
|
1391
|
+
*/
|
|
1392
|
+
export declare function paintIsomDiamonds(scn: Scenario & {
|
|
1393
|
+
isom: Uint16Array;
|
|
1394
|
+
}, tileset: Tileset, diamonds: readonly Diamond[], terrainType: number, random?: () => number): IsomEdit | null;
|
|
1102
1395
|
export interface IsomCheck {
|
|
1103
1396
|
/** Rects that have tiles under them. */
|
|
1104
1397
|
rects: number;
|
|
@@ -1122,6 +1415,10 @@ export interface IsomReport extends IsomCheck {
|
|
|
1122
1415
|
/** A rebuild would bring more than `STALE_ISOM_SHARE` of the rects back in step. */
|
|
1123
1416
|
stale: boolean;
|
|
1124
1417
|
}
|
|
1418
|
+
/** How well the ISOM section describes the tiles that are actually on the map. */
|
|
1419
|
+
export declare function checkIsom(scn: Scenario & {
|
|
1420
|
+
isom: Uint16Array;
|
|
1421
|
+
}, tileset: Tileset): IsomCheck;
|
|
1125
1422
|
/**
|
|
1126
1423
|
* What `useIsomStatus` measured for the open map — whether it can be painted
|
|
1127
1424
|
* isometrically and how well its lattice describes its tiles. Check Map reads it.
|
|
@@ -1319,6 +1616,8 @@ export declare function summarizeTrigger(t: ReadonlyTrigger, names: TriggerNames
|
|
|
1319
1616
|
conditions: string;
|
|
1320
1617
|
actions: string;
|
|
1321
1618
|
};
|
|
1619
|
+
/** Text of the trigger's Comment action, if it has one. */
|
|
1620
|
+
export declare function triggerComment(t: ReadonlyTrigger, names: TriggerNames): string | null;
|
|
1322
1621
|
/**
|
|
1323
1622
|
* A `TriggerNames` over the scenario. `intern` appends to the string table (marking it
|
|
1324
1623
|
* dirty), so parsing text into a scenario changes it even before the triggers are applied;
|
|
@@ -1574,6 +1873,36 @@ export declare function updateUnits(scn: Scenario, indices: readonly number[], p
|
|
|
1574
1873
|
* to the map.
|
|
1575
1874
|
*/
|
|
1576
1875
|
export declare function moveUnits(scn: Scenario, units: UnitsDat | null, indices: readonly number[], dx: number, dy: number, snap?: boolean): UnitChange[];
|
|
1876
|
+
export type SymmetryMode = "none" | "h" | "v" | "hv" | "rot180" | "rot90" | "diag" | "adiag";
|
|
1877
|
+
export interface Point {
|
|
1878
|
+
x: number;
|
|
1879
|
+
y: number;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* One image of a mode, as a map from a point to its image over a continuous plane `w` by
|
|
1883
|
+
* `h` (pixels or tiles, whichever the caller measures in), with the same map's linear part
|
|
1884
|
+
* — how a movement turns — and which element of the mode's group it is. The elements are
|
|
1885
|
+
* numbered so that `mirroredOwner` can hand each image a player consistently: for the
|
|
1886
|
+
* reflections 1 is the one flip (and in "hv" 2 is the other, 3 both), for the quarter turn
|
|
1887
|
+
* 1, 2 and 3 are the turns clockwise.
|
|
1888
|
+
*/
|
|
1889
|
+
export interface SymmetryImage {
|
|
1890
|
+
element: number;
|
|
1891
|
+
map(x: number, y: number): Point;
|
|
1892
|
+
linear(dx: number, dy: number): Point;
|
|
1893
|
+
}
|
|
1894
|
+
/** The images of `mode` other than the identity; modes that turn the plane need it square and answer nothing otherwise. */
|
|
1895
|
+
export declare function symmetryImages(mode: SymmetryMode, w: number, h: number): SymmetryImage[];
|
|
1896
|
+
/**
|
|
1897
|
+
* The player an image of something `owner` placed belongs to, when Symmetry hands each
|
|
1898
|
+
* copy its own player. The eight players go in groups of as many as the mode has images —
|
|
1899
|
+
* P1–P2, P3–P4, … for the two-way modes, P1–P4 and P5–P8 for the four-way ones — and the
|
|
1900
|
+
* copy takes the player in the same group the image's element leads to, so whichever
|
|
1901
|
+
* player you place for, each corner keeps its own: under "hv" P1 top-left gives P2
|
|
1902
|
+
* top-right, P3 bottom-left and P4 bottom-right, and placing for P3 bottom-left gives the
|
|
1903
|
+
* same four. Neutral and the rescuable players (9–12) are left alone.
|
|
1904
|
+
*/
|
|
1905
|
+
export declare function mirroredOwner(mode: SymmetryMode, owner: number, element: number): number;
|
|
1577
1906
|
/**
|
|
1578
1907
|
* Something on the map, for finding its mirror images among the others: its centre in
|
|
1579
1908
|
* pixels and what it is (a unit type, a doodad, a box's size). Moving and deleting under
|
|
@@ -1717,6 +2046,27 @@ export interface SoundRow {
|
|
|
1717
2046
|
}
|
|
1718
2047
|
/** The table's filled slots, in slot order. */
|
|
1719
2048
|
export declare function soundList(scn: Scenario, extras: Extras, wavs?: readonly number[]): SoundRow[];
|
|
2049
|
+
export interface WavInfo {
|
|
2050
|
+
/** The `fmt ` tag; for WAVE_FORMAT_EXTENSIBLE the sub-format's tag (its GUID's first field). */
|
|
2051
|
+
format: number;
|
|
2052
|
+
channels: number;
|
|
2053
|
+
sampleRate: number;
|
|
2054
|
+
bitsPerSample: number;
|
|
2055
|
+
/** Byte length of the `data` chunk, clipped to the file. */
|
|
2056
|
+
dataLength: number;
|
|
2057
|
+
/** Offset of the first sample byte. */
|
|
2058
|
+
dataOffset: number;
|
|
2059
|
+
/** Bytes per frame (PCM) or per block (ADPCM), from the header. */
|
|
2060
|
+
blockAlign: number;
|
|
2061
|
+
/** The `fmt ` chunk's bytes past the 16 common ones (ADPCM's block parameters and coefficients). */
|
|
2062
|
+
extra: Uint8Array;
|
|
2063
|
+
}
|
|
2064
|
+
/** Duration in seconds, from the header — no decoding needed. */
|
|
2065
|
+
export declare function wavDuration(info: WavInfo): number;
|
|
2066
|
+
/** A short label: `22050 Hz · 16-bit · mono`, with the codec named when it is not plain PCM. */
|
|
2067
|
+
export declare function wavFormatLabel(info: WavInfo): string;
|
|
2068
|
+
/** Reads the header of a RIFF/WAVE file; null when the bytes are not one. */
|
|
2069
|
+
export declare function parseWavHeader(bytes: Uint8Array): WavInfo | null;
|
|
1720
2070
|
export interface BaseTerrain {
|
|
1721
2071
|
/** CV5 group `index`, which is also the ISOM terrain id. */
|
|
1722
2072
|
id: number;
|
|
@@ -1813,6 +2163,104 @@ export declare function idealStarts(width: number, height: number, players: numb
|
|
|
1813
2163
|
* ones placed before it, so they never overlap each other.
|
|
1814
2164
|
*/
|
|
1815
2165
|
export declare function placeStartLocations(scn: Scenario, tileset: Tileset | null, tables: UnitsDat | null, options: StartPlacementOptions): StartPlacementResult;
|
|
2166
|
+
export interface DoodadDef {
|
|
2167
|
+
/** The `dddata.bin` index, which DD2 records store. */
|
|
2168
|
+
id: number;
|
|
2169
|
+
/** First CV5 group; row `r` is group `group + r`, column `c` is slot `c`. */
|
|
2170
|
+
group: number;
|
|
2171
|
+
width: number;
|
|
2172
|
+
height: number;
|
|
2173
|
+
/** Palette category, from stat_txt.tbl; "Unlisted" for groups without a name. */
|
|
2174
|
+
category: string;
|
|
2175
|
+
/** The first group's CV5 flag word — copied onto the overlay's THG2 record, as StarEdit does. */
|
|
2176
|
+
flags: number;
|
|
2177
|
+
/** The sprite (or unit) drawn over the tiles, or null. */
|
|
2178
|
+
overlay: DoodadOverlay | null;
|
|
2179
|
+
/** MTXM id per cell, row-major; 0 where the doodad leaves the ground alone. */
|
|
2180
|
+
tiles: Uint16Array;
|
|
2181
|
+
/** CV5 group required under each cell, row-major; 0 = no requirement. */
|
|
2182
|
+
required: Uint16Array;
|
|
2183
|
+
/**
|
|
2184
|
+
* Whether any of its minitiles carries the VF4 ramp bit. StarEdit files ramps under the
|
|
2185
|
+
* cliff categories with no name of their own; this is the only way to tell them apart.
|
|
2186
|
+
*/
|
|
2187
|
+
ramp: boolean;
|
|
2188
|
+
}
|
|
2189
|
+
export interface DoodadOverlay {
|
|
2190
|
+
kind: "sprite" | "unit";
|
|
2191
|
+
/** sprites.dat or units.dat id. */
|
|
2192
|
+
id: number;
|
|
2193
|
+
flipped: boolean;
|
|
2194
|
+
}
|
|
2195
|
+
export interface DoodadCategory {
|
|
2196
|
+
name: string;
|
|
2197
|
+
doodads: DoodadDef[];
|
|
2198
|
+
}
|
|
2199
|
+
export interface DoodadCatalogue {
|
|
2200
|
+
doodads: DoodadDef[];
|
|
2201
|
+
byId: Map<number, DoodadDef>;
|
|
2202
|
+
/** In first-appearance order, the way StarEdit's category drop-down lists them; "Unlisted" last. */
|
|
2203
|
+
categories: DoodadCategory[];
|
|
2204
|
+
/** Whether dddata.bin was available; without it nothing is ever refused for its ground. */
|
|
2205
|
+
hasPlacementData: boolean;
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Read the doodads out of the CV5. `dddata` may be null (no requirements) and `names`
|
|
2209
|
+
* the decoded stat_txt.tbl or null (one anonymous category).
|
|
2210
|
+
*/
|
|
2211
|
+
export declare function buildDoodadCatalogue(tileset: Tileset, dddata: Uint8Array | null, names: readonly string[] | null): DoodadCatalogue;
|
|
2212
|
+
export interface SpriteChange {
|
|
2213
|
+
index: number;
|
|
2214
|
+
before: SpriteRecord | null;
|
|
2215
|
+
after: SpriteRecord | null;
|
|
2216
|
+
}
|
|
2217
|
+
export interface DoodadChange {
|
|
2218
|
+
index: number;
|
|
2219
|
+
before: DoodadRecord | null;
|
|
2220
|
+
after: DoodadRecord | null;
|
|
2221
|
+
}
|
|
2222
|
+
/** Everything one doodad edit changes; each list undoes in reverse. */
|
|
2223
|
+
export interface DoodadEdit {
|
|
2224
|
+
/** MTXM-only tile changes (apply with `applyChanges(…, "mtxm")`). */
|
|
2225
|
+
tiles: TileChange[];
|
|
2226
|
+
doodads: DoodadChange[];
|
|
2227
|
+
sprites: SpriteChange[];
|
|
2228
|
+
}
|
|
2229
|
+
export declare function applyDoodadChanges(scn: Scenario, changes: readonly DoodadChange[], direction?: "do" | "undo"): void;
|
|
2230
|
+
export interface DoodadPlacementOptions {
|
|
2231
|
+
/** Skip StarEdit's ground check: any doodad goes on any terrain, even over another doodad. */
|
|
2232
|
+
placeAnywhere: boolean;
|
|
2233
|
+
/** Keep the left column on an even tile, as StarEdit always does. */
|
|
2234
|
+
snapToGrid: boolean;
|
|
2235
|
+
/** Place as plain terrain: the tiles (both sections) and any overlay sprite, no DD2 record — a placement and a conversion in one. */
|
|
2236
|
+
asTerrain: boolean;
|
|
2237
|
+
}
|
|
2238
|
+
export declare const DEFAULT_DOODAD_PLACEMENT: DoodadPlacementOptions;
|
|
2239
|
+
export interface DoodadVerdict {
|
|
2240
|
+
ok: boolean;
|
|
2241
|
+
/** The footprint leaves the map (never allowed). */
|
|
2242
|
+
outOfBounds: boolean;
|
|
2243
|
+
/** Cell indices (row-major) whose ground fails the check, for the ghost to mark red. */
|
|
2244
|
+
bad: number[];
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* May `def` go with its top-left tile at (tx, ty)? `tileAt` overrides what a cell
|
|
2248
|
+
* currently holds — a move passes the map as it would be with the moving doodads gone.
|
|
2249
|
+
*
|
|
2250
|
+
* A requirement counts only under a cell the doodad draws. Measured against Blizzard's
|
|
2251
|
+
* own maps (Ice Floes, Spring Thaw, Isolation): every ramp and bridge they placed sits
|
|
2252
|
+
* on ground that matches its drawn cells exactly and its undrawn "approach" cells not
|
|
2253
|
+
* at all — an Ice cliff ramp wants two more rows of cliff above it than any cliff has, a
|
|
2254
|
+
* Desert bridge wants dirt where its channel's water is — so StarEdit never looked at
|
|
2255
|
+
* those.
|
|
2256
|
+
*/
|
|
2257
|
+
export declare function checkDoodadPlacement(scn: Scenario, tileset: Tileset | null, def: DoodadDef, tx: number, ty: number, opts: DoodadPlacementOptions, tileAt?: (at: number) => number): DoodadVerdict;
|
|
2258
|
+
/**
|
|
2259
|
+
* Stamp `def` at (tx, ty): its tiles into MTXM, a DD2 record and, if it has one, the
|
|
2260
|
+
* overlay sprite. `tileAt` is what the cells hold right now (a move passes the state
|
|
2261
|
+
* with the old copy removed). Nothing is applied.
|
|
2262
|
+
*/
|
|
2263
|
+
export declare function placeDoodad(scn: Scenario, def: DoodadDef, tx: number, ty: number, owner: number, tileAt?: (at: number) => number): DoodadEdit;
|
|
1816
2264
|
/** OWNR controller bytes as StarEdit's Player Settings lists them, with the rest for maps that use them. */
|
|
1817
2265
|
export declare const PLAYER_TYPES: {
|
|
1818
2266
|
value: number;
|