@korial29/tiny-fps 0.177.0 → 0.179.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -341,9 +341,11 @@ var [NECK, HIPS, MIDLINE] = [
341
341
  /**
342
342
  * The ninja's parry (the user, 2026-11-16): with the katana in hand, a ball (not a grenade or an arc)
343
343
  * that comes at him within PARRY_ARC radians of his facing is struck back PARRY of the time (Kit.parry),
344
- * along his look.
344
+ * along his look; PARRY_WIDE of those (the user, 2026-11-16: so the foe in front is not killed too
345
+ * easily) go off to his left or right instead, PARRY_SIDE radians off the look.
345
346
  */
346
347
  var PARRY = .7;
348
+ var PARRY_SIDE = 1.2;
347
349
  var RIFLE_DRIFT = .012;
348
350
  var RULES = {
349
351
  maxPlayers: 16,
@@ -7411,6 +7413,9 @@ var HOVER = 4;
7411
7413
  var TACKLE = 4;
7412
7414
  /** Metres a bot without a gun goes out of its way to the rack. */
7413
7415
  var ARM = 30;
7416
+ /** Metres off a bot that takes no gun goes for an enemy in sight, and the most he may be above or below. */
7417
+ var HUNT = 15;
7418
+ var HUNT_Y = 2;
7414
7419
  /**
7415
7420
  * Metres ahead a walking bot looks for a wall or a drop, the seconds of its speed it looks for the
7416
7421
  * floor further on (it does not stop at once), and the share of the drop that hurts it will walk into.
@@ -7517,6 +7522,11 @@ var Bot = class {
7517
7522
  weighed = /* @__PURE__ */ new Set();
7518
7523
  /** Its errand to the orbital station, when it has one. */
7519
7524
  sortie = new Sortie();
7525
+ /**
7526
+ * Whether it jumps unlike the marine the routes were flown with (the ninja, the xenomorph): it
7527
+ * steers every leap in the air to come down on its point, as the moon's (`land`).
7528
+ */
7529
+ steer = false;
7520
7530
  constructor(id, skill = 4) {
7521
7531
  this.id = id;
7522
7532
  this.prefer = id % ROUTES.length;
@@ -7533,6 +7543,7 @@ var Bot = class {
7533
7543
  const t = ++this.ticks;
7534
7544
  const p = s.me.state;
7535
7545
  this.world = s.world;
7546
+ this.steer = !!s.kit && s.kit.jump !== 7;
7536
7547
  if (p.down) {
7537
7548
  this.goal = void 0;
7538
7549
  this.foe = -1;
@@ -7687,7 +7698,19 @@ var Bot = class {
7687
7698
  };
7688
7699
  if (theirs.state === FLAG$1.CARRIED && theirs.by === me.id) return home.base;
7689
7700
  if (this.sortie.board) return this.sortie.board;
7690
- if (p.ammo < 0 && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) return home.rack;
7701
+ const gear = s.kit?.gear ?? true;
7702
+ if (p.ammo < 0 && gear && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) return home.rack;
7703
+ const eye = [
7704
+ p.x,
7705
+ p.y + eyeHeight(p),
7706
+ p.z
7707
+ ];
7708
+ const prey = gear ? void 0 : others.find((o) => o.team !== team && !o.state.down && Math.abs(o.state.y - p.y) < HUNT_Y && flat(p.x, p.z, o.state.x, o.state.z) < HUNT && !hidden(world, eye, [
7709
+ o.state.x,
7710
+ o.state.y + 1.2,
7711
+ o.state.z
7712
+ ]));
7713
+ if (prey) return at(prey.state);
7691
7714
  if (mine.state === FLAG$1.CARRIED) {
7692
7715
  const h = holder(mine);
7693
7716
  if (h) return h;
@@ -7918,22 +7941,23 @@ var Bot = class {
7918
7941
  f.k++;
7919
7942
  if (p.mode === MODE.WALLRUN) f.ran = true;
7920
7943
  else if (f.ran && f.ended < 0) f.ended = f.k;
7921
- if (leg.land) {
7944
+ const n = leg.run ? f.ended < 0 ? -1 : f.k - f.ended : f.k;
7945
+ const extra = (n === leg.dash ? DASH : 0) | (n === leg.double ? JUMP : 0);
7946
+ if (leg.land || this.steer) {
7922
7947
  const [tx, tz] = leg.to;
7923
7948
  const d = flat(p.x, p.z, tx, tz);
7924
7949
  const v = (p.vx * (tx - p.x) + p.vz * (tz - p.z)) / (d || 1);
7925
7950
  const g = gravity(this.world);
7926
7951
  const t = Math.max((p.vy + Math.sqrt(Math.max(p.vy ** 2 + 2 * g * (p.y - leg.y), 0))) / g, .05);
7927
7952
  return {
7928
- keys: v * t < d - .3 ? FORWARD : v * t > d + .3 ? BACK : 0,
7953
+ keys: (v * t < d - .3 ? FORWARD : v * t > d + .3 ? BACK : 0) | (leg.land ? 0 : extra),
7929
7954
  yaw,
7930
7955
  free: false,
7931
7956
  exact: true
7932
7957
  };
7933
7958
  }
7934
- const n = leg.run ? f.ended < 0 ? -1 : f.k - f.ended : f.k;
7935
7959
  return {
7936
- keys: (n === leg.dash ? keys | DASH : keys) | (n === leg.double ? JUMP : 0),
7960
+ keys: keys | extra,
7937
7961
  yaw,
7938
7962
  free: false,
7939
7963
  exact: true
@@ -8543,6 +8567,16 @@ var BOT_NAMES = [
8543
8567
  "Gear",
8544
8568
  "Hex"
8545
8569
  ];
8570
+ /**
8571
+ * The classes the bots take in turn by their name (the user, 2026-11-16: bots play the ninja and
8572
+ * the xenomorph too). A map that does not offer one gives its default (roleOf()): the moon's
8573
+ * ninja is an astronaut.
8574
+ */
8575
+ var BOT_ROLES = [
8576
+ ROLE.MARINE,
8577
+ ROLE.NINJA,
8578
+ ROLE.XENO
8579
+ ];
8546
8580
  /** The two seats of a rover, the driver's first. */
8547
8581
  var SEATS = ["driver", "rider"];
8548
8582
  /** An index in [0, n), or undefined. */
@@ -9216,14 +9250,18 @@ var Room = class {
9216
9250
  }
9217
9251
  /**
9218
9252
  * The katana of `p` met the ball `b`: it ends on the blade (its burst, no hit), and one as strong
9219
- * leaves his eye along his look, his own and his team's, its range full again. Its id runs on from
9220
- * his `shots` by 64 plus his parries: the sum only grows, so it names no ball of his still in flight.
9253
+ * leaves his eye along his look, or PARRY_WIDE of the time PARRY_SIDE off it to one side, his own
9254
+ * and his team's, its range full again. Its id runs on from his `shots` by 64 plus his parries: the
9255
+ * sum only grows, so it names no ball of his still in flight.
9221
9256
  */
9222
9257
  deflect(p, b) {
9223
9258
  p.parries = (p.parries ?? 0) + 1 & 255;
9259
+ const r = roll(this.ticks, b.by, b.id, p.info.id, p.parries);
9260
+ const yaw = p.state.yaw + (r < .3 ? r < .3 / 2 ? -PARRY_SIDE : PARRY_SIDE : 0);
9224
9261
  this.shoot(p, this.ticks, {
9225
9262
  ...launch$1({
9226
9263
  ...p.state,
9264
+ yaw,
9227
9265
  rifled: false
9228
9266
  }, p.info.team),
9229
9267
  id: p.state.shots + 64 + p.parries & 255,
@@ -9893,7 +9931,8 @@ var Room = class {
9893
9931
  flags: this.ctf.flags,
9894
9932
  world: this.world,
9895
9933
  balls: this.balls,
9896
- errand: errands.get(p.info.id)
9934
+ errand: errands.get(p.info.id),
9935
+ kit: this.kit(p)
9897
9936
  });
9898
9937
  p.seq = (p.seq ?? -1) + 1 & 65535;
9899
9938
  this.apply(p, onWire({
@@ -9989,8 +10028,9 @@ var Room = class {
9989
10028
  const conn = { send: () => void 0 };
9990
10029
  this.peers.set(conn, null);
9991
10030
  const names = players.map((p) => p.info.name);
9992
- const name = BOT_NAMES.map((n) => `${n} (bot)`).find((n) => !names.includes(n)) ?? "Bot";
9993
- this.join(conn, name, {}, true);
10031
+ const n = BOT_NAMES.findIndex((b) => !names.includes(`${b} (bot)`));
10032
+ const name = n < 0 ? "Bot" : `${BOT_NAMES[n]} (bot)`;
10033
+ this.join(conn, name, { role: BOT_ROLES[Math.max(n, 0) % BOT_ROLES.length] }, true);
9994
10034
  } else return;
9995
10035
  }
9996
10036
  }
@@ -1,5 +1,6 @@
1
1
  import type { Flying } from './plasma';
2
2
  import type { Errand } from './sortie';
3
+ import type { Kit } from './kit';
3
4
  import type { FlagState, PlayerState } from './types';
4
5
  import type { World } from './world';
5
6
  /** A player as a bot sees him: the host's own state, no rewind. */
@@ -18,6 +19,8 @@ export interface Sight {
18
19
  balls?: readonly Flying[];
19
20
  /** What the room asks of it at the orbital station (sortie.ts). */
20
21
  errand?: Errand;
22
+ /** The numbers of its class (kit.ts): the marine's when absent. */
23
+ kit?: Kit;
21
24
  }
22
25
  export type Intent = {
23
26
  keys: number;
@@ -83,6 +86,11 @@ export declare class Bot {
83
86
  private weighed;
84
87
  /** Its errand to the orbital station, when it has one. */
85
88
  private sortie;
89
+ /**
90
+ * Whether it jumps unlike the marine the routes were flown with (the ninja, the xenomorph): it
91
+ * steers every leap in the air to come down on its point, as the moon's (`land`).
92
+ */
93
+ private steer;
86
94
  constructor(id: number, skill?: number);
87
95
  /** A number in [0, 1) from its own sequence. */
88
96
  private rnd;
@@ -404,10 +404,13 @@ export declare const SHOCK_KNOCK = 4;
404
404
  /**
405
405
  * The ninja's parry (the user, 2026-11-16): with the katana in hand, a ball (not a grenade or an arc)
406
406
  * that comes at him within PARRY_ARC radians of his facing is struck back PARRY of the time (Kit.parry),
407
- * along his look.
407
+ * along his look; PARRY_WIDE of those (the user, 2026-11-16: so the foe in front is not killed too
408
+ * easily) go off to his left or right instead, PARRY_SIDE radians off the look.
408
409
  */
409
410
  export declare const PARRY = 0.7;
410
411
  export declare const PARRY_ARC = 1.2;
412
+ export declare const PARRY_WIDE = 0.3;
413
+ export declare const PARRY_SIDE = 1.2;
411
414
  /**
412
415
  * The saber lock (the user, 2026-11-07, after Jedi Outcast): two foes whose cuts strike within
413
416
  * LOCK_WINDOW ticks (0.15 s) of each other, each in the other's reach and facing him (within
@@ -152,8 +152,9 @@ export declare class Room {
152
152
  private fly;
153
153
  /**
154
154
  * The katana of `p` met the ball `b`: it ends on the blade (its burst, no hit), and one as strong
155
- * leaves his eye along his look, his own and his team's, its range full again. Its id runs on from
156
- * his `shots` by 64 plus his parries: the sum only grows, so it names no ball of his still in flight.
155
+ * leaves his eye along his look, or PARRY_WIDE of the time PARRY_SIDE off it to one side, his own
156
+ * and his team's, its range full again. Its id runs on from his `shots` by 64 plus his parries: the
157
+ * sum only grows, so it names no ball of his still in flight.
157
158
  */
158
159
  private deflect;
159
160
  /**
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.177.0",
5
+ "version": "0.179.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"