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.
Files changed (49) hide show
  1. package/build/browser.js +6 -6
  2. package/package.json +29 -9
  3. package/src/api.js +97 -23
  4. package/src/bot/GamePlayer.js +2 -2
  5. package/src/bot.js +888 -481
  6. package/src/comm/Codes.js +73 -0
  7. package/src/constants/challenges.js +1822 -0
  8. package/src/constants/index.js +25 -1
  9. package/src/constants/items.js +663 -264
  10. package/src/constants/maps.js +57 -18
  11. package/src/dispatches/BootPlayerDispatch.js +1 -1
  12. package/src/dispatches/ChatDispatch.js +1 -1
  13. package/src/dispatches/GameOptionsDispatch.js +1 -1
  14. package/src/dispatches/GoToAmmoDispatch.js +44 -0
  15. package/src/dispatches/GoToCoopDispatch.js +44 -0
  16. package/src/dispatches/GoToGrenadeDispatch.js +44 -0
  17. package/src/dispatches/GoToPlayerDispatch.js +5 -1
  18. package/src/dispatches/GoToSpatulaDispatch.js +5 -1
  19. package/src/dispatches/LookAtPosDispatch.js +0 -2
  20. package/src/dispatches/LookDispatch2.js +18 -0
  21. package/src/dispatches/MeleeDispatch.js +1 -1
  22. package/src/dispatches/PauseDispatch.js +1 -1
  23. package/src/dispatches/ReloadDispatch.js +14 -2
  24. package/src/dispatches/ReportPlayerDispatch.js +1 -1
  25. package/src/dispatches/SaveLoadoutDispatch.js +11 -34
  26. package/src/dispatches/SpawnDispatch.js +1 -1
  27. package/src/dispatches/SwapWeaponDispatch.js +1 -1
  28. package/src/dispatches/SwitchTeamDispatch.js +1 -1
  29. package/src/dispatches/ThrowGrenadeDispatch.js +1 -1
  30. package/src/dispatches/index.js +9 -0
  31. package/src/matchmaker.js +13 -7
  32. package/src/pathing/mapnode.js +89 -250
  33. package/src/socket.js +2 -3
  34. package/src/types/api.d.ts +2 -16
  35. package/src/types/bot/GamePlayer.d.ts +25 -21
  36. package/src/types/bot.d.ts +125 -54
  37. package/src/types/constants/challenges.d.ts +19 -0
  38. package/src/types/constants/guns.d.ts +240 -0
  39. package/src/types/constants/index.d.ts +102 -0
  40. package/src/types/constants/items.d.ts +21 -0
  41. package/src/types/constants/maps.d.ts +15 -0
  42. package/src/types/dispatches/GoToAmmoDispatch.d.ts +8 -0
  43. package/src/types/dispatches/GoToCoopDispatch.d.ts +8 -0
  44. package/src/types/dispatches/GoToGrenadeDispatch.d.ts +8 -0
  45. package/src/types/dispatches/MovementDispatch.d.ts +2 -0
  46. package/src/types/dispatches/index.d.ts +45 -1
  47. package/src/types/matchmaker.d.ts +19 -14
  48. package/src/types/socket.d.ts +7 -0
  49. package/src/types/gun.d.ts +0 -131
@@ -10,7 +10,7 @@ export const Maps = [
10
10
  "Spatula": true,
11
11
  "King": true
12
12
  },
13
- "availability": "both",
13
+ "availability": "private",
14
14
  "numPlayers": "18"
15
15
  },
16
16
  {
@@ -88,7 +88,7 @@ export const Maps = [
88
88
  "Spatula": true,
89
89
  "King": true
90
90
  },
91
- "availability": "private",
91
+ "availability": "both",
92
92
  "numPlayers": "14"
93
93
  },
94
94
  {
@@ -127,7 +127,7 @@ export const Maps = [
127
127
  "Spatula": true,
128
128
  "King": true
129
129
  },
130
- "availability": "private",
130
+ "availability": "both",
131
131
  "numPlayers": "18"
132
132
  },
133
133
  {
@@ -322,7 +322,7 @@ export const Maps = [
322
322
  "Spatula": true,
323
323
  "King": true
324
324
  },
325
- "availability": "both",
325
+ "availability": "private",
326
326
  "numPlayers": "16"
327
327
  },
328
328
  {
@@ -387,7 +387,20 @@ export const Maps = [
387
387
  "Spatula": true,
388
388
  "King": true
389
389
  },
390
- "availability": "private",
390
+ "availability": "both",
391
+ "numPlayers": "18"
392
+ },
393
+ {
394
+ "filename": "foundation",
395
+ "hash": "11y636vc64b",
396
+ "name": "Foundation",
397
+ "modes": {
398
+ "FFA": true,
399
+ "Teams": true,
400
+ "Spatula": true,
401
+ "King": true
402
+ },
403
+ "availability": "both",
391
404
  "numPlayers": "18"
392
405
  },
393
406
  {
@@ -413,7 +426,7 @@ export const Maps = [
413
426
  "Spatula": true,
414
427
  "King": true
415
428
  },
416
- "availability": "private",
429
+ "availability": "both",
417
430
  "numPlayers": "12"
418
431
  },
419
432
  {
@@ -452,7 +465,7 @@ export const Maps = [
452
465
  "Spatula": true,
453
466
  "King": true
454
467
  },
455
- "availability": "both",
468
+ "availability": "private",
456
469
  "numPlayers": "18"
457
470
  },
458
471
  {
@@ -517,7 +530,7 @@ export const Maps = [
517
530
  "Spatula": true,
518
531
  "King": true
519
532
  },
520
- "availability": "both",
533
+ "availability": "private",
521
534
  "numPlayers": "18"
522
535
  },
523
536
  {
@@ -530,7 +543,7 @@ export const Maps = [
530
543
  "Spatula": true,
531
544
  "King": true
532
545
  },
533
- "availability": "both",
546
+ "availability": "private",
534
547
  "numPlayers": "18"
535
548
  },
536
549
  {
@@ -556,9 +569,22 @@ export const Maps = [
556
569
  "Spatula": true,
557
570
  "King": true
558
571
  },
559
- "availability": "both",
572
+ "availability": "private",
560
573
  "numPlayers": "18"
561
574
  },
575
+ {
576
+ "filename": "metamorph",
577
+ "hash": "hlpma5zbhi",
578
+ "name": "Metamorph",
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": "both",
624
+ "availability": "private",
599
625
  "numPlayers": "18"
600
626
  },
601
627
  {
@@ -647,7 +673,7 @@ export const Maps = [
647
673
  "Spatula": true,
648
674
  "King": true
649
675
  },
650
- "availability": "private",
676
+ "availability": "both",
651
677
  "numPlayers": "14"
652
678
  },
653
679
  {
@@ -738,7 +764,7 @@ export const Maps = [
738
764
  "Spatula": true,
739
765
  "King": true
740
766
  },
741
- "availability": "private",
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": "private",
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": "private",
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": "both",
897
+ "availability": "private",
872
898
  "numPlayers": "12"
873
899
  },
874
900
  {
@@ -920,7 +946,7 @@ export const Maps = [
920
946
  "Spatula": true,
921
947
  "King": true
922
948
  },
923
- "availability": "both",
949
+ "availability": "private",
924
950
  "numPlayers": "18"
925
951
  },
926
952
  {
@@ -985,9 +1011,22 @@ export const Maps = [
985
1011
  "Spatula": true,
986
1012
  "King": true
987
1013
  },
988
- "availability": "private",
1014
+ "availability": "both",
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": false
1026
+ },
1027
+ "availability": "both",
1028
+ "numPlayers": "12"
1029
+ },
991
1030
  {
992
1031
  "filename": "vert",
993
1032
  "hash": "25a9ikled77",
@@ -10,7 +10,7 @@ export class BootPlayerDispatch {
10
10
  }
11
11
 
12
12
  execute(bot) {
13
- new packet.BootPacket(this.uniqueId).execute(bot.gameSocket);
13
+ new packet.BootPacket(this.uniqueId).execute(bot.game.socket);
14
14
  }
15
15
  }
16
16
 
@@ -17,7 +17,7 @@ export class ChatDispatch {
17
17
  }
18
18
 
19
19
  execute(bot) {
20
- new packet.ChatPacket(this.msg).execute(bot.gameSocket);
20
+ new packet.ChatPacket(this.msg).execute(bot.game.socket);
21
21
  bot.lastChatTime = Date.now();
22
22
  }
23
23
  }
@@ -21,7 +21,7 @@ export class GameOptionsDispatch {
21
21
  }
22
22
 
23
23
  execute(bot) {
24
- new packet.GameOptionsPacket(bot.game.options).execute(bot.gameSocket);
24
+ new packet.GameOptionsPacket(bot.game.options).execute(bot.game.socket);
25
25
  }
26
26
  }
27
27
 
@@ -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 && this.target && this.target.playing && this.target.position && !bot.disablePathing;
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 && !bot.disablePathing && bot.game.spatula && bot.game.spatula.coords && bot.game.spatula.coords.x;
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) {
@@ -7,8 +7,6 @@ const calculateYaw = (pos) => setPrecision(mod(Math.atan2(-pos.x, -pos.z), PI2))
7
7
  const calculatePitch = (pos) => setPrecision(Math.atan2(pos.y, Math.hypot(pos.x, pos.z)));
8
8
 
9
9
  export class LookAtPosDispatch {
10
- idOrName;
11
-
12
10
  constructor(pos) {
13
11
  this.pos = pos;
14
12
  }
@@ -0,0 +1,18 @@
1
+ export class LookDispatch2 {
2
+ check(bot) {
3
+ return bot.me.playing;
4
+ }
5
+
6
+ execute(bot) {
7
+ let x = 0;
8
+
9
+ (() => setInterval(() => {
10
+ x += 0.1;
11
+ x %= 2 * Math.PI;
12
+ bot.me.view.yaw = x - Math.PI;
13
+ bot.me.view.pitch = x;
14
+ }, 20))();
15
+ }
16
+ }
17
+
18
+ export default LookDispatch2;
@@ -6,7 +6,7 @@ export class MeleeDispatch {
6
6
  }
7
7
 
8
8
  execute(bot) {
9
- new packet.MeleePacket().execute(bot.gameSocket);
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
@@ -6,7 +6,7 @@ export class PauseDispatch {
6
6
  }
7
7
 
8
8
  execute(bot) {
9
- new packet.PausePacket().execute(bot.gameSocket);
9
+ new packet.PausePacket().execute(bot.game.socket);
10
10
  setTimeout(() => bot.me.playing = false, 3000);
11
11
  }
12
12
  }
@@ -6,9 +6,21 @@ export class ReloadDispatch {
6
6
  }
7
7
 
8
8
  execute(bot) {
9
- new packet.ReloadPacket().execute(bot.gameSocket);
9
+ new packet.ReloadPacket().execute(bot.game.socket);
10
10
 
11
- bot.processReloadPacket(bot.me.id, true);
11
+ const playerActiveWeapon = bot.me.weapons[bot.me.activeGun];
12
+
13
+ if (playerActiveWeapon.ammo) {
14
+ const newRounds = Math.min(
15
+ Math.min(playerActiveWeapon.ammo.capacity, playerActiveWeapon.ammo.reload) - playerActiveWeapon.ammo.rounds,
16
+ playerActiveWeapon.ammo.store
17
+ );
18
+
19
+ playerActiveWeapon.ammo.rounds += newRounds;
20
+ playerActiveWeapon.ammo.store -= newRounds;
21
+ }
22
+
23
+ bot.emit('playerReload', bot.me, playerActiveWeapon);
12
24
 
13
25
  const activeWeapon = bot.me.weapons[bot.me.activeGun];
14
26
  const isLongTime = activeWeapon.ammo.rounds < 1;
@@ -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.gameSocket);
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.gameSocket);
93
+ new packet.ChangeCharacterPacket(this.changes?.classIdx || bot.me.selectedGun).execute(bot.game.socket);
94
+
95
+ const findCosmetics = bot.intents.includes(bot.Intents.COSMETIC_DATA);
94
96
 
95
97
  // apply changes to the bot
96
98
  Object.entries(this.changes).forEach(([changeKey, changeValue]) => {
97
- switch (changeKey) {
98
- case 'classIdx':
99
- bot.me.selectedGun = changeValue;
100
- break;
101
-
102
- case 'hatId':
103
- bot.me.character.hat = findItemById(changeValue);
104
- break;
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
  }
@@ -8,7 +8,7 @@ export class SpawnDispatch {
8
8
  }
9
9
 
10
10
  execute(bot) {
11
- new packet.RespawnPacket().execute(bot.gameSocket);
11
+ new packet.RespawnPacket().execute(bot.game.socket);
12
12
 
13
13
  bot.lastSpawnedTime = Date.now();
14
14
  bot.me.playing = true;
@@ -7,7 +7,7 @@ export class SwapWeaponDispatch {
7
7
 
8
8
  execute(bot) {
9
9
  bot.me.activeGun = +!bot.me.activeGun;
10
- new packet.SwapWeaponPacket(bot.me.activeGun).execute(bot.gameSocket);
10
+ new packet.SwapWeaponPacket(bot.me.activeGun).execute(bot.game.socket);
11
11
  }
12
12
  }
13
13
 
@@ -24,7 +24,7 @@ export class SwitchTeamDispatch {
24
24
  }
25
25
 
26
26
  execute(bot) {
27
- new packet.TeamSwitchingTraitorPacket().execute(bot.gameSocket);
27
+ new packet.TeamSwitchingTraitorPacket().execute(bot.game.socket);
28
28
  }
29
29
  }
30
30
 
@@ -15,7 +15,7 @@ export class ThrowGrenadeDispatch {
15
15
  }
16
16
 
17
17
  execute(bot) {
18
- new packet.ThrowGrenadePacket(this.power).execute(bot.gameSocket);
18
+ new packet.ThrowGrenadePacket(this.power).execute(bot.game.socket);
19
19
  }
20
20
  }
21
21
 
@@ -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';
@@ -22,6 +25,9 @@ export {
22
25
  ChatDispatch,
23
26
  FireDispatch,
24
27
  GameOptionsDispatch,
28
+ GoToAmmoDispatch,
29
+ GoToCoopDispatch,
30
+ GoToGrenadeDispatch,
25
31
  GoToPlayerDispatch,
26
32
  GoToSpatulaDispatch,
27
33
  LookAtDispatch,
@@ -43,6 +49,9 @@ export default {
43
49
  ChatDispatch,
44
50
  FireDispatch,
45
51
  GameOptionsDispatch,
52
+ GoToAmmoDispatch,
53
+ GoToCoopDispatch,
54
+ GoToGrenadeDispatch,
46
55
  GoToPlayerDispatch,
47
56
  GoToSpatulaDispatch,
48
57
  LookAtDispatch,
package/src/matchmaker.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { loginAnonymously } from '#api';
2
- import { GameModes, IsBrowser, PlayTypes } from '#constants';
2
+ import { GameModes, PlayTypes, ProxiesEnabled } from '#constants';
3
3
 
4
4
  import yolkws from './socket.js';
5
5
 
@@ -21,20 +21,26 @@ export class Matchmaker {
21
21
  constructor(params = {}) {
22
22
  if (!params.instance) params.instance = 'shellshock.io';
23
23
 
24
- if (params.proxy && IsBrowser)
25
- throw new Error('proxies do not work and hence are not supported in the browser');
26
-
27
24
  if (params.sessionId) this.sessionId = params.sessionId;
28
25
  else this.#createSessionId(params.instance);
29
26
 
30
- if (params.proxy && IsBrowser) throw new Error('proxies do not work and hence are not supported in the browser');
27
+ if (params.proxy && !ProxiesEnabled) throw new Error('proxies do not work and hence are not supported in the browser');
31
28
  else if (params.proxy) this.proxy = params.proxy;
32
29
 
33
30
  this.#createSocket(params.instance);
34
31
  }
35
32
 
36
- #createSocket(instance) {
37
- this.ws = new yolkws(`wss://${instance}/matchmaker/`, this.proxy);
33
+ async #createSocket(instance) {
34
+ const attempt = async () => {
35
+ try {
36
+ this.ws = new yolkws(`wss://${instance}/matchmaker/`, this.proxy);
37
+ } catch {
38
+ await new Promise((resolve) => setTimeout(resolve, 100));
39
+ await attempt();
40
+ }
41
+ }
42
+
43
+ await attempt();
38
44
 
39
45
  this.ws.onopen = () => {
40
46
  this.connected = true;