@korial29/tiny-fps 0.174.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;
@@ -16,9 +16,9 @@ export interface Audio {
16
16
  /**
17
17
  * Plays the sound `id` (an index into the layers). With `at`, panned left or right by its direction from the listener and
18
18
  * fainter with distance; without, centred (the own player's sounds). `gain` scales the volume,
19
- * `rate` the speed and so the pitch.
19
+ * `rate` the speed and so the pitch; over the `radio` as speak() says a line.
20
20
  */
21
- play(id: number, at?: Vec3, gain?: number, rate?: number): void;
21
+ play(id: number, at?: Vec3, gain?: number, rate?: number, radio?: boolean): void;
22
22
  /**
23
23
  * Says the announcer's line `id` (LINE), centred, the music lowered under it. Lines wait their
24
24
  * turn, two at most and each once; none before the voice is decoded, a moment after unlock.
@@ -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
  /**
@@ -140,6 +140,8 @@ export declare const SOUND: {
140
140
  * noise is quiet (lp 0.06 keeps about a tenth of the swing): the loops have a high volume.
141
141
  */
142
142
  export declare const LAYERS: Voice[][];
143
+ /** The seconds sound `id` lasts: its longest voice, from its start late to the end of its decay. */
144
+ export declare const secondsOf: (id: number, layers?: Voice[][]) => number;
143
145
  /** The sounds played in a loop: their buffers go through seam. */
144
146
  export declare const LOOPED: number[];
145
147
  /**
@@ -6,8 +6,8 @@ export declare const TAUNT_DELAY = 0.6;
6
6
  export declare const TAUNT_LATE = 1.3;
7
7
  /** Seconds a player keeps quiet after a taunt: a quick run of frags gets one. */
8
8
  export declare const TAUNT_GAP = 4;
9
- /** The voice of player `id` in a build (BODY): one of the man's or one of the woman's. */
10
- export declare const speakerOf: (id: number, body?: number) => number;
9
+ /** The voice of player `id` in a build (BODY): one of the man's or one of the woman's, a ninja's own. */
10
+ export declare const speakerOf: (id: number, body?: number, ninja?: boolean) => number;
11
11
  /** A player's speed of speech, a little off the next's by his id, so that two in a voice differ. */
12
12
  export declare const paceOf: (id: number) => number;
13
13
  /**
@@ -17,7 +17,7 @@ export declare const paceOf: (id: number) => number;
17
17
  export declare const tauntOf: (speaker: number, how: number, n: number) => number;
18
18
  /** The clip (CAST) of `speaker`'s `k`th cry as he goes down. */
19
19
  export declare const deathOf: (speaker: number, k: number) => number;
20
- /** An ally's line that began: who says it, and its seconds. */
20
+ /** A line over the radio that began: who says it, and its seconds. */
21
21
  export interface Said {
22
22
  by: number;
23
23
  s: number;
@@ -34,16 +34,17 @@ export interface Taunts {
34
34
  n: number;
35
35
  }, me: number, now: number, wait?: number): void;
36
36
  /**
37
- * Says the taunts due at `now` (s): the own and the one aimed at the own player centred, an
38
- * ally's over the radio wherever he is, an enemy's from where `where` draws him (feet), unheard
39
- * when it does not draw him. Returns the allies' lines that began.
37
+ * Says the taunts due at `now` (s): the own centred, an ally's and the one aimed at the own
38
+ * player over the radio wherever their author is, any other enemy's from where `where` draws him
39
+ * (feet), unheard when it does not draw him; a xenomorph roars in their place. Returns the
40
+ * radio's lines that began.
40
41
  */
41
42
  frame(now: number, where: (id: number) => Vec3 | undefined): Said[];
42
43
  }
43
44
  export declare const createTaunts: (audio: Pick<Audio, "speak"> & Partial<Pick<Audio, "play">>,
44
- /** A player's build (BODY) from the roster. */
45
- body: (id: number) => number | undefined,
45
+ /** A player's voice from the roster (speakerOf()). */
46
+ speaker: (id: number) => number,
46
47
  /** A player's team from the roster. */
47
48
  team?: (id: number) => number | undefined,
48
- /** Whether a player is a xenomorph: it roars (ROAR), with no words and no radio. */
49
+ /** Whether a player is a xenomorph: it roars (ROAR), with no words, over the radio all the same. */
49
50
  beast?: (id: number) => boolean) => Taunts;