yolkbot 0.1.0-alpha.9 → 0.1.1-alpha.10
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/build/browser.js +6 -6
- package/package.json +29 -9
- package/src/api.js +97 -23
- package/src/bot/GamePlayer.js +2 -2
- package/src/bot.js +888 -481
- package/src/comm/Codes.js +73 -0
- package/src/constants/challenges.js +1822 -0
- package/src/constants/index.js +25 -1
- package/src/constants/items.js +663 -264
- package/src/constants/maps.js +57 -18
- package/src/dispatches/BootPlayerDispatch.js +1 -1
- package/src/dispatches/ChatDispatch.js +1 -1
- package/src/dispatches/GameOptionsDispatch.js +1 -1
- package/src/dispatches/GoToAmmoDispatch.js +44 -0
- package/src/dispatches/GoToCoopDispatch.js +44 -0
- package/src/dispatches/GoToGrenadeDispatch.js +44 -0
- package/src/dispatches/GoToPlayerDispatch.js +5 -1
- package/src/dispatches/GoToSpatulaDispatch.js +5 -1
- package/src/dispatches/LookAtPosDispatch.js +0 -2
- package/src/dispatches/LookDispatch2.js +18 -0
- package/src/dispatches/MeleeDispatch.js +1 -1
- package/src/dispatches/PauseDispatch.js +1 -1
- package/src/dispatches/ReloadDispatch.js +14 -2
- package/src/dispatches/ReportPlayerDispatch.js +1 -1
- package/src/dispatches/SaveLoadoutDispatch.js +11 -34
- package/src/dispatches/SpawnDispatch.js +1 -1
- package/src/dispatches/SwapWeaponDispatch.js +1 -1
- package/src/dispatches/SwitchTeamDispatch.js +1 -1
- package/src/dispatches/ThrowGrenadeDispatch.js +1 -1
- package/src/dispatches/index.js +9 -0
- package/src/matchmaker.js +13 -7
- package/src/pathing/mapnode.js +89 -250
- package/src/socket.js +2 -3
- package/src/types/api.d.ts +2 -16
- package/src/types/bot/GamePlayer.d.ts +25 -21
- package/src/types/bot.d.ts +125 -54
- package/src/types/constants/challenges.d.ts +19 -0
- package/src/types/constants/guns.d.ts +240 -0
- package/src/types/constants/index.d.ts +102 -0
- package/src/types/constants/items.d.ts +21 -0
- package/src/types/constants/maps.d.ts +15 -0
- package/src/types/dispatches/GoToAmmoDispatch.d.ts +8 -0
- package/src/types/dispatches/GoToCoopDispatch.d.ts +8 -0
- package/src/types/dispatches/GoToGrenadeDispatch.d.ts +8 -0
- package/src/types/dispatches/MovementDispatch.d.ts +2 -0
- package/src/types/dispatches/index.d.ts +45 -1
- package/src/types/matchmaker.d.ts +19 -14
- package/src/types/socket.d.ts +7 -0
- package/src/types/gun.d.ts +0 -131
package/src/pathing/mapnode.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable stylistic/max-len */
|
|
2
|
-
function stringifyCircular(obj) {
|
|
2
|
+
/*function stringifyCircular(obj) {
|
|
3
3
|
const cache = [];
|
|
4
4
|
return JSON.stringify(obj, (_, value) => {
|
|
5
5
|
if (typeof value === 'object' && value !== null) {
|
|
@@ -14,55 +14,63 @@ function stringifyCircular(obj) {
|
|
|
14
14
|
}
|
|
15
15
|
return value;
|
|
16
16
|
}, 4);
|
|
17
|
-
}
|
|
17
|
+
}*/
|
|
18
18
|
|
|
19
19
|
class NodeList {
|
|
20
20
|
constructor(raw) {
|
|
21
21
|
const now = Date.now();
|
|
22
22
|
this.list = [];
|
|
23
|
-
|
|
24
|
-
const addedPositions = [];
|
|
23
|
+
const addedPositions = {};
|
|
25
24
|
|
|
26
25
|
for (const meshName of Object.keys(raw.data)) {
|
|
27
26
|
for (const nodeData of raw.data[meshName]) {
|
|
28
|
-
addedPositions
|
|
27
|
+
addedPositions[(
|
|
28
|
+
(nodeData.x << 16) |
|
|
29
|
+
(nodeData.y << 8) |
|
|
30
|
+
(nodeData.z))] = true;
|
|
29
31
|
this.add(new MapNode(meshName, nodeData));
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
// data doesn't include air, but we need to include them anyway
|
|
34
|
-
// addedPositions stores all the blocks with nodes - create a node for every block not in there.
|
|
35
|
-
// width/height/depth are given by raw.width/height/depth
|
|
36
35
|
for (let x = 0; x < raw.width; x++) {
|
|
37
36
|
for (let y = 0; y < raw.height; y++) {
|
|
38
37
|
for (let z = 0; z < raw.depth; z++) {
|
|
39
|
-
if (!addedPositions
|
|
40
|
-
|
|
38
|
+
if (!addedPositions[(
|
|
39
|
+
(x << 16) |
|
|
40
|
+
(y << 8) |
|
|
41
|
+
(z)
|
|
42
|
+
)]) {
|
|
43
|
+
this.add(new MapNode('SPECIAL.__yolkbot_air__.none', { x: x, y: y, z: z }));
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
const nodeMap = new Map();
|
|
46
50
|
for (const node of this.list) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
nodeMap.set(node.positionStr(), node);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const node of this.list) {
|
|
55
|
+
const neighbors = [
|
|
56
|
+
{ x: node.x + 1, y: node.y, z: node.z },
|
|
57
|
+
{ x: node.x - 1, y: node.y, z: node.z },
|
|
58
|
+
{ x: node.x, y: node.y + 1, z: node.z },
|
|
59
|
+
{ x: node.x, y: node.y - 1, z: node.z },
|
|
60
|
+
{ x: node.x, y: node.y, z: node.z + 1 },
|
|
61
|
+
{ x: node.x, y: node.y, z: node.z - 1 }
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
for (const neighborPos of neighbors) {
|
|
65
|
+
const neighborKey = `${neighborPos.x},${neighborPos.y},${neighborPos.z}`;
|
|
66
|
+
const neighborNode = nodeMap.get(neighborKey);
|
|
67
|
+
if (neighborNode && node.canLink(neighborNode, this)) {
|
|
68
|
+
node.addLink(neighborNode);
|
|
60
69
|
}
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
console.log(`NodeList created in ${Date.now() - now}ms`);
|
|
65
|
-
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
add(node) {
|
|
@@ -74,7 +82,16 @@ class NodeList {
|
|
|
74
82
|
}
|
|
75
83
|
|
|
76
84
|
at(x, y, z) {
|
|
77
|
-
|
|
85
|
+
if (!this.nodeMap) {
|
|
86
|
+
this.nodeMap = new Map();
|
|
87
|
+
for (const node of this.list) {
|
|
88
|
+
const key = `${node.x},${node.y},${node.z}`;
|
|
89
|
+
this.nodeMap.set(key, node);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const key = `${x},${y},${z}`;
|
|
94
|
+
return this.nodeMap.get(key);
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
clean() {
|
|
@@ -87,6 +104,34 @@ class NodeList {
|
|
|
87
104
|
node.closed = undefined;
|
|
88
105
|
}
|
|
89
106
|
}
|
|
107
|
+
|
|
108
|
+
hasLineOfSight(bot, target) {
|
|
109
|
+
const dx = target.x - bot.x;
|
|
110
|
+
const dy = target.y - bot.y;
|
|
111
|
+
const dz = target.z - bot.z;
|
|
112
|
+
|
|
113
|
+
const steps = Math.max(Math.abs(dx), Math.abs(dy), Math.abs(dz));
|
|
114
|
+
|
|
115
|
+
const xStep = dx / steps;
|
|
116
|
+
const yStep = dy / steps;
|
|
117
|
+
const zStep = dz / steps;
|
|
118
|
+
|
|
119
|
+
let x = bot.x;
|
|
120
|
+
let y = bot.y;
|
|
121
|
+
let z = bot.z;
|
|
122
|
+
|
|
123
|
+
for (let i = 0; i <= steps; i++) {
|
|
124
|
+
const node = this.at(Math.round(x), Math.round(y), Math.round(z));
|
|
125
|
+
if (node && node.isSolid()) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
x += xStep;
|
|
129
|
+
y += yStep;
|
|
130
|
+
z += zStep;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
90
135
|
}
|
|
91
136
|
|
|
92
137
|
class MapNode {
|
|
@@ -157,254 +202,48 @@ class MapNode {
|
|
|
157
202
|
const dy = Math.abs(dy0);
|
|
158
203
|
const dz = Math.abs(dz0);
|
|
159
204
|
|
|
160
|
-
if (dx + dy + dz
|
|
205
|
+
if (dx + dy + dz === 0 || dx + dz > 1 || this.isSolid() || node.isSolid()) {
|
|
161
206
|
return false;
|
|
162
207
|
}
|
|
163
208
|
|
|
164
|
-
|
|
209
|
+
const belowMe = list.at(this.x, this.y - 1, this.z);
|
|
210
|
+
const belowOther = list.at(node.x, node.y - 1, node.z);
|
|
211
|
+
|
|
212
|
+
if (!belowMe || !belowOther) {
|
|
165
213
|
return false;
|
|
166
214
|
}
|
|
167
|
-
/*
|
|
168
|
-
if (i am solid || target is solid) // can't walk into solid
|
|
169
|
-
-> return false
|
|
170
|
-
if (solid || ladder directly below me) and (solid directly below target) // above solid to above solid
|
|
171
|
-
-> return true
|
|
172
|
-
if (i am ladder && target is ladder && dy == 1 && dx, dz == 0) // up/down ladders
|
|
173
|
-
-> return true
|
|
174
|
-
if (below me is solid && target is wedge && dy == 0 && ry matches) // can walk onto stairs
|
|
175
|
-
-> return true
|
|
176
|
-
if (i am a wedge && dy == 1 && dx/dz matches my ry) // can walk up stairs
|
|
177
|
-
-> return true
|
|
178
|
-
*/
|
|
179
|
-
|
|
180
|
-
/*
|
|
181
|
-
Wedge rotation data:
|
|
182
|
-
|
|
183
|
-
ry | facing
|
|
184
|
-
0 | -z
|
|
185
|
-
1 | -x
|
|
186
|
-
2 | +z
|
|
187
|
-
3 | +x
|
|
188
|
-
*/
|
|
189
215
|
|
|
190
216
|
const FORWARD_RY_WEDGE_MAPPING = {
|
|
191
217
|
0: { x: 0, z: -1 },
|
|
192
218
|
1: { x: -1, z: 0 },
|
|
193
219
|
2: { x: 0, z: 1 },
|
|
194
220
|
3: { x: 1, z: 0 }
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if ((!this.isStair() && !node.isStair()) && dx + dy + dz > 1) { // if we are more than 1 unit away and no stairs, we can't travel
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (this.isSolid() || node.isSolid()) { // if either of us are impassable, we obviously can't travel between
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const belowMe = list.at(this.x, this.y - 1, this.z);
|
|
206
|
-
const belowOther = list.at(node.x, node.y - 1, node.z);
|
|
207
|
-
|
|
208
|
-
if (!belowMe || !belowOther) { // if we are at the bottom of the map, we can't travel
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
221
|
+
};
|
|
211
222
|
|
|
212
223
|
switch (this.meshType) {
|
|
213
|
-
// full block
|
|
214
|
-
case 'full':
|
|
215
|
-
return false;
|
|
216
|
-
|
|
217
|
-
// usually useless decorations or internal things like spawnpoints
|
|
218
224
|
case 'none':
|
|
219
|
-
if (dy0
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (belowMe.canWalkOn() || belowMe.isLadder()) {
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
return false;
|
|
228
|
-
case 'ladder':
|
|
229
|
-
if (dy == 0) {
|
|
230
|
-
if (belowMe.canWalkOn()) {
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return false;
|
|
235
|
-
case 'wedge':
|
|
236
|
-
if (dy0 == 0) { // same level
|
|
237
|
-
if (belowMe.canWalkOn()) {
|
|
238
|
-
// if the stair is pointing to me
|
|
239
|
-
if (dx0 == -FORWARD_RY_WEDGE_MAPPING[node.ry].x && dz0 == -FORWARD_RY_WEDGE_MAPPING[node.ry].z) {
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
return false;
|
|
246
|
-
case 'aabb':
|
|
247
|
-
return false;
|
|
248
|
-
case 'verysoft':
|
|
249
|
-
return false;
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
break;
|
|
253
|
-
|
|
254
|
-
case 'ladder':
|
|
255
|
-
if (dy == 1 && node.canWalkThrough()) {
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
switch (node.meshType) {
|
|
259
|
-
case 'none':
|
|
260
|
-
if (dy == 0) {
|
|
261
|
-
if (belowMe.canWalkOn()) {
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
if (dy == 1) {
|
|
266
|
-
if (node.canWalkThrough()) {
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return false;
|
|
271
|
-
case 'ladder':
|
|
272
|
-
if (dy == 1) {
|
|
273
|
-
return true;
|
|
274
|
-
}
|
|
275
|
-
if (belowMe.canWalkOn() && belowOther.canWalkOn()) {
|
|
276
|
-
return true;
|
|
277
|
-
}
|
|
278
|
-
return false;
|
|
279
|
-
case 'wedge':
|
|
280
|
-
return false; // wrong but this should never happen wtf :sob:
|
|
281
|
-
case 'aabb':
|
|
282
|
-
return false;
|
|
283
|
-
}
|
|
284
|
-
break;
|
|
285
|
-
|
|
286
|
-
// stairs
|
|
287
|
-
case 'wedge':
|
|
288
|
-
// console.log(`I'm a wedge at ${stringifyCircular(this.position)}`)
|
|
289
|
-
/*console.log(`Following the RY mapping, my bottom points to ${this.x - FORWARD_RY_WEDGE_MAPPING[this.ry].x
|
|
290
|
-
}, ${this.y
|
|
291
|
-
}, ${this.z - FORWARD_RY_WEDGE_MAPPING[this.ry].z
|
|
292
|
-
}`)*/
|
|
293
|
-
switch (node.meshType) {
|
|
294
|
-
case 'none':
|
|
295
|
-
case 'wedge':
|
|
296
|
-
// if i'm pointing to it and dy0 = -1, i can walk to it (above)
|
|
297
|
-
// if i'm reverse pointing and dy0 = 0, i can walk to it (level)
|
|
298
|
-
// if i'm reverse pointing and dy0 = 1, i can walk to it (below)
|
|
299
|
-
if (this.x + FORWARD_RY_WEDGE_MAPPING[this.ry].x == node.x && this.z + FORWARD_RY_WEDGE_MAPPING[this.ry].z == node.z) {
|
|
300
|
-
if (this.y + 1 == node.y) {
|
|
301
|
-
return true;
|
|
302
|
-
}
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
|
-
if (this.x - FORWARD_RY_WEDGE_MAPPING[this.ry].x == node.x && this.z - FORWARD_RY_WEDGE_MAPPING[this.ry].z == node.z) {
|
|
306
|
-
if (this.y == node.y) {
|
|
307
|
-
return true;
|
|
308
|
-
}
|
|
309
|
-
if (this.y - 1 == node.y) {
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
console.log(`Wedge at ${stringifyCircular(this.position)} can't walk to wedge/air at ${stringifyCircular(node.position)}`);
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
return false;
|
|
316
|
-
case 'ladder':
|
|
317
|
-
return false; // same as above, should never happen
|
|
318
|
-
case 'aabb':
|
|
319
|
-
case 'verysoft':
|
|
320
|
-
return false;
|
|
225
|
+
if (dy0 === 1 && node.canWalkThrough()) return true;
|
|
226
|
+
if (belowMe.canWalkOn() || belowMe.isLadder()) {
|
|
227
|
+
if (node.meshType === 'none' || (node.meshType === 'ladder' && dy === 0) || (node.meshType === 'wedge' && dy0 === 0 && dx0 === -FORWARD_RY_WEDGE_MAPPING[node.ry].x && dz0 === -FORWARD_RY_WEDGE_MAPPING[node.ry].z)) {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
321
230
|
}
|
|
322
|
-
break;
|
|
323
|
-
|
|
324
|
-
// the various random weird shapes, sometimes block most of a block, often can either be walked over or not at all
|
|
325
|
-
case 'aabb':
|
|
326
231
|
return false;
|
|
327
232
|
|
|
328
|
-
|
|
329
|
-
|
|
233
|
+
case 'ladder':
|
|
234
|
+
if (dy === 1 && node.canWalkThrough()) return true;
|
|
235
|
+
if (dy === 0 && belowMe.canWalkOn()) return true;
|
|
236
|
+
if (node.meshType === 'ladder' && (dy === 1 || (belowMe.canWalkOn() && belowOther.canWalkOn()))) return true;
|
|
330
237
|
return false;
|
|
331
238
|
|
|
332
|
-
|
|
333
|
-
|
|
239
|
+
case 'wedge':
|
|
240
|
+
if (this.x + FORWARD_RY_WEDGE_MAPPING[this.ry].x === node.x && this.z + FORWARD_RY_WEDGE_MAPPING[this.ry].z === node.z && this.y + 1 === node.y) return true;
|
|
241
|
+
if (this.x - FORWARD_RY_WEDGE_MAPPING[this.ry].x === node.x && this.z - FORWARD_RY_WEDGE_MAPPING[this.ry].z === node.z && (this.y === node.y || this.y - 1 === node.y)) return true;
|
|
334
242
|
return false;
|
|
335
|
-
}
|
|
336
243
|
|
|
337
|
-
|
|
338
|
-
if (dy == 0) {
|
|
339
|
-
if (belowMe.isSolid() || belowMe.isLadder()) {
|
|
340
|
-
if (belowOther.isSolid()) { // if there is a solid block below both of us, we can travel
|
|
341
|
-
return true;
|
|
342
|
-
} else if (belowOther.canWalk()) { // if we can fall off a corner, we can travel
|
|
343
|
-
return true;
|
|
344
|
-
} else {
|
|
345
|
-
return false; // prevent falling multiple blocks (i think?) may not be necessary
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
} else {
|
|
349
|
-
if (dy0 == 1) { // if we are above the other node, we can travel
|
|
350
|
-
return true;
|
|
351
|
-
}
|
|
244
|
+
default:
|
|
352
245
|
return false;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (!belowMe.isSolid()) {
|
|
357
|
-
if (this.y - node.y == 1) { // i can fall down one node
|
|
358
|
-
return true;
|
|
359
|
-
} else {
|
|
360
|
-
return false; // if there's air beneath me, we can't move side to side
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
if (this.isLadder() && node.isLadder() && dy == 1 && dx + dz == 0) { // we can climb up and down ladders
|
|
365
|
-
return true;
|
|
366
246
|
}
|
|
367
|
-
|
|
368
|
-
if (belowMe.isSolid() && node.isStair() && dy == 0) { // we can walk onto stairs but the stair needs to be pointing to me
|
|
369
|
-
if (dz0 == FORWARD_RY_WEDGE_MAPPING[node.ry].z && dx0 == FORWARD_RY_WEDGE_MAPPING[node.ry].x) {
|
|
370
|
-
return true;
|
|
371
|
-
}
|
|
372
|
-
return false;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (this.isStair()) {
|
|
376
|
-
if (dx + dz > 1) {
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
if (dy == 1) { // node is below me
|
|
380
|
-
if (dx0 == FORWARD_RY_WEDGE_MAPPING[this.ry].x && dz0 == FORWARD_RY_WEDGE_MAPPING[this.ry].z) { // if i'm pointing to it
|
|
381
|
-
const inTheWay = list.at(this.x + FORWARD_RY_WEDGE_MAPPING[this.ry].x, this.y, this.z + FORWARD_RY_WEDGE_MAPPING[this.ry].z);
|
|
382
|
-
if (inTheWay && inTheWay.isSolid()) {
|
|
383
|
-
return false;
|
|
384
|
-
}
|
|
385
|
-
return true;
|
|
386
|
-
}
|
|
387
|
-
return false;
|
|
388
|
-
} else if (dy == 0) { // node is level with me
|
|
389
|
-
if (dx0 == FORWARD_RY_WEDGE_MAPPING[this.ry].x && dz0 == FORWARD_RY_WEDGE_MAPPING[this.ry].z) { // if i'm pointing to it
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
return false;
|
|
393
|
-
} else { // node is above me
|
|
394
|
-
if (dx0 == FORWARD_RY_WEDGE_MAPPING[this.ry].x && dz0 == FORWARD_RY_WEDGE_MAPPING[this.ry].z) { // if i'm pointing to it
|
|
395
|
-
const inTheWay = list.at(this.x, this.y + 1, this.z);
|
|
396
|
-
if (inTheWay && inTheWay.isSolid()) {
|
|
397
|
-
return false;
|
|
398
|
-
}
|
|
399
|
-
return true;
|
|
400
|
-
}
|
|
401
|
-
return false;
|
|
402
|
-
}
|
|
403
|
-
}*/
|
|
404
|
-
// console.log('My meshtype, below meshtype: ', this.meshType, belowMe.meshType, 'Other meshtype, below other meshtype: ', node.meshType, belowOther.meshType);
|
|
405
|
-
// console.log('My ry, other ry: ', this.ry, node.ry);
|
|
406
|
-
// console.log('dx0, dy0, dz0: ', dx0, dy0, dz0);
|
|
407
|
-
throw new Error(`Unrecognized node meshType, me: ${stringifyCircular(this)}, other: ${stringifyCircular(node)}, below me: ${stringifyCircular(belowMe)}, below other: ${stringifyCircular(belowOther)}\n\nThis is NOT your fault. This is an internal error related to pathfinding.\nIf you need an immediate fix and don't use pathfinding features, set "doPathing" to false when creating a Bot.\n\nPlease paste this full error to our support server and **include the map the bot is on**.`);
|
|
408
247
|
}
|
|
409
248
|
|
|
410
249
|
trueCenter() {
|
package/src/socket.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import NodeWebSocket from 'ws';
|
|
2
2
|
|
|
3
|
-
import { IsBrowser, UserAgent } from '#constants';
|
|
3
|
+
import { IsBrowser, ProxiesEnabled, UserAgent } from '#constants';
|
|
4
4
|
|
|
5
|
-
// eslint-disable-next-line no-undef
|
|
6
5
|
const WS = IsBrowser ? window.WebSocket : NodeWebSocket;
|
|
7
6
|
|
|
8
7
|
let SocksProxyAgent;
|
|
9
|
-
if (
|
|
8
|
+
if (ProxiesEnabled) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
|
|
10
9
|
|
|
11
10
|
class yolkws extends WS {
|
|
12
11
|
constructor(url, proxy) {
|
package/src/types/api.d.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
import { FirebaseKey, UserAgent } from '../constants/index.js';
|
|
2
|
-
|
|
3
|
-
declare module './socket.js' {
|
|
4
|
-
export default class yolkws {
|
|
5
|
-
constructor(url: string, proxy: string);
|
|
6
|
-
onopen: () => void;
|
|
7
|
-
onmessage: (event: { data: string }) => void;
|
|
8
|
-
onerror: () => void;
|
|
9
|
-
onclose: () => void;
|
|
10
|
-
send(data: string): void;
|
|
11
|
-
close(): void;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
1
|
export interface QueryRequest {
|
|
16
2
|
cmd: string;
|
|
17
3
|
firebaseToken?: string;
|
|
@@ -25,11 +11,11 @@ export interface QueryResponse {
|
|
|
25
11
|
kills?: number;
|
|
26
12
|
deaths?: number;
|
|
27
13
|
currentBalance?: number;
|
|
14
|
+
// theres more that we don't use and don't type
|
|
28
15
|
[key: string]: any;
|
|
29
16
|
}
|
|
30
17
|
|
|
31
18
|
export function queryServices(request: QueryRequest, proxy?: string, instance?: string): Promise<QueryResponse | string>;
|
|
32
|
-
|
|
33
19
|
export function loginWithCredentials(email: string, password: string, prox?: string, instance?: string): Promise<QueryResponse | string>;
|
|
34
|
-
|
|
20
|
+
export function loginWithRefreshToken(refreshToken: string, prox?: string, instance?: string): Promise<QueryResponse | string>;
|
|
35
21
|
export function loginAnonymously(prox?: string, instance?: string): Promise<QueryResponse | string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AnyGun } from '../constants/guns';
|
|
2
|
+
import { Item } from '../constants/items';
|
|
3
3
|
|
|
4
4
|
export interface Position {
|
|
5
5
|
x: number;
|
|
@@ -14,15 +14,17 @@ export interface View {
|
|
|
14
14
|
|
|
15
15
|
export interface Character {
|
|
16
16
|
eggColor: string;
|
|
17
|
-
primaryGun:
|
|
18
|
-
secondaryGun:
|
|
19
|
-
stamp:
|
|
20
|
-
hat:
|
|
21
|
-
grenade:
|
|
22
|
-
melee:
|
|
17
|
+
primaryGun: Item;
|
|
18
|
+
secondaryGun: Item | number;
|
|
19
|
+
stamp: Item | number;
|
|
20
|
+
hat: Item | number;
|
|
21
|
+
grenade: Item | number;
|
|
22
|
+
melee: Item | number;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface Buffer {
|
|
26
|
+
// not sure how buffers work
|
|
27
|
+
// users dont need to access anyways
|
|
26
28
|
[key: number]: any;
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -38,15 +40,21 @@ export interface PlayerData {
|
|
|
38
40
|
yaw_: number;
|
|
39
41
|
pitch_: number;
|
|
40
42
|
shellColor_: string;
|
|
41
|
-
primaryWeaponItem_:
|
|
42
|
-
secondaryWeaponItem_:
|
|
43
|
-
stampItem_:
|
|
44
|
-
hatItem_:
|
|
45
|
-
grenadeItem_:
|
|
46
|
-
meleeItem_:
|
|
43
|
+
primaryWeaponItem_: Item;
|
|
44
|
+
secondaryWeaponItem_: Item | number;
|
|
45
|
+
stampItem_: Item | number;
|
|
46
|
+
hatItem_: Item | number;
|
|
47
|
+
grenadeItem_: Item | number;
|
|
48
|
+
meleeItem_: Item | number;
|
|
47
49
|
weaponIdx_: number;
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
export interface Social {
|
|
53
|
+
id: number;
|
|
54
|
+
url: string;
|
|
55
|
+
active: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
50
58
|
export class GamePlayer {
|
|
51
59
|
id: string;
|
|
52
60
|
team: 0 | 1 | 2;
|
|
@@ -54,7 +62,7 @@ export class GamePlayer {
|
|
|
54
62
|
name: string;
|
|
55
63
|
uniqueId: string;
|
|
56
64
|
playing: boolean;
|
|
57
|
-
social:
|
|
65
|
+
social: Social[];
|
|
58
66
|
showBadge: boolean;
|
|
59
67
|
position: Position;
|
|
60
68
|
jumping: boolean;
|
|
@@ -63,21 +71,17 @@ export class GamePlayer {
|
|
|
63
71
|
character: Character;
|
|
64
72
|
activeGun: number;
|
|
65
73
|
selectedGun: number;
|
|
66
|
-
weapons:
|
|
74
|
+
weapons: AnyGun[];
|
|
67
75
|
grenades: number;
|
|
68
76
|
buffer: Buffer;
|
|
69
77
|
kills: number;
|
|
70
78
|
hp: number;
|
|
71
79
|
hpShield: number;
|
|
72
|
-
streakRewards:
|
|
80
|
+
streakRewards: number[];
|
|
73
81
|
randomSeed: number;
|
|
74
82
|
serverStateIdx: number;
|
|
75
83
|
|
|
76
84
|
constructor(id: string, team: string, playerData: PlayerData);
|
|
77
|
-
|
|
78
|
-
dispatch(): void;
|
|
79
|
-
join(): void;
|
|
80
|
-
update(): void;
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
export default GamePlayer;
|