@korial29/tiny-fps 0.138.0 → 0.139.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.
@@ -1,3 +1,4 @@
1
+ import type { Flying } from './plasma';
1
2
  import type { FlagState, PlayerState } from './types';
2
3
  import type { World } from './world';
3
4
  /** A player as a bot sees him: the host's own state, no rewind. */
@@ -12,12 +13,36 @@ export interface Sight {
12
13
  others: Seen[];
13
14
  flags: readonly FlagState[];
14
15
  world: World;
16
+ /** The balls in flight, to get out of their way. */
17
+ balls?: readonly Flying[];
15
18
  }
16
19
  export type Intent = {
17
20
  keys: number;
18
21
  yaw: number;
19
22
  pitch: number;
20
23
  };
24
+ /** The skill of a room's bots when its rules give none: 0 (novice) to 7 (godlike), as in UT2004. */
25
+ export declare const SKILL = 4;
26
+ /**
27
+ * A bot's character, after UT2004's (Accuracy, ReactionTime, Jumpiness, StrafingAbility): drawn
28
+ * from its id, the same on every host, and scaled by the room's skill.
29
+ */
30
+ export interface Persona {
31
+ /** Radians its aim starts off a new target. */
32
+ miss: number;
33
+ /** Ticks a new target must be in sight before its first shot. */
34
+ react: number;
35
+ /** The most its aim turns in a tick. */
36
+ turn: number;
37
+ /** Its chance a tick, while it fights, of a jump; a dash aside is one in DASHY of them. */
38
+ jumpy: number;
39
+ /** The fewest ticks it strafes one way before it may turn back. */
40
+ strafe: number;
41
+ /** Its chance of dashing out of the way of a ball coming at it. */
42
+ duck: number;
43
+ }
44
+ /** The character of the bot `id` in a room of this skill. */
45
+ export declare const personaOf: (id: number, skill?: number) => Persona;
21
46
  export declare class Bot {
22
47
  readonly id: number;
23
48
  /** The route it prefers, an index of nav.ts's ROUTES. */
@@ -41,20 +66,62 @@ export declare class Bot {
41
66
  private since;
42
67
  private last;
43
68
  private world;
44
- constructor(id: number);
69
+ /** Where it looks walking, turned a little each tick; the side of its last detour; its last dash. */
70
+ private look;
71
+ private side;
72
+ private dashed;
73
+ private readonly persona;
74
+ /** Its own random numbers, seeded by its id: the same match plays the same on every host. */
75
+ private seed;
76
+ /** The way it strafes in a fight (1 left, -1 right) and the tick it may turn back. */
77
+ private strafing;
78
+ private turnBack;
79
+ /** The balls it has weighed, by shooter and count: it decides once whether to get out of the way. */
80
+ private weighed;
81
+ constructor(id: number, skill?: number);
82
+ /** A number in [0, 1) from its own sequence. */
83
+ private rnd;
45
84
  /** The input of this tick. */
46
85
  think(s: Sight): Intent;
47
- /** A side step while it fights, one way then the other, never toward a drop. */
86
+ /**
87
+ * How it moves while it fights, as UT2004's bots do: it strafes, one way for a while then the
88
+ * other, never toward a drop, and now and then jumps or dashes aside (its Jumpiness).
89
+ */
48
90
  private dodge;
91
+ /**
92
+ * Out of the way of a ball coming at it, as UT2004's bots dodge a rocket: an enemy ball that will
93
+ * pass within CLOSE of its chest in the next WARN seconds is weighed once, and with the bot's
94
+ * chance it dashes aside, across the ball's way and away from it, where the floor is open.
95
+ * Not on a leg of a route, nor in the air.
96
+ */
97
+ private evade;
49
98
  /** Where it wants to be. */
50
99
  private goalOf;
51
100
  private plan;
52
101
  /** The point it walks straight to now: the entry, a walk's end, or the goal past the last edge. */
53
102
  private target;
54
- /** The keys and yaw of the move, and whether the bot may look away from it to shoot. */
103
+ /**
104
+ * The keys and yaw of the move, whether the bot may look away from it to shoot, and whether the
105
+ * yaw must be kept to the letter (a leg of a route, as the tests fly it).
106
+ */
55
107
  private pilot;
108
+ /**
109
+ * A straight walk toward `want`: round a wall or a drop that hurts by the nearest turn that is open
110
+ * (on the side it last went round, first), up a box low enough to jump onto, and a dash when the
111
+ * way ahead is long, straight and open. It steps down onto a lower roof.
112
+ */
113
+ private walk;
114
+ /** DASH when the way ahead is long, open and wide and the last dash is a while back, else 0. */
115
+ private dash;
116
+ /** Whether the floor of a dash's run is wide: a metre each side of it, all along, no edge or beam. */
117
+ private wide;
118
+ /**
119
+ * Whether a body may walk `ahead` metres along `yaw` from where it stands: 'open', 'hop' over a box
120
+ * it can jump onto, or false at a wall, the void or a drop that hurts.
121
+ */
122
+ private open;
56
123
  private next;
57
- /** `keys`, with a jump when it has not got closer for a while; a new way when that does not help. */
124
+ /** Counts the progress toward the point it goes to: a new way when there has been none for a while. */
58
125
  private unstick;
59
126
  /** One step of a leg of a route, the way test/routes.ts flies it. */
60
127
  private fly;
@@ -432,6 +432,8 @@ export interface Rules {
432
432
  map?: string;
433
433
  /** Bots fill the room up to this many players while a human is in it (bot.ts). Absent, none. */
434
434
  bots?: number;
435
+ /** The bots' skill, 0 (novice) to 7 (godlike) as in UT2004 (bot.ts's SKILL when absent). */
436
+ botSkill?: number;
435
437
  }
436
438
  /**
437
439
  * The subset of WebSocket the client relies on. A real WebSocket (with
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.138.0",
5
+ "version": "0.139.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"