@korial29/tiny-fps 0.141.0 → 0.143.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
@@ -48,8 +48,45 @@ var PUNCH = {
48
48
  reach: 1.4,
49
49
  arc: .6,
50
50
  hp: 0,
51
- hold: -1
51
+ hold: -1,
52
+ knock: 0
52
53
  };
54
+ /**
55
+ * The blows of the fists (the user, 2026-11-13), the `cut` of a swing with no weapon: the JAB is the
56
+ * punch above, the left fist. A fresh FIRE press after a blow's strike, while its swing runs, throws
57
+ * the next of the chain at once: the CROSS (the right fist), then the HOOK (the left, swung round),
58
+ * which ends the chain. A blow started at a sprint on the ground, in a slide or in a dash's burst is
59
+ * the LUNGE, a long straight right. `hp` 0 is half a point (PUNCH_HITS), 1 a whole one; a blow with
60
+ * a `knock` throws whoever it hits as a tackle does, `knock` times as hard, and drops his flag.
61
+ */
62
+ var BLOW = {
63
+ JAB: 0,
64
+ CROSS: 1,
65
+ HOOK: 2,
66
+ LUNGE: 3
67
+ };
68
+ var PUNCHES = [
69
+ PUNCH,
70
+ PUNCH,
71
+ {
72
+ ticks: 28,
73
+ strike: 9,
74
+ reach: 1.5,
75
+ arc: .9,
76
+ hp: 1,
77
+ hold: -1,
78
+ knock: 1.4
79
+ },
80
+ {
81
+ ticks: 26,
82
+ strike: 7,
83
+ reach: 2.2,
84
+ arc: .5,
85
+ hp: 1,
86
+ hold: -1,
87
+ knock: 1.2
88
+ }
89
+ ];
53
90
  var [PUNCH_HITS, PUNCH_STUN, PUNCH_MEMORY] = [
54
91
  2,
55
92
  3,
@@ -441,6 +478,16 @@ var LIMB = {
441
478
  LEG_L: 4,
442
479
  LEG_R: 5
443
480
  };
481
+ /**
482
+ * How a player went down (bits 5-6 of PlayerState.fell), for the clients' fall: PLAIN as before,
483
+ * SHOT thrown the way the hit went (a gun, a blast, a rover), STRUCK by a blade or the fists: on
484
+ * his knees, then over on his side.
485
+ */
486
+ var FALL$1 = {
487
+ PLAIN: 0,
488
+ SHOT: 1,
489
+ STRUCK: 2
490
+ };
444
491
  /** The movement state of a player: what the body is doing, one of these. */
445
492
  var MODE = {
446
493
  /** Standing or running on a floor. */
@@ -5940,12 +5987,22 @@ var swing = (w, feet, rovers = []) => w.doors?.forEach((s, i) => {
5940
5987
  var shut = (w) => w.doors?.forEach((s) => {
5941
5988
  s.open = s.wait = 0;
5942
5989
  });
5990
+ // src/shared/tackle.ts
5991
+ /** Whether the player's body is a weapon: in a slide, or in the burst of a dash. */
5992
+ var tackling = (p) => p.mode === MODE.SLIDE || p.dash > 50;
5993
+ /**
5994
+ * Whether the cylinders of `a` and `b` overlap, with TACKLE_REACH of reach on top: closer than
5995
+ * two radii and the reach on the floor plane, and their heights (low in a slide) overlap.
5996
+ */
5997
+ 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);
5943
5998
  // src/shared/gun.ts
5944
5999
  /** Whether the feet of `p` are within `r` of the point `at` on the floor plane and within PICK_H of its height. */
5945
6000
  var within = (p, at, r) => {
5946
6001
  const [dx, dz] = [p.x - at[0], p.z - at[2]];
5947
6002
  return dx * dx + dz * dz < r * r && Math.abs(p.y - at[1]) < 1;
5948
6003
  };
6004
+ /** PlayerState.fell of one put down the FALL `kind` by a hit going (dx, dz) on the floor. */
6005
+ var felled = (kind, dx, dz) => kind << 5 | Math.round(Math.atan2(-dx, -dz) * 16 / Math.PI) & 31;
5949
6006
  /**
5950
6007
  * The start of a cut that moves the body, from a floor only: the lunge throws him along the look at
5951
6008
  * LUNGE_SPEED for the burst of a dash, and spends the dash; the leap jumps him LEAP_SPEED up.
@@ -6018,6 +6075,8 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6018
6075
  return STRIKE.NONE;
6019
6076
  }
6020
6077
  if (locked) return duel(p, i);
6078
+ const fresh = !!(i.keys & KEY.FIRE) && !p.pressed;
6079
+ p.pressed = !!(i.keys & KEY.FIRE);
6021
6080
  const { rack, blade, rail, rifle } = w.def.teams[team];
6022
6081
  const inside = !!rack && within(p, rack, 1.2);
6023
6082
  if (armed && inside && !p.rack) [p.ammo, p.mag] = [kit.ammo, kit.mag];
@@ -6054,7 +6113,8 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6054
6113
  p.charge = top ? 0 : p.charge;
6055
6114
  const s = p.swing ?? 0;
6056
6115
  const c = swingOf(p);
6057
- const stop = (v) => v == s - 1 && (v == c.ticks - c.strike || v == PUNCH.ticks - PUNCH.strike || !p.heavy && v == ticks - hold);
6116
+ const blow = PUNCHES[p.cut ?? 0] ?? PUNCHES[0];
6117
+ const stop = (v) => v == s - 1 && (v == c.ticks - c.strike || v == blow.ticks - blow.strike || !p.heavy && v == ticks - hold);
6058
6118
  p.swing = Math.max(0, kit.haste > 1 && stop(s - 1) ? s - 1 : s - kit.haste);
6059
6119
  p.heavy = !!p.swing && !!p.heavy;
6060
6120
  }
@@ -6099,7 +6159,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6099
6159
  if (!--p.reload) p[key] = full;
6100
6160
  } else if (hand != 1 && carried >= 0 && !busy && load < full && (!load || i.keys & KEY.RELOAD)) [p.reload, p.charge] = [ticks2, 0];
6101
6161
  const bare = hand < 0;
6102
- const c = bare ? PUNCH : swingOf(p);
6162
+ const c = bare ? PUNCHES[p.cut ?? 0] ?? PUNCHES[0] : swingOf(p);
6103
6163
  if (p.swing && c.ticks - p.swing === c.strike) return STRIKE.CUT;
6104
6164
  if (p.wield && !top || p.railed || p.rifled || busy || p.reload || !p.wield && !p.mag) p.charge = 0;
6105
6165
  if (p.rifled && i.keys & KEY.SPECIAL && !busy && p.nades && !p.lob) {
@@ -6112,11 +6172,13 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6112
6172
  const late = CUTS[p.cut ?? 0].ticks - (p.swing ?? 0);
6113
6173
  const special = !!(i.keys & KEY.SPECIAL) && (!p.swing || !p.heavy && (p.cut ?? 0) < 4 && late <= 18);
6114
6174
  if (bare) {
6115
- if (!p.swing) [p.cut, p.heavy, p.swing] = [
6116
- 0,
6117
- false,
6118
- PUNCH.ticks
6119
- ];
6175
+ if (!p.swing) {
6176
+ p.cut = tackling(p) || p.mode === MODE.GROUND && !!(i.keys & KEY.SPRINT) && p.vx * p.vx + p.vz * p.vz > kit.run * kit.run ? BLOW.LUNGE : BLOW.JAB;
6177
+ [p.heavy, p.swing] = [false, PUNCHES[p.cut].ticks];
6178
+ } else if (fresh && p.cut < BLOW.HOOK && c.ticks - p.swing > c.strike) {
6179
+ p.cut++;
6180
+ p.swing = PUNCHES[p.cut].ticks;
6181
+ }
6120
6182
  } else if (p.wield && (!p.swing || special)) {
6121
6183
  p.cut = cutOf(i.keys) + (special ? 4 : 0);
6122
6184
  [p.swing, p.charge] = [CUTS[p.cut].ticks, 0];
@@ -6290,7 +6352,7 @@ var encodeSnapshot = (s) => {
6290
6352
  v.setUint8(o + 44, p.hits);
6291
6353
  v.setUint8(o + 45, (p.swing ?? 0) & 63 | ((p.cut ?? 0) & 3) << 6);
6292
6354
  v.setUint8(o + 46, (p.lost ?? 0) & 7 | ((p.cut ?? 0) & 4) << 1 | (p.fried ? 16 : 0) | (p.heavy ? 32 : 0));
6293
- v.setUint8(o + 47, p.charge ?? 0);
6355
+ v.setUint8(o + 47, p.down ? p.fell ?? 0 : p.charge ?? 0);
6294
6356
  v.setUint8(o + 48, p.lock ?? 0);
6295
6357
  v.setUint8(o + 49, (p.foe ?? 0) & 15 | (p.dashes & 2) << 3 | (p.pressed ? 128 : 0));
6296
6358
  v.setUint8(o + 50, p.pushes ?? 0);
@@ -7571,14 +7633,6 @@ var missile = (r, by, team, yaw, pitch, id, k, sight) => {
7571
7633
  v: Math.min(63, SHIP.MISSILE_SPEED + Math.max(0, own))
7572
7634
  };
7573
7635
  };
7574
- // src/shared/tackle.ts
7575
- /** Whether the player's body is a weapon: in a slide, or in the burst of a dash. */
7576
- var tackling = (p) => p.mode === MODE.SLIDE || p.dash > 50;
7577
- /**
7578
- * Whether the cylinders of `a` and `b` overlap, with TACKLE_REACH of reach on top: closer than
7579
- * two radii and the reach on the floor plane, and their heights (low in a slide) overlap.
7580
- */
7581
- 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);
7582
7636
  // src/shared/room.ts
7583
7637
  /** Ticks run at most this many times per timer callback, so a stalled host does not spiral. */
7584
7638
  var MAX_CATCH_UP = 20;
@@ -8065,19 +8119,21 @@ var Room = class {
8065
8119
  }
8066
8120
  /**
8067
8121
  * `hp` of a gun's damage to `foe` from `by`: as his class deals it (Kit.damage, a ninja's half), the
8068
- * half points kept on `foe` toward the next. True when he went down; `how` is the FRAG then.
8122
+ * half points kept on `foe` toward the next, the hit going (dx, dz). True when he went down; `how`
8123
+ * is the FRAG then.
8069
8124
  */
8070
- shot(foe, hp, by, how = FRAG.GUN) {
8125
+ shot(foe, hp, by, dx, dz, how = FRAG.GUN) {
8071
8126
  const bank = (foe.halves ?? 0) + hp * 2 * (by ? kitOf(by.info.role, this.world.def).damage : 1);
8072
8127
  foe.halves = bank % 2;
8073
- return bank >= 2 && this.harm(foe, Math.floor(bank / 2), by, how);
8128
+ return bank >= 2 && this.harm(foe, Math.floor(bank / 2), by, how, felled(FALL$1.SHOT, dx, dz));
8074
8129
  }
8075
8130
  /**
8076
8131
  * `hp` of damage to `foe`; the last one puts him down: he lies where he fell, without the gun or
8077
8132
  * the katana, a flag he carries drops with the lock, and `lost` is NONE (a cut sets it after).
8078
- * True when he went down: an enemy `by` scores a frag made `how` (FRAG), told to everyone.
8133
+ * True when he went down: an enemy `by` scores a frag made `how` (FRAG), told to everyone. `fell`
8134
+ * is how he falls (felled()).
8079
8135
  */
8080
- harm(foe, hp, by, how = FRAG.GUN) {
8136
+ harm(foe, hp, by, how = FRAG.GUN, fell = 0) {
8081
8137
  if ((foe.state.hp -= hp) > 0) return false;
8082
8138
  [foe.graze, foe.bruise, foe.blows, foe.halves] = [
8083
8139
  0,
@@ -8099,6 +8155,7 @@ var Room = class {
8099
8155
  wield: false,
8100
8156
  swing: 0,
8101
8157
  lost: LIMB.NONE,
8158
+ fell,
8102
8159
  rail: -1,
8103
8160
  railed: false,
8104
8161
  rifle: -1,
@@ -8182,9 +8239,9 @@ var Room = class {
8182
8239
  if (by) by.state.hits = by.state.hits + 1 & 255;
8183
8240
  if (b.power === 0 || b.power === 6) {
8184
8241
  foe.graze = ((foe.graze ?? 0) + 1) % 2;
8185
- if (!foe.graze) this.shot(foe, 1, by);
8186
- } else if (!b.arc) this.shot(foe, b.power ?? 1, by);
8187
- else if (this.harm(foe, CUTS[b.arc].hp, by, FRAG.BLADE)) {
8242
+ if (!foe.graze) this.shot(foe, 1, by, b.dx, b.dz);
8243
+ } else if (!b.arc) this.shot(foe, b.power ?? 1, by, b.dx, b.dz);
8244
+ else if (this.harm(foe, CUTS[b.arc].hp, by, FRAG.BLADE, felled(FALL$1.STRUCK, b.dx, b.dz))) {
8188
8245
  const from = by && {
8189
8246
  ...by.state,
8190
8247
  cut: b.arc,
@@ -8253,7 +8310,7 @@ var Room = class {
8253
8310
  for (const [, k] of cars) this.hurt(this.rovers[k], swingOf(p.state).hp, p.info.id, p.info.team);
8254
8311
  for (const foe of foes) {
8255
8312
  const drawn = seen.find((s) => s.id === foe.info.id);
8256
- if (this.harm(foe, swingOf(p.state).hp, p, FRAG.BLADE)) foe.state.lost = limbOf(p.state, drawn);
8313
+ if (this.harm(foe, swingOf(p.state).hp, p, FRAG.BLADE, felled(FALL$1.STRUCK, ...knock(p.state)))) foe.state.lost = limbOf(p.state, drawn);
8257
8314
  else {
8258
8315
  const [dx, dz] = knock(p.state);
8259
8316
  stumble(foe.state, dx, dz, 24, 4 * (p.state.heavy ? HEAVY : 1));
@@ -8263,27 +8320,30 @@ var Room = class {
8263
8320
  }
8264
8321
  }
8265
8322
  /**
8266
- * A punch of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him (the
8267
- * strike test, with PUNCH's reach and arc) takes half a point, 1 hp every PUNCH_HITS punches; the
8268
- * `hits` count goes up once. The PUNCH_STUN-th he takes with no more than PUNCH_MEMORY ticks
8269
- * between two stuns him as a tackle does: a stumble thrown the way `p` faces, the flag dropped,
8270
- * `by` the puncher.
8323
+ * A punch of `p` struck at the view tick `view`: every enemy its blow (PUNCHES by `cut`) reaches
8324
+ * as `p` drew him (the strike test, with the blow's reach and arc) is hit; the `hits` count goes
8325
+ * up once. A jab or a cross takes half a point, 1 hp every PUNCH_HITS of them; a hook or a lunge a
8326
+ * whole one. The PUNCH_STUN-th blow he takes with no more than PUNCH_MEMORY ticks between two, or
8327
+ * a blow with a `knock`, stuns him as a tackle does: a stumble thrown the way `p` faces (`knock`
8328
+ * times as hard), the flag dropped, `by` the puncher.
8271
8329
  */
8272
8330
  punch(p, view) {
8273
- const seen = strike(this.world, p.state, this.enemies(p, view), PUNCH);
8331
+ const blow = PUNCHES[p.state.cut ?? 0] ?? PUNCHES[0];
8332
+ const seen = strike(this.world, p.state, this.enemies(p, view), blow);
8274
8333
  const foes = this.players().filter((q) => seen.some((s) => s.id === q.info.id));
8275
8334
  if (!foes.length) return;
8276
8335
  p.state.hits = p.state.hits + 1 & 255;
8277
8336
  for (const foe of foes) {
8278
8337
  foe.blows = (this.ticks - (foe.punched ?? -Infinity) <= PUNCH_MEMORY ? foe.blows ?? 0 : 0) + 1;
8279
8338
  foe.punched = this.ticks;
8280
- foe.bruise = ((foe.bruise ?? 0) + 1) % PUNCH_HITS;
8281
- if (!foe.bruise && this.harm(foe, 1, p, FRAG.FIST)) continue;
8282
- if (foe.blows >= PUNCH_STUN) {
8339
+ if (!blow.hp) foe.bruise = ((foe.bruise ?? 0) + 1) % PUNCH_HITS;
8340
+ const fell = felled(FALL$1.STRUCK, ...forward(p.state.yaw));
8341
+ if ((blow.hp || !foe.bruise) && this.harm(foe, 1, p, FRAG.FIST, fell)) continue;
8342
+ if (blow.knock || foe.blows >= PUNCH_STUN) {
8283
8343
  foe.blows = 0;
8284
8344
  this.drop(foe.info.id);
8285
8345
  const [dx, dz] = forward(p.state.yaw);
8286
- stumble(foe.state, dx, dz);
8346
+ stumble(foe.state, dx, dz, 48, 6 * (blow.knock || 1));
8287
8347
  foe.state.zap = false;
8288
8348
  foe.by = p.info.id;
8289
8349
  }
@@ -8328,7 +8388,8 @@ var Room = class {
8328
8388
  }
8329
8389
  /** 1 hp of the bolt's drain to `foe`, as his railer deals it; if it puts him down he is disintegrated (`fried`). */
8330
8390
  fry(foe) {
8331
- foe.state.fried = this.shot(foe, 1, foe.railer, FRAG.RAIL);
8391
+ const r = foe.railer?.state ?? foe.state;
8392
+ foe.state.fried = this.shot(foe, 1, foe.railer, foe.state.x - r.x, foe.state.z - r.z, FRAG.RAIL);
8332
8393
  }
8333
8394
  /**
8334
8395
  * A saber lock of `p`, after his input: it ends when a side leads by LOCK_WIN presses (the other
@@ -8352,7 +8413,7 @@ var Room = class {
8352
8413
  if (Math.abs(lead) >= 8) {
8353
8414
  const [w, l] = lead > 0 ? [p, o] : [o, p];
8354
8415
  w.state.hits = w.state.hits + 1 & 255;
8355
- if (!this.harm(l, 3, w, FRAG.BLADE)) {
8416
+ if (!this.harm(l, 3, w, FRAG.BLADE, felled(FALL$1.STRUCK, ...forward(w.state.yaw)))) {
8356
8417
  const [dx, dz] = forward(w.state.yaw);
8357
8418
  stumble(l.state, dx, dz, 24, 4);
8358
8419
  l.state.zap = true;
@@ -8640,7 +8701,7 @@ var Room = class {
8640
8701
  const own = q.info.id === by;
8641
8702
  const hp = !q.state.down && q.state.mode !== MODE.RIDE && (own || q.info.team !== team) ? blast(this.world, c, q.state) : 0;
8642
8703
  if (hp) {
8643
- this.shot(q, hp, this.players().find((o) => o.info.id === by), FRAG.NADE);
8704
+ this.shot(q, hp, this.players().find((o) => o.info.id === by), q.state.x - c[0], q.state.z - c[2], FRAG.NADE);
8644
8705
  hit ||= !own;
8645
8706
  }
8646
8707
  }
@@ -8659,7 +8720,9 @@ var Room = class {
8659
8720
  if (closing < ROVER.SPLAT_MIN) continue;
8660
8721
  foe.run = this.ticks;
8661
8722
  p.state.hits = p.state.hits + 1 & 255;
8662
- if (!this.harm(foe, closing < ROVER.SPLAT_KILL ? 1 : foe.state.hp, p, FRAG.VEHICLE)) {
8723
+ const fell = felled(FALL$1.SHOT, r.vx, r.vz);
8724
+ const hp = closing < ROVER.SPLAT_KILL ? 1 : foe.state.hp;
8725
+ if (!this.harm(foe, hp, p, FRAG.VEHICLE, fell)) {
8663
8726
  const v = len(r.vx, r.vz);
8664
8727
  stumble(foe.state, r.vx / v, r.vz / v);
8665
8728
  foe.state.zap = false;
@@ -36,7 +36,7 @@ export interface Combat {
36
36
  /** Shots between two states of a player, a u8 counter that wraps. */
37
37
  export declare const fired: (a?: PlayerState, b?: PlayerState) => number;
38
38
  /** What the katana's sounds read of a player: the swing, the cut and whether it is in hand. */
39
- type Blade = Pick<PlayerState, 'swing' | 'cut' | 'wield' | 'blade' | 'heavy' | 'down' | 'railed' | 'ammo' | 'reload' | 'rifled' | 'hot'>;
39
+ type Blade = Pick<PlayerState, 'swing' | 'cut' | 'wield' | 'blade' | 'heavy' | 'down' | 'railed' | 'ammo' | 'reload' | 'rifled' | 'hot' | 'hits'>;
40
40
  /**
41
41
  * The CUT of a swing that started between two states of a player, or -1: `swing` jumped up (it
42
42
  * only counts down), or the cut changed under a running one.
@@ -46,7 +46,7 @@ export declare const swung: (a?: Blade, b?: Blade) => number;
46
46
  export declare const struck: (a?: Blade, b?: Blade) => boolean;
47
47
  /** The pitch of a player's voice: the woman's higher, and each a little off the next by his id. */
48
48
  export declare const voiceOf: (id: number, body?: number) => number;
49
- 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">, tracer: Pick<Tracer, "flash" | "burst" | "blast" | "orbs" | "update" | "mount" | "crackle" | "charging" | "lightning">, ctl: {
49
+ 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: {
50
50
  pitch: number;
51
51
  }, balls: Pick<Balls, "fire" | "frame">,
52
52
  /** The muzzle of a runner's long gun as last drawn, from his feet (Renderer.muzzle()). */
@@ -35,6 +35,12 @@ export interface Effects {
35
35
  punch(): void;
36
36
  /** The own katana's cut struck: a thrust punches the field of view, a slash dips the look, a cut across rolls toward the side it ends on. */
37
37
  cut(c: number): void;
38
+ /**
39
+ * A blow of the fists (BLOW) struck: the own (the look kicked toward the fist's side, rolled hard
40
+ * by a hook, a lunge punching the field of view), or, `taken`, one the own player took: the eye
41
+ * dipped and the look knocked up.
42
+ */
43
+ blow(b: number, taken?: boolean): void;
38
44
  /**
39
45
  * Advances dt seconds: the own player (eased, undefined before the first snapshot), the held keys,
40
46
  * the events, and the stride phase of its drawn legs (Gait.phase): with it the bob dips as a foot
@@ -69,6 +69,15 @@ export declare const SIT: {
69
69
  * trunk and the legs follow the knock.
70
70
  */
71
71
  export declare const MOVES: number[][];
72
+ /**
73
+ * The falls of one put down shot or struck (FALL, less one), keys of the seconds since he went
74
+ * down: the pelvis's tip (forward or back) and roll to the side, its height over the floor and how
75
+ * far it has gone along the throw (metres), the bend of the hips and the knees, the arms' lift
76
+ * forward and out, the elbows' bend, the spine's slump. Shot: thrown off his feet along the hit,
77
+ * flat on his back or his face, the arms flung out; struck: down on his knees, a sway, then over
78
+ * on his side, curled.
79
+ */
80
+ export declare const FALLS: number[][][];
72
81
  /**
73
82
  * An arm's pose, the upper arm then the forearm, as the gait builds them: `s` 1 the right, -1 the
74
83
  * left; the upper arm's lift forward, out to the side and turn inward, and the elbow's bend.
@@ -84,9 +93,28 @@ export declare const JAB: {
84
93
  back: number[];
85
94
  twist: number;
86
95
  };
96
+ /**
97
+ * The other blows (BLOW, the user 2026-11-13), as JAB's arms: the HOOK's left arm swung round at
98
+ * the shoulder's height, the elbow bent square and out, the chest turned behind it; the LUNGE's right
99
+ * arm driven straight out, further than a jab, the chest turned the other way.
100
+ */
101
+ export declare const HOOK: {
102
+ out: number[];
103
+ twist: number;
104
+ };
105
+ export declare const LUNGE: {
106
+ out: number[];
107
+ twist: number;
108
+ };
109
+ /** The striking arm of each blow (BLOW): -1 the left, 1 the right. */
110
+ export declare const SIDE: number[];
111
+ /** Whether the player has no weapon at all: FIRE punches. */
112
+ export declare const bare: (p: PlayerState) => boolean;
113
+ /** The blow (BLOW) of a bare-handed swing. */
114
+ export declare const blowOf: (p: Pick<PlayerState, "cut">) => number;
87
115
  /**
88
116
  * How far out the fist of a punch is, 0 to 1, by the swing of a player with no weapon at all: out
89
- * at the strike, back by the swing's end.
117
+ * at the strike of its blow, back by the swing's end.
90
118
  */
91
119
  export declare const thrown: (p: PlayerState) => number;
92
120
  /** `bow` is the guard's lean forward: none for the eye's own body, whose arms hold to the view and which stands in no sword guard. */
@@ -28,10 +28,13 @@ export interface Runner {
28
28
  /** Seconds left of the grimace a hit puts on his face, and of the grin of a capture or of a foe put down. */
29
29
  hurt: number;
30
30
  grin: number;
31
- /** How far out the fist of a punch is, 0 to 1, eased. */
31
+ /** How far out the fist of a punch is, 0 to 1, eased, and its blow (BLOW). */
32
32
  jab: number;
33
33
  /** How closed his hands are, left then right, eased toward grasp(). */
34
34
  curls: number[];
35
+ blow: number;
36
+ /** How far his head is still thrown back by a blow he took, 1 to 0. */
37
+ flinch: number;
35
38
  /** His face (expression.ts), and the seconds it has yet to live through: soldier() moves it once drawn, where the head's turn is known. */
36
39
  face: Face;
37
40
  dt: number;
@@ -190,7 +190,31 @@ export declare const PUNCH: {
190
190
  arc: number;
191
191
  hp: number;
192
192
  hold: number;
193
+ knock: number;
193
194
  };
195
+ /**
196
+ * The blows of the fists (the user, 2026-11-13), the `cut` of a swing with no weapon: the JAB is the
197
+ * punch above, the left fist. A fresh FIRE press after a blow's strike, while its swing runs, throws
198
+ * the next of the chain at once: the CROSS (the right fist), then the HOOK (the left, swung round),
199
+ * which ends the chain. A blow started at a sprint on the ground, in a slide or in a dash's burst is
200
+ * the LUNGE, a long straight right. `hp` 0 is half a point (PUNCH_HITS), 1 a whole one; a blow with
201
+ * a `knock` throws whoever it hits as a tackle does, `knock` times as hard, and drops his flag.
202
+ */
203
+ export declare const BLOW: {
204
+ readonly JAB: 0;
205
+ readonly CROSS: 1;
206
+ readonly HOOK: 2;
207
+ readonly LUNGE: 3;
208
+ };
209
+ export declare const PUNCHES: {
210
+ ticks: number;
211
+ strike: number;
212
+ reach: number;
213
+ arc: number;
214
+ hp: number;
215
+ hold: number;
216
+ knock: number;
217
+ }[];
194
218
  export declare const PUNCH_HITS: number, PUNCH_STUN: number, PUNCH_MEMORY: number;
195
219
  /** Shots the rack loads. */
196
220
  export declare const AMMO_MAX = 60;
@@ -5,6 +5,8 @@ import type { World } from './world';
5
5
  type Vec3 = [number, number, number];
6
6
  /** Whether the feet of `p` are within `r` of the point `at` on the floor plane and within PICK_H of its height. */
7
7
  export declare const within: (p: PlayerState, at: Vec3, r: number) => boolean;
8
+ /** PlayerState.fell of one put down the FALL `kind` by a hit going (dx, dz) on the floor. */
9
+ export declare const felled: (kind: number, dx: number, dz: number) => number;
8
10
  /** What a step struck, for the host to resolve: nothing, a shot (a plasma ball), the katana's cut, a rail gun's beam, a laser rifle's shot, or a grenade from its launcher. */
9
11
  export declare const STRIKE: {
10
12
  readonly NONE: 0;
@@ -102,13 +102,15 @@ export declare class Room {
102
102
  private enemies;
103
103
  /**
104
104
  * `hp` of a gun's damage to `foe` from `by`: as his class deals it (Kit.damage, a ninja's half), the
105
- * half points kept on `foe` toward the next. True when he went down; `how` is the FRAG then.
105
+ * half points kept on `foe` toward the next, the hit going (dx, dz). True when he went down; `how`
106
+ * is the FRAG then.
106
107
  */
107
108
  private shot;
108
109
  /**
109
110
  * `hp` of damage to `foe`; the last one puts him down: he lies where he fell, without the gun or
110
111
  * the katana, a flag he carries drops with the lock, and `lost` is NONE (a cut sets it after).
111
- * True when he went down: an enemy `by` scores a frag made `how` (FRAG), told to everyone.
112
+ * True when he went down: an enemy `by` scores a frag made `how` (FRAG), told to everyone. `fell`
113
+ * is how he falls (felled()).
112
114
  */
113
115
  private harm;
114
116
  /**
@@ -137,11 +139,12 @@ export declare class Room {
137
139
  */
138
140
  private cut;
139
141
  /**
140
- * A punch of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him (the
141
- * strike test, with PUNCH's reach and arc) takes half a point, 1 hp every PUNCH_HITS punches; the
142
- * `hits` count goes up once. The PUNCH_STUN-th he takes with no more than PUNCH_MEMORY ticks
143
- * between two stuns him as a tackle does: a stumble thrown the way `p` faces, the flag dropped,
144
- * `by` the puncher.
142
+ * A punch of `p` struck at the view tick `view`: every enemy its blow (PUNCHES by `cut`) reaches
143
+ * as `p` drew him (the strike test, with the blow's reach and arc) is hit; the `hits` count goes
144
+ * up once. A jab or a cross takes half a point, 1 hp every PUNCH_HITS of them; a hook or a lunge a
145
+ * whole one. The PUNCH_STUN-th blow he takes with no more than PUNCH_MEMORY ticks between two, or
146
+ * a blow with a `knock`, stuns him as a tackle does: a stumble thrown the way `p` faces (`knock`
147
+ * times as hard), the flag dropped, `by` the puncher.
145
148
  */
146
149
  private punch;
147
150
  /**
@@ -107,6 +107,16 @@ export declare const LIMB: {
107
107
  readonly LEG_L: 4;
108
108
  readonly LEG_R: 5;
109
109
  };
110
+ /**
111
+ * How a player went down (bits 5-6 of PlayerState.fell), for the clients' fall: PLAIN as before,
112
+ * SHOT thrown the way the hit went (a gun, a blast, a rover), STRUCK by a blade or the fists: on
113
+ * his knees, then over on his side.
114
+ */
115
+ export declare const FALL: {
116
+ readonly PLAIN: 0;
117
+ readonly SHOT: 1;
118
+ readonly STRUCK: 2;
119
+ };
110
120
  /** The movement state of a player: what the body is doing, one of these. */
111
121
  export declare const MODE: {
112
122
  /** Standing or running on a floor. */
@@ -285,6 +295,8 @@ export interface PlayerState {
285
295
  heavy?: boolean;
286
296
  /** 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. */
287
297
  lost?: number;
298
+ /** While down: bits 5-6 the FALL, bits 0-4 the way the hit went, a yaw in 32nds of a turn (felled() in gun.ts). Absent reads 0. */
299
+ fell?: number;
288
300
  /** For the animation, not sent: the EV bits of the last step, and the speed of a landing. */
289
301
  ev: number;
290
302
  fall: number;
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.141.0",
5
+ "version": "0.143.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"