@korial29/tiny-fps 0.202.3 → 0.203.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.
package/dist/server.js CHANGED
@@ -381,6 +381,18 @@ var [NECK, HIPS, MIDLINE] = [
381
381
  */
382
382
  var PARRY = .7;
383
383
  var PARRY_SIDE = 1.2;
384
+ /**
385
+ * The rail gun's ring (the user, 2026-11-23): G or the right button with it in hand spends RING_COST
386
+ * ticks of the capsule in one discharge round the player, which overheats the gun (HEAT_MAX, 2 s to
387
+ * cool; the user asked for a smaller one than the first 6 m). Every enemy within RING_R metres on the floor plane and RING_H of his height, in sight of
388
+ * his chest, takes 1 hp, is drained as the bolt drains (RAIL_TICKS, slowed under SLOW_SPEED) and
389
+ * shocked as a katana shocks (SHOCK_TICKS, thrown out of the ring).
390
+ */
391
+ var [RING_COST, RING_R, RING_H] = [
392
+ 20,
393
+ 4,
394
+ 2.5
395
+ ];
384
396
  var RIFLE_DRIFT = .012;
385
397
  var RULES = {
386
398
  maxPlayers: 16,
@@ -599,7 +611,8 @@ var KEY = {
599
611
  /**
600
612
  * Set for one step by G or the right button (the client's choice): with the katana in hand, the
601
613
  * special of the cut the keys give (see CUT); with the laser rifle in hand, a grenade from its
602
- * launcher. Ignored with the other guns.
614
+ * launcher; with the pistol, a burst of BURST shots; with the rail gun, a discharge all round
615
+ * (RING_R).
603
616
  */
604
617
  SPECIAL: 1024,
605
618
  /**
@@ -6785,7 +6798,8 @@ var STRIKE = {
6785
6798
  RAIL: 3,
6786
6799
  LASER: 4,
6787
6800
  NADE: 5,
6788
- DISK: 6
6801
+ DISK: 6,
6802
+ RING: 7
6789
6803
  };
6790
6804
  /**
6791
6805
  * One input: the move, then the weapons. Returns what struck on this step (STRIKE), for the host to
@@ -6835,6 +6849,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6835
6849
  p.hot = !!p.hot && p.heat > 0;
6836
6850
  p.zapping = false;
6837
6851
  p.zap = !!p.stun && !!p.zap;
6852
+ if (down || locked) p.burst = 0;
6838
6853
  if (down) {
6839
6854
  if (p.down > 0 && !--p.down) respawn(p, w, team, kit);
6840
6855
  return STRIKE.NONE;
@@ -6953,6 +6968,24 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6953
6968
  return STRIKE.NONE;
6954
6969
  }
6955
6970
  if (bare || p.wield && !top || p.railed || p.rifled || busy || p.reload || !p.wield && !p.mag) p.charge = 0;
6971
+ const pistol = hand == 0 && !busy && !p.reload && !p.charge && !!p.mag;
6972
+ p.burst = pistol ? p.burst ?? 0 : 0;
6973
+ if (pistol && !p.cool && (p.burst || i.keys & KEY.SPECIAL)) {
6974
+ p.burst = (p.burst || 3) - 1;
6975
+ p.power = 1;
6976
+ p.ammo--;
6977
+ p.mag--;
6978
+ p.shots = p.shots + 1 & 255;
6979
+ p.cool = p.burst ? Math.ceil(kit.cool / 2) : Math.min(15, kit.cool * 2);
6980
+ return STRIKE.SHOT;
6981
+ }
6982
+ if (p.railed && i.keys & KEY.SPECIAL && !busy && !p.reload && !p.hot && p.cap >= RING_COST) {
6983
+ p.rail -= RING_COST;
6984
+ p.cap -= RING_COST;
6985
+ [p.heat, p.hot] = [120, true];
6986
+ p.shots = p.shots + 1 & 255;
6987
+ return STRIKE.RING;
6988
+ }
6956
6989
  if (p.rifled && i.keys & KEY.SPECIAL && !busy && p.nades && !p.lob) {
6957
6990
  p.nades--;
6958
6991
  [p.lob, p.cool] = [60, 7];
@@ -9295,7 +9328,7 @@ function encodeSnapshot(s, meta) {
9295
9328
  v.setUint8(o + 44, p.hits);
9296
9329
  v.setUint8(o + 45, (p.swing ?? 0) & 63 | ((p.cut ?? 0) & 3) << 6);
9297
9330
  v.setUint8(o + 46, (p.lost ?? 0) & 7 | ((p.cut ?? 0) & 4) << 1 | (p.fried ? 16 : 0) | (p.heavy ? 32 : 0) | (p.armor ?? 0) << 6);
9298
- v.setUint8(o + 47, p.down ? p.fell ?? 0 : p.charge ?? 0);
9331
+ v.setUint8(o + 47, p.down ? p.fell ?? 0 : (p.charge ?? 0) | (p.burst ?? 0) << 6);
9299
9332
  v.setUint8(o + 48, p.lock ?? 0);
9300
9333
  v.setUint8(o + 49, (p.foe ?? 0) & 15 | (p.dashes & 2) << 3 | (p.hp & 8) << 2 | (p.mode & 8) << 3 | (p.pressed ? 128 : 0));
9301
9334
  v.setUint8(o + 50, p.pushes ?? 0);
@@ -9704,6 +9737,7 @@ var Room = class {
9704
9737
  else if (struck === STRIKE.RAIL) this.rail(p, input.view);
9705
9738
  else if (struck === STRIKE.LASER) this.shoot(p, input.view);
9706
9739
  else if (struck === STRIKE.NADE) this.shoot(p, input.view, lob(p.state, p.info.team));
9740
+ else if (struck === STRIKE.RING) this.ring(p, input.view);
9707
9741
  else if (struck === STRIKE.DISK) this.shoot(p, input.view, disk(p.state, p.info.team));
9708
9742
  Object.assign(p.state, here);
9709
9743
  if (use && r && p.state.mode === MODE.RIDE) leave(p.state, r, 1, this.world);
@@ -10428,6 +10462,43 @@ var Room = class {
10428
10462
  const foe = this.players().find((q) => q.info.id === target.id);
10429
10463
  if (foe) this.shot(foe, 3, p, aimed.d[0], aimed.d[2]);
10430
10464
  }
10465
+ /**
10466
+ * The rail gun's ring of `p` at the view tick `view`: every enemy within RING_R of him as `p` drew
10467
+ * him, within RING_H of his height and in sight of his chest, is drained as the bolt drains (a
10468
+ * first hp at once) and, still up and in no lock, shocked out of the ring. One hit for `p`.
10469
+ */
10470
+ ring(p, view) {
10471
+ const me = p.state;
10472
+ const c = [
10473
+ me.x,
10474
+ me.y + 1,
10475
+ me.z
10476
+ ];
10477
+ let hit = false;
10478
+ for (const seen of this.enemies(p, view)) {
10479
+ const foe = this.players().find((q) => q.info.id === seen.id);
10480
+ const [dx, dz] = [seen.x - me.x, seen.z - me.z];
10481
+ const d = Math.hypot(dx, dz);
10482
+ if (!foe || d > RING_R + .4 || Math.abs(seen.y - me.y) > RING_H || hidden(this.world, c, [
10483
+ seen.x,
10484
+ seen.y + 1,
10485
+ seen.z
10486
+ ])) continue;
10487
+ hit = true;
10488
+ [foe.burn, foe.railer, foe.state.slow] = [
10489
+ 0,
10490
+ p,
10491
+ 180
10492
+ ];
10493
+ this.fry(foe);
10494
+ if (!foe.state.down && !foe.state.lock) {
10495
+ stumble(foe.state, dx / (d || 1), dz / (d || 1), 24, 4);
10496
+ foe.state.zap = true;
10497
+ foe.by = p.info.id;
10498
+ }
10499
+ }
10500
+ if (hit) me.hits = me.hits + 1 & 255;
10501
+ }
10431
10502
  /** 1 hp of the bolt's drain to `foe`, as his railer deals it; if it puts him down he is disintegrated (`fried`). */
10432
10503
  fry(foe) {
10433
10504
  const r = foe.railer?.state ?? foe.state;
@@ -35,6 +35,8 @@ export interface Tracer {
35
35
  blast(at: Vec3, size?: number): void;
36
36
  /** A shock wave from `at`: a ring of fire flat on the ground, out to `r` metres as it fades. */
37
37
  ring(at: Vec3, r: number): void;
38
+ /** The rail gun's discharge round `at` (the feet): a loop of lightning out to `r` metres and bolts out to it, flickering as it fades. */
39
+ tesla(at: Vec3, r: number): void;
38
40
  /**
39
41
  * A short jagged bolt from `a` to `b` with a fork off its kink, gone in a twentieth of a second:
40
42
  * an arc on a damaged hull, `wide` times as thick as the katana's bolts.
@@ -98,6 +98,8 @@ export declare const FINGER_SIDES = 10;
98
98
  type Ring = [c: Vec3, x: Vec3, y: Vec3];
99
99
  /** The curl the xenomorph's fingers close to at most. */
100
100
  export declare const RAKE = 0.35;
101
+ export declare const HUNTER_HAND: Vec3;
102
+ type Claws = boolean | 'short';
101
103
  /** The ring of a finger from which on it is bare: the glove's fingers end 60 % along the middle phalanx. */
102
104
  export declare const BARE = 8;
103
105
  /**
@@ -140,7 +142,7 @@ lite?: boolean,
140
142
  /** The marine's: lit buttons on the strap round the wrist (WRIST_LIGHTS). */
141
143
  lights?: boolean,
142
144
  /** The xenomorph's claws on the fingertips (Grip). */
143
- claws?: boolean,
145
+ claws?: Claws,
144
146
  /** Its size: the xenomorph's grows from the wrist over 4 cm, hers is smaller (hands()). */
145
147
  grow?: number) => void;
146
148
  /** What a hand does besides closing (hand()): the left index pointing, the right thumb pushing toward `to`, the left thumb cupped. */
@@ -152,7 +154,7 @@ export interface Grip {
152
154
  /** The marine's lit buttons on the wrists' straps. */
153
155
  lights?: boolean;
154
156
  /** The xenomorph's: a hooked claw of bone on each fingertip, for the nail. */
155
- claws?: boolean;
157
+ claws?: Claws;
156
158
  }
157
159
  /**
158
160
  * Both hands of the skeleton `s` on its wrists, left then right, each closed `curls[i]` (hand()), in
@@ -58,7 +58,7 @@ export declare const dreadful: (was: {
58
58
  life: number;
59
59
  vy: number;
60
60
  }, p: PlayerState) => boolean;
61
- export declare const createCombat: (world: World, audio: Pick<Audio, "play"> & Partial<Pick<Audio, "loop">>, hud: Pick<Hud, "vitals" | "hit" | "down">, fx: Pick<Effects, "fire" | "cut" | "wound" | "lie" | "quake" | "blow" | "punch">, tracer: Pick<Tracer, "flash" | "burst" | "blast" | "orbs" | "update" | "mount" | "crackle" | "charging" | "lightning">, ctl: {
61
+ export declare const createCombat: (world: World, audio: Pick<Audio, "play"> & Partial<Pick<Audio, "loop">>, hud: Pick<Hud, "vitals" | "hit" | "down">, fx: Pick<Effects, "fire" | "cut" | "wound" | "lie" | "quake" | "blow" | "punch">, tracer: Pick<Tracer, "flash" | "burst" | "blast" | "orbs" | "update" | "mount" | "crackle" | "charging" | "lightning" | "tesla">, ctl: {
62
62
  pitch: number;
63
63
  }, balls: Pick<Balls, "fire" | "frame">,
64
64
  /** The muzzle of a runner's long gun as last drawn, from his feet (Renderer.muzzle()). */
@@ -1,2 +1,5 @@
1
+ import type { Vec3 } from './mesh';
1
2
  export declare function hunter(lod: 0 | 1 | 2): Record<string, number[]>;
3
+ /** Model-space cut trail on the same scaled mount as the baked blades. */
4
+ export declare const hunterWristEnds: () => Vec3[];
2
5
  export declare const hunterHarpoon: (lod: 0 | 1 | 2) => number[];
@@ -15,11 +15,9 @@ export declare const S: number, C: number;
15
15
  * rounded-square guard, a grip wrapped in a violet check and a pommel with a glowing bead.
16
16
  */
17
17
  export declare const katana: (lod: number) => number[];
18
- /** The Hunter's twin inward-curving wrist blades and forearm bracelet, in the hand's local space. */
18
+ /** Right wrist space: +x over the knuckles, -y along the fingers, z across the hand. */
19
19
  export declare const wristBlade: (lod: number) => number[];
20
- /** Places the wrist blade at the Hunter's right wrist. */
21
20
  export declare const heldWrist: (out: Out, pos: Vec3, q: Quat, lod: number, k?: number, list?: Pieces) => void;
22
- /** The blade's sweep endpoints for the Hunter's cut trail. */
23
21
  export declare const wristEnds: (pos: Vec3, q: Quat) => Vec3[];
24
22
  /** Appends arcs of lightning flickering along the blade at the clock `t` (s): a few zigzags of thin crossed ribbons, each new every 70 ms. */
25
23
  export declare const arcs: (out: Out, at: Vec3, [r, u, f]: Vec3[], t: number, lod: number, k?: number) => void;
@@ -347,6 +347,11 @@ export declare const GUN_COOLDOWN = 7;
347
347
  export declare const CHARGE_TAP = 10;
348
348
  export declare const CHARGE_TICKS = 60;
349
349
  export declare const CHARGE_MAX = 5;
350
+ /**
351
+ * The pistol's burst (the user, 2026-11-23): G or the right button with it in hand fires BURST plain
352
+ * shots, half its cooldown apart, then waits twice its cooldown (15 ticks at most: `cool` has 4 bits).
353
+ */
354
+ export declare const BURST = 3;
350
355
  /** Metres a shot reaches: a plasma ball that has flown this far is gone. */
351
356
  export declare const GUN_RANGE = 80;
352
357
  /**
@@ -501,6 +506,14 @@ export declare const RAIL_RANGE = 30;
501
506
  export declare const HEAT_MAX = 120;
502
507
  export declare const HEAT_COOL = 2;
503
508
  export declare const HEAT_LOCK = 0;
509
+ /**
510
+ * The rail gun's ring (the user, 2026-11-23): G or the right button with it in hand spends RING_COST
511
+ * ticks of the capsule in one discharge round the player, which overheats the gun (HEAT_MAX, 2 s to
512
+ * cool; the user asked for a smaller one than the first 6 m). Every enemy within RING_R metres on the floor plane and RING_H of his height, in sight of
513
+ * his chest, takes 1 hp, is drained as the bolt drains (RAIL_TICKS, slowed under SLOW_SPEED) and
514
+ * shocked as a katana shocks (SHOCK_TICKS, thrown out of the ring).
515
+ */
516
+ export declare const RING_COST: number, RING_R: number, RING_H: number;
504
517
  export declare const RAIL_TICKS = 180;
505
518
  export declare const RAIL_DRAIN = 60;
506
519
  export declare const SLOW_SPEED = 3;
@@ -16,6 +16,7 @@ export declare const STRIKE: {
16
16
  readonly LASER: 4;
17
17
  readonly NADE: 5;
18
18
  readonly DISK: 6;
19
+ readonly RING: 7;
19
20
  };
20
21
  export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
21
22
  /**
@@ -198,6 +198,12 @@ export declare class Room {
198
198
  private shoulderTarget;
199
199
  /** Fires only after an uninterrupted three-second target lock; damage is three HP. */
200
200
  private shoulder;
201
+ /**
202
+ * The rail gun's ring of `p` at the view tick `view`: every enemy within RING_R of him as `p` drew
203
+ * him, within RING_H of his height and in sight of his chest, is drained as the bolt drains (a
204
+ * first hp at once) and, still up and in no lock, shocked out of the ring. One hit for `p`.
205
+ */
206
+ private ring;
201
207
  /** 1 hp of the bolt's drain to `foe`, as his railer deals it; if it puts him down he is disintegrated (`fried`). */
202
208
  private fry;
203
209
  /**
@@ -60,7 +60,8 @@ export declare const KEY: {
60
60
  /**
61
61
  * Set for one step by G or the right button (the client's choice): with the katana in hand, the
62
62
  * special of the cut the keys give (see CUT); with the laser rifle in hand, a grenade from its
63
- * launcher. Ignored with the other guns.
63
+ * launcher; with the pistol, a burst of BURST shots; with the rail gun, a discharge all round
64
+ * (RING_R).
64
65
  */
65
66
  readonly SPECIAL: 1024;
66
67
  /**
@@ -256,6 +257,8 @@ export interface PlayerState {
256
257
  inRifle?: boolean;
257
258
  /** Ticks FIRE has been held with the gun, up to CHARGE_TICKS, 0 when not charging. Absent reads 0. */
258
259
  charge?: number;
260
+ /** Shots left in the pistol's burst (G), 0 to BURST - 1. Absent reads 0. */
261
+ burst?: number;
259
262
  /** The strength of the last shot, 1 to CHARGE_MAX: the shots it spent and the health it takes. Set by the step that fires; not on the wire. */
260
263
  power?: number;
261
264
  /** Standing inside the circle of the team's rack as of the last step: the gun is filled on arrival only. Absent reads false. */
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.202.3",
5
+ "version": "0.203.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"