@falloutmp/types 0.1.0 → 0.2.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.
@@ -1,4 +1,4 @@
1
- import type { EventHandler, MessageHandler, MessageReply, Quaternion, Unsubscribe, Vector3 } from "../shared.js";
1
+ import type { EventHandler, MessageHandler, MessageReply, Unsubscribe } from "../shared.js";
2
2
 
3
3
  declare global {
4
4
  /**
@@ -30,6 +30,21 @@ declare global {
30
30
  */
31
31
  playerShoot: [player: Player];
32
32
 
33
+ /**
34
+ * Dispatched when a player's game launches a projectile: a missile, a grenade in flight, a flame, or one an NPC it simulates launched (`npc`). `projectile` is the BGSProjectile form ID. Return `false` to refuse: nobody else sees it. It still flies on the shooter's own screen.
35
+ */
36
+ playerProjectile: [player: Player, projectile: number, npc: Npc | null];
37
+
38
+ /**
39
+ * Dispatched when a player's game reports them in another worldspace or interior: through a door, a fast travel or `teleport`. `previous` is null for the first space they report after joining.
40
+ */
41
+ playerSpaceChange: [player: Player, space: PlayerSpace, previous: PlayerSpace | null];
42
+
43
+ /**
44
+ * Dispatched when a player's game reports a new look after the one they joined with: the look editor closed, or `setLook`, `randomizeLook` or `setAppearance` changed it. `getAppearance` reads it.
45
+ */
46
+ playerAppearanceChange: [player: Player];
47
+
33
48
  /**
34
49
  * Dispatched when a player's game lands a hit on another player, before the victim takes it. Return `false` to drop the hit. `damage` is the attacker's game's own. `kind` is a shot or a blow, an explosion's blast, or a hazard the attacker left (a radiation or gas cloud), which casts its spell and carries no damage figure.
35
50
  */
@@ -50,6 +65,16 @@ declare global {
50
65
  */
51
66
  playerPowerArmor: [player: Player, entered: boolean];
52
67
 
68
+ /**
69
+ * Dispatched when the charge of the fusion core in a player's power armor changes, in whole units: their game drains it (a jump, among others), a new core is loaded, or `setPowerArmorBattery` set it. Not on getting in.
70
+ */
71
+ playerPowerArmorBattery: [player: Player, charge: number, previous: number];
72
+
73
+ /**
74
+ * Dispatched when a player's game takes a fusion core into their power armor or launches it out. `consumed`: the suit's core ran out and their game loaded the next one they carry. `inserted`: a core went into the empty suit as it reached them. `ejected`: they launched the core out of the suit (Nuclear Physicist), `core` null. `condition` is the core's charge in percent. Return `false` to refuse a core taken in: it goes back to their inventory, the suit keeps the charge it had and takes no other core until `setPowerArmorBattery` gives it a charge or they get out. A launch cannot be refused.
75
+ */
76
+ playerFusionCore: [player: Player, kind: "consumed" | "inserted" | "ejected", core: number | null, condition: number];
77
+
53
78
  /**
54
79
  * Dispatched for a chat line, before anyone sees it. Return `false` to swallow it.
55
80
  */
@@ -60,6 +85,11 @@ declare global {
60
85
  */
61
86
  playerCommand: [player: Player, command: string, args: string[]];
62
87
 
88
+ /**
89
+ * Dispatched when the running clock reaches a new whole hour, 0 to 23. `World.setHour` does not raise it.
90
+ */
91
+ worldHourChange: [hour: number];
92
+
63
93
  /**
64
94
  * Dispatched when a player opens or closes a door. Return `false` to refuse: their door swings back.
65
95
  */
@@ -75,6 +105,16 @@ declare global {
75
105
  */
76
106
  containerOpen: [player: Player, ref: number];
77
107
 
108
+ /**
109
+ * Dispatched when the player holding a container closes its menu; anyone may open it again.
110
+ */
111
+ containerClose: [player: Player, ref: number];
112
+
113
+ /**
114
+ * Dispatched when a player's game reports what a container holds now, after they put something in or took something out. To refuse a transfer, refuse the player's `inventoryChange`, which reverts the container with it.
115
+ */
116
+ containerChange: [player: Player, ref: number, items: InventoryItem[]];
117
+
78
118
  /**
79
119
  * Dispatched when a player drops an item. Return `false` to refuse: the item leaves the world and goes back into their inventory.
80
120
  */
@@ -86,10 +126,45 @@ declare global {
86
126
  itemPickUp: [player: Player, item: Item | null, ref: number | null];
87
127
 
88
128
  /**
89
- * Dispatched after the server accepted a change a player's game reported: looting, buying, crafting, using an item. Changes a script made itself do not raise it.
129
+ * Dispatched when a player's game reports a change the server would accept: looting, buying, crafting, using an item. Return `false` to refuse it: the server keeps its record and sends it back to their game, and any container involved keeps what it held. Changes a script made itself do not raise it.
90
130
  */
91
131
  inventoryChange: [player: Player, changes: InventoryDelta[]];
92
132
 
133
+ /**
134
+ * Dispatched once a player's character is established, shortly after they join: adopted from their game. Restore a kept character here with `setCharacter`. Character methods work from here.
135
+ */
136
+ playerCharacterLoad: [player: Player];
137
+
138
+ /**
139
+ * Dispatched when the player's game awards XP: a kill, a quest, a lock, a terminal, a workshop build. `amount` is the game's, Intelligence included. Return `false` to refuse it: their game takes it back.
140
+ */
141
+ playerXpGain: [player: Player, amount: number];
142
+
143
+ /**
144
+ * Dispatched when the character's level moves, by XP or by a script.
145
+ */
146
+ playerLevelChange: [player: Player, level: number, previous: number];
147
+
148
+ /**
149
+ * Dispatched when the player's game changes a perk rank: bought on the perk chart (after the server checked points, level, the rank below and SPECIAL), given by something in the game such as a magazine, or taken away. Return `false` to refuse it: their game undoes it.
150
+ */
151
+ playerPerkRequest: [player: Player, perk: number, kind: "buy" | "grant" | "remove"];
152
+
153
+ /**
154
+ * Dispatched when a perk rank was added to or taken from the character, by their game or by a script.
155
+ */
156
+ playerPerkChange: [player: Player, perk: number, added: boolean];
157
+
158
+ /**
159
+ * Dispatched when the player's game moves a SPECIAL base: the SPECIAL menu, a bobblehead, a book. `value` is its editor ID. Return `false` to refuse it: their game puts it back.
160
+ */
161
+ playerValueRequest: [player: Player, value: string, previous: number, base: number];
162
+
163
+ /**
164
+ * Dispatched when an actor value base on the character's record moved, by their game or by a script.
165
+ */
166
+ playerValueChange: [player: Player, value: string, base: number, previous: number];
167
+
93
168
  /**
94
169
  * Dispatched once a player's mine settles and is armed. Return `false` to refuse: it leaves the world unexploded.
95
170
  */
@@ -105,6 +180,51 @@ declare global {
105
180
  */
106
181
  mineRemove: [mine: Mine];
107
182
 
183
+ /**
184
+ * Dispatched when a player's game lands a hit on an NPC, before the NPC takes it. Return `false` to drop the hit. `damage` is the attacker's game's own; `kind` is a shot or a blow, or an explosion's blast.
185
+ */
186
+ npcHit: [attacker: Player, npc: Npc, damage: number, kind: "direct" | "blast"];
187
+
188
+ /**
189
+ * Dispatched when an NPC lands a hit on a player, before the victim takes it. Return `false` to drop the hit. `damage` is the game's own, from the client that runs the NPC.
190
+ */
191
+ npcAttack: [npc: Npc, victim: Player, damage: number, kind: "direct" | "blast"];
192
+
193
+ /**
194
+ * Dispatched once when an NPC dies. `killer` is the last player who hit it, or null. It comes back on its own a while later; `npcRespawn` follows.
195
+ */
196
+ npcDeath: [npc: Npc, killer: Player | null];
197
+
198
+ /**
199
+ * Dispatched when an NPC is back at its placement, whole: on its own after its death, or from `respawn`.
200
+ */
201
+ npcRespawn: [npc: Npc];
202
+
203
+ /**
204
+ * Dispatched when another player's game takes over running an NPC, or when nobody near does any more (`simulator` null) and the server walks it.
205
+ */
206
+ npcSimulatorChange: [npc: Npc, simulator: Player | null];
207
+
208
+ /**
209
+ * Dispatched when an NPC becomes a player's companion (`setLeader`), or follows nobody any more (`leader` null): let go, or its leader left.
210
+ */
211
+ npcLeaderChange: [npc: Npc, leader: Player | null];
212
+
213
+ /**
214
+ * Dispatched when a player builds an object in a settlement, before anyone else sees it. Return `false` to refuse: their game takes it back out. The recipe's components are theirs to have spent; the server cannot refund them.
215
+ */
216
+ workshopBuild: [player: Player, form: number, workbench: number, position: Vector3, angle: Vector3];
217
+
218
+ /**
219
+ * Dispatched when a player moves a built object, before anyone else sees it. Return `false` to refuse: the object is put back where it was for everyone, as a new `WorkshopItem`, and the old handle reads nothing.
220
+ */
221
+ workshopMove: [player: Player, item: WorkshopItem, position: Vector3, angle: Vector3];
222
+
223
+ /**
224
+ * Dispatched when a player scraps or stores a built object, before it goes for everyone. Return `false` to refuse: the object is put back for everyone, as a new `WorkshopItem`, and the old handle reads nothing. The player keeps what their game gave them for it.
225
+ */
226
+ workshopScrap: [player: Player, item: WorkshopItem];
227
+
108
228
  /**
109
229
  * Dispatched after a resource entry point has run and immediately before the resource becomes running.
110
230
  */
@@ -134,6 +254,27 @@ declare global {
134
254
  /** Names of native events available in this scripting environment. */
135
255
  type EventName = keyof EventMap;
136
256
 
257
+ /**
258
+ * The game this server runs, and the systems only some games have.
259
+ */
260
+ const Game: {
261
+ /**
262
+ * The game, as server.json's `mod.game` names it.
263
+ */
264
+ readonly id: "fo4" | "fo76";
265
+
266
+ /**
267
+ * The game's display name: "Fallout 4" or "Fallout 76".
268
+ */
269
+ readonly name: string;
270
+
271
+ /**
272
+ * Whether this game has the system. Settlements, companions, the perk chart and the SPECIAL creation menu are Fallout 4's; C.A.M.P., perk cards, teams and mutations are Fallout 76's. Every other binding exists on both.
273
+ * @param feature A system only some games have.
274
+ */
275
+ has(feature: "settlements" | "companions" | "perkChart" | "specialMenu" | "camp" | "perkCards" | "teams" | "mutations"): boolean;
276
+ };
277
+
137
278
  /**
138
279
  * Where a player is: the worldspace it stands in, or the interior cell, which has none.
139
280
  */
@@ -197,6 +338,16 @@ declare global {
197
338
  * The frame's TESFurniture form ID; null when the game created that record at runtime.
198
339
  */
199
340
  base: number | null;
341
+
342
+ /**
343
+ * The charge left in the inserted fusion core, in whole units rounded up; 0 when it is empty or there is none.
344
+ */
345
+ battery: number;
346
+
347
+ /**
348
+ * The inserted fusion core's capacity, 100 for the game's own; 0 while none was ever inserted.
349
+ */
350
+ batteryMax: number;
200
351
  }
201
352
 
202
353
  /**
@@ -212,6 +363,11 @@ declare global {
212
363
  * How many the player carries.
213
364
  */
214
365
  count: number;
366
+
367
+ /**
368
+ * The stack's condition in percent of full, 0 to 100: the charge a fusion core has left. 100 for an item that has none.
369
+ */
370
+ condition: number;
215
371
  }
216
372
 
217
373
  /**
@@ -230,9 +386,9 @@ declare global {
230
386
  readonly nickname: string;
231
387
 
232
388
  /**
233
- * Current health, as the player's game last reported it.
389
+ * Current health, as the player's game last reported it. Assigning asks their game to move it there, as `setValue("Health", value)` does; it reads the new value once they report it.
234
390
  */
235
- readonly health: number;
391
+ health: number;
236
392
 
237
393
  /**
238
394
  * Health at full.
@@ -310,7 +466,7 @@ declare global {
310
466
  readonly isInPowerArmor: boolean;
311
467
 
312
468
  /**
313
- * Takes the player out of their power armor; the frame stays where they stand. `playerPowerArmor` follows.
469
+ * Takes the player out of their power armor; the frame stays where they stand. `playerPowerArmor` follows once their game is done, which it is not while they fly the fly camera (`NoClip`): the game leaves the player's own update alone until the camera comes back.
314
470
  * @returns True when sent; false when the player is gone or not in power armor.
315
471
  */
316
472
  exitPowerArmor(): boolean;
@@ -340,12 +496,13 @@ declare global {
340
496
  toString(): string;
341
497
 
342
498
  /**
343
- * Moves the player within their current worldspace.
344
- * @param position Where to, in the worldspace the player is in.
499
+ * Moves the player, within their space or into another one. Into an interior they land at a persistent reference inside it, as a quest script moves the player, and `position` is not used: wait for `playerSpaceChange`, then teleport them within it. `playerSpaceChange` follows any change of space.
500
+ * @param position Where to, in the space the player goes to.
345
501
  * @param heading Facing in radians; the current one when left out.
346
- * @returns True when sent; false when the player is gone. Throws for a position that is not a finite Vector3.
502
+ * @param space Another worldspace or an interior cell, exactly one of the two; the one the player is in when left out.
503
+ * @returns True when sent; false when the player is gone, or the interior has no reference to land at. Throws for a position that is not a finite Vector3.
347
504
  */
348
- teleport(position: Vector3, heading?: number): boolean;
505
+ teleport(position: Vector3, heading?: number, space?: { worldSpace?: number | string; interiorCell?: number | string }): boolean;
349
506
 
350
507
  /**
351
508
  * Brings a dead player back at full health. Nothing respawns a player on its own: call this from `playerDeath`, at once or later.
@@ -369,6 +526,13 @@ declare global {
369
526
  */
370
527
  enterPowerArmor(frame?: number | string): boolean;
371
528
 
529
+ /**
530
+ * Sets the charge of the fusion core in the player's power armor, through the value their game drains. At 0 their game does what it does with an empty core: it loads the next fusion core they carry, or leaves the suit unpowered. Above the core's capacity the capacity follows. It also lifts the hold a refused core left the suit in. `playerPowerArmorBattery` follows.
531
+ * @param charge The charge to leave in the core, 0 to 1000; a full fusion core holds 100.
532
+ * @returns True when sent; false when the player is gone or not in power armor.
533
+ */
534
+ setPowerArmorBattery(charge: number): boolean;
535
+
372
536
  /**
373
537
  * The power armor frame the player wears.
374
538
  * @returns The frame, or null when they wear none or are gone.
@@ -423,9 +587,29 @@ declare global {
423
587
  */
424
588
  randomizeLook(seed?: number, morphsOnly?: boolean): boolean;
425
589
 
590
+ /**
591
+ * The player's whole look as their game last reported it, as an opaque string to keep (a database column) and hand back to `setAppearance`.
592
+ * @returns Null before their first report or once they are gone.
593
+ */
594
+ getAppearance(): string | null;
595
+
596
+ /**
597
+ * Puts a whole look back on the player: their game rebuilds them and everyone sees it. Throws for a look from another server version.
598
+ * @param look As `getAppearance` returned it on this server version.
599
+ * @returns True when sent; false when the player is gone.
600
+ */
601
+ setAppearance(look: string): boolean;
602
+
603
+ /**
604
+ * Names the player's character in their own game, as the Vault 111 registration form does: what the game's menus show, and what the SPECIAL menu requires before it closes. Others see the nametag, not this.
605
+ * @param name 1 to 64 characters.
606
+ * @returns True when sent; false when the player is gone.
607
+ */
608
+ setGameName(name: string): boolean;
609
+
426
610
  /**
427
611
  * What the player carries, from the server's record.
428
- * @returns One entry per stack; empty before the player's first report, shortly after they join, and once they are gone.
612
+ * @returns One entry per base object and condition; empty before the player's first report, shortly after they join, and once they are gone.
429
613
  */
430
614
  getInventory(): InventoryItem[];
431
615
 
@@ -440,20 +624,22 @@ declare global {
440
624
  * Puts items in the player's inventory. It does not equip them: see `equipItem`.
441
625
  * @param form The base object.
442
626
  * @param count How many, 1 to 1000000; one when left out.
627
+ * @param condition Their condition in percent of full, 0 to 100, as one stack: a fusion core's charge. Full when left out.
443
628
  * @returns True when the record changed; false before the player's first report or once they are gone.
444
629
  */
445
- giveItem(form: number | string, count?: number): boolean;
630
+ giveItem(form: number | string, count?: number, condition?: number): boolean;
446
631
 
447
632
  /**
448
633
  * Takes items out of the player's inventory.
449
634
  * @param form The base object.
450
635
  * @param count How many, 1 to 1000000; one when left out. More than they carry takes them all.
636
+ * @param condition The condition to take first, 0 to 100; the rest come from the fullest stacks. Full when left out.
451
637
  * @returns True when the record changed; false before the player's first report or once they are gone.
452
638
  */
453
- removeItem(form: number | string, count?: number): boolean;
639
+ removeItem(form: number | string, count?: number, condition?: number): boolean;
454
640
 
455
641
  /**
456
- * Sets how many of an item the player carries.
642
+ * Sets how many of an item the player carries, over every condition: more are added at full condition, fewer are taken from full stacks first.
457
643
  * @param form The base object.
458
644
  * @param count How many the player should carry, 0 to 1000000.
459
645
  * @returns True when the record changed; false before the player's first report or once they are gone.
@@ -474,6 +660,205 @@ declare global {
474
660
  */
475
661
  playIdle(idle: string | number): boolean;
476
662
 
663
+ /**
664
+ * An actor value as it stands: Health, ActionPoints and Rads as the player's game last reported them, any other the base the record holds.
665
+ * @param value An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
666
+ * @returns The value; null before the character is established or for a value the record does not hold.
667
+ */
668
+ getValue(value: string | number): number | null;
669
+
670
+ /**
671
+ * The base the character's record holds for an actor value: SPECIAL, Experience, and any base a script set.
672
+ * @param value An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
673
+ * @returns The base; null for one the record does not hold.
674
+ */
675
+ getBaseValue(value: string | number): number | null;
676
+
677
+ /**
678
+ * Sets an actor value's base on the record and in the player's game, as `ObjectReference.SetValue` does: for Health or CarryWeight that is the maximum. It is saved with the character and set again whenever they join.
679
+ * @param value An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
680
+ * @param base The new base. SPECIAL is rounded and kept within 1 to 11.
681
+ * @returns True when the record changed; false before the character is established.
682
+ */
683
+ setBaseValue(value: string | number, base: number): boolean;
684
+
685
+ /**
686
+ * Lowers an actor value's current value in the player's game, as `ObjectReference.DamageValue` does. Health damaged to 0 kills.
687
+ * @param value An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
688
+ * @param amount How much, at least 0. Rads rise by it.
689
+ * @returns True when sent; false when the player is gone.
690
+ */
691
+ damageValue(value: string | number, amount: number): boolean;
692
+
693
+ /**
694
+ * Raises an actor value's current value in the player's game up to its maximum, as `ObjectReference.RestoreValue` does.
695
+ * @param value An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
696
+ * @param amount How much, at least 0. Rads fall by it.
697
+ * @returns True when sent; false when the player is gone.
698
+ */
699
+ restoreValue(value: string | number, amount: number): boolean;
700
+
701
+ /**
702
+ * Moves an actor value's current value in the player's game, keeping its base.
703
+ * @param value An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
704
+ * @param current The current value to reach; no higher than the maximum.
705
+ * @returns True when sent; false when the player is gone.
706
+ */
707
+ setValue(value: string | number, current: number): boolean;
708
+
709
+ /**
710
+ * The character's level.
711
+ * @returns The level; 0 when the player is gone.
712
+ */
713
+ getLevel(): number;
714
+
715
+ /**
716
+ * Sets the character's level and their XP to the start of it. No perk points come with it: see `setPerkPoints`.
717
+ * @param level 1 to 65535.
718
+ * @returns True when the record changed; false before the character is established.
719
+ */
720
+ setLevel(level: number): boolean;
721
+
722
+ /**
723
+ * The character's total experience.
724
+ * @returns The XP; 0 when the player is gone.
725
+ */
726
+ getXp(): number;
727
+
728
+ /**
729
+ * Sets the character's total experience, and their level to match. No perk points come with it.
730
+ * @param xp The total, at least 0.
731
+ * @returns True when the record changed; false before the character is established.
732
+ */
733
+ setXp(xp: number): boolean;
734
+
735
+ /**
736
+ * Awards experience as the game does: each level it reaches brings a perk point and the game's level-up.
737
+ * @param amount More than 0. Not scaled by Intelligence.
738
+ * @returns True when the record changed; false before the character is established.
739
+ */
740
+ addXp(amount: number): boolean;
741
+
742
+ /**
743
+ * The character's unspent perk points.
744
+ * @returns The points; 0 when the player is gone.
745
+ */
746
+ getPerkPoints(): number;
747
+
748
+ /**
749
+ * Sets the character's unspent perk points.
750
+ * @param points 0 to 255.
751
+ * @returns True when the record changed; false before the character is established.
752
+ */
753
+ setPerkPoints(points: number): boolean;
754
+
755
+ /**
756
+ * The perk ranks the character holds. Each rank of a perk is a BGSPerk of its own.
757
+ * @returns Their form IDs; empty when the player is gone.
758
+ */
759
+ getPerks(): number[];
760
+
761
+ /**
762
+ * Whether the character holds a perk rank.
763
+ * @param perk A BGSPerk rank.
764
+ * @returns True when they hold it. Throws for a form ID that is no perk.
765
+ */
766
+ hasPerk(perk: number | string): boolean;
767
+
768
+ /**
769
+ * Gives the character a perk rank without spending a point.
770
+ * @param perk A BGSPerk rank.
771
+ * @param withLowerRanks Also give the ranks below it; true when left out.
772
+ * @returns True when the record changed; false before the character is established. Throws for a form ID that is no perk.
773
+ */
774
+ addPerk(perk: number | string, withLowerRanks?: boolean): boolean;
775
+
776
+ /**
777
+ * Takes a perk rank from the character, and every rank above it. No point is refunded.
778
+ * @param perk A BGSPerk rank.
779
+ * @returns True when the record changed; false when they do not hold it.
780
+ */
781
+ removePerk(perk: number | string): boolean;
782
+
783
+ /**
784
+ * The bottle caps the player carries: the Caps001 item in the inventory record.
785
+ * @returns The count; 0 before the first inventory report or once they are gone.
786
+ */
787
+ getCaps(): number;
788
+
789
+ /**
790
+ * Sets the bottle caps the player carries.
791
+ * @param caps 0 to 1000000.
792
+ * @returns True when the record changed; false before the first inventory report.
793
+ */
794
+ setCaps(caps: number): boolean;
795
+
796
+ /**
797
+ * Opens the game's SPECIAL allocation menu on the player's screen, as the Vault 111 exit does. Each point they move comes back as `playerValueRequest`.
798
+ * @returns True when sent; false when the player is gone.
799
+ */
800
+ openSpecialMenu(): boolean;
801
+
802
+ /**
803
+ * Opens the game's perk chart on the player's screen. Each rank bought comes back as `playerPerkRequest`.
804
+ * @returns True when sent; false when the player is gone.
805
+ */
806
+ openPerkChart(): boolean;
807
+
808
+ /**
809
+ * The whole character: experience, level, perk points, bases, perks, current values and inventory. Keep it wherever the gamemode likes; `setCharacter` takes it back.
810
+ * @returns The document; null before the character is established.
811
+ */
812
+ getCharacter(): CharacterDocument | null;
813
+
814
+ /**
815
+ * Replaces the character with a document, and brings the player's game to it.
816
+ * @param character As `getCharacter` returns it. What it leaves out stays as it is.
817
+ * @returns True when applied; false before the character is established. Throws for a malformed document.
818
+ */
819
+ setCharacter(character: Partial<CharacterDocument>): boolean;
820
+
821
+ /**
822
+ * The total experience a level starts at, by the game's formula.
823
+ * @param level 1 to 65535.
824
+ * @returns The XP.
825
+ */
826
+ static xpForLevel(level: number): number;
827
+
828
+ /**
829
+ * The factions the server put the player in, each with its rank. The factions their character holds from the game's own data, such as PlayerFaction, are not listed.
830
+ * @returns One entry per faction, in the order they were joined; empty when the player is gone.
831
+ */
832
+ getFactions(): { faction: number; rank: number }[];
833
+
834
+ /**
835
+ * The player's rank in a faction the server put them in.
836
+ * @param faction A TESFaction form ID, as a number or hex string.
837
+ * @returns The rank; null when the server did not put them in it.
838
+ */
839
+ getFactionRank(faction: number | string): number | null;
840
+
841
+ /**
842
+ * Puts the player in a faction at a rank, or re-ranks them, as `Actor.SetFactionRank` does: their own game and every other player's give their character the membership, so the game's hostility follows it. NPCs of the faction and its allies treat them as one of their own; its enemies attack them. Up to 16 factions per player; whether a player's hits on another land stays `playerHit`'s say.
843
+ * @param faction A TESFaction form ID, as a number or hex string.
844
+ * @param rank 0 to 127; 0 when left out.
845
+ * @returns True when set; false when the player is gone or already in 16 factions.
846
+ */
847
+ setFactionRank(faction: number | string, rank?: number): boolean;
848
+
849
+ /**
850
+ * Takes the player out of a faction the server put them in, as `Actor.RemoveFromFaction` does.
851
+ * @param faction A TESFaction form ID, as a number or hex string.
852
+ * @returns True when they were in it; false otherwise or when the player is gone.
853
+ */
854
+ removeFromFaction(faction: number | string): boolean;
855
+
856
+ /**
857
+ * Takes the player out of every faction the server put them in. The factions their character holds from the game's own data stay.
858
+ * @returns True when sent; false when the player is gone.
859
+ */
860
+ removeFromAllFactions(): boolean;
861
+
477
862
  /**
478
863
  * Every connected player.
479
864
  * @returns One handle per player, in no particular order.
@@ -661,12 +1046,99 @@ declare global {
661
1046
  */
662
1047
  delta: number;
663
1048
 
1049
+ /**
1050
+ * The stack's condition in percent of full, 0 to 100: the charge a fusion core has left. 100 for an item that has none.
1051
+ */
1052
+ condition: number;
1053
+
664
1054
  /**
665
1055
  * The reference on the other side, such as a container; null for none the game named.
666
1056
  */
667
1057
  from: number | null;
668
1058
  }
669
1059
 
1060
+ /**
1061
+ * A whole character, as getCharacter gives it and setCharacter takes it. Actor values are keyed by editor ID; forms are hex strings.
1062
+ */
1063
+ interface CharacterDocument {
1064
+ /**
1065
+ * The document's format, 1.
1066
+ */
1067
+ version: number;
1068
+
1069
+ /**
1070
+ * The nickname of the player it was taken from.
1071
+ */
1072
+ nickname: string;
1073
+
1074
+ /**
1075
+ * Total XP.
1076
+ */
1077
+ experience: number;
1078
+
1079
+ /**
1080
+ * The level.
1081
+ */
1082
+ level: number;
1083
+
1084
+ /**
1085
+ * Unspent perk points.
1086
+ */
1087
+ perkPoints: number;
1088
+
1089
+ /**
1090
+ * Actor value bases: SPECIAL and any a script set.
1091
+ */
1092
+ values: Record<string, number>;
1093
+
1094
+ /**
1095
+ * The BGSPerk ranks held.
1096
+ */
1097
+ perks: string[];
1098
+
1099
+ /**
1100
+ * Health, ActionPoints and Rads as they stood.
1101
+ */
1102
+ current: Record<string, number>;
1103
+
1104
+ /**
1105
+ * What the character carries.
1106
+ */
1107
+ inventory: { form: string; count: number }[];
1108
+ }
1109
+
1110
+ /**
1111
+ * How the game's factions react to each other, on every client. Combined with `Player.setFactionRank` it decides who the game treats as friend or foe: NPCs, turrets and companions alike.
1112
+ */
1113
+ const Faction: {
1114
+ /**
1115
+ * How one faction reacts to another, where the server overrides it.
1116
+ * @param faction A TESFaction form ID, as a number or hex string.
1117
+ * @param other The faction it reacts to, as a number or hex string.
1118
+ * @returns The reaction; null when the game's data files decide.
1119
+ */
1120
+ getReaction(faction: number | string, other: number | string): "neutral" | "enemy" | "ally" | "friend" | null;
1121
+
1122
+ /**
1123
+ * Overrides how one faction reacts to another on every client, as `Faction.SetAlly` and `Faction.SetEnemy` do, until it is cleared or the server stops. A faction can be its own enemy. Up to 64 directions are overridden at once.
1124
+ * @param faction A TESFaction form ID, as a number or hex string.
1125
+ * @param other The faction it reacts to, as a number or hex string.
1126
+ * @param reaction Enemies fight on sight; allies and friends help each other, friends also in combat.
1127
+ * @param mutual Both directions, as `Faction.SetAlly` and `Faction.SetEnemy` do; true when left out.
1128
+ * @returns True when set; false when the table is full.
1129
+ */
1130
+ setReaction(faction: number | string, other: number | string, reaction: "neutral" | "enemy" | "ally" | "friend", mutual?: boolean): boolean;
1131
+
1132
+ /**
1133
+ * Gives a reaction back to the game's data files on every client.
1134
+ * @param faction A TESFaction form ID, as a number or hex string.
1135
+ * @param other The faction it reacts to, as a number or hex string.
1136
+ * @param mutual Both directions, as `Faction.SetAlly` and `Faction.SetEnemy` do; true when left out.
1137
+ * @returns True when one was overridden.
1138
+ */
1139
+ clearReaction(faction: number | string, other: number | string, mutual?: boolean): boolean;
1140
+ };
1141
+
670
1142
  /**
671
1143
  * An armed mine a player laid. Its owner's game holds the mine and sets it off; the server decides when. Once it goes off or is removed the handle reads nothing. Mines go with their owner when they leave.
672
1144
  */
@@ -810,6 +1282,191 @@ declare global {
810
1282
 
811
1283
  interface RadioStation extends Entity {}
812
1284
 
1285
+ /**
1286
+ * A non-player actor the server took over from the data files: the generic placed ones, not the unique, essential or quest actors, which stay each client's own. A client near it runs it with the game's own AI and reports its health; nobody near, the server walks it. It lives for the whole session and comes back on its own a while after it dies. Move it with `teleport`, not by setting `position`.
1287
+ */
1288
+ class Npc {
1289
+ /**
1290
+ * Wraps an existing NPC with this ID; it spawns nothing.
1291
+ * @param id Network entity identifier.
1292
+ */
1293
+ constructor(id: number);
1294
+
1295
+ /**
1296
+ * The form ID of the placed reference (ACHR) it stands for.
1297
+ */
1298
+ readonly ref: number;
1299
+
1300
+ /**
1301
+ * The TESNPC every client builds it from; the server rolled any leveled list.
1302
+ */
1303
+ readonly form: number;
1304
+
1305
+ /**
1306
+ * Current health, as its simulator last measured it. 0 until a client has run it: the server cannot work it out from the records.
1307
+ */
1308
+ readonly health: number;
1309
+
1310
+ /**
1311
+ * Health at full; 0 until a client has run it.
1312
+ */
1313
+ readonly maxHealth: number;
1314
+
1315
+ /**
1316
+ * Whether it is dead.
1317
+ */
1318
+ readonly isDead: boolean;
1319
+
1320
+ /**
1321
+ * Facing, in radians around Z.
1322
+ */
1323
+ readonly heading: number;
1324
+
1325
+ /**
1326
+ * Kills it through the path a hit takes; `npcDeath` follows with a null killer. One no client has run yet dies when the next one takes it on.
1327
+ * @returns True when sent; false when it is already dead.
1328
+ */
1329
+ kill(): boolean;
1330
+
1331
+ /**
1332
+ * Puts it back at its placement, whole, dead or alive; `npcRespawn` follows.
1333
+ * @returns True when done.
1334
+ */
1335
+ respawn(): boolean;
1336
+
1337
+ /**
1338
+ * Formats this handle for logging.
1339
+ * @returns The NPC's network ID, reference and form.
1340
+ */
1341
+ toString(): string;
1342
+
1343
+ /**
1344
+ * Where the NPC is.
1345
+ * @returns The worldspace or interior cell.
1346
+ */
1347
+ getSpace(): PlayerSpace | null;
1348
+
1349
+ /**
1350
+ * The player whose game runs the NPC.
1351
+ * @returns Null while nobody near does and the server walks it.
1352
+ */
1353
+ getSimulator(): Player | null;
1354
+
1355
+ /**
1356
+ * The player the NPC follows as a companion.
1357
+ * @returns Null when it follows nobody.
1358
+ */
1359
+ getLeader(): Player | null;
1360
+
1361
+ /**
1362
+ * Makes the NPC a player's companion, as the game's own Followers quest makes one: the leader's game runs it with the follow packages, command mode and trading of a vanilla companion, and every other player sees it follow. It is taken along when its leader goes to another space or far off, and let go when the leader leaves; `npcLeaderChange` follows.
1363
+ * @param player Who it follows; null lets it go.
1364
+ * @returns True when done; false for a dead NPC or a player who is gone. Throws for anything but a Player or null.
1365
+ */
1366
+ setLeader(player: Player | null): boolean;
1367
+
1368
+ /**
1369
+ * Hits the NPC from nobody, as a shot would; `npcHit` is not raised.
1370
+ * @param amount Health to take, above 0.
1371
+ * @returns True when sent; false when it is dead.
1372
+ */
1373
+ damage(amount: number): boolean;
1374
+
1375
+ /**
1376
+ * Moves the NPC within its space. Left alone, it wanders back toward its placement over time.
1377
+ * @param position Where to, in the NPC's own space.
1378
+ * @param heading Facing in radians; the current one when left out.
1379
+ * @returns True when done. Throws for a position that is not a finite Vector3.
1380
+ */
1381
+ teleport(position: Vector3, heading?: number): boolean;
1382
+
1383
+ /**
1384
+ * Every NPC the server took over.
1385
+ * @returns One handle per NPC; empty when the server could not read the game's data files.
1386
+ */
1387
+ static all(): Npc[];
1388
+
1389
+ /**
1390
+ * Looks an NPC up by network ID.
1391
+ * @param id Network entity identifier.
1392
+ * @returns The handle, or null when no NPC has that ID.
1393
+ */
1394
+ static getById(id: number): Npc | null;
1395
+
1396
+ /**
1397
+ * Looks an NPC up by the placed reference it stands for.
1398
+ * @param ref The placed reference's form ID.
1399
+ * @returns The handle, or null when the server did not take that reference over.
1400
+ */
1401
+ static getByRef(ref: number | string): Npc | null;
1402
+ }
1403
+
1404
+ interface Npc extends Entity {}
1405
+
1406
+ /**
1407
+ * An object built in a settlement, by a player or a script, linked to a workbench the data files place. It lasts the whole session, whoever built it, until a player scraps or stores it or a script destroys it. Setting `position` or `angle` moves it for everyone.
1408
+ */
1409
+ class WorkshopItem {
1410
+ /**
1411
+ * Wraps an existing built object with this ID; it builds nothing. See `WorkshopItem.place`.
1412
+ * @param id Network entity identifier.
1413
+ */
1414
+ constructor(id: number);
1415
+
1416
+ /**
1417
+ * The base object's form ID; 0 once it is gone.
1418
+ */
1419
+ readonly form: number;
1420
+
1421
+ /**
1422
+ * The workbench reference it belongs to; 0 once it is gone.
1423
+ */
1424
+ readonly workbench: number;
1425
+
1426
+ /**
1427
+ * Its rotation, radians, as the game stores it. Assigning turns it for everyone.
1428
+ */
1429
+ angle: Vector3;
1430
+
1431
+ /**
1432
+ * Takes the object out of the settlement for everyone; nobody gets its components back.
1433
+ * @returns True when it was there to take.
1434
+ */
1435
+ destroy(): boolean;
1436
+
1437
+ /**
1438
+ * Formats this handle for logging.
1439
+ * @returns The object's network ID, form and workbench.
1440
+ */
1441
+ toString(): string;
1442
+
1443
+ /**
1444
+ * Where the object stands.
1445
+ * @returns The worldspace or interior cell, or null once it is gone.
1446
+ */
1447
+ getSpace(): PlayerSpace | null;
1448
+
1449
+ /**
1450
+ * Builds an object for everyone, as if a player had at that workbench. Nothing is checked: not the recipe, its cost nor the buildable area.
1451
+ * @param form The base object to build.
1452
+ * @param workbench The workbench reference it belongs to, placed by the data files.
1453
+ * @param position Where it stands.
1454
+ * @param space The worldspace, or the interior cell: exactly one of the two.
1455
+ * @param angle Its rotation, radians.
1456
+ * @returns The object, or null when it could not be created.
1457
+ */
1458
+ static place(form: number | string, workbench: number | string, position: Vector3, space: { worldSpace?: number | string; interiorCell?: number | string }, angle?: Vector3): WorkshopItem | null;
1459
+
1460
+ /**
1461
+ * Every object built this session.
1462
+ * @param workbench Only the objects of this workbench.
1463
+ * @returns One handle per object.
1464
+ */
1465
+ static all(workbench?: number | string): WorkshopItem[];
1466
+ }
1467
+
1468
+ interface WorkshopItem extends Entity {}
1469
+
813
1470
  /**
814
1471
  * Node.js timer handle returned by setTimeout and setInterval.
815
1472
  */