@korial29/tiny-fps 0.196.2 → 0.197.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 +53 -52
- package/dist/local.js +1 -1
- package/dist/server.js +284 -77
- package/dist/types/client/balls.d.ts +1 -1
- package/dist/types/client/body.d.ts +1 -1
- package/dist/types/client/combat.d.ts +3 -1
- package/dist/types/client/face.d.ts +2 -1
- package/dist/types/client/hud.d.ts +2 -0
- package/dist/types/client/hunter.d.ts +1 -0
- package/dist/types/client/input.d.ts +4 -0
- package/dist/types/client/katana.d.ts +6 -0
- package/dist/types/client/render.d.ts +2 -0
- package/dist/types/client/sfx.d.ts +6 -0
- package/dist/types/client/soldier.d.ts +1 -1
- package/dist/types/client/taunt.d.ts +3 -1
- package/dist/types/shared/constants.d.ts +16 -0
- package/dist/types/shared/gun.d.ts +1 -0
- package/dist/types/shared/kit.d.ts +3 -0
- package/dist/types/shared/physics.d.ts +2 -0
- package/dist/types/shared/plasma.d.ts +3 -1
- package/dist/types/shared/protocol.d.ts +10 -2
- package/dist/types/shared/room.d.ts +8 -0
- package/dist/types/shared/types.d.ts +3 -1
- package/dist/types/shared/world.d.ts +2 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -233,6 +233,8 @@ var EXEC = {
|
|
|
233
233
|
/** How much faster than a man the xenomorph runs (the user, 2026-11-16: a little, not twice). */
|
|
234
234
|
var XENO_PACE = 1.25;
|
|
235
235
|
var PLASMA_R = .12;
|
|
236
|
+
var HARPOON_R = .08;
|
|
237
|
+
var DISK_R = .16;
|
|
236
238
|
/**
|
|
237
239
|
* What a vehicle's bolts take (the user, 2026-11-16: stronger, they grazed like the rifle's rounds):
|
|
238
240
|
* BOLT_HP from a player each one that hits him, and 1 from a hull every BOLT_GRAZE on it.
|
|
@@ -738,7 +740,8 @@ var ROLE = {
|
|
|
738
740
|
MARINE: 0,
|
|
739
741
|
NINJA: 1,
|
|
740
742
|
ASTRONAUT: 2,
|
|
741
|
-
XENO: 3
|
|
743
|
+
XENO: 3,
|
|
744
|
+
HUNTER: 4
|
|
742
745
|
};
|
|
743
746
|
var MARINE = {
|
|
744
747
|
run: 6,
|
|
@@ -813,16 +816,26 @@ var KITS = [
|
|
|
813
816
|
hp: 12,
|
|
814
817
|
gear: false,
|
|
815
818
|
xeno: true
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
...MARINE,
|
|
822
|
+
katana: true,
|
|
823
|
+
hunter: true
|
|
816
824
|
}
|
|
817
825
|
];
|
|
818
826
|
/**
|
|
819
827
|
* The classes a map offers, the first one the default: on a map with space helmets the astronaut
|
|
820
828
|
* and the xenomorph, who breathes none.
|
|
821
829
|
*/
|
|
822
|
-
var rolesOf = (def) => def.helmets ? [
|
|
830
|
+
var rolesOf = (def) => def.helmets ? [
|
|
831
|
+
ROLE.ASTRONAUT,
|
|
832
|
+
ROLE.XENO,
|
|
833
|
+
ROLE.HUNTER
|
|
834
|
+
] : [
|
|
823
835
|
ROLE.MARINE,
|
|
824
836
|
ROLE.NINJA,
|
|
825
|
-
ROLE.XENO
|
|
837
|
+
ROLE.XENO,
|
|
838
|
+
ROLE.HUNTER
|
|
826
839
|
];
|
|
827
840
|
/** The class a player plays on the map: his `role` when the map offers it, else the map's default. */
|
|
828
841
|
var roleOf = (role, def) => {
|
|
@@ -839,6 +852,9 @@ var OFF = 1024;
|
|
|
839
852
|
var key = (cx, cz) => (cx + OFF) * (2 * OFF) + cz + OFF;
|
|
840
853
|
/** Integer cell coordinate of a metre value, clamped to the keyed range. */
|
|
841
854
|
var at$3 = (v, cell) => Math.min(Math.max(Math.floor(v / cell), -1024), 1023);
|
|
855
|
+
var EMPTY = [];
|
|
856
|
+
/** Brush candidates in the one cell containing a point; the returned list is read-only. */
|
|
857
|
+
var atPoint = (w, x, z) => w.grid.get(key(at$3(x, w.cell), at$3(z, w.cell))) ?? EMPTY;
|
|
842
858
|
/** Builds the grid: each brush is listed in every cell its footprint covers. */
|
|
843
859
|
var build$1 = (def, cell = CELL$1) => {
|
|
844
860
|
const grid = /* @__PURE__ */ new Map();
|
|
@@ -1176,6 +1192,8 @@ var gapTo = (o, x, z) => {
|
|
|
1176
1192
|
ay + t * (by - ay)
|
|
1177
1193
|
];
|
|
1178
1194
|
};
|
|
1195
|
+
/** A conservative horizontal bound around a body's axis, expanded by the other radius. */
|
|
1196
|
+
var nearBody = (o, x, z, radius) => x >= Math.min(o.a[0], o.b[0]) - radius && x <= Math.max(o.a[0], o.b[0]) + radius && z >= Math.min(o.a[2], o.b[2]) - radius && z <= Math.max(o.a[2], o.b[2]) + radius;
|
|
1179
1197
|
/**
|
|
1180
1198
|
* push() for the bodies: the player's circle out of each body that blocks it (as blocks() a
|
|
1181
1199
|
* brush), along the line from its axis. A centre on the axis leaves by the body's right (a is its
|
|
@@ -1184,8 +1202,9 @@ var gapTo = (o, x, z) => {
|
|
|
1184
1202
|
var jostle = (p, bodies, h) => {
|
|
1185
1203
|
let [tx, tz] = [0, 0];
|
|
1186
1204
|
for (const o of bodies) {
|
|
1187
|
-
const [dx, dz, y] = gapTo(o, p.x, p.z);
|
|
1188
1205
|
const r = o.r + PLAYER_R;
|
|
1206
|
+
if (!nearBody(o, p.x, p.z, r)) continue;
|
|
1207
|
+
const [dx, dz, y] = gapTo(o, p.x, p.z);
|
|
1189
1208
|
const d2 = dx * dx + dz * dz;
|
|
1190
1209
|
if (d2 >= (r - EPS) ** 2 || y + o.h <= p.y + .5 + SKIN || y >= p.y + h - SKIN) continue;
|
|
1191
1210
|
const d = sqrt$2(d2);
|
|
@@ -1221,6 +1240,7 @@ var span = (p, w, h, bodies = []) => {
|
|
|
1221
1240
|
else if (b.min[1] >= p.y + h - SKIN) ceil = Math.min(ceil, b.min[1]);
|
|
1222
1241
|
}
|
|
1223
1242
|
for (const o of bodies) {
|
|
1243
|
+
if (!nearBody(o, p.x, p.z, o.r + .4)) continue;
|
|
1224
1244
|
const [dx, dz, y] = gapTo(o, p.x, p.z);
|
|
1225
1245
|
if (dx * dx + dz * dz >= (o.r + .4 - EPS) ** 2) continue;
|
|
1226
1246
|
if (y + o.h <= p.y + .5 + SKIN) floor = Math.max(floor, y + o.h);
|
|
@@ -1234,7 +1254,7 @@ var span = (p, w, h, bodies = []) => {
|
|
|
1234
1254
|
*/
|
|
1235
1255
|
var floorAt = (w, x, z, y) => {
|
|
1236
1256
|
let floor = ground(w, x, z);
|
|
1237
|
-
for (const i of
|
|
1257
|
+
for (const i of atPoint(w, x, z)) {
|
|
1238
1258
|
const { min, max } = w.def.brushes[i];
|
|
1239
1259
|
if (x >= min[0] && x <= max[0] && z >= min[2] && z <= max[2] && max[1] <= y) floor = Math.max(floor, max[1]);
|
|
1240
1260
|
}
|
|
@@ -5910,7 +5930,7 @@ var drift = (n) => [RIFLE_DRIFT * Math.sin(n * 2.4), RIFLE_DRIFT * Math.cos(n *
|
|
|
5910
5930
|
* as the shot (`power`). The laser rifle's (the user, 2026-11-08: the gun's balls, in red) has
|
|
5911
5931
|
* power 0, RIFLE_RANGE to go, and leaves along the look drifted by its shot's pattern.
|
|
5912
5932
|
*/
|
|
5913
|
-
var launch$1 = (p, team = 0) => {
|
|
5933
|
+
var launch$1 = (p, team = 0, harpoon = false) => {
|
|
5914
5934
|
const [dy, dp] = p.rifled ? drift(p.shots) : [0, 0];
|
|
5915
5935
|
const [yaw, pitch] = [p.yaw + dy, p.pitch + dp];
|
|
5916
5936
|
const [sy, cy, sp, cp] = [
|
|
@@ -5929,11 +5949,17 @@ var launch$1 = (p, team = 0) => {
|
|
|
5929
5949
|
dx: -sy * cp,
|
|
5930
5950
|
dy: sp,
|
|
5931
5951
|
dz: -cy * cp,
|
|
5932
|
-
left: p.rifled ? 60 : 80,
|
|
5952
|
+
left: p.rifled ? 60 : harpoon ? 90 : 80,
|
|
5933
5953
|
burst: false,
|
|
5934
|
-
power: p.rifled ? 0 : p.power ?? 1
|
|
5954
|
+
power: p.rifled ? 0 : harpoon ? 8 : p.power ?? 1
|
|
5935
5955
|
};
|
|
5936
5956
|
};
|
|
5957
|
+
/** The Hunter's returning disc: a wide, fast shot that the room turns back toward its owner. */
|
|
5958
|
+
var disk = (p, team = 0) => ({
|
|
5959
|
+
...launch$1(p, team),
|
|
5960
|
+
power: 9,
|
|
5961
|
+
left: 28
|
|
5962
|
+
});
|
|
5937
5963
|
/**
|
|
5938
5964
|
* The arc of energy the ARC cut of `p` throws at its strike (`p` the state after that step): from
|
|
5939
5965
|
* the eye along the look like a ball, ARC_RANGE metres to go, its CUT in `arc`. Its id is the
|
|
@@ -5947,7 +5973,7 @@ var wave = (p, team = 0) => ({
|
|
|
5947
5973
|
arc: p.cut
|
|
5948
5974
|
});
|
|
5949
5975
|
/** The speed of the flight `b`, m/s: an arc's, a bolt's, a rifle round's (power 0) or a ball's. A grenade has its own (`Ball.v`). */
|
|
5950
|
-
var speedOf = (b) => b.arc ? ARC_SPEED : b.power === 6 ? 120 : b.power === 0 ? 400 : 80;
|
|
5976
|
+
var speedOf = (b) => b.arc ? ARC_SPEED : b.power === 9 || b.power === 10 ? 52 : b.power === 8 ? 72 : b.power === 6 ? 120 : b.power === 0 ? 400 : 80;
|
|
5951
5977
|
/** Metres the flight `b` goes in a tick. */
|
|
5952
5978
|
var stepOf = (b) => speedOf(b) / 60;
|
|
5953
5979
|
/**
|
|
@@ -5986,11 +6012,12 @@ var fly = (w, b, m, foes) => {
|
|
|
5986
6012
|
b.dz
|
|
5987
6013
|
];
|
|
5988
6014
|
const go = Math.min(m, b.left);
|
|
6015
|
+
const radius = b.power === 9 || b.power === 10 ? DISK_R : b.power === 8 ? HARPOON_R : PLASMA_R;
|
|
5989
6016
|
const seam = w.def.seam === void 0 || !d[1] ? Infinity : (w.def.seam - o[1]) / d[1];
|
|
5990
|
-
let t = ray(w, o, d, seam > 1e-6 ? Math.min(go, seam) : go,
|
|
6017
|
+
let t = ray(w, o, d, seam > 1e-6 ? Math.min(go, seam) : go, radius);
|
|
5991
6018
|
let hit;
|
|
5992
6019
|
for (const f of foes) {
|
|
5993
|
-
const u = cylinder(o, d, f, PLAYER_R + (b.arc ? ARC_R :
|
|
6020
|
+
const u = cylinder(o, d, f, PLAYER_R + (b.arc ? ARC_R : radius), heightOf(f));
|
|
5994
6021
|
if (u < t) [t, hit] = [u, f];
|
|
5995
6022
|
}
|
|
5996
6023
|
b.burst = t < go;
|
|
@@ -6189,11 +6216,16 @@ var WING = [
|
|
|
6189
6216
|
]
|
|
6190
6217
|
];
|
|
6191
6218
|
/** The right wing's section `x` metres right of the centre, between two of WING's. */
|
|
6219
|
+
var sections = /* @__PURE__ */ new Map();
|
|
6192
6220
|
var section = (x) => {
|
|
6221
|
+
const cached = sections.get(x);
|
|
6222
|
+
if (cached) return cached;
|
|
6193
6223
|
const k = x < WING[1][0] ? 0 : 1;
|
|
6194
6224
|
const [a, b] = [WING[k], WING[k + 1]];
|
|
6195
6225
|
const t = (x - a[0]) / (b[0] - a[0]);
|
|
6196
|
-
|
|
6226
|
+
const result = a.map((v, n) => v + (b[n] - v) * t);
|
|
6227
|
+
sections.set(x, result);
|
|
6228
|
+
return result;
|
|
6197
6229
|
};
|
|
6198
6230
|
/**
|
|
6199
6231
|
* The right wing as the shots meet it: boxes in the ship's frame along the span, each round its
|
|
@@ -6234,6 +6266,8 @@ var TIP = {
|
|
|
6234
6266
|
X: 5.6,
|
|
6235
6267
|
R: .8
|
|
6236
6268
|
};
|
|
6269
|
+
/** Horizontal bound on every collision circle, at any pitch and roll. */
|
|
6270
|
+
var COLLISION_REACH = Math.max(...SHIP.BODY.map((k) => Math.abs(k) + SHIP.DROP + SHIP.R), TIP.X + Math.abs(section(TIP.X)[4]) + Math.max(Math.abs(section(TIP.X)[1]), Math.abs(section(TIP.X)[2])) + TIP.R);
|
|
6237
6271
|
/** 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). */
|
|
6238
6272
|
var TOUCH = [
|
|
6239
6273
|
[3.2, 0],
|
|
@@ -6257,10 +6291,13 @@ var FLOATS$1 = "x y z vx vy vz yaw pitch roll wy wp wr steer".split(" ");
|
|
|
6257
6291
|
/** The ship's axes in the world: right, up and the nose, pitched and banked (mesh.ts's basis()). */
|
|
6258
6292
|
var axes = (r) => {
|
|
6259
6293
|
const [sy, cy, sp, cp, sr, cr] = [
|
|
6260
|
-
r.yaw,
|
|
6261
|
-
r.
|
|
6262
|
-
r.
|
|
6263
|
-
|
|
6294
|
+
sin$1(r.yaw),
|
|
6295
|
+
cos$1(r.yaw),
|
|
6296
|
+
sin$1(r.pitch),
|
|
6297
|
+
cos$1(r.pitch),
|
|
6298
|
+
sin$1(r.roll),
|
|
6299
|
+
cos$1(r.roll)
|
|
6300
|
+
];
|
|
6264
6301
|
const R = [
|
|
6265
6302
|
cy,
|
|
6266
6303
|
0,
|
|
@@ -6289,9 +6326,23 @@ var axes = (r) => {
|
|
|
6289
6326
|
]
|
|
6290
6327
|
];
|
|
6291
6328
|
};
|
|
6329
|
+
/** Points on the same ship share its axes until it turns. */
|
|
6330
|
+
var frames = /* @__PURE__ */ new WeakMap();
|
|
6331
|
+
var pointAxes = (r) => {
|
|
6332
|
+
const f = frames.get(r);
|
|
6333
|
+
if (f && f.yaw === r.yaw && f.pitch === r.pitch && f.roll === r.roll) return f.axes;
|
|
6334
|
+
const next = {
|
|
6335
|
+
yaw: r.yaw,
|
|
6336
|
+
pitch: r.pitch,
|
|
6337
|
+
roll: r.roll,
|
|
6338
|
+
axes: axes(r)
|
|
6339
|
+
};
|
|
6340
|
+
frames.set(r, next);
|
|
6341
|
+
return next.axes;
|
|
6342
|
+
};
|
|
6292
6343
|
/** A point of the ship, `b` m right of the centre, `u` m above it and `a` m ahead of it. */
|
|
6293
6344
|
var point = (r, b, u, a) => {
|
|
6294
|
-
const [R, U, F] =
|
|
6345
|
+
const [R, U, F] = pointAxes(r);
|
|
6295
6346
|
return [
|
|
6296
6347
|
r.x + R[0] * b + U[0] * u + F[0] * a,
|
|
6297
6348
|
r.y + R[1] * b + U[1] * u + F[1] * a,
|
|
@@ -6569,18 +6620,22 @@ var pilot = (r, i, w, others = [], crash) => {
|
|
|
6569
6620
|
WING_H
|
|
6570
6621
|
]
|
|
6571
6622
|
];
|
|
6572
|
-
for (const o of others)
|
|
6573
|
-
|
|
6574
|
-
const [
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6623
|
+
for (const o of others) {
|
|
6624
|
+
if (!nearBody(o, r.x, r.z, COLLISION_REACH + o.r)) continue;
|
|
6625
|
+
for (const [b, u, k, rad, h] of mine) {
|
|
6626
|
+
const [x, y, z] = point(r, b, u, k);
|
|
6627
|
+
const reach = rad + o.r;
|
|
6628
|
+
if (!nearBody(o, x, z, reach)) continue;
|
|
6629
|
+
const [dx, dz, oy] = gapTo(o, x, z);
|
|
6630
|
+
const d = sqrt$1(dx * dx + dz * dz);
|
|
6631
|
+
if (d >= reach - 1e-4 || oy >= y + h || oy + o.h <= y) continue;
|
|
6632
|
+
const [nx, nz] = d ? [dx / d, dz / d] : [cos$1(r.yaw), -sin$1(r.yaw)];
|
|
6633
|
+
r.x += nx * (reach - d);
|
|
6634
|
+
r.z += nz * (reach - d);
|
|
6635
|
+
const v = min$1(0, r.vx * nx + r.vz * nz) * (1 + SHIP.BOUNCE);
|
|
6636
|
+
r.vx -= v * nx;
|
|
6637
|
+
r.vz -= v * nz;
|
|
6638
|
+
}
|
|
6584
6639
|
}
|
|
6585
6640
|
}
|
|
6586
6641
|
bound(r, w);
|
|
@@ -6727,7 +6782,8 @@ var STRIKE = {
|
|
|
6727
6782
|
CUT: 2,
|
|
6728
6783
|
RAIL: 3,
|
|
6729
6784
|
LASER: 4,
|
|
6730
|
-
NADE: 5
|
|
6785
|
+
NADE: 5,
|
|
6786
|
+
DISK: 6
|
|
6731
6787
|
};
|
|
6732
6788
|
/**
|
|
6733
6789
|
* One input: the move, then the weapons. Returns what struck on this step (STRIKE), for the host to
|
|
@@ -6898,6 +6954,11 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6898
6954
|
p.shots = p.shots + 1 & 255;
|
|
6899
6955
|
return STRIKE.NADE;
|
|
6900
6956
|
}
|
|
6957
|
+
if (kit.hunter && p.wield && i.keys & KEY.SPECIAL && !(i.keys & KEY.FIRE) && !busy && !p.swing && !p.cool) {
|
|
6958
|
+
p.cool = 75;
|
|
6959
|
+
p.shots = p.shots + 1 & 255;
|
|
6960
|
+
return STRIKE.DISK;
|
|
6961
|
+
}
|
|
6901
6962
|
if (p.wield && i.keys & KEY.SPECIAL && !busy && !p.swing) {
|
|
6902
6963
|
p.cut = i.keys & KEY.FIRE ? cutOf(i.keys) + 4 : (i.keys & (KEY.LEFT | KEY.RIGHT)) === KEY.LEFT ? CUT.ARC_L : CUT.ARC_R;
|
|
6903
6964
|
[p.swing, p.charge] = [CUTS[p.cut].ticks, 0];
|
|
@@ -7196,12 +7257,6 @@ var skid = (r) => {
|
|
|
7196
7257
|
if (!r.ship) [r.vx, r.vz] = [f32(r.vx * VEHICLE.SKID), f32(r.vz * VEHICLE.SKID)];
|
|
7197
7258
|
};
|
|
7198
7259
|
/**
|
|
7199
|
-
* The vehicles' bodies as the step of `p` on foot meets them: every hull(), but for a player who
|
|
7200
|
-
* is down the wrecks' (his own vehicle's among them: he lies where it blew up, and no wreck that
|
|
7201
|
-
* moves under him bends his replay).
|
|
7202
|
-
*/
|
|
7203
|
-
var solid = (rovers, p) => rovers.filter((r) => !(p.down && r.wreck)).flatMap(hulls);
|
|
7204
|
-
/**
|
|
7205
7260
|
* The map's rovers at rest on their spawns, whole, nobody aboard, then its ships on their pads
|
|
7206
7261
|
* (ship.ts): the order of the snapshot's.
|
|
7207
7262
|
*/
|
|
@@ -7394,8 +7449,9 @@ var drive = (r, i, w, fleet = [], crash) => {
|
|
|
7394
7449
|
if (o === r) continue;
|
|
7395
7450
|
for (const h of hulls(o)) for (const a of ROVER.BODY) {
|
|
7396
7451
|
const [x, y, z] = at$1(r, a, 0, -DROP);
|
|
7397
|
-
const [dx, dz, oy] = gapTo(h, x, z);
|
|
7398
7452
|
const reach = ROVER.RB + h.r;
|
|
7453
|
+
if (!nearBody(h, x, z, reach)) continue;
|
|
7454
|
+
const [dx, dz, oy] = gapTo(h, x, z);
|
|
7399
7455
|
const d = sqrt(dx * dx + dz * dz);
|
|
7400
7456
|
if (d >= reach - 1e-4 || oy >= y + ROVER.BODY_H || oy + h.h <= y) continue;
|
|
7401
7457
|
const [ox, oz] = forward(o.yaw);
|
|
@@ -7974,10 +8030,25 @@ var squad = (team, players, flags, world) => {
|
|
|
7974
8030
|
const by = (id) => up.find((o) => o.id === id);
|
|
7975
8031
|
const ours = theirs.state === FLAG$1.CARRIED ? by(theirs.by) : void 0;
|
|
7976
8032
|
const enemy = mine.state === FLAG$1.CARRIED ? by(mine.by) : void 0;
|
|
7977
|
-
|
|
8033
|
+
let trouble;
|
|
8034
|
+
for (const o of up) if (o.team === team && o.state.hp <= LOW && (!trouble || o.state.hp < trouble.state.hp) && up.some((f) => f.team !== team && flat(f.state.x, f.state.z, o.state.x, o.state.z) < NEAR)) trouble = o;
|
|
7978
8035
|
const free = up.filter((o) => o.team === team && o.bot && o !== ours && o !== trouble).sort((a, b) => a.id - b.id);
|
|
7979
8036
|
const n = free.length;
|
|
7980
|
-
const take = (role, count, x, z, far = Infinity) =>
|
|
8037
|
+
const take = (role, count, x, z, far = Infinity) => {
|
|
8038
|
+
while (count-- > 0) {
|
|
8039
|
+
let nearest;
|
|
8040
|
+
let distance = far;
|
|
8041
|
+
for (const o of free) if (!roles.has(o.id)) {
|
|
8042
|
+
const d = flat(o.state.x, o.state.z, x, z);
|
|
8043
|
+
if (d < distance) {
|
|
8044
|
+
nearest = o;
|
|
8045
|
+
distance = d;
|
|
8046
|
+
}
|
|
8047
|
+
}
|
|
8048
|
+
if (!nearest) break;
|
|
8049
|
+
roles.set(nearest.id, role);
|
|
8050
|
+
}
|
|
8051
|
+
};
|
|
7981
8052
|
if (enemy) take("chase", ours ? Math.max(1, n - 1) : Math.ceil(n / 2), enemy.state.x, enemy.state.z);
|
|
7982
8053
|
if (mine.state === FLAG$1.DROPPED) take("return", n >= 4 ? 2 : 1, mine.x, mine.z);
|
|
7983
8054
|
if (ours) take("escort", 2, ours.state.x, ours.state.z);
|
|
@@ -8324,10 +8395,15 @@ var Bot = class {
|
|
|
8324
8395
|
}, ...others], flags, world);
|
|
8325
8396
|
const role = roles.get(me.id);
|
|
8326
8397
|
if (p.hp <= LOW && role !== "chase") {
|
|
8327
|
-
|
|
8398
|
+
let pack;
|
|
8399
|
+
let nearest = MEND;
|
|
8400
|
+
for (const q of s.packs ?? []) {
|
|
8401
|
+
const d = flat(p.x, p.z, q[0], q[2]);
|
|
8402
|
+
if (d < nearest) [pack, nearest] = [q, d];
|
|
8403
|
+
}
|
|
8328
8404
|
if (pack) {
|
|
8329
8405
|
this.why = "health";
|
|
8330
|
-
return pack
|
|
8406
|
+
return pack;
|
|
8331
8407
|
}
|
|
8332
8408
|
}
|
|
8333
8409
|
const h = role === "chase" ? holder(mine) : role === "escort" ? holder(theirs) : void 0;
|
|
@@ -8649,7 +8725,8 @@ var Bot = class {
|
|
|
8649
8725
|
fight(s, free) {
|
|
8650
8726
|
const { me, others, world, flags } = s;
|
|
8651
8727
|
const p = me.state;
|
|
8652
|
-
|
|
8728
|
+
const theirs = flags[1 - me.team];
|
|
8729
|
+
if (!p.ground || !free || theirs.state === FLAG$1.CARRIED && theirs.by === me.id) {
|
|
8653
8730
|
this.foe = -1;
|
|
8654
8731
|
return;
|
|
8655
8732
|
}
|
|
@@ -8659,25 +8736,22 @@ var Bot = class {
|
|
|
8659
8736
|
p.z
|
|
8660
8737
|
];
|
|
8661
8738
|
const carrier = flags[me.team].state === FLAG$1.CARRIED ? flags[me.team].by : -1;
|
|
8662
|
-
const theirs = flags[1 - me.team];
|
|
8663
|
-
const mates = others.filter((o) => o.team === me.team && !o.state.down).filter((o) => o.state.hp <= LOW || theirs.state === FLAG$1.CARRIED && theirs.by === o.id).map((o) => o.state);
|
|
8664
8739
|
let foe;
|
|
8665
8740
|
let best = Infinity;
|
|
8666
8741
|
for (const o of others) {
|
|
8667
8742
|
const q = o.state;
|
|
8668
8743
|
if (o.team === me.team || q.down) continue;
|
|
8669
8744
|
const d = flat(p.x, p.z, q.x, q.z);
|
|
8670
|
-
|
|
8745
|
+
if (d >= RANGE || o.id !== this.foe && d >= HEAR && Math.abs(turn(p.yaw, toward(p.x, p.z, q.x, q.z))) >= VIEW) continue;
|
|
8746
|
+
const onMate = others.some((m) => m.team === me.team && !m.state.down && (m.state.hp <= LOW || theirs.state === FLAG$1.CARRIED && theirs.by === m.id) && flat(m.state.x, m.state.z, q.x, q.z) < NEAR);
|
|
8671
8747
|
const score = o.id === carrier ? d - RANGE : onMate ? d - RANGE / 2 : d;
|
|
8672
|
-
|
|
8673
|
-
if ((o.id === this.foe || d < HEAR || ahead) && d < RANGE && score < best && !hidden(world, eye, [
|
|
8748
|
+
if (score < best && !hidden(world, eye, [
|
|
8674
8749
|
q.x,
|
|
8675
8750
|
q.y + 1.2,
|
|
8676
8751
|
q.z
|
|
8677
8752
|
])) [foe, best] = [o, score];
|
|
8678
8753
|
}
|
|
8679
|
-
|
|
8680
|
-
if (!foe || !free || carrying) {
|
|
8754
|
+
if (!foe) {
|
|
8681
8755
|
this.foe = -1;
|
|
8682
8756
|
return;
|
|
8683
8757
|
}
|
|
@@ -8721,7 +8795,7 @@ var Bot = class {
|
|
|
8721
8795
|
const shake = this.persona.shake * (1 + across / CROSS);
|
|
8722
8796
|
this.err = this.err * .94 + (this.rnd() * 2 - 1) * shake * .35;
|
|
8723
8797
|
this.errUp = this.errUp * .94 + (this.rnd() * 2 - 1) * shake * .2;
|
|
8724
|
-
const before = (s.hunters?.get(foe.id) ?? []).filter((id) => id
|
|
8798
|
+
const before = (s.hunters?.get(foe.id) ?? []).filter((id) => id < this.id).length;
|
|
8725
8799
|
const warning = (p.shots - this.shot & 255) < this.warned;
|
|
8726
8800
|
const off = !warning && before < TOKENS ? this.err : this.past * Math.atan2(PAST, Math.max(d, 1));
|
|
8727
8801
|
const want = norm(toward(p.x, p.z, tx, tz) + off);
|
|
@@ -9105,7 +9179,7 @@ var decodeInput = (buf) => {
|
|
|
9105
9179
|
};
|
|
9106
9180
|
/** Bytes of a flag on the wire, by its state. */
|
|
9107
9181
|
var flagBytes = (state) => state === FLAG$1.CARRIED ? 2 : state === FLAG$1.DROPPED ? 8 : 1;
|
|
9108
|
-
|
|
9182
|
+
function encodeSnapshot(s, meta) {
|
|
9109
9183
|
const rovers = (s.rovers ?? []).slice(0, 15);
|
|
9110
9184
|
const mid = 5 + 62 * s.players.length;
|
|
9111
9185
|
const end = mid + 57 * rovers.length;
|
|
@@ -9121,6 +9195,8 @@ var encodeSnapshot = (s) => {
|
|
|
9121
9195
|
v.setUint8(4, rovers.length);
|
|
9122
9196
|
s.players.forEach((p, i) => {
|
|
9123
9197
|
const o = 5 + i * 62;
|
|
9198
|
+
const ack = meta ? meta[i].ack : p.ack;
|
|
9199
|
+
const by = meta ? p.stun ? meta[i].by : 0 : p.by;
|
|
9124
9200
|
v.setUint8(o, p.id);
|
|
9125
9201
|
v.setFloat32(o + 1, p.x);
|
|
9126
9202
|
v.setFloat32(o + 5, p.y);
|
|
@@ -9131,12 +9207,12 @@ var encodeSnapshot = (s) => {
|
|
|
9131
9207
|
v.setFloat32(o + 25, p.edge);
|
|
9132
9208
|
v.setUint16(o + 29, toTurn(p.yaw));
|
|
9133
9209
|
v.setInt16(o + 31, toPitch(p.pitch));
|
|
9134
|
-
v.setUint16(o + 33,
|
|
9210
|
+
v.setUint16(o + 33, ack & 65535);
|
|
9135
9211
|
v.setUint8(o + 35, p.mode & 7 | (p.wall & 7) << 3 | (p.jumps & 1) << 6 | (p.dashes & 1) << 7);
|
|
9136
9212
|
v.setUint8(o + 36, p.t);
|
|
9137
|
-
v.setUint8(o + 37, p.dash | (
|
|
9213
|
+
v.setUint8(o + 37, p.dash | (by >> 2 & 3) << 6);
|
|
9138
9214
|
v.setUint8(o + 38, p.coyote & 7 | (p.buffer & 7) << 3 | (p.held & KEY.JUMP ? 64 : 0) | (p.held & KEY.DASH ? 128 : 0));
|
|
9139
|
-
v.setUint8(o + 39, p.stun | (
|
|
9215
|
+
v.setUint8(o + 39, p.stun | (by & 3) << 6);
|
|
9140
9216
|
const gun = p.hp & 7 | (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;
|
|
9141
9217
|
v.setUint8(o + 40, gun >> 16);
|
|
9142
9218
|
v.setUint16(o + 41, gun & 65535);
|
|
@@ -9210,7 +9286,7 @@ var encodeSnapshot = (s) => {
|
|
|
9210
9286
|
}
|
|
9211
9287
|
if (st) v.setUint16(o + gate - 1, st.phase & 3 | (st.team & 1) << 2 | Math.min(127, st.left) << 3);
|
|
9212
9288
|
return v.buffer;
|
|
9213
|
-
}
|
|
9289
|
+
}
|
|
9214
9290
|
/** Returns null on anything that is not a known text message. */
|
|
9215
9291
|
var parseText = (raw) => {
|
|
9216
9292
|
try {
|
|
@@ -9280,7 +9356,8 @@ var BOT_NAMES = [
|
|
|
9280
9356
|
var BOT_ROLES = [
|
|
9281
9357
|
ROLE.MARINE,
|
|
9282
9358
|
ROLE.NINJA,
|
|
9283
|
-
ROLE.XENO
|
|
9359
|
+
ROLE.XENO,
|
|
9360
|
+
ROLE.HUNTER
|
|
9284
9361
|
];
|
|
9285
9362
|
/** The two seats of a rover, the driver's first. */
|
|
9286
9363
|
var SEATS = ["driver", "rider"];
|
|
@@ -9394,8 +9471,12 @@ var Room = class {
|
|
|
9394
9471
|
gone;
|
|
9395
9472
|
/** The plasma balls in flight, and the ones that burst since the last snapshot, which sends them once more. */
|
|
9396
9473
|
balls = [];
|
|
9474
|
+
/** Last tick a Hunter's shoulder laser hit, by player id. */
|
|
9475
|
+
hunterLasers = /* @__PURE__ */ new Map();
|
|
9397
9476
|
/** The map's rovers, in the order of WorldDef.rovers, then its ships (ship.ts). */
|
|
9398
9477
|
rovers = [];
|
|
9478
|
+
/** Collision geometry reused while a vehicle's pose is unchanged. */
|
|
9479
|
+
vehicleBodies = /* @__PURE__ */ new WeakMap();
|
|
9399
9480
|
/** Ticks toward each ship's next missile, by index in `rovers`. */
|
|
9400
9481
|
rearm = [];
|
|
9401
9482
|
/** Each vehicle's damage short of a whole hp, by index in `rovers`. */
|
|
@@ -9533,7 +9614,7 @@ var Room = class {
|
|
|
9533
9614
|
}
|
|
9534
9615
|
} else {
|
|
9535
9616
|
const lying = p.state.down > 0;
|
|
9536
|
-
const struck = step(p.state, input, this.world, p.info.team, !this.ctf.over,
|
|
9617
|
+
const struck = step(p.state, input, this.world, p.info.team, !this.ctf.over, this.solids(p.state), kitOf(p.info.role, this.world.def));
|
|
9537
9618
|
this.ctf.moved(p.state);
|
|
9538
9619
|
const fall = p.state.ev & EV.LAND && !lying && !this.ctf.over ? bruise(p.state.fall) : 0;
|
|
9539
9620
|
if (fall) this.harm(p, fall);
|
|
@@ -9546,6 +9627,7 @@ var Room = class {
|
|
|
9546
9627
|
else if (struck === STRIKE.RAIL) this.rail(p, input.view);
|
|
9547
9628
|
else if (struck === STRIKE.LASER) this.shoot(p, input.view);
|
|
9548
9629
|
else if (struck === STRIKE.NADE) this.shoot(p, input.view, lob(p.state, p.info.team));
|
|
9630
|
+
else if (struck === STRIKE.DISK) this.shoot(p, input.view, disk(p.state, p.info.team));
|
|
9549
9631
|
Object.assign(p.state, here);
|
|
9550
9632
|
if (use && r && p.state.mode === MODE.RIDE) leave(p.state, r, 1, this.world);
|
|
9551
9633
|
else if (use && !this.feast(p, input.view) && !this.press(p)) this.enter(p);
|
|
@@ -9557,6 +9639,31 @@ var Room = class {
|
|
|
9557
9639
|
this.seats();
|
|
9558
9640
|
}
|
|
9559
9641
|
}
|
|
9642
|
+
/** Vehicle solids for a step; a driven vehicle can move between two players' inputs. */
|
|
9643
|
+
solids(p) {
|
|
9644
|
+
const out = [];
|
|
9645
|
+
for (const r of this.rovers) {
|
|
9646
|
+
if (p.down && r.wreck) continue;
|
|
9647
|
+
let saved = this.vehicleBodies.get(r);
|
|
9648
|
+
if (!saved || saved.ship !== r.ship || saved.pose[0] !== r.x || saved.pose[1] !== r.y || saved.pose[2] !== r.z || saved.pose[3] !== r.yaw || saved.pose[4] !== r.pitch || saved.pose[5] !== r.roll) {
|
|
9649
|
+
saved = {
|
|
9650
|
+
pose: [
|
|
9651
|
+
r.x,
|
|
9652
|
+
r.y,
|
|
9653
|
+
r.z,
|
|
9654
|
+
r.yaw,
|
|
9655
|
+
r.pitch,
|
|
9656
|
+
r.roll
|
|
9657
|
+
],
|
|
9658
|
+
ship: r.ship,
|
|
9659
|
+
bodies: hulls(r)
|
|
9660
|
+
};
|
|
9661
|
+
this.vehicleBodies.set(r, saved);
|
|
9662
|
+
}
|
|
9663
|
+
out.push(...saved.bodies);
|
|
9664
|
+
}
|
|
9665
|
+
return out;
|
|
9666
|
+
}
|
|
9560
9667
|
/** A peer left: its player goes, the roster goes out again. */
|
|
9561
9668
|
disconnect(conn) {
|
|
9562
9669
|
const p = this.peers.get(conn);
|
|
@@ -9642,18 +9749,14 @@ var Room = class {
|
|
|
9642
9749
|
while (this.history[0].tick < now - 30) this.history.shift();
|
|
9643
9750
|
const snap = encodeSnapshot({
|
|
9644
9751
|
tick: now,
|
|
9645
|
-
players: players.map((p) =>
|
|
9646
|
-
...p.state,
|
|
9647
|
-
ack: p.ack,
|
|
9648
|
-
by: p.state.stun ? p.by : 0
|
|
9649
|
-
})),
|
|
9752
|
+
players: players.map((p) => p.state),
|
|
9650
9753
|
...this.ctf.wire(),
|
|
9651
9754
|
packs: this.gone.reduce((m, t, k) => t ? m : m + 2 ** k, 0),
|
|
9652
9755
|
balls: this.balls,
|
|
9653
9756
|
rovers: this.rovers,
|
|
9654
9757
|
doors: this.world.doors?.map((d) => d.open),
|
|
9655
9758
|
station: this.world.def.station && this.station.wire()
|
|
9656
|
-
});
|
|
9759
|
+
}, players);
|
|
9657
9760
|
players.forEach((p) => p.conn.send(snap));
|
|
9658
9761
|
this.balls = this.balls.filter((b) => !b.burst && b.left > 0);
|
|
9659
9762
|
}
|
|
@@ -9890,7 +9993,8 @@ var Room = class {
|
|
|
9890
9993
|
* against the others as they are now. Past PLASMA_MAX balls in flight, the oldest bursts. A
|
|
9891
9994
|
* grenade (lob()) is flown on the same way, a tick of its arc at a time.
|
|
9892
9995
|
*/
|
|
9893
|
-
shoot(p, view = 0, b
|
|
9996
|
+
shoot(p, view = 0, b) {
|
|
9997
|
+
b ??= launch$1(p.state, p.info.team, this.kit(p).hunter);
|
|
9894
9998
|
const lag = (this.ticks - view + 65536) % 65536;
|
|
9895
9999
|
this.balls.push(b);
|
|
9896
10000
|
const ticks = Math.min(lag < 32768 ? lag : 0, 12);
|
|
@@ -9916,6 +10020,31 @@ var Room = class {
|
|
|
9916
10020
|
b.y,
|
|
9917
10021
|
b.z
|
|
9918
10022
|
];
|
|
10023
|
+
if (b.returning || b.power === 10) {
|
|
10024
|
+
if (!by) {
|
|
10025
|
+
b.burst = true;
|
|
10026
|
+
return;
|
|
10027
|
+
}
|
|
10028
|
+
const delta = [
|
|
10029
|
+
by.state.x,
|
|
10030
|
+
by.state.y + eyeHeight(by.state),
|
|
10031
|
+
by.state.z
|
|
10032
|
+
].map((v, i) => v - o[i]);
|
|
10033
|
+
const distance = Math.hypot(...delta);
|
|
10034
|
+
if (distance < .65) {
|
|
10035
|
+
b.burst = true;
|
|
10036
|
+
return;
|
|
10037
|
+
}
|
|
10038
|
+
[b.dx, b.dy, b.dz] = delta.map((v) => v / distance);
|
|
10039
|
+
const travel = Math.min(distance, 52 / 60);
|
|
10040
|
+
[b.x, b.y, b.z] = [
|
|
10041
|
+
o[0] + b.dx * travel,
|
|
10042
|
+
o[1] + b.dy * travel,
|
|
10043
|
+
o[2] + b.dz * travel
|
|
10044
|
+
];
|
|
10045
|
+
b.power = 10;
|
|
10046
|
+
return;
|
|
10047
|
+
}
|
|
9919
10048
|
if (b.power === 7) {
|
|
9920
10049
|
toss(this.world, b, foes.map((f) => f.state));
|
|
9921
10050
|
this.ram(b, o);
|
|
@@ -9928,6 +10057,14 @@ var Room = class {
|
|
|
9928
10057
|
return;
|
|
9929
10058
|
}
|
|
9930
10059
|
const hit = fly(this.world, b, m, foes.map((f) => f.state));
|
|
10060
|
+
const turnDiskBack = () => {
|
|
10061
|
+
if (b.power === 9 && (b.burst || b.left <= 0)) {
|
|
10062
|
+
b.returning = true;
|
|
10063
|
+
b.power = 10;
|
|
10064
|
+
b.burst = false;
|
|
10065
|
+
b.left = 1;
|
|
10066
|
+
}
|
|
10067
|
+
};
|
|
9931
10068
|
const hull = this.ram(b, o);
|
|
9932
10069
|
if (hull) {
|
|
9933
10070
|
if (by) by.state.hits = by.state.hits + 1 & 255;
|
|
@@ -9935,17 +10072,26 @@ var Room = class {
|
|
|
9935
10072
|
const w = this.wear[this.rovers.indexOf(hull)];
|
|
9936
10073
|
w.graze = (w.graze + 1) % (b.power === 6 ? BOLT_GRAZE : VEHICLE.GRAZE);
|
|
9937
10074
|
if (!w.graze) this.hurt(hull, 1, b.by, b.team);
|
|
9938
|
-
} else
|
|
10075
|
+
} else if (b.power === 8) this.hurt(hull, 1, b.by, b.team);
|
|
10076
|
+
else if (b.power === 9) this.hurt(hull, 1, b.by, b.team);
|
|
10077
|
+
else this.hurt(hull, b.arc ? CUTS[b.arc].hp : b.power ?? 1, b.by, b.team);
|
|
10078
|
+
turnDiskBack();
|
|
9939
10079
|
return;
|
|
9940
10080
|
}
|
|
9941
10081
|
const foe = foes.find((q) => q.state === hit);
|
|
9942
|
-
if (!foe)
|
|
10082
|
+
if (!foe) {
|
|
10083
|
+
turnDiskBack();
|
|
10084
|
+
return;
|
|
10085
|
+
}
|
|
9943
10086
|
if (fends(foe.state, b) && roll(this.ticks, b.by, b.id, foe.info.id) < this.kit(foe).parry) {
|
|
9944
10087
|
this.deflect(foe, b);
|
|
10088
|
+
turnDiskBack();
|
|
9945
10089
|
return;
|
|
9946
10090
|
}
|
|
9947
10091
|
if (by) by.state.hits = by.state.hits + 1 & 255;
|
|
9948
10092
|
if (b.power === 6) this.shot(foe, BOLT_HP, by, b.dx, b.dz);
|
|
10093
|
+
else if (b.power === 8) this.shot(foe, 2, by, b.dx, b.dz, FRAG.GUN, b.back);
|
|
10094
|
+
else if (b.power === 9) this.shot(foe, 2, by, b.dx, b.dz, FRAG.GUN, b.back);
|
|
9949
10095
|
else if (b.power === 0) {
|
|
9950
10096
|
foe.graze = ((foe.graze ?? 0) + 1) % 2;
|
|
9951
10097
|
if (!foe.graze) this.shot(foe, 1, by, b.dx, b.dz, FRAG.GUN, b.back);
|
|
@@ -9969,6 +10115,7 @@ var Room = class {
|
|
|
9969
10115
|
foe.by = b.by;
|
|
9970
10116
|
this.ctf.drop(foe.state);
|
|
9971
10117
|
}
|
|
10118
|
+
turnDiskBack();
|
|
9972
10119
|
}
|
|
9973
10120
|
/**
|
|
9974
10121
|
* The katana of `p` met the ball `b`: it ends on the blade (its burst, no hit), and one as strong
|
|
@@ -10095,6 +10242,10 @@ var Room = class {
|
|
|
10095
10242
|
* and counts a hit. An enemy vehicle's hull is drained the same way, and shields who is behind it.
|
|
10096
10243
|
*/
|
|
10097
10244
|
rail(p, view) {
|
|
10245
|
+
if (this.kit(p).hunter) {
|
|
10246
|
+
this.shoulder(p, view);
|
|
10247
|
+
return;
|
|
10248
|
+
}
|
|
10098
10249
|
const { o, d, t, hit } = beam(this.world, p.state, this.enemies(p, view));
|
|
10099
10250
|
const [s, k] = this.hulls(p.info.team, view).reduce((best, [r, n]) => {
|
|
10100
10251
|
const u = struck(r, o, d, best[0]);
|
|
@@ -10126,6 +10277,56 @@ var Room = class {
|
|
|
10126
10277
|
}
|
|
10127
10278
|
}
|
|
10128
10279
|
}
|
|
10280
|
+
/** A lightly assisted shoulder shot: host-side target selection stays inside a narrow forward cone. */
|
|
10281
|
+
shoulder(p, view) {
|
|
10282
|
+
const foes = this.enemies(p, view);
|
|
10283
|
+
const origin = [
|
|
10284
|
+
p.state.x,
|
|
10285
|
+
p.state.y + eyeHeight(p.state),
|
|
10286
|
+
p.state.z
|
|
10287
|
+
];
|
|
10288
|
+
const cp = Math.cos(p.state.pitch);
|
|
10289
|
+
const look = [
|
|
10290
|
+
-Math.sin(p.state.yaw) * cp,
|
|
10291
|
+
Math.sin(p.state.pitch),
|
|
10292
|
+
-Math.cos(p.state.yaw) * cp
|
|
10293
|
+
];
|
|
10294
|
+
let target;
|
|
10295
|
+
let best = .985;
|
|
10296
|
+
for (const foe of foes) {
|
|
10297
|
+
const point = [
|
|
10298
|
+
foe.x,
|
|
10299
|
+
foe.y + eyeHeight(foe) * .65,
|
|
10300
|
+
foe.z
|
|
10301
|
+
];
|
|
10302
|
+
const delta = point.map((v, i) => v - origin[i]);
|
|
10303
|
+
const distance = Math.hypot(...delta);
|
|
10304
|
+
const alignment = distance ? delta.reduce((sum, v, i) => sum + v / distance * look[i], 0) : 1;
|
|
10305
|
+
if (distance < 80 && alignment > best && !hidden(this.world, origin, point)) {
|
|
10306
|
+
best = alignment;
|
|
10307
|
+
target = foe;
|
|
10308
|
+
}
|
|
10309
|
+
}
|
|
10310
|
+
if (!target || this.ticks - (this.hunterLasers.get(p.info.id) ?? -Infinity) < 18) return;
|
|
10311
|
+
const delta = [
|
|
10312
|
+
target.x,
|
|
10313
|
+
target.y + eyeHeight(target) * .65,
|
|
10314
|
+
target.z
|
|
10315
|
+
].map((v, i) => v - origin[i]);
|
|
10316
|
+
const distance = Math.hypot(...delta) || 1;
|
|
10317
|
+
const yaw = Math.atan2(-delta[0], -delta[2]);
|
|
10318
|
+
const pitch = Math.asin(delta[1] / distance);
|
|
10319
|
+
const aimed = beam(this.world, {
|
|
10320
|
+
...p.state,
|
|
10321
|
+
yaw,
|
|
10322
|
+
pitch
|
|
10323
|
+
}, [target]);
|
|
10324
|
+
if (aimed.hit?.id !== target.id) return;
|
|
10325
|
+
this.hunterLasers.set(p.info.id, this.ticks);
|
|
10326
|
+
p.state.hits = p.state.hits + 1 & 255;
|
|
10327
|
+
const foe = this.players().find((q) => q.info.id === target.id);
|
|
10328
|
+
if (foe) this.shot(foe, 1, p, aimed.d[0], aimed.d[2]);
|
|
10329
|
+
}
|
|
10129
10330
|
/** 1 hp of the bolt's drain to `foe`, as his railer deals it; if it puts him down he is disintegrated (`fried`). */
|
|
10130
10331
|
fry(foe) {
|
|
10131
10332
|
const r = foe.railer?.state ?? foe.state;
|
|
@@ -10271,7 +10472,7 @@ var Room = class {
|
|
|
10271
10472
|
kit.gear && (q.armor ?? 0) < 3
|
|
10272
10473
|
][kind];
|
|
10273
10474
|
};
|
|
10274
|
-
const p = players.find((o) => !o.state.down &&
|
|
10475
|
+
const p = players.find((o) => !o.state.down && within(o.state, at, .9) && wants(o));
|
|
10275
10476
|
if (p) {
|
|
10276
10477
|
const q = p.state;
|
|
10277
10478
|
const kit = kitOf(p.info.role, this.world.def);
|
|
@@ -10645,9 +10846,13 @@ var Room = class {
|
|
|
10645
10846
|
const errands = this.errands(players);
|
|
10646
10847
|
const squads = [0, 1].map((team) => squad(team, others, this.ctf.flags, this.world));
|
|
10647
10848
|
const hunters = /* @__PURE__ */ new Map();
|
|
10648
|
-
for (const p of players) if (p.bot && p.bot.hunting >= 0)
|
|
10649
|
-
|
|
10650
|
-
|
|
10849
|
+
for (const p of players) if (p.bot && p.bot.hunting >= 0) {
|
|
10850
|
+
const ids = hunters.get(p.bot.hunting);
|
|
10851
|
+
if (ids) ids.push(p.info.id);
|
|
10852
|
+
else hunters.set(p.bot.hunting, [p.info.id]);
|
|
10853
|
+
}
|
|
10854
|
+
for (const [index, p] of players.entries()) if (p.bot) {
|
|
10855
|
+
const me = others[index];
|
|
10651
10856
|
const i = p.bot.think({
|
|
10652
10857
|
me,
|
|
10653
10858
|
others: others.filter((o) => o !== me),
|
|
@@ -10661,13 +10866,15 @@ var Room = class {
|
|
|
10661
10866
|
squad: squads[p.info.team]
|
|
10662
10867
|
});
|
|
10663
10868
|
p.seq = (p.seq ?? -1) + 1 & 65535;
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10869
|
+
if (this.ticks % WATCH === 0) {
|
|
10870
|
+
const watchers = players.filter((q) => q.watch === p.info.id);
|
|
10871
|
+
if (watchers.length) {
|
|
10872
|
+
const text = JSON.stringify({
|
|
10873
|
+
t: "bot",
|
|
10874
|
+
...p.bot.view()
|
|
10875
|
+
});
|
|
10876
|
+
watchers.forEach((q) => q.conn.send(text));
|
|
10877
|
+
}
|
|
10671
10878
|
}
|
|
10672
10879
|
this.apply(p, onWire({
|
|
10673
10880
|
...i,
|