@korial29/tiny-fps 0.2.0 → 0.4.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 +6 -5
- package/dist/local.js +1 -1
- package/dist/server.js +2106 -272
- package/dist/types/client/effects.d.ts +79 -7
- package/dist/types/client/hud.d.ts +21 -0
- package/dist/types/client/items.d.ts +19 -0
- package/dist/types/client/mesh.d.ts +24 -0
- package/dist/types/client/monsters.d.ts +36 -0
- package/dist/types/client/predict.d.ts +24 -4
- package/dist/types/client/progress.d.ts +41 -0
- package/dist/types/client/render.d.ts +9 -17
- package/dist/types/shared/constants.d.ts +39 -0
- package/dist/types/shared/level.d.ts +2 -0
- package/dist/types/shared/levels.d.ts +2 -0
- package/dist/types/shared/map.d.ts +2 -1
- package/dist/types/shared/monsters.d.ts +23 -0
- package/dist/types/shared/physics.d.ts +22 -5
- package/dist/types/shared/protocol.d.ts +15 -2
- package/dist/types/shared/room.d.ts +50 -10
- package/dist/types/shared/shoot.d.ts +12 -3
- package/dist/types/shared/types.d.ts +128 -1
- package/package.json +1 -1
|
@@ -55,9 +55,100 @@ export interface Shot {
|
|
|
55
55
|
x: number;
|
|
56
56
|
y: number;
|
|
57
57
|
z: number;
|
|
58
|
-
/** Id of the player hit, -1 for the level or nothing. */
|
|
58
|
+
/** Id of the player or monster hit, -1 for the level or nothing. */
|
|
59
59
|
hit: number;
|
|
60
60
|
}
|
|
61
|
+
/** Monster kinds. */
|
|
62
|
+
export declare const MONSTER: {
|
|
63
|
+
/** Walks the floors like a player, shoots bullets from afar and hits up close. */
|
|
64
|
+
readonly WALKER: 0;
|
|
65
|
+
/** Hovers above the floor, flies over steps and pits, hits up close. */
|
|
66
|
+
readonly FLYER: 1;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A monster as the host runs it and the snapshot carries it. Ids run from MAX_PLAYERS up, so a
|
|
70
|
+
* Shot.hit or an event names a player or a monster with one u8.
|
|
71
|
+
*/
|
|
72
|
+
export interface Monster {
|
|
73
|
+
id: number;
|
|
74
|
+
/** MONSTER kind. */
|
|
75
|
+
kind: number;
|
|
76
|
+
/** Bottom of the body: the feet of a walker, the underside of a flyer. */
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
z: number;
|
|
80
|
+
/** Facing, as a player's yaw. */
|
|
81
|
+
yaw: number;
|
|
82
|
+
/** Hunting a player (it saw one, or was alerted), not patrolling. */
|
|
83
|
+
chase: boolean;
|
|
84
|
+
}
|
|
85
|
+
/** A monster's bullet in flight, host-simulated. Ids are a u8 counter that wraps. */
|
|
86
|
+
export interface Bullet {
|
|
87
|
+
id: number;
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
z: number;
|
|
91
|
+
}
|
|
92
|
+
/** What a GameEvent reports. */
|
|
93
|
+
export declare const EVENT: {
|
|
94
|
+
/** Monster `id` died, (x, y, z) the middle of its body: gibs and an explosion. */
|
|
95
|
+
readonly DIE: 0;
|
|
96
|
+
/** Player `id` was hit by a bullet or a blow at (x, y, z). Harmless until health (step 4). */
|
|
97
|
+
readonly HURT: 1;
|
|
98
|
+
/** A bullet burst on the level at (x, y, z); `id` is the bullet. */
|
|
99
|
+
readonly BOOM: 2;
|
|
100
|
+
/** Monster `id` swung at its target from (x, y, z), hit or miss. */
|
|
101
|
+
readonly SWING: 3;
|
|
102
|
+
};
|
|
103
|
+
export interface GameEvent {
|
|
104
|
+
/** EVENT type. */
|
|
105
|
+
type: number;
|
|
106
|
+
id: number;
|
|
107
|
+
x: number;
|
|
108
|
+
y: number;
|
|
109
|
+
z: number;
|
|
110
|
+
}
|
|
111
|
+
/** Something a shot can hit: an upright cylinder of radius r from y up to y + h. */
|
|
112
|
+
export interface Body {
|
|
113
|
+
id: number;
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
z: number;
|
|
117
|
+
r: number;
|
|
118
|
+
h: number;
|
|
119
|
+
}
|
|
120
|
+
/** Pickup kinds. A key is shared by the team: once anyone takes it, its gates open for all. */
|
|
121
|
+
export declare const ITEM: {
|
|
122
|
+
/** Gives HEAL health, up to HEALTH. Left in the level by every DROP_EVERY-th kill. */
|
|
123
|
+
readonly HEALTH: 0;
|
|
124
|
+
readonly KEY_RED: 1;
|
|
125
|
+
readonly KEY_BLUE: 2;
|
|
126
|
+
readonly KEY_YELLOW: 3;
|
|
127
|
+
};
|
|
128
|
+
/** A pickup lying in the level. Ids are unique within a level, u8. */
|
|
129
|
+
export interface Item {
|
|
130
|
+
id: number;
|
|
131
|
+
/** ITEM kind. */
|
|
132
|
+
kind: number;
|
|
133
|
+
/** Where it rests: on the floor of the sector under it. */
|
|
134
|
+
x: number;
|
|
135
|
+
y: number;
|
|
136
|
+
z: number;
|
|
137
|
+
}
|
|
138
|
+
/** A barred doorway: bodies cannot enter the sector until the team holds the key. */
|
|
139
|
+
export interface Gate {
|
|
140
|
+
/** Sector index, a thin doorway between two rooms. */
|
|
141
|
+
sector: number;
|
|
142
|
+
/** ITEM.KEY_* kind that opens it. */
|
|
143
|
+
key: number;
|
|
144
|
+
}
|
|
145
|
+
/** Where a level stands. */
|
|
146
|
+
export declare const PHASE: {
|
|
147
|
+
/** Find the goal: the exit sector is barred. */
|
|
148
|
+
readonly HUNT: 0;
|
|
149
|
+
/** The goal was touched: the exit sector is open; the level is won when every living player is in it. */
|
|
150
|
+
readonly RETURN: 1;
|
|
151
|
+
};
|
|
61
152
|
/** Procedural textures, generated by the client. A sector names one per surface. */
|
|
62
153
|
export declare const TEX: {
|
|
63
154
|
readonly BRICK: 0;
|
|
@@ -91,6 +182,19 @@ export interface MapDef {
|
|
|
91
182
|
sectors: Sector[];
|
|
92
183
|
/** Spawn points: feet x, z (inside a sector, standing on its floor) and the yaw to face. */
|
|
93
184
|
spawns: [x: number, z: number, yaw: number][];
|
|
185
|
+
/** Monsters at the start: x, z inside a sector, the yaw they face, their MONSTER kind. Absent: none. */
|
|
186
|
+
monsters?: [x: number, z: number, yaw: number, kind: number][];
|
|
187
|
+
/** Pickups at the start: x, z inside a sector, their ITEM kind. Absent: none. */
|
|
188
|
+
items?: [x: number, z: number, kind: number][];
|
|
189
|
+
/** Barred doorways. Absent: none. */
|
|
190
|
+
gates?: Gate[];
|
|
191
|
+
/** The goal pad, far from the start: touching it (within GOAL_R) turns the level to RETURN. */
|
|
192
|
+
goal?: [x: number, z: number];
|
|
193
|
+
/**
|
|
194
|
+
* Sector index of the exit, barred until the goal is touched. Usually the start room: players
|
|
195
|
+
* spawn in it and can walk out, but not back in until RETURN.
|
|
196
|
+
*/
|
|
197
|
+
exit?: number;
|
|
94
198
|
}
|
|
95
199
|
/** One directed edge of a sector, see compile in level.ts. */
|
|
96
200
|
export interface Edge {
|
|
@@ -108,6 +212,11 @@ export interface Level {
|
|
|
108
212
|
map: MapDef;
|
|
109
213
|
/** Every edge of every sector, in sector then point order. */
|
|
110
214
|
edges: Edge[];
|
|
215
|
+
/**
|
|
216
|
+
* Sectors that bodies cannot enter now: gates without their key, the exit before RETURN.
|
|
217
|
+
* Mutable: set it with bar() in level.ts (host and client alike); sight and shots ignore it.
|
|
218
|
+
*/
|
|
219
|
+
barred: Set<number>;
|
|
111
220
|
}
|
|
112
221
|
/** One player in a snapshot. */
|
|
113
222
|
export interface SnapPlayer {
|
|
@@ -120,6 +229,8 @@ export interface SnapPlayer {
|
|
|
120
229
|
pitch: number;
|
|
121
230
|
ground: boolean;
|
|
122
231
|
cool: number;
|
|
232
|
+
/** Health, HEALTH at most; 0 is dead, waiting PLAYER_RESPAWN ticks to respawn at the start. */
|
|
233
|
+
hp: number;
|
|
123
234
|
/** Seq of the last input of this player the host applied: the client replays the ones after. */
|
|
124
235
|
ack: number;
|
|
125
236
|
}
|
|
@@ -129,6 +240,22 @@ export interface Snapshot {
|
|
|
129
240
|
players: SnapPlayer[];
|
|
130
241
|
/** Shots fired since the previous snapshot, in order. */
|
|
131
242
|
shots: Shot[];
|
|
243
|
+
/** Living monsters. */
|
|
244
|
+
monsters: Monster[];
|
|
245
|
+
/** Bullets in flight. */
|
|
246
|
+
bullets: Bullet[];
|
|
247
|
+
/** Events since the previous snapshot, in order. */
|
|
248
|
+
events: GameEvent[];
|
|
249
|
+
/** Index of the level in LEVELS (levels.ts). A change means a new level: clients rebuild. */
|
|
250
|
+
level: number;
|
|
251
|
+
/** The second run and later: monsters are faster and fire more often. */
|
|
252
|
+
hard: boolean;
|
|
253
|
+
/** PHASE of the level. */
|
|
254
|
+
phase: number;
|
|
255
|
+
/** Keys the team holds: bit (1 << ITEM.KEY_*). */
|
|
256
|
+
keys: number;
|
|
257
|
+
/** Pickups lying in the level. */
|
|
258
|
+
items: Item[];
|
|
132
259
|
}
|
|
133
260
|
/** Room rules, set by the host. Defaults in constants.ts (RULES). */
|
|
134
261
|
export interface Rules {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@korial29/tiny-fps",
|
|
3
3
|
"description": "Tiny multiplayer first-person shooter 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.4.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|