@korial29/tiny-fps 0.101.1 → 0.103.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
@@ -304,7 +304,7 @@ var trace = (w, o, d, max, grow = 0) => {
304
304
  };
305
305
  // src/shared/types.ts
306
306
  /** Where a team's flag is: at its base, on a carrier's back, or on the ground where it was dropped. */
307
- var FLAG = {
307
+ var FLAG$1 = {
308
308
  HOME: 0,
309
309
  CARRIED: 1,
310
310
  DROPPED: 2
@@ -755,15 +755,51 @@ var shove = (p, w, h, r) => {
755
755
  }
756
756
  return [tx, tz];
757
757
  };
758
+ /** The offset from the closest point of a body's axis to (x, z), and the height of its bottom there. */
759
+ var gapTo = (o, x, z) => {
760
+ const [[ax, ay, az], [bx, by, bz]] = [o.a, o.b];
761
+ const [ux, uz] = [bx - ax, bz - az];
762
+ const l2 = ux * ux + uz * uz;
763
+ const t = l2 ? clamp$1(((x - ax) * ux + (z - az) * uz) / l2, 0, 1) : 0;
764
+ return [
765
+ x - ax - t * ux,
766
+ z - az - t * uz,
767
+ ay + t * (by - ay)
768
+ ];
769
+ };
770
+ /**
771
+ * push() for the bodies: the player's circle out of each body that blocks it (as blocks() a
772
+ * brush), along the line from its axis. A centre on the axis leaves by the body's right (a is its
773
+ * front). A body moves on its own clock and may be deep in him: the push is as deep as it needs.
774
+ */
775
+ var jostle = (p, bodies, h) => {
776
+ let [tx, tz] = [0, 0];
777
+ for (const o of bodies) {
778
+ const [dx, dz, y] = gapTo(o, p.x, p.z);
779
+ const r = o.r + PLAYER_R;
780
+ const d2 = dx * dx + dz * dz;
781
+ if (d2 >= (r - EPS) ** 2 || y + o.h <= p.y + .5 + SKIN || y >= p.y + h - SKIN) continue;
782
+ const d = sqrt$1(d2);
783
+ const [ux, uz] = [o.b[0] - o.a[0], o.b[2] - o.a[2]];
784
+ const l = len$1(ux, uz);
785
+ const [nx, nz] = d ? [dx / d, dz / d] : l ? [uz / l, -ux / l] : [1, 0];
786
+ p.x += nx * (r - d);
787
+ p.z += nz * (r - d);
788
+ tx += nx * (r - d);
789
+ tz += nz * (r - d);
790
+ }
791
+ return [tx, tz];
792
+ };
758
793
  /**
759
794
  * The floor and the ceiling under the player: the highest top the player can stand on (at most
760
- * STEP_H above the feet) and the lowest bottom above the head, among the boxes the circle overlaps.
795
+ * STEP_H above the feet) and the lowest bottom above the head, among the boxes and the bodies the
796
+ * circle overlaps.
761
797
  * Every top between the feet and the fall is a candidate and so is every bottom above the head,
762
798
  * however far: a fall of any speed stops on the first top under the circle, and a rise (at most
763
799
  * DOUBLE_JUMP_SPEED / TICK_HZ = 0.12 m a step) cannot pass a bottom. Only a corner clipped by under a
764
800
  * millimetre of overlap at one end of a step and none at the other could slip past.
765
801
  */
766
- var span = (p, w, h) => {
802
+ var span = (p, w, h, bodies = []) => {
767
803
  const { brushes } = w.def;
768
804
  const reach = (PLAYER_R - EPS) ** 2;
769
805
  let floor = ground(w, p.x, p.z);
@@ -775,6 +811,12 @@ var span = (p, w, h) => {
775
811
  if (b.max[1] <= p.y + .5 + SKIN) floor = Math.max(floor, b.max[1]);
776
812
  else if (b.min[1] >= p.y + h - SKIN) ceil = Math.min(ceil, b.min[1]);
777
813
  }
814
+ for (const o of bodies) {
815
+ const [dx, dz, y] = gapTo(o, p.x, p.z);
816
+ if (dx * dx + dz * dz >= (o.r + .4 - EPS) ** 2) continue;
817
+ if (y + o.h <= p.y + .5 + SKIN) floor = Math.max(floor, y + o.h);
818
+ else if (y >= p.y + h - SKIN) ceil = Math.min(ceil, y);
819
+ }
778
820
  return [floor, ceil];
779
821
  };
780
822
  /**
@@ -981,13 +1023,20 @@ var steer = (p, wish, top) => {
981
1023
  * Moves the cylinder by its speed for one step: sideways (sliding along the boxes, which takes the
982
1024
  * speed into them away), then up or down by g times the world's gravity (a ceiling stops a rise, a floor a
983
1025
  * fall). Returns the speed it came down on a floor at, or -1 when it is not on one. With `snap`
984
- * a drop of at most STEP_H stays on the ground (a stair going down is not a fall).
1026
+ * a drop of at most STEP_H stays on the ground (a stair going down is not a fall). The bodies
1027
+ * are walls and floors like the boxes; a brush wins over a body that shoves him into it.
985
1028
  */
986
- var fly$1 = (p, w, h, g, snap) => {
1029
+ var fly$1 = (p, w, h, g, snap, bodies) => {
987
1030
  const y0 = p.y;
988
1031
  p.x += p.vx * DT$1;
989
1032
  p.z += p.vz * DT$1;
990
- const [cx, cz] = push(p, w, h);
1033
+ let [cx, cz] = push(p, w, h);
1034
+ const [jx, jz] = jostle(p, bodies, h);
1035
+ if (jx || jz) {
1036
+ const [ex, ez] = push(p, w, h);
1037
+ cx += jx + ex;
1038
+ cz += jz + ez;
1039
+ }
991
1040
  const d = len$1(cx, cz);
992
1041
  if (d) {
993
1042
  const into = (p.vx * cx + p.vz * cz) / d;
@@ -997,7 +1046,7 @@ var fly$1 = (p, w, h, g, snap) => {
997
1046
  }
998
1047
  }
999
1048
  bound(p, w);
1000
- const [floor, ceil] = span(p, w, h);
1049
+ const [floor, ceil] = span(p, w, h, bodies);
1001
1050
  const vy = p.vy - g * gravity(w) * DT$1;
1002
1051
  p.y += (p.vy + vy) / 2 * DT$1;
1003
1052
  p.vy = vy;
@@ -1169,7 +1218,7 @@ var free = (p, w, c) => {
1169
1218
  if (p.mode === MODE.AIR) air(p, w, c, burst);
1170
1219
  const g = burst && p.vy <= 0 ? 0 : p.mode === MODE.WALLRUN ? WALLRUN_GRAVITY : 1;
1171
1220
  const was = p.mode;
1172
- const hit = fly$1(p, w, heightOf(p), g, onFloor(was));
1221
+ const hit = fly$1(p, w, heightOf(p), g, onFloor(was), c.bodies);
1173
1222
  if (hit >= 0) {
1174
1223
  if (!onFloor(p.mode)) {
1175
1224
  p.ev |= EV.LAND | (p.mode === MODE.WALLRUN ? EV.WALLRUN_END : 0);
@@ -1251,9 +1300,10 @@ var air = (p, w, c, burst) => {
1251
1300
  /**
1252
1301
  * Applies one input for 1 / TICK_HZ s, in place: yaw and pitch from the input (pitch clamped to
1253
1302
  * MAX_PITCH), then the step of the current mode (see the top of the file). Feet under the world's
1254
- * kill floor put the player back at a spawn of his `team` (EV.RESPAWN).
1303
+ * kill floor put the player back at a spawn of his `team` (EV.RESPAWN). `bodies` are the rovers'
1304
+ * (hull(), rover.ts) as they stand when the step runs: walls and floors for this step alone.
1255
1305
  */
1256
- var move = (p, i, w, team = 0) => {
1306
+ var move = (p, i, w, team = 0, bodies = []) => {
1257
1307
  p.yaw = norm(i.yaw);
1258
1308
  p.pitch = Math.max(-MAX_PITCH, Math.min(MAX_PITCH, i.pitch));
1259
1309
  const f = (i.keys & KEY.FORWARD ? 1 : 0) - (i.keys & KEY.BACK ? 1 : 0);
@@ -1272,7 +1322,8 @@ var move = (p, i, w, team = 0) => {
1272
1322
  wx: (fx * f - fz * s) / n,
1273
1323
  wz: (fz * f + fx * s) / n,
1274
1324
  fx,
1275
- fz
1325
+ fz,
1326
+ bodies
1276
1327
  };
1277
1328
  const before = p.mode;
1278
1329
  p.ev = 0;
@@ -1415,7 +1466,7 @@ var limbOf = (p, f) => {
1415
1466
  };
1416
1467
  // src/shared/ctf.ts
1417
1468
  var home = () => ({
1418
- state: FLAG.HOME,
1469
+ state: FLAG$1.HOME,
1419
1470
  by: 0,
1420
1471
  x: 0,
1421
1472
  y: 0,
@@ -1538,7 +1589,7 @@ var Ctf = class {
1538
1589
  }
1539
1590
  /** The team whose flag the player carries, or -1. */
1540
1591
  carrying(id) {
1541
- return this.flags.findIndex((f) => f.state === FLAG.CARRIED && f.by === id);
1592
+ return this.flags.findIndex((f) => f.state === FLAG$1.CARRIED && f.by === id);
1542
1593
  }
1543
1594
  /** The winning team of a match that is over, or -1 for a draw. */
1544
1595
  winner() {
@@ -1590,21 +1641,21 @@ var Ctf = class {
1590
1641
  const f = this.flags[k];
1591
1642
  this.lock[k].left--;
1592
1643
  this.hold[k]--;
1593
- if (f.state === FLAG.DROPPED) {
1644
+ if (f.state === FLAG$1.DROPPED) {
1594
1645
  f.left = Math.ceil(--this.back[k] / 60);
1595
1646
  if (this.back[k] <= 0) this.flags[k] = home();
1596
1647
  }
1597
1648
  }
1598
1649
  for (const k of [0, 1]) {
1599
1650
  const f = this.flags[k];
1600
- if (f.state === FLAG.CARRIED) continue;
1601
- const at = f.state === FLAG.HOME ? this.world.def.teams[k].base : [
1651
+ if (f.state === FLAG$1.CARRIED) continue;
1652
+ const at = f.state === FLAG$1.HOME ? this.world.def.teams[k].base : [
1602
1653
  f.x,
1603
1654
  f.y,
1604
1655
  f.z
1605
1656
  ];
1606
1657
  const near = players.filter((q) => touches(q.state, at));
1607
- const mate = f.state === FLAG.DROPPED && this.hold[k] <= 0 ? near.find((q) => q.team === k) : void 0;
1658
+ const mate = f.state === FLAG$1.DROPPED && this.hold[k] <= 0 ? near.find((q) => q.team === k) : void 0;
1608
1659
  const foe = near.find((q) => q.team !== k && (q.id !== this.lock[k].id || this.lock[k].left <= 0));
1609
1660
  if (mate) {
1610
1661
  const m = this.mates.get(mate.id);
@@ -1612,13 +1663,13 @@ var Ctf = class {
1612
1663
  this.flags[k] = home();
1613
1664
  } else if (foe) this.flags[k] = {
1614
1665
  ...home(),
1615
- state: FLAG.CARRIED,
1666
+ state: FLAG$1.CARRIED,
1616
1667
  by: foe.id
1617
1668
  };
1618
1669
  }
1619
1670
  for (const p of players) {
1620
1671
  const k = this.carrying(p.id);
1621
- if (k >= 0 && this.flags[p.team].state === FLAG.HOME && touches(p.state, this.world.def.teams[p.team].base)) {
1672
+ if (k >= 0 && this.flags[p.team].state === FLAG$1.HOME && touches(p.state, this.world.def.teams[p.team].base)) {
1622
1673
  this.score[p.team]++;
1623
1674
  const m = this.mates.get(p.id);
1624
1675
  if (m) m.caps++;
@@ -1633,7 +1684,7 @@ var Ctf = class {
1633
1684
  }
1634
1685
  dropAt(k, [x, y, z]) {
1635
1686
  this.flags[k] = {
1636
- state: FLAG.DROPPED,
1687
+ state: FLAG$1.DROPPED,
1637
1688
  by: 0,
1638
1689
  x,
1639
1690
  y,
@@ -1702,15 +1753,15 @@ var STRIKE = {
1702
1753
  * With SPECIAL (a double click) the swing is the cut's special; its press within SPECIAL_LATE
1703
1754
  * ticks of a cut's start turns that cut into it. The cut strikes `CUTS[cut].strike` ticks into
1704
1755
  * its swing. The look is the input's, so both go where the player sees.
1705
- * `armed` is false while the match is over: no weapon, no rack.
1756
+ * `armed` is false while the match is over: no weapon, no rack. `bodies` are move()'s.
1706
1757
  */
1707
- var step = (p, i, w, team, armed = true) => {
1758
+ var step = (p, i, w, team, armed = true, bodies = []) => {
1708
1759
  const down = p.down > 0;
1709
1760
  const locked = !down && (p.lock ?? 0) > 0;
1710
1761
  move(p, down || locked ? {
1711
1762
  ...i,
1712
1763
  keys: 0
1713
- } : i, w, team);
1764
+ } : i, w, team, bodies);
1714
1765
  p.heat = Math.max(0, (p.heat ?? 0) - (p.zapping ? 0 : p.hot ? 1 : 2));
1715
1766
  p.hot = !!p.hot && p.heat > 0;
1716
1767
  p.zapping = false;
@@ -2945,7 +2996,7 @@ var stairs = (axis, a, b, w0, w1, y, top) => {
2945
2996
  * What stands in the hall, about the dome's centre: ghosts, since client/moonbase.ts draws them
2946
2997
  * with the hall (the sun's shadow map is 64 m wide, a brush across the hall would be drawn sunlit).
2947
2998
  * The mezzanine 3.5 m up along the walls (not over the door), the stairs up to it facing the door,
2948
- * a console and two parapets on it, three crates on the floor.
2999
+ * a console and two parapets on it, three crates on the floor clear of the flag's dais (moon.ts).
2949
3000
  */
2950
3001
  var FIT = [
2951
3002
  ...turns([[
@@ -2982,24 +3033,143 @@ var FIT = [
2982
3033
  12.5
2983
3034
  ], 3.5, 4.6, STEEL$1, PAINT$1),
2984
3035
  ghost([
2985
- -6,
2986
- -8,
2987
- -4,
2988
- -6
3036
+ -9.5,
3037
+ -10,
3038
+ -7.5,
3039
+ -8
2989
3040
  ], 0, 1.4, STEEL$1),
2990
3041
  ghost([
2991
- 4,
2992
- -8,
2993
- 6,
2994
- -6
3042
+ 7.5,
3043
+ -10,
3044
+ 9.5,
3045
+ -8
2995
3046
  ], 0, 1.4, STEEL$1),
2996
3047
  ghost([
2997
- 5.5,
2998
- 1.5,
2999
- 8,
3000
- 4
3048
+ 7.5,
3049
+ 3,
3050
+ 10,
3051
+ 5.5
3001
3052
  ], 0, 2.4, STEEL$1)
3002
3053
  ];
3054
+ var { BENCH, SAMPLES, RACKS, SCOPE, ANALYSER, PLANTS, LOCKERS, SUIT } = {
3055
+ BENCH: 0,
3056
+ SAMPLES: 1,
3057
+ RACKS: 2,
3058
+ SCOPE: 3,
3059
+ ANALYSER: 4,
3060
+ PLANTS: 5,
3061
+ LOCKERS: 6,
3062
+ SUIT: 7
3063
+ };
3064
+ /**
3065
+ * The lab kit in red's half: kind, x0, z0, x1, z1, y0, y1, and the way its front looks (0 +x, 1
3066
+ * +z, 2 -x, 3 -z). Its box is a ghost, drawn by client/moonbase.ts as the hall's fittings are.
3067
+ * Each stands flush on a wall or more than a body away from it (no crack to stick in), what stands
3068
+ * under the mezzanine leaves a body room on top or reaches up to it, and none stands by the middle
3069
+ * of a module's wall: vision.ts would band its top as a ledge.
3070
+ */
3071
+ var KIT = [
3072
+ [
3073
+ BENCH,
3074
+ 60.2,
3075
+ 230.5,
3076
+ 61.2,
3077
+ 241.5,
3078
+ 0,
3079
+ .95,
3080
+ 0
3081
+ ],
3082
+ [
3083
+ SAMPLES,
3084
+ 65,
3085
+ 233.5,
3086
+ 66.5,
3087
+ 238.5,
3088
+ 0,
3089
+ .9,
3090
+ 0
3091
+ ],
3092
+ [
3093
+ RACKS,
3094
+ 98.8,
3095
+ 229.3,
3096
+ 99.8,
3097
+ 234.3,
3098
+ 0,
3099
+ 3.1,
3100
+ 2
3101
+ ],
3102
+ [
3103
+ RACKS,
3104
+ 98.8,
3105
+ 237.7,
3106
+ 99.8,
3107
+ 242.7,
3108
+ 0,
3109
+ 3.1,
3110
+ 2
3111
+ ],
3112
+ [
3113
+ SCOPE,
3114
+ 68.9,
3115
+ 250.8,
3116
+ 70.1,
3117
+ 252,
3118
+ 3.5,
3119
+ 4.5,
3120
+ 3
3121
+ ],
3122
+ [
3123
+ ANALYSER,
3124
+ 89.4,
3125
+ 250.8,
3126
+ 91.4,
3127
+ 252,
3128
+ 3.5,
3129
+ 4.8,
3130
+ 3
3131
+ ],
3132
+ [
3133
+ PLANTS,
3134
+ 115,
3135
+ 222.4,
3136
+ 121,
3137
+ 223.2,
3138
+ 0,
3139
+ 2,
3140
+ 1
3141
+ ],
3142
+ [
3143
+ PLANTS,
3144
+ 123.8,
3145
+ 226.4,
3146
+ 124.6,
3147
+ 229.6,
3148
+ 0,
3149
+ 2,
3150
+ 2
3151
+ ],
3152
+ [
3153
+ LOCKERS,
3154
+ 96.4,
3155
+ 200.4,
3156
+ 97,
3157
+ 203.6,
3158
+ 0,
3159
+ 2.1,
3160
+ 0
3161
+ ],
3162
+ [
3163
+ SUIT,
3164
+ 108.6,
3165
+ 197.4,
3166
+ 109.6,
3167
+ 198.4,
3168
+ 0,
3169
+ 2,
3170
+ 2
3171
+ ]
3172
+ ];
3003
3173
  /**
3004
3174
  * A wall along the axis k from a to b, between p and q across, up to y: a doorway H high in each
3005
3175
  * gap (from, to). A gap of no width only cuts the wall in two: vision.ts stripes a wall of 8 m.
@@ -3077,6 +3247,10 @@ var BASE = [
3077
3247
  ]
3078
3248
  ].map((p) => ghost(p, 0, BANDS[1])),
3079
3249
  ...FIT,
3250
+ ...KIT.map(([, x0, z0, x1, z1, y0, y1]) => ({
3251
+ ...box(x0, y0, z0, x1, y1, z1, STEEL$1),
3252
+ ghost: true
3253
+ })),
3080
3254
  ...room(MODULES[0], [
3081
3255
  [[118, 118]],
3082
3256
  [[116.8, 119.2]],
@@ -3111,6 +3285,8 @@ var MASTS = [
3111
3285
  [106.2, 230.4],
3112
3286
  [103.2, 212.4]
3113
3287
  ];
3288
+ /** Red's flag: in the hall, 2 m from the dome's centre toward the door. */
3289
+ var FLAG = DOME[1] - 2;
3114
3290
  var c1 = (t) => Math.min(Math.max(t, 0), 1);
3115
3291
  var sm = (t) => c1(t) * c1(t) * (3 - 2 * c1(t));
3116
3292
  var far = (a, b) => Math.sqrt(a * a + b * b);
@@ -3390,8 +3566,14 @@ var both = (l, ...mid) => [
3390
3566
  var half = [
3391
3567
  box(0, -30, 148, 160, 0, 280, STONE),
3392
3568
  ...BASE,
3393
- box(74, 0, 199, 86, .5, 211, PAINT, CONCRETE, RED),
3394
- box(76, .5, 201, 84, 1, 209, PAINT, CONCRETE, RED),
3569
+ {
3570
+ ...box(75.25, 0, FLAG - 4.75, 84.75, .5, FLAG + 4.75, PAINT, CONCRETE, RED),
3571
+ ghost: true
3572
+ },
3573
+ {
3574
+ ...box(75.75, .5, FLAG - 4.25, 84.25, 1, FLAG + 4.25, PAINT, CONCRETE, RED),
3575
+ ghost: true
3576
+ },
3395
3577
  box(60, 0, 259, 70, 1.5, 265, STEEL, PAINT, RED),
3396
3578
  box(27, 0, 207, 53, .25, 233, METAL),
3397
3579
  {
@@ -3490,7 +3672,7 @@ var team = (z, s) => ({
3490
3672
  z
3491
3673
  ],
3492
3674
  spawns: s,
3493
- ...racks(z + (z > 140 ? 57 : -57))
3675
+ ...racks(z + (z > 140 ? 28 : -28))
3494
3676
  });
3495
3677
  // src/shared/maps.ts
3496
3678
  var MAPS = {
@@ -3502,7 +3684,7 @@ var MAPS = {
3502
3684
  ...half.map(flip),
3503
3685
  ...centre
3504
3686
  ],
3505
- teams: [team(205, SPAWNS), team(75, SPAWNS.map(([x, y, z]) => [
3687
+ teams: [team(FLAG, SPAWNS), team(280 - FLAG, SPAWNS.map(([x, y, z]) => [
3506
3688
  x,
3507
3689
  y,
3508
3690
  280 - z,
@@ -3797,7 +3979,7 @@ var decodeInput = (buf) => {
3797
3979
  };
3798
3980
  };
3799
3981
  /** Bytes of a flag on the wire, by its state. */
3800
- var flagBytes = (state) => state === FLAG.CARRIED ? 2 : state === FLAG.DROPPED ? 8 : 1;
3982
+ var flagBytes = (state) => state === FLAG$1.CARRIED ? 2 : state === FLAG$1.DROPPED ? 8 : 1;
3801
3983
  var encodeSnapshot = (s) => {
3802
3984
  const rovers = (s.rovers ?? []).slice(0, 7);
3803
3985
  const mid = 4 + 61 * s.players.length;
@@ -3863,8 +4045,8 @@ var encodeSnapshot = (s) => {
3863
4045
  let o = end + 10;
3864
4046
  for (const f of s.flags) {
3865
4047
  v.setUint8(o, f.state);
3866
- if (f.state === FLAG.CARRIED) v.setUint8(o + 1, f.by);
3867
- else if (f.state === FLAG.DROPPED) {
4048
+ if (f.state === FLAG$1.CARRIED) v.setUint8(o + 1, f.by);
4049
+ else if (f.state === FLAG$1.DROPPED) {
3868
4050
  v.setInt16(o + 1, clamp16(f.x * POS));
3869
4051
  v.setInt16(o + 3, clamp16(f.y * POS));
3870
4052
  v.setInt16(o + 5, clamp16(f.z * POS));
@@ -3983,6 +4165,8 @@ var ROVER = {
3983
4165
  ],
3984
4166
  BODY_H: 1.5,
3985
4167
  WHEEL_STEP: .6,
4168
+ /** The share of its speed into another rover a rover bounces back with. */
4169
+ BOUNCE: .3,
3986
4170
  /** A player this close to a rover's centre gets in; a rover this fast hurts an enemy, and this fast puts him down. */
3987
4171
  ENTER_R: 3,
3988
4172
  SPLAT_MIN: 6,
@@ -4068,6 +4252,19 @@ var corners = (r, w) => AI.map((a, k) => {
4068
4252
  * the nose, front first, each at the height of its bottom, BODY_H under its top.
4069
4253
  */
4070
4254
  var footprint = (r) => ROVER.BODY.map((a) => at(r, a, 0, -DROP));
4255
+ /**
4256
+ * The body as the players on foot and the other rovers meet it: the stadium round the front and
4257
+ * rear circles of footprint(), RB wide and BODY_H tall. A player walks into it and stands on it.
4258
+ */
4259
+ var hull = (r) => {
4260
+ const [a, , b] = footprint(r);
4261
+ return {
4262
+ a,
4263
+ b,
4264
+ r: ROVER.RB,
4265
+ h: ROVER.BODY_H
4266
+ };
4267
+ };
4071
4268
  /** The map's rovers at rest on their spawns, nobody aboard. */
4072
4269
  var park = (w) => (w.def.rovers ?? []).map(([x, y, z, yaw]) => ({
4073
4270
  x: f32(x),
@@ -4089,7 +4286,8 @@ var park = (w) => (w.def.rovers ?? []).map(([x, y, z, yaw]) => ({
4089
4286
  /**
4090
4287
  * One step of 1 / TICK_HZ s, in place. `i` is the driver's input as the wire rounds it (FORWARD and
4091
4288
  * BACK the throttle, JUMP the handbrake, its yaw where the nose is steered to), or undefined with
4092
- * nobody at the wheel: the brake is on. Reads only the rover, the input and the world. Returns
4289
+ * nobody at the wheel: the brake is on. Reads only the rover, the input, the world and the
4290
+ * `fleet` (the map's rovers, itself skipped: walls it stops on, BOUNCE back, never pushed). Returns
4093
4291
  * whether it fell under the world's kill floor: the caller parks it again.
4094
4292
  *
4095
4293
  * The body is a point with a pitch and a roll on four springs. Each wheel reads the floor under
@@ -4098,7 +4296,7 @@ var park = (w) => (w.def.rovers ?? []).map(([x, y, z, yaw]) => ({
4098
4296
  * turns toward the look as fast as the speed allows, and the tyres' grip decides how much of the
4099
4297
  * speed follows it. The rest drifts.
4100
4298
  */
4101
- var drive = (r, i, w) => {
4299
+ var drive = (r, i, w, fleet = []) => {
4102
4300
  const { A, B, CMAX, K, D, KP2, KR2, HC, MU, MUL, TILT } = ROVER;
4103
4301
  const g = gravity(w);
4104
4302
  const keys = i ? i.keys : 0;
@@ -4192,6 +4390,24 @@ var drive = (r, i, w) => {
4192
4390
  r.vz -= v * pz;
4193
4391
  }
4194
4392
  }
4393
+ for (const o of fleet) {
4394
+ if (o === r) continue;
4395
+ const h = hull(o);
4396
+ for (const a of ROVER.BODY) {
4397
+ const [x, y, z] = at(r, a, 0, -DROP);
4398
+ const [dx, dz, oy] = gapTo(h, x, z);
4399
+ const reach = 2 * ROVER.RB;
4400
+ const d = sqrt(dx * dx + dz * dz);
4401
+ if (d >= reach - 1e-4 || oy >= y + ROVER.BODY_H || oy + ROVER.BODY_H <= y) continue;
4402
+ const [ox, oz] = forward(o.yaw);
4403
+ const [nx, nz] = d ? [dx / d, dz / d] : [-oz, ox];
4404
+ r.x += nx * (reach - d);
4405
+ r.z += nz * (reach - d);
4406
+ const v = min(0, r.vx * nx + r.vz * nz) * (1 + ROVER.BOUNCE);
4407
+ r.vx -= v * nx;
4408
+ r.vz -= v * nz;
4409
+ }
4410
+ }
4195
4411
  bound(r, w);
4196
4412
  for (const k of FLOATS) r[k] = f32(r[k]);
4197
4413
  return r.y < w.def.floor;
@@ -4268,10 +4484,11 @@ var leave = (p, r, s, w) => {
4268
4484
  * The driver's whole step, on the host and in the predictor alike: the rover is driven by his
4269
4485
  * input, he follows on his seat, and a press of USE gets him out. Returns drive()'s answer. A step
4270
4486
  * that takes him off his seat (move() puts a body under the kill floor back at a spawn) frees it.
4487
+ * `fleet` is drive()'s.
4271
4488
  */
4272
- var ride = (p, r, i, w, team) => {
4489
+ var ride = (p, r, i, w, team, fleet = []) => {
4273
4490
  const out = (i.keys & KEY.USE) !== 0 && (p.held & KEY.USE) === 0;
4274
- const fell = drive(r, i, w);
4491
+ const fell = drive(r, i, w, fleet);
4275
4492
  step(p, i, w, team, false);
4276
4493
  if (p.mode !== MODE.RIDE) r.driver = 255;
4277
4494
  else {
@@ -4378,6 +4595,8 @@ var setEvery = (cb, ms) => {
4378
4595
  * next join once the room is empty. The roster tells everyone the host and the map picked.
4379
4596
  * - The map's rovers (rover.ts) are in every snapshot. A press of USE near one seats a player; a
4380
4597
  * driven rover is stepped by its driver's inputs alone (ride()), a driverless one by the tick.
4598
+ * A player on foot walks into the rovers as they stand when his input arrives (hull()); a rover
4599
+ * stops on the others as they stand when it steps.
4381
4600
  * seats() keeps the seats and the players' MODE.RIDE in step.
4382
4601
  */
4383
4602
  /** A player out of any saber lock. */
@@ -4491,7 +4710,7 @@ var Room = class {
4491
4710
  const use = (input.keys & KEY.USE) !== 0 && (p.state.held & KEY.USE) === 0;
4492
4711
  const [r, s] = this.seatOf(p);
4493
4712
  if (r && !s) {
4494
- const fell = ride(p.state, r, input, this.world, p.info.team);
4713
+ const fell = ride(p.state, r, input, this.world, p.info.team, this.rovers);
4495
4714
  this.ctf.moved(p.state);
4496
4715
  if (fell) this.sink(r);
4497
4716
  else {
@@ -4500,7 +4719,7 @@ var Room = class {
4500
4719
  this.lase(p, r, input);
4501
4720
  }
4502
4721
  } else {
4503
- const struck = step(p.state, input, this.world, p.info.team, !this.ctf.over);
4722
+ const struck = step(p.state, input, this.world, p.info.team, !this.ctf.over, this.rovers.map(hull));
4504
4723
  this.ctf.moved(p.state);
4505
4724
  this.tackle(p, input.view);
4506
4725
  const here = spot(p.state);
@@ -4568,7 +4787,7 @@ var Room = class {
4568
4787
  }
4569
4788
  this.seats();
4570
4789
  for (const r of this.rovers) if (r.driver !== 255) this.carry(r);
4571
- else if (drive(r, void 0, this.world)) this.sink(r);
4790
+ else if (drive(r, void 0, this.world, this.rovers)) this.sink(r);
4572
4791
  else this.carry(r);
4573
4792
  this.seats();
4574
4793
  if (now % 2 === 0) {
@@ -1,4 +1,4 @@
1
- import type { Brush } from '../shared/world';
1
+ import type { Brush, WorldDef } from '../shared/world';
2
2
  import type { Vec3 } from './mesh';
3
3
  /** A model whose length runs up (y): the frame place() takes. */
4
4
  export declare const UP: Vec3[];
@@ -22,3 +22,9 @@ export declare const LINTELS: Brush[];
22
22
  export declare const INDOORS: number[];
23
23
  /** Red's half of the base: the dome, its hall, the tubes and the modules, a metal floor in the last two, a lit frame in each of their doorways. */
24
24
  export declare const moonbase: (o: number[]) => void;
25
+ /**
26
+ * The base's furnishing, both halves, which render.ts draws beside the scenery: the flags' daises
27
+ * (the ghosts with a team tint, shared/moon.ts) as the hall's fittings but in their tint, `keys`
28
+ * being the renderer's palette, then the dressing of red's half and its mirror for blue.
29
+ */
30
+ export declare const furnishing: ({ brushes }: WorldDef, keys: string[]) => number[];
@@ -1,3 +1,4 @@
1
+ import type { Body } from './physics';
1
2
  import type { Input, PlayerState } from './types';
2
3
  import type { World } from './world';
3
4
  type Vec3 = [number, number, number];
@@ -38,9 +39,9 @@ export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
38
39
  * With SPECIAL (a double click) the swing is the cut's special; its press within SPECIAL_LATE
39
40
  * ticks of a cut's start turns that cut into it. The cut strikes `CUTS[cut].strike` ticks into
40
41
  * its swing. The look is the input's, so both go where the player sees.
41
- * `armed` is false while the match is over: no weapon, no rack.
42
+ * `armed` is false while the match is over: no weapon, no rack. `bodies` are move()'s.
42
43
  */
43
- export declare const step: (p: PlayerState, i: Input, w: World, team: number, armed?: boolean) => Strike;
44
+ export declare const step: (p: PlayerState, i: Input, w: World, team: number, armed?: boolean, bodies?: readonly Body[]) => Strike;
44
45
  /** The strength a charge of `ticks` gives, 1 to CHARGE_MAX: 1 under CHARGE_TAP, CHARGE_MAX at CHARGE_TICKS. */
45
46
  export declare const powerOf: (ticks: number) => number;
46
47
  export {};
@@ -38,8 +38,27 @@ export declare const MOUTHS: number[][];
38
38
  * What stands in the hall, about the dome's centre: ghosts, since client/moonbase.ts draws them
39
39
  * with the hall (the sun's shadow map is 64 m wide, a brush across the hall would be drawn sunlit).
40
40
  * The mezzanine 3.5 m up along the walls (not over the door), the stairs up to it facing the door,
41
- * a console and two parapets on it, three crates on the floor.
41
+ * a console and two parapets on it, three crates on the floor clear of the flag's dais (moon.ts).
42
42
  */
43
43
  export declare const FIT: Brush[];
44
+ /** The kinds of lab kit client/moonbase.ts draws. */
45
+ export declare const KIND: {
46
+ BENCH: number;
47
+ SAMPLES: number;
48
+ RACKS: number;
49
+ SCOPE: number;
50
+ ANALYSER: number;
51
+ PLANTS: number;
52
+ LOCKERS: number;
53
+ SUIT: number;
54
+ };
55
+ /**
56
+ * The lab kit in red's half: kind, x0, z0, x1, z1, y0, y1, and the way its front looks (0 +x, 1
57
+ * +z, 2 -x, 3 -z). Its box is a ghost, drawn by client/moonbase.ts as the hall's fittings are.
58
+ * Each stands flush on a wall or more than a body away from it (no crack to stick in), what stands
59
+ * under the mezzanine leaves a body room on top or reaches up to it, and none stands by the middle
60
+ * of a module's wall: vision.ts would band its top as a ledge.
61
+ */
62
+ export declare const KIT: number[][];
44
63
  /** Red's half of the base. */
45
64
  export declare const BASE: Brush[];
@@ -68,6 +68,19 @@ export declare const speedOf: (p: Pick<PlayerState, "vx" | "vz">) => number;
68
68
  export declare const sprinting: (p: Pick<PlayerState, "mode" | "vx" | "vz">) => boolean;
69
69
  /** push() for a circle of radius r: a rover's body is a few of them. */
70
70
  export declare const shove: (p: Pos, w: World, h: number, r: number) => [x: number, z: number];
71
+ /**
72
+ * A solid that moves, which the players walk into and stand on: a rover's body (hull(), rover.ts).
73
+ * The stadium of radius r round the segment a to b on the floor plane, from the height of the
74
+ * segment (between those of a and b) up h.
75
+ */
76
+ export interface Body {
77
+ a: [x: number, y: number, z: number];
78
+ b: [x: number, y: number, z: number];
79
+ r: number;
80
+ h: number;
81
+ }
82
+ /** The offset from the closest point of a body's axis to (x, z), and the height of its bottom there. */
83
+ export declare const gapTo: (o: Body, x: number, z: number) => [dx: number, dz: number, y: number];
71
84
  /**
72
85
  * The highest floor under the point (x, z) at most as high as y: the ground of the relief, or the
73
86
  * top of a brush the point is over. For a rover's wheel.
@@ -87,7 +100,8 @@ export declare const stumble: (p: PlayerState, dx: number, dz: number, ticks?: n
87
100
  /**
88
101
  * Applies one input for 1 / TICK_HZ s, in place: yaw and pitch from the input (pitch clamped to
89
102
  * MAX_PITCH), then the step of the current mode (see the top of the file). Feet under the world's
90
- * kill floor put the player back at a spawn of his `team` (EV.RESPAWN).
103
+ * kill floor put the player back at a spawn of his `team` (EV.RESPAWN). `bodies` are the rovers'
104
+ * (hull(), rover.ts) as they stand when the step runs: walls and floors for this step alone.
91
105
  */
92
- export declare const move: (p: PlayerState, i: Input, w: World, team?: number) => void;
106
+ export declare const move: (p: PlayerState, i: Input, w: World, team?: number, bodies?: readonly Body[]) => void;
93
107
  export {};