@korial29/tiny-fps 0.130.1 → 0.131.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
@@ -370,6 +370,7 @@ var BODY = {
370
370
  MALE: 0,
371
371
  FEMALE: 1
372
372
  };
373
+ var HAIRS_N = [4, 5];
373
374
  /** Bits of Input.keys. Keys are read by KeyboardEvent.code, so WASD is ZQSD on AZERTY. */
374
375
  var KEY = {
375
376
  FORWARD: 1,
@@ -511,6 +512,53 @@ var TEX = {
511
512
  /** Dark basalt: mottled, speckled with pits and light flecks, a few fine cracks. The moon's boulders. */
512
513
  ROCK: 12
513
514
  };
515
+ // src/shared/kit.ts
516
+ var ROLE = {
517
+ MARINE: 0,
518
+ NINJA: 1,
519
+ ASTRONAUT: 2
520
+ };
521
+ var MARINE = {
522
+ run: 6,
523
+ sprint: 9,
524
+ jump: 7,
525
+ double: 6,
526
+ wallrun: 60,
527
+ dashes: 1,
528
+ haste: 1,
529
+ ammo: 60,
530
+ rail: 240,
531
+ rifle: 240,
532
+ cool: 7,
533
+ rifleCool: 3
534
+ };
535
+ /** By ROLE. The astronaut moves and fights as the marine: the moon's gravity is the map's. */
536
+ var KITS = [
537
+ MARINE,
538
+ {
539
+ run: 6 * 1.2,
540
+ sprint: 9 * 1.2,
541
+ jump: 7 * 1.15,
542
+ double: 6 * 1.15,
543
+ wallrun: 120,
544
+ dashes: 3,
545
+ haste: 2,
546
+ ammo: 30,
547
+ rail: 120,
548
+ rifle: 120,
549
+ cool: 14,
550
+ rifleCool: 6
551
+ },
552
+ MARINE
553
+ ];
554
+ /** The classes a map offers, the first one the default: the astronaut alone on a map with space helmets. */
555
+ var rolesOf = (def) => def.helmets ? [ROLE.ASTRONAUT] : [ROLE.MARINE, ROLE.NINJA];
556
+ /** The class a player plays on the map: his `role` when the map offers it, else the map's default. */
557
+ var roleOf = (role, def) => {
558
+ const all = rolesOf(def);
559
+ return all.includes(role ?? -1) ? role : all[0];
560
+ };
561
+ var kitOf = (role, def) => KITS[roleOf(role, def)];
514
562
  // src/shared/world.ts
515
563
  /** Metres per grid cell: about the size of the player's reach, so a query touches 1 to 4 cells. */
516
564
  var CELL = 4;
@@ -1073,7 +1121,7 @@ var unwalled = (p, w, c, h) => {
1073
1121
  * Ground control: speed toward the wished direction (a vector of length 0 to 1), up to `top` times
1074
1122
  * its length; friction with none.
1075
1123
  */
1076
- var steer = (p, wish, top) => {
1124
+ var steer = (p, wish, top, run = 6) => {
1077
1125
  const m = len$1(wish[0], wish[1]);
1078
1126
  if (m < EPS) {
1079
1127
  const s = len$1(p.vx, p.vz);
@@ -1091,7 +1139,7 @@ var steer = (p, wish, top) => {
1091
1139
  [px, pz] = [px * k, pz * k];
1092
1140
  }
1093
1141
  top *= m;
1094
- par = par < top ? Math.min(top, par + (par >= 6 ? 3 : 50) * DT$2) : Math.max(top, par - 12 * DT$2);
1142
+ par = par < top ? Math.min(top, par + (par >= run ? 3 : 50) * DT$2) : Math.max(top, par - 12 * DT$2);
1095
1143
  p.vx = px + par * wx;
1096
1144
  p.vz = pz + par * wz;
1097
1145
  };
@@ -1210,11 +1258,11 @@ var run = (p, w, c) => {
1210
1258
  p.vz = tz - nz * 5;
1211
1259
  leap(p, WALL_KICK_UP);
1212
1260
  p.jumps = 1;
1213
- p.dashes = 1;
1261
+ p.dashes = c.kit.dashes;
1214
1262
  p.ev |= EV.WALLRUN_END;
1215
1263
  } else {
1216
1264
  const gap = wallGap(p, w, p.wall);
1217
- if (gap === void 0 || !c.fwd || s < 3.5 || p.t >= 60) {
1265
+ if (gap === void 0 || !c.fwd || s < 3.5 || p.t >= c.kit.wallrun) {
1218
1266
  enter(p, MODE.AIR);
1219
1267
  p.ev |= EV.WALLRUN_END;
1220
1268
  return;
@@ -1249,7 +1297,7 @@ var startRun = (p, w, c) => {
1249
1297
  [p.vx, p.vz] = [tx * k, tz * k];
1250
1298
  p.vy = clamp$2(p.vy, 2, 3);
1251
1299
  p.jumps = 1;
1252
- p.dashes = 1;
1300
+ p.dashes = c.kit.dashes;
1253
1301
  p.coyote = 0;
1254
1302
  p.ev |= EV.WALLRUN_START;
1255
1303
  return;
@@ -1257,7 +1305,7 @@ var startRun = (p, w, c) => {
1257
1305
  }
1258
1306
  };
1259
1307
  /** Takes hold of a ledge: hang there. */
1260
- var grab = (p, l) => {
1308
+ var grab = (p, l, dashes) => {
1261
1309
  enter(p, MODE.HANG);
1262
1310
  p.wall = l.side;
1263
1311
  p.edge = f32$2(l.top);
@@ -1265,7 +1313,7 @@ var grab = (p, l) => {
1265
1313
  else p.z = l.hang;
1266
1314
  p.vx = p.vy = p.vz = 0;
1267
1315
  p.jumps = 1;
1268
- p.dashes = 1;
1316
+ p.dashes = dashes;
1269
1317
  p.coyote = 0;
1270
1318
  p.buffer = 0;
1271
1319
  p.ev |= EV.GRAB;
@@ -1273,8 +1321,11 @@ var grab = (p, l) => {
1273
1321
  /** The modes that move freely: everything but the hang and the climb. */
1274
1322
  var free$1 = (p, w, c) => {
1275
1323
  const ground = p.mode === MODE.GROUND;
1276
- if (c.dash && p.dash === 0 && (ground || (p.mode === MODE.AIR || p.mode === MODE.WALLRUN) && p.dashes > 0)) {
1324
+ const chain = c.kit.dashes > 1;
1325
+ if (chain && ground && p.dash === 0) p.dashes = c.kit.dashes;
1326
+ if (c.dash && (p.dash === 0 || chain && p.dashes > 0 && p.dash <= 44) && (ground ? !chain || p.dashes > 0 : (p.mode === MODE.AIR || p.mode === MODE.WALLRUN) && p.dashes > 0)) {
1277
1327
  const [dx, dz] = c.wx || c.wz ? [c.wx, c.wz] : [c.fx, c.fz];
1328
+ p.dashes -= +(ground && chain);
1278
1329
  if (!ground) {
1279
1330
  p.dashes--;
1280
1331
  p.vy = 0;
@@ -1300,7 +1351,7 @@ var free$1 = (p, w, c) => {
1300
1351
  p.ev |= EV.LAND | (p.mode === MODE.WALLRUN ? EV.WALLRUN_END : 0);
1301
1352
  p.fall = hit;
1302
1353
  p.jumps = 1;
1303
- p.dashes = 1;
1354
+ p.dashes = c.kit.dashes;
1304
1355
  p.wall = SIDE.NONE;
1305
1356
  if (c.keys & KEY.CROUCH) {
1306
1357
  const slide = len$1(p.vx, p.vz) >= SLIDE_MIN_SPEED;
@@ -1315,7 +1366,7 @@ var free$1 = (p, w, c) => {
1315
1366
  }
1316
1367
  if (p.mode === MODE.AIR) {
1317
1368
  const ledge = ledgeAt(p, w);
1318
- if (ledge) grab(p, ledge);
1369
+ if (ledge) grab(p, ledge, c.kit.dashes);
1319
1370
  else startRun(p, w, c);
1320
1371
  }
1321
1372
  };
@@ -1325,7 +1376,7 @@ var onGround = (p, w, c, burst) => {
1325
1376
  if (p.buffer > 0 && (p.mode === MODE.GROUND || canStand(p, w))) {
1326
1377
  p.ev |= p.mode === MODE.SLIDE ? EV.SLIDE_END : 0;
1327
1378
  enter(p, MODE.AIR);
1328
- leap(p, 7);
1379
+ leap(p, c.kit.jump);
1329
1380
  return;
1330
1381
  }
1331
1382
  const speed = len$1(p.vx, p.vz);
@@ -1354,16 +1405,16 @@ var onGround = (p, w, c, burst) => {
1354
1405
  } else if (p.mode === MODE.CROUCH) steer(p, unwalled(p, w, c, LOW_H), 3);
1355
1406
  else {
1356
1407
  const sprint = (c.keys & KEY.SPRINT) !== 0 && c.fwd;
1357
- steer(p, unwalled(p, w, c, PLAYER_H), sprint ? 9 : 6);
1408
+ steer(p, unwalled(p, w, c, PLAYER_H), sprint ? c.kit.sprint : c.kit.run, c.kit.run);
1358
1409
  }
1359
1410
  };
1360
1411
  /** In the air: the extra jump, a jump just after an edge (coyote), and air control. */
1361
1412
  var air = (p, w, c, burst) => {
1362
1413
  if (p.buffer > 0) {
1363
- if (p.coyote > 0) leap(p, 7);
1414
+ if (p.coyote > 0) leap(p, c.kit.jump);
1364
1415
  else if (p.jumps > 0 && !landingSoon(p, w)) {
1365
1416
  p.jumps--;
1366
- leap(p, 6);
1417
+ leap(p, c.kit.double);
1367
1418
  p.ev = p.ev & ~EV.JUMP | EV.DOUBLE;
1368
1419
  }
1369
1420
  }
@@ -1379,7 +1430,7 @@ var air = (p, w, c, burst) => {
1379
1430
  * kill floor put the player back at a spawn of his `team` (EV.RESPAWN). `bodies` are the rovers'
1380
1431
  * (hull(), rover.ts) as they stand when the step runs: walls and floors for this step alone.
1381
1432
  */
1382
- var move = (p, i, w, team = 0, bodies = []) => {
1433
+ var move = (p, i, w, team = 0, bodies = [], kit = KITS[0]) => {
1383
1434
  p.yaw = norm(i.yaw);
1384
1435
  p.pitch = Math.max(-MAX_PITCH, Math.min(MAX_PITCH, i.pitch));
1385
1436
  const f = (i.keys & KEY.FORWARD ? 1 : 0) - (i.keys & KEY.BACK ? 1 : 0);
@@ -1399,7 +1450,8 @@ var move = (p, i, w, team = 0, bodies = []) => {
1399
1450
  wz: (fz * f + fx * s) / n,
1400
1451
  fx,
1401
1452
  fz,
1402
- bodies
1453
+ bodies,
1454
+ kit
1403
1455
  };
1404
1456
  const before = p.mode;
1405
1457
  p.ev = 0;
@@ -1865,13 +1917,13 @@ var STRIKE = {
1865
1917
  * its swing. The look is the input's, so both go where the player sees.
1866
1918
  * `armed` is false while the match is over: no weapon, no rack. `bodies` are move()'s.
1867
1919
  */
1868
- var step = (p, i, w, team, armed = true, bodies = []) => {
1920
+ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
1869
1921
  const down = p.down > 0;
1870
1922
  const locked = !down && (p.lock ?? 0) > 0;
1871
1923
  move(p, down || locked ? {
1872
1924
  ...i,
1873
1925
  keys: 0
1874
- } : i, w, team, bodies);
1926
+ } : i, w, team, bodies, kit);
1875
1927
  p.heat = Math.max(0, (p.heat ?? 0) - (p.zapping ? 0 : p.hot ? 1 : 2));
1876
1928
  p.hot = !!p.hot && p.heat > 0;
1877
1929
  p.zapping = false;
@@ -1883,19 +1935,22 @@ var step = (p, i, w, team, armed = true, bodies = []) => {
1883
1935
  if (locked) return duel(p, i);
1884
1936
  const { rack, blade, rail, rifle } = w.def.teams[team];
1885
1937
  const inside = !!rack && within(p, rack, 1.2);
1886
- if (armed && inside && !p.rack) [p.ammo, p.mag] = [60, 15];
1938
+ if (armed && inside && !p.rack) [p.ammo, p.mag] = [kit.ammo, 15];
1887
1939
  p.rack = inside;
1888
1940
  p.blade = !!p.blade || armed && !!blade && within(p, blade, 1.2);
1889
1941
  const inRail = !!rail && within(p, rail, 1.2);
1890
- if (armed && inRail && !p.inRail) [p.rail, p.cap] = [240, 80];
1942
+ if (armed && inRail && !p.inRail) [p.rail, p.cap] = [kit.rail, 80];
1891
1943
  p.inRail = inRail;
1892
1944
  const inRifle = !!rifle && within(p, rifle, 1.2);
1893
1945
  if (armed && inRifle && !p.inRifle) [p.rifle, p.clip, p.nades] = [
1894
- 240,
1946
+ kit.rifle,
1895
1947
  60,
1896
1948
  3
1897
1949
  ];
1898
1950
  p.inRifle = inRifle;
1951
+ p.ammo = Math.min(p.ammo, kit.ammo);
1952
+ p.rail = p.rail === void 0 ? p.rail : Math.min(p.rail, kit.rail);
1953
+ p.rifle = p.rifle === void 0 ? p.rifle : Math.min(p.rifle, kit.rifle);
1899
1954
  p.cool = Math.max(0, p.cool - 1);
1900
1955
  p.lob = Math.max(0, (p.lob ?? 0) - 1);
1901
1956
  const busy = p.mode === MODE.HANG || p.mode === MODE.CLIMB;
@@ -1907,7 +1962,10 @@ var step = (p, i, w, team, armed = true, bodies = []) => {
1907
1962
  p.swing = swingOf(p).ticks;
1908
1963
  } else {
1909
1964
  p.charge = top ? 0 : p.charge;
1910
- p.swing = Math.max(0, (p.swing ?? 0) - 1);
1965
+ const s = p.swing ?? 0;
1966
+ const c = swingOf(p);
1967
+ const stop = (v) => v == s - 1 && (v == c.ticks - c.strike || v == PUNCH.ticks - PUNCH.strike || !p.heavy && v == ticks - hold);
1968
+ p.swing = Math.max(0, kit.haste > 1 && stop(s - 1) ? s - 1 : s - kit.haste);
1911
1969
  p.heavy = !!p.swing && !!p.heavy;
1912
1970
  }
1913
1971
  p.mag = Math.min(p.mag ?? 0, Math.max(p.ammo, 0));
@@ -1977,7 +2035,7 @@ var step = (p, i, w, team, armed = true, bodies = []) => {
1977
2035
  if (!p.cool && p.clip && !p.reload) {
1978
2036
  p.rifle--;
1979
2037
  p.clip--;
1980
- p.cool = 3;
2038
+ p.cool = kit.rifleCool;
1981
2039
  p.shots = p.shots + 1 & 255;
1982
2040
  return STRIKE.LASER;
1983
2041
  }
@@ -2000,7 +2058,7 @@ var step = (p, i, w, team, armed = true, bodies = []) => {
2000
2058
  p.ammo -= p.power;
2001
2059
  p.mag = p.mag - p.power;
2002
2060
  p.shots = p.shots + 1 & 255;
2003
- p.cool = 7;
2061
+ p.cool = kit.cool;
2004
2062
  return STRIKE.SHOT;
2005
2063
  }
2006
2064
  return STRIKE.NONE;
@@ -4927,12 +4985,12 @@ var encodeSnapshot = (s) => {
4927
4985
  v.setUint16(o + 29, toTurn(p.yaw));
4928
4986
  v.setInt16(o + 31, toPitch(p.pitch));
4929
4987
  v.setUint16(o + 33, p.ack & 65535);
4930
- v.setUint8(o + 35, p.mode & 7 | (p.wall & 7) << 3 | (p.jumps & 1) << 6 | p.dashes << 7);
4988
+ v.setUint8(o + 35, p.mode & 7 | (p.wall & 7) << 3 | (p.jumps & 1) << 6 | (p.dashes & 1) << 7);
4931
4989
  v.setUint8(o + 36, p.t);
4932
4990
  v.setUint8(o + 37, p.dash | (p.by >> 2 & 3) << 6);
4933
4991
  v.setUint8(o + 38, p.coyote & 7 | (p.buffer & 7) << 3 | (p.held & KEY.JUMP ? 64 : 0) | (p.held & KEY.DASH ? 128 : 0));
4934
4992
  v.setUint8(o + 39, p.stun | (p.by & 3) << 6);
4935
- const gun = p.hp | p.cool << 3 | (p.ammo < 0 ? NO_GUN : p.ammo) << 6 | p.down << 13 | +!!p.rack << 20 | +!!p.blade << 21 | +!!p.wield << 22 | +!!p.zap << 23;
4993
+ const gun = p.hp | (p.cool & 7) << 3 | (p.ammo < 0 ? NO_GUN : p.ammo) << 6 | p.down << 13 | +!!p.rack << 20 | +!!p.blade << 21 | +!!p.wield << 22 | +!!p.zap << 23;
4936
4994
  v.setUint8(o + 40, gun >> 16);
4937
4995
  v.setUint16(o + 41, gun & 65535);
4938
4996
  v.setUint8(o + 43, p.shots);
@@ -4941,11 +4999,11 @@ var encodeSnapshot = (s) => {
4941
4999
  v.setUint8(o + 46, (p.lost ?? 0) & 7 | ((p.cut ?? 0) & 4) << 1 | (p.fried ? 16 : 0) | (p.heavy ? 32 : 0));
4942
5000
  v.setUint8(o + 47, p.charge ?? 0);
4943
5001
  v.setUint8(o + 48, p.lock ?? 0);
4944
- v.setUint8(o + 49, (p.foe ?? 0) & 15 | (p.pressed ? 128 : 0));
5002
+ v.setUint8(o + 49, (p.foe ?? 0) & 15 | (p.dashes & 2) << 3 | (p.pressed ? 128 : 0));
4945
5003
  v.setUint8(o + 50, p.pushes ?? 0);
4946
5004
  v.setUint8(o + 51, p.away ?? 0);
4947
5005
  v.setUint8(o + 52, (p.rail ?? -1) + 1);
4948
- v.setUint8(o + 53, +!!p.railed | +!!p.inRail << 1 | +!!p.zapping << 2 | +!!p.rifled << 3 | +!!p.inRifle << 4 | +!!p.hot << 5 | (p.held & KEY.USE ? 64 : 0));
5006
+ v.setUint8(o + 53, +!!p.railed | +!!p.inRail << 1 | +!!p.zapping << 2 | +!!p.rifled << 3 | +!!p.inRifle << 4 | +!!p.hot << 5 | (p.held & KEY.USE ? 64 : 0) | (p.cool & 8) << 4);
4949
5007
  v.setUint8(o + 54, p.slow ?? 0);
4950
5008
  v.setUint8(o + 55, p.mag ?? 0);
4951
5009
  v.setUint8(o + 56, p.cap ?? 0);
@@ -6237,6 +6295,26 @@ var SPAWN_CLEAR = 2;
6237
6295
  var SPLAT_COOLDOWN = 30;
6238
6296
  /** The two seats of a rover, the driver's first. */
6239
6297
  var SEATS = ["driver", "rider"];
6298
+ /** An index in [0, n), or undefined. */
6299
+ var index = (v, n) => Number.isInteger(v) && v >= 0 && v < n ? v : void 0;
6300
+ /**
6301
+ * What a player picked, only what the game knows: the woman's body (the man's is no field, so an old
6302
+ * roster is unchanged), a skin, a haircut of that body and a class (ROLE: the map says which it offers).
6303
+ */
6304
+ var chosen = (m) => {
6305
+ const body = m.body === BODY.FEMALE ? BODY.FEMALE : void 0;
6306
+ const [tone, hair, role] = [
6307
+ index(m.tone, 6),
6308
+ index(m.hair, HAIRS_N[body ?? 0]),
6309
+ index(m.role, 3)
6310
+ ];
6311
+ return {
6312
+ ...body !== void 0 ? { body } : {},
6313
+ ...tone !== void 0 ? { tone } : {},
6314
+ ...hair !== void 0 ? { hair } : {},
6315
+ ...role !== void 0 ? { role } : {}
6316
+ };
6317
+ };
6240
6318
  /** First n characters (code points) of s, trimmed. */
6241
6319
  var cut = (s, n) => Array.from(s).slice(0, n).join("").trim();
6242
6320
  var cleanName = (raw) => cut((typeof raw === "string" ? raw : "").replace(/\s+/g, " ").replace(/\p{Cc}/gu, "").trim(), 16);
@@ -6396,14 +6474,23 @@ var Room = class {
6396
6474
  const p = this.peers.get(conn);
6397
6475
  if (typeof data === "string") {
6398
6476
  const msg = parseText(data);
6399
- if (p === null && msg?.t === "join") this.join(conn, msg.name, msg.body);
6477
+ if (p === null && msg?.t === "join") this.join(conn, msg.name, msg);
6400
6478
  else if (p && msg?.t === "map" && p === this.host() && Object.hasOwn(MAPS, msg.map)) {
6401
6479
  this.next = msg.map === this.mapName ? void 0 : msg.map;
6402
6480
  this.roster();
6403
- } else if (p && msg?.t === "body" && msg.body === BODY.FEMALE !== !!p.info.body) {
6404
- if (msg.body === BODY.FEMALE) p.info.body = BODY.FEMALE;
6405
- else delete p.info.body;
6406
- this.roster();
6481
+ } else if (p && msg?.t === "body") {
6482
+ const { id, name, team, color } = p.info;
6483
+ const info = {
6484
+ id,
6485
+ name,
6486
+ team,
6487
+ color,
6488
+ ...chosen(msg)
6489
+ };
6490
+ if (JSON.stringify(info) !== JSON.stringify(p.info)) {
6491
+ p.info = info;
6492
+ this.roster();
6493
+ }
6407
6494
  }
6408
6495
  return;
6409
6496
  }
@@ -6424,7 +6511,7 @@ var Room = class {
6424
6511
  this.lase(p, r, input);
6425
6512
  }
6426
6513
  } else {
6427
- const struck = step(p.state, input, this.world, p.info.team, !this.ctf.over, solid(this.rovers, p.state));
6514
+ const struck = step(p.state, input, this.world, p.info.team, !this.ctf.over, solid(this.rovers, p.state), kitOf(p.info.role, this.world.def));
6428
6515
  this.ctf.moved(p.state);
6429
6516
  this.tackle(p, input.view);
6430
6517
  const here = spot(p.state);
@@ -6956,19 +7043,23 @@ var Room = class {
6956
7043
  return;
6957
7044
  }
6958
7045
  const kind = +(k >= packs.length) + +(k >= packs.length + ammo.length);
6959
- const wants = (q) => [
6960
- q.hp < 5,
6961
- q.ammo >= 0 && q.ammo < 60 || (q.rifle ?? -1) >= 0 && q.rifle < 240,
6962
- (q.rail ?? -1) >= 0 && q.rail < 240
6963
- ][kind];
6964
- const p = players.find(({ state: q }) => !q.down && wants(q) && within(q, at, .9));
7046
+ const wants = ({ state: q, info }) => {
7047
+ const kit = kitOf(info.role, this.world.def);
7048
+ return [
7049
+ q.hp < 5,
7050
+ q.ammo >= 0 && q.ammo < kit.ammo || (q.rifle ?? -1) >= 0 && q.rifle < kit.rifle,
7051
+ (q.rail ?? -1) >= 0 && q.rail < kit.rail
7052
+ ][kind];
7053
+ };
7054
+ const p = players.find((o) => !o.state.down && wants(o) && within(o.state, at, .9));
6965
7055
  if (p) {
6966
7056
  const q = p.state;
7057
+ const kit = kitOf(p.info.role, this.world.def);
6967
7058
  if (kind == 0) q.hp = Math.min(5, q.hp + 2);
6968
7059
  else if (kind == 1) {
6969
- q.ammo = q.ammo < 0 ? -1 : Math.min(60, q.ammo + 20);
6970
- q.rifle = (q.rifle ?? -1) < 0 ? -1 : Math.min(240, q.rifle + 60);
6971
- } else q.rail = Math.min(240, q.rail + 80);
7060
+ q.ammo = q.ammo < 0 ? -1 : Math.min(kit.ammo, q.ammo + 20);
7061
+ q.rifle = (q.rifle ?? -1) < 0 ? -1 : Math.min(kit.rifle, q.rifle + 60);
7062
+ } else q.rail = Math.min(kit.rail, q.rail + 80);
6972
7063
  this.gone[k] = (kind == 1 ? 10 : 20) * 60;
6973
7064
  }
6974
7065
  });
@@ -7281,7 +7372,7 @@ var Room = class {
7281
7372
  players() {
7282
7373
  return [...this.peers.values()].filter((p) => p !== null);
7283
7374
  }
7284
- join(conn, name, body) {
7375
+ join(conn, name, picked = {}) {
7285
7376
  const players = this.players();
7286
7377
  if (players.length >= this.rules.maxPlayers) {
7287
7378
  conn.send(JSON.stringify({ t: "full" }));
@@ -7298,7 +7389,7 @@ var Room = class {
7298
7389
  name: unique(cleanName(name) || `Player ${id}`, players.map((p) => p.info.name)),
7299
7390
  team,
7300
7391
  color: TEAM_COLOR[team],
7301
- ...body === BODY.FEMALE ? { body } : {}
7392
+ ...chosen(picked)
7302
7393
  },
7303
7394
  state: this.place(id, team, players.map((p) => p.state)),
7304
7395
  since: this.joins++,
@@ -14,9 +14,9 @@ interface Region {
14
14
  swell?: (x: number, y: number) => number;
15
15
  /** Where its angles are measured from, degrees (0 the front): 180 for a plate on the back. */
16
16
  face?: number;
17
- /** Its bottom and top at each angle (degrees from the front, + outward), when not level: a leg's opening. */
18
- low?: (a: number) => number;
19
- high?: (a: number) => number;
17
+ /** Its bottom and top at each angle (degrees from the front, + outward) or rest point, when not level: a leg's opening. */
18
+ low?: (a: number, c: Corner) => number;
19
+ high?: (a: number, c: Corner) => number;
20
20
  /** Only on the woman's skin. */
21
21
  fem?: boolean;
22
22
  /** Only on the man's. */
@@ -25,6 +25,9 @@ interface Region {
25
25
  round?: [number, number, number];
26
26
  /** Moulded: a smooth shell round the trunk rather than the skin's facets (moulding()). */
27
27
  mould?: boolean;
28
+ /** Worn by the ninja too (the user, 2026-11-13: the marine's shoulder pieces and chest plate alone); `alone`, by the ninja alone. */
29
+ ninja?: boolean;
30
+ alone?: boolean;
28
31
  }
29
32
  /**
30
33
  * The chest plate's pecs (the user, 2026-11-10: fuller toward the bottom, then the round part too
@@ -54,6 +57,21 @@ export declare const SHOULDER: {
54
57
  y: number;
55
58
  h: number;
56
59
  };
60
+ /**
61
+ * The briefs (the user, 2026-11-10: round the hips under the belt, the leg's opening rising from the
62
+ * crotch to the hip and lower behind, never between the thighs; 2026-11-12: thinner on the sides,
63
+ * and no glitches). One opening line for all their pieces, the band on the trunk and the piece on
64
+ * each thigh, by the angle of the rest point round the trunk (0 the front, 180 the back, either
65
+ * side): the pieces met at the border of the trunk's skin and the legs' (0.93 m) on two lines that
66
+ * did not agree, and left gaps, overlaps and slivers there. Lowest at the crotch, before and
67
+ * behind, it rises to `side`, under the band's top (0.982), between the angles `at`.
68
+ */
69
+ export declare const BRIEFS: {
70
+ front: number;
71
+ back: number;
72
+ side: number;
73
+ at: number[];
74
+ };
57
75
  /**
58
76
  * The chest plate's outer corners go round under the armpits (the user, 2026-11-12: a triangle came
59
77
  * through the plate under the armpit): the shoulder's skin stands out of the trunk's at the split
@@ -78,6 +96,8 @@ export declare const BAND: {
78
96
  /** The gap the user asked between the chest plate and the belly's plates, and between those. */
79
97
  export declare const GAP = 0.02;
80
98
  export declare const REGIONS: Region[];
99
+ /** A corner being clipped: its place at rest, its weights of its skin triangle's corners, its normal at rest, then the limits it lies on (BITS). */
100
+ type Corner = number[];
81
101
  /** The scratches' colours on coloured plates: the white under the paint, and paler. */
82
102
  export declare const SCRATCHED: number[][];
83
103
  /**
@@ -97,5 +117,5 @@ export declare const DOME: {
97
117
  * outlines follow the skin's own triangles, unrefined, and there are no scratches. `plate` is the
98
118
  * plates' colour (their walls a shade darker): white when absent.
99
119
  */
100
- export declare const armor: (out: number[], from: number, s: Skin, fine?: boolean, plate?: number[]) => void;
120
+ export declare const armor: (out: number[], from: number, s: Skin, fine?: boolean, plate?: number[], ninja?: boolean) => void;
101
121
  export {};
@@ -25,8 +25,8 @@ export interface Body {
25
25
  pose(eye: Vec3, yaw: number, pitch: number, roll?: number): Solved | undefined;
26
26
  /** Appends the body's vertices (see STRIDE) in the jacket `color`; nothing when pose() has none. */
27
27
  draw(out: number[], eye: Vec3, yaw: number, pitch: number, roll?: number, color?: number[]): void;
28
- /** The own player's character (BUILD in rig.ts, PlayerInfo.body): the woman's arms are slimmer and her hands smaller, on the same grips. */
29
- wear(build: number): void;
28
+ /** The own player's character (BUILD in rig.ts, PlayerInfo.body): the woman's arms are slimmer and her hands smaller, on the same grips; `tone` the skin he picked (the default's when absent). */
29
+ wear(build: number, tone?: number[], ninja?: boolean): void;
30
30
  }
31
31
  export declare const inv: ([x, y, z, w]: Quat) => Quat;
32
32
  /**
@@ -96,6 +96,10 @@ export declare const hash: (id: number, salt: number) => number;
96
96
  export declare const TONES: number[][];
97
97
  /** A skin tone for the runner `id`, the same for everyone who sees him. */
98
98
  export declare const toneOf: (id: number) => number[];
99
+ /** The skin tone the player picked (`c.tone`, an index of TONES), else his id's. */
100
+ export declare const toneFor: (id: number, c?: {
101
+ tone?: number;
102
+ }) => number[];
99
103
  /**
100
104
  * The face of the runner `id`: the weights of the trait channels (the expressions' are 0), the
101
105
  * same for everyone who sees him. Each trait is the mean of two draws, so most faces are near the
@@ -8,8 +8,10 @@ export declare const STYLE: {
8
8
  readonly UNDERCUT: 4;
9
9
  };
10
10
  export declare const STYLES: number;
11
- /** The hair style of the woman `id`: the same for everyone who sees her. */
12
- export declare const styleOf: (id: number) => number;
11
+ /** The hair style of the woman `id`: the one she picked (`c.hair`), else her id's, the same for everyone who sees her. */
12
+ export declare const styleOf: (id: number, c?: {
13
+ hair?: number;
14
+ }) => number;
13
15
  /** The woman's head to the man's (SCALE in skin.ts), and the lowest a style may hang on the man's head at rest, metres: the chin's height. */
14
16
  export declare const HEAD_SCALE: number, LOWEST: number;
15
17
  /** The style's rest mesh (make()), built once per style and fineness. */
@@ -1,13 +1,21 @@
1
1
  import type { Result } from '../shared/protocol';
2
- import type { PlayerState, Rover, Snapshot } from '../shared/types';
2
+ import type { Choice, PlayerState, Rover, Snapshot } from '../shared/types';
3
3
  import type { Mark } from './marks';
4
4
  export declare const rim: () => [number, number][];
5
5
  export declare const HUD_CSS: string;
6
+ /** The menu of a game paused by Escape (the user, 2026-11-12): play on, then the two parts of the title screen it opens, then leave. */
7
+ export declare const PAUSE: string[];
6
8
  /** The tabs of the title screen's menu, the first one shown first. */
7
9
  export declare const TABS: string[];
8
- /** The characters' first names (the user, 2026-11-11: names, not "man" and "woman"), in BODY's order, and the size of a card's picture in pixels. */
10
+ /** The characters' first names (the user, 2026-11-11: names, not "man" and "woman"), in BODY's order, and the size of the character's picture in pixels. */
9
11
  export declare const CAST: string[];
10
12
  export declare const SHOT: number[];
13
+ /** The size of a haircut's picture, pixels. */
14
+ export declare const HEAD_PX = 112;
15
+ /** The haircuts of each body, in HAIRS_N's order: the man's by length (LENGTHS, soldier.ts), the woman's STYLE (hair.ts). */
16
+ export declare const HAIR_NAMES: string[][];
17
+ /** The classes, in ROLE's order (kit.ts): the name, what it does, and where it plays. */
18
+ export declare const ROLES: [name: string, does: string, where: string][];
11
19
  /** Capture the flag in a few lines, with the room's default rules. */
12
20
  export declare const GOAL: string[];
13
21
  /**
@@ -39,16 +47,20 @@ export interface Hud {
39
47
  */
40
48
  title(status: string, name: string, tag?: string, lore?: string): void;
41
49
  /**
42
- * The character cards of the title screen: `pick` is told the BODY of the card the player
43
- * chooses. Returns the cards' canvases, in BODY's order, for their pictures (SHOT pixels).
50
+ * Whether the player has been in the game: then the title screen opens on the pause menu (PAUSE)
51
+ * rather than the whole panel, until he plays again.
44
52
  */
45
- cast(pick: (body: number) => void): HTMLCanvasElement[];
53
+ paused(on: boolean): void;
46
54
  /**
47
- * The maps in the title screen's Game panel, [key, name] each: the one the next match plays (`next`, else
48
- * `played`) stands out. They are buttons that `pick` when the own player is the host (`mine`),
49
- * read-only for the others; `host` is his name.
55
+ * The character on the title screen: `pick` is told the whole choice (the body, the skin, the
56
+ * haircut, the class) each time the player changes a part of it. Returns the canvas of his live
57
+ * picture (SHOT pixels).
50
58
  */
51
- maps(list: [string, string][], played: string, next: string | undefined, host: string, mine: boolean, pick: (key: string) => void): void;
59
+ cast(pick: (c: Choice & {
60
+ body: number;
61
+ }) => void): HTMLCanvasElement;
62
+ /** The pictures of the haircuts on offer, in their order (HEAD_PX square): the own head with each. */
63
+ heads(): HTMLCanvasElement[];
52
64
  /** Shows or hides the muted mark. */
53
65
  mute(on: boolean): void;
54
66
  /**
@@ -78,8 +90,12 @@ export interface Hud {
78
90
  hit(): void;
79
91
  /** The face over the health, frame `n` of face.ts (-1 hides it). */
80
92
  face(n: number): void;
81
- /** The own player's character (BODY): the face is hers when she is the woman, and her card is the chosen one. */
82
- wear(body: number): void;
93
+ /**
94
+ * The own player's character (BODY): the face is hers when she is the woman. `c` is what the
95
+ * roster says he picked, shown chosen on the title screen, and `roles` the classes the map offers
96
+ * (ROLE): the others are greyed out.
97
+ */
98
+ wear(body: number, c?: Choice, roles?: number[]): void;
83
99
  /**
84
100
  * A saber lock: the gauge of the tug of war under the crosshair, with `lead` the own side's, -1
85
101
  * (the foe wins) to 1 (he wins); undefined hides it.
@@ -129,4 +145,4 @@ export declare const clock: (s: number) => string;
129
145
  * Appends the HUD to `screen`, whose stylesheet has HUD_CSS. `play` is the title screen's button:
130
146
  * the click that starts the game (the panel takes its other clicks, the view round it plays too).
131
147
  */
132
- export declare const createHud: (screen: HTMLElement, play?: () => void) => Hud;
148
+ export declare const createHud: (screen: HTMLElement, play?: () => void, quit?: () => void) => Hud;
@@ -14,7 +14,8 @@ export interface TinyFpsOptions {
14
14
  /** The character to play (BODY): the man (0, the default) or the woman (1). The look only. */
15
15
  body?: number;
16
16
  }
17
- export type TinyFpsEvent = 'roster' | 'open' | 'close';
17
+ /** quit: the player left from the pause menu (Escape, then Quit); the page decides where he goes. */
18
+ export type TinyFpsEvent = 'roster' | 'open' | 'close' | 'quit';
18
19
  export interface TinyFps {
19
20
  on(ev: TinyFpsEvent, cb: () => void): void;
20
21
  /** Everyone in the room, the own player included. */
@@ -0,0 +1,14 @@
1
+ import type { Quat } from './rig';
2
+ import type { Vec3 } from './mesh';
3
+ import type { Skin } from './skin';
4
+ /** The suit's and the hood's black, a touch of blue in it; the guard's rim, a shade lighter; the disc's ink. */
5
+ export declare const CLOTH: number[];
6
+ /**
7
+ * Dresses the head of the skin `s` just drawn into `out` from `from` (skin(), in the order of its
8
+ * triangles' corners), on the head joint at `at` turned by `q`: the hood painted on it (the head,
9
+ * the neck and the skin at the neck's foot, but the opening round the eyes, soft at its edge), and
10
+ * the face under the guard pressed in behind it.
11
+ */
12
+ export declare const dress: (out: number[], from: number, s: Skin, at: Vec3, q: Quat, build?: number) => void;
13
+ /** Appends the guard and the ideograms on the head joint at `at` turned by `q` (see solve()), on the woman's smaller head with `build`, in the team's `color`. */
14
+ export declare const mask: (out: number[], at: Vec3, q: Quat, build?: number, color?: number[]) => void;
@@ -3,9 +3,9 @@ import type { World } from '../shared/world';
3
3
  export interface Predictor {
4
4
  /**
5
5
  * The own player id and team, from the roster. Snapshots before it are only used for the others.
6
- * The team picks the spawn a fall puts the player back at.
6
+ * The team picks the spawn a fall puts the player back at, the role (ROLE) the kit of the steps.
7
7
  */
8
- you(id: number, team?: number): void;
8
+ you(id: number, team?: number, role?: number): void;
9
9
  /**
10
10
  * One local step: gives the input the next seq, rounds its yaw and pitch to the wire, moves the
11
11
  * own player with it, keeps it for replay, and returns it for the caller to send (the very