@kingdomsconnected/types 1.5.2 → 1.5.3

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.
@@ -168,7 +168,7 @@ declare global {
168
168
  dialogueClosed: [session: number, player: Player, reason: number];
169
169
 
170
170
  /**
171
- * Dispatched once a deal has settled: everything in it has already moved. `balance` is what the player came out with in money units -- positive when the vendor paid them. What the player sold does not join the vendor's stock; add it with `setStock` here if this vendor resells.
171
+ * Dispatched once a deal has settled: everything in it has already moved, in one commit on the player's inventory whose playerInventoryChanged reason is `trade`. `balance` is what the player came out with in money units -- positive when the vendor paid them. What the player sold does not join the vendor's stock; add it with `setStock` here if this vendor resells.
172
172
  */
173
173
  vendorTrade: [vendor: number, player: Player, bought: VendorTradeLine[], sold: VendorTradeLine[], balance: number];
174
174
 
@@ -249,6 +249,31 @@ declare global {
249
249
  */
250
250
  propDestroy: [prop: Prop];
251
251
 
252
+ /**
253
+ * Dispatched immediately after a cart is created and replicated, whether by `Cart.spawn`, the `/cart` command, or anything else.
254
+ */
255
+ cartSpawn: [cart: Cart];
256
+
257
+ /**
258
+ * Dispatched while a cart is being despawned, after everyone in it has been let out. The handle still resolves, so its blueprint and its pose can be read one last time.
259
+ */
260
+ cartDestroy: [cart: Cart];
261
+
262
+ /**
263
+ * Dispatched before a player is put in a seat -- by their own use of the cart's prompt, or `putPlayer`. Return `false` from a handler and the seat is refused: nothing changes, and the player's game never climbs in. Handlers run synchronously.
264
+ */
265
+ cartEntering: [cart: Cart, player: Player, seat: string];
266
+
267
+ /**
268
+ * Dispatched after a player is given a seat. `seat` is `driver` or `back`; a driver's client runs the cart from here on.
269
+ */
270
+ cartEnter: [cart: Cart, player: Player | null, seat: string];
271
+
272
+ /**
273
+ * Dispatched after a player leaves a seat: their own climb down, `removePlayer`, a disconnect, or the cart being destroyed.
274
+ */
275
+ cartExit: [cart: Cart, player: Player | null, seat: string];
276
+
252
277
  /**
253
278
  * Dispatched immediately after a replicated particle effect is placed, whether by `Vfx.spawn`, a command, or anything else.
254
279
  */
@@ -355,11 +380,11 @@ declare global {
355
380
  gatheringHarvested: [player: Player, event: GatheringHarvestedEvent];
356
381
 
357
382
  /**
358
- * Dispatched when a player's client reports working a door, before the server applies it. `action` is `open`, `close`, `lock`, `unlock` or `lockpick`; a key turned in the same use as the push arrives as `unlock` and then `open`. `keySide` says whether the player stood on the side with the keyhole, which is where an unlock needs a key.
383
+ * Dispatched when a player's client reports working a door, before the server applies it. `action` is `open`, `close`, `unlock` or `lockpick`; a key turned in the same use as the push arrives as `unlock` and then `open`. `keySide` says whether the player stood on the side with the keyhole, which is where an unlock needs a key.
359
384
  *
360
385
  * Return false to refuse it: the door is put back on every client, the player's included, and nobody else sees it happen. Every handler runs whatever an earlier one returned, and an async handler cannot refuse. The server has already refused what the game's own rules forbid -- a player out of reach, a door the server locked, opening a locked door, picking a door with no keyhole -- so this only sees what the game would allow.
361
386
  */
362
- doorInteract: [player: Player, door: Door, action: "open" | "close" | "lock" | "unlock" | "lockpick", keySide: boolean];
387
+ doorInteract: [player: Player, door: Door, action: "open" | "close" | "unlock" | "lockpick", keySide: boolean];
363
388
 
364
389
  /**
365
390
  * A container now exists: one a script spawned, or one the level places, built in a virtual world the first time anything there asked for it. Every container starts empty; restore saved contents here with `setInventory`. The level's containers in the global world are built before any resource runs, so restore those from `resourceStart` by walking `Stash.all()`.
@@ -1540,7 +1565,7 @@ declare global {
1540
1565
  revision: number;
1541
1566
 
1542
1567
  /**
1543
- * `add`, `remove`, `properties`, `set`, `transfer`, `wear` when the player's game wore an item down in use, `use` for food, potions and ointments, `shot` for a fired round, `pickpocket`, `drop` for `player.dropInventory`, or the ground, stash and gathering reasons.
1568
+ * `add`, `remove`, `properties`, `set`, `transfer`, `wear` when the player's game wore an item down in use, `use` for food, potions and ointments, `shot` for a fired round, `pickpocket`, `trade` for a vendor deal, `drop` for `player.dropInventory`, or the ground, stash and gathering reasons.
1544
1569
  */
1545
1570
  reason: string;
1546
1571
 
@@ -1989,7 +2014,7 @@ declare global {
1989
2014
  create(options?: VendorOptions): number;
1990
2015
 
1991
2016
  /**
1992
- * Closes every session at the vendor and forgets it. A deal already settling still completes.
2017
+ * Closes every session at the vendor and forgets it. A deal settles the moment its basket arrives, so none is ever left half done.
1993
2018
  * @param vendor The vendor to remove.
1994
2019
  * @returns False when there was no such vendor.
1995
2020
  */
@@ -2697,6 +2722,124 @@ declare global {
2697
2722
 
2698
2723
  interface Prop extends Entity {}
2699
2724
 
2725
+ /**
2726
+ * Replicated cart or wagon handle.
2727
+ */
2728
+ class Cart {
2729
+ /**
2730
+ * Creates a script wrapper for an existing cart with this ID; use Cart.spawn() to spawn one.
2731
+ * @param id Network entity identifier.
2732
+ */
2733
+ constructor(id: number);
2734
+
2735
+ /**
2736
+ * The game prefab this cart was built from, e.g. `wagon_b_covered`. `Cart.blueprints()` lists them all.
2737
+ */
2738
+ readonly blueprint: string;
2739
+
2740
+ /**
2741
+ * How many horses the cart is harnessed for: 2 for a wagon, 1 for the two-wheeled cart, 0 for `wagon_b_covered_empty`, whose chassis has nowhere to hitch one and so can be sat in but never pulled.
2742
+ */
2743
+ readonly horseCount: number;
2744
+
2745
+ /**
2746
+ * The player at the reins, or null when nobody drives it.
2747
+ */
2748
+ readonly driver: Player | null;
2749
+
2750
+ /**
2751
+ * How the driver last asked the cart to go: `stand`, `walk`, `trot` or `reverse`.
2752
+ */
2753
+ readonly pace: string;
2754
+
2755
+ /**
2756
+ * Formats this cart handle for logging and debugging.
2757
+ * @returns The cart ID, its blueprint, its driver and its pace.
2758
+ */
2759
+ toString(): string;
2760
+
2761
+ /**
2762
+ * Despawns this cart on every client. Everyone in it is let out first, each with a `cartExit`, then `cartDestroy` is raised.
2763
+ */
2764
+ destroy(): void;
2765
+
2766
+ /**
2767
+ * Puts a player in a seat. They are taken out of any cart they were in, their own game walks them to the seat and climbs in, and `cartEnter` follows; the driver's client runs the cart from then on. `cartEntering` handlers are asked first.
2768
+ * @param player The player to seat.
2769
+ * @param seat `driver` (the bench, holding the reins) or `back` (the right rail): the two seats the game animates a player in.
2770
+ * @returns Whether the player was seated: false for a taken seat, a player that is not connected, or a handler's refusal.
2771
+ */
2772
+ putPlayer(player: Player, seat: string): boolean;
2773
+
2774
+ /**
2775
+ * Lets a player out of this cart: their own game climbs down, and `cartExit` is raised.
2776
+ * @param player The player to let out.
2777
+ * @returns False when the player is not in this cart.
2778
+ */
2779
+ removePlayer(player: Player): boolean;
2780
+
2781
+ /**
2782
+ * Who sits in a seat.
2783
+ * @param seat `driver` or `back`.
2784
+ * @returns The player in it, or null when it is empty.
2785
+ */
2786
+ getOccupant(seat: string): Player | null;
2787
+
2788
+ /**
2789
+ * Where a player sits in this cart.
2790
+ * @param player The player to look for.
2791
+ * @returns `driver` or `back`, or null when they are not in it.
2792
+ */
2793
+ seatOf(player: Player): string | null;
2794
+
2795
+ /**
2796
+ * Moves the cart outright, with everyone in it: every client rebuilds it on a new short road at the new pose, and a driver carries on from there.
2797
+ * @param position Where the cart's front axle stands.
2798
+ * @param rotation Which way it faces; omitted keeps its heading.
2799
+ * @returns False for a pose that is not finite.
2800
+ */
2801
+ teleport(position: Vector3, rotation?: Vector3 | Quaternion): boolean;
2802
+
2803
+ /**
2804
+ * Spawns and replicates a cart or wagon from the game's own prefabs, with its horses already in the shafts. It stands on a short straight road until somebody takes the reins.
2805
+ * @param blueprint Which of the game's cart prefabs to build; omitted builds `wagon_b_covered`. `Cart.blueprints()` lists them.
2806
+ * @param position Where the cart's front axle stands; omitted components default to zero.
2807
+ * @param rotation Which way it faces: a Quaternion, or a Vector3 of Euler angles in degrees.
2808
+ * @param virtualWorld Optional virtual world the cart belongs to; omitted puts it in the global one.
2809
+ * @returns The newly spawned cart handle.
2810
+ */
2811
+ static spawn(blueprint?: string, position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, virtualWorld?: number): Cart;
2812
+
2813
+ /**
2814
+ * Lists the carts the server has.
2815
+ * @param virtualWorld Optional virtual world to list; omitted lists every one.
2816
+ * @returns One handle per live cart, in no particular order.
2817
+ */
2818
+ static all(virtualWorld?: number): Cart[];
2819
+
2820
+ /**
2821
+ * Looks a cart up by its network entity ID.
2822
+ * @param id Network entity identifier.
2823
+ * @returns The cart's handle, or null when no live cart has that ID.
2824
+ */
2825
+ static getById(id: number): Cart | null;
2826
+
2827
+ /**
2828
+ * Despawns carts, emitting cartDestroy for each one.
2829
+ * @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
2830
+ * @returns How many carts were removed.
2831
+ */
2832
+ static destroyAll(virtualWorld?: number): number;
2833
+
2834
+ /**
2835
+ * Names every cart prefab `Cart.spawn` can build.
2836
+ * @returns The blueprint names, in catalog order.
2837
+ */
2838
+ static blueprints(): string[];
2839
+ }
2840
+
2841
+ interface Cart extends Entity {}
2842
+
2700
2843
  /**
2701
2844
  * Replicated particle effect handle.
2702
2845
  */
@@ -3388,30 +3531,44 @@ declare global {
3388
3531
  * @param objective The line, as text or as an object carrying its state.
3389
3532
  * @param announce Whether to raise the quest-updated toast; defaults to true.
3390
3533
  */
3391
- setObjective(index: number, objective: string | { text: string; progress?: 'active' | 'done' | 'failed'; optional?: boolean }, announce?: boolean): void;
3534
+ setObjective(index: number, objective: string | { text: string; progress?: 'active' | 'done' | 'failed'; optional?: boolean; position?: Vector3 }, announce?: boolean): void;
3392
3535
 
3393
3536
  /**
3394
3537
  * Replaces the quest's objective list.
3395
3538
  * @param objectives The whole list, at most eight entries; anything past that is dropped.
3396
3539
  * @param announce Whether to raise the quest-updated toast; defaults to true.
3397
3540
  */
3398
- setObjectives(objectives: (string | { text: string; progress?: 'active' | 'done' | 'failed'; optional?: boolean })[], announce?: boolean): void;
3541
+ setObjectives(objectives: (string | { text: string; progress?: 'active' | 'done' | 'failed'; optional?: boolean; position?: Vector3 })[], announce?: boolean): void;
3399
3542
 
3400
3543
  /**
3401
3544
  * Reads the quest's objectives back.
3402
- * @returns One entry per objective, in journal order.
3545
+ * @returns One entry per objective, in journal order. `position` is present only on an objective that has one.
3546
+ */
3547
+ objectives(): { text: string; progress: 'active' | 'done' | 'failed' | 'none'; optional: boolean; position?: Vector3 }[];
3548
+
3549
+ /**
3550
+ * Makes the game follow this quest, exactly as the journal's track button does: it is listed in the HUD tracker, and every active objective that has a `position` is drawn as the game's own quest marker on the map and the compass. It is an instruction, not a lock -- the player can untrack it from the journal -- and the outcome arrives as `questTrackingChanged` like any other change. A quest given a moment ago can be tracked at once; the client waits for it to arrive.
3551
+ * @param player Network id of the player who should follow the quest. Omitted, everyone who has the quest follows it: its one owner, or every player in its world.
3552
+ * @returns How many clients were told. Zero when the player does not have this quest.
3553
+ */
3554
+ track(player?: number): number;
3555
+
3556
+ /**
3557
+ * Makes the game stop following this quest, which takes its markers off the map and the compass. The outcome arrives as `questTrackingChanged`.
3558
+ * @param player Network id of the player who should stop following the quest. Omitted, everyone who has the quest stops.
3559
+ * @returns How many clients were told.
3403
3560
  */
3404
- objectives(): { text: string; progress: 'active' | 'done' | 'failed' | 'none'; optional: boolean }[];
3561
+ untrack(player?: number): number;
3405
3562
 
3406
3563
  /**
3407
3564
  * Writes a quest into the game's own journal. It is a replicated entity, so a player who joins late, reloads or walks away still finds it in their log -- which is what a quest needs and what a one-shot notification cannot do. What the player sees is the game's quest UI: its journal row, its diary page, its objective tracker and its quest-updated toast, all reading a quest node the client builds with the game's own constructor.
3408
3565
  * @param key What the quest is filed under: up to 64 letters, digits, underscores or dashes, unique within its virtual world.
3409
3566
  * @param title The line the journal row shows.
3410
- * @param options `description` is the diary page, `type` the journal section, `objectives` the lines under it, `player` the network id of the one player it belongs to, and `announce` whether to raise the toast.
3567
+ * @param options `description` is the diary page, `type` the journal section, `objectives` the lines under it -- each with an optional world `position` the game marks on the map and compass while the quest is followed -- `player` the network id of the one player it belongs to, `announce` whether to raise the toast, and `track` whether its recipients start following it.
3411
3568
  * @param virtualWorld Optional virtual world the quest belongs to; omitted puts it in the global one.
3412
3569
  * @returns The newly written quest handle.
3413
3570
  */
3414
- static give(key: string, title: string, options?: { description?: string; type?: 'main' | 'side' | 'activity' | 'event' | 'micro' | 'racing'; objectives?: (string | { text: string; progress?: 'active' | 'done' | 'failed'; optional?: boolean })[]; player?: number; announce?: boolean }, virtualWorld?: number): Quest;
3571
+ static give(key: string, title: string, options?: { description?: string; type?: 'main' | 'side' | 'activity' | 'event' | 'micro' | 'racing'; objectives?: (string | { text: string; progress?: 'active' | 'done' | 'failed'; optional?: boolean; position?: Vector3 })[]; player?: number; announce?: boolean; track?: boolean }, virtualWorld?: number): Quest;
3415
3572
 
3416
3573
  /**
3417
3574
  * Lists every replicated quest the server currently has.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingdomsconnected/types",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "TypeScript declarations for the Kingdoms Connected scripting API, one entry per side: @kingdomsconnected/types/server and @kingdomsconnected/types/client",
5
5
  "license": "UNLICENSED",
6
6
  "keywords": [