@korial29/tiny-fps 0.137.0 → 0.139.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.
@@ -208,11 +208,20 @@ export declare const DETAILS: number[][];
208
208
  * three slits between them; a groove down each shin guard, a rivet each side of its top.
209
209
  */
210
210
  export declare const NINJA_DETAILS: number[][];
211
+ /**
212
+ * The astronaut's details (the user, 2026-11-13: more detail on his armour), as DETAILS, then 1 for
213
+ * the team's colour (ACCENT) or 0 dark: three rank bars on the left of the chest; a band of the
214
+ * team's colour round each wrist; a patch on the left biceps; a dark control panel on the left
215
+ * forearm with a row of keys beside it; a rivet at each corner of the belly's plate; two grooves
216
+ * down the front of each thigh plate.
217
+ */
218
+ export declare const ASTRO_DETAILS: number[][];
211
219
  /**
212
220
  * Appends the armour cut out of the skin `s` drawn into `out` from the float `from` on (skin()
213
221
  * writes three vertices per triangle of s.t, in order). Not `fine` (a runner not close by), curved
214
222
  * outlines follow the skin's own triangles, unrefined, and there are no scratches. `plate` is the
215
- * plates' colour (their walls a shade darker): white when absent. The `ninja` wears his own armour.
223
+ * plates' colour (their walls a shade darker): white when absent, the astronaut's, who has his own
224
+ * details in his team's colour `accent` too. The `ninja` wears his own armour.
216
225
  */
217
- export declare const armor: (out: number[], from: number, s: Skin, fine?: boolean, plate?: number[], ninja?: boolean) => void;
226
+ export declare const armor: (out: number[], from: number, s: Skin, fine?: boolean, plate?: number[], ninja?: boolean, accent?: number[]) => void;
218
227
  export {};
@@ -65,8 +65,10 @@ export declare const glazed: (a: number, y: number, grow?: number) => boolean;
65
65
  * The cheeks (the user, 2026-11-11, after a Mandalorian helmet, an idea and nothing copied): the
66
66
  * dome is whole but for a V carved in each cheek, no panel and no line round it. The V is upside
67
67
  * down: its top edge just under the slit, from the slot back across the cheek, its inner side
68
- * straight down along the slot (the helmet's middle line), its point low by the jaw. Each corner is
69
- * [u, v] on the outline (outline()).
68
+ * straight down along the slot (the helmet's middle line), its point low by the jaw. Its top edge
69
+ * rises to the back, under the ear (the user, 2026-11-13: the V wider toward the back, its branch by
70
+ * the eyes spread out, more angular and aggressive). Each corner is [u, v] on the outline
71
+ * (outline()).
70
72
  */
71
73
  export declare const CUT: {
72
74
  tip: [number, number];
@@ -43,11 +43,20 @@ export declare const BELL: {
43
43
  flare: number;
44
44
  fem: number;
45
45
  };
46
+ /**
47
+ * The band round the bell (the user, 2026-11-13: more detail on the astronaut): its rows of the
48
+ * bell's outer face, drawn in `pads()`'s `band` colour, and the shade that tells them.
49
+ */
50
+ export declare const BAND: {
51
+ rows: number[];
52
+ shade: number;
53
+ };
46
54
  /**
47
55
  * Appends the ninja's shoulder pads and his collar on the solved pose `s`, in the team's `color`;
48
- * smaller on the woman (`build`). Or the `marine`'s shoulder bells, and no collar.
56
+ * smaller on the woman (`build`). Or the `marine`'s shoulder bells, and no collar, with a band
57
+ * round them in `band` (the astronaut's team colour on his white bells).
49
58
  */
50
59
  export declare const pads: (out: number[], s: {
51
60
  pos: Vec3[];
52
61
  rot: Quat[];
53
- }, build?: number, color?: number[], marine?: boolean) => void;
62
+ }, build?: number, color?: number[], marine?: boolean, band?: number[]) => void;
@@ -0,0 +1,134 @@
1
+ import type { Flying } from './plasma';
2
+ import type { FlagState, PlayerState } from './types';
3
+ import type { World } from './world';
4
+ /** A player as a bot sees him: the host's own state, no rewind. */
5
+ export interface Seen {
6
+ id: number;
7
+ team: number;
8
+ state: PlayerState;
9
+ }
10
+ /** What a bot knows each tick. */
11
+ export interface Sight {
12
+ me: Seen;
13
+ others: Seen[];
14
+ flags: readonly FlagState[];
15
+ world: World;
16
+ /** The balls in flight, to get out of their way. */
17
+ balls?: readonly Flying[];
18
+ }
19
+ export type Intent = {
20
+ keys: number;
21
+ yaw: number;
22
+ pitch: number;
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;
46
+ export declare class Bot {
47
+ readonly id: number;
48
+ /** The route it prefers, an index of nav.ts's ROUTES. */
49
+ private prefer;
50
+ private nav;
51
+ private way;
52
+ /** The goal of the way, and the tick it was planned. */
53
+ private goal;
54
+ private planned;
55
+ /** -1 walking to the way's entry, then the edge it is on; edges.length walking to the goal. */
56
+ private leg;
57
+ private flight;
58
+ /** The best distance to the point it walks to, and the tick it was last bettered. */
59
+ private best;
60
+ private better;
61
+ private ticks;
62
+ /** Where it aims, the enemy it aims at and since when. */
63
+ private aim;
64
+ private pitch;
65
+ private foe;
66
+ private since;
67
+ private last;
68
+ private world;
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;
84
+ /** The input of this tick. */
85
+ think(s: Sight): Intent;
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
+ */
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;
98
+ /** Where it wants to be. */
99
+ private goalOf;
100
+ private plan;
101
+ /** The point it walks straight to now: the entry, a walk's end, or the goal past the last edge. */
102
+ private target;
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
+ */
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;
123
+ private next;
124
+ /** Counts the progress toward the point it goes to: a new way when there has been none for a while. */
125
+ private unstick;
126
+ /** One step of a leg of a route, the way test/routes.ts flies it. */
127
+ private fly;
128
+ /** Whether the edge after this one is a jump that wants the run-up of this one. */
129
+ private leapNext;
130
+ /** A leg is over: on to the next on its roof, else a new way from where the bot came down. */
131
+ private landed;
132
+ /** The look and the trigger at the enemy to fight now, if any. */
133
+ private fight;
134
+ }
@@ -0,0 +1,42 @@
1
+ import type { Leg } from './routes';
2
+ import type { World } from './world';
3
+ export type Vec3 = [number, number, number];
4
+ /** A way from one point to another: a leg of a route, or a straight walk when `leg` is absent. */
5
+ export interface Edge {
6
+ to: number;
7
+ leg?: Leg;
8
+ /** The route of the leg, an index of ROUTES; -1 for a walk or a way back up. */
9
+ route: number;
10
+ /** Seconds, about. */
11
+ cost: number;
12
+ }
13
+ export interface Nav {
14
+ nodes: Vec3[];
15
+ /** The ways out of each node. */
16
+ out: Edge[][];
17
+ /** Nodes a straight walk must not end at: the take-off of a run and jump, whose run-up is the leg before it. */
18
+ runUp: Set<number>;
19
+ }
20
+ /** The routes, fastest first: the Spine, Midtown, the Lowline. */
21
+ export declare const ROUTES: import("./routes").Route[];
22
+ /**
23
+ * Whether a body walks in a straight line from a to b, a step up or a drop of DROP at most: a floor
24
+ * under the middle and both sides of the body every half metre, and nothing in the way at the knees
25
+ * or the head from the height of a.
26
+ */
27
+ export declare const walkable: (w: World, a: Vec3, b: Vec3) => boolean;
28
+ /** Whether the bots' map of a world is built. */
29
+ export declare const navBuilt: (w: World) => boolean;
30
+ /** The bots' map of a world, built once per world. */
31
+ export declare const navOf: (w: World) => Nav;
32
+ /** A way across the map: walk straight to `entry`, follow the edges, then walk straight to the goal. */
33
+ export interface Way {
34
+ entry?: Vec3;
35
+ edges: Edge[];
36
+ }
37
+ /**
38
+ * The cheapest way from the point `a` to the point `b`. No entry when `a` walks straight to `b`, or
39
+ * when the map has no way. The legs of the routes other than `prefer` (an index of ROUTES) cost
40
+ * more, so bots that prefer different ones spread over the map.
41
+ */
42
+ export declare const path: (nav: Nav, w: World, a: Vec3, b: Vec3, prefer?: number) => Way;
@@ -33,6 +33,8 @@ export declare class Room {
33
33
  private next;
34
34
  /** Joins so far: each player's `since`. */
35
35
  private joins;
36
+ /** Ids of bots let go this tick, not given again before the next: the person who takes a bot's place would be drawn where it stood. */
37
+ private freed;
36
38
  /** Missing rules fall back to RULES. The map is the rules' one, unless a definition is given. */
37
39
  constructor(rules?: Partial<Rules>, def?: WorldDef);
38
40
  /** Every vehicle of the map parked afresh: whole, empty, on its spawn. */
@@ -43,12 +45,14 @@ export declare class Room {
43
45
  private host;
44
46
  /** The map the host picked, from now on: a new world and a new match, the players in it. */
45
47
  private load;
46
- /** Number of joined players. */
48
+ /** Number of joined players, the bots left out: a room of bots alone is empty. */
47
49
  get size(): number;
48
50
  /** A peer opened. Nothing is sent until it joins. */
49
51
  connect(conn: Conn): void;
50
52
  /** A text (JSON) or binary frame from a peer. */
51
53
  receive(conn: Conn, data: string | ArrayBuffer): void;
54
+ /** One input of a player, moved at once. An input beyond the bank is dropped, and not acked. */
55
+ private apply;
52
56
  /** A peer left: its player goes, the roster goes out again. */
53
57
  disconnect(conn: Conn): void;
54
58
  /**
@@ -253,6 +257,18 @@ export declare class Room {
253
257
  /** A new match: everyone back at a spawn of his team. */
254
258
  private restart;
255
259
  private players;
260
+ private humans;
261
+ /** Each bot's input of this tick, applied as a client's would be on arrival. */
262
+ private think;
263
+ /** The bots' map of the world, built when it loads rather than in the tick of a bot's first plan. */
264
+ private guide;
265
+ /** The players the bots fill the room up to: none with no human. */
266
+ private wanted;
267
+ /**
268
+ * Bots in and out so that there are `want` players, the humans first, the teams even: a bot comes
269
+ * on the smaller team and leaves the larger one.
270
+ */
271
+ private fill;
256
272
  private join;
257
273
  /** Each joined peer gets the full roster with its own id. */
258
274
  private roster;
@@ -0,0 +1,76 @@
1
+ export type P = [x: number, z: number];
2
+ /**
3
+ * One leg of a route, ending standing on a roof `y` metres up:
4
+ * - `go`: run (or walk) to a point;
5
+ * - `leap`: run to `at`, jump there and steer for `to`. `dash` and `double` are the steps after the
6
+ * jump (after the wall-run ends, when `run`) at which to dash forward and to jump again;
7
+ * - `slide`: run to `from`, then toward `to`, crouched between `c` metres along the way.
8
+ */
9
+ export type Leg = {
10
+ k: 'go';
11
+ to: P;
12
+ y: number;
13
+ sprint: boolean;
14
+ } | {
15
+ k: 'leap';
16
+ at: P;
17
+ to: P;
18
+ y: number;
19
+ dash?: number;
20
+ double?: number;
21
+ run?: boolean;
22
+ sprint: boolean;
23
+ /** In the air, forward or back so as to come down on `to`, a stone or a ledge: the bots' (bot.ts). */
24
+ land?: boolean;
25
+ } | {
26
+ k: 'slide';
27
+ from: P;
28
+ to: P;
29
+ c: [number, number];
30
+ y: number;
31
+ };
32
+ export declare const go: (x: number, z: number, y: number, sprint?: boolean) => Leg;
33
+ export declare const leap: (at: P, to: P, y: number, o?: {
34
+ dash?: number;
35
+ double?: number;
36
+ run?: boolean;
37
+ sprint?: boolean;
38
+ land?: boolean;
39
+ }) => Leg;
40
+ /** The mirror image of a leg across z = zed / 2. */
41
+ export declare const mirror: (l: Leg, zed: number) => Leg;
42
+ /** The mirror image of a leg across HIGHLINE's centre line. */
43
+ export declare const flip: (l: Leg) => Leg;
44
+ /** The same legs with no dash, double jump or wall-run: plain runs and jumps. */
45
+ export declare const plain: (legs: Leg[]) => Leg[];
46
+ export interface Route {
47
+ /** Legs to run before `out` when the trip starts at the flag, not at a spawn: room for the run-up. */
48
+ flag: Leg[];
49
+ out: Leg[];
50
+ in: Leg[];
51
+ mid: [x: number, y: number, z: number];
52
+ start: number;
53
+ }
54
+ /** The Spine: the tower's north edge across 11 m, the viaduct along its wall, the beam over the plaza. */
55
+ export declare const HIGH: Route;
56
+ /** Midtown: down onto the forecourt, two roofs, the plaza and its dais; back by the ledge ladders. */
57
+ export declare const MID: Route;
58
+ /** The Lowline: the stairs down the tower's east face, short gaps, the east terrace; back up. */
59
+ export declare const LOW: Route;
60
+ /** The legs of a trip from a spawn of one base to the other flag, and from that flag home. */
61
+ export declare const trip: (r: Route, from: "red" | "blue") => {
62
+ there: Leg[];
63
+ back: Leg[];
64
+ };
65
+ /**
66
+ * The ways back up after a miss, from the roof a fall lands on to the roof above (red's half):
67
+ * the terrace under the first gap of the Spine, the roof under the viaduct, the plaza under the
68
+ * beam, and the shortcut from the forecourt of Midtown up to the first Spine roof. Each starts with
69
+ * the player on the lower roof, standing at `from`.
70
+ */
71
+ export declare const UP: Record<'terrace' | 'viaduct' | 'plaza' | 'forecourt', {
72
+ from: [number, number, number];
73
+ legs: Leg[];
74
+ }>;
75
+ /** What is left of a way up from a roof `y` high: the legs from the first ledge above it, with the run-up to it. */
76
+ export declare const above: (legs: Leg[], y: number) => Leg[];
@@ -24,6 +24,8 @@ export interface PlayerInfo {
24
24
  hair?: number;
25
25
  /** ROLE (kit.ts) on the maps that offer it; absent, the map's default (the marine, the astronaut on the moon). */
26
26
  role?: number;
27
+ /** Played by the host (bot.ts). Absent for a human. */
28
+ bot?: boolean;
27
29
  }
28
30
  /** What a player picks on the title screen: his body, his skin, his haircut and his class (PlayerInfo's). */
29
31
  export type Choice = Pick<PlayerInfo, 'body' | 'tone' | 'hair' | 'role'>;
@@ -428,6 +430,10 @@ export interface Rules {
428
430
  timeLimit: number;
429
431
  /** The map's key in MAPS (maps.ts); an unknown one plays 'highline'. */
430
432
  map?: string;
433
+ /** Bots fill the room up to this many players while a human is in it (bot.ts). Absent, none. */
434
+ bots?: number;
435
+ /** The bots' skill, 0 (novice) to 7 (godlike) as in UT2004 (bot.ts's SKILL when absent). */
436
+ botSkill?: number;
431
437
  }
432
438
  /**
433
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.137.0",
5
+ "version": "0.139.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"