castle-web-cli 0.4.230 → 0.4.232
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/dist/castle-host/host.js +81 -0
- package/dist/devSaveStorage.d.ts +36 -0
- package/dist/devSaveStorage.js +469 -0
- package/dist/devSessionChild.js +22 -12
- package/dist/devSessionServer.js +8 -2
- package/dist/devSessionStorage.d.ts +9 -0
- package/dist/devSessionStorage.js +66 -1
- package/dist/init.js +1 -1
- package/dist/serve.js +5 -1
- package/dist/serverBundle.js +5 -3
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +148 -1
- package/kits/base/sdk/castle.d.ts +4 -0
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +15 -0
- package/kits/base/sdk/multiplayer.js +52 -4
- package/kits/base/sdk/save.d.ts +197 -0
- package/kits/base/sdk/save.js +525 -0
- package/kits/base/sdk/saveCoordinator.d.ts +39 -0
- package/kits/base/sdk/saveCoordinator.js +252 -0
- package/kits/base/sdk/server/storage.d.ts +3 -2
- package/kits/base/sdk/server/storage.js +25 -5
- package/kits/base/sdk/server/wrapper.d.ts +4 -0
- package/kits/base/sdk/server/wrapper.js +2 -0
- package/kits/base/sdk/store.d.ts +3 -2
- package/kits/base/sdk/store.js +5 -0
- package/kits/hub-game/CLAUDE.md +29 -4
- package/kits/hub-game/code/client/avatar.js +39 -0
- package/kits/hub-game/code/client/chat.js +12 -0
- package/kits/hub-game/code/client/chrome.js +237 -13
- package/kits/hub-game/code/client/grab.js +166 -7
- package/kits/hub-game/code/client/hats.js +26 -0
- package/kits/hub-game/code/client/hookLayer.js +36 -3
- package/kits/hub-game/code/client/hudClear.js +126 -0
- package/kits/hub-game/code/client/state.js +35 -1
- package/kits/hub-game/code/client/talk.js +10 -36
- package/kits/hub-game/code/client/tiers.js +505 -0
- package/kits/hub-game/code/client/together.js +144 -4
- package/kits/hub-game/code/client/wear.js +96 -14
- package/kits/hub-game/code/server/actors.js +5 -0
- package/kits/hub-game/code/server/grab.js +299 -13
- package/kits/hub-game/code/server/hub.js +162 -7
- package/kits/hub-game/code/server/manifest.js +80 -8
- package/kits/hub-game/code/server/npcs.js +21 -33
- package/kits/hub-game/code/server/party.js +75 -6
- package/kits/hub-game/code/server/say.js +8 -2
- package/kits/hub-game/code/server/wear.js +116 -11
- package/kits/hub-game/code/systems/hub.js +386 -21
- package/kits/hub-game/docs/contract.md +285 -19
- package/kits/hub-game/package.json +1 -1
- package/kits/hub-game/scripts/test-chat.mjs +32 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +511 -0
- package/kits/hub-game/scripts/test-grab.mjs +857 -3
- package/kits/hub-game/scripts/test-hats.mjs +229 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +721 -0
- package/kits/hub-game/scripts/test-hud-clear.mjs +676 -0
- package/kits/hub-game/scripts/test-manifest.mjs +122 -1
- package/kits/hub-game/scripts/test-npcs.mjs +34 -24
- package/kits/hub-game/scripts/test-party.mjs +108 -4
- package/kits/hub-game/scripts/test-say.mjs +59 -2
- package/kits/hub-game/scripts/test-tiers.mjs +854 -0
- package/kits/hub-game/scripts/test-together.mjs +33 -1
- package/kits/hub-game/scripts/test-try-on.mjs +940 -0
- package/kits/physics-2d/CLAUDE.md +2 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +127 -0
- package/kits/physics-2d/package.json +1 -1
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +298 -0
- package/kits/physics-3d/CLAUDE.md +531 -0
- package/kits/physics-3d/behaviors/Player.jsx +437 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +4 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +33 -1
- package/kits/physics-3d/engine3d/actornode.js +253 -0
- package/kits/physics-3d/engine3d/nearshadows.js +600 -0
- package/kits/physics-3d/engine3d/optimize.js +49 -0
- package/kits/physics-3d/engine3d/orbitinput.js +277 -0
- package/kits/physics-3d/engine3d/unchanged.js +153 -0
- package/kits/physics-3d/engine3d/world3d.js +525 -11
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/Player.before-orbit.mjs +310 -0
- package/kits/physics-3d/scripts/Scene3DPlayer.before-orbit.jsx +337 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +543 -0
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2105 -0
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +787 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +1073 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +667 -0
- package/kits/physics-3d/scripts/test-static-passes.mjs +459 -0
- package/kits/physics-3d/scripts/test-static-physics.mjs +128 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +633 -0
- package/kits/physics-3d/systems/physics3d.js +273 -9
- package/package.json +1 -1
|
@@ -155,7 +155,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
if (data?.k === 'hub-say') {
|
|
158
|
-
Say.message(
|
|
158
|
+
Say.message(sayDeps(h), player, data);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
if (data?.k === 'hub-party') {
|
|
@@ -198,9 +198,14 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
198
198
|
const dt = h.lastPlaceAt === null ? 0 : Math.min(0.25, (sim.timeMs - h.lastPlaceAt) / 1000);
|
|
199
199
|
h.lastPlaceAt = sim.timeMs;
|
|
200
200
|
reconcile(h);
|
|
201
|
+
// v1.28: a try-on on a player who went before saying hello goes too.
|
|
202
|
+
if (Wear.tryOnUsed(h)) {
|
|
203
|
+
Wear.pruneTries(h);
|
|
204
|
+
}
|
|
201
205
|
readResults(h);
|
|
202
206
|
arrivals(h);
|
|
203
207
|
enforceHolds(h);
|
|
208
|
+
enforceSettle(h);
|
|
204
209
|
Idle.tick(h);
|
|
205
210
|
enforceDuration(h);
|
|
206
211
|
catchFalls(h);
|
|
@@ -222,6 +227,10 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
222
227
|
sendAvatarOverrides(h);
|
|
223
228
|
Party.tick(partyDeps(h));
|
|
224
229
|
Wear.sendOverrides(h, blockedPairs(h));
|
|
230
|
+
// v1.28 `hub.tryOn`: nothing in a place that never calls it.
|
|
231
|
+
if (Wear.tryOnUsed(h)) {
|
|
232
|
+
Wear.sendTryOverrides(h, blockedPairs(h));
|
|
233
|
+
}
|
|
225
234
|
// Cabinet cards (v1.7): nothing in a place with no classic door.
|
|
226
235
|
Cabinets.send(h, (playerId) => namesOf(h, blockedPairs(h)?.get(playerId) ?? []));
|
|
227
236
|
Actors.flushHandovers(h, handovers);
|
|
@@ -259,6 +268,10 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
259
268
|
spawnTemplates: Actors.templatesOf(h),
|
|
260
269
|
// v1.6, only in a place that turns idle play on.
|
|
261
270
|
...Idle.fields(h),
|
|
271
|
+
// v1.27, only once the place keeps an object for a player.
|
|
272
|
+
...(h.keptFor.size > 0 ? { hubKept: Grab.keptOf(h) } : {}),
|
|
273
|
+
// v1.28, only while the place shows a try-on on someone.
|
|
274
|
+
...(h.trying.size > 0 ? tryingForJoin(h) : {}),
|
|
262
275
|
};
|
|
263
276
|
},
|
|
264
277
|
|
|
@@ -278,6 +291,14 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
278
291
|
for (const [field, value] of Object.entries(Idle.fields(h))) {
|
|
279
292
|
latch(h, field, value, out);
|
|
280
293
|
}
|
|
294
|
+
// v1.27 `hub.keepFor`: nothing until something is kept, then each change.
|
|
295
|
+
if (h.keptFor.size > 0 || h.sent.has('hubKept')) {
|
|
296
|
+
latch(h, 'hubKept', Grab.keptOf(h), out);
|
|
297
|
+
}
|
|
298
|
+
// v1.28 `hub.tryOn`: nothing until someone tries something on, then each change.
|
|
299
|
+
if (h.trying.size > 0 || h.sent.has('hubTry')) {
|
|
300
|
+
latchTrying(h, out);
|
|
301
|
+
}
|
|
281
302
|
return Object.keys(out).length ? out : null;
|
|
282
303
|
},
|
|
283
304
|
|
|
@@ -398,6 +419,8 @@ function newState(manifest) {
|
|
|
398
419
|
jumpAt: new Map(),
|
|
399
420
|
// playerId -> when they last asked where others are (`hub-where`)
|
|
400
421
|
whereAt: new Map(),
|
|
422
|
+
// playerId -> { at, facing, until }: bodies kept where a jump put them (`settle`)
|
|
423
|
+
settling: new Map(),
|
|
401
424
|
// `logStats`: when the window began, the CPU reading then, ticks since
|
|
402
425
|
stats: { at: null, cpu: null, ticks: 0 },
|
|
403
426
|
// playerId -> { avatar, clientAvatar, from, fromDeckId, party, carry, read,
|
|
@@ -426,7 +449,7 @@ function newState(manifest) {
|
|
|
426
449
|
// actorId -> { text, style, until }
|
|
427
450
|
labels: new Map(),
|
|
428
451
|
// playerId -> Map(actorId -> label): words over an actor for some players
|
|
429
|
-
// only (an NPC's reply to
|
|
452
|
+
// only (an NPC's reply to the player it answers), and what was last sent
|
|
430
453
|
labelsMe: new Map(),
|
|
431
454
|
sentLabelsMe: new Map(),
|
|
432
455
|
// playerId -> JSON of the avatars last sent to that player alone
|
|
@@ -498,6 +521,7 @@ function makeContext(h) {
|
|
|
498
521
|
const point = at ? { ...at } : { ...body.at };
|
|
499
522
|
const facing = facingDeg === undefined ? body.facing : facingDeg * DEG;
|
|
500
523
|
h.held.set(playerId, { at: point, facing });
|
|
524
|
+
Grab.stilled(h, playerId);
|
|
501
525
|
placeAt(h, playerId, point, facing);
|
|
502
526
|
},
|
|
503
527
|
release(playerId) {
|
|
@@ -514,10 +538,17 @@ function makeContext(h) {
|
|
|
514
538
|
}
|
|
515
539
|
},
|
|
516
540
|
hide(actorId) {
|
|
517
|
-
if (!isSceneActor(h, actorId)
|
|
541
|
+
if (!isSceneActor(h, actorId)) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
if (h.hidden.has(actorId)) {
|
|
545
|
+
// Hidden already, and kept since (`keepFor` takes a hidden object): hiding it again still ends that.
|
|
546
|
+
Grab.unkeep(h, actorId);
|
|
518
547
|
return;
|
|
519
548
|
}
|
|
520
549
|
h.hidden.add(actorId);
|
|
550
|
+
Grab.taken(h, actorId);
|
|
551
|
+
Grab.unkeep(h, actorId);
|
|
521
552
|
h.sim?.bodies.get(actorId)?.setEnabled(false);
|
|
522
553
|
},
|
|
523
554
|
show(actorId) {
|
|
@@ -531,6 +562,7 @@ function makeContext(h) {
|
|
|
531
562
|
mark: (playerId, spec) => Actors.mark(h, playerId, spec),
|
|
532
563
|
results: (playerId) => History.results(h, playerId),
|
|
533
564
|
wear: (playerId, spec) => wear(h, playerId, spec),
|
|
565
|
+
tryOn: (playerId, spec) => Wear.tryOn(h, playerId, spec),
|
|
534
566
|
tune: (playerId, spec) => Actors.tune(h, playerId, spec),
|
|
535
567
|
spawn: (fromActorId, at) => Actors.spawn(h, fromActorId, at, h.engine),
|
|
536
568
|
pose: (actorId) => Actors.pose(h, actorId),
|
|
@@ -547,6 +579,7 @@ function makeContext(h) {
|
|
|
547
579
|
seat: (playerId) => Idle.seat(h, playerId),
|
|
548
580
|
sound: (actorId, file, options) => Idle.sound(h, actorId, file, options),
|
|
549
581
|
holding: (playerId) => Grab.holding(h, playerId),
|
|
582
|
+
keepFor: (actorId, playerId) => Grab.keepFor(h, actorId, playerId),
|
|
550
583
|
end(playerIds) {
|
|
551
584
|
const ids = playerIds ?? [...(h.sim?.players.keys() ?? [])];
|
|
552
585
|
for (const playerId of ids) {
|
|
@@ -556,6 +589,8 @@ function makeContext(h) {
|
|
|
556
589
|
go: (door, playerIds, options) => go(h, door, playerIds, options),
|
|
557
590
|
pad: (door, playerIds) => gather(h, door, playerIds),
|
|
558
591
|
coming: (door) => Party.coming(h, door),
|
|
592
|
+
// v1.16: the other members of a player's party who are in this place now.
|
|
593
|
+
partyOf: (playerId) => Party.matesHere(h, playerId),
|
|
559
594
|
board: (door) => h.boards.get(door) ?? null,
|
|
560
595
|
doors: () => doors(h),
|
|
561
596
|
send: (playerId, data) => h.session?.send(playerId, data),
|
|
@@ -587,6 +622,8 @@ function hello(h, player, data) {
|
|
|
587
622
|
// holds none of the cabinet cards it was sent (v1.7).
|
|
588
623
|
if (data.again !== true) {
|
|
589
624
|
Cabinets.forget(h, player.playerId);
|
|
625
|
+
// v1.28: nothing in a place that never sent a try-on to one player alone.
|
|
626
|
+
Wear.joinedAfresh(h, player.playerId);
|
|
590
627
|
}
|
|
591
628
|
h.players.set(player.playerId, {
|
|
592
629
|
// Who this is, kept for `leave`: by then the session has forgotten them.
|
|
@@ -680,6 +717,7 @@ function forget(h, playerId) {
|
|
|
680
717
|
h.shut.delete(playerId);
|
|
681
718
|
h.jumpAt.delete(playerId);
|
|
682
719
|
h.whereAt.delete(playerId);
|
|
720
|
+
h.settling.delete(playerId);
|
|
683
721
|
Grab.forget(h, playerId);
|
|
684
722
|
Idle.forget(h, playerId);
|
|
685
723
|
Cabinets.forget(h, playerId);
|
|
@@ -700,6 +738,9 @@ async function shutdown(h) {
|
|
|
700
738
|
for (const playerId of [...h.players.keys()]) {
|
|
701
739
|
forget(h, playerId);
|
|
702
740
|
}
|
|
741
|
+
if (Wear.tryOnUsed(h)) {
|
|
742
|
+
Wear.endTries(h);
|
|
743
|
+
}
|
|
703
744
|
let timer = null;
|
|
704
745
|
await Promise.race([
|
|
705
746
|
Promise.resolve()
|
|
@@ -755,6 +796,9 @@ function arrivals(h) {
|
|
|
755
796
|
fromDeckId: entry.fromDeckId,
|
|
756
797
|
near: entry.near ?? null,
|
|
757
798
|
carry: entry.carry,
|
|
799
|
+
// How many went through the door together, by the client's word (the
|
|
800
|
+
// way back carries what the way out was sent with): 1 for anyone else.
|
|
801
|
+
party: entry.party ?? 1,
|
|
758
802
|
};
|
|
759
803
|
});
|
|
760
804
|
placeGroup(h, group.map((g) => g.playerId));
|
|
@@ -835,10 +879,14 @@ function placeBeside(h, playerId, otherId, used = new Map()) {
|
|
|
835
879
|
[Math.sin(f), Math.cos(f)],
|
|
836
880
|
];
|
|
837
881
|
const taken = used.get(otherId) ?? [];
|
|
838
|
-
|
|
882
|
+
// Never on or at the edge of a door's pad, theirs included (v1.19): a pad
|
|
883
|
+
// takes whoever stands on it into its game, and nobody goes into a game
|
|
884
|
+
// they did not choose. Beside a friend on a pad is a step or two further
|
|
885
|
+
// out, just off its edge and facing them, so joining them is that step.
|
|
886
|
+
for (const step of [1, 1.5, 2, 2.5, 3, 3.5]) {
|
|
839
887
|
const spot = dirs
|
|
840
888
|
.map(([dx, dz]) => ({ x: other.at.x + dx * NEAR_STEP_M * step, y: other.at.y, z: other.at.z + dz * NEAR_STEP_M * step }))
|
|
841
|
-
.find((at) => !taken.some((t) => Math.hypot(t.x - at.x, t.z - at.z) < 2 * BODY_RADIUS_M) && spotClear(h, at));
|
|
889
|
+
.find((at) => !taken.some((t) => Math.hypot(t.x - at.x, t.z - at.z) < 2 * BODY_RADIUS_M) && spotClear(h, at) && padAt(h, at, BODY_RADIUS_M) === null);
|
|
842
890
|
if (spot) {
|
|
843
891
|
taken.push(spot);
|
|
844
892
|
used.set(otherId, taken);
|
|
@@ -849,6 +897,19 @@ function placeBeside(h, playerId, otherId, used = new Map()) {
|
|
|
849
897
|
return false;
|
|
850
898
|
}
|
|
851
899
|
|
|
900
|
+
// The id of the pad actor a body at `at` stands on, or within `margin` of, or
|
|
901
|
+
// null. A pad takes a player whose middle is inside its radius.
|
|
902
|
+
function padAt(h, at, margin) {
|
|
903
|
+
for (const actor of h.actors) {
|
|
904
|
+
const pad = actor.components.HubPad;
|
|
905
|
+
const t = actor.components.Transform;
|
|
906
|
+
if (pad && t && !h.hidden.has(actor.id) && Math.hypot(at.x - t.x, at.z - t.z) <= (pad.radius ?? actor.components.Shape?.radius ?? 2.3) + margin) {
|
|
907
|
+
return actor.id;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
return null;
|
|
911
|
+
}
|
|
912
|
+
|
|
852
913
|
// Whether a standing body fits at `at`: no solid scene actor overlaps it, and
|
|
853
914
|
// on a scene with no ground (`fallY`) a solid's top is under its feet.
|
|
854
915
|
function spotClear(h, at) {
|
|
@@ -903,6 +964,38 @@ function placeAt(h, playerId, at, facing) {
|
|
|
903
964
|
body.body.setTranslation(body.at, true);
|
|
904
965
|
}
|
|
905
966
|
|
|
967
|
+
// After a jump (to a door's pad, beside a player) the body is kept where it
|
|
968
|
+
// was put for a moment. The client's move reports already on their way still
|
|
969
|
+
// name the spot it left, and the server's movement clamp lets each one pull
|
|
970
|
+
// the body a step back toward it: on a slow phone that dragged a player a
|
|
971
|
+
// metre or two off the pad they had just been put on, and the pad never
|
|
972
|
+
// counted them. This is not a hold (contract §8): the player is not in the
|
|
973
|
+
// `held` list, keeps what they carry and may jump again at once; the body is
|
|
974
|
+
// only put back each tick it drifts, until the client has caught up.
|
|
975
|
+
const SETTLE_MS = 600;
|
|
976
|
+
|
|
977
|
+
function settle(h, playerId) {
|
|
978
|
+
const body = h.sim?.players.get(playerId);
|
|
979
|
+
if (body) {
|
|
980
|
+
h.settling.set(playerId, { at: { ...body.at }, facing: body.facing, until: Date.now() + SETTLE_MS });
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
function enforceSettle(h) {
|
|
985
|
+
const nowMs = Date.now();
|
|
986
|
+
for (const [playerId, spot] of h.settling) {
|
|
987
|
+
const body = h.sim.players.get(playerId);
|
|
988
|
+
// Over, gone, or held by the place (a hold has its own spot).
|
|
989
|
+
if (!body || nowMs >= spot.until || h.held.has(playerId)) {
|
|
990
|
+
h.settling.delete(playerId);
|
|
991
|
+
continue;
|
|
992
|
+
}
|
|
993
|
+
if (Math.hypot(body.at.x - spot.at.x, body.at.z - spot.at.z) > HOLD_SLACK) {
|
|
994
|
+
placeAt(h, playerId, spot.at, spot.facing);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
|
|
906
999
|
// A held body that drifted is put back, every tick it drifts (contract §8).
|
|
907
1000
|
function enforceHolds(h) {
|
|
908
1001
|
for (const [playerId, hold] of h.held) {
|
|
@@ -1034,6 +1127,11 @@ function doorList(h) {
|
|
|
1034
1127
|
if (h.boards.get(door.id)?.featured === true) {
|
|
1035
1128
|
row.featured = true;
|
|
1036
1129
|
}
|
|
1130
|
+
// Whether someone can still be followed in: a game under way takes late
|
|
1131
|
+
// joiners only where its door says so.
|
|
1132
|
+
if (door.lateJoin === true) {
|
|
1133
|
+
row.late = true;
|
|
1134
|
+
}
|
|
1037
1135
|
if (door.maxPlayers === 1) {
|
|
1038
1136
|
row.solo = true;
|
|
1039
1137
|
} else if (door.minPlayers > 1) {
|
|
@@ -1061,9 +1159,10 @@ function doorJump(h, player, data) {
|
|
|
1061
1159
|
h.jumpAt.set(player.playerId, now);
|
|
1062
1160
|
// Onto the door's pad where it has one (v1.10), a little off its middle so
|
|
1063
1161
|
// two who jump there do not land in one spot; else in front of the door.
|
|
1064
|
-
const at = Party.padPoint(h, door, Math.floor(Math.random() * 6)) ?? frontOf(door);
|
|
1162
|
+
const at = Party.padPoint(h, door, Math.floor(Math.random() * 6), player.playerId) ?? frontOf(door);
|
|
1065
1163
|
const facing = ((door.t.rotationY ?? 0) + 180) * DEG;
|
|
1066
1164
|
placeAt(h, player.playerId, { x: at.x, y: 1.2, z: at.z }, facing);
|
|
1165
|
+
settle(h, player.playerId);
|
|
1067
1166
|
h.session?.send(player.playerId, { k: 'hub-jumped', facing });
|
|
1068
1167
|
}
|
|
1069
1168
|
|
|
@@ -1073,9 +1172,26 @@ function frontOf(door) {
|
|
|
1073
1172
|
return doorPoint({ x: t.x, z: t.z, rotationY: t.rotationY ?? 0 }, (Math.random() - 0.5) * JUMP_SPREAD, JUMP_OUT);
|
|
1074
1173
|
}
|
|
1075
1174
|
|
|
1175
|
+
// What `say.js` uses of this layer. A deck whose manifest sets `cues` (v1.23)
|
|
1176
|
+
// hands it more; any other hands it exactly what it did.
|
|
1177
|
+
function sayDeps(h) {
|
|
1178
|
+
const d = { h, blockedPairs, jumpDoors: doors };
|
|
1179
|
+
if (h.manifest.cues) {
|
|
1180
|
+
d.cues = true;
|
|
1181
|
+
d.goDoors = jumpDoors;
|
|
1182
|
+
d.proposalDoor = Party.proposalDoor;
|
|
1183
|
+
}
|
|
1184
|
+
return d;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1076
1187
|
// What `party.js` uses of this layer.
|
|
1077
1188
|
function partyDeps(h) {
|
|
1078
|
-
|
|
1189
|
+
// A party member put on a pad is settled there like any jump.
|
|
1190
|
+
const placeAndSettle = (state, playerId, at, facing) => {
|
|
1191
|
+
placeAt(state, playerId, at, facing);
|
|
1192
|
+
settle(state, playerId);
|
|
1193
|
+
};
|
|
1194
|
+
return { h, blockedPairs, usernameOf, placeAt: placeAndSettle, stand: Idle.stand, jumpDoors, front: frontOf };
|
|
1079
1195
|
}
|
|
1080
1196
|
|
|
1081
1197
|
// Where the players a client asks about are (the chrome's People list and its
|
|
@@ -1156,9 +1272,32 @@ function goTo(h, player, data) {
|
|
|
1156
1272
|
return;
|
|
1157
1273
|
}
|
|
1158
1274
|
h.jumpAt.set(playerId, now);
|
|
1275
|
+
settle(h, playerId);
|
|
1159
1276
|
h.session?.send(playerId, { k: 'hub-jumped', facing: h.sim.players.get(playerId).facing, to: otherId });
|
|
1160
1277
|
}
|
|
1161
1278
|
|
|
1279
|
+
// The players staying in a town are told who went through which door
|
|
1280
|
+
// (`hub-went`, v1.15), so a friend left behind can follow: each client shows
|
|
1281
|
+
// it only for its own friends and party. Never across a block, and not for a
|
|
1282
|
+
// cabinet (a classic deck is played alone).
|
|
1283
|
+
function tellWent(h, goingIds, door) {
|
|
1284
|
+
if (!h.sim || h.place.result || !goingIds.length) {
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
const going = new Set(goingIds);
|
|
1288
|
+
const pairs = blockedPairs(h);
|
|
1289
|
+
for (const [playerId, entry] of h.players) {
|
|
1290
|
+
if (!entry.arrived || going.has(playerId)) {
|
|
1291
|
+
continue;
|
|
1292
|
+
}
|
|
1293
|
+
const hidden = pairs?.get(playerId);
|
|
1294
|
+
const who = goingIds.filter((id) => !hidden?.has(id));
|
|
1295
|
+
if (who.length) {
|
|
1296
|
+
h.session?.send(playerId, { k: 'hub-went', players: who, door });
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1162
1301
|
function doors(h) {
|
|
1163
1302
|
const out = [];
|
|
1164
1303
|
for (const actor of h.actors) {
|
|
@@ -1276,6 +1415,7 @@ function go(h, door, playerIds, { instance } = {}) {
|
|
|
1276
1415
|
const prefix = deck ? `deck:${deck}/` : here;
|
|
1277
1416
|
const key =
|
|
1278
1417
|
typeof instance === 'string' && instance.startsWith(`${prefix}hub.${to}.`) ? instance : prefix + Place.devKey(to);
|
|
1418
|
+
tellWent(h, playerIds, door);
|
|
1279
1419
|
for (const playerId of playerIds) {
|
|
1280
1420
|
h.session?.send(playerId, {
|
|
1281
1421
|
k: 'hub-go',
|
|
@@ -1532,6 +1672,7 @@ function padFired(h, door, pad, users, fired) {
|
|
|
1532
1672
|
const group = Array.isArray(fired) ? fired : [];
|
|
1533
1673
|
// The group is ghost's; anyone of it still here goes, on the pad now or not.
|
|
1534
1674
|
const here = membersOf(h, h.session?.players.map((p) => p.playerId));
|
|
1675
|
+
tellWent(h, group.map((userId) => users.get(userId) ?? here.get(userId)).filter(Boolean), door);
|
|
1535
1676
|
for (const userId of group) {
|
|
1536
1677
|
const playerId = users.get(userId) ?? here.get(userId);
|
|
1537
1678
|
if (playerId) {
|
|
@@ -1869,6 +2010,20 @@ function latchWearing(h, out) {
|
|
|
1869
2010
|
}
|
|
1870
2011
|
}
|
|
1871
2012
|
|
|
2013
|
+
// `hubTry` (v1.28) the same way: in the snapshot only while a try-on is
|
|
2014
|
+
// shown, in deltas from the first one on, `{}` once when the last is gone.
|
|
2015
|
+
function tryingForJoin(h) {
|
|
2016
|
+
const trying = Wear.tryingOf(h, blockedPairs(h));
|
|
2017
|
+
return Object.keys(trying).length ? { hubTry: trying } : {};
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
function latchTrying(h, out) {
|
|
2021
|
+
const trying = Wear.tryingOf(h, blockedPairs(h));
|
|
2022
|
+
if (Object.keys(trying).length || h.sent.has('hubTry')) {
|
|
2023
|
+
latch(h, 'hubTry', trying, out);
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
|
|
1872
2027
|
function latch(h, field, value, out) {
|
|
1873
2028
|
const json = JSON.stringify(value);
|
|
1874
2029
|
if (h.sent.get(field) !== json) {
|
|
@@ -28,6 +28,16 @@ export const NEAREST_PLAYERS_CAP = 100;
|
|
|
28
28
|
// owned object's reported speed (40 m/s), so a throw is never cut short by it.
|
|
29
29
|
export const GRAB_DEFAULTS = { throwSpeed: 10, holdDistance: 1.4, holdHeight: 1.2 };
|
|
30
30
|
const GRAB_LIMITS = { throwSpeed: [1, 14, 'm/s'], holdDistance: [0.8, 3, 'metres'], holdHeight: [0, 2.5, 'metres'] };
|
|
31
|
+
// v1.22: a place may lengthen the reach at which an object is offered (from
|
|
32
|
+
// the object's near side, flat metres; 1.6 is the reach without it) and ask
|
|
33
|
+
// for a steady offer (`code/client/grab.js`). Neither has a default written
|
|
34
|
+
// into the place: a place that sets neither is sent what it always was. The
|
|
35
|
+
// top stays inside the server's GRAB_REACH (4 m, centre to centre), and the
|
|
36
|
+
// client also never offers an object whose centre is past 3 m.
|
|
37
|
+
export const GRAB_REACH_LIMITS = [1.6, 3, 'metres'];
|
|
38
|
+
// v1.25 `keepHeld`: a held object stays its holder's (`code/server/grab.js`).
|
|
39
|
+
// Kept only when true, like `steady`.
|
|
40
|
+
const GRAB_KEYS = [...Object.keys(GRAB_DEFAULTS), 'reach', 'steady', 'keepHeld'];
|
|
31
41
|
// Idle play (v1.6, §6): emotes, seats and the place's own sounds. Sounds are
|
|
32
42
|
// files of the deck, listed so the server can refuse any other name.
|
|
33
43
|
export const IDLE_KEYS = ['emotes', 'seats', 'sounds'];
|
|
@@ -35,6 +45,12 @@ export const SOUND_EXTS = ['.mp3', '.wav', '.m4a'];
|
|
|
35
45
|
export const MAX_SOUND_FILES = 16;
|
|
36
46
|
const SOUND_PATH = /^[A-Za-z0-9_@-][A-Za-z0-9_./@-]{0,199}$/;
|
|
37
47
|
|
|
48
|
+
// v1.26 `hud`: how a place's client lays the HUD out. `clear` keeps the HUD
|
|
49
|
+
// short and keeps what is drawn over the world out from under it
|
|
50
|
+
// (`code/client/hudClear.js`). The client's only; kept only when true, so a
|
|
51
|
+
// place without it is read and sent exactly as before.
|
|
52
|
+
const HUD_KEYS = ['clear'];
|
|
53
|
+
|
|
38
54
|
const PLACE_KEYS = [
|
|
39
55
|
'title',
|
|
40
56
|
'scene',
|
|
@@ -51,8 +67,14 @@ const PLACE_KEYS = [
|
|
|
51
67
|
'fallY',
|
|
52
68
|
'grab',
|
|
53
69
|
'idle',
|
|
70
|
+
'hud',
|
|
54
71
|
];
|
|
55
|
-
|
|
72
|
+
// `tiers` is the deck's, not a place's: the client's picture on a slow device
|
|
73
|
+
// (v1.21, `code/client/tiers.js`). The server reads nothing of it.
|
|
74
|
+
// `cues` is the deck's too (v1.23): a town that tells its players more about
|
|
75
|
+
// the friends and party they came with. Both halves read it, and a deck
|
|
76
|
+
// without it is sent and draws exactly what it did.
|
|
77
|
+
const TOP_KEYS = ['contract', 'places', 'tiers', 'cues', ...PLACE_KEYS];
|
|
56
78
|
|
|
57
79
|
const DEFAULT_SCENE = 'scenes/main.scene';
|
|
58
80
|
|
|
@@ -70,6 +92,12 @@ export function readManifest(castleJson, sceneExists = () => true) {
|
|
|
70
92
|
);
|
|
71
93
|
}
|
|
72
94
|
unknownKeys(hub, TOP_KEYS, 'hub', errors);
|
|
95
|
+
if (hub.tiers !== undefined && typeof hub.tiers !== 'boolean') {
|
|
96
|
+
errors.push('hub.tiers must be true or false.');
|
|
97
|
+
}
|
|
98
|
+
if (hub.cues !== undefined && typeof hub.cues !== 'boolean') {
|
|
99
|
+
errors.push('hub.cues must be true or false.');
|
|
100
|
+
}
|
|
73
101
|
const defaultScene =
|
|
74
102
|
typeof castleJson?.editor?.defaultPlayFile === 'string' ? castleJson.editor.defaultPlayFile : DEFAULT_SCENE;
|
|
75
103
|
const serverMax = Number.isInteger(castleJson?.server?.maxPlayers) ? castleJson.server.maxPlayers : MAX_PLAYERS_CAP;
|
|
@@ -97,7 +125,7 @@ export function readManifest(castleJson, sceneExists = () => true) {
|
|
|
97
125
|
}
|
|
98
126
|
}
|
|
99
127
|
}
|
|
100
|
-
return errors.length ? { errors, manifest: null } : { errors, manifest: { contract: CONTRACT_VERSION, places } };
|
|
128
|
+
return errors.length ? { errors, manifest: null } : { errors, manifest: { contract: CONTRACT_VERSION, cues: hub.cues === true, places } };
|
|
101
129
|
}
|
|
102
130
|
|
|
103
131
|
function readPlace(block, where, defaultScene, serverMax, sceneExists, errors, destinations, bundle) {
|
|
@@ -174,11 +202,35 @@ function readPlace(block, where, defaultScene, serverMax, sceneExists, errors, d
|
|
|
174
202
|
if (idle) {
|
|
175
203
|
place.idle = idle;
|
|
176
204
|
}
|
|
205
|
+
// v1.26: the HUD's layout, likewise carried only by a place that asks.
|
|
206
|
+
const hud = readHud(block.hud, `${where}.hud`, errors);
|
|
207
|
+
if (hud) {
|
|
208
|
+
place.hud = hud;
|
|
209
|
+
}
|
|
177
210
|
return place;
|
|
178
211
|
}
|
|
179
212
|
|
|
213
|
+
// `hud`: absent is none; an object turns each option on by name. `clear:
|
|
214
|
+
// false` (and an empty object) is the same as leaving it out.
|
|
215
|
+
function readHud(value, where, errors) {
|
|
216
|
+
if (value === undefined) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
if (!isObject(value)) {
|
|
220
|
+
errors.push(`${where} must be an object.`);
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
unknownKeys(value, HUD_KEYS, where, errors);
|
|
224
|
+
if (value.clear !== undefined && typeof value.clear !== 'boolean') {
|
|
225
|
+
errors.push(`${where}.clear must be true or false.`);
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
return value.clear === true ? { clear: true } : null;
|
|
229
|
+
}
|
|
230
|
+
|
|
180
231
|
// `grab`: absent or false is none; true is the defaults; an object sets any of
|
|
181
|
-
// them.
|
|
232
|
+
// them, and may add `reach` and `steady` (v1.22), which are kept only when
|
|
233
|
+
// set: `steady: false` is the same as leaving it out.
|
|
182
234
|
function readGrab(value, where, errors) {
|
|
183
235
|
if (value === undefined || value === false) {
|
|
184
236
|
return null;
|
|
@@ -190,7 +242,7 @@ function readGrab(value, where, errors) {
|
|
|
190
242
|
errors.push(`${where} must be true, false or an object.`);
|
|
191
243
|
return null;
|
|
192
244
|
}
|
|
193
|
-
unknownKeys(value,
|
|
245
|
+
unknownKeys(value, GRAB_KEYS, where, errors);
|
|
194
246
|
const grab = { ...GRAB_DEFAULTS };
|
|
195
247
|
for (const [key, [min, max, unit]] of Object.entries(GRAB_LIMITS)) {
|
|
196
248
|
if (value[key] === undefined) {
|
|
@@ -202,6 +254,24 @@ function readGrab(value, where, errors) {
|
|
|
202
254
|
grab[key] = value[key];
|
|
203
255
|
}
|
|
204
256
|
}
|
|
257
|
+
if (value.reach !== undefined) {
|
|
258
|
+
const [min, max, unit] = GRAB_REACH_LIMITS;
|
|
259
|
+
if (typeof value.reach !== 'number' || !(value.reach >= min && value.reach <= max)) {
|
|
260
|
+
errors.push(`${where}.reach must be a number of ${unit} from ${min} to ${max}.`);
|
|
261
|
+
} else {
|
|
262
|
+
grab.reach = value.reach;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (value.steady !== undefined && typeof value.steady !== 'boolean') {
|
|
266
|
+
errors.push(`${where}.steady must be true or false.`);
|
|
267
|
+
} else if (value.steady === true) {
|
|
268
|
+
grab.steady = true;
|
|
269
|
+
}
|
|
270
|
+
if (value.keepHeld !== undefined && typeof value.keepHeld !== 'boolean') {
|
|
271
|
+
errors.push(`${where}.keepHeld must be true or false.`);
|
|
272
|
+
} else if (value.keepHeld === true) {
|
|
273
|
+
grab.keepHeld = true;
|
|
274
|
+
}
|
|
205
275
|
return grab;
|
|
206
276
|
}
|
|
207
277
|
|
|
@@ -281,8 +351,8 @@ function readNpcs(value, destinations, bundle, where, errors) {
|
|
|
281
351
|
} else {
|
|
282
352
|
npcs.route = value.route;
|
|
283
353
|
}
|
|
284
|
-
// A place's server, not a client, decides who hears a turn
|
|
285
|
-
// a turn's audience only for a bundle that says so.
|
|
354
|
+
// A place's server, not a client, decides who hears a turn (nobody but its
|
|
355
|
+
// speaker): ghost admits a turn's audience only for a bundle that says so.
|
|
286
356
|
if (!isObject(bundle) || !Array.isArray(bundle.characters) || !bundle.characters.length) {
|
|
287
357
|
errors.push(`${where} needs a castle.json characterBundle with the characters its NPCs speak for.`);
|
|
288
358
|
} else if (bundle.conversation?.version !== 1 || bundle.conversation?.authority !== 'server') {
|
|
@@ -298,10 +368,10 @@ function readNpcs(value, destinations, bundle, where, errors) {
|
|
|
298
368
|
npcs.turnsPerMinute = intIn(value.turnsPerMinute, 6, 1, 30, `${where}.turnsPerMinute`, errors);
|
|
299
369
|
npcs.followSec = intIn(value.followSec, 120, 10, 600, `${where}.followSec`, errors);
|
|
300
370
|
if (value.disclosure !== undefined) {
|
|
371
|
+
// Read for decks that set it, and no longer acted on (v1.17): a player's
|
|
372
|
+
// conversation with a character is theirs alone, whatever this says.
|
|
301
373
|
if (value.disclosure !== 'participants' && value.disclosure !== 'world') {
|
|
302
374
|
errors.push(`${where}.disclosure must be "participants" or "world".`);
|
|
303
|
-
} else {
|
|
304
|
-
npcs.disclosure = value.disclosure;
|
|
305
375
|
}
|
|
306
376
|
}
|
|
307
377
|
return npcs;
|
|
@@ -497,6 +567,8 @@ export function publicPlace(id, place) {
|
|
|
497
567
|
...(place.grab ? { grab: { ...place.grab } } : {}),
|
|
498
568
|
// v1.6: likewise idle play.
|
|
499
569
|
...(place.idle ? { idle: { emotes: place.idle.emotes, seats: place.idle.seats, sounds: [...place.idle.sounds] } } : {}),
|
|
570
|
+
// v1.26: likewise the HUD's layout.
|
|
571
|
+
...(place.hud ? { hud: { ...place.hud } } : {}),
|
|
500
572
|
result: place.result
|
|
501
573
|
? { score: place.result.score ? { unit: place.result.score.unit, better: place.result.score.better } : null }
|
|
502
574
|
: null,
|
|
@@ -12,8 +12,11 @@
|
|
|
12
12
|
// grant, inside a per-character budget per minute; anywhere
|
|
13
13
|
// else, or over budget, the place's `npcLine` hook answers with
|
|
14
14
|
// an authored line and no model is called
|
|
15
|
-
// speech a reply is drawn over the body for
|
|
16
|
-
//
|
|
15
|
+
// speech a reply is drawn over the body for the player it answers
|
|
16
|
+
// and nobody else: what a player says to a character, and what
|
|
17
|
+
// it says back, is theirs alone (it is kept in ghost as that
|
|
18
|
+
// player's own conversation, and no turn names a listener).
|
|
19
|
+
// An authored line is the place's own words, for everyone
|
|
17
20
|
//
|
|
18
21
|
// notes what the place knows right now that the character should
|
|
19
22
|
// (a quest-giver's ledger, a barker's pad), from the place's
|
|
@@ -31,9 +34,8 @@
|
|
|
31
34
|
// message can neither start nor aim it.
|
|
32
35
|
|
|
33
36
|
const TALK_RANGE_M = 3.5;
|
|
34
|
-
// A speaker
|
|
35
|
-
|
|
36
|
-
const HEAR_RANGE_M = 6;
|
|
37
|
+
// A speaker who walks this far from the body has left the conversation.
|
|
38
|
+
const LEAVE_RANGE_M = 8;
|
|
37
39
|
const WALK_MPS = 2.6;
|
|
38
40
|
const FOLLOW_GAP_M = 1.6;
|
|
39
41
|
const SPEECH_MS = 7000;
|
|
@@ -54,7 +56,6 @@ const TURNS_KEPT = 128;
|
|
|
54
56
|
// this long, to see whether the character chose to follow someone.
|
|
55
57
|
const FOLLOW_POLL_MS = 2000;
|
|
56
58
|
const FOLLOW_WATCH_MS = 60_000;
|
|
57
|
-
const LISTENERS_MAX = 7;
|
|
58
59
|
// The place's notes for a turn (`npcContext`): at most NOTES_MAX characters,
|
|
59
60
|
// read for the body's speaker every NOTES_EVERY_MS, and any of the last
|
|
60
61
|
// NOTES_KEPT issued within NOTES_KEEP_MS is accepted (the speaker's client
|
|
@@ -70,7 +71,7 @@ export const NOTES_SAYS = '\n[The speaker says]\n';
|
|
|
70
71
|
export function makeNpcs(h) {
|
|
71
72
|
const n = {
|
|
72
73
|
bodies: new Map(),
|
|
73
|
-
// `${playerId}:${operationId}` -> { npc,
|
|
74
|
+
// `${playerId}:${operationId}` -> { npc, speaker, at, delivered }
|
|
74
75
|
turns: new Map(),
|
|
75
76
|
// playerId -> durable participant id, from that player's own inspect read
|
|
76
77
|
participants: new Map(),
|
|
@@ -253,11 +254,6 @@ function say(h, npc, text, { to, ttlMs = SPEECH_MS, about } = {}) {
|
|
|
253
254
|
h.npcLabel(npc.id, line, { style: 'speech', ttlMs, to, about });
|
|
254
255
|
}
|
|
255
256
|
|
|
256
|
-
// Whether a block hides these two players from each other.
|
|
257
|
-
function hiddenPair(h, a, b) {
|
|
258
|
-
return Boolean(h.blockedPairs?.()?.get(a)?.has(b));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
257
|
function distanceTo(h, npc, playerId) {
|
|
262
258
|
const player = h.sim?.players.get(playerId);
|
|
263
259
|
if (!player) {
|
|
@@ -306,8 +302,10 @@ function open(h, n, playerId, npcId) {
|
|
|
306
302
|
mind,
|
|
307
303
|
character: mind ? npc.character : null,
|
|
308
304
|
name: npc.name,
|
|
309
|
-
hearRange
|
|
310
|
-
|
|
305
|
+
// A client from before v1.17 named the players within `hearRange` as a
|
|
306
|
+
// turn's listeners: zero has it name nobody.
|
|
307
|
+
hearRange: 0,
|
|
308
|
+
disclosure: 'participants',
|
|
311
309
|
});
|
|
312
310
|
npc.notes = null;
|
|
313
311
|
if (!mind) {
|
|
@@ -449,8 +447,10 @@ function authoredSay(h, n, playerId, npcId, text) {
|
|
|
449
447
|
}
|
|
450
448
|
|
|
451
449
|
// A turn the host granted: the kit admits it only for the player this body is
|
|
452
|
-
// talking to, standing near it, with
|
|
453
|
-
//
|
|
450
|
+
// talking to, standing near it, with no listener of any kind (ghost keeps a
|
|
451
|
+
// turn's words for everyone its audience names, so a listener would be handed
|
|
452
|
+
// the speaker's words), inside the character's budget. Anything else is
|
|
453
|
+
// refused before a model is called.
|
|
454
454
|
async function admitTurn(h, n, turn) {
|
|
455
455
|
const speaker = turn.speaker.playerId;
|
|
456
456
|
// Several bodies may share one character (the town's barkers): the one this
|
|
@@ -467,14 +467,7 @@ async function admitTurn(h, n, turn) {
|
|
|
467
467
|
return;
|
|
468
468
|
}
|
|
469
469
|
const audience = turn.audience;
|
|
470
|
-
if (
|
|
471
|
-
audience.disclosure !== npcs.disclosure ||
|
|
472
|
-
audience.characterIds.length ||
|
|
473
|
-
audience.players.length > LISTENERS_MAX ||
|
|
474
|
-
audience.players.some((p) => distanceTo(h, npc, p.playerId) > HEAR_RANGE_M) ||
|
|
475
|
-
// A listener a block hides from the speaker never hears their conversation.
|
|
476
|
-
audience.players.some((p) => hiddenPair(h, speaker, p.playerId))
|
|
477
|
-
) {
|
|
470
|
+
if (audience.disclosure !== 'participants' || audience.characterIds.length || audience.players.length) {
|
|
478
471
|
turn.reject('HUB_NPC_AUDIENCE');
|
|
479
472
|
return;
|
|
480
473
|
}
|
|
@@ -510,7 +503,6 @@ async function admitTurn(h, n, turn) {
|
|
|
510
503
|
key,
|
|
511
504
|
npc: npc.id,
|
|
512
505
|
speaker,
|
|
513
|
-
recipients: new Set([speaker, ...audience.players.map((p) => p.playerId)]),
|
|
514
506
|
at: h.sim.timeMs,
|
|
515
507
|
delivered: false,
|
|
516
508
|
};
|
|
@@ -561,7 +553,7 @@ function trimTurns(h, n) {
|
|
|
561
553
|
}
|
|
562
554
|
|
|
563
555
|
// A player's own read. A status read that carries their turn's finished reply
|
|
564
|
-
// is when
|
|
556
|
+
// is when they see it over the body, and only they do: the reply is ghost's
|
|
565
557
|
// canonical text, never a client's message.
|
|
566
558
|
async function routeRead(h, n, request) {
|
|
567
559
|
const type = request.query?.type;
|
|
@@ -593,12 +585,8 @@ async function routeRead(h, n, request) {
|
|
|
593
585
|
if (npc.pending === turn) {
|
|
594
586
|
npc.pending = null;
|
|
595
587
|
}
|
|
596
|
-
if (typeof result.response === 'string' && result.response.trim()) {
|
|
597
|
-
|
|
598
|
-
const to = [...turn.recipients].filter(
|
|
599
|
-
(playerId) => h.sim?.players.has(playerId) && !hiddenPair(h, turn.speaker, playerId),
|
|
600
|
-
);
|
|
601
|
-
say(h, npc, unquote(result.response), { to, about: turn.speaker });
|
|
588
|
+
if (typeof result.response === 'string' && result.response.trim() && h.sim?.players.has(turn.speaker)) {
|
|
589
|
+
say(h, npc, unquote(result.response), { to: [turn.speaker], about: turn.speaker });
|
|
602
590
|
}
|
|
603
591
|
// The reply may have come with the character's follow action.
|
|
604
592
|
n.watchUntil = h.sim.timeMs + FOLLOW_WATCH_MS;
|
|
@@ -664,7 +652,7 @@ function moveBody(h, n, npc, dt) {
|
|
|
664
652
|
if (npc.talking) {
|
|
665
653
|
const gone = !h.sim.players.has(npc.talking.playerId);
|
|
666
654
|
const idle = now - npc.talking.at > IDLE_END_MS;
|
|
667
|
-
const far = distanceTo(h, npc, npc.talking.playerId) >
|
|
655
|
+
const far = distanceTo(h, npc, npc.talking.playerId) > LEAVE_RANGE_M;
|
|
668
656
|
if (gone || idle || far) {
|
|
669
657
|
endTalk(h, n, npc.id, npc.talking.playerId, gone ? 'left' : idle ? 'idle' : 'far');
|
|
670
658
|
}
|