@kingdomsconnected/types 1.6.0 → 1.6.2

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.
@@ -37,6 +37,11 @@ declare global {
37
37
  */
38
38
  progressionPerkRefused: [perk: string, reason: "points" | "level" | "parent" | "exclusive" | "blocked" | "script" | "owned" | "hidden"];
39
39
 
40
+ /**
41
+ * Dispatched when a monologue line of the local character -- a photo-mode comment, the sharpening remark -- was kept silent and unsubtitled. `text` is localized; `textKey` is its localization key. Not raised while `Hud.setMonologueEnabled(true)` has released it. Handler promises are not awaited.
42
+ */
43
+ monologueSuppressed: [text: string, textKey: string];
44
+
40
45
  /**
41
46
  * Dispatched when this player starts or stops following a server quest in the game's journal, whichever way it happened: the track button, the game auto-tracking a quest that turns active, or the untrack that follows finishing or failing one. Local to this machine and raised before the server is told; the server raises its own `questTrackingChanged` when the report arrives. Repeats are filtered, so it only fires on an actual change. Handler promises are not awaited.
42
47
  */
@@ -94,6 +99,16 @@ declare global {
94
99
  */
95
100
  bookClosed: [bookId: number, reason: "player" | "script" | "failed" | "sessionOver"];
96
101
 
102
+ /**
103
+ * The local native follow action has entered. A successful start request may still fail before this event.
104
+ */
105
+ followStarted: [target: FollowTarget];
106
+
107
+ /**
108
+ * A queued or active scripted follow ended on this client.
109
+ */
110
+ followStopped: [target: FollowTarget, reason: "script" | "input" | "targetLost" | "mountChanged" | "teleported" | "unavailable" | "interrupted" | "failed" | "resourceStopped" | "sessionEnded" | "worldChanged"];
111
+
97
112
  /**
98
113
  * Dispatched once for every creator, on this machine only, whatever ended it. `appearance` is the look the player accepted, and null for every other ending. `reason` is `accepted`, `cancelled` for the player backing out, `closed` for `CharacterCreator.close`, `replaced` for another `CharacterCreator.open`, `unavailable` when the stage could not be put up, and `interrupted` when the session or the body went away under it. Nothing is put on the body: send the look wherever it should go -- `Events.emitServer`, then `player.setAppearance` on the server -- or open the next creator straight from the handler.
99
114
  */
@@ -178,6 +193,161 @@ declare global {
178
193
  /** Names of native events available in this scripting environment. */
179
194
  type EventName = keyof EventMap;
180
195
 
196
+ /**
197
+ * Writable player stats, in native units. Use getStat and the server's setStat.
198
+ */
199
+ const PlayerStat: {
200
+ /**
201
+ * Current health, in native units. Zero can kill.
202
+ */
203
+ readonly Health: "health";
204
+
205
+ /**
206
+ * Current stamina; the game continues spending and regenerating it.
207
+ */
208
+ readonly Stamina: "stamina";
209
+
210
+ /**
211
+ * Current energy reserve; higher means better rested.
212
+ */
213
+ readonly Exhaust: "exhaust";
214
+
215
+ /**
216
+ * Current nourishment; higher means better fed.
217
+ */
218
+ readonly Hunger: "hunger";
219
+ };
220
+
221
+ /**
222
+ * Read-only computed player stats. Use getDerivedStat; these values cannot be passed to setStat.
223
+ */
224
+ const DerivedPlayerStat: {
225
+ /**
226
+ * Total bleeding strength.
227
+ */
228
+ readonly Bleeding: "bleeding";
229
+
230
+ /**
231
+ * Sleepiness; above zero means asleep.
232
+ */
233
+ readonly Sleeping: "sleeping";
234
+
235
+ /**
236
+ * Consciousness; zero means knocked out.
237
+ */
238
+ readonly Consciousness: "consciousness";
239
+
240
+ /**
241
+ * Native drunkenness value.
242
+ */
243
+ readonly Drunkenness: "drunkenness";
244
+
245
+ /**
246
+ * Native poisoning value; not every named poison changes this value.
247
+ */
248
+ readonly Poisoning: "poisoning";
249
+
250
+ /**
251
+ * Effective charisma.
252
+ */
253
+ readonly Charisma: "charisma";
254
+
255
+ /**
256
+ * Effective visibility.
257
+ */
258
+ readonly Visibility: "visibility";
259
+
260
+ /**
261
+ * Effective conspicuousness.
262
+ */
263
+ readonly Conspicuousness: "conspicuousness";
264
+
265
+ /**
266
+ * Effective noise.
267
+ */
268
+ readonly Noise: "noise";
269
+
270
+ /**
271
+ * Native dirtiness reading; reading it does not clean the body or equipment.
272
+ */
273
+ readonly Dirtiness: "dirtiness";
274
+
275
+ /**
276
+ * Native bloodiness reading.
277
+ */
278
+ readonly Bloodiness: "bloodiness";
279
+
280
+ /**
281
+ * Native smell reading.
282
+ */
283
+ readonly Smell: "smell";
284
+
285
+ /**
286
+ * Native smell intensity.
287
+ */
288
+ readonly SmellIntensity: "smellIntensity";
289
+
290
+ /**
291
+ * Native fragrance reading.
292
+ */
293
+ readonly Fragrance: "fragrance";
294
+
295
+ /**
296
+ * Carried weight in the same units as InventoryCapacity.
297
+ */
298
+ readonly CarriedWeight: "carriedWeight";
299
+
300
+ /**
301
+ * Native carrying capacity, including applicable equipment effects.
302
+ */
303
+ readonly InventoryCapacity: "inventoryCapacity";
304
+
305
+ /**
306
+ * Native encumbrance reading.
307
+ */
308
+ readonly Encumbrance: "encumbrance";
309
+
310
+ /**
311
+ * Native hangover reading.
312
+ */
313
+ readonly Hangover: "hangover";
314
+
315
+ /**
316
+ * Computed alcoholism reading, not the persistent soul resource.
317
+ */
318
+ readonly Alcoholism: "alcoholism";
319
+
320
+ /**
321
+ * Effective armor rating.
322
+ */
323
+ readonly ArmorRating: "armorRating";
324
+
325
+ /**
326
+ * Overall armor defense.
327
+ */
328
+ readonly OverallArmorDefense: "overallArmorDefense";
329
+
330
+ /**
331
+ * Overall weapon attack.
332
+ */
333
+ readonly OverallWeaponAttack: "overallWeaponAttack";
334
+
335
+ /**
336
+ * Normalized run speed; not world-space velocity.
337
+ */
338
+ readonly NormalizedRunSpeed: "normalizedRunSpeed";
339
+
340
+ /**
341
+ * Native base run speed.
342
+ */
343
+ readonly RunSpeedBase: "runSpeedBase";
344
+
345
+ /**
346
+ * Native morale reading.
347
+ */
348
+ readonly Morale: "morale";
349
+ };
350
+
181
351
  /**
182
352
  * How a player's body looks: four of the game's own character-component names, and the gender whose catalog they come from.
183
353
  *
@@ -670,12 +840,12 @@ declare global {
670
840
  readonly healthyStamina: number;
671
841
 
672
842
  /**
673
- * Current tiredness, in the game's own units.
843
+ * Current energy reserve, in the game's own units. Higher means better rested.
674
844
  */
675
845
  readonly exhaust: number;
676
846
 
677
847
  /**
678
- * Tiredness capacity, in the game's own units.
848
+ * Maximum energy reserve, in the game's own units.
679
849
  */
680
850
  readonly maxExhaust: number;
681
851
 
@@ -745,7 +915,7 @@ declare global {
745
915
  readonly relativeSkills: SoulSkills;
746
916
 
747
917
  /**
748
- * The velocity the body's own animation was driven by this frame, not the one its physics settled on.
918
+ * On the owning machine, the velocity the body's own animation was driven by this frame, not the one its physics settled on. Everywhere else, measured from successive replicated positions.
749
919
  */
750
920
  readonly velocity: Vector3;
751
921
 
@@ -759,21 +929,6 @@ declare global {
759
929
  */
760
930
  readonly inAir: boolean;
761
931
 
762
- /**
763
- * The engine's own locomotion pace tag -- walk, jog, sprint -- as its animation system picked it. Raw Mannequin tag ids; 255 means nothing is set.
764
- */
765
- readonly moveSpeedTag: number;
766
-
767
- /**
768
- * The engine's own movement direction tag. Raw Mannequin tag ids; 255 means nothing is set.
769
- */
770
- readonly moveDirTag: number;
771
-
772
- /**
773
- * The engine's own stance tag -- upright, sneaking, sitting, lying. Raw Mannequin tag ids; 255 means nothing is set.
774
- */
775
- readonly stanceTag: number;
776
-
777
932
  /**
778
933
  * Whether this player is crouched, as their own game's crouch action reports it. False once their body is gone.
779
934
  */
@@ -830,12 +985,27 @@ declare global {
830
985
  readonly perks: string[];
831
986
 
832
987
  /**
833
- * Whether this handle is the player sitting at this machine, rather than someone else's puppet.
988
+ * The locomotion pace tag -- walk, jog, sprint -- this machine's animation system picked for this body. Raw Mannequin tag ids; 255 means nothing is set.
989
+ */
990
+ readonly moveSpeedTag: number;
991
+
992
+ /**
993
+ * The movement direction tag this machine's animation system picked for this body. Raw Mannequin tag ids; 255 means nothing is set.
994
+ */
995
+ readonly moveDirTag: number;
996
+
997
+ /**
998
+ * The stance tag -- upright, sneaking, sitting, lying -- this machine's animation system picked for this body. Raw Mannequin tag ids; 255 means nothing is set.
999
+ */
1000
+ readonly stanceTag: number;
1001
+
1002
+ /**
1003
+ * Whether this handle is the player sitting at this machine, rather than someone else's copy.
834
1004
  */
835
1005
  readonly local: boolean;
836
1006
 
837
1007
  /**
838
- * The engine entity this body was spawned as, or 0 across a level load and before the puppet exists. Not stable across a session: the engine reuses entity ids.
1008
+ * The engine entity behind this player: the game's own player entity for the local player, otherwise the entity the copy was spawned as, or 0 across a level load and before it exists. Not stable across a session: the engine reuses entity ids.
839
1009
  */
840
1010
  readonly entityId: number;
841
1011
 
@@ -862,6 +1032,18 @@ declare global {
862
1032
  */
863
1033
  toString(): string;
864
1034
 
1035
+ /**
1036
+ * Reads the latest reported stat in native units. Returns zero when no valid body snapshot exists; check player.ready to distinguish that from a real zero. Throws for an unknown stat or invalid arguments.
1037
+ * @param stat A PlayerStat value.
1038
+ */
1039
+ getStat(stat: "health" | "stamina" | "exhaust" | "hunger"): number;
1040
+
1041
+ /**
1042
+ * Reads a computed stat from the latest body snapshot. Bleeding, Sleeping, Consciousness, Drunkenness and Poisoning follow the body as it changes; the others are sampled about every 250 ms to a hundredth of a native unit, then replicated. Values use native units and can be negative; they are not universally percentages. Returns zero without a valid snapshot. Throws for an unknown stat or invalid arguments. These readings do not override another player's native calculations.
1043
+ * @param stat A DerivedPlayerStat value.
1044
+ */
1045
+ getDerivedStat(stat: "bleeding" | "sleeping" | "consciousness" | "drunkenness" | "poisoning" | "charisma" | "visibility" | "conspicuousness" | "noise" | "dirtiness" | "bloodiness" | "smell" | "smellIntensity" | "fragrance" | "carriedWeight" | "inventoryCapacity" | "encumbrance" | "hangover" | "alcoholism" | "armorRating" | "overallArmorDefense" | "overallWeaponAttack" | "normalizedRunSpeed" | "runSpeedBase" | "morale"): number;
1046
+
865
1047
  /**
866
1048
  * Where the local player stands on one track: level, XP towards the next one, and unspent perk points. Only the local player carries XP and points; for anyone else this is null.
867
1049
  * @param track A track name, from `Progression.tracks()`.
@@ -1043,6 +1225,18 @@ declare global {
1043
1225
  */
1044
1226
  isElementVisible(element: string): boolean;
1045
1227
 
1228
+ /**
1229
+ * The local character's own monologue -- photo-mode comments, the sharpening remark -- is spoken in Henry's voice and captioned with his name whoever is playing, so multiplayer suppresses it and raises each line as `monologueSuppressed`. Releasing it lasts until the session ends.
1230
+ * @param enabled True lets the game voice and subtitle it again; false suppresses it.
1231
+ */
1232
+ setMonologueEnabled(enabled: boolean): void;
1233
+
1234
+ /**
1235
+ * Whether the game voices and subtitles the local character's monologue.
1236
+ * @returns False while multiplayer suppresses it, which is the default.
1237
+ */
1238
+ isMonologueEnabled(): boolean;
1239
+
1046
1240
  /**
1047
1241
  * Every effect `addScreenEffect` accepts, with each parameter's range, default and neutral value.
1048
1242
  * @returns The effects, in a fixed order.
@@ -1093,6 +1287,13 @@ declare global {
1093
1287
  * @returns False once it has been removed and faded, has run its duration out, or was dropped by its resource stopping, the session ending or the level changing.
1094
1288
  */
1095
1289
  isScreenEffectActive(handle: number): boolean;
1290
+
1291
+ /**
1292
+ * Projects a world point through the camera this frame is drawn with, so a resource can pin its own overlay to the world.
1293
+ * @param point World position to project.
1294
+ * @returns Its screen position, or null when the point is behind the camera or there is no view to place it in.
1295
+ */
1296
+ worldToScreen(point: Vector3): ScreenPoint | null;
1096
1297
  };
1097
1298
 
1098
1299
  /**
@@ -1150,6 +1351,26 @@ declare global {
1150
1351
  params: ScreenEffectParam[];
1151
1352
  }
1152
1353
 
1354
+ /**
1355
+ * Where a world point lands on screen, in the pixels Web views are placed in.
1356
+ */
1357
+ interface ScreenPoint {
1358
+ /**
1359
+ * Pixels from the left edge of the window's client area.
1360
+ */
1361
+ x: number;
1362
+
1363
+ /**
1364
+ * Pixels from the top edge of the window's client area.
1365
+ */
1366
+ y: number;
1367
+
1368
+ /**
1369
+ * Whether the point is inside the view. One past an edge keeps its coordinates with this false.
1370
+ */
1371
+ onScreen: boolean;
1372
+ }
1373
+
1153
1374
  /**
1154
1375
  * The game's own sound triggers, played at this machine. A trigger is a name the game's audio data declares -- `a_o_bell_kkut_kostelni`, `c_torch_whoosh1`, `f_ge_cough_woman` -- standing for an FMOD event. The full vocabulary is `Libs/GameAudio/*.xml` in `IPL_GameData.pak`, with the gameplay-facing subset listed in `Libs/Tables/GameAudio/SkaldAtlTrigger.xml`. Nothing here is replicated: a sound everyone should hear is one the server tells every client to play. Every call returns false while the audio system is not up, which is the case before a world is loaded, and for a trigger name the audio data does not declare.
1155
1376
  */
@@ -1228,7 +1449,7 @@ declare global {
1228
1449
  };
1229
1450
 
1230
1451
  /**
1231
- * What the server streams, seen from this machine. Models, materials, textures, sounds and particle libraries a server streams load by path like the game's own -- `objects/kcdc/<resource>/chair.cgf` works wherever a model path does -- so nothing here is needed to use them. Clips play through the server's `playClip`.
1452
+ * What the server streams, seen from this machine. Models, materials, textures, sounds and particle libraries a server streams load by path like the game's own -- `objects/kcdc/<resource>/chair.cgf` works wherever a model path does -- so nothing here is needed to use them. Clips play through the server's `playAnimation("", { clip })`.
1232
1453
  */
1233
1454
  const Assets: {
1234
1455
  /**
@@ -2539,12 +2760,12 @@ declare global {
2539
2760
  /**
2540
2761
  * The world builder: a free camera, the game's mesh catalog as an asset library, a placement brush, a gizmo that moves anything, and maps saved to and loaded from files.
2541
2762
  *
2542
- * No key opens it. A resource decides when it does, and only on a server whose `server.json` sets `mod.map_editor` to true; anywhere else `open` refuses. While it is open it holds the one free camera, so a `NoClip` flight in progress ends and `NoClip.enable` refuses. The player can still close it from its own window.
2763
+ * F7 or a client resource opens it. Multiplayer requires the server to grant this player access with `player.setWorldBuilderEnabled(true)`; single-player and offline editing are always allowed. While it is open it holds the one free camera, so a `NoClip` flight in progress ends and `NoClip.enable` refuses. The player can still close it from its own window.
2543
2764
  */
2544
2765
  const MapEditor: {
2545
2766
  /**
2546
2767
  * Opens the editor.
2547
- * @returns `opened` when it opened. `alreadyOpen` when it was open already. `disabled` when the server has not turned `mod.map_editor` on, which includes no session at all.
2768
+ * @returns `opened` when it opened. `alreadyOpen` when it was open already. `disabled` when this multiplayer connection has not been granted access.
2548
2769
  */
2549
2770
  open(): "opened" | "alreadyOpen" | "disabled";
2550
2771
 
@@ -2561,8 +2782,8 @@ declare global {
2561
2782
  isOpen(): boolean;
2562
2783
 
2563
2784
  /**
2564
- * Whether the connected server lets the editor open.
2565
- * @returns True when its `server.json` sets `mod.map_editor` to true.
2785
+ * Whether this client may open World Builder.
2786
+ * @returns True offline or when the server has granted this player access.
2566
2787
  */
2567
2788
  isEnabled(): boolean;
2568
2789
  };
@@ -3213,6 +3434,68 @@ declare global {
3213
3434
  image(path: string): string;
3214
3435
  };
3215
3436
 
3437
+ /**
3438
+ * A streamed player or human NPC. Its network identity is resolved again when follow starts; position and name are snapshots.
3439
+ */
3440
+ interface FollowTarget {
3441
+ /**
3442
+ * The target's network id.
3443
+ */
3444
+ id: number;
3445
+
3446
+ /**
3447
+ * Which replicated entity the id identifies.
3448
+ */
3449
+ kind: "player" | "npc";
3450
+
3451
+ /**
3452
+ * Player nickname or NPC name.
3453
+ */
3454
+ name: string;
3455
+
3456
+ /**
3457
+ * Current native body position, in world-space metres.
3458
+ */
3459
+ position: Vector3;
3460
+ }
3461
+
3462
+ /**
3463
+ * Follow another player or a streamed human NPC using the local player's native walking or riding action. Native combat, interaction and mount restrictions still apply. Only one scripted follow can be queued or active. Movement input, target loss, mount changes and resource shutdown stop it. This controls only the local player; it does not command an NPC to follow.
3464
+ */
3465
+ const Follow: {
3466
+ /**
3467
+ * Lists streamed players and human NPCs within 20 metres. Use canStart to check whether one can currently be followed.
3468
+ */
3469
+ targets(): FollowTarget[];
3470
+
3471
+ /**
3472
+ * Checks the target and native follow restrictions, including the game's start distance.
3473
+ * @param target A remote player handle or a descriptor from targets().
3474
+ */
3475
+ canStart(target: Player | FollowTarget): boolean;
3476
+
3477
+ /**
3478
+ * Queues native follow for the calling resource. True means queued; followStarted confirms entry. False means the request was refused.
3479
+ * @param target Who the local player should follow.
3480
+ */
3481
+ start(target: Player | FollowTarget): boolean;
3482
+
3483
+ /**
3484
+ * The active scripted follow target, or null while idle or pending.
3485
+ */
3486
+ getTarget(): FollowTarget | null;
3487
+
3488
+ /**
3489
+ * Whether a scripted follow is queued but has not entered yet.
3490
+ */
3491
+ isPending(): boolean;
3492
+
3493
+ /**
3494
+ * Cancels the calling resource's queued or active follow. Other resources' follow actions are left alone.
3495
+ */
3496
+ stop(): void;
3497
+ };
3498
+
3216
3499
  /**
3217
3500
  * What `CharacterCreator.open` shows.
3218
3501
  */
@@ -3266,7 +3549,7 @@ declare global {
3266
3549
  *
3267
3550
  * A hint names one of the game's keys by its control -- `primary_action`, `jump` and the rest of `keys()` -- and never a physical key: the glyph is whatever the player has bound to that control, keyboard or pad, and follows a rebind. A press hint fires on the press; a hold hint draws the game's ring and fires once it fills.
3268
3551
  *
3269
- * Hints are drawn while the player is in control of their character, on foot or in the saddle, and the game takes them down in dialogue, minigames and menus. Two hints on one key stack: the newest is drawn and gets the press, and removing it brings back the one under it. A hint does not stop the game's own action on that key -- put a hint on `primary_action` and the player still interacts with whatever they look at.
3552
+ * Hints are drawn while the player is in control of their character, on foot or in the saddle, and the game takes them down in dialogue, minigames and menus. Two hints on one key stack: the newest is drawn and gets the press, and removing it brings back the one under it. A hint normally leaves the game's own action on that key enabled. `chat_focus_follow_init` replaces the native focus/follow toggle while its hint is shown, so a scripted Follow action receives one press.
3270
3553
  *
3271
3554
  * Client-only and local: a hint is shown to the player at this machine. Hints go when the resource that made them stops.
3272
3555
  */
@@ -4239,6 +4522,16 @@ declare global {
4239
4522
  * True in the authoritative server scripting runtime.
4240
4523
  */
4241
4524
  readonly isServer: boolean;
4525
+
4526
+ /**
4527
+ * Local Framework release version.
4528
+ */
4529
+ readonly frameworkVersion: string;
4530
+
4531
+ /**
4532
+ * Local mod version from InstanceOptions.modVersion; empty when unset.
4533
+ */
4534
+ readonly modVersion: string;
4242
4535
  };
4243
4536
 
4244
4537
  /**
@@ -4834,7 +5127,7 @@ declare global {
4834
5127
  update(): boolean;
4835
5128
 
4836
5129
  /**
4837
- * Clears the published Discord activity and resets staged state.
5130
+ * Clears what scripts published and resets staged state.
4838
5131
  * @returns True when dispatched; false when Discord is unavailable.
4839
5132
  */
4840
5133
  clear(): boolean;
@@ -5107,6 +5400,8 @@ declare global {
5107
5400
  * 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.
5108
5401
  */
5109
5402
  class StateBag {
5403
+ private constructor();
5404
+
5110
5405
  /**
5111
5406
  * Reads one key from this entity's state.
5112
5407
  * @param key Key to read.