@scm-js/plugin-api 1.37.0 → 1.38.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.
Files changed (2) hide show
  1. package/index.d.ts +119 -1
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1327,6 +1327,80 @@ export interface TextTrigger {
1327
1327
  /** 1-based line the `Trigger(` header starts on. */
1328
1328
  line: number;
1329
1329
  }
1330
+ /** Every kind of thing a condition or action can refer to. */
1331
+ export type TriggerRefKind =
1332
+ /** A switch; `id` is its 0-based number. */
1333
+ "switch"
1334
+ /** A death counter; `id` is the unit id, `players` the slots whose cell it is. */
1335
+ | "deaths"
1336
+ /** A death counter out of range — an EUD read or write; `address` is the dword it reaches, `id` the unit value as written. */
1337
+ | "memory"
1338
+ /** A location; `id` is its 0-based slot (63 is Anywhere). */
1339
+ | "location"
1340
+ /** The countdown timer; `id` is 0. */
1341
+ | "timer"
1342
+ /** A player's ore or gas; `id` is the `ResourceType`. */
1343
+ | "resources"
1344
+ /** A player's score; `id` is the `ScoreType`. */
1345
+ | "score"
1346
+ /** Units of a type; `id` is the unit id (a class id for *Any unit*, *Men*, …). */
1347
+ | "units"
1348
+ /** Victory, Defeat or Draw; `id` is the action type, `players` the trigger's owners. */
1349
+ | "outcome"
1350
+ /** A string of the map's string table; `id` is the 1-based string index. */
1351
+ | "string"
1352
+ /** A sound; `id` is the string index of its file name. */
1353
+ | "wav"
1354
+ /** A Run AI Script code (four characters as a little-endian u32). */
1355
+ | "aiScript"
1356
+ /** A Create Unit with Properties slot, 0-based. */
1357
+ | "cuwp";
1358
+ /**
1359
+ * `read`: a condition tests it. `write`: an action changes it. `use`: an action names it
1360
+ * without changing it — the location units appear at, the text a message shows.
1361
+ */
1362
+ export type TriggerRefAccess = "read" | "write" | "use";
1363
+ export interface TriggerRef {
1364
+ kind: TriggerRefKind;
1365
+ access: TriggerRefAccess;
1366
+ /** Whether a condition or an action refers to it. */
1367
+ part: "condition" | "action";
1368
+ /** The condition's or action's position in the trigger. */
1369
+ slot: number;
1370
+ /** The condition or action type. */
1371
+ type: number;
1372
+ id: number;
1373
+ /**
1374
+ * The 0-based player slots it is about, for the kinds that belong to a player
1375
+ * (`deaths`, `resources`, `score`, `units`, `outcome`); empty for the rest, and for a
1376
+ * condition such as *Command the Most* that compares every player.
1377
+ */
1378
+ players: number[];
1379
+ /** The player group as the record stores it, where the record has one. */
1380
+ group?: number;
1381
+ /**
1382
+ * The group resolves only while the game runs (*Foes*, *Allies*, *Neutral Players*,
1383
+ * *Non Allied Victory Players*), so `players` is every slot it could name.
1384
+ */
1385
+ approximate?: boolean;
1386
+ /** `memory`: the address reached (rounded down to a dword). */
1387
+ address?: number;
1388
+ /** `memory`: the bits a masked record reaches (its `location` field), when the record is masked. */
1389
+ mask?: number;
1390
+ /** The condition or action is switched off (its Disabled flag); the game skips it. */
1391
+ disabled?: boolean;
1392
+ }
1393
+ export interface TriggerRefs {
1394
+ /** The trigger's index in the list. */
1395
+ index: number;
1396
+ /** The 0-based slots the trigger runs for. */
1397
+ owners: number[];
1398
+ /** The player groups ticked in the trigger, as stored. */
1399
+ groups: number[];
1400
+ /** Set by the Disabled flag, or no player owns it: the game never runs it. */
1401
+ inert: boolean;
1402
+ refs: TriggerRef[];
1403
+ }
1330
1404
  export type IssueLevel = "error" | "warn" | "info";
1331
1405
  export type IssueTarget = {
1332
1406
  kind: "location";
@@ -3161,6 +3235,39 @@ export interface TriggersApi {
3161
3235
  ][];
3162
3236
  switches: number[];
3163
3237
  };
3238
+ /**
3239
+ * What each trigger reads, writes and names — TRIG when `list` is omitted, one entry per
3240
+ * trigger in list order. A condition *reads* (a switch, a death counter, the timer, a
3241
+ * player's ore, units at a location); an action *writes* (Set Switch, Set Deaths, Create
3242
+ * Unit, Move Location's target, Victory) or *uses* something without changing it (the
3243
+ * location units appear at, the text a message shows, a sound). Player groups are
3244
+ * resolved to slots against the map's forces, *Current Player* as the trigger's owners;
3245
+ * a Deaths record past the counters is a `memory` reference with its address.
3246
+ *
3247
+ * What a plugin needs to draw how triggers depend on each other, find a switch that is
3248
+ * set and never tested, or answer "which triggers can end the game". With `briefing`,
3249
+ * MBRF, where only strings and sounds are referred to.
3250
+ *
3251
+ * @example
3252
+ * // Switches something tests that nothing ever sets.
3253
+ * const refs = api.triggers.references().flatMap((t) => t.refs).filter((r) => r.kind === "switch");
3254
+ * const set = new Set(refs.filter((r) => r.access === "write").map((r) => r.id));
3255
+ * const never = [...new Set(refs.filter((r) => r.access === "read" && !set.has(r.id)).map((r) => r.id))];
3256
+ */
3257
+ references(list?: TriggerRecord[], options?: {
3258
+ briefing?: boolean;
3259
+ }): TriggerRefs[];
3260
+ /**
3261
+ * The 0-based player slots a player group names on the open map: a slot itself, the
3262
+ * members of a force, players 1–8 for *All Players*, and for *Current Player* the slots
3263
+ * of `owners` (the groups a trigger is ticked for). `approximate` when the group is only
3264
+ * settled while the game runs (*Foes*, *Allies*, *Neutral Players*, *Non Allied Victory
3265
+ * Players*); `players` is then every slot it could name.
3266
+ */
3267
+ resolvePlayers(group: number, owners?: number[]): {
3268
+ players: number[];
3269
+ approximate: boolean;
3270
+ };
3164
3271
  /**
3165
3272
  * Tell the editor that a run of the trigger list is generated by this plugin. The
3166
3273
  * Trigger Editor badges those rows, locks them and offers the plugin's own editor in
@@ -3289,6 +3396,12 @@ export type GoTo = {
3289
3396
  } | {
3290
3397
  kind: "location";
3291
3398
  index: number;
3399
+ }
3400
+ /** Opens the Trigger Editor (or, with `briefing`, the Mission Briefing) on that trigger. */
3401
+ | {
3402
+ kind: "trigger";
3403
+ index: number;
3404
+ briefing?: boolean;
3292
3405
  };
3293
3406
  /**
3294
3407
  * The map view: where the viewport is looking, how far in, and what it draws over the
@@ -4287,7 +4400,12 @@ export interface MapButtonHandle {
4287
4400
  * not yet applied to the map — so a slot's button can fill it in and leave OK to them.
4288
4401
  *
4289
4402
  * - `mapProperties`: `name`, `description`.
4290
- * - `triggerEditor`, `stringEditor`, `playerSettings`, `missionBriefing`: no fields, a slot only.
4403
+ * - `triggerEditor`, `missionBriefing`: `selected`, the selected row's index in the list
4404
+ * as text (`""` for none). Setting it selects that row. The index is into the dialog's
4405
+ * working copy, which matches `triggers.list()` until the person inserts or removes rows.
4406
+ * And `modified`, `"1"` while that working copy has changes not yet applied (read only):
4407
+ * `close()` discards them, so ask before closing when it is set.
4408
+ * - `stringEditor`, `playerSettings`: no fields, a slot only.
4291
4409
  *
4292
4410
  * A plugin's own dialog can offer a slot too (`DialogSpec.slot`), under an id of its
4293
4411
  * choosing — `"trigedit.text"` is the Text Trigger Editor's, lending `text` with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.37.0",
3
+ "version": "1.38.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",