@korial29/tiny-fps 0.129.0 → 0.130.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/index.js +15 -15
- package/dist/local.js +1 -1
- package/dist/server.js +306 -46
- package/dist/types/client/craft.d.ts +3 -2
- package/dist/types/client/foley.d.ts +5 -0
- package/dist/types/client/sfx.d.ts +6 -0
- package/dist/types/shared/room.d.ts +11 -0
- package/dist/types/shared/rover.d.ts +25 -6
- package/dist/types/shared/ship.d.ts +21 -2
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -648,7 +648,7 @@ var SKIN = .01;
|
|
|
648
648
|
* A circle this close to a box (1 mm) is touching it: a push leaves it exactly PLAYER_R away, and
|
|
649
649
|
* the float32 position it is rounded to is a few micrometres off.
|
|
650
650
|
*/
|
|
651
|
-
var TOUCH = .001;
|
|
651
|
+
var TOUCH$1 = .001;
|
|
652
652
|
/** An angle in [0, 2π). */
|
|
653
653
|
var norm = (a) => (a % TAU + TAU) % TAU;
|
|
654
654
|
/** Unit vector the player faces at yaw, on the floor plane: yaw 0 looks toward -z. */
|
|
@@ -948,7 +948,7 @@ var along = (p, side) => {
|
|
|
948
948
|
var faceDist = (b, p, side, reach) => {
|
|
949
949
|
const { a, o, sign, c, co } = along(p, side);
|
|
950
950
|
const dist = ((sign > 0 ? b.min[a] : b.max[a]) - c) * sign;
|
|
951
|
-
return dist >= .4 - TOUCH && dist <= .4 + reach && co >= b.min[o] && co <= b.max[o] ? dist : void 0;
|
|
951
|
+
return dist >= .4 - TOUCH$1 && dist <= .4 + reach && co >= b.min[o] && co <= b.max[o] ? dist : void 0;
|
|
952
952
|
};
|
|
953
953
|
/**
|
|
954
954
|
* The gap between the cylinder and a wall on `side` that covers the body from the knees to the
|
|
@@ -1055,11 +1055,11 @@ var cap = (p, max) => {
|
|
|
1055
1055
|
*/
|
|
1056
1056
|
var unwalled = (p, w, c, h) => {
|
|
1057
1057
|
let [x, z] = [c.wx, c.wz];
|
|
1058
|
-
for (const i of near(w, p.x, p.z, PLAYER_R + TOUCH)) {
|
|
1058
|
+
for (const i of near(w, p.x, p.z, PLAYER_R + TOUCH$1)) {
|
|
1059
1059
|
const b = w.def.brushes[i];
|
|
1060
1060
|
const [dx, dz] = gap(b, p.x, p.z);
|
|
1061
1061
|
const d = len$1(dx, dz);
|
|
1062
|
-
if (d > 0 && d <= .4 + TOUCH && blocks(b, p.y, h)) {
|
|
1062
|
+
if (d > 0 && d <= .4 + TOUCH$1 && blocks(b, p.y, h)) {
|
|
1063
1063
|
const into = (-x * dx - z * dz) / d;
|
|
1064
1064
|
if (into > 0) {
|
|
1065
1065
|
x += into * dx / d;
|
|
@@ -3406,7 +3406,7 @@ var { STONE, CONCRETE, METAL, STEEL, PAINT } = TEX;
|
|
|
3406
3406
|
/** The twin of a box across the centre line. */
|
|
3407
3407
|
var mirror = ({ min, max }) => bx(min[0], min[1], 280 - max[2], max[0], max[1], 280 - min[2]);
|
|
3408
3408
|
/** The domes' centres, the landing pads (x, z, radius), the modules, the tubes and the masts (centres), red's then blue's: what the scenery draws on. */
|
|
3409
|
-
var PAD = [
|
|
3409
|
+
var PAD$1 = [
|
|
3410
3410
|
40,
|
|
3411
3411
|
220,
|
|
3412
3412
|
13
|
|
@@ -4348,10 +4348,10 @@ var LAYOUT = {
|
|
|
4348
4348
|
sites: SITES,
|
|
4349
4349
|
pillars: PILLARS,
|
|
4350
4350
|
domes: [DOME, [DOME[0], 280 - DOME[1]]],
|
|
4351
|
-
pads: [PAD, [
|
|
4352
|
-
PAD[0],
|
|
4353
|
-
280 - PAD[1],
|
|
4354
|
-
PAD[2]
|
|
4351
|
+
pads: [PAD$1, [
|
|
4352
|
+
PAD$1[0],
|
|
4353
|
+
280 - PAD$1[1],
|
|
4354
|
+
PAD$1[2]
|
|
4355
4355
|
]],
|
|
4356
4356
|
modules: [...MODULES, ...MODULES.map(mirror)],
|
|
4357
4357
|
tubes: [...TUBES, ...TUBES.map(mirror)],
|
|
@@ -4667,14 +4667,14 @@ var MAPS = {
|
|
|
4667
4667
|
]
|
|
4668
4668
|
],
|
|
4669
4669
|
ships: [[
|
|
4670
|
-
PAD[0],
|
|
4670
|
+
PAD$1[0],
|
|
4671
4671
|
.25,
|
|
4672
|
-
PAD[1],
|
|
4672
|
+
PAD$1[1],
|
|
4673
4673
|
0
|
|
4674
4674
|
], [
|
|
4675
|
-
PAD[0],
|
|
4675
|
+
PAD$1[0],
|
|
4676
4676
|
.25,
|
|
4677
|
-
280 - PAD[1],
|
|
4677
|
+
280 - PAD$1[1],
|
|
4678
4678
|
Math.PI
|
|
4679
4679
|
]],
|
|
4680
4680
|
doors: [...DOORS, ...DOORS.map(mirror)],
|
|
@@ -5109,7 +5109,15 @@ var SHIP = {
|
|
|
5109
5109
|
MISSILES: 4,
|
|
5110
5110
|
MISSILE_COOL: 30,
|
|
5111
5111
|
RELOAD: 300,
|
|
5112
|
-
MISSILE_SPEED: 60
|
|
5112
|
+
MISSILE_SPEED: 60,
|
|
5113
|
+
/**
|
|
5114
|
+
* A crash (the user, 2026-11-12): the speed a step's collisions take away (m/s, the vertical
|
|
5115
|
+
* part halved, so a sink onto a pad is no crash) past CRASH costs 1 hp each CRASH_HP more.
|
|
5116
|
+
*/
|
|
5117
|
+
CRASH: 12,
|
|
5118
|
+
CRASH_HP: 4,
|
|
5119
|
+
/** How much of the speed into another vehicle comes back off it. */
|
|
5120
|
+
BOUNCE: .3
|
|
5113
5121
|
};
|
|
5114
5122
|
/** The lasers' muzzles under the wings, the missiles' pods under the wings: right of the centre, above it, ahead of it. */
|
|
5115
5123
|
var SHIP_GUNS = [[
|
|
@@ -5130,6 +5138,87 @@ var PODS = [[
|
|
|
5130
5138
|
-.7,
|
|
5131
5139
|
-2.9
|
|
5132
5140
|
]];
|
|
5141
|
+
/**
|
|
5142
|
+
* A wing's sections, at the hull, at the cannon and at the tip: right, the leading and the trailing
|
|
5143
|
+
* edge ahead, the top and the bottom. craft.ts draws them; the shots, the players on foot, the
|
|
5144
|
+
* other vehicles and the brushes meet them (the user, 2026-11-12: the wings went through all).
|
|
5145
|
+
*/
|
|
5146
|
+
var WING = [
|
|
5147
|
+
[
|
|
5148
|
+
.9,
|
|
5149
|
+
-2.7,
|
|
5150
|
+
-5.3,
|
|
5151
|
+
.14,
|
|
5152
|
+
-.12
|
|
5153
|
+
],
|
|
5154
|
+
[
|
|
5155
|
+
2.6,
|
|
5156
|
+
-2.6,
|
|
5157
|
+
-5.5,
|
|
5158
|
+
.12,
|
|
5159
|
+
-.1
|
|
5160
|
+
],
|
|
5161
|
+
[
|
|
5162
|
+
6.4,
|
|
5163
|
+
-4.9,
|
|
5164
|
+
-6.1,
|
|
5165
|
+
-.7,
|
|
5166
|
+
-.78
|
|
5167
|
+
]
|
|
5168
|
+
];
|
|
5169
|
+
/** The right wing's section `x` metres right of the centre, between two of WING's. */
|
|
5170
|
+
var section = (x) => {
|
|
5171
|
+
const k = x < WING[1][0] ? 0 : 1;
|
|
5172
|
+
const [a, b] = [WING[k], WING[k + 1]];
|
|
5173
|
+
const t = (x - a[0]) / (b[0] - a[0]);
|
|
5174
|
+
return a.map((v, n) => v + (b[n] - v) * t);
|
|
5175
|
+
};
|
|
5176
|
+
/**
|
|
5177
|
+
* The right wing as the shots meet it: boxes in the ship's frame along the span, each round its
|
|
5178
|
+
* slice of the wing with a margin of PAD: [right, up, ahead] each from, to.
|
|
5179
|
+
*/
|
|
5180
|
+
var PAD = .1;
|
|
5181
|
+
var WING_BOXES = [
|
|
5182
|
+
.9,
|
|
5183
|
+
2.6,
|
|
5184
|
+
3.9,
|
|
5185
|
+
5.15,
|
|
5186
|
+
6.4
|
|
5187
|
+
].slice(1).map((x1, k, xs) => {
|
|
5188
|
+
const x0 = k ? xs[k - 1] : .9;
|
|
5189
|
+
const [s0, s1] = [section(x0), section(x1)];
|
|
5190
|
+
return [
|
|
5191
|
+
[x0, x1 + PAD],
|
|
5192
|
+
[Math.min(s0[4], s1[4]) - PAD, Math.max(s0[3], s1[3]) + PAD],
|
|
5193
|
+
[Math.min(s0[2], s1[2]) - PAD, Math.max(s0[1], s1[1]) + PAD]
|
|
5194
|
+
];
|
|
5195
|
+
});
|
|
5196
|
+
/**
|
|
5197
|
+
* The right wing as the players on foot and the other vehicles meet it: stadiums from the root to
|
|
5198
|
+
* near the tip along the middle of the chord ([from, to, radius]), WING_H thick over its bottom.
|
|
5199
|
+
*/
|
|
5200
|
+
var WING_BODY = [[
|
|
5201
|
+
1.4,
|
|
5202
|
+
3.2,
|
|
5203
|
+
1.1
|
|
5204
|
+
], [
|
|
5205
|
+
3.2,
|
|
5206
|
+
5.8,
|
|
5207
|
+
.75
|
|
5208
|
+
]];
|
|
5209
|
+
var WING_H = .4;
|
|
5210
|
+
/** The wing tips against the brushes: a circle this wide, this far right of the centre. */
|
|
5211
|
+
var TIP = {
|
|
5212
|
+
X: 5.6,
|
|
5213
|
+
R: .8
|
|
5214
|
+
};
|
|
5215
|
+
/** Where the wings' undersides meet the floor: right of the centre, and the trailing edge (-1), the middle of the chord (0) or the leading edge (1). */
|
|
5216
|
+
var TOUCH = [
|
|
5217
|
+
[3.2, 0],
|
|
5218
|
+
[4.8, 0],
|
|
5219
|
+
[6.4, -1],
|
|
5220
|
+
[6.4, 1]
|
|
5221
|
+
];
|
|
5133
5222
|
/** The pilot's seat in the cockpit, behind the long nose: right of the centre, above it (the feet), ahead of it. */
|
|
5134
5223
|
var COCKPIT = [
|
|
5135
5224
|
0,
|
|
@@ -5222,6 +5311,21 @@ var shipHull = (r) => {
|
|
|
5222
5311
|
h: SHIP.H
|
|
5223
5312
|
};
|
|
5224
5313
|
};
|
|
5314
|
+
/** The wings as solids (WING_BODY), the left one then the right one. */
|
|
5315
|
+
var wings = (r) => [-1, 1].flatMap((s) => WING_BODY.map(([x0, x1, rad]) => {
|
|
5316
|
+
const [a, b] = [x0, x1].map((x) => {
|
|
5317
|
+
const [, le, te, , low] = section(x);
|
|
5318
|
+
return point(r, s * x, low - .05, (le + te) / 2);
|
|
5319
|
+
});
|
|
5320
|
+
return {
|
|
5321
|
+
a,
|
|
5322
|
+
b,
|
|
5323
|
+
r: rad,
|
|
5324
|
+
h: WING_H
|
|
5325
|
+
};
|
|
5326
|
+
}));
|
|
5327
|
+
/** Every solid of the ship: its hull, then its wings. */
|
|
5328
|
+
var shipBodies = (r) => [shipHull(r), ...wings(r)];
|
|
5225
5329
|
/**
|
|
5226
5330
|
* The ship against the crater's edge: its distance from the bound's centre and the edge's along the
|
|
5227
5331
|
* same line, and the unit way out on the floor plane. Undefined on a map without a relief.
|
|
@@ -5265,7 +5369,7 @@ var roof = (w, x, z, y0, y1) => {
|
|
|
5265
5369
|
* the engines hold it against gravity: it hovers with no key held. On a floor it rests on its
|
|
5266
5370
|
* skids, level.
|
|
5267
5371
|
*/
|
|
5268
|
-
var pilot = (r, i, w) => {
|
|
5372
|
+
var pilot = (r, i, w, others = [], crash) => {
|
|
5269
5373
|
const keys = i ? i.keys : 0;
|
|
5270
5374
|
const on = (k) => keys & k ? 1 : 0;
|
|
5271
5375
|
const thr = on(KEY.FORWARD) - on(KEY.BACK);
|
|
@@ -5351,6 +5455,11 @@ var pilot = (r, i, w) => {
|
|
|
5351
5455
|
r.z -= nz * (d - at - SHIP.OVER);
|
|
5352
5456
|
}
|
|
5353
5457
|
}
|
|
5458
|
+
const v0 = [
|
|
5459
|
+
r.vx,
|
|
5460
|
+
r.vy,
|
|
5461
|
+
r.vz
|
|
5462
|
+
];
|
|
5354
5463
|
let lifted = 0;
|
|
5355
5464
|
for (const k of SHIP.BODY) {
|
|
5356
5465
|
const [x, y, z] = point(r, 0, -SHIP.DROP, k);
|
|
@@ -5362,6 +5471,16 @@ var pilot = (r, i, w) => {
|
|
|
5362
5471
|
r.vy = max$1(r.vy, 0);
|
|
5363
5472
|
r.steer = r.vy > .5 ? 0 : -1;
|
|
5364
5473
|
}
|
|
5474
|
+
let scraped = 0;
|
|
5475
|
+
for (const s of [-1, 1]) for (const [x, edge] of TOUCH) {
|
|
5476
|
+
const [, le, te, , low] = section(x);
|
|
5477
|
+
const [px, py, pz] = point(r, s * x, low, edge < 0 ? te : edge > 0 ? le : (le + te) / 2);
|
|
5478
|
+
scraped = max$1(scraped, floorAt(w, px, pz, py + 1) - py);
|
|
5479
|
+
}
|
|
5480
|
+
if (scraped > 0) {
|
|
5481
|
+
r.y += scraped;
|
|
5482
|
+
r.vy = max$1(r.vy, 0);
|
|
5483
|
+
}
|
|
5365
5484
|
for (const k of SHIP.BODY) {
|
|
5366
5485
|
const [x, y, z] = point(r, 0, -SHIP.DROP, k);
|
|
5367
5486
|
const top = roof(w, x, z, y + .6, y + SHIP.H);
|
|
@@ -5386,7 +5505,65 @@ var pilot = (r, i, w) => {
|
|
|
5386
5505
|
r.vz -= v * pz;
|
|
5387
5506
|
}
|
|
5388
5507
|
}
|
|
5508
|
+
for (const s of [-1, 1]) {
|
|
5509
|
+
const [, le, te, , low] = section(TIP.X);
|
|
5510
|
+
const [x, y, z] = point(r, s * TIP.X, low, (le + te) / 2);
|
|
5511
|
+
const [px, pz] = shove({
|
|
5512
|
+
x,
|
|
5513
|
+
y,
|
|
5514
|
+
z
|
|
5515
|
+
}, w, WING_H, TIP.R);
|
|
5516
|
+
const d = px * px + pz * pz;
|
|
5517
|
+
if (d) {
|
|
5518
|
+
r.x += px;
|
|
5519
|
+
r.z += pz;
|
|
5520
|
+
const v = min$1(0, r.vx * px + r.vz * pz) / d;
|
|
5521
|
+
r.vx -= v * px;
|
|
5522
|
+
r.vz -= v * pz;
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
if (others.length) {
|
|
5526
|
+
const [, le, te, , low] = section(TIP.X);
|
|
5527
|
+
const mine = [
|
|
5528
|
+
...SHIP.BODY.map((k) => [
|
|
5529
|
+
0,
|
|
5530
|
+
-SHIP.DROP,
|
|
5531
|
+
k,
|
|
5532
|
+
SHIP.R,
|
|
5533
|
+
SHIP.H
|
|
5534
|
+
]),
|
|
5535
|
+
[
|
|
5536
|
+
-TIP.X,
|
|
5537
|
+
low,
|
|
5538
|
+
(le + te) / 2,
|
|
5539
|
+
TIP.R,
|
|
5540
|
+
WING_H
|
|
5541
|
+
],
|
|
5542
|
+
[
|
|
5543
|
+
TIP.X,
|
|
5544
|
+
low,
|
|
5545
|
+
(le + te) / 2,
|
|
5546
|
+
TIP.R,
|
|
5547
|
+
WING_H
|
|
5548
|
+
]
|
|
5549
|
+
];
|
|
5550
|
+
for (const o of others) for (const [b, u, k, rad, h] of mine) {
|
|
5551
|
+
const [x, y, z] = point(r, b, u, k);
|
|
5552
|
+
const [dx, dz, oy] = gapTo(o, x, z);
|
|
5553
|
+
const reach = rad + o.r;
|
|
5554
|
+
const d = sqrt$1(dx * dx + dz * dz);
|
|
5555
|
+
if (d >= reach - 1e-4 || oy >= y + h || oy + o.h <= y) continue;
|
|
5556
|
+
const [nx, nz] = d ? [dx / d, dz / d] : [cos$1(r.yaw), -sin$1(r.yaw)];
|
|
5557
|
+
r.x += nx * (reach - d);
|
|
5558
|
+
r.z += nz * (reach - d);
|
|
5559
|
+
const v = min$1(0, r.vx * nx + r.vz * nz) * (1 + SHIP.BOUNCE);
|
|
5560
|
+
r.vx -= v * nx;
|
|
5561
|
+
r.vz -= v * nz;
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5389
5564
|
bound(r, w);
|
|
5565
|
+
const jolt = sqrt$1((r.vx - v0[0]) ** 2 + ((r.vy - v0[1]) / 2) ** 2 + (r.vz - v0[2]) ** 2);
|
|
5566
|
+
if (crash && jolt > SHIP.CRASH) crash(jolt);
|
|
5390
5567
|
if (abs$1(r.roll) < 1e-6) r.roll = 0;
|
|
5391
5568
|
for (const k of FLOATS$1) r[k] = f32$1(r[k]);
|
|
5392
5569
|
return r.y < w.def.floor;
|
|
@@ -5396,7 +5573,7 @@ var pilot = (r, i, w) => {
|
|
|
5396
5573
|
* Infinity. The hull is the HITS spheres.
|
|
5397
5574
|
*/
|
|
5398
5575
|
var struck$1 = (r, o, d, m) => {
|
|
5399
|
-
let best =
|
|
5576
|
+
let best = wingStruck(r, o, d);
|
|
5400
5577
|
for (const k of SHIP.HITS) {
|
|
5401
5578
|
const c = point(r, 0, 0, k);
|
|
5402
5579
|
const [px, py, pz] = [
|
|
@@ -5411,13 +5588,51 @@ var struck$1 = (r, o, d, m) => {
|
|
|
5411
5588
|
const t = max$1(0, -b - sqrt$1(disc));
|
|
5412
5589
|
if (t <= m && t < best) best = t;
|
|
5413
5590
|
}
|
|
5591
|
+
return best <= m ? best : Infinity;
|
|
5592
|
+
};
|
|
5593
|
+
/** `v` in the ship's frame: right, up and ahead of its centre (`at`), or along its axes. */
|
|
5594
|
+
var frame = (r, v, at = true) => {
|
|
5595
|
+
const q = at ? [
|
|
5596
|
+
v[0] - r.x,
|
|
5597
|
+
v[1] - r.y,
|
|
5598
|
+
v[2] - r.z
|
|
5599
|
+
] : v;
|
|
5600
|
+
return axes(r).map((e) => e[0] * q[0] + e[1] * q[1] + e[2] * q[2]);
|
|
5601
|
+
};
|
|
5602
|
+
/** The boxes of both wings, each [right, up, ahead] from, to. */
|
|
5603
|
+
var BOXES = [-1, 1].flatMap((s) => WING_BOXES.map(([x, y, a]) => [
|
|
5604
|
+
s > 0 ? x : [-x[1], -x[0]],
|
|
5605
|
+
y,
|
|
5606
|
+
a
|
|
5607
|
+
]));
|
|
5608
|
+
/** Where a shot from `o` along the unit `d` first enters a wing: the distance, or Infinity. */
|
|
5609
|
+
var wingStruck = (r, o, d) => {
|
|
5610
|
+
const [lo, ld] = [frame(r, o), frame(r, d, false)];
|
|
5611
|
+
let best = Infinity;
|
|
5612
|
+
for (const box of BOXES) {
|
|
5613
|
+
let [t0, t1] = [0, Infinity];
|
|
5614
|
+
for (let n = 0; n < 3 && t0 <= t1; n++) {
|
|
5615
|
+
const [from, to] = box[n];
|
|
5616
|
+
if (abs$1(ld[n]) < 1e-9) {
|
|
5617
|
+
if (lo[n] < from || lo[n] > to) t0 = Infinity;
|
|
5618
|
+
continue;
|
|
5619
|
+
}
|
|
5620
|
+
const [a, b] = [(from - lo[n]) / ld[n], (to - lo[n]) / ld[n]];
|
|
5621
|
+
t0 = max$1(t0, min$1(a, b));
|
|
5622
|
+
t1 = min$1(t1, max$1(a, b));
|
|
5623
|
+
}
|
|
5624
|
+
if (t0 <= t1 && t0 < best) best = t0;
|
|
5625
|
+
}
|
|
5414
5626
|
return best;
|
|
5415
5627
|
};
|
|
5416
|
-
/** The distance from `c` to the nearest point of the hull's spheres, 0 inside. */
|
|
5417
|
-
var reach$1 = (r, c) =>
|
|
5418
|
-
const
|
|
5419
|
-
return
|
|
5420
|
-
|
|
5628
|
+
/** The distance from `c` to the nearest point of the hull's spheres and the wings, 0 inside. */
|
|
5629
|
+
var reach$1 = (r, c) => {
|
|
5630
|
+
const l = frame(r, c);
|
|
5631
|
+
return min$1(...SHIP.HITS.map((k) => {
|
|
5632
|
+
const [x, y, z] = point(r, 0, 0, k).map((v, n) => c[n] - v);
|
|
5633
|
+
return max$1(0, sqrt$1(x * x + y * y + z * z) - SHIP.HIT);
|
|
5634
|
+
}), ...BOXES.map((box) => sqrt$1(box.reduce((s, [from, to], n) => s + max$1(0, from - l[n], l[n] - to) ** 2, 0))));
|
|
5635
|
+
};
|
|
5421
5636
|
// src/shared/rover.ts
|
|
5422
5637
|
/** The rover's sizes and its handling (docs/MOON.md). Lengths in metres, per wheel rates for a body of mass 1. */
|
|
5423
5638
|
var ROVER = {
|
|
@@ -5474,6 +5689,12 @@ var ROVER = {
|
|
|
5474
5689
|
WHEEL_STEP: .6,
|
|
5475
5690
|
/** The share of its speed into another rover a rover bounces back with. */
|
|
5476
5691
|
BOUNCE: .3,
|
|
5692
|
+
/**
|
|
5693
|
+
* A crash (the user, 2026-11-12): the speed on the level that a step's walls and vehicles take
|
|
5694
|
+
* away (m/s) past CRASH costs 1 hp each CRASH_HP more. A landing is the springs': no crash.
|
|
5695
|
+
*/
|
|
5696
|
+
CRASH: 10,
|
|
5697
|
+
CRASH_HP: 3,
|
|
5477
5698
|
/** A player this close to a rover's centre gets in; a rover this fast hurts an enemy, and this fast puts him down. */
|
|
5478
5699
|
ENTER_R: 3,
|
|
5479
5700
|
SPLAT_MIN: 6,
|
|
@@ -5573,6 +5794,8 @@ var hull = (r) => {
|
|
|
5573
5794
|
h: ROVER.BODY_H
|
|
5574
5795
|
};
|
|
5575
5796
|
};
|
|
5797
|
+
/** Every solid of the vehicle: a rover's hull(), a ship's hull and its two wings. */
|
|
5798
|
+
var hulls = (r) => r.ship ? shipBodies(r) : [hull(r)];
|
|
5576
5799
|
/**
|
|
5577
5800
|
* A rover's wreck skids to a stop where it blew up: before each of its steps with nobody at the
|
|
5578
5801
|
* wheel it keeps VEHICLE.SKID of its speed along the ground. A ship's wreck falls as it flew.
|
|
@@ -5585,7 +5808,7 @@ var skid = (r) => {
|
|
|
5585
5808
|
* is down the wrecks' (his own vehicle's among them: he lies where it blew up, and no wreck that
|
|
5586
5809
|
* moves under him bends his replay).
|
|
5587
5810
|
*/
|
|
5588
|
-
var solid = (rovers, p) => rovers.filter((r) => !(p.down && r.wreck)).
|
|
5811
|
+
var solid = (rovers, p) => rovers.filter((r) => !(p.down && r.wreck)).flatMap(hulls);
|
|
5589
5812
|
/**
|
|
5590
5813
|
* The map's rovers at rest on their spawns, whole, nobody aboard, then its ships on their pads
|
|
5591
5814
|
* (ship.ts): the order of the snapshot's.
|
|
@@ -5643,8 +5866,9 @@ var reach = (r, c) => r.ship ? reach$1(r, c) : min(...footprint(r).map(([x, y, z
|
|
|
5643
5866
|
* vehicle: its hull() within reach of his centre on the floor plane, inside the arc round his look
|
|
5644
5867
|
* (the hull's own angular radius counts), the heights overlapping and no brush before it.
|
|
5645
5868
|
*/
|
|
5646
|
-
var slashed = (w, r, p, { reach, arc }) =>
|
|
5647
|
-
|
|
5869
|
+
var slashed = (w, r, p, { reach, arc }) => hulls(r).some((h) => cuts(w, h, p, reach, arc));
|
|
5870
|
+
/** Whether a cut of `p` with this reach and arc meets the body `h`. */
|
|
5871
|
+
var cuts = (w, h, p, reach, arc) => {
|
|
5648
5872
|
const [dx, dz, y] = gapTo(h, p.x, p.z);
|
|
5649
5873
|
const d = sqrt(dx * dx + dz * dz);
|
|
5650
5874
|
const tall = heightOf(p);
|
|
@@ -5676,8 +5900,8 @@ var slashed = (w, r, p, { reach, arc }) => {
|
|
|
5676
5900
|
* turns toward the look as fast as the speed allows, and the tyres' grip decides how much of the
|
|
5677
5901
|
* speed follows it. The rest drifts.
|
|
5678
5902
|
*/
|
|
5679
|
-
var drive = (r, i, w, fleet = []) => {
|
|
5680
|
-
if (r.ship) return pilot(r, i, w);
|
|
5903
|
+
var drive = (r, i, w, fleet = [], crash) => {
|
|
5904
|
+
if (r.ship) return pilot(r, i, w, fleet.filter((o) => o !== r).flatMap(hulls), crash);
|
|
5681
5905
|
const { A, B, CMAX, K, D, KP2, KR2, HC, MU, MUL, TILT } = ROVER;
|
|
5682
5906
|
const g = gravity(w);
|
|
5683
5907
|
const keys = i ? i.keys : 0;
|
|
@@ -5755,6 +5979,7 @@ var drive = (r, i, w, fleet = []) => {
|
|
|
5755
5979
|
r.roll = clamp(r.roll + r.wr * DT, -TILT, TILT);
|
|
5756
5980
|
if (abs(r.pitch) === TILT && r.pitch * r.wp > 0) r.wp = 0;
|
|
5757
5981
|
if (abs(r.roll) === TILT && r.roll * r.wr > 0) r.wr = 0;
|
|
5982
|
+
const [vx0, vz0] = [r.vx, r.vz];
|
|
5758
5983
|
for (const a of ROVER.BODY) {
|
|
5759
5984
|
const [x, y, z] = at(r, a, 0, -DROP);
|
|
5760
5985
|
const [px, pz] = shove({
|
|
@@ -5773,13 +5998,12 @@ var drive = (r, i, w, fleet = []) => {
|
|
|
5773
5998
|
}
|
|
5774
5999
|
for (const o of fleet) {
|
|
5775
6000
|
if (o === r) continue;
|
|
5776
|
-
const h
|
|
5777
|
-
for (const a of ROVER.BODY) {
|
|
6001
|
+
for (const h of hulls(o)) for (const a of ROVER.BODY) {
|
|
5778
6002
|
const [x, y, z] = at(r, a, 0, -DROP);
|
|
5779
6003
|
const [dx, dz, oy] = gapTo(h, x, z);
|
|
5780
|
-
const reach =
|
|
6004
|
+
const reach = ROVER.RB + h.r;
|
|
5781
6005
|
const d = sqrt(dx * dx + dz * dz);
|
|
5782
|
-
if (d >= reach - 1e-4 || oy >= y + ROVER.BODY_H || oy +
|
|
6006
|
+
if (d >= reach - 1e-4 || oy >= y + ROVER.BODY_H || oy + h.h <= y) continue;
|
|
5783
6007
|
const [ox, oz] = forward(o.yaw);
|
|
5784
6008
|
const [nx, nz] = d ? [dx / d, dz / d] : [-oz, ox];
|
|
5785
6009
|
r.x += nx * (reach - d);
|
|
@@ -5790,6 +6014,8 @@ var drive = (r, i, w, fleet = []) => {
|
|
|
5790
6014
|
}
|
|
5791
6015
|
}
|
|
5792
6016
|
bound(r, w);
|
|
6017
|
+
const jolt = sqrt((r.vx - vx0) ** 2 + (r.vz - vz0) ** 2);
|
|
6018
|
+
if (crash && jolt > ROVER.CRASH) crash(jolt);
|
|
5793
6019
|
for (const k of FLOATS) r[k] = f32(r[k]);
|
|
5794
6020
|
return r.y < w.def.floor;
|
|
5795
6021
|
};
|
|
@@ -5869,9 +6095,9 @@ var leave = (p, r, s, w) => {
|
|
|
5869
6095
|
* that takes him off his seat (move() puts a body under the kill floor back at a spawn) frees it.
|
|
5870
6096
|
* `fleet` is drive()'s.
|
|
5871
6097
|
*/
|
|
5872
|
-
var ride = (p, r, i, w, team, fleet = []) => {
|
|
6098
|
+
var ride = (p, r, i, w, team, fleet = [], crash) => {
|
|
5873
6099
|
const out = (i.keys & KEY.USE) !== 0 && (p.held & KEY.USE) === 0;
|
|
5874
|
-
const fell = drive(r, i, w, fleet);
|
|
6100
|
+
const fell = drive(r, i, w, fleet, crash);
|
|
5875
6101
|
step(p, i, w, team, false);
|
|
5876
6102
|
if (p.mode !== MODE.RIDE) r.driver = 255;
|
|
5877
6103
|
else {
|
|
@@ -5897,19 +6123,34 @@ var nearby = (r, p) => {
|
|
|
5897
6123
|
var free = (r, carrier) => r.driver === 255 && !carrier ? 0 : r.rider === 255 && !r.ship ? 1 : -1;
|
|
5898
6124
|
/** Metres from the centre to where the lasers cross along the look: a ship's or a rover's. */
|
|
5899
6125
|
var aimRange = (r) => r.ship ? SHIP.GUN_AIM : ROVER.GUN_AIM;
|
|
5900
|
-
/**
|
|
5901
|
-
|
|
6126
|
+
/**
|
|
6127
|
+
* Where the lasers cross: on what the driver's look meets within the guns' range (`sight`, the
|
|
6128
|
+
* user, 2026-11-12: with a cross at a fixed distance the two beams went either side of a rover
|
|
6129
|
+
* nearer than it), AIM_MIN at least; else aimRange() metres from the centre along the look.
|
|
6130
|
+
*/
|
|
6131
|
+
var aimOf = (r, yaw, pitch, sight) => {
|
|
5902
6132
|
const [sy, cy, sp, cp] = [
|
|
5903
6133
|
Math.sin(yaw),
|
|
5904
6134
|
Math.cos(yaw),
|
|
5905
6135
|
Math.sin(pitch),
|
|
5906
6136
|
Math.cos(pitch)
|
|
5907
6137
|
];
|
|
5908
|
-
const
|
|
6138
|
+
const d = [
|
|
6139
|
+
-sy * cp,
|
|
6140
|
+
sp,
|
|
6141
|
+
-cy * cp
|
|
6142
|
+
];
|
|
6143
|
+
const far = r.ship ? SHIP.GUN_RANGE : ROVER.GUN_RANGE;
|
|
6144
|
+
const t = sight ? sight([
|
|
6145
|
+
r.x,
|
|
6146
|
+
r.y,
|
|
6147
|
+
r.z
|
|
6148
|
+
], d, far) : Infinity;
|
|
6149
|
+
const k = t < far ? max(t, 8) : aimRange(r);
|
|
5909
6150
|
return [
|
|
5910
|
-
r.x
|
|
5911
|
-
r.y +
|
|
5912
|
-
r.z
|
|
6151
|
+
r.x + d[0] * k,
|
|
6152
|
+
r.y + d[1] * k,
|
|
6153
|
+
r.z + d[2] * k
|
|
5913
6154
|
];
|
|
5914
6155
|
};
|
|
5915
6156
|
/** A muzzle of the vehicle in the world: `m` is right of the centre, above it, ahead of it. */
|
|
@@ -5933,8 +6174,8 @@ var toward = (o, aim) => {
|
|
|
5933
6174
|
* the point GUN_AIM metres along the driver's look (the yaw and pitch of his input) from the rover's
|
|
5934
6175
|
* centre, so the beams cross there, chest high on level ground with a level look. `id` names the first, `id + 1` the second.
|
|
5935
6176
|
*/
|
|
5936
|
-
var bolts = (r, by, team, yaw, pitch, id) => {
|
|
5937
|
-
const aim = aimOf(r, yaw, pitch);
|
|
6177
|
+
var bolts = (r, by, team, yaw, pitch, id, sight) => {
|
|
6178
|
+
const aim = aimOf(r, yaw, pitch, sight);
|
|
5938
6179
|
return (r.ship ? SHIP_GUNS : GUNS).map((m, k) => {
|
|
5939
6180
|
const o = muzzle(r, m);
|
|
5940
6181
|
const d = toward(o, aim);
|
|
@@ -5959,9 +6200,9 @@ var bolts = (r, by, team, yaw, pitch, id) => {
|
|
|
5959
6200
|
* (plasma.ts's toss() flies it, blast() is its burst) launched at MISSILE_SPEED plus the ship's own
|
|
5960
6201
|
* speed along the way, 63 m/s at most (the wire's six bits).
|
|
5961
6202
|
*/
|
|
5962
|
-
var missile = (r, by, team, yaw, pitch, id, k) => {
|
|
6203
|
+
var missile = (r, by, team, yaw, pitch, id, k, sight) => {
|
|
5963
6204
|
const o = muzzle(r, PODS[k]);
|
|
5964
|
-
const d = toward(o, aimOf(r, yaw, pitch));
|
|
6205
|
+
const d = toward(o, aimOf(r, yaw, pitch, sight));
|
|
5965
6206
|
const own = r.vx * d[0] + r.vy * d[1] + r.vz * d[2];
|
|
5966
6207
|
return {
|
|
5967
6208
|
id: id & 255,
|
|
@@ -6173,7 +6414,7 @@ var Room = class {
|
|
|
6173
6414
|
const use = (input.keys & KEY.USE) !== 0 && (p.state.held & KEY.USE) === 0;
|
|
6174
6415
|
const [r, s] = this.seatOf(p);
|
|
6175
6416
|
if (r && !s) {
|
|
6176
|
-
const fell = ride(p.state, r, input, this.world, p.info.team, this.rovers);
|
|
6417
|
+
const fell = ride(p.state, r, input, this.world, p.info.team, this.rovers, (j) => this.crash(r, j));
|
|
6177
6418
|
this.ctf.moved(p.state);
|
|
6178
6419
|
if (fell) this.sink(r);
|
|
6179
6420
|
else {
|
|
@@ -6267,7 +6508,7 @@ var Room = class {
|
|
|
6267
6508
|
continue;
|
|
6268
6509
|
}
|
|
6269
6510
|
if (r.wreck) skid(r);
|
|
6270
|
-
if (drive(r, void 0, this.world, this.rovers)) this.sink(r);
|
|
6511
|
+
if (drive(r, void 0, this.world, this.rovers, (j) => this.crash(r, j))) this.sink(r);
|
|
6271
6512
|
else this.carry(r);
|
|
6272
6513
|
}
|
|
6273
6514
|
this.seats();
|
|
@@ -6847,7 +7088,7 @@ var Room = class {
|
|
|
6847
7088
|
if (!(i.keys & KEY.FIRE) || p.gun || this.ctf.over || p.state.mode !== MODE.RIDE) return;
|
|
6848
7089
|
p.gun = r.ship ? SHIP.GUN_COOL : ROVER.GUN_COOL;
|
|
6849
7090
|
p.bolt = (p.bolt ?? 0) + 2 & 255;
|
|
6850
|
-
for (const b of bolts(r, p.info.id, p.info.team, i.yaw, i.pitch, p.bolt)) this.shoot(p, i.view, b);
|
|
7091
|
+
for (const b of bolts(r, p.info.id, p.info.team, i.yaw, i.pitch, p.bolt, this.sight(p, i))) this.shoot(p, i.view, b);
|
|
6851
7092
|
}
|
|
6852
7093
|
/**
|
|
6853
7094
|
* A ship's missiles: while its pilot holds SPECIAL (G), one each SHIP.MISSILE_COOL of his inputs
|
|
@@ -6861,7 +7102,17 @@ var Room = class {
|
|
|
6861
7102
|
p.side = (p.side ?? 0) ^ 1;
|
|
6862
7103
|
r.nades--;
|
|
6863
7104
|
p.bolt = (p.bolt ?? 0) + 1 & 255;
|
|
6864
|
-
this.shoot(p, i.view, missile(r, p.info.id, p.info.team, i.yaw, i.pitch, p.bolt, p.side));
|
|
7105
|
+
this.shoot(p, i.view, missile(r, p.info.id, p.info.team, i.yaw, i.pitch, p.bolt, p.side, this.sight(p, i)));
|
|
7106
|
+
}
|
|
7107
|
+
/**
|
|
7108
|
+
* What the look of the driver `p` meets for his guns' aim (aimOf()): a brush, an enemy vehicle's
|
|
7109
|
+
* hull where it is, or an enemy on foot who is up as `p` drew him at the input's view tick.
|
|
7110
|
+
*/
|
|
7111
|
+
sight(p, i) {
|
|
7112
|
+
const foes = new Set(this.players().filter((q) => q.info.team !== p.info.team).map((q) => q.info.id));
|
|
7113
|
+
const drawn = this.past(i.view).filter((q) => foes.has(q.id) && !q.down && q.mode !== MODE.RIDE);
|
|
7114
|
+
const hulls = this.targets(p.info.team);
|
|
7115
|
+
return (o, d, m) => Math.min(ray(this.world, o, d, m), ...hulls.map((v) => struck(v, o, d, m)), ...drawn.map((q) => cylinder(o, d, q, PLAYER_R, heightOf(q))));
|
|
6865
7116
|
}
|
|
6866
7117
|
/**
|
|
6867
7118
|
* A vehicle's clock outside its driver's inputs: a wreck is parked afresh after VEHICLE.WRECK
|
|
@@ -6894,6 +7145,15 @@ var Room = class {
|
|
|
6894
7145
|
targets(team) {
|
|
6895
7146
|
return this.rovers.filter((r) => !r.wreck && this.teamOf(r) !== team);
|
|
6896
7147
|
}
|
|
7148
|
+
/**
|
|
7149
|
+
* A vehicle that crashed with a jolt of `jolt` m/s: a ship into a brush, the ground or another
|
|
7150
|
+
* vehicle (pilot()), a rover into a wall or a vehicle (drive()). 1 hp each CRASH_HP past CRASH
|
|
7151
|
+
* (SHIP's, ROVER's), nobody's shot; at 0 it blows up as its team's, so its blast spares its mates.
|
|
7152
|
+
*/
|
|
7153
|
+
crash(r, jolt) {
|
|
7154
|
+
const [from, per] = r.ship ? [SHIP.CRASH, SHIP.CRASH_HP] : [ROVER.CRASH, ROVER.CRASH_HP];
|
|
7155
|
+
this.hurt(r, Math.ceil((jolt - from) / per), 255, this.teamOf(r));
|
|
7156
|
+
}
|
|
6897
7157
|
/** The vehicle `r` loses `hp` to player `by` of `team`; at 0 it blows up (wreck()). */
|
|
6898
7158
|
hurt(r, hp, by, team) {
|
|
6899
7159
|
if (r.wreck) return;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Rover } from '../shared/types';
|
|
2
|
+
import { WING } from '../shared/ship';
|
|
2
3
|
import type { Vec3 } from './mesh';
|
|
3
4
|
/**
|
|
4
5
|
* The ship's lines, metres ahead of the centre: the nose's tip and where its sensor starts, the
|
|
@@ -23,8 +24,8 @@ export declare const ENGINE: {
|
|
|
23
24
|
};
|
|
24
25
|
/** The engines' nozzles: right of the centre, above it, ahead of it. */
|
|
25
26
|
export declare const NOZZLES: Vec3[];
|
|
26
|
-
/** A wing's sections
|
|
27
|
-
export
|
|
27
|
+
/** A wing's sections (ship.ts's: the wings collide as they are drawn). */
|
|
28
|
+
export { WING };
|
|
28
29
|
/** The feet of the three legs it stands on: right of the centre, under it, ahead of it. */
|
|
29
30
|
export declare const FEET: Vec3[];
|
|
30
31
|
/** The navigation lights: red on the port tip, green on the starboard one, a strobe on the spine. */
|
|
@@ -11,6 +11,11 @@ export interface Foley {
|
|
|
11
11
|
* call, and the keys he holds at its wheel (0 for the rider): the engine, the skid, the landings.
|
|
12
12
|
*/
|
|
13
13
|
rover(r: Rover | undefined, dt: number, keys?: number): void;
|
|
14
|
+
/**
|
|
15
|
+
* The ship the own player flies, as drawn (undefined otherwise), `dt` seconds after the last
|
|
16
|
+
* call, and the keys he holds at its stick: the engines, and a crash.
|
|
17
|
+
*/
|
|
18
|
+
ship(r: Rover | undefined, dt: number, keys?: number): void;
|
|
14
19
|
/**
|
|
15
20
|
* The own player's breath in his space helmet, `dt` seconds after the last call: in and out,
|
|
16
21
|
* quicker and louder the harder he has been moving lately. None when down or without a player.
|
|
@@ -97,6 +97,12 @@ export declare const SOUND: {
|
|
|
97
97
|
readonly ARC: 48;
|
|
98
98
|
readonly WRECK: 49;
|
|
99
99
|
readonly CRUMBLE: 50;
|
|
100
|
+
/** A vehicle's laser bolt (the user, 2026-11-12: a blaster of the films): a bright zing diving fast, metallic. */
|
|
101
|
+
readonly BLASTER: 51;
|
|
102
|
+
/** The combat ship's engines, looped: a turbine's whine over a jet's roar, played higher and louder with the thrust. */
|
|
103
|
+
readonly JET: 52;
|
|
104
|
+
/** The ship crashing into a wall, the ground or another vehicle: a crunch of metal over a deep thump. */
|
|
105
|
+
readonly CRASH: 53;
|
|
100
106
|
};
|
|
101
107
|
/**
|
|
102
108
|
* The sounds of the game: one entry per sound, its voices layered, in SOUND order. A low-passed
|
|
@@ -198,6 +198,11 @@ export declare class Room {
|
|
|
198
198
|
* while it has any, from the left pod then the right, toward where its lasers cross.
|
|
199
199
|
*/
|
|
200
200
|
private launch;
|
|
201
|
+
/**
|
|
202
|
+
* What the look of the driver `p` meets for his guns' aim (aimOf()): a brush, an enemy vehicle's
|
|
203
|
+
* hull where it is, or an enemy on foot who is up as `p` drew him at the input's view tick.
|
|
204
|
+
*/
|
|
205
|
+
private sight;
|
|
201
206
|
/**
|
|
202
207
|
* A vehicle's clock outside its driver's inputs: a wreck is parked afresh after VEHICLE.WRECK
|
|
203
208
|
* ticks; a hull the rail gun's bolt sears loses 1 hp each RAIL_DRAIN ticks after its first touch;
|
|
@@ -208,6 +213,12 @@ export declare class Room {
|
|
|
208
213
|
private teamOf;
|
|
209
214
|
/** The vehicles a shooter of `team` hurts: whole, and not of his team. */
|
|
210
215
|
private targets;
|
|
216
|
+
/**
|
|
217
|
+
* A vehicle that crashed with a jolt of `jolt` m/s: a ship into a brush, the ground or another
|
|
218
|
+
* vehicle (pilot()), a rover into a wall or a vehicle (drive()). 1 hp each CRASH_HP past CRASH
|
|
219
|
+
* (SHIP's, ROVER's), nobody's shot; at 0 it blows up as its team's, so its blast spares its mates.
|
|
220
|
+
*/
|
|
221
|
+
private crash;
|
|
211
222
|
/** The vehicle `r` loses `hp` to player `by` of `team`; at 0 it blows up (wreck()). */
|
|
212
223
|
private hurt;
|
|
213
224
|
/**
|