@korial29/tiny-fps 0.199.1 → 0.200.1
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 +49 -49
- package/dist/local.js +1 -1
- package/dist/server.js +146 -79
- package/dist/types/client/soldier.d.ts +2 -0
- package/dist/types/shared/bot.d.ts +5 -0
- package/dist/types/shared/moon.d.ts +1 -1
- package/dist/types/shared/world.d.ts +3 -3
- package/package.json +2 -1
package/dist/server.js
CHANGED
|
@@ -2338,15 +2338,6 @@ var half$1 = [
|
|
|
2338
2338
|
27.1,
|
|
2339
2339
|
229.6
|
|
2340
2340
|
], TEX.CONCRETE),
|
|
2341
|
-
box$2([
|
|
2342
|
-
24.5,
|
|
2343
|
-
26,
|
|
2344
|
-
215
|
|
2345
|
-
], [
|
|
2346
|
-
35,
|
|
2347
|
-
27.5,
|
|
2348
|
-
219
|
|
2349
|
-
], TEX.STEEL, TEX.PAINT, RED$1),
|
|
2350
2341
|
roof$1(6, 164, 26, 201, 26, TEX.GLASS),
|
|
2351
2342
|
roof$1(6, 134, 26, 147, 26, TEX.GLASS),
|
|
2352
2343
|
roof$1(6, 201, 26, 212, 19),
|
|
@@ -2920,23 +2911,23 @@ var HIGHLINE = {
|
|
|
2920
2911
|
spawns: row(0, 236, 231),
|
|
2921
2912
|
rack: [
|
|
2922
2913
|
30.75,
|
|
2923
|
-
|
|
2914
|
+
26,
|
|
2924
2915
|
217
|
|
2925
2916
|
],
|
|
2926
2917
|
blade: [
|
|
2927
|
-
|
|
2928
|
-
|
|
2918
|
+
38,
|
|
2919
|
+
26,
|
|
2929
2920
|
217
|
|
2930
2921
|
],
|
|
2931
2922
|
rail: [
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2923
|
+
18,
|
|
2924
|
+
26,
|
|
2925
|
+
137
|
|
2935
2926
|
],
|
|
2936
2927
|
rifle: [
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2928
|
+
48,
|
|
2929
|
+
19,
|
|
2930
|
+
156
|
|
2940
2931
|
]
|
|
2941
2932
|
}, {
|
|
2942
2933
|
base: [
|
|
@@ -2947,23 +2938,23 @@ var HIGHLINE = {
|
|
|
2947
2938
|
spawns: row(Math.PI, 4, 9),
|
|
2948
2939
|
rack: [
|
|
2949
2940
|
30.75,
|
|
2950
|
-
|
|
2941
|
+
26,
|
|
2951
2942
|
23
|
|
2952
2943
|
],
|
|
2953
2944
|
blade: [
|
|
2954
|
-
|
|
2955
|
-
|
|
2945
|
+
38,
|
|
2946
|
+
26,
|
|
2956
2947
|
23
|
|
2957
2948
|
],
|
|
2958
2949
|
rail: [
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2950
|
+
18,
|
|
2951
|
+
26,
|
|
2952
|
+
103
|
|
2962
2953
|
],
|
|
2963
2954
|
rifle: [
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2955
|
+
48,
|
|
2956
|
+
19,
|
|
2957
|
+
84
|
|
2967
2958
|
]
|
|
2968
2959
|
}],
|
|
2969
2960
|
packs: [
|
|
@@ -3890,7 +3881,7 @@ var MOUNDS = [48, 144];
|
|
|
3890
3881
|
var [MOUND, RISE] = [3, 8];
|
|
3891
3882
|
/**
|
|
3892
3883
|
* Where the field stays flat at y 0, x0, z0, x1, z1 with z from the centre line: the landing pad,
|
|
3893
|
-
* the dome
|
|
3884
|
+
* the dome and the spawns, the modules and tubes, the two rovers, the packs on the
|
|
3894
3885
|
* floor, the run-up to each mound. The relief is 0 for 6 m round each (so the lattice's
|
|
3895
3886
|
* triangles are level over it) and back to itself 6 m further. The lips need none: the field
|
|
3896
3887
|
* starts 12 m behind them.
|
|
@@ -4238,6 +4229,7 @@ var at$2 = (x, z) => {
|
|
|
4238
4229
|
const soft = 10 * sm((k - 1) / .1);
|
|
4239
4230
|
w = (w + crest - Math.sqrt((w - crest) * (w - crest) + soft * soft)) / 2 * (1 - sm((k - 1.3) / .35));
|
|
4240
4231
|
}
|
|
4232
|
+
h *= 1 - .55 * sm((16 - far(x - 44, z - 122)) / 10);
|
|
4241
4233
|
return Math.max(h, -14.5) + w;
|
|
4242
4234
|
};
|
|
4243
4235
|
/** How high a rock's middle is over the ground: three tenths of its height, and 0.6 m or half its height if less. Its widest is there, its flank steep down to the ground: a body is stopped at its foot. */
|
|
@@ -4723,7 +4715,6 @@ var half = [
|
|
|
4723
4715
|
...box$1(75.75, .5, FLAG - 4.25, 84.25, 1, FLAG + 4.25, PAINT, CONCRETE, RED),
|
|
4724
4716
|
ghost: true
|
|
4725
4717
|
},
|
|
4726
|
-
box$1(60, 0, 259, 70, 1.5, 265, STEEL, PAINT, RED),
|
|
4727
4718
|
...PADS.map(([x, z, r]) => box$1(x - r, 0, z - r, x + r, .25, z + r, METAL)),
|
|
4728
4719
|
...MASTS.map(([x, z]) => box$1(x - .2, 0, z - .2, x + .2, 10, z + .2, STEEL)),
|
|
4729
4720
|
box$1(12, -30, 148 - 2.5 / 2, 24, 0, 148, PAINT, STONE, [
|
|
@@ -4781,26 +4772,37 @@ var SPAWNS = [...[
|
|
|
4781
4772
|
267,
|
|
4782
4773
|
0
|
|
4783
4774
|
])];
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4775
|
+
var team = (z, s) => {
|
|
4776
|
+
const side = (p) => z > 140 ? p : flipPoint(p);
|
|
4777
|
+
return {
|
|
4778
|
+
base: [
|
|
4779
|
+
80,
|
|
4780
|
+
1,
|
|
4781
|
+
z
|
|
4782
|
+
],
|
|
4783
|
+
spawns: s,
|
|
4784
|
+
rack: side([
|
|
4785
|
+
66,
|
|
4786
|
+
0,
|
|
4787
|
+
262
|
|
4788
|
+
]),
|
|
4789
|
+
blade: side([
|
|
4790
|
+
94,
|
|
4791
|
+
0,
|
|
4792
|
+
262
|
|
4793
|
+
]),
|
|
4794
|
+
rifle: side([
|
|
4795
|
+
145,
|
|
4796
|
+
0,
|
|
4797
|
+
191
|
|
4798
|
+
]),
|
|
4799
|
+
rail: side([
|
|
4800
|
+
43,
|
|
4801
|
+
0,
|
|
4802
|
+
158
|
|
4803
|
+
])
|
|
4804
|
+
};
|
|
4805
|
+
};
|
|
4804
4806
|
/** The orbital station (station.ts): over the rille, between the edge of space and the ceiling. */
|
|
4805
4807
|
var [STATION_BRUSHES, STATION_DEF, STATION_DOOR] = station(80, 600, 140);
|
|
4806
4808
|
var MOON = {
|
|
@@ -7874,7 +7876,7 @@ var Sortie = class {
|
|
|
7874
7876
|
}
|
|
7875
7877
|
};
|
|
7876
7878
|
// src/shared/bot.ts
|
|
7877
|
-
var { FORWARD, BACK, LEFT, RIGHT, JUMP, SPRINT, DASH, CROUCH, FIRE,
|
|
7879
|
+
var { FORWARD, BACK, LEFT, RIGHT, JUMP, SPRINT, DASH, CROUCH, FIRE, BLADE, SPECIAL } = KEY;
|
|
7878
7880
|
/** How far a bot shoots, metres, and how far it sees an enemy to fight. */
|
|
7879
7881
|
var RANGE = 35;
|
|
7880
7882
|
/** Radians off the target a bot still shoots. */
|
|
@@ -8100,6 +8102,10 @@ var Bot = class {
|
|
|
8100
8102
|
/** The goal of the way, and the tick it was planned. */
|
|
8101
8103
|
goal;
|
|
8102
8104
|
planned = 0;
|
|
8105
|
+
/** Tick of the last grounded rack search, and the path to its chosen rack. */
|
|
8106
|
+
rackChecked = -120;
|
|
8107
|
+
rackTarget;
|
|
8108
|
+
rackSteps;
|
|
8103
8109
|
/** The step it is on; steps.length once there. */
|
|
8104
8110
|
step = 0;
|
|
8105
8111
|
flight;
|
|
@@ -8123,6 +8129,7 @@ var Bot = class {
|
|
|
8123
8129
|
/** Its shot count when it met the target, the shots it fires past him first, and to which side. */
|
|
8124
8130
|
shot = 0;
|
|
8125
8131
|
warned = 0;
|
|
8132
|
+
railWarnings = 0;
|
|
8126
8133
|
past = 1;
|
|
8127
8134
|
/** A guard's flag and round, the point it goes to, the tick it leaves it, and where it looks there. */
|
|
8128
8135
|
base;
|
|
@@ -8175,8 +8182,11 @@ var Bot = class {
|
|
|
8175
8182
|
}
|
|
8176
8183
|
/** The input of this tick. */
|
|
8177
8184
|
think(s) {
|
|
8178
|
-
const
|
|
8179
|
-
|
|
8185
|
+
const p = s.me.state;
|
|
8186
|
+
const weapon = p.down ? 0 : s.kit?.katana && p.blade ? BLADE : (p.rail ?? 0) > 0 ? KEY.RAIL : (p.rifle ?? 0) > 0 ? KEY.RIFLE : p.ammo < 0 && p.blade ? BLADE : 0;
|
|
8187
|
+
if (this.foe >= 0 && this.keys & FIRE && p.zapping) this.railWarnings++;
|
|
8188
|
+
const i = this.decide(s, weapon);
|
|
8189
|
+
i.keys |= weapon;
|
|
8180
8190
|
this.keys = i.keys;
|
|
8181
8191
|
return i;
|
|
8182
8192
|
}
|
|
@@ -8203,14 +8213,15 @@ var Bot = class {
|
|
|
8203
8213
|
};
|
|
8204
8214
|
}
|
|
8205
8215
|
/** think()'s work. */
|
|
8206
|
-
decide(s) {
|
|
8216
|
+
decide(s, weapon) {
|
|
8207
8217
|
const t = ++this.ticks;
|
|
8208
8218
|
const p = s.me.state;
|
|
8209
8219
|
this.hunting = -1;
|
|
8210
8220
|
this.world = s.world;
|
|
8211
8221
|
this.steer = !!s.kit && s.kit.jump !== 7;
|
|
8212
8222
|
if (p.down) {
|
|
8213
|
-
this.goal = void 0;
|
|
8223
|
+
this.goal = this.rackTarget = void 0;
|
|
8224
|
+
this.rackChecked = -120;
|
|
8214
8225
|
this.foe = -1;
|
|
8215
8226
|
return {
|
|
8216
8227
|
keys: 0,
|
|
@@ -8218,11 +8229,14 @@ var Bot = class {
|
|
|
8218
8229
|
pitch: 0
|
|
8219
8230
|
};
|
|
8220
8231
|
}
|
|
8221
|
-
if (p.ev & EV.RESPAWN || flat(p.x, p.z, this.last[0], this.last[2]) > 5)
|
|
8232
|
+
if (p.ev & EV.RESPAWN || flat(p.x, p.z, this.last[0], this.last[2]) > 5) {
|
|
8233
|
+
this.goal = this.rackTarget = void 0;
|
|
8234
|
+
this.rackChecked = -120;
|
|
8235
|
+
}
|
|
8222
8236
|
this.last = at(p);
|
|
8223
8237
|
if (s.errand) {
|
|
8224
8238
|
const e = this.sortie.think(this.id, p, s.errand, t);
|
|
8225
|
-
const f = e && s.errand.go === "guard" && !e.keys ? this.fight(s, true) : void 0;
|
|
8239
|
+
const f = e && s.errand.go === "guard" && !e.keys ? this.fight(s, true, weapon) : void 0;
|
|
8226
8240
|
if (f) return {
|
|
8227
8241
|
keys: f.keys,
|
|
8228
8242
|
yaw: this.aim,
|
|
@@ -8240,17 +8254,16 @@ var Bot = class {
|
|
|
8240
8254
|
yaw: p.yaw,
|
|
8241
8255
|
pitch: 0
|
|
8242
8256
|
};
|
|
8243
|
-
if (p.ground && (!this.goal || flat(goal[0], goal[2], this.goal[0], this.goal[2]) > Math.max(DRIFT, SHARE * flat(p.x, p.z, goal[0], goal[2])) || !this.steps.some((st) => st.leg) && t - this.planned > REPLAN)) this.plan(s.world, p, goal);
|
|
8257
|
+
if (p.ground && (!this.goal || !!this.rackSteps || flat(goal[0], goal[2], this.goal[0], this.goal[2]) > Math.max(DRIFT, SHARE * flat(p.x, p.z, goal[0], goal[2])) || !this.steps.some((st) => st.leg) && t - this.planned > REPLAN)) this.plan(s.world, p, goal);
|
|
8244
8258
|
const move = this.pilot(p);
|
|
8245
|
-
const fight = this.fight(s, move.free);
|
|
8246
|
-
const reload = p.ammo > 0 && !p.mag && !p.reload && t & 1 ? RELOAD : 0;
|
|
8259
|
+
const fight = this.fight(s, move.free, weapon);
|
|
8247
8260
|
if (!fight) {
|
|
8248
8261
|
this.pitch = 0;
|
|
8249
8262
|
const runs = s.flags[1 - s.me.team].state === FLAG$1.CARRIED && s.flags[1 - s.me.team].by === s.me.id;
|
|
8250
8263
|
if (move.exact || runs) {
|
|
8251
8264
|
this.look = this.aim = move.yaw;
|
|
8252
8265
|
return this.evade(s, {
|
|
8253
|
-
keys: move.keys
|
|
8266
|
+
keys: move.keys,
|
|
8254
8267
|
yaw: move.yaw,
|
|
8255
8268
|
pitch: 0
|
|
8256
8269
|
}, move.exact);
|
|
@@ -8259,7 +8272,7 @@ var Bot = class {
|
|
|
8259
8272
|
this.look = this.aim = norm(this.look + Math.max(-.2, Math.min(WALK_TURN, off)));
|
|
8260
8273
|
const keys = Math.abs(off) > SWING && move.keys & FORWARD ? move.keys & ~(FORWARD | SPRINT | DASH) | keysFor(this.look, move.yaw) : move.keys;
|
|
8261
8274
|
return this.evade(s, {
|
|
8262
|
-
keys
|
|
8275
|
+
keys,
|
|
8263
8276
|
yaw: this.look,
|
|
8264
8277
|
pitch: 0
|
|
8265
8278
|
}, false);
|
|
@@ -8272,7 +8285,7 @@ var Bot = class {
|
|
|
8272
8285
|
};
|
|
8273
8286
|
const keys = move.keys & ~(FORWARD | BACK | LEFT | RIGHT | SPRINT);
|
|
8274
8287
|
const out = {
|
|
8275
|
-
keys: (move.keys & FORWARD ? keysFor(this.aim, move.yaw) : 0) & ~(LEFT | RIGHT) | this.dodge(s.world, p) | keys | fight.keys
|
|
8288
|
+
keys: (move.keys & FORWARD ? keysFor(this.aim, move.yaw) : 0) & ~(LEFT | RIGHT) | this.dodge(s.world, p) | keys | fight.keys,
|
|
8276
8289
|
yaw: this.aim,
|
|
8277
8290
|
pitch: this.pitch
|
|
8278
8291
|
};
|
|
@@ -8371,10 +8384,6 @@ var Bot = class {
|
|
|
8371
8384
|
return this.sortie.board;
|
|
8372
8385
|
}
|
|
8373
8386
|
const gear = s.kit?.gear ?? true;
|
|
8374
|
-
if (p.ammo < 0 && gear && !s.kit?.katana && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) {
|
|
8375
|
-
this.why = "gun rack";
|
|
8376
|
-
return home.rack;
|
|
8377
|
-
}
|
|
8378
8387
|
const eye = [
|
|
8379
8388
|
p.x,
|
|
8380
8389
|
p.y + eyeHeight(p),
|
|
@@ -8423,6 +8432,58 @@ var Bot = class {
|
|
|
8423
8432
|
this.why = "help";
|
|
8424
8433
|
return at(trouble.state);
|
|
8425
8434
|
}
|
|
8435
|
+
if (p.ammo <= 0 && (p.rail ?? 0) <= 0 && (p.rifle ?? 0) <= 0 && !p.rack && gear && !s.kit?.katana && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) {
|
|
8436
|
+
this.why = "gun rack";
|
|
8437
|
+
return home.rack;
|
|
8438
|
+
}
|
|
8439
|
+
if (gear && !s.kit?.katana && role === "attack") {
|
|
8440
|
+
const choices = [
|
|
8441
|
+
[
|
|
8442
|
+
home.rail,
|
|
8443
|
+
(p.rail ?? -1) < 0,
|
|
8444
|
+
"rail rack"
|
|
8445
|
+
],
|
|
8446
|
+
[
|
|
8447
|
+
home.rifle,
|
|
8448
|
+
(p.rifle ?? -1) < 0,
|
|
8449
|
+
"rifle rack"
|
|
8450
|
+
],
|
|
8451
|
+
[
|
|
8452
|
+
home.blade,
|
|
8453
|
+
!p.blade,
|
|
8454
|
+
"katana rack"
|
|
8455
|
+
]
|
|
8456
|
+
];
|
|
8457
|
+
const current = choices.find(([point, missing]) => missing && point && point === this.rackTarget);
|
|
8458
|
+
if (current && this.goal === this.rackTarget) {
|
|
8459
|
+
this.why = current[2];
|
|
8460
|
+
return this.rackTarget;
|
|
8461
|
+
}
|
|
8462
|
+
if (p.ground && this.ticks - this.rackChecked >= REPLAN / 4) {
|
|
8463
|
+
const from = at(p);
|
|
8464
|
+
this.rackTarget = void 0;
|
|
8465
|
+
this.rackChecked = this.ticks;
|
|
8466
|
+
let nearest = 14;
|
|
8467
|
+
for (const [point, missing, why] of choices) {
|
|
8468
|
+
if (!point || !missing || flat(p.x, p.z, point[0], point[2]) >= nearest) continue;
|
|
8469
|
+
const steps = path(navOf(world), world, from, point);
|
|
8470
|
+
if (steps.at(-1)?.to !== point) continue;
|
|
8471
|
+
let length = 0;
|
|
8472
|
+
let last = from;
|
|
8473
|
+
for (const { to } of steps) {
|
|
8474
|
+
length += Math.hypot(to[0] - last[0], to[1] - last[1], to[2] - last[2]);
|
|
8475
|
+
last = to;
|
|
8476
|
+
}
|
|
8477
|
+
if (length < nearest) {
|
|
8478
|
+
nearest = length;
|
|
8479
|
+
this.rackTarget = point;
|
|
8480
|
+
this.rackSteps = steps;
|
|
8481
|
+
this.why = why;
|
|
8482
|
+
}
|
|
8483
|
+
}
|
|
8484
|
+
if (this.rackTarget) return this.rackTarget;
|
|
8485
|
+
}
|
|
8486
|
+
}
|
|
8426
8487
|
if (role === "guard") {
|
|
8427
8488
|
this.why = "guard";
|
|
8428
8489
|
return this.patrol(world, p, home.base, world.def.teams[1 - team].base);
|
|
@@ -8457,8 +8518,9 @@ var Bot = class {
|
|
|
8457
8518
|
plan(w, p, goal) {
|
|
8458
8519
|
this.goal = goal;
|
|
8459
8520
|
this.planned = this.ticks;
|
|
8460
|
-
const prefer = this.why === "flag home" && !this.steer ? -1 : this.prefer;
|
|
8461
|
-
this.steps = path(navOf(w), w, at(p), goal, prefer);
|
|
8521
|
+
const prefer = this.why === "flag home" && !this.steer || this.why.endsWith(" rack") ? -1 : this.prefer;
|
|
8522
|
+
this.steps = this.rackSteps ?? path(navOf(w), w, at(p), goal, prefer);
|
|
8523
|
+
this.rackSteps = void 0;
|
|
8462
8524
|
this.step = 0;
|
|
8463
8525
|
this.flight = void 0;
|
|
8464
8526
|
this.best = Infinity;
|
|
@@ -8722,7 +8784,7 @@ var Bot = class {
|
|
|
8722
8784
|
return this.pilot(p);
|
|
8723
8785
|
}
|
|
8724
8786
|
/** The look and the trigger at the enemy to fight now, if any. */
|
|
8725
|
-
fight(s, free) {
|
|
8787
|
+
fight(s, free, weapon) {
|
|
8726
8788
|
const { me, others, world, flags } = s;
|
|
8727
8789
|
const p = me.state;
|
|
8728
8790
|
const theirs = flags[1 - me.team];
|
|
@@ -8735,6 +8797,9 @@ var Bot = class {
|
|
|
8735
8797
|
p.y + eyeHeight(p),
|
|
8736
8798
|
p.z
|
|
8737
8799
|
];
|
|
8800
|
+
const rail = weapon === KEY.RAIL;
|
|
8801
|
+
const rifle = weapon === KEY.RIFLE;
|
|
8802
|
+
const range = rail ? 30 : rifle ? 60 : RANGE;
|
|
8738
8803
|
const carrier = flags[me.team].state === FLAG$1.CARRIED ? flags[me.team].by : -1;
|
|
8739
8804
|
let foe;
|
|
8740
8805
|
let best = Infinity;
|
|
@@ -8742,9 +8807,9 @@ var Bot = class {
|
|
|
8742
8807
|
const q = o.state;
|
|
8743
8808
|
if (o.team === me.team || q.down) continue;
|
|
8744
8809
|
const d = flat(p.x, p.z, q.x, q.z);
|
|
8745
|
-
if (d >=
|
|
8810
|
+
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
8811
|
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);
|
|
8747
|
-
const score = o.id === carrier ? d -
|
|
8812
|
+
const score = o.id === carrier ? d - range : onMate ? d - range / 2 : d;
|
|
8748
8813
|
if (score < best && !hidden(world, eye, [
|
|
8749
8814
|
q.x,
|
|
8750
8815
|
q.y + 1.2,
|
|
@@ -8767,16 +8832,17 @@ var Bot = class {
|
|
|
8767
8832
|
0
|
|
8768
8833
|
];
|
|
8769
8834
|
const known = this.ticks - (this.met.get(foe.id) ?? -180) < MEMORY;
|
|
8770
|
-
[this.shot, this.warned, this.past] = [
|
|
8835
|
+
[this.shot, this.warned, this.past, this.railWarnings] = [
|
|
8771
8836
|
p.shots,
|
|
8772
8837
|
known ? 0 : this.persona.warn,
|
|
8773
|
-
1
|
|
8838
|
+
1,
|
|
8839
|
+
0
|
|
8774
8840
|
];
|
|
8775
8841
|
if (this.rnd() < .5) this.past = -1;
|
|
8776
8842
|
}
|
|
8777
8843
|
this.met.set(foe.id, this.ticks);
|
|
8778
8844
|
const d = flat(p.x, p.z, q.x, q.z);
|
|
8779
|
-
const blade = !!
|
|
8845
|
+
const blade = weapon === BLADE || !!(p.swing && p.wield);
|
|
8780
8846
|
const v = this.speed;
|
|
8781
8847
|
const k = this.persona.track;
|
|
8782
8848
|
[v[0], v[1], v[2]] = [
|
|
@@ -8784,7 +8850,7 @@ var Bot = class {
|
|
|
8784
8850
|
v[1] + (q.vy - v[1]) * k,
|
|
8785
8851
|
v[2] + (q.vz - v[2]) * k
|
|
8786
8852
|
];
|
|
8787
|
-
const lead = blade ? 0 : this.persona.lead * d / (
|
|
8853
|
+
const lead = blade || rail ? 0 : this.persona.lead * d / (rifle ? 400 : 80);
|
|
8788
8854
|
const [tx, ty, tz] = [
|
|
8789
8855
|
q.x + v[0] * lead,
|
|
8790
8856
|
q.y + 1.1 + v[1] * lead,
|
|
@@ -8796,7 +8862,7 @@ var Bot = class {
|
|
|
8796
8862
|
this.err = this.err * .94 + (this.rnd() * 2 - 1) * shake * .35;
|
|
8797
8863
|
this.errUp = this.errUp * .94 + (this.rnd() * 2 - 1) * shake * .2;
|
|
8798
8864
|
const before = (s.hunters?.get(foe.id) ?? []).filter((id) => id < this.id).length;
|
|
8799
|
-
const warning = (p.shots - this.shot & 255) < this.warned;
|
|
8865
|
+
const warning = (p.shots - this.shot & 255) + this.railWarnings < this.warned;
|
|
8800
8866
|
const off = !warning && before < TOKENS ? this.err : this.past * Math.atan2(PAST, Math.max(d, 1));
|
|
8801
8867
|
const want = norm(toward(p.x, p.z, tx, tz) + off);
|
|
8802
8868
|
const rate = this.persona.turn;
|
|
@@ -8808,10 +8874,11 @@ var Bot = class {
|
|
|
8808
8874
|
const inReach = d < CUTS[CUT.SLASH].reach && Math.abs(q.y - p.y) < HUNT_Y;
|
|
8809
8875
|
return { keys: ready && inReach && !p.swing ? this.rnd() < .25 ? SPECIAL : FIRE : 0 };
|
|
8810
8876
|
}
|
|
8811
|
-
const armed = p.ammo > 0 && (p.mag ?? 0) > 0
|
|
8812
|
-
const
|
|
8877
|
+
const armed = rail ? !!p.cap && !p.hot : rifle ? !!p.clip && !p.cool : p.ammo > 0 && (p.mag ?? 0) > 0;
|
|
8878
|
+
const reach = rail || rifle ? Math.hypot(d, ty - eye[1]) : d;
|
|
8879
|
+
const pull = p.ammo < 0 && !weapon ? d < 1.4 : armed && !p.reload && reach < range;
|
|
8813
8880
|
if (!warning && ready && pull) this.hunting = foe.id;
|
|
8814
|
-
return { keys: ready && pull && this.ticks & 1 ? FIRE : 0 };
|
|
8881
|
+
return { keys: ready && pull && (rail || rifle || this.ticks & 1) ? FIRE : 0 };
|
|
8815
8882
|
}
|
|
8816
8883
|
};
|
|
8817
8884
|
// src/shared/ctf.ts
|
|
@@ -199,6 +199,8 @@ export declare const stance: (r: Runner) => {
|
|
|
199
199
|
yaw: number;
|
|
200
200
|
carry: [Vec3, Vec3[]] | undefined;
|
|
201
201
|
};
|
|
202
|
+
/** Build and index the Hunter models before they can be drawn during a match. */
|
|
203
|
+
export declare const warmHunter: () => void;
|
|
202
204
|
/** Draws the runner and gives back its solved skeleton, or nothing once a bolt has burnt it away. */
|
|
203
205
|
export declare const soldier: (out: Out, r: Runner, color: number[], lod?: number, helmets?: boolean, armored?: boolean,
|
|
204
206
|
/** The frame's pieces of the store: the rigid ones go there (store.ts), but on one coming apart. */
|
|
@@ -105,6 +105,10 @@ export declare class Bot {
|
|
|
105
105
|
/** The goal of the way, and the tick it was planned. */
|
|
106
106
|
private goal;
|
|
107
107
|
private planned;
|
|
108
|
+
/** Tick of the last grounded rack search, and the path to its chosen rack. */
|
|
109
|
+
private rackChecked;
|
|
110
|
+
private rackTarget?;
|
|
111
|
+
private rackSteps?;
|
|
108
112
|
/** The step it is on; steps.length once there. */
|
|
109
113
|
private step;
|
|
110
114
|
private flight;
|
|
@@ -124,6 +128,7 @@ export declare class Bot {
|
|
|
124
128
|
/** Its shot count when it met the target, the shots it fires past him first, and to which side. */
|
|
125
129
|
private shot;
|
|
126
130
|
private warned;
|
|
131
|
+
private railWarnings;
|
|
127
132
|
private past;
|
|
128
133
|
/** A guard's flag and round, the point it goes to, the tick it leaves it, and where it looks there. */
|
|
129
134
|
private base;
|
|
@@ -27,7 +27,7 @@ export declare const MOUNDS: number[];
|
|
|
27
27
|
export declare const MOUND: number, RISE: number;
|
|
28
28
|
/**
|
|
29
29
|
* Where the field stays flat at y 0, x0, z0, x1, z1 with z from the centre line: the landing pad,
|
|
30
|
-
* the dome
|
|
30
|
+
* the dome and the spawns, the modules and tubes, the two rovers, the packs on the
|
|
31
31
|
* floor, the run-up to each mound. The relief is 0 for 6 m round each (so the lattice's
|
|
32
32
|
* triangles are level over it) and back to itself 6 m further. The lips need none: the field
|
|
33
33
|
* starts 12 m behind them.
|
|
@@ -24,11 +24,11 @@ export interface TeamDef {
|
|
|
24
24
|
spawns: Spawn[];
|
|
25
25
|
/** The gun rack near the spawns, a point on a top: walking within RACK_R gives the gun with AMMO_MAX shots. */
|
|
26
26
|
rack?: Vec3;
|
|
27
|
-
/** The katana rack,
|
|
27
|
+
/** The katana rack, a point on a top: walking within RACK_R gives the katana. */
|
|
28
28
|
blade?: Vec3;
|
|
29
|
-
/** The rail gun rack
|
|
29
|
+
/** The rail gun rack: walking within RACK_R gives the rail gun with RAIL_MAX shots. */
|
|
30
30
|
rail?: Vec3;
|
|
31
|
-
/** The laser rifle rack
|
|
31
|
+
/** The laser rifle rack: walking within RACK_R gives the rifle with RIFLE_MAX rounds. */
|
|
32
32
|
rifle?: Vec3;
|
|
33
33
|
}
|
|
34
34
|
/** A sliding door (doors.ts): the box its two panels fill when shut, in a doorway of the brushes. */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@korial29/tiny-fps",
|
|
3
3
|
"description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.200.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"eslint-plugin-prettier": "^5.5.7",
|
|
82
82
|
"jsdom": "^30.1.3",
|
|
83
83
|
"prettier": "^3.9.10",
|
|
84
|
+
"terser": "^5.51.4",
|
|
84
85
|
"tsx": "^4.23.15",
|
|
85
86
|
"typescript": "^6.0.3",
|
|
86
87
|
"typescript-eslint": "^8.72.0",
|