@korial29/tiny-fps 0.196.0 → 0.196.2

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
@@ -108,7 +108,7 @@ var PUNCHES = [
108
108
  * the top of its wind-up (`hold`) it charges as a cut does (HEAVY, swingOf()), and the strike takes
109
109
  * more the longer it charged (TAIL_HP, sting()). A double click of the right button (KEY.SPECIAL
110
110
  * with it) is its special: a sweep's is the SPIN, the tail whipped all round the body; the stab's
111
- * and the lash's the LEAP, up TAIL_LEAP m/s and down on the foe as it lands; each takes its own
111
+ * and the lash's the LEAP, up TAIL_LEAP m/s once released and down on the foe; each takes its own
112
112
  * `hp`. The xenomorph's `cut` reads this table: CLAW_L and CLAW_R are its claws, at their place in it.
113
113
  */
114
114
  /**
@@ -170,7 +170,7 @@ var TAILS = [
170
170
  reach: 2.6,
171
171
  arc: Math.PI,
172
172
  hp: 3,
173
- hold: -1,
173
+ hold: 18,
174
174
  knock: 0
175
175
  },
176
176
  {
@@ -179,7 +179,7 @@ var TAILS = [
179
179
  reach: 2.8,
180
180
  arc: .6,
181
181
  hp: 5,
182
- hold: -1,
182
+ hold: 32,
183
183
  knock: 0
184
184
  }
185
185
  ];
@@ -610,7 +610,9 @@ var KEY = {
610
610
  /** Set while the player wants the laser rifle in hand (4 or the wheel), with BLADE and RAIL clear. Ignored without it. */
611
611
  RIFLE: 8192,
612
612
  /** Press to get into the rover at hand, or out of the one he rides. */
613
- USE: 16384
613
+ USE: 16384,
614
+ /** Select bare hands even while carrying a weapon. */
615
+ FISTS: 32768
614
616
  };
615
617
  /**
616
618
  * The katana's cuts (PlayerState.cut, constants CUTS), chosen by the keys held when FIRE starts
@@ -787,6 +789,7 @@ var KITS = [
787
789
  slow: .55,
788
790
  accel: 1,
789
791
  parry: PARRY,
792
+ katana: true,
790
793
  hp: 8,
791
794
  gear: true,
792
795
  xeno: false
@@ -1018,6 +1021,7 @@ var STILL = {
1018
1021
  hits: 0,
1019
1022
  blade: false,
1020
1023
  wield: false,
1024
+ fists: false,
1021
1025
  swing: 0,
1022
1026
  cut: 0,
1023
1027
  zap: false,
@@ -1039,7 +1043,7 @@ var STILL = {
1039
1043
  fall: 0
1040
1044
  };
1041
1045
  /** A player standing on spawn point n of a team (modulo the count): the red team's by default. */
1042
- var spawn = (id, w, n, team = 0) => {
1046
+ var spawn = (id, w, n, team = 0, kit = KITS[0]) => {
1043
1047
  const { spawns } = w.def.teams[team];
1044
1048
  const [x, y, z, yaw] = spawns[(n % spawns.length + spawns.length) % spawns.length];
1045
1049
  return {
@@ -1051,16 +1055,19 @@ var spawn = (id, w, n, team = 0) => {
1051
1055
  yaw: norm(yaw),
1052
1056
  pitch: 0,
1053
1057
  ground: true,
1054
- ...STILL
1058
+ ...STILL,
1059
+ hp: kit.hp,
1060
+ blade: !!kit.katana,
1061
+ wield: !!kit.katana
1055
1062
  };
1056
1063
  };
1057
1064
  /**
1058
1065
  * Puts the player back at the spawn of his id in his team, looking where he looked, with full
1059
1066
  * health and no gun (EV.RESPAWN). The shot and hit counters go on: a reset would read as a shot.
1060
1067
  */
1061
- var respawn = (p, w, team) => {
1068
+ var respawn = (p, w, team, kit = KITS[0]) => {
1062
1069
  const { yaw, pitch, id, shots, hits } = p;
1063
- Object.assign(p, spawn(id, w, id, team), {
1070
+ Object.assign(p, spawn(id, w, id, team, kit), {
1064
1071
  yaw,
1065
1072
  pitch,
1066
1073
  shots,
@@ -1863,7 +1870,7 @@ var move = (p, i, w, team = 0, bodies = [], kit = KITS[0]) => {
1863
1870
  fz,
1864
1871
  bodies,
1865
1872
  kit,
1866
- pace: !p.wield && (p.ammo >= 0 || (p.rail ?? -1) >= 0 || (p.rifle ?? -1) >= 0) ? kit.slow : 1
1873
+ pace: !p.fists && !p.wield && (p.ammo >= 0 || (p.rail ?? -1) >= 0 || (p.rifle ?? -1) >= 0) ? kit.slow : 1
1867
1874
  };
1868
1875
  const before = p.mode;
1869
1876
  p.ev = 0;
@@ -1882,7 +1889,7 @@ var move = (p, i, w, team = 0, bodies = [], kit = KITS[0]) => {
1882
1889
  p.slow--;
1883
1890
  cap(p, 3);
1884
1891
  }
1885
- if (p.y < w.def.floor) respawn(p, w, team);
1892
+ if (p.y < w.def.floor) respawn(p, w, team, kit);
1886
1893
  p.t = p.mode === before ? Math.min(255, p.t + 1) : p.t;
1887
1894
  p.buffer = Math.max(0, p.buffer - 1);
1888
1895
  if (p.mode === MODE.AIR && before === MODE.AIR) p.coyote = Math.max(0, p.coyote - 1);
@@ -1944,15 +1951,15 @@ var swingOf = (p, table = CUTS) => {
1944
1951
  } : c;
1945
1952
  };
1946
1953
  /**
1947
- * The health a xenomorph's swing `p` takes: the claws and the specials their own `hp`; the tail
1948
- * TAIL_HP[0] let go before a charge, up to TAIL_HP[1] for a heavy release of a full one (`charge`
1954
+ * The health a xenomorph's swing `p` takes: its base damage on a tap, and for a tail strike
1955
+ * up to TAIL_HP[1] on a full charge (`charge`
1949
1956
  * stays through the release, gun.ts).
1950
1957
  */
1951
1958
  var sting = (p) => {
1952
1959
  const c = TAILS[p.cut ?? 0];
1953
1960
  if (c.hold < 0) return c.hp;
1954
1961
  const k = p.heavy ? Math.min(p.charge ?? 0, HEAVY_MAX) / HEAVY_MAX : 0;
1955
- return TAIL_HP[0] + Math.round((TAIL_HP[1] - TAIL_HP[0]) * k);
1962
+ return c.hp + Math.round((TAIL_HP[1] - c.hp) * k);
1956
1963
  };
1957
1964
  /**
1958
1965
  * The enemies the cut of `p` (`p.cut`, `p` the state after the step that struck) hits, of `foes`
@@ -6771,10 +6778,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6771
6778
  p.zapping = false;
6772
6779
  p.zap = !!p.stun && !!p.zap;
6773
6780
  if (down) {
6774
- if (p.down > 0 && !--p.down) {
6775
- respawn(p, w, team);
6776
- p.hp = kit.hp;
6777
- }
6781
+ if (p.down > 0 && !--p.down) respawn(p, w, team, kit);
6778
6782
  return STRIKE.NONE;
6779
6783
  }
6780
6784
  if (locked) return duel(p, i);
@@ -6792,7 +6796,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6792
6796
  ];
6793
6797
  if (armed && gear && inside && !p.rack) [p.ammo, p.mag] = [kit.ammo, kit.mag];
6794
6798
  p.rack = inside;
6795
- p.blade = !!p.blade || armed && gear && !!blade && within(p, blade, 1.2);
6799
+ p.blade = !!kit.katana || !!p.blade || armed && gear && !!blade && within(p, blade, 1.2);
6796
6800
  const inRail = !!rail && within(p, rail, 1.2);
6797
6801
  if (armed && gear && inRail && !p.inRail) [p.rail, p.cap] = [kit.rail, kit.cap];
6798
6802
  p.inRail = inRail;
@@ -6816,9 +6820,12 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6816
6820
  const busy = p.mode === MODE.HANG || p.mode === MODE.CLIMB;
6817
6821
  const table = kit.xeno ? TAILS : CUTS;
6818
6822
  const { ticks, hold } = table[p.cut ?? 0];
6819
- const top = !!p.swing && !p.heavy && ticks - (p.swing ?? 0) === hold;
6820
- if (top && (p.wield || kit.xeno) && armed && !busy && i.keys & (kit.xeno ? KEY.BLADE : KEY.FIRE)) p.charge = Math.min((p.charge ?? 0) + 1, HEAVY_MAX);
6821
- else if (top && armed && !busy && (p.charge ?? 0) >= HEAVY_TAP) {
6823
+ const top = !!p.swing && !p.heavy && ticks - p.swing === hold;
6824
+ const free = armed && !busy;
6825
+ const holding = !!(i.keys & (kit.xeno ? KEY.BLADE : KEY.FIRE));
6826
+ if (kit.xeno && top && !free) [p.swing, p.charge] = [0, 0];
6827
+ else if (top && free && holding && (p.wield || kit.xeno)) p.charge = Math.min((p.charge ?? 0) + 1, HEAVY_MAX);
6828
+ else if (top && free && (p.charge ?? 0) >= HEAVY_TAP) {
6822
6829
  [p.heavy, p.charge] = [true, kit.xeno ? p.charge : 0];
6823
6830
  p.swing = swingOf(p, table).ticks;
6824
6831
  } else {
@@ -6831,6 +6838,10 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6831
6838
  p.heavy = !!p.swing && !!p.heavy;
6832
6839
  p.charge = kit.xeno && !p.heavy ? 0 : p.charge;
6833
6840
  }
6841
+ if (kit.xeno && top && free && !holding && p.cut === STING.LEAP && p.mode === MODE.GROUND) {
6842
+ p.vy = 10;
6843
+ p.ev |= EV.JUMP;
6844
+ }
6834
6845
  p.mag = Math.min(p.mag ?? 0, Math.max(p.ammo, 0));
6835
6846
  const has = [
6836
6847
  p.ammo >= 0,
@@ -6839,14 +6850,16 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6839
6850
  (p.rifle ?? -1) >= 0
6840
6851
  ];
6841
6852
  const want = i.keys & KEY.BLADE ? 1 : i.keys & KEY.RAIL ? 2 : i.keys & KEY.RIFLE ? 3 : 0;
6842
- const hand = p.swing && p.blade ? 1 : has[want] ? want : has.indexOf(true);
6843
- if (hand != (p.rifled ? 3 : p.railed ? 2 : +!!p.wield)) p.reload = 0;
6844
- [p.wield, p.railed, p.rifled] = [
6853
+ const fists = gear && !!(i.keys & KEY.FISTS) && !(p.swing && p.wield);
6854
+ const hand = p.swing && p.wield ? 1 : fists ? -1 : has[want] ? want : has.indexOf(true);
6855
+ if (hand != (p.fists ? -1 : p.rifled ? 3 : p.railed ? 2 : +!!p.wield)) p.reload = 0;
6856
+ if (p.swing && hand >= 0 && !p.wield) p.swing = 0;
6857
+ [p.wield, p.railed, p.rifled, p.fists] = [
6845
6858
  hand == 1,
6846
6859
  hand == 2,
6847
- hand == 3
6860
+ hand == 3,
6861
+ fists
6848
6862
  ];
6849
- if (p.swing && hand >= 0 && !p.blade) p.swing = 0;
6850
6863
  if (!armed) {
6851
6864
  [p.charge, p.reload] = [kit.xeno ? p.charge : 0, 0];
6852
6865
  return STRIKE.NONE;
@@ -6870,7 +6883,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6870
6883
  const [load, full] = [p[key] ?? 0, Math.min(size, carried)];
6871
6884
  if (p.reload) {
6872
6885
  if (!--p.reload) p[key] = full;
6873
- } else if (hand != 1 && carried >= 0 && !busy && load < full && (!load || i.keys & KEY.RELOAD)) [p.reload, p.charge] = [ticks2, 0];
6886
+ } else if (hand >= 0 && hand != 1 && !busy && load < full && (!load || i.keys & KEY.RELOAD)) [p.reload, p.charge] = [ticks2, 0];
6874
6887
  const bare = hand < 0;
6875
6888
  const c = kit.xeno ? swingOf(p, TAILS) : bare ? PUNCHES[p.cut ?? 0] ?? PUNCHES[0] : swingOf(p);
6876
6889
  if (p.swing && c.ticks - p.swing === c.strike) return STRIKE.CUT;
@@ -6878,7 +6891,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6878
6891
  beast(p, i, fresh, busy);
6879
6892
  return STRIKE.NONE;
6880
6893
  }
6881
- if (p.wield && !top || p.railed || p.rifled || busy || p.reload || !p.wield && !p.mag) p.charge = 0;
6894
+ if (bare || p.wield && !top || p.railed || p.rifled || busy || p.reload || !p.wield && !p.mag) p.charge = 0;
6882
6895
  if (p.rifled && i.keys & KEY.SPECIAL && !busy && p.nades && !p.lob) {
6883
6896
  p.nades--;
6884
6897
  [p.lob, p.cool] = [60, 7];
@@ -6940,16 +6953,16 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
6940
6953
  * The xenomorph's blows: FIRE swipes the left claws, then the right while it goes on, a fresh press
6941
6954
  * after a swipe's strike throwing the next at once (BLOW). The right button (KEY.BLADE) strikes with
6942
6955
  * the tail as FIRE cuts with the katana (TAILS): by the keys (cutOf()), its special with SPECIAL (a
6943
- * double click), which also turns a strike just started into it within SPECIAL_LATE ticks. Not while
6944
- * the tail charges, nor with the hands busy (a hang, a climb); on a wall they are free.
6956
+ * double click), which can replace the first tap before it strikes. All tail attacks pause
6957
+ * at their wind-up while the button is held. On a wall the hands are free.
6945
6958
  */
6946
6959
  var beast = (p, i, fresh, busy) => {
6947
6960
  if (busy) return;
6948
6961
  const c = TAILS[p.cut ?? 0];
6949
6962
  const claw = p.cut === BLOW.CLAW_L || p.cut === BLOW.CLAW_R;
6950
6963
  const tail = !!(i.keys & KEY.BLADE);
6951
- const late = c.ticks - (p.swing ?? 0);
6952
- const special = tail && !!(i.keys & KEY.SPECIAL) && !!p.swing && !claw && !p.heavy && (p.cut ?? 0) < 4 && late <= 18;
6964
+ const elapsed = c.ticks - (p.swing ?? 0);
6965
+ const special = tail && !!(i.keys & KEY.SPECIAL) && !!p.swing && !claw && !p.heavy && (p.cut ?? 0) < 4 && elapsed < c.strike;
6953
6966
  if (tail && (!p.swing && !p.charge || special)) {
6954
6967
  const base = cutOf(i.keys);
6955
6968
  p.cut = i.keys & KEY.SPECIAL ? base === CUT.LEFT || base === CUT.RIGHT ? STING.SPIN : STING.LEAP : base;
@@ -6958,10 +6971,6 @@ var beast = (p, i, fresh, busy) => {
6958
6971
  TAILS[p.cut].ticks,
6959
6972
  0
6960
6973
  ];
6961
- if (p.cut === STING.LEAP && p.mode === MODE.GROUND) {
6962
- p.vy = 10;
6963
- p.ev |= EV.JUMP;
6964
- }
6965
6974
  } else if (i.keys & KEY.FIRE && (!p.swing || fresh && claw && c.ticks - p.swing > c.strike)) {
6966
6975
  p.cut = p.cut === BLOW.CLAW_L ? BLOW.CLAW_R : BLOW.CLAW_L;
6967
6976
  [p.heavy, p.swing] = [false, TAILS[p.cut].ticks];
@@ -7809,7 +7818,7 @@ var Sortie = class {
7809
7818
  }
7810
7819
  };
7811
7820
  // src/shared/bot.ts
7812
- var { FORWARD, BACK, LEFT, RIGHT, JUMP, SPRINT, DASH, CROUCH, FIRE, RELOAD } = KEY;
7821
+ var { FORWARD, BACK, LEFT, RIGHT, JUMP, SPRINT, DASH, CROUCH, FIRE, RELOAD, BLADE, SPECIAL } = KEY;
7813
7822
  /** How far a bot shoots, metres, and how far it sees an enemy to fight. */
7814
7823
  var RANGE = 35;
7815
7824
  /** Radians off the target a bot still shoots. */
@@ -7913,6 +7922,44 @@ var NEAR = 12;
7913
7922
  /** Metres a bot goes out of its way to a health pack when it is in trouble, or to help a teammate. */
7914
7923
  var MEND = 30;
7915
7924
  var HELP = 40;
7925
+ /** Metres round its flag a guard walks, the points of its round, and the ticks it stands at one. */
7926
+ var ROUND = 5;
7927
+ var POSTS = 8;
7928
+ var PAUSE = 90;
7929
+ /** Metres off its flag the ways in are watched from, and radians a guard's look sweeps either side. */
7930
+ var ENTRY = 12;
7931
+ var SWEEP = .35;
7932
+ /**
7933
+ * A guard's round about `base`: up to POSTS points on the flag's own floor, each with the yaw it
7934
+ * watches from there. That is the way in nearest its side: where the ways from the enemy's base,
7935
+ * one by each route, come within ENTRY of the flag.
7936
+ */
7937
+ var round = (w, base, from) => {
7938
+ const nav = navOf(w);
7939
+ const ins = [-1, ...ROUTES.keys()].map((r) => {
7940
+ return [from, ...path(nav, w, from, base, r).map((st) => st.to)].reverse().find((q) => flat(q[0], q[2], base[0], base[2]) > ENTRY) ?? from;
7941
+ });
7942
+ const out = [];
7943
+ for (let k = 0; k < POSTS; k++) {
7944
+ const a = k * 2 * Math.PI / POSTS;
7945
+ const v = [
7946
+ base[0] + ROUND * Math.sin(a),
7947
+ base[1],
7948
+ base[2] + ROUND * Math.cos(a)
7949
+ ];
7950
+ const [i, on] = locate(nav, w, v);
7951
+ if (i >= 0 && Math.abs(on[1] - base[1]) < .6 && flat(on[0], on[2], v[0], v[2]) < .5) {
7952
+ const away = toward(base[0], base[2], on[0], on[2]);
7953
+ const side = (q) => Math.abs(turn(away, toward(base[0], base[2], q[0], q[2])));
7954
+ const q = ins.reduce((m, c) => side(c) < side(m) ? c : m);
7955
+ out.push({
7956
+ at: on,
7957
+ look: toward(on[0], on[2], q[0], q[2])
7958
+ });
7959
+ }
7960
+ }
7961
+ return out;
7962
+ };
7916
7963
  /**
7917
7964
  * The roles of a team's bots this tick, the same in every bot's head (they see the same team):
7918
7965
  * the nearest to each job takes it, the most pressing jobs first. Half the team or more chase the
@@ -8006,6 +8053,12 @@ var Bot = class {
8006
8053
  shot = 0;
8007
8054
  warned = 0;
8008
8055
  past = 1;
8056
+ /** A guard's flag and round, the point it goes to, the tick it leaves it, and where it looks there. */
8057
+ base;
8058
+ posts = [];
8059
+ post = 0;
8060
+ stop = 0;
8061
+ gaze;
8009
8062
  /** The tick it last fought each enemy, by id. */
8010
8063
  met = /* @__PURE__ */ new Map();
8011
8064
  /** The enemy it shot to hit this tick, -1 for none: the room hands it to the others as `hunters`. */
@@ -8052,6 +8105,7 @@ var Bot = class {
8052
8105
  /** The input of this tick. */
8053
8106
  think(s) {
8054
8107
  const i = this.decide(s);
8108
+ if (s.kit?.katana && s.me.state.blade && !s.me.state.down) i.keys |= BLADE;
8055
8109
  this.keys = i.keys;
8056
8110
  return i;
8057
8111
  }
@@ -8108,6 +8162,7 @@ var Bot = class {
8108
8162
  return e;
8109
8163
  }
8110
8164
  } else this.sortie.board = void 0;
8165
+ this.gaze = void 0;
8111
8166
  const goal = this.goalOf(s);
8112
8167
  if (!this.goal && !p.ground) return {
8113
8168
  keys: FORWARD,
@@ -8245,7 +8300,7 @@ var Bot = class {
8245
8300
  return this.sortie.board;
8246
8301
  }
8247
8302
  const gear = s.kit?.gear ?? true;
8248
- if (p.ammo < 0 && gear && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) {
8303
+ if (p.ammo < 0 && gear && !s.kit?.katana && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) {
8249
8304
  this.why = "gun rack";
8250
8305
  return home.rack;
8251
8306
  }
@@ -8254,7 +8309,7 @@ var Bot = class {
8254
8309
  p.y + eyeHeight(p),
8255
8310
  p.z
8256
8311
  ];
8257
- const prey = gear ? void 0 : others.find((o) => o.team !== team && !o.state.down && Math.abs(o.state.y - p.y) < HUNT_Y && flat(p.x, p.z, o.state.x, o.state.z) < HUNT && !hidden(world, eye, [
8312
+ const prey = gear && !s.kit?.katana ? void 0 : others.find((o) => o.team !== team && !o.state.down && Math.abs(o.state.y - p.y) < HUNT_Y && flat(p.x, p.z, o.state.x, o.state.z) < HUNT && !hidden(world, eye, [
8258
8313
  o.state.x,
8259
8314
  o.state.y + 1.2,
8260
8315
  o.state.z
@@ -8263,7 +8318,7 @@ var Bot = class {
8263
8318
  this.why = "hunt";
8264
8319
  return at(prey.state);
8265
8320
  }
8266
- const { roles, trouble } = squad(team, [{
8321
+ const { roles, trouble } = s.squad ?? squad(team, [{
8267
8322
  ...me,
8268
8323
  bot: true
8269
8324
  }, ...others], flags, world);
@@ -8294,7 +8349,7 @@ var Bot = class {
8294
8349
  }
8295
8350
  if (role === "guard") {
8296
8351
  this.why = "guard";
8297
- return home.base;
8352
+ return this.patrol(world, p, home.base, world.def.teams[1 - team].base);
8298
8353
  }
8299
8354
  this.why = "take flag";
8300
8355
  return theirs.state === FLAG$1.DROPPED ? [
@@ -8303,6 +8358,26 @@ var Bot = class {
8303
8358
  theirs.z
8304
8359
  ] : world.def.teams[1 - team].base;
8305
8360
  }
8361
+ /** The guard's point: round its flag, a stop at each point, one way or the other by its id. */
8362
+ patrol(w, p, base, from) {
8363
+ if (this.base !== base) [this.base, this.posts, this.post] = [
8364
+ base,
8365
+ round(w, base, from),
8366
+ 0
8367
+ ];
8368
+ const n = this.posts.length;
8369
+ if (!n) return base;
8370
+ const { at, look } = this.posts[this.post];
8371
+ if (flat(p.x, p.z, at[0], at[2]) < 1.5) {
8372
+ this.gaze = norm(look + SWEEP * Math.sin(this.ticks / 50 + this.id));
8373
+ this.stop ||= this.ticks + PAUSE + Math.floor(this.rnd() * PAUSE);
8374
+ if (this.ticks > this.stop) {
8375
+ this.post = (this.post + (this.id & 1 ? 1 : n - 1)) % n;
8376
+ this.stop = 0;
8377
+ }
8378
+ }
8379
+ return this.posts[this.post].at;
8380
+ }
8306
8381
  plan(w, p, goal) {
8307
8382
  this.goal = goal;
8308
8383
  this.planned = this.ticks;
@@ -8343,7 +8418,7 @@ var Bot = class {
8343
8418
  }
8344
8419
  return {
8345
8420
  keys: 0,
8346
- yaw: this.aim,
8421
+ yaw: this.gaze ?? this.aim,
8347
8422
  free: true,
8348
8423
  exact: false
8349
8424
  };
@@ -8627,6 +8702,7 @@ var Bot = class {
8627
8702
  }
8628
8703
  this.met.set(foe.id, this.ticks);
8629
8704
  const d = flat(p.x, p.z, q.x, q.z);
8705
+ const blade = !!s.kit?.katana && !!p.blade;
8630
8706
  const v = this.speed;
8631
8707
  const k = this.persona.track;
8632
8708
  [v[0], v[1], v[2]] = [
@@ -8634,7 +8710,7 @@ var Bot = class {
8634
8710
  v[1] + (q.vy - v[1]) * k,
8635
8711
  v[2] + (q.vz - v[2]) * k
8636
8712
  ];
8637
- const lead = this.persona.lead * d / (p.rifled ? 400 : 80);
8713
+ const lead = blade ? 0 : this.persona.lead * d / (p.rifled ? 400 : 80);
8638
8714
  const [tx, ty, tz] = [
8639
8715
  q.x + v[0] * lead,
8640
8716
  q.y + 1.1 + v[1] * lead,
@@ -8646,7 +8722,7 @@ var Bot = class {
8646
8722
  this.err = this.err * .94 + (this.rnd() * 2 - 1) * shake * .35;
8647
8723
  this.errUp = this.errUp * .94 + (this.rnd() * 2 - 1) * shake * .2;
8648
8724
  const before = (s.hunters?.get(foe.id) ?? []).filter((id) => id !== this.id && id < this.id).length;
8649
- const warning = p.shots - this.shot < this.warned;
8725
+ const warning = (p.shots - this.shot & 255) < this.warned;
8650
8726
  const off = !warning && before < TOKENS ? this.err : this.past * Math.atan2(PAST, Math.max(d, 1));
8651
8727
  const want = norm(toward(p.x, p.z, tx, tz) + off);
8652
8728
  const rate = this.persona.turn;
@@ -8654,9 +8730,13 @@ var Bot = class {
8654
8730
  this.pitch = Math.atan2(ty - eye[1], Math.max(d, .1)) + this.errUp;
8655
8731
  const ready = this.ticks - this.since > this.persona.react && Math.abs(turn(this.aim, want)) < CONE;
8656
8732
  if (foe.id === carrier && d < TACKLE && p.ground && !(p.held & DASH)) return { keys: FORWARD | DASH };
8733
+ if (blade) {
8734
+ const inReach = d < CUTS[CUT.SLASH].reach && Math.abs(q.y - p.y) < HUNT_Y;
8735
+ return { keys: ready && inReach && !p.swing ? this.rnd() < .25 ? SPECIAL : FIRE : 0 };
8736
+ }
8657
8737
  const armed = p.ammo > 0 && (p.mag ?? 0) > 0 && !p.wield;
8658
8738
  const pull = armed && d < RANGE || !armed && d < 1.4;
8659
- if (!warning) this.hunting = foe.id;
8739
+ if (!warning && ready && pull) this.hunting = foe.id;
8660
8740
  return { keys: ready && pull && this.ticks & 1 ? FIRE : 0 };
8661
8741
  }
8662
8742
  };
@@ -9017,7 +9097,7 @@ var decodeInput = (buf) => {
9017
9097
  if (v.getUint8(0) !== 1) return null;
9018
9098
  return {
9019
9099
  seq: v.getUint16(1),
9020
- keys: v.getUint16(3) & 32767,
9100
+ keys: v.getUint16(3),
9021
9101
  yaw: fromTurn(v.getUint16(5)),
9022
9102
  pitch: fromPitch(v.getInt16(7)),
9023
9103
  view: (v.getUint16(9) * 256 + v.getUint8(11)) / 256
@@ -9074,7 +9154,7 @@ var encodeSnapshot = (s) => {
9074
9154
  v.setUint8(o + 54, p.slow ?? 0);
9075
9155
  v.setUint8(o + 55, p.mag ?? 0);
9076
9156
  v.setUint8(o + 56, p.cap ?? 0);
9077
- v.setUint8(o + 57, p.reload ?? 0);
9157
+ v.setUint8(o + 57, (p.reload ?? 0) | +!!p.fists << 7);
9078
9158
  v.setUint8(o + 58, (p.rifle ?? -1) + 1);
9079
9159
  v.setUint8(o + 59, p.clip ?? 0);
9080
9160
  v.setUint8(o + 60, p.heat ?? 0);
@@ -9775,6 +9855,7 @@ var Room = class {
9775
9855
  reload: 0,
9776
9856
  blade: false,
9777
9857
  wield: false,
9858
+ fists: false,
9778
9859
  swing: 0,
9779
9860
  lost: LIMB.NONE,
9780
9861
  fell,
@@ -9920,7 +10001,7 @@ var Room = class {
9920
10001
  * `p` drew it) takes the cut's hp, and its crew none of it.
9921
10002
  */
9922
10003
  cut(p, view) {
9923
- if (!p.state.blade) {
10004
+ if (!p.state.wield && (!p.state.blade || p.state.fists)) {
9924
10005
  this.punch(p, view);
9925
10006
  return;
9926
10007
  }
@@ -10325,8 +10406,7 @@ var Room = class {
10325
10406
  /** The rover fell under the kill floor: who was aboard is back at a spawn, it is parked again. */
10326
10407
  sink(r) {
10327
10408
  for (const p of this.players()) if (this.seatOf(p)[0] === r) {
10328
- respawn(p.state, this.world, p.info.team);
10329
- p.state.hp = this.kit(p).hp;
10409
+ respawn(p.state, this.world, p.info.team, this.kit(p));
10330
10410
  this.ctf.moved(p.state);
10331
10411
  }
10332
10412
  this.renew(this.rovers.indexOf(r));
@@ -10503,12 +10583,12 @@ var Room = class {
10503
10583
  }
10504
10584
  }
10505
10585
  /** The first spawn point of the team with none of `others` within SPAWN_CLEAR, else the next one round-robin. */
10506
- place(id, team, others) {
10586
+ place(id, team, others, kit) {
10507
10587
  const n = this.world.def.teams[team].spawns.findIndex((_, k) => {
10508
10588
  const { x, z } = spawn(id, this.world, k, team);
10509
10589
  return !others.some((o) => Math.hypot(o.x - x, o.z - z) < SPAWN_CLEAR);
10510
10590
  });
10511
- return spawn(id, this.world, n < 0 ? this.rr[team]++ : n, team);
10591
+ return spawn(id, this.world, n < 0 ? this.rr[team]++ : n, team, kit);
10512
10592
  }
10513
10593
  /** The match is over: everyone gets the result and what each player did. */
10514
10594
  end(players) {
@@ -10538,10 +10618,9 @@ var Room = class {
10538
10618
  for (const p of players) {
10539
10619
  const { shots, hits } = p.state;
10540
10620
  p.state = {
10541
- ...this.place(p.info.id, p.info.team, put),
10621
+ ...this.place(p.info.id, p.info.team, put, this.kit(p)),
10542
10622
  shots,
10543
- hits,
10544
- hp: this.kit(p).hp
10623
+ hits
10545
10624
  };
10546
10625
  put.push(p.state);
10547
10626
  this.ctf.place(p.info.id, p.state);
@@ -10564,6 +10643,7 @@ var Room = class {
10564
10643
  const { packs = [] } = this.world.def;
10565
10644
  const health = packs.filter((_, k) => !this.gone[k]);
10566
10645
  const errands = this.errands(players);
10646
+ const squads = [0, 1].map((team) => squad(team, others, this.ctf.flags, this.world));
10567
10647
  const hunters = /* @__PURE__ */ new Map();
10568
10648
  for (const p of players) if (p.bot && p.bot.hunting >= 0) hunters.set(p.bot.hunting, [...hunters.get(p.bot.hunting) ?? [], p.info.id]);
10569
10649
  for (const p of players) if (p.bot) {
@@ -10577,7 +10657,8 @@ var Room = class {
10577
10657
  errand: errands.get(p.info.id),
10578
10658
  kit: this.kit(p),
10579
10659
  hunters,
10580
- packs: health
10660
+ packs: health,
10661
+ squad: squads[p.info.team]
10581
10662
  });
10582
10663
  p.seq = (p.seq ?? -1) + 1 & 65535;
10583
10664
  const watchers = players.filter((q) => q.watch === p.info.id);
@@ -10708,10 +10789,7 @@ var Room = class {
10708
10789
  ...chosen(picked),
10709
10790
  ...bot ? { bot } : {}
10710
10791
  },
10711
- state: {
10712
- ...this.place(id, team, players.map((p) => p.state)),
10713
- hp: kitOf(chosen(picked).role, this.world.def).hp
10714
- },
10792
+ state: this.place(id, team, players.map((p) => p.state), kitOf(chosen(picked).role, this.world.def)),
10715
10793
  since: this.joins++,
10716
10794
  bank: 10,
10717
10795
  ack: 65535,
@@ -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' | 'hits'>;
39
+ type Blade = Pick<PlayerState, 'swing' | 'cut' | 'wield' | 'blade' | 'fists' | '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.
@@ -111,12 +111,14 @@ export declare const GUN_ON: {
111
111
  */
112
112
  export declare const PRESS = 0.45;
113
113
  export declare const pressAt: (kind: number) => number;
114
+ /** The selected weapon slot, or -1 when bare-handed or down. */
115
+ export declare const handOf: (p: Pick<PlayerState, "down" | "fists" | "wield" | "rifled" | "railed" | "ammo">) => number;
114
116
  /**
115
117
  * A tracker of the weapons each player has had in hand since taking them: true when the weapon in
116
118
  * `p`'s hand comes to it for the first time, the only time it is switched on (the user,
117
119
  * 2026-11-09). A weapon the player no longer carries (lost going down) is forgotten.
118
120
  */
119
- export declare const firsts: () => (p: Pick<PlayerState, "id" | "ammo" | "blade" | "rail" | "rifle" | "down" | "wield" | "rifled" | "railed">) => boolean;
121
+ export declare const firsts: () => (p: Pick<PlayerState, "id" | "ammo" | "fists" | "blade" | "rail" | "rifle" | "down" | "wield" | "rifled" | "railed">) => boolean;
120
122
  /**
121
123
  * The rail gun's capsule `t` after the gun came to hand, the left hand on it at `at`: turned a
122
124
  * quarter of a turn to tune it on (the user, 2026-11-09), radians, as the screw turns it.
@@ -94,7 +94,7 @@ export interface Hud {
94
94
  * `nades` left in its launcher as dots after the count, hollow for the ones spent. `armor` shows
95
95
  * as gold pips after the health's, only the ones he has.
96
96
  */
97
- vitals(hp: number, ammo: number, blade?: boolean, wield?: boolean, rail?: number, railed?: boolean, loaded?: number, swapping?: boolean, rifle?: number, rifled?: boolean, nades?: number, armor?: number): void;
97
+ vitals(hp: number, ammo: number, blade?: boolean, wield?: boolean, rail?: number, railed?: boolean, loaded?: number, swapping?: boolean, rifle?: number, rifled?: boolean, nades?: number, armor?: number, fists?: boolean): void;
98
98
  /** The health the own player's class has at most (Kit.hp): as many pips. */
99
99
  life(max: number): void;
100
100
  /** A hit marker on the crosshair for a moment: a ball or a cut of the own player hit. */
@@ -11,26 +11,25 @@ export declare const keyBit: (code: string) => number;
11
11
  export declare const DOUBLE_CLICK_MS = 300;
12
12
  /** The wheel swaps the weapon at most this often (ms): a trackpad's flick is a hundred events, one swap. */
13
13
  export declare const WHEEL_MS = 250;
14
- /** The weapon chosen: 1, 2, 3 and 4 on the keyboard. */
14
+ /** The weapon chosen: 1 through 5 on the keyboard. */
15
15
  export declare const WEAPON: {
16
16
  readonly GUN: 0;
17
17
  readonly BLADE: 1;
18
18
  readonly RAIL: 2;
19
19
  readonly RIFLE: 3;
20
+ readonly FISTS: 4;
20
21
  };
21
22
  /** The choice after a key: 1 the gun, 2 the katana, 3 the rail gun, 4 the laser rifle, any other key keeps it. */
22
23
  export declare const picked: (weapon: number, code: string) => number;
23
24
  /** Which of the gun, the katana, the rail gun and the laser rifle a player has; all of them when there is no state yet. */
24
25
  export declare const owned: (p?: PlayerState) => boolean[];
25
26
  /**
26
- * The choice after a step of the own player. Picking the katana, the rail gun or the rifle up switches to
27
- * it, once; losing every weapon (going down) goes back to the gun; anything else, the gun picked
28
- * up included, keeps it.
27
+ * Follow the spawn's weapon and switch to newly picked-up special weapons unless fists are selected.
29
28
  */
30
29
  export declare const chosen: (weapon: number, was?: PlayerState, now?: PlayerState) => number;
31
30
  /** The keys of a step with KEY.BLADE set while the katana is the choice, KEY.RAIL while the rail gun is, KEY.RIFLE while the rifle is. */
32
31
  export declare const withWeapon: (keys: number, weapon: number) => number;
33
- /** The choice the wheel turns to, `dir` 1 or -1: the next weapon he has, round the four. */
32
+ /** The choice the wheel turns to, `dir` 1 or -1: the next weapon he has, including fists. */
34
33
  export declare const turned: (weapon: number, dir: number, have: boolean[]) => number;
35
34
  /** Live look angles and held keys; the loop reads them once per step and per frame. */
36
35
  export interface Controls {
@@ -178,7 +178,7 @@ export interface Renderer {
178
178
  parried(id: number, late: number): void;
179
179
  /** The xenomorph's vision (the own player is one): a grey-blue world, the enemies in sight glowing. */
180
180
  vision(on: boolean): void;
181
- /** The own katana in hand (the user, 2026-11-16): an enemy it could glory kill flashes. */
181
+ /** Let eligible glory kill targets flash during play. */
182
182
  edge(on: boolean): void;
183
183
  /** 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`. */
184
184
  wear(builds: ReadonlyMap<number, number>, looks?: ReadonlyMap<number, Choice>): void;
@@ -21,7 +21,7 @@ export declare const TAIL: {
21
21
  * forward down into the view), its turn about the pelvis' up (radians, to its left: through its
22
22
  * right side, a tail pointing back turns forward), its lean to the right, its reach (as a share of
23
23
  * its length, a whip stretched), how much of the hook at its tip it keeps, how far its root
24
- * rises (radians, less toward the tip), and how far it is coiled in an S to the side (0 to 1, a charge).
24
+ * rises, how far it coils in an S, and how strongly its tip follows the aim.
25
25
  */
26
26
  export type Lash = readonly [
27
27
  sting: number,
@@ -30,7 +30,8 @@ export type Lash = readonly [
30
30
  reach: number,
31
31
  hook: number,
32
32
  rise: number,
33
- coil?: number
33
+ coil?: number,
34
+ aim?: number
34
35
  ];
35
36
  /** At rest: behind, hooked. */
36
37
  export declare const HOOKED: Lash;
@@ -106,7 +107,7 @@ export declare const backOf: (lod: number) => Back;
106
107
  * (blade()), glowing in the team's `color`. Written straight into `out`. `lod` 0 far, 1 near, 3 close.
107
108
  * `fours` (0 to 1): how far the body is on all fours (fours.ts).
108
109
  */
109
- export declare const tail: (out: Out, s: Solved, t: number, run: number, lash: Lash, color: number[], lod: number, fours?: number) => void;
110
+ export declare const tail: (out: Out, s: Solved, t: number, run: number, lash: Lash, color: number[], lod: number, fours?: number, look?: Pick<PlayerState, "yaw" | "pitch">) => void;
110
111
  /** Bone: its claws and teeth, nothing else. */
111
112
  export declare const BONE: number[];
112
113
  /** Its claws, hands and feet (the user, 2026-11-17: less white): a dull horn, darker than bone. */
@@ -31,8 +31,8 @@ export declare const swingOf: (p: Pick<PlayerState, "cut" | "heavy">, table?: ty
31
31
  hold: number;
32
32
  };
33
33
  /**
34
- * The health a xenomorph's swing `p` takes: the claws and the specials their own `hp`; the tail
35
- * TAIL_HP[0] let go before a charge, up to TAIL_HP[1] for a heavy release of a full one (`charge`
34
+ * The health a xenomorph's swing `p` takes: its base damage on a tap, and for a tail strike
35
+ * up to TAIL_HP[1] on a full charge (`charge`
36
36
  * stays through the release, gun.ts).
37
37
  */
38
38
  export declare const sting: (p: Pick<PlayerState, "cut" | "heavy" | "charge">) => number;