@korial29/tiny-fps 0.138.0 → 0.140.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.
@@ -115,7 +115,23 @@ export declare const phalanges: (curl: number, i: number) => [Vec3, Vec3, Vec3];
115
115
  */
116
116
  export declare const hand: (out: number[], end: Vec3, f: Vec3, u: Vec3, th: Vec3, curl: number, tint: number[], point?: number, push?: number, to?: Vec3, bare?: number[],
117
117
  /** 0 to 1: the thumb out of the fist to CUP, up the side of what the palm carries. */
118
- cup?: number) => void;
118
+ cup?: number,
119
+ /** A near runner's hand: fewer sides, on the near sleeve's cuff, and none of the glove's small parts. */
120
+ lite?: boolean) => void;
121
+ /** What a hand does besides closing (hand()): the left index pointing, the right thumb pushing toward `to`, the left thumb cupped. */
122
+ export interface Grip {
123
+ point?: number;
124
+ push?: number;
125
+ to?: Vec3;
126
+ cup?: number;
127
+ }
128
+ /**
129
+ * Both hands of the skeleton `s` on its wrists, left then right, each closed `curls[i]` (hand()), in
130
+ * the glove `glove` with the bare fingertips `bare`; hers smaller about the wrist (HAND_F). The own
131
+ * body and the runners share it, so a runner's fist closes on a grip as the own one does. `lite` is
132
+ * a near runner's hand, `skip` a hand not drawn (the one a cut took off with its arm).
133
+ */
134
+ export declare const hands: (out: number[], s: Solved, build: number, curls: number[], glove: number[], bare: number[], { point, push, to, cup }?: Grip, lite?: boolean, skip?: number) => void;
119
135
  /** On a wall run the rail gun is put away, unless its bolt is going out. */
120
136
  export declare const stowed: (p: PlayerState) => boolean;
121
137
  export declare const createBody: (world?: World) => Body;
@@ -5,6 +5,8 @@ import type { Gait } from './gait';
5
5
  import type { Vec3 } from './mesh';
6
6
  import { solve } from './rig';
7
7
  import type { Quat } from './rig';
8
+ /** How closed the hand of an arm cut off is (hand() in body.ts). */
9
+ export declare const LIMP = 0.35;
8
10
  /** The height of the floor under (x, z) for something whose middle is at height y. */
9
11
  export type Ground = (x: number, y: number, z: number) => number;
10
12
  /** The first top under a point, none (it falls out of sight) off the roofs; without a world, the height `y0`. */
@@ -49,5 +51,8 @@ export declare const track: (r: {
49
51
  cut?: Piece;
50
52
  build?: number;
51
53
  }, dt: number, floor: Ground, fresh: boolean, tracer?: Pick<Tracer, "shock" | "spit">) => void;
52
- /** Appends the piece at level of detail `lod`, in `colors` (see palette()), sunk by `sink` metres with the body. */
53
- export declare const piece: (out: number[], c: Piece, colors: number[][], lod: number, sink: number, face?: ArrayLike<number>) => void;
54
+ /**
55
+ * Appends the piece at level of detail `lod`, in `colors` (see palette()), sunk by `sink` metres with
56
+ * the body; an arm with its hand, limp, in a space suit's glove on `suit`.
57
+ */
58
+ export declare const piece: (out: number[], c: Piece, colors: number[][], lod: number, sink: number, face?: ArrayLike<number>, suit?: boolean) => void;
@@ -29,9 +29,10 @@ export declare const eyesOf: (id: number, c?: Choice) => number[];
29
29
  * the shaved beard is on it, 0 to 1. `fem` (the woman's): redder lips, darker lashes.
30
30
  */
31
31
  export declare const palette: (jacket: number[], hair?: number[], eyes?: number[], suit?: boolean, tone?: number[], beard?: number, fem?: boolean) => number[][];
32
- /** The ring where the eye's sleeve ends in the glove, which body.ts starts the palm on, and its sides: the close ones (the eye's body is close). A thin wrist (3.2 cm until the user, 2026-11-09). */
32
+ /** The ring where a sleeve ends in the glove, which body.ts starts the palm on, and its sides: the close ones (the eye's body is close), and the near ones. A thin wrist (3.2 cm until the user, 2026-11-09). */
33
33
  export declare const CUFF: number[];
34
34
  export declare const CUFF_SIDES: number;
35
+ export declare const CUFF_NEAR: number;
35
36
  /**
36
37
  * A point of the man's skull at rest, `a` radians round it from the front (+ toward +x) at height
37
38
  * `y`, `off` metres out of it along its normal: what hair.ts lays a woman's hair on.
@@ -87,9 +88,9 @@ export declare const BUST = 0.028;
87
88
  /** Where it is fullest, metres up (the user, 2026-11-11: a little higher; it was 1.345). */
88
89
  export declare const BUST_Y = 1.37;
89
90
  /**
90
- * The skin at a level of detail: 0 far, 1 near (see DETAIL in mesh.ts), 2 near, headless and
91
- * handless, for the eye, 3 close (CLOSE in render.ts), twice the rings and half more sides, the
92
- * face carved finest. Built once.
91
+ * The skin at a level of detail: 0 far, 1 near (see DETAIL in mesh.ts), 2 near, headless, for the
92
+ * eye, 3 close (CLOSE in render.ts), twice the rings and half more sides, the face carved finest.
93
+ * Only the far one has hands, mittens: the others end at the wrists, where hands() goes. Built once.
93
94
  */
94
95
  export declare const body: (lod: number, build?: number) => Skin;
95
96
  /**
@@ -30,6 +30,8 @@ export interface Runner {
30
30
  grin: number;
31
31
  /** How far out the fist of a punch is, 0 to 1, eased. */
32
32
  jab: number;
33
+ /** How closed his hands are, left then right, eased toward grasp(). */
34
+ curls: number[];
33
35
  /** His face (expression.ts), and the seconds it has yet to live through: soldier() moves it once drawn, where the head's turn is known. */
34
36
  face: Face;
35
37
  dt: number;
@@ -95,6 +97,13 @@ export declare const lowered: (r: Runner) => number;
95
97
  * it), and the trunk twisting, bending and leaning through it (trunk()).
96
98
  */
97
99
  export declare const brandish: (from: Pose, p: PlayerState, prog: number, ph: number, t?: number) => Pose;
100
+ /**
101
+ * How closed the hands of `p` are, left then right (hand() in body.ts: 0 flat, 0.9 round a grip, 1
102
+ * a fist), as the own body closes its own: round what they hold and on the wheel, fists with
103
+ * nothing in them (the guard), a loose fist on a run, tighter at a sprint, open in the air, flat
104
+ * on a ledge, a wall or the floor, limp lying down.
105
+ */
106
+ export declare const grasp: (p: PlayerState, seat?: Seat) => number[];
98
107
  /** Seconds a runner the rail gun's bolt put down takes to come apart. */
99
108
  export declare const FRY = 0.9;
100
109
  /** How far a runner has come apart, 0 (whole, or not fried) to 1 (gone). */
@@ -1,3 +1,4 @@
1
+ import type { Flying } from './plasma';
1
2
  import type { FlagState, PlayerState } from './types';
2
3
  import type { World } from './world';
3
4
  /** A player as a bot sees him: the host's own state, no rewind. */
@@ -12,12 +13,36 @@ export interface Sight {
12
13
  others: Seen[];
13
14
  flags: readonly FlagState[];
14
15
  world: World;
16
+ /** The balls in flight, to get out of their way. */
17
+ balls?: readonly Flying[];
15
18
  }
16
19
  export type Intent = {
17
20
  keys: number;
18
21
  yaw: number;
19
22
  pitch: number;
20
23
  };
24
+ /** The skill of a room's bots when its rules give none: 0 (novice) to 7 (godlike), as in UT2004. */
25
+ export declare const SKILL = 4;
26
+ /**
27
+ * A bot's character, after UT2004's (Accuracy, ReactionTime, Jumpiness, StrafingAbility): drawn
28
+ * from its id, the same on every host, and scaled by the room's skill.
29
+ */
30
+ export interface Persona {
31
+ /** Radians its aim starts off a new target. */
32
+ miss: number;
33
+ /** Ticks a new target must be in sight before its first shot. */
34
+ react: number;
35
+ /** The most its aim turns in a tick. */
36
+ turn: number;
37
+ /** Its chance a tick, while it fights, of a jump; a dash aside is one in DASHY of them. */
38
+ jumpy: number;
39
+ /** The fewest ticks it strafes one way before it may turn back. */
40
+ strafe: number;
41
+ /** Its chance of dashing out of the way of a ball coming at it. */
42
+ duck: number;
43
+ }
44
+ /** The character of the bot `id` in a room of this skill. */
45
+ export declare const personaOf: (id: number, skill?: number) => Persona;
21
46
  export declare class Bot {
22
47
  readonly id: number;
23
48
  /** The route it prefers, an index of nav.ts's ROUTES. */
@@ -41,20 +66,62 @@ export declare class Bot {
41
66
  private since;
42
67
  private last;
43
68
  private world;
44
- constructor(id: number);
69
+ /** Where it looks walking, turned a little each tick; the side of its last detour; its last dash. */
70
+ private look;
71
+ private side;
72
+ private dashed;
73
+ private readonly persona;
74
+ /** Its own random numbers, seeded by its id: the same match plays the same on every host. */
75
+ private seed;
76
+ /** The way it strafes in a fight (1 left, -1 right) and the tick it may turn back. */
77
+ private strafing;
78
+ private turnBack;
79
+ /** The balls it has weighed, by shooter and count: it decides once whether to get out of the way. */
80
+ private weighed;
81
+ constructor(id: number, skill?: number);
82
+ /** A number in [0, 1) from its own sequence. */
83
+ private rnd;
45
84
  /** The input of this tick. */
46
85
  think(s: Sight): Intent;
47
- /** A side step while it fights, one way then the other, never toward a drop. */
86
+ /**
87
+ * How it moves while it fights, as UT2004's bots do: it strafes, one way for a while then the
88
+ * other, never toward a drop, and now and then jumps or dashes aside (its Jumpiness).
89
+ */
48
90
  private dodge;
91
+ /**
92
+ * Out of the way of a ball coming at it, as UT2004's bots dodge a rocket: an enemy ball that will
93
+ * pass within CLOSE of its chest in the next WARN seconds is weighed once, and with the bot's
94
+ * chance it dashes aside, across the ball's way and away from it, where the floor is open.
95
+ * Not on a leg of a route, nor in the air.
96
+ */
97
+ private evade;
49
98
  /** Where it wants to be. */
50
99
  private goalOf;
51
100
  private plan;
52
101
  /** The point it walks straight to now: the entry, a walk's end, or the goal past the last edge. */
53
102
  private target;
54
- /** The keys and yaw of the move, and whether the bot may look away from it to shoot. */
103
+ /**
104
+ * The keys and yaw of the move, whether the bot may look away from it to shoot, and whether the
105
+ * yaw must be kept to the letter (a leg of a route, as the tests fly it).
106
+ */
55
107
  private pilot;
108
+ /**
109
+ * A straight walk toward `want`: round a wall or a drop that hurts by the nearest turn that is open
110
+ * (on the side it last went round, first), up a box low enough to jump onto, and a dash when the
111
+ * way ahead is long, straight and open. It steps down onto a lower roof.
112
+ */
113
+ private walk;
114
+ /** DASH when the way ahead is long, open and wide and the last dash is a while back, else 0. */
115
+ private dash;
116
+ /** Whether the floor of a dash's run is wide: a metre each side of it, all along, no edge or beam. */
117
+ private wide;
118
+ /**
119
+ * Whether a body may walk `ahead` metres along `yaw` from where it stands: 'open', 'hop' over a box
120
+ * it can jump onto, or false at a wall, the void or a drop that hurts.
121
+ */
122
+ private open;
56
123
  private next;
57
- /** `keys`, with a jump when it has not got closer for a while; a new way when that does not help. */
124
+ /** Counts the progress toward the point it goes to: a new way when there has been none for a while. */
58
125
  private unstick;
59
126
  /** One step of a leg of a route, the way test/routes.ts flies it. */
60
127
  private fly;
@@ -432,6 +432,8 @@ export interface Rules {
432
432
  map?: string;
433
433
  /** Bots fill the room up to this many players while a human is in it (bot.ts). Absent, none. */
434
434
  bots?: number;
435
+ /** The bots' skill, 0 (novice) to 7 (godlike) as in UT2004 (bot.ts's SKILL when absent). */
436
+ botSkill?: number;
435
437
  }
436
438
  /**
437
439
  * The subset of WebSocket the client relies on. A real WebSocket (with
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.138.0",
5
+ "version": "0.140.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"