@korial29/tiny-fps 0.40.0 → 0.41.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.
@@ -251,6 +251,19 @@ export declare const LOCK_WIN = 8;
251
251
  export declare const LOCK_HP = 3;
252
252
  export declare const LOCK_TICKS = 240;
253
253
  export declare const LOCK_BREAK = 24;
254
+ /**
255
+ * The rail gun (rail.ts, the user, 2026-11-07): taken at the team's third rack with RAIL_MAX shots,
256
+ * it fires an instant beam every RAIL_COOLDOWN ticks that goes RAIL_RANGE metres to the first wall
257
+ * or enemy. An enemy it hits is drained for RAIL_TICKS (3 s): 1 hp at once, then 1 more each
258
+ * RAIL_DRAIN ticks, and his speed on the floor plane is held under SLOW_SPEED. A new hit starts
259
+ * the 3 s again. Ticks are u8 on the wire, RAIL_MAX 5 bits.
260
+ */
261
+ export declare const RAIL_MAX = 10;
262
+ export declare const RAIL_COOLDOWN = 72;
263
+ export declare const RAIL_RANGE = 120;
264
+ export declare const RAIL_TICKS = 180;
265
+ export declare const RAIL_DRAIN = 60;
266
+ export declare const SLOW_SPEED = 3;
254
267
  /** Seconds a carrier who is made to drop the flag cannot take it again: he would pick it up where he stands. */
255
268
  export declare const FLAG_LOCK = 2;
256
269
  /** Seconds the end screen of a match stays, then a new match starts. */
@@ -3,11 +3,12 @@ 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 shot (a plasma ball), or the katana's cut. */
6
+ /** What a step struck, for the host to resolve: nothing, a shot (a plasma ball), the katana's cut, or a rail gun's beam. */
7
7
  export declare const STRIKE: {
8
8
  readonly NONE: 0;
9
9
  readonly SHOT: 1;
10
10
  readonly CUT: 2;
11
+ readonly RAIL: 3;
11
12
  };
12
13
  export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
13
14
  /**
@@ -17,8 +18,11 @@ export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
17
18
  * - The team's rack fills the gun when the player steps into its circle (`rack` tells he is in it),
18
19
  * and again each time he comes back; staying gives nothing. The katana rack gives the katana,
19
20
  * once and for good: it stays until he goes down.
20
- * - In hand (`wield`) is the katana when he has it and wants it (KEY.BLADE) or has no gun, and
21
- * it stays in hand for the length of a swing.
21
+ * - The rail rack fills the rail gun with RAIL_MAX shots on arrival, as the gun's does.
22
+ * - In hand is the weapon he wants (KEY.BLADE the katana, KEY.RAIL the rail gun, neither the gun)
23
+ * when he has it, else the first he has of the gun, the katana and the rail gun; the katana
24
+ * stays in hand for the length of a swing. `wield` is the katana in hand, `railed` the rail gun.
25
+ * - The rail gun fires a beam every RAIL_COOLDOWN ticks while FIRE is held, with a shot left.
22
26
  * - The trigger: `cool` and `swing` run down, and at 0 a held FIRE charges the gun, with ammo, and
23
27
  * letting it go fires a ball as strong as the charge (powerOf()), spending as many shots; or it
24
28
  * starts the katana's swing (`cut` from the keys), unless the hands are busy (a hang, a climb).
@@ -28,7 +28,7 @@ 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 = 52;
31
+ export declare const SNAP_PLAYER = 55;
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
34
  /** Bytes of a plasma ball. */
@@ -0,0 +1,14 @@
1
+ import type { PlayerState } from './types';
2
+ import type { World } from './world';
3
+ type Vec3 = [number, number, number];
4
+ /**
5
+ * The beam `p` fires along his look: where it starts (his eye), its unit direction, how far it goes
6
+ * (to the first brush, or RAIL_RANGE) and the first of `foes` whose body it enters before that.
7
+ */
8
+ export declare const beam: (w: World, p: PlayerState, foes?: PlayerState[]) => {
9
+ o: Vec3;
10
+ d: Vec3;
11
+ t: number;
12
+ hit?: PlayerState;
13
+ };
14
+ export {};
@@ -83,6 +83,11 @@ export declare class Room {
83
83
  * crosses where `p` drew him (`limbOf`).
84
84
  */
85
85
  private cut;
86
+ /**
87
+ * A rail beam of `p` went off at the view tick `view`: the first enemy it enters as `p` drew him
88
+ * takes 1 hp and is drained (`slow`, RAIL_TICKS), and the `hits` count goes up.
89
+ */
90
+ private rail;
86
91
  /**
87
92
  * A saber lock of `p`, after his input: it ends when a side leads by LOCK_WIN presses (the other
88
93
  * takes LOCK_HP and the katana's shock, thrown along the winner's look), when one has stepped out
@@ -42,6 +42,11 @@ export declare const KEY: {
42
42
  * of the cut the keys give (see CUT). Ignored without the katana in hand.
43
43
  */
44
44
  readonly SPECIAL: 1024;
45
+ /**
46
+ * Set while the player wants the rail gun in hand (the client's choice: 3 or the wheel), with
47
+ * KEY.BLADE clear. Ignored without the rail gun.
48
+ */
49
+ readonly RAIL: 2048;
45
50
  };
46
51
  /**
47
52
  * The katana's cuts (PlayerState.cut, constants CUTS), chosen by the keys held when FIRE starts
@@ -213,6 +218,16 @@ export interface PlayerState {
213
218
  pushes?: number;
214
219
  pressed?: boolean;
215
220
  away?: number;
221
+ /** Shots left in the rail gun; absent or -1 without it (taken at the team's rail rack, lost on going down). */
222
+ rail?: number;
223
+ /** The rail gun is in hand (see KEY.RAIL). Absent reads false. */
224
+ railed?: boolean;
225
+ /** Standing inside the circle of the team's rail rack as of the last step: it fills on arrival only. Absent reads false. */
226
+ inRail?: boolean;
227
+ /** Ticks to the next rail shot. Absent reads 0. */
228
+ reload?: number;
229
+ /** Ticks left drained by a rail hit: slowed under SLOW_SPEED, and the host takes 1 hp each RAIL_DRAIN. Absent reads 0. */
230
+ slow?: number;
216
231
  /** 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. */
217
232
  lost?: number;
218
233
  /** For the animation, not sent: the EV bits of the last step, and the speed of a landing. */
@@ -22,6 +22,8 @@ export interface TeamDef {
22
22
  rack?: Vec3;
23
23
  /** The katana rack, next to the gun rack, a point on a top: walking within RACK_R gives the katana. */
24
24
  blade?: Vec3;
25
+ /** The rail gun rack, on the other side of the gun rack: walking within RACK_R gives the rail gun with RAIL_MAX shots. */
26
+ rail?: Vec3;
25
27
  }
26
28
  export interface WorldDef {
27
29
  /** Shown on the title screen. */
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.40.0",
5
+ "version": "0.41.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"