@kingdomsconnected/types 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/client/index.d.ts +4112 -0
- package/package.json +30 -0
- package/server/index.d.ts +4577 -0
- package/shared.d.ts +82 -0
|
@@ -0,0 +1,4577 @@
|
|
|
1
|
+
import type { EventHandler, MessageHandler, MessageReply, Quaternion, Unsubscribe, Vector3 } from "../shared.js";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
/**
|
|
5
|
+
* Native events dispatched through `Events.on`. Each property is the exact callback argument tuple for that event.
|
|
6
|
+
*/
|
|
7
|
+
interface EventMap {
|
|
8
|
+
/**
|
|
9
|
+
* Dispatched once a connecting player's body exists and can be resolved to a handle. The body has no pose yet -- `player.ready` is false until the owner reports one.
|
|
10
|
+
*/
|
|
11
|
+
playerConnect: [player: Player];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Dispatched while a player is leaving, before their body is destroyed, so the handle still reads. Anything keyed on the player must be cleaned up here: a dropped connection raises no other event.
|
|
15
|
+
*/
|
|
16
|
+
playerDisconnect: [player: Player];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Dispatched once per accepted death report. Call player.revive() to request revival; there is no automatic respawn.
|
|
20
|
+
*
|
|
21
|
+
* `killer` is the player whose blow took the last of the health, as the dying player's own client saw it -- null for a fall, a bleed-out, or anything that was not a player. `reason` is the game's own for that last write: `combat` for a blade or a bow, `fall`, `bleeding`, `poison` and so on.
|
|
22
|
+
*/
|
|
23
|
+
playerDied: [player: Player, killer: Player | null, reason: "unknown" | "combat" | "gunshot" | "starvation" | "collision" | "scripted" | "disintegrate" | "fall" | "poison" | "bleeding" | "selfHarm"];
|
|
24
|
+
|
|
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.
|
|
27
|
+
*
|
|
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
|
+
*
|
|
30
|
+
* Bleeding, poison and hunger wear health down a tick at a time without raising this -- `bleeding`, `poisoning` and `hunger` are live numbers already. The tick that kills does arrive, with its own reason, just before the `playerDied` it causes.
|
|
31
|
+
*/
|
|
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
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 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
|
+
*/
|
|
37
|
+
playerInjured: [player: Player, bodyPart: "head" | "torso" | "leftArm" | "rightArm" | "leftLeg" | "rightLeg"];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Dispatched when a limb injury is gone: it healed by itself, a bandage took it, or `player.heal` did.
|
|
41
|
+
*/
|
|
42
|
+
playerInjuryHealed: [player: Player, bodyPart: "head" | "torso" | "leftArm" | "rightArm" | "leftLeg" | "rightLeg"];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Dispatched when a player's body needs somewhere to stand, while their own client waits on the answer behind its loading screen. This is the one moment a spawn can be chosen without anybody seeing the body move -- call `player.spawn(position)` from the handler and that becomes where they arrive.
|
|
46
|
+
*
|
|
47
|
+
* Handlers run synchronously, so the choice has to be made in the handler itself rather than in something awaited from it. A handler that names no placement leaves the player at the level's own start point, which is the same tile for everybody.
|
|
48
|
+
*
|
|
49
|
+
* `reason` says whether they are arriving or coming back: `join` for a connection, `respawn` after a death.
|
|
50
|
+
*/
|
|
51
|
+
playerSpawning: [player: Player];
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 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.
|
|
55
|
+
*/
|
|
56
|
+
playerSpawned: [player: Player];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Dispatched immediately after a horse is created and replicated, whether by `Horse.spawn`, the `/horse` command, or anything else.
|
|
60
|
+
*/
|
|
61
|
+
horseSpawn: [horse: Horse];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Dispatched while a horse is being despawned. The handle still resolves, so its rider and name can be read one last time.
|
|
65
|
+
*/
|
|
66
|
+
horseDestroy: [horse: Horse];
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Dispatched after a player climbs into a saddle and the horse's authority has been handed to their client.
|
|
70
|
+
*/
|
|
71
|
+
horseMount: [horse: Horse, player: Player | null];
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Dispatched after a rider leaves a saddle, including the dismount a disconnect implies, the one a destroyed or dead horse forces, and the one a rider's own death forces.
|
|
75
|
+
*/
|
|
76
|
+
horseDismount: [horse: Horse, player: Player | null];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Dispatched when a player has climbed into a saddle, before the server accepts it -- the place to decide who may ride which horse. Return `false` from a handler and the ride is refused: the player's client is told to get back off, and no `horseMount` follows. Handlers run synchronously, so the decision cannot wait on anything awaited.
|
|
80
|
+
*
|
|
81
|
+
* The player's own game has already started the mount when this runs, so a refusal plays the get-off.
|
|
82
|
+
*/
|
|
83
|
+
horseMounting: [horse: Horse, player: Player];
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Dispatched when health comes off a horse: a blade, an arrow, a fall. The client running the horse reports it, because its copy of the animal is the one whose soul counts -- a blow resolved on the attacker's machine is handed to it first -- so `amount` is what was really taken. `attacker` is the player who dealt it, or null.
|
|
87
|
+
*/
|
|
88
|
+
horseDamage: [horse: Horse, attacker: Player | null, amount: number, reason: "unknown" | "combat" | "gunshot" | "starvation" | "collision" | "scripted" | "disintegrate" | "fall" | "poison" | "bleeding" | "selfHarm"];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Dispatched once when a horse dies, whatever killed it: its body falls where it stood, and anyone in the saddle has already been taken off (with a `horseDismount`). `killer` is the player whose blow took the last of the health, or null. It follows the `horseDamage` of the blow that caused it: the client running the horse reports both, in that order.
|
|
92
|
+
*/
|
|
93
|
+
horseDeath: [horse: Horse, killer: Player | null, reason: "unknown" | "combat" | "gunshot" | "starvation" | "collision" | "scripted" | "disintegrate" | "fall" | "poison" | "bleeding" | "selfHarm"];
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Dispatched when a player has changed a horse's gear -- in the game's own horse inventory screen -- before the server accepts it. `gear` is what the horse would wear. Return `false` from a handler and the change is refused: every copy of the horse, the player's own included, is dressed back in what it wore before. Not dispatched while `gearLocked` is set, which refuses first, nor for a script's own `setGear`. Handlers run synchronously.
|
|
97
|
+
*/
|
|
98
|
+
horseGearChanging: [horse: Horse, player: Player | null, gear: { saddle: string | null; head: string | null; torso: string | null; shoe: string | null }];
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Dispatched after a horse's gear changed on every client. `player` is the rider who changed it, or null for a script.
|
|
102
|
+
*/
|
|
103
|
+
horseGearChanged: [horse: Horse, player: Player | null, gear: { saddle: string | null; head: string | null; torso: string | null; shoe: string | null }];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Dispatched when a player picks an option. The option's own id comes back, never its index, so a handler stays correct when the page is rebuilt with different rows. Anything the option costs is checked here, not when the page was built: `enabled` on the wire is a rendering hint and the server is what decides.
|
|
107
|
+
*/
|
|
108
|
+
dialogueChoice: [session: number, player: Player, optionId: string];
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Dispatched when a conversation ends, whoever ended it. 0 completed, 1 the player cancelled, 2 another conversation replaced it, 3 it was interrupted -- a disconnect, most often.
|
|
112
|
+
*/
|
|
113
|
+
dialogueClosed: [session: number, player: Player, reason: number];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Dispatched once a deal has settled: everything in it has already moved. `balance` is what the player came out with in money units -- positive when the vendor paid them. What the player sold does not join the vendor's stock; add it with `setStock` here if this vendor resells.
|
|
117
|
+
*/
|
|
118
|
+
vendorTrade: [vendor: number, player: Player, bought: VendorTradeLine[], sold: VendorTradeLine[], balance: number];
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Dispatched when a trading session ends, whoever ended it. 0 the player closed the screen, 1 the server closed it, 2 another vendor replaced it, 3 the client could not bring the screen up, 4 the player left.
|
|
122
|
+
*/
|
|
123
|
+
vendorClosed: [vendor: number, player: Player, reason: number];
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Dispatched when a player's charge begins on the game's own Rob entry against another player, before the victim's pockets are opened to them -- the place to decide who may rob whom. Return `false` from a handler and the attempt is refused: the thief's minigame ends before its loot screen opens, and nothing else follows. Handlers run synchronously, so the decision cannot wait on anything awaited.
|
|
127
|
+
*
|
|
128
|
+
* Whether the victim notices is the game's own rule, played on the thief's machine against the victim's body: it turns on the victim's facing and on both players' skills, exactly as against an NPC.
|
|
129
|
+
*/
|
|
130
|
+
playerPickpocketStart: [thief: Player, victim: Player];
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Dispatched once a theft has settled: everything in `items` has already left the victim and reached the thief. The thief's loot screen is only a claim -- each line was taken from the victim first and only what really came out was handed over -- so `items` can be shorter than what the thief took, or empty when they closed the screen with nothing. Nothing else happens to either player: whether this is a crime, and what it costs, is the gamemode's.
|
|
134
|
+
*/
|
|
135
|
+
playerPickpocketed: [thief: Player, victim: Player, items: PickpocketLine[]];
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Dispatched when the victim noticed the thief, while charging or with the loot screen up. Nothing was taken, and no NPC reacts on the victim's behalf: the gamemode decides what being caught means.
|
|
139
|
+
*/
|
|
140
|
+
playerPickpocketCaught: [thief: Player, victim: Player];
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Dispatched immediately after a dog is created and replicated, whether by `Dog.spawn` or anything else.
|
|
144
|
+
*/
|
|
145
|
+
dogSpawn: [dog: Dog];
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Dispatched while a dog is being despawned. The handle still resolves, so its owner and name can be read one last time.
|
|
149
|
+
*/
|
|
150
|
+
dogDestroy: [dog: Dog];
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Dispatched after a dog is handed to another player, or left masterless.
|
|
154
|
+
*/
|
|
155
|
+
dogOwnerChanged: [dog: Dog, player: Player | null];
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Dispatched after a dog's companion mode actually changes.
|
|
159
|
+
*/
|
|
160
|
+
dogModeChanged: [dog: Dog, mode: number];
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Dispatched immediately after a prop is created and replicated, whether by `Prop.spawn`, the `/prop` command, or anything else.
|
|
164
|
+
*/
|
|
165
|
+
propSpawn: [prop: Prop];
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Dispatched while a prop is being despawned. The handle still resolves, so its model and its pose can be read one last time.
|
|
169
|
+
*/
|
|
170
|
+
propDestroy: [prop: Prop];
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Dispatched immediately after a replicated particle effect is placed, whether by `Vfx.spawn`, a command, or anything else.
|
|
174
|
+
*/
|
|
175
|
+
vfxSpawn: [vfx: Vfx];
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Dispatched while a replicated particle effect is being stopped. The handle still resolves, so its name and its pose can be read one last time.
|
|
179
|
+
*/
|
|
180
|
+
vfxDestroy: [vfx: Vfx];
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Dispatched immediately after a ground marker is drawn, whether by `Marker.place`, a command, or anything else.
|
|
184
|
+
*/
|
|
185
|
+
markerPlace: [marker: Marker];
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Dispatched while a ground marker is being removed. The handle still resolves, so its material and its pose can be read one last time.
|
|
189
|
+
*/
|
|
190
|
+
markerRemove: [marker: Marker];
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Dispatched when a player walks into a marker whose `trigger` is on. The client detects the crossing and the server confirms it against the position it already replicates, so a claim it does not agree with never reaches here.
|
|
194
|
+
*/
|
|
195
|
+
markerEnter: [marker: Marker, player: Player];
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Dispatched when a player walks out of a marker whose `trigger` is on. Not raised when the marker is removed, when `trigger` is turned off, or when the player leaves the world -- none of those is the player walking out.
|
|
199
|
+
*/
|
|
200
|
+
markerExit: [marker: Marker, player: Player];
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Dispatched immediately after an NPC is spawned or adopted, whether by `Npc.create`, a command, or anything else.
|
|
204
|
+
*/
|
|
205
|
+
npcSpawn: [npc: Npc];
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Dispatched while an NPC is being despawned. The handle still resolves, so what it was and where it stood can be read one last time.
|
|
209
|
+
*/
|
|
210
|
+
npcDestroy: [npc: Npc];
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Dispatched when an NPC finishes what it was told to do. `status` is `reached` when it arrived, `blocked` when it could not make progress, or `failed` when the order could not be carried out at all. A patrol steps on this event, so a handler that re-orders the NPC here replaces the route rather than racing it.
|
|
214
|
+
*/
|
|
215
|
+
npcIntentDone: [npc: Npc, status: string];
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Dispatched after health came off the ledger. The attacker's own client resolved the hit and the server agreed to it, so `amount` is what was actually taken, not what was claimed.
|
|
219
|
+
*/
|
|
220
|
+
npcDamage: [npc: Npc, attacker: Player | null, amount: number];
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Dispatched when the last of an NPC's health goes. The body stays as a corpse and the handle keeps resolving.
|
|
224
|
+
*/
|
|
225
|
+
npcDeath: [npc: Npc, attacker: Player | null];
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Dispatched when a dead NPC is brought back. Every client makes a new body for it.
|
|
229
|
+
*/
|
|
230
|
+
npcRevive: [npc: Npc];
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Dispatched when a player presses use on an NPC whose `interactable` is on. The client reports the press and the server confirms the distance against the position it already replicates, so a claim it does not agree with never reaches here.
|
|
234
|
+
*/
|
|
235
|
+
npcInteract: [npc: Npc, player: Player];
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Dispatched when the client running an NPC changes -- somebody walked into range, out of it, or disconnected. `player` is null when it went dormant. Nothing about the NPC changes with it: intent, ledger and identity are the server's, and the new simulator re-derives from them.
|
|
239
|
+
*/
|
|
240
|
+
npcSimulatorChange: [npc: Npc, player: Player | null];
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Dispatched when a player starts or stops following a 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. The client reports it -- following a quest is decided there and cannot be refused here -- so a handler reacts rather than vetoes. It fires only on an actual change, and only for a quest that player was given.
|
|
244
|
+
*/
|
|
245
|
+
questTrackingChanged: [quest: Quest, player: Player, tracked: boolean];
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Dispatched immediately after a stack is laid in the world and replicated, whether by `GroundItem.spawn`, the `/drop` command, or a player dropping something from their own inventory.
|
|
249
|
+
*/
|
|
250
|
+
groundItemSpawn: [groundItem: GroundItem];
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Dispatched while a stack is being taken out of the world, including the removal a completed pickup performs. The handle still resolves, so its item and its pose can be read one last time.
|
|
254
|
+
*/
|
|
255
|
+
groundItemDestroy: [groundItem: GroundItem];
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Dispatched when a player's pickup has been granted and the stack is about to go, so what was taken and by whom can both still be read. It reports a pickup rather than deciding one -- the server has already told that client the stack is theirs by the time this is raised -- and `groundItemDestroy` follows it.
|
|
259
|
+
*/
|
|
260
|
+
groundItemPickup: [groundItem: GroundItem, player: Player | null];
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Dispatched when a player's client reports working a door, before the server applies it. `action` is `open`, `close`, `lock`, `unlock` or `lockpick`; a key turned in the same use as the push arrives as `unlock` and then `open`. `keySide` says whether the player stood on the side with the keyhole, which is where an unlock needs a key.
|
|
264
|
+
*
|
|
265
|
+
* Return false to refuse it: the door is put back on every client, the player's included, and nobody else sees it happen. Every handler runs whatever an earlier one returned, and an async handler cannot refuse. The server has already refused what the game's own rules forbid -- a player out of reach, a door the server locked, opening a locked door, picking a door with no keyhole -- so this only sees what the game would allow.
|
|
266
|
+
*/
|
|
267
|
+
doorInteract: [player: Player, door: Door, action: "open" | "close" | "lock" | "unlock" | "lockpick", keySide: boolean];
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Dispatched when a player submits a plain chat line. Turn `Chat.setDefaultRelay(false)` off to own delivery yourself.
|
|
271
|
+
*/
|
|
272
|
+
playerChat: [player: Player, text: string];
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Dispatched when a player's chat line begins with `/` and no built-in command claimed it. A `/` line is never relayed to anyone else.
|
|
276
|
+
*/
|
|
277
|
+
playerCommand: [player: Player, command: string, args: string[]];
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Dispatched when the world clock crosses midnight, whether it walked over or `World.setTime` jumped past. The day it carries is the one that just began.
|
|
281
|
+
*/
|
|
282
|
+
worldDayChange: [day: number];
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Dispatched when the sky starts blending to another time-of-day preset, from `World.setWeather` or the `/world weather` command. It is raised when the blend starts, not when it settles.
|
|
286
|
+
*/
|
|
287
|
+
worldWeatherChange: [preset: string, previous: string, seconds: number];
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Dispatched when a status effect appears on a player's body. `source` says whether this server added it; `native` means the game did -- a potion they drank, an injury they took. It fires for whatever they are already carrying when their client first reports in, so a handler sees the full picture without asking for it.
|
|
291
|
+
*/
|
|
292
|
+
playerBuffAdded: [player: Player, buff: string, source: "server" | "native"];
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Dispatched when a status effect leaves a player's body. `server` is a removal this server asked for; `expired` is everything else -- it ran out, or the game replaced it. Effect timers run on each player's own machine, so the server never expires one itself.
|
|
296
|
+
*/
|
|
297
|
+
playerBuffRemoved: [player: Player, buff: string, reason: "server" | "expired"];
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Dispatched when the game tried to give a player an effect of a kind this server claimed, and their client turned it down. This is the other half of `Buffs.claim`: the drink was still drunk and the item still consumed, so the handler decides what really happens -- usually `player.addBuff` with the resource's own rule applied. Nothing raises it until something is claimed, and repeats of the same effect are limited to twice a second per player.
|
|
301
|
+
*/
|
|
302
|
+
playerBuffBlocked: [player: Player, buff: string];
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Dispatched after a resource entry point has run and immediately before the resource becomes running.
|
|
306
|
+
*/
|
|
307
|
+
resourceStart: [resourceName: string];
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Dispatched while a resource is stopping, before its stop callback, timers, exports and event handlers are cleaned up.
|
|
311
|
+
*/
|
|
312
|
+
resourceStop: [resourceName: string];
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Dispatched when one key of an entity's state changes: on the server when a script writes it, on a client when the write arrives. `value` is undefined when the key was removed and `previous` is undefined when it held nothing before, so a stored null stays distinguishable from an absent key. The entity is whatever the game's WrapScriptEntity answers, and the base Entity handle by default.
|
|
316
|
+
*/
|
|
317
|
+
entityStateChange: [entity: Entity, key: string, value: any, previous: any];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Names of native events available in this scripting environment. */
|
|
321
|
+
type EventName = keyof EventMap;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* How a player's body looks: four of the game's own character-component names, and the gender whose catalog they come from.
|
|
325
|
+
*
|
|
326
|
+
* A part left out, or set to an empty string, means "leave that one alone" -- the body keeps whatever it would have had. An appearance with every part empty is the default body, which is what everyone wears until something chooses otherwise.
|
|
327
|
+
*/
|
|
328
|
+
interface Appearance {
|
|
329
|
+
/**
|
|
330
|
+
* Which half of the game's character-component tree the four names come from. Not one of the four: a body's gender comes from its soul, and a name from one tree means nothing under the other, so this travels with them and is applied first.
|
|
331
|
+
*/
|
|
332
|
+
gender: "male" | "female";
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* The skin: complexion and build. One of `Appearances.options("body", gender)`, or empty.
|
|
336
|
+
*/
|
|
337
|
+
body: string;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* The face. One of `Appearances.options("head", gender)`, or empty.
|
|
341
|
+
*/
|
|
342
|
+
head: string;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* The hairstyle, including its colour -- the game ships each style recoloured rather than colouring one. One of `Appearances.options("hair", gender)`, or empty.
|
|
346
|
+
*/
|
|
347
|
+
hair: string;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* The beard. Male only -- the female tree has none -- and one of `Appearances.beards(head)`, or empty.
|
|
351
|
+
*
|
|
352
|
+
* Not every beard goes with every face: they are modelled per head, and a body asked for a pair that was never modelled refuses the whole appearance rather than quietly losing the beard.
|
|
353
|
+
*/
|
|
354
|
+
beard: string;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* One entry of the game's character-component tree: something a body can be given for one part.
|
|
359
|
+
*/
|
|
360
|
+
interface AppearanceOption {
|
|
361
|
+
/**
|
|
362
|
+
* What to put in the part. This is the game's own node name.
|
|
363
|
+
*/
|
|
364
|
+
name: string;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Which part it fills.
|
|
368
|
+
*/
|
|
369
|
+
part: "body" | "head" | "hair" | "beard";
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Which tree it came out of. An option is only valid on a body of the same gender.
|
|
373
|
+
*/
|
|
374
|
+
gender: "male" | "female";
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* The option this one is a variation of, or null when it stands on its own. The game ships a hairstyle once per colour, all derived from the same style node, so grouping by this is what turns 262 hairstyles into a list somebody can read.
|
|
378
|
+
*/
|
|
379
|
+
group: string | null;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* The three character attributes a body's soul carries, in the game's own units.
|
|
384
|
+
*/
|
|
385
|
+
interface SoulStats {
|
|
386
|
+
/**
|
|
387
|
+
* Attribute value, or 0 while the body has published no soul.
|
|
388
|
+
*/
|
|
389
|
+
strength: number;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Attribute value, or 0 while the body has published no soul.
|
|
393
|
+
*/
|
|
394
|
+
agility: number;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Attribute value, or 0 while the body has published no soul.
|
|
398
|
+
*/
|
|
399
|
+
vitality: number;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The nine skills a hit or a draw is evaluated against, in the game's own units.
|
|
404
|
+
*/
|
|
405
|
+
interface SoulSkills {
|
|
406
|
+
/**
|
|
407
|
+
* Skill level, or 0 while the body has published no soul.
|
|
408
|
+
*/
|
|
409
|
+
fencing: number;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Skill level, or 0 while the body has published no soul.
|
|
413
|
+
*/
|
|
414
|
+
survival: number;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Skill level, or 0 while the body has published no soul.
|
|
418
|
+
*/
|
|
419
|
+
defense: number;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Skill level, or 0 while the body has published no soul.
|
|
423
|
+
*/
|
|
424
|
+
sword: number;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Skill level, or 0 while the body has published no soul.
|
|
428
|
+
*/
|
|
429
|
+
heavyWeapons: number;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Skill level, or 0 while the body has published no soul.
|
|
433
|
+
*/
|
|
434
|
+
marksmanship: number;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Skill level, or 0 while the body has published no soul.
|
|
438
|
+
*/
|
|
439
|
+
dagger: number;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Skill level, or 0 while the body has published no soul.
|
|
443
|
+
*/
|
|
444
|
+
largeWeapons: number;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Skill level, or 0 while the body has published no soul.
|
|
448
|
+
*/
|
|
449
|
+
unarmed: number;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* The pace rule a server puts on one player. Both halves default to off, and a call to `setMovementMode` states both of them.
|
|
454
|
+
*/
|
|
455
|
+
interface MovementMode {
|
|
456
|
+
/**
|
|
457
|
+
* Whether walking, rather than jogging, is the pace this player keeps coming back to. A preference: they start each body walking and return to it after every sprint, and their own toggle key works normally in between.
|
|
458
|
+
*/
|
|
459
|
+
walkByDefault: boolean;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Whether this player may not run or sprint at all. A rule rather than a preference: it holds the engine's own movement permissions, so the toggle key and the sprint key both stop raising the pace, and lifting it hands back whatever the body had before.
|
|
463
|
+
*/
|
|
464
|
+
walkEnforced: boolean;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* 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`.
|
|
469
|
+
*/
|
|
470
|
+
interface Injuries {
|
|
471
|
+
/**
|
|
472
|
+
* Whether the head is injured.
|
|
473
|
+
*/
|
|
474
|
+
head: boolean;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Whether the torso is injured.
|
|
478
|
+
*/
|
|
479
|
+
torso: boolean;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Whether the left arm is injured.
|
|
483
|
+
*/
|
|
484
|
+
leftArm: boolean;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Whether the right arm is injured.
|
|
488
|
+
*/
|
|
489
|
+
rightArm: boolean;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Whether the left leg is injured.
|
|
493
|
+
*/
|
|
494
|
+
leftLeg: boolean;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Whether the right leg is injured.
|
|
498
|
+
*/
|
|
499
|
+
rightLeg: boolean;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* A connected KCDC player and the body they occupy.
|
|
504
|
+
*/
|
|
505
|
+
class Player {
|
|
506
|
+
/**
|
|
507
|
+
* Creates a script wrapper for an existing connected player with this ID; it neither connects nor spawns anyone.
|
|
508
|
+
* @param id Network entity identifier.
|
|
509
|
+
*/
|
|
510
|
+
constructor(id: number);
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* The name this player connected under, or an empty string once their body is gone.
|
|
514
|
+
*/
|
|
515
|
+
readonly nickname: string;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Connection slot this player holds, or 65535 when unassigned. Stable for the length of the session and reused afterwards.
|
|
519
|
+
*/
|
|
520
|
+
readonly playerIndex: number;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* What this player's body looks like, as their own client last published it. Every part is empty until something chooses one, which is the default body -- and why everyone looks the same until a resource says otherwise.
|
|
524
|
+
*
|
|
525
|
+
* Read back rather than assumed after `setAppearance`: the owning client is authoritative for its own body, so a new look appears here once they have actually put it on.
|
|
526
|
+
*/
|
|
527
|
+
readonly appearance: Appearance;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Whether this player's body has both a pose and a soul, which is what everyone else waits for before spawning a puppet for them. False for the first moments of a connection.
|
|
531
|
+
*/
|
|
532
|
+
readonly ready: boolean;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Whether this player has health left. False also while no soul has been published.
|
|
536
|
+
*/
|
|
537
|
+
readonly alive: boolean;
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Whether the body can be driven at all: alive, conscious and not asleep.
|
|
541
|
+
*/
|
|
542
|
+
readonly canAct: boolean;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Health as a percentage from 0 to 100 -- what the nametag bar draws. Derived from the pair behind it, so it survives a maximum that changes.
|
|
546
|
+
*/
|
|
547
|
+
readonly healthPercent: number;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Current health, in the game's own units. 0 while no soul has been published.
|
|
551
|
+
*/
|
|
552
|
+
readonly health: number;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Health capacity, in the game's own units.
|
|
556
|
+
*/
|
|
557
|
+
readonly maxHealth: number;
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Current stamina, in the game's own units.
|
|
561
|
+
*/
|
|
562
|
+
readonly stamina: number;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Stamina capacity, in the game's own units. Collapses to 0 for a tick around death, which is real rather than a bad read.
|
|
566
|
+
*/
|
|
567
|
+
readonly maxStamina: number;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* The stamina ceiling the body's injuries currently allow, which is at or below maxStamina.
|
|
571
|
+
*/
|
|
572
|
+
readonly healthyStamina: number;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Current tiredness, in the game's own units.
|
|
576
|
+
*/
|
|
577
|
+
readonly exhaust: number;
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Tiredness capacity, in the game's own units.
|
|
581
|
+
*/
|
|
582
|
+
readonly maxExhaust: number;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Current nourishment, in the game's own units.
|
|
586
|
+
*/
|
|
587
|
+
readonly hunger: number;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Nourishment capacity, in the game's own units.
|
|
591
|
+
*/
|
|
592
|
+
readonly maxHunger: number;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* How heavily the body is bleeding; 0 when it is not.
|
|
596
|
+
*/
|
|
597
|
+
readonly bleeding: number;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Sleepiness the game has accumulated for this body; above 0 means asleep.
|
|
601
|
+
*/
|
|
602
|
+
readonly sleeping: number;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* How conscious the body is; 0 is knocked out.
|
|
606
|
+
*/
|
|
607
|
+
readonly consciousness: number;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* How drunk the body is; 0 is sober.
|
|
611
|
+
*/
|
|
612
|
+
readonly drunkenness: number;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* How poisoned the body is; 0 is clean.
|
|
616
|
+
*/
|
|
617
|
+
readonly poisoning: number;
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Strength, in the game's own units.
|
|
621
|
+
*/
|
|
622
|
+
readonly strength: number;
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Agility, in the game's own units.
|
|
626
|
+
*/
|
|
627
|
+
readonly agility: number;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Vitality, in the game's own units.
|
|
631
|
+
*/
|
|
632
|
+
readonly vitality: number;
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* The same three attributes as the engine's relative values, which is what its own modifiers are expressed in.
|
|
636
|
+
*/
|
|
637
|
+
readonly relativeStats: SoulStats;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* The nine combat and survival skills a hit or a draw is evaluated against. Read as a whole rather than one at a time: the snapshot carries them together.
|
|
641
|
+
*/
|
|
642
|
+
readonly skills: SoulSkills;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* The same nine skills as the engine's relative values.
|
|
646
|
+
*/
|
|
647
|
+
readonly relativeSkills: SoulSkills;
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* The velocity the body's own animation was driven by this frame, not the one its physics settled on.
|
|
651
|
+
*/
|
|
652
|
+
readonly velocity: Vector3;
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* World-space direction the head and eyes are turned towards. Zero while the body has reported none.
|
|
656
|
+
*/
|
|
657
|
+
readonly lookDirection: Vector3;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Whether the body is off the ground -- fallen or mid-jump -- as its own physics reports it, debounced past the flicker a stair step causes.
|
|
661
|
+
*/
|
|
662
|
+
readonly inAir: boolean;
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* 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.
|
|
666
|
+
*/
|
|
667
|
+
readonly moveSpeedTag: number;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* The engine's own movement direction tag. Raw Mannequin tag ids; 255 means nothing is set.
|
|
671
|
+
*/
|
|
672
|
+
readonly moveDirTag: number;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* The engine's own stance tag -- upright, sneaking, sitting, lying. Raw Mannequin tag ids; 255 means nothing is set.
|
|
676
|
+
*/
|
|
677
|
+
readonly stanceTag: number;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Whether this player is crouched, as their own game's crouch action reports it. False once their body is gone.
|
|
681
|
+
*/
|
|
682
|
+
readonly crouched: boolean;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* The ragdoll physics profile the body is in, or 255 when it has none to report.
|
|
686
|
+
*/
|
|
687
|
+
readonly physicsProfile: number;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Whether this player has their fists -- or their weapon -- up. Stays true after the arm comes down, which is how the engine holds it.
|
|
691
|
+
*/
|
|
692
|
+
readonly fistsUp: boolean;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* The arm guard in the engine's own levels: 0 arms down, 1 the guard a player holds.
|
|
696
|
+
*/
|
|
697
|
+
readonly guard: number;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Which direction of the combat star this player is aiming at, as a row of the game's zone table, or -1 when they are aiming at none.
|
|
701
|
+
*/
|
|
702
|
+
readonly combatZone: number;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Item class drawn in the right hand as 32 hex digits, or an empty string when the hand is empty. A class rather than an item: no engine-local identifier crosses the wire.
|
|
706
|
+
*/
|
|
707
|
+
readonly rightHandItem: string;
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Item class drawn in the left hand as 32 hex digits, or an empty string when the hand is empty.
|
|
711
|
+
*/
|
|
712
|
+
readonly leftHandItem: string;
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Item classes this player is wearing, each as 32 hex digits. What they actually have on rather than a preset, so a bare body reads as an empty array.
|
|
716
|
+
*/
|
|
717
|
+
readonly equipment: string[];
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Whether this player is in a saddle.
|
|
721
|
+
*/
|
|
722
|
+
readonly mounted: boolean;
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* The horse this player is riding, or null when they are on foot.
|
|
726
|
+
*/
|
|
727
|
+
readonly horse: Horse | null;
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* The dog companion this player has, or null when they have none. One dog per player, as in the game.
|
|
731
|
+
*/
|
|
732
|
+
readonly dog: Dog | null;
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* The status effects on this player's body, as their own client last reported them: potions, poison, injury, drunkenness, illness, unconsciousness, and anything this server added. Perks and equipment effects are not in here -- they follow state that already replicates.
|
|
736
|
+
*
|
|
737
|
+
* This is the list of *named effects*. For how drunk, poisoned, hurt or tired someone actually is, read `drunkenness`, `poisoning`, `bleeding`, `consciousness`, `hunger` and `exhaust` instead: those are live numbers and need no name to look up.
|
|
738
|
+
*
|
|
739
|
+
* Empty until the player's client sends its first report, shortly after they connect; `playerBuffAdded` fires for whatever it was already carrying.
|
|
740
|
+
*/
|
|
741
|
+
readonly buffs: BuffState[];
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Which limbs are injured, as the player's own client last reported them -- the same report `buffs` reads, named by limb so nobody has to know the six buff names. All false until the first report arrives. `playerInjured` and `playerInjuryHealed` fire as a flag changes.
|
|
745
|
+
*
|
|
746
|
+
* What an injury does is the game's own: a hurt head, torso or arm weakens its stats, a hurt leg takes away running and sprinting, and a badly hurt limb bleeds. Everybody else sees the consequences rather than the injury: the owner's slower pace, the lower stamina ceiling, bleeding, and the hurt gait the game plays once health is low. The game has no leg-specific limp animation, so there is nothing more to show.
|
|
747
|
+
*/
|
|
748
|
+
readonly injuries: Injuries;
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Formats this player handle for logging and debugging.
|
|
752
|
+
* @returns The player's network entity ID and nickname.
|
|
753
|
+
*/
|
|
754
|
+
toString(): string;
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Requests revival of this player after playerDied.
|
|
758
|
+
* @returns True when sent; false when disconnected, no death was reported, or revival was already requested.
|
|
759
|
+
*/
|
|
760
|
+
revive(): boolean;
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* 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.
|
|
764
|
+
*
|
|
765
|
+
* Called from a `playerSpawning` handler this *is* the answer to that request -- the player is still behind their loading screen, and nothing is seen. Called at any other time it moves a player who is already in the world, which is visible.
|
|
766
|
+
*
|
|
767
|
+
* Nothing else names a spawn: with no handler calling this, everybody arrives at the level's own start point, because every client asks the game for the identical map start.
|
|
768
|
+
* @param position Where the body goes; a Vector3 or any object carrying x, y and z.
|
|
769
|
+
* @param rotation Which way they face: a Quaternion, or a Vector3 of Euler degrees.
|
|
770
|
+
* @returns True when the placement was accepted; false for a position that is not somewhere in the world, or a player with no connection to ask.
|
|
771
|
+
*/
|
|
772
|
+
spawn(position: Vector3 | Partial<Vector3>, rotation?: Quaternion | Vector3): boolean;
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Asks this player's own client to put them somewhere else. The owning client is authoritative for its body's pose, so this is a request that lands on their next frame rather than a write.
|
|
776
|
+
* @param position World-space destination; a Vector3 or any object carrying x, y and z.
|
|
777
|
+
* @param label Optional name for the destination, echoed back in the client's own teleport panel. Display only.
|
|
778
|
+
* @returns True when the request went out; false when the position is not finite or the player has no connection to ask.
|
|
779
|
+
*/
|
|
780
|
+
teleport(position: Vector3 | Partial<Vector3>, label?: string): boolean;
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Makes this player's body play one of the game's animations, on their own screen and on everybody else's -- a wave, a bow, a woodcutter's swing with the axe in hand. It is state rather than a one-off: a player who streams in or joins while it plays sees it too, and it lasts until `stopAnimation` or the next `playAnimation`, even after a one-shot has finished.
|
|
784
|
+
*
|
|
785
|
+
* The animation is the game's own, so the game can cut it short: a hit, a fall or drawing a weapon ends it, and so can the player walking off from one that leaves the legs free. `loop` starts it again when that happens.
|
|
786
|
+
*
|
|
787
|
+
* 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.
|
|
788
|
+
* @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.
|
|
789
|
+
* @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.
|
|
790
|
+
* @returns True when the request went out; false for a player with no body yet. Throws for a prop or option it cannot use.
|
|
791
|
+
*/
|
|
792
|
+
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;
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Ends what `playAnimation` started, takes its props away and hands the body back to the game.
|
|
796
|
+
* @returns True when the request went out; false for a player with no body yet.
|
|
797
|
+
*/
|
|
798
|
+
stopAnimation(): boolean;
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Asks this player's own client to wear a different body -- face, hair, beard and skin. The owning client is authoritative for its body, so this is a request that lands on their next frame rather than a write; read `player.appearance` back to see what they actually put on.
|
|
802
|
+
*
|
|
803
|
+
* Gender is applied before the parts, because it decides which half of the game's catalog the names come from -- and it is the one part of this with a price. A soul's gender lives on its archetype, so changing it moves the player to the game's own counterpart archetype, which also carries four authored numbers: base armour, the conspicuousness and visibility pair, and unarmed attack. Nothing reads those on the puppets other people see, but on the body its owner plays they are a real change. Ask for a gender only when you mean it; a male-to-male change never touches the archetype.
|
|
804
|
+
*
|
|
805
|
+
* Everyone starts as Henry, so a server that wants people to tell each other apart has to call this.
|
|
806
|
+
*
|
|
807
|
+
* Face and beard travel together whether or not both are named. Beards are modelled per face, so changing either into a pair that was never modelled is refused whole rather than applied without the beard; `Appearances.beards` says which pairs are real.
|
|
808
|
+
* @param appearance The parts to change. Anything left out keeps what the player is wearing, and an empty string hands that part back to the game. Names come from `Appearances.options`, except the beard, which comes from `Appearances.beards`.
|
|
809
|
+
* @returns True when the request went out; false for a name that is not in the catalog, a gender it does not belong to, a beard that face cannot wear, or a player with no connection to ask.
|
|
810
|
+
*/
|
|
811
|
+
setAppearance(appearance: Partial<Appearance>): boolean;
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* 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.
|
|
815
|
+
*
|
|
816
|
+
* The two are different things and both are worth having: a default is a preference, an enforcement is a rule. Nothing about either goes out to anybody else -- the pace every other player draws comes from this body's own published animation tags, so a walking player already looks like one everywhere.
|
|
817
|
+
*
|
|
818
|
+
* A default holds across sprints. The game itself ends every sprint in a jog, deliberately, so the client puts the walk back once the sprint is over rather than during it, and a player who chose to jog keeps jogging: only the pace the sprint took is given back. On a gamepad the stick's own deflection decides the pace, which the rule neither reads nor overrides.
|
|
819
|
+
*
|
|
820
|
+
* Enforcement holds the engine's own run and sprint permissions, the same pair the game clears while somebody carries a body, and hands back what it found when the rule is lifted. Sprinting cannot shake it off.
|
|
821
|
+
* @param mode The whole rule. A key left out is off, because the server keeps no copy of what this player is currently under.
|
|
822
|
+
* @returns True when the rule went out; false for a player with no connection to ask.
|
|
823
|
+
*/
|
|
824
|
+
setMovementMode(mode: Partial<MovementMode>): boolean;
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Grants items into this player's inventory on their own client. The server holds no inventory of its own, so this is an instruction rather than a transfer.
|
|
828
|
+
* @param item Item class GUID, or the exact name the game's own item tables use.
|
|
829
|
+
* @param amount How many to grant; defaults to 1, and at most 10000.
|
|
830
|
+
* @returns True when the grant went out; false for an unknown item or an amount the wire refuses.
|
|
831
|
+
*/
|
|
832
|
+
giveItem(item: string, amount?: number): boolean;
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Takes items back out of this player's inventory, on their own client -- the mirror of `giveItem`, and what makes a trade or a theft able to move in both directions.
|
|
836
|
+
*
|
|
837
|
+
* It is a promise rather than a boolean because a grant always lands and a take may not. The server holds no inventory of its own, so it cannot know what the player is carrying: it asks their client, and the answer is a round trip away. Await it, and read `ok` before crediting the other side of a trade -- a player who has only one of the three you asked for gives back `removed: 1, ok: false`, and their client is already one short.
|
|
838
|
+
*
|
|
839
|
+
* Across stacks of the same class, oldest first, and an item counts even while it is in the player's hand. Nothing else of theirs is touched.
|
|
840
|
+
* @param item Item class GUID, or the exact name the game's own item tables use. The same spelling `giveItem` takes.
|
|
841
|
+
* @param amount How many units to take; defaults to 1, and at most 10000. Zero is refused rather than read as "all of them".
|
|
842
|
+
* @returns An object carrying `removed` (units that actually went), `requested` (what was asked for), `ok` (true only when the client answered and removed every unit), and `reason` (empty when it answered, otherwise what went wrong).
|
|
843
|
+
*/
|
|
844
|
+
takeItem(item: string, amount?: number): Promise<{ removed: number; requested: number; ok: boolean; reason: string }>;
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Puts a status effect on this player's body. The server runs no effects of its own, so this asks their client rather than writing anything, and it lands a moment later -- `hasBuff` right after this call still says false. Watch `playerBuffAdded` for the moment it is really on.
|
|
848
|
+
*
|
|
849
|
+
* The ask is not a promise, either: the game refuses an effect that conflicts with one already there, and a second drink folds into the first rather than stacking.
|
|
850
|
+
* @param buff Buff GUID, or the exact name the game's own buff tables use. `Buffs.find` resolves either.
|
|
851
|
+
* @returns True when the instruction went out; false for an unknown buff or a player with no connection to ask.
|
|
852
|
+
*/
|
|
853
|
+
addBuff(buff: string): boolean;
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Asks this player's own client to take a status effect off: the exact instance when a report named one, and every instance of that definition otherwise.
|
|
857
|
+
* @param buff Buff GUID, or the exact name the game's own buff tables use.
|
|
858
|
+
* @returns True when the instruction went out; false for an unknown buff or a player with no connection to ask.
|
|
859
|
+
*/
|
|
860
|
+
removeBuff(buff: string): boolean;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Clears every effect in one of the game's own families at once: one call for all poisons, or all bleeding, without naming them. `Buffs.tags` lists the families. Note that `World.setTime` does not fast-forward effects -- their time runs off each client's frame delta and never reads the calendar -- so a scripted sleep has to clear what it means to end.
|
|
864
|
+
* @param tag An effect family, from `Buffs.tags` -- `poison`, `bleed`, `alcohol_drunk`, `unconscious`.
|
|
865
|
+
* @returns True when the instruction went out; false for a tag no buff table uses or a player with no connection to ask.
|
|
866
|
+
*/
|
|
867
|
+
clearBuffs(tag: string): boolean;
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Whether this player's last report carried that status effect.
|
|
871
|
+
* @param buff Buff GUID, or the exact name the game's own buff tables use.
|
|
872
|
+
* @returns True when it did; false for an unknown buff, or a player who has reported nothing yet.
|
|
873
|
+
*/
|
|
874
|
+
hasBuff(buff: string): boolean;
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Nurses this player back, on their own client and with the game's own recipe -- the one its quests use for a full heal: the `remove_injuries` and `remove_all_posions` cures, which each wipe their whole kind of effect as they land, then health raised through the soul's own setter, the way a potion raises it. What comes off raises `playerInjuryHealed` and `playerBuffRemoved` as usual.
|
|
878
|
+
*
|
|
879
|
+
* It does not revive anybody: a dead player stays dead until `revive`.
|
|
880
|
+
* @param options What to restore; everything when left out. `health`: true or absent for all of it, a number to raise it to that much (never lowers it), false to leave it. `injuries`: clear every limb injury, and with it the bleeding a badly hurt limb causes. `poisons`: clear every poison. `bleeding`: clear the standalone bleeding effect.
|
|
881
|
+
* @returns True when the orders went out; false for a player with no connection to ask. Throws for a health that is not a finite, non-negative number.
|
|
882
|
+
*/
|
|
883
|
+
heal(options?: { health?: number | boolean; injuries?: boolean; poisons?: boolean; bleeding?: boolean }): boolean;
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Takes this player out of whatever saddle they are in: their own client gets them off, and `horseDismount` is raised.
|
|
887
|
+
* @returns The horse they were taken off, or null when they were not riding one.
|
|
888
|
+
*/
|
|
889
|
+
dismount(): Horse | null;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* 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.
|
|
893
|
+
* @param horse The horse to climb onto.
|
|
894
|
+
* @returns True when the order went out; false when the horse is dead or somebody else is riding it, or the player has no connection.
|
|
895
|
+
*/
|
|
896
|
+
mount(horse: Horse): boolean;
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Lists every player currently connected, including those whose body has no pose yet.
|
|
900
|
+
* @returns One handle per connected player, in no particular order.
|
|
901
|
+
*/
|
|
902
|
+
static all(): Player[];
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Looks a player up by their network entity ID.
|
|
906
|
+
* @param id Network entity identifier.
|
|
907
|
+
* @returns The player's handle, or null when no connected player has that ID.
|
|
908
|
+
*/
|
|
909
|
+
static getById(id: number): Player | null;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
interface Player extends BasePlayer {}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Replicated KCD2 horse handle.
|
|
916
|
+
*/
|
|
917
|
+
class Horse {
|
|
918
|
+
/**
|
|
919
|
+
* Creates a script wrapper for an existing horse with this ID; use Horse.spawn() to spawn one.
|
|
920
|
+
* @param id Network entity identifier.
|
|
921
|
+
*/
|
|
922
|
+
constructor(id: number);
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* What this horse wears, by slot: `saddle` (the saddlebags are part of it, and so is the carrying capacity they add), `head` (a bridle or chanfron), `torso` (a caparison), `shoe`. Item class names, null for an empty slot. A spawned horse wears the game's own tack for it unless `Horse.spawn` said otherwise. The gear changes the horse's stats as well as its look.
|
|
926
|
+
*/
|
|
927
|
+
readonly gear: { saddle: string | null; head: string | null; torso: string | null; shoe: string | null };
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* While true, players' own changes to this horse's gear are refused and put back, before `horseGearChanging` is asked. Scripts can still change it. False by default.
|
|
931
|
+
*/
|
|
932
|
+
gearLocked: boolean;
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* GUID of the soul this horse was spawned against, which decides its appearance.
|
|
936
|
+
*/
|
|
937
|
+
readonly soul: string;
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Name every client shows for this horse. Assignment renames it on all of them; empty means the name its soul carries stands. A rider keeps the name it mounted with until it dismounts.
|
|
941
|
+
*/
|
|
942
|
+
name: string;
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* What this horse can carry, in the game's own weight units, or 0 before any client has reported it. Derived by the engine, so read-only.
|
|
946
|
+
*/
|
|
947
|
+
readonly inventoryCapacity: number;
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Network ID of the player in the saddle, or 0 when the horse is riderless.
|
|
951
|
+
*/
|
|
952
|
+
readonly riderId: number;
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* The player in the saddle, or null when the horse is riderless.
|
|
956
|
+
*/
|
|
957
|
+
readonly rider: Player | null;
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Whether a player is currently riding this horse.
|
|
961
|
+
*/
|
|
962
|
+
readonly mounted: boolean;
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* Health, as the client running this horse last reported it off the animal's own soul -- 0 before any client has. Assigning sets it on that client, clamped to `maxHealth`; 0 kills. A dead horse ignores the write: `revive` is what brings one back.
|
|
966
|
+
*/
|
|
967
|
+
health: number;
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* The most health this horse can have, from its soul; 0 before any client has run it.
|
|
971
|
+
*/
|
|
972
|
+
readonly maxHealth: number;
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Stamina, as its client last reported it -- the bar the game draws for a ridden horse, spent by galloping. Read-only: the game runs it.
|
|
976
|
+
*/
|
|
977
|
+
readonly stamina: number;
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* The most stamina this horse can have; 0 before any client has run it.
|
|
981
|
+
*/
|
|
982
|
+
readonly maxStamina: number;
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* False once the horse has died. A dead horse is still an entity: its body stays where it fell, nobody can ride it, and `revive` or `destroy` are the ways out.
|
|
986
|
+
*/
|
|
987
|
+
readonly alive: boolean;
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Formats this horse handle for logging and debugging.
|
|
991
|
+
* @returns The horse ID, its soul, and its rider.
|
|
992
|
+
*/
|
|
993
|
+
toString(): string;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Despawns this horse on every client after emitting horseDestroy.
|
|
997
|
+
*/
|
|
998
|
+
destroy(): void;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Rears the horse on every client so it throws its rider off. The game's own animation, not a pose.
|
|
1002
|
+
* @returns True when the request went out; false when nobody is riding it.
|
|
1003
|
+
*/
|
|
1004
|
+
rearAndThrowDown(): boolean;
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* Has a player pull this horse's rider down, on every client.
|
|
1008
|
+
* @param attacker The player dragging the rider out of the saddle.
|
|
1009
|
+
* @returns True when the request went out; false when nobody is riding it.
|
|
1010
|
+
*/
|
|
1011
|
+
pullDownRider(attacker: Player): boolean;
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* Takes whoever is in the saddle out of it: their own client is told to get off, and `horseDismount` is raised.
|
|
1015
|
+
* @returns The player taken off, or null when the saddle was already empty.
|
|
1016
|
+
*/
|
|
1017
|
+
dismountRider(): Player | null;
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* Kills this horse on the client running it, the way any other death happens there: the body falls, anyone riding it comes off, and `horseDeath` follows with a null killer and the reason `scripted`.
|
|
1021
|
+
* @returns True when the horse was alive; false when it was already dead.
|
|
1022
|
+
*/
|
|
1023
|
+
kill(): boolean;
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* Brings a dead horse back where it lies, at its full health.
|
|
1027
|
+
* @returns True when the horse was dead; false when it was alive.
|
|
1028
|
+
*/
|
|
1029
|
+
revive(): boolean;
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Dresses this horse in exactly this gear on every client, the one running it included: what it wore before is taken off. Throws on an item that is not horse gear, one keyed under the wrong slot, or a caparison (`torso`) with no saddle under it. Not subject to `gearLocked` or `horseGearChanging`, which govern players; `horseGearChanged` follows with a null player.
|
|
1033
|
+
* @param gear A preset from `Horse.gearPresets()` (`horse_noble05`), or item class names or GUIDs by slot from `Horse.gearItems()`, where a missing key or null leaves that slot empty; `{}` is a bare horse.
|
|
1034
|
+
* @returns True when the gear was written; false when the horse is gone.
|
|
1035
|
+
*/
|
|
1036
|
+
setGear(gear: string | { saddle?: string | null; head?: string | null; torso?: string | null; shoe?: string | null }): boolean;
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Puts one piece of gear in its own slot, replacing what was there and keeping the rest.
|
|
1040
|
+
* @param item An item class name or GUID from `Horse.gearItems()`.
|
|
1041
|
+
* @returns True when it was put on; false for an item that is not horse gear, a caparison on a horse with no saddle, or a horse that is gone.
|
|
1042
|
+
*/
|
|
1043
|
+
equipGear(item: string): boolean;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Takes one piece of gear off. Removing the saddle removes the caparison too, since it lies on the saddle.
|
|
1047
|
+
* @param slot The slot to empty.
|
|
1048
|
+
* @returns True when something was taken off; false when the slot was already empty.
|
|
1049
|
+
*/
|
|
1050
|
+
removeGear(slot: 'saddle' | 'head' | 'torso' | 'shoe'): boolean;
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Spawns and replicates a horse.
|
|
1054
|
+
* @param position Optional world-space spawn position; omitted components default to zero.
|
|
1055
|
+
* @param rotation Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in degrees.
|
|
1056
|
+
* @param soul Optional breed from `Horse.breeds()` (`pebbles`), or a soul GUID from the game's tables; omitted spawns the generic riding horse.
|
|
1057
|
+
* @param name Optional name every client shows for the horse; omitted leaves the name its soul carries.
|
|
1058
|
+
* @param gear Optional gear the horse is born wearing on every client, as `setGear` takes it; `{}` spawns it bare. Omitted, it wears the game's own tack: a named horse's own preset, or one of the generic ones (`horse_common01`, `horse_common02`).
|
|
1059
|
+
* @returns The newly spawned horse handle.
|
|
1060
|
+
*/
|
|
1061
|
+
static spawn(position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, soul?: string, name?: string, gear?: string | { saddle?: string | null; head?: string | null; torso?: string | null; shoe?: string | null }): Horse;
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* The game's own sets of horse tack, from its clothing presets: the generic `horse_common`, `horse_noble`, `horse_nomad` and `horse_draft` families, and the named horses' own. Any of them goes to `setGear` or `Horse.spawn` by name.
|
|
1065
|
+
* @returns Preset names, alphabetical.
|
|
1066
|
+
*/
|
|
1067
|
+
static gearPresets(): string[];
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Every item class a horse can wear, from the game's own tables: saddles, bridles and chanfrons, caparisons and trappings, horseshoes.
|
|
1071
|
+
* @param slot Only the gear for this slot; omitted lists all of it.
|
|
1072
|
+
* @returns Item class names, saddles first.
|
|
1073
|
+
*/
|
|
1074
|
+
static gearItems(slot?: 'saddle' | 'head' | 'torso' | 'shoe'): string[];
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* The horses `Horse.spawn` knows by name: every horse the game gives a character of its own -- the ones its traders sell and the named horses of its quests -- plus `horse`, the generic one.
|
|
1078
|
+
* @returns Breed names, `horse` first and the rest alphabetical.
|
|
1079
|
+
*/
|
|
1080
|
+
static breeds(): string[];
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Lists every horse the server currently has.
|
|
1084
|
+
* @returns One handle per live horse, in no particular order.
|
|
1085
|
+
*/
|
|
1086
|
+
static all(): Horse[];
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Looks a horse up by its network entity ID.
|
|
1090
|
+
* @param id Network entity identifier.
|
|
1091
|
+
* @returns The horse's handle, or null when no live horse has that ID.
|
|
1092
|
+
*/
|
|
1093
|
+
static getById(id: number): Horse | null;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
interface Horse extends Entity {}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* One row of a page.
|
|
1100
|
+
*/
|
|
1101
|
+
interface DialogueOption {
|
|
1102
|
+
/**
|
|
1103
|
+
* What comes back on `dialogueChoice` when this row is picked. An id, never an index, so a handler stays correct when the page is rebuilt with different rows.
|
|
1104
|
+
*/
|
|
1105
|
+
id: string;
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* The line the player reads. Server-authored text reaches the game's own list as written; it is not a localization key.
|
|
1109
|
+
*/
|
|
1110
|
+
text: string;
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* 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.
|
|
1114
|
+
*/
|
|
1115
|
+
enabled: boolean | undefined;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* A line and the options under it.
|
|
1120
|
+
*/
|
|
1121
|
+
interface DialoguePage {
|
|
1122
|
+
/**
|
|
1123
|
+
* Shown above the options. Omit it for a list with no preamble.
|
|
1124
|
+
*/
|
|
1125
|
+
line: string | undefined;
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* Draws the list on the right of the screen instead of the left.
|
|
1129
|
+
*/
|
|
1130
|
+
onRight: boolean | undefined;
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* The rows, at least one and at most eight. A page with none is refused.
|
|
1134
|
+
*/
|
|
1135
|
+
options: DialogueOption[];
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* Conversations the server drives on a player, in the game's own dialogue list.
|
|
1140
|
+
*
|
|
1141
|
+
* A conversation is attached to nothing. It runs on a player and what it is about -- a smith, a notice board, a chest, a timer -- is this gamemode's own business, held in its own closures. That is deliberate and it has a cost: nothing here watches distance, line of sight or whether anyone died, because none of that is knowable without the relationship it refuses to hold. Close the conversation yourself when the fiction says it should end.
|
|
1142
|
+
*/
|
|
1143
|
+
const Dialogue: {
|
|
1144
|
+
/**
|
|
1145
|
+
* Opens a conversation and shows its first page. A player already in one has it closed with reason 2 first, because the game has a single choice list and stacking them would lie about which is live.
|
|
1146
|
+
* @param player NetworkID of the player the conversation runs on.
|
|
1147
|
+
* @param page The first page. `options` is required and carries at most 8 rows; each needs an `id` and a `text`, and may set `enabled`. `line` and `onRight` are optional.
|
|
1148
|
+
* @returns The session id, or 0 when the page was unusable or the player is gone.
|
|
1149
|
+
*/
|
|
1150
|
+
open(player: number, page: DialoguePage): number;
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* Replaces the page a live conversation is showing. Each page carries a generation the client echoes, so an answer still in flight against the page this replaces is dropped rather than misapplied.
|
|
1154
|
+
* @param session The session to advance.
|
|
1155
|
+
* @param page The page to show instead.
|
|
1156
|
+
* @returns False when that session has already ended.
|
|
1157
|
+
*/
|
|
1158
|
+
update(session: number, page: DialoguePage): boolean;
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* Ends a conversation and takes the list off that player's screen.
|
|
1162
|
+
* @param session The session to end.
|
|
1163
|
+
* @returns False when the session had already ended.
|
|
1164
|
+
*/
|
|
1165
|
+
close(session: number): boolean;
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* The conversation that player is in.
|
|
1169
|
+
* @param player NetworkID of the player to ask about.
|
|
1170
|
+
* @returns The session id, or 0 when they are not in one.
|
|
1171
|
+
*/
|
|
1172
|
+
sessionOf(player: number): number;
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* How a vendor starts out.
|
|
1177
|
+
*/
|
|
1178
|
+
interface VendorOptions {
|
|
1179
|
+
/**
|
|
1180
|
+
* Shown in the server's log only. The trade screen names whoever keeps the shop.
|
|
1181
|
+
*/
|
|
1182
|
+
name: string | undefined;
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* Money units the vendor starts with, and all it can pay out. Omit it for a purse that never runs out.
|
|
1186
|
+
*/
|
|
1187
|
+
purse: number | undefined;
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Whether the vendor takes the player's items at all. On by default; `setBuyPrices` says which ones.
|
|
1191
|
+
*/
|
|
1192
|
+
buys: boolean | undefined;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* One thing a vendor sells.
|
|
1197
|
+
*/
|
|
1198
|
+
interface VendorStockRow {
|
|
1199
|
+
/**
|
|
1200
|
+
* The item class, by GUID or by the game's own item name.
|
|
1201
|
+
*/
|
|
1202
|
+
item: string;
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* How many the vendor has. A row the players buy out disappears.
|
|
1206
|
+
*/
|
|
1207
|
+
amount: number;
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* What one costs, in money units -- the amount of the game's `money` item, which is also what `player.giveItem('money', n)` hands out.
|
|
1211
|
+
*/
|
|
1212
|
+
price: number;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* One thing a vendor buys from players.
|
|
1217
|
+
*/
|
|
1218
|
+
interface VendorBuyRow {
|
|
1219
|
+
/**
|
|
1220
|
+
* The item class, by GUID or by the game's own item name.
|
|
1221
|
+
*/
|
|
1222
|
+
item: string;
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* What the vendor pays for one, in money units.
|
|
1226
|
+
*/
|
|
1227
|
+
price: number;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* One settled line of a deal.
|
|
1232
|
+
*/
|
|
1233
|
+
interface VendorTradeLine {
|
|
1234
|
+
/**
|
|
1235
|
+
* The item class GUID.
|
|
1236
|
+
*/
|
|
1237
|
+
item: string;
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* The game's own name for the item class.
|
|
1241
|
+
*/
|
|
1242
|
+
name: string;
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* How many changed hands.
|
|
1246
|
+
*/
|
|
1247
|
+
amount: number;
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* What one was priced at when the deal settled.
|
|
1251
|
+
*/
|
|
1252
|
+
price: number;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
/**
|
|
1256
|
+
* Price lists and purses the server owns, traded on the game's own shop screen.
|
|
1257
|
+
*
|
|
1258
|
+
* A vendor is attached to nothing: open one in front of a player from wherever the gamemode decides the counter is -- `npcInteract`, a dialogue option, a command. The screen is a preview. Its prices come from here, and pressing Trade sends a basket that the server re-prices, settles and moves itself; nothing the client shows is trusted.
|
|
1259
|
+
*
|
|
1260
|
+
* Prices count in money units, the amount of the game's `money` item.
|
|
1261
|
+
*/
|
|
1262
|
+
const Vendor: {
|
|
1263
|
+
/**
|
|
1264
|
+
* Creates a vendor with nothing to sell and nothing it buys.
|
|
1265
|
+
* @param options Name, starting purse and whether it buys. All optional.
|
|
1266
|
+
* @returns The vendor id.
|
|
1267
|
+
*/
|
|
1268
|
+
create(options?: VendorOptions): number;
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Closes every session at the vendor and forgets it. A deal already settling still completes.
|
|
1272
|
+
* @param vendor The vendor to remove.
|
|
1273
|
+
* @returns False when there was no such vendor.
|
|
1274
|
+
*/
|
|
1275
|
+
destroy(vendor: number): boolean;
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Replaces what a vendor sells. Every player with its screen open sees the new shelf straight away, and a basket priced against the old one is refused.
|
|
1279
|
+
* @param vendor The vendor to stock.
|
|
1280
|
+
* @param rows Everything it sells, at most 128 rows and each item class once. Replaces the old list.
|
|
1281
|
+
* @returns False when there is no such vendor.
|
|
1282
|
+
*/
|
|
1283
|
+
setStock(vendor: number, rows: VendorStockRow[]): boolean;
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Replaces what a vendor buys from players and what it pays. Anything not listed is shown at no value and a basket selling it is refused.
|
|
1287
|
+
* @param vendor The vendor to change.
|
|
1288
|
+
* @param rows Everything it buys, at most 128 rows and each item class once. Replaces the old list.
|
|
1289
|
+
* @returns False when there is no such vendor.
|
|
1290
|
+
*/
|
|
1291
|
+
setBuyPrices(vendor: number, rows: VendorBuyRow[]): boolean;
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Sets what a vendor can pay out. Deals keep it current: what players pay goes in, what they are paid comes out.
|
|
1295
|
+
* @param vendor The vendor to change.
|
|
1296
|
+
* @param purse Money units it holds, or null for a purse that never runs out.
|
|
1297
|
+
* @returns False when there is no such vendor.
|
|
1298
|
+
*/
|
|
1299
|
+
setPurse(vendor: number, purse: number | null): boolean;
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* What a vendor holds.
|
|
1303
|
+
* @param vendor The vendor to ask about.
|
|
1304
|
+
* @returns Money units, or null for a purse that never runs out or a vendor that does not exist.
|
|
1305
|
+
*/
|
|
1306
|
+
getPurse(vendor: number): number | null;
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Opens the game's own trade screen on a player. A player already trading has that session closed with reason 2 first, because the game has one trade screen.
|
|
1310
|
+
* @param vendor The vendor to trade with.
|
|
1311
|
+
* @param player NetworkID of the player to show it to.
|
|
1312
|
+
* @param npc NetworkID of the NPC who keeps the shop. The screen shows that NPC as the trader; omit it to trade with nobody in particular.
|
|
1313
|
+
* @returns The session id, or 0 when the vendor or the player is gone.
|
|
1314
|
+
*/
|
|
1315
|
+
open(vendor: number, player: number, npc?: number): number;
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Takes the trade screen off that player.
|
|
1319
|
+
* @param session The session to end.
|
|
1320
|
+
* @returns False when the session had already ended.
|
|
1321
|
+
*/
|
|
1322
|
+
close(session: number): boolean;
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* The trading session a player is in.
|
|
1326
|
+
* @param player NetworkID of the player to ask about.
|
|
1327
|
+
* @returns The session id, or 0 when they are not trading.
|
|
1328
|
+
*/
|
|
1329
|
+
sessionOf(player: number): number;
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* The vendor a session trades with.
|
|
1333
|
+
* @param session The session to ask about.
|
|
1334
|
+
* @returns The vendor id, or 0 when the session has ended.
|
|
1335
|
+
*/
|
|
1336
|
+
vendorOf(session: number): number;
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* One item class that left a victim's pockets for a thief's.
|
|
1341
|
+
*/
|
|
1342
|
+
interface PickpocketLine {
|
|
1343
|
+
/**
|
|
1344
|
+
* The item class GUID.
|
|
1345
|
+
*/
|
|
1346
|
+
item: string;
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* The game's own name for the item class.
|
|
1350
|
+
*/
|
|
1351
|
+
name: string;
|
|
1352
|
+
|
|
1353
|
+
/**
|
|
1354
|
+
* How many moved.
|
|
1355
|
+
*/
|
|
1356
|
+
amount: number;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Replicated KCD2 dog companion handle.
|
|
1361
|
+
*/
|
|
1362
|
+
class Dog {
|
|
1363
|
+
/**
|
|
1364
|
+
* Creates a script wrapper for an existing dog with this ID; use Dog.spawn() to spawn one.
|
|
1365
|
+
* @param id Network entity identifier.
|
|
1366
|
+
*/
|
|
1367
|
+
constructor(id: number);
|
|
1368
|
+
|
|
1369
|
+
/**
|
|
1370
|
+
* GUID of the soul this dog was spawned against, which decides its appearance.
|
|
1371
|
+
*/
|
|
1372
|
+
readonly soul: string;
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* Name every client shows for this dog. Assignment renames it on all of them; empty means the name its soul carries stands.
|
|
1376
|
+
*/
|
|
1377
|
+
name: string;
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Network ID of the player this dog belongs to, or 0 when it has no master.
|
|
1381
|
+
*/
|
|
1382
|
+
readonly ownerId: number;
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* The player this dog belongs to, or null when it has no master.
|
|
1386
|
+
*/
|
|
1387
|
+
readonly owner: Player | null;
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* The dog's companion mode: 0 Wait, 1 Follow, 2 Free, 3 Aggressive, 4 Search, 5 Hunt, 6 Guard, 7 Ambush. Assignment applies it on every client.
|
|
1391
|
+
*/
|
|
1392
|
+
mode: number;
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* What the owner's game currently has this dog doing, as an E_DogObjective ordinal: 0 Wait, 2 Bark, 4 Follow, 5 FollowHeel, 7 Search, 8 MeleeCombat, 9 Fetch, 10 Hunt, 19 Eat, 21 Distract, 22 Pet, 25 Invalid when idle. Reported by the owner, so read-only.
|
|
1396
|
+
*/
|
|
1397
|
+
readonly objective: number;
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* The dog's morale as its owner last read it off the game, or 0 before any report. Below the game's own threshold the dog stops obeying commands. Owner-reported, so read-only.
|
|
1401
|
+
*/
|
|
1402
|
+
readonly morale: number;
|
|
1403
|
+
|
|
1404
|
+
/**
|
|
1405
|
+
* Formats this dog handle for logging and debugging.
|
|
1406
|
+
* @returns The dog ID, its soul, its owner and its mode.
|
|
1407
|
+
*/
|
|
1408
|
+
toString(): string;
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* Despawns this dog on every client after emitting dogDestroy.
|
|
1412
|
+
*/
|
|
1413
|
+
destroy(): void;
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* Hands this dog to another player. Every client re-possesses the body onto the new master's soul, and authority over its pose moves with it.
|
|
1417
|
+
* @param player The dog's new master, or null to leave it masterless.
|
|
1418
|
+
*/
|
|
1419
|
+
giveTo(player: Player | null): void;
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* Spawns and replicates a dog companion for a player.
|
|
1423
|
+
* @param owner The player the dog belongs to. A dog is somebody's from the moment it exists.
|
|
1424
|
+
* @param position Optional world-space spawn position; omitted spawns the dog on its owner.
|
|
1425
|
+
* @param rotation Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in degrees.
|
|
1426
|
+
* @param soul Optional soul GUID from the game's tables; omitted spawns the generic dog.
|
|
1427
|
+
* @param name Optional name every client shows for the dog; omitted leaves the name its soul carries.
|
|
1428
|
+
* @returns The newly spawned dog handle.
|
|
1429
|
+
*/
|
|
1430
|
+
static spawn(owner: Player, position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, soul?: string, name?: string): Dog;
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Lists every dog the server currently has.
|
|
1434
|
+
* @returns One handle per live dog, in no particular order.
|
|
1435
|
+
*/
|
|
1436
|
+
static all(): Dog[];
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* Looks a dog up by its network entity ID.
|
|
1440
|
+
* @param id Network entity identifier.
|
|
1441
|
+
* @returns The dog's handle, or null when no live dog has that ID.
|
|
1442
|
+
*/
|
|
1443
|
+
static getById(id: number): Dog | null;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
interface Dog extends Entity {}
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* Replicated static mesh handle.
|
|
1450
|
+
*/
|
|
1451
|
+
class Prop {
|
|
1452
|
+
/**
|
|
1453
|
+
* Creates a script wrapper for an existing prop with this ID; use Prop.spawn() to spawn one.
|
|
1454
|
+
* @param id Network entity identifier.
|
|
1455
|
+
*/
|
|
1456
|
+
constructor(id: number);
|
|
1457
|
+
|
|
1458
|
+
/**
|
|
1459
|
+
* Catalog path of the mesh this prop was built from, e.g. `objects/manmade/barrels/barrel_a.cgf`. Read-only: the collision is built from the mesh when the entity is spawned and never re-read, so a prop is the model it was created with.
|
|
1460
|
+
*/
|
|
1461
|
+
readonly model: string;
|
|
1462
|
+
|
|
1463
|
+
/**
|
|
1464
|
+
* File stem of the mesh, e.g. `barrel_a`, which is the short name `Prop.spawn` also accepts.
|
|
1465
|
+
*/
|
|
1466
|
+
readonly modelName: string;
|
|
1467
|
+
|
|
1468
|
+
/**
|
|
1469
|
+
* Browsing bucket the mesh sits in, e.g. `manmade/structures`.
|
|
1470
|
+
*/
|
|
1471
|
+
readonly modelGroup: string;
|
|
1472
|
+
|
|
1473
|
+
/**
|
|
1474
|
+
* What this prop's collision does: `static` collides but never moves, `rigid` falls and can be pushed, `none` has none at all. Assignment rebuilds the prop on every client, and a rigid one is simulated separately by each of them with nothing reconciling it.
|
|
1475
|
+
*/
|
|
1476
|
+
physics: string;
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* Uniform scale, from 0.01 to 100; a value outside that is clamped into it. Assignment rebuilds the prop on every client, because the collision is sized from the scale at spawn and never re-read.
|
|
1480
|
+
*/
|
|
1481
|
+
scale: number;
|
|
1482
|
+
|
|
1483
|
+
/**
|
|
1484
|
+
* Formats this prop handle for logging and debugging.
|
|
1485
|
+
* @returns The prop ID, its model, its physics and its scale.
|
|
1486
|
+
*/
|
|
1487
|
+
toString(): string;
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* Despawns this prop on every client after emitting propDestroy.
|
|
1491
|
+
*/
|
|
1492
|
+
destroy(): void;
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* Spawns and replicates a static mesh from the game's own object catalog.
|
|
1496
|
+
* @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.
|
|
1497
|
+
* @param position Optional world-space spawn position; omitted components default to zero.
|
|
1498
|
+
* @param rotation Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in degrees.
|
|
1499
|
+
* @param scale Optional uniform scale from 0.01 to 100; omitted spawns the mesh at its own size.
|
|
1500
|
+
* @param physics Optional collision: `static` (the default), `rigid` or `none`.
|
|
1501
|
+
* @param virtualWorld Optional virtual world the prop belongs to; omitted puts it in the global one.
|
|
1502
|
+
* @returns The newly spawned prop handle.
|
|
1503
|
+
*/
|
|
1504
|
+
static spawn(model: string, position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, scale?: number, physics?: string, virtualWorld?: number): Prop;
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Lists every prop the server currently has.
|
|
1508
|
+
* @returns One handle per live prop, in no particular order.
|
|
1509
|
+
*/
|
|
1510
|
+
static all(): Prop[];
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* Looks a prop up by its network entity ID.
|
|
1514
|
+
* @param id Network entity identifier.
|
|
1515
|
+
* @returns The prop's handle, or null when no live prop has that ID.
|
|
1516
|
+
*/
|
|
1517
|
+
static getById(id: number): Prop | null;
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* Despawns props, emitting propDestroy for each one.
|
|
1521
|
+
* @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
|
|
1522
|
+
* @returns How many props were removed.
|
|
1523
|
+
*/
|
|
1524
|
+
static destroyAll(virtualWorld?: number): number;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
interface Prop extends Entity {}
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Replicated particle effect handle.
|
|
1531
|
+
*/
|
|
1532
|
+
class Vfx {
|
|
1533
|
+
/**
|
|
1534
|
+
* Creates a script wrapper for an existing effect with this ID; use Vfx.spawn() to place one.
|
|
1535
|
+
* @param id Network entity identifier.
|
|
1536
|
+
*/
|
|
1537
|
+
constructor(id: number);
|
|
1538
|
+
|
|
1539
|
+
/**
|
|
1540
|
+
* Name of the particle effect this is playing, e.g. `WH_Particels.fires.campfire_a`. Read-only: every spawn parameter is read once when the emitter is created, so an effect is the one it was placed as.
|
|
1541
|
+
*/
|
|
1542
|
+
readonly effect: string;
|
|
1543
|
+
|
|
1544
|
+
/**
|
|
1545
|
+
* Particle library the effect came out of, e.g. `WH_Particels`, which is the part of the name before the first dot.
|
|
1546
|
+
*/
|
|
1547
|
+
readonly library: string;
|
|
1548
|
+
|
|
1549
|
+
/**
|
|
1550
|
+
* Authored bucket inside that library, e.g. `fires`.
|
|
1551
|
+
*/
|
|
1552
|
+
readonly group: string;
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* Multiplies every size the effect authored, from 0.01 to 32; a value outside that is clamped into it. Assignment rebuilds the emitter on every client that can see it, so the effect restarts.
|
|
1556
|
+
*/
|
|
1557
|
+
scale: number;
|
|
1558
|
+
|
|
1559
|
+
/**
|
|
1560
|
+
* Multiplies how many particles are emitted, from 0.01 to 16. Assignment restarts the effect.
|
|
1561
|
+
*/
|
|
1562
|
+
countScale: number;
|
|
1563
|
+
|
|
1564
|
+
/**
|
|
1565
|
+
* Multiplies emission speed, from 0 to 16. Assignment restarts the effect.
|
|
1566
|
+
*/
|
|
1567
|
+
speedScale: number;
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* Multiplies how fast the emitter's own time runs, from 0.01 to 16. Assignment restarts the effect.
|
|
1571
|
+
*/
|
|
1572
|
+
timeScale: number;
|
|
1573
|
+
|
|
1574
|
+
/**
|
|
1575
|
+
* Feeds the effect's own strength curves, from -1 to 1; -1 leaves them where the effect authored them. Assignment restarts the effect.
|
|
1576
|
+
*/
|
|
1577
|
+
strength: number;
|
|
1578
|
+
|
|
1579
|
+
/**
|
|
1580
|
+
* Seconds between restarts of the whole emitter, from 0 to 600; 0 never restarts it. Assignment restarts the effect.
|
|
1581
|
+
*/
|
|
1582
|
+
pulsePeriod: number;
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* Formats this effect handle for logging and debugging.
|
|
1586
|
+
* @returns The effect ID, its name and its scale.
|
|
1587
|
+
*/
|
|
1588
|
+
toString(): string;
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* Stops this effect on every client that can see it, after emitting vfxDestroy.
|
|
1592
|
+
*/
|
|
1593
|
+
destroy(): void;
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* Places a particle effect in the world and leaves it running. It is a replicated entity, so the interest grid streams it to whoever comes near and takes it away again when they leave -- which is what a campfire, a torch or a plume of smoke needs and what `burst` cannot do. How far it streams is taken from the effect's own draw distance, between 25 and 250 metres.
|
|
1597
|
+
* @param effect Effect to place, spelled as the game's particle libraries spell it -- `WH_Particels.fires.campfire_a`. `Vfx.list()` is the whole vocabulary.
|
|
1598
|
+
* @param position Optional world-space position; omitted components default to zero.
|
|
1599
|
+
* @param options `rotation` aims the emitter; `scale`, `countScale`, `speedScale` and `timeScale` multiply what the effect authored; `strength` feeds its strength curves; `pulsePeriod` restarts it on that many seconds; `prime` starts it already running, which is what a fire wants. `durationMs` is ignored here -- a placed effect lasts until it is destroyed.
|
|
1600
|
+
* @param virtualWorld Optional virtual world the effect belongs to; omitted puts it in the global one.
|
|
1601
|
+
* @returns The newly placed effect handle.
|
|
1602
|
+
*/
|
|
1603
|
+
static spawn(effect: string, position?: Vector3 | Partial<Vector3>, options?: { rotation?: Quaternion | Vector3; scale?: number; countScale?: number; speedScale?: number; timeScale?: number; strength?: number; pulsePeriod?: number; prime?: boolean; durationMs?: number }, virtualWorld?: number): Vfx;
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Plays an effect once for the players who can see the point it happens at, and keeps nothing. Recipients are chosen by the effect's own draw distance -- there is no point telling a client about something its engine would not draw -- so a blood spray reaches the people standing there and nobody else. A player who arrives afterwards sees nothing, which is the right answer for a spark and the wrong one for a campfire; use `spawn` for those.
|
|
1607
|
+
* @param effect Effect to play, spelled as the game's particle libraries spell it.
|
|
1608
|
+
* @param position Where it happens, in world-space metres.
|
|
1609
|
+
* @param options As `spawn`, and here `durationMs` does apply: how long each client keeps the emitter, two seconds by default and a minute at most.
|
|
1610
|
+
* @param virtualWorld Optional virtual world; omitted uses the global one.
|
|
1611
|
+
* @returns How many clients were told.
|
|
1612
|
+
*/
|
|
1613
|
+
static burst(effect: string, position: Vector3, options?: { rotation?: Quaternion | Vector3; scale?: number; countScale?: number; speedScale?: number; timeScale?: number; strength?: number; pulsePeriod?: number; prime?: boolean; durationMs?: number }, virtualWorld?: number): number;
|
|
1614
|
+
|
|
1615
|
+
/**
|
|
1616
|
+
* Plays an effect once on a replicated entity, where it follows that entity: blood on the body that was hit, sparks on the weapon that struck. A client that has not streamed the entity in drops it rather than playing it somewhere else.
|
|
1617
|
+
* @param effect Effect to play, spelled as the game's particle libraries spell it.
|
|
1618
|
+
* @param entity What to hang it on: any replicated handle -- a Player, Prop, Horse or Dog -- or a bare network entity ID.
|
|
1619
|
+
* @param options As `burst`, plus `offset`: where the emitter sits in the entity's own space, in metres, up to 8 m from its origin.
|
|
1620
|
+
* @returns How many clients were told.
|
|
1621
|
+
*/
|
|
1622
|
+
static burstOn(effect: string, entity: Entity | number, options?: { offset?: Vector3; rotation?: Quaternion | Vector3; scale?: number; countScale?: number; speedScale?: number; timeScale?: number; strength?: number; pulsePeriod?: number; prime?: boolean; durationMs?: number }): number;
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* Lists every replicated effect the server currently has.
|
|
1626
|
+
* @param virtualWorld Optional virtual world to list; omitted lists every one of them.
|
|
1627
|
+
* @returns One handle per live effect, in no particular order.
|
|
1628
|
+
*/
|
|
1629
|
+
static all(virtualWorld?: number): Vfx[];
|
|
1630
|
+
|
|
1631
|
+
/**
|
|
1632
|
+
* Looks a replicated effect up by its network entity ID.
|
|
1633
|
+
* @param id Network entity identifier.
|
|
1634
|
+
* @returns The effect's handle, or null when no live effect has that ID.
|
|
1635
|
+
*/
|
|
1636
|
+
static getById(id: number): Vfx | null;
|
|
1637
|
+
|
|
1638
|
+
/**
|
|
1639
|
+
* Stops replicated effects, emitting vfxDestroy for each one.
|
|
1640
|
+
* @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
|
|
1641
|
+
* @returns How many effects were stopped.
|
|
1642
|
+
*/
|
|
1643
|
+
static destroyAll(virtualWorld?: number): number;
|
|
1644
|
+
|
|
1645
|
+
/**
|
|
1646
|
+
* Every effect name the shipped game declares, in order. Mined from the game's particle libraries at build time, so it is the same list the client has.
|
|
1647
|
+
* @param prefix Keep only the names starting with this, e.g. `WH_Particels.fires` or `collisions.combat`.
|
|
1648
|
+
* @returns The matching names.
|
|
1649
|
+
*/
|
|
1650
|
+
static list(prefix?: string): string[];
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
interface Vfx extends Entity {}
|
|
1654
|
+
|
|
1655
|
+
/**
|
|
1656
|
+
* Replicated ground marker handle.
|
|
1657
|
+
*/
|
|
1658
|
+
class Marker {
|
|
1659
|
+
/**
|
|
1660
|
+
* Creates a script wrapper for an existing marker with this ID; use Marker.place() to draw one.
|
|
1661
|
+
* @param id Network entity identifier.
|
|
1662
|
+
*/
|
|
1663
|
+
constructor(id: number);
|
|
1664
|
+
|
|
1665
|
+
/**
|
|
1666
|
+
* Decal material this marker is drawn with, e.g. `materials/decals/chalk_cross`. Read-only: a decal node reads its material once, so a marker is the one it was placed as.
|
|
1667
|
+
*/
|
|
1668
|
+
readonly material: string;
|
|
1669
|
+
|
|
1670
|
+
/**
|
|
1671
|
+
* Subfolder the material came out of under `materials/decals/`, empty at the top level.
|
|
1672
|
+
*/
|
|
1673
|
+
readonly group: string;
|
|
1674
|
+
|
|
1675
|
+
/**
|
|
1676
|
+
* What the marker is made of: `decal` for the projected one, or `cylinder`, `sphere`, `chevron`, `cube` or `plane` for a mesh standing in the world. Read-only: changing it is a rebuild, so place a new marker instead.
|
|
1677
|
+
*/
|
|
1678
|
+
readonly shape: string;
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* How wide the marker is, in metres, from 0.25 to 64; a value outside that is clamped into it. Assignment restates it in place rather than rebuilding, and widens how far the marker streams.
|
|
1682
|
+
*/
|
|
1683
|
+
size: number;
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* How tall a mesh marker stands, in metres, from 0.25 to 64. Ignored by `decal`, `sphere` and `plane`, which are sized by width alone.
|
|
1687
|
+
*/
|
|
1688
|
+
height: number;
|
|
1689
|
+
|
|
1690
|
+
/**
|
|
1691
|
+
* Degrees per second the marker turns about its own up axis, from -720 to 720; 0 stands still. Played on each client's own clock, so two players need not see it at the same angle. Ignored by `decal`.
|
|
1692
|
+
*/
|
|
1693
|
+
spin: number;
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* Packed 0xRRGGBBAA tint, or 0 for the material as it ships. The shipped material is shared by everything that names it, so a tint is a private clone rather than a write to the original -- which is why assignment rebuilds the marker.
|
|
1697
|
+
*/
|
|
1698
|
+
color: number;
|
|
1699
|
+
|
|
1700
|
+
/**
|
|
1701
|
+
* Whether clients watch the local player against this marker's volume and report crossings, which is what raises `markerEnter` and `markerExit`. Off by default: a marker nobody listens to should cost nothing but its draw.
|
|
1702
|
+
*/
|
|
1703
|
+
trigger: boolean;
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* How far the marker rises and falls from its resting height, in metres, up to 4; 0 stands still. Played on each client's own clock. Ignored by `decal`, which cannot leave the surface it projects onto.
|
|
1707
|
+
*/
|
|
1708
|
+
bob: number;
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* Formats this marker handle for logging and debugging.
|
|
1712
|
+
* @returns The marker ID, its material and its size.
|
|
1713
|
+
*/
|
|
1714
|
+
toString(): string;
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Removes this marker from every client that can see it, after emitting markerRemove.
|
|
1718
|
+
*/
|
|
1719
|
+
remove(): void;
|
|
1720
|
+
|
|
1721
|
+
/**
|
|
1722
|
+
* Puts a marker in the world and leaves it there. It is a replicated entity, so the interest grid streams it to whoever comes near and takes it away again when they leave -- which is what a zone or a checkpoint needs and what a one-shot message cannot do. How far it streams is taken from its own extent, between 50 and 400 metres.
|
|
1723
|
+
* @param material Decal material to project, spelled as the game's own data spells it -- `materials/decals/chalk_cross`. `Marker.list()` is the whole vocabulary.
|
|
1724
|
+
* @param position Optional world-space position; omitted components default to zero.
|
|
1725
|
+
* @param options `shape` picks what it is made of -- `decal` projects onto the surface under it, the rest stand in the world as meshes and can be seen from below a ridge. `rotation` aims it, so a marker laid on a wall is the same call with a different rotation; `size` and `height` are its extent in metres; `spin` and `bob` give a mesh marker motion; `color` tints it.
|
|
1726
|
+
* @param virtualWorld Optional virtual world the marker belongs to; omitted puts it in the global one.
|
|
1727
|
+
* @returns The newly drawn marker handle.
|
|
1728
|
+
*/
|
|
1729
|
+
static place(material: string, position?: Vector3 | Partial<Vector3>, options?: { shape?: 'decal' | 'cylinder' | 'sphere' | 'chevron' | 'cube' | 'plane'; rotation?: Quaternion | Vector3; size?: number; height?: number; spin?: number; bob?: number; color?: number; trigger?: boolean }, virtualWorld?: number): Marker;
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* Lists every replicated marker the server currently has.
|
|
1733
|
+
* @param virtualWorld Optional virtual world to list; omitted lists every one of them.
|
|
1734
|
+
* @returns One handle per live marker, in no particular order.
|
|
1735
|
+
*/
|
|
1736
|
+
static all(virtualWorld?: number): Marker[];
|
|
1737
|
+
|
|
1738
|
+
/**
|
|
1739
|
+
* Looks a replicated marker up by its network entity ID.
|
|
1740
|
+
* @param id Network entity identifier.
|
|
1741
|
+
* @returns The marker's handle, or null when no live marker has that ID.
|
|
1742
|
+
*/
|
|
1743
|
+
static getById(id: number): Marker | null;
|
|
1744
|
+
|
|
1745
|
+
/**
|
|
1746
|
+
* Removes markers, emitting markerRemove for each one.
|
|
1747
|
+
* @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
|
|
1748
|
+
* @returns How many markers were removed.
|
|
1749
|
+
*/
|
|
1750
|
+
static removeAll(virtualWorld?: number): number;
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* Every decal material the shipped game preloads, in order. Mined from the game's own material folder at build time, so it is the same list the client has.
|
|
1754
|
+
* @param prefix Keep only the names starting with this, e.g. `materials/decals/burglar`.
|
|
1755
|
+
* @returns The matching names.
|
|
1756
|
+
*/
|
|
1757
|
+
static list(prefix?: string): string[];
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
interface Marker extends Entity {}
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* Replicated compass and map-screen blip handle.
|
|
1764
|
+
*/
|
|
1765
|
+
class Blip {
|
|
1766
|
+
/**
|
|
1767
|
+
* Creates a script wrapper for an existing blip with this ID; use Blip.create() to place one.
|
|
1768
|
+
* @param id Network entity identifier.
|
|
1769
|
+
*/
|
|
1770
|
+
constructor(id: number);
|
|
1771
|
+
|
|
1772
|
+
/**
|
|
1773
|
+
* Which of the game's own compass icons the blip draws as, by the game's own name for it -- `Blip.types()` lists them. Assigning a name the game does not know leaves the blip as it was.
|
|
1774
|
+
*/
|
|
1775
|
+
type: string;
|
|
1776
|
+
|
|
1777
|
+
/**
|
|
1778
|
+
* The mark's state, forwarded to the compass and map movies as-is -- what the client Blip calls `state`, renamed here because every entity's `state` is its StateBag. What a given value draws is undocumented; 0 is what a fresh game mark carries.
|
|
1779
|
+
*/
|
|
1780
|
+
markState: number;
|
|
1781
|
+
|
|
1782
|
+
/**
|
|
1783
|
+
* The blip's name on the map screen, shown verbatim in place of the name the game gives its icon type; empty keeps that name. Cut to 64 bytes. The compass has no text, so it never shows this.
|
|
1784
|
+
*/
|
|
1785
|
+
label: string;
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Whether the blip is drawn on players' HUD compasses.
|
|
1789
|
+
*/
|
|
1790
|
+
compass: boolean;
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* Whether the blip is drawn on players' map screens, for an icon the map has art for: `Main`, `Side`, `Micro`, `Checkpoint`, `Dlcs`, `Bailiff`, `FistFight` and `Racing` have none and stay on the compass. The map legend's switch for the blip's icon type hides it like one of the game's own.
|
|
1794
|
+
*/
|
|
1795
|
+
map: boolean;
|
|
1796
|
+
|
|
1797
|
+
/**
|
|
1798
|
+
* Formats this blip handle for logging and debugging.
|
|
1799
|
+
* @returns The blip ID, its type and its label.
|
|
1800
|
+
*/
|
|
1801
|
+
toString(): string;
|
|
1802
|
+
|
|
1803
|
+
/**
|
|
1804
|
+
* Takes this blip off every compass and map screen that shows it.
|
|
1805
|
+
*/
|
|
1806
|
+
remove(): void;
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* Puts a blip on the compass and map screen of every player in its virtual world, or of the one player it is private to. It is a replicated entity that is never culled by distance -- a blip is for finding something far away -- so it reaches players however far they are and whenever they join, and assigning `position` moves it for all of them. `setVisibleTo` works on it like on any entity.
|
|
1810
|
+
* @param options Where the blip goes, which icon it draws with -- one of `Blip.types()`, `GeneralPoi` by default -- its mark state, its name on the map screen, and whether it shows on the compass and the map screen, both by default. `player` makes it private to that player from the start; `virtualWorld` puts a public one in that world, the global one by default.
|
|
1811
|
+
* @returns The new blip handle.
|
|
1812
|
+
*/
|
|
1813
|
+
static create(options: { position: Vector3; type?: string; markState?: number; label?: string; compass?: boolean; map?: boolean; player?: Player; virtualWorld?: number }): Blip;
|
|
1814
|
+
|
|
1815
|
+
/**
|
|
1816
|
+
* Lists every blip the server currently has.
|
|
1817
|
+
* @param virtualWorld Optional virtual world to list; omitted lists every one of them.
|
|
1818
|
+
* @returns One handle per live blip, in no particular order.
|
|
1819
|
+
*/
|
|
1820
|
+
static all(virtualWorld?: number): Blip[];
|
|
1821
|
+
|
|
1822
|
+
/**
|
|
1823
|
+
* Looks a blip up by its network entity ID.
|
|
1824
|
+
* @param id Network entity identifier.
|
|
1825
|
+
* @returns The blip's handle, or null when no live blip has that ID.
|
|
1826
|
+
*/
|
|
1827
|
+
static getById(id: number): Blip | null;
|
|
1828
|
+
|
|
1829
|
+
/**
|
|
1830
|
+
* Removes blips.
|
|
1831
|
+
* @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
|
|
1832
|
+
* @returns How many blips were removed.
|
|
1833
|
+
*/
|
|
1834
|
+
static removeAll(virtualWorld?: number): number;
|
|
1835
|
+
|
|
1836
|
+
/**
|
|
1837
|
+
* Every icon a blip can draw with, by the game's own name for it, misspellings included.
|
|
1838
|
+
* @returns The names, in the game's own order.
|
|
1839
|
+
*/
|
|
1840
|
+
static types(): string[];
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
interface Blip extends Entity {}
|
|
1844
|
+
|
|
1845
|
+
/**
|
|
1846
|
+
* A server-owned NPC: spawned by a resource, simulated by whichever client is nearest.
|
|
1847
|
+
*/
|
|
1848
|
+
class Npc {
|
|
1849
|
+
/**
|
|
1850
|
+
* Creates a script wrapper for an existing NPC with this ID; use Npc.create() to spawn one.
|
|
1851
|
+
* @param id Network entity identifier.
|
|
1852
|
+
*/
|
|
1853
|
+
constructor(id: number);
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* GUID of the soul the body was spawned against, or empty for an adopted level body. Read-only: a soul decides what the body is, so a different one is a different NPC.
|
|
1857
|
+
*/
|
|
1858
|
+
readonly soul: string;
|
|
1859
|
+
|
|
1860
|
+
/**
|
|
1861
|
+
* Entity class the body is spawned as -- `NPC` or `NPC_Female`.
|
|
1862
|
+
*/
|
|
1863
|
+
readonly actorClass: string;
|
|
1864
|
+
|
|
1865
|
+
/**
|
|
1866
|
+
* `EntityGuid` of the level body this NPC adopted, or 0 for a spawned one.
|
|
1867
|
+
*/
|
|
1868
|
+
readonly levelGuid: number;
|
|
1869
|
+
|
|
1870
|
+
/**
|
|
1871
|
+
* What every client shows over the body and in conversation. Empty leaves the name its soul was born with.
|
|
1872
|
+
*/
|
|
1873
|
+
name: string;
|
|
1874
|
+
|
|
1875
|
+
/**
|
|
1876
|
+
* Faction row used for relationship and crime decisions; 0 is no faction.
|
|
1877
|
+
*/
|
|
1878
|
+
faction: number;
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* The server's ledger of this body's health, clamped to `maxHealth`. Damage from players arrives here after the server has agreed to it.
|
|
1882
|
+
*/
|
|
1883
|
+
health: number;
|
|
1884
|
+
|
|
1885
|
+
/**
|
|
1886
|
+
* Health the body starts with and is revived to.
|
|
1887
|
+
*/
|
|
1888
|
+
readonly maxHealth: number;
|
|
1889
|
+
|
|
1890
|
+
/**
|
|
1891
|
+
* False once health reached zero. A dead NPC is still an entity -- it is a corpse, and it can still be looted or revived.
|
|
1892
|
+
*/
|
|
1893
|
+
readonly alive: boolean;
|
|
1894
|
+
|
|
1895
|
+
/**
|
|
1896
|
+
* Whether damage is refused before it reaches the ledger.
|
|
1897
|
+
*/
|
|
1898
|
+
invulnerable: boolean;
|
|
1899
|
+
|
|
1900
|
+
/**
|
|
1901
|
+
* Whether the body holds its pose whatever its intent says.
|
|
1902
|
+
*/
|
|
1903
|
+
frozen: boolean;
|
|
1904
|
+
|
|
1905
|
+
/**
|
|
1906
|
+
* Whether clients watch the use key against this body and raise `npcInteract`. On by default.
|
|
1907
|
+
*/
|
|
1908
|
+
interactable: boolean;
|
|
1909
|
+
|
|
1910
|
+
/**
|
|
1911
|
+
* Whether its name is drawn over it the way a player's is.
|
|
1912
|
+
*/
|
|
1913
|
+
nametag: boolean;
|
|
1914
|
+
|
|
1915
|
+
/**
|
|
1916
|
+
* Whether its corpse keeps its inventory for whoever searches it.
|
|
1917
|
+
*/
|
|
1918
|
+
lootable: boolean;
|
|
1919
|
+
|
|
1920
|
+
/**
|
|
1921
|
+
* How the simulating client moves this body.
|
|
1922
|
+
*
|
|
1923
|
+
* `kinematic` (the default) advances the pose and lets every client animate it -- predictable, and the same path every remote player's body already runs on. `native` hands the destination to the game's own movement controller, which walks the body with real footfalls and real turns but will walk into whatever the engine does not route around. Pick `native` for bodies in the open and `kinematic` for anything on an authored route.
|
|
1924
|
+
*/
|
|
1925
|
+
locomotion: string;
|
|
1926
|
+
|
|
1927
|
+
/**
|
|
1928
|
+
* What the NPC has been told to do: `hold`, `moveTo`, `follow`, `flee`, `lookAt`, `playAnim` or `talk`.
|
|
1929
|
+
*/
|
|
1930
|
+
readonly intent: string;
|
|
1931
|
+
|
|
1932
|
+
/**
|
|
1933
|
+
* What the simulating client last reported about the current intent: `idle`, `running`, `reached`, `blocked` or `failed`. A dormant NPC that is walking an authored route reports through the server's own dead reckoning instead, so a patrol keeps stepping with nobody there to watch it.
|
|
1934
|
+
*/
|
|
1935
|
+
readonly status: string;
|
|
1936
|
+
|
|
1937
|
+
/**
|
|
1938
|
+
* The body under the clothes, as the game's own component names. Write it with `setAppearance`.
|
|
1939
|
+
*/
|
|
1940
|
+
readonly appearance: Appearance;
|
|
1941
|
+
|
|
1942
|
+
/**
|
|
1943
|
+
* What it has been told to wear, as item class GUIDs; empty when it wears its own clothes. Write it with `wear` or `setOutfit`.
|
|
1944
|
+
*/
|
|
1945
|
+
readonly wearing: string[];
|
|
1946
|
+
|
|
1947
|
+
/**
|
|
1948
|
+
* The player whose client is currently running this NPC, or null while it is dormant. Dormant is not broken: nobody is near enough for it to matter, and the server keeps its route advancing until somebody is.
|
|
1949
|
+
*/
|
|
1950
|
+
readonly simulator: Player | null;
|
|
1951
|
+
|
|
1952
|
+
/**
|
|
1953
|
+
* Formats this NPC handle for logging and debugging.
|
|
1954
|
+
* @returns The NPC's ID, name, intent and last reported status.
|
|
1955
|
+
*/
|
|
1956
|
+
toString(): string;
|
|
1957
|
+
|
|
1958
|
+
/**
|
|
1959
|
+
* Despawns this NPC everywhere, after emitting npcDestroy.
|
|
1960
|
+
*/
|
|
1961
|
+
remove(): void;
|
|
1962
|
+
|
|
1963
|
+
/**
|
|
1964
|
+
* Cancels whatever it was doing and leaves it standing where it is.
|
|
1965
|
+
*/
|
|
1966
|
+
hold(): void;
|
|
1967
|
+
|
|
1968
|
+
/**
|
|
1969
|
+
* Sends the NPC somewhere and raises `npcIntentDone` when it arrives, cannot get there, or gives up. Cancels any patrol.
|
|
1970
|
+
* @param position Where to walk to.
|
|
1971
|
+
* @param options `speed` is the pace to walk at; `radius` is how close counts as arrived, in metres.
|
|
1972
|
+
* @returns True when the order went out.
|
|
1973
|
+
*/
|
|
1974
|
+
moveTo(position: Vector3 | Partial<Vector3>, options?: { speed?: 'walk' | 'jog' | 'run'; radius?: number }): boolean;
|
|
1975
|
+
|
|
1976
|
+
/**
|
|
1977
|
+
* Walks a route, one waypoint at a time. The route stays on the server and only the waypoint being walked to is ever replicated, so a player who joins mid-patrol sees one move rather than a plan to catch up with -- and a patrol nobody is near enough to simulate keeps advancing on the server's own reckoning.
|
|
1978
|
+
* @param points The waypoints, in order.
|
|
1979
|
+
* @param options `loop` walks the route forever (the default); `waitSeconds` is how long to stand at each waypoint; `speed` is the pace.
|
|
1980
|
+
* @returns True when the route was accepted; false for an empty route or a point that is not finite.
|
|
1981
|
+
*/
|
|
1982
|
+
patrol(points: (Vector3 | Partial<Vector3>)[], options?: { speed?: 'walk' | 'jog' | 'run'; loop?: boolean; waitSeconds?: number }): boolean;
|
|
1983
|
+
|
|
1984
|
+
/**
|
|
1985
|
+
* Keeps the NPC near somebody as they move.
|
|
1986
|
+
* @param target Who to follow, as a handle or a network ID.
|
|
1987
|
+
* @param options `radius` is how close it tries to stay, in metres; `speed` is the pace.
|
|
1988
|
+
* @returns True when the order went out.
|
|
1989
|
+
*/
|
|
1990
|
+
follow(target: Player | Npc | number, options?: { speed?: 'walk' | 'jog' | 'run'; radius?: number }): boolean;
|
|
1991
|
+
|
|
1992
|
+
/**
|
|
1993
|
+
* Sends the NPC away from a place. The one intent that picks its own direction.
|
|
1994
|
+
* @param from What to run away from.
|
|
1995
|
+
* @param options `radius` is how far away is far enough; `speed` is the pace, `run` by default.
|
|
1996
|
+
* @returns True when the order went out.
|
|
1997
|
+
*/
|
|
1998
|
+
flee(from: Vector3 | Partial<Vector3>, options?: { speed?: 'walk' | 'jog' | 'run'; radius?: number }): boolean;
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* Turns the NPC's head, and its body when it has to, without moving it.
|
|
2002
|
+
* @param target Who or what to look at.
|
|
2003
|
+
* @returns True when the order went out.
|
|
2004
|
+
*/
|
|
2005
|
+
lookAt(target: Player | Npc | number | Vector3 | Partial<Vector3>): boolean;
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* Moves the body outright, whoever is simulating it. Unlike a player teleport this is a write rather than a request: the server bumps the body's epoch, so a pose the simulator had already sent cannot put it back.
|
|
2009
|
+
* @param position Where to put it.
|
|
2010
|
+
* @param rotation Optional facing; a Quaternion, or Euler angles in degrees.
|
|
2011
|
+
* @returns True when the position was usable.
|
|
2012
|
+
*/
|
|
2013
|
+
teleport(position: Vector3 | Partial<Vector3>, rotation?: Quaternion | Vector3 | Partial<Vector3>): boolean;
|
|
2014
|
+
|
|
2015
|
+
/**
|
|
2016
|
+
* Makes the NPC play one of the game's animations -- chopping wood with an axe in hand, drawing water, sitting, drinking -- on every client, the one simulating it included. It is state rather than a one-off: a client that streams the NPC in, and the next one to simulate it, play it too, until `stopAnimation` or the next `playAnimation`.
|
|
2017
|
+
*
|
|
2018
|
+
* Give it something to do that keeps it in place, `hold` or `lookAt`: an order to walk makes the legs fight a full-body animation. A hit or a fall can cut the animation short; `loop` starts it again.
|
|
2019
|
+
* @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.
|
|
2020
|
+
* @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.
|
|
2021
|
+
* @returns True when the request went out; false for a dead NPC. Throws for a prop or option it cannot use.
|
|
2022
|
+
*/
|
|
2023
|
+
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;
|
|
2024
|
+
|
|
2025
|
+
/**
|
|
2026
|
+
* Ends what `playAnimation` started, takes its props away and hands the body back to its intent.
|
|
2027
|
+
* @returns True when the request went out.
|
|
2028
|
+
*/
|
|
2029
|
+
stopAnimation(): boolean;
|
|
2030
|
+
|
|
2031
|
+
/**
|
|
2032
|
+
* Puts a line of speech over the body on every client that can see it.
|
|
2033
|
+
* @param text What it says, up to 256 characters.
|
|
2034
|
+
* @returns True when the line went out.
|
|
2035
|
+
*/
|
|
2036
|
+
say(text: string): boolean;
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* Dresses the body in exactly these items, replacing what it had on. An empty list takes off what it was given and leaves what its soul owns -- which for many souls, a role's among them, is only underwear, so re-dress those with `setOutfit`.
|
|
2040
|
+
* @param itemClasses Item class GUIDs in the dashed form the game's own tables spell them.
|
|
2041
|
+
* @returns True when every GUID names an item class this build has. Otherwise nothing changes, and each refused GUID is logged.
|
|
2042
|
+
*/
|
|
2043
|
+
wear(itemClasses: string[]): boolean;
|
|
2044
|
+
|
|
2045
|
+
/**
|
|
2046
|
+
* Dresses the body in one of the game's own outfits.
|
|
2047
|
+
* @param preset Clothing preset GUID from the game's own table.
|
|
2048
|
+
* @returns True when the preset is one this build has.
|
|
2049
|
+
*/
|
|
2050
|
+
setOutfit(preset: string): boolean;
|
|
2051
|
+
|
|
2052
|
+
/**
|
|
2053
|
+
* Changes the body under the clothes -- face, hair, beard and skin. Unlike a player's, this is a write rather than a request: nobody owns an NPC's body but the server.
|
|
2054
|
+
* @param appearance The parts to change; anything left out keeps what it is wearing.
|
|
2055
|
+
* @returns True when the appearance was accepted.
|
|
2056
|
+
*/
|
|
2057
|
+
setAppearance(appearance: Partial<Appearance>): boolean;
|
|
2058
|
+
|
|
2059
|
+
/**
|
|
2060
|
+
* Takes health off the ledger, raising `npcDamage` and, if it is the last of it, `npcDeath`. Refused for an invulnerable or already-dead body.
|
|
2061
|
+
* @param amount Health to take off.
|
|
2062
|
+
* @param attacker Who did it, for the events this raises.
|
|
2063
|
+
*/
|
|
2064
|
+
damage(amount: number, attacker?: Player | number): void;
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* Kills it outright, through the same path damage takes -- including an invulnerable one, which is the difference between this and `damage`.
|
|
2068
|
+
* @param attacker Who to credit with it.
|
|
2069
|
+
*/
|
|
2070
|
+
kill(attacker?: Player | number): void;
|
|
2071
|
+
|
|
2072
|
+
/**
|
|
2073
|
+
* Brings a dead NPC back at full health. Every client makes a fresh body for it, because the one they have is a corpse.
|
|
2074
|
+
*/
|
|
2075
|
+
revive(): void;
|
|
2076
|
+
|
|
2077
|
+
/**
|
|
2078
|
+
* Pins simulation of this NPC to one player's client, whatever the distances say. What a scripted scene wants: the actor has to be run by the machine the scene is being played to. A pinned NPC goes dormant rather than migrating when that player leaves range, and is unpinned automatically if they disconnect.
|
|
2079
|
+
* @param player Whose client should run it, or null to hand it back to the election.
|
|
2080
|
+
*/
|
|
2081
|
+
pin(player: Player | number | null): void;
|
|
2082
|
+
|
|
2083
|
+
/**
|
|
2084
|
+
* Spawns an NPC and replicates it. It exists on the server from this moment: every client near enough makes a body for it, one of them is elected to run it, and the rest draw what that one reports.
|
|
2085
|
+
*
|
|
2086
|
+
* The body is not simulated until somebody is close enough to run it, which is not a failure -- a guard on the other side of the map has nothing to do that anybody can see. Read `simulator` to tell.
|
|
2087
|
+
* @param options `soul` is a role name from `Npc.roles()` or a soul GUID; `position` is where to put it. Everything else has a default.
|
|
2088
|
+
* @returns The new NPC's handle.
|
|
2089
|
+
*/
|
|
2090
|
+
static create(options: { soul?: string; class?: string; name?: string; outfit?: string; wearing?: string[]; appearance?: Partial<Appearance>; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3>; faction?: number; health?: number; maxHealth?: number; locomotion?: 'kinematic' | 'native'; invulnerable?: boolean; frozen?: boolean; interactable?: boolean; nametag?: boolean; lootable?: boolean; virtualWorld?: number }): Npc;
|
|
2091
|
+
|
|
2092
|
+
/**
|
|
2093
|
+
* Takes over one of the level's own NPCs instead of spawning a new body. A level `EntityGuid` is the same number on every machine, so every client finds the same body -- which is how doors, gates and stashes are already addressed. Adopting the same guid twice returns the NPC that already has it.
|
|
2094
|
+
* @param levelGuid `EntityGuid` of the body the level already placed.
|
|
2095
|
+
* @param options The same options a spawn takes; `soul` and `class` are ignored, since the body already exists.
|
|
2096
|
+
* @returns The NPC handle for that body.
|
|
2097
|
+
*/
|
|
2098
|
+
static adopt(levelGuid: number, options?: { soul?: string; class?: string; name?: string; outfit?: string; wearing?: string[]; appearance?: Partial<Appearance>; position?: Vector3 | Partial<Vector3>; rotation?: Quaternion | Vector3 | Partial<Vector3>; faction?: number; health?: number; maxHealth?: number; locomotion?: 'kinematic' | 'native'; invulnerable?: boolean; frozen?: boolean; interactable?: boolean; nametag?: boolean; lootable?: boolean; virtualWorld?: number }): Npc;
|
|
2099
|
+
|
|
2100
|
+
/**
|
|
2101
|
+
* Lists every server-owned NPC.
|
|
2102
|
+
* @param virtualWorld Optional virtual world to list; omitted lists every one of them.
|
|
2103
|
+
* @returns One handle per live NPC, in no particular order.
|
|
2104
|
+
*/
|
|
2105
|
+
static all(virtualWorld?: number): Npc[];
|
|
2106
|
+
|
|
2107
|
+
/**
|
|
2108
|
+
* Looks an NPC up by its network entity ID.
|
|
2109
|
+
* @param id Network entity identifier.
|
|
2110
|
+
* @returns The NPC's handle, or null when no live NPC has that ID.
|
|
2111
|
+
*/
|
|
2112
|
+
static getById(id: number): Npc | null;
|
|
2113
|
+
|
|
2114
|
+
/**
|
|
2115
|
+
* Despawns NPCs, emitting npcDestroy for each.
|
|
2116
|
+
* @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
|
|
2117
|
+
* @returns How many were despawned.
|
|
2118
|
+
*/
|
|
2119
|
+
static removeAll(virtualWorld?: number): number;
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
* The named kinds of NPC this build ships -- `guard`, `bandit`, `townswoman` and the rest. Each is a real soul out of the game's own tables, so a role spawns a body that already looks the part. Anything not in this list is taken as a soul GUID.
|
|
2123
|
+
* @returns The role names.
|
|
2124
|
+
*/
|
|
2125
|
+
static roles(): string[];
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
interface Npc extends Entity {}
|
|
2129
|
+
|
|
2130
|
+
/**
|
|
2131
|
+
* Replicated journal quest handle.
|
|
2132
|
+
*/
|
|
2133
|
+
class Quest {
|
|
2134
|
+
/**
|
|
2135
|
+
* Creates a script wrapper for an existing quest with this ID; use Quest.give() to write one.
|
|
2136
|
+
* @param id Network entity identifier.
|
|
2137
|
+
*/
|
|
2138
|
+
constructor(id: number);
|
|
2139
|
+
|
|
2140
|
+
/**
|
|
2141
|
+
* The key the quest is filed under, and the name the game knows the quest node by. Read-only: it is the quest's identity.
|
|
2142
|
+
*/
|
|
2143
|
+
readonly key: string;
|
|
2144
|
+
|
|
2145
|
+
/**
|
|
2146
|
+
* The line the journal row and the quest toast show. Assignment is silent; it does not raise a toast.
|
|
2147
|
+
*/
|
|
2148
|
+
title: string;
|
|
2149
|
+
|
|
2150
|
+
/**
|
|
2151
|
+
* The body of the journal's diary page for this quest. Assignment is silent.
|
|
2152
|
+
*/
|
|
2153
|
+
description: string;
|
|
2154
|
+
|
|
2155
|
+
/**
|
|
2156
|
+
* Which section of the journal the quest files under. Read-only: it is decided when the quest is given.
|
|
2157
|
+
*/
|
|
2158
|
+
readonly type: string;
|
|
2159
|
+
|
|
2160
|
+
/**
|
|
2161
|
+
* `active`, `done` or `failed`. Assignment announces the change; `setProgress` can do it quietly.
|
|
2162
|
+
*/
|
|
2163
|
+
progress: string;
|
|
2164
|
+
|
|
2165
|
+
/**
|
|
2166
|
+
* Network id of the one player this quest was written for, or 0 when it went to everyone in the world. Read-only: who a quest belongs to is decided when it is given.
|
|
2167
|
+
*/
|
|
2168
|
+
readonly player: number;
|
|
2169
|
+
|
|
2170
|
+
/**
|
|
2171
|
+
* How many objectives the quest carries, up to eight.
|
|
2172
|
+
*/
|
|
2173
|
+
readonly objectiveCount: number;
|
|
2174
|
+
|
|
2175
|
+
/**
|
|
2176
|
+
* Formats this quest handle for logging and debugging.
|
|
2177
|
+
* @returns The quest ID, its key, its state and how many objectives it carries.
|
|
2178
|
+
*/
|
|
2179
|
+
toString(): string;
|
|
2180
|
+
|
|
2181
|
+
/**
|
|
2182
|
+
* Takes this quest out of every journal it was written into.
|
|
2183
|
+
*/
|
|
2184
|
+
remove(): void;
|
|
2185
|
+
|
|
2186
|
+
/**
|
|
2187
|
+
* Moves the quest on. There is no way back to unstarted: a quest nobody should see any more is removed.
|
|
2188
|
+
* @param progress Where the quest now stands.
|
|
2189
|
+
* @param announce Whether to raise the game's quest-updated toast; defaults to true. Pass false for a correction the player should not be told about.
|
|
2190
|
+
*/
|
|
2191
|
+
setProgress(progress: 'active' | 'done' | 'failed', announce?: boolean): void;
|
|
2192
|
+
|
|
2193
|
+
/**
|
|
2194
|
+
* Rewrites one line of the quest in place.
|
|
2195
|
+
* @param index Which objective to rewrite, counting from zero. An index past the end is ignored.
|
|
2196
|
+
* @param objective The line, as text or as an object carrying its state.
|
|
2197
|
+
* @param announce Whether to raise the quest-updated toast; defaults to true.
|
|
2198
|
+
*/
|
|
2199
|
+
setObjective(index: number, objective: string | { text: string; progress?: 'active' | 'done' | 'failed'; optional?: boolean }, announce?: boolean): void;
|
|
2200
|
+
|
|
2201
|
+
/**
|
|
2202
|
+
* Replaces the quest's objective list.
|
|
2203
|
+
* @param objectives The whole list, at most eight entries; anything past that is dropped.
|
|
2204
|
+
* @param announce Whether to raise the quest-updated toast; defaults to true.
|
|
2205
|
+
*/
|
|
2206
|
+
setObjectives(objectives: (string | { text: string; progress?: 'active' | 'done' | 'failed'; optional?: boolean })[], announce?: boolean): void;
|
|
2207
|
+
|
|
2208
|
+
/**
|
|
2209
|
+
* Reads the quest's objectives back.
|
|
2210
|
+
* @returns One entry per objective, in journal order.
|
|
2211
|
+
*/
|
|
2212
|
+
objectives(): { text: string; progress: 'active' | 'done' | 'failed' | 'none'; optional: boolean }[];
|
|
2213
|
+
|
|
2214
|
+
/**
|
|
2215
|
+
* Writes a quest into the game's own journal. It is a replicated entity, so a player who joins late, reloads or walks away still finds it in their log -- which is what a quest needs and what a one-shot notification cannot do. What the player sees is the game's quest UI: its journal row, its diary page, its objective tracker and its quest-updated toast, all reading a quest node the client builds with the game's own constructor.
|
|
2216
|
+
* @param key What the quest is filed under: up to 64 letters, digits, underscores or dashes, unique within its virtual world.
|
|
2217
|
+
* @param title The line the journal row shows.
|
|
2218
|
+
* @param options `description` is the diary page, `type` the journal section, `objectives` the lines under it, `player` the network id of the one player it belongs to, and `announce` whether to raise the toast.
|
|
2219
|
+
* @param virtualWorld Optional virtual world the quest belongs to; omitted puts it in the global one.
|
|
2220
|
+
* @returns The newly written quest handle.
|
|
2221
|
+
*/
|
|
2222
|
+
static give(key: string, title: string, options?: { description?: string; type?: 'main' | 'side' | 'activity' | 'event' | 'micro' | 'racing'; objectives?: (string | { text: string; progress?: 'active' | 'done' | 'failed'; optional?: boolean })[]; player?: number; announce?: boolean }, virtualWorld?: number): Quest;
|
|
2223
|
+
|
|
2224
|
+
/**
|
|
2225
|
+
* Lists every replicated quest the server currently has.
|
|
2226
|
+
* @param virtualWorld Optional virtual world to list; omitted lists every one of them.
|
|
2227
|
+
* @returns One handle per live quest, in no particular order.
|
|
2228
|
+
*/
|
|
2229
|
+
static all(virtualWorld?: number): Quest[];
|
|
2230
|
+
|
|
2231
|
+
/**
|
|
2232
|
+
* Looks a quest up by its key.
|
|
2233
|
+
* @param key The key the quest was given under.
|
|
2234
|
+
* @param virtualWorld Optional virtual world to search; omitted searches every one of them.
|
|
2235
|
+
* @param player Network id of the player whose copy to find. Keys are unique per recipient, so this is how one player's errand is told from another's.
|
|
2236
|
+
* @returns The quest's handle, or null when no live quest has that key.
|
|
2237
|
+
*/
|
|
2238
|
+
static find(key: string, virtualWorld?: number, player?: number): Quest | null;
|
|
2239
|
+
|
|
2240
|
+
/**
|
|
2241
|
+
* Looks a replicated quest up by its network entity ID.
|
|
2242
|
+
* @param id Network entity identifier.
|
|
2243
|
+
* @returns The quest's handle, or null when no live quest has that ID.
|
|
2244
|
+
*/
|
|
2245
|
+
static getById(id: number): Quest | null;
|
|
2246
|
+
|
|
2247
|
+
/**
|
|
2248
|
+
* Takes quests out of every journal they were written into.
|
|
2249
|
+
* @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
|
|
2250
|
+
* @returns How many quests were removed.
|
|
2251
|
+
*/
|
|
2252
|
+
static removeAll(virtualWorld?: number): number;
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
interface Quest extends Entity {}
|
|
2256
|
+
|
|
2257
|
+
/**
|
|
2258
|
+
* Replicated world stack handle.
|
|
2259
|
+
*/
|
|
2260
|
+
class GroundItem {
|
|
2261
|
+
/**
|
|
2262
|
+
* Creates a script wrapper for an existing ground item with this ID; use GroundItem.spawn() to spawn one.
|
|
2263
|
+
* @param id Network entity identifier.
|
|
2264
|
+
*/
|
|
2265
|
+
constructor(id: number);
|
|
2266
|
+
|
|
2267
|
+
/**
|
|
2268
|
+
* The class of item lying here, as the same 32 hex digits `player.rightHandItem` and `player.equipment` use, so the three can be compared directly. The server holds no name for a class: naming one is an item database's job.
|
|
2269
|
+
*/
|
|
2270
|
+
readonly itemClass: string;
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* How many units are in the stack. One entity however many that is: a stack is picked up whole or not at all.
|
|
2274
|
+
*/
|
|
2275
|
+
readonly amount: number;
|
|
2276
|
+
|
|
2277
|
+
/**
|
|
2278
|
+
* Quality the stack was made with, or 0 when it was left to the class's own.
|
|
2279
|
+
*/
|
|
2280
|
+
readonly quality: number;
|
|
2281
|
+
|
|
2282
|
+
/**
|
|
2283
|
+
* Absolute item health from 0 to 1, or -1 when it was left to the class's own.
|
|
2284
|
+
*/
|
|
2285
|
+
readonly health: number;
|
|
2286
|
+
|
|
2287
|
+
/**
|
|
2288
|
+
* Displayed condition from 0 to 1, or -1 when it was left to the class's own.
|
|
2289
|
+
*/
|
|
2290
|
+
readonly condition: number;
|
|
2291
|
+
|
|
2292
|
+
/**
|
|
2293
|
+
* Whether the stack has settled where it will stay. A stack a script spawned is resting from the start; one a player threw down is false until that player's own physics stops it and publishes the final pose, and its position moves until then.
|
|
2294
|
+
*/
|
|
2295
|
+
readonly resting: boolean;
|
|
2296
|
+
|
|
2297
|
+
/**
|
|
2298
|
+
* Network ID of the player who dropped this stack, or 0 when the server spawned it.
|
|
2299
|
+
*/
|
|
2300
|
+
readonly droppedById: number;
|
|
2301
|
+
|
|
2302
|
+
/**
|
|
2303
|
+
* The player who dropped this stack, or null when the server spawned it or that player has since left.
|
|
2304
|
+
*/
|
|
2305
|
+
readonly droppedBy: Player | null;
|
|
2306
|
+
|
|
2307
|
+
/**
|
|
2308
|
+
* Formats this ground item handle for logging and debugging.
|
|
2309
|
+
* @returns The stack ID, its item class, how many of it there are and whether it has settled.
|
|
2310
|
+
*/
|
|
2311
|
+
toString(): string;
|
|
2312
|
+
|
|
2313
|
+
/**
|
|
2314
|
+
* Takes this stack back out of the world on every client after emitting groundItemDestroy.
|
|
2315
|
+
*/
|
|
2316
|
+
destroy(): void;
|
|
2317
|
+
|
|
2318
|
+
/**
|
|
2319
|
+
* Lays a pickable stack of an item on the ground and replicates it, spawning it already at rest.
|
|
2320
|
+
* @param item Item class to lay down, as either its GUID or its name (`arrow_crude`). The same spelling `player.giveItem` takes.
|
|
2321
|
+
* @param position Optional world-space spawn position; omitted components default to zero. The stack is placed there rather than dropped, so put it where the ground is.
|
|
2322
|
+
* @param rotation Optional resting orientation: a Quaternion, or a Vector3 of Euler angles in degrees.
|
|
2323
|
+
* @param amount Optional number of units in the stack, from 1 to 10000; omitted lays down one. A stack is picked up whole.
|
|
2324
|
+
* @param virtualWorld Optional virtual world the stack belongs to; omitted puts it in the global one.
|
|
2325
|
+
* @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.
|
|
2326
|
+
* @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.
|
|
2327
|
+
*/
|
|
2328
|
+
static spawn(item: string, position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, amount?: number, virtualWorld?: number, properties?: { quality?: number; health?: number; condition?: number }): GroundItem;
|
|
2329
|
+
|
|
2330
|
+
/**
|
|
2331
|
+
* Lists every stack lying in the world, however it got there.
|
|
2332
|
+
* @returns One handle per live stack, in no particular order.
|
|
2333
|
+
*/
|
|
2334
|
+
static all(): GroundItem[];
|
|
2335
|
+
|
|
2336
|
+
/**
|
|
2337
|
+
* Looks a stack up by its network entity ID.
|
|
2338
|
+
* @param id Network entity identifier.
|
|
2339
|
+
* @returns The stack's handle, or null when no live stack has that ID.
|
|
2340
|
+
*/
|
|
2341
|
+
static getById(id: number): GroundItem | null;
|
|
2342
|
+
|
|
2343
|
+
/**
|
|
2344
|
+
* Removes stacks from the world, emitting groundItemDestroy for each one.
|
|
2345
|
+
* @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
|
|
2346
|
+
* @returns How many stacks were removed.
|
|
2347
|
+
*/
|
|
2348
|
+
static destroyAll(virtualWorld?: number): number;
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
interface GroundItem extends Entity {}
|
|
2352
|
+
|
|
2353
|
+
/** */
|
|
2354
|
+
interface NearestDoor {
|
|
2355
|
+
/**
|
|
2356
|
+
* Whether the client had a door in sight and it belongs to this level.
|
|
2357
|
+
*/
|
|
2358
|
+
found: boolean;
|
|
2359
|
+
|
|
2360
|
+
/**
|
|
2361
|
+
* Why there is no door: nothing in sight, another level, no answer, or a caller who left. Empty when one was found.
|
|
2362
|
+
*/
|
|
2363
|
+
reason: string;
|
|
2364
|
+
|
|
2365
|
+
/**
|
|
2366
|
+
* The door handle. Null whenever `found` is false.
|
|
2367
|
+
*/
|
|
2368
|
+
door: Door | null;
|
|
2369
|
+
|
|
2370
|
+
/**
|
|
2371
|
+
* The door's level EntityGuid as hex, present only when one was found.
|
|
2372
|
+
*/
|
|
2373
|
+
guid: string | undefined;
|
|
2374
|
+
|
|
2375
|
+
/**
|
|
2376
|
+
* The name the level gives the door, often empty. Present only when one was found.
|
|
2377
|
+
*/
|
|
2378
|
+
name: string | undefined;
|
|
2379
|
+
|
|
2380
|
+
/**
|
|
2381
|
+
* How far the player is from it, in metres. Present only when one was found.
|
|
2382
|
+
*/
|
|
2383
|
+
distance: number | undefined;
|
|
2384
|
+
|
|
2385
|
+
/**
|
|
2386
|
+
* Whether it is standing open, as the client at it sees right now. Present only when one was found.
|
|
2387
|
+
*/
|
|
2388
|
+
open: boolean | undefined;
|
|
2389
|
+
|
|
2390
|
+
/**
|
|
2391
|
+
* Whether it is locked, as the client at it sees right now. Present only when one was found.
|
|
2392
|
+
*/
|
|
2393
|
+
locked: boolean | undefined;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
/**
|
|
2397
|
+
* Replicated handle for one of the level's own doors.
|
|
2398
|
+
*/
|
|
2399
|
+
class Door {
|
|
2400
|
+
/**
|
|
2401
|
+
* Creates a script wrapper for a door the server already knows; doors are the level's own and are never spawned.
|
|
2402
|
+
* @param id Network entity identifier.
|
|
2403
|
+
*/
|
|
2404
|
+
constructor(id: number);
|
|
2405
|
+
|
|
2406
|
+
/**
|
|
2407
|
+
* The level's own EntityGuid, as sixteen lowercase hex digits. The same on every machine, so it is the identity to store a door under; `Door.find` takes it back.
|
|
2408
|
+
*/
|
|
2409
|
+
readonly guid: string;
|
|
2410
|
+
|
|
2411
|
+
/**
|
|
2412
|
+
* Bumped on every durable change. Clients act on the edges rather than the value, so it only tells one change from the next.
|
|
2413
|
+
*/
|
|
2414
|
+
readonly stateToken: number;
|
|
2415
|
+
|
|
2416
|
+
/**
|
|
2417
|
+
* Whether the door is standing open. Change it with `setOpen`, which also says which way it swings.
|
|
2418
|
+
*/
|
|
2419
|
+
readonly open: boolean;
|
|
2420
|
+
|
|
2421
|
+
/**
|
|
2422
|
+
* Which side the leaf was last worked from, which decides the way it swings. A player arriving later poses the door from this, so everyone sees it swung the same way.
|
|
2423
|
+
*/
|
|
2424
|
+
readonly openedFromFront: boolean;
|
|
2425
|
+
|
|
2426
|
+
/**
|
|
2427
|
+
* Whether the door is locked. Assignment reaches every client that has the door streamed in, including one already standing at it. A door locked from here can only be opened again from here or with a lockpick: a player unlocking it by hand or with a key is refused.
|
|
2428
|
+
*/
|
|
2429
|
+
locked: boolean;
|
|
2430
|
+
|
|
2431
|
+
/**
|
|
2432
|
+
* Whether the lock was set by a script or an operator rather than by the level. It clears when the door is unlocked, by any route the server accepted.
|
|
2433
|
+
*/
|
|
2434
|
+
readonly lockedByServer: boolean;
|
|
2435
|
+
|
|
2436
|
+
/**
|
|
2437
|
+
* The entity name the level gives the door.
|
|
2438
|
+
*/
|
|
2439
|
+
readonly name: string;
|
|
2440
|
+
|
|
2441
|
+
/**
|
|
2442
|
+
* The item class GUID of the key the level assigns to the door's keyhole, as `player.giveItem` takes it. Empty when it takes none of its own -- most doors open to the generated home or shop key instead. The server does not see inventories, so this is for a resource that keeps its own.
|
|
2443
|
+
*/
|
|
2444
|
+
readonly keyItem: string;
|
|
2445
|
+
|
|
2446
|
+
/**
|
|
2447
|
+
* Whether the level lets this door be lockpicked. A lockpick reported on one that cannot be is refused.
|
|
2448
|
+
*/
|
|
2449
|
+
readonly lockpickable: boolean;
|
|
2450
|
+
|
|
2451
|
+
/**
|
|
2452
|
+
* Whether the level builds this door locked, which is the state it has at boot.
|
|
2453
|
+
*/
|
|
2454
|
+
readonly startsLocked: boolean;
|
|
2455
|
+
|
|
2456
|
+
/**
|
|
2457
|
+
* Formats this door handle for logging and debugging.
|
|
2458
|
+
* @returns The door ID, its level GUID and whether it is open and locked.
|
|
2459
|
+
*/
|
|
2460
|
+
toString(): string;
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* Opens or closes the door with nobody pushing it. Every client that has the door built plays the game's own swing; one arriving later finds it posed the same way. Opening a locked door unlocks it, as the game's own `Open` does.
|
|
2464
|
+
* @param open True to open the door, false to close it.
|
|
2465
|
+
* @param fromFront Which side the leaf is worked from, and so which way it swings. Omitted keeps the side it was last worked from.
|
|
2466
|
+
* @returns False when the door is already that way.
|
|
2467
|
+
*/
|
|
2468
|
+
setOpen(open: boolean, fromFront?: boolean): boolean;
|
|
2469
|
+
|
|
2470
|
+
/**
|
|
2471
|
+
* Lists every door the level places, all of which exist from boot in the global world. In another virtual world a door is built the first time anything there reaches it, so this lists only those.
|
|
2472
|
+
* @returns One handle per known door, in no particular order.
|
|
2473
|
+
*/
|
|
2474
|
+
static all(): Door[];
|
|
2475
|
+
|
|
2476
|
+
/**
|
|
2477
|
+
* Looks a door up by its network entity ID.
|
|
2478
|
+
* @param id Network entity identifier.
|
|
2479
|
+
* @returns The door's handle, or null when no live door has that ID.
|
|
2480
|
+
*/
|
|
2481
|
+
static getById(id: number): Door | null;
|
|
2482
|
+
|
|
2483
|
+
/**
|
|
2484
|
+
* Looks a door up by the level's own identity for it, which survives a restart and is the same on every machine. A door the level places is always found, in any virtual world.
|
|
2485
|
+
* @param guid The door's level EntityGuid as hex, with or without an `0x` prefix, as `door.guid` prints it.
|
|
2486
|
+
* @param virtualWorld Optional virtual world to look in; omitted looks in the global one, where every body starts.
|
|
2487
|
+
* @returns The door's handle, or null when the level places no such door.
|
|
2488
|
+
*/
|
|
2489
|
+
static find(guid: string, virtualWorld?: number): Door | null;
|
|
2490
|
+
|
|
2491
|
+
/**
|
|
2492
|
+
* Asks a player's client which door their body is standing at. The server knows every door the level places but has no world to measure distances in, so this is how a command finds the door in front of a player, and the answer is what that client sees now rather than what the replica last carried.
|
|
2493
|
+
*
|
|
2494
|
+
* The promise always settles: on the answer, on a five-second timeout, or when the player leaves, with `found` false and `reason` saying which.
|
|
2495
|
+
* @param player The player to ask. The question goes to their own client.
|
|
2496
|
+
* @returns The answer, once that client has given one.
|
|
2497
|
+
*/
|
|
2498
|
+
static queryNearest(player: Player): Promise<NearestDoor>;
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
interface Door extends Entity {}
|
|
2502
|
+
|
|
2503
|
+
/** */
|
|
2504
|
+
interface GateToggle {
|
|
2505
|
+
/**
|
|
2506
|
+
* Whether a cycle started.
|
|
2507
|
+
*/
|
|
2508
|
+
accepted: boolean;
|
|
2509
|
+
|
|
2510
|
+
/**
|
|
2511
|
+
* Why nothing moved, as a phrase that reads after the gate's name: `is already open`, `is already closing`. Empty when a cycle started.
|
|
2512
|
+
*/
|
|
2513
|
+
reason: string;
|
|
2514
|
+
|
|
2515
|
+
/**
|
|
2516
|
+
* The direction taken, or the one that was refused.
|
|
2517
|
+
*/
|
|
2518
|
+
opening: boolean;
|
|
2519
|
+
|
|
2520
|
+
/**
|
|
2521
|
+
* How long the motion still has to run. 0 when nothing moved.
|
|
2522
|
+
*/
|
|
2523
|
+
seconds: number;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
/**
|
|
2527
|
+
* Replicated handle for one of the level's animated gates.
|
|
2528
|
+
*/
|
|
2529
|
+
class Gate {
|
|
2530
|
+
/**
|
|
2531
|
+
* Creates a script wrapper for a gate the server already knows; gates are the level's own and are never spawned.
|
|
2532
|
+
* @param id Network entity identifier.
|
|
2533
|
+
*/
|
|
2534
|
+
constructor(id: number);
|
|
2535
|
+
|
|
2536
|
+
/**
|
|
2537
|
+
* 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.
|
|
2538
|
+
*/
|
|
2539
|
+
readonly guid: string;
|
|
2540
|
+
|
|
2541
|
+
/**
|
|
2542
|
+
* What piece of architecture this is: `drawbridge` or `portcullis`. The shipped game has two in total.
|
|
2543
|
+
*/
|
|
2544
|
+
readonly kind: string;
|
|
2545
|
+
|
|
2546
|
+
/**
|
|
2547
|
+
* Where the gate is in its cycle: `closed`, `opening`, `open` or `closing`. Open always means passable -- a portcullis raised, a drawbridge lowered. Named `cycle` because every entity already has a `state`, which is its state bag.
|
|
2548
|
+
*/
|
|
2549
|
+
readonly cycle: string;
|
|
2550
|
+
|
|
2551
|
+
/**
|
|
2552
|
+
* How far open the gate is, from 0 shut to 1 fully open, read off the pose curve mined from the asset's own animation at the point the server clock says the motion has reached. It follows the bars, not the clock: a portcullis reads 0 within the first fifth of its close, and holds there while the clip finishes.
|
|
2553
|
+
*/
|
|
2554
|
+
readonly openness: number;
|
|
2555
|
+
|
|
2556
|
+
/**
|
|
2557
|
+
* Whether a cycle is running. `toggle` reverses a moving gate from where it has got to rather than refusing it.
|
|
2558
|
+
*/
|
|
2559
|
+
readonly moving: boolean;
|
|
2560
|
+
|
|
2561
|
+
/**
|
|
2562
|
+
* 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.
|
|
2563
|
+
*/
|
|
2564
|
+
readonly openDuration: number;
|
|
2565
|
+
|
|
2566
|
+
/**
|
|
2567
|
+
* How long closing takes, in seconds, from the asset's animation database.
|
|
2568
|
+
*/
|
|
2569
|
+
readonly closeDuration: number;
|
|
2570
|
+
|
|
2571
|
+
/**
|
|
2572
|
+
* Formats this gate handle for logging and debugging.
|
|
2573
|
+
* @returns The gate ID, its level GUID, what kind it is and where it is in its cycle.
|
|
2574
|
+
*/
|
|
2575
|
+
toString(): string;
|
|
2576
|
+
|
|
2577
|
+
/**
|
|
2578
|
+
* Starts a cycle. The motion is never streamed: every client plays it out from the server clock it started on, and a gate reversed mid-cycle picks up where it is rather than snapping to the far end.
|
|
2579
|
+
* @param open true opens, false closes. Omitted heads away from whichever end the gate is at, reversing one already moving.
|
|
2580
|
+
* @returns What happened, and the phrase to explain it with when nothing did.
|
|
2581
|
+
*/
|
|
2582
|
+
toggle(open?: boolean): GateToggle;
|
|
2583
|
+
|
|
2584
|
+
/**
|
|
2585
|
+
* Lists every gate the level places, all of which exist from boot in the global world. In another virtual world a gate is built the first time anything there reaches it, so this lists only those.
|
|
2586
|
+
* @returns One handle per gate, in no particular order.
|
|
2587
|
+
*/
|
|
2588
|
+
static all(): Gate[];
|
|
2589
|
+
|
|
2590
|
+
/**
|
|
2591
|
+
* Looks a gate up by its network entity ID.
|
|
2592
|
+
* @param id Network entity identifier.
|
|
2593
|
+
* @returns The gate's handle, or null when no live gate has that ID.
|
|
2594
|
+
*/
|
|
2595
|
+
static getById(id: number): Gate | null;
|
|
2596
|
+
|
|
2597
|
+
/**
|
|
2598
|
+
* Looks a gate up by the level's own identity for it, which survives a restart and is the same on every machine. A gate the level places is always found, in any virtual world.
|
|
2599
|
+
* @param guid The gate's level EntityGuid as hex, with or without an `0x` prefix, as `gate.guid` prints it.
|
|
2600
|
+
* @param virtualWorld Optional virtual world to look in; omitted looks in the global one, where every body starts.
|
|
2601
|
+
* @returns The gate's handle, or null when the level places no such gate.
|
|
2602
|
+
*/
|
|
2603
|
+
static find(guid: string, virtualWorld?: number): Gate | null;
|
|
2604
|
+
|
|
2605
|
+
/**
|
|
2606
|
+
* Finds the gate nearest a point. Gate positions come from the level's own data, so unlike a door this needs no round trip to anybody's client.
|
|
2607
|
+
* @param position World-space point to measure from.
|
|
2608
|
+
* @param radius How far to look, in metres. Castle architecture is visible from a long way off, so this is tens of metres rather than a couple.
|
|
2609
|
+
* @param virtualWorld Optional virtual world to look in; omitted looks in the global one.
|
|
2610
|
+
* @returns The nearest gate within the radius, or null when there is none.
|
|
2611
|
+
*/
|
|
2612
|
+
static nearest(position: Vector3 | Partial<Vector3>, radius: number, virtualWorld?: number): Gate | null;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
interface Gate extends Entity {}
|
|
2616
|
+
|
|
2617
|
+
/**
|
|
2618
|
+
* Replicated container handle.
|
|
2619
|
+
*/
|
|
2620
|
+
class Stash {
|
|
2621
|
+
/**
|
|
2622
|
+
* Creates a script wrapper for an existing container with this ID; use Stash.spawn() to spawn one.
|
|
2623
|
+
* @param id Network entity identifier.
|
|
2624
|
+
*/
|
|
2625
|
+
constructor(id: number);
|
|
2626
|
+
|
|
2627
|
+
/**
|
|
2628
|
+
* The identity every client turns into the same native container. Minted by the server from 1, and not `id`, which is the replication entity's.
|
|
2629
|
+
*/
|
|
2630
|
+
readonly stashId: number;
|
|
2631
|
+
|
|
2632
|
+
/**
|
|
2633
|
+
* How many stacks the server is holding. Contents are not replicated -- they are pulled when a player opens the container and pushed back when they close it -- so this is the only view of what is in one.
|
|
2634
|
+
*/
|
|
2635
|
+
readonly itemCount: number;
|
|
2636
|
+
|
|
2637
|
+
/**
|
|
2638
|
+
* The network ID of the player who has it open, or 0. While it is held, the game's own lock keeps every other client out.
|
|
2639
|
+
*/
|
|
2640
|
+
readonly holderId: number;
|
|
2641
|
+
|
|
2642
|
+
/**
|
|
2643
|
+
* Formats this container handle for logging and debugging.
|
|
2644
|
+
* @returns The stash ID, its shared identity, how much is in it and who has it open.
|
|
2645
|
+
*/
|
|
2646
|
+
toString(): string;
|
|
2647
|
+
|
|
2648
|
+
/**
|
|
2649
|
+
* Despawns this container on every client and forgets what was in it. Anything inside goes with it.
|
|
2650
|
+
*/
|
|
2651
|
+
destroy(): void;
|
|
2652
|
+
|
|
2653
|
+
/**
|
|
2654
|
+
* Spawns and replicates an empty container. Empty by design: an item class is a 16-byte engine GUID only the game's own parser turns from text, and the server has no game to ask. Fill one by having a player put things in it.
|
|
2655
|
+
* @param position Optional world-space spawn position; omitted components default to zero.
|
|
2656
|
+
* @param rotation Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in degrees.
|
|
2657
|
+
* @param virtualWorld Optional virtual world the container belongs to; omitted puts it in the global one.
|
|
2658
|
+
* @returns The newly spawned container handle.
|
|
2659
|
+
*/
|
|
2660
|
+
static spawn(position?: Vector3 | Partial<Vector3>, rotation?: Vector3 | Quaternion, virtualWorld?: number): Stash;
|
|
2661
|
+
|
|
2662
|
+
/**
|
|
2663
|
+
* Lists every container the server currently has.
|
|
2664
|
+
* @returns One handle per live container, in no particular order.
|
|
2665
|
+
*/
|
|
2666
|
+
static all(): Stash[];
|
|
2667
|
+
|
|
2668
|
+
/**
|
|
2669
|
+
* Looks a container up by its network entity ID.
|
|
2670
|
+
* @param id Network entity identifier.
|
|
2671
|
+
* @returns The container's handle, or null when no live container has that ID.
|
|
2672
|
+
*/
|
|
2673
|
+
static getById(id: number): Stash | null;
|
|
2674
|
+
|
|
2675
|
+
/**
|
|
2676
|
+
* Despawns containers, and everything in them with them.
|
|
2677
|
+
* @param virtualWorld Optional virtual world to clear; omitted clears every one of them.
|
|
2678
|
+
* @returns How many containers were removed.
|
|
2679
|
+
*/
|
|
2680
|
+
static destroyAll(virtualWorld?: number): number;
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
interface Stash extends Entity {}
|
|
2684
|
+
|
|
2685
|
+
/**
|
|
2686
|
+
* The server's own clock and weather, which every client follows, and the three questions it can ask a client's engine about the level itself.
|
|
2687
|
+
*/
|
|
2688
|
+
const World: {
|
|
2689
|
+
/**
|
|
2690
|
+
* Whole days the clock has run, from the level's own midnight. Starts at 0 and only grows.
|
|
2691
|
+
*/
|
|
2692
|
+
readonly day: number;
|
|
2693
|
+
|
|
2694
|
+
/**
|
|
2695
|
+
* Hour within the current day, from 0 up to but not including 24, with the minutes as the fraction. 13.5 is half past one.
|
|
2696
|
+
*/
|
|
2697
|
+
readonly hour: number;
|
|
2698
|
+
|
|
2699
|
+
/**
|
|
2700
|
+
* How many game seconds pass per real second. 15 is the game's own pace, 0 stops the clock, and the server drops it to 0 by itself at the clock's ceiling.
|
|
2701
|
+
*/
|
|
2702
|
+
readonly timeScale: number;
|
|
2703
|
+
|
|
2704
|
+
/**
|
|
2705
|
+
* The time-of-day preset the sky is blending towards, which is where it settles. Set it with `setWeather`.
|
|
2706
|
+
*/
|
|
2707
|
+
readonly weather: string;
|
|
2708
|
+
|
|
2709
|
+
/**
|
|
2710
|
+
* The preset the sky is blending from; the same as `weather` once it has settled.
|
|
2711
|
+
*/
|
|
2712
|
+
readonly previousWeather: string;
|
|
2713
|
+
|
|
2714
|
+
/**
|
|
2715
|
+
* Whether a blend is still running. `setWeather` is refused while it is: a half-finished blend has no single preset to leave from.
|
|
2716
|
+
*/
|
|
2717
|
+
readonly weatherBlending: boolean;
|
|
2718
|
+
|
|
2719
|
+
/**
|
|
2720
|
+
* Game seconds left of the blend, and 0 once the sky has settled. `setWeather` is refused until then.
|
|
2721
|
+
*/
|
|
2722
|
+
readonly weatherRemaining: number;
|
|
2723
|
+
|
|
2724
|
+
/**
|
|
2725
|
+
* How hard it is raining, from 0 to 1.
|
|
2726
|
+
*/
|
|
2727
|
+
readonly rainIntensity: number;
|
|
2728
|
+
|
|
2729
|
+
/**
|
|
2730
|
+
* How much of the rain is drawn, from 0 to 1. Thins the downpour without stopping it.
|
|
2731
|
+
*/
|
|
2732
|
+
readonly rainAmount: number;
|
|
2733
|
+
|
|
2734
|
+
/**
|
|
2735
|
+
* The wind every client is blowing, in metres per second, world space. It bends the trees, drags the cloth and slants the rain, and it is the one part of the weather the game itself never touches. Set it with `setWind`.
|
|
2736
|
+
*/
|
|
2737
|
+
readonly wind: Vector3;
|
|
2738
|
+
|
|
2739
|
+
/**
|
|
2740
|
+
* How hard the wind is blowing, whichever way: the length of `wind`, from 0 to 50.
|
|
2741
|
+
*/
|
|
2742
|
+
readonly windSpeed: number;
|
|
2743
|
+
|
|
2744
|
+
/**
|
|
2745
|
+
* How wet the ground has become, from 0 to 3. Derived from how long it has been raining, so it is read-only, and it dries far slower than it soaks.
|
|
2746
|
+
*/
|
|
2747
|
+
readonly wetness: number;
|
|
2748
|
+
|
|
2749
|
+
/**
|
|
2750
|
+
* Puddle coverage, from 0 to 1. Derived like `wetness`, and only starts filling after the rain has run a while.
|
|
2751
|
+
*/
|
|
2752
|
+
readonly puddles: number;
|
|
2753
|
+
|
|
2754
|
+
/**
|
|
2755
|
+
* Winds the clock forward to an absolute day and hour, which is how a saved clock is restored.
|
|
2756
|
+
* @param day Absolute day to wind forward to, as the `day` property counts them. Must be whole.
|
|
2757
|
+
* @param hour Hour of that day, from 0 up to but not including 24.
|
|
2758
|
+
* @returns True when the clock moved; false when that moment is already past, or the day or hour is out of range.
|
|
2759
|
+
*/
|
|
2760
|
+
setTime(day: number, hour: number): boolean;
|
|
2761
|
+
|
|
2762
|
+
/**
|
|
2763
|
+
* Winds the clock forward to the next time it is this hour, rolling into tomorrow when it has passed today. The clock never runs backwards: clients cannot be wound back with it.
|
|
2764
|
+
* @param hour Hour to wind forward to, from 0 up to but not including 24.
|
|
2765
|
+
* @returns True when the clock moved; false when the hour is out of range.
|
|
2766
|
+
*/
|
|
2767
|
+
setHour(hour: number): boolean;
|
|
2768
|
+
|
|
2769
|
+
/**
|
|
2770
|
+
* Sets how fast the day passes for everyone.
|
|
2771
|
+
* @param scale Game seconds per real second, from 0 to 200. 0 freezes the clock where it stands.
|
|
2772
|
+
* @returns True when the scale was taken; false when it is out of range.
|
|
2773
|
+
*/
|
|
2774
|
+
setTimeScale(scale: number): boolean;
|
|
2775
|
+
|
|
2776
|
+
/**
|
|
2777
|
+
* Blends the sky to another of the game's time-of-day presets, and raises `worldWeatherChange`. Only a client can tell whether a preset exists, so a name the game does not know leaves every sky where it is.
|
|
2778
|
+
* @param preset Name of one of the game's own time-of-day presets, such as `cloudless_sunny`.
|
|
2779
|
+
* @param seconds Game seconds to blend over, up to 21600. Omitted, the sky changes at once.
|
|
2780
|
+
* @returns True when the blend started; false while an earlier one is still running, or when the name or duration is out of range.
|
|
2781
|
+
*/
|
|
2782
|
+
setWeather(preset: string, seconds?: number): boolean;
|
|
2783
|
+
|
|
2784
|
+
/**
|
|
2785
|
+
* Sets the rain, which is separate from the sky preset: a preset can be overcast without a drop falling. Starting or stopping it restarts the phase the ground soaks and dries over.
|
|
2786
|
+
* @param intensity How hard it rains, from 0 to 1. 0 stops it.
|
|
2787
|
+
* @param amount How much of the rain is drawn, from 0 to 1; defaults to all of it.
|
|
2788
|
+
* @returns True when the rain was taken; false when either value is out of range.
|
|
2789
|
+
*/
|
|
2790
|
+
setRain(intensity: number, amount?: number): boolean;
|
|
2791
|
+
|
|
2792
|
+
/**
|
|
2793
|
+
* Sets the wind for everyone. There is nothing to blend against -- the engine takes a vector and holds it -- so a gust is a script ramping this itself. It also drives a physical wind area, which is why the length is capped.
|
|
2794
|
+
* @param wind Wind velocity in metres per second, world space; omitted components are zero. Its length may not exceed 50.
|
|
2795
|
+
* @returns True when the wind was taken; false when a component is not finite or it blows harder than 50 m/s.
|
|
2796
|
+
*/
|
|
2797
|
+
setWind(wind: Vector3 | Partial<Vector3>): boolean;
|
|
2798
|
+
|
|
2799
|
+
/**
|
|
2800
|
+
* Traces a segment through the world and reports the first thing it meets.
|
|
2801
|
+
*
|
|
2802
|
+
* The server has no world of its own, so this asks that player's client and waits for it to answer. Three things follow: the answer is a round trip late; it covers only what that machine has streamed in, so a point far from the player reads as empty world; and it is a client's word, which is fine for a prompt and is not fine for anything a player gains by lying about. The promise always settles -- on the answer, on a five-second timeout, or when the player leaves -- and `answered` says which.
|
|
2803
|
+
* @param player Whose client is asked. Their machine is the one that answers, so pick a player near the point in question.
|
|
2804
|
+
* @param from Where the ray starts, in world-space metres.
|
|
2805
|
+
* @param to Where it ends. Up to 4096 metres away; a ray of no length is refused.
|
|
2806
|
+
* @param options `mode` picks which of the game's own three traces to run: `cover` asks whether the world is in the way -- static geometry, props and doors block, and bodies cannot, which is what a line of sight wants; `anything` asks what is under the ray, bodies included, which is what a pick wants; `ground` sees only surfaces a player could stand on. It defaults to `cover`, and a name that is none of the three is rejected rather than guessed at.
|
|
2807
|
+
* @returns The trace, once that client has run it.
|
|
2808
|
+
*/
|
|
2809
|
+
raycast(player: Player, from: Vector3, to: Vector3, options?: { mode?: "cover" | "anything" | "ground" }): Promise<WorldTraceResult>;
|
|
2810
|
+
|
|
2811
|
+
/**
|
|
2812
|
+
* Traces a segment and reports everything solid along it, nearest first.
|
|
2813
|
+
*
|
|
2814
|
+
* The server has no world of its own, so this asks that player's client and waits for it to answer. Three things follow: the answer is a round trip late; it covers only what that machine has streamed in, so a point far from the player reads as empty world; and it is a client's word, which is fine for a prompt and is not fine for anything a player gains by lying about. The promise always settles -- on the answer, on a five-second timeout, or when the player leaves -- and `answered` says which.
|
|
2815
|
+
* @param player Whose client is asked. Their machine is the one that answers, so pick a player near the point in question.
|
|
2816
|
+
* @param from Where the ray starts, in world-space metres.
|
|
2817
|
+
* @param to Where it ends. Up to 4096 metres away; a ray of no length is refused.
|
|
2818
|
+
* @param options `mode` is as `World.raycast` documents it. `maxHits` is how many things along the ray to report, up to 8 and 8 by default; each is a separate solid hit, found by re-tracing past the one before, so a window does not hide the wall it is set in.
|
|
2819
|
+
* @returns The trace, once that client has run it.
|
|
2820
|
+
*/
|
|
2821
|
+
raycastAll(player: Player, from: Vector3, to: Vector3, options?: { mode?: "cover" | "anything" | "ground"; maxHits?: number }): Promise<WorldTraceResult>;
|
|
2822
|
+
|
|
2823
|
+
/**
|
|
2824
|
+
* What is underfoot at a point: its height in `hit.position.z`, the slope it landed on, and what the surface is made of.
|
|
2825
|
+
*
|
|
2826
|
+
* A trace rather than a terrain height, so it stands on whatever is actually there -- a bridge, a floor, a castle roof -- and not on the heightmap underneath it. There is no bare-number form here, because a promise has to be able to say that nothing answered.
|
|
2827
|
+
*
|
|
2828
|
+
* The server has no world of its own, so this asks that player's client and waits for it to answer. Three things follow: the answer is a round trip late; it covers only what that machine has streamed in, so a point far from the player reads as empty world; and it is a client's word, which is fine for a prompt and is not fine for anything a player gains by lying about. The promise always settles -- on the answer, on a five-second timeout, or when the player leaves -- and `answered` says which.
|
|
2829
|
+
* @param player Whose client is asked. Their machine is the one that answers, so pick a player near the point in question.
|
|
2830
|
+
* @param position The point to look under, in world-space metres. Its own z is where the probe is centred.
|
|
2831
|
+
* @param options How far above the point the probe starts and how far below it reaches, in metres. 5 and 200 by default -- the 5 above is what lets a point already slightly underground still resolve -- and up to 512 each.
|
|
2832
|
+
* @returns The probe, once that client has run it.
|
|
2833
|
+
*/
|
|
2834
|
+
resolveGround(player: Player, position: Vector3, options?: { up?: number; down?: number }): Promise<WorldTraceResult>;
|
|
2835
|
+
|
|
2836
|
+
/**
|
|
2837
|
+
* The server's own replicated entities near a point, nearest first -- players, horses, dogs, props, dropped items, doors, gates and stashes, each as its own handle.
|
|
2838
|
+
*
|
|
2839
|
+
* This needs no client: the server already knows where its replicas are, so unlike `entitiesInRadius` it is immediate and authoritative. It sees only what the server replicates, which is the other half -- the level's own entities are what `entitiesInRadius` is for.
|
|
2840
|
+
* @param position World-space point to measure from.
|
|
2841
|
+
* @param radius How far to look, in metres.
|
|
2842
|
+
* @param virtualWorld Optional virtual world to look in; omitted looks in the global one, where every body starts.
|
|
2843
|
+
* @returns The handles, nearest first.
|
|
2844
|
+
*/
|
|
2845
|
+
replicasInRadius(position: Vector3, radius: number, virtualWorld?: number): Entity[];
|
|
2846
|
+
|
|
2847
|
+
/**
|
|
2848
|
+
* Every entity that client's engine has inside a sphere, nearest first.
|
|
2849
|
+
*
|
|
2850
|
+
* It reads the engine's own spatial grid, so it costs what the sphere covers rather than what the level holds. This reports the level's entities -- doors, props, bodies -- and not the server's replicas; correlate them by `guid`.
|
|
2851
|
+
*
|
|
2852
|
+
* The server has no world of its own, so this asks that player's client and waits for it to answer. Three things follow: the answer is a round trip late; it covers only what that machine has streamed in, so a point far from the player reads as empty world; and it is a client's word, which is fine for a prompt and is not fine for anything a player gains by lying about. The promise always settles -- on the answer, on a five-second timeout, or when the player leaves -- and `answered` says which.
|
|
2853
|
+
* @param player Whose client is asked. Their machine is the one that answers, so pick a player near the point in question.
|
|
2854
|
+
* @param centre The centre of the sphere, in world-space metres.
|
|
2855
|
+
* @param radius Its radius in metres, up to 256.
|
|
2856
|
+
* @param options `class` reports only entities of that engine class -- `AnimDoor`, `NPC_NAI`, `GeomEntity` -- and a class the engine does not know matches nothing rather than everything; omitted, every class is reported. `max` is how many to report, nearest first, up to 64. `physicalOnly` skips entities the engine has built no physics for, which is the filter the game's own proximity query applies, and is off by default.
|
|
2857
|
+
* @returns The entities, once that client has looked.
|
|
2858
|
+
*/
|
|
2859
|
+
entitiesInRadius(player: Player, centre: Vector3, radius: number, options?: { class?: string; max?: number; physicalOnly?: boolean }): Promise<WorldRadiusResult>;
|
|
2860
|
+
};
|
|
2861
|
+
|
|
2862
|
+
/**
|
|
2863
|
+
* One thing a trace met, as the machine that traced it saw it.
|
|
2864
|
+
*/
|
|
2865
|
+
interface WorldRayHit {
|
|
2866
|
+
/**
|
|
2867
|
+
* Where the ray met it, in world-space metres.
|
|
2868
|
+
*/
|
|
2869
|
+
position: Vector3;
|
|
2870
|
+
|
|
2871
|
+
/**
|
|
2872
|
+
* The surface normal at that point, as a unit vector.
|
|
2873
|
+
*/
|
|
2874
|
+
normal: Vector3;
|
|
2875
|
+
|
|
2876
|
+
/**
|
|
2877
|
+
* How far along the ray it sits, in metres.
|
|
2878
|
+
*/
|
|
2879
|
+
distance: number;
|
|
2880
|
+
|
|
2881
|
+
/**
|
|
2882
|
+
* 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.
|
|
2883
|
+
*/
|
|
2884
|
+
surface: string;
|
|
2885
|
+
|
|
2886
|
+
/**
|
|
2887
|
+
* Whether the ground itself was hit rather than anything placed on it. Nothing lies behind the terrain, so a trace stops there.
|
|
2888
|
+
*/
|
|
2889
|
+
terrain: boolean;
|
|
2890
|
+
|
|
2891
|
+
/**
|
|
2892
|
+
* 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.
|
|
2893
|
+
*/
|
|
2894
|
+
entityGuid: string | null;
|
|
2895
|
+
|
|
2896
|
+
/**
|
|
2897
|
+
* The name the level gives it, often empty. Null when nothing that carries a name was hit.
|
|
2898
|
+
*/
|
|
2899
|
+
entityName: string | null;
|
|
2900
|
+
|
|
2901
|
+
/**
|
|
2902
|
+
* The engine class it belongs to -- `AnimDoor`, `NPC_NAI`, `GeomEntity`. Null when nothing that carries a class was hit.
|
|
2903
|
+
*/
|
|
2904
|
+
entityClass: string | null;
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
/**
|
|
2908
|
+
* One entity a sphere reported, and where it stood when it did.
|
|
2909
|
+
*/
|
|
2910
|
+
interface WorldNearbyEntity {
|
|
2911
|
+
/**
|
|
2912
|
+
* Where it is, in world-space metres.
|
|
2913
|
+
*/
|
|
2914
|
+
position: Vector3;
|
|
2915
|
+
|
|
2916
|
+
/**
|
|
2917
|
+
* How far it is from the centre of the sphere, in metres.
|
|
2918
|
+
*/
|
|
2919
|
+
distance: number;
|
|
2920
|
+
|
|
2921
|
+
/**
|
|
2922
|
+
* The level's own identity for it, as sixteen lowercase hex digits. Null for anything the session spawned, which the level does not name.
|
|
2923
|
+
*/
|
|
2924
|
+
guid: string | null;
|
|
2925
|
+
|
|
2926
|
+
/**
|
|
2927
|
+
* The name the level gives it, often empty.
|
|
2928
|
+
*/
|
|
2929
|
+
name: string;
|
|
2930
|
+
|
|
2931
|
+
/**
|
|
2932
|
+
* The engine class it belongs to -- `AnimDoor`, `NPC_NAI`, `GeomEntity`.
|
|
2933
|
+
*/
|
|
2934
|
+
class: string;
|
|
2935
|
+
|
|
2936
|
+
/**
|
|
2937
|
+
* Whether the engine has built physics for it, which is what makes it something a trace could also find.
|
|
2938
|
+
*/
|
|
2939
|
+
physicalized: boolean;
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2942
|
+
/**
|
|
2943
|
+
* What a trace came back with, and whether it came back at all.
|
|
2944
|
+
*/
|
|
2945
|
+
interface WorldTraceResult {
|
|
2946
|
+
/**
|
|
2947
|
+
* Whether the client ran the trace. False when it has no world loaded, is in another level, did not answer in time, or left.
|
|
2948
|
+
*/
|
|
2949
|
+
answered: boolean;
|
|
2950
|
+
|
|
2951
|
+
/**
|
|
2952
|
+
* Why it did not answer. Empty when it did.
|
|
2953
|
+
*/
|
|
2954
|
+
reason: string;
|
|
2955
|
+
|
|
2956
|
+
/**
|
|
2957
|
+
* The nearest thing the ray met, or null when it met nothing and whenever `answered` is false.
|
|
2958
|
+
*/
|
|
2959
|
+
hit: WorldRayHit | null;
|
|
2960
|
+
|
|
2961
|
+
/**
|
|
2962
|
+
* Everything it met, nearest first. One entry at most unless `maxHits` asked for more; empty whenever `answered` is false.
|
|
2963
|
+
*/
|
|
2964
|
+
hits: WorldRayHit[];
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
/**
|
|
2968
|
+
* What a sphere came back with, and whether it came back at all.
|
|
2969
|
+
*/
|
|
2970
|
+
interface WorldRadiusResult {
|
|
2971
|
+
/**
|
|
2972
|
+
* Whether the client ran the query. False when it has no world loaded, is in another level, did not answer in time, or left.
|
|
2973
|
+
*/
|
|
2974
|
+
answered: boolean;
|
|
2975
|
+
|
|
2976
|
+
/**
|
|
2977
|
+
* Why it did not answer. Empty when it did.
|
|
2978
|
+
*/
|
|
2979
|
+
reason: string;
|
|
2980
|
+
|
|
2981
|
+
/**
|
|
2982
|
+
* The entities inside the sphere, nearest first. Empty whenever `answered` is false.
|
|
2983
|
+
*/
|
|
2984
|
+
entities: WorldNearbyEntity[];
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
/**
|
|
2988
|
+
* What the game's own tables say about one status effect.
|
|
2989
|
+
*/
|
|
2990
|
+
interface BuffInfo {
|
|
2991
|
+
/**
|
|
2992
|
+
* The name the game's own buff tables give the effect, and the spelling every buff verb takes.
|
|
2993
|
+
*/
|
|
2994
|
+
name: string;
|
|
2995
|
+
|
|
2996
|
+
/**
|
|
2997
|
+
* The kind of effect it is -- `poison`, `alcohol`, `injury`, `potion`. `Buffs.classes` lists the ones a server can take over.
|
|
2998
|
+
*/
|
|
2999
|
+
class: string;
|
|
3000
|
+
|
|
3001
|
+
/**
|
|
3002
|
+
* The family `player.clearBuffs` would take it off with, or null for the majority that belong to none.
|
|
3003
|
+
*/
|
|
3004
|
+
aiTag: string | null;
|
|
3005
|
+
|
|
3006
|
+
/**
|
|
3007
|
+
* How long the effect runs from start to finish, in real seconds, and negative for one with no end.
|
|
3008
|
+
*/
|
|
3009
|
+
duration: number;
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
/**
|
|
3013
|
+
* One status effect currently on a body: everything `BuffInfo` says about it, plus how long it has been there and who put it there.
|
|
3014
|
+
*/
|
|
3015
|
+
interface BuffState {
|
|
3016
|
+
/**
|
|
3017
|
+
* The name the game's own buff tables give the effect, and the spelling every buff verb takes.
|
|
3018
|
+
*/
|
|
3019
|
+
name: string;
|
|
3020
|
+
|
|
3021
|
+
/**
|
|
3022
|
+
* The kind of effect it is -- `poison`, `alcohol`, `injury`, `potion`. `Buffs.classes` lists the ones a server can take over.
|
|
3023
|
+
*/
|
|
3024
|
+
class: string;
|
|
3025
|
+
|
|
3026
|
+
/**
|
|
3027
|
+
* The family `player.clearBuffs` would take it off with, or null for the majority that belong to none.
|
|
3028
|
+
*/
|
|
3029
|
+
aiTag: string | null;
|
|
3030
|
+
|
|
3031
|
+
/**
|
|
3032
|
+
* How long the effect runs from start to finish, in real seconds, and negative for one with no end.
|
|
3033
|
+
*/
|
|
3034
|
+
duration: number;
|
|
3035
|
+
|
|
3036
|
+
/**
|
|
3037
|
+
* How long it has been on the body, in real seconds. `duration - since` is roughly what is left, and roughly is the best anyone can do: the game advances buff time from each client's own frame delta. 0 for an effect that was already there when the player connected.
|
|
3038
|
+
*/
|
|
3039
|
+
since: number;
|
|
3040
|
+
|
|
3041
|
+
/**
|
|
3042
|
+
* Whether this server put it there, or the game did -- a potion they drank, an injury they took.
|
|
3043
|
+
*/
|
|
3044
|
+
source: "server" | "native";
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
/**
|
|
3048
|
+
* The game's status-effect table, and which of it this server decides.
|
|
3049
|
+
*/
|
|
3050
|
+
const Buffs: {
|
|
3051
|
+
/**
|
|
3052
|
+
* The kinds of effect a server can take over, which is what `claim` accepts: the ones carrying state nobody can work out for themselves -- potions, poison, injury, drunkenness, illness, unconsciousness. The game has other kinds, and they read back in `BuffInfo.class`, but they either shadow something that already replicates or are the game's own plumbing, so there is no decision in them to take.
|
|
3053
|
+
*/
|
|
3054
|
+
readonly classes: string[];
|
|
3055
|
+
|
|
3056
|
+
/**
|
|
3057
|
+
* The families the game groups effects into, which is what `player.clearBuffs` takes: `poison`, `bleed`, `alcohol_drunk`, `unconscious` and nineteen more. These are the game's own words, and its own AI reasons in them.
|
|
3058
|
+
*/
|
|
3059
|
+
readonly tags: string[];
|
|
3060
|
+
|
|
3061
|
+
/**
|
|
3062
|
+
* Looks a status effect up, so a resource can check a name is real before handing it to a player and can see what the effect is before applying it.
|
|
3063
|
+
* @param query An effect's name, as the game's buff tables spell it, or its GUID.
|
|
3064
|
+
* @returns What the tables say about it, or null for a name they do not carry.
|
|
3065
|
+
*/
|
|
3066
|
+
find(query: string): BuffInfo | null;
|
|
3067
|
+
|
|
3068
|
+
/**
|
|
3069
|
+
* Takes over whole kinds of effect. Every client then turns down an effect of that kind the game tried to give its own player, and raises `playerBuffBlocked` instead -- which is where the resource decides what really happens, usually `player.addBuff` with its own rule applied. A claim nothing listens to does not move the gameplay here, it removes it.
|
|
3070
|
+
*
|
|
3071
|
+
* Two things to plan around. The refusal covers the game's follow-on effects too: claim `alcohol` and the six `alcoholism_level*` steps stop arriving along with the drink, so the resource owns the whole progression. And an effect has no strength -- the handler can block it, swap it for another, or let it through, but it cannot make the drink half as strong.
|
|
3072
|
+
*
|
|
3073
|
+
* Replaces the previous claim rather than adding to it, and reaches every connected client at once.
|
|
3074
|
+
* @param classNames The kinds of effect to decide, from `Buffs.classes`. `[]` hands them all back. Throws for anything else.
|
|
3075
|
+
* @returns The kinds now claimed.
|
|
3076
|
+
*/
|
|
3077
|
+
claim(classNames: string[]): string[];
|
|
3078
|
+
};
|
|
3079
|
+
|
|
3080
|
+
/**
|
|
3081
|
+
* The game's own character-component catalog: every face, hairstyle, beard and skin a player's body can be given.
|
|
3082
|
+
*
|
|
3083
|
+
* Everyone on a fresh server is Henry, because a body with nothing chosen is the one the game hands out. This is where the alternatives come from; `player.setAppearance` is what puts one on somebody.
|
|
3084
|
+
*/
|
|
3085
|
+
const Appearances: {
|
|
3086
|
+
/**
|
|
3087
|
+
* Every option the game ships for one part. The male tree has 212 faces, 262 hairstyles, 51 beards and 47 skins; the female tree has 61, 71, none and 41.
|
|
3088
|
+
*
|
|
3089
|
+
* The hairstyle count is large because the game ships each style once per colour rather than colouring one. Group by `option.group` to get the styles back.
|
|
3090
|
+
*
|
|
3091
|
+
* The 51 beards are the whole catalog, not what any one body can wear: a beard is modelled per face and only exists for the faces it was modelled for. `Appearances.beards` is the list to show somebody.
|
|
3092
|
+
* @param part Which part to list.
|
|
3093
|
+
* @param gender Which half of the catalog to read; male by default.
|
|
3094
|
+
* @returns The options, in the catalog's own order.
|
|
3095
|
+
*/
|
|
3096
|
+
options(part: "body" | "head" | "hair" | "beard", gender?: "male" | "female"): AppearanceOption[];
|
|
3097
|
+
|
|
3098
|
+
/**
|
|
3099
|
+
* The beards that face can actually grow.
|
|
3100
|
+
*
|
|
3101
|
+
* A beard is modelled against one head's mesh and stored under that head's own folder, so asking for one the artists never made for the face wearing it does nothing at all -- no error, no beard, a body that comes back clean-shaven. The owning client refuses such a pair outright, so filter a chooser through this rather than through `options("beard")`.
|
|
3102
|
+
*
|
|
3103
|
+
* The 164 generic faces carry 24 each, Henry's face carries the 15 the game's own barber offers, and 14 faces carry none.
|
|
3104
|
+
* @param head The face to ask about -- a name from `Appearances.options("head")`. Omitted or empty means the face a body nobody has chosen one for wears.
|
|
3105
|
+
* @param gender Which half of the catalog the head came from; male by default.
|
|
3106
|
+
* @returns The wearable beards, in the catalog's own order. Empty for a female body, for a face with none, and for a name the catalog does not carry.
|
|
3107
|
+
*/
|
|
3108
|
+
beards(head?: string, gender?: "male" | "female"): AppearanceOption[];
|
|
3109
|
+
|
|
3110
|
+
/**
|
|
3111
|
+
* Looks one component name up, so a resource can check a name is real before handing it to a player.
|
|
3112
|
+
* @param part Which part the name is for.
|
|
3113
|
+
* @param name The component name to look up.
|
|
3114
|
+
* @param gender Which half of the catalog to look in; male by default.
|
|
3115
|
+
* @returns What the catalog says about it, or null for a name it does not carry.
|
|
3116
|
+
*/
|
|
3117
|
+
find(part: "body" | "head" | "hair" | "beard", name: string, gender?: "male" | "female"): AppearanceOption | null;
|
|
3118
|
+
|
|
3119
|
+
/**
|
|
3120
|
+
* Picks one option for every part, which is the cheapest way to stop a server full of Henrys. Hand the result straight to `player.setAppearance`.
|
|
3121
|
+
*
|
|
3122
|
+
* Uniform over the catalog rather than over what looks good together: the game's own faces and hairstyles are authored for particular NPCs, so a random body is recognisably random. The beard is drawn after the face and only from what that face can wear, so the result is always one a client will accept.
|
|
3123
|
+
* @param gender Which half of the catalog to draw from; male by default.
|
|
3124
|
+
* @returns A complete appearance. `beard` is empty for a female one, which the catalog has none of, and for the fourteen male faces no beard was modelled for.
|
|
3125
|
+
*/
|
|
3126
|
+
random(gender?: "male" | "female"): Appearance;
|
|
3127
|
+
};
|
|
3128
|
+
|
|
3129
|
+
/**
|
|
3130
|
+
* One animation the game plays on a human body: a Mannequin fragment and the tags that pick its variant, as a row of the game's own `actor_anim_action` table.
|
|
3131
|
+
*/
|
|
3132
|
+
interface AnimationInfo {
|
|
3133
|
+
/**
|
|
3134
|
+
* The fragment's name, which is what `playAnimation` takes.
|
|
3135
|
+
*/
|
|
3136
|
+
fragment: string;
|
|
3137
|
+
|
|
3138
|
+
/**
|
|
3139
|
+
* The tags that select this variant, `+`-separated, which is what `playAnimation`'s `tags` option takes. Empty for the fragment's default.
|
|
3140
|
+
*/
|
|
3141
|
+
tags: string;
|
|
3142
|
+
|
|
3143
|
+
/**
|
|
3144
|
+
* How long one pass lasts, in seconds.
|
|
3145
|
+
*/
|
|
3146
|
+
duration: number;
|
|
3147
|
+
|
|
3148
|
+
/**
|
|
3149
|
+
* Whether it ends by itself. One that does not is a loop and plays until something replaces it, `loop` or not.
|
|
3150
|
+
*/
|
|
3151
|
+
oneShot: boolean;
|
|
3152
|
+
|
|
3153
|
+
/**
|
|
3154
|
+
* Whether it takes the whole body. A full-body animation stops the legs, so a player playing one is held still unless `lockMovement` says otherwise.
|
|
3155
|
+
*/
|
|
3156
|
+
fullBody: boolean;
|
|
3157
|
+
|
|
3158
|
+
/**
|
|
3159
|
+
* What the right hand is animated holding, as the game names the kind (`bucket`, `axe_tool`), or empty for nothing. Match it against `AnimationPropInfo.hand` to find a prop that fits.
|
|
3160
|
+
*/
|
|
3161
|
+
rightHand: string;
|
|
3162
|
+
|
|
3163
|
+
/**
|
|
3164
|
+
* The same for the left hand.
|
|
3165
|
+
*/
|
|
3166
|
+
leftHand: string;
|
|
3167
|
+
|
|
3168
|
+
/**
|
|
3169
|
+
* Whether the game has it for a man's body.
|
|
3170
|
+
*/
|
|
3171
|
+
male: boolean;
|
|
3172
|
+
|
|
3173
|
+
/**
|
|
3174
|
+
* Whether the game has it for a woman's body.
|
|
3175
|
+
*/
|
|
3176
|
+
female: boolean;
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
/**
|
|
3180
|
+
* A model the game puts in a body's hand: one of its tools, from the item tables.
|
|
3181
|
+
*/
|
|
3182
|
+
interface AnimationPropInfo {
|
|
3183
|
+
/**
|
|
3184
|
+
* The item's name, which is what a prop's `item` takes.
|
|
3185
|
+
*/
|
|
3186
|
+
name: string;
|
|
3187
|
+
|
|
3188
|
+
/**
|
|
3189
|
+
* The model it is drawn with.
|
|
3190
|
+
*/
|
|
3191
|
+
model: string;
|
|
3192
|
+
|
|
3193
|
+
/**
|
|
3194
|
+
* The kind of thing it is (`bucket`, `axe_tool`), which is what `AnimationInfo.rightHand` and `leftHand` name.
|
|
3195
|
+
*/
|
|
3196
|
+
hand: string;
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
/**
|
|
3200
|
+
* Every animation the game plays on a human body, and the props it gives one to hold. `player.playAnimation` and `npc.playAnimation` play them.
|
|
3201
|
+
*/
|
|
3202
|
+
const Animations: {
|
|
3203
|
+
/**
|
|
3204
|
+
* Lists the animations the game plays on people -- over six thousand, from waves and bows to chopping wood, drinking and every tavern pose. These are the game's own combinations, so each one is known to play; `playAnimation` also takes fragments and tags this does not list, and plays whatever the body's animation database makes of them.
|
|
3205
|
+
* @param search Only rows whose fragment or tags contain this, ignoring case. Everything when left out.
|
|
3206
|
+
* @returns One row per fragment and tag combination, sorted by fragment.
|
|
3207
|
+
*/
|
|
3208
|
+
list(search?: string): AnimationInfo[];
|
|
3209
|
+
|
|
3210
|
+
/**
|
|
3211
|
+
* Lists the tools and carried objects the game puts in people's hands, by item name. Pick one whose `hand` matches the animation's `rightHand` or `leftHand` and it sits in the hand the way the animation was made for.
|
|
3212
|
+
* @returns Every prop, sorted by name.
|
|
3213
|
+
*/
|
|
3214
|
+
props(): AnimationPropInfo[];
|
|
3215
|
+
};
|
|
3216
|
+
|
|
3217
|
+
/**
|
|
3218
|
+
* Node.js timer handle returned by setTimeout and setInterval.
|
|
3219
|
+
*/
|
|
3220
|
+
interface Timeout {
|
|
3221
|
+
/**
|
|
3222
|
+
* Keeps the event loop alive while this timer is pending.
|
|
3223
|
+
* @returns This timer.
|
|
3224
|
+
*/
|
|
3225
|
+
ref(): Timeout;
|
|
3226
|
+
|
|
3227
|
+
/**
|
|
3228
|
+
* Lets the event loop exit while this timer is still pending.
|
|
3229
|
+
* @returns This timer.
|
|
3230
|
+
*/
|
|
3231
|
+
unref(): Timeout;
|
|
3232
|
+
|
|
3233
|
+
/**
|
|
3234
|
+
* Whether this timer keeps the event loop alive.
|
|
3235
|
+
*/
|
|
3236
|
+
hasRef(): boolean;
|
|
3237
|
+
|
|
3238
|
+
/**
|
|
3239
|
+
* Restarts this timer's countdown from now, with its original delay.
|
|
3240
|
+
* @returns This timer.
|
|
3241
|
+
*/
|
|
3242
|
+
refresh(): Timeout;
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
/**
|
|
3246
|
+
* Mutable two-dimensional vector.
|
|
3247
|
+
*/
|
|
3248
|
+
class Vector2 {
|
|
3249
|
+
/**
|
|
3250
|
+
* Creates a vector from two numeric components.
|
|
3251
|
+
* @param x Initial X component.
|
|
3252
|
+
* @param y Initial Y component.
|
|
3253
|
+
*/
|
|
3254
|
+
constructor(x: number, y: number);
|
|
3255
|
+
|
|
3256
|
+
/**
|
|
3257
|
+
* Mutable X component.
|
|
3258
|
+
*/
|
|
3259
|
+
x: number;
|
|
3260
|
+
|
|
3261
|
+
/**
|
|
3262
|
+
* Mutable Y component.
|
|
3263
|
+
*/
|
|
3264
|
+
y: number;
|
|
3265
|
+
|
|
3266
|
+
/**
|
|
3267
|
+
* Read-only Euclidean magnitude of this vector.
|
|
3268
|
+
*/
|
|
3269
|
+
readonly length: number;
|
|
3270
|
+
|
|
3271
|
+
/**
|
|
3272
|
+
* Read-only squared magnitude, avoiding a square-root calculation.
|
|
3273
|
+
*/
|
|
3274
|
+
readonly lengthSquared: number;
|
|
3275
|
+
|
|
3276
|
+
/**
|
|
3277
|
+
* Adds another vector to this vector in place.
|
|
3278
|
+
* @param other Vector to add component-wise.
|
|
3279
|
+
* @returns This mutated vector for chaining.
|
|
3280
|
+
*/
|
|
3281
|
+
add(other: Vector2): this;
|
|
3282
|
+
|
|
3283
|
+
/**
|
|
3284
|
+
* Subtracts another vector from this vector in place.
|
|
3285
|
+
* @param other Vector to subtract component-wise.
|
|
3286
|
+
* @returns This mutated vector for chaining.
|
|
3287
|
+
*/
|
|
3288
|
+
sub(other: Vector2): this;
|
|
3289
|
+
|
|
3290
|
+
/**
|
|
3291
|
+
* Multiplies this vector by a scalar in place.
|
|
3292
|
+
* @param scalar Multiplier applied to both components.
|
|
3293
|
+
* @returns This mutated vector for chaining.
|
|
3294
|
+
*/
|
|
3295
|
+
mul(scalar: number): this;
|
|
3296
|
+
|
|
3297
|
+
/**
|
|
3298
|
+
* Divides this vector by a scalar in place.
|
|
3299
|
+
* @param scalar Divisor applied to both components; must be non-zero.
|
|
3300
|
+
* @returns This mutated vector for chaining.
|
|
3301
|
+
*/
|
|
3302
|
+
div(scalar: number): this;
|
|
3303
|
+
|
|
3304
|
+
/**
|
|
3305
|
+
* Computes the dot product without changing either vector.
|
|
3306
|
+
* @param other Vector used for the dot product.
|
|
3307
|
+
* @returns Scalar dot product.
|
|
3308
|
+
*/
|
|
3309
|
+
dot(other: Vector2): number;
|
|
3310
|
+
|
|
3311
|
+
/**
|
|
3312
|
+
* Normalizes this vector in place; a zero vector remains unchanged.
|
|
3313
|
+
* @returns This mutated vector for chaining.
|
|
3314
|
+
*/
|
|
3315
|
+
normalize(): this;
|
|
3316
|
+
|
|
3317
|
+
/**
|
|
3318
|
+
* Linearly interpolates this vector toward a target in place.
|
|
3319
|
+
* @param target Destination vector.
|
|
3320
|
+
* @param t Interpolation factor; 0 keeps the current value and 1 reaches target.
|
|
3321
|
+
* @returns This mutated vector for chaining.
|
|
3322
|
+
*/
|
|
3323
|
+
lerp(target: Vector2, t: number): this;
|
|
3324
|
+
|
|
3325
|
+
/**
|
|
3326
|
+
* Replaces both components in place.
|
|
3327
|
+
* @param x Replacement X component.
|
|
3328
|
+
* @param y Replacement Y component.
|
|
3329
|
+
* @returns This mutated vector for chaining.
|
|
3330
|
+
*/
|
|
3331
|
+
set(x: number, y: number): this;
|
|
3332
|
+
|
|
3333
|
+
/**
|
|
3334
|
+
* Computes Euclidean distance to another vector.
|
|
3335
|
+
* @param other Vector to measure from this vector.
|
|
3336
|
+
* @returns Distance between the two vectors.
|
|
3337
|
+
*/
|
|
3338
|
+
distance(other: Vector2): number;
|
|
3339
|
+
|
|
3340
|
+
/**
|
|
3341
|
+
* Creates an independent copy of this vector.
|
|
3342
|
+
* @returns New vector with the same components.
|
|
3343
|
+
*/
|
|
3344
|
+
clone(): Vector2;
|
|
3345
|
+
|
|
3346
|
+
/**
|
|
3347
|
+
* Formats this vector for logging and debugging.
|
|
3348
|
+
* @returns Text in Vector2(x, y) form.
|
|
3349
|
+
*/
|
|
3350
|
+
toString(): string;
|
|
3351
|
+
|
|
3352
|
+
/**
|
|
3353
|
+
* Converts this vector to a plain object for JSON.stringify.
|
|
3354
|
+
* @returns Object containing the current components.
|
|
3355
|
+
*/
|
|
3356
|
+
toJSON(): { x: number; y: number };
|
|
3357
|
+
|
|
3358
|
+
/**
|
|
3359
|
+
* Creates a vector whose components are zero.
|
|
3360
|
+
* @returns New Vector2(0, 0).
|
|
3361
|
+
*/
|
|
3362
|
+
static zero(): Vector2;
|
|
3363
|
+
|
|
3364
|
+
/**
|
|
3365
|
+
* Creates a vector whose components are one.
|
|
3366
|
+
* @returns New Vector2(1, 1).
|
|
3367
|
+
*/
|
|
3368
|
+
static one(): Vector2;
|
|
3369
|
+
}
|
|
3370
|
+
|
|
3371
|
+
/**
|
|
3372
|
+
* Mutable three-dimensional vector for positions, directions, and Euler angles.
|
|
3373
|
+
*/
|
|
3374
|
+
class Vector3 {
|
|
3375
|
+
/**
|
|
3376
|
+
* Creates a vector from three numeric components.
|
|
3377
|
+
* @param x Initial X component.
|
|
3378
|
+
* @param y Initial Y component.
|
|
3379
|
+
* @param z Initial Z component.
|
|
3380
|
+
*/
|
|
3381
|
+
constructor(x: number, y: number, z: number);
|
|
3382
|
+
|
|
3383
|
+
/**
|
|
3384
|
+
* Mutable X component.
|
|
3385
|
+
*/
|
|
3386
|
+
x: number;
|
|
3387
|
+
|
|
3388
|
+
/**
|
|
3389
|
+
* Mutable Y component.
|
|
3390
|
+
*/
|
|
3391
|
+
y: number;
|
|
3392
|
+
|
|
3393
|
+
/**
|
|
3394
|
+
* Mutable Z component.
|
|
3395
|
+
*/
|
|
3396
|
+
z: number;
|
|
3397
|
+
|
|
3398
|
+
/**
|
|
3399
|
+
* Read-only Euclidean magnitude of this vector.
|
|
3400
|
+
*/
|
|
3401
|
+
readonly length: number;
|
|
3402
|
+
|
|
3403
|
+
/**
|
|
3404
|
+
* Read-only squared magnitude, avoiding a square-root calculation.
|
|
3405
|
+
*/
|
|
3406
|
+
readonly lengthSquared: number;
|
|
3407
|
+
|
|
3408
|
+
/**
|
|
3409
|
+
* Adds another vector to this vector in place.
|
|
3410
|
+
* @param other Vector to add component-wise.
|
|
3411
|
+
* @returns This mutated vector for chaining.
|
|
3412
|
+
*/
|
|
3413
|
+
add(other: Vector3): this;
|
|
3414
|
+
|
|
3415
|
+
/**
|
|
3416
|
+
* Subtracts another vector from this vector in place.
|
|
3417
|
+
* @param other Vector to subtract component-wise.
|
|
3418
|
+
* @returns This mutated vector for chaining.
|
|
3419
|
+
*/
|
|
3420
|
+
sub(other: Vector3): this;
|
|
3421
|
+
|
|
3422
|
+
/**
|
|
3423
|
+
* Multiplies this vector by a scalar in place.
|
|
3424
|
+
* @param scalar Multiplier applied to every component.
|
|
3425
|
+
* @returns This mutated vector for chaining.
|
|
3426
|
+
*/
|
|
3427
|
+
mul(scalar: number): this;
|
|
3428
|
+
|
|
3429
|
+
/**
|
|
3430
|
+
* Divides this vector by a scalar in place.
|
|
3431
|
+
* @param scalar Divisor applied to every component; must be non-zero.
|
|
3432
|
+
* @returns This mutated vector for chaining.
|
|
3433
|
+
*/
|
|
3434
|
+
div(scalar: number): this;
|
|
3435
|
+
|
|
3436
|
+
/**
|
|
3437
|
+
* Computes the dot product without changing either vector.
|
|
3438
|
+
* @param other Vector used for the dot product.
|
|
3439
|
+
* @returns Scalar dot product.
|
|
3440
|
+
*/
|
|
3441
|
+
dot(other: Vector3): number;
|
|
3442
|
+
|
|
3443
|
+
/**
|
|
3444
|
+
* Replaces this vector with its cross product against another vector.
|
|
3445
|
+
* @param other Second vector in the cross product.
|
|
3446
|
+
* @returns This mutated perpendicular vector for chaining.
|
|
3447
|
+
*/
|
|
3448
|
+
cross(other: Vector3): this;
|
|
3449
|
+
|
|
3450
|
+
/**
|
|
3451
|
+
* Normalizes this vector in place; a zero vector remains unchanged.
|
|
3452
|
+
* @returns This mutated vector for chaining.
|
|
3453
|
+
*/
|
|
3454
|
+
normalize(): this;
|
|
3455
|
+
|
|
3456
|
+
/**
|
|
3457
|
+
* Linearly interpolates this vector toward a target in place.
|
|
3458
|
+
* @param target Destination vector.
|
|
3459
|
+
* @param t Interpolation factor; 0 keeps the current value and 1 reaches target.
|
|
3460
|
+
* @returns This mutated vector for chaining.
|
|
3461
|
+
*/
|
|
3462
|
+
lerp(target: Vector3, t: number): this;
|
|
3463
|
+
|
|
3464
|
+
/**
|
|
3465
|
+
* Replaces all components in place.
|
|
3466
|
+
* @param x Replacement X component.
|
|
3467
|
+
* @param y Replacement Y component.
|
|
3468
|
+
* @param z Replacement Z component.
|
|
3469
|
+
* @returns This mutated vector for chaining.
|
|
3470
|
+
*/
|
|
3471
|
+
set(x: number, y: number, z: number): this;
|
|
3472
|
+
|
|
3473
|
+
/**
|
|
3474
|
+
* Computes Euclidean distance to another vector.
|
|
3475
|
+
* @param other Vector to measure from this vector.
|
|
3476
|
+
* @returns Distance between the two vectors.
|
|
3477
|
+
*/
|
|
3478
|
+
distance(other: Vector3): number;
|
|
3479
|
+
|
|
3480
|
+
/**
|
|
3481
|
+
* Creates an independent copy of this vector.
|
|
3482
|
+
* @returns New vector with the same components.
|
|
3483
|
+
*/
|
|
3484
|
+
clone(): Vector3;
|
|
3485
|
+
|
|
3486
|
+
/**
|
|
3487
|
+
* Formats this vector for logging and debugging.
|
|
3488
|
+
* @returns Text in Vector3(x, y, z) form.
|
|
3489
|
+
*/
|
|
3490
|
+
toString(): string;
|
|
3491
|
+
|
|
3492
|
+
/**
|
|
3493
|
+
* Converts this vector to a plain object for JSON.stringify.
|
|
3494
|
+
* @returns Object containing the current components.
|
|
3495
|
+
*/
|
|
3496
|
+
toJSON(): { x: number; y: number; z: number };
|
|
3497
|
+
|
|
3498
|
+
/**
|
|
3499
|
+
* Creates a zero vector.
|
|
3500
|
+
* @returns New Vector3(0, 0, 0).
|
|
3501
|
+
*/
|
|
3502
|
+
static zero(): Vector3;
|
|
3503
|
+
|
|
3504
|
+
/**
|
|
3505
|
+
* Creates a vector whose components are one.
|
|
3506
|
+
* @returns New Vector3(1, 1, 1).
|
|
3507
|
+
*/
|
|
3508
|
+
static one(): Vector3;
|
|
3509
|
+
|
|
3510
|
+
/**
|
|
3511
|
+
* Creates the framework's positive-Y unit direction.
|
|
3512
|
+
* @returns New Vector3(0, 1, 0).
|
|
3513
|
+
*/
|
|
3514
|
+
static up(): Vector3;
|
|
3515
|
+
|
|
3516
|
+
/**
|
|
3517
|
+
* Creates the framework's positive-Z unit direction.
|
|
3518
|
+
* @returns New Vector3(0, 0, 1).
|
|
3519
|
+
*/
|
|
3520
|
+
static forward(): Vector3;
|
|
3521
|
+
|
|
3522
|
+
/**
|
|
3523
|
+
* Creates the framework's positive-X unit direction.
|
|
3524
|
+
* @returns New Vector3(1, 0, 0).
|
|
3525
|
+
*/
|
|
3526
|
+
static right(): Vector3;
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3529
|
+
/**
|
|
3530
|
+
* Mutable four-dimensional vector.
|
|
3531
|
+
*/
|
|
3532
|
+
class Vector4 {
|
|
3533
|
+
/**
|
|
3534
|
+
* Creates a vector from four numeric components.
|
|
3535
|
+
* @param x Initial X component.
|
|
3536
|
+
* @param y Initial Y component.
|
|
3537
|
+
* @param z Initial Z component.
|
|
3538
|
+
* @param w Initial W component.
|
|
3539
|
+
*/
|
|
3540
|
+
constructor(x: number, y: number, z: number, w: number);
|
|
3541
|
+
|
|
3542
|
+
/**
|
|
3543
|
+
* Mutable X component.
|
|
3544
|
+
*/
|
|
3545
|
+
x: number;
|
|
3546
|
+
|
|
3547
|
+
/**
|
|
3548
|
+
* Mutable Y component.
|
|
3549
|
+
*/
|
|
3550
|
+
y: number;
|
|
3551
|
+
|
|
3552
|
+
/**
|
|
3553
|
+
* Mutable Z component.
|
|
3554
|
+
*/
|
|
3555
|
+
z: number;
|
|
3556
|
+
|
|
3557
|
+
/**
|
|
3558
|
+
* Mutable W component.
|
|
3559
|
+
*/
|
|
3560
|
+
w: number;
|
|
3561
|
+
|
|
3562
|
+
/**
|
|
3563
|
+
* Read-only Euclidean magnitude of this vector.
|
|
3564
|
+
*/
|
|
3565
|
+
readonly length: number;
|
|
3566
|
+
|
|
3567
|
+
/**
|
|
3568
|
+
* Read-only squared magnitude, avoiding a square-root calculation.
|
|
3569
|
+
*/
|
|
3570
|
+
readonly lengthSquared: number;
|
|
3571
|
+
|
|
3572
|
+
/**
|
|
3573
|
+
* Adds another vector to this vector in place.
|
|
3574
|
+
* @param other Vector to add component-wise.
|
|
3575
|
+
* @returns This mutated vector for chaining.
|
|
3576
|
+
*/
|
|
3577
|
+
add(other: Vector4): this;
|
|
3578
|
+
|
|
3579
|
+
/**
|
|
3580
|
+
* Subtracts another vector from this vector in place.
|
|
3581
|
+
* @param other Vector to subtract component-wise.
|
|
3582
|
+
* @returns This mutated vector for chaining.
|
|
3583
|
+
*/
|
|
3584
|
+
sub(other: Vector4): this;
|
|
3585
|
+
|
|
3586
|
+
/**
|
|
3587
|
+
* Multiplies this vector by a scalar in place.
|
|
3588
|
+
* @param scalar Multiplier applied to every component.
|
|
3589
|
+
* @returns This mutated vector for chaining.
|
|
3590
|
+
*/
|
|
3591
|
+
mul(scalar: number): this;
|
|
3592
|
+
|
|
3593
|
+
/**
|
|
3594
|
+
* Divides this vector by a scalar in place.
|
|
3595
|
+
* @param scalar Divisor applied to every component; must be non-zero.
|
|
3596
|
+
* @returns This mutated vector for chaining.
|
|
3597
|
+
*/
|
|
3598
|
+
div(scalar: number): this;
|
|
3599
|
+
|
|
3600
|
+
/**
|
|
3601
|
+
* Computes the dot product without changing either vector.
|
|
3602
|
+
* @param other Vector used for the dot product.
|
|
3603
|
+
* @returns Scalar dot product.
|
|
3604
|
+
*/
|
|
3605
|
+
dot(other: Vector4): number;
|
|
3606
|
+
|
|
3607
|
+
/**
|
|
3608
|
+
* Computes Euclidean distance to another vector.
|
|
3609
|
+
* @param other Vector to measure from this vector.
|
|
3610
|
+
* @returns Distance between the two vectors.
|
|
3611
|
+
*/
|
|
3612
|
+
distance(other: Vector4): number;
|
|
3613
|
+
|
|
3614
|
+
/**
|
|
3615
|
+
* Normalizes this vector in place; a zero vector remains unchanged.
|
|
3616
|
+
* @returns This mutated vector for chaining.
|
|
3617
|
+
*/
|
|
3618
|
+
normalize(): this;
|
|
3619
|
+
|
|
3620
|
+
/**
|
|
3621
|
+
* Linearly interpolates this vector toward a target in place.
|
|
3622
|
+
* @param target Destination vector.
|
|
3623
|
+
* @param t Interpolation factor; 0 keeps the current value and 1 reaches target.
|
|
3624
|
+
* @returns This mutated vector for chaining.
|
|
3625
|
+
*/
|
|
3626
|
+
lerp(target: Vector4, t: number): this;
|
|
3627
|
+
|
|
3628
|
+
/**
|
|
3629
|
+
* Replaces all components in place.
|
|
3630
|
+
* @param x Replacement X component.
|
|
3631
|
+
* @param y Replacement Y component.
|
|
3632
|
+
* @param z Replacement Z component.
|
|
3633
|
+
* @param w Replacement W component.
|
|
3634
|
+
* @returns This mutated vector for chaining.
|
|
3635
|
+
*/
|
|
3636
|
+
set(x: number, y: number, z: number, w: number): this;
|
|
3637
|
+
|
|
3638
|
+
/**
|
|
3639
|
+
* Creates an independent copy of this vector.
|
|
3640
|
+
* @returns New vector with the same components.
|
|
3641
|
+
*/
|
|
3642
|
+
clone(): Vector4;
|
|
3643
|
+
|
|
3644
|
+
/**
|
|
3645
|
+
* Formats this vector for logging and debugging.
|
|
3646
|
+
* @returns Text in Vector4(x, y, z, w) form.
|
|
3647
|
+
*/
|
|
3648
|
+
toString(): string;
|
|
3649
|
+
|
|
3650
|
+
/**
|
|
3651
|
+
* Converts this vector to a plain object for JSON.stringify.
|
|
3652
|
+
* @returns Object containing the current components.
|
|
3653
|
+
*/
|
|
3654
|
+
toJSON(): { x: number; y: number; z: number; w: number };
|
|
3655
|
+
|
|
3656
|
+
/**
|
|
3657
|
+
* Creates a zero vector.
|
|
3658
|
+
* @returns New Vector4(0, 0, 0, 0).
|
|
3659
|
+
*/
|
|
3660
|
+
static zero(): Vector4;
|
|
3661
|
+
|
|
3662
|
+
/**
|
|
3663
|
+
* Creates a vector whose components are one.
|
|
3664
|
+
* @returns New Vector4(1, 1, 1, 1).
|
|
3665
|
+
*/
|
|
3666
|
+
static one(): Vector4;
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
/**
|
|
3670
|
+
* Mutable quaternion for three-dimensional rotations. Components are scalar-first (w, x, y, z), matching GLM — not the x, y, z, w order some libraries use.
|
|
3671
|
+
*/
|
|
3672
|
+
class Quaternion {
|
|
3673
|
+
/**
|
|
3674
|
+
* Creates a quaternion in scalar-first w, x, y, z component order. Watch the trap: the scalar w is the first argument, unlike the x, y, z, w order used by some other libraries.
|
|
3675
|
+
* @param w Initial scalar component (comes first — this is not x, y, z, w order).
|
|
3676
|
+
* @param x Initial X imaginary component.
|
|
3677
|
+
* @param y Initial Y imaginary component.
|
|
3678
|
+
* @param z Initial Z imaginary component.
|
|
3679
|
+
*/
|
|
3680
|
+
constructor(w: number, x: number, y: number, z: number);
|
|
3681
|
+
|
|
3682
|
+
/**
|
|
3683
|
+
* Mutable scalar component.
|
|
3684
|
+
*/
|
|
3685
|
+
w: number;
|
|
3686
|
+
|
|
3687
|
+
/**
|
|
3688
|
+
* Mutable X imaginary component.
|
|
3689
|
+
*/
|
|
3690
|
+
x: number;
|
|
3691
|
+
|
|
3692
|
+
/**
|
|
3693
|
+
* Mutable Y imaginary component.
|
|
3694
|
+
*/
|
|
3695
|
+
y: number;
|
|
3696
|
+
|
|
3697
|
+
/**
|
|
3698
|
+
* Mutable Z imaginary component.
|
|
3699
|
+
*/
|
|
3700
|
+
z: number;
|
|
3701
|
+
|
|
3702
|
+
/**
|
|
3703
|
+
* Read-only magnitude (norm) of this quaternion; 1 for a unit rotation.
|
|
3704
|
+
*/
|
|
3705
|
+
readonly length: number;
|
|
3706
|
+
|
|
3707
|
+
/**
|
|
3708
|
+
* Read-only squared magnitude, avoiding a square-root calculation.
|
|
3709
|
+
*/
|
|
3710
|
+
readonly lengthSquared: number;
|
|
3711
|
+
|
|
3712
|
+
/**
|
|
3713
|
+
* Composes this rotation with another quaternion in place.
|
|
3714
|
+
* @param other Rotation composed after this quaternion.
|
|
3715
|
+
* @returns This mutated quaternion for chaining.
|
|
3716
|
+
*/
|
|
3717
|
+
mul(other: Quaternion): this;
|
|
3718
|
+
|
|
3719
|
+
/**
|
|
3720
|
+
* Normalizes this quaternion in place; a zero quaternion becomes the identity rotation instead of NaN.
|
|
3721
|
+
* @returns This unit quaternion for chaining.
|
|
3722
|
+
*/
|
|
3723
|
+
normalize(): this;
|
|
3724
|
+
|
|
3725
|
+
/**
|
|
3726
|
+
* Computes the conjugate without changing this quaternion.
|
|
3727
|
+
* @returns New conjugated quaternion.
|
|
3728
|
+
*/
|
|
3729
|
+
conjugate(): Quaternion;
|
|
3730
|
+
|
|
3731
|
+
/**
|
|
3732
|
+
* Computes the inverse rotation without changing this quaternion.
|
|
3733
|
+
* @returns New inverse quaternion.
|
|
3734
|
+
*/
|
|
3735
|
+
inverse(): Quaternion;
|
|
3736
|
+
|
|
3737
|
+
/**
|
|
3738
|
+
* Spherically interpolates this quaternion toward a target in place.
|
|
3739
|
+
* @param target Destination rotation.
|
|
3740
|
+
* @param t Interpolation factor; 0 keeps the current rotation and 1 reaches target.
|
|
3741
|
+
* @returns This mutated quaternion for chaining.
|
|
3742
|
+
*/
|
|
3743
|
+
slerp(target: Quaternion, t: number): this;
|
|
3744
|
+
|
|
3745
|
+
/**
|
|
3746
|
+
* Computes the quaternion dot product.
|
|
3747
|
+
* @param other Quaternion used for the dot product.
|
|
3748
|
+
* @returns Scalar dot product.
|
|
3749
|
+
*/
|
|
3750
|
+
dot(other: Quaternion): number;
|
|
3751
|
+
|
|
3752
|
+
/**
|
|
3753
|
+
* Applies this rotation to a vector without mutating either value.
|
|
3754
|
+
* @param vector Vector to rotate.
|
|
3755
|
+
* @returns New rotated vector.
|
|
3756
|
+
*/
|
|
3757
|
+
rotateVector(vector: Vector3): Vector3;
|
|
3758
|
+
|
|
3759
|
+
/**
|
|
3760
|
+
* Converts this rotation to Euler angles in radians.
|
|
3761
|
+
* @returns Pitch, yaw, and roll as a Vector3.
|
|
3762
|
+
*/
|
|
3763
|
+
toEuler(): Vector3;
|
|
3764
|
+
|
|
3765
|
+
/**
|
|
3766
|
+
* Replaces all quaternion components in place.
|
|
3767
|
+
* @param w Replacement scalar component.
|
|
3768
|
+
* @param x Replacement X imaginary component.
|
|
3769
|
+
* @param y Replacement Y imaginary component.
|
|
3770
|
+
* @param z Replacement Z imaginary component.
|
|
3771
|
+
* @returns This mutated quaternion for chaining.
|
|
3772
|
+
*/
|
|
3773
|
+
set(w: number, x: number, y: number, z: number): this;
|
|
3774
|
+
|
|
3775
|
+
/**
|
|
3776
|
+
* Creates an independent copy of this quaternion.
|
|
3777
|
+
* @returns New quaternion with the same components.
|
|
3778
|
+
*/
|
|
3779
|
+
clone(): Quaternion;
|
|
3780
|
+
|
|
3781
|
+
/**
|
|
3782
|
+
* Formats this quaternion for logging and debugging.
|
|
3783
|
+
* @returns Text in Quaternion(w, x, y, z) form.
|
|
3784
|
+
*/
|
|
3785
|
+
toString(): string;
|
|
3786
|
+
|
|
3787
|
+
/**
|
|
3788
|
+
* Converts this quaternion to a plain object for JSON.stringify.
|
|
3789
|
+
* @returns Object containing the current components.
|
|
3790
|
+
*/
|
|
3791
|
+
toJSON(): { w: number; x: number; y: number; z: number };
|
|
3792
|
+
|
|
3793
|
+
/**
|
|
3794
|
+
* Creates the identity rotation.
|
|
3795
|
+
* @returns New Quaternion(1, 0, 0, 0).
|
|
3796
|
+
*/
|
|
3797
|
+
static identity(): Quaternion;
|
|
3798
|
+
|
|
3799
|
+
/**
|
|
3800
|
+
* Creates a rotation from Euler angles.
|
|
3801
|
+
* @param pitch Pitch angle in radians.
|
|
3802
|
+
* @param yaw Yaw angle in radians.
|
|
3803
|
+
* @param roll Roll angle in radians.
|
|
3804
|
+
* @returns New rotation quaternion.
|
|
3805
|
+
*/
|
|
3806
|
+
static fromEuler(pitch: number, yaw: number, roll: number): Quaternion;
|
|
3807
|
+
|
|
3808
|
+
/**
|
|
3809
|
+
* Creates a rotation around an axis.
|
|
3810
|
+
* @param axis Rotation axis; it is normalized internally.
|
|
3811
|
+
* @param angle Rotation angle in radians.
|
|
3812
|
+
* @returns New axis-angle rotation quaternion.
|
|
3813
|
+
*/
|
|
3814
|
+
static fromAxisAngle(axis: Vector3, angle: number): Quaternion;
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3817
|
+
/**
|
|
3818
|
+
* Mutable RGBA color, with components stored from 0 to 1.
|
|
3819
|
+
*/
|
|
3820
|
+
class Color {
|
|
3821
|
+
/**
|
|
3822
|
+
* Creates a color from normalized RGBA components.
|
|
3823
|
+
* @param r Initial red component from 0 to 1.
|
|
3824
|
+
* @param g Initial green component from 0 to 1.
|
|
3825
|
+
* @param b Initial blue component from 0 to 1.
|
|
3826
|
+
* @param a Optional alpha component from 0 to 1; defaults to 1.
|
|
3827
|
+
*/
|
|
3828
|
+
constructor(r: number, g: number, b: number, a?: number);
|
|
3829
|
+
|
|
3830
|
+
/**
|
|
3831
|
+
* Mutable normalized red component.
|
|
3832
|
+
*/
|
|
3833
|
+
r: number;
|
|
3834
|
+
|
|
3835
|
+
/**
|
|
3836
|
+
* Mutable normalized green component.
|
|
3837
|
+
*/
|
|
3838
|
+
g: number;
|
|
3839
|
+
|
|
3840
|
+
/**
|
|
3841
|
+
* Mutable normalized blue component.
|
|
3842
|
+
*/
|
|
3843
|
+
b: number;
|
|
3844
|
+
|
|
3845
|
+
/**
|
|
3846
|
+
* Mutable normalized alpha component.
|
|
3847
|
+
*/
|
|
3848
|
+
a: number;
|
|
3849
|
+
|
|
3850
|
+
/**
|
|
3851
|
+
* Linearly interpolates every component toward a target in place.
|
|
3852
|
+
* @param target Destination color.
|
|
3853
|
+
* @param t Interpolation factor; 0 keeps this color and 1 reaches target.
|
|
3854
|
+
* @returns This mutated color for chaining.
|
|
3855
|
+
*/
|
|
3856
|
+
lerp(target: Color, t: number): this;
|
|
3857
|
+
|
|
3858
|
+
/**
|
|
3859
|
+
* Replaces this color's normalized components in place.
|
|
3860
|
+
* @param r Replacement red component from 0 to 1.
|
|
3861
|
+
* @param g Replacement green component from 0 to 1.
|
|
3862
|
+
* @param b Replacement blue component from 0 to 1.
|
|
3863
|
+
* @param a Optional replacement alpha; defaults to 1 when omitted.
|
|
3864
|
+
* @returns This mutated color for chaining.
|
|
3865
|
+
*/
|
|
3866
|
+
set(r: number, g: number, b: number, a?: number): this;
|
|
3867
|
+
|
|
3868
|
+
/**
|
|
3869
|
+
* Creates an independent copy of this color.
|
|
3870
|
+
* @returns New color with the same components.
|
|
3871
|
+
*/
|
|
3872
|
+
clone(): Color;
|
|
3873
|
+
|
|
3874
|
+
/**
|
|
3875
|
+
* Converts normalized components to a hexadecimal CSS-style string.
|
|
3876
|
+
* @param includeAlpha Whether to append the alpha byte; defaults to false.
|
|
3877
|
+
* @returns Lowercase #rrggbb or #rrggbbaa string.
|
|
3878
|
+
*/
|
|
3879
|
+
toHex(includeAlpha?: boolean): string;
|
|
3880
|
+
|
|
3881
|
+
/**
|
|
3882
|
+
* Formats this color for logging and debugging.
|
|
3883
|
+
* @returns Text in Color(r, g, b, a) form.
|
|
3884
|
+
*/
|
|
3885
|
+
toString(): string;
|
|
3886
|
+
|
|
3887
|
+
/**
|
|
3888
|
+
* Converts this color to a plain object for JSON.stringify.
|
|
3889
|
+
* @returns Object containing the current normalized components.
|
|
3890
|
+
*/
|
|
3891
|
+
toJSON(): { r: number; g: number; b: number; a: number };
|
|
3892
|
+
|
|
3893
|
+
/**
|
|
3894
|
+
* Parses a hexadecimal color string.
|
|
3895
|
+
* @param hex Hexadecimal color in #RRGGBB or #RRGGBBAA form; the leading # is optional. Three- and four-digit shorthands are not supported.
|
|
3896
|
+
* @returns Parsed color, or opaque white when the input is invalid.
|
|
3897
|
+
*/
|
|
3898
|
+
static fromHex(hex: string): Color;
|
|
3899
|
+
|
|
3900
|
+
/**
|
|
3901
|
+
* Creates a normalized color from byte components.
|
|
3902
|
+
* @param r Red byte from 0 to 255.
|
|
3903
|
+
* @param g Green byte from 0 to 255.
|
|
3904
|
+
* @param b Blue byte from 0 to 255.
|
|
3905
|
+
* @param a Optional alpha byte from 0 to 255; defaults to 255.
|
|
3906
|
+
* @returns New normalized color.
|
|
3907
|
+
*/
|
|
3908
|
+
static fromRGB(r: number, g: number, b: number, a?: number): Color;
|
|
3909
|
+
|
|
3910
|
+
/**
|
|
3911
|
+
* Creates opaque white.
|
|
3912
|
+
* @returns New Color(1, 1, 1, 1).
|
|
3913
|
+
*/
|
|
3914
|
+
static white(): Color;
|
|
3915
|
+
|
|
3916
|
+
/**
|
|
3917
|
+
* Creates opaque black.
|
|
3918
|
+
* @returns New Color(0, 0, 0, 1).
|
|
3919
|
+
*/
|
|
3920
|
+
static black(): Color;
|
|
3921
|
+
|
|
3922
|
+
/**
|
|
3923
|
+
* Creates opaque red.
|
|
3924
|
+
* @returns New Color(1, 0, 0, 1).
|
|
3925
|
+
*/
|
|
3926
|
+
static red(): Color;
|
|
3927
|
+
|
|
3928
|
+
/**
|
|
3929
|
+
* Creates opaque green.
|
|
3930
|
+
* @returns New Color(0, 1, 0, 1).
|
|
3931
|
+
*/
|
|
3932
|
+
static green(): Color;
|
|
3933
|
+
|
|
3934
|
+
/**
|
|
3935
|
+
* Creates opaque blue.
|
|
3936
|
+
* @returns New Color(0, 0, 1, 1).
|
|
3937
|
+
*/
|
|
3938
|
+
static blue(): Color;
|
|
3939
|
+
|
|
3940
|
+
/**
|
|
3941
|
+
* Creates opaque yellow.
|
|
3942
|
+
* @returns New Color(1, 1, 0, 1).
|
|
3943
|
+
*/
|
|
3944
|
+
static yellow(): Color;
|
|
3945
|
+
|
|
3946
|
+
/**
|
|
3947
|
+
* Creates opaque cyan.
|
|
3948
|
+
* @returns New Color(0, 1, 1, 1).
|
|
3949
|
+
*/
|
|
3950
|
+
static cyan(): Color;
|
|
3951
|
+
|
|
3952
|
+
/**
|
|
3953
|
+
* Creates opaque magenta.
|
|
3954
|
+
* @returns New Color(1, 0, 1, 1).
|
|
3955
|
+
*/
|
|
3956
|
+
static magenta(): Color;
|
|
3957
|
+
|
|
3958
|
+
/**
|
|
3959
|
+
* Creates fully transparent black.
|
|
3960
|
+
* @returns New Color(0, 0, 0, 0).
|
|
3961
|
+
*/
|
|
3962
|
+
static transparent(): Color;
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3965
|
+
/**
|
|
3966
|
+
* Asynchronous resource event bus.
|
|
3967
|
+
*/
|
|
3968
|
+
interface EventBus {
|
|
3969
|
+
/**
|
|
3970
|
+
* Registers a persistent handler in the shared event namespace.
|
|
3971
|
+
* @param eventName Case-sensitive event name.
|
|
3972
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
3973
|
+
* @returns Function that removes this exact subscription.
|
|
3974
|
+
*/
|
|
3975
|
+
on<K extends EventName>(eventName: K, handler: (...args: EventMap[K]) => unknown | Promise<unknown>): Unsubscribe;
|
|
3976
|
+
|
|
3977
|
+
/**
|
|
3978
|
+
* Registers a persistent handler in the shared event namespace.
|
|
3979
|
+
* @param eventName Case-sensitive event name.
|
|
3980
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
3981
|
+
* @returns Function that removes this exact subscription.
|
|
3982
|
+
*/
|
|
3983
|
+
on(eventName: string, handler: EventHandler): Unsubscribe;
|
|
3984
|
+
|
|
3985
|
+
/**
|
|
3986
|
+
* Registers a handler that is removed before its first invocation.
|
|
3987
|
+
* @param eventName Case-sensitive event name.
|
|
3988
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
3989
|
+
*/
|
|
3990
|
+
once<K extends EventName>(eventName: K, handler: (...args: EventMap[K]) => unknown | Promise<unknown>): void;
|
|
3991
|
+
|
|
3992
|
+
/**
|
|
3993
|
+
* Registers a handler that is removed before its first invocation.
|
|
3994
|
+
* @param eventName Case-sensitive event name.
|
|
3995
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
3996
|
+
*/
|
|
3997
|
+
once(eventName: string, handler: EventHandler): void;
|
|
3998
|
+
|
|
3999
|
+
/**
|
|
4000
|
+
* Removes a matching handler owned by the calling resource.
|
|
4001
|
+
* @param eventName Case-sensitive event name.
|
|
4002
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
4003
|
+
*/
|
|
4004
|
+
off<K extends EventName>(eventName: K, handler: (...args: EventMap[K]) => unknown | Promise<unknown>): void;
|
|
4005
|
+
|
|
4006
|
+
/**
|
|
4007
|
+
* Removes a matching handler owned by the calling resource.
|
|
4008
|
+
* @param eventName Case-sensitive event name.
|
|
4009
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
4010
|
+
*/
|
|
4011
|
+
off(eventName: string, handler: EventHandler): void;
|
|
4012
|
+
|
|
4013
|
+
/**
|
|
4014
|
+
* Invokes every shared handler and waits for all synchronous and asynchronous results.
|
|
4015
|
+
* @param eventName Shared event name.
|
|
4016
|
+
* @param args Arguments delivered to every matching handler.
|
|
4017
|
+
* @returns Promise rejected with an AggregateError when one or more handlers fail.
|
|
4018
|
+
*/
|
|
4019
|
+
emit(eventName: string, ...args: unknown[]): Promise<void>;
|
|
4020
|
+
|
|
4021
|
+
/**
|
|
4022
|
+
* Invokes matching handlers belonging only to one resource.
|
|
4023
|
+
* @param resourceName Destination running resource.
|
|
4024
|
+
* @param eventName Shared event name.
|
|
4025
|
+
* @param args Arguments delivered to matching handlers owned by the destination.
|
|
4026
|
+
* @returns Promise rejected when one or more destination handlers fail.
|
|
4027
|
+
*/
|
|
4028
|
+
emitTo(resourceName: string, eventName: string, ...args: unknown[]): Promise<void>;
|
|
4029
|
+
|
|
4030
|
+
/**
|
|
4031
|
+
* Registers a handler in the calling resource's private local-event namespace.
|
|
4032
|
+
* @param eventName Case-sensitive event name.
|
|
4033
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
4034
|
+
*/
|
|
4035
|
+
onLocal(eventName: string, handler: EventHandler): void;
|
|
4036
|
+
|
|
4037
|
+
/**
|
|
4038
|
+
* Emits an event only within the calling resource.
|
|
4039
|
+
* @param eventName Private local event name.
|
|
4040
|
+
* @param args Arguments delivered only to handlers owned by the calling resource.
|
|
4041
|
+
* @returns Promise rejected when one or more local handlers fail.
|
|
4042
|
+
*/
|
|
4043
|
+
emitLocal(eventName: string, ...args: unknown[]): Promise<void>;
|
|
4044
|
+
|
|
4045
|
+
/**
|
|
4046
|
+
* Counts persistent and one-shot shared handlers across resources.
|
|
4047
|
+
* @param eventName Shared event name to inspect.
|
|
4048
|
+
* @returns Number of matching handlers.
|
|
4049
|
+
*/
|
|
4050
|
+
listenerCount(eventName: string): number;
|
|
4051
|
+
|
|
4052
|
+
/**
|
|
4053
|
+
* Broadcasts a named event to every connected client's shared Events handlers.
|
|
4054
|
+
* @param eventName Client shared-event name.
|
|
4055
|
+
* @param payload Optional string payload sent verbatim; other values are JSON-serialized.
|
|
4056
|
+
*/
|
|
4057
|
+
emitAllClients(eventName: string, payload?: unknown): void;
|
|
4058
|
+
|
|
4059
|
+
/**
|
|
4060
|
+
* Registers a persistent server handler for events originating from clients; this namespace is isolated from native events.
|
|
4061
|
+
* @param eventName Case-sensitive event name.
|
|
4062
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
4063
|
+
* @returns Function that removes this exact subscription.
|
|
4064
|
+
*/
|
|
4065
|
+
onClient(eventName: string, handler: EventHandler): Unsubscribe;
|
|
4066
|
+
|
|
4067
|
+
/**
|
|
4068
|
+
* Registers a one-shot server handler for a client-originated event.
|
|
4069
|
+
* @param eventName Case-sensitive event name.
|
|
4070
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
4071
|
+
*/
|
|
4072
|
+
onceClient(eventName: string, handler: EventHandler): void;
|
|
4073
|
+
|
|
4074
|
+
/**
|
|
4075
|
+
* Removes a matching client-originated event handler owned by the calling resource.
|
|
4076
|
+
* @param eventName Case-sensitive event name.
|
|
4077
|
+
* @param handler Resource-owned callback invoked with the emitted arguments.
|
|
4078
|
+
*/
|
|
4079
|
+
offClient(eventName: string, handler: EventHandler): void;
|
|
4080
|
+
}
|
|
4081
|
+
|
|
4082
|
+
/**
|
|
4083
|
+
* Asynchronous resource event bus.
|
|
4084
|
+
*/
|
|
4085
|
+
const Events: EventBus;
|
|
4086
|
+
|
|
4087
|
+
/**
|
|
4088
|
+
* Typed request and notification channel between local resources through the global Messages object.
|
|
4089
|
+
*/
|
|
4090
|
+
const Messages: {
|
|
4091
|
+
/**
|
|
4092
|
+
* Registers or replaces a message handler owned by the calling resource.
|
|
4093
|
+
* @param messageType Message type unique within the receiving resource.
|
|
4094
|
+
* @param handler Handler invoked with the payload and a reply callback; the reply is ignored for notifications.
|
|
4095
|
+
*/
|
|
4096
|
+
handle(messageType: string, handler: MessageHandler): void;
|
|
4097
|
+
|
|
4098
|
+
/**
|
|
4099
|
+
* Sends a request to another local resource and waits for its handler to call reply.
|
|
4100
|
+
* @param resourceName Destination running resource.
|
|
4101
|
+
* @param messageType Handler type registered by the destination.
|
|
4102
|
+
* @param payload Optional payload delivered to the handler.
|
|
4103
|
+
* @returns Promise resolved with the reply value or rejected when delivery or handling fails.
|
|
4104
|
+
*/
|
|
4105
|
+
request(resourceName: string, messageType: string, payload?: unknown): Promise<unknown>;
|
|
4106
|
+
|
|
4107
|
+
/**
|
|
4108
|
+
* Sends a fire-and-forget notification to another local resource.
|
|
4109
|
+
* @param resourceName Destination running resource.
|
|
4110
|
+
* @param messageType Handler type registered by the destination.
|
|
4111
|
+
* @param payload Optional payload delivered to the handler.
|
|
4112
|
+
*/
|
|
4113
|
+
send(resourceName: string, messageType: string, payload?: unknown): void;
|
|
4114
|
+
};
|
|
4115
|
+
|
|
4116
|
+
/**
|
|
4117
|
+
* Bulk access to values exported by another running resource through the global Imports object.
|
|
4118
|
+
*/
|
|
4119
|
+
const Imports: {
|
|
4120
|
+
/**
|
|
4121
|
+
* Builds an object containing every currently registered export from another resource; undeclared dependencies produce a warning.
|
|
4122
|
+
* @param resourceName Name of the running resource whose exports should be read.
|
|
4123
|
+
* @returns Object keyed by export name, or an empty object when the resource has no exports.
|
|
4124
|
+
*/
|
|
4125
|
+
get(resourceName: string): Record<string, unknown>;
|
|
4126
|
+
};
|
|
4127
|
+
|
|
4128
|
+
/**
|
|
4129
|
+
* Registration and lookup of cross-resource values through the global Exports object.
|
|
4130
|
+
*/
|
|
4131
|
+
const Exports: {
|
|
4132
|
+
/**
|
|
4133
|
+
* Registers a value from the calling resource for use by dependent resources.
|
|
4134
|
+
* @param name Export name, preferably declared in the current resource manifest.
|
|
4135
|
+
* @param value JavaScript value or function retained by the current resource.
|
|
4136
|
+
* @returns True when the value was registered.
|
|
4137
|
+
*/
|
|
4138
|
+
register(name: string, value: unknown): boolean;
|
|
4139
|
+
|
|
4140
|
+
/**
|
|
4141
|
+
* Reads one registered export from another running resource; undeclared dependencies produce a warning.
|
|
4142
|
+
* @param resourceName Name of the running resource that owns the export.
|
|
4143
|
+
* @param exportName Registered export name.
|
|
4144
|
+
* @returns The exported value.
|
|
4145
|
+
*/
|
|
4146
|
+
get(resourceName: string, exportName: string): unknown;
|
|
4147
|
+
};
|
|
4148
|
+
|
|
4149
|
+
/**
|
|
4150
|
+
* Resource-aware console that routes output through the Framework logger.
|
|
4151
|
+
*/
|
|
4152
|
+
const console: {
|
|
4153
|
+
/**
|
|
4154
|
+
* Writes an informational log entry prefixed with the current resource name.
|
|
4155
|
+
* @param values Values formatted and joined with spaces.
|
|
4156
|
+
*/
|
|
4157
|
+
log(...values: unknown[]): void;
|
|
4158
|
+
|
|
4159
|
+
/**
|
|
4160
|
+
* Alias of console.log for informational output.
|
|
4161
|
+
* @param values Values formatted and joined with spaces.
|
|
4162
|
+
*/
|
|
4163
|
+
info(...values: unknown[]): void;
|
|
4164
|
+
|
|
4165
|
+
/**
|
|
4166
|
+
* Writes a warning log entry prefixed with the current resource name.
|
|
4167
|
+
* @param values Values formatted and joined with spaces.
|
|
4168
|
+
*/
|
|
4169
|
+
warn(...values: unknown[]): void;
|
|
4170
|
+
|
|
4171
|
+
/**
|
|
4172
|
+
* Writes an error log entry prefixed with the current resource name.
|
|
4173
|
+
* @param values Values formatted and joined with spaces.
|
|
4174
|
+
*/
|
|
4175
|
+
error(...values: unknown[]): void;
|
|
4176
|
+
|
|
4177
|
+
/**
|
|
4178
|
+
* Writes a debug log entry prefixed with the current resource name.
|
|
4179
|
+
* @param values Values formatted and joined with spaces.
|
|
4180
|
+
*/
|
|
4181
|
+
debug(...values: unknown[]): void;
|
|
4182
|
+
};
|
|
4183
|
+
|
|
4184
|
+
/**
|
|
4185
|
+
* Runtime-side flags exposed as the global ExecutionEnvironment.
|
|
4186
|
+
*/
|
|
4187
|
+
const ExecutionEnvironment: {
|
|
4188
|
+
/**
|
|
4189
|
+
* True in the sandboxed client scripting runtime.
|
|
4190
|
+
*/
|
|
4191
|
+
readonly isClient: boolean;
|
|
4192
|
+
|
|
4193
|
+
/**
|
|
4194
|
+
* True in the authoritative server scripting runtime.
|
|
4195
|
+
*/
|
|
4196
|
+
readonly isServer: boolean;
|
|
4197
|
+
};
|
|
4198
|
+
|
|
4199
|
+
/**
|
|
4200
|
+
* Server-side delivery of structured chat messages to connected clients.
|
|
4201
|
+
*/
|
|
4202
|
+
const Chat: {
|
|
4203
|
+
/**
|
|
4204
|
+
* Broadcasts a structured chat message to all clients.
|
|
4205
|
+
* @param text Message body broadcast to every connected client.
|
|
4206
|
+
* @param options Optional author label and color: a Color or a packed 0xRRGGBBAA integer.
|
|
4207
|
+
*/
|
|
4208
|
+
sendToAll(text: string, options?: { author?: string; color?: number | Color }): void;
|
|
4209
|
+
|
|
4210
|
+
/**
|
|
4211
|
+
* Sends a structured chat message to one player's owning connection.
|
|
4212
|
+
* @param player Player-owned entity identifying the destination connection.
|
|
4213
|
+
* @param text Message body sent to the player.
|
|
4214
|
+
* @param options Optional author label and color: a Color or a packed 0xRRGGBBAA integer.
|
|
4215
|
+
*/
|
|
4216
|
+
sendToPlayer(player: Entity, text: string, options?: { author?: string; color?: number | Color }): void;
|
|
4217
|
+
|
|
4218
|
+
/**
|
|
4219
|
+
* Enables or disables the built-in player-to-player chat relay.
|
|
4220
|
+
* @param enabled True to relay chat automatically; false to answer playerChat yourself.
|
|
4221
|
+
*/
|
|
4222
|
+
setDefaultRelay(enabled: boolean): void;
|
|
4223
|
+
|
|
4224
|
+
/**
|
|
4225
|
+
* Checks whether the built-in chat relay is enabled.
|
|
4226
|
+
* @returns True when chat is relayed automatically.
|
|
4227
|
+
*/
|
|
4228
|
+
isDefaultRelay(): boolean;
|
|
4229
|
+
};
|
|
4230
|
+
|
|
4231
|
+
/**
|
|
4232
|
+
* Server-side proximity voice rules: how far voice carries, and who may talk to or hear whom.
|
|
4233
|
+
*/
|
|
4234
|
+
const Voice: {
|
|
4235
|
+
/**
|
|
4236
|
+
* Sets how far voice carries for talkers with no override of their own. Connected clients are told, so their playback fades out at the same distance.
|
|
4237
|
+
* @param range Audibility radius in world units; values <= 0 restore the default of 25.
|
|
4238
|
+
*/
|
|
4239
|
+
setRange(range: number): void;
|
|
4240
|
+
|
|
4241
|
+
/**
|
|
4242
|
+
* Reads the server-wide proximity range.
|
|
4243
|
+
* @returns Radius in world units.
|
|
4244
|
+
*/
|
|
4245
|
+
getRange(): number;
|
|
4246
|
+
|
|
4247
|
+
/**
|
|
4248
|
+
* Overrides how far one player's voice carries, for whisper and shout modes.
|
|
4249
|
+
* @param player Player whose voice carries the given distance.
|
|
4250
|
+
* @param range Audibility radius in world units; values <= 0 return them to the server-wide range.
|
|
4251
|
+
*/
|
|
4252
|
+
setPlayerRange(player: Entity, range: number): void;
|
|
4253
|
+
|
|
4254
|
+
/**
|
|
4255
|
+
* Reads how far a player's voice carries, with the server-wide default already resolved.
|
|
4256
|
+
* @param player Player to query.
|
|
4257
|
+
* @returns Radius in world units.
|
|
4258
|
+
*/
|
|
4259
|
+
getPlayerRange(player: Entity): number;
|
|
4260
|
+
|
|
4261
|
+
/**
|
|
4262
|
+
* Server-wide mute: a muted player's voice reaches nobody.
|
|
4263
|
+
* @param player Player to mute or unmute.
|
|
4264
|
+
* @param muted True to stop their voice reaching anyone.
|
|
4265
|
+
*/
|
|
4266
|
+
setPlayerMuted(player: Entity, muted: boolean): void;
|
|
4267
|
+
|
|
4268
|
+
/**
|
|
4269
|
+
* Checks the server-wide mute flag.
|
|
4270
|
+
* @param player Player to query.
|
|
4271
|
+
* @returns True when the player's voice reaches nobody.
|
|
4272
|
+
*/
|
|
4273
|
+
isPlayerMuted(player: Entity): boolean;
|
|
4274
|
+
|
|
4275
|
+
/**
|
|
4276
|
+
* Server-wide deafen: a deaf player receives nobody.
|
|
4277
|
+
* @param player Player to deafen or undeafen.
|
|
4278
|
+
* @param deaf True to stop them receiving anyone's voice.
|
|
4279
|
+
*/
|
|
4280
|
+
setPlayerDeaf(player: Entity, deaf: boolean): void;
|
|
4281
|
+
|
|
4282
|
+
/**
|
|
4283
|
+
* Checks the server-wide deafen flag.
|
|
4284
|
+
* @param player Player to query.
|
|
4285
|
+
* @returns True when the player receives nobody's voice.
|
|
4286
|
+
*/
|
|
4287
|
+
isPlayerDeaf(player: Entity): boolean;
|
|
4288
|
+
|
|
4289
|
+
/**
|
|
4290
|
+
* One-way mute between two players, enforced by the server rather than the client.
|
|
4291
|
+
* @param listener Player who stops hearing the target.
|
|
4292
|
+
* @param target Player the listener stops hearing.
|
|
4293
|
+
* @param muted True to mute, false to restore.
|
|
4294
|
+
*/
|
|
4295
|
+
setLocalMute(listener: Entity, target: Entity, muted: boolean): void;
|
|
4296
|
+
|
|
4297
|
+
/**
|
|
4298
|
+
* Checks a one-way mute.
|
|
4299
|
+
* @param listener Player doing the muting.
|
|
4300
|
+
* @param target Player being muted.
|
|
4301
|
+
* @returns True when the listener does not receive the target.
|
|
4302
|
+
*/
|
|
4303
|
+
isLocallyMuted(listener: Entity, target: Entity): boolean;
|
|
4304
|
+
|
|
4305
|
+
/**
|
|
4306
|
+
* Checks whether a player left voice chat enabled in their own client settings. A preference, not a permission: use setPlayerMuted or setPlayerDeaf to enforce anything.
|
|
4307
|
+
* @param player Player to query.
|
|
4308
|
+
* @returns True unless the player turned voice chat off.
|
|
4309
|
+
*/
|
|
4310
|
+
isPlayerVoiceEnabled(player: Entity): boolean;
|
|
4311
|
+
|
|
4312
|
+
/**
|
|
4313
|
+
* Checks whether a player is speaking right now. Tracks speech rather than the push-to-talk key: silence is dropped before it reaches the server, and the state clears shortly after the last frame. The same signal raises the playerVoiceStart and playerVoiceStop events.
|
|
4314
|
+
* @param player Player to query.
|
|
4315
|
+
* @returns True while the player's voice is reaching the server.
|
|
4316
|
+
*/
|
|
4317
|
+
isPlayerTalking(player: Entity): boolean;
|
|
4318
|
+
};
|
|
4319
|
+
|
|
4320
|
+
/**
|
|
4321
|
+
* Base handle for a live replicated network entity.
|
|
4322
|
+
*/
|
|
4323
|
+
class Entity {
|
|
4324
|
+
/**
|
|
4325
|
+
* Creates a script wrapper for an existing entity with this ID; it does not spawn an entity.
|
|
4326
|
+
* @param id Network entity identifier.
|
|
4327
|
+
*/
|
|
4328
|
+
constructor(id: number);
|
|
4329
|
+
|
|
4330
|
+
/**
|
|
4331
|
+
* Immutable network entity identifier.
|
|
4332
|
+
*/
|
|
4333
|
+
readonly id: number;
|
|
4334
|
+
|
|
4335
|
+
/**
|
|
4336
|
+
* Current virtual-world identifier.
|
|
4337
|
+
*/
|
|
4338
|
+
readonly virtualWorld: number;
|
|
4339
|
+
|
|
4340
|
+
/**
|
|
4341
|
+
* Authoritative world-space position; assignment forces replicated state.
|
|
4342
|
+
*/
|
|
4343
|
+
position: Vector3;
|
|
4344
|
+
|
|
4345
|
+
/**
|
|
4346
|
+
* Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.
|
|
4347
|
+
*/
|
|
4348
|
+
rotation: Quaternion | Vector3;
|
|
4349
|
+
|
|
4350
|
+
/**
|
|
4351
|
+
* Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.
|
|
4352
|
+
*/
|
|
4353
|
+
readonly state: StateBag;
|
|
4354
|
+
|
|
4355
|
+
/**
|
|
4356
|
+
* Formats this entity handle for logging and debugging.
|
|
4357
|
+
* @returns Text containing the network entity ID.
|
|
4358
|
+
*/
|
|
4359
|
+
toString(): string;
|
|
4360
|
+
|
|
4361
|
+
/**
|
|
4362
|
+
* Moves this entity into another virtual world.
|
|
4363
|
+
* @param world Virtual-world identifier used to partition replication and visibility.
|
|
4364
|
+
*/
|
|
4365
|
+
setVirtualWorld(world: number): void;
|
|
4366
|
+
|
|
4367
|
+
/**
|
|
4368
|
+
* Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.
|
|
4369
|
+
* @param player Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.
|
|
4370
|
+
*/
|
|
4371
|
+
setVisibleTo(player: Entity | null): void;
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4374
|
+
/**
|
|
4375
|
+
* 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.
|
|
4376
|
+
*/
|
|
4377
|
+
class StateBag {
|
|
4378
|
+
/**
|
|
4379
|
+
* Reads one key from this entity's state.
|
|
4380
|
+
* @param key Key to read.
|
|
4381
|
+
* @returns The stored value, or undefined when the key is not set.
|
|
4382
|
+
*/
|
|
4383
|
+
get(key: string): any;
|
|
4384
|
+
|
|
4385
|
+
/**
|
|
4386
|
+
* Checks whether this entity's state holds a key.
|
|
4387
|
+
* @param key Key to test.
|
|
4388
|
+
* @returns True when the key is set.
|
|
4389
|
+
*/
|
|
4390
|
+
has(key: string): boolean;
|
|
4391
|
+
|
|
4392
|
+
/**
|
|
4393
|
+
* Lists the keys this entity's state holds, sorted.
|
|
4394
|
+
* @returns Every key currently set, in ascending order.
|
|
4395
|
+
*/
|
|
4396
|
+
keys(): string[];
|
|
4397
|
+
|
|
4398
|
+
/**
|
|
4399
|
+
* Copies this entity's whole state into a plain object.
|
|
4400
|
+
* @returns Every key and value currently set. The copy does not track later changes.
|
|
4401
|
+
*/
|
|
4402
|
+
toObject(): Record<string, any>;
|
|
4403
|
+
|
|
4404
|
+
/**
|
|
4405
|
+
* Watches this entity's state. The filter is applied before the handler runs, so a listener watching one key of one entity is not woken by unrelated changes. The subscription is dropped when the registering resource stops.
|
|
4406
|
+
* @param key Only report this key, or null to report every key of this entity.
|
|
4407
|
+
* @param handler Called as (key: string, value: any, previous: any) with the changed key, its new value and the value before it. `value` is undefined when the key was removed and `previous` is undefined when it held nothing.
|
|
4408
|
+
* @returns A zero-argument function that cancels this subscription.
|
|
4409
|
+
*/
|
|
4410
|
+
onChange(key: string | null, handler: Function): Function;
|
|
4411
|
+
|
|
4412
|
+
/**
|
|
4413
|
+
* Writes one key of this entity's state and replicates it to whoever the scope names. Throws when a limit is reached.
|
|
4414
|
+
* @param key Key to write; at most 64 UTF-8 bytes.
|
|
4415
|
+
* @param value Value to store. Booleans, numbers and strings travel as themselves; anything else is serialized as JSON. At most 4096 bytes.
|
|
4416
|
+
* @param options Who the key reaches: every client that can see the entity (the default), only its owning client, or nobody -- server-side storage that never goes on the wire.
|
|
4417
|
+
* @returns True when the value changed, false when it was already stored.
|
|
4418
|
+
*/
|
|
4419
|
+
set(key: string, value: any, options?: { scope?: 'broadcast' | 'owner' | 'server' }): boolean;
|
|
4420
|
+
|
|
4421
|
+
/**
|
|
4422
|
+
* Removes one key from this entity's state, telling every client that held it.
|
|
4423
|
+
* @param key Key to drop.
|
|
4424
|
+
* @returns True when the key was set and has been removed.
|
|
4425
|
+
*/
|
|
4426
|
+
remove(key: string): boolean;
|
|
4427
|
+
}
|
|
4428
|
+
|
|
4429
|
+
/**
|
|
4430
|
+
* Framework-owned base handle for a connected player, extended by each game or mod.
|
|
4431
|
+
*/
|
|
4432
|
+
class BasePlayer {
|
|
4433
|
+
/**
|
|
4434
|
+
* Creates a wrapper for an existing connected player with this ID; it does not connect or spawn a player.
|
|
4435
|
+
* @param id Network entity identifier.
|
|
4436
|
+
*/
|
|
4437
|
+
constructor(id: number);
|
|
4438
|
+
|
|
4439
|
+
/**
|
|
4440
|
+
* Authenticated Steam identifier, or an empty string when unavailable.
|
|
4441
|
+
*/
|
|
4442
|
+
readonly steamId: string;
|
|
4443
|
+
|
|
4444
|
+
/**
|
|
4445
|
+
* Authenticated Discord identifier, or an empty string when unavailable.
|
|
4446
|
+
*/
|
|
4447
|
+
readonly discordId: string;
|
|
4448
|
+
|
|
4449
|
+
/**
|
|
4450
|
+
* Framework hardware identifier, or an empty string when unavailable.
|
|
4451
|
+
*/
|
|
4452
|
+
readonly hardwareId: string;
|
|
4453
|
+
|
|
4454
|
+
/**
|
|
4455
|
+
* Current round-trip latency in milliseconds, or -1 when unavailable.
|
|
4456
|
+
*/
|
|
4457
|
+
readonly ping: number;
|
|
4458
|
+
|
|
4459
|
+
/**
|
|
4460
|
+
* Current remote network address, or an empty string when unavailable.
|
|
4461
|
+
*/
|
|
4462
|
+
readonly ip: string;
|
|
4463
|
+
|
|
4464
|
+
/**
|
|
4465
|
+
* Formats this player handle for logging and debugging.
|
|
4466
|
+
* @returns Text containing the player's network entity ID.
|
|
4467
|
+
*/
|
|
4468
|
+
toString(): string;
|
|
4469
|
+
|
|
4470
|
+
/**
|
|
4471
|
+
* Checks whether this player's nametag is shown to other players.
|
|
4472
|
+
* @returns True unless the nametag was hidden; false also when this game has no nametags.
|
|
4473
|
+
*/
|
|
4474
|
+
isNametagVisible(): boolean;
|
|
4475
|
+
|
|
4476
|
+
/**
|
|
4477
|
+
* Checks whether the health bar under this player's nametag is shown.
|
|
4478
|
+
* @returns True unless the health bar was hidden; false also when this game has no nametags.
|
|
4479
|
+
*/
|
|
4480
|
+
isNametagHealthVisible(): boolean;
|
|
4481
|
+
|
|
4482
|
+
/**
|
|
4483
|
+
* Reads this player's nametag text override.
|
|
4484
|
+
* @returns The override, or an empty string when the player's own name is drawn.
|
|
4485
|
+
*/
|
|
4486
|
+
getNametagText(): string;
|
|
4487
|
+
|
|
4488
|
+
/**
|
|
4489
|
+
* Reads this player's nametag color.
|
|
4490
|
+
* @returns Packed 0xAARRGGBB color; opaque white when untinted.
|
|
4491
|
+
*/
|
|
4492
|
+
getNametagColor(): number;
|
|
4493
|
+
|
|
4494
|
+
/**
|
|
4495
|
+
* Disconnects this player from the server.
|
|
4496
|
+
* @param reason Optional reason shown to the disconnected player; omitting it uses the generic kicked reason.
|
|
4497
|
+
*/
|
|
4498
|
+
kick(reason?: string): void;
|
|
4499
|
+
|
|
4500
|
+
/**
|
|
4501
|
+
* Emits a named script event to this player's client connection.
|
|
4502
|
+
* @param eventName Client event name.
|
|
4503
|
+
* @param payloadJson Optional JSON payload forwarded verbatim to the owning client.
|
|
4504
|
+
*/
|
|
4505
|
+
emit(eventName: string, payloadJson?: string): void;
|
|
4506
|
+
|
|
4507
|
+
/**
|
|
4508
|
+
* Returns this player's current remote network address.
|
|
4509
|
+
* @returns Address string, or an empty string when the player or peer is unavailable.
|
|
4510
|
+
*/
|
|
4511
|
+
getIP(): string;
|
|
4512
|
+
|
|
4513
|
+
/**
|
|
4514
|
+
* Shows or hides the name over this player's head for every other player. The health bar has its own switch, and each player can still hide all nametags locally.
|
|
4515
|
+
* @param visible True to show this player's nametag to everyone, false to hide it.
|
|
4516
|
+
*/
|
|
4517
|
+
setNametagVisible(visible: boolean): void;
|
|
4518
|
+
|
|
4519
|
+
/**
|
|
4520
|
+
* Shows or hides the health bar under this player's nametag, leaving the name itself alone.
|
|
4521
|
+
* @param visible True to show the health bar under this player's name, false to hide it.
|
|
4522
|
+
*/
|
|
4523
|
+
setNametagHealthVisible(visible: boolean): void;
|
|
4524
|
+
|
|
4525
|
+
/**
|
|
4526
|
+
* Overrides the text drawn on this player's nametag.
|
|
4527
|
+
* @param text Text to show instead of the player's name; empty or omitted restores the name.
|
|
4528
|
+
*/
|
|
4529
|
+
setNametagText(text?: string): void;
|
|
4530
|
+
|
|
4531
|
+
/**
|
|
4532
|
+
* Tints the text on this player's nametag.
|
|
4533
|
+
* @param color Packed 0xAARRGGBB color.
|
|
4534
|
+
*/
|
|
4535
|
+
setNametagColor(color: number): void;
|
|
4536
|
+
}
|
|
4537
|
+
|
|
4538
|
+
interface BasePlayer extends Entity {}
|
|
4539
|
+
|
|
4540
|
+
/**
|
|
4541
|
+
* Calls a function once after a delay.
|
|
4542
|
+
* @param handler Function to call.
|
|
4543
|
+
* @param milliseconds Delay before the call.
|
|
4544
|
+
* @param args Arguments passed to the handler.
|
|
4545
|
+
* @returns Handle to pass to the matching clear function.
|
|
4546
|
+
*/
|
|
4547
|
+
function setTimeout(handler: (...args: any[]) => void, milliseconds?: number, ...args: unknown[]): Timeout;
|
|
4548
|
+
|
|
4549
|
+
/**
|
|
4550
|
+
* Calls a function repeatedly, waiting the delay between calls.
|
|
4551
|
+
* @param handler Function to call.
|
|
4552
|
+
* @param milliseconds Delay before the call.
|
|
4553
|
+
* @param args Arguments passed to the handler.
|
|
4554
|
+
* @returns Handle to pass to the matching clear function.
|
|
4555
|
+
*/
|
|
4556
|
+
function setInterval(handler: (...args: any[]) => void, milliseconds?: number, ...args: unknown[]): Timeout;
|
|
4557
|
+
|
|
4558
|
+
/**
|
|
4559
|
+
* Cancels a pending setTimeout.
|
|
4560
|
+
* @param handle Handle returned when the timer was scheduled; anything else is ignored.
|
|
4561
|
+
*/
|
|
4562
|
+
function clearTimeout(handle?: Timeout): void;
|
|
4563
|
+
|
|
4564
|
+
/**
|
|
4565
|
+
* Cancels a setInterval.
|
|
4566
|
+
* @param handle Handle returned when the timer was scheduled; anything else is ignored.
|
|
4567
|
+
*/
|
|
4568
|
+
function clearInterval(handle?: Timeout): void;
|
|
4569
|
+
|
|
4570
|
+
/**
|
|
4571
|
+
* Queues a function on the microtask queue.
|
|
4572
|
+
* @param callback Function to run once the current task completes.
|
|
4573
|
+
*/
|
|
4574
|
+
function queueMicrotask(callback: () => void): void;
|
|
4575
|
+
}
|
|
4576
|
+
|
|
4577
|
+
export {};
|