@korial29/tiny-fps 0.32.0 → 0.34.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.
@@ -1,23 +1,34 @@
1
1
  import type { Light } from './lights';
2
2
  import type { Vec3 } from './mesh';
3
- /** Seconds a beam lasts, and a flash of light and a spark. */
4
- export declare const LIFE = 0.08;
3
+ /** A ball as drawn this frame: its centre, its unit direction, and the metres of trail behind it. */
4
+ export interface Orb {
5
+ p: Vec3;
6
+ d: Vec3;
7
+ tail: number;
8
+ }
9
+ /** Seconds a muzzle flash, a splash and a spark last. */
10
+ export declare const FLASH = 0.06;
11
+ export declare const SPLASH = 0.16;
5
12
  export interface Tracer {
6
- /** A shot from `a` to `b`; `hit` when it ended on a wall, which sparks; `own` for the player's, which stays on its muzzle. */
7
- shoot(a: Vec3, b: Vec3, hit: boolean, own?: boolean): void;
13
+ /** A shot's flash at the muzzle `a`; `own` for the player's, which stays on its muzzle. */
14
+ flash(a: Vec3, own?: boolean): void;
15
+ /** A ball burst at `at`: a splash of light and a spray of sparks. */
16
+ burst(at: Vec3): void;
17
+ /** The balls to draw this frame. */
18
+ orbs(list: Orb[]): void;
8
19
  /** The katana's shock at `at`: a burst of sparks and bolts. */
9
20
  shock(at: Vec3): void;
10
21
  /** One frame of the crackle around a shocked runner whose middle is `at`: a few bolts, flickering. */
11
22
  crackle(at: Vec3): void;
12
- /** Where the own muzzle is now: the own beams start there, so that a kick of the view does not swing them. */
23
+ /** One spark out of `at`, up and a little aside: a cut limb's stump spitting. */
24
+ spit(at: Vec3): void;
25
+ /** Where the own muzzle is now: its flash stays there, so that a kick of the view does not leave it behind. */
13
26
  mount(a: Vec3): void;
14
27
  /** Ages everything by dt seconds and drops what is over. */
15
28
  update(dt: number): void;
16
- /** Appends the ribbons and the sparks, turned to the camera at `eye`. */
29
+ /** Appends the balls, the flashes, the bolts and the sparks, turned to the camera at `eye`. */
17
30
  draw(out: number[], eye: Vec3): void;
18
- /** The lights of the flashes at the muzzles and the impacts, for gather(). */
31
+ /** The lights of the flashes, the splashes, the bolts and the nearest balls, for gather(). */
19
32
  lights(): Light[];
20
- /** The beams alive now. */
21
- readonly count: number;
22
33
  }
23
34
  export declare const createTracer: () => Tracer;
@@ -1,6 +1,7 @@
1
1
  import type { PlayerState } from '../shared/types';
2
2
  import type { World } from '../shared/world';
3
3
  import type { Audio } from './audio';
4
+ import type { Balls } from './balls';
4
5
  import type { Tracer } from './beams';
5
6
  import type { Effects } from './effects';
6
7
  import type { Hud } from './hud';
@@ -15,9 +16,6 @@ export interface View {
15
16
  drawn: number;
16
17
  /** The own muzzle (the emitter) in the camera's space. */
17
18
  muzzle: Vec3;
18
- /** Where the look ray ends, from sight(): the beam goes there. */
19
- end: Vec3;
20
- hit: boolean;
21
19
  }
22
20
  /**
23
21
  * Where the own shots end: the first wall along the look ray from the eye, or the range. `local` is
@@ -32,8 +30,8 @@ export declare const sight: (world: World, eye: Vec3, cam: Vec3, yaw: number, pi
32
30
  export interface Combat {
33
31
  /** One live step of the own player, its state before and after: the recoil and the kick of each shot it fired, the swish and the punch of a cut. */
34
32
  step(a?: PlayerState, b?: PlayerState): void;
35
- /** One frame: the beams and the sounds of what changed since the last one, and the HUD. */
36
- frame(v: View | undefined, me: PlayerState | undefined, others: PlayerState[], keys: number, dt: number): void;
33
+ /** One frame at `now` (ms): the balls, the flashes and the sounds of what changed since the last one, and the HUD. */
34
+ frame(v: View | undefined, me: PlayerState | undefined, others: PlayerState[], keys: number, dt: number, now?: number): void;
37
35
  }
38
36
  /** Shots between two states of a player, a u8 counter that wraps. */
39
37
  export declare const fired: (a?: PlayerState, b?: PlayerState) => number;
@@ -46,7 +44,7 @@ type Blade = Pick<PlayerState, 'swing' | 'cut' | 'wield' | 'blade'>;
46
44
  export declare const swung: (a?: Blade, b?: Blade) => number;
47
45
  /** Whether the step from a to b is the strike of its cut: `swing` went down through the strike tick (CUTS). */
48
46
  export declare const struck: (a?: Blade, b?: Blade) => boolean;
49
- export declare const createCombat: (world: World, audio: Pick<Audio, "play">, hud: Pick<Hud, "vitals" | "hit" | "down">, fx: Pick<Effects, "fire" | "cut" | "wound" | "lie">, tracer: Pick<Tracer, "shoot" | "update" | "mount" | "crackle">, ctl: {
47
+ export declare const createCombat: (world: World, audio: Pick<Audio, "play">, hud: Pick<Hud, "vitals" | "hit" | "down">, fx: Pick<Effects, "fire" | "cut" | "wound" | "lie">, tracer: Pick<Tracer, "flash" | "burst" | "orbs" | "update" | "mount" | "crackle">, ctl: {
50
48
  pitch: number;
51
- }) => Combat;
49
+ }, balls: Pick<Balls, "fire" | "frame">) => Combat;
52
50
  export {};
@@ -25,7 +25,7 @@ export interface Effects {
25
25
  lie: number;
26
26
  /** The own player fired: a small shake of the eye, the look and the roll, and the kick of the gun. */
27
27
  fire(): void;
28
- /** The own player was hit by a laser: the red vignette and a small knock. */
28
+ /** The own player was hit: the red vignette and a small knock. */
29
29
  wound(): void;
30
30
  /** The own player was tackled: a hard jolt of the eye, the look and the roll, and the vignette. */
31
31
  jolt(): void;
@@ -27,7 +27,7 @@ export interface Hud {
27
27
  * katana carried; both carried show the slots (1 gun, 2 katana) over the glyph, none hides it.
28
28
  */
29
29
  vitals(hp: number, ammo: number, blade?: boolean, wield?: boolean): void;
30
- /** A hit marker on the crosshair for a moment: a laser of the own player hit. */
30
+ /** A hit marker on the crosshair for a moment: a ball or a cut of the own player hit. */
31
31
  hit(): void;
32
32
  /** The state of being down: `level` 0 (up) to 1 hides or greys the screen, `left` seconds till the respawn. */
33
33
  down(level: number, left: number): void;
@@ -1,8 +1,10 @@
1
1
  import type { PlayerState } from '../shared/types';
2
2
  import type { Vec3 } from './mesh';
3
3
  import type { Quat } from './rig';
4
- /** Where the blade starts and ends along the model's forward axis, metres from the right hand. */
4
+ /** Where the blade starts and ends along the model's forward axis, metres from the right hand: a metre from the guard to the point. */
5
5
  export declare const BASE: number, TIP: number;
6
+ /** The left hand grips this far behind the right one: a gap between the two fists. */
7
+ export declare const BEHIND = 0.14;
6
8
  /**
7
9
  * The katana at a level of detail (0 far, 1 near), built once, in the vertex format of mesh.ts: the
8
10
  * blade (bevelled edge, a ridge, a spine, a point), a thin cyan glow along its edge, a collar, a
@@ -34,10 +36,11 @@ export declare const ends: (pos: Vec3, q: Quat) => Vec3[];
34
36
  export declare const frameOf: (d: Vec3, roll: number) => Vec3[];
35
37
  /**
36
38
  * The cuts. Each is keys of [share of the swing, grip x, y, z, blade direction x, y, z, roll] in
37
- * the camera's space (right, up, forward), the guard first, and the same guard last: a wind-up,
38
- * the strike at its tick (every cut passes the middle of the view there, the point 81 cm from
39
- * the grip) and a follow-through, with the hand taking the slope between its neighbours' keys
40
- * (fastest through the strike). The right hand holds the grip, the left 9.5 cm behind it.
39
+ * the camera's space (right, up, forward), the guard first and last: a wind-up, the strike at its
40
+ * tick (every cut passes the middle of the view there) and a follow-through, with the hands taking
41
+ * the slope between their neighbours' keys (fastest through the strike). Both hands hold the grip,
42
+ * the left BEHIND the right. The wind-ups and follow-throughs go out of the view. The guard is
43
+ * rolled a little, its flat toward the eye.
41
44
  */
42
45
  export declare const GUARD: number[];
43
46
  /** The grip and the blade direction (x, y, z each) and the roll of cut `cut` at `p` of the swing: one array, rewritten by each call. */
@@ -48,5 +51,5 @@ export declare const stroke: (cut: number, p: number) => number[];
48
51
  * time, never more than two ticks ahead of the count, never behind it. `was` is the last answer.
49
52
  */
50
53
  export declare const progress: (was: number, p: Pick<PlayerState, "swing" | "cut">, dt: number) => number;
51
- /** Whether the blade is cutting at `p` of its swing: the wind-up and the recovery leave no trail. */
54
+ /** Whether the blade is cutting at `p` of its swing: the wind-up, over by 0.22 to 0.27, and the recovery leave no trail. */
52
55
  export declare const cutting: (p: number) => boolean;
@@ -0,0 +1,50 @@
1
+ import type { PlayerState } from '../shared/types';
2
+ import type { World } from '../shared/world';
3
+ import type { Tracer } from './beams';
4
+ import type { Gait } from './gait';
5
+ import type { Vec3 } from './mesh';
6
+ import { solve } from './rig';
7
+ import type { Quat } from './rig';
8
+ /** The height of the floor under (x, z) for something whose middle is at height y. */
9
+ export type Ground = (x: number, y: number, z: number) => number;
10
+ /** The first top under a point, none (it falls out of sight) off the roofs; without a world, the height `y0`. */
11
+ export declare const ground: (world: World | undefined, y0: number) => Ground;
12
+ export interface Piece {
13
+ limb: number;
14
+ /** The joints in the pose of the cut, which the limb is skinned with, and its middle then. */
15
+ s: ReturnType<typeof solve>;
16
+ c: Vec3;
17
+ /** Its points around that middle, for the floor, and its long axis, middle away from the cut. */
18
+ pts: Vec3[];
19
+ long: Vec3;
20
+ /** Where its middle is now, its velocity, its turn since the cut and its spin (axis times rad/s). */
21
+ p: Vec3;
22
+ v: Vec3;
23
+ q: Quat;
24
+ w: Vec3;
25
+ /** The stump's cut face on the body (soldier() keeps it there), and seconds since the cut. */
26
+ at: Vec3;
27
+ age: number;
28
+ }
29
+ /**
30
+ * The limb `limb` of `p` coming off the body posed as `s`: thrown with the body's speed, a little
31
+ * outward (and back) from the hips and up, tumbling outward.
32
+ */
33
+ export declare const sever: (limb: number, s: ReturnType<typeof solve>, p: PlayerState) => Piece;
34
+ /**
35
+ * One step of dt seconds of a piece's fall: gravity and spin, then the floor under it, which it
36
+ * bounces off, rubs along and lies down on (its long axis toppling to the level).
37
+ */
38
+ export declare const fall: (c: Piece, dt: number, floor: Ground) => void;
39
+ /**
40
+ * Keeps the piece of a runner in step with its player `r.p`: made when `lost` is set while down,
41
+ * with a burst of sparks at the cut, or already lying when the runner was `fresh` (first seen that
42
+ * way); moved by dt, the stump spitting; forgotten once he is up.
43
+ */
44
+ export declare const track: (r: {
45
+ p: PlayerState;
46
+ gait: Pick<Gait, "pose">;
47
+ cut?: Piece;
48
+ }, dt: number, floor: Ground, fresh: boolean, tracer?: Pick<Tracer, "shock" | "spit">) => void;
49
+ /** Appends the piece at level of detail `lod`, in `colors` (see palette()), sunk by `sink` metres with the body. */
50
+ export declare const piece: (out: number[], c: Piece, colors: number[][], lod: number, sink: number) => void;
@@ -106,7 +106,7 @@ export interface Renderer {
106
106
  lights: Light[], body?: Body,
107
107
  /** The bases, the flags, the racks and the health packs: drawn lit, casting shadows, with the other players. */
108
108
  ctf?: CtfScene,
109
- /** The laser beams: glowing ribbons that cast no shadow. */
109
+ /** The plasma balls, the flashes and the sparks: they glow and cast no shadow. */
110
110
  tracer?: Tracer): void;
111
111
  /** A world point on screen as of the last frame, in [0, 1] from the top left. */
112
112
  project(x: number, y: number, z: number): [number, number] | undefined;
@@ -1,6 +1,6 @@
1
1
  import type { Quat } from './rig';
2
2
  import type { Vec3 } from './mesh';
3
- /** Jacket, its darker trim, trousers, skin, hair, shoe upper, sole, gloves and shades. */
3
+ /** Jacket, its darker trim, trousers, skin, hair, shoe upper, sole, gloves, shades and the cut's cauterized face, which glows. */
4
4
  export declare const palette: (jacket: number[]) => number[][];
5
5
  /** The ring where the eye's sleeve ends in the glove, which body.ts starts the palm on, and its sides. */
6
6
  export declare const CUFF: number[];
@@ -13,9 +13,16 @@ export interface Skin {
13
13
  /** Three vertex indices per triangle, and the palette colour of each. */
14
14
  t: Uint16Array;
15
15
  c: Uint8Array;
16
+ /** Per triangle the LIMB it comes off with, NONE for the trunk's. */
17
+ l?: Uint8Array;
16
18
  }
17
19
  /** The skin at a level of detail (see DETAIL in mesh.ts): 0 far, 1 near, 2 near, headless and handless, for the eye. Built once. */
18
20
  export declare const body: (lod: number) => Skin;
21
+ /**
22
+ * The skin at a level of detail without the LIMB `limb`, then the limb alone, each closed by a
23
+ * glowing cut face whose middle is the last vertex of the last triangle. Built once.
24
+ */
25
+ export declare const cut: (lod: number, limb: number) => Skin[];
19
26
  /**
20
27
  * Appends the skin in the pose `solved` (see solve()) to `out` as triangles in the renderer's
21
28
  * vertex format, each in its palette colour: a vertex goes where the two joints it hangs on would
@@ -1,7 +1,10 @@
1
1
  import type { PlayerState } from '../shared/types';
2
2
  import type { World } from '../shared/world';
3
3
  import type { Gait } from './gait';
4
+ import type { Tracer } from './beams';
5
+ import type { Piece } from './limbs';
4
6
  import type { Vec3 } from './mesh';
7
+ import type { Pose } from './rig';
5
8
  import type { Trail } from './trail';
6
9
  /** What a runner keeps between frames. */
7
10
  export interface Runner {
@@ -19,15 +22,23 @@ export interface Runner {
19
22
  prog: number;
20
23
  trail: Trail;
21
24
  t: number;
25
+ /** The limb a katana's cut took off, while he is down (see limbs.ts). */
26
+ cut?: Piece;
22
27
  }
23
28
  /** A runner as first seen: in the pose its state asks for, no ease. */
24
29
  export declare const createRunner: (p: PlayerState) => Runner;
25
30
  /**
26
31
  * Moves each runner of `book` to its player in `others` after dt seconds: a new player gets a
27
32
  * runner already in pose, one that left loses it. With a `world` the feet stand on the brushes
28
- * under them.
33
+ * under them. The `tracer` gets the sparks of a limb cut off.
29
34
  */
30
- export declare const animate: (book: Map<number, Runner>, others: PlayerState[], dt: number, world?: World) => void;
35
+ export declare const animate: (book: Map<number, Runner>, others: PlayerState[], dt: number, world?: World, tracer?: Pick<Tracer, "shock" | "spit">) => void;
36
+ /**
37
+ * The pose with the katana in both hands: carried, or in a cut, which is the first person's cut
38
+ * seen from the runner's eye (the share `e` of it, so that it is drawn from the carry and back to
39
+ * it), the trunk turning with the blade and leaning into the lunge and the low finish.
40
+ */
41
+ export declare const brandish: (pose: Pose, p: PlayerState, prog: number, ph: number) => Pose;
31
42
  /**
32
43
  * Appends a runner at level of detail `lod` (see body()): the jacket in `color` (r, g, b), dark
33
44
  * trousers, skin, hair and light shoes, posed by its gait. A dash trails a few glowing streaks.
@@ -18,3 +18,14 @@ export declare const strike: (w: World, p: PlayerState, foes: PlayerState[]) =>
18
18
  * so LEFT throws to his right and RIGHT to his left.
19
19
  */
20
20
  export declare const knock: (p: PlayerState) => [x: number, z: number];
21
+ /**
22
+ * The LIMB the cut of `p` (the state after the step that struck) takes off `f` (as he saw him) when
23
+ * it puts him down. The blade's line is his look from his chest (CHEST of his height), so a level
24
+ * cut meets the foe's arms. It enters the foe's body (a circle of PLAYER_R on the floor plane) on
25
+ * the near side; the side is the foe's own, measured where it enters, on his right axis. A slash
26
+ * takes the head within MIDLINE of his middle, else the arm on that side. A thrust and a cut across
27
+ * go by the line's height at the foe's distance, as a share of his height: above NECK the head,
28
+ * below HIPS a leg, else an arm. A cut across takes the side facing where it comes from; a thrust
29
+ * the side it enters, and no arm within MIDLINE of his middle.
30
+ */
31
+ export declare const limbOf: (p: PlayerState, f: PlayerState) => number;
@@ -171,8 +171,17 @@ export declare const HP_MAX = 5;
171
171
  export declare const AMMO_MAX = 60;
172
172
  /** Ticks between two shots while the trigger is held: 8.6 shots a second. */
173
173
  export declare const GUN_COOLDOWN = 7;
174
- /** Metres a laser reaches. */
174
+ /** Metres a shot reaches: a plasma ball that has flown this far is gone. */
175
175
  export declare const GUN_RANGE = 80;
176
+ /**
177
+ * A shot is a plasma ball (the user, 2026-11-06, Doom-like): it leaves the eye along the look at
178
+ * PLASMA_SPEED m/s, is a sphere of PLASMA_R metres, and bursts on the first brush or enemy body it
179
+ * touches (teammates and the shooter let it through). It lives GUN_RANGE / PLASMA_SPEED s.
180
+ */
181
+ export declare const PLASMA_SPEED = 40;
182
+ export declare const PLASMA_R = 0.12;
183
+ /** Plasma balls in flight in a room at most: past it the oldest bursts. They go on the wire. */
184
+ export declare const PLASMA_MAX = 64;
176
185
  /** Radians the view kicks up per shot (client side: the kick is in the pitch the inputs carry). */
177
186
  export declare const RECOIL = 0.012;
178
187
  /** Ticks a player lies down after the health ran out, then he is back at a spawn of his team. */
@@ -200,6 +209,13 @@ export declare const CUTS: {
200
209
  arc: number;
201
210
  hp: number;
202
211
  }[];
212
+ /**
213
+ * Where a finishing cut crosses the body, as a share of its height from the feet, picks the limb
214
+ * (limbOf(), blade.ts): above NECK the head, below HIPS a leg, between them an arm. A thrust or a
215
+ * slash whose line passes within MIDLINE metres of the body's middle takes no arm: the slash takes
216
+ * the head, the thrust nothing unless it is above NECK.
217
+ */
218
+ export declare const NECK: number, HIPS: number, MIDLINE: number;
203
219
  /**
204
220
  * A cut that does not put the enemy down shocks him: a stumble (`stumble()`, physics.ts) of
205
221
  * SHOCK_TICKS (0.4 s), thrown SHOCK_KNOCK m/s the way the blade goes.
@@ -3,7 +3,7 @@ import type { World } from './world';
3
3
  type Vec3 = [number, number, number];
4
4
  /** Whether the feet of `p` are within `r` of the point `at` on the floor plane and within PICK_H of its height. */
5
5
  export declare const within: (p: PlayerState, at: Vec3, r: number) => boolean;
6
- /** What a step struck, for the host to resolve: nothing, a laser shot, or the katana's cut. */
6
+ /** What a step struck, for the host to resolve: nothing, a shot (a plasma ball), or the katana's cut. */
7
7
  export declare const STRIKE: {
8
8
  readonly NONE: 0;
9
9
  readonly SHOT: 1;
@@ -26,10 +26,4 @@ export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
26
26
  * `armed` is false while the match is over: no weapon, no rack.
27
27
  */
28
28
  export declare const step: (p: PlayerState, i: Input, w: World, team: number, armed?: boolean) => Strike;
29
- /**
30
- * The first of `foes` (the players he may hit, as he saw them) that the laser of `p` meets: from his
31
- * eye along his look, at most GUN_RANGE and not through a brush. `p` is the state after the input
32
- * that fired.
33
- */
34
- export declare const shoot: (w: World, p: PlayerState, foes: PlayerState[]) => PlayerState | undefined;
35
29
  export {};
@@ -32,6 +32,7 @@ export declare const STILL: {
32
32
  swing: number;
33
33
  cut: number;
34
34
  zap: boolean;
35
+ lost: number;
35
36
  ev: number;
36
37
  fall: number;
37
38
  };
@@ -0,0 +1,29 @@
1
+ import type { Ball, PlayerState } from './types';
2
+ import type { World } from './world';
3
+ type Vec3 = [number, number, number];
4
+ /** Metres a ball flies in a tick. */
5
+ export declare const PLASMA_STEP: number;
6
+ /** Ticks of the shooter's lag a new ball is flown at most on the host before its first tick. */
7
+ export declare const PLASMA_LAG = 12;
8
+ /** A ball the host flies: whose team fired it, and the metres it has left. */
9
+ export interface Flying extends Ball {
10
+ team: number;
11
+ left: number;
12
+ }
13
+ /**
14
+ * The ball of the shot `p` has just fired (`p` is the state after the step that fired): from the
15
+ * eye of the mode along the look, GUN_RANGE metres to go, named by his `shots` count.
16
+ */
17
+ export declare const launch: (p: PlayerState, team?: number) => Flying;
18
+ /**
19
+ * Distance at which the ray from `o` along the unit `d` enters the upright cylinder of radius `r`
20
+ * on `c`'s feet, `h` tall; Infinity on a miss.
21
+ */
22
+ export declare const cylinder: (o: Vec3, d: Vec3, c: PlayerState, r: number, h: number) => number;
23
+ /**
24
+ * Flies `b` on by `m` metres (at most what it has left) as a sphere of PLASMA_R: it stops and
25
+ * bursts on the first brush, or on the first of `foes` whose body (a cylinder PLASMA_R wider) it
26
+ * enters. Returns the foe it burst on.
27
+ */
28
+ export declare const fly: (w: World, b: Flying, m: number, foes: PlayerState[]) => PlayerState | undefined;
29
+ export {};
@@ -28,9 +28,11 @@ export declare const MSG_INPUT = 1;
28
28
  export declare const MSG_SNAPSHOT = 2;
29
29
  export declare const INPUT_BYTES = 12;
30
30
  export declare const SNAP_HEAD = 4;
31
- export declare const SNAP_PLAYER = 46;
31
+ export declare const SNAP_PLAYER = 47;
32
32
  /** The match block after the players: the captures, the clock, the packs; the flags follow (2 to 16 bytes). */
33
33
  export declare const SNAP_MATCH = 8;
34
+ /** Bytes of a plasma ball. */
35
+ export declare const SNAP_BALL = 10;
34
36
  /**
35
37
  * The input as the host will read it after encodeInput and decodeInput: yaw, pitch and view
36
38
  * rounded to the wire (an absent view stays absent here, and reads 0 on the host). The client
@@ -31,6 +31,8 @@ export declare class Room {
31
31
  private rr;
32
32
  /** Ticks before each health pack of the map is back: 0 when it is there to take. */
33
33
  private gone;
34
+ /** The plasma balls in flight, and the ones that burst since the last snapshot, which sends them once more. */
35
+ private balls;
34
36
  /** Missing rules fall back to RULES. */
35
37
  constructor(rules?: Partial<Rules>, map?: WorldDef);
36
38
  /** Number of joined players. */
@@ -78,19 +80,24 @@ export declare class Room {
78
80
  private enemies;
79
81
  /**
80
82
  * `hp` of damage to `foe`; the last one puts him down: he lies where he fell, without the gun or
81
- * the katana, and a flag he carries drops with the lock. True when he went down.
83
+ * the katana, a flag he carries drops with the lock, and `lost` is NONE (a cut sets it after).
84
+ * True when he went down.
82
85
  */
83
86
  private harm;
84
87
  /**
85
- * A shot of `p` went off at the view tick `view`: it hits the first enemy on its way as `p` drew
86
- * him, and takes 1 hp.
88
+ * A shot of `p` went off at the view tick `view`: its ball starts where `p` saw it start, flown
89
+ * on by his lag (the view tick to now, at most PLASMA_LAG ticks) against the others as they are
90
+ * now. Past PLASMA_MAX balls in flight, the oldest bursts.
87
91
  */
88
92
  private shoot;
93
+ /** Flies the ball `b` on by `m` metres: one that bursts on an enemy who is up takes 1 hp from him, and counts a hit to its shooter. */
94
+ private fly;
89
95
  /**
90
96
  * A cut of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him is hit
91
97
  * (`strike`), and the `hits` count goes up once. Each takes the cut's hp; one it does not put
92
98
  * down is shocked: a stumble of SHOCK_TICKS thrown SHOCK_KNOCK m/s the way the blade goes, with
93
- * `zap`, and `by` the attacker. A shock drops no flag.
99
+ * `zap`, and `by` the attacker. A shock drops no flag. One it puts down loses the limb the blade
100
+ * crosses where `p` drew him (`limbOf`).
94
101
  */
95
102
  private cut;
96
103
  /**
@@ -49,6 +49,18 @@ export declare const CUT: {
49
49
  readonly RIGHT: 2;
50
50
  readonly SLASH: 3;
51
51
  };
52
+ /**
53
+ * The limb a katana's cut takes off when it puts a player down (PlayerState.lost), by where the
54
+ * blade crosses the body (see limbOf(), blade.ts). Sides are the victim's own.
55
+ */
56
+ export declare const LIMB: {
57
+ readonly NONE: 0;
58
+ readonly HEAD: 1;
59
+ readonly ARM_L: 2;
60
+ readonly ARM_R: 3;
61
+ readonly LEG_L: 4;
62
+ readonly LEG_R: 5;
63
+ };
52
64
  /** The movement state of a player: what the body is doing, one of these. */
53
65
  export declare const MODE: {
54
66
  /** Standing or running on a floor. */
@@ -160,7 +172,7 @@ export interface PlayerState {
160
172
  rack?: boolean;
161
173
  /** Ticks left lying down after the health ran out; at 0 the player is back at a spawn. 0 when up. */
162
174
  down: number;
163
- /** Shots fired and hits landed (a laser or a cut), u8 counters that wrap: the clients draw a beam and play the hit sound on each change. */
175
+ /** Shots fired and hits landed (a plasma ball or a cut), u8 counters that wrap: the clients flash the muzzle and play the hit sound on each change. */
164
176
  shots: number;
165
177
  hits: number;
166
178
  /** Has the katana (taken at the team's katana rack, lost on going down). Absent reads false. */
@@ -173,6 +185,8 @@ export interface PlayerState {
173
185
  cut?: number;
174
186
  /** The running stumble (`stun`) is a katana's shock, not a tackle. Absent reads false. */
175
187
  zap?: boolean;
188
+ /** While down after a katana's cut put him down: the LIMB it took off, for the clients to draw. NONE once up. Absent reads NONE. */
189
+ lost?: number;
176
190
  /** For the animation, not sent: the EV bits of the last step, and the speed of a landing. */
177
191
  ev: number;
178
192
  fall: number;
@@ -207,6 +221,22 @@ export interface SnapPlayer extends PlayerState {
207
221
  /** While `stun` runs: the id of the player who tackled this one (4 bits), else 0. Not part of the movement. */
208
222
  by: number;
209
223
  }
224
+ /** A plasma ball as a snapshot carries it (plasma.ts). */
225
+ export interface Ball {
226
+ /** The shooter's `shots` count after the shot that fired it, u8: with `by`, it names the ball. */
227
+ id: number;
228
+ /** The shooter's player id. */
229
+ by: number;
230
+ /** Its centre, metres (the wire keeps 1/32 m), and its unit direction of flight. */
231
+ x: number;
232
+ y: number;
233
+ z: number;
234
+ dx: number;
235
+ dy: number;
236
+ dz: number;
237
+ /** It burst where it is: the last snapshot that carries it. */
238
+ burst: boolean;
239
+ }
210
240
  /** The flag of a team as a snapshot carries it: only the fields of its state are meaningful, the rest read 0. */
211
241
  export interface FlagState {
212
242
  /** FLAG. */
@@ -236,6 +266,8 @@ export interface Snapshot {
236
266
  * packs of WorldDef.ammo (bit packs.length + n). Absent: none.
237
267
  */
238
268
  packs?: number;
269
+ /** The plasma balls in flight, and those that burst since the last snapshot. Absent: none. */
270
+ balls?: Ball[];
239
271
  }
240
272
  /** Room rules, set by the host. Defaults in constants.ts (RULES). */
241
273
  export interface Rules {
@@ -65,12 +65,14 @@ export declare const near: (w: World, x: number, z: number, r: number) => number
65
65
  /**
66
66
  * Distance along the ray from o in the unit direction d to the first brush face, at most max. A ray
67
67
  * that starts inside a brush hits at 0; one that starts on a face and moves away from it does not hit it.
68
+ * With `grow`, every brush is that much bigger on each side: the path of a sphere of that radius
69
+ * (its corners square, and a brush is only found in the cells the ray crosses).
68
70
  *
69
71
  * Walks the grid cells the ray crosses (Amanatides and Woo), testing the brushes of each against
70
72
  * the exact slab test, and stops once the next cell starts beyond the best hit or max. A brush
71
73
  * spanning several cells is tested in each: the hit is the same, and lists are short.
72
74
  */
73
- export declare const ray: (w: World, o: Vec3, d: Vec3, max: number) => number;
75
+ export declare const ray: (w: World, o: Vec3, d: Vec3, max: number, grow?: number) => number;
74
76
  /** Whether a brush hides b from a. */
75
77
  export declare const hidden: (w: World, a: Vec3, b: Vec3) => boolean;
76
78
  export {};
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.32.0",
5
+ "version": "0.34.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"