@kingdomsconnected/types 1.5.7 → 1.6.1

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.
@@ -23,7 +23,7 @@ declare global {
23
23
  playerDied: [player: Player, killer: Player | null, reason: "unknown" | "combat" | "gunshot" | "starvation" | "collision" | "scripted" | "disintegrate" | "fall" | "poison" | "bleeding" | "selfHarm"];
24
24
 
25
25
  /**
26
- * Dispatched when something takes health off a player: a weapon, an arrow, a fall, a collision, a scripted hit. The hit player's own client reports it, because only it resolved the blow against its armour and its skills, so `amount` is what was really taken. It arrives ahead of the `playerDied` a killing blow causes.
26
+ * Dispatched when something takes health off a player: a weapon, an arrow, a fall, a collision, a scripted hit. Another player's blow is raised by the server as it rules on it, after `playerHit` had its say, so `amount` is what the ruling takes; anything else is reported by the hit player's own client, which resolved it against its armour and its skills. It arrives ahead of the `playerDied` a killing blow causes.
27
27
  *
28
28
  * `attacker` is the player who dealt it, or null. `bodyPart` is where it landed, or null for damage that lands nowhere in particular. The weapon is the attacker's own `rightHandItem` or `leftHandItem`.
29
29
  *
@@ -31,6 +31,23 @@ declare global {
31
31
  */
32
32
  playerDamage: [player: Player, attacker: Player | null, amount: number, bodyPart: "head" | "torso" | "leftArm" | "rightArm" | "leftLeg" | "rightLeg" | null, reason: "unknown" | "combat" | "gunshot" | "starvation" | "collision" | "scripted" | "disintegrate" | "fall" | "poison" | "bleeding" | "selfHarm"];
33
33
 
34
+ /**
35
+ * A melee swing aimed at another player was admitted by the server, including a miss. Raised once per attack generation, after presentation admission. Use it to track combat inactivity in your resource.
36
+ */
37
+ playerAttack: [player: Player, opponent: Player];
38
+
39
+ /**
40
+ * A resource called cancelCombat for this pair. Raised after the cancellation was sent to both players and their observers.
41
+ */
42
+ playerCombatCancelled: [first: Player, second: Player];
43
+
44
+ /**
45
+ * Dispatched when another player's blade or arrow lands on a player, before anything is taken -- the place for teams, safe zones, friendly fire and damage rules. The game resolved the blow against the guard the victim really held -- whether it was blocked, perfectly or not, and where it landed -- and the server works out what a swing takes from there; it has checked that the swing was one it relayed and could still land, or that the arrow was one whose impact it accepted, and that the two stood within reach. Only what is ruled here comes off the victim's health, on every client at once.
46
+ *
47
+ * Return `false` from a handler to refuse the blow: no health is taken and no `playerDamage` follows. Scale `hit.modifiers` to change how a swing is worked out -- a stronger attack, weaker armour -- or set `hit.damage` to say outright what it takes: `0` for a blow that lands harmlessly, more for a heavier one. Either way the blow is still seen and heard: the blades met. Handlers run synchronously, so the decision cannot wait on anything awaited.
48
+ */
49
+ playerHit: [player: Player, attacker: Player, hit: PlayerHit];
50
+
34
51
  /**
35
52
  * Dispatched when a limb becomes injured -- usually a blow landing there, sometimes a fall on both legs. `player.injuries` already says so. A limb hit again while injured stays injured and raises nothing new.
36
53
  */
@@ -74,6 +91,21 @@ declare global {
74
91
  */
75
92
  playerPutDown: [carrier: Player, carried: Player];
76
93
 
94
+ /**
95
+ * Dispatched when a player starts a carry of their own, before the server accepts it: they chose the game's pick-up prompt over a carryable `groundItem`, or took an item from one of the world's own piles (`groundItem` null). Return `false` from a handler and the carry is refused -- the prop stays where it is, and a pile's item is let go at once. Handlers run synchronously, so the decision cannot wait on anything awaited. A carry a script ordered with `carryItem` is not asked. `item` is the item's name.
96
+ */
97
+ playerCarryingItem: [player: Player, item: string, groundItem: GroundItem | null];
98
+
99
+ /**
100
+ * Dispatched once an item carry is accepted: everybody sees the player pick it up and carry it, and `player.carriedItem` names it. `groundItem` is the prop it was taken up from, still readable here and gone a moment later, or null. It is carried until `playerPutDownItem`.
101
+ */
102
+ playerCarryItem: [player: Player, item: string, groundItem: GroundItem | null];
103
+
104
+ /**
105
+ * Dispatched once an item carry is over, however it ended: the player put it down, `putDownItem` asked them to, it went into a pile, or they left. `groundItem` is the carryable prop it became where it fell -- still falling, settling where the game's physics puts it -- or null when it went into a pile or they have no room left on the ground.
106
+ */
107
+ playerPutDownItem: [player: Player, item: string, groundItem: GroundItem | null];
108
+
77
109
  /**
78
110
  * Dispatched once a joining player is really standing in the world: their level is up, their body is where `playerSpawning` put it, and the ground under it has loaded. Anything that acts on an arriving player -- kit, a welcome line, a marker -- belongs here rather than in `playerConnect`, which fires while they are still loading the level, or in `playerSpawning`, where the body is still mid-placement.
79
111
  *
@@ -204,6 +236,11 @@ declare global {
204
236
  */
205
237
  diceMatchEnd: [match: number, first: Player | null, second: Player | null, winner: number, reason: string, firstScore: number, secondScore: number];
206
238
 
239
+ /**
240
+ * Synchronous decision before an unfinished craft settles, including when no native refund is due. Call refund() to request a full refund; return values are ignored. No handler or no call preserves native rules. JavaScript exceptions are logged and do not cancel a call already made. The callback expires on return; delayed calls do nothing. The `cancelled`, `interrupted` and `clientError` reasons are reported by the player's own client: a modified client can send any of them, so refunding on one lets that client keep its materials. Never grants a completed craft twice. craftingEnded follows the actual inventory changes.
241
+ */
242
+ craftingRefunding: [player: Player, proposal: CraftRefundProposal, refund: () => void];
243
+
207
244
  /**
208
245
  * A player asks to open an alchemy table, or to begin a smithing recipe. Every handler runs; one returning literal `false` refuses it. An async handler cannot refuse.
209
246
  */
@@ -396,6 +433,36 @@ declare global {
396
433
  */
397
434
  doorInteract: [player: Player, door: Door, action: "open" | "close" | "unlock" | "lockpick", keySide: boolean];
398
435
 
436
+ /**
437
+ * Dispatched immediately after a siege engine is built.
438
+ */
439
+ siegeEngineSpawn: [engine: SiegeEngine];
440
+
441
+ /**
442
+ * Dispatched while a siege engine is being removed. The handle still resolves.
443
+ */
444
+ siegeEngineDestroy: [engine: SiegeEngine];
445
+
446
+ /**
447
+ * Dispatched when an engine's load cycle finishes and it can fire.
448
+ */
449
+ siegeEngineReady: [engine: SiegeEngine];
450
+
451
+ /**
452
+ * Dispatched when a player presses a `usable` engine's native prompt, standing at it, on the step the prompt was offered for. Return false to refuse; otherwise the engine loads, or fires along the player's facing at `range` with the player as the attacker. A handler that works the engine itself should refuse, so it is not worked twice.
453
+ */
454
+ siegeEngineUse: [player: Player, engine: SiegeEngine, action: "load" | "fire"];
455
+
456
+ /**
457
+ * Dispatched the moment an engine lets its projectile go, partway through the shot `fire` started.
458
+ */
459
+ siegeFire: [engine: SiegeEngine, attacker: Player | null, target: Vector3];
460
+
461
+ /**
462
+ * Dispatched where a projectile came down: what the reporting player -- the attacker when near enough, else whoever is nearest the target -- saw it hit, checked against the arc it was thrown on, or the target itself when nobody could see it. Players within `damageRadius` have already been told to take their share, and NPCs have taken theirs. `engine` is null when it was destroyed while the stone was in the air.
463
+ */
464
+ siegeImpact: [engine: SiegeEngine | null, position: Vector3, attacker: Player | null];
465
+
399
466
  /**
400
467
  * Dispatched when a body comes to be inside an enabled area: it walked or rode in, or the area was created, moved, reshaped or enabled around it. The server decides this itself from the pose it already replicates, by the game's own rule for that kind of area, so a client cannot claim it. `matchingVirtualWorld` is false when a script area bound to one world is crossed by a body in another; a level area is in every world.
401
468
  */
@@ -407,12 +474,17 @@ declare global {
407
474
  areaExit: [area: Area, entity: Player | Horse | Cart | Npc, matchingVirtualWorld: boolean];
408
475
 
409
476
  /**
410
- * 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()`.
477
+ * Raised once after every configured world export has loaded successfully, including an empty list. WorldResource.ready is true inside the handler. A script starting later must check WorldResource.ready first; the event is not replayed. Do not await this event inside resourceStart: exports load after script startup. Handler promises are not awaited.
478
+ */
479
+ worldResourcesReady: [];
480
+
481
+ /**
482
+ * A container now exists: a scripted chest, a virtual stash, 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()`.
411
483
  */
412
484
  stashSpawn: [stash: Stash];
413
485
 
414
486
  /**
415
- * A player opened a container and sees what it holds.
487
+ * A player holds a container view. Physical chests report the native opening; virtual stashes report the server grant before requesting the native screen.
416
488
  */
417
489
  stashOpen: [stash: Stash, player: Player];
418
490
 
@@ -432,9 +504,9 @@ declare global {
432
504
  stashDestroy: [stash: Stash];
433
505
 
434
506
  /**
435
- * Dispatched when a player presses a container's prompt, before anything happens: the player's client holds the game's own handler until the server answers. `action` is `open`, `unlock` -- a key turned, which opens it in the same use -- or `lockpick`, the minigame starting; a successful pick then opens it without asking again.
507
+ * Dispatched for a physical chest prompt or virtual stash open(player), before access is granted. For a prompt: the player's client holds the game's own handler until the server answers. `action` is `open`, `unlock` -- a key turned, which opens it in the same use -- or `lockpick`, the minigame starting; a successful pick then opens it without asking again.
436
508
  *
437
- * Return false to refuse it: the prompt does nothing, and no transfer screen, key or minigame ever appears. 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 container another player has open, opening a locked one, picking one that cannot be -- so this only sees what the game would allow. Closing is never asked.
509
+ * Return false to refuse it: the prompt does nothing, and no transfer screen, key or minigame ever appears. 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 container another player has open, opening a locked one, picking one that cannot be -- so this only sees what the game would allow. Virtual opening has no distance check; world, player readiness, lock and exclusive access checks still apply. Closing is never asked.
438
510
  */
439
511
  stashInteract: [player: Player, stash: Stash, action: "open" | "unlock" | "lockpick"];
440
512
 
@@ -906,6 +978,136 @@ declare global {
906
978
  walkEnforced: boolean;
907
979
  }
908
980
 
981
+ /**
982
+ * One number per damage type a blow is worked out in. A blade's stab, slash and smash are priced separately and added; a blow runs only the passes its attack and weapon call for.
983
+ */
984
+ interface DamagePasses {
985
+ /**
986
+ * The stab pass.
987
+ */
988
+ stab: number;
989
+
990
+ /**
991
+ * The slash pass.
992
+ */
993
+ slash: number;
994
+
995
+ /**
996
+ * The smash pass.
997
+ */
998
+ smash: number;
999
+ }
1000
+
1001
+ /**
1002
+ * Scales a `playerHit` handler puts on the server's price of a melee blow, each 1 until a handler changes it. The server works the blow out again with them, step by step as the game does: a heavier attack has to get through the same armour and the same block, so doubling `attack` does not simply double the damage. Never negative.
1003
+ */
1004
+ interface PlayerHitModifiers {
1005
+ /**
1006
+ * Scales the attacker's attack in every pass, after their weapon, strength, skill and the swing itself.
1007
+ */
1008
+ attack: number;
1009
+
1010
+ /**
1011
+ * Scales the victim's armour where the blow landed.
1012
+ */
1013
+ defense: number;
1014
+
1015
+ /**
1016
+ * Scales what the victim's block put up. Nothing for a blow that was not blocked.
1017
+ */
1018
+ block: number;
1019
+
1020
+ /**
1021
+ * Scales the health the blow takes, once everything else is worked out. The game's own cap of 200 a blow is applied before it, so this can go past it.
1022
+ */
1023
+ health: number;
1024
+ }
1025
+
1026
+ /**
1027
+ * Another player's blow, as `playerHit` shows it before the referee rules. `damage` is what the blow will take and `modifiers` scale how the server works it out; a handler may change either. Every other field describes what happened and is read-only in effect.
1028
+ */
1029
+ interface PlayerHit {
1030
+ /**
1031
+ * Health the blow takes. For a swing the server works it out itself, the way the game does, from the attacker's weapon and its wear, both players' strength and skills, the armour the victim wears where it landed, the block and the perks and buffs it can vouch for; for an arrow it is what the victim's own game worked out. Set it and it stands as set: `modifiers` are then ignored. Never negative.
1032
+ */
1033
+ damage: number;
1034
+
1035
+ /**
1036
+ * Health the game itself took for the blow on the machine that saw it land. Matches `damage` unless a perk that depends on the moment -- a heavy weapon's, a first strike's -- was in play, which the server leaves out.
1037
+ */
1038
+ engineDamage: number;
1039
+
1040
+ /**
1041
+ * Whether the server worked `damage` out itself: true for a swing, false for an arrow.
1042
+ */
1043
+ priced: boolean;
1044
+
1045
+ /**
1046
+ * The attacker's weapon as 32 hex digits, or null for a bare hand.
1047
+ */
1048
+ weapon: string | null;
1049
+
1050
+ /**
1051
+ * The attacker's attack in each pass, after the swing's own strength and before `modifiers`.
1052
+ */
1053
+ attack: DamagePasses;
1054
+
1055
+ /**
1056
+ * The victim's armour in each pass where the blow landed, before `modifiers`.
1057
+ */
1058
+ armor: DamagePasses;
1059
+
1060
+ /**
1061
+ * What the victim's block put up, or 0 when nothing blocked it.
1062
+ */
1063
+ blockDefense: number;
1064
+
1065
+ /**
1066
+ * How much the place it landed multiplies the damage by: 1.5 for the head, 1 for the torso, 0.7 for a limb.
1067
+ */
1068
+ bodyPartCoefficient: number;
1069
+
1070
+ /**
1071
+ * Scales on the server's price; see `PlayerHitModifiers`. Ignored for an arrow.
1072
+ */
1073
+ modifiers: PlayerHitModifiers;
1074
+
1075
+ /**
1076
+ * Stamina the blow cost the victim. Already spent: stamina decides their next block, which cannot wait for a ruling.
1077
+ */
1078
+ stamina: number;
1079
+
1080
+ /**
1081
+ * The limb it landed on, or null for none in particular.
1082
+ */
1083
+ bodyPart: "head" | "torso" | "leftArm" | "rightArm" | "leftLeg" | "rightLeg" | null;
1084
+
1085
+ /**
1086
+ * The game's own reason for the damage: `combat` for a blade or a bow.
1087
+ */
1088
+ reason: "unknown" | "combat" | "gunshot" | "starvation" | "collision" | "scripted" | "disintegrate" | "fall" | "poison" | "bleeding" | "selfHarm";
1089
+
1090
+ /**
1091
+ * Whether it was a swing or an arrow.
1092
+ */
1093
+ source: "melee" | "missile";
1094
+
1095
+ /**
1096
+ * The victim's block caught it.
1097
+ */
1098
+ blocked: boolean;
1099
+
1100
+ /**
1101
+ * The victim's perfect block caught it. The game takes nothing for one.
1102
+ */
1103
+ perfectBlock: boolean;
1104
+
1105
+ /**
1106
+ * The victim's block gave way under it.
1107
+ */
1108
+ blockBroken: boolean;
1109
+ }
1110
+
909
1111
  /**
910
1112
  * Which of a player's limbs carry an injury, one flag per limb. An injury is the game's own: it lowers the stamina ceiling (`healthyStamina`), can bleed, and heals slowly by itself or at once with a bandage or `player.heal`.
911
1113
  */
@@ -1198,6 +1400,11 @@ declare global {
1198
1400
  */
1199
1401
  readonly carriedBy: Player | null;
1200
1402
 
1403
+ /**
1404
+ * The item this player carries in their arms, by its item name, or null. Set once `playerCarryItem` has fired, cleared once `playerPutDownItem` has.
1405
+ */
1406
+ readonly carriedItem: string | null;
1407
+
1201
1408
  /**
1202
1409
  * The horse this player is riding, or null when they are on foot.
1203
1410
  */
@@ -1301,6 +1508,13 @@ declare global {
1301
1508
  */
1302
1509
  revive(): boolean;
1303
1510
 
1511
+ /**
1512
+ * Ends melee combat between these two players and retires their pending blows against each other. Other opponents are left alone. A later attack can start combat again. Consent and timeout rules belong to your resource.
1513
+ * @param opponent The other player. Both sides are cancelled.
1514
+ * @returns True when sent; false for disconnected players, the same player, or different virtual worlds.
1515
+ */
1516
+ cancelCombat(opponent: Player): boolean;
1517
+
1304
1518
  /**
1305
1519
  * Puts this player somewhere, as a spawn rather than as a teleport: their client holds the body still until there is real ground under it, so it cannot fall through a world that has not streamed in yet.
1306
1520
  *
@@ -1330,10 +1544,10 @@ declare global {
1330
1544
  *
1331
1545
  * A hand tag is only half of holding something. `r_bucket` makes the body move as if it carried a bucket, but the bucket itself is a `props` entry.
1332
1546
  * @param fragment A Mannequin fragment, as `Animations.list` names it. `""` plays none and only puts the props and tags on, which with a hand tag like `r_bucket` makes the player carry something while they walk.
1333
- * @param options `tags` pick the variant, `loop` repeats it until stopped, `lockMovement` holds the player still, `props` puts up to two models in their hands.
1547
+ * @param options `clip` plays a clip the server streams instead of a fragment (`animations/kcdc/<resource>/wave.caf`, the fragment left `""`), `tags` pick the variant, `loop` repeats it until stopped, `lockMovement` holds the player still, `props` puts up to two models in their hands.
1334
1548
  * @returns True when the request went out; false for a player with no body yet. Throws for a prop or option it cannot use.
1335
1549
  */
1336
- playAnimation(fragment: string, options?: { tags?: string; loop?: boolean; lockMovement?: boolean; props?: { item?: string; model?: string; hand?: 'right' | 'left'; joint?: string; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3> } | { item?: string; model?: string; hand?: 'right' | 'left'; joint?: string; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3> }[] }): boolean;
1550
+ playAnimation(fragment: string, options?: { clip?: string; tags?: string; loop?: boolean; lockMovement?: boolean; props?: { item?: string; model?: string; hand?: 'right' | 'left'; joint?: string; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3> } | { item?: string; model?: string; hand?: 'right' | 'left'; joint?: string; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3> }[] }): boolean;
1337
1551
 
1338
1552
  /**
1339
1553
  * Ends what `playAnimation` started at once, takes its props away and hands the body back to the game. A stance tag the animation set goes with it, so without `standUp` a seated player pops upright.
@@ -1379,6 +1593,13 @@ declare global {
1379
1593
  */
1380
1594
  setAppearance(appearance: Partial<Appearance>): boolean;
1381
1595
 
1596
+ /**
1597
+ * Grants or revokes World Builder access for this player. Multiplayer connections start without access. Enabling allows F7 and the client MapEditor.open API; disabling also closes an open editor. The permission lasts until changed or disconnected and does not affect other players. Offline editing is always allowed.
1598
+ * @param enabled Whether this player may open World Builder.
1599
+ * @returns True when the permission was sent; false for a player with no connection. Throws unless enabled is a boolean.
1600
+ */
1601
+ setWorldBuilderEnabled(enabled: boolean): boolean;
1602
+
1382
1603
  /**
1383
1604
  * Puts a pace rule on this player. `walkByDefault` makes walking the pace they keep coming back to and leaves their own key working; `walkEnforced` forbids running and sprinting outright, and their key stops mattering.
1384
1605
  *
@@ -1393,7 +1614,7 @@ declare global {
1393
1614
  setMovementMode(mode: Partial<MovementMode>): boolean;
1394
1615
 
1395
1616
  /**
1396
- * Grants items into this player's inventory, which the server holds; their game shows them on the next tick. `Inventory.add` does the same and can also set the items' properties.
1617
+ * Grants items into this player's inventory, which the server holds; their game shows them on the next tick and announces them with its own "You received" toast. `Inventory.add` does the same, can set the items' properties, and can leave out the toast.
1397
1618
  * @param item Item class GUID, or the exact name the game's own item tables use.
1398
1619
  * @param amount How many to grant; defaults to 1, and at most 10000.
1399
1620
  * @returns True when the items were added; false for an unknown item, an amount outside 1..10000, or a player with no inventory.
@@ -1401,7 +1622,7 @@ declare global {
1401
1622
  giveItem(item: string, amount?: number): boolean;
1402
1623
 
1403
1624
  /**
1404
- * Takes items of a class out of this player's inventory, across its rows, all of them or none. The server holds the inventory, so the promise is already settled when it is returned; it stays a promise so existing scripts keep working. To move items between players use `Inventory.transfer`, which cannot lose them half way.
1625
+ * Takes items of a class out of this player's inventory, across its rows, all of them or none. The server holds the inventory, so the promise is already settled when it is returned; it stays a promise so existing scripts keep working. Their game announces the loss with its own toast; `Inventory.remove` can leave it out. To move items between players use `Inventory.transfer`, which cannot lose them half way.
1405
1626
  * @param item Item class GUID, or the exact name the game's own item tables use. The same spelling `giveItem` takes.
1406
1627
  * @param amount How many units to take; defaults to 1, and at most 10000. Zero is refused rather than read as "all of them".
1407
1628
  * @returns An object carrying `removed` (the amount when it happened, otherwise 0), `requested`, `ok`, and `reason` (empty on success, otherwise the inventory code, such as `insufficientItems`).
@@ -1468,7 +1689,7 @@ declare global {
1468
1689
  * The game's own camera sits in the head, which the mesh now covers: pair this with the client's `Camera.setThirdPerson` for the disguised player. Nametags are not touched; `setNametagVisible` is the call for that. NPCs still see a person.
1469
1690
  *
1470
1691
  * The owning client is authoritative for its body, so this is a request that lands on their next frame; `player.disguise` reads what they actually have on.
1471
- * @param model A mesh from the prop catalog, by its `objects/...cgf` path or its file stem -- anything `Prop.spawn` takes. Null puts the player back in their own body.
1692
+ * @param model A mesh from the prop catalog, by its `objects/...cgf` path or its file stem, or one this server streams by its full path -- anything `Prop.spawn` takes. Null puts the player back in their own body.
1472
1693
  * @returns True when the request went out; false for a player with no connection to ask. Throws for a model the catalog does not carry.
1473
1694
  */
1474
1695
  setDisguise(model: string | null): boolean;
@@ -1485,6 +1706,24 @@ declare global {
1485
1706
  */
1486
1707
  putDown(): boolean;
1487
1708
 
1709
+ /**
1710
+ * Has this player carry an item in their arms, the way the game's own people carry firewood, sacks and baskets: the carrying walk, and the put-down at the end. While it is carried they walk, since the game has no running with a load.
1711
+ *
1712
+ * It is an instruction to their client, so the carry lands when that client reports it: `playerCarryItem` and `carriedItem` follow. A carry a script ordered is not put to `playerCarryingItem`. The item never enters their inventory. Put down -- with the game's own key or `putDownItem` -- it falls from their hands and becomes a carryable `GroundItem` where it lands, which `playerPutDownItem` hands over and anybody can take up again.
1713
+ *
1714
+ * Their hands have to be free -- a drawn weapon or a torch makes their game refuse the carry, and nothing is reported.
1715
+ * @param item What to carry. A name from `Animations.props()` whose `hand` the game has a carrying walk for -- the baskets (`basket_full_wood`, `basket_b_apples`, `stonebasket`, `eggbasket`, `shoppingbasket`), `firewoodChipsHand`, the buckets (`waterBucket`, `milkBucket`), and for a man only the sacks (`sack`, `sack_miller`), `barrel` and `crate_with_silver` -- puts a new one straight into their hands. A `GroundItem` of such a class has them pick that one up off the ground with the game's own bend-down; it has to be a single item within their reach.
1716
+ * @returns True when the order went out; false when they cannot act, are riding, already carry an item or a body, the stack is not resting within their reach or somebody else is taking it, or they have no connection. Throws for an item with no carrying walk, or none for this player's body.
1717
+ */
1718
+ carryItem(item: string | GroundItem): boolean;
1719
+
1720
+ /**
1721
+ * Has this player put down the item in their arms, with the game's own put-down. It is an instruction to their client, so the carry ends when that put-down lands: `playerPutDownItem` follows then.
1722
+ * @param options `immediate` lets go at once, without the put-down.
1723
+ * @returns True when the order went out; false when they carry no item or have no connection.
1724
+ */
1725
+ putDownItem(options?: { immediate?: boolean }): boolean;
1726
+
1488
1727
  /**
1489
1728
  * Puts this player in a horse's saddle, the way the game's own forced mount does -- their client plays the climb. It is an instruction to their client, so the seat is reported back like any other mount: `horseMounting` can still refuse it, and `horseMount` and `player.horse` follow once it lands. The player has to be standing near the horse; teleport them beside it first.
1490
1729
  * @param horse The horse to climb onto.
@@ -1603,7 +1842,7 @@ declare global {
1603
1842
  revision: number;
1604
1843
 
1605
1844
  /**
1606
- * `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.
1845
+ * `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, `repair` for a repair kit, `drop` for `player.dropInventory`, or the ground, stash and gathering reasons.
1607
1846
  */
1608
1847
  reason: string;
1609
1848
 
@@ -1623,7 +1862,7 @@ declare global {
1623
1862
  ok: boolean;
1624
1863
 
1625
1864
  /**
1626
- * Empty on success, otherwise why not: `inventoryUnavailable`, `invalidRequest`, `staleRevision`, `invalidItem`, `invalidItems`, `invalidAmount`, `unknownItem`, `insufficientItems`, `inventoryCapacity`, `sameInventory`, or a property policy code (`invalidMetadata`, `unknownItemClass`, `questItem`, `invalidQuality`, `immutableItemHealth`, `invalidItemHealth`, `contradictoryItemHealth`, `invalidCreationSentinel`, `unsupportedPoisonProperties`, `unsupportedOnEquipBuffs`).
1865
+ * Empty on success, otherwise why not: `inventoryUnavailable`, `invalidRequest`, `staleRevision`, `invalidItem`, `invalidItems`, `invalidAmount`, `unknownItem`, `insufficientItems`, `inventoryCapacity`, `sameInventory`, `invalidEquipment`, or a property policy code (`invalidMetadata`, `unknownItemClass`, `questItem`, `invalidQuality`, `immutableItemHealth`, `invalidItemHealth`, `contradictoryItemHealth`, `invalidCreationSentinel`, `unsupportedPoisonProperties`, `unsupportedOnEquipBuffs`).
1627
1866
  */
1628
1867
  code: string;
1629
1868
 
@@ -1649,14 +1888,14 @@ declare global {
1649
1888
  get(player: Player): InventoryState | null;
1650
1889
 
1651
1890
  /**
1652
- * Gives a player items of a class, 1 to 10000 at a time. `item` is the class GUID or the exact name the game's own item tables use, the same spelling `giveItem` takes. Left-out properties mean quality 1 at full condition; `metadata.quality` asks for a higher tier, up to what the class is made in, and `invalidQuality` refuses one past it. The units join the row that already holds this class with these properties, if there is one.
1891
+ * Gives a player items of a class, 1 to 10000 at a time. `item` is the class GUID or the exact name the game's own item tables use, the same spelling `giveItem` takes. Left-out properties mean quality 1 at full condition; `metadata.quality` asks for a higher tier, up to what the class is made in, and `invalidQuality` refuses one past it. The units join the row that already holds this class with these properties, if there is one. The player's game announces them with its own "You received" toast unless `notify` is false.
1653
1892
  */
1654
- add(player: Player, request: { item: string; amount: number; metadata?: Record<string, unknown>; revision?: number }): InventoryResult;
1893
+ add(player: Player, request: { item: string; amount: number; metadata?: Record<string, unknown>; revision?: number; notify?: boolean }): InventoryResult;
1655
1894
 
1656
1895
  /**
1657
- * Takes exact units from named rows, every one of them or none.
1896
+ * Takes exact units from named rows, every one of them or none. The player's game announces the loss with its own toast unless `notify` is false.
1658
1897
  */
1659
- remove(player: Player, request: { units: InventoryUnit[]; revision?: number }): InventoryResult;
1898
+ remove(player: Player, request: { units: InventoryUnit[]; revision?: number; notify?: boolean }): InventoryResult;
1660
1899
 
1661
1900
  /**
1662
1901
  * Replaces a row's properties. The row keeps its identity and amount. It replaces rather than merges: carry over anything you want to keep, and give `health` or `condition`, not two that disagree.
@@ -1664,14 +1903,14 @@ declare global {
1664
1903
  setProperties(player: Player, request: { id: string; metadata: Record<string, unknown>; revision?: number }): InventoryResult;
1665
1904
 
1666
1905
  /**
1667
- * Replaces a player's whole inventory, which is how a saved one comes back. Rows keep the ids they are given (letters, digits and `-_:.`, up to 64) and get new ones when they have none. `equipped` is how many units of a gear row the body wears, up to 48 in all; their game dresses in them. An empty list clears the inventory.
1906
+ * Replaces a player's whole inventory, which is how a saved one comes back. It is never announced in the player's game. Rows keep the ids they are given (letters, digits and `-_:.`, up to 64) and get new ones when they have none. `equipped` is how many units of a gear row the body wears, up to 48 in all; their game dresses in them. An empty list clears the inventory.
1668
1907
  */
1669
1908
  set(player: Player, request: { items: { id?: string; item: string; amount: number; metadata?: Record<string, unknown>; equipped?: number }[]; revision?: number }): InventoryResult;
1670
1909
 
1671
1910
  /**
1672
- * Moves exact units from one player to another with their properties, all or nothing. They join matching rows in the target, so the target's row ids are the ones in the result's `items`. Whether the two may trade -- distance, consent, price -- is for the script to decide.
1911
+ * Moves exact units from one player to another with their properties, all or nothing. They join matching rows in the target, so the target's row ids are the ones in the result's `items`. Whether the two may trade -- distance, consent, price -- is for the script to decide. Both players' games announce what they lost and gained unless `notify` is false.
1673
1912
  */
1674
- transfer(source: Player, target: Player, request: { units: InventoryUnit[]; sourceRevision?: number; targetRevision?: number }): InventoryResult;
1913
+ transfer(source: Player, target: Player, request: { units: InventoryUnit[]; sourceRevision?: number; targetRevision?: number; notify?: boolean }): InventoryResult;
1675
1914
 
1676
1915
  /**
1677
1916
  * What the game prices one unit of an item at, in money units, worked out the way the game does it. `pristine` is the price at the best health its quality allows, `current` at its own health. Quality changes the price only through that health. The metadata reads as `Inventory.add` reads it -- left out, quality 1 at full condition -- so `Inventory.getItemPrice(row.item, row.metadata)` prices a row. This is the item's own worth: what the game's shopkeepers would ask depends on their terms and the haggling, and a `Vendor` charges whatever its script says.
@@ -1911,7 +2150,7 @@ declare global {
1911
2150
  /**
1912
2151
  * Draws the row greyed and unpickable when false. A rendering hint only -- the server re-checks the choice when it arrives, so nothing a row costs may rely on this.
1913
2152
  */
1914
- enabled: boolean | undefined;
2153
+ enabled?: boolean | undefined;
1915
2154
  }
1916
2155
 
1917
2156
  /**
@@ -1921,12 +2160,12 @@ declare global {
1921
2160
  /**
1922
2161
  * Shown above the options. Omit it for a list with no preamble.
1923
2162
  */
1924
- line: string | undefined;
2163
+ line?: string | undefined;
1925
2164
 
1926
2165
  /**
1927
2166
  * Draws the list on the right of the screen instead of the left.
1928
2167
  */
1929
- onRight: boolean | undefined;
2168
+ onRight?: boolean | undefined;
1930
2169
 
1931
2170
  /**
1932
2171
  * The rows, at least one and at most eight. A page with none is refused.
@@ -1978,17 +2217,17 @@ declare global {
1978
2217
  /**
1979
2218
  * Shown in the server's log only. The trade screen names whoever keeps the shop.
1980
2219
  */
1981
- name: string | undefined;
2220
+ name?: string | undefined;
1982
2221
 
1983
2222
  /**
1984
2223
  * Money units the vendor starts with, and all it can pay out. Omit it for a purse that never runs out.
1985
2224
  */
1986
- purse: number | undefined;
2225
+ purse?: number | undefined;
1987
2226
 
1988
2227
  /**
1989
2228
  * Whether the vendor takes the player's items at all. On by default; `setBuyPrices` says which ones.
1990
2229
  */
1991
- buys: boolean | undefined;
2230
+ buys?: boolean | undefined;
1992
2231
  }
1993
2232
 
1994
2233
  /**
@@ -2155,6 +2394,26 @@ declare global {
2155
2394
  amount: number;
2156
2395
  }
2157
2396
 
2397
+ /**
2398
+ * A dice table placed by the current level. The catalog includes quest-layer tables that may not currently be loaded on a client.
2399
+ */
2400
+ interface DiceTableInfo {
2401
+ /**
2402
+ * The table's level GUID as sixteen lowercase hex digits.
2403
+ */
2404
+ id: string;
2405
+
2406
+ /**
2407
+ * The world-space midpoint between the table's two seat alignment points, in metres. The behavior entity itself may be offset from this interaction centre.
2408
+ */
2409
+ position: Vector3;
2410
+
2411
+ /**
2412
+ * The two sitting smart-object GUIDs, in native seat order. Compare with a seated player's seatGuid; these are not the minigame's alignment tagpoints.
2413
+ */
2414
+ seats: [string, string];
2415
+ }
2416
+
2158
2417
  /**
2159
2418
  * How a dice match is played.
2160
2419
  */
@@ -2162,7 +2421,7 @@ declare global {
2162
2421
  /**
2163
2422
  * The score that wins, banked at the end of a turn. 2000 when omitted, at most 100000.
2164
2423
  */
2165
- targetScore: number | undefined;
2424
+ targetScore?: number | undefined;
2166
2425
  }
2167
2426
 
2168
2427
  /**
@@ -2171,6 +2430,12 @@ declare global {
2171
2430
  * Both players sit down at the dice table nearest them and play it as they would against an NPC, the other player's body opposite. Every throw is dealt and every move checked by the server, by the game's own scoring rules; badges and dice perks are off, so a match is decided by the dice and the decisions alone.
2172
2431
  */
2173
2432
  const Dice: {
2433
+ /**
2434
+ * Lists the current level's dice tables and their seats. The same placements exist in every virtual world; readiness and occupancy belong to the gamemode.
2435
+ * @returns The level's tables, in GUID order.
2436
+ */
2437
+ tables(): DiceTableInfo[];
2438
+
2174
2439
  /**
2175
2440
  * Starts a match. Both players must stand together, within a few metres, at a dice table, and neither may be playing already. Throws an Error saying why when it cannot start.
2176
2441
  * @param first NetworkID of the player on the table's first seat.
@@ -2385,6 +2650,66 @@ declare global {
2385
2650
  knowledge: Record<string, number> | undefined;
2386
2651
  }
2387
2652
 
2653
+ /**
2654
+ * An original ingredient still held by this session, including its original inventory properties.
2655
+ */
2656
+ interface CraftRefundMaterial {
2657
+ /**
2658
+ * Item class GUID.
2659
+ */
2660
+ item: string;
2661
+
2662
+ /**
2663
+ * Units originally removed and not already returned.
2664
+ */
2665
+ amount: number;
2666
+
2667
+ /**
2668
+ * Original canonical inventory properties, preserved by refunds.
2669
+ */
2670
+ metadata: Record<string, unknown>;
2671
+ }
2672
+
2673
+ /**
2674
+ * An unfinished craft before material settlement. Frozen. Call the event's refund callback synchronously to request all its materials back; otherwise the native refund rules apply.
2675
+ */
2676
+ interface CraftRefundProposal {
2677
+ /**
2678
+ * Which craft.
2679
+ */
2680
+ kind: 'alchemy' | 'smithing';
2681
+
2682
+ /**
2683
+ * The session being settled, once only.
2684
+ */
2685
+ session: string;
2686
+
2687
+ /**
2688
+ * Station id.
2689
+ */
2690
+ station: string;
2691
+
2692
+ /**
2693
+ * The session's virtual world.
2694
+ */
2695
+ virtualWorld: number;
2696
+
2697
+ /**
2698
+ * No product was granted for this craft.
2699
+ */
2700
+ outcome: 'failed' | 'cancelled';
2701
+
2702
+ /**
2703
+ * Why it ended: cancelled for normal native or script cancellation; interrupted for native teardown without a normal exit; clientError for an alchemy adapter failure; craftingFailed for a broken smithing workpiece. Server closures also include disconnected, timeout and contextInvalidated; settlement refusals retain their existing reasons. Client exit reasons are observations, not server-verified combat evidence.
2704
+ */
2705
+ reason: string;
2706
+
2707
+ /**
2708
+ * All remaining original ingredients, including processed alchemy ingredients. Station liquids and ingredients already returned are excluded. Do not grant these yourself; call refund().
2709
+ */
2710
+ materials: CraftRefundMaterial[];
2711
+ }
2712
+
2388
2713
  /**
2389
2714
  * A batch or workpiece that is over, for any reason. A table kept for the next batch is not closed by this.
2390
2715
  */
@@ -2415,12 +2740,12 @@ declare global {
2415
2740
  outcome: 'success' | 'failed' | 'cancelled';
2416
2741
 
2417
2742
  /**
2418
- * Empty for a completed batch or a workpiece the game finished or broke. `craftingCompletingRejected` when a handler refused the result; `cancelled` by the player or a script; `disconnected`; `timeout` after 30 minutes; `contextInvalidated` when the player walked away, died or changed world. Smithing adds `abandoned` (the recipe never reached the anvil), `abandonTooLate`, `invalidQuality` and `inventoryUnavailable`.
2743
+ * Empty for a completed batch or a successful workpiece. `craftingFailed` for a broken workpiece; `cancelled` for normal native or script cancellation; `interrupted` for unexpected native teardown; `clientError` for alchemy adapter errors. Other reasons: `craftingCompletingRejected`, `disconnected`, `timeout`, `contextInvalidated`, and for smithing `abandoned`, `abandonTooLate`, `invalidQuality`, `inventoryUnavailable`. See CraftRefundProposal.
2419
2744
  */
2420
2745
  reason: string;
2421
2746
 
2422
2747
  /**
2423
- * The inventory rows ingredients went back to. Alchemy: wholly unmilled bowl, mortar and herb groups come back; everything else put on the table was spent. Smithing: a failed workpiece spends half of each divisible material, rounded down, and a coin decides a single unit; the rest comes back.
2748
+ * The inventory rows ingredients went back to. Alchemy: wholly unmilled bowl, mortar and herb groups come back; everything else put on the table was spent. Smithing: a failed workpiece spends half of each divisible material, rounded down, and a coin decides a single unit; the rest comes back. A full refund requested through craftingRefunding returns all remaining original materials instead.
2424
2749
  */
2425
2750
  refunded: InventoryUnit[];
2426
2751
  }
@@ -2820,7 +3145,7 @@ declare global {
2820
3145
  readonly modelName: string;
2821
3146
 
2822
3147
  /**
2823
- * Browsing bucket the mesh sits in, e.g. `manmade/structures`.
3148
+ * Browsing bucket the mesh sits in, e.g. `manmade/structures`; `kcdc/<resource>` for a mesh the server streams.
2824
3149
  */
2825
3150
  readonly modelGroup: string;
2826
3151
 
@@ -2847,15 +3172,15 @@ declare global {
2847
3172
 
2848
3173
  /**
2849
3174
  * Spawns and replicates a static mesh from the game's own object catalog.
2850
- * @param model Mesh to build, as either a full catalog path (`objects/manmade/barrels/barrel_a.cgf`) or its file stem (`barrel_a`). A stem several meshes share resolves to the first of them, so pass the path when it matters which.
3175
+ * @param model Mesh to build, as either a full catalog path (`objects/manmade/barrels/barrel_a.cgf`) or its file stem (`barrel_a`). A stem several meshes share resolves to the first of them, so pass the path when it matters which. A mesh this server streams -- a `.cgf` in a resource's `stream/objects/kcdc/<resource>/` folder -- is named by its full path, `objects/kcdc/<resource>/chair.cgf`; a player whose game does not have it yet sees the prop as soon as it does.
2851
3176
  * @param position Optional world-space spawn position; omitted components default to zero.
2852
3177
  * @param rotation Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in degrees.
2853
- * @param scale Optional uniform scale from 0.01 to 100; omitted spawns the mesh at its own size.
3178
+ * @param scale Uniform size or separate X/Y/Z sizes, each from 0.01 to 100. Omitted uses the mesh size. Nonuniform collision follows the native engine limitations.
2854
3179
  * @param physics Optional collision: `static` (the default), `rigid` or `none`.
2855
3180
  * @param virtualWorld Optional virtual world the prop belongs to; omitted puts it in the global one.
2856
3181
  * @returns The newly spawned prop handle.
2857
3182
  */
2858
- static spawn(model: string, position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, scale?: number, physics?: string, virtualWorld?: number): Prop;
3183
+ static spawn(model: string, position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, scale?: number | Vector3, physics?: string, virtualWorld?: number): Prop;
2859
3184
 
2860
3185
  /**
2861
3186
  * Lists every prop the server currently has.
@@ -3329,22 +3654,22 @@ declare global {
3329
3654
  /**
3330
3655
  * What the object is; a brush when omitted. A brush has no identity of its own, so it is found by its mesh and where the level put it; a level entity by its EntityGuid.
3331
3656
  */
3332
- kind: 'brush' | 'entity' | undefined;
3657
+ kind?: 'brush' | 'entity' | undefined;
3333
3658
 
3334
3659
  /**
3335
3660
  * A brush's mesh path, `objects/...cgf`, as the World Builder shows it; required for a brush. An entity's name, kept for reading only.
3336
3661
  */
3337
- name: string | undefined;
3662
+ name?: string | undefined;
3338
3663
 
3339
3664
  /**
3340
3665
  * An entity's level EntityGuid as sixteen hex digits; required for an entity.
3341
3666
  */
3342
- guid: string | undefined;
3667
+ guid?: string | undefined;
3343
3668
 
3344
3669
  /**
3345
3670
  * An entity's class, kept for reading only.
3346
3671
  */
3347
- class: string | undefined;
3672
+ class?: string | undefined;
3348
3673
 
3349
3674
  /**
3350
3675
  * Where the level put the object: its pivot, matched within 5 cm. A brush's key, with its mesh.
@@ -3354,22 +3679,22 @@ declare global {
3354
3679
  /**
3355
3680
  * Whether it is taken out of the world: not drawn and not solid.
3356
3681
  */
3357
- hidden: boolean | undefined;
3682
+ hidden?: boolean | undefined;
3358
3683
 
3359
3684
  /**
3360
3685
  * Where it stands instead; present, the edit is a move.
3361
3686
  */
3362
- position: Vector3 | number[] | undefined;
3687
+ position?: Vector3 | number[] | undefined;
3363
3688
 
3364
3689
  /**
3365
3690
  * A move's orientation: a Quaternion, {x, y, z, w} or [x, y, z, w]. None when omitted.
3366
3691
  */
3367
- rotation: Quaternion | number[] | undefined;
3692
+ rotation?: Quaternion | number[] | undefined;
3368
3693
 
3369
3694
  /**
3370
3695
  * A move's scale per axis, from 0.01 to 100. None when omitted.
3371
3696
  */
3372
- scale: Vector3 | number[] | undefined;
3697
+ scale?: Vector3 | number[] | undefined;
3373
3698
  }
3374
3699
 
3375
3700
  /**
@@ -3377,7 +3702,7 @@ declare global {
3377
3702
  */
3378
3703
  class LevelEdit {
3379
3704
  /**
3380
- * Wraps an edit the server already holds; use LevelEdit.apply or LevelEdit.applyMap to make one.
3705
+ * Wraps an edit the server already holds; use LevelEdit.apply to make one, or WorldResource for a whole export.
3381
3706
  * @param id Network entity identifier.
3382
3707
  */
3383
3708
  constructor(id: number);
@@ -3461,14 +3786,6 @@ declare global {
3461
3786
  */
3462
3787
  static apply(definition: LevelEditDefinition, virtualWorld?: number): LevelEdit;
3463
3788
 
3464
- /**
3465
- * Applies every entry of a map's `world` array, which is how edits made in the World Builder reach every player instead of being loaded by hand on each.
3466
- * @param map A World Builder map saved from the editor, as its JSON text or the parsed object. Only its `world` array is read: its placed objects are `Prop.spawn`'s, its areas `Area.create`'s.
3467
- * @param virtualWorld Optional virtual world whose players see the edits; the global one when omitted.
3468
- * @returns One edit per entry, in the map's order. Throws, naming the entry, for one no client could find the object by.
3469
- */
3470
- static applyMap(map: string | Record<string, unknown>, virtualWorld?: number): LevelEdit[];
3471
-
3472
3789
  /**
3473
3790
  * Lists every edit the server currently has.
3474
3791
  * @param virtualWorld Optional virtual world to list; omitted lists every one of them.
@@ -3722,10 +4039,10 @@ declare global {
3722
4039
  *
3723
4040
  * `npcAnimationEnd` fires once when the animation this request started is over, and says how.
3724
4041
  * @param fragment A Mannequin fragment, as `Animations.list` names it -- or, as before, a row of the shipped emote catalog, which plays that gesture once and is not remembered.
3725
- * @param options `tags` pick the variant, `loop` repeats it until stopped, `props` puts up to two models in its hands. `lockMovement` does nothing here: an NPC standing still is its intent's business.
4042
+ * @param options `clip` plays a clip the server streams instead of a fragment (`animations/kcdc/<resource>/wave.caf`, the fragment left `""`), `tags` pick the variant, `loop` repeats it until stopped, `props` puts up to two models in its hands. `lockMovement` does nothing here: an NPC standing still is its intent's business.
3726
4043
  * @returns True when the request went out; false for a dead NPC. Throws for a prop or option it cannot use.
3727
4044
  */
3728
- playAnimation(fragment: string | number, options?: { tags?: string; loop?: boolean; lockMovement?: boolean; props?: { item?: string; model?: string; hand?: 'right' | 'left'; joint?: string; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3> } | { item?: string; model?: string; hand?: 'right' | 'left'; joint?: string; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3> }[] }): boolean;
4045
+ playAnimation(fragment: string | number, options?: { clip?: string; tags?: string; loop?: boolean; lockMovement?: boolean; props?: { item?: string; model?: string; hand?: 'right' | 'left'; joint?: string; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3> } | { item?: string; model?: string; hand?: 'right' | 'left'; joint?: string; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3> }[] }): boolean;
3729
4046
 
3730
4047
  /**
3731
4048
  * Ends what `playAnimation` started at once, takes its props away and hands the body back to its intent. The stand-up `standUp` asks for is an animation of its own and raises its own `npcAnimationEnd`.
@@ -4032,6 +4349,11 @@ declare global {
4032
4349
  */
4033
4350
  readonly resting: boolean;
4034
4351
 
4352
+ /**
4353
+ * Whether this is a prop people carry in their arms -- one a carry put down, or one spawned `carryable` -- rather than stock. Taking it up is a carry: the game's pick-up prompt or `player.carryItem(groundItem)`, never an inventory.
4354
+ */
4355
+ readonly carryable: boolean;
4356
+
4035
4357
  /**
4036
4358
  * Network ID of the player who dropped this stack, or 0 when the server spawned it.
4037
4359
  */
@@ -4060,10 +4382,10 @@ declare global {
4060
4382
  * @param rotation Optional resting orientation: a Quaternion, or a Vector3 of Euler angles in degrees.
4061
4383
  * @param amount Optional number of units in the stack, from 1 to 10000; omitted lays down one. A stack is picked up whole.
4062
4384
  * @param virtualWorld Optional virtual world the stack belongs to; omitted puts it in the global one.
4063
- * @param properties Optional condition of the item itself: `quality` as the game grades it, `health` and `condition` from 0 to 1. Each defaults to the class's own. Arrows and other missile classes are held to tighter bounds by the receiving client and are given a quality of 1 and full health when these are left out, since a stack outside those bounds is one no client would build.
4385
+ * @param properties Optional condition of the item itself: `quality` as the game grades it, `health` and `condition` from 0 to 1. Each defaults to the class's own. Arrows and other missile classes are held to tighter bounds by the receiving client and are given a quality of 1 and full health when these are left out, since a stack outside those bounds is one no client would build. `carryable` makes it a prop people carry in their arms rather than stock: the game's pick-up prompt over it starts a carry (raising `playerCarryingItem`) and never puts it in an inventory. Only for a single item `player.carryItem` takes by name.
4064
4386
  * @returns The newly spawned ground item handle. Throws when the item is not a class in the game's tables, or when no client could build the stack as described.
4065
4387
  */
4066
- static spawn(item: string, position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, amount?: number, virtualWorld?: number, properties?: { quality?: number; health?: number; condition?: number }): GroundItem;
4388
+ static spawn(item: string, position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, amount?: number, virtualWorld?: number, properties?: { quality?: number; health?: number; condition?: number; carryable?: boolean }): GroundItem;
4067
4389
 
4068
4390
  /**
4069
4391
  * Lists every stack lying in the world, however it got there.
@@ -4393,7 +4715,7 @@ declare global {
4393
4715
  }
4394
4716
 
4395
4717
  /**
4396
- * Replicated handle for one of the level's animated gates.
4718
+ * Replicated handle for one of the level's castle gates.
4397
4719
  */
4398
4720
  class Gate {
4399
4721
  /**
@@ -4403,12 +4725,12 @@ declare global {
4403
4725
  constructor(id: number);
4404
4726
 
4405
4727
  /**
4406
- * The level's own EntityGuid, as sixteen lowercase hex digits. The same on every machine, so it is the identity to store a gate under; `Gate.find` takes it back.
4728
+ * The level's own EntityGuid, as sixteen lowercase hex digits. The same on every machine, so it is the identity to store a gate under; `Gate.find` takes it back. A `gate` has no entity of its own, so its key is the GUID of the layer that draws it shut.
4407
4729
  */
4408
4730
  readonly guid: string;
4409
4731
 
4410
4732
  /**
4411
- * What piece of architecture this is: `drawbridge` or `portcullis`. The shipped game has two in total.
4733
+ * What piece of architecture this is: `drawbridge` or `portcullis`, which animate, or `gate`, a pair of leaves the level swaps between drawn open and drawn shut -- the Ratborsch and Nebakov fortress gates and the Ruthard palace gate. A `gate` opens and closes at once.
4412
4734
  */
4413
4735
  readonly kind: string;
4414
4736
 
@@ -4428,7 +4750,7 @@ declare global {
4428
4750
  readonly moving: boolean;
4429
4751
 
4430
4752
  /**
4431
- * How long opening takes, in seconds, from the key range the asset's animation database stores. A gate with no opening clip runs its closing one backwards, so this is that clip's length.
4753
+ * How long opening takes, in seconds, from the key range the asset's animation database stores. A gate with no opening clip runs its closing one backwards, so this is that clip's length. 0 for a `gate`.
4432
4754
  */
4433
4755
  readonly openDuration: number;
4434
4756
 
@@ -4483,6 +4805,162 @@ declare global {
4483
4805
 
4484
4806
  interface Gate extends Entity {}
4485
4807
 
4808
+ /** */
4809
+ interface SiegeResult {
4810
+ /**
4811
+ * Whether the engine did it.
4812
+ */
4813
+ accepted: boolean;
4814
+
4815
+ /**
4816
+ * Why it did not, as a phrase that reads after the engine's name: `is not loaded`, `cannot fire: the target is further than the engine can throw`. Empty when it did.
4817
+ */
4818
+ reason: string;
4819
+
4820
+ /**
4821
+ * How long until the step it started is over: the whole load for `load`, until the projectile is let go for `fire`. 0 when nothing happened.
4822
+ */
4823
+ seconds: number;
4824
+ }
4825
+
4826
+ /**
4827
+ * Replicated handle for a trebuchet or a cannon.
4828
+ */
4829
+ class SiegeEngine {
4830
+ /**
4831
+ * Creates a script wrapper for an existing siege engine with this ID; use SiegeEngine.spawn() to build one.
4832
+ * @param id Network entity identifier.
4833
+ */
4834
+ constructor(id: number);
4835
+
4836
+ /**
4837
+ * What the engine is: `trebuchet` or `cannon`. The game ships no catapult and no ballista.
4838
+ */
4839
+ readonly kind: string;
4840
+
4841
+ /**
4842
+ * Where the engine is in its cycle: `idle` (unloaded), `drawing` (a trebuchet's arm being winched down), `loading` (the crew laying the projectile), `ready` or `firing`. Named `cycle` because every entity already has a `state`, which is its state bag.
4843
+ */
4844
+ readonly cycle: string;
4845
+
4846
+ /**
4847
+ * Whether the engine is ready to fire.
4848
+ */
4849
+ readonly loaded: boolean;
4850
+
4851
+ /**
4852
+ * How fast the cycle runs, from 0.1 to 20; 1 is the game's own pace, which takes a trebuchet's crew nearly two minutes to load and lets the stone go 3.5 seconds into the shot. Changing it mid-step carries on from where the engine has got to.
4853
+ */
4854
+ speed: number;
4855
+
4856
+ /**
4857
+ * Health taken from anything at the point of impact; a player has 100. A quarter of it reaches the edge of `damageRadius`. 0 leaves hits to `siegeImpact`.
4858
+ */
4859
+ damage: number;
4860
+
4861
+ /**
4862
+ * How far from the point of impact anything is hurt, in metres, up to 100.
4863
+ */
4864
+ damageRadius: number;
4865
+
4866
+ /**
4867
+ * Whether players within 12 m of the engine get the game's own action hint for it on the use key: Load while it is idle, Fire while it is loaded. A press raises `siegeEngineUse`, and unless a handler refuses it the engine loads, or fires along the player's facing at `range`. Off by default.
4868
+ */
4869
+ usable: boolean;
4870
+
4871
+ /**
4872
+ * How far a shot fired from the native prompt goes along the player's facing, in metres; kept between `minRange` and `maxRange`. 150 for a trebuchet and 120 for a cannon to start with.
4873
+ */
4874
+ range: number;
4875
+
4876
+ /**
4877
+ * The closest the engine can be aimed, in metres along the ground.
4878
+ */
4879
+ readonly minRange: number;
4880
+
4881
+ /**
4882
+ * The furthest the engine can be aimed, in metres along the ground.
4883
+ */
4884
+ readonly maxRange: number;
4885
+
4886
+ /**
4887
+ * How long `load` takes at the engine's speed, in seconds.
4888
+ */
4889
+ readonly loadDuration: number;
4890
+
4891
+ /**
4892
+ * Formats this engine handle for logging and debugging.
4893
+ * @returns The engine ID, its kind and where it is in its cycle.
4894
+ */
4895
+ toString(): string;
4896
+
4897
+ /**
4898
+ * Starts the reload cycle of an idle engine. `siegeEngineReady` fires when it can shoot.
4899
+ * @returns What happened, and the phrase to explain it with when nothing did.
4900
+ */
4901
+ load(): SiegeResult;
4902
+
4903
+ /**
4904
+ * Turns a loaded engine to face the target and shoots at it. A trebuchet's arm lets the stone go at one angle, so its speed is solved for the distance; a cannon fires at one speed, so its elevation is. The stone is let go partway through the shot (`seconds`), then every client nearby draws it along the same arc. It comes down where the world stops it, which the attacker is asked to report when near enough, else the player nearest the target, or on the target when nobody can.
4905
+ * @param target Where the projectile should come down.
4906
+ * @param attacker The player credited with whatever it hits, in `playerDamage`, `npcDamage` and `siegeImpact`.
4907
+ * @returns What happened, and the phrase to explain it with when nothing did.
4908
+ */
4909
+ fire(target: Vector3 | Partial<Vector3>, attacker?: Player | number | null): SiegeResult;
4910
+
4911
+ /**
4912
+ * Turns the engine to face a point without shooting. `fire` turns it anyway; this is for showing where it will shoot.
4913
+ * @param target The point to turn towards.
4914
+ * @returns What happened, and the phrase to explain it with when nothing did.
4915
+ */
4916
+ aim(target: Vector3 | Partial<Vector3>): SiegeResult;
4917
+
4918
+ /**
4919
+ * Whether the engine can reach a point from where it stands.
4920
+ * @param target The point to test.
4921
+ * @returns Empty when it can; otherwise why not, as a phrase.
4922
+ */
4923
+ canHit(target: Vector3 | Partial<Vector3>): string;
4924
+
4925
+ /**
4926
+ * Removes the engine on every client after emitting `siegeEngineDestroy`. A projectile already in the air still lands.
4927
+ */
4928
+ destroy(): void;
4929
+
4930
+ /**
4931
+ * Builds and replicates a siege engine, unloaded. The trebuchet is the game's own model and plays its own winch, load and fire animations; the cannon is the game's static gun.
4932
+ * @param kind `trebuchet` or `cannon`.
4933
+ * @param position World-space position of the engine's base.
4934
+ * @param rotation Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in degrees. `fire` and `aim` turn it to face their target.
4935
+ * @param virtualWorld Optional virtual world the engine belongs to; omitted puts it in the global one.
4936
+ * @returns The new engine's handle.
4937
+ */
4938
+ static spawn(kind: string, position: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, virtualWorld?: number): SiegeEngine;
4939
+
4940
+ /**
4941
+ * Lists the siege engines the server has.
4942
+ * @param virtualWorld Optional virtual world to list; omitted lists every one.
4943
+ * @returns One handle per engine, in no particular order.
4944
+ */
4945
+ static all(virtualWorld?: number): SiegeEngine[];
4946
+
4947
+ /**
4948
+ * Looks an engine up by its network entity ID.
4949
+ * @param id Network entity identifier.
4950
+ * @returns The engine's handle, or null when no live engine has that ID.
4951
+ */
4952
+ static getById(id: number): SiegeEngine | null;
4953
+
4954
+ /**
4955
+ * Removes siege engines, emitting `siegeEngineDestroy` for each one.
4956
+ * @param virtualWorld Optional virtual world to clear; omitted clears every one.
4957
+ * @returns How many were removed.
4958
+ */
4959
+ static destroyAll(virtualWorld?: number): number;
4960
+ }
4961
+
4962
+ interface SiegeEngine extends Entity {}
4963
+
4486
4964
  /** */
4487
4965
  interface AreaDefinition {
4488
4966
  /**
@@ -4493,7 +4971,7 @@ declare global {
4493
4971
  /**
4494
4972
  * A readable name; the id when omitted.
4495
4973
  */
4496
- name: string | undefined;
4974
+ name?: string | undefined;
4497
4975
 
4498
4976
  /**
4499
4977
  * CryEngine's own area shapes: `AreaBox`, `AreaShape` (a closed polygon with a height) and `AreaSphere`.
@@ -4503,57 +4981,57 @@ declare global {
4503
4981
  /**
4504
4982
  * Where the shape is placed from; the origin when omitted.
4505
4983
  */
4506
- position: Vector3 | undefined;
4984
+ position?: Vector3 | undefined;
4507
4985
 
4508
4986
  /**
4509
4987
  * The shape's orientation: a Quaternion or {x, y, z, w}, or Euler angles in degrees.
4510
4988
  */
4511
- rotation: Quaternion | Vector3 | undefined;
4989
+ rotation?: Quaternion | Vector3 | undefined;
4512
4990
 
4513
4991
  /**
4514
4992
  * box: the corner nearest negative infinity, relative to `position` before rotation.
4515
4993
  */
4516
- min: Vector3 | undefined;
4994
+ min?: Vector3 | undefined;
4517
4995
 
4518
4996
  /**
4519
4997
  * box: the opposite corner. Every component must be above `min`'s.
4520
4998
  */
4521
- max: Vector3 | undefined;
4999
+ max?: Vector3 | undefined;
4522
5000
 
4523
5001
  /**
4524
5002
  * shape: 3 to 256 corners relative to `position` before rotation, closed back to the first. As in the engine, the floor is the lowest corner.
4525
5003
  */
4526
- points: Vector3[] | undefined;
5004
+ points?: Vector3[] | undefined;
4527
5005
 
4528
5006
  /**
4529
5007
  * shape: how far above its lowest corner the area reaches; 0, the default, for no ceiling.
4530
5008
  */
4531
- height: number | undefined;
5009
+ height?: number | undefined;
4532
5010
 
4533
5011
  /**
4534
5012
  * sphere: its radius around `position`.
4535
5013
  */
4536
- radius: number | undefined;
5014
+ radius?: number | undefined;
4537
5015
 
4538
5016
  /**
4539
5017
  * Free-form labels, found again with `Area.withLabel`.
4540
5018
  */
4541
- labels: string[] | undefined;
5019
+ labels?: string[] | undefined;
4542
5020
 
4543
5021
  /**
4544
5022
  * Anything JSON can hold, kept on the area for scripts.
4545
5023
  */
4546
- metadata: Record<string, unknown> | undefined;
5024
+ metadata?: Record<string, unknown> | undefined;
4547
5025
 
4548
5026
  /**
4549
5027
  * The one virtual world it belongs to; every world when omitted.
4550
5028
  */
4551
- virtualWorld: number | undefined;
5029
+ virtualWorld?: number | undefined;
4552
5030
 
4553
5031
  /**
4554
5032
  * Whether it starts enabled; true when omitted.
4555
5033
  */
4556
- enabled: boolean | undefined;
5034
+ enabled?: boolean | undefined;
4557
5035
  }
4558
5036
 
4559
5037
  /** */
@@ -4772,32 +5250,97 @@ declare global {
4772
5250
  }
4773
5251
 
4774
5252
  /**
4775
- * Replicated container handle: one a script spawned, or one the level places.
5253
+ * A named world export loaded from mod.world_resources. Server-owned, with live access to its surviving props, effects, level edits and areas. Obtain handles through all or find; runtime loading, reloading and unloading are not exposed.
5254
+ */
5255
+ class WorldResource {
5256
+ private constructor();
5257
+
5258
+ /**
5259
+ * Unique case-sensitive resource name: the filename without .world.json, or the explicit config name. Empty after shutdown.
5260
+ */
5261
+ readonly name: string;
5262
+
5263
+ /**
5264
+ * Resolved absolute source file path, in UTF-8. Empty after shutdown.
5265
+ */
5266
+ readonly path: string;
5267
+
5268
+ /**
5269
+ * The exported game level, checked against the server level at startup. Empty after shutdown.
5270
+ */
5271
+ readonly level: string;
5272
+
5273
+ /**
5274
+ * Whether this export is registered. Remains true even if scripts destroy all of its contents.
5275
+ */
5276
+ readonly loaded: boolean;
5277
+
5278
+ /**
5279
+ * A fresh array of surviving props in export order. Changing the array does not change membership; the handles support normal Prop operations.
5280
+ */
5281
+ readonly props: Prop[];
5282
+
5283
+ /**
5284
+ * A fresh array of surviving effects in export order, excluding destroyed effects.
5285
+ */
5286
+ readonly effects: Vfx[];
5287
+
5288
+ /**
5289
+ * A fresh array of surviving level edits in export order, excluding restored edits.
5290
+ */
5291
+ readonly levelEdits: LevelEdit[];
5292
+
5293
+ /**
5294
+ * A fresh array of surviving exported areas in export order, excluding destroyed areas.
5295
+ */
5296
+ readonly areas: Area[];
5297
+
5298
+ /**
5299
+ * True after every configured export has loaded successfully, even when the config list is empty. Check this before subscribing to worldResourcesReady when a script may start later.
5300
+ */
5301
+ static readonly ready: boolean;
5302
+
5303
+ /**
5304
+ * Lists config-loaded world exports in configuration order. Empty before successful startup and after shutdown.
5305
+ * @returns A fresh array of resource handles.
5306
+ */
5307
+ static all(): WorldResource[];
5308
+
5309
+ /**
5310
+ * Finds a config-loaded export by name. Throws for a non-string argument.
5311
+ * @param name Exact, case-sensitive resource name.
5312
+ * @returns The resource, or null when absent or startup has not completed.
5313
+ */
5314
+ static find(name: string): WorldResource | null;
5315
+ }
5316
+
5317
+ /**
5318
+ * Container handle for a spawned chest, a level chest, or virtual stock without a world entity.
4776
5319
  */
4777
5320
  class Stash {
4778
5321
  /**
4779
- * Creates a script wrapper for an existing container with this ID; use Stash.spawn() to spawn one, or Stash.find() for one the level places.
5322
+ * Creates a script wrapper for an existing container with this ID; use Stash.spawn() for a chest, Stash.createVirtual() for stock without a chest, or Stash.find() for one the level places.
4780
5323
  * @param id Network entity identifier.
4781
5324
  */
4782
5325
  constructor(id: number);
4783
5326
 
4784
5327
  /**
4785
- * The identity every client turns into the same native container, for one a script spawned. Minted by the server from 1, and not `id`, which is the replication entity's. 0 for a container the level places.
5328
+ * The server-minted identity of a scripted chest or virtual stash, from 1. Distinct from the network entity id. Virtual stashes use it for an inventory GUID without creating a chest. 0 for a level chest.
4786
5329
  */
4787
5330
  readonly stashId: number;
4788
5331
 
4789
5332
  /**
4790
- * The EntityGuid every client finds this container under, as sixteen lowercase hex digits: the level's own for a container the level places, the one minted when a script spawned it otherwise. Every container has one, and `Stash.find` takes it back.
5333
+ * The EntityGuid every client finds this container under, as sixteen lowercase hex digits: the level's own for a container the level places, the one minted when a script spawned it otherwise. Empty for virtual stock; `Stash.find` takes physical container GUIDs back.
4791
5334
  */
4792
5335
  readonly guid: string;
4793
5336
 
4794
5337
  /**
4795
- * The level's own EntityGuid for a container the level places, as sixteen lowercase hex digits; empty for one a script spawned. The same on every machine, so it is the identity to store a container under; `Stash.find` takes it back.
5338
+ * The level's own EntityGuid for a container the level places, as sixteen lowercase hex digits; empty for a scripted chest or virtual stock. The same on every machine, so it is the identity to store a container under; `Stash.find` takes it back.
4796
5339
  */
4797
5340
  readonly levelGuid: string;
4798
5341
 
4799
5342
  /**
4800
- * The entity name the level gives the container, or `spawned_stash_<stashId>` for one a script spawned.
5343
+ * The entity name the level gives the container, or `spawned_stash_<stashId>` for a scripted chest; empty for virtual stock.
4801
5344
  */
4802
5345
  readonly name: string;
4803
5346
 
@@ -4807,10 +5350,15 @@ declare global {
4807
5350
  readonly itemCount: number;
4808
5351
 
4809
5352
  /**
4810
- * Whether a player has it open. Every client animates the lid by it.
5353
+ * Whether a player holds its view. Physical chests animate their lid by it; virtual stashes have no lid.
4811
5354
  */
4812
5355
  readonly isOpen: boolean;
4813
5356
 
5357
+ /**
5358
+ * Whether this stash has stock without a chest entity. Open it with open(player); its position and rotation do not govern access, and guid is empty.
5359
+ */
5360
+ readonly isVirtual: boolean;
5361
+
4814
5362
  /**
4815
5363
  * The network ID of the player who has its contents open, or 0. While it is held, every other player's open is refused before their transfer screen appears.
4816
5364
  */
@@ -4853,10 +5401,16 @@ declare global {
4853
5401
  toString(): string;
4854
5402
 
4855
5403
  /**
4856
- * Despawns this container on every client and forgets what was in it. Anything inside goes with it. Does nothing to a container the level places.
5404
+ * Destroys this scripted chest or virtual stash and forgets what was in it. Anything inside goes with it. Does nothing to a container the level places.
4857
5405
  */
4858
5406
  destroy(): void;
4859
5407
 
5408
+ /**
5409
+ * Opens a virtual stash from anywhere in its virtual world. Calls stashInteract before granting exclusive access. Returns false for a physical stash, a locked or busy stash, an unavailable player, or a script refusal. A true result requests the screen; the client releases access if it cannot open.
5410
+ * @param player Player whose native transfer screen should open.
5411
+ */
5412
+ open(player: Player): boolean;
5413
+
4860
5414
  /**
4861
5415
  * Reads what the container holds. A linked child reads its master's.
4862
5416
  * @returns A copy of its rows, or null once the container is gone.
@@ -4878,6 +5432,12 @@ declare global {
4878
5432
  */
4879
5433
  setInventory(request: { items: { id?: string; item: string; amount: number; metadata?: Record<string, unknown> }[]; revision?: number }): InventoryResult;
4880
5434
 
5435
+ /**
5436
+ * Creates empty server-owned stock without spawning a chest on any client. Supports the same inventory methods and events as physical stashes. Use open(player) to show the native transfer screen, and destroy() to discard it. Contents last until destroyed or the server restarts.
5437
+ * @param virtualWorld World whose players may open it, as a uint32 number; defaults to the global world. Invalid values throw before creating stock.
5438
+ */
5439
+ static createVirtual(virtualWorld?: number): Stash;
5440
+
4881
5441
  /**
4882
5442
  * Spawns and replicates an empty container. Fill it with `addItem` or `setInventory`, or let players put things in it.
4883
5443
  * @param position Optional world-space spawn position; omitted components default to zero.
@@ -4888,7 +5448,7 @@ declare global {
4888
5448
  static spawn(position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, virtualWorld?: number): Stash;
4889
5449
 
4890
5450
  /**
4891
- * Lists every container the server currently has: every one the level places, which exist from boot in the global world, and every one a script spawned. In another virtual world a level container is built the first time anything there reaches it, so this lists only those.
5451
+ * Lists every container the server currently has: every one the level places, which exist from boot in the global world, and every scripted chest or virtual stash. In another virtual world a level container is built the first time anything there reaches it, so this lists only those.
4892
5452
  * @returns One handle per live container, in no particular order.
4893
5453
  */
4894
5454
  static all(): Stash[];
@@ -4909,7 +5469,7 @@ declare global {
4909
5469
  static find(guid: string, virtualWorld?: number): Stash | null;
4910
5470
 
4911
5471
  /**
4912
- * Finds the container nearest a point, level or spawned. The server knows where every container the level places stands, so this answers at once, without asking a client.
5472
+ * Finds the physical container nearest a point, level or spawned. Virtual stock is excluded. The server knows where every container the level places stands, so this answers at once, without asking a client.
4913
5473
  * @param position The point to measure from, usually a player's position.
4914
5474
  * @param maxDistance How far to look, in metres; omitted looks 5 m, about the reach the game gives a chest.
4915
5475
  * @param virtualWorld Optional virtual world to look in; omitted looks in the global one.
@@ -4918,7 +5478,7 @@ declare global {
4918
5478
  static nearest(position: Vector3 | Partial<Vector3>, maxDistance?: number, virtualWorld?: number): Stash | null;
4919
5479
 
4920
5480
  /**
4921
- * Despawns containers a script spawned, and everything in them with them. The level's own stay.
5481
+ * Destroys scripted chests and virtual stashes, including everything inside. The level's own stay.
4922
5482
  * @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
4923
5483
  * @returns How many containers were removed.
4924
5484
  */
@@ -5124,15 +5684,35 @@ declare global {
5124
5684
  distance: number;
5125
5685
 
5126
5686
  /**
5127
- * The surface type's own name, spelled the way the game's tables spell it -- `mat_wood`, `mat_stone`, `mat_water`. This is what a trace is worth over a position: it says what was hit, not just where. Empty only before the material tables are up.
5687
+ * The surface type's own name, spelled the way the game's tables spell it in `Libs/MaterialEffects/SurfaceTypes.xml` -- `mat_wood`, `mat_rock`, `mat_soil`, `mat_water`. It says what the thing is made of, which is how footsteps and blows sound, not what it is: a plank wall is `mat_wood` as much as a trunk is, so tell a tree by `category`. Among the 74 the game defines: `mat_wood`, `mat_wood_soft`, `mat_vegetation`, `mat_bushes`, `mat_rock`, `mat_rock_unwalk`, `mat_rock_horse_ignore`, `mat_stairs_stone`, `mat_gravel`, `mat_soil`, `mat_mud`, `mat_grass`, `mat_road`, `mat_metal`, `mat_glass`, `mat_plaster`, `mat_thatch`, `mat_fabric`, `mat_flesh`. Empty only before the material tables are up.
5128
5688
  */
5129
5689
  surface: string;
5130
5690
 
5131
5691
  /**
5132
- * Whether the ground itself was hit rather than anything placed on it. Nothing lies behind the terrain, so a trace stops there.
5692
+ * Whether the ground itself was hit rather than anything placed on it. Nothing lies behind the terrain, so a trace stops there. The same as `kind` being `terrain`.
5133
5693
  */
5134
5694
  terrain: boolean;
5135
5695
 
5696
+ /**
5697
+ * What sort of thing the ray stopped on. `entity` is anything with an `entityClass` -- doors, props, NPCs, players. `vegetation` is an instance the level paints on: trees, bushes, plants, and boulders painted the same way. `brush` is a static mesh placed one by one: walls, houses, rocks and cliffs. `static` is static geometry that is neither, or whose source the engine does not record. Trees and rocks are not entities, so for them this, `model` and `category` are what say what was hit.
5698
+ */
5699
+ kind: "terrain" | "entity" | "vegetation" | "brush" | "static";
5700
+
5701
+ /**
5702
+ * The mesh of a vegetation instance or a brush, as the path the game loads it from -- `objects/natural/vegetation/trees/normal_trees/quercus_robur/quercus_robur_big_a.cgf`. Null for terrain, entities and `static`. A tree or a rock has no GUID, but its `model` and `position` together are the same on every client on the same level, which is what a server keeps a felled tree or a mined rock by.
5703
+ */
5704
+ model: string | null;
5705
+
5706
+ /**
5707
+ * Which of the game's own folders of natural objects `model` comes from: `tree` for `objects/natural/vegetation/trees` -- living, dead, fallen and stumps alike, which `model` tells apart -- `bush` for its bushes, `plant` for the rest of its vegetation (grass, ferns, mushrooms, branches), and `rock` for `objects/natural/rocks` and `objects/natural/stones`. Null for anything else, man-made included.
5708
+ */
5709
+ category: "tree" | "bush" | "plant" | "rock" | null;
5710
+
5711
+ /**
5712
+ * The material drawn where the ray met it, as the path the material manager keys it by, the sub-material when the mesh has several -- a trunk's bark rather than the tree's whole material. Null for terrain and when nothing names one.
5713
+ */
5714
+ material: string | null;
5715
+
5136
5716
  /**
5137
5717
  * The level's own identity for what was hit, as sixteen lowercase hex digits -- the same on every machine, and what `Door.find` and the other GUID lookups take. Null for terrain, for static geometry and for anything the session spawned, none of which the level names.
5138
5718
  */
@@ -6932,6 +7512,8 @@ declare global {
6932
7512
  * Arbitrary key/value state attached to one replicated entity, reached as `entity.state`. Keys set on the server replicate to every client that can currently see the entity.
6933
7513
  */
6934
7514
  class StateBag {
7515
+ private constructor();
7516
+
6935
7517
  /**
6936
7518
  * Reads one key from this entity's state.
6937
7519
  * @param key Key to read.