@korial29/tiny-fps 0.104.1 → 0.106.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.
@@ -327,6 +327,25 @@ export declare const RIFLE_COOL = 3;
327
327
  export declare const RIFLE_RANGE = 60;
328
328
  export declare const RIFLE_DRIFT = 0.012;
329
329
  export declare const RIFLE_HITS = 2;
330
+ /**
331
+ * The laser rifle's grenade launcher (the user, 2026-11-10: "a double click and it sends an
332
+ * explosive grenade at range, like on an M16"): the block under the barrel. The rifle's rack loads
333
+ * NADE_MAX grenades with the rounds. A double click (KEY.SPECIAL) with the rifle in hand launches
334
+ * one from the eye along the look at NADE_SPEED m/s, NADE_COOL ticks after the last, and the rifle
335
+ * holds its fire NADE_HOLD ticks. It falls under the map's gravity and bursts on the first brush or
336
+ * enemy body, or after NADE_RANGE metres of flight. The burst takes NADE_HP at its centre, falling
337
+ * off to nothing NADE_R metres away, from every enemy and from its owner (no teammate), unless a
338
+ * brush hides him. NADE is its Ball.power, past BOLT. NADE_COOL fits 6 bits and NADE_MAX 2 on the
339
+ * wire, NADE_HOLD the 3 of `cool`.
340
+ */
341
+ export declare const NADE = 7;
342
+ export declare const NADE_MAX = 3;
343
+ export declare const NADE_COOL = 60;
344
+ export declare const NADE_HOLD = 7;
345
+ export declare const NADE_SPEED = 36;
346
+ export declare const NADE_RANGE = 150;
347
+ export declare const NADE_R = 5;
348
+ export declare const NADE_HP = 5;
330
349
  /** Seconds a carrier who is made to drop the flag cannot take it again: he would pick it up where he stands. */
331
350
  export declare const FLAG_LOCK = 2;
332
351
  /** Seconds the end screen of a match stays, then a new match starts. */
@@ -4,13 +4,14 @@ import type { World } from './world';
4
4
  type Vec3 = [number, number, number];
5
5
  /** Whether the feet of `p` are within `r` of the point `at` on the floor plane and within PICK_H of its height. */
6
6
  export declare const within: (p: PlayerState, at: Vec3, r: number) => boolean;
7
- /** What a step struck, for the host to resolve: nothing, a shot (a plasma ball), the katana's cut, a rail gun's beam, or a laser rifle's shot. */
7
+ /** What a step struck, for the host to resolve: nothing, a shot (a plasma ball), the katana's cut, a rail gun's beam, a laser rifle's shot, or a grenade from its launcher. */
8
8
  export declare const STRIKE: {
9
9
  readonly NONE: 0;
10
10
  readonly SHOT: 1;
11
11
  readonly CUT: 2;
12
12
  readonly RAIL: 3;
13
13
  readonly LASER: 4;
14
+ readonly NADE: 5;
14
15
  };
15
16
  export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
16
17
  /**
@@ -31,7 +32,9 @@ export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
31
32
  * - The rail gun throws its bolt on every step FIRE is held, spending a tick of it (`zapping`),
32
33
  * unless it is `hot`: its `heat` rises while it fires and falls when it does not (HEAT_MAX).
33
34
  * - The laser rifle (KEY.RIFLE, `rifled`), filled at its rack on arrival, fires a round from its
34
- * cell (`clip`) each RIFLE_COOL ticks while FIRE is held (STRIKE.LASER).
35
+ * cell (`clip`) each RIFLE_COOL ticks while FIRE is held (STRIKE.LASER). Its rack loads NADE_MAX
36
+ * grenades too: SPECIAL (a double click) launches one (STRIKE.NADE) when `lob` is 0, even during
37
+ * a swap of the cell, then `lob` runs NADE_COOL ticks and the rifle holds its fire NADE_HOLD.
35
38
  * - The trigger: `cool` and `swing` run down, and at 0 a held FIRE charges the gun, with ammo, and
36
39
  * letting it go fires a ball as strong as the charge (powerOf()), spending as many shots; or it
37
40
  * starts the katana's swing (`cut` from the keys), unless the hands are busy (a hang, a climb).
@@ -42,6 +42,8 @@ export declare const STILL: {
42
42
  rifle: number;
43
43
  clip: number;
44
44
  rifled: boolean;
45
+ nades: number;
46
+ lob: number;
45
47
  inRifle: boolean;
46
48
  inRail: boolean;
47
49
  zapping: boolean;
@@ -39,4 +39,26 @@ export declare const cylinder: (o: Vec3, d: Vec3, c: PlayerState, r: number, h:
39
39
  * for an arc) it enters. Returns the foe it burst on.
40
40
  */
41
41
  export declare const fly: (w: World, b: Flying, m: number, foes: PlayerState[]) => PlayerState | undefined;
42
+ /**
43
+ * The grenade `p` has just launched (`p` the state after that step): from the eye along the look,
44
+ * with no drift, at NADE_SPEED, NADE_RANGE metres of flight to go. Named by his `shots` like a ball.
45
+ */
46
+ export declare const lob: (p: PlayerState, team?: number) => Flying;
47
+ /**
48
+ * Whether the shot `p` has just fired (a change of `shots`) was a grenade: the rifle holds its
49
+ * fire NADE_HOLD ticks after one, so nothing else of his counts in them.
50
+ */
51
+ export declare const lobbed: (p: PlayerState) => boolean;
52
+ /**
53
+ * One tick of the grenade `b`: the map's gravity bends its flight, then it flies on as a ball
54
+ * (fly()) and bursts on the first brush or foe, or at the end of its range. Float32, so the
55
+ * shooter's client flies the same one.
56
+ */
57
+ export declare const toss: (w: World, b: Flying, foes: PlayerState[]) => PlayerState | undefined;
58
+ /**
59
+ * The health a grenade bursting at `c` takes from `p`: NADE_HP at the body, less with the distance
60
+ * to its nearest point (the axis, feet to head), nothing from NADE_R on, rounded up. Nothing when
61
+ * a brush hides both that point and the chest.
62
+ */
63
+ export declare const blast: (w: World, c: Vec3, p: PlayerState) => number;
42
64
  export {};
@@ -40,7 +40,7 @@ export declare const MSG_INPUT = 1;
40
40
  export declare const MSG_SNAPSHOT = 2;
41
41
  export declare const INPUT_BYTES = 12;
42
42
  export declare const SNAP_HEAD = 4;
43
- export declare const SNAP_PLAYER = 61;
43
+ export declare const SNAP_PLAYER = 62;
44
44
  /** Bytes of a rover: thirteen float32 and the two seats. */
45
45
  export declare const SNAP_ROVER = 54;
46
46
  /** The rover count has three bits of the head's count byte, the players the other five. */
@@ -86,13 +86,17 @@ export declare class Room {
86
86
  /**
87
87
  * A shot of `p` went off at the view tick `view`: its ball (or the arc `b` of an ARC cut) starts
88
88
  * where `p` saw it start, flown on by his lag (the view tick to now, at most PLASMA_LAG ticks)
89
- * against the others as they are now. Past PLASMA_MAX balls in flight, the oldest bursts.
89
+ * against the others as they are now. Past PLASMA_MAX balls in flight, the oldest bursts. A
90
+ * grenade (lob()) is flown on the same way, a tick of its arc at a time.
90
91
  */
91
92
  private shoot;
92
93
  /**
93
94
  * Flies the ball `b` on by `m` metres: one that bursts on an enemy who is up takes its power in hp
94
95
  * from him, and counts a hit to its shooter. An arc takes its cut's hp; one it does not put down
95
96
  * is floored (FLOOR_TICKS, `zap`), thrown ARC_KNOCK m/s the way it flies, and drops the flag.
97
+ * A grenade flies one tick of its arc whatever `m`, and its burst is a blast: every enemy who is
98
+ * up, and its owner, lose what blast() gives where they stand now; one hit for the shooter when
99
+ * it hurt an enemy.
96
100
  */
97
101
  private fly;
98
102
  /**
@@ -39,7 +39,8 @@ export declare const KEY: {
39
39
  readonly BLADE: 512;
40
40
  /**
41
41
  * Set with FIRE by a double click (the client's choice): the katana's special cut, the special
42
- * of the cut the keys give (see CUT). Ignored without the katana in hand.
42
+ * of the cut the keys give (see CUT); with the laser rifle in hand, a grenade from its launcher.
43
+ * Ignored with the other guns.
43
44
  */
44
45
  readonly SPECIAL: 1024;
45
46
  /**
@@ -205,6 +206,10 @@ export interface PlayerState {
205
206
  rifle?: number;
206
207
  /** Rounds in the laser rifle's power cell, of `rifle` (RIFLE_CLIP at most). Absent reads 0. */
207
208
  clip?: number;
209
+ /** Grenades left in the laser rifle's launcher (NADE_MAX at its rack, none without the rifle). Absent reads 0. */
210
+ nades?: number;
211
+ /** Ticks before the launcher fires again (NADE_COOL after a grenade). Absent reads 0. */
212
+ lob?: number;
208
213
  /** The laser rifle is in hand (see KEY.RIFLE). Absent reads false. */
209
214
  rifled?: boolean;
210
215
  /** Standing inside the circle of the team's rifle rack as of the last step. Absent reads false. */
@@ -311,8 +316,10 @@ export interface Ball {
311
316
  dz: number;
312
317
  /** It burst where it is: the last snapshot that carries it. */
313
318
  burst: boolean;
314
- /** Its strength, 1 to CHARGE_MAX: the health it takes. Absent reads 1. */
319
+ /** Its strength, 1 to CHARGE_MAX: the health it takes. Absent reads 1. 0 is a laser rifle's, BOLT a rover's, NADE a grenade. */
315
320
  power?: number;
321
+ /** A grenade's speed along its direction, m/s (the wire keeps whole m/s, 63 at most). Absent for the rest. */
322
+ v?: number;
316
323
  /** An arc of energy, not a ball: the CUT that threw it (ARC_L or ARC_R). Absent for a ball. */
317
324
  arc?: number;
318
325
  }
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.104.1",
5
+ "version": "0.106.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"