yolkbot 0.1.0-alpha.6 → 0.1.0-alpha.60
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 +15 -5
- package/src/api.js +97 -23
- package/src/bot/GamePlayer.js +3 -3
- package/src/bot.js +851 -484
- package/src/constants/index.js +23 -1
- package/src/constants/items.js +372 -173
- package/src/constants/maps.js +51 -12
- 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/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 +11 -2
- package/src/pathing/mapnode.js +83 -250
- package/src/socket.js +1 -1
- package/src/types/api.d.ts +2 -16
- package/src/types/bot/GamePlayer.d.ts +26 -22
- package/src/types/bot.d.ts +118 -30
- package/src/types/constants/guns.d.ts +240 -0
- package/src/types/constants/index.d.ts +100 -0
- package/src/types/constants/items.d.ts +21 -0
- package/src/types/constants/maps.d.ts +15 -0
- package/src/types/dispatches/BootPlayerDispatch.d.ts +4 -2
- package/src/types/dispatches/ChatDispatch.d.ts +1 -1
- package/src/types/dispatches/FireDispatch.d.ts +2 -0
- package/src/types/dispatches/GameOptionsDispatch.d.ts +1 -1
- 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/GoToPlayerDispatch.d.ts +2 -1
- package/src/types/dispatches/GoToSpatulaDispatch.d.ts +1 -1
- package/src/types/dispatches/LookAtPosDispatch.d.ts +2 -0
- package/src/types/dispatches/MeleeDispatch.d.ts +2 -0
- package/src/types/dispatches/MovementDispatch.d.ts +2 -0
- package/src/types/dispatches/PauseDispatch.d.ts +2 -0
- package/src/types/dispatches/ReloadDispatch.d.ts +2 -0
- package/src/types/dispatches/ReportPlayerDispatch.d.ts +10 -1
- package/src/types/dispatches/SaveLoadoutDispatch.d.ts +2 -0
- package/src/types/dispatches/SpawnDispatch.d.ts +2 -0
- package/src/types/dispatches/SwapWeaponDispatch.d.ts +2 -0
- package/src/types/dispatches/SwitchTeamDispatch.d.ts +2 -0
- package/src/types/dispatches/ThrowGrenadeDispatch.d.ts +3 -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/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,57 @@ 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 = new Set();
|
|
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.add(`${nodeData.x},${nodeData.y},${nodeData.z}`);
|
|
29
28
|
this.add(new MapNode(meshName, nodeData));
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
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
32
|
for (let x = 0; x < raw.width; x++) {
|
|
37
33
|
for (let y = 0; y < raw.height; y++) {
|
|
38
34
|
for (let z = 0; z < raw.depth; z++) {
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const posKey = `${x},${y},${z}`;
|
|
36
|
+
if (!addedPositions.has(posKey)) {
|
|
37
|
+
this.add(new MapNode('SPECIAL.__yolkbot_air__.none', { x: x, y: y, z: z }));
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
|
|
43
|
+
const nodeMap = new Map();
|
|
46
44
|
for (const node of this.list) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
nodeMap.set(node.positionStr(), node);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (const node of this.list) {
|
|
49
|
+
const neighbors = [
|
|
50
|
+
{ x: node.x + 1, y: node.y, z: node.z },
|
|
51
|
+
{ x: node.x - 1, y: node.y, z: node.z },
|
|
52
|
+
{ x: node.x, y: node.y + 1, z: node.z },
|
|
53
|
+
{ x: node.x, y: node.y - 1, z: node.z },
|
|
54
|
+
{ x: node.x, y: node.y, z: node.z + 1 },
|
|
55
|
+
{ x: node.x, y: node.y, z: node.z - 1 }
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
for (const neighborPos of neighbors) {
|
|
59
|
+
const neighborKey = `${neighborPos.x},${neighborPos.y},${neighborPos.z}`;
|
|
60
|
+
const neighborNode = nodeMap.get(neighborKey);
|
|
61
|
+
if (neighborNode && node.canLink(neighborNode, this)) {
|
|
62
|
+
node.addLink(neighborNode);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
console.log(`NodeList created in ${Date.now() - now}ms`);
|
|
65
|
-
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
add(node) {
|
|
@@ -74,7 +76,16 @@ class NodeList {
|
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
at(x, y, z) {
|
|
77
|
-
|
|
79
|
+
if (!this.nodeMap) {
|
|
80
|
+
this.nodeMap = new Map();
|
|
81
|
+
for (const node of this.list) {
|
|
82
|
+
const key = `${node.x},${node.y},${node.z}`;
|
|
83
|
+
this.nodeMap.set(key, node);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const key = `${x},${y},${z}`;
|
|
88
|
+
return this.nodeMap.get(key);
|
|
78
89
|
}
|
|
79
90
|
|
|
80
91
|
clean() {
|
|
@@ -87,6 +98,34 @@ class NodeList {
|
|
|
87
98
|
node.closed = undefined;
|
|
88
99
|
}
|
|
89
100
|
}
|
|
101
|
+
|
|
102
|
+
hasLineOfSight(bot, target) {
|
|
103
|
+
const dx = target.x - bot.x;
|
|
104
|
+
const dy = target.y - bot.y;
|
|
105
|
+
const dz = target.z - bot.z;
|
|
106
|
+
|
|
107
|
+
const steps = Math.max(Math.abs(dx), Math.abs(dy), Math.abs(dz));
|
|
108
|
+
|
|
109
|
+
const xStep = dx / steps;
|
|
110
|
+
const yStep = dy / steps;
|
|
111
|
+
const zStep = dz / steps;
|
|
112
|
+
|
|
113
|
+
let x = bot.x;
|
|
114
|
+
let y = bot.y;
|
|
115
|
+
let z = bot.z;
|
|
116
|
+
|
|
117
|
+
for (let i = 0; i <= steps; i++) {
|
|
118
|
+
const node = this.at(Math.round(x), Math.round(y), Math.round(z));
|
|
119
|
+
if (node && node.isSolid()) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
x += xStep;
|
|
123
|
+
y += yStep;
|
|
124
|
+
z += zStep;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
90
129
|
}
|
|
91
130
|
|
|
92
131
|
class MapNode {
|
|
@@ -157,254 +196,48 @@ class MapNode {
|
|
|
157
196
|
const dy = Math.abs(dy0);
|
|
158
197
|
const dz = Math.abs(dz0);
|
|
159
198
|
|
|
160
|
-
if (dx + dy + dz
|
|
199
|
+
if (dx + dy + dz === 0 || dx + dz > 1 || this.isSolid() || node.isSolid()) {
|
|
161
200
|
return false;
|
|
162
201
|
}
|
|
163
202
|
|
|
164
|
-
|
|
203
|
+
const belowMe = list.at(this.x, this.y - 1, this.z);
|
|
204
|
+
const belowOther = list.at(node.x, node.y - 1, node.z);
|
|
205
|
+
|
|
206
|
+
if (!belowMe || !belowOther) {
|
|
165
207
|
return false;
|
|
166
208
|
}
|
|
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
209
|
|
|
190
210
|
const FORWARD_RY_WEDGE_MAPPING = {
|
|
191
211
|
0: { x: 0, z: -1 },
|
|
192
212
|
1: { x: -1, z: 0 },
|
|
193
213
|
2: { x: 0, z: 1 },
|
|
194
214
|
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
|
-
}
|
|
215
|
+
};
|
|
211
216
|
|
|
212
217
|
switch (this.meshType) {
|
|
213
|
-
// full block
|
|
214
|
-
case 'full':
|
|
215
|
-
return false;
|
|
216
|
-
|
|
217
|
-
// usually useless decorations or internal things like spawnpoints
|
|
218
218
|
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;
|
|
219
|
+
if (dy0 === 1 && node.canWalkThrough()) return true;
|
|
220
|
+
if (belowMe.canWalkOn() || belowMe.isLadder()) {
|
|
221
|
+
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)) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
321
224
|
}
|
|
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
225
|
return false;
|
|
327
226
|
|
|
328
|
-
|
|
329
|
-
|
|
227
|
+
case 'ladder':
|
|
228
|
+
if (dy === 1 && node.canWalkThrough()) return true;
|
|
229
|
+
if (dy === 0 && belowMe.canWalkOn()) return true;
|
|
230
|
+
if (node.meshType === 'ladder' && (dy === 1 || (belowMe.canWalkOn() && belowOther.canWalkOn()))) return true;
|
|
330
231
|
return false;
|
|
331
232
|
|
|
332
|
-
|
|
333
|
-
|
|
233
|
+
case 'wedge':
|
|
234
|
+
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;
|
|
235
|
+
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
236
|
return false;
|
|
335
|
-
}
|
|
336
237
|
|
|
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
|
-
}
|
|
238
|
+
default:
|
|
352
239
|
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
240
|
}
|
|
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
241
|
}
|
|
409
242
|
|
|
410
243
|
trueCenter() {
|
package/src/socket.js
CHANGED
|
@@ -6,7 +6,7 @@ import { IsBrowser, UserAgent } from '#constants';
|
|
|
6
6
|
const WS = IsBrowser ? window.WebSocket : NodeWebSocket;
|
|
7
7
|
|
|
8
8
|
let SocksProxyAgent;
|
|
9
|
-
if (!IsBrowser) SocksProxyAgent = (await import('
|
|
9
|
+
if (!IsBrowser) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
|
|
10
10
|
|
|
11
11
|
class yolkws extends WS {
|
|
12
12
|
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,23 +40,29 @@ 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
|
-
team:
|
|
60
|
+
team: 0 | 1 | 2;
|
|
53
61
|
data: PlayerData;
|
|
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;
|