@korial29/tiny-fps 0.175.0 → 0.176.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
@@ -182,7 +182,6 @@ var [PUNCH_HITS, PUNCH_STUN, PUNCH_MEMORY] = [
182
182
  3,
183
183
  180
184
184
  ];
185
- var CLING_SPEED = 4.5;
186
185
  var [POUNCE_MIN, POUNCE_MAX, POUNCE_PITCH] = [
187
186
  9,
188
187
  17,
@@ -190,6 +189,20 @@ var [POUNCE_MIN, POUNCE_MAX, POUNCE_PITCH] = [
190
189
  ];
191
190
  var [POUNCE_COOL, POUNCE_FLY] = [48, 40];
192
191
  var [POUNCE_HP, POUNCE_STUN] = [2, 60];
192
+ /**
193
+ * The glory kill (the user, 2026-11-16, after DOOM 2016): an enemy with GLORY_HP health or less, up,
194
+ * flashes in the xenomorph's vision and to one with the katana in hand, who beheads him on E; E (KEY.USE) within GLORY_REACH metres of him and GLORY_ARC
195
+ * radians of its look locks the two (`lock`, `foe`, as a saber lock) for GLORY_TICKS, where neither
196
+ * moves, then it eats his head: he goes down through his armour (LIMB.EATEN), a frag of FRAG.GLORY.
197
+ */
198
+ var [GLORY_HP, GLORY_REACH, GLORY_ARC, GLORY_TICKS] = [
199
+ 3,
200
+ 2.5,
201
+ 1,
202
+ 54
203
+ ];
204
+ /** How much faster than a man the xenomorph runs (the user, 2026-11-16: a little, not twice). */
205
+ var XENO_PACE = 1.25;
193
206
  var PLASMA_R = .12;
194
207
  /**
195
208
  * What a vehicle's bolts take (the user, 2026-11-16: stronger, they grazed like the rifle's rounds):
@@ -596,7 +609,9 @@ var LIMB = {
596
609
  ARM_L: 2,
597
610
  ARM_R: 3,
598
611
  LEG_L: 4,
599
- LEG_R: 5
612
+ LEG_R: 5,
613
+ /** The head a xenomorph's glory kill ate (GLORY_HP): gone, not thrown. */
614
+ EATEN: 6
600
615
  };
601
616
  /**
602
617
  * How a player went down (bits 5-6 of PlayerState.fell), for the clients' fall: PLAIN as before,
@@ -744,11 +759,11 @@ var KITS = [
744
759
  MARINE,
745
760
  {
746
761
  ...MARINE,
747
- run: 12,
748
- sprint: 18,
762
+ run: 6 * XENO_PACE,
763
+ sprint: 9 * XENO_PACE,
749
764
  jump: 7 * Math.SQRT2,
750
765
  double: 6 * Math.SQRT2,
751
- accel: 2,
766
+ accel: XENO_PACE,
752
767
  ammo: 0,
753
768
  rail: 0,
754
769
  rifle: 0,
@@ -1598,7 +1613,7 @@ var cling = (p, w, c) => {
1598
1613
  const up = (c.keys & KEY.FORWARD ? 1 : 0) - (c.keys & KEY.BACK ? 1 : 0);
1599
1614
  const s = (c.keys & KEY.RIGHT ? 1 : 0) - (c.keys & KEY.LEFT ? 1 : 0);
1600
1615
  const [tx, tz] = [-nz, nx];
1601
- const k = (tx * -c.fz + tz * c.fx >= 0 ? s : -s) * CLING_SPEED;
1616
+ const k = (tx * -c.fz + tz * c.fx >= 0 ? s : -s) * 8;
1602
1617
  const { a, sign } = along(p, p.wall);
1603
1618
  if (up > 0 && hold.top < p.y + 1.8) {
1604
1619
  const land = hold.face + sign * CLIMB_INSET;
@@ -1612,7 +1627,7 @@ var cling = (p, w, c) => {
1612
1627
  }
1613
1628
  p.vx = tx * k;
1614
1629
  p.vz = tz * k;
1615
- p.vy = up > 0 && hold.top - p.y <= .45 ? 0 : up * CLING_SPEED;
1630
+ p.vy = up > 0 && hold.top - p.y <= .45 ? 0 : up * 8;
1616
1631
  const pull = Math.min(hold.gap, 4 * DT$2);
1617
1632
  p.x += nx * pull;
1618
1633
  p.z += nz * pull;
@@ -6272,6 +6287,23 @@ var pouncing = (p) => p.mode === MODE.AIR && p.dash > POUNCE_COOL - POUNCE_FLY &
6272
6287
  * two radii and the reach on the floor plane, and their heights (low in a slide) overlap.
6273
6288
  */
6274
6289
  var reaches = (a, b) => Math.hypot(a.x - b.x, a.z - b.z) < 1.1 && a.y < b.y + heightOf(b) && b.y < a.y + heightOf(a);
6290
+ /**
6291
+ * The enemy the xenomorph `me` would glory kill with E (room.ts feast()), of `foes` as it sees
6292
+ * them: the nearest one up, in no lock and not seated, with GLORY_HP health or less, within
6293
+ * GLORY_REACH on the floor plane, a body's height above or below, and GLORY_ARC of its look.
6294
+ */
6295
+ var glory = (me, foes) => {
6296
+ const [fx, fz] = forward(me.yaw);
6297
+ let best;
6298
+ let near = GLORY_REACH;
6299
+ for (const f of foes) {
6300
+ const [dx, dz] = [f.x - me.x, f.z - me.z];
6301
+ const d = Math.hypot(dx, dz);
6302
+ const facing = d < .001 || Math.acos(Math.min(1, (dx * fx + dz * fz) / d)) <= GLORY_ARC;
6303
+ if (!f.down && !f.lock && f.mode !== MODE.RIDE && f.hp <= GLORY_HP && d <= near && Math.abs(f.y - me.y) < 1.8 && facing) [best, near] = [f, d];
6304
+ }
6305
+ return best;
6306
+ };
6275
6307
  // src/shared/gun.ts
6276
6308
  /** Whether the feet of `p` are within `r` of the point `at` on the floor plane and within PICK_H of its height. */
6277
6309
  var within = (p, at, r) => {
@@ -6552,7 +6584,7 @@ var duel = (p, i) => {
6552
6584
  p.away = i.keys & (KEY.LEFT | KEY.RIGHT | KEY.BACK) ? Math.min((p.away ?? 0) + 1, 24) : 0;
6553
6585
  p.lock = Math.max(1, p.lock - 1);
6554
6586
  [p.wield, p.swing, p.charge] = [
6555
- true,
6587
+ !!p.blade,
6556
6588
  0,
6557
6589
  0
6558
6590
  ];
@@ -8305,7 +8337,9 @@ var FRAG = {
8305
8337
  RAIL: 3,
8306
8338
  NADE: 4,
8307
8339
  VEHICLE: 5,
8308
- CLAW: 6
8340
+ CLAW: 6,
8341
+ /** The xenomorph's pounce that ate his head (GLORY_HP). */
8342
+ GLORY: 7
8309
8343
  };
8310
8344
  /** A rover's floats, in wire order. */
8311
8345
  var ROVER_F = [...[
@@ -8784,7 +8818,7 @@ var Room = class {
8784
8818
  else if (struck === STRIKE.NADE) this.shoot(p, input.view, lob(p.state, p.info.team));
8785
8819
  Object.assign(p.state, here);
8786
8820
  if (use && r && p.state.mode === MODE.RIDE) leave(p.state, r, 1, this.world);
8787
- else if (use && !this.press(p)) this.enter(p);
8821
+ else if (use && !this.feast(p, input.view) && !this.press(p)) this.enter(p);
8788
8822
  }
8789
8823
  p.burn = slow ? (p.burn ?? 0) + 1 : 0;
8790
8824
  if (slow && !(p.burn % 60)) this.fry(p);
@@ -9359,6 +9393,73 @@ var Room = class {
9359
9393
  foe.state.fried = this.shot(foe, 1, foe.railer, foe.state.x - r.x, foe.state.z - r.z, FRAG.RAIL);
9360
9394
  }
9361
9395
  /**
9396
+ * E pressed by `p`, the xenomorph or one with the katana in hand: the nearest enemy who is up with
9397
+ * GLORY_HP or less, within GLORY_REACH and GLORY_ARC of its look where `p` drew him, and in no
9398
+ * lock, is glory killed. The katana takes his head at once and throws the body back GLORY_PUSH
9399
+ * m/s, the follow-through of a cut across in hand (the user, 2026-11-16). The xenomorph holds
9400
+ * him: the two locked (`lock`, `foe`) for GLORY_TICKS, his flag dropped, `p` brought in a metre
9401
+ * from him; duel() ends it. True when it happened.
9402
+ */
9403
+ feast(p, view) {
9404
+ const me = p.state;
9405
+ const xeno = this.kit(p).xeno;
9406
+ if (!xeno && !me.wield || me.down || me.stun || me.lock || me.mode === MODE.RIDE) return false;
9407
+ const seen = glory(me, this.enemies(p, view).flatMap((s) => {
9408
+ const q = this.players().find((o) => o.info.id === s.id);
9409
+ const { hp, down, lock, mode } = q?.state ?? s;
9410
+ return q ? [{
9411
+ ...s,
9412
+ hp,
9413
+ down,
9414
+ lock,
9415
+ mode
9416
+ }] : [];
9417
+ }));
9418
+ const foe = this.players().find((q) => q.info.id === seen?.id);
9419
+ if (!seen || !foe) return false;
9420
+ const [dx, dz] = [seen.x - me.x, seen.z - me.z];
9421
+ const d = Math.hypot(dx, dz) || 1;
9422
+ if (!xeno) {
9423
+ const c = CUTS[CUT.RIGHT];
9424
+ [me.cut, me.swing, me.heavy, me.charge] = [
9425
+ CUT.RIGHT,
9426
+ c.ticks - c.strike - 1,
9427
+ false,
9428
+ 0
9429
+ ];
9430
+ me.hits = me.hits + 1 & 255;
9431
+ this.harm(foe, Infinity, p, FRAG.GLORY, felled(FALL$1.STRUCK, dx / d, dz / d));
9432
+ Object.assign(foe.state, {
9433
+ lost: LIMB.HEAD,
9434
+ vx: dx / d * 7,
9435
+ vy: 3,
9436
+ vz: dz / d * 7,
9437
+ ground: false,
9438
+ mode: MODE.AIR
9439
+ });
9440
+ return true;
9441
+ }
9442
+ this.drop(foe.info.id);
9443
+ for (const [a, b] of [[p, foe], [foe, p]]) {
9444
+ Object.assign(a.state, {
9445
+ ...FREE,
9446
+ lock: GLORY_TICKS,
9447
+ foe: b.info.id,
9448
+ pressed: true
9449
+ });
9450
+ Object.assign(a.state, {
9451
+ swing: 0,
9452
+ charge: 0,
9453
+ stun: 0,
9454
+ zap: false,
9455
+ vx: 0,
9456
+ vz: 0
9457
+ });
9458
+ }
9459
+ if (d > 1) [me.x, me.z] = [Math.fround(me.x + dx * (d - 1) / d), Math.fround(me.z + dz * (d - 1) / d)];
9460
+ return true;
9461
+ }
9462
+ /**
9362
9463
  * A saber lock of `p`, after his input: it ends when a side leads by LOCK_WIN presses (the other
9363
9464
  * takes LOCK_HP and the katana's shock, thrown along the winner's look), when one has stepped out
9364
9465
  * (LOCK_BREAK ticks of a side or back key: both are free), or when it has run its LOCK_TICKS (both
@@ -9372,6 +9473,19 @@ var Room = class {
9372
9473
  Object.assign(q, FREE);
9373
9474
  return;
9374
9475
  }
9476
+ const [x, y] = [p, o].map((r) => this.kit(r).xeno);
9477
+ if (x !== y) {
9478
+ if (q.lock > 1 && o.state.lock > 1) return;
9479
+ const [eater, prey] = x ? [p, o] : [o, p];
9480
+ Object.assign(q, FREE);
9481
+ Object.assign(o.state, FREE);
9482
+ eater.state.hits = eater.state.hits + 1 & 255;
9483
+ const [dx, dz] = [prey.state.x - eater.state.x, prey.state.z - eater.state.z];
9484
+ const d = Math.hypot(dx, dz) || 1;
9485
+ this.harm(prey, Infinity, eater, FRAG.GLORY, felled(FALL$1.STRUCK, dx / d, dz / d));
9486
+ prey.state.lost = LIMB.EATEN;
9487
+ return;
9488
+ }
9375
9489
  const lead = (q.pushes ?? 0) - (o.state.pushes ?? 0);
9376
9490
  const out = (q.away ?? 0) >= 24 || (o.state.away ?? 0) >= 24;
9377
9491
  if (Math.abs(lead) < 8 && !out && q.lock > 1) return;
@@ -161,5 +161,11 @@ export interface Grip {
161
161
  export declare const hands: (out: Out, s: Solved, build: number, curls: number[], glove: number[], bare: number[], { point, push, to, cup, lights, claws }?: Grip, lite?: boolean, skip?: number) => void;
162
162
  /** On a wall run the rail gun is put away, unless its bolt is going out. */
163
163
  export declare const stowed: (p: PlayerState) => boolean;
164
+ /**
165
+ * The bite of a glory kill (the user, 2026-11-16, after DOOM 2016) at `lock` ticks left of its
166
+ * GLORY_TICKS: the head drawn back over the first two thirds as the claws hold the prey, then
167
+ * driven down into him; the neck's turn for menace().
168
+ */
169
+ export declare const devour: (lock: number) => number;
164
170
  export declare const createBody: (world?: World) => Body;
165
171
  export {};
@@ -14,6 +14,8 @@ export type Ground = (x: number, y: number, z: number) => number;
14
14
  export declare const ground: (world: World | undefined, y0: number) => Ground;
15
15
  export interface Piece {
16
16
  limb: number;
17
+ /** The head a xenomorph ate (LIMB.EATEN): the stump is drawn, raw and unlit, not the piece. */
18
+ eaten?: boolean;
17
19
  /** The joints in the pose of the cut, which the limb is skinned with, and its middle then. */
18
20
  s: ReturnType<typeof solve>;
19
21
  c: Vec3;
@@ -153,6 +153,8 @@ export interface Renderer {
153
153
  parried(id: number, late: number): void;
154
154
  /** The xenomorph's vision (the own player is one): a grey-blue world, the enemies in sight glowing. */
155
155
  vision(on: boolean): void;
156
+ /** The own katana in hand (the user, 2026-11-16): an enemy it could glory kill flashes. */
157
+ edge(on: boolean): void;
156
158
  /** The body of each player (PlayerInfo.body, BODY), from the roster: the man's for one not in it; and the skin and haircut he picked, his id's for one not in `looks`. */
157
159
  wear(builds: ReadonlyMap<number, number>, looks?: ReadonlyMap<number, Choice>): void;
158
160
  /**
@@ -258,16 +258,17 @@ export declare const TAIL_LEAP = 10;
258
258
  export declare const PUNCH_HITS: number, PUNCH_STUN: number, PUNCH_MEMORY: number;
259
259
  /**
260
260
  * The xenomorph (the user, 2026-11-15; kit.ts). XENO_HP health. It clings to a wall it faces with
261
- * forward and the sprint held (MODE.CLING, physics.ts; the sprint since the user, 2026-11-16): CLING_SPEED m/s up, down or along it while the wall rises
262
- * CLING_HOLD m over its feet; a jump kicks it off along the look at CLING_LEAP m/s. DASH held on a
263
- * floor or a wall charges a pounce for up to POUNCE_HOLD ticks (PlayerState.charge); let go, it
264
- * leaps POUNCE_MIN to POUNCE_MAX m/s toward the keys held (the look with none), at least POUNCE_PITCH up, and the dash timer
265
- * runs from POUNCE_COOL: the first POUNCE_FLY ticks of it in the air, an enemy it reaches is
266
- * pinned (room.ts): POUNCE_HP health, his flag dropped, a stumble of POUNCE_STUN ticks. An enemy
267
- * whose katana or fists hit it loses ACID_HP.
261
+ * forward and the sprint held (MODE.CLING, physics.ts; the sprint since the user, 2026-11-16):
262
+ * CLING_SPEED m/s up, down or along it (faster than a man runs, the user 2026-11-16: it was slow)
263
+ * while the wall rises CLING_HOLD m over its feet; a jump kicks it off along the look at CLING_LEAP
264
+ * m/s. DASH held on a floor or a wall charges a pounce for up to POUNCE_HOLD ticks
265
+ * (PlayerState.charge); let go, it leaps POUNCE_MIN to POUNCE_MAX m/s toward the keys held (the
266
+ * look with none), at least POUNCE_PITCH up, and the dash timer runs from POUNCE_COOL: the first
267
+ * POUNCE_FLY ticks of it in the air, an enemy it reaches is pinned (room.ts): POUNCE_HP health, his
268
+ * flag dropped, a stumble of POUNCE_STUN ticks. An enemy whose katana or fists hit it loses ACID_HP.
268
269
  */
269
270
  export declare const XENO_HP = 12;
270
- export declare const CLING_SPEED = 4.5;
271
+ export declare const CLING_SPEED = 8;
271
272
  export declare const CLING_FACING = 0.6;
272
273
  export declare const CLING_HOLD = 0.4;
273
274
  export declare const CLING_LEAP = 10;
@@ -275,6 +276,17 @@ export declare const POUNCE_HOLD = 36;
275
276
  export declare const POUNCE_MIN: number, POUNCE_MAX: number, POUNCE_PITCH: number;
276
277
  export declare const POUNCE_COOL: number, POUNCE_FLY: number;
277
278
  export declare const POUNCE_HP: number, POUNCE_STUN: number;
279
+ /**
280
+ * The glory kill (the user, 2026-11-16, after DOOM 2016): an enemy with GLORY_HP health or less, up,
281
+ * flashes in the xenomorph's vision and to one with the katana in hand, who beheads him on E; E (KEY.USE) within GLORY_REACH metres of him and GLORY_ARC
282
+ * radians of its look locks the two (`lock`, `foe`, as a saber lock) for GLORY_TICKS, where neither
283
+ * moves, then it eats his head: he goes down through his armour (LIMB.EATEN), a frag of FRAG.GLORY.
284
+ */
285
+ export declare const GLORY_HP: number, GLORY_REACH: number, GLORY_ARC: number, GLORY_TICKS: number;
286
+ /** The katana's glory kill (room.ts feast()): the speed it throws the beheaded body back at. */
287
+ export declare const GLORY_PUSH = 7;
288
+ /** How much faster than a man the xenomorph runs (the user, 2026-11-16: a little, not twice). */
289
+ export declare const XENO_PACE = 1.25;
278
290
  export declare const ACID_HP = 1;
279
291
  /** Shots the rack loads. */
280
292
  export declare const AMMO_MAX = 60;
@@ -34,6 +34,8 @@ export declare const FRAG: {
34
34
  readonly NADE: 4;
35
35
  readonly VEHICLE: 5;
36
36
  readonly CLAW: 6;
37
+ /** The xenomorph's pounce that ate his head (GLORY_HP). */
38
+ readonly GLORY: 7;
37
39
  };
38
40
  export type ServerText =
39
41
  /**
@@ -183,6 +183,15 @@ export declare class Room {
183
183
  private rail;
184
184
  /** 1 hp of the bolt's drain to `foe`, as his railer deals it; if it puts him down he is disintegrated (`fried`). */
185
185
  private fry;
186
+ /**
187
+ * E pressed by `p`, the xenomorph or one with the katana in hand: the nearest enemy who is up with
188
+ * GLORY_HP or less, within GLORY_REACH and GLORY_ARC of its look where `p` drew him, and in no
189
+ * lock, is glory killed. The katana takes his head at once and throws the body back GLORY_PUSH
190
+ * m/s, the follow-through of a cut across in hand (the user, 2026-11-16). The xenomorph holds
191
+ * him: the two locked (`lock`, `foe`) for GLORY_TICKS, his flag dropped, `p` brought in a metre
192
+ * from him; duel() ends it. True when it happened.
193
+ */
194
+ private feast;
186
195
  /**
187
196
  * A saber lock of `p`, after his input: it ends when a side leads by LOCK_WIN presses (the other
188
197
  * takes LOCK_HP and the katana's shock, thrown along the winner's look), when one has stepped out
@@ -11,3 +11,9 @@ export declare const pouncing: (p: PlayerState) => boolean;
11
11
  * two radii and the reach on the floor plane, and their heights (low in a slide) overlap.
12
12
  */
13
13
  export declare const reaches: (a: PlayerState, b: PlayerState) => boolean;
14
+ /**
15
+ * The enemy the xenomorph `me` would glory kill with E (room.ts feast()), of `foes` as it sees
16
+ * them: the nearest one up, in no lock and not seated, with GLORY_HP health or less, within
17
+ * GLORY_REACH on the floor plane, a body's height above or below, and GLORY_ARC of its look.
18
+ */
19
+ export declare const glory: (me: PlayerState, foes: readonly PlayerState[]) => PlayerState | undefined;
@@ -106,6 +106,8 @@ export declare const LIMB: {
106
106
  readonly ARM_R: 3;
107
107
  readonly LEG_L: 4;
108
108
  readonly LEG_R: 5;
109
+ /** The head a xenomorph's glory kill ate (GLORY_HP): gone, not thrown. */
110
+ readonly EATEN: 6;
109
111
  };
110
112
  /**
111
113
  * How a player went down (bits 5-6 of PlayerState.fell), for the clients' fall: PLAIN as before,
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.175.0",
5
+ "version": "0.176.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"