@korial29/tiny-fps 1.4.0 → 1.4.2
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.
|
@@ -7215,10 +7215,10 @@ var NEAR$1 = 6;
|
|
|
7215
7215
|
var ABOVE = 2.2;
|
|
7216
7216
|
var BELOW = 8;
|
|
7217
7217
|
/**
|
|
7218
|
-
* The rectangle a body at `v` stands on, or the nearest one within
|
|
7219
|
-
* it and BELOW under it, as (index, the point of it to walk to); -1 when none.
|
|
7218
|
+
* The rectangle a body at `v` stands on, or the nearest one within `near` metres, at most `above`
|
|
7219
|
+
* over it and BELOW under it, as (index, the point of it to walk to); -1 when none.
|
|
7220
7220
|
*/
|
|
7221
|
-
var locate = (nav, w, v) => {
|
|
7221
|
+
var locate = (nav, w, v, above = ABOVE, near = NEAR$1) => {
|
|
7222
7222
|
const i = under(nav, w, v[0], v[1], v[2], PLAYER_R);
|
|
7223
7223
|
if (i >= 0 && heightAt(w, nav.polys[i], v[0], v[2]) > v[1] - 1.5) return [i, onto(w, nav.polys[i], v[0], v[2])];
|
|
7224
7224
|
let best = -1;
|
|
@@ -7230,20 +7230,28 @@ var locate = (nav, w, v) => {
|
|
|
7230
7230
|
v[2],
|
|
7231
7231
|
v[0],
|
|
7232
7232
|
v[2]
|
|
7233
|
-
],
|
|
7233
|
+
], near, (k) => {
|
|
7234
7234
|
for (const j of nav.grid.get(k) ?? []) {
|
|
7235
7235
|
if (seen.has(j)) continue;
|
|
7236
7236
|
seen.add(j);
|
|
7237
7237
|
const o = onto(w, nav.polys[j], v[0], v[2]);
|
|
7238
7238
|
const d = flat$2(v[0], v[2], o[0], o[2]) + Math.abs(o[1] - v[1]);
|
|
7239
|
-
if (d < least && o[1] - v[1] <=
|
|
7239
|
+
if (d < least && o[1] - v[1] <= above && v[1] - o[1] <= BELOW) [best, least, pt] = [
|
|
7240
7240
|
j,
|
|
7241
7241
|
d,
|
|
7242
7242
|
o
|
|
7243
7243
|
];
|
|
7244
7244
|
}
|
|
7245
7245
|
});
|
|
7246
|
-
return [least <=
|
|
7246
|
+
return [least <= near ? best : -1, pt];
|
|
7247
|
+
};
|
|
7248
|
+
/**
|
|
7249
|
+
* Where a swimmer at `v` gets out: the nearest floor no higher than a step over his feet, within
|
|
7250
|
+
* twice NEAR. He neither jumps nor climbs in the water, so a float's or a box's top is no way out.
|
|
7251
|
+
*/
|
|
7252
|
+
var ashore = (nav, w, v) => {
|
|
7253
|
+
const [i, on] = locate(nav, w, v, STEP_H, 12);
|
|
7254
|
+
return i < 0 ? void 0 : on;
|
|
7247
7255
|
};
|
|
7248
7256
|
/**
|
|
7249
7257
|
* Adds a route's legs from `start` as links: a jump with the run up to it, a slide; the runs
|
|
@@ -10012,12 +10020,13 @@ var Bot = class {
|
|
|
10012
10020
|
} else this.sortie.board = void 0;
|
|
10013
10021
|
this.gaze = void 0;
|
|
10014
10022
|
const goal = this.goalOf(s);
|
|
10015
|
-
|
|
10023
|
+
const afloat = p.mode === MODE.SWIM;
|
|
10024
|
+
if (!this.goal && !p.ground && !afloat) return {
|
|
10016
10025
|
keys: FORWARD,
|
|
10017
10026
|
yaw: p.yaw,
|
|
10018
10027
|
pitch: 0
|
|
10019
10028
|
};
|
|
10020
|
-
if (p.ground && (!this.goal || !!this.rackSteps || this.plannedWhy !== this.why && (this.urgent() || this.urgent(this.plannedWhy)) || this.urgent() && Math.abs(goal[1] - this.goal[1]) > HOVER || 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);
|
|
10029
|
+
if ((p.ground || afloat) && (!this.goal || !!this.rackSteps || this.plannedWhy !== this.why && (this.urgent() || this.urgent(this.plannedWhy)) || this.urgent() && Math.abs(goal[1] - this.goal[1]) > HOVER || 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);
|
|
10021
10030
|
const move = this.pilot(p);
|
|
10022
10031
|
const fight = this.fight(s, move.free, weapon);
|
|
10023
10032
|
if (!fight) {
|
|
@@ -10047,8 +10056,10 @@ var Bot = class {
|
|
|
10047
10056
|
pitch: 0
|
|
10048
10057
|
};
|
|
10049
10058
|
const keys = move.keys & ~(FORWARD | BACK | LEFT | RIGHT | SPRINT);
|
|
10059
|
+
const dirs = move.keys & FORWARD ? keysFor(this.aim, move.yaw) : 0;
|
|
10060
|
+
const side = this.dodge(s.world, p);
|
|
10050
10061
|
const out = {
|
|
10051
|
-
keys: (
|
|
10062
|
+
keys: (side ? dirs & ~(LEFT | RIGHT) : dirs) | side | keys | fight.keys,
|
|
10052
10063
|
yaw: this.aim,
|
|
10053
10064
|
pitch: this.pitch
|
|
10054
10065
|
};
|
|
@@ -10304,7 +10315,8 @@ var Bot = class {
|
|
|
10304
10315
|
const direct = this.urgent() && !this.steer || this.why.endsWith(" rack");
|
|
10305
10316
|
const nav = navOf(w);
|
|
10306
10317
|
const prefer = direct ? -1 : this.id % nav.ways;
|
|
10307
|
-
|
|
10318
|
+
const out = p.mode === MODE.SWIM && !this.rackSteps ? ashore(nav, w, at(p)) : void 0;
|
|
10319
|
+
this.steps = this.rackSteps ?? (out ? [{ to: out }, ...path(nav, w, out, goal, prefer)] : path(nav, w, at(p), goal, prefer));
|
|
10308
10320
|
this.rackSteps = void 0;
|
|
10309
10321
|
const [x, , z] = this.steps[0].to;
|
|
10310
10322
|
if (this.steps.length === 1 && this.steps[0].to !== goal && flat(p.x, p.z, x, z) < 1) this.steps = [{ to: goal }];
|
|
@@ -10319,6 +10331,17 @@ var Bot = class {
|
|
|
10319
10331
|
*/
|
|
10320
10332
|
pilot(p) {
|
|
10321
10333
|
const s = this.steps[this.step];
|
|
10334
|
+
const afloat = p.mode === MODE.SWIM;
|
|
10335
|
+
if (s?.leg && afloat) {
|
|
10336
|
+
if (s.edge) s.edge.fails = (s.edge.fails ?? 0) + 1;
|
|
10337
|
+
this.goal = void 0;
|
|
10338
|
+
return {
|
|
10339
|
+
keys: 0,
|
|
10340
|
+
yaw: p.yaw,
|
|
10341
|
+
free: false,
|
|
10342
|
+
exact: true
|
|
10343
|
+
};
|
|
10344
|
+
}
|
|
10322
10345
|
if (s?.leg) return this.fly(p, s.leg);
|
|
10323
10346
|
if (!s) return {
|
|
10324
10347
|
keys: 0,
|
|
@@ -10328,7 +10351,7 @@ var Bot = class {
|
|
|
10328
10351
|
};
|
|
10329
10352
|
const [x, y, z] = s.to;
|
|
10330
10353
|
const d = flat(p.x, p.z, x, z);
|
|
10331
|
-
if (!p.ground) return {
|
|
10354
|
+
if (!p.ground && !afloat) return {
|
|
10332
10355
|
keys: this.alight(p, x, y, z),
|
|
10333
10356
|
yaw: toward(p.x, p.z, x, z),
|
|
10334
10357
|
free: false,
|