@korial29/tiny-fps 0.188.0 → 0.190.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/dist/server.js CHANGED
@@ -7624,6 +7624,9 @@ var Bot = class {
7624
7624
  /** The way it strafes in a fight (1 left, -1 right) and the tick it may turn back. */
7625
7625
  strafing = 1;
7626
7626
  turnBack = 0;
7627
+ /** Why it goes where it goes, and the keys it last pressed: for its view(). */
7628
+ why = "";
7629
+ keys = 0;
7627
7630
  /** The balls it has weighed, by shooter and count: it decides once whether to get out of the way. */
7628
7631
  weighed = /* @__PURE__ */ new Set();
7629
7632
  /** Its errand to the orbital station, when it has one. */
@@ -7646,6 +7649,37 @@ var Bot = class {
7646
7649
  }
7647
7650
  /** The input of this tick. */
7648
7651
  think(s) {
7652
+ const i = this.decide(s);
7653
+ this.keys = i.keys;
7654
+ return i;
7655
+ }
7656
+ /**
7657
+ * What it is up to, for a player who watches it (the client's bot view): its goal and why, the
7658
+ * way there as points (its entry, the nodes of the edges, the goal), the index of the point it
7659
+ * goes to now, what it is doing on the way, the enemy it fights and the keys it last pressed.
7660
+ */
7661
+ view() {
7662
+ const { entry, edges } = this.way;
7663
+ const r = (v) => [
7664
+ v[0],
7665
+ v[1],
7666
+ v[2]
7667
+ ].map((n) => Math.round(n * 10) / 10);
7668
+ const path = [...entry ? [entry] : [], ...edges.map((e) => this.nav.nodes[e.to])];
7669
+ if (this.goal) path.push(this.goal);
7670
+ const e = edges[this.leg];
7671
+ return {
7672
+ id: this.id,
7673
+ why: this.why,
7674
+ path: path.map(r),
7675
+ next: this.leg < 0 ? 0 : this.leg + (entry ? 1 : 0),
7676
+ doing: !this.goal ? "no way" : this.leg < 0 ? "to entry" : e ? e.leg?.k ?? "walk" : "to goal",
7677
+ foe: this.foe,
7678
+ keys: this.keys
7679
+ };
7680
+ }
7681
+ /** think()'s work. */
7682
+ decide(s) {
7649
7683
  const t = ++this.ticks;
7650
7684
  const p = s.me.state;
7651
7685
  this.world = s.world;
@@ -7802,10 +7836,19 @@ var Bot = class {
7802
7836
  h.z
7803
7837
  ];
7804
7838
  };
7805
- if (theirs.state === FLAG$1.CARRIED && theirs.by === me.id) return home.base;
7806
- if (this.sortie.board) return this.sortie.board;
7839
+ if (theirs.state === FLAG$1.CARRIED && theirs.by === me.id) {
7840
+ this.why = "flag home";
7841
+ return home.base;
7842
+ }
7843
+ if (this.sortie.board) {
7844
+ this.why = "station";
7845
+ return this.sortie.board;
7846
+ }
7807
7847
  const gear = s.kit?.gear ?? true;
7808
- if (p.ammo < 0 && gear && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) return home.rack;
7848
+ if (p.ammo < 0 && gear && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) {
7849
+ this.why = "gun rack";
7850
+ return home.rack;
7851
+ }
7809
7852
  const eye = [
7810
7853
  p.x,
7811
7854
  p.y + eyeHeight(p),
@@ -7816,26 +7859,45 @@ var Bot = class {
7816
7859
  o.state.y + 1.2,
7817
7860
  o.state.z
7818
7861
  ]));
7819
- if (prey) return at(prey.state);
7862
+ if (prey) {
7863
+ this.why = "hunt";
7864
+ return at(prey.state);
7865
+ }
7820
7866
  if (mine.state === FLAG$1.CARRIED) {
7821
7867
  const h = holder(mine);
7822
- if (h) return h;
7868
+ if (h) {
7869
+ this.why = "chase carrier";
7870
+ return h;
7871
+ }
7872
+ }
7873
+ if (mine.state === FLAG$1.DROPPED) {
7874
+ this.why = "return flag";
7875
+ return [
7876
+ mine.x,
7877
+ mine.y,
7878
+ mine.z
7879
+ ];
7880
+ }
7881
+ if (this.id % GUARD === 7) {
7882
+ this.why = "guard";
7883
+ return home.base;
7823
7884
  }
7824
- if (mine.state === FLAG$1.DROPPED) return [
7825
- mine.x,
7826
- mine.y,
7827
- mine.z
7828
- ];
7829
- if (this.id % GUARD === 7) return home.base;
7830
7885
  if (theirs.state === FLAG$1.CARRIED) {
7831
7886
  const h = holder(theirs);
7832
- if (h) return h;
7887
+ if (h) {
7888
+ this.why = "escort";
7889
+ return h;
7890
+ }
7833
7891
  }
7834
- if (theirs.state === FLAG$1.DROPPED) return [
7835
- theirs.x,
7836
- theirs.y,
7837
- theirs.z
7838
- ];
7892
+ if (theirs.state === FLAG$1.DROPPED) {
7893
+ this.why = "take flag";
7894
+ return [
7895
+ theirs.x,
7896
+ theirs.y,
7897
+ theirs.z
7898
+ ];
7899
+ }
7900
+ this.why = "take flag";
7839
7901
  return world.def.teams[1 - team].base;
7840
7902
  }
7841
7903
  plan(w, p, goal) {
@@ -8662,6 +8724,8 @@ var MAX_CATCH_UP = 20;
8662
8724
  var SPAWN_CLEAR = 2;
8663
8725
  /** Ticks before a rover can run the same player over again. */
8664
8726
  var SPLAT_COOLDOWN = 30;
8727
+ /** Ticks between two of a bot's views to the players who watch it. */
8728
+ var WATCH = 6;
8665
8729
  /** The names of the bots, in turn. */
8666
8730
  var BOT_NAMES = [
8667
8731
  "Ada",
@@ -8883,7 +8947,8 @@ var Room = class {
8883
8947
  else if (p && msg?.t === "map" && p === this.host() && Object.hasOwn(MAPS, msg.map)) {
8884
8948
  this.next = msg.map === this.mapName ? void 0 : msg.map;
8885
8949
  this.roster();
8886
- } else if (p && msg?.t === "body") {
8950
+ } else if (p && msg?.t === "watch") p.watch = typeof msg.id === "number" ? msg.id : void 0;
8951
+ else if (p && msg?.t === "body") {
8887
8952
  const { id, name, team, color } = p.info;
8888
8953
  const info = {
8889
8954
  id,
@@ -10039,6 +10104,14 @@ var Room = class {
10039
10104
  kit: this.kit(p)
10040
10105
  });
10041
10106
  p.seq = (p.seq ?? -1) + 1 & 65535;
10107
+ const watchers = players.filter((q) => q.watch === p.info.id);
10108
+ if (watchers.length && this.ticks % WATCH === 0) {
10109
+ const text = JSON.stringify({
10110
+ t: "bot",
10111
+ ...p.bot.view()
10112
+ });
10113
+ watchers.forEach((q) => q.conn.send(text));
10114
+ }
10042
10115
  this.apply(p, onWire({
10043
10116
  ...i,
10044
10117
  seq: p.seq,
@@ -7,7 +7,7 @@ export declare const MULTI = 4;
7
7
  export declare const QUICK: (16 | 14 | 18 | 15 | 17)[];
8
8
  /** Frags without going down between two lines of a run; the last line for every SPREE after. */
9
9
  export declare const SPREE = 5;
10
- export declare const RUNS: (20 | 21 | 22 | 23 | 19)[];
10
+ export declare const RUNS: (20 | 19 | 22 | 23 | 21)[];
11
11
  /** Shots of the gun in one run judged for the aim, and the share of them that must hit. */
12
12
  export declare const AIM_SHOTS = 12;
13
13
  export declare const AIM_SHARE = 0.75;
@@ -36,7 +36,7 @@ interface Region {
36
36
  legs?: boolean;
37
37
  /** No plate: the suit's dark ribbed cloth, a hair off the skin, with no wall (the gusset). */
38
38
  thin?: boolean;
39
- /** No plate: the ninja's belt, cloth in the team's colour a hair off the skin, with no wall. */
39
+ /** No plate: the ninja's sash, cloth in its own grey (SASH) a hair off the skin, with no wall. */
40
40
  belt?: boolean;
41
41
  }
42
42
  /**
@@ -147,11 +147,11 @@ export declare const THIGH: {
147
147
  at: number[];
148
148
  };
149
149
  /**
150
- * The ninja's belt (the user, 2026-11-13: a V on the sides, then deeper, on him and on her): its
151
- * bottom at the front's middle, under the buckle's middle (buckle.ts), rising `rise` to the hips,
152
- * then down round the back to `back` from the front's (over it, the back's last lames would meet
153
- * it); its height, and how far it stands off the skin. Cut as the gusset is, so drawn on every
154
- * map, armour or none (armor()'s `bare`).
150
+ * The ninja's belt, a sash (the user, 2026-11-17: the thin strip in a V of 2026-11-13 did not
151
+ * please): wide, nearly level, woven cloth knotted in front (buckle.ts). Its bottom at the front's
152
+ * middle, rising `rise` to the hips, then down round the back to `back` over the front's; its
153
+ * height, and how far it stands off the skin. Cut as the gusset is, so drawn on every map, armour
154
+ * or none (armor()'s `bare`).
155
155
  */
156
156
  export declare const BELT: {
157
157
  y: number;
@@ -160,6 +160,8 @@ export declare const BELT: {
160
160
  h: number;
161
161
  off: number;
162
162
  };
163
+ /** The sash's dark grey (the user, 2026-11-17: thinner, and black; then less black), and the face guard's (mask.ts: the same). */
164
+ export declare const SASH: number[];
163
165
  /**
164
166
  * The chest plate's armholes (the user, 2026-11-12: a triangle came through the plate under the
165
167
  * armpit; 2026-11-13: small triangles on its sides): the shoulder's skin stands out of the trunk's
@@ -249,44 +251,18 @@ export declare const ARMHOLE: {
249
251
  round: number[][];
250
252
  };
251
253
  /**
252
- * The ninja's back (the user, 2026-11-13: one big block, not pretty): two plates on each shoulder
253
- * blade, from `spine` degrees off the spine (a groove down it) to `a`, parted at the trunk's split
254
- * (`split`, 1.41 m: one plate across it showed the step between the two rings): the upper one up to
255
- * `top` by the spine, rising `rise` toward the shoulder and rounding off by `corner` at its outer
256
- * end; the lower one from `low` by the spine, rising `wing` to its outer end. Under them three lames
257
- * as the belly's, the first's top at `lames`, each `lame` high, their point `dip` down at the spine.
254
+ * The ninja's back piece (the user, 2026-11-17: one piece as the front's, where plates by halves
255
+ * stood each side of a spine of blocks, with a plate on each flank): its top is at `top` at the
256
+ * spine and rises by `rise` beside it, before it falls (SHIELD).
258
257
  */
259
258
  export declare const BACK: {
260
- spine: number;
261
- a: number;
262
- split: number[];
263
259
  top: number;
264
260
  rise: number;
265
- corner: number;
266
- low: number;
267
- wing: number;
268
- lames: number;
269
- lame: number;
270
- dip: number;
271
- };
272
- /**
273
- * The blocks down the spine, in the back's groove: how many, the first's top, their height and the
274
- * gap between two (none across the split), their half width (degrees) and how far they stand off
275
- * the skin.
276
- */
277
- export declare const SPINE: {
278
- n: number;
279
- top: number;
280
- h: number;
281
- gap: number;
282
- a: number;
283
- off: number;
284
- };
285
- /** The plates on the flanks: their heights, and the angles round from the front they span. */
286
- export declare const SIDES: {
287
- y: number[][];
288
- a: number[];
289
261
  };
262
+ /** How far round the lames go, from the front and from the back (degrees): they meet at the flank, a seam between them. */
263
+ export declare const FLANK = 88.5;
264
+ /** The back piece's shield: the angles off the spine between which its top falls. */
265
+ export declare const SHIELD: number[];
290
266
  /** How far the ninja's bracers stand off the forearm: half a plate's thickness. */
291
267
  export declare const BRACER = 0.006;
292
268
  export declare const REGIONS: Region[];
@@ -330,7 +306,13 @@ export declare const DOME: {
330
306
  h: number;
331
307
  };
332
308
  /** The ninja's vest has them a little smaller (the user, 2026-11-13): this much of their height. */
333
- export declare const SLIM = 0.8;
309
+ export declare const SLIM = 0.65;
310
+ /** The cut down the sternum of his chest piece: how deep at the middle, how far round each side (degrees), and how hollow its sides. */
311
+ export declare const NOTCH: {
312
+ deep: number;
313
+ a: number;
314
+ curve: number;
315
+ };
334
316
  /**
335
317
  * The marine's chest shell swells toward the shoulders (the user, 2026-11-13: the plate on over the
336
318
  * top of the pecs, near the shoulders): there the shoulder's skin stands out of the trunk's, and a
@@ -368,10 +350,11 @@ export declare const SIGN: {
368
350
  }[];
369
351
  /**
370
352
  * The ninja's details (the user, 2026-11-13: more detail on his armour), as DETAILS on his own
371
- * pieces: a seam down the chest piece; a rivet at each end of each lame;
372
- * a groove down each of the back's blade plates, a rivet at each end of each back lame; a band at each end of the bracers with
373
- * three slits between them; a groove down each shin guard, a rivet each side of its top. And by
374
- * build, the vents (VENTS) and 忍 on the left pec (SIGNS).
353
+ * pieces: a seam down the chest piece, what its cut down the sternum leaves of it (NOTCH); a rivet
354
+ * each side of each lame; a groove down each side of the back piece, a rivet each side of each back
355
+ * lame, as the belly's; a band at each end of the bracers with three slits between them; a groove
356
+ * down each shin guard, a rivet each side of its top. And by build, the vents (VENTS) and 忍 on the
357
+ * left pec (SIGNS).
375
358
  */
376
359
  export declare const NINJA_DETAILS: number[][];
377
360
  /**
@@ -1,9 +1,17 @@
1
1
  import type { Vec3 } from './mesh';
2
2
  import type { Quat } from './rig';
3
3
  import type { Out } from './verts';
4
- /** The height of its middle at rest, on the middle of the belt (0.99 to 1.03 m). */
4
+ /** The height of its middle at rest, on the middle of the sash. */
5
5
  export declare const BUCKLE_Y = 1.008;
6
- /** Its radius and depth (m). */
6
+ /** The knot's half width and its depth (m): what the vest's last lame is cut round (armor.ts). */
7
7
  export declare const BUCKLE: number[];
8
- /** Appends the buckle for build b's pelvis at `at` turned by `q`, its middle in `team`. */
9
- export declare const buckle: (out: Out, at: Vec3, q: Quat, b: number, team: number[]) => void;
8
+ /** Its ends: across from the knot's middle, lean from straight down (radians), length, half width. */
9
+ export declare const ENDS: number[][];
10
+ /** Appends the knot for build b's pelvis at `at` turned by `q`, its band in `team`. */
11
+ export declare const buckle: (out: Out, at: Vec3, q: Quat, b: number) => void;
12
+ /**
13
+ * Appends the sash's two ends under the knot, at the clock `t` (s) of a runner going at `speed`
14
+ * (m/s): ribbons of PIECES pieces, each leaning a little more than the one above it, by a wave that
15
+ * runs down it; out of the body and wider apart, faster, the faster he goes. Two faces each.
16
+ */
17
+ export declare const tails: (out: Out, at: Vec3, q: Quat, b: number, t: number, speed: number) => void;
@@ -37,4 +37,6 @@ export declare const flesh: (list: Pieces, s: Skin, pose: {
37
37
  /** The runner's id: his skin's marks. */
38
38
  seed?: number,
39
39
  /** The xenomorph's: its chitin. */
40
- chitin?: boolean) => void;
40
+ chitin?: boolean,
41
+ /** The ninja's: his suit is woven cloth. */
42
+ woven?: boolean) => void;
@@ -27,4 +27,6 @@ export declare const dressedOf: (n: number) => [Float64Array, Float64Array];
27
27
  /** Appends the guard and the ideograms on the head joint at `at` turned by `q` (see solve()), on the woman's smaller head with `build`, in the team's `color`. */
28
28
  export declare const mask: (out: Out, at: Vec3, q: Quat, build?: number, color?: number[],
29
29
  /** A far runner's: fewer quads. */
30
- far?: boolean) => void;
30
+ far?: boolean,
31
+ /** The guard's shell, when not in `color` (the user, 2026-11-17: the sash's grey); the ideograms stay in `color`. */
32
+ shell?: number[]) => void;
@@ -62,6 +62,19 @@ export declare const CHITIN = -1.17;
62
62
  * of SHINE's sheen, whose band it is in.
63
63
  */
64
64
  export declare const TUBE = -1.19;
65
+ /**
66
+ * Brushed, scratched metal (the ninja's guard and shoulder pads, the user, 2026-11-17: a metallic
67
+ * texture with scratches; it was a twill): within GLOSS's band of the shader, so it keeps the clear
68
+ * coat and the wear, with a fine brushing across it and long pale scratches two ways, on its rest
69
+ * place.
70
+ */
71
+ export declare const TWILL = -1.135;
72
+ /**
73
+ * Woven cloth (the ninja's hood, the user, 2026-11-17: a weave on it), on its rest place: a plain
74
+ * weave of threads round the piece's upright axis and up it, each over one and under the next, a
75
+ * bump and a tone, and a slow mottle. Lit like -1, whose band of the shader's SPEC row it is in.
76
+ */
77
+ export declare const WEAVE = -0.94;
65
78
  /**
66
79
  * Camera axes [right, up, forward]: forward is (-sin yaw cos pitch, sin pitch, -cos yaw cos pitch),
67
80
  * y up at roll 0. A positive roll leans the camera right: up tilts toward right.
@@ -67,16 +67,11 @@ export declare const BAND: {
67
67
  };
68
68
  /** A lame's quads: its top and underside, its inner end, its front and back edges. */
69
69
  export declare const LAME_QUADS: number;
70
- /**
71
- * The ninja's colours (the user, 2026-11-13: vary them): gold shoulder pads that shine (GILT; a darker
72
- * gold, the user), and a
73
- * collar of brown cloth, matte.
74
- */
75
- export declare const GOLD: number[];
70
+ /** The ninja's collar (the user, 2026-11-13: vary the colours): brown cloth, matte. */
76
71
  export declare const COLLAR_CLOTH: number[];
77
72
  /**
78
- * Appends the ninja's shoulder pads and his collar on the solved pose `s`, the pads in `color` (GOLD
79
- * for him), the collar in COLLAR_CLOTH;
73
+ * Appends the ninja's shoulder pads and his collar on the solved pose `s`, the pads in `color` (the
74
+ * sash's grey for him, brushed metal), the collar in COLLAR_CLOTH;
80
75
  * smaller on the woman (`build`). Or the `marine`'s shoulder bells, and no collar, with a band
81
76
  * round them in `band` (the astronaut's team colour on his white bells).
82
77
  */
@@ -43,6 +43,14 @@ export declare const FOV: number;
43
43
  export declare const ROVER_NEAR: number, ROVER_MID: number;
44
44
  /** A ship's, 14 m long: its cockpit and its struts within 45 m, its plain shape past 160 m. */
45
45
  export declare const SHIP_NEAR: number, SHIP_MID: number;
46
+ /**
47
+ * The layer of the ninja's boots' uppers, in WEAVE's band (woven as it is): the shader adds their
48
+ * details on the rest place (the user, 2026-11-17): a band wound round the ankle, a cord tied under
49
+ * the lip of the shaft, and the split of the toe.
50
+ */
51
+ export declare const BOOT_LAYER = -0.88;
52
+ /** The regions of a ninja's skin that are woven cloth: his suit, and his boots' uppers (the user, 2026-11-17: cloth, not leather). */
53
+ export declare const SUIT: number[];
46
54
  export declare const POST_FRAG = "#version 300 es\nprecision highp float;uniform sampler2D S[4];uniform vec4 Y;uniform float L;in vec2 U;out vec4 o;\nvec3 b(vec2 x){vec3 c=texture(S[0],x).rgb;return c*smoothstep(.9,2.,max(c.r,max(c.g,c.b)));}\n#define T(k)texture(S[0],U+Y.xy*(k)).rgb\nvoid main(){\nvec3 c;\nif(Y.z<1.)c=(b(U+Y.xy)+b(U-Y.xy)+b(U+Y.xy*vec2(1,-1))+b(U-Y.xy*vec2(1,-1)))/4.;\nelse if(Y.z<2.)c=T(0.)*.227+(T(1.3846)+T(-1.3846))*.3162+(T(3.2308)+T(-3.2308))*.0703;\nelse{\nc=texture(S[0],U).rgb+texture(S[1],U).rgb*1.3+texture(S[2],U).rgb*1.+texture(S[3],U).rgb*.7;\nvec2 q=U-.5;\nc=min(c,.6)+.4*(1.-exp(-max(c-.6,0.)/.4));\nfloat a=atan(q.y,q.x)*24.,h=fract(sin(floor(a)*12.9898)*43758.5453);\nc+=L*step(.85-.5*L,h)*sin(fract(a)*3.1416)*smoothstep(.2,.6,length(q))*fract(length(q)*3.-Y.w*.002+h*9.)*.22;\nc*=1.-(.7+.3*L)*dot(q,q);\nc=pow(max(c*vec3(.97,1.,1.03),0.),vec3(.92))+(fract(sin(dot(gl_FragCoord.xy+Y.w,vec2(12.9898,78.233)))*43758.5453)-.5)*.03;}\no=vec4(c,1);}";
47
55
  /**
48
56
  * Blinn-Phong strength and exponent: a row per TEX id in order (brick, tile, lava, stone, metal, wood,
@@ -42,6 +42,10 @@ export interface Flesh {
42
42
  seed?: number;
43
43
  /** The xenomorph's skin: its chitin (CHITIN in mesh.ts). */
44
44
  chitin?: boolean;
45
+ /** The ninja's skin: his suit is woven cloth (WEAVE in mesh.ts). */
46
+ woven?: boolean;
47
+ /** The ninja's armour: its trunk is quilted (render.ts). */
48
+ quilt?: boolean;
45
49
  }
46
50
  /** What the vertex shader reads by texel (flesh.ts): four floats each, 2048 a row. */
47
51
  export declare let data: Float32Array<ArrayBuffer>;
@@ -0,0 +1,14 @@
1
+ import type { BotView } from '../shared/bot';
2
+ export interface Watch {
3
+ /** The bot watched, if any. */
4
+ readonly id: number | undefined;
5
+ /** The next of these bots after the one watched (the first when none), or none after the last. */
6
+ next(bots: number[]): number | undefined;
7
+ /** What the bot watched is up to, as the room last told it. */
8
+ take(v: BotView): void;
9
+ /** Its way and its panel over the frame just drawn, `project` the renderer's; with no bot watched, nothing. */
10
+ draw(project: (x: number, y: number, z: number) => [number, number] | undefined, name: (id: number) => string): void;
11
+ /** Takes its canvas and panel off the screen. */
12
+ destroy(): void;
13
+ }
14
+ export declare const createWatch: (screen: HTMLElement) => Watch;
@@ -1,3 +1,4 @@
1
+ import type { Vec3 } from './nav';
1
2
  import type { Flying } from './plasma';
2
3
  import type { Errand } from './sortie';
3
4
  import type { Kit } from './kit';
@@ -27,6 +28,21 @@ export type Intent = {
27
28
  yaw: number;
28
29
  pitch: number;
29
30
  };
31
+ /** What a bot is up to, sent to a player who watches it (the room's 'bot' text). */
32
+ export interface BotView {
33
+ id: number;
34
+ /** Why it goes where it goes: 'take flag', 'chase carrier', 'gun rack'… */
35
+ why: string;
36
+ /** Its way: the entry, the nodes it goes through, then its goal; `next` is the point it goes to now. */
37
+ path: Vec3[];
38
+ next: number;
39
+ /** What it does on the way: 'to entry', a leg's kind ('go', 'leap', 'slide'), 'walk', 'to goal', 'no way'. */
40
+ doing: string;
41
+ /** The enemy it fights, -1 for none. */
42
+ foe: number;
43
+ /** The KEY bits it last pressed. */
44
+ keys: number;
45
+ }
30
46
  /** The skill of a room's bots when its rules give none: 0 (novice) to 7 (godlike), as in UT2004. */
31
47
  export declare const SKILL = 4;
32
48
  /**
@@ -82,6 +98,9 @@ export declare class Bot {
82
98
  /** The way it strafes in a fight (1 left, -1 right) and the tick it may turn back. */
83
99
  private strafing;
84
100
  private turnBack;
101
+ /** Why it goes where it goes, and the keys it last pressed: for its view(). */
102
+ private why;
103
+ private keys;
85
104
  /** The balls it has weighed, by shooter and count: it decides once whether to get out of the way. */
86
105
  private weighed;
87
106
  /** Its errand to the orbital station, when it has one. */
@@ -96,6 +115,14 @@ export declare class Bot {
96
115
  private rnd;
97
116
  /** The input of this tick. */
98
117
  think(s: Sight): Intent;
118
+ /**
119
+ * What it is up to, for a player who watches it (the client's bot view): its goal and why, the
120
+ * way there as points (its entry, the nodes of the edges, the goal), the index of the point it
121
+ * goes to now, what it is doing on the way, the enemy it fights and the keys it last pressed.
122
+ */
123
+ view(): BotView;
124
+ /** think()'s work. */
125
+ private decide;
99
126
  /**
100
127
  * How it moves while it fights, as UT2004's bots do: it strafes, one way for a while then the
101
128
  * other, never toward a drop, and now and then jumps or dashes aside (its Jumpiness).
@@ -1,3 +1,4 @@
1
+ import type { BotView } from './bot';
1
2
  import type { Choice, Input, PlayerInfo, Snapshot } from './types';
2
3
  /**
3
4
  * join: the first frame of a peer, with what he picked on the title screen (Choice: the body, BODY,
@@ -13,7 +14,12 @@ export type ClientText = ({
13
14
  } | ({
14
15
  t: 'body';
15
16
  body: number;
16
- } & Choice);
17
+ } & Choice)
18
+ /** Watch a bot (its id) and get what it is up to, or stop (no id). */
19
+ | {
20
+ t: 'watch';
21
+ id?: number;
22
+ };
17
23
  /** What a player did in a match, for the end screen: it carries the name and the team, which a leaver takes out of the roster. */
18
24
  export interface Result {
19
25
  id: number;
@@ -69,7 +75,11 @@ export type ServerText =
69
75
  t: 'end';
70
76
  score: [number, number];
71
77
  players: Result[];
72
- };
78
+ }
79
+ /** What the bot a player watches is up to, ten times a second. */
80
+ | ({
81
+ t: 'bot';
82
+ } & BotView);
73
83
  export declare const MSG_INPUT = 1;
74
84
  export declare const MSG_SNAPSHOT = 2;
75
85
  export declare const INPUT_BYTES = 12;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@korial29/tiny-fps",
3
3
  "description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
4
4
  "license": "Apache-2.0",
5
- "version": "0.188.0",
5
+ "version": "0.190.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"