@scm-js/core 0.10.0 → 0.12.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 +119 -1
- package/dist/index.mjs +623 -4
- 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.12.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';
|
|
@@ -72,6 +72,8 @@ export interface TextEncodingInfo {
|
|
|
72
72
|
}
|
|
73
73
|
export declare const TEXT_ENCODINGS: readonly TextEncodingInfo[];
|
|
74
74
|
export declare const DEFAULT_TEXT_ENCODING: TextEncoding;
|
|
75
|
+
/** Bytes to text; a sequence the encoding does not define becomes U+FFFD rather than failing. */
|
|
76
|
+
export declare function decodeText(bytes: Uint8Array, encoding: TextEncoding): string;
|
|
75
77
|
/**
|
|
76
78
|
* STR/STRx string table.
|
|
77
79
|
*
|
|
@@ -112,6 +114,16 @@ export interface UnitRecord {
|
|
|
112
114
|
unused: number;
|
|
113
115
|
relatedSerial: number;
|
|
114
116
|
}
|
|
117
|
+
/** `validStates` bits (offset 0x0E): which of the fields below are set ("properties used"). */
|
|
118
|
+
export declare const UnitUsed: {
|
|
119
|
+
readonly Owner: 1;
|
|
120
|
+
readonly HitPoints: 2;
|
|
121
|
+
readonly Shields: 4;
|
|
122
|
+
readonly Energy: 8;
|
|
123
|
+
readonly Resources: 16;
|
|
124
|
+
readonly Hangar: 32;
|
|
125
|
+
readonly State: 64;
|
|
126
|
+
};
|
|
115
127
|
export interface SpriteRecord {
|
|
116
128
|
/** sprites.dat id for a pure sprite, units.dat id for a unit sprite (see `SpriteFlag.PureSprite`). */
|
|
117
129
|
spriteId: number;
|
|
@@ -148,6 +160,11 @@ export interface LocationRecord {
|
|
|
148
160
|
/** Bit 0 low ground, 1 medium, 2 high, 3 low air, 4 medium air, 5 high air. */
|
|
149
161
|
elevationFlags: number;
|
|
150
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* How many location slots a file of this revision has. The game takes `MRGN` only at
|
|
165
|
+
* exactly this size: 64 slots in a StarCraft 1.00 file (`VER` below 63), 255 from 63 up.
|
|
166
|
+
*/
|
|
167
|
+
export declare function locationSlots(fileVersion: number): number;
|
|
151
168
|
export declare const PLAYER_SLOTS = 12;
|
|
152
169
|
/** Forces only cover the eight playable slots. */
|
|
153
170
|
export declare const FORCE_SLOTS = 8;
|
|
@@ -237,6 +254,8 @@ export interface UnitSettings {
|
|
|
237
254
|
weaponDamage: Uint16Array;
|
|
238
255
|
weaponBonus: Uint16Array;
|
|
239
256
|
}
|
|
257
|
+
/** Every type on its dat defaults — what a map has before anyone opens Unit Settings. */
|
|
258
|
+
export declare function defaultUnitSettings(): UnitSettings;
|
|
240
259
|
/**
|
|
241
260
|
* Which players may build which unit types. Three tables, player-major (`puniIndex`):
|
|
242
261
|
* a per-player answer, the global default, and whether each player defers to it.
|
|
@@ -249,6 +268,8 @@ export interface UnitAvailability {
|
|
|
249
268
|
/** 1 = the player takes `defaultAvailable` for the type. */
|
|
250
269
|
playerUsesDefault: Uint8Array;
|
|
251
270
|
}
|
|
271
|
+
/** Everything buildable by everyone, every player on the default — StarEdit's starting point. */
|
|
272
|
+
export declare function defaultUnitAvailability(): UnitAvailability;
|
|
252
273
|
/**
|
|
253
274
|
* Research cost per upgrade: a base and a per-level factor for minerals, gas and time.
|
|
254
275
|
* Struct of arrays over 61 upgrades; the original sections only store the first 46.
|
|
@@ -264,6 +285,8 @@ export interface UpgradeSettings {
|
|
|
264
285
|
timeCost: Uint16Array;
|
|
265
286
|
timeFactor: Uint16Array;
|
|
266
287
|
}
|
|
288
|
+
/** Every upgrade on its upgrades.dat costs. */
|
|
289
|
+
export declare function defaultUpgradeSettings(): UpgradeSettings;
|
|
267
290
|
/**
|
|
268
291
|
* How far each player may research each upgrade and where they start. Player-major
|
|
269
292
|
* tables (`upgradeIndex`), a global default pair, and a per-player "use the default" flag.
|
|
@@ -275,6 +298,8 @@ export interface UpgradeRestrictions {
|
|
|
275
298
|
defaultStart: Uint8Array;
|
|
276
299
|
playerUsesDefault: Uint8Array;
|
|
277
300
|
}
|
|
301
|
+
/** Every player on the default, which caps each upgrade at its upgrades.dat level and starts it at 0. */
|
|
302
|
+
export declare function defaultUpgradeRestrictions(): UpgradeRestrictions;
|
|
278
303
|
export interface TechSettings {
|
|
279
304
|
/** 1 = the game uses techdata.dat for this ability. */
|
|
280
305
|
useDefault: Uint8Array;
|
|
@@ -284,6 +309,7 @@ export interface TechSettings {
|
|
|
284
309
|
researchTime: Uint16Array;
|
|
285
310
|
energyCost: Uint16Array;
|
|
286
311
|
}
|
|
312
|
+
export declare function defaultTechSettings(): TechSettings;
|
|
287
313
|
/** Whether each player may research each ability and whether they start with it. Same shape as `UpgradeRestrictions`. */
|
|
288
314
|
export interface TechRestrictions {
|
|
289
315
|
playerAvailable: Uint8Array;
|
|
@@ -292,6 +318,8 @@ export interface TechRestrictions {
|
|
|
292
318
|
defaultResearched: Uint8Array;
|
|
293
319
|
playerUsesDefault: Uint8Array;
|
|
294
320
|
}
|
|
321
|
+
/** Everything researchable by everyone, nothing pre-researched, every player on the default. */
|
|
322
|
+
export declare function defaultTechRestrictions(): TechRestrictions;
|
|
295
323
|
export interface CuwpSlot {
|
|
296
324
|
/** `CuwpValid` bits. */
|
|
297
325
|
validProperties: number;
|
|
@@ -657,6 +685,12 @@ export declare const techSettingsSections: (scn: Scenario) => ("TYPE" | "VER " |
|
|
|
657
685
|
/** PTEC and/or PTEx. */
|
|
658
686
|
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")[];
|
|
659
687
|
export declare function parseScenario(bytes: Uint8Array): Scenario;
|
|
688
|
+
/**
|
|
689
|
+
* Encode one modelled section from the live scenario state: the bytes a save would write for it,
|
|
690
|
+
* or null when the model has nothing to write (a section it does not model, or an optional one
|
|
691
|
+
* the file lacks).
|
|
692
|
+
*/
|
|
693
|
+
export declare function encodeSection(scn: Scenario, name: string): Uint8Array | null;
|
|
660
694
|
declare const MODELLED: readonly [
|
|
661
695
|
"TYPE",
|
|
662
696
|
"VER ",
|
|
@@ -733,6 +767,8 @@ export interface LoadedMap {
|
|
|
733
767
|
* custom sounds and graphics live alongside scenario.chk and are easy to lose.
|
|
734
768
|
*/
|
|
735
769
|
export declare function loadMap(bytes: Uint8Array): Promise<LoadedMap>;
|
|
770
|
+
/** What the block table says about a member, in the editor's terms. */
|
|
771
|
+
export declare function memberInfo(archive: Archive, name: string): MemberInfo | null;
|
|
736
772
|
/**
|
|
737
773
|
* The members of the opened archive the editor could not read by name — carried across a
|
|
738
774
|
* save exactly as stored, through mopaq's `addStored`, with the hash table they were found
|
|
@@ -1702,6 +1738,82 @@ export declare function applyStringImport(scn: Scenario, entries: readonly {
|
|
|
1702
1738
|
replaced: number;
|
|
1703
1739
|
added: number;
|
|
1704
1740
|
};
|
|
1741
|
+
/** Every kind of thing a condition or action can refer to. */
|
|
1742
|
+
export type TriggerRefKind =
|
|
1743
|
+
/** A switch; `id` is its 0-based number. */
|
|
1744
|
+
"switch"
|
|
1745
|
+
/** A death counter; `id` is the unit id, `players` the slots whose cell it is. */
|
|
1746
|
+
| "deaths"
|
|
1747
|
+
/** A death counter out of range — an EUD read or write; `address` is the dword it reaches, `id` the unit value as written. */
|
|
1748
|
+
| "memory"
|
|
1749
|
+
/** A location; `id` is its 0-based slot (63 is Anywhere). */
|
|
1750
|
+
| "location"
|
|
1751
|
+
/** The countdown timer; `id` is 0. */
|
|
1752
|
+
| "timer"
|
|
1753
|
+
/** A player's ore or gas; `id` is the `ResourceType`. */
|
|
1754
|
+
| "resources"
|
|
1755
|
+
/** A player's score; `id` is the `ScoreType`. */
|
|
1756
|
+
| "score"
|
|
1757
|
+
/** Units of a type; `id` is the unit id (a class id for *Any unit*, *Men*, …). */
|
|
1758
|
+
| "units"
|
|
1759
|
+
/** Victory, Defeat or Draw; `id` is the action type, `players` the trigger's owners. */
|
|
1760
|
+
| "outcome"
|
|
1761
|
+
/** A string of the map's string table; `id` is the 1-based string index. */
|
|
1762
|
+
| "string"
|
|
1763
|
+
/** A sound; `id` is the string index of its file name. */
|
|
1764
|
+
| "wav"
|
|
1765
|
+
/** A Run AI Script code (four characters as a little-endian u32). */
|
|
1766
|
+
| "aiScript"
|
|
1767
|
+
/** A Create Unit with Properties slot, 0-based. */
|
|
1768
|
+
| "cuwp";
|
|
1769
|
+
/**
|
|
1770
|
+
* `read`: a condition tests it. `write`: an action changes it. `use`: an action names it
|
|
1771
|
+
* without changing it — the location units appear at, the text a message shows.
|
|
1772
|
+
*/
|
|
1773
|
+
export type TriggerRefAccess = "read" | "write" | "use";
|
|
1774
|
+
export interface TriggerRef {
|
|
1775
|
+
kind: TriggerRefKind;
|
|
1776
|
+
access: TriggerRefAccess;
|
|
1777
|
+
/** Whether a condition or an action refers to it. */
|
|
1778
|
+
part: "condition" | "action";
|
|
1779
|
+
/** The condition's or action's position in the trigger. */
|
|
1780
|
+
slot: number;
|
|
1781
|
+
/** The condition or action type. */
|
|
1782
|
+
type: number;
|
|
1783
|
+
id: number;
|
|
1784
|
+
/**
|
|
1785
|
+
* The 0-based player slots it is about, for the kinds that belong to a player
|
|
1786
|
+
* (`deaths`, `resources`, `score`, `units`, `outcome`); empty for the rest, and for a
|
|
1787
|
+
* condition such as *Command the Most* that compares every player.
|
|
1788
|
+
*/
|
|
1789
|
+
players: number[];
|
|
1790
|
+
/** The player group as the record stores it, where the record has one. */
|
|
1791
|
+
group?: number;
|
|
1792
|
+
/**
|
|
1793
|
+
* The group resolves only while the game runs (*Foes*, *Allies*, *Neutral Players*,
|
|
1794
|
+
* *Non Allied Victory Players*), so `players` is every slot it could name.
|
|
1795
|
+
*/
|
|
1796
|
+
approximate?: boolean;
|
|
1797
|
+
/** `memory`: the address reached (rounded down to a dword). */
|
|
1798
|
+
address?: number;
|
|
1799
|
+
/** `memory`: the bits a masked record reaches (its `location` field), when the record is masked. */
|
|
1800
|
+
mask?: number;
|
|
1801
|
+
/** The condition or action is switched off (its Disabled flag); the game skips it. */
|
|
1802
|
+
disabled?: boolean;
|
|
1803
|
+
}
|
|
1804
|
+
export interface TriggerRefs {
|
|
1805
|
+
/** The trigger's index in the list. */
|
|
1806
|
+
index: number;
|
|
1807
|
+
/** The 0-based slots the trigger runs for. */
|
|
1808
|
+
owners: number[];
|
|
1809
|
+
/** The player groups ticked in the trigger, as stored. */
|
|
1810
|
+
groups: number[];
|
|
1811
|
+
/** Set by the Disabled flag, or no player owns it: the game never runs it. */
|
|
1812
|
+
inert: boolean;
|
|
1813
|
+
refs: TriggerRef[];
|
|
1814
|
+
}
|
|
1815
|
+
/** Every trigger's references, in list order. MBRF when `briefing`, where only strings and sounds mean anything. */
|
|
1816
|
+
export declare function triggerReferences(list: readonly ReadonlyTrigger[], forces: readonly (readonly number[])[], briefing?: boolean): TriggerRefs[];
|
|
1705
1817
|
export type StringUsageKind = "name" | "description" | "force" | "location" | "unit" | "switch" | "trigger" | "briefing" | "wav";
|
|
1706
1818
|
export interface StringUsage {
|
|
1707
1819
|
kind: StringUsageKind;
|
|
@@ -2044,8 +2156,11 @@ export interface SoundRow {
|
|
|
2044
2156
|
member: string | null;
|
|
2045
2157
|
usedBy: string[];
|
|
2046
2158
|
}
|
|
2159
|
+
export declare function readWavs(scn: Scenario): number[];
|
|
2047
2160
|
/** The table's filled slots, in slot order. */
|
|
2048
2161
|
export declare function soundList(scn: Scenario, extras: Extras, wavs?: readonly number[]): SoundRow[];
|
|
2162
|
+
/** Install an edited table, creating the section when the file had none. Marks WAV dirty only on a change. */
|
|
2163
|
+
export declare function applySounds(scn: Scenario, wavs: readonly number[]): boolean;
|
|
2049
2164
|
export interface WavInfo {
|
|
2050
2165
|
/** The `fmt ` tag; for WAVE_FORMAT_EXTENSIBLE the sub-format's tag (its GUID's first field). */
|
|
2051
2166
|
format: number;
|
|
@@ -2306,6 +2421,9 @@ export declare const UPGRADE_NAMES: readonly string[];
|
|
|
2306
2421
|
export declare const TECH_NAMES: readonly string[];
|
|
2307
2422
|
export declare const upgradeName: (id: number) => string;
|
|
2308
2423
|
export declare const techName: (id: number) => string;
|
|
2424
|
+
/** weapons.dat ids → StarEdit's names (stat_txt.tbl order), for the Unit Settings weapon rows. */
|
|
2425
|
+
export declare const WEAPON_NAMES: readonly string[];
|
|
2426
|
+
export declare function weaponName(id: number): string;
|
|
2309
2427
|
/**
|
|
2310
2428
|
* The version a host provides; a manifest that asks for a newer one is refused. It stays
|
|
2311
2429
|
* at 1 while the API is only used by the plugins in the scm-js organisation and grows
|
package/dist/index.mjs
CHANGED
|
@@ -3325,7 +3325,11 @@ function parseScenario(bytes) {
|
|
|
3325
3325
|
if (chk.sections.some((s) => s.name === "MRGN" && s.data.length !== locationSlots(fileVersion) * 20)) markDirty(scn, "MRGN");
|
|
3326
3326
|
return scn;
|
|
3327
3327
|
}
|
|
3328
|
-
/**
|
|
3328
|
+
/**
|
|
3329
|
+
* Encode one modelled section from the live scenario state: the bytes a save would write for it,
|
|
3330
|
+
* or null when the model has nothing to write (a section it does not model, or an optional one
|
|
3331
|
+
* the file lacks).
|
|
3332
|
+
*/
|
|
3329
3333
|
function encodeSection(scn, name) {
|
|
3330
3334
|
switch (name) {
|
|
3331
3335
|
case "DIM ": {
|
|
@@ -4701,6 +4705,13 @@ function choiceValue(kind, text) {
|
|
|
4701
4705
|
if (c.aliases?.some((al) => al.toLowerCase() === key)) return c.value;
|
|
4702
4706
|
}
|
|
4703
4707
|
}
|
|
4708
|
+
/** Encode a four-character script code the way the action stores it (little-endian u32). */
|
|
4709
|
+
/**
|
|
4710
|
+
* Where the deaths table starts in StarCraft 1.16.1's memory: `EPD(address)` is the player
|
|
4711
|
+
* value that reaches `address` through a Deaths condition or Set Deaths action (the
|
|
4712
|
+
* Classic editor's EPD box, and the trigger script's `Memory` / `SetMemory`).
|
|
4713
|
+
*/
|
|
4714
|
+
var DEATHS_TABLE_ADDRESS = 5808996;
|
|
4704
4715
|
function aiScriptCode(id) {
|
|
4705
4716
|
if (id.length !== 4) throw new Error(`AI script codes are four characters: "${id}"`);
|
|
4706
4717
|
return (id.charCodeAt(0) | id.charCodeAt(1) << 8 | id.charCodeAt(2) << 16 | id.charCodeAt(3) << 24) >>> 0;
|
|
@@ -5033,6 +5044,10 @@ var UNIT_NAMES = [
|
|
|
5033
5044
|
var UNIT_TYPE_COUNT = UNIT_NAMES.length;
|
|
5034
5045
|
var START_LOCATION = 214;
|
|
5035
5046
|
var loadedNames = null;
|
|
5047
|
+
/** The names currently in front of the tables, or null when the data's are the game's own or nothing is loaded. */
|
|
5048
|
+
function currentLoadedNames() {
|
|
5049
|
+
return loadedNames;
|
|
5050
|
+
}
|
|
5036
5051
|
/** A unit type's display name: the loaded data's where it differs from the game's own, else StarEdit's. */
|
|
5037
5052
|
function unitName(id) {
|
|
5038
5053
|
return loadedNames?.units[id] ?? UNIT_NAMES[id] ?? `Unit #${id}`;
|
|
@@ -6166,6 +6181,144 @@ function displayColorHex(colors, rgb, owner) {
|
|
|
6166
6181
|
return custom ? rgbToHex(custom) : playerColorHex(colors, owner);
|
|
6167
6182
|
}
|
|
6168
6183
|
//#endregion
|
|
6184
|
+
//#region src/data/weapons.ts
|
|
6185
|
+
/** weapons.dat ids → StarEdit's names (stat_txt.tbl order), for the Unit Settings weapon rows. */
|
|
6186
|
+
var WEAPON_NAMES = [
|
|
6187
|
+
"Gauss Rifle",
|
|
6188
|
+
"Gauss Rifle (Jim Raynor)",
|
|
6189
|
+
"C-10 Canister Rifle",
|
|
6190
|
+
"C-10 Canister Rifle (Sarah Kerrigan)",
|
|
6191
|
+
"Fragmentation Grenade",
|
|
6192
|
+
"Fragmentation Grenade (Jim Raynor)",
|
|
6193
|
+
"Spider Mines",
|
|
6194
|
+
"Twin Autocannons",
|
|
6195
|
+
"Hellfire Missile Pack",
|
|
6196
|
+
"Twin Autocannons (Alan Schezar)",
|
|
6197
|
+
"Hellfire Missile Pack (Alan Schezar)",
|
|
6198
|
+
"Arclite Cannon",
|
|
6199
|
+
"Arclite Cannon (Edmund Duke)",
|
|
6200
|
+
"Fusion Cutter",
|
|
6201
|
+
"Fusion Cutter (Harvest)",
|
|
6202
|
+
"Gemini Missiles",
|
|
6203
|
+
"Burst Lasers",
|
|
6204
|
+
"Gemini Missiles (Tom Kazansky)",
|
|
6205
|
+
"Burst Lasers (Tom Kazansky)",
|
|
6206
|
+
"ATS Laser Battery",
|
|
6207
|
+
"ATA Laser Battery",
|
|
6208
|
+
"ATS Laser Battery (Hero)",
|
|
6209
|
+
"ATA Laser Battery (Hero)",
|
|
6210
|
+
"ATS Laser Battery (Hyperion)",
|
|
6211
|
+
"ATA Laser Battery (Hyperion)",
|
|
6212
|
+
"Flame Thrower",
|
|
6213
|
+
"Flame Thrower (Gui Montag)",
|
|
6214
|
+
"Arclite Shock Cannon",
|
|
6215
|
+
"Arclite Shock Cannon (Edmund Duke)",
|
|
6216
|
+
"Longbolt Missile",
|
|
6217
|
+
"Yamato Gun",
|
|
6218
|
+
"Nuclear Strike",
|
|
6219
|
+
"Lockdown",
|
|
6220
|
+
"EMP Shockwave",
|
|
6221
|
+
"Irradiate",
|
|
6222
|
+
"Claws",
|
|
6223
|
+
"Claws (Devouring One)",
|
|
6224
|
+
"Claws (Infested Kerrigan)",
|
|
6225
|
+
"Needle Spines",
|
|
6226
|
+
"Needle Spines (Hunter Killer)",
|
|
6227
|
+
"Kaiser Blades",
|
|
6228
|
+
"Kaiser Blades (Torrasque)",
|
|
6229
|
+
"Toxic Spores (Broodling)",
|
|
6230
|
+
"Spines",
|
|
6231
|
+
"Spines (Harvest)",
|
|
6232
|
+
"Acid Spray (Unused)",
|
|
6233
|
+
"Acid Spore",
|
|
6234
|
+
"Acid Spore (Kukulza)",
|
|
6235
|
+
"Glave Wurm",
|
|
6236
|
+
"Glave Wurm (Kukulza)",
|
|
6237
|
+
"Venom (Unused)",
|
|
6238
|
+
"Venom (Unused, Hero)",
|
|
6239
|
+
"Seeker Spores",
|
|
6240
|
+
"Subterranean Tentacle",
|
|
6241
|
+
"Suicide (Infested Terran)",
|
|
6242
|
+
"Suicide (Scourge)",
|
|
6243
|
+
"Parasite",
|
|
6244
|
+
"Spawn Broodlings",
|
|
6245
|
+
"Ensnare",
|
|
6246
|
+
"Dark Swarm",
|
|
6247
|
+
"Plague",
|
|
6248
|
+
"Consume",
|
|
6249
|
+
"Particle Beam",
|
|
6250
|
+
"Particle Beam (Harvest)",
|
|
6251
|
+
"Psi Blades",
|
|
6252
|
+
"Psi Blades (Fenix)",
|
|
6253
|
+
"Phase Disruptor",
|
|
6254
|
+
"Phase Disruptor (Fenix)",
|
|
6255
|
+
"Psi Assault (Unused)",
|
|
6256
|
+
"Psi Assault (Tassadar/Aldaris)",
|
|
6257
|
+
"Psionic Shockwave",
|
|
6258
|
+
"Psionic Shockwave (Tassadar/Zeratul Archon)",
|
|
6259
|
+
"Unknown 72",
|
|
6260
|
+
"Dual Photon Blasters",
|
|
6261
|
+
"Anti-Matter Missiles",
|
|
6262
|
+
"Dual Photon Blasters (Mojo)",
|
|
6263
|
+
"Anti-Matter Missiles (Mojo)",
|
|
6264
|
+
"Phase Disruptor Cannon",
|
|
6265
|
+
"Phase Disruptor Cannon (Danimoth)",
|
|
6266
|
+
"Pulse Cannon",
|
|
6267
|
+
"STS Photon Cannon",
|
|
6268
|
+
"STA Photon Cannon",
|
|
6269
|
+
"Scarab",
|
|
6270
|
+
"Stasis Field",
|
|
6271
|
+
"Psionic Storm",
|
|
6272
|
+
"Warp Blades (Zeratul)",
|
|
6273
|
+
"Warp Blades (Dark Templar Hero)",
|
|
6274
|
+
"Missiles (Unused)",
|
|
6275
|
+
"Laser Battery 1 (Unused)",
|
|
6276
|
+
"Tormentor Missiles (Unused)",
|
|
6277
|
+
"Bombs (Unused)",
|
|
6278
|
+
"Raider Gun (Unused)",
|
|
6279
|
+
"Laser Battery 2 (Unused)",
|
|
6280
|
+
"Laser Battery 3 (Unused)",
|
|
6281
|
+
"Dual Photon Blasters (Unused)",
|
|
6282
|
+
"Flechette Grenade (Unused)",
|
|
6283
|
+
"Twin Autocannons (Floor Trap)",
|
|
6284
|
+
"Hellfire Missile Pack (Wall Trap)",
|
|
6285
|
+
"Flame Thrower (Wall Trap)",
|
|
6286
|
+
"Hellfire Missile Pack (Floor Trap)",
|
|
6287
|
+
"Neutron Flare",
|
|
6288
|
+
"Disruption Web",
|
|
6289
|
+
"Restoration",
|
|
6290
|
+
"Halo Rockets",
|
|
6291
|
+
"Corrosive Acid",
|
|
6292
|
+
"Mind Control",
|
|
6293
|
+
"Feedback",
|
|
6294
|
+
"Optical Flare",
|
|
6295
|
+
"Maelstrom",
|
|
6296
|
+
"Subterranean Spines",
|
|
6297
|
+
"Gauss Rifle 0 (Unused)",
|
|
6298
|
+
"Warp Blades",
|
|
6299
|
+
"C-10 Canister Rifle (Samir Duran)",
|
|
6300
|
+
"C-10 Canister Rifle (Infested Duran)",
|
|
6301
|
+
"Dual Photon Blasters (Artanis)",
|
|
6302
|
+
"Anti-Matter Missiles (Artanis)",
|
|
6303
|
+
"C-10 Canister Rifle (Alexei Stukov)",
|
|
6304
|
+
"Gauss Rifle 1 (Unused)",
|
|
6305
|
+
"Unknown 118",
|
|
6306
|
+
"Unknown 119",
|
|
6307
|
+
"Unknown 120",
|
|
6308
|
+
"Unknown 121",
|
|
6309
|
+
"Unknown 122",
|
|
6310
|
+
"Unknown 123",
|
|
6311
|
+
"Unknown 124",
|
|
6312
|
+
"Unknown 125",
|
|
6313
|
+
"Unknown 126",
|
|
6314
|
+
"Unknown 127",
|
|
6315
|
+
"Unknown 128",
|
|
6316
|
+
"Unknown 129"
|
|
6317
|
+
];
|
|
6318
|
+
function weaponName(id) {
|
|
6319
|
+
return currentLoadedNames()?.weapons[id] ?? WEAPON_NAMES[id] ?? `Weapon #${id}`;
|
|
6320
|
+
}
|
|
6321
|
+
//#endregion
|
|
6169
6322
|
//#region src/editor/settings.ts
|
|
6170
6323
|
/**
|
|
6171
6324
|
* Scenario-wide settings the dialogs edit: players, forces, colours and unit settings.
|
|
@@ -6588,6 +6741,10 @@ function actionStrings(a, briefing = false) {
|
|
|
6588
6741
|
});
|
|
6589
6742
|
return out;
|
|
6590
6743
|
}
|
|
6744
|
+
/** The address a (player, unit) pair reaches through the deaths table: `table + player × 4 + unit × 48`. */
|
|
6745
|
+
function addressOfEpd(player, unit = 0) {
|
|
6746
|
+
return DEATHS_TABLE_ADDRESS + player * 4 + unit * 48 >>> 0;
|
|
6747
|
+
}
|
|
6591
6748
|
/**
|
|
6592
6749
|
* A content fingerprint of a trigger (FNV-1a over its numbers), the same wherever it
|
|
6593
6750
|
* sits in the list and whatever the game's bookkeeping bits say — what a plugin that
|
|
@@ -6979,6 +7136,12 @@ function formatBytes(n) {
|
|
|
6979
7136
|
}
|
|
6980
7137
|
//#endregion
|
|
6981
7138
|
//#region src/editor/sounds.ts
|
|
7139
|
+
/**
|
|
7140
|
+
* The Sound Editor's view of a map's sounds: the WAV table (`scn.wavs`, 512 string indices
|
|
7141
|
+
* of archive paths) joined with the archive members that actually hold the bytes
|
|
7142
|
+
* (`archiveExtrasAtom`). Play WAV / Transmission actions store the *string index*, so a
|
|
7143
|
+
* sound is "used" when a trigger's `wav` field equals its string.
|
|
7144
|
+
*/
|
|
6982
7145
|
/** Archive member names compare case-insensitively with either slash. */
|
|
6983
7146
|
function normalizeMember(name) {
|
|
6984
7147
|
return name.replace(/\//g, "\\").toLowerCase();
|
|
@@ -7023,6 +7186,9 @@ function referencedMembers(scn) {
|
|
|
7023
7186
|
MANIFEST_MEMBER
|
|
7024
7187
|
];
|
|
7025
7188
|
}
|
|
7189
|
+
function readWavs(scn) {
|
|
7190
|
+
return scn.wavs ? scn.wavs.slice() : defaultWavs();
|
|
7191
|
+
}
|
|
7026
7192
|
/** The table's filled slots, in slot order. */
|
|
7027
7193
|
function soundList(scn, extras, wavs = scn.wavs ?? []) {
|
|
7028
7194
|
const out = [];
|
|
@@ -7042,6 +7208,14 @@ function soundList(scn, extras, wavs = scn.wavs ?? []) {
|
|
|
7042
7208
|
});
|
|
7043
7209
|
return out;
|
|
7044
7210
|
}
|
|
7211
|
+
/** Install an edited table, creating the section when the file had none. Marks WAV dirty only on a change. */
|
|
7212
|
+
function applySounds(scn, wavs) {
|
|
7213
|
+
const next = Array.from({ length: 512 }, (_, i) => wavs[i] ?? 0);
|
|
7214
|
+
if (scn.wavs && scn.wavs.length === 512 && scn.wavs.every((v, i) => v === next[i])) return false;
|
|
7215
|
+
scn.wavs = next;
|
|
7216
|
+
markDirty(scn, "WAV ");
|
|
7217
|
+
return true;
|
|
7218
|
+
}
|
|
7045
7219
|
//#endregion
|
|
7046
7220
|
//#region src/editor/mapBuild.ts
|
|
7047
7221
|
/**
|
|
@@ -9934,6 +10108,450 @@ function applyStringImport(scn, entries) {
|
|
|
9934
10108
|
};
|
|
9935
10109
|
}
|
|
9936
10110
|
//#endregion
|
|
10111
|
+
//#region src/editor/triggerRefs.ts
|
|
10112
|
+
/**
|
|
10113
|
+
* What each trigger reads, writes and names: the switches, death counters, locations,
|
|
10114
|
+
* timer, resources, scores, units, strings, sounds, AI scripts and game endings its
|
|
10115
|
+
* conditions and actions touch, with the player groups resolved to slots.
|
|
10116
|
+
*
|
|
10117
|
+
* `triggerUsage` answers "which counters are taken" for a plugin allocating its own; this
|
|
10118
|
+
* answers "who talks to whom" — the graph a trigger map draws, a dead-switch check, a
|
|
10119
|
+
* "what leads to Victory" search. It reads only the records and the forces, so it is
|
|
10120
|
+
* pure and testable without a scenario.
|
|
10121
|
+
*/
|
|
10122
|
+
/** The value of a masked record's `mask` word (Remastered). */
|
|
10123
|
+
var MASKED_RECORD = 17235;
|
|
10124
|
+
var EIGHT = [
|
|
10125
|
+
0,
|
|
10126
|
+
1,
|
|
10127
|
+
2,
|
|
10128
|
+
3,
|
|
10129
|
+
4,
|
|
10130
|
+
5,
|
|
10131
|
+
6,
|
|
10132
|
+
7
|
|
10133
|
+
];
|
|
10134
|
+
var TWELVE = [
|
|
10135
|
+
...EIGHT,
|
|
10136
|
+
8,
|
|
10137
|
+
9,
|
|
10138
|
+
10,
|
|
10139
|
+
11
|
|
10140
|
+
];
|
|
10141
|
+
/**
|
|
10142
|
+
* The 0-based slots a player group names. `forces` holds each force's slots; `owners` are
|
|
10143
|
+
* the groups the trigger is ticked for, which *Current Player* stands for — only those the
|
|
10144
|
+
* game hands triggers to (Players 1–8, All Players, the forces). Groups past the 27 (EUD
|
|
10145
|
+
* values) name no slot.
|
|
10146
|
+
*/
|
|
10147
|
+
function resolvePlayers(group, owners, forces) {
|
|
10148
|
+
if (group < 0 || group >= 27) return {
|
|
10149
|
+
players: [],
|
|
10150
|
+
approximate: false
|
|
10151
|
+
};
|
|
10152
|
+
if (group < 12) return {
|
|
10153
|
+
players: [group],
|
|
10154
|
+
approximate: false
|
|
10155
|
+
};
|
|
10156
|
+
switch (group) {
|
|
10157
|
+
case PlayerGroup.CurrentPlayer: {
|
|
10158
|
+
const out = /* @__PURE__ */ new Set();
|
|
10159
|
+
let approximate = false;
|
|
10160
|
+
for (const o of owners) {
|
|
10161
|
+
if (!TRIGGER_OWNERS.has(o)) continue;
|
|
10162
|
+
const r = o === PlayerGroup.AllPlayers ? {
|
|
10163
|
+
players: EIGHT,
|
|
10164
|
+
approximate: false
|
|
10165
|
+
} : resolvePlayers(o, [], forces);
|
|
10166
|
+
r.players.forEach((p) => out.add(p));
|
|
10167
|
+
approximate ||= r.approximate;
|
|
10168
|
+
}
|
|
10169
|
+
return {
|
|
10170
|
+
players: [...out].sort((a, b) => a - b),
|
|
10171
|
+
approximate
|
|
10172
|
+
};
|
|
10173
|
+
}
|
|
10174
|
+
case PlayerGroup.AllPlayers: return {
|
|
10175
|
+
players: TWELVE.slice(),
|
|
10176
|
+
approximate: false
|
|
10177
|
+
};
|
|
10178
|
+
case PlayerGroup.Force1:
|
|
10179
|
+
case PlayerGroup.Force2:
|
|
10180
|
+
case PlayerGroup.Force3:
|
|
10181
|
+
case PlayerGroup.Force4: return {
|
|
10182
|
+
players: [...forces[group - PlayerGroup.Force1] ?? []].sort((a, b) => a - b),
|
|
10183
|
+
approximate: false
|
|
10184
|
+
};
|
|
10185
|
+
case PlayerGroup.Foes:
|
|
10186
|
+
case PlayerGroup.Allies:
|
|
10187
|
+
case PlayerGroup.NonAlliedVictoryPlayers: return {
|
|
10188
|
+
players: EIGHT.slice(),
|
|
10189
|
+
approximate: true
|
|
10190
|
+
};
|
|
10191
|
+
case PlayerGroup.NeutralPlayers: return {
|
|
10192
|
+
players: TWELVE.slice(),
|
|
10193
|
+
approximate: true
|
|
10194
|
+
};
|
|
10195
|
+
default: return {
|
|
10196
|
+
players: [],
|
|
10197
|
+
approximate: false
|
|
10198
|
+
};
|
|
10199
|
+
}
|
|
10200
|
+
}
|
|
10201
|
+
/** Every trigger's references, in list order. MBRF when `briefing`, where only strings and sounds mean anything. */
|
|
10202
|
+
function triggerReferences(list, forces, briefing = false) {
|
|
10203
|
+
return list.map((trigger, index) => {
|
|
10204
|
+
const groups = trigger.players.flatMap((on, i) => on ? [i] : []);
|
|
10205
|
+
const owners = resolvePlayers(PlayerGroup.CurrentPlayer, groups, forces).players;
|
|
10206
|
+
const refs = [];
|
|
10207
|
+
if (!briefing) trigger.conditions.forEach((c, slot) => conditionRefs(c, slot, groups, forces, refs));
|
|
10208
|
+
trigger.actions.forEach((a, slot) => actionRefs(a, slot, groups, owners, forces, briefing, refs));
|
|
10209
|
+
return {
|
|
10210
|
+
index,
|
|
10211
|
+
owners,
|
|
10212
|
+
groups,
|
|
10213
|
+
inert: (trigger.flags & TriggerFlag.Disabled) !== 0 || owners.length === 0,
|
|
10214
|
+
refs
|
|
10215
|
+
};
|
|
10216
|
+
});
|
|
10217
|
+
}
|
|
10218
|
+
function conditionRefs(c, slot, groups, forces, out) {
|
|
10219
|
+
if (c.type === ConditionType.None) return;
|
|
10220
|
+
const base = {
|
|
10221
|
+
part: "condition",
|
|
10222
|
+
slot,
|
|
10223
|
+
type: c.type,
|
|
10224
|
+
...(c.flags & ConditionFlag.Disabled) !== 0 ? { disabled: true } : {}
|
|
10225
|
+
};
|
|
10226
|
+
const who = () => withPlayers(c.player, groups, forces);
|
|
10227
|
+
switch (c.type) {
|
|
10228
|
+
case ConditionType.Switch:
|
|
10229
|
+
out.push({
|
|
10230
|
+
...base,
|
|
10231
|
+
kind: "switch",
|
|
10232
|
+
access: "read",
|
|
10233
|
+
id: c.resource,
|
|
10234
|
+
players: []
|
|
10235
|
+
});
|
|
10236
|
+
break;
|
|
10237
|
+
case ConditionType.Deaths:
|
|
10238
|
+
deathsRefs(base, "read", c.player, c.unitId, c.mask === MASKED_RECORD ? c.location : void 0, groups, forces, out);
|
|
10239
|
+
break;
|
|
10240
|
+
case ConditionType.CountdownTimer:
|
|
10241
|
+
out.push({
|
|
10242
|
+
...base,
|
|
10243
|
+
kind: "timer",
|
|
10244
|
+
access: "read",
|
|
10245
|
+
id: 0,
|
|
10246
|
+
players: []
|
|
10247
|
+
});
|
|
10248
|
+
break;
|
|
10249
|
+
case ConditionType.Accumulate:
|
|
10250
|
+
out.push({
|
|
10251
|
+
...base,
|
|
10252
|
+
kind: "resources",
|
|
10253
|
+
access: "read",
|
|
10254
|
+
id: c.resource,
|
|
10255
|
+
...who()
|
|
10256
|
+
});
|
|
10257
|
+
break;
|
|
10258
|
+
case ConditionType.MostResources:
|
|
10259
|
+
case ConditionType.LeastResources:
|
|
10260
|
+
out.push({
|
|
10261
|
+
...base,
|
|
10262
|
+
kind: "resources",
|
|
10263
|
+
access: "read",
|
|
10264
|
+
id: c.resource,
|
|
10265
|
+
players: []
|
|
10266
|
+
});
|
|
10267
|
+
break;
|
|
10268
|
+
case ConditionType.Score:
|
|
10269
|
+
out.push({
|
|
10270
|
+
...base,
|
|
10271
|
+
kind: "score",
|
|
10272
|
+
access: "read",
|
|
10273
|
+
id: c.resource,
|
|
10274
|
+
...who()
|
|
10275
|
+
});
|
|
10276
|
+
break;
|
|
10277
|
+
case ConditionType.HighestScore:
|
|
10278
|
+
case ConditionType.LowestScore:
|
|
10279
|
+
out.push({
|
|
10280
|
+
...base,
|
|
10281
|
+
kind: "score",
|
|
10282
|
+
access: "read",
|
|
10283
|
+
id: c.resource,
|
|
10284
|
+
players: []
|
|
10285
|
+
});
|
|
10286
|
+
break;
|
|
10287
|
+
case ConditionType.Bring:
|
|
10288
|
+
case ConditionType.Command:
|
|
10289
|
+
out.push({
|
|
10290
|
+
...base,
|
|
10291
|
+
kind: "units",
|
|
10292
|
+
access: "read",
|
|
10293
|
+
id: c.unitId,
|
|
10294
|
+
...who()
|
|
10295
|
+
});
|
|
10296
|
+
break;
|
|
10297
|
+
case ConditionType.CommandTheMost:
|
|
10298
|
+
case ConditionType.CommandTheMostAt:
|
|
10299
|
+
case ConditionType.CommandTheLeast:
|
|
10300
|
+
case ConditionType.CommandTheLeastAt: out.push({
|
|
10301
|
+
...base,
|
|
10302
|
+
kind: "units",
|
|
10303
|
+
access: "read",
|
|
10304
|
+
id: c.unitId,
|
|
10305
|
+
players: []
|
|
10306
|
+
});
|
|
10307
|
+
}
|
|
10308
|
+
for (const arg of conditionDef(c.type)?.args ?? []) if (arg.kind === "location" && c.location > 0) out.push({
|
|
10309
|
+
...base,
|
|
10310
|
+
kind: "location",
|
|
10311
|
+
access: "read",
|
|
10312
|
+
id: c.location - 1,
|
|
10313
|
+
players: []
|
|
10314
|
+
});
|
|
10315
|
+
}
|
|
10316
|
+
function actionRefs(a, slot, groups, owners, forces, briefing, out) {
|
|
10317
|
+
if (a.type === 0) return;
|
|
10318
|
+
const base = {
|
|
10319
|
+
part: "action",
|
|
10320
|
+
slot,
|
|
10321
|
+
type: a.type,
|
|
10322
|
+
...(a.flags & ActionFlag.Disabled) !== 0 ? { disabled: true } : {}
|
|
10323
|
+
};
|
|
10324
|
+
const def = actionDef(a.type, briefing);
|
|
10325
|
+
for (const arg of def?.args ?? []) {
|
|
10326
|
+
const value = a[arg.field];
|
|
10327
|
+
if (briefing && arg.kind !== "text" && arg.kind !== "wav") continue;
|
|
10328
|
+
switch (arg.kind) {
|
|
10329
|
+
case "text":
|
|
10330
|
+
if (value > 0) out.push({
|
|
10331
|
+
...base,
|
|
10332
|
+
kind: "string",
|
|
10333
|
+
access: "use",
|
|
10334
|
+
id: value,
|
|
10335
|
+
players: []
|
|
10336
|
+
});
|
|
10337
|
+
break;
|
|
10338
|
+
case "wav":
|
|
10339
|
+
if (value > 0) out.push({
|
|
10340
|
+
...base,
|
|
10341
|
+
kind: "wav",
|
|
10342
|
+
access: "use",
|
|
10343
|
+
id: value,
|
|
10344
|
+
players: []
|
|
10345
|
+
});
|
|
10346
|
+
break;
|
|
10347
|
+
case "aiScript":
|
|
10348
|
+
if (value !== 0) out.push({
|
|
10349
|
+
...base,
|
|
10350
|
+
kind: "aiScript",
|
|
10351
|
+
access: "use",
|
|
10352
|
+
id: value >>> 0,
|
|
10353
|
+
players: []
|
|
10354
|
+
});
|
|
10355
|
+
break;
|
|
10356
|
+
case "cuwp":
|
|
10357
|
+
out.push({
|
|
10358
|
+
...base,
|
|
10359
|
+
kind: "cuwp",
|
|
10360
|
+
access: "use",
|
|
10361
|
+
id: value,
|
|
10362
|
+
players: []
|
|
10363
|
+
});
|
|
10364
|
+
break;
|
|
10365
|
+
case "location": if (value > 0) out.push({
|
|
10366
|
+
...base,
|
|
10367
|
+
kind: "location",
|
|
10368
|
+
access: a.type === ActionType.MoveLocation && arg.field === "target" ? "write" : "use",
|
|
10369
|
+
id: value - 1,
|
|
10370
|
+
players: []
|
|
10371
|
+
});
|
|
10372
|
+
}
|
|
10373
|
+
}
|
|
10374
|
+
if (briefing) return;
|
|
10375
|
+
const who = (group = a.player) => withPlayers(group, groups, forces, EIGHT_ONLY.has(a.type));
|
|
10376
|
+
switch (a.type) {
|
|
10377
|
+
case ActionType.SetSwitch:
|
|
10378
|
+
out.push({
|
|
10379
|
+
...base,
|
|
10380
|
+
kind: "switch",
|
|
10381
|
+
access: "write",
|
|
10382
|
+
id: a.target,
|
|
10383
|
+
players: []
|
|
10384
|
+
});
|
|
10385
|
+
break;
|
|
10386
|
+
case ActionType.SetDeaths:
|
|
10387
|
+
deathsRefs(base, "write", a.player, a.unitId, a.mask === MASKED_RECORD ? a.location : void 0, groups, forces, out, true);
|
|
10388
|
+
break;
|
|
10389
|
+
case ActionType.SetCountdownTimer:
|
|
10390
|
+
case ActionType.PauseTimer:
|
|
10391
|
+
case ActionType.UnpauseTimer:
|
|
10392
|
+
out.push({
|
|
10393
|
+
...base,
|
|
10394
|
+
kind: "timer",
|
|
10395
|
+
access: "write",
|
|
10396
|
+
id: 0,
|
|
10397
|
+
players: []
|
|
10398
|
+
});
|
|
10399
|
+
break;
|
|
10400
|
+
case ActionType.SetResources:
|
|
10401
|
+
out.push({
|
|
10402
|
+
...base,
|
|
10403
|
+
kind: "resources",
|
|
10404
|
+
access: "write",
|
|
10405
|
+
id: a.unitId,
|
|
10406
|
+
...who()
|
|
10407
|
+
});
|
|
10408
|
+
break;
|
|
10409
|
+
case ActionType.SetScore:
|
|
10410
|
+
out.push({
|
|
10411
|
+
...base,
|
|
10412
|
+
kind: "score",
|
|
10413
|
+
access: "write",
|
|
10414
|
+
id: a.unitId,
|
|
10415
|
+
...who()
|
|
10416
|
+
});
|
|
10417
|
+
break;
|
|
10418
|
+
case ActionType.CreateUnit:
|
|
10419
|
+
case ActionType.CreateUnitWithProperties:
|
|
10420
|
+
case ActionType.KillUnit:
|
|
10421
|
+
case ActionType.KillUnitAt:
|
|
10422
|
+
case ActionType.RemoveUnit:
|
|
10423
|
+
case ActionType.RemoveUnitAt:
|
|
10424
|
+
case ActionType.MoveUnit:
|
|
10425
|
+
out.push({
|
|
10426
|
+
...base,
|
|
10427
|
+
kind: "units",
|
|
10428
|
+
access: "write",
|
|
10429
|
+
id: a.unitId,
|
|
10430
|
+
...who()
|
|
10431
|
+
});
|
|
10432
|
+
break;
|
|
10433
|
+
case ActionType.GiveUnits: {
|
|
10434
|
+
const from = who(), to = who(a.target);
|
|
10435
|
+
out.push({
|
|
10436
|
+
...base,
|
|
10437
|
+
kind: "units",
|
|
10438
|
+
access: "write",
|
|
10439
|
+
id: a.unitId,
|
|
10440
|
+
players: union(from.players, to.players),
|
|
10441
|
+
group: a.player,
|
|
10442
|
+
...from.approximate || to.approximate ? { approximate: true } : {}
|
|
10443
|
+
});
|
|
10444
|
+
break;
|
|
10445
|
+
}
|
|
10446
|
+
case ActionType.Order:
|
|
10447
|
+
case ActionType.ModifyHitPoints:
|
|
10448
|
+
case ActionType.ModifyEnergy:
|
|
10449
|
+
case ActionType.ModifyShields:
|
|
10450
|
+
case ActionType.ModifyHangarCount:
|
|
10451
|
+
case ActionType.SetInvincibility:
|
|
10452
|
+
case ActionType.SetDoodadState:
|
|
10453
|
+
case ActionType.MoveLocation:
|
|
10454
|
+
out.push({
|
|
10455
|
+
...base,
|
|
10456
|
+
kind: "units",
|
|
10457
|
+
access: "use",
|
|
10458
|
+
id: a.unitId,
|
|
10459
|
+
...who()
|
|
10460
|
+
});
|
|
10461
|
+
break;
|
|
10462
|
+
case ActionType.Victory:
|
|
10463
|
+
case ActionType.Defeat:
|
|
10464
|
+
case ActionType.Draw: out.push({
|
|
10465
|
+
...base,
|
|
10466
|
+
kind: "outcome",
|
|
10467
|
+
access: "write",
|
|
10468
|
+
id: a.type,
|
|
10469
|
+
players: owners.slice()
|
|
10470
|
+
});
|
|
10471
|
+
}
|
|
10472
|
+
}
|
|
10473
|
+
/** Actions that do nothing for Players 9–12, so All Players reaches only 1–8 through them. */
|
|
10474
|
+
var EIGHT_ONLY = /* @__PURE__ */ new Set([
|
|
10475
|
+
ActionType.CreateUnit,
|
|
10476
|
+
ActionType.CreateUnitWithProperties,
|
|
10477
|
+
ActionType.SetDeaths,
|
|
10478
|
+
ActionType.SetResources,
|
|
10479
|
+
ActionType.SetScore
|
|
10480
|
+
]);
|
|
10481
|
+
/** {@link resolvePlayers}, with All Players kept to 1–8 for the actions that refuse 9–12. */
|
|
10482
|
+
function groupPlayers(group, owners, forces, eightOnly) {
|
|
10483
|
+
return eightOnly && group === PlayerGroup.AllPlayers ? {
|
|
10484
|
+
players: EIGHT.slice(),
|
|
10485
|
+
approximate: false
|
|
10486
|
+
} : resolvePlayers(group, owners, forces);
|
|
10487
|
+
}
|
|
10488
|
+
/** `players` / `group` / `approximate` for a record's player group. */
|
|
10489
|
+
function withPlayers(group, owners, forces, eightOnly = false) {
|
|
10490
|
+
const r = groupPlayers(group, owners, forces, eightOnly);
|
|
10491
|
+
return {
|
|
10492
|
+
players: r.players,
|
|
10493
|
+
group,
|
|
10494
|
+
...r.approximate ? { approximate: true } : {}
|
|
10495
|
+
};
|
|
10496
|
+
}
|
|
10497
|
+
function union(a, b) {
|
|
10498
|
+
return [.../* @__PURE__ */ new Set([...a, ...b])].sort((x, y) => x - y);
|
|
10499
|
+
}
|
|
10500
|
+
/**
|
|
10501
|
+
* A Deaths condition or Set Deaths action: a counter when the player is a group or a slot
|
|
10502
|
+
* and the unit is a real unit, the sum the game computes for a unit class (which counts
|
|
10503
|
+
* as reading *units* of that class), and a memory address for everything else.
|
|
10504
|
+
*/
|
|
10505
|
+
function deathsRefs(base, access, player, unitId, mask, owners, forces, out, eightOnly = false) {
|
|
10506
|
+
const masked = mask !== void 0 ? { mask: mask >>> 0 } : {};
|
|
10507
|
+
const address = (slot) => addressOfEpd(slot, unitId);
|
|
10508
|
+
if (player >= 27) {
|
|
10509
|
+
out.push({
|
|
10510
|
+
...base,
|
|
10511
|
+
kind: "memory",
|
|
10512
|
+
access,
|
|
10513
|
+
id: unitId,
|
|
10514
|
+
players: [],
|
|
10515
|
+
group: player,
|
|
10516
|
+
address: address(player),
|
|
10517
|
+
...masked
|
|
10518
|
+
});
|
|
10519
|
+
return;
|
|
10520
|
+
}
|
|
10521
|
+
const r = groupPlayers(player, owners, forces, eightOnly);
|
|
10522
|
+
const approximate = r.approximate ? { approximate: true } : {};
|
|
10523
|
+
if (unitId < UNIT_TYPE_COUNT && mask === void 0) out.push({
|
|
10524
|
+
...base,
|
|
10525
|
+
kind: "deaths",
|
|
10526
|
+
access,
|
|
10527
|
+
id: unitId,
|
|
10528
|
+
players: r.players,
|
|
10529
|
+
group: player,
|
|
10530
|
+
...approximate
|
|
10531
|
+
});
|
|
10532
|
+
else if (unitId <= 232 && mask === void 0) {
|
|
10533
|
+
if (access === "read") out.push({
|
|
10534
|
+
...base,
|
|
10535
|
+
kind: "units",
|
|
10536
|
+
access,
|
|
10537
|
+
id: unitId,
|
|
10538
|
+
players: r.players,
|
|
10539
|
+
group: player,
|
|
10540
|
+
...approximate
|
|
10541
|
+
});
|
|
10542
|
+
} else for (const slot of r.players) out.push({
|
|
10543
|
+
...base,
|
|
10544
|
+
kind: "memory",
|
|
10545
|
+
access,
|
|
10546
|
+
id: unitId,
|
|
10547
|
+
players: [slot],
|
|
10548
|
+
group: player,
|
|
10549
|
+
address: address(slot),
|
|
10550
|
+
...approximate,
|
|
10551
|
+
...masked
|
|
10552
|
+
});
|
|
10553
|
+
}
|
|
10554
|
+
//#endregion
|
|
9937
10555
|
//#region src/editor/strings.ts
|
|
9938
10556
|
/**
|
|
9939
10557
|
* The string table as the String Editor sees it: where every entry is referenced, which
|
|
@@ -12575,8 +13193,9 @@ function rebuildIsomFromTiles(scn, tileset) {
|
|
|
12575
13193
|
/**
|
|
12576
13194
|
* Resize / crop the map in place.
|
|
12577
13195
|
*
|
|
12578
|
-
*
|
|
12579
|
-
* (`
|
|
13196
|
+
* A whole-map change: the caller (`resizeDocumentAtom`) records the map as it was as one
|
|
13197
|
+
* undo step (`WholeState`), so nothing here may write into the arrays it replaces — every
|
|
13198
|
+
* grid and list is built new. Existing content keeps its position relative
|
|
12580
13199
|
* to the chosen anchor: the offset `dx` is kept *even* so StarEdit's left/right tile
|
|
12581
13200
|
* pairs stay on their columns. Terrain outside the new bounds is cropped; units, sprites
|
|
12582
13201
|
* and doodads whose position falls outside are dropped (a doodad's tiles are already part
|
|
@@ -13249,4 +13868,4 @@ function canonicalSpec(source) {
|
|
|
13249
13868
|
return source.kind === "builtin" ? `builtin:${source.name}` : source.display;
|
|
13250
13869
|
}
|
|
13251
13870
|
//#endregion
|
|
13252
|
-
export { ACTION_DEFS, AI_SCRIPT_NAMES, ANYWHERE_NAME, ActionType, BRIEFING_ACTION_DEFS, BUILD_MANIFEST_MEMBER, BUILD_SOURCE_MEMBER, CHOICES, CONDITION_DEFS, ColorMode, Comparison, ConditionType, DEFAULT_DOODAD_PLACEMENT, DEFAULT_GAS, DEFAULT_MINERALS, DEFAULT_PLACEMENT, DEFAULT_SAVE_OPTIONS, DEFAULT_START_PLACEMENT, DEFAULT_TEXT_ENCODING, DIRT, FIND_KINDS, FORCE_SLOTS, ForceFlag, MAP_SIZES, MAP_VERSIONS, MEGATILE_PX, MINERAL_FIELD_IDS, MODELLED_SECTIONS, MapLoadError, PLAYER_COLORS, PLAYER_RACES, PLAYER_SLOTS, PLAYER_TYPES, PLUGIN_API_VERSION, PlayerGroup, PlayerRace, PlayerType, REQUIRED_SECTIONS, ResourceType, SAVE_PRESETS, SCENARIO_PATH, START_LOCATION, STRX_CAPACITY, SetModifier, SwitchAction, SwitchState, TECH_NAMES, TEXT_CODES, TEXT_ENCODINGS, TILESETS, TILESET_BY_ID, TRIGGER_OWNERS, TileFlag, TriggerTextError, UNIT_LIMIT, UNIT_NAMES, UNIT_TYPE_COUNT, UPGRADE_NAMES, UnitClass, VESPENE_GEYSER, actionDef, actionDefByName, addLocation, addUnits, aiScriptByName, aiScriptName, applyBriefing, applyChanges, applyDoodadChanges, applyForceSettings, applyLocationChanges, applyPlayerSettings, applyStringImport, applyStrings, applyTechSettings, applyTriggers, applyUnitChanges, applyUnitSettings, applyUpgradeSettings, baseTerrain, buildChk, buildDoodadCatalogue, buildMapFile, changeMapVersion, changeTextEncoding, checkDoodadPlacement, checkIsom, choiceLabel, choiceValue, conditionDef, conditionDefByName, createScenario, decodeTrg, decodeUnitsDat, defaultSaveOptions, deleteUnused, diamondAt, displayColorHex, drawMegatile, editLocation, encodeTrg, escapeStringText, extraKind, findInScenario, fingerprintTrigger, flatTerrain, forceName, formatBytes, formatOf, formatStringTable, formatTrigger, formatTriggers, groupBuildable, hasIsom, idealStarts, internString, isExpansion, isPreserved, isRemasteredRevision, isResource, isomTables, issueCounts, keptExtras, loadMap, loadTileset, locationCapacity, locationName, looksLikeMpq, makeUnit, mapStatistics, mapVersionOf, markDirty, megatileForTile, megatileHeight, mirroredOwner, moveLocations, moveUnits, newAction, newCondition, newTrigger, nextSerial, openMapBytes, packBuiltMap, paintIsom, paintIsomDiamonds, parseChk, parseScenario, parseStringTable, parseTriggers, parseWavHeader, placeDoodad, placeStartLocations, placedLocations, plainText, planSave, playableCount, playerColorHex, playerRaceLabel, playerTypeLabel, readArchive, readBriefing, readBuildManifest, readExtras, readForceSettings, readMembers, readPlayerSettings, readStrings, readSwitchNames, readTechSettings, readTriggerFile, readTriggers, readUnitSettings, readUpgradeSettings, removeLocations, removeUnits, requiredSections, resizeScenario, resolveIcon, restoreBuiltMap, runsOf, sameTriggers, scenarioDescription, scenarioName, serializeChk, serializeScenario, setExtendedStrings, setMapVersion, setPreserved, setScenarioDescription, setScenarioName, setTextEncoding, soundList, statisticsText, stringCapacity, stringUsages, summarizeTrigger, symmetryImages, techName, techRestrictionSections, techSettingsSections, textCode, tilesetIndex, triggerComment, triggerFormatOf, triggerNames, triggerUsage, triggersFromText, triggersToText, unescapeStringText, unitAt, unitCustomName, unitGeometry, unitName, unitSettingsSections, unitsInBox, unusedStrings, updateUnits, upgradeName, upgradeRestrictionSections, upgradeSettingsSections, usedLocations, validateManifest, validateScenario, wavDuration, wavFormatLabel, writeArchiveBytes, writeMapBytes };
|
|
13871
|
+
export { ACTION_DEFS, AI_SCRIPT_NAMES, ANYWHERE_NAME, ActionType, BRIEFING_ACTION_DEFS, BUILD_MANIFEST_MEMBER, BUILD_SOURCE_MEMBER, CHOICES, CONDITION_DEFS, ColorMode, Comparison, ConditionType, DEFAULT_DOODAD_PLACEMENT, DEFAULT_GAS, DEFAULT_MINERALS, DEFAULT_PLACEMENT, DEFAULT_SAVE_OPTIONS, DEFAULT_START_PLACEMENT, DEFAULT_TEXT_ENCODING, DIRT, FIND_KINDS, FORCE_SLOTS, ForceFlag, MAP_SIZES, MAP_VERSIONS, MEGATILE_PX, MINERAL_FIELD_IDS, MODELLED_SECTIONS, MapLoadError, PLAYER_COLORS, PLAYER_RACES, PLAYER_SLOTS, PLAYER_TYPES, PLUGIN_API_VERSION, PlayerGroup, PlayerRace, PlayerType, REQUIRED_SECTIONS, ResourceType, SAVE_PRESETS, SCENARIO_PATH, START_LOCATION, STRX_CAPACITY, SetModifier, SwitchAction, SwitchState, TECH_NAMES, TEXT_CODES, TEXT_ENCODINGS, TILESETS, TILESET_BY_ID, TRIGGER_OWNERS, TileFlag, TriggerTextError, UNIT_LIMIT, UNIT_NAMES, UNIT_TYPE_COUNT, UPGRADE_NAMES, UnitClass, UnitUsed, VESPENE_GEYSER, WEAPON_NAMES, actionDef, actionDefByName, addLocation, addUnits, aiScriptByName, aiScriptName, applyBriefing, applyChanges, applyDoodadChanges, applyForceSettings, applyLocationChanges, applyPlayerSettings, applySounds, applyStringImport, applyStrings, applyTechSettings, applyTriggers, applyUnitChanges, applyUnitSettings, applyUpgradeSettings, baseTerrain, buildChk, buildDoodadCatalogue, buildMapFile, changeMapVersion, changeTextEncoding, checkDoodadPlacement, checkIsom, choiceLabel, choiceValue, conditionDef, conditionDefByName, createScenario, decodeText, decodeTrg, decodeUnitsDat, defaultSaveOptions, defaultTechRestrictions, defaultTechSettings, defaultUnitAvailability, defaultUnitSettings, defaultUpgradeRestrictions, defaultUpgradeSettings, deleteUnused, diamondAt, displayColorHex, drawMegatile, editLocation, encodeSection, encodeTrg, escapeStringText, extraKind, findInScenario, fingerprintTrigger, flatTerrain, forceName, formatBytes, formatOf, formatStringTable, formatTrigger, formatTriggers, groupBuildable, hasIsom, idealStarts, internString, isExpansion, isPreserved, isRemasteredRevision, isResource, isomTables, issueCounts, keptExtras, loadMap, loadTileset, locationCapacity, locationName, locationSlots, looksLikeMpq, makeUnit, mapStatistics, mapVersionOf, markDirty, megatileForTile, megatileHeight, memberInfo, mirroredOwner, moveLocations, moveUnits, newAction, newCondition, newTrigger, nextSerial, openMapBytes, packBuiltMap, paintIsom, paintIsomDiamonds, parseChk, parseScenario, parseStringTable, parseTriggers, parseWavHeader, placeDoodad, placeStartLocations, placedLocations, plainText, planSave, playableCount, playerColorHex, playerRaceLabel, playerTypeLabel, readArchive, readBriefing, readBuildManifest, readExtras, readForceSettings, readMembers, readPlayerSettings, readStrings, readSwitchNames, readTechSettings, readTriggerFile, readTriggers, readUnitSettings, readUpgradeSettings, readWavs, removeLocations, removeUnits, requiredSections, resizeScenario, resolveIcon, restoreBuiltMap, runsOf, sameTriggers, scenarioDescription, scenarioName, serializeChk, serializeScenario, setExtendedStrings, setMapVersion, setPreserved, setScenarioDescription, setScenarioName, setTextEncoding, soundList, statisticsText, stringCapacity, stringUsages, summarizeTrigger, symmetryImages, techName, techRestrictionSections, techSettingsSections, textCode, tilesetIndex, triggerComment, triggerFormatOf, triggerNames, triggerReferences, triggerUsage, triggersFromText, triggersToText, unescapeStringText, unitAt, unitCustomName, unitGeometry, unitName, unitSettingsSections, unitsInBox, unusedStrings, updateUnits, upgradeName, upgradeRestrictionSections, upgradeSettingsSections, usedLocations, validateManifest, validateScenario, wavDuration, wavFormatLabel, weaponName, writeArchiveBytes, writeMapBytes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scm-js/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "StarCraft: Brood War maps in Node.js and the browser, as the scmJS editor reads and writes them: open .scm/.scx/.chk, triggers, strings, units, locations, settings, Check Map, and write the map back",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"starcraft",
|