@korial29/tiny-fps 0.33.0 → 0.34.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 +14 -14
- package/dist/local.js +1 -1
- package/dist/server.js +139 -62
- package/dist/types/client/balls.d.ts +22 -0
- package/dist/types/client/beams.d.ts +18 -9
- package/dist/types/client/combat.d.ts +5 -7
- package/dist/types/client/effects.d.ts +1 -1
- package/dist/types/client/hud.d.ts +1 -1
- package/dist/types/client/render.d.ts +1 -1
- package/dist/types/shared/constants.d.ts +10 -1
- package/dist/types/shared/gun.d.ts +1 -7
- package/dist/types/shared/plasma.d.ts +29 -0
- package/dist/types/shared/protocol.d.ts +2 -0
- package/dist/types/shared/room.d.ts +7 -2
- package/dist/types/shared/types.d.ts +19 -1
- package/dist/types/shared/world.d.ts +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Ball, PlayerState } from './types';
|
|
2
|
+
import type { World } from './world';
|
|
3
|
+
type Vec3 = [number, number, number];
|
|
4
|
+
/** Metres a ball flies in a tick. */
|
|
5
|
+
export declare const PLASMA_STEP: number;
|
|
6
|
+
/** Ticks of the shooter's lag a new ball is flown at most on the host before its first tick. */
|
|
7
|
+
export declare const PLASMA_LAG = 12;
|
|
8
|
+
/** A ball the host flies: whose team fired it, and the metres it has left. */
|
|
9
|
+
export interface Flying extends Ball {
|
|
10
|
+
team: number;
|
|
11
|
+
left: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The ball of the shot `p` has just fired (`p` is the state after the step that fired): from the
|
|
15
|
+
* eye of the mode along the look, GUN_RANGE metres to go, named by his `shots` count.
|
|
16
|
+
*/
|
|
17
|
+
export declare const launch: (p: PlayerState, team?: number) => Flying;
|
|
18
|
+
/**
|
|
19
|
+
* Distance at which the ray from `o` along the unit `d` enters the upright cylinder of radius `r`
|
|
20
|
+
* on `c`'s feet, `h` tall; Infinity on a miss.
|
|
21
|
+
*/
|
|
22
|
+
export declare const cylinder: (o: Vec3, d: Vec3, c: PlayerState, r: number, h: number) => number;
|
|
23
|
+
/**
|
|
24
|
+
* Flies `b` on by `m` metres (at most what it has left) as a sphere of PLASMA_R: it stops and
|
|
25
|
+
* bursts on the first brush, or on the first of `foes` whose body (a cylinder PLASMA_R wider) it
|
|
26
|
+
* enters. Returns the foe it burst on.
|
|
27
|
+
*/
|
|
28
|
+
export declare const fly: (w: World, b: Flying, m: number, foes: PlayerState[]) => PlayerState | undefined;
|
|
29
|
+
export {};
|
|
@@ -31,6 +31,8 @@ export declare const SNAP_HEAD = 4;
|
|
|
31
31
|
export declare const SNAP_PLAYER = 47;
|
|
32
32
|
/** The match block after the players: the captures, the clock, the packs; the flags follow (2 to 16 bytes). */
|
|
33
33
|
export declare const SNAP_MATCH = 8;
|
|
34
|
+
/** Bytes of a plasma ball. */
|
|
35
|
+
export declare const SNAP_BALL = 10;
|
|
34
36
|
/**
|
|
35
37
|
* The input as the host will read it after encodeInput and decodeInput: yaw, pitch and view
|
|
36
38
|
* rounded to the wire (an absent view stays absent here, and reads 0 on the host). The client
|
|
@@ -31,6 +31,8 @@ export declare class Room {
|
|
|
31
31
|
private rr;
|
|
32
32
|
/** Ticks before each health pack of the map is back: 0 when it is there to take. */
|
|
33
33
|
private gone;
|
|
34
|
+
/** The plasma balls in flight, and the ones that burst since the last snapshot, which sends them once more. */
|
|
35
|
+
private balls;
|
|
34
36
|
/** Missing rules fall back to RULES. */
|
|
35
37
|
constructor(rules?: Partial<Rules>, map?: WorldDef);
|
|
36
38
|
/** Number of joined players. */
|
|
@@ -83,10 +85,13 @@ export declare class Room {
|
|
|
83
85
|
*/
|
|
84
86
|
private harm;
|
|
85
87
|
/**
|
|
86
|
-
* A shot of `p` went off at the view tick `view`:
|
|
87
|
-
*
|
|
88
|
+
* A shot of `p` went off at the view tick `view`: its ball starts where `p` saw it start, flown
|
|
89
|
+
* on by his lag (the view tick to now, at most PLASMA_LAG ticks) against the others as they are
|
|
90
|
+
* now. Past PLASMA_MAX balls in flight, the oldest bursts.
|
|
88
91
|
*/
|
|
89
92
|
private shoot;
|
|
93
|
+
/** Flies the ball `b` on by `m` metres: one that bursts on an enemy who is up takes 1 hp from him, and counts a hit to its shooter. */
|
|
94
|
+
private fly;
|
|
90
95
|
/**
|
|
91
96
|
* A cut of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him is hit
|
|
92
97
|
* (`strike`), and the `hits` count goes up once. Each takes the cut's hp; one it does not put
|
|
@@ -172,7 +172,7 @@ export interface PlayerState {
|
|
|
172
172
|
rack?: boolean;
|
|
173
173
|
/** Ticks left lying down after the health ran out; at 0 the player is back at a spawn. 0 when up. */
|
|
174
174
|
down: number;
|
|
175
|
-
/** Shots fired and hits landed (a
|
|
175
|
+
/** Shots fired and hits landed (a plasma ball or a cut), u8 counters that wrap: the clients flash the muzzle and play the hit sound on each change. */
|
|
176
176
|
shots: number;
|
|
177
177
|
hits: number;
|
|
178
178
|
/** Has the katana (taken at the team's katana rack, lost on going down). Absent reads false. */
|
|
@@ -221,6 +221,22 @@ export interface SnapPlayer extends PlayerState {
|
|
|
221
221
|
/** While `stun` runs: the id of the player who tackled this one (4 bits), else 0. Not part of the movement. */
|
|
222
222
|
by: number;
|
|
223
223
|
}
|
|
224
|
+
/** A plasma ball as a snapshot carries it (plasma.ts). */
|
|
225
|
+
export interface Ball {
|
|
226
|
+
/** The shooter's `shots` count after the shot that fired it, u8: with `by`, it names the ball. */
|
|
227
|
+
id: number;
|
|
228
|
+
/** The shooter's player id. */
|
|
229
|
+
by: number;
|
|
230
|
+
/** Its centre, metres (the wire keeps 1/32 m), and its unit direction of flight. */
|
|
231
|
+
x: number;
|
|
232
|
+
y: number;
|
|
233
|
+
z: number;
|
|
234
|
+
dx: number;
|
|
235
|
+
dy: number;
|
|
236
|
+
dz: number;
|
|
237
|
+
/** It burst where it is: the last snapshot that carries it. */
|
|
238
|
+
burst: boolean;
|
|
239
|
+
}
|
|
224
240
|
/** The flag of a team as a snapshot carries it: only the fields of its state are meaningful, the rest read 0. */
|
|
225
241
|
export interface FlagState {
|
|
226
242
|
/** FLAG. */
|
|
@@ -250,6 +266,8 @@ export interface Snapshot {
|
|
|
250
266
|
* packs of WorldDef.ammo (bit packs.length + n). Absent: none.
|
|
251
267
|
*/
|
|
252
268
|
packs?: number;
|
|
269
|
+
/** The plasma balls in flight, and those that burst since the last snapshot. Absent: none. */
|
|
270
|
+
balls?: Ball[];
|
|
253
271
|
}
|
|
254
272
|
/** Room rules, set by the host. Defaults in constants.ts (RULES). */
|
|
255
273
|
export interface Rules {
|
|
@@ -65,12 +65,14 @@ export declare const near: (w: World, x: number, z: number, r: number) => number
|
|
|
65
65
|
/**
|
|
66
66
|
* Distance along the ray from o in the unit direction d to the first brush face, at most max. A ray
|
|
67
67
|
* that starts inside a brush hits at 0; one that starts on a face and moves away from it does not hit it.
|
|
68
|
+
* With `grow`, every brush is that much bigger on each side: the path of a sphere of that radius
|
|
69
|
+
* (its corners square, and a brush is only found in the cells the ray crosses).
|
|
68
70
|
*
|
|
69
71
|
* Walks the grid cells the ray crosses (Amanatides and Woo), testing the brushes of each against
|
|
70
72
|
* the exact slab test, and stops once the next cell starts beyond the best hit or max. A brush
|
|
71
73
|
* spanning several cells is tested in each: the hit is the same, and lists are short.
|
|
72
74
|
*/
|
|
73
|
-
export declare const ray: (w: World, o: Vec3, d: Vec3, max: number) => number;
|
|
75
|
+
export declare const ray: (w: World, o: Vec3, d: Vec3, max: number, grow?: number) => number;
|
|
74
76
|
/** Whether a brush hides b from a. */
|
|
75
77
|
export declare const hidden: (w: World, a: Vec3, b: Vec3) => boolean;
|
|
76
78
|
export {};
|
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.34.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|