@korial29/tiny-fps 0.11.0 → 0.12.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/README.md +27 -38
- package/dist/index.js +12 -13
- package/dist/local.js +1 -1
- package/dist/server.js +261 -2220
- package/dist/types/client/audio.d.ts +3 -16
- package/dist/types/client/effects.d.ts +7 -162
- package/dist/types/client/hud.d.ts +1 -25
- package/dist/types/client/input.d.ts +2 -2
- package/dist/types/client/lights.d.ts +6 -12
- package/dist/types/client/mesh.d.ts +13 -22
- package/dist/types/client/predict.d.ts +2 -27
- package/dist/types/client/render.d.ts +6 -9
- package/dist/types/client/sfx.d.ts +27 -20
- package/dist/types/client/soldier.d.ts +21 -0
- package/dist/types/shared/constants.d.ts +2 -49
- package/dist/types/shared/level.d.ts +0 -2
- package/dist/types/shared/map.d.ts +7 -2
- package/dist/types/shared/physics.d.ts +3 -19
- package/dist/types/shared/protocol.d.ts +2 -22
- package/dist/types/shared/room.d.ts +12 -53
- package/dist/types/shared/trace.d.ts +12 -0
- package/dist/types/shared/types.d.ts +2 -147
- package/package.json +2 -2
- package/dist/types/client/gun.d.ts +0 -24
- package/dist/types/client/items.d.ts +0 -19
- package/dist/types/client/monsters.d.ts +0 -60
- package/dist/types/client/progress.d.ts +0 -56
- package/dist/types/shared/levels.d.ts +0 -2
- package/dist/types/shared/monsters.d.ts +0 -23
- package/dist/types/shared/shoot.d.ts +0 -33
package/dist/server.js
CHANGED
|
@@ -3,81 +3,18 @@ import { WebSocketServer } from "ws";
|
|
|
3
3
|
/** Player cylinder. */
|
|
4
4
|
var PLAYER_R = .4;
|
|
5
5
|
var PLAYER_H = 1.8;
|
|
6
|
-
/** Camera height above the feet. */
|
|
7
|
-
var EYE = 1.6;
|
|
8
6
|
/** Pitch is clamped to ±MAX_PITCH radians, just short of straight up or down. */
|
|
9
7
|
var MAX_PITCH = 1.55;
|
|
10
8
|
/** A floor at most this much higher is walked onto; a higher one needs a jump. */
|
|
11
9
|
var STEP_H = .5;
|
|
12
|
-
/** Speed factor while the trigger is held. */
|
|
13
|
-
var FIRE_SLOW = .5;
|
|
14
|
-
/** Largest angle, in radians, between a shot and the view direction. */
|
|
15
|
-
var SPREAD = .02;
|
|
16
|
-
var WALKER_R = .4;
|
|
17
|
-
var WALKER_H = 1.8;
|
|
18
|
-
var WALKER_SPEED = 2.5;
|
|
19
|
-
var FLYER_R = .45;
|
|
20
|
-
var FLYER_H = .9;
|
|
21
|
-
/** A flyer's underside floats this high above the floor below it, ceilings allowing. */
|
|
22
|
-
var FLYER_HOVER = 1.2;
|
|
23
|
-
var FLYER_SPEED = 3.5;
|
|
24
|
-
var SIGHT_COS = Math.cos(Math.PI / 6);
|
|
25
|
-
var BULLET_R = .15;
|
|
26
|
-
/** Hard mode (second run on): monster speed factor, and the share of SHOOT_EVERY and MELEE_EVERY. */
|
|
27
|
-
var HARD_SPEED = 1.3;
|
|
28
|
-
var HARD_RATE = .6;
|
|
29
10
|
var RULES = { maxPlayers: 16 };
|
|
30
|
-
// src/shared/types.ts
|
|
31
|
-
/** Bits of Input.keys. Keys are read by KeyboardEvent.code, so WASD is ZQSD on AZERTY. */
|
|
32
|
-
var KEY = {
|
|
33
|
-
FORWARD: 1,
|
|
34
|
-
BACK: 2,
|
|
35
|
-
LEFT: 4,
|
|
36
|
-
RIGHT: 8,
|
|
37
|
-
JUMP: 16,
|
|
38
|
-
/** Left mouse button: the chaingun fires every FIRE_EVERY steps while held. */
|
|
39
|
-
FIRE: 32
|
|
40
|
-
};
|
|
41
|
-
/** Monster kinds. */
|
|
42
|
-
var MONSTER = {
|
|
43
|
-
/** Walks the floors like a player, shoots bullets from afar and hits up close. */
|
|
44
|
-
WALKER: 0,
|
|
45
|
-
/** Hovers above the floor, flies over steps and pits, hits up close. */
|
|
46
|
-
FLYER: 1
|
|
47
|
-
};
|
|
48
|
-
/** What a GameEvent reports. */
|
|
49
|
-
var EVENT = {
|
|
50
|
-
/** Monster `id` died, (x, y, z) the middle of its body: gibs and an explosion. */
|
|
51
|
-
DIE: 0,
|
|
52
|
-
/** Player `id` was hit by a bullet or a blow at (x, y, z). Harmless until health (step 4). */
|
|
53
|
-
HURT: 1,
|
|
54
|
-
/** A bullet burst on the level at (x, y, z); `id` is the bullet. */
|
|
55
|
-
BOOM: 2,
|
|
56
|
-
/** Monster `id` swung at its target from (x, y, z), hit or miss. */
|
|
57
|
-
SWING: 3
|
|
58
|
-
};
|
|
59
|
-
/** Pickup kinds. A key is shared by the team: once anyone takes it, its gates open for all. */
|
|
60
|
-
var ITEM = {
|
|
61
|
-
/** Gives HEAL health, up to HEALTH. Left in the level by every DROP_EVERY-th kill. */
|
|
62
|
-
HEALTH: 0,
|
|
63
|
-
KEY_RED: 1,
|
|
64
|
-
KEY_BLUE: 2,
|
|
65
|
-
KEY_YELLOW: 3
|
|
66
|
-
};
|
|
67
|
-
/** Where a level stands. */
|
|
68
|
-
var PHASE = {
|
|
69
|
-
/** Find the goal: the exit sector is barred. */
|
|
70
|
-
HUNT: 0,
|
|
71
|
-
/** The goal was touched: the exit sector is open; the level is won when every living player is in it. */
|
|
72
|
-
RETURN: 1
|
|
73
|
-
};
|
|
74
11
|
// src/shared/level.ts
|
|
75
12
|
/** Joins every edge a→b with the sector that has b→a, if any: that edge is a portal. */
|
|
76
13
|
var compile = (map) => {
|
|
77
14
|
const key = (ax, az, bx, bz) => `${ax},${az},${bx},${bz}`;
|
|
78
15
|
const owner = /* @__PURE__ */ new Map();
|
|
79
16
|
map.sectors.forEach(({ pts }, s) => pts.forEach(([ax, az], i) => owner.set(key(ax, az, ...pts[(i + 1) % pts.length]), s)));
|
|
80
|
-
|
|
17
|
+
return {
|
|
81
18
|
map,
|
|
82
19
|
edges: map.sectors.flatMap(({ pts }, front) => pts.map(([ax, az], i) => {
|
|
83
20
|
const [bx, bz] = pts[(i + 1) % pts.length];
|
|
@@ -89,17 +26,8 @@ var compile = (map) => {
|
|
|
89
26
|
front,
|
|
90
27
|
back: owner.get(key(bx, bz, ax, az)) ?? -1
|
|
91
28
|
};
|
|
92
|
-
}))
|
|
93
|
-
barred: /* @__PURE__ */ new Set()
|
|
29
|
+
}))
|
|
94
30
|
};
|
|
95
|
-
bar(lvl, 0, PHASE.HUNT);
|
|
96
|
-
return lvl;
|
|
97
|
-
};
|
|
98
|
-
/** Bars the gates whose key is not in `keys` (bits 1 << ITEM.KEY_*), and the exit before RETURN. */
|
|
99
|
-
var bar = ({ map, barred }, keys, phase) => {
|
|
100
|
-
barred.clear();
|
|
101
|
-
map.gates?.forEach((g) => keys & 1 << g.key || barred.add(g.sector));
|
|
102
|
-
if (map.exit !== void 0 && phase === PHASE.HUNT) barred.add(map.exit);
|
|
103
31
|
};
|
|
104
32
|
/** Whether (x, z) is inside the sector, its edges included. */
|
|
105
33
|
var inside = ({ pts }, x, z) => pts.every(([ax, az], i) => {
|
|
@@ -108,1491 +36,263 @@ var inside = ({ pts }, x, z) => pts.every(([ax, az], i) => {
|
|
|
108
36
|
});
|
|
109
37
|
/** Index of the first sector holding (x, z), -1 outside the map. */
|
|
110
38
|
var sectorAt = ({ map }, x, z) => map.sectors.findIndex((s) => inside(s, x, z));
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
]);
|
|
145
|
-
/** n slices of a box along x (0) or z (1), the first at floor f and each one rising by up. */
|
|
146
|
-
var stairs = (axis, [x0, z0, x1, z1], f, up, n, ceil, tex, light) => Array.from({ length: n }, (_, i) => {
|
|
147
|
-
const [lo, hi] = axis ? [z0, z1] : [x0, x1];
|
|
148
|
-
const [a, b, h] = [
|
|
149
|
-
lo + i * (hi - lo) / n,
|
|
150
|
-
lo + (i + 1) * (hi - lo) / n,
|
|
151
|
-
+(f + i * up).toFixed(1)
|
|
152
|
-
];
|
|
153
|
-
return axis ? [
|
|
154
|
-
x0,
|
|
155
|
-
a,
|
|
156
|
-
x1,
|
|
157
|
-
b,
|
|
158
|
-
h,
|
|
159
|
-
ceil,
|
|
160
|
-
tex,
|
|
161
|
-
light
|
|
162
|
-
] : [
|
|
163
|
-
a,
|
|
164
|
-
z0,
|
|
165
|
-
b,
|
|
166
|
-
z1,
|
|
167
|
-
h,
|
|
168
|
-
ceil,
|
|
169
|
-
tex,
|
|
170
|
-
light
|
|
171
|
-
];
|
|
39
|
+
// src/shared/types.ts
|
|
40
|
+
/** Bits of Input.keys. Keys are read by KeyboardEvent.code, so WASD is ZQSD on AZERTY. */
|
|
41
|
+
var KEY = {
|
|
42
|
+
FORWARD: 1,
|
|
43
|
+
BACK: 2,
|
|
44
|
+
LEFT: 4,
|
|
45
|
+
RIGHT: 8,
|
|
46
|
+
JUMP: 16
|
|
47
|
+
};
|
|
48
|
+
/** Procedural textures, generated by the client. A sector names one per surface. */
|
|
49
|
+
var TEX = {
|
|
50
|
+
BRICK: 0,
|
|
51
|
+
TILE: 1,
|
|
52
|
+
LAVA: 2,
|
|
53
|
+
STONE: 3,
|
|
54
|
+
/** Riveted metal plates. */
|
|
55
|
+
METAL: 4,
|
|
56
|
+
/** Planks, the grain running along u. */
|
|
57
|
+
WOOD: 5,
|
|
58
|
+
/** Stone blocks with moss in the joints. */
|
|
59
|
+
MOSS: 6,
|
|
60
|
+
/** Metal floor grating over darkness. */
|
|
61
|
+
GRATE: 7
|
|
62
|
+
};
|
|
63
|
+
// src/shared/map.ts
|
|
64
|
+
var sector = (pts, floor, ceil, ft, light) => ({
|
|
65
|
+
pts,
|
|
66
|
+
floor,
|
|
67
|
+
ceil,
|
|
68
|
+
ft,
|
|
69
|
+
wt: TEX.BRICK,
|
|
70
|
+
ct: TEX.STONE,
|
|
71
|
+
light
|
|
172
72
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
73
|
+
sector([
|
|
74
|
+
[0, 0],
|
|
75
|
+
[16, 0],
|
|
76
|
+
[16, 6],
|
|
77
|
+
[16, 10],
|
|
78
|
+
[16, 16],
|
|
79
|
+
[0, 16]
|
|
80
|
+
], 1, 5, TEX.TILE), sector([
|
|
81
|
+
[16, 6],
|
|
82
|
+
[20, 6],
|
|
83
|
+
[20, 10],
|
|
84
|
+
[16, 10]
|
|
85
|
+
], 1, 3.5, TEX.TILE, .6), sector([
|
|
86
|
+
[20, 0],
|
|
87
|
+
[36, 0],
|
|
88
|
+
[36, 6],
|
|
89
|
+
[30, 6],
|
|
90
|
+
[26, 6],
|
|
91
|
+
[20, 6]
|
|
92
|
+
], 1, 7, TEX.TILE), sector([
|
|
93
|
+
[20, 6],
|
|
94
|
+
[26, 6],
|
|
95
|
+
[26, 10],
|
|
96
|
+
[20, 10]
|
|
97
|
+
], 1, 7, TEX.TILE), sector([
|
|
98
|
+
[30, 6],
|
|
99
|
+
[36, 6],
|
|
100
|
+
[36, 10],
|
|
101
|
+
[30, 10]
|
|
102
|
+
], 1, 7, TEX.TILE), sector([
|
|
103
|
+
[20, 10],
|
|
104
|
+
[26, 10],
|
|
105
|
+
[30, 10],
|
|
106
|
+
[36, 10],
|
|
107
|
+
[36, 16],
|
|
108
|
+
[32, 16],
|
|
109
|
+
[28, 16],
|
|
110
|
+
[20, 16]
|
|
111
|
+
], 1, 7, TEX.TILE), sector([
|
|
112
|
+
[26, 6],
|
|
113
|
+
[30, 6],
|
|
114
|
+
[30, 10],
|
|
115
|
+
[26, 10]
|
|
116
|
+
], 0, 7, TEX.LAVA), sector([
|
|
117
|
+
[28, 16],
|
|
118
|
+
[32, 16],
|
|
119
|
+
[32, 17],
|
|
120
|
+
[28, 17]
|
|
121
|
+
], 1.4, 7, TEX.STONE), sector([
|
|
122
|
+
[28, 17],
|
|
123
|
+
[32, 17],
|
|
124
|
+
[32, 18],
|
|
125
|
+
[28, 18]
|
|
126
|
+
], 1.8, 7, TEX.STONE), sector([
|
|
127
|
+
[28, 18],
|
|
128
|
+
[32, 18],
|
|
129
|
+
[32, 19],
|
|
130
|
+
[28, 19]
|
|
131
|
+
], 2.2, 7, TEX.STONE), sector([
|
|
132
|
+
[24, 19],
|
|
133
|
+
[28, 19],
|
|
134
|
+
[32, 19],
|
|
135
|
+
[36, 19],
|
|
136
|
+
[36, 26],
|
|
137
|
+
[24, 26]
|
|
138
|
+
], 2.6, 7, TEX.TILE, .8);
|
|
139
|
+
/** Grid lines of ROOF, metres: every feature below starts and ends on one, so the cells join exactly. */
|
|
140
|
+
var GRID_X = [
|
|
141
|
+
0,
|
|
142
|
+
1.2,
|
|
143
|
+
7,
|
|
144
|
+
9,
|
|
145
|
+
14,
|
|
146
|
+
17,
|
|
147
|
+
23,
|
|
148
|
+
26,
|
|
149
|
+
27,
|
|
150
|
+
31,
|
|
151
|
+
38.8,
|
|
152
|
+
40
|
|
178
153
|
];
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
1,
|
|
182
|
-
|
|
183
|
-
|
|
154
|
+
var GRID_Z = [
|
|
155
|
+
0,
|
|
156
|
+
1.2,
|
|
157
|
+
8,
|
|
158
|
+
9,
|
|
159
|
+
10,
|
|
160
|
+
11,
|
|
161
|
+
16,
|
|
162
|
+
18,
|
|
163
|
+
24,
|
|
164
|
+
26,
|
|
165
|
+
38.8,
|
|
166
|
+
40
|
|
184
167
|
];
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
168
|
+
/** A very high ceiling: the sky, until the sector walls go (step 2). */
|
|
169
|
+
var SKY = 120;
|
|
170
|
+
/** What ROOF is made of, painted in order: x0, z0, x1, z1, floor height, floor texture. */
|
|
171
|
+
var PAINT = [
|
|
172
|
+
[
|
|
173
|
+
0,
|
|
174
|
+
0,
|
|
175
|
+
40,
|
|
176
|
+
40,
|
|
177
|
+
1,
|
|
178
|
+
TEX.STONE
|
|
179
|
+
],
|
|
180
|
+
[
|
|
181
|
+
1.2,
|
|
182
|
+
1.2,
|
|
183
|
+
38.8,
|
|
184
|
+
38.8,
|
|
185
|
+
0,
|
|
186
|
+
TEX.TILE
|
|
187
|
+
],
|
|
188
|
+
[
|
|
189
|
+
14,
|
|
190
|
+
1.2,
|
|
191
|
+
26,
|
|
192
|
+
8,
|
|
193
|
+
1.6,
|
|
194
|
+
TEX.TILE
|
|
195
|
+
],
|
|
196
|
+
[
|
|
197
|
+
17,
|
|
198
|
+
8,
|
|
199
|
+
23,
|
|
200
|
+
9,
|
|
201
|
+
1.2,
|
|
202
|
+
TEX.STONE
|
|
203
|
+
],
|
|
204
|
+
[
|
|
205
|
+
17,
|
|
206
|
+
9,
|
|
207
|
+
23,
|
|
208
|
+
10,
|
|
209
|
+
.8,
|
|
210
|
+
TEX.STONE
|
|
211
|
+
],
|
|
212
|
+
[
|
|
213
|
+
17,
|
|
214
|
+
10,
|
|
215
|
+
23,
|
|
216
|
+
11,
|
|
217
|
+
.4,
|
|
218
|
+
TEX.STONE
|
|
219
|
+
],
|
|
220
|
+
[
|
|
221
|
+
7,
|
|
222
|
+
16,
|
|
223
|
+
9,
|
|
224
|
+
18,
|
|
225
|
+
1,
|
|
226
|
+
TEX.WOOD
|
|
227
|
+
],
|
|
228
|
+
[
|
|
229
|
+
27,
|
|
230
|
+
24,
|
|
231
|
+
31,
|
|
232
|
+
26,
|
|
233
|
+
2,
|
|
234
|
+
TEX.METAL
|
|
235
|
+
]
|
|
189
236
|
];
|
|
190
237
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
238
|
+
* The first rooftop, for the capture-the-flag game: a flat 40 x 40 m deck in the open, a 1 m
|
|
239
|
+
* parapet round it, a crate, a block and a platform with steps. Built as a grid of cells, one
|
|
240
|
+
* sector each: neighbours at one height are open to each other, and the edge is solid wall.
|
|
194
241
|
*/
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
ct: +t[2],
|
|
216
|
-
light,
|
|
217
|
-
tint
|
|
218
|
-
})),
|
|
219
|
-
spawns: Array.from({ length: 16 }, (_, i) => [
|
|
220
|
-
sx + i % 4 * 2,
|
|
221
|
-
sz + (i >> 2) * 2,
|
|
222
|
-
sd * QUARTER
|
|
223
|
-
]),
|
|
224
|
-
monsters: [...walkers.map(([x, z, d]) => [
|
|
225
|
-
x,
|
|
226
|
-
z,
|
|
227
|
-
d * QUARTER,
|
|
228
|
-
MONSTER.WALKER
|
|
229
|
-
]), ...flyers.map(([x, z, d]) => [
|
|
230
|
-
x,
|
|
231
|
-
z,
|
|
232
|
-
d * QUARTER,
|
|
233
|
-
MONSTER.FLYER
|
|
234
|
-
])],
|
|
235
|
-
items,
|
|
236
|
-
gates: rooms.flatMap(([, , , , , , , , key], sector) => key ? [{
|
|
237
|
-
sector,
|
|
238
|
-
key
|
|
239
|
-
}] : []),
|
|
240
|
-
goal,
|
|
241
|
-
exit: 0,
|
|
242
|
-
fog
|
|
243
|
-
};
|
|
244
|
-
};
|
|
245
|
-
var LEVELS = [
|
|
246
|
-
level("Warm-up", [
|
|
247
|
-
[
|
|
248
|
-
0,
|
|
249
|
-
0,
|
|
250
|
-
10,
|
|
251
|
-
10,
|
|
252
|
-
0,
|
|
253
|
-
4,
|
|
254
|
-
"103"
|
|
255
|
-
],
|
|
256
|
-
[
|
|
257
|
-
10,
|
|
258
|
-
4,
|
|
259
|
-
22,
|
|
260
|
-
6,
|
|
261
|
-
0,
|
|
262
|
-
2.8,
|
|
263
|
-
"333",
|
|
264
|
-
.6
|
|
265
|
-
],
|
|
266
|
-
...tinted([
|
|
267
|
-
1,
|
|
268
|
-
.85,
|
|
269
|
-
.65
|
|
270
|
-
], [
|
|
271
|
-
22,
|
|
272
|
-
0,
|
|
273
|
-
38,
|
|
274
|
-
14,
|
|
275
|
-
0,
|
|
276
|
-
6,
|
|
277
|
-
"553"
|
|
278
|
-
], ...stairs(0, [
|
|
279
|
-
38,
|
|
280
|
-
4,
|
|
281
|
-
42,
|
|
282
|
-
10
|
|
283
|
-
], .4, .4, 4, 6, "553")),
|
|
284
|
-
[
|
|
285
|
-
42,
|
|
286
|
-
2,
|
|
287
|
-
52,
|
|
288
|
-
12,
|
|
289
|
-
2,
|
|
290
|
-
6,
|
|
291
|
-
"103",
|
|
292
|
-
.9
|
|
293
|
-
],
|
|
294
|
-
...stairs(1, [
|
|
295
|
-
46,
|
|
296
|
-
12,
|
|
297
|
-
48,
|
|
298
|
-
22
|
|
299
|
-
], 1.6, -.4, 4, 4.8, "744", .7),
|
|
300
|
-
[
|
|
301
|
-
38,
|
|
302
|
-
22,
|
|
303
|
-
56,
|
|
304
|
-
36,
|
|
305
|
-
0,
|
|
306
|
-
6,
|
|
307
|
-
"113"
|
|
308
|
-
]
|
|
309
|
-
], [
|
|
310
|
-
2,
|
|
311
|
-
2,
|
|
312
|
-
6
|
|
313
|
-
], [
|
|
314
|
-
[
|
|
315
|
-
28,
|
|
316
|
-
4,
|
|
317
|
-
3
|
|
318
|
-
],
|
|
319
|
-
[
|
|
320
|
-
34,
|
|
321
|
-
10,
|
|
322
|
-
4
|
|
323
|
-
],
|
|
242
|
+
var ROOF = {
|
|
243
|
+
name: "Rooftops",
|
|
244
|
+
fog: [
|
|
245
|
+
.8,
|
|
246
|
+
.88,
|
|
247
|
+
1,
|
|
248
|
+
.02
|
|
249
|
+
],
|
|
250
|
+
sectors: GRID_X.slice(1).flatMap((x1, i) => GRID_Z.slice(1).map((z1, j) => {
|
|
251
|
+
const [x0, z0] = [GRID_X[i], GRID_Z[j]];
|
|
252
|
+
const [cx, cz] = [(x0 + x1) / 2, (z0 + z1) / 2];
|
|
253
|
+
const [, , , , floor, tex] = PAINT.filter(([ax, az, bx, bz]) => ax < cx && cx < bx && az < cz && cz < bz).at(-1);
|
|
254
|
+
return sector([
|
|
255
|
+
[x0, z0],
|
|
256
|
+
[x1, z0],
|
|
257
|
+
[x1, z1],
|
|
258
|
+
[x0, z1]
|
|
259
|
+
], floor, SKY, tex);
|
|
260
|
+
})),
|
|
261
|
+
spawns: [
|
|
324
262
|
[
|
|
325
|
-
48,
|
|
326
263
|
6,
|
|
327
|
-
4
|
|
328
|
-
],
|
|
329
|
-
[
|
|
330
|
-
44,
|
|
331
|
-
30,
|
|
332
|
-
0
|
|
333
|
-
]
|
|
334
|
-
], [[
|
|
335
|
-
30,
|
|
336
|
-
8,
|
|
337
|
-
0
|
|
338
|
-
], [
|
|
339
|
-
52,
|
|
340
|
-
28,
|
|
341
|
-
2
|
|
342
|
-
]], [
|
|
343
|
-
[
|
|
344
|
-
26,
|
|
345
|
-
12,
|
|
346
|
-
H
|
|
347
|
-
],
|
|
348
|
-
[
|
|
349
|
-
50,
|
|
350
|
-
10,
|
|
351
|
-
H
|
|
352
|
-
],
|
|
353
|
-
[
|
|
354
|
-
40,
|
|
355
264
|
34,
|
|
356
|
-
H
|
|
357
|
-
]
|
|
358
|
-
], [54, 34]),
|
|
359
|
-
level("Foundry", [
|
|
360
|
-
...tinted([
|
|
361
|
-
1,
|
|
362
|
-
.9,
|
|
363
|
-
.8
|
|
364
|
-
], [
|
|
365
|
-
0,
|
|
366
|
-
14,
|
|
367
|
-
10,
|
|
368
|
-
26,
|
|
369
|
-
0,
|
|
370
|
-
4,
|
|
371
|
-
"443"
|
|
372
|
-
], [
|
|
373
|
-
10,
|
|
374
|
-
22,
|
|
375
|
-
20,
|
|
376
|
-
24,
|
|
377
|
-
0,
|
|
378
|
-
2.8,
|
|
379
|
-
"744",
|
|
380
|
-
.6
|
|
381
|
-
]),
|
|
382
|
-
...tinted([
|
|
383
|
-
1,
|
|
384
|
-
.5,
|
|
385
|
-
.25
|
|
386
|
-
], [
|
|
387
|
-
24,
|
|
388
|
-
8,
|
|
389
|
-
28,
|
|
390
|
-
16,
|
|
391
|
-
0,
|
|
392
|
-
9,
|
|
393
|
-
"744"
|
|
394
|
-
], [
|
|
395
|
-
20,
|
|
396
|
-
16,
|
|
397
|
-
28,
|
|
398
|
-
30,
|
|
399
|
-
0,
|
|
400
|
-
9,
|
|
401
|
-
"443"
|
|
402
|
-
], ...stairs(1, [
|
|
403
|
-
20,
|
|
404
|
-
8,
|
|
405
|
-
24,
|
|
406
|
-
16
|
|
407
|
-
], 2, -.4, 5, 9, "744"), [
|
|
408
|
-
28,
|
|
409
|
-
8,
|
|
410
|
-
42,
|
|
411
|
-
18,
|
|
412
|
-
-1.6,
|
|
413
|
-
9,
|
|
414
|
-
"233",
|
|
415
|
-
.9
|
|
416
|
-
], ...stairs(1, [
|
|
417
|
-
28,
|
|
418
|
-
18,
|
|
419
|
-
42,
|
|
420
|
-
21
|
|
421
|
-
], -1.2, .4, 3, 9, "333"), [
|
|
422
|
-
28,
|
|
423
|
-
21,
|
|
424
|
-
50,
|
|
425
|
-
30,
|
|
426
|
-
0,
|
|
427
|
-
9,
|
|
428
|
-
"744"
|
|
429
|
-
], [
|
|
430
|
-
42,
|
|
431
|
-
8,
|
|
432
|
-
50,
|
|
433
|
-
21,
|
|
434
|
-
0,
|
|
435
|
-
9,
|
|
436
|
-
"744"
|
|
437
|
-
], [
|
|
438
|
-
20,
|
|
439
|
-
0,
|
|
440
|
-
50,
|
|
441
|
-
8,
|
|
442
|
-
2.4,
|
|
443
|
-
9,
|
|
444
|
-
"744",
|
|
445
|
-
.8
|
|
446
|
-
]),
|
|
447
|
-
[
|
|
448
|
-
50,
|
|
449
|
-
14,
|
|
450
|
-
51,
|
|
451
|
-
17,
|
|
452
|
-
0,
|
|
453
|
-
3.5,
|
|
454
|
-
"444",
|
|
455
|
-
1,
|
|
456
|
-
R
|
|
457
|
-
],
|
|
458
|
-
...tinted([
|
|
459
|
-
.85,
|
|
460
|
-
.65,
|
|
461
|
-
.5
|
|
462
|
-
], [
|
|
463
|
-
51,
|
|
464
|
-
8,
|
|
465
|
-
59,
|
|
466
|
-
26,
|
|
467
|
-
0,
|
|
468
|
-
7,
|
|
469
|
-
"443",
|
|
470
|
-
.6
|
|
471
|
-
], [
|
|
472
|
-
59,
|
|
473
|
-
8,
|
|
474
|
-
67,
|
|
475
|
-
26,
|
|
476
|
-
.4,
|
|
477
|
-
7,
|
|
478
|
-
"143",
|
|
479
|
-
.8
|
|
480
|
-
], [
|
|
481
|
-
57,
|
|
482
|
-
26,
|
|
483
|
-
59,
|
|
484
|
-
36,
|
|
485
|
-
0,
|
|
486
|
-
4.8,
|
|
487
|
-
"744",
|
|
488
|
-
.7
|
|
489
|
-
]),
|
|
490
|
-
...tinted([
|
|
491
|
-
1,
|
|
492
|
-
.6,
|
|
493
|
-
.45
|
|
494
|
-
], [
|
|
495
|
-
50,
|
|
496
|
-
36,
|
|
497
|
-
68,
|
|
498
|
-
50,
|
|
499
|
-
0,
|
|
500
|
-
7,
|
|
501
|
-
"443"
|
|
502
|
-
])
|
|
503
|
-
], [
|
|
504
|
-
2,
|
|
505
|
-
16,
|
|
506
|
-
6
|
|
507
|
-
], [
|
|
508
|
-
[
|
|
509
|
-
46,
|
|
510
|
-
14,
|
|
511
|
-
2
|
|
512
|
-
],
|
|
513
|
-
[
|
|
514
|
-
36,
|
|
515
|
-
26,
|
|
516
265
|
0
|
|
517
266
|
],
|
|
518
267
|
[
|
|
519
|
-
38,
|
|
520
|
-
4,
|
|
521
|
-
2
|
|
522
|
-
],
|
|
523
|
-
[
|
|
524
|
-
56,
|
|
525
|
-
12,
|
|
526
|
-
4
|
|
527
|
-
],
|
|
528
|
-
[
|
|
529
|
-
62,
|
|
530
|
-
20,
|
|
531
|
-
2
|
|
532
|
-
],
|
|
533
|
-
[
|
|
534
|
-
60,
|
|
535
|
-
44,
|
|
536
|
-
0
|
|
537
|
-
]
|
|
538
|
-
], [
|
|
539
|
-
[
|
|
540
|
-
35,
|
|
541
268
|
13,
|
|
542
|
-
0
|
|
543
|
-
],
|
|
544
|
-
[
|
|
545
|
-
60,
|
|
546
|
-
14,
|
|
547
|
-
4
|
|
548
|
-
],
|
|
549
|
-
[
|
|
550
|
-
58,
|
|
551
|
-
42,
|
|
552
|
-
6
|
|
553
|
-
]
|
|
554
|
-
], [
|
|
555
|
-
[
|
|
556
|
-
24,
|
|
557
|
-
26,
|
|
558
|
-
H
|
|
559
|
-
],
|
|
560
|
-
[
|
|
561
|
-
24,
|
|
562
|
-
4,
|
|
563
|
-
H
|
|
564
|
-
],
|
|
565
|
-
[
|
|
566
|
-
64,
|
|
567
|
-
10,
|
|
568
|
-
H
|
|
569
|
-
],
|
|
570
|
-
[
|
|
571
|
-
52,
|
|
572
|
-
46,
|
|
573
|
-
H
|
|
574
|
-
],
|
|
575
|
-
[
|
|
576
|
-
46,
|
|
577
|
-
4,
|
|
578
|
-
R
|
|
579
|
-
]
|
|
580
|
-
], [66, 48], [
|
|
581
|
-
.07,
|
|
582
|
-
.05,
|
|
583
|
-
.04,
|
|
584
|
-
.026
|
|
585
|
-
]),
|
|
586
|
-
level("Cistern", [
|
|
587
|
-
...tinted([
|
|
588
|
-
.45,
|
|
589
|
-
.9,
|
|
590
|
-
1
|
|
591
|
-
], [
|
|
592
|
-
0,
|
|
593
|
-
20,
|
|
594
|
-
10,
|
|
595
|
-
32,
|
|
596
|
-
0,
|
|
597
|
-
4,
|
|
598
|
-
"363"
|
|
599
|
-
], [
|
|
600
|
-
10,
|
|
601
|
-
26,
|
|
602
|
-
20,
|
|
603
|
-
28,
|
|
604
|
-
0,
|
|
605
|
-
2.8,
|
|
606
|
-
"363",
|
|
607
|
-
.6
|
|
608
|
-
], [
|
|
609
|
-
20,
|
|
610
|
-
14,
|
|
611
|
-
56,
|
|
612
|
-
26,
|
|
613
|
-
0,
|
|
614
|
-
11,
|
|
615
|
-
"363",
|
|
616
|
-
.9
|
|
617
|
-
], [
|
|
618
|
-
20,
|
|
619
|
-
26,
|
|
620
|
-
34,
|
|
621
|
-
32,
|
|
622
|
-
0,
|
|
623
|
-
11,
|
|
624
|
-
"363",
|
|
625
|
-
.9
|
|
626
|
-
]),
|
|
627
|
-
...tinted([
|
|
628
|
-
.9,
|
|
629
|
-
.6,
|
|
630
|
-
.45
|
|
631
|
-
], [
|
|
632
269
|
34,
|
|
633
|
-
26,
|
|
634
|
-
42,
|
|
635
|
-
32,
|
|
636
|
-
-.4,
|
|
637
|
-
11,
|
|
638
|
-
"263"
|
|
639
|
-
]),
|
|
640
|
-
...tinted([
|
|
641
|
-
.45,
|
|
642
|
-
.9,
|
|
643
|
-
1
|
|
644
|
-
], [
|
|
645
|
-
42,
|
|
646
|
-
26,
|
|
647
|
-
56,
|
|
648
|
-
32,
|
|
649
|
-
0,
|
|
650
|
-
11,
|
|
651
|
-
"363",
|
|
652
|
-
.9
|
|
653
|
-
], [
|
|
654
|
-
20,
|
|
655
|
-
32,
|
|
656
|
-
56,
|
|
657
|
-
44,
|
|
658
|
-
0,
|
|
659
|
-
11,
|
|
660
|
-
"363",
|
|
661
|
-
.9
|
|
662
|
-
], [
|
|
663
|
-
36,
|
|
664
|
-
44,
|
|
665
|
-
38,
|
|
666
|
-
54,
|
|
667
|
-
0,
|
|
668
|
-
1.9,
|
|
669
|
-
"000",
|
|
670
|
-
.35
|
|
671
|
-
], [
|
|
672
|
-
30,
|
|
673
|
-
54,
|
|
674
|
-
46,
|
|
675
|
-
68,
|
|
676
|
-
0,
|
|
677
|
-
5,
|
|
678
|
-
"003",
|
|
679
|
-
.7
|
|
680
|
-
]),
|
|
681
|
-
[
|
|
682
|
-
56,
|
|
683
|
-
28,
|
|
684
|
-
57,
|
|
685
|
-
31,
|
|
686
|
-
0,
|
|
687
|
-
4,
|
|
688
|
-
"444",
|
|
689
|
-
1,
|
|
690
|
-
R
|
|
691
|
-
],
|
|
692
|
-
...tinted([
|
|
693
|
-
.55,
|
|
694
|
-
.85,
|
|
695
|
-
1
|
|
696
|
-
], ...stairs(0, [
|
|
697
|
-
57,
|
|
698
|
-
26,
|
|
699
|
-
65,
|
|
700
|
-
32
|
|
701
|
-
], .4, .4, 8, 10, "333", .8)),
|
|
702
|
-
...tinted([
|
|
703
|
-
.7,
|
|
704
|
-
1,
|
|
705
|
-
.85
|
|
706
|
-
], [
|
|
707
|
-
65,
|
|
708
|
-
22,
|
|
709
|
-
81,
|
|
710
|
-
36,
|
|
711
|
-
3.6,
|
|
712
|
-
11,
|
|
713
|
-
"563"
|
|
714
|
-
]),
|
|
715
|
-
[
|
|
716
|
-
71,
|
|
717
|
-
36,
|
|
718
|
-
74,
|
|
719
|
-
37,
|
|
720
|
-
3.6,
|
|
721
|
-
7,
|
|
722
|
-
"444",
|
|
723
|
-
1,
|
|
724
|
-
B
|
|
725
|
-
],
|
|
726
|
-
...tinted([
|
|
727
|
-
.45,
|
|
728
|
-
.9,
|
|
729
|
-
1
|
|
730
|
-
], [
|
|
731
|
-
71,
|
|
732
|
-
37,
|
|
733
|
-
74,
|
|
734
|
-
48,
|
|
735
|
-
3.6,
|
|
736
|
-
6.4,
|
|
737
|
-
"363",
|
|
738
|
-
.6
|
|
739
|
-
]),
|
|
740
|
-
...tinted([
|
|
741
|
-
.9,
|
|
742
|
-
.6,
|
|
743
|
-
.45
|
|
744
|
-
], [
|
|
745
|
-
62,
|
|
746
|
-
48,
|
|
747
|
-
82,
|
|
748
|
-
64,
|
|
749
|
-
3.6,
|
|
750
|
-
10,
|
|
751
|
-
"263"
|
|
752
|
-
])
|
|
753
|
-
], [
|
|
754
|
-
2,
|
|
755
|
-
22,
|
|
756
|
-
6
|
|
757
|
-
], [
|
|
758
|
-
[
|
|
759
|
-
30,
|
|
760
|
-
18,
|
|
761
|
-
4
|
|
762
|
-
],
|
|
763
|
-
[
|
|
764
|
-
50,
|
|
765
|
-
20,
|
|
766
|
-
4
|
|
767
|
-
],
|
|
768
|
-
[
|
|
769
|
-
30,
|
|
770
|
-
40,
|
|
771
|
-
0
|
|
772
|
-
],
|
|
773
|
-
[
|
|
774
|
-
50,
|
|
775
|
-
40,
|
|
776
|
-
0
|
|
777
|
-
],
|
|
778
|
-
[
|
|
779
|
-
36,
|
|
780
|
-
60,
|
|
781
|
-
2
|
|
782
|
-
],
|
|
783
|
-
[
|
|
784
|
-
42,
|
|
785
|
-
64,
|
|
786
|
-
0
|
|
787
|
-
],
|
|
788
|
-
[
|
|
789
|
-
76,
|
|
790
|
-
28,
|
|
791
|
-
2
|
|
792
|
-
],
|
|
793
|
-
[
|
|
794
|
-
70,
|
|
795
|
-
58,
|
|
796
|
-
0
|
|
797
|
-
]
|
|
798
|
-
], [
|
|
799
|
-
[
|
|
800
|
-
26,
|
|
801
|
-
24,
|
|
802
|
-
0
|
|
803
|
-
],
|
|
804
|
-
[
|
|
805
|
-
48,
|
|
806
|
-
22,
|
|
807
270
|
0
|
|
808
271
|
],
|
|
809
272
|
[
|
|
810
|
-
36,
|
|
811
|
-
40,
|
|
812
|
-
2
|
|
813
|
-
],
|
|
814
|
-
[
|
|
815
|
-
72,
|
|
816
|
-
56,
|
|
817
|
-
4
|
|
818
|
-
]
|
|
819
|
-
], [
|
|
820
|
-
[
|
|
821
|
-
24,
|
|
822
|
-
40,
|
|
823
|
-
H
|
|
824
|
-
],
|
|
825
|
-
[
|
|
826
|
-
52,
|
|
827
|
-
42,
|
|
828
|
-
H
|
|
829
|
-
],
|
|
830
|
-
[
|
|
831
|
-
44,
|
|
832
|
-
57,
|
|
833
|
-
H
|
|
834
|
-
],
|
|
835
|
-
[
|
|
836
|
-
68,
|
|
837
|
-
34,
|
|
838
|
-
H
|
|
839
|
-
],
|
|
840
|
-
[
|
|
841
|
-
64,
|
|
842
|
-
62,
|
|
843
|
-
H
|
|
844
|
-
],
|
|
845
|
-
[
|
|
846
|
-
38,
|
|
847
|
-
66,
|
|
848
|
-
R
|
|
849
|
-
],
|
|
850
|
-
[
|
|
851
|
-
79,
|
|
852
|
-
24,
|
|
853
|
-
B
|
|
854
|
-
]
|
|
855
|
-
], [80, 62], [
|
|
856
|
-
.04,
|
|
857
|
-
.11,
|
|
858
|
-
.1,
|
|
859
|
-
.034
|
|
860
|
-
]),
|
|
861
|
-
level("Loop", [
|
|
862
|
-
...tinted(WOOD, [
|
|
863
|
-
0,
|
|
864
|
-
44,
|
|
865
|
-
10,
|
|
866
|
-
56,
|
|
867
|
-
0,
|
|
868
|
-
4,
|
|
869
|
-
"153"
|
|
870
|
-
], [
|
|
871
|
-
10,
|
|
872
|
-
49,
|
|
873
273
|
20,
|
|
874
|
-
51,
|
|
875
|
-
0,
|
|
876
|
-
2.8,
|
|
877
|
-
"553",
|
|
878
|
-
.6
|
|
879
|
-
]),
|
|
880
|
-
[
|
|
881
|
-
20,
|
|
882
|
-
30,
|
|
883
|
-
52,
|
|
884
|
-
40,
|
|
885
|
-
0,
|
|
886
|
-
9,
|
|
887
|
-
"113"
|
|
888
|
-
],
|
|
889
|
-
[
|
|
890
|
-
20,
|
|
891
|
-
48,
|
|
892
|
-
52,
|
|
893
|
-
58,
|
|
894
|
-
0,
|
|
895
|
-
9,
|
|
896
|
-
"113",
|
|
897
|
-
.9
|
|
898
|
-
],
|
|
899
|
-
[
|
|
900
|
-
20,
|
|
901
|
-
40,
|
|
902
|
-
32,
|
|
903
|
-
48,
|
|
904
|
-
0,
|
|
905
|
-
9,
|
|
906
|
-
"113"
|
|
907
|
-
],
|
|
908
|
-
[
|
|
909
|
-
40,
|
|
910
|
-
40,
|
|
911
|
-
52,
|
|
912
|
-
48,
|
|
913
|
-
0,
|
|
914
|
-
9,
|
|
915
|
-
"113"
|
|
916
|
-
],
|
|
917
|
-
[
|
|
918
|
-
20,
|
|
919
|
-
22,
|
|
920
|
-
49,
|
|
921
|
-
30,
|
|
922
|
-
3.2,
|
|
923
|
-
9,
|
|
924
|
-
"743",
|
|
925
|
-
.8
|
|
926
|
-
],
|
|
927
|
-
...tinted(WOOD, [
|
|
928
|
-
34,
|
|
929
|
-
58,
|
|
930
|
-
36,
|
|
931
|
-
66,
|
|
932
|
-
0,
|
|
933
|
-
2.8,
|
|
934
|
-
"553",
|
|
935
|
-
.4
|
|
936
|
-
], [
|
|
937
|
-
26,
|
|
938
|
-
66,
|
|
939
|
-
46,
|
|
940
|
-
84,
|
|
941
|
-
0,
|
|
942
|
-
5,
|
|
943
|
-
"353",
|
|
944
|
-
.5
|
|
945
|
-
]),
|
|
946
|
-
[
|
|
947
|
-
52,
|
|
948
|
-
42,
|
|
949
|
-
53,
|
|
950
|
-
45,
|
|
951
|
-
0,
|
|
952
|
-
4,
|
|
953
|
-
"444",
|
|
954
|
-
1,
|
|
955
|
-
R
|
|
956
|
-
],
|
|
957
|
-
...tinted(WOOD, [
|
|
958
|
-
53,
|
|
959
|
-
36,
|
|
960
|
-
64,
|
|
961
|
-
54,
|
|
962
|
-
0,
|
|
963
|
-
6,
|
|
964
|
-
"153",
|
|
965
|
-
.8
|
|
966
|
-
], [
|
|
967
|
-
64,
|
|
968
|
-
36,
|
|
969
|
-
70,
|
|
970
|
-
54,
|
|
971
|
-
.4,
|
|
972
|
-
6,
|
|
973
|
-
"253",
|
|
974
|
-
.8
|
|
975
|
-
]),
|
|
976
|
-
[
|
|
977
|
-
60,
|
|
978
|
-
35,
|
|
979
|
-
63,
|
|
980
|
-
36,
|
|
981
|
-
0,
|
|
982
|
-
4,
|
|
983
|
-
"444",
|
|
984
|
-
1,
|
|
985
|
-
B
|
|
986
|
-
],
|
|
987
|
-
...tinted(WOOD, [
|
|
988
|
-
57,
|
|
989
|
-
12,
|
|
990
|
-
77,
|
|
991
|
-
35,
|
|
992
|
-
0,
|
|
993
|
-
8,
|
|
994
|
-
"053",
|
|
995
|
-
.9
|
|
996
|
-
]),
|
|
997
|
-
[
|
|
998
|
-
56,
|
|
999
|
-
24,
|
|
1000
|
-
57,
|
|
1001
|
-
27,
|
|
1002
|
-
0,
|
|
1003
|
-
4,
|
|
1004
|
-
"444",
|
|
1005
|
-
1,
|
|
1006
|
-
Y
|
|
1007
|
-
],
|
|
1008
|
-
...stairs(0, [
|
|
1009
|
-
49,
|
|
1010
|
-
22,
|
|
1011
|
-
56,
|
|
1012
|
-
30
|
|
1013
|
-
], 2.8, -.4, 7, 9, "744", .8),
|
|
1014
|
-
...tinted(WOOD, [
|
|
1015
|
-
12,
|
|
1016
|
-
24,
|
|
1017
|
-
20,
|
|
1018
|
-
28,
|
|
1019
|
-
3.2,
|
|
1020
|
-
6,
|
|
1021
|
-
"744",
|
|
1022
|
-
.6
|
|
1023
|
-
], [
|
|
1024
|
-
0,
|
|
1025
|
-
10,
|
|
1026
|
-
12,
|
|
1027
274
|
34,
|
|
1028
|
-
3.2,
|
|
1029
|
-
9,
|
|
1030
|
-
"553"
|
|
1031
|
-
])
|
|
1032
|
-
], [
|
|
1033
|
-
2,
|
|
1034
|
-
46,
|
|
1035
|
-
6
|
|
1036
|
-
], [
|
|
1037
|
-
[
|
|
1038
|
-
30,
|
|
1039
|
-
36,
|
|
1040
|
-
4
|
|
1041
|
-
],
|
|
1042
|
-
[
|
|
1043
|
-
44,
|
|
1044
|
-
36,
|
|
1045
|
-
2
|
|
1046
|
-
],
|
|
1047
|
-
[
|
|
1048
|
-
40,
|
|
1049
|
-
52,
|
|
1050
|
-
0
|
|
1051
|
-
],
|
|
1052
|
-
[
|
|
1053
|
-
40,
|
|
1054
|
-
26,
|
|
1055
|
-
4
|
|
1056
|
-
],
|
|
1057
|
-
[
|
|
1058
|
-
30,
|
|
1059
|
-
74,
|
|
1060
|
-
6
|
|
1061
|
-
],
|
|
1062
|
-
[
|
|
1063
|
-
42,
|
|
1064
|
-
78,
|
|
1065
|
-
2
|
|
1066
|
-
],
|
|
1067
|
-
[
|
|
1068
|
-
56,
|
|
1069
|
-
40,
|
|
1070
|
-
6
|
|
1071
|
-
],
|
|
1072
|
-
[
|
|
1073
|
-
64,
|
|
1074
|
-
50,
|
|
1075
|
-
2
|
|
1076
|
-
],
|
|
1077
|
-
[
|
|
1078
|
-
62,
|
|
1079
|
-
18,
|
|
1080
|
-
4
|
|
1081
|
-
],
|
|
1082
|
-
[
|
|
1083
|
-
72,
|
|
1084
|
-
28,
|
|
1085
|
-
2
|
|
1086
|
-
],
|
|
1087
|
-
[
|
|
1088
|
-
6,
|
|
1089
|
-
22,
|
|
1090
|
-
0
|
|
1091
|
-
]
|
|
1092
|
-
], [
|
|
1093
|
-
[
|
|
1094
|
-
28,
|
|
1095
|
-
48,
|
|
1096
|
-
0
|
|
1097
|
-
],
|
|
1098
|
-
[
|
|
1099
|
-
46,
|
|
1100
|
-
44,
|
|
1101
|
-
4
|
|
1102
|
-
],
|
|
1103
|
-
[
|
|
1104
|
-
36,
|
|
1105
|
-
72,
|
|
1106
275
|
0
|
|
1107
276
|
],
|
|
1108
277
|
[
|
|
1109
|
-
60,
|
|
1110
|
-
45,
|
|
1111
|
-
6
|
|
1112
|
-
],
|
|
1113
|
-
[
|
|
1114
|
-
68,
|
|
1115
|
-
22,
|
|
1116
|
-
4
|
|
1117
|
-
]
|
|
1118
|
-
], [
|
|
1119
|
-
[
|
|
1120
|
-
24,
|
|
1121
|
-
54,
|
|
1122
|
-
H
|
|
1123
|
-
],
|
|
1124
|
-
[
|
|
1125
|
-
24,
|
|
1126
|
-
26,
|
|
1127
|
-
H
|
|
1128
|
-
],
|
|
1129
|
-
[
|
|
1130
|
-
44,
|
|
1131
|
-
80,
|
|
1132
|
-
H
|
|
1133
|
-
],
|
|
1134
|
-
[
|
|
1135
|
-
68,
|
|
1136
|
-
38,
|
|
1137
|
-
H
|
|
1138
|
-
],
|
|
1139
|
-
[
|
|
1140
|
-
74,
|
|
1141
|
-
14,
|
|
1142
|
-
H
|
|
1143
|
-
],
|
|
1144
|
-
[
|
|
1145
|
-
36,
|
|
1146
|
-
82,
|
|
1147
|
-
R
|
|
1148
|
-
],
|
|
1149
|
-
[
|
|
1150
|
-
68,
|
|
1151
|
-
52,
|
|
1152
|
-
B
|
|
1153
|
-
],
|
|
1154
|
-
[
|
|
1155
|
-
74,
|
|
1156
|
-
32,
|
|
1157
|
-
Y
|
|
1158
|
-
]
|
|
1159
|
-
], [6, 13], [
|
|
1160
|
-
.06,
|
|
1161
|
-
.045,
|
|
1162
|
-
.04,
|
|
1163
|
-
.02
|
|
1164
|
-
]),
|
|
1165
|
-
level("Citadel", [
|
|
1166
|
-
...tinted(STEEL, [
|
|
1167
|
-
0,
|
|
1168
|
-
60,
|
|
1169
|
-
10,
|
|
1170
|
-
72,
|
|
1171
|
-
0,
|
|
1172
|
-
4,
|
|
1173
|
-
"303"
|
|
1174
|
-
], [
|
|
1175
|
-
10,
|
|
1176
|
-
65,
|
|
1177
|
-
24,
|
|
1178
|
-
67,
|
|
1179
|
-
0,
|
|
1180
|
-
2.8,
|
|
1181
|
-
"363",
|
|
1182
|
-
.6
|
|
1183
|
-
], [
|
|
1184
|
-
24,
|
|
1185
|
-
48,
|
|
1186
|
-
56,
|
|
1187
|
-
84,
|
|
1188
|
-
0,
|
|
1189
|
-
12,
|
|
1190
|
-
"363"
|
|
1191
|
-
], [
|
|
1192
|
-
27,
|
|
1193
|
-
40,
|
|
1194
|
-
31,
|
|
1195
|
-
48,
|
|
1196
|
-
0,
|
|
1197
|
-
3.4,
|
|
1198
|
-
"363",
|
|
1199
|
-
.4
|
|
1200
|
-
]),
|
|
1201
|
-
...tinted([
|
|
1202
|
-
.85,
|
|
1203
|
-
.7,
|
|
1204
|
-
.65
|
|
1205
|
-
], [
|
|
1206
|
-
24,
|
|
1207
|
-
16,
|
|
1208
|
-
34,
|
|
1209
|
-
40,
|
|
1210
|
-
0,
|
|
1211
|
-
12,
|
|
1212
|
-
"443",
|
|
1213
|
-
.9
|
|
1214
|
-
], ...stairs(0, [
|
|
1215
|
-
34,
|
|
1216
|
-
16,
|
|
1217
|
-
40,
|
|
1218
|
-
26
|
|
1219
|
-
], -.4, -.4, 3, 12, "243"), [
|
|
1220
|
-
34,
|
|
1221
|
-
26,
|
|
1222
|
-
40,
|
|
1223
|
-
30,
|
|
1224
|
-
0,
|
|
1225
|
-
12,
|
|
1226
|
-
"744"
|
|
1227
|
-
], ...stairs(0, [
|
|
1228
|
-
34,
|
|
1229
|
-
30,
|
|
1230
|
-
40,
|
|
1231
|
-
40
|
|
1232
|
-
], -.4, -.4, 3, 12, "243"), [
|
|
1233
|
-
40,
|
|
1234
|
-
16,
|
|
1235
|
-
60,
|
|
1236
|
-
40,
|
|
1237
|
-
0,
|
|
1238
|
-
12,
|
|
1239
|
-
"443",
|
|
1240
|
-
.9
|
|
1241
|
-
]),
|
|
1242
|
-
[
|
|
1243
|
-
60,
|
|
1244
278
|
27,
|
|
1245
|
-
61,
|
|
1246
|
-
30,
|
|
1247
|
-
0,
|
|
1248
|
-
4,
|
|
1249
|
-
"444",
|
|
1250
|
-
1,
|
|
1251
|
-
Y
|
|
1252
|
-
],
|
|
1253
|
-
...tinted([
|
|
1254
|
-
.55,
|
|
1255
|
-
.3,
|
|
1256
|
-
1
|
|
1257
|
-
], [
|
|
1258
|
-
61,
|
|
1259
|
-
10,
|
|
1260
|
-
101,
|
|
1261
|
-
16,
|
|
1262
|
-
0,
|
|
1263
|
-
14,
|
|
1264
|
-
"443",
|
|
1265
|
-
1
|
|
1266
|
-
], [
|
|
1267
|
-
61,
|
|
1268
|
-
40,
|
|
1269
|
-
101,
|
|
1270
|
-
46,
|
|
1271
|
-
0,
|
|
1272
|
-
14,
|
|
1273
|
-
"443",
|
|
1274
|
-
1
|
|
1275
|
-
], [
|
|
1276
|
-
61,
|
|
1277
|
-
16,
|
|
1278
|
-
69,
|
|
1279
|
-
40,
|
|
1280
|
-
0,
|
|
1281
|
-
14,
|
|
1282
|
-
"443",
|
|
1283
|
-
1
|
|
1284
|
-
], [
|
|
1285
|
-
93,
|
|
1286
|
-
16,
|
|
1287
|
-
101,
|
|
1288
|
-
40,
|
|
1289
|
-
0,
|
|
1290
|
-
14,
|
|
1291
|
-
"443",
|
|
1292
|
-
1
|
|
1293
|
-
], [
|
|
1294
|
-
69,
|
|
1295
|
-
16,
|
|
1296
|
-
93,
|
|
1297
|
-
20,
|
|
1298
|
-
.4,
|
|
1299
|
-
14,
|
|
1300
|
-
"243",
|
|
1301
|
-
1
|
|
1302
|
-
], [
|
|
1303
|
-
69,
|
|
1304
|
-
36,
|
|
1305
|
-
93,
|
|
1306
|
-
40,
|
|
1307
|
-
.4,
|
|
1308
|
-
14,
|
|
1309
|
-
"243",
|
|
1310
|
-
1
|
|
1311
|
-
], [
|
|
1312
|
-
69,
|
|
1313
|
-
20,
|
|
1314
|
-
73,
|
|
1315
|
-
36,
|
|
1316
|
-
.4,
|
|
1317
|
-
14,
|
|
1318
|
-
"243",
|
|
1319
|
-
1
|
|
1320
|
-
], [
|
|
1321
|
-
89,
|
|
1322
|
-
20,
|
|
1323
|
-
93,
|
|
1324
|
-
36,
|
|
1325
|
-
.4,
|
|
1326
|
-
14,
|
|
1327
|
-
"243",
|
|
1328
|
-
1
|
|
1329
|
-
], [
|
|
1330
|
-
73,
|
|
1331
|
-
20,
|
|
1332
|
-
89,
|
|
1333
|
-
36,
|
|
1334
|
-
.8,
|
|
1335
|
-
14,
|
|
1336
|
-
"744",
|
|
1337
|
-
1
|
|
1338
|
-
]),
|
|
1339
|
-
[
|
|
1340
|
-
101,
|
|
1341
|
-
26,
|
|
1342
|
-
111,
|
|
1343
|
-
28,
|
|
1344
|
-
0,
|
|
1345
|
-
3.2,
|
|
1346
|
-
"744",
|
|
1347
|
-
.6
|
|
1348
|
-
],
|
|
1349
|
-
[
|
|
1350
|
-
111,
|
|
1351
|
-
16,
|
|
1352
|
-
131,
|
|
1353
|
-
40,
|
|
1354
|
-
0,
|
|
1355
|
-
8,
|
|
1356
|
-
"163"
|
|
1357
|
-
],
|
|
1358
|
-
[
|
|
1359
|
-
56,
|
|
1360
|
-
66,
|
|
1361
|
-
57,
|
|
1362
|
-
69,
|
|
1363
|
-
0,
|
|
1364
|
-
4,
|
|
1365
|
-
"444",
|
|
1366
|
-
1,
|
|
1367
|
-
R
|
|
1368
|
-
],
|
|
1369
|
-
...tinted([
|
|
1370
|
-
1,
|
|
1371
|
-
.5,
|
|
1372
|
-
.45
|
|
1373
|
-
], [
|
|
1374
|
-
57,
|
|
1375
|
-
56,
|
|
1376
|
-
75,
|
|
1377
|
-
80,
|
|
1378
|
-
0,
|
|
1379
|
-
12,
|
|
1380
|
-
"443",
|
|
1381
|
-
.7
|
|
1382
|
-
], ...stairs(0, [
|
|
1383
|
-
75,
|
|
1384
|
-
60,
|
|
1385
|
-
85,
|
|
1386
|
-
72
|
|
1387
|
-
], .4, .4, 5, 12, "744", .8), [
|
|
1388
|
-
85,
|
|
1389
|
-
52,
|
|
1390
|
-
101,
|
|
1391
|
-
80,
|
|
1392
|
-
2.4,
|
|
1393
|
-
12,
|
|
1394
|
-
"543"
|
|
1395
|
-
]),
|
|
1396
|
-
[
|
|
1397
|
-
38,
|
|
1398
|
-
84,
|
|
1399
|
-
42,
|
|
1400
|
-
85,
|
|
1401
|
-
0,
|
|
1402
|
-
4,
|
|
1403
|
-
"444",
|
|
1404
|
-
1,
|
|
1405
|
-
B
|
|
1406
|
-
],
|
|
1407
|
-
...tinted([
|
|
1408
|
-
.6,
|
|
1409
|
-
.85,
|
|
1410
|
-
.85
|
|
1411
|
-
], [
|
|
1412
|
-
38,
|
|
1413
|
-
85,
|
|
1414
|
-
42,
|
|
1415
|
-
95,
|
|
1416
|
-
0,
|
|
1417
|
-
1.9,
|
|
1418
|
-
"363",
|
|
1419
|
-
.35
|
|
1420
|
-
], [
|
|
1421
|
-
28,
|
|
1422
|
-
95,
|
|
1423
|
-
56,
|
|
1424
|
-
115,
|
|
1425
|
-
0,
|
|
1426
|
-
6,
|
|
1427
|
-
"663",
|
|
1428
|
-
.6
|
|
1429
|
-
])
|
|
1430
|
-
], [
|
|
1431
|
-
2,
|
|
1432
|
-
62,
|
|
1433
|
-
6
|
|
1434
|
-
], [
|
|
1435
|
-
[
|
|
1436
279
|
34,
|
|
1437
|
-
56,
|
|
1438
|
-
4
|
|
1439
|
-
],
|
|
1440
|
-
[
|
|
1441
|
-
50,
|
|
1442
|
-
56,
|
|
1443
|
-
2
|
|
1444
|
-
],
|
|
1445
|
-
[
|
|
1446
|
-
36,
|
|
1447
|
-
76,
|
|
1448
280
|
0
|
|
1449
281
|
],
|
|
1450
282
|
[
|
|
1451
|
-
46,
|
|
1452
|
-
20,
|
|
1453
|
-
4
|
|
1454
|
-
],
|
|
1455
|
-
[
|
|
1456
|
-
54,
|
|
1457
283
|
34,
|
|
1458
|
-
2
|
|
1459
|
-
],
|
|
1460
|
-
[
|
|
1461
|
-
66,
|
|
1462
|
-
60,
|
|
1463
|
-
2
|
|
1464
|
-
],
|
|
1465
|
-
[
|
|
1466
|
-
66,
|
|
1467
|
-
76,
|
|
1468
|
-
0
|
|
1469
|
-
],
|
|
1470
|
-
[
|
|
1471
|
-
92,
|
|
1472
|
-
60,
|
|
1473
|
-
2
|
|
1474
|
-
],
|
|
1475
|
-
[
|
|
1476
284
|
34,
|
|
1477
|
-
100,
|
|
1478
|
-
4
|
|
1479
|
-
],
|
|
1480
|
-
[
|
|
1481
|
-
50,
|
|
1482
|
-
108,
|
|
1483
|
-
2
|
|
1484
|
-
],
|
|
1485
|
-
[
|
|
1486
|
-
70,
|
|
1487
|
-
13,
|
|
1488
|
-
4
|
|
1489
|
-
],
|
|
1490
|
-
[
|
|
1491
|
-
92,
|
|
1492
|
-
13,
|
|
1493
|
-
2
|
|
1494
|
-
],
|
|
1495
|
-
[
|
|
1496
|
-
70,
|
|
1497
|
-
43,
|
|
1498
|
-
0
|
|
1499
|
-
],
|
|
1500
|
-
[
|
|
1501
|
-
92,
|
|
1502
|
-
43,
|
|
1503
|
-
6
|
|
1504
|
-
]
|
|
1505
|
-
], [
|
|
1506
|
-
[
|
|
1507
|
-
30,
|
|
1508
|
-
70,
|
|
1509
285
|
0
|
|
1510
286
|
],
|
|
1511
287
|
[
|
|
1512
|
-
|
|
1513
|
-
68,
|
|
1514
|
-
0
|
|
1515
|
-
],
|
|
1516
|
-
[
|
|
1517
|
-
50,
|
|
1518
|
-
28,
|
|
1519
|
-
0
|
|
1520
|
-
],
|
|
1521
|
-
[
|
|
1522
|
-
76,
|
|
1523
|
-
26,
|
|
1524
|
-
0
|
|
1525
|
-
],
|
|
1526
|
-
[
|
|
1527
|
-
86,
|
|
1528
|
-
30,
|
|
1529
|
-
0
|
|
1530
|
-
],
|
|
1531
|
-
[
|
|
1532
|
-
81,
|
|
288
|
+
20,
|
|
1533
289
|
22,
|
|
1534
290
|
0
|
|
1535
291
|
]
|
|
1536
|
-
]
|
|
1537
|
-
|
|
1538
|
-
30,
|
|
1539
|
-
80,
|
|
1540
|
-
H
|
|
1541
|
-
],
|
|
1542
|
-
[
|
|
1543
|
-
56,
|
|
1544
|
-
36,
|
|
1545
|
-
H
|
|
1546
|
-
],
|
|
1547
|
-
[
|
|
1548
|
-
60,
|
|
1549
|
-
78,
|
|
1550
|
-
H
|
|
1551
|
-
],
|
|
1552
|
-
[
|
|
1553
|
-
50,
|
|
1554
|
-
112,
|
|
1555
|
-
H
|
|
1556
|
-
],
|
|
1557
|
-
[
|
|
1558
|
-
64,
|
|
1559
|
-
13,
|
|
1560
|
-
H
|
|
1561
|
-
],
|
|
1562
|
-
[
|
|
1563
|
-
98,
|
|
1564
|
-
43,
|
|
1565
|
-
H
|
|
1566
|
-
],
|
|
1567
|
-
[
|
|
1568
|
-
114,
|
|
1569
|
-
38,
|
|
1570
|
-
H
|
|
1571
|
-
],
|
|
1572
|
-
[
|
|
1573
|
-
52,
|
|
1574
|
-
22,
|
|
1575
|
-
R
|
|
1576
|
-
],
|
|
1577
|
-
[
|
|
1578
|
-
95,
|
|
1579
|
-
66,
|
|
1580
|
-
B
|
|
1581
|
-
],
|
|
1582
|
-
[
|
|
1583
|
-
42,
|
|
1584
|
-
110,
|
|
1585
|
-
Y
|
|
1586
|
-
]
|
|
1587
|
-
], [127, 36], [
|
|
1588
|
-
.045,
|
|
1589
|
-
.05,
|
|
1590
|
-
.075,
|
|
1591
|
-
.02
|
|
1592
|
-
])
|
|
1593
|
-
];
|
|
292
|
+
]
|
|
293
|
+
};
|
|
1594
294
|
// src/shared/physics.ts
|
|
1595
|
-
var DT
|
|
295
|
+
var DT = 1 / 60;
|
|
1596
296
|
var TAU = Math.PI * 2;
|
|
1597
297
|
/** Overlaps smaller than this are rounding noise, not contact. */
|
|
1598
298
|
var EPS = 1e-6;
|
|
@@ -1609,13 +309,13 @@ var forward = (yaw) => [-Math.sin(yaw), -Math.cos(yaw)];
|
|
|
1609
309
|
var f32 = Math.fround;
|
|
1610
310
|
var clamp = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
1611
311
|
/**
|
|
1612
|
-
* Whether the edge stops a body of height h whose feet are at y: a solid wall, a
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
312
|
+
* Whether the edge stops a body of height h whose feet are at y: a solid wall, a floor on the far
|
|
313
|
+
* side more than `step` above the feet, or an opening (the lower ceiling minus the higher floor)
|
|
314
|
+
* too short for the body or under the head. SKIN keeps rounding from flipping the answer for a
|
|
315
|
+
* player resting on a step or against a ceiling.
|
|
1616
316
|
*/
|
|
1617
|
-
var shut = ({ map
|
|
1618
|
-
if (e.back < 0
|
|
317
|
+
var shut = ({ map }, e, y, h, step) => {
|
|
318
|
+
if (e.back < 0) return true;
|
|
1619
319
|
const f = map.sectors[e.front];
|
|
1620
320
|
const k = map.sectors[e.back];
|
|
1621
321
|
const top = Math.min(f.ceil, k.ceil);
|
|
@@ -1692,7 +392,7 @@ var span = (lvl, x, z, y, r, h, step) => {
|
|
|
1692
392
|
* collisions of the cylinder (PLAYER_R, PLAYER_H) with the sectors of the level: it slides along
|
|
1693
393
|
* shut edges (see shut and push), stands on the highest floor under the circle (a step up to
|
|
1694
394
|
* STEP_H is climbed at once, a higher one needs a jump, a ledge is a fall), and bumps its head on
|
|
1695
|
-
* the lowest ceiling
|
|
395
|
+
* the lowest ceiling, in place.
|
|
1696
396
|
*/
|
|
1697
397
|
var walk = (p, dx, dz, jump, lvl) => {
|
|
1698
398
|
p.x += dx;
|
|
@@ -1700,8 +400,8 @@ var walk = (p, dx, dz, jump, lvl) => {
|
|
|
1700
400
|
push(p, lvl, PLAYER_R, PLAYER_H, STEP_H);
|
|
1701
401
|
const [floor, ceil] = span(lvl, p.x, p.z, p.y, PLAYER_R, PLAYER_H, STEP_H);
|
|
1702
402
|
if (p.ground && jump) p.vy = 7;
|
|
1703
|
-
const vy = p.vy - 20 * DT
|
|
1704
|
-
p.y += (p.vy + vy) / 2 * DT
|
|
403
|
+
const vy = p.vy - 20 * DT;
|
|
404
|
+
p.y += (p.vy + vy) / 2 * DT;
|
|
1705
405
|
p.vy = vy;
|
|
1706
406
|
p.ground = false;
|
|
1707
407
|
if (p.y + 1.8 > ceil) {
|
|
@@ -1721,47 +421,17 @@ var walk = (p, dx, dz, jump, lvl) => {
|
|
|
1721
421
|
p.vy = f32(p.vy);
|
|
1722
422
|
};
|
|
1723
423
|
/**
|
|
1724
|
-
* Moves a flyer (underside at p.y, radius FLYER_R, height FLYER_H) by (dx, dy, dz): sideways it is
|
|
1725
|
-
* stopped by solid walls and by openings too small for it, and it never steps (it flies over
|
|
1726
|
-
* steps and pits); then y is held between FLYER_HOVER above the highest floor under it and the
|
|
1727
|
-
* lowest ceiling minus FLYER_H, the ceiling winning in a low room. Below the hover height it
|
|
1728
|
-
* rises at FLYER_SPEED, so crossing from a pit to a ledge is not a jump; the floor itself is
|
|
1729
|
-
* never entered.
|
|
1730
|
-
*/
|
|
1731
|
-
var fly = (p, dx, dy, dz, lvl) => {
|
|
1732
|
-
p.x += dx;
|
|
1733
|
-
p.z += dz;
|
|
1734
|
-
push(p, lvl, FLYER_R, FLYER_H, 0);
|
|
1735
|
-
const [floor, ceil] = span(lvl, p.x, p.z, p.y, FLYER_R, FLYER_H, 0);
|
|
1736
|
-
const hover = Math.min(floor + FLYER_HOVER, ceil - FLYER_H);
|
|
1737
|
-
const low = Math.max(floor, Math.min(hover, p.y + FLYER_SPEED * DT$1));
|
|
1738
|
-
p.y = Math.min(Math.max(p.y + dy, low), ceil - FLYER_H);
|
|
1739
|
-
p.x = f32(p.x);
|
|
1740
|
-
p.y = f32(p.y);
|
|
1741
|
-
p.z = f32(p.z);
|
|
1742
|
-
};
|
|
1743
|
-
/**
|
|
1744
424
|
* Applies one input for 1 / TICK_HZ s, in place: yaw and pitch from the input (pitch clamped to
|
|
1745
425
|
* MAX_PITCH), RUN_SPEED along the held keys (diagonals not faster), then walk().
|
|
1746
|
-
* The chaingun: `cool` counts down one per step, RUN_SPEED is scaled by FIRE_SLOW while KEY.FIRE
|
|
1747
|
-
* is held, and the step that finds it held with `cool` at 0 re-arms it to FIRE_EVERY and returns
|
|
1748
|
-
* true: the caller resolves a shot (one every FIRE_EVERY steps, the first at once).
|
|
1749
426
|
*/
|
|
1750
427
|
var move = (p, i, lvl) => {
|
|
1751
|
-
const fire = (i.keys & KEY.FIRE) !== 0;
|
|
1752
|
-
p.cool = Math.max(0, p.cool - 1);
|
|
1753
428
|
p.yaw = norm(i.yaw);
|
|
1754
429
|
p.pitch = Math.max(-MAX_PITCH, Math.min(MAX_PITCH, i.pitch));
|
|
1755
430
|
const f = (i.keys & KEY.FORWARD ? 1 : 0) - (i.keys & KEY.BACK ? 1 : 0);
|
|
1756
431
|
const s = (i.keys & KEY.RIGHT ? 1 : 0) - (i.keys & KEY.LEFT ? 1 : 0);
|
|
1757
|
-
const d = 6 * DT
|
|
432
|
+
const d = 6 * DT / (Math.hypot(f, s) || 1);
|
|
1758
433
|
const [fx, fz] = forward(p.yaw);
|
|
1759
434
|
walk(p, (fx * f - fz * s) * d, (fz * f + fx * s) * d, (i.keys & KEY.JUMP) !== 0, lvl);
|
|
1760
|
-
if (fire && !p.cool) {
|
|
1761
|
-
p.cool = 5;
|
|
1762
|
-
return true;
|
|
1763
|
-
}
|
|
1764
|
-
return false;
|
|
1765
435
|
};
|
|
1766
436
|
/** A player standing on the floor at spawn point n of the map (modulo the count). */
|
|
1767
437
|
var spawn = (id, lvl, n) => {
|
|
@@ -1776,423 +446,7 @@ var spawn = (id, lvl, n) => {
|
|
|
1776
446
|
vy: 0,
|
|
1777
447
|
yaw: norm(yaw),
|
|
1778
448
|
pitch: 0,
|
|
1779
|
-
ground: true
|
|
1780
|
-
cool: 0
|
|
1781
|
-
};
|
|
1782
|
-
};
|
|
1783
|
-
// src/shared/shoot.ts
|
|
1784
|
-
/** 32-bit integer hash (a xorshift-multiply round, twice). */
|
|
1785
|
-
var hash = (n) => {
|
|
1786
|
-
for (let k = 0; k < 2; k++) n = Math.imul(n ^ n >>> 16, 73244475);
|
|
1787
|
-
return (n ^ n >>> 16) >>> 0;
|
|
1788
|
-
};
|
|
1789
|
-
/**
|
|
1790
|
-
* Unit direction of a shot: the view direction at yaw and pitch (yaw 0, pitch 0 is -z; pitch > 0
|
|
1791
|
-
* looks up), turned by at most SPREAD in a direction hashed from seq, so the host and the
|
|
1792
|
-
* shooter's client agree on it.
|
|
1793
|
-
*/
|
|
1794
|
-
var aim = (yaw, pitch, seq) => {
|
|
1795
|
-
const [sy, cy, sp, cp] = [
|
|
1796
|
-
Math.sin(yaw),
|
|
1797
|
-
Math.cos(yaw),
|
|
1798
|
-
Math.sin(pitch),
|
|
1799
|
-
Math.cos(pitch)
|
|
1800
|
-
];
|
|
1801
|
-
const h = hash(seq + 1);
|
|
1802
|
-
const a = (h & 65535) / 65536 * TAU;
|
|
1803
|
-
const r = (h >>> 16) / 65535;
|
|
1804
|
-
const [x, y] = [Math.cos(a) * r * SPREAD, Math.sin(a) * r * SPREAD];
|
|
1805
|
-
const d = [
|
|
1806
|
-
-sy * cp + cy * x + sy * sp * y,
|
|
1807
|
-
sp + cp * y,
|
|
1808
|
-
-cy * cp - sy * x + cy * sp * y
|
|
1809
|
-
];
|
|
1810
|
-
const n = Math.hypot(...d);
|
|
1811
|
-
return [
|
|
1812
|
-
d[0] / n,
|
|
1813
|
-
d[1] / n,
|
|
1814
|
-
d[2] / n
|
|
1815
|
-
];
|
|
1816
|
-
};
|
|
1817
|
-
/**
|
|
1818
|
-
* Distance along the ray from o (inside the map) in the unit direction d to the first wall, step
|
|
1819
|
-
* face, floor or ceiling, at most max.
|
|
1820
|
-
*
|
|
1821
|
-
* Walks the sectors: in the current convex one the ray leaves through the edge with the least
|
|
1822
|
-
* crossing distance among the edges it goes outward through, or ends earlier on the floor or the
|
|
1823
|
-
* ceiling. A solid edge, or a portal whose opening does not hold the crossing height, ends it.
|
|
1824
|
-
*/
|
|
1825
|
-
var trace = (lvl, o, d, max) => {
|
|
1826
|
-
const { map, edges } = lvl;
|
|
1827
|
-
let s = Math.max(sectorAt(lvl, o[0], o[2]), 0);
|
|
1828
|
-
let t = 0;
|
|
1829
|
-
for (let hop = 0; hop <= map.sectors.length; hop++) {
|
|
1830
|
-
const { floor, ceil } = map.sectors[s];
|
|
1831
|
-
let exit = Infinity;
|
|
1832
|
-
let through;
|
|
1833
|
-
for (const e of edges) {
|
|
1834
|
-
if (e.front !== s) continue;
|
|
1835
|
-
const [ex, ez] = [e.bx - e.ax, e.bz - e.az];
|
|
1836
|
-
const out = d[2] * ex - d[0] * ez;
|
|
1837
|
-
if (out >= 0) continue;
|
|
1838
|
-
const x = Math.max(((o[2] - e.az) * ex - (o[0] - e.ax) * ez) / -out, t);
|
|
1839
|
-
const u = ((o[0] + x * d[0] - e.ax) * ex + (o[2] + x * d[2] - e.az) * ez) / (ex * ex + ez * ez);
|
|
1840
|
-
if (u > -1e-9 && u < 1 + 1e-9 && (x < exit - 1e-9 || x < exit + 1e-9 && e.back < 0)) [exit, through] = [x, e];
|
|
1841
|
-
}
|
|
1842
|
-
const flat = d[1] < 0 ? (floor - o[1]) / d[1] : d[1] > 0 ? (ceil - o[1]) / d[1] : Infinity;
|
|
1843
|
-
if (flat <= exit || !through) return Math.min(Math.max(flat, t), max);
|
|
1844
|
-
if (exit >= max) return max;
|
|
1845
|
-
const y = o[1] + exit * d[1];
|
|
1846
|
-
const k = through.back < 0 ? void 0 : map.sectors[through.back];
|
|
1847
|
-
if (!k || y < Math.max(floor, k.floor) || y > Math.min(ceil, k.ceil)) return exit;
|
|
1848
|
-
[s, t] = [through.back, exit];
|
|
1849
|
-
}
|
|
1850
|
-
return t;
|
|
1851
|
-
};
|
|
1852
|
-
/**
|
|
1853
|
-
* Distance at which the ray enters the upright cylinder of t (sides and caps), Infinity on a miss:
|
|
1854
|
-
* the span of the ray inside the infinite cylinder, cut to the span between the cap planes.
|
|
1855
|
-
*/
|
|
1856
|
-
var hit = (o, d, t) => {
|
|
1857
|
-
const [px, pz] = [o[0] - t.x, o[2] - t.z];
|
|
1858
|
-
const a = d[0] * d[0] + d[2] * d[2];
|
|
1859
|
-
const b = px * d[0] + pz * d[2];
|
|
1860
|
-
const c = px * px + pz * pz - t.r * t.r;
|
|
1861
|
-
let [lo, hi] = [0, Infinity];
|
|
1862
|
-
if (a > 1e-12) {
|
|
1863
|
-
const q = b * b - a * c;
|
|
1864
|
-
if (q < 0) return Infinity;
|
|
1865
|
-
[lo, hi] = [Math.max(0, (-b - Math.sqrt(q)) / a), (-b + Math.sqrt(q)) / a];
|
|
1866
|
-
} else if (c > 0) return Infinity;
|
|
1867
|
-
const [y0, y1] = [t.y - o[1], t.y + t.h - o[1]];
|
|
1868
|
-
if (d[1]) {
|
|
1869
|
-
const [u, v] = [y0 / d[1], y1 / d[1]];
|
|
1870
|
-
lo = Math.max(lo, Math.min(u, v));
|
|
1871
|
-
hi = Math.min(hi, Math.max(u, v));
|
|
1872
|
-
} else if (y0 > 0 || y1 < 0) return Infinity;
|
|
1873
|
-
return lo <= hi ? lo : Infinity;
|
|
1874
|
-
};
|
|
1875
|
-
/** The body a shot sees of a player. */
|
|
1876
|
-
var body = ({ id, x, y, z }) => ({
|
|
1877
|
-
id,
|
|
1878
|
-
x,
|
|
1879
|
-
y,
|
|
1880
|
-
z,
|
|
1881
|
-
r: PLAYER_R,
|
|
1882
|
-
h: PLAYER_H
|
|
1883
|
-
});
|
|
1884
|
-
/** The body a shot sees of a monster. */
|
|
1885
|
-
var monsterBody = ({ id, kind, x, y, z }) => {
|
|
1886
|
-
const walker = kind === MONSTER.WALKER;
|
|
1887
|
-
return {
|
|
1888
|
-
id,
|
|
1889
|
-
x,
|
|
1890
|
-
y,
|
|
1891
|
-
z,
|
|
1892
|
-
r: walker ? WALKER_R : FLYER_R,
|
|
1893
|
-
h: walker ? WALKER_H : FLYER_H
|
|
1894
|
-
};
|
|
1895
|
-
};
|
|
1896
|
-
/**
|
|
1897
|
-
* Resolves one shot of `shooter` (state after the step that fired) from its eye (feet + EYE)
|
|
1898
|
-
* along aim(yaw, pitch, seq): the nearest of the level (trace) and the upright cylinders
|
|
1899
|
-
* of `targets` (bodies: players, monsters) other than the shooter, within RANGE.
|
|
1900
|
-
*/
|
|
1901
|
-
var fire = (lvl, shooter, seq, targets) => {
|
|
1902
|
-
const o = [
|
|
1903
|
-
shooter.x,
|
|
1904
|
-
shooter.y + EYE,
|
|
1905
|
-
shooter.z
|
|
1906
|
-
];
|
|
1907
|
-
const d = aim(shooter.yaw, shooter.pitch, seq);
|
|
1908
|
-
let t = trace(lvl, o, d, 100);
|
|
1909
|
-
let id = -1;
|
|
1910
|
-
for (const p of targets) {
|
|
1911
|
-
const u = p.id === shooter.id ? Infinity : hit(o, d, p);
|
|
1912
|
-
if (u < t) [t, id] = [u, p.id];
|
|
1913
|
-
}
|
|
1914
|
-
return {
|
|
1915
|
-
id: shooter.id,
|
|
1916
|
-
x: o[0] + d[0] * t,
|
|
1917
|
-
y: o[1] + d[1] * t,
|
|
1918
|
-
z: o[2] + d[2] * t,
|
|
1919
|
-
hit: id
|
|
1920
|
-
};
|
|
1921
|
-
};
|
|
1922
|
-
// src/shared/monsters.ts
|
|
1923
|
-
var DT = 1 / 60;
|
|
1924
|
-
/** Radians a monster turns per tick toward its target. */
|
|
1925
|
-
var TURN$1 = .05;
|
|
1926
|
-
/** A patrolling monster moves at this share of its speed. */
|
|
1927
|
-
var PATROL = .4;
|
|
1928
|
-
/** A chasing monster stops this close (metres): inside MELEE_R, short of standing in the player. */
|
|
1929
|
-
var STOP = 1;
|
|
1930
|
-
/** Ticks between the start of a swing and its blow. */
|
|
1931
|
-
var SWING_DELAY = 15;
|
|
1932
|
-
/** Height of a player's chest above the feet: where monsters aim. */
|
|
1933
|
-
var CHEST = 1.2;
|
|
1934
|
-
/** The snapshot counts bullets with a u8. */
|
|
1935
|
-
var MAX_BULLETS = 255;
|
|
1936
|
-
/** Mulberry32: a small seeded generator, uniform in [0, 1). */
|
|
1937
|
-
var mulberry32 = (seed) => {
|
|
1938
|
-
let a = seed | 0;
|
|
1939
|
-
return () => {
|
|
1940
|
-
a = a + 1831565813 | 0;
|
|
1941
|
-
let t = Math.imul(a ^ a >>> 15, 1 | a);
|
|
1942
|
-
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
1943
|
-
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1944
|
-
};
|
|
1945
|
-
};
|
|
1946
|
-
/**
|
|
1947
|
-
* The monsters of the level's map, from the first spawn. In hard mode they move HARD_SPEED faster
|
|
1948
|
-
* and swing and shoot HARD_RATE as often.
|
|
1949
|
-
*/
|
|
1950
|
-
var createHorde = (lvl, rand, hard = false) => {
|
|
1951
|
-
const def = (lvl.map.monsters ?? []).slice(0, 64);
|
|
1952
|
-
const [fast, rate] = hard ? [HARD_SPEED, HARD_RATE] : [1, 1];
|
|
1953
|
-
const [walkerSpeed, flyerSpeed] = [WALKER_SPEED * fast, FLYER_SPEED * fast];
|
|
1954
|
-
const [shootEvery, meleeEvery] = [90, 45].map((n) => Math.round(n * rate));
|
|
1955
|
-
let shells = [];
|
|
1956
|
-
const events = [];
|
|
1957
|
-
let tick = 0;
|
|
1958
|
-
let nextBullet = 0;
|
|
1959
|
-
const mobs = def.map(([x, z, yaw, kind], i) => {
|
|
1960
|
-
const { floor, ceil } = lvl.map.sectors[Math.max(sectorAt(lvl, x, z), 0)];
|
|
1961
|
-
const flyer = kind === MONSTER.FLYER;
|
|
1962
|
-
return {
|
|
1963
|
-
id: 16 + i,
|
|
1964
|
-
kind,
|
|
1965
|
-
x: Math.fround(x),
|
|
1966
|
-
y: Math.fround(flyer ? Math.min(floor + FLYER_HOVER, ceil - FLYER_H) : floor),
|
|
1967
|
-
z: Math.fround(z),
|
|
1968
|
-
yaw: norm(yaw),
|
|
1969
|
-
chase: false,
|
|
1970
|
-
vy: 0,
|
|
1971
|
-
ground: true,
|
|
1972
|
-
target: -1,
|
|
1973
|
-
turn: Math.floor(rand() * 240),
|
|
1974
|
-
melee: 0,
|
|
1975
|
-
swing: 0,
|
|
1976
|
-
shoot: Math.floor(rand() * shootEvery)
|
|
1977
|
-
};
|
|
1978
|
-
});
|
|
1979
|
-
const mid = (m) => m.y + monsterBody(m).h / 2;
|
|
1980
|
-
const eye = (m) => [
|
|
1981
|
-
m.x,
|
|
1982
|
-
m.kind === MONSTER.WALKER ? m.y + EYE : mid(m),
|
|
1983
|
-
m.z
|
|
1984
|
-
];
|
|
1985
|
-
const eyeOf = (p) => [
|
|
1986
|
-
p.x,
|
|
1987
|
-
p.y + EYE,
|
|
1988
|
-
p.z
|
|
1989
|
-
];
|
|
1990
|
-
const hunt = (m, id) => {
|
|
1991
|
-
m.target = id;
|
|
1992
|
-
m.chase = id >= 0;
|
|
1993
|
-
};
|
|
1994
|
-
/** The monsters within ALERT_R of `src` that it can see, and that are not hunting, hunt `who`. */
|
|
1995
|
-
const alert = (src, who) => {
|
|
1996
|
-
for (const m of mobs) if (m !== src && !m.chase && Math.hypot(m.x - src.x, m.z - src.z) < 12 && !blocked(lvl, eye(src), eye(m))) hunt(m, who);
|
|
1997
|
-
};
|
|
1998
|
-
/** The nearest player in range, inside the sight cone and not hidden becomes the target. */
|
|
1999
|
-
const look = (m, players) => {
|
|
2000
|
-
const [fx, fz] = forward(m.yaw);
|
|
2001
|
-
let seen;
|
|
2002
|
-
let near = Infinity;
|
|
2003
|
-
for (const p of players) {
|
|
2004
|
-
const [dx, dz] = [p.x - m.x, p.z - m.z];
|
|
2005
|
-
const d = Math.hypot(dx, dz);
|
|
2006
|
-
if (d <= 30 && d < near && dx * fx + dz * fz >= SIGHT_COS * d && !blocked(lvl, eye(m), eyeOf(p))) [seen, near] = [p, d];
|
|
2007
|
-
}
|
|
2008
|
-
if (seen) {
|
|
2009
|
-
const spotted = !m.chase;
|
|
2010
|
-
hunt(m, seen.id);
|
|
2011
|
-
if (spotted) alert(m, seen.id);
|
|
2012
|
-
}
|
|
2013
|
-
};
|
|
2014
|
-
const turnTo = (m, yaw) => {
|
|
2015
|
-
const arc = ((yaw - m.yaw + Math.PI) % TAU + TAU) % TAU - Math.PI;
|
|
2016
|
-
m.yaw = norm(m.yaw + Math.max(-.05, Math.min(TURN$1, arc)));
|
|
2017
|
-
};
|
|
2018
|
-
/** Whether the floor under the axis is more than a step below `y`. */
|
|
2019
|
-
const ledge = (m, y) => lvl.map.sectors[Math.max(sectorAt(lvl, m.x, m.z), 0)].floor < y - STEP_H;
|
|
2020
|
-
const patrol = (m) => {
|
|
2021
|
-
const s = (m.kind === MONSTER.WALKER ? walkerSpeed : flyerSpeed) * PATROL * DT;
|
|
2022
|
-
const [fx, fz] = forward(m.yaw);
|
|
2023
|
-
const before = {
|
|
2024
|
-
x: m.x,
|
|
2025
|
-
y: m.y,
|
|
2026
|
-
z: m.z,
|
|
2027
|
-
vy: m.vy,
|
|
2028
|
-
ground: m.ground
|
|
2029
|
-
};
|
|
2030
|
-
if (m.kind === MONSTER.WALKER) walk(m, fx * s, fz * s, false, lvl);
|
|
2031
|
-
else fly(m, fx * s, -s, fz * s, lvl);
|
|
2032
|
-
const drop = m.kind === MONSTER.WALKER && ledge(m, before.y);
|
|
2033
|
-
if (drop || Math.hypot(m.x - before.x, m.z - before.z) < s / 2) {
|
|
2034
|
-
if (drop) Object.assign(m, before);
|
|
2035
|
-
m.yaw = norm(m.yaw + rand() * TAU);
|
|
2036
|
-
} else if (--m.turn <= 0) {
|
|
2037
|
-
m.turn = 120 + Math.floor(rand() * 240);
|
|
2038
|
-
m.yaw = norm(m.yaw + (rand() - .5) * Math.PI);
|
|
2039
|
-
}
|
|
2040
|
-
};
|
|
2041
|
-
/** A walker that sees the player fires a bullet from its eye at the chest, and waits. */
|
|
2042
|
-
const shootAt = (m, p) => {
|
|
2043
|
-
const [ox, oy, oz] = eye(m);
|
|
2044
|
-
if (shells.length >= MAX_BULLETS || blocked(lvl, [
|
|
2045
|
-
ox,
|
|
2046
|
-
oy,
|
|
2047
|
-
oz
|
|
2048
|
-
], eyeOf(p))) {
|
|
2049
|
-
m.shoot = 0;
|
|
2050
|
-
return;
|
|
2051
|
-
}
|
|
2052
|
-
const v = [
|
|
2053
|
-
p.x - ox,
|
|
2054
|
-
p.y + CHEST - oy,
|
|
2055
|
-
p.z - oz
|
|
2056
|
-
];
|
|
2057
|
-
const k = 12 * DT / Math.hypot(...v);
|
|
2058
|
-
shells.push({
|
|
2059
|
-
id: nextBullet++ & 255,
|
|
2060
|
-
x: ox,
|
|
2061
|
-
y: oy,
|
|
2062
|
-
z: oz,
|
|
2063
|
-
vx: v[0] * k,
|
|
2064
|
-
vy: v[1] * k,
|
|
2065
|
-
vz: v[2] * k,
|
|
2066
|
-
life: 300
|
|
2067
|
-
});
|
|
2068
|
-
m.shoot = shootEvery + Math.floor((rand() - .5) * 20);
|
|
2069
|
-
};
|
|
2070
|
-
const chase = (m, p) => {
|
|
2071
|
-
const [dx, dz] = [p.x - m.x, p.z - m.z];
|
|
2072
|
-
const d = Math.hypot(dx, dz);
|
|
2073
|
-
if (d > 1e-6) turnTo(m, Math.atan2(-dx, -dz));
|
|
2074
|
-
if (m.kind === MONSTER.WALKER) {
|
|
2075
|
-
const [fx, fz] = forward(m.yaw);
|
|
2076
|
-
const s = d > STOP ? walkerSpeed * DT : 0;
|
|
2077
|
-
walk(m, fx * s, fz * s, false, lvl);
|
|
2078
|
-
} else {
|
|
2079
|
-
const dy = p.y + CHEST - FLYER_H / 2 - m.y;
|
|
2080
|
-
const k = Math.min(1, flyerSpeed * DT / (Math.hypot(d, dy) || 1));
|
|
2081
|
-
fly(m, d > STOP ? dx * k : 0, dy * k, d > STOP ? dz * k : 0, lvl);
|
|
2082
|
-
}
|
|
2083
|
-
const near = Math.hypot(p.x - m.x, p.z - m.z) <= 1.4 && m.y < p.y + 1.8 && p.y < m.y + monsterBody(m).h;
|
|
2084
|
-
m.melee = Math.max(0, m.melee - 1);
|
|
2085
|
-
if (m.swing && !--m.swing && near) {
|
|
2086
|
-
const [fx, fz] = forward(m.yaw);
|
|
2087
|
-
if ((p.x - m.x) * fx + (p.z - m.z) * fz > 0) events.push({
|
|
2088
|
-
type: EVENT.HURT,
|
|
2089
|
-
id: p.id,
|
|
2090
|
-
x: p.x,
|
|
2091
|
-
y: p.y + CHEST,
|
|
2092
|
-
z: p.z
|
|
2093
|
-
});
|
|
2094
|
-
}
|
|
2095
|
-
if (near && !m.melee) {
|
|
2096
|
-
events.push({
|
|
2097
|
-
type: EVENT.SWING,
|
|
2098
|
-
id: m.id,
|
|
2099
|
-
x: m.x,
|
|
2100
|
-
y: mid(m),
|
|
2101
|
-
z: m.z
|
|
2102
|
-
});
|
|
2103
|
-
[m.melee, m.swing] = [meleeEvery, SWING_DELAY];
|
|
2104
|
-
}
|
|
2105
|
-
if (m.kind === MONSTER.WALKER && m.shoot-- <= 0 && d <= 30) shootAt(m, p);
|
|
2106
|
-
};
|
|
2107
|
-
/** Moves a bullet one tick; false when it is spent: it hit a player or the level, or timed out. */
|
|
2108
|
-
const advance = (b, players) => {
|
|
2109
|
-
const len = Math.hypot(b.vx, b.vy, b.vz);
|
|
2110
|
-
const o = [
|
|
2111
|
-
b.x,
|
|
2112
|
-
b.y,
|
|
2113
|
-
b.z
|
|
2114
|
-
];
|
|
2115
|
-
const dir = [
|
|
2116
|
-
b.vx / len,
|
|
2117
|
-
b.vy / len,
|
|
2118
|
-
b.vz / len
|
|
2119
|
-
];
|
|
2120
|
-
let t = trace(lvl, o, dir, len);
|
|
2121
|
-
let who = -1;
|
|
2122
|
-
for (const p of players) {
|
|
2123
|
-
const u = hit(o, dir, {
|
|
2124
|
-
id: p.id,
|
|
2125
|
-
x: p.x,
|
|
2126
|
-
y: p.y - BULLET_R,
|
|
2127
|
-
z: p.z,
|
|
2128
|
-
r: PLAYER_R + BULLET_R,
|
|
2129
|
-
h: PLAYER_H + 2 * BULLET_R
|
|
2130
|
-
});
|
|
2131
|
-
if (u < t) [t, who] = [u, p.id];
|
|
2132
|
-
}
|
|
2133
|
-
[b.x, b.y, b.z] = [
|
|
2134
|
-
o[0] + dir[0] * t,
|
|
2135
|
-
o[1] + dir[1] * t,
|
|
2136
|
-
o[2] + dir[2] * t
|
|
2137
|
-
];
|
|
2138
|
-
if (who >= 0) events.push({
|
|
2139
|
-
type: EVENT.HURT,
|
|
2140
|
-
id: who,
|
|
2141
|
-
x: b.x,
|
|
2142
|
-
y: b.y,
|
|
2143
|
-
z: b.z
|
|
2144
|
-
});
|
|
2145
|
-
else if (t < len) events.push({
|
|
2146
|
-
type: EVENT.BOOM,
|
|
2147
|
-
id: b.id,
|
|
2148
|
-
x: b.x,
|
|
2149
|
-
y: b.y,
|
|
2150
|
-
z: b.z
|
|
2151
|
-
});
|
|
2152
|
-
return who < 0 && t >= len && --b.life > 0;
|
|
2153
|
-
};
|
|
2154
|
-
return {
|
|
2155
|
-
monsters: () => mobs.map(({ id, kind, x, y, z, yaw, chase }) => ({
|
|
2156
|
-
id,
|
|
2157
|
-
kind,
|
|
2158
|
-
x,
|
|
2159
|
-
y,
|
|
2160
|
-
z,
|
|
2161
|
-
yaw,
|
|
2162
|
-
chase
|
|
2163
|
-
})),
|
|
2164
|
-
bullets: () => shells.map(({ id, x, y, z }) => ({
|
|
2165
|
-
id,
|
|
2166
|
-
x,
|
|
2167
|
-
y,
|
|
2168
|
-
z
|
|
2169
|
-
})),
|
|
2170
|
-
events,
|
|
2171
|
-
step: (players) => {
|
|
2172
|
-
tick++;
|
|
2173
|
-
for (const m of mobs) {
|
|
2174
|
-
if ((tick + m.id) % 60 === 0) look(m, players);
|
|
2175
|
-
const target = players.find((p) => p.id === m.target);
|
|
2176
|
-
if (m.chase && !target) hunt(m, -1);
|
|
2177
|
-
if (target) chase(m, target);
|
|
2178
|
-
else patrol(m);
|
|
2179
|
-
}
|
|
2180
|
-
shells = shells.filter((b) => advance(b, players));
|
|
2181
|
-
},
|
|
2182
|
-
kill: (id, by) => {
|
|
2183
|
-
const i = mobs.findIndex((m) => m.id === id);
|
|
2184
|
-
if (i < 0) return;
|
|
2185
|
-
const [m] = mobs.splice(i, 1);
|
|
2186
|
-
events.push({
|
|
2187
|
-
type: EVENT.DIE,
|
|
2188
|
-
id,
|
|
2189
|
-
x: m.x,
|
|
2190
|
-
y: mid(m),
|
|
2191
|
-
z: m.z
|
|
2192
|
-
});
|
|
2193
|
-
alert(m, by);
|
|
2194
|
-
return m;
|
|
2195
|
-
}
|
|
449
|
+
ground: true
|
|
2196
450
|
};
|
|
2197
451
|
};
|
|
2198
452
|
var TURN = 65536 / (2 * Math.PI);
|
|
@@ -2217,20 +471,12 @@ var decodeInput = (buf) => {
|
|
|
2217
471
|
};
|
|
2218
472
|
};
|
|
2219
473
|
var encodeSnapshot = (s) => {
|
|
2220
|
-
const
|
|
2221
|
-
const monsters = shots + 1 + 14 * s.shots.length;
|
|
2222
|
-
const bullets = monsters + 1 + 16 * s.monsters.length;
|
|
2223
|
-
const events = bullets + 1 + 13 * s.bullets.length;
|
|
2224
|
-
const items = events + 1 + 14 * s.events.length;
|
|
2225
|
-
const v = new DataView(new ArrayBuffer(items + 1 + 14 * s.items.length));
|
|
474
|
+
const v = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4 + 24 * s.players.length));
|
|
2226
475
|
v.setUint8(0, 2);
|
|
2227
476
|
v.setUint16(1, s.tick & 65535);
|
|
2228
477
|
v.setUint8(3, s.players.length);
|
|
2229
|
-
v.setUint8(4, s.level);
|
|
2230
|
-
v.setUint8(5, +s.hard | (s.phase & 1) << 1);
|
|
2231
|
-
v.setUint8(6, s.keys);
|
|
2232
478
|
s.players.forEach((p, i) => {
|
|
2233
|
-
const o =
|
|
479
|
+
const o = 4 + i * 24;
|
|
2234
480
|
v.setUint8(o, p.id);
|
|
2235
481
|
v.setFloat32(o + 1, p.x);
|
|
2236
482
|
v.setFloat32(o + 5, p.y);
|
|
@@ -2239,53 +485,7 @@ var encodeSnapshot = (s) => {
|
|
|
2239
485
|
v.setUint16(o + 17, toTurn(p.yaw));
|
|
2240
486
|
v.setInt16(o + 19, toPitch(p.pitch));
|
|
2241
487
|
v.setUint16(o + 21, p.ack & 65535);
|
|
2242
|
-
v.setUint8(o + 23, +p.ground
|
|
2243
|
-
v.setUint8(o + 24, p.hp);
|
|
2244
|
-
});
|
|
2245
|
-
v.setUint8(shots, s.shots.length);
|
|
2246
|
-
s.shots.forEach((h, i) => {
|
|
2247
|
-
const o = shots + 1 + i * 14;
|
|
2248
|
-
v.setUint8(o, h.id);
|
|
2249
|
-
v.setFloat32(o + 1, h.x);
|
|
2250
|
-
v.setFloat32(o + 5, h.y);
|
|
2251
|
-
v.setFloat32(o + 9, h.z);
|
|
2252
|
-
v.setUint8(o + 13, h.hit & 255);
|
|
2253
|
-
});
|
|
2254
|
-
v.setUint8(monsters, s.monsters.length);
|
|
2255
|
-
s.monsters.forEach((m, i) => {
|
|
2256
|
-
const o = monsters + 1 + i * 16;
|
|
2257
|
-
v.setUint8(o, m.id);
|
|
2258
|
-
v.setUint8(o + 1, m.kind & 1 | +m.chase << 1);
|
|
2259
|
-
v.setFloat32(o + 2, m.x);
|
|
2260
|
-
v.setFloat32(o + 6, m.y);
|
|
2261
|
-
v.setFloat32(o + 10, m.z);
|
|
2262
|
-
v.setUint16(o + 14, toTurn(m.yaw));
|
|
2263
|
-
});
|
|
2264
|
-
v.setUint8(bullets, s.bullets.length);
|
|
2265
|
-
s.bullets.forEach((b, i) => {
|
|
2266
|
-
const o = bullets + 1 + i * 13;
|
|
2267
|
-
v.setUint8(o, b.id);
|
|
2268
|
-
v.setFloat32(o + 1, b.x);
|
|
2269
|
-
v.setFloat32(o + 5, b.y);
|
|
2270
|
-
v.setFloat32(o + 9, b.z);
|
|
2271
|
-
});
|
|
2272
|
-
v.setUint8(events, s.events.length);
|
|
2273
|
-
s.events.forEach((e, i) => {
|
|
2274
|
-
const o = events + 1 + i * 14;
|
|
2275
|
-
v.setUint8(o, e.type);
|
|
2276
|
-
v.setUint8(o + 1, e.id);
|
|
2277
|
-
v.setFloat32(o + 2, e.x);
|
|
2278
|
-
v.setFloat32(o + 6, e.y);
|
|
2279
|
-
v.setFloat32(o + 10, e.z);
|
|
2280
|
-
});
|
|
2281
|
-
v.setUint8(items, s.items.length);
|
|
2282
|
-
s.items.forEach((t, i) => {
|
|
2283
|
-
const o = items + 1 + i * 14;
|
|
2284
|
-
v.setUint8(o, t.id);
|
|
2285
|
-
v.setUint8(o + 1, t.kind);
|
|
2286
|
-
v.setFloat32(o + 2, t.x);
|
|
2287
|
-
v.setFloat32(o + 6, t.y);
|
|
2288
|
-
v.setFloat32(o + 10, t.z);
|
|
488
|
+
v.setUint8(o + 23, +p.ground);
|
|
2289
489
|
});
|
|
2290
490
|
return v.buffer;
|
|
2291
491
|
};
|
|
@@ -2301,8 +501,6 @@ var parseText = (raw) => {
|
|
|
2301
501
|
// src/shared/room.ts
|
|
2302
502
|
/** Ticks run at most this many times per timer callback, so a stalled host does not spiral. */
|
|
2303
503
|
var MAX_CATCH_UP = 20;
|
|
2304
|
-
/** A pickup is this tall, standing on the floor: a body touches it when their heights overlap. */
|
|
2305
|
-
var ITEM_H = .5;
|
|
2306
504
|
/** A new player does not spawn within this many metres of another one. */
|
|
2307
505
|
var SPAWN_CLEAR = 2;
|
|
2308
506
|
var COLORS = [
|
|
@@ -2332,8 +530,6 @@ var unique = (name, taken) => {
|
|
|
2332
530
|
for (let n = 2; taken.includes(out); n++) out = `${cut(name, 15 - `${n}`.length)} ${n}`;
|
|
2333
531
|
return out;
|
|
2334
532
|
};
|
|
2335
|
-
/** Whether the player's body is within r of (x, z) on the floor plane and meets a thing resting on y. */
|
|
2336
|
-
var reach = (p, x, y, z, r) => Math.hypot(p.x - x, p.z - z) <= r && p.y < y + ITEM_H && y < p.y + 1.8;
|
|
2337
533
|
var setEvery = (cb, ms) => {
|
|
2338
534
|
const id = setInterval(cb, ms);
|
|
2339
535
|
return () => clearInterval(id);
|
|
@@ -2346,59 +542,28 @@ var setEvery = (cb, ms) => {
|
|
|
2346
542
|
* taken by another player; 'full' beyond rules.maxPlayers. Everyone gets a fresh 'roster' on
|
|
2347
543
|
* every join and leave.
|
|
2348
544
|
* - Each input frame moves its player at once with move(); the INPUT_BURST bank drops the excess.
|
|
2349
|
-
*
|
|
2350
|
-
*
|
|
2351
|
-
* -
|
|
2352
|
-
* rewinds the monsters with the players, and one that hits a monster kills it.
|
|
2353
|
-
* - A player has HEALTH. A monster's blow or bullet takes 1, then HIT_COOLDOWN ticks of grace
|
|
2354
|
-
* (only a hit that took health is told as a HURT event). A dead player moves, shoots and
|
|
2355
|
-
* counts for nothing until PLAYER_RESPAWN ticks later, when it is back at a spawn.
|
|
2356
|
-
* - The level's items lie in it, and every DROP_EVERY-th kill leaves a HEALTH pack. A key taken
|
|
2357
|
-
* opens its gates for the team, a pack heals below full health.
|
|
2358
|
-
* - Touching the goal turns the level from HUNT to RETURN (the exit opens); when every living
|
|
2359
|
-
* player is in the exit the level is won: the next one starts, everyone respawned. After the
|
|
2360
|
-
* last, every player gets { t: 'end' } with the run's kills and deaths per player, and a new
|
|
2361
|
-
* run starts at level 0, hard from then on, the counts back at 0.
|
|
2362
|
-
* - Every SNAP_EVERY ticks of TICK_HZ, one snapshot with every player, the shots resolved since
|
|
2363
|
-
* the last one, the monsters, the bullets, the events since the last one and the items goes to
|
|
2364
|
-
* every peer.
|
|
545
|
+
* rewind() answers where the others were drawn at the view tick of an input (lag compensation,
|
|
546
|
+
* at most MAX_REWIND ticks back).
|
|
547
|
+
* - Every SNAP_EVERY ticks of TICK_HZ, one snapshot with every player goes to every peer.
|
|
2365
548
|
*/
|
|
2366
549
|
var Room = class {
|
|
2367
550
|
/** Every connected peer; null until it joins. */
|
|
2368
551
|
peers = /* @__PURE__ */ new Map();
|
|
2369
552
|
ticks = 0;
|
|
2370
|
-
/** The players
|
|
553
|
+
/** The players as each snapshot of the last MAX_REWIND ticks sent them. */
|
|
2371
554
|
history = [];
|
|
2372
|
-
maps;
|
|
2373
555
|
lvl;
|
|
2374
|
-
horde;
|
|
2375
|
-
rand;
|
|
2376
|
-
level = 0;
|
|
2377
|
-
hard = false;
|
|
2378
|
-
phase = PHASE.HUNT;
|
|
2379
|
-
/** The team's key bits (1 << ITEM.KEY_*). */
|
|
2380
|
-
keys = 0;
|
|
2381
|
-
items = [];
|
|
2382
|
-
nextItem = 0;
|
|
2383
|
-
/** Monsters the team killed in this level. */
|
|
2384
|
-
kills = 0;
|
|
2385
|
-
/** Host tick the run started at. */
|
|
2386
|
-
runStart = 0;
|
|
2387
|
-
/** Shots resolved since the last snapshot. */
|
|
2388
|
-
shots = [];
|
|
2389
556
|
halt;
|
|
2390
557
|
rules;
|
|
2391
558
|
/** Round-robin cursor over the spawn points, used once they are all taken. */
|
|
2392
559
|
rr = 0;
|
|
2393
|
-
/** Missing rules fall back to RULES.
|
|
2394
|
-
constructor(rules = {},
|
|
560
|
+
/** Missing rules fall back to RULES. */
|
|
561
|
+
constructor(rules = {}, map = ROOF) {
|
|
2395
562
|
this.rules = {
|
|
2396
563
|
...RULES,
|
|
2397
564
|
...rules
|
|
2398
565
|
};
|
|
2399
|
-
this.
|
|
2400
|
-
this.maps = levels.map(compile);
|
|
2401
|
-
this.load(0);
|
|
566
|
+
this.lvl = compile(map);
|
|
2402
567
|
}
|
|
2403
568
|
/** Number of joined players. */
|
|
2404
569
|
get size() {
|
|
@@ -2419,15 +584,7 @@ var Room = class {
|
|
|
2419
584
|
const input = p && decodeInput(data);
|
|
2420
585
|
if (input && p.bank > 0) {
|
|
2421
586
|
p.bank--;
|
|
2422
|
-
|
|
2423
|
-
const shot = fire(this.lvl, p.state, input.seq, this.rewind(p, input.view));
|
|
2424
|
-
this.shots.push(shot);
|
|
2425
|
-
if (shot.hit >= 16) {
|
|
2426
|
-
const dead = this.horde.kill(shot.hit, p.state.id);
|
|
2427
|
-
if (dead) p.kills++;
|
|
2428
|
-
if (dead && ++this.kills % 4 === 0) this.drop(ITEM.HEALTH, dead.x, dead.z);
|
|
2429
|
-
}
|
|
2430
|
-
}
|
|
587
|
+
move(p.state, input, this.lvl);
|
|
2431
588
|
p.ack = input.seq;
|
|
2432
589
|
}
|
|
2433
590
|
}
|
|
@@ -2442,44 +599,20 @@ var Room = class {
|
|
|
2442
599
|
const players = this.players();
|
|
2443
600
|
if (!players.length) return;
|
|
2444
601
|
const now = ++this.ticks;
|
|
2445
|
-
for (const p of players)
|
|
2446
|
-
p.bank = Math.min(10, p.bank + 1);
|
|
2447
|
-
if (!p.hp && now - p.hurt >= 180) {
|
|
2448
|
-
p.hp = 9;
|
|
2449
|
-
p.state = this.place(p.info.id, players.filter((q) => q.hp && q !== p).map((q) => q.state));
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
const { events } = this.horde;
|
|
2453
|
-
const old = events.length;
|
|
2454
|
-
this.horde.step(players.filter((p) => p.hp).map((p) => p.state));
|
|
2455
|
-
events.push(...events.splice(old).filter((e) => e.type !== EVENT.HURT || this.wound(e.id, now)));
|
|
2456
|
-
this.progress(players.filter((p) => p.hp));
|
|
602
|
+
for (const p of players) p.bank = Math.min(10, p.bank + 1);
|
|
2457
603
|
if (now % 2 === 0) {
|
|
2458
|
-
const monsters = this.horde.monsters();
|
|
2459
604
|
this.history.push({
|
|
2460
605
|
tick: now,
|
|
2461
|
-
players: players.map((p) => ({ ...p.state }))
|
|
2462
|
-
monsters
|
|
606
|
+
players: players.map((p) => ({ ...p.state }))
|
|
2463
607
|
});
|
|
2464
608
|
while (this.history[0].tick < now - 30) this.history.shift();
|
|
2465
609
|
const snap = encodeSnapshot({
|
|
2466
610
|
tick: now,
|
|
2467
611
|
players: players.map((p) => ({
|
|
2468
612
|
...p.state,
|
|
2469
|
-
ack: p.ack
|
|
2470
|
-
|
|
2471
|
-
})),
|
|
2472
|
-
shots: this.shots,
|
|
2473
|
-
monsters,
|
|
2474
|
-
bullets: this.horde.bullets(),
|
|
2475
|
-
events: this.horde.events.splice(0, 255),
|
|
2476
|
-
level: this.level,
|
|
2477
|
-
hard: this.hard,
|
|
2478
|
-
phase: this.phase,
|
|
2479
|
-
keys: this.keys,
|
|
2480
|
-
items: this.items
|
|
613
|
+
ack: p.ack
|
|
614
|
+
}))
|
|
2481
615
|
});
|
|
2482
|
-
this.shots = [];
|
|
2483
616
|
players.forEach((p) => p.conn.send(snap));
|
|
2484
617
|
}
|
|
2485
618
|
}
|
|
@@ -2511,16 +644,15 @@ var Room = class {
|
|
|
2511
644
|
this.halt = void 0;
|
|
2512
645
|
}
|
|
2513
646
|
/**
|
|
2514
|
-
* The
|
|
2515
|
-
* fractional, read against the current tick and clamped to the
|
|
2516
|
-
*
|
|
2517
|
-
*
|
|
647
|
+
* The players other than `id` as player `id` drew them at `view`, the view tick of
|
|
648
|
+
* one of its inputs (a u16 tick, fractional, read against the current tick and clamped to the
|
|
649
|
+
* kept history): x, y, z interpolated between the two snapshots around it like the client does.
|
|
650
|
+
* One the history does not hold stands where it is.
|
|
2518
651
|
*/
|
|
2519
|
-
rewind(
|
|
2520
|
-
const now = this.players().filter((p) => p !==
|
|
2521
|
-
const mobs = this.horde.monsters();
|
|
652
|
+
rewind(id, view = 0) {
|
|
653
|
+
const now = this.players().filter((p) => p.info.id !== id).map((p) => p.state);
|
|
2522
654
|
const [first, last] = [this.history[0], this.history.at(-1)];
|
|
2523
|
-
if (!first || !last) return
|
|
655
|
+
if (!first || !last) return now;
|
|
2524
656
|
const back = ((this.ticks - view + 32768) % 65536 + 65536) % 65536 - 32768;
|
|
2525
657
|
const t = Math.min(Math.max(this.ticks - back, first.tick), last.tick);
|
|
2526
658
|
let k = 0;
|
|
@@ -2528,9 +660,9 @@ var Room = class {
|
|
|
2528
660
|
const [a, b] = [this.history[k], this.history[k + 1] ?? this.history[k]];
|
|
2529
661
|
const u = b.tick > a.tick ? (t - a.tick) / (b.tick - a.tick) : 0;
|
|
2530
662
|
const l = (m, n) => m + (n - m) * u;
|
|
2531
|
-
|
|
2532
|
-
const pa =
|
|
2533
|
-
const pb =
|
|
663
|
+
return now.map((p) => {
|
|
664
|
+
const pa = a.players.find((q) => q.id === p.id);
|
|
665
|
+
const pb = b.players.find((q) => q.id === p.id);
|
|
2534
666
|
return pa && pb ? {
|
|
2535
667
|
...pb,
|
|
2536
668
|
x: l(pa.x, pb.x),
|
|
@@ -2538,28 +670,6 @@ var Room = class {
|
|
|
2538
670
|
z: l(pa.z, pb.z)
|
|
2539
671
|
} : pb ?? pa ?? p;
|
|
2540
672
|
});
|
|
2541
|
-
return [...at(now, (h) => h.players).map(body), ...at(mobs, (h) => h.monsters).map(monsterBody)];
|
|
2542
|
-
}
|
|
2543
|
-
/** Resets everything a level owns, and puts every player on a spawn of it with full health. */
|
|
2544
|
-
load(n) {
|
|
2545
|
-
this.level = n;
|
|
2546
|
-
this.lvl = this.maps[n];
|
|
2547
|
-
this.keys = 0;
|
|
2548
|
-
this.phase = PHASE.HUNT;
|
|
2549
|
-
bar(this.lvl, 0, PHASE.HUNT);
|
|
2550
|
-
this.horde = createHorde(this.lvl, this.rand, this.hard);
|
|
2551
|
-
this.items = [];
|
|
2552
|
-
this.nextItem = 0;
|
|
2553
|
-
this.kills = 0;
|
|
2554
|
-
this.lvl.map.items?.forEach(([x, z, kind]) => this.drop(kind, x, z));
|
|
2555
|
-
this.shots = [];
|
|
2556
|
-
this.history = [];
|
|
2557
|
-
const placed = [];
|
|
2558
|
-
for (const p of this.players()) {
|
|
2559
|
-
p.hp = 9;
|
|
2560
|
-
p.state = this.place(p.info.id, placed);
|
|
2561
|
-
placed.push(p.state);
|
|
2562
|
-
}
|
|
2563
673
|
}
|
|
2564
674
|
/** The first spawn point with none of `others` within SPAWN_CLEAR, else the next one round-robin. */
|
|
2565
675
|
place(id, others) {
|
|
@@ -2569,71 +679,6 @@ var Room = class {
|
|
|
2569
679
|
});
|
|
2570
680
|
return spawn(id, this.lvl, n < 0 ? this.rr++ : n);
|
|
2571
681
|
}
|
|
2572
|
-
/** The floor of the sector holding (x, z). */
|
|
2573
|
-
floor(x, z) {
|
|
2574
|
-
return this.lvl.map.sectors[Math.max(sectorAt(this.lvl, x, z), 0)].floor;
|
|
2575
|
-
}
|
|
2576
|
-
/** Leaves an item of `kind` on the floor at (x, z). */
|
|
2577
|
-
drop(kind, x, z) {
|
|
2578
|
-
const f = Math.fround;
|
|
2579
|
-
this.items.push({
|
|
2580
|
-
id: this.nextItem++,
|
|
2581
|
-
kind,
|
|
2582
|
-
x: f(x),
|
|
2583
|
-
y: f(this.floor(x, z)),
|
|
2584
|
-
z: f(z)
|
|
2585
|
-
});
|
|
2586
|
-
}
|
|
2587
|
-
/** Takes 1 health off player `id` unless it was hurt less than HIT_COOLDOWN ticks ago. */
|
|
2588
|
-
wound(id, now) {
|
|
2589
|
-
const p = this.players().find((q) => q.info.id === id);
|
|
2590
|
-
if (!p?.hp || now - p.hurt < 60) return false;
|
|
2591
|
-
[p.hp, p.hurt] = [p.hp - 1, now];
|
|
2592
|
-
p.deaths += +!p.hp;
|
|
2593
|
-
return true;
|
|
2594
|
-
}
|
|
2595
|
-
/** What the living players do to the level: pick things up, touch the goal, win. */
|
|
2596
|
-
progress(alive) {
|
|
2597
|
-
const { sectors, goal, exit } = this.lvl.map;
|
|
2598
|
-
let bars = false;
|
|
2599
|
-
this.items = this.items.filter((t) => {
|
|
2600
|
-
const who = alive.find((p) => reach(p.state, t.x, t.y, t.z, .8) && (t.kind !== ITEM.HEALTH || p.hp < 9));
|
|
2601
|
-
if (who && t.kind === ITEM.HEALTH) who.hp = Math.min(9, who.hp + 3);
|
|
2602
|
-
else if (who) {
|
|
2603
|
-
this.keys |= 1 << t.kind;
|
|
2604
|
-
bars = true;
|
|
2605
|
-
}
|
|
2606
|
-
return !who;
|
|
2607
|
-
});
|
|
2608
|
-
if (this.phase === PHASE.HUNT) {
|
|
2609
|
-
if (goal && alive.some((p) => reach(p.state, goal[0], this.floor(...goal), goal[1], 1))) {
|
|
2610
|
-
this.phase = PHASE.RETURN;
|
|
2611
|
-
bars = true;
|
|
2612
|
-
}
|
|
2613
|
-
} else if (exit !== void 0 && alive.length && alive.every((p) => inside(sectors[exit], p.state.x, p.state.z))) return this.win();
|
|
2614
|
-
if (bars) bar(this.lvl, this.keys, this.phase);
|
|
2615
|
-
}
|
|
2616
|
-
/** The level is won: the next one, or the end of the run and a new, hard one. */
|
|
2617
|
-
win() {
|
|
2618
|
-
if (this.level + 1 < this.maps.length) {
|
|
2619
|
-
this.load(this.level + 1);
|
|
2620
|
-
return;
|
|
2621
|
-
}
|
|
2622
|
-
const end = JSON.stringify({
|
|
2623
|
-
t: "end",
|
|
2624
|
-
ticks: this.ticks - this.runStart,
|
|
2625
|
-
hard: this.hard,
|
|
2626
|
-
stats: this.players().map((p) => ({
|
|
2627
|
-
id: p.info.id,
|
|
2628
|
-
kills: p.kills,
|
|
2629
|
-
deaths: p.deaths
|
|
2630
|
-
}))
|
|
2631
|
-
});
|
|
2632
|
-
this.players().forEach((p) => p.conn.send(end));
|
|
2633
|
-
this.players().forEach((p) => p.kills = p.deaths = 0);
|
|
2634
|
-
[this.hard, this.runStart] = [true, this.ticks];
|
|
2635
|
-
this.load(0);
|
|
2636
|
-
}
|
|
2637
682
|
players() {
|
|
2638
683
|
return [...this.peers.values()].filter((p) => p !== null);
|
|
2639
684
|
}
|
|
@@ -2653,13 +698,9 @@ var Room = class {
|
|
|
2653
698
|
name: unique(cleanName(name) || `Player ${id}`, players.map((p) => p.info.name)),
|
|
2654
699
|
color
|
|
2655
700
|
},
|
|
2656
|
-
state: this.place(id, players.
|
|
701
|
+
state: this.place(id, players.map((p) => p.state)),
|
|
2657
702
|
bank: 10,
|
|
2658
|
-
ack: 65535
|
|
2659
|
-
hp: 9,
|
|
2660
|
-
hurt: -60,
|
|
2661
|
-
kills: 0,
|
|
2662
|
-
deaths: 0
|
|
703
|
+
ack: 65535
|
|
2663
704
|
};
|
|
2664
705
|
this.peers.set(conn, player);
|
|
2665
706
|
this.roster();
|