yolkbot 0.1.0-alpha.5 → 0.1.0-alpha.50
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 +27 -8
- package/src/api.js +44 -23
- package/src/bot/GamePlayer.js +3 -3
- package/src/bot.js +758 -391
- 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 +1 -1
- 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 +14 -2
- package/src/matchmaker.js +11 -2
- package/src/pathing/mapnode.js +33 -4
- package/src/socket.js +1 -1
- package/src/types/api.d.ts +1 -16
- package/src/types/bot/GamePlayer.d.ts +87 -0
- package/src/types/bot.d.ts +117 -35
- 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 +12 -0
- package/src/types/dispatches/ChatDispatch.d.ts +10 -0
- package/src/types/dispatches/FireDispatch.d.ts +10 -0
- package/src/types/dispatches/GameOptionsDispatch.d.ts +8 -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/GoToPlayerDispatch.d.ts +11 -0
- package/src/types/dispatches/GoToSpatulaDispatch.d.ts +8 -0
- package/src/types/dispatches/LookAtDispatch.d.ts +14 -0
- package/src/types/dispatches/LookAtPosDispatch.d.ts +19 -0
- package/src/types/dispatches/MeleeDispatch.d.ts +8 -0
- package/src/types/dispatches/MovementDispatch.d.ts +12 -0
- package/src/types/dispatches/PauseDispatch.d.ts +8 -0
- package/src/types/dispatches/ReloadDispatch.d.ts +8 -0
- package/src/types/dispatches/ReportPlayerDispatch.d.ts +22 -0
- package/src/types/dispatches/SaveLoadoutDispatch.d.ts +34 -0
- package/src/types/dispatches/SpawnDispatch.d.ts +8 -0
- package/src/types/dispatches/SwapWeaponDispatch.d.ts +8 -0
- package/src/types/dispatches/SwitchTeamDispatch.d.ts +8 -0
- package/src/types/dispatches/ThrowGrenadeDispatch.d.ts +10 -0
- package/src/types/dispatches/index.d.ts +174 -0
- package/src/types/matchmaker.d.ts +19 -14
- package/src/types/socket.d.ts +7 -0
package/src/constants/maps.js
CHANGED
|
@@ -23,7 +23,7 @@ export const Maps = [
|
|
|
23
23
|
"Spatula": true,
|
|
24
24
|
"King": true
|
|
25
25
|
},
|
|
26
|
-
"availability": "
|
|
26
|
+
"availability": "both",
|
|
27
27
|
"numPlayers": "14"
|
|
28
28
|
},
|
|
29
29
|
{
|
|
@@ -88,7 +88,7 @@ export const Maps = [
|
|
|
88
88
|
"Spatula": true,
|
|
89
89
|
"King": true
|
|
90
90
|
},
|
|
91
|
-
"availability": "
|
|
91
|
+
"availability": "both",
|
|
92
92
|
"numPlayers": "14"
|
|
93
93
|
},
|
|
94
94
|
{
|
|
@@ -166,7 +166,7 @@ export const Maps = [
|
|
|
166
166
|
"Spatula": true,
|
|
167
167
|
"King": true
|
|
168
168
|
},
|
|
169
|
-
"availability": "
|
|
169
|
+
"availability": "both",
|
|
170
170
|
"numPlayers": "18"
|
|
171
171
|
},
|
|
172
172
|
{
|
|
@@ -322,7 +322,7 @@ export const Maps = [
|
|
|
322
322
|
"Spatula": true,
|
|
323
323
|
"King": true
|
|
324
324
|
},
|
|
325
|
-
"availability": "
|
|
325
|
+
"availability": "private",
|
|
326
326
|
"numPlayers": "16"
|
|
327
327
|
},
|
|
328
328
|
{
|
|
@@ -390,6 +390,19 @@ export const Maps = [
|
|
|
390
390
|
"availability": "private",
|
|
391
391
|
"numPlayers": "18"
|
|
392
392
|
},
|
|
393
|
+
{
|
|
394
|
+
"filename": "foundation",
|
|
395
|
+
"hash": "1s6kfr5u037",
|
|
396
|
+
"name": "Foundation",
|
|
397
|
+
"modes": {
|
|
398
|
+
"FFA": true,
|
|
399
|
+
"Teams": true,
|
|
400
|
+
"Spatula": true,
|
|
401
|
+
"King": true
|
|
402
|
+
},
|
|
403
|
+
"availability": "both",
|
|
404
|
+
"numPlayers": "18"
|
|
405
|
+
},
|
|
393
406
|
{
|
|
394
407
|
"filename": "fourQuarters",
|
|
395
408
|
"hash": "1a0w7vbz8is",
|
|
@@ -517,7 +530,7 @@ export const Maps = [
|
|
|
517
530
|
"Spatula": true,
|
|
518
531
|
"King": true
|
|
519
532
|
},
|
|
520
|
-
"availability": "
|
|
533
|
+
"availability": "private",
|
|
521
534
|
"numPlayers": "18"
|
|
522
535
|
},
|
|
523
536
|
{
|
|
@@ -559,6 +572,19 @@ export const Maps = [
|
|
|
559
572
|
"availability": "both",
|
|
560
573
|
"numPlayers": "18"
|
|
561
574
|
},
|
|
575
|
+
{
|
|
576
|
+
"filename": "metamorphosis",
|
|
577
|
+
"hash": "hlpma5zbhi",
|
|
578
|
+
"name": "Metamorphosis",
|
|
579
|
+
"modes": {
|
|
580
|
+
"FFA": true,
|
|
581
|
+
"Teams": true,
|
|
582
|
+
"Spatula": true,
|
|
583
|
+
"King": false
|
|
584
|
+
},
|
|
585
|
+
"availability": "both",
|
|
586
|
+
"numPlayers": "14"
|
|
587
|
+
},
|
|
562
588
|
{
|
|
563
589
|
"filename": "moonbase",
|
|
564
590
|
"hash": "1yzocf1mex3",
|
|
@@ -595,7 +621,7 @@ export const Maps = [
|
|
|
595
621
|
"Spatula": true,
|
|
596
622
|
"King": true
|
|
597
623
|
},
|
|
598
|
-
"availability": "
|
|
624
|
+
"availability": "private",
|
|
599
625
|
"numPlayers": "18"
|
|
600
626
|
},
|
|
601
627
|
{
|
|
@@ -738,7 +764,7 @@ export const Maps = [
|
|
|
738
764
|
"Spatula": true,
|
|
739
765
|
"King": true
|
|
740
766
|
},
|
|
741
|
-
"availability": "
|
|
767
|
+
"availability": "both",
|
|
742
768
|
"numPlayers": "14"
|
|
743
769
|
},
|
|
744
770
|
{
|
|
@@ -790,7 +816,7 @@ export const Maps = [
|
|
|
790
816
|
"Spatula": true,
|
|
791
817
|
"King": true
|
|
792
818
|
},
|
|
793
|
-
"availability": "
|
|
819
|
+
"availability": "both",
|
|
794
820
|
"numPlayers": "16"
|
|
795
821
|
},
|
|
796
822
|
{
|
|
@@ -803,7 +829,7 @@ export const Maps = [
|
|
|
803
829
|
"Spatula": true,
|
|
804
830
|
"King": true
|
|
805
831
|
},
|
|
806
|
-
"availability": "
|
|
832
|
+
"availability": "both",
|
|
807
833
|
"numPlayers": "18"
|
|
808
834
|
},
|
|
809
835
|
{
|
|
@@ -868,7 +894,7 @@ export const Maps = [
|
|
|
868
894
|
"Spatula": true,
|
|
869
895
|
"King": true
|
|
870
896
|
},
|
|
871
|
-
"availability": "
|
|
897
|
+
"availability": "private",
|
|
872
898
|
"numPlayers": "12"
|
|
873
899
|
},
|
|
874
900
|
{
|
|
@@ -881,7 +907,7 @@ export const Maps = [
|
|
|
881
907
|
"Spatula": true,
|
|
882
908
|
"King": true
|
|
883
909
|
},
|
|
884
|
-
"availability": "
|
|
910
|
+
"availability": "both",
|
|
885
911
|
"numPlayers": "18"
|
|
886
912
|
},
|
|
887
913
|
{
|
|
@@ -920,7 +946,7 @@ export const Maps = [
|
|
|
920
946
|
"Spatula": true,
|
|
921
947
|
"King": true
|
|
922
948
|
},
|
|
923
|
-
"availability": "
|
|
949
|
+
"availability": "private",
|
|
924
950
|
"numPlayers": "18"
|
|
925
951
|
},
|
|
926
952
|
{
|
|
@@ -988,6 +1014,19 @@ export const Maps = [
|
|
|
988
1014
|
"availability": "private",
|
|
989
1015
|
"numPlayers": "18"
|
|
990
1016
|
},
|
|
1017
|
+
{
|
|
1018
|
+
"filename": "uncovered",
|
|
1019
|
+
"hash": "bxrd0zdvtn",
|
|
1020
|
+
"name": "Uncovered",
|
|
1021
|
+
"modes": {
|
|
1022
|
+
"FFA": true,
|
|
1023
|
+
"Teams": true,
|
|
1024
|
+
"Spatula": true,
|
|
1025
|
+
"King": true
|
|
1026
|
+
},
|
|
1027
|
+
"availability": "both",
|
|
1028
|
+
"numPlayers": "12"
|
|
1029
|
+
},
|
|
991
1030
|
{
|
|
992
1031
|
"filename": "vert",
|
|
993
1032
|
"hash": "25a9ikled77",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import AStar from '../pathing/astar.js';
|
|
2
|
+
|
|
3
|
+
export class GoToAmmoDispatch {
|
|
4
|
+
check(bot) {
|
|
5
|
+
return bot.me.playing && bot.game.collectables[0].length && bot.intents.includes(bot.Intents.PATHFINDING);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
execute(bot) {
|
|
9
|
+
this.pather = new AStar(bot.pathing.nodeList);
|
|
10
|
+
|
|
11
|
+
let minDistance = 200;
|
|
12
|
+
let closestAmmo = null;
|
|
13
|
+
|
|
14
|
+
for (const ammo of bot.game.collectables[0]) {
|
|
15
|
+
const dx = ammo.x - bot.me.position.x;
|
|
16
|
+
const dy = ammo.y - bot.me.position.y;
|
|
17
|
+
const dz = ammo.z - bot.me.position.z;
|
|
18
|
+
|
|
19
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
20
|
+
|
|
21
|
+
if (distance < minDistance) {
|
|
22
|
+
minDistance = distance;
|
|
23
|
+
closestAmmo = ammo;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const position = Object.entries(bot.me.position).map(entry => Math.floor(entry[1]));
|
|
28
|
+
const targetPos = Object.entries(closestAmmo).map(entry => Math.floor(entry[1]));
|
|
29
|
+
|
|
30
|
+
const myNode = bot.pathing.nodeList.at(...position);
|
|
31
|
+
const targetNode = bot.pathing.nodeList.at(...targetPos);
|
|
32
|
+
|
|
33
|
+
bot.pathing.activePath = this.pather.path(myNode, targetNode);
|
|
34
|
+
|
|
35
|
+
if (!bot.pathing.activePath) return console.error('no path found');
|
|
36
|
+
if (bot.pathing.activePath.length < 2) return console.error('path too short');
|
|
37
|
+
|
|
38
|
+
bot.pathing.followingPath = true;
|
|
39
|
+
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
40
|
+
bot.pathing.activeNodeIdx = 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default GoToAmmoDispatch;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import AStar from '../pathing/astar.js';
|
|
2
|
+
|
|
3
|
+
export class GoToCoopDispatch {
|
|
4
|
+
check(bot) {
|
|
5
|
+
return bot.me.playing && bot.game.zoneNumber && bot.game.activeZone && bot.intents.includes(bot.Intents.PATHFINDING);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
execute(bot) {
|
|
9
|
+
this.pather = new AStar(bot.pathing.nodeList);
|
|
10
|
+
|
|
11
|
+
let minDistance = 200;
|
|
12
|
+
let closestZone = null;
|
|
13
|
+
|
|
14
|
+
for (const zone of bot.game.activeZone) {
|
|
15
|
+
const dx = zone.x - bot.me.position.x;
|
|
16
|
+
const dy = zone.y - bot.me.position.y;
|
|
17
|
+
const dz = zone.z - bot.me.position.z;
|
|
18
|
+
|
|
19
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
20
|
+
|
|
21
|
+
if (distance < minDistance) {
|
|
22
|
+
minDistance = distance;
|
|
23
|
+
closestZone = zone;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const position = Object.entries(bot.me.position).map(entry => Math.floor(entry[1]));
|
|
28
|
+
const targetPos = Object.entries(closestZone).map(entry => Math.floor(entry[1]));
|
|
29
|
+
|
|
30
|
+
const myNode = bot.pathing.nodeList.at(...position);
|
|
31
|
+
const targetNode = bot.pathing.nodeList.at(...targetPos);
|
|
32
|
+
|
|
33
|
+
bot.pathing.activePath = this.pather.path(myNode, targetNode);
|
|
34
|
+
|
|
35
|
+
if (!bot.pathing.activePath) return console.error('no path found');
|
|
36
|
+
if (bot.pathing.activePath.length < 2) return console.error('path too short');
|
|
37
|
+
|
|
38
|
+
bot.pathing.followingPath = true;
|
|
39
|
+
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
40
|
+
bot.pathing.activeNodeIdx = 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default GoToCoopDispatch;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import AStar from '../pathing/astar.js';
|
|
2
|
+
|
|
3
|
+
export class GoToGrenadeDispatch {
|
|
4
|
+
check(bot) {
|
|
5
|
+
return bot.me.playing && bot.game.collectables[1].length && bot.intents.includes(bot.Intents.PATHFINDING);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
execute(bot) {
|
|
9
|
+
this.pather = new AStar(bot.pathing.nodeList);
|
|
10
|
+
|
|
11
|
+
let minDistance = 200;
|
|
12
|
+
let closestGrenade = null;
|
|
13
|
+
|
|
14
|
+
for (const grenade of bot.game.collectables[1]) {
|
|
15
|
+
const dx = grenade.x - bot.me.position.x;
|
|
16
|
+
const dy = grenade.y - bot.me.position.y;
|
|
17
|
+
const dz = grenade.z - bot.me.position.z;
|
|
18
|
+
|
|
19
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
20
|
+
|
|
21
|
+
if (distance < minDistance) {
|
|
22
|
+
minDistance = distance;
|
|
23
|
+
closestGrenade = grenade;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const position = Object.entries(bot.me.position).map(entry => Math.floor(entry[1]));
|
|
28
|
+
const targetPos = Object.entries(closestGrenade).map(entry => Math.floor(entry[1]));
|
|
29
|
+
|
|
30
|
+
const myNode = bot.pathing.nodeList.at(...position);
|
|
31
|
+
const targetNode = bot.pathing.nodeList.at(...targetPos);
|
|
32
|
+
|
|
33
|
+
bot.pathing.activePath = this.pather.path(myNode, targetNode);
|
|
34
|
+
|
|
35
|
+
if (!bot.pathing.activePath) return console.error('no path found');
|
|
36
|
+
if (bot.pathing.activePath.length < 2) return console.error('path too short');
|
|
37
|
+
|
|
38
|
+
bot.pathing.followingPath = true;
|
|
39
|
+
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
40
|
+
bot.pathing.activeNodeIdx = 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default GoToGrenadeDispatch;
|
|
@@ -6,7 +6,11 @@ export class GoToPlayerDispatch {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
check(bot) {
|
|
9
|
-
return bot.me.playing &&
|
|
9
|
+
return bot.me.playing &&
|
|
10
|
+
this.target &&
|
|
11
|
+
this.target.playing &&
|
|
12
|
+
this.target.position &&
|
|
13
|
+
bot.intents.includes(bot.Intents.PATHFINDING);
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
execute(bot) {
|
|
@@ -2,7 +2,11 @@ import AStar from '../pathing/astar.js';
|
|
|
2
2
|
|
|
3
3
|
export class GoToSpatulaDispatch {
|
|
4
4
|
check(bot) {
|
|
5
|
-
return bot.me.playing &&
|
|
5
|
+
return bot.me.playing &&
|
|
6
|
+
bot.game.spatula &&
|
|
7
|
+
bot.game.spatula.coords &&
|
|
8
|
+
bot.game.spatula.coords.x &&
|
|
9
|
+
bot.intents.includes(bot.Intents.PATHFINDING);
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
execute(bot) {
|
|
@@ -6,7 +6,7 @@ export class MeleeDispatch {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
execute(bot) {
|
|
9
|
-
new packet.MeleePacket().execute(bot.
|
|
9
|
+
new packet.MeleePacket().execute(bot.game.socket);
|
|
10
10
|
bot.usingMelee = true;
|
|
11
11
|
|
|
12
12
|
// gameloop every 33.33 (repeating) ms, 17 ticks, so 566.61 is the closest you get
|
|
@@ -39,7 +39,7 @@ export class ReportPlayerDispatch {
|
|
|
39
39
|
|
|
40
40
|
if (!target) throw new Error('target player for ReportPlayerDispatch not found')
|
|
41
41
|
|
|
42
|
-
new packet.ReportPacket(target, this.reasonInt).execute(bot.
|
|
42
|
+
new packet.ReportPacket(target, this.reasonInt).execute(bot.game.socket);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -90,43 +90,20 @@ export class SaveLoadoutDispatch {
|
|
|
90
90
|
|
|
91
91
|
saveLoadout.then(() => {
|
|
92
92
|
if (bot.state.joinedGame)
|
|
93
|
-
new packet.ChangeCharacterPacket(this.changes?.classIdx || bot.me.selectedGun).execute(bot.
|
|
93
|
+
new packet.ChangeCharacterPacket(this.changes?.classIdx || bot.me.selectedGun).execute(bot.game.socket);
|
|
94
|
+
|
|
95
|
+
const findCosmetics = this.intents.includes(this.Intents.COSMETIC_DATA);
|
|
94
96
|
|
|
95
97
|
// apply changes to the bot
|
|
96
98
|
Object.entries(this.changes).forEach(([changeKey, changeValue]) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
case 'stampId':
|
|
107
|
-
bot.me.character.stamp = findItemById(changeValue);
|
|
108
|
-
break;
|
|
109
|
-
|
|
110
|
-
case 'grenadeId':
|
|
111
|
-
bot.me.character.grenade = findItemById(changeValue);
|
|
112
|
-
break;
|
|
113
|
-
|
|
114
|
-
case 'meleeId':
|
|
115
|
-
bot.me.character.melee = findItemById(changeValue);
|
|
116
|
-
break;
|
|
117
|
-
|
|
118
|
-
case 'colorIdx':
|
|
119
|
-
bot.me.character.eggColor = changeValue;
|
|
120
|
-
break;
|
|
121
|
-
|
|
122
|
-
case 'primaryId':
|
|
123
|
-
bot.me.character.primaryGun = findItemById(changeValue[bot.me.selectedGun]);
|
|
124
|
-
break;
|
|
125
|
-
|
|
126
|
-
case 'secondaryId':
|
|
127
|
-
bot.me.character.secondaryGun = findItemById(changeValue[bot.me.selectedGun]);
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
99
|
+
if (changeKey === 'classIdx') bot.me.selectedGun = changeValue;
|
|
100
|
+
else if (changeKey === 'hatId') bot.me.character.hat = findCosmetics ? findItemById(changeValue) : changeValue;
|
|
101
|
+
else if (changeKey === 'stampId') bot.me.character.stamp = findCosmetics ? findItemById(changeValue) : changeValue;
|
|
102
|
+
else if (changeKey === 'grenadeId') bot.me.character.grenade = findCosmetics ? findItemById(changeValue) : changeValue;
|
|
103
|
+
else if (changeKey === 'meleeId') bot.me.character.melee = findCosmetics ? findItemById(changeValue) : changeValue;
|
|
104
|
+
else if (changeKey === 'colorIdx') bot.me.character.eggColor = changeValue;
|
|
105
|
+
else if (changeKey === 'primaryId') bot.me.character.primaryGun = findItemById(changeValue[bot.me.selectedGun]);
|
|
106
|
+
else if (changeKey === 'secondaryId') bot.me.character.secondaryGun = findCosmetics ? findItemById(changeValue[bot.me.selectedGun]) : changeValue;
|
|
130
107
|
})
|
|
131
108
|
})
|
|
132
109
|
}
|
package/src/dispatches/index.js
CHANGED
|
@@ -2,6 +2,9 @@ import BootPlayerDispatch from './BootPlayerDispatch.js';
|
|
|
2
2
|
import ChatDispatch from './ChatDispatch.js';
|
|
3
3
|
import FireDispatch from './FireDispatch.js';
|
|
4
4
|
import GameOptionsDispatch from './GameOptionsDispatch.js';
|
|
5
|
+
import GoToAmmoDispatch from './GoToAmmoDispatch.js';
|
|
6
|
+
import GoToCoopDispatch from './GoToCoopDispatch.js';
|
|
7
|
+
import GoToGrenadeDispatch from './GoToGrenadeDispatch.js';
|
|
5
8
|
import GoToPlayerDispatch from './GoToPlayerDispatch.js';
|
|
6
9
|
import GoToSpatulaDispatch from './GoToSpatulaDispatch.js';
|
|
7
10
|
import LookAtDispatch from './LookAtDispatch.js';
|
|
@@ -15,12 +18,16 @@ import SaveLoadoutDispatch from './SaveLoadoutDispatch.js';
|
|
|
15
18
|
import SpawnDispatch from './SpawnDispatch.js';
|
|
16
19
|
import SwapWeaponDispatch from './SwapWeaponDispatch.js';
|
|
17
20
|
import SwitchTeamDispatch from './SwitchTeamDispatch.js';
|
|
21
|
+
import ThrowGrenadeDispatch from './ThrowGrenadeDispatch.js';
|
|
18
22
|
|
|
19
23
|
export {
|
|
20
24
|
BootPlayerDispatch,
|
|
21
25
|
ChatDispatch,
|
|
22
26
|
FireDispatch,
|
|
23
27
|
GameOptionsDispatch,
|
|
28
|
+
GoToAmmoDispatch,
|
|
29
|
+
GoToCoopDispatch,
|
|
30
|
+
GoToGrenadeDispatch,
|
|
24
31
|
GoToPlayerDispatch,
|
|
25
32
|
GoToSpatulaDispatch,
|
|
26
33
|
LookAtDispatch,
|
|
@@ -33,7 +40,8 @@ export {
|
|
|
33
40
|
SaveLoadoutDispatch,
|
|
34
41
|
SpawnDispatch,
|
|
35
42
|
SwapWeaponDispatch,
|
|
36
|
-
SwitchTeamDispatch
|
|
43
|
+
SwitchTeamDispatch,
|
|
44
|
+
ThrowGrenadeDispatch
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
export default {
|
|
@@ -41,6 +49,9 @@ export default {
|
|
|
41
49
|
ChatDispatch,
|
|
42
50
|
FireDispatch,
|
|
43
51
|
GameOptionsDispatch,
|
|
52
|
+
GoToAmmoDispatch,
|
|
53
|
+
GoToCoopDispatch,
|
|
54
|
+
GoToGrenadeDispatch,
|
|
44
55
|
GoToPlayerDispatch,
|
|
45
56
|
GoToSpatulaDispatch,
|
|
46
57
|
LookAtDispatch,
|
|
@@ -53,5 +64,6 @@ export default {
|
|
|
53
64
|
SaveLoadoutDispatch,
|
|
54
65
|
SpawnDispatch,
|
|
55
66
|
SwapWeaponDispatch,
|
|
56
|
-
SwitchTeamDispatch
|
|
67
|
+
SwitchTeamDispatch,
|
|
68
|
+
ThrowGrenadeDispatch
|
|
57
69
|
}
|
package/src/matchmaker.js
CHANGED
|
@@ -33,8 +33,17 @@ export class Matchmaker {
|
|
|
33
33
|
this.#createSocket(params.instance);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
#createSocket(instance) {
|
|
37
|
-
|
|
36
|
+
async #createSocket(instance) {
|
|
37
|
+
const attempt = async () => {
|
|
38
|
+
try {
|
|
39
|
+
this.ws = new yolkws(`wss://${instance}/matchmaker/`, this.proxy);
|
|
40
|
+
} catch {
|
|
41
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
42
|
+
await attempt();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await attempt();
|
|
38
47
|
|
|
39
48
|
this.ws.onopen = () => {
|
|
40
49
|
this.connected = true;
|
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,7 +14,7 @@ function stringifyCircular(obj) {
|
|
|
14
14
|
}
|
|
15
15
|
return value;
|
|
16
16
|
}, 4);
|
|
17
|
-
}
|
|
17
|
+
}*/
|
|
18
18
|
|
|
19
19
|
class NodeList {
|
|
20
20
|
constructor(raw) {
|
|
@@ -87,6 +87,34 @@ class NodeList {
|
|
|
87
87
|
node.closed = undefined;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
|
|
91
|
+
hasLineOfSight(bot, target) {
|
|
92
|
+
const dx = target.x - bot.x;
|
|
93
|
+
const dy = target.y - bot.y;
|
|
94
|
+
const dz = target.z - bot.z;
|
|
95
|
+
|
|
96
|
+
const steps = Math.max(Math.abs(dx), Math.abs(dy), Math.abs(dz));
|
|
97
|
+
|
|
98
|
+
const xStep = dx / steps;
|
|
99
|
+
const yStep = dy / steps;
|
|
100
|
+
const zStep = dz / steps;
|
|
101
|
+
|
|
102
|
+
let x = bot.x;
|
|
103
|
+
let y = bot.y;
|
|
104
|
+
let z = bot.z;
|
|
105
|
+
|
|
106
|
+
for (let i = 0; i <= steps; i++) {
|
|
107
|
+
const node = this.at(Math.round(x), Math.round(y), Math.round(z));
|
|
108
|
+
if (node && node.isSolid()) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
x += xStep;
|
|
112
|
+
y += yStep;
|
|
113
|
+
z += zStep;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
90
118
|
}
|
|
91
119
|
|
|
92
120
|
class MapNode {
|
|
@@ -309,7 +337,7 @@ class MapNode {
|
|
|
309
337
|
if (this.y - 1 == node.y) {
|
|
310
338
|
return true;
|
|
311
339
|
}
|
|
312
|
-
console.log(`Wedge at ${stringifyCircular(this.position)} can't walk to wedge/air at ${stringifyCircular(node.position)}`);
|
|
340
|
+
// console.log(`Wedge at ${stringifyCircular(this.position)} can't walk to wedge/air at ${stringifyCircular(node.position)}`);
|
|
313
341
|
return false;
|
|
314
342
|
}
|
|
315
343
|
return false;
|
|
@@ -404,7 +432,8 @@ class MapNode {
|
|
|
404
432
|
// console.log('My meshtype, below meshtype: ', this.meshType, belowMe.meshType, 'Other meshtype, below other meshtype: ', node.meshType, belowOther.meshType);
|
|
405
433
|
// console.log('My ry, other ry: ', this.ry, node.ry);
|
|
406
434
|
// console.log('dx0, dy0, dz0: ', dx0, dy0, dz0);
|
|
407
|
-
|
|
435
|
+
// console.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, remove the "PATHFINDING" intent.\n\nPlease paste this full error to our support server and **include the map the bot is on**.`);
|
|
436
|
+
return false;
|
|
408
437
|
}
|
|
409
438
|
|
|
410
439
|
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) {
|