@korial29/tiny-fps 0.180.0 → 0.181.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,14 +182,18 @@ var [PUNCH_HITS, PUNCH_STUN, PUNCH_MEMORY] = [
182
182
  3,
183
183
  180
184
184
  ];
185
+ /** Its walk on a wall, a share of its run: the sprint key runs there (the user, 2026-11-16). */
186
+ var CLING_WALK = .5;
185
187
  /** 1.4: a step of its burst stays under PLAYER_R, so it cannot tunnel through a thin brush (physics.ts). */
186
188
  var XENO_DASH = 1.4;
187
189
  var [POUNCE_HP, POUNCE_STUN] = [2, 60];
188
190
  /**
189
191
  * The glory kill (the user, 2026-11-16, after DOOM 2016): an enemy with GLORY_HP health or less, up,
190
- * 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
191
- * radians of its look locks the two (`lock`, `foe`, as a saber lock) for GLORY_TICKS, where neither
192
- * moves, then it eats his head: he goes down through his armour (LIMB.EATEN), a frag of FRAG.GLORY.
192
+ * flashes to one with the katana in hand, who beheads him on E within GLORY_REACH metres. The
193
+ * xenomorph's takes any enemy up, with no flash (the user, 2026-11-16): E within GLORY_FAR metres
194
+ * of him, in sight, and GLORY_ARC radians of its look locks the two (`lock`, `foe`, as a saber
195
+ * lock) for GLORY_TICKS, where he does not move and it dashes to him, then it eats his head: he
196
+ * goes down through his armour (LIMB.EATEN), a frag of FRAG.GLORY.
193
197
  */
194
198
  var [GLORY_HP, GLORY_REACH, GLORY_ARC, GLORY_TICKS] = [
195
199
  3,
@@ -197,6 +201,12 @@ var [GLORY_HP, GLORY_REACH, GLORY_ARC, GLORY_TICKS] = [
197
201
  1,
198
202
  54
199
203
  ];
204
+ /**
205
+ * The xenomorph's glory kill from afar (the user, 2026-11-16): within GLORY_FAR metres, in sight,
206
+ * it dashes to a metre of its prey over the first GLORY_DASH ticks of the lock. 7 m in 20 ticks is
207
+ * 21 m/s, a step under PLAYER_R: it cannot tunnel.
208
+ */
209
+ var [GLORY_FAR, GLORY_DASH] = [8, 20];
200
210
  /** How much faster than a man the xenomorph runs (the user, 2026-11-16: a little, not twice). */
201
211
  var XENO_PACE = 1.25;
202
212
  var PLASMA_R = .12;
@@ -1381,6 +1391,18 @@ var steer$1 = (p, wish, top, run = 6, accel = 1) => {
1381
1391
  p.vz = pz + par * wz;
1382
1392
  };
1383
1393
  /**
1394
+ * A step along its speed, through the boxes and bodies as fly() takes it, with no gravity and no
1395
+ * control: the xenomorph's dash to its glory kill's prey (gun.ts).
1396
+ */
1397
+ var coast = (p, w, bodies) => {
1398
+ fly$1(p, w, heightOf(p), 0, false, bodies);
1399
+ [p.x, p.y, p.z] = [
1400
+ f32$2(p.x),
1401
+ f32$2(p.y),
1402
+ f32$2(p.z)
1403
+ ];
1404
+ };
1405
+ /**
1384
1406
  * Moves the cylinder by its speed for one step: sideways (sliding along the boxes, which takes the
1385
1407
  * speed into them away), then up or down by g times the world's gravity (a ceiling stops a rise, a floor a
1386
1408
  * fall). Returns the speed it came down on a floor at, or -1 when it is not on one. With `snap`
@@ -1594,8 +1616,8 @@ var clingTo = (p, w, c, speed) => {
1594
1616
  /**
1595
1617
  * On a wall, the wall is its floor (the user, 2026-11-16, to roam it freely): the look's heading
1596
1618
  * turned onto it is forward, so W climbs looking at the wall, goes along it looking along it and
1597
- * down it looking away, S the other way, A and D across. Crouch lets go; a jump kicks off it,
1598
- * straight back when looking at it, else along the look. At a top under the head, climbing pulls
1619
+ * down it looking away, S the other way, A and D across. Crouch lets go; a jump leaps where the
1620
+ * view turned over onto the wall looks. At a top under the head, climbing pulls
1599
1621
  * it up onto the top (MODE.CLIMB); down on a floor, it stands.
1600
1622
  */
1601
1623
  var cling = (p, w, c) => {
@@ -1608,16 +1630,11 @@ var cling = (p, w, c) => {
1608
1630
  }
1609
1631
  if (c.jump) {
1610
1632
  enter(p, MODE.AIR);
1611
- if (c.fx * nx + c.fz * nz > .3) {
1612
- p.vx = -nx * WALL_KICK_SPEED;
1613
- p.vz = -nz * WALL_KICK_SPEED;
1614
- leap$1(p, WALL_KICK_UP);
1615
- } else {
1616
- const cp = Math.cos(p.pitch);
1617
- p.vx = c.fx * cp * 10;
1618
- p.vz = c.fz * cp * 10;
1619
- leap$1(p, Math.max(Math.sin(p.pitch) * 10, WALL_KICK_UP / 2));
1620
- }
1633
+ const [cp, out] = [Math.cos(p.pitch) * 10, Math.sin(p.pitch) * 10];
1634
+ const [k, a] = [Math.max(out, WALL_KICK_SPEED / 2), (c.fz * nx - c.fx * nz) * cp];
1635
+ p.vx = -nx * k - nz * a;
1636
+ p.vz = -nz * k + nx * a;
1637
+ leap$1(p, (c.fx * nx + c.fz * nz) * cp);
1621
1638
  return;
1622
1639
  }
1623
1640
  const fw = (c.keys & KEY.FORWARD ? 1 : 0) - (c.keys & KEY.BACK ? 1 : 0);
@@ -1627,8 +1644,9 @@ var cling = (p, w, c) => {
1627
1644
  const [wu, wa] = [fw * hu - s * ha, fw * ha + s * hu];
1628
1645
  const n = Math.sqrt(wu * wu + wa * wa);
1629
1646
  const was = Math.sqrt(p.vx * p.vx + p.vy * p.vy + p.vz * p.vz);
1630
- const run = c.kit.run * c.pace;
1631
- const top = c.keys & KEY.SPRINT ? c.kit.sprint * c.pace : run;
1647
+ const runs = c.keys & KEY.SPRINT;
1648
+ const run = c.kit.run * c.pace * (runs ? 1 : CLING_WALK);
1649
+ const top = runs ? c.kit.sprint * c.pace : run;
1632
1650
  const sp = was > top ? Math.max(top, was - 12 * DT$2) : Math.min(top, Math.max(run, was + 3 * c.kit.accel * DT$2));
1633
1651
  const v = n > 1 ? sp / n : sp;
1634
1652
  const up = wu > .05 ? 1 : wu < -.05 ? -1 : 0;
@@ -6281,19 +6299,29 @@ var pouncing = (p) => p.dash > 50;
6281
6299
  */
6282
6300
  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);
6283
6301
  /**
6284
- * The enemy the xenomorph `me` would glory kill with E (room.ts feast()), of `foes` as it sees
6285
- * them: the nearest one up, in no lock and not seated, with GLORY_HP health or less, within
6286
- * GLORY_REACH on the floor plane, a body's height above or below, and GLORY_ARC of its look.
6302
+ * The enemy `me` would glory kill with E (room.ts feast()), of `foes` as it sees them: the nearest
6303
+ * one up, in no lock and not seated, a body's height above or below and GLORY_ARC of its look. With
6304
+ * the katana (`w` undefined) within GLORY_REACH on the floor plane, with GLORY_HP health or less;
6305
+ * the xenomorph's within GLORY_FAR, in sight through the world `w`, at any health (the user,
6306
+ * 2026-11-16).
6287
6307
  */
6288
- var glory = (me, foes) => {
6308
+ var glory = (me, foes, w) => {
6289
6309
  const [fx, fz] = forward(me.yaw);
6290
6310
  let best;
6291
- let near = GLORY_REACH;
6311
+ let near = w ? GLORY_FAR : GLORY_REACH;
6292
6312
  for (const f of foes) {
6293
6313
  const [dx, dz] = [f.x - me.x, f.z - me.z];
6294
6314
  const d = Math.hypot(dx, dz);
6295
6315
  const facing = d < .001 || Math.acos(Math.min(1, (dx * fx + dz * fz) / d)) <= GLORY_ARC;
6296
- 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];
6316
+ if (!f.down && !f.lock && f.mode !== MODE.RIDE && (w ? !hidden(w, [
6317
+ me.x,
6318
+ me.y + 1.3,
6319
+ me.z
6320
+ ], [
6321
+ f.x,
6322
+ f.y + 1.3,
6323
+ f.z
6324
+ ]) : f.hp <= GLORY_HP) && d <= near && Math.abs(f.y - me.y) < 1.8 && facing) [best, near] = [f, d];
6297
6325
  }
6298
6326
  return best;
6299
6327
  };
@@ -6364,7 +6392,11 @@ var STRIKE = {
6364
6392
  var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6365
6393
  const down = p.down > 0;
6366
6394
  const locked = !down && (p.lock ?? 0) > 0;
6367
- move(p, down || locked ? {
6395
+ if (locked && !p.wield && p.lock > GLORY_TICKS - GLORY_DASH && (p.vx || p.vz)) {
6396
+ coast(p, w, bodies);
6397
+ p.ev = p.lock == GLORY_TICKS ? EV.DASH : 0;
6398
+ if (p.lock <= GLORY_TICKS - GLORY_DASH + 1) p.vx = p.vz = 0;
6399
+ } else move(p, down || locked ? {
6368
6400
  ...i,
6369
6401
  keys: 0
6370
6402
  } : i, w, team, bodies, kit);
@@ -9423,12 +9455,14 @@ var Room = class {
9423
9455
  foe.state.fried = this.shot(foe, 1, foe.railer, foe.state.x - r.x, foe.state.z - r.z, FRAG.RAIL);
9424
9456
  }
9425
9457
  /**
9426
- * E pressed by `p`, the xenomorph or one with the katana in hand: the nearest enemy who is up with
9427
- * GLORY_HP or less, within GLORY_REACH and GLORY_ARC of its look where `p` drew him, and in no
9428
- * lock, is glory killed. The katana takes his head at once and throws the body back GLORY_PUSH
9429
- * m/s, the follow-through of a cut across in hand (the user, 2026-11-16). The xenomorph holds
9430
- * him: the two locked (`lock`, `foe`) for GLORY_TICKS, his flag dropped, `p` brought in a metre
9431
- * from him; duel() ends it. True when it happened.
9458
+ * E pressed by `p`, the xenomorph or one with the katana in hand: the nearest enemy who is up,
9459
+ * within GLORY_ARC of its look where `p` drew him, and in no lock, is glory killed (glory()):
9460
+ * with the katana within GLORY_REACH and with GLORY_HP or less, the xenomorph's within
9461
+ * GLORY_FAR, in sight, at any health (the user, 2026-11-16). The katana takes his head at once
9462
+ * and throws the body back GLORY_PUSH m/s, the follow-through of a cut across in hand (the user,
9463
+ * 2026-11-16). The xenomorph holds him: the two locked (`lock`, `foe`) for GLORY_TICKS, his flag
9464
+ * dropped, `p` dashing to a metre of him (the user, 2026-11-16); duel() ends it. True when it
9465
+ * happened.
9432
9466
  */
9433
9467
  feast(p, view) {
9434
9468
  const me = p.state;
@@ -9444,7 +9478,7 @@ var Room = class {
9444
9478
  lock,
9445
9479
  mode
9446
9480
  }] : [];
9447
- }));
9481
+ }), xeno ? this.world : void 0);
9448
9482
  const foe = this.players().find((q) => q.info.id === seen?.id);
9449
9483
  if (!seen || !foe) return false;
9450
9484
  const [dx, dz] = [seen.x - me.x, seen.z - me.z];
@@ -9486,7 +9520,8 @@ var Room = class {
9486
9520
  vz: 0
9487
9521
  });
9488
9522
  }
9489
- if (d > 1) [me.x, me.z] = [Math.fround(me.x + dx * (d - 1) / d), Math.fround(me.z + dz * (d - 1) / d)];
9523
+ const v = Math.max(d - 1, 0) * 60 / GLORY_DASH / d;
9524
+ [me.vx, me.vz] = [Math.fround(dx * v), Math.fround(dz * v)];
9490
9525
  return true;
9491
9526
  }
9492
9527
  /**
@@ -0,0 +1,13 @@
1
+ import type { PlayerState } from '../shared/types';
2
+ /**
3
+ * The yaw, pitch and roll of the view `yaw`, `pitch`, `roll` turned by `a` (a quarter turn is the
4
+ * whole way) about the horizontal of the wall on `wall` (SIDE).
5
+ */
6
+ export declare const turned: (yaw: number, pitch: number, roll: number, wall: number, a: number) => [number, number, number];
7
+ export interface Crawl {
8
+ /** Follows the own player `p` for dt seconds: on a wall the view turns over onto it, off it back. */
9
+ update(p: PlayerState | undefined, dt: number): void;
10
+ /** The view `yaw`, `pitch`, `roll` as drawn: turned over onto the wall as far as it has gone. */
11
+ view(yaw: number, pitch: number, roll: number): [number, number, number];
12
+ }
13
+ export declare const createCrawl: () => Crawl;
@@ -38,8 +38,9 @@ export declare const HOOKED: Lash;
38
38
  * Where its tail is through a strike (TAILS, by the cut): it goes from HOOKED to the strike's poise
39
39
  * in the first third of the wind-up (or most of the way to the strike for a special), so it answers
40
40
  * the click at once (the user, 2026-11-16), is driven to its end at the strike, eased in, then
41
- * comes back. A charge holds the poise drawn in, coils it in an S to the side as it grows (the
42
- * user, 2026-11-16) and trembles with the clock `t`. The SPIN turns the tail low once round the body.
41
+ * comes back. A charge holds it cocked on its side, drawn in and coiled in an S over a tap of
42
+ * charge, then still but for its breath with the clock `t` (the user, 2026-11-16); let go, it
43
+ * strikes from there. The SPIN turns the tail low once round the body.
43
44
  */
44
45
  export declare const lashOf: (p: Pick<PlayerState, "cut" | "swing" | "heavy" | "charge" | "down">, t?: number) => Lash;
45
46
  /** A solved skeleton (solve() in rig.ts): each joint's place and turn in the world. */
@@ -259,8 +259,8 @@ export declare const PUNCH_HITS: number, PUNCH_STUN: number, PUNCH_MEMORY: numbe
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
261
  * forward and the sprint held (MODE.CLING, physics.ts; the sprint since the user, 2026-11-16):
262
- * up, down or along it as fast as on a floor, its run and its sprint with the key held (the user,
263
- * 2026-11-16) while the wall rises CLING_HOLD m over its feet; a jump kicks it off along the look at CLING_LEAP
262
+ * up, down or along it at a walk (CLING_WALK of its run), with the sprint key at its run then its
263
+ * sprint as on a floor (the user, 2026-11-16) while the wall rises CLING_HOLD m over its feet; a jump kicks it off along the look at CLING_LEAP
264
264
  * m/s. It dashes as a man does, XENO_DASH times as fast so as far, three in a row (kit.ts; the
265
265
  * user, 2026-11-16: no more charged pounce); an enemy its dash's burst reaches is pinned (room.ts):
266
266
  * POUNCE_HP health, his flag dropped, a stumble of POUNCE_STUN ticks, once per TACKLE_COOLDOWN. An
@@ -270,16 +270,26 @@ export declare const XENO_HP = 12;
270
270
  export declare const CLING_FACING = 0.6;
271
271
  export declare const CLING_HOLD = 0.4;
272
272
  export declare const CLING_LEAP = 10;
273
+ /** Its walk on a wall, a share of its run: the sprint key runs there (the user, 2026-11-16). */
274
+ export declare const CLING_WALK = 0.5;
273
275
  /** 1.4: a step of its burst stays under PLAYER_R, so it cannot tunnel through a thin brush (physics.ts). */
274
276
  export declare const XENO_DASH = 1.4;
275
277
  export declare const POUNCE_HP: number, POUNCE_STUN: number;
276
278
  /**
277
279
  * The glory kill (the user, 2026-11-16, after DOOM 2016): an enemy with GLORY_HP health or less, up,
278
- * 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
279
- * radians of its look locks the two (`lock`, `foe`, as a saber lock) for GLORY_TICKS, where neither
280
- * moves, then it eats his head: he goes down through his armour (LIMB.EATEN), a frag of FRAG.GLORY.
280
+ * flashes to one with the katana in hand, who beheads him on E within GLORY_REACH metres. The
281
+ * xenomorph's takes any enemy up, with no flash (the user, 2026-11-16): E within GLORY_FAR metres
282
+ * of him, in sight, and GLORY_ARC radians of its look locks the two (`lock`, `foe`, as a saber
283
+ * lock) for GLORY_TICKS, where he does not move and it dashes to him, then it eats his head: he
284
+ * goes down through his armour (LIMB.EATEN), a frag of FRAG.GLORY.
281
285
  */
282
286
  export declare const GLORY_HP: number, GLORY_REACH: number, GLORY_ARC: number, GLORY_TICKS: number;
287
+ /**
288
+ * The xenomorph's glory kill from afar (the user, 2026-11-16): within GLORY_FAR metres, in sight,
289
+ * it dashes to a metre of its prey over the first GLORY_DASH ticks of the lock. 7 m in 20 ticks is
290
+ * 21 m/s, a step under PLAYER_R: it cannot tunnel.
291
+ */
292
+ export declare const GLORY_FAR: number, GLORY_DASH: number;
283
293
  /** The katana's glory kill (room.ts feast()): the speed it throws the beheaded body back at. */
284
294
  export declare const GLORY_PUSH = 7;
285
295
  /** How much faster than a man the xenomorph runs (the user, 2026-11-16: a little, not twice). */
@@ -105,6 +105,11 @@ export declare const floored: (p: Pick<PlayerState, "zap" | "stun">) => boolean;
105
105
  * two steps. The katana's shock calls it with its own ticks and knock.
106
106
  */
107
107
  export declare const stumble: (p: PlayerState, dx: number, dz: number, ticks?: number, knock?: number) => void;
108
+ /**
109
+ * A step along its speed, through the boxes and bodies as fly() takes it, with no gravity and no
110
+ * control: the xenomorph's dash to its glory kill's prey (gun.ts).
111
+ */
112
+ export declare const coast: (p: PlayerState, w: World, bodies: readonly Body[]) => void;
108
113
  /**
109
114
  * Applies one input for 1 / TICK_HZ s, in place: yaw and pitch from the input (pitch clamped to
110
115
  * MAX_PITCH), then the step of the current mode (see the top of the file). Feet under the world's
@@ -185,12 +185,14 @@ export declare class Room {
185
185
  /** 1 hp of the bolt's drain to `foe`, as his railer deals it; if it puts him down he is disintegrated (`fried`). */
186
186
  private fry;
187
187
  /**
188
- * E pressed by `p`, the xenomorph or one with the katana in hand: the nearest enemy who is up with
189
- * GLORY_HP or less, within GLORY_REACH and GLORY_ARC of its look where `p` drew him, and in no
190
- * lock, is glory killed. The katana takes his head at once and throws the body back GLORY_PUSH
191
- * m/s, the follow-through of a cut across in hand (the user, 2026-11-16). The xenomorph holds
192
- * him: the two locked (`lock`, `foe`) for GLORY_TICKS, his flag dropped, `p` brought in a metre
193
- * from him; duel() ends it. True when it happened.
188
+ * E pressed by `p`, the xenomorph or one with the katana in hand: the nearest enemy who is up,
189
+ * within GLORY_ARC of its look where `p` drew him, and in no lock, is glory killed (glory()):
190
+ * with the katana within GLORY_REACH and with GLORY_HP or less, the xenomorph's within
191
+ * GLORY_FAR, in sight, at any health (the user, 2026-11-16). The katana takes his head at once
192
+ * and throws the body back GLORY_PUSH m/s, the follow-through of a cut across in hand (the user,
193
+ * 2026-11-16). The xenomorph holds him: the two locked (`lock`, `foe`) for GLORY_TICKS, his flag
194
+ * dropped, `p` dashing to a metre of him (the user, 2026-11-16); duel() ends it. True when it
195
+ * happened.
194
196
  */
195
197
  private feast;
196
198
  /**
@@ -1,4 +1,5 @@
1
1
  import type { PlayerState } from './types';
2
+ import type { World } from './world';
2
3
  /** Whether the player's body is a weapon: in a slide, or in the burst of a dash. */
3
4
  export declare const tackling: (p: PlayerState) => boolean;
4
5
  /**
@@ -12,8 +13,10 @@ export declare const pouncing: (p: PlayerState) => boolean;
12
13
  */
13
14
  export declare const reaches: (a: PlayerState, b: PlayerState) => boolean;
14
15
  /**
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.
16
+ * The enemy `me` would glory kill with E (room.ts feast()), of `foes` as it sees them: the nearest
17
+ * one up, in no lock and not seated, a body's height above or below and GLORY_ARC of its look. With
18
+ * the katana (`w` undefined) within GLORY_REACH on the floor plane, with GLORY_HP health or less;
19
+ * the xenomorph's within GLORY_FAR, in sight through the world `w`, at any health (the user,
20
+ * 2026-11-16).
18
21
  */
19
- export declare const glory: (me: PlayerState, foes: readonly PlayerState[]) => PlayerState | undefined;
22
+ export declare const glory: (me: PlayerState, foes: readonly PlayerState[], w?: World) => PlayerState | undefined;
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.180.0",
5
+ "version": "0.181.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"