@scm-js/plugin-api 1.11.0 → 1.13.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 +37 -0
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1638,6 +1638,15 @@ export interface DoodadPlacementOptions {
1638
1638
  placeAnywhere: boolean;
1639
1639
  /** Keep the left column on an even tile, as StarEdit always does. */
1640
1640
  snapToGrid: boolean;
1641
+ /** Place as plain terrain: the tiles (both sections) and any overlay sprite, no DD2 record — a placement and a conversion in one. */
1642
+ asTerrain: boolean;
1643
+ }
1644
+ export interface DoodadVerdict {
1645
+ ok: boolean;
1646
+ /** The footprint leaves the map (never allowed). */
1647
+ outOfBounds: boolean;
1648
+ /** Cell indices (row-major) whose ground fails the check, for the ghost to mark red. */
1649
+ bad: number[];
1641
1650
  }
1642
1651
  export type StartLayout = "ring" | "corners";
1643
1652
  export interface StartPlacementResult {
@@ -2337,6 +2346,13 @@ export interface EditTransaction {
2337
2346
  /** Stamp a doodad (a `dddata.bin` id) at a tile; returns its record index, or -1 when unknown or off the map. */
2338
2347
  placeDoodad(doodadId: number, tx: number, ty: number, owner?: number): number;
2339
2348
  removeDoodads(indices: number[]): number;
2349
+ /**
2350
+ * Make doodads plain terrain: their records go, their tiles stay (in TILE as well as
2351
+ * MTXM, so the cells are ground to every tool from here on) and an overlay stays as an
2352
+ * ordinary sprite. The way to touch up a ramp or a cliff piece tile by tile.
2353
+ * Returns records converted.
2354
+ */
2355
+ convertDoodads(indices: number[]): number;
2340
2356
  /** A location in the lowest free slot (pixel bounds); returns the slot, or -1 when the table is full. */
2341
2357
  addLocation(bounds: Bounds, name?: string, elevationFlags?: number): number;
2342
2358
  editLocation(index: number, patch: LocationPatch): boolean;
@@ -2733,6 +2749,14 @@ export interface QueryApi {
2733
2749
  startLocations(): StartLocation[];
2734
2750
  /** Whether a unit type may be placed centred there, and what stops it; null with no map. */
2735
2751
  placement(unitId: number, x: number, y: number): PlacementVerdict | null;
2752
+ /**
2753
+ * StarEdit's ground check for a doodad with its top-left tile at (tx, ty): `ok`, or the
2754
+ * cells (row-major) whose ground is not what `DoodadInfo.required` asks for. It reads the
2755
+ * map as it is right now — inside a `document.edit` that is the map with the transaction's
2756
+ * earlier changes in — so a plugin can paint a cliff and then look for where a ramp fits.
2757
+ * Null with no map or without the tileset graphics.
2758
+ */
2759
+ doodadPlacement(doodadId: number, tx: number, ty: number): DoodadVerdict | null;
2736
2760
  /** The MASK bits at a tile: bit n set = player n + 1 starts fogged there (every bit when the map has no MASK). */
2737
2761
  fogAt(tx: number, ty: number): number;
2738
2762
  /** The string table as it stands (index 0 is nothing); empty with no map. */
@@ -3385,6 +3409,19 @@ export interface DoodadInfo {
3385
3409
  /** Footprint in tiles. */
3386
3410
  width: number;
3387
3411
  height: number;
3412
+ /**
3413
+ * A ramp: a doodad with the VF4 ramp bit, filed under a cliff category with no name of
3414
+ * its own. Ramps fit only on the cliff shape they were drawn for (see `required`), and
3415
+ * a tileset has them for a few terrain pairs only.
3416
+ */
3417
+ ramp: boolean;
3418
+ /**
3419
+ * Per cell (row-major, `width` × `height`): the CV5 tile group that must already lie
3420
+ * under it for StarEdit to allow the placement, or 0 for "anything". A flat terrain's
3421
+ * pair is its `TerrainType.group` (even) and `group + 1`; the other numbers are cliff
3422
+ * and shore pieces. `query.doodadPlacement` applies the rule.
3423
+ */
3424
+ required: number[];
3388
3425
  }
3389
3426
  export interface PaletteApi {
3390
3427
  active(): PaletteChoice;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",