@korial29/tiny-fps 0.153.0 → 0.154.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.
@@ -46,6 +46,11 @@ export interface Tracer {
46
46
  shock(at: Vec3): void;
47
47
  /** One frame of the crackle around a shocked runner whose middle is `at`: a few bolts, flickering. */
48
48
  crackle(at: Vec3): void;
49
+ /**
50
+ * The orbital station's strike on a player at `at` (his feet): red lasers onto him for RAY
51
+ * seconds from round `from`, the station cannon's muzzle (straight down from the sky without).
52
+ */
53
+ strike(at: Vec3, from?: Vec3): void;
49
54
  /** One spark out of `at`, up and a little aside: a cut limb's stump spitting. */
50
55
  spit(at: Vec3): void;
51
56
  /** Where the own muzzle is now: its flash stays there, so that a kick of the view does not leave it behind. */
@@ -30,6 +30,11 @@ export type Beat = {
30
30
  who: number;
31
31
  by: number;
32
32
  at: Vec3;
33
+ }
34
+ /** The orbital station's mission (station.ts): `team` armed it, an enemy of it cancelled it, its lasers struck. */
35
+ | {
36
+ kind: 'armed' | 'cancelled' | 'strike';
37
+ team: number;
33
38
  };
34
39
  /**
35
40
  * The beats from snapshot `a` to `b`. Nothing at the first snapshot, nothing while a match is
@@ -72,6 +72,8 @@ export interface Hud {
72
72
  match(m: Pick<Snapshot, 'score' | 'clock' | 'over' | 'flags'>, who: (id: number) => string): void;
73
73
  /** The markers of this frame (see marks.ts), in the order given; the ones before are removed. */
74
74
  marks(list: Mark[]): void;
75
+ /** The orbital station's mission line (mission.ts), `hot` when urgent; none hides it. */
76
+ mission(text?: string, hot?: boolean): void;
75
77
  /** The dark rim of a space helmet's visor around the screen: on while the own player wears one, off otherwise. */
76
78
  visor(on: boolean): void;
77
79
  /** The red vignette of a tackle, 0 (none) to 1 (full). */
@@ -105,7 +107,7 @@ export interface Hud {
105
107
  */
106
108
  duel(lead: number | undefined): void;
107
109
  /** The state of being down: `level` 0 (up) to 1 hides or greys the screen, `left` seconds till the respawn. */
108
- down(level: number, left: number): void;
110
+ down(level: number, left: number, what?: string): void;
109
111
  /** A line in the middle of the top of the screen in `team`'s colour, for a few seconds; a newer one replaces it. */
110
112
  banner(text: string, team?: number): void;
111
113
  /** The own frags this match, top left. */
@@ -153,7 +155,6 @@ export interface ShipPanel {
153
155
  export declare const warning: (up: number, out: number) => string;
154
156
  /** The ship's height on its panel: metres under the edge of space, kilometres in orbit. */
155
157
  export declare const height: (alt: number) => string;
156
- /** Milliseconds a banner stays, and a hit marker. */
157
158
  export declare const BANNER_MS = 2800;
158
159
  /** Milliseconds an own frag's name and award stay, and a line of the kill feed; the feed's lines. */
159
160
  export declare const FRAG_MS = 2400;
@@ -1,9 +1,9 @@
1
1
  import type { FlagState } from '../shared/types';
2
2
  import type { Vec3 } from './mesh';
3
3
  export interface Mark {
4
- /** The team whose flag or base it is: its colour. */
4
+ /** The team whose flag or base it is: its colour; -1 for the station's, in amber. */
5
5
  team: number;
6
- kind: 'flag' | 'base';
6
+ kind: 'flag' | 'base' | 'station' | 'post';
7
7
  /** Where it is on the screen, in [0, 1] from the top left. */
8
8
  x: number;
9
9
  y: number;
@@ -32,6 +32,11 @@ export interface MarkScene {
32
32
  where(id: number): Vec3 | undefined;
33
33
  /** A world point on the screen as of the last frame, or undefined behind the camera. */
34
34
  project(x: number, y: number, z: number): [number, number] | undefined;
35
+ /** The orbital mission's marker: the station or its command post, and where (mission.ts). */
36
+ goal?: {
37
+ kind: 'station' | 'post';
38
+ at: Vec3;
39
+ };
35
40
  }
36
41
  /**
37
42
  * The markers of a frame: each flag but one the player carries, and the own base while he carries
@@ -0,0 +1,13 @@
1
+ import type { StationDef } from '../shared/station';
2
+ import type { StationState } from '../shared/types';
3
+ import type { Vec3 } from './mesh';
4
+ /** The line, whether it is urgent, and what the marker points at: the station from outside, its console from inside. */
5
+ export interface Brief {
6
+ text: string;
7
+ hot?: boolean;
8
+ to?: 'station' | 'post';
9
+ }
10
+ /** The brief of the own player of `team`: `flying` a ship, `inside` the station. */
11
+ export declare const brief: (st: StationState | undefined, team: number, flying: boolean, inside: boolean) => Brief | undefined;
12
+ /** Where a brief's marker points: the middle of the hangar, or the top of the console. */
13
+ export declare const goal: ({ post: [lo, hi], hall: [a, b] }: StationDef, to: Brief["to"]) => Vec3;
@@ -0,0 +1,17 @@
1
+ import type { StationDef } from '../shared/station';
2
+ import type { Vec3 } from './mesh';
3
+ import type { Light } from './lights';
4
+ export declare const satellite: ({ hall: [lo], post, hull: [cx, y0, cz, y1], gun, }: StationDef) => number[];
5
+ /**
6
+ * The station's inside (the user, 2026-11-14): pipes along the hangar's walls and ducts under its
7
+ * roof, a painted landing circle with its lights where each team's ship sets down (sortie.ts lands
8
+ * there), the way out to space lit (a green bar across each mouth's edge and up its sides, amber
9
+ * chevrons on the deck toward it), lamps under the roof, and in the command room consoles with
10
+ * glowing screens. The hangar's x0..x1 inside its walls, its mouths at z0 and z1.
11
+ */
12
+ export declare const hangar: ({ hall: [lo], post, hull: [cx, , cz] }: StationDef) => number[];
13
+ /**
14
+ * The station's lamps as lights, while the eye is near it: three under the hangar's roof and one in
15
+ * the command room, cold white; red and pulsing while a strike counts down (`alarm`).
16
+ */
17
+ export declare const lamps: ({ hall: [lo], post, hull: [cx, , cz] }: StationDef, eye: Vec3, alarm: boolean, t: number) => Light[];
@@ -115,6 +115,9 @@ export declare const SOUND: {
115
115
  */
116
116
  readonly AMMO: 56;
117
117
  readonly ARMOR: 57;
118
+ /** The orbital station's mission: the alarm of a strike armed, and the strike's lasers from the sky. */
119
+ readonly ALARM: 58;
120
+ readonly STRIKE: 59;
118
121
  };
119
122
  /**
120
123
  * The sounds of the game: one entry per sound, its voices layered, in SOUND order. A low-passed
@@ -1,4 +1,5 @@
1
1
  import type { Flying } from './plasma';
2
+ import type { Errand } from './sortie';
2
3
  import type { FlagState, PlayerState } from './types';
3
4
  import type { World } from './world';
4
5
  /** A player as a bot sees him: the host's own state, no rewind. */
@@ -15,6 +16,8 @@ export interface Sight {
15
16
  world: World;
16
17
  /** The balls in flight, to get out of their way. */
17
18
  balls?: readonly Flying[];
19
+ /** What the room asks of it at the orbital station (sortie.ts). */
20
+ errand?: Errand;
18
21
  }
19
22
  export type Intent = {
20
23
  keys: number;
@@ -78,6 +81,8 @@ export declare class Bot {
78
81
  private turnBack;
79
82
  /** The balls it has weighed, by shooter and count: it decides once whether to get out of the way. */
80
83
  private weighed;
84
+ /** Its errand to the orbital station, when it has one. */
85
+ private sortie;
81
86
  constructor(id: number, skill?: number);
82
87
  /** A number in [0, 1) from its own sequence. */
83
88
  private rnd;
@@ -35,6 +35,14 @@ export declare class Room {
35
35
  private joins;
36
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
37
  private freed;
38
+ /** The orbital station's mission, on a map with a station. */
39
+ private station;
40
+ /** The players its strike disintegrated: held down until its STATION.OUT is over. */
41
+ private out;
42
+ /** The bot of each team on an errand to the station, or -1 (errands()). */
43
+ private pilots;
44
+ /** Ticks each vehicle has stood empty in the station with nobody in it, by index in `rovers`. */
45
+ private idle;
38
46
  /** Missing rules fall back to RULES. The map is the rules' one, unless a definition is given. */
39
47
  constructor(rules?: Partial<Rules>, def?: WorldDef);
40
48
  /** Every vehicle of the map parked afresh: whole, empty, on its spawn. */
@@ -172,6 +180,15 @@ export declare class Room {
172
180
  */
173
181
  private heal;
174
182
  /** The rover `p` is seated in and his seat (0 the driver's), or nothing on foot. */
183
+ /**
184
+ * A press of USE on foot at the station's console: it arms the mission for his team, or cancels
185
+ * the other team's. False when he is not there to press it.
186
+ */
187
+ private press;
188
+ /** The countdown ran out: every player of the other team is disintegrated, one already down too. */
189
+ private strike;
190
+ /** The disintegrated lie until the strike's wait is over: then their own count puts them back. */
191
+ private hold;
175
192
  private seatOf;
176
193
  /** Takes `p` off his seat: in the air where he sat. */
177
194
  private unseat;
@@ -265,6 +282,19 @@ export declare class Room {
265
282
  private humans;
266
283
  /** Each bot's input of this tick, applied as a client's would be on arrival. */
267
284
  private think;
285
+ /**
286
+ * A ship left empty in the station once nobody is in it any more goes home after STATION.RECALL
287
+ * ticks, parked afresh on its pad: its team can fly the mission again.
288
+ */
289
+ private recall;
290
+ /**
291
+ * The bots' errands at the orbital station (sortie.ts): at most one pilot a team, sent while the
292
+ * mission waits or the other team's strike counts down, the nearest to its team's ship of its bots
293
+ * that are up and carry no flag, when that ship stands free on its pad; one in the station keeps
294
+ * guard while its own team's strike counts down. A bot in its ship or in the station with no
295
+ * errand goes home.
296
+ */
297
+ private errands;
268
298
  /** The bots' map of the world, built when it loads rather than in the tick of a bot's first plan. */
269
299
  private guide;
270
300
  /** The players the bots fill the room up to: none with no human. */
@@ -0,0 +1,71 @@
1
+ import type { StationDef } from './station';
2
+ import type { PlayerState, Rover } from './types';
3
+ import type { Spawn } from './world';
4
+ type Vec3 = [number, number, number];
5
+ export type Intent = {
6
+ keys: number;
7
+ yaw: number;
8
+ pitch: number;
9
+ };
10
+ /**
11
+ * What the room asks of a bot: its team's ship and the pad it stands on, and `go` 'press' (arm the
12
+ * mission, or cancel the enemy's strike), 'guard' (its team's strike counts down: stay at the post),
13
+ * or nothing (the errand is over: back home).
14
+ */
15
+ export interface Errand {
16
+ def: StationDef;
17
+ team: number;
18
+ ship: Rover;
19
+ home: Spawn;
20
+ go?: 'press' | 'guard';
21
+ }
22
+ /**
23
+ * The flight: metres out from the mouth where it lines up; how high over the deck it flies in, over a pad it starts down; the top speed it asks, the share of
24
+ * the distance it slows to near a stop, the nose's error past which it does not thrust, the
25
+ * fastest it climbs or sinks and the braking it counts on, how far under the cannon's muzzle it
26
+ * comes down out there, and where it lands: east of the hangar's middle, toward the command room's
27
+ * door, and from the station's middle along z.
28
+ */
29
+ export declare const SORTIE: {
30
+ OUT: number;
31
+ ABOVE: number;
32
+ PAD: number;
33
+ FAST: number;
34
+ EASE: number;
35
+ AIM: number;
36
+ CLIMB: number;
37
+ SETTLE: number;
38
+ CLEAR: number;
39
+ EAST: number;
40
+ LAND: number;
41
+ };
42
+ /** A team's way into the station: in front of its mouth (red's is the +z one), then down on the deck inside. */
43
+ export declare const approach: ({ hull: [cx, , cz], post }: StationDef, team: number) => [Vec3, Vec3];
44
+ /**
45
+ * The keys and look that fly the ship `r` toward `to`: the nose on it, thrust while it points there
46
+ * and the speed is under what it asks (all it can far away, easing to a stop when `stop`), the
47
+ * brake past it, the lift to hold the height near it.
48
+ */
49
+ export declare const steer: (r: Rover, to: Vec3, stop: boolean) => Intent;
50
+ /** The bot's own memory of an errand: the stage of its flight. */
51
+ export declare class Sortie {
52
+ private stage;
53
+ private landed;
54
+ /** The errand its stages are of: a change of mind starts them again. */
55
+ private going;
56
+ /** The points of its flight, set when it starts: each a point and whether it stops there. */
57
+ private route;
58
+ /** Where it walks to on the ground to board, for its own way finding; none when it is not boarding. */
59
+ board: Vec3 | undefined;
60
+ /**
61
+ * The input of this tick for the bot `id` on `p` with errand `e`, or none: then it plays as usual
62
+ * (and walks to `board` if set). `t` is its tick, for presses.
63
+ */
64
+ think(id: number, p: PlayerState, e: Errand, t: number): Intent | undefined;
65
+ /**
66
+ * Up to the station and in, or home: out of the hangar by the mouth ahead, to over the pad and
67
+ * down. Landed at the end, out.
68
+ */
69
+ private fly;
70
+ }
71
+ export {};
@@ -0,0 +1,94 @@
1
+ import type { PlayerState, StationState } from './types';
2
+ import type { Brush, Door } from './world';
3
+ type Vec3 = [number, number, number];
4
+ /**
5
+ * The station of a map: its command post (the console, a box), the inside of the station (a box),
6
+ * the satellite's body, and the muzzle of its laser cannon, pointed down at the moon, where the
7
+ * strike's lasers leave from.
8
+ */
9
+ export interface StationDef {
10
+ post: [min: Vec3, max: Vec3];
11
+ hall: [min: Vec3, max: Vec3];
12
+ /** The satellite's cylinder (HULL.R wide): its axis at (x, z), from y0 to y1. */
13
+ hull: [x: number, y0: number, z: number, y1: number];
14
+ gun: Vec3;
15
+ }
16
+ /** Where the mission stands. */
17
+ export declare const PHASE: {
18
+ readonly READY: 0;
19
+ readonly ARMED: 1;
20
+ readonly STRUCK: 2;
21
+ readonly COOL: 3;
22
+ };
23
+ /**
24
+ * Metres from the console's sides on the floor plane within which a player on foot reaches its
25
+ * button, and the ticks of the countdown (30 s), of the disintegrated team's wait (15 s) and of the
26
+ * recharge from the strike or the cancel to the next mission (90 s); a ship left empty in the
27
+ * station goes home RECALL ticks after the last player has left it (20 s).
28
+ */
29
+ export declare const STATION: {
30
+ REACH: number;
31
+ ARM: number;
32
+ OUT: number;
33
+ COOL: number;
34
+ RECALL: number;
35
+ };
36
+ /** True when the feet of `p` are within STATION.REACH of the console's sides, at its foot. */
37
+ export declare const reaches: ({ post: [min, max] }: StationDef, { x, y, z }: PlayerState) => boolean;
38
+ /** True when (x, y, z) is inside the station. */
39
+ export declare const inside: ({ hall: [min, max] }: StationDef, x: number, y: number, z: number) => boolean;
40
+ export declare class Station {
41
+ phase: number;
42
+ /** The team that armed the mission (ARMED, STRUCK). */
43
+ team: number;
44
+ /** Ticks left in the phase. */
45
+ ticks: number;
46
+ /** Back to READY: a new match, a new map, an empty room. */
47
+ reset(): void;
48
+ /**
49
+ * A player of `team` pressed the button: READY arms it for his team, ARMED by the other team is
50
+ * cancelled and recharges. Anything else does nothing. Returns what it did.
51
+ */
52
+ press(team: number): 'armed' | 'cancelled' | undefined;
53
+ /** One tick. 'strike' on the tick the countdown runs out: the room disintegrates the other team. */
54
+ tick(): 'strike' | undefined;
55
+ wire(): StationState;
56
+ }
57
+ /**
58
+ * The satellite's body: a cylinder standing round the hangar, its radius and its bottom and top over
59
+ * the deck. As in the user's picture it is about twice as long as it is wide.
60
+ */
61
+ export declare const HULL: {
62
+ R: number;
63
+ LOW: number;
64
+ TOP: number;
65
+ };
66
+ /**
67
+ * The rest of the satellite, which satellite.ts draws and the ghost brushes stop ships at: the
68
+ * cannon's barrel (its radius as a share of the body's, its length under it), each wing (its boom
69
+ * out from the wall, its four panels' length, height and gap, its height up the body as a share),
70
+ * the cap's dome and the mast of its dish.
71
+ */
72
+ export declare const PARTS: {
73
+ BARREL: number;
74
+ GUN: number;
75
+ BOOM: number;
76
+ PANEL: number;
77
+ SPAN: number;
78
+ GAP: number;
79
+ WING: number;
80
+ DOME: number;
81
+ MAST: number;
82
+ };
83
+ /**
84
+ * The station over the point (x, Y, z), symmetric across z: a satellite after the user's picture, a
85
+ * cylinder standing on its axis (HULL) wrapped in foil, solar wings each side, and under it the laser
86
+ * cannon's aperture pointed down at the moon, all drawn by the client (satellite.ts). Through it a
87
+ * hangar along z opens at both ends in the cylinder's wall, so each team's ship flies in from its own
88
+ * side (40 m wide, 88 long, 11 m high at the mouths), the deck at Y; through a doorway in its east
89
+ * wall the command room behind a sliding door, the console in its middle. The cylinder, the
90
+ * cannon, the wings and the dish are solid and not drawn (ghost brushes, the round ones in slices of
91
+ * 4 m), so a ship stops on what it sees. Returns the brushes, the StationDef and the door.
92
+ */
93
+ export declare const station: (x: number, Y: number, z: number) => [Brush[], StationDef, Door];
94
+ export {};
@@ -436,6 +436,14 @@ export interface Snapshot {
436
436
  rovers?: Rover[];
437
437
  /** How far each of WorldDef.doors is open, 0 shut to 1, in sixteen steps on the wire. Absent: none. */
438
438
  doors?: number[];
439
+ /** The orbital station's mission (station.ts). Absent: the map has no station. */
440
+ station?: StationState;
441
+ }
442
+ /** The orbital station's mission as a snapshot carries it: the PHASE, the team that armed it, whole seconds left in the phase (127 at most). */
443
+ export interface StationState {
444
+ phase: number;
445
+ team: number;
446
+ left: number;
439
447
  }
440
448
  /** Room rules, set by the host. Defaults in constants.ts (RULES). */
441
449
  export interface Rules {
@@ -1,3 +1,4 @@
1
+ import type { StationDef } from './station';
1
2
  import type { Relief, ReliefDef } from './relief';
2
3
  type Vec3 = [number, number, number];
3
4
  /** One solid box. */
@@ -81,6 +82,8 @@ export interface WorldDef {
81
82
  doors?: Door[];
82
83
  /** The height of the edge of space (ORBIT.SEAM): a shot that crosses it either way bursts there. Absent: none. */
83
84
  seam?: number;
85
+ /** The orbital station's command post and inside (station.ts), its brushes among the others. Absent: none. */
86
+ station?: StationDef;
84
87
  }
85
88
  /** A world ready for physics and drawing: the definition and a grid of brushes on the floor plane. */
86
89
  export interface World {
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.153.0",
5
+ "version": "0.154.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"