yolkbot 1.4.8 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +1 -1
  2. package/browser/build/global.js +1 -1
  3. package/browser/build/module.js +1 -1
  4. package/dist/api.d.ts +34 -16
  5. package/dist/api.js +164 -121
  6. package/dist/bot/GamePlayer.d.ts +2 -2
  7. package/dist/bot/GamePlayer.js +15 -5
  8. package/dist/bot.d.ts +121 -83
  9. package/dist/bot.js +624 -1077
  10. package/dist/comm/CommIn.js +14 -17
  11. package/dist/comm/CommOut.js +15 -15
  12. package/dist/constants/CommCode.js +1 -1
  13. package/dist/constants/findItemById.js +2 -1
  14. package/dist/constants/guns.d.ts +16 -41
  15. package/dist/constants/guns.js +137 -259
  16. package/dist/constants/index.d.ts +7 -9
  17. package/dist/constants/index.js +15 -13
  18. package/dist/dispatches/BanPlayerDispatch.d.ts +3 -1
  19. package/dist/dispatches/BootPlayerDispatch.d.ts +3 -1
  20. package/dist/dispatches/ChatDispatch.d.ts +3 -1
  21. package/dist/dispatches/ChatDispatch.js +3 -3
  22. package/dist/dispatches/FireDispatch.d.ts +3 -1
  23. package/dist/dispatches/GameOptionsDispatch.d.ts +3 -1
  24. package/dist/dispatches/GoToAmmoDispatch.d.ts +2 -0
  25. package/dist/dispatches/GoToAmmoDispatch.js +15 -16
  26. package/dist/dispatches/GoToCoopDispatch.d.ts +2 -0
  27. package/dist/dispatches/GoToCoopDispatch.js +19 -20
  28. package/dist/dispatches/GoToGrenadeDispatch.d.ts +2 -0
  29. package/dist/dispatches/GoToGrenadeDispatch.js +15 -16
  30. package/dist/dispatches/GoToPlayerDispatch.d.ts +3 -1
  31. package/dist/dispatches/GoToPlayerDispatch.js +16 -21
  32. package/dist/dispatches/GoToSpatulaDispatch.d.ts +2 -0
  33. package/dist/dispatches/GoToSpatulaDispatch.js +11 -14
  34. package/dist/dispatches/LookAtDispatch.d.ts +3 -1
  35. package/dist/dispatches/LookAtDispatch.js +8 -6
  36. package/dist/dispatches/LookAtPosDispatch.d.ts +3 -1
  37. package/dist/dispatches/LookAtPosDispatch.js +1 -1
  38. package/dist/dispatches/MeleeDispatch.d.ts +2 -0
  39. package/dist/dispatches/MeleeDispatch.js +4 -4
  40. package/dist/dispatches/MovementDispatch.d.ts +3 -1
  41. package/dist/dispatches/MovementDispatch.js +1 -1
  42. package/dist/dispatches/PauseDispatch.d.ts +2 -0
  43. package/dist/dispatches/ReloadDispatch.d.ts +2 -0
  44. package/dist/dispatches/ReloadDispatch.js +17 -10
  45. package/dist/dispatches/ReportPlayerDispatch.d.ts +4 -2
  46. package/dist/dispatches/ReportPlayerDispatch.js +8 -6
  47. package/dist/dispatches/ResetGameDispatch.d.ts +2 -0
  48. package/dist/dispatches/SaveLoadoutDispatch.d.ts +4 -2
  49. package/dist/dispatches/SaveLoadoutDispatch.js +9 -8
  50. package/dist/dispatches/SpawnDispatch.d.ts +2 -0
  51. package/dist/dispatches/SpawnDispatch.js +5 -1
  52. package/dist/dispatches/SwapWeaponDispatch.d.ts +3 -1
  53. package/dist/dispatches/SwapWeaponDispatch.js +1 -1
  54. package/dist/dispatches/SwitchTeamDispatch.d.ts +2 -0
  55. package/dist/dispatches/SwitchTeamDispatch.js +2 -1
  56. package/dist/dispatches/ThrowGrenadeDispatch.d.ts +3 -1
  57. package/dist/dispatches/index.d.ts +105 -182
  58. package/dist/dispatches/index.js +24 -25
  59. package/dist/enums.d.ts +154 -0
  60. package/dist/enums.js +114 -0
  61. package/dist/env/fetch.d.ts +15 -0
  62. package/dist/env/fetch.js +113 -79
  63. package/dist/env/globals.d.ts +9 -0
  64. package/dist/env/globals.js +11 -9
  65. package/dist/index.d.ts +31 -0
  66. package/dist/index.js +24 -14
  67. package/dist/packets/addPlayer.js +63 -0
  68. package/dist/packets/beginShellStreak.js +44 -0
  69. package/dist/packets/challengeCompleted.js +16 -0
  70. package/dist/packets/changeCharacter.js +46 -0
  71. package/dist/packets/chat.js +10 -0
  72. package/dist/packets/collectItem.js +26 -0
  73. package/dist/packets/die.js +40 -0
  74. package/dist/packets/endShellStreak.js +21 -0
  75. package/dist/packets/eventModifier.js +8 -0
  76. package/dist/packets/explode.js +19 -0
  77. package/dist/packets/fire.js +21 -0
  78. package/dist/packets/gameAction.js +33 -0
  79. package/dist/packets/gameJoined.js +64 -0
  80. package/dist/packets/gameOptions.js +27 -0
  81. package/dist/packets/hitMe.js +12 -0
  82. package/dist/packets/hitMeHardBoiled.js +18 -0
  83. package/dist/packets/hitThem.js +12 -0
  84. package/dist/packets/melee.js +8 -0
  85. package/dist/packets/metaGameState.js +62 -0
  86. package/dist/packets/pause.js +17 -0
  87. package/dist/packets/ping.js +19 -0
  88. package/dist/packets/playerInfo.js +15 -0
  89. package/dist/packets/reload.js +17 -0
  90. package/dist/packets/removePlayer.js +10 -0
  91. package/dist/packets/respawn.js +31 -0
  92. package/dist/packets/socketReady.js +16 -0
  93. package/dist/packets/spawnItem.js +11 -0
  94. package/dist/packets/swapWeapon.js +11 -0
  95. package/dist/packets/switchTeam.js +13 -0
  96. package/dist/packets/syncMe.js +25 -0
  97. package/dist/packets/syncThem.js +63 -0
  98. package/dist/packets/throwGrenade.js +17 -0
  99. package/dist/packets/updateBalance.js +8 -0
  100. package/dist/pathing/astar.js +33 -20
  101. package/dist/pathing/mapnode.d.ts +3 -1
  102. package/dist/pathing/mapnode.js +170 -65
  103. package/dist/socket.d.ts +21 -6
  104. package/dist/socket.js +48 -38
  105. package/dist/util.d.ts +4 -1
  106. package/dist/util.js +102 -44
  107. package/dist/wasm/bytes.d.ts +1 -1
  108. package/dist/wasm/bytes.js +1 -1
  109. package/dist/wasm/direct.d.ts +1 -1
  110. package/dist/wasm/direct.js +13 -13
  111. package/dist/wasm/legacy.d.ts +7 -6
  112. package/dist/wasm/legacy.js +14 -8
  113. package/package.json +43 -30
  114. package/dist/comm/index.d.ts +0 -12
  115. package/dist/comm/index.js +0 -11
  116. package/dist/constants/changelog.d.ts +0 -7
  117. package/dist/constants/housePromo.d.ts +0 -40
  118. package/dist/constants/language.d.ts +0 -3
  119. package/dist/constants/notices.d.ts +0 -4
  120. package/dist/constants/shellNews.d.ts +0 -12
  121. package/dist/constants/shellYoutube.d.ts +0 -12
  122. package/dist/constants/shopItems.d.ts +0 -15
  123. package/dist/constants/sounds.d.ts +0 -10
  124. package/dist/matchmaker.d.ts +0 -50
  125. package/dist/matchmaker.js +0 -141
  126. package/dist/pathing/binaryheap.d.ts +0 -18
  127. package/dist/pathing/binaryheap.js +0 -79
  128. package/dist/wasm/util.d.ts +0 -9
  129. package/dist/wasm/util.js +0 -19
@@ -1,5 +1,4 @@
1
- import globals from "../env/globals.js";
2
- import { AUG, CSG1, DozenGauge, Eggk47, M24, RPEGG, SMG } from "./guns.js";
1
+ import { AUG, CSG1, DozenGauge, EggK47, M24, RPEGG, SMG } from "./guns.js";
3
2
  export { findItemById } from "./findItemById.js";
4
3
  export const BanDuration = {
5
4
  FiveMinutes: 0,
@@ -54,7 +53,8 @@ export const CoopState = {
54
53
  Abandoned: 6,
55
54
  Unclaimed: 7
56
55
  };
57
- export const FirebaseKey = "AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50";
56
+ const miniCodec = (s, k = 42) => s.split("").map((c) => String.fromCharCode(c.charCodeAt(0) ^ k)).join("");
57
+ export const FirebaseKey = miniCodec("kcPKySnz\x1Eyc@aK]\x1Ck\x1EI\x07P\\LsRciZHo@D\x1BXxDd\x1F\x1A");
58
58
  export const FramesBetweenSyncs = 3;
59
59
  export const GameAction = {
60
60
  Reset: 1,
@@ -72,7 +72,7 @@ export const GameOptionFlag = {
72
72
  NoTeamShuffle: 4
73
73
  };
74
74
  export const GunEquipTime = 13;
75
- export const GunList = [Eggk47, DozenGauge, CSG1, RPEGG, SMG, M24, AUG];
75
+ export const GunList = [EggK47, DozenGauge, CSG1, RPEGG, SMG, M24, AUG];
76
76
  export const ItemType = {
77
77
  Hat: 1,
78
78
  Stamp: 2,
@@ -127,13 +127,15 @@ export const Team = {
127
127
  Blue: 1,
128
128
  Red: 2
129
129
  };
130
- export const URLRewards = [
131
- "giveBasketBrosReward",
132
- "mercZoneFinalGift",
133
- "midMonthGiveMeEggs",
134
- "newYolkerSignupReward",
135
- "newYolkerItemReward",
136
- "newYolkerWelcomeBack",
137
- "WelcomeBack"
130
+ const latestChromeVersion = 143;
131
+ const latestFirefoxVersion = 146;
132
+ const agents = [
133
+ `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${latestChromeVersion}.0.0.0 Safari/537.36`,
134
+ `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${latestChromeVersion}.0.0.0 Safari/537.36`,
135
+ `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:${latestFirefoxVersion}.0) Gecko/20100101 Firefox/${latestFirefoxVersion}.0`,
136
+ `Mozilla/5.0 (X11; Linux x86_64; rv:${latestFirefoxVersion}.0) Gecko/20100101 Firefox/${latestFirefoxVersion}.0`,
137
+ `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${latestChromeVersion}.0.0.0 Safari/537.36`,
138
+ `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${latestChromeVersion}.0.0.0 Safari/537.36 Edg/${latestChromeVersion}.0.0.0`,
139
+ `Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:${latestFirefoxVersion}.0) Gecko/20100101 Firefox/${latestFirefoxVersion}.0`
138
140
  ];
139
- export const UserAgent = globals.isBrowser ? null : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";
141
+ export const UserAgent = agents[Math.floor(Math.random() * agents.length)];
@@ -1,11 +1,13 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [uniqueId: string, duration: number, reason?: string];
4
+
3
5
  export declare class BanPlayerDispatch {
4
6
  uniqueId: string;
5
7
  duration: number;
6
8
  reason?: string;
7
9
 
8
- constructor(uniqueId: string, duration: number, reason?: string);
10
+ constructor(...args: Params);
9
11
 
10
12
  validate(bot: Bot): boolean;
11
13
  check(bot: Bot): boolean;
@@ -1,9 +1,11 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [uniqueId: string];
4
+
3
5
  export declare class BootPlayerDispatch {
4
6
  uniqueId: string;
5
7
 
6
- constructor(uniqueId: string);
8
+ constructor(...args: Params);
7
9
 
8
10
  validate(bot: Bot): boolean;
9
11
  check(bot: Bot): boolean;
@@ -1,9 +1,11 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [msg: string];
4
+
3
5
  export declare class ChatDispatch {
4
6
  msg: string;
5
7
 
6
- constructor(msg: string);
8
+ constructor(...args: Params);
7
9
 
8
10
  validate(bot: Bot): boolean;
9
11
  check(bot: Bot): boolean;
@@ -5,11 +5,13 @@ export class ChatDispatch {
5
5
  constructor(msg) {
6
6
  this.msg = msg;
7
7
  }
8
- validate() {
8
+ validate(bot) {
9
9
  if (typeof this.msg !== "string")
10
10
  return false;
11
11
  if (this.msg.length < 1 || this.msg.length > 64)
12
12
  return false;
13
+ if (!bot.game.isPrivate && !bot.account.emailVerified && !bot.account.isAged && !bot.account.isCG)
14
+ return false;
13
15
  return true;
14
16
  }
15
17
  check(bot) {
@@ -17,8 +19,6 @@ export class ChatDispatch {
17
19
  return false;
18
20
  if (!bot.game.isPrivate && !bot.account.adminRoles && bot.state.chatLines >= 2)
19
21
  return false;
20
- if (!bot.game.isPrivate && !bot.account.emailVerified && !bot.account.isAged)
21
- return false;
22
22
  return true;
23
23
  }
24
24
  execute(bot) {
@@ -1,9 +1,11 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [amount?: number];
4
+
3
5
  export declare class FireDispatch {
4
6
  amount: number;
5
7
 
6
- constructor(amount?: number);
8
+ constructor(...args: Params);
7
9
 
8
10
  validate(bot: Bot): boolean;
9
11
  check(bot: Bot): boolean;
@@ -19,10 +19,12 @@ export interface GameOptionChanges {
19
19
  rawWeaponsDisabled?: boolean[];
20
20
  }
21
21
 
22
+ export type Params = [changes: GameOptionChanges];
23
+
22
24
  export declare class GameOptionsDispatch {
23
25
  changes: GameOptionChanges;
24
26
 
25
- constructor(changes: GameOptionChanges);
27
+ constructor(...args: Params);
26
28
 
27
29
  validate(bot: Bot): boolean;
28
30
  check(bot: Bot): boolean;
@@ -1,5 +1,7 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [];
4
+
3
5
  export class GoToAmmoDispatch {
4
6
  validate(bot: Bot): boolean;
5
7
  check(bot: Bot): boolean;
@@ -1,17 +1,16 @@
1
- import AStar from "../pathing/astar.js";
1
+ import { Intents, PathfindError } from "../enums.js";
2
2
 
3
3
  export class GoToAmmoDispatch {
4
4
  validate(bot) {
5
- return bot.intents.includes(bot.Intents.PATHFINDING);
5
+ return bot.intents.includes(Intents.PATHFINDING);
6
6
  }
7
7
  check(bot) {
8
- return bot.me.playing && bot.game.collectables[0].length;
8
+ return bot.me.playing && bot.game.collectibles[0].length;
9
9
  }
10
10
  execute(bot) {
11
- this.pather = new AStar(bot.pathing.nodeList);
12
- let minDistance = 200;
11
+ let minDistance = 2000;
13
12
  let closestAmmo = null;
14
- for (const ammo of bot.game.collectables[0]) {
13
+ for (const ammo of bot.game.collectibles[0]) {
15
14
  const dx = ammo.x - bot.me.position.x;
16
15
  const dy = ammo.y - bot.me.position.y;
17
16
  const dz = ammo.z - bot.me.position.z;
@@ -21,16 +20,16 @@ export class GoToAmmoDispatch {
21
20
  closestAmmo = ammo;
22
21
  }
23
22
  }
24
- const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
25
- const targetPos = Object.entries(closestAmmo).map((entry) => Math.floor(entry[1]));
26
- const myNode = bot.pathing.nodeList.at(...position);
27
- const targetNode = bot.pathing.nodeList.at(...targetPos);
28
- bot.pathing.activePath = this.pather.path(myNode, targetNode);
29
- if (!bot.pathing.activePath)
30
- return bot.processError("no path found");
31
- if (bot.pathing.activePath.length < 2)
32
- return bot.processError("path too short");
33
- bot.pathing.followingPath = true;
23
+ if (!closestAmmo)
24
+ return;
25
+ const myNode = bot.pathing.nodeList.atObject(bot.me.position);
26
+ const targetNode = bot.pathing.nodeList.atObject(closestAmmo);
27
+ const path = bot.pathing.astar.path(myNode, targetNode);
28
+ if (!path)
29
+ return bot.$emit("pathfindError", PathfindError.NoPathFound);
30
+ if (path.length < 2)
31
+ return bot.$emit("pathfindError", PathfindError.PathTooShort);
32
+ bot.pathing.activePath = path;
34
33
  bot.pathing.activeNode = bot.pathing.activePath[1];
35
34
  bot.pathing.activeNodeIdx = 1;
36
35
  }
@@ -1,5 +1,7 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [];
4
+
3
5
  export class GoToCoopDispatch {
4
6
  validate(bot: Bot): boolean;
5
7
  check(bot: Bot): boolean;
@@ -1,36 +1,35 @@
1
- import AStar from "../pathing/astar.js";
1
+ import { Intents, PathfindError } from "../enums.js";
2
2
 
3
3
  export class GoToCoopDispatch {
4
4
  validate(bot) {
5
- return bot.intents.includes(bot.Intents.PATHFINDING);
5
+ return bot.intents.includes(Intents.PATHFINDING);
6
6
  }
7
7
  check(bot) {
8
- return bot.me.playing && bot.game.zoneNumber && bot.game.activeZone;
8
+ return bot.me.playing && bot.game.kotc.zoneIdx && bot.game.kotc.activeZone;
9
9
  }
10
10
  execute(bot) {
11
- this.pather = new AStar(bot.pathing.nodeList);
12
- let minDistance = 200;
11
+ let minDistance = 20000;
13
12
  let closestZone = null;
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;
13
+ for (const zoneCoords of bot.game.kotc.activeZone) {
14
+ const dx = zoneCoords.x - bot.me.position.x;
15
+ const dy = zoneCoords.y - bot.me.position.y;
16
+ const dz = zoneCoords.z - bot.me.position.z;
18
17
  const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
19
18
  if (distance < minDistance) {
20
19
  minDistance = distance;
21
- closestZone = zone;
20
+ closestZone = zoneCoords;
22
21
  }
23
22
  }
24
- const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
25
- const targetPos = Object.entries(closestZone).map((entry) => Math.floor(entry[1]));
26
- const myNode = bot.pathing.nodeList.at(...position);
27
- const targetNode = bot.pathing.nodeList.at(...targetPos);
28
- bot.pathing.activePath = this.pather.path(myNode, targetNode);
29
- if (!bot.pathing.activePath)
30
- return bot.processError("no path found");
31
- if (bot.pathing.activePath.length < 2)
32
- return bot.processError("path too short");
33
- bot.pathing.followingPath = true;
23
+ if (!closestZone)
24
+ return;
25
+ const myNode = bot.pathing.nodeList.atObject(bot.me.position);
26
+ const targetNode = bot.pathing.nodeList.atObject(closestZone);
27
+ const path = bot.pathing.astar.path(myNode, targetNode);
28
+ if (!path)
29
+ return bot.$emit("pathfindError", PathfindError.NoPathFound);
30
+ if (path.length < 2)
31
+ return bot.$emit("pathfindError", PathfindError.PathTooShort);
32
+ bot.pathing.activePath = path;
34
33
  bot.pathing.activeNode = bot.pathing.activePath[1];
35
34
  bot.pathing.activeNodeIdx = 1;
36
35
  }
@@ -1,5 +1,7 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [];
4
+
3
5
  export class GoToGrenadeDispatch {
4
6
  validate(bot: Bot): boolean;
5
7
  check(bot: Bot): boolean;
@@ -1,17 +1,16 @@
1
- import AStar from "../pathing/astar.js";
1
+ import { Intents, PathfindError } from "../enums.js";
2
2
 
3
3
  export class GoToGrenadeDispatch {
4
4
  validate(bot) {
5
- return bot.intents.includes(bot.Intents.PATHFINDING);
5
+ return bot.intents.includes(Intents.PATHFINDING);
6
6
  }
7
7
  check(bot) {
8
- return bot.me.playing && bot.game.collectables[1].length;
8
+ return bot.me.playing && bot.game.collectibles[1].length;
9
9
  }
10
10
  execute(bot) {
11
- this.pather = new AStar(bot.pathing.nodeList);
12
- let minDistance = 200;
11
+ let minDistance = 2000;
13
12
  let closestGrenade = null;
14
- for (const grenade of bot.game.collectables[1]) {
13
+ for (const grenade of bot.game.collectibles[1]) {
15
14
  const dx = grenade.x - bot.me.position.x;
16
15
  const dy = grenade.y - bot.me.position.y;
17
16
  const dz = grenade.z - bot.me.position.z;
@@ -21,16 +20,16 @@ export class GoToGrenadeDispatch {
21
20
  closestGrenade = grenade;
22
21
  }
23
22
  }
24
- const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
25
- const targetPos = Object.entries(closestGrenade).map((entry) => Math.floor(entry[1]));
26
- const myNode = bot.pathing.nodeList.at(...position);
27
- const targetNode = bot.pathing.nodeList.at(...targetPos);
28
- bot.pathing.activePath = this.pather.path(myNode, targetNode);
29
- if (!bot.pathing.activePath)
30
- return bot.processError("no path found");
31
- if (bot.pathing.activePath.length < 2)
32
- return bot.processError("path too short");
33
- bot.pathing.followingPath = true;
23
+ if (!closestGrenade)
24
+ return;
25
+ const myNode = bot.pathing.nodeList.atObject(bot.me.position);
26
+ const targetNode = bot.pathing.nodeList.atObject(closestGrenade);
27
+ const path = bot.pathing.astar.path(myNode, targetNode);
28
+ if (!path)
29
+ return bot.$emit("pathfindError", PathfindError.NoPathFound);
30
+ if (path.length < 2)
31
+ return bot.$emit("pathfindError", PathfindError.PathTooShort);
32
+ bot.pathing.activePath = path;
34
33
  bot.pathing.activeNode = bot.pathing.activePath[1];
35
34
  bot.pathing.activeNodeIdx = 1;
36
35
  }
@@ -1,9 +1,11 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [idOrName: string];
4
+
3
5
  export declare class GoToPlayerDispatch {
4
6
  idOrName: string;
5
7
 
6
- constructor(idOrName: string);
8
+ constructor(...args: Params);
7
9
 
8
10
  validate(bot: Bot): boolean;
9
11
  check(bot: Bot): boolean;
@@ -1,37 +1,32 @@
1
- import AStar from "../pathing/astar.js";
1
+ import { Intents, PathfindError } from "../enums.js";
2
2
 
3
3
  export class GoToPlayerDispatch {
4
4
  idOrName;
5
5
  constructor(idOrName) {
6
6
  this.idOrName = idOrName;
7
7
  }
8
+ $grabPlayer(bot) {
9
+ return bot.players[this.idOrName.toString()] || Object.values(bot.players).find((player) => player.name === this.idOrName.toString());
10
+ }
8
11
  validate(bot) {
9
- if (!bot.intents.includes(bot.Intents.PATHFINDING))
10
- return false;
11
- if (!this.idOrName)
12
- return false;
13
- const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
14
- return !!target;
12
+ return bot.intents.includes(Intents.PATHFINDING) && (typeof this.idOrName === "string" || typeof this.idOrName === "number");
15
13
  }
16
14
  check(bot) {
17
15
  if (!bot.me.playing)
18
16
  return false;
19
- const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
20
- return target && target.playing && target.position && target.position.x;
17
+ const target = this.$grabPlayer(bot);
18
+ return target && target.playing && target.position && Number.isFinite(target.position.x);
21
19
  }
22
20
  execute(bot) {
23
- this.pather = new AStar(bot.pathing.nodeList);
24
- const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
25
- const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
26
- const targetPos = Object.entries(target.position).map((entry) => Math.floor(entry[1]));
27
- const myNode = bot.pathing.nodeList.at(...position);
28
- const targetNode = bot.pathing.nodeList.at(...targetPos);
29
- bot.pathing.activePath = this.pather.path(myNode, targetNode);
30
- if (!bot.pathing.activePath)
31
- return bot.processError("no path found");
32
- if (bot.pathing.activePath.length < 2)
33
- return bot.processError("path too short");
34
- bot.pathing.followingPath = true;
21
+ const target = this.$grabPlayer(bot);
22
+ const myNode = bot.pathing.nodeList.atObject(bot.me.position);
23
+ const targetNode = bot.pathing.nodeList.atObject(target.position);
24
+ const path = bot.pathing.astar.path(myNode, targetNode);
25
+ if (!path)
26
+ return bot.$emit("pathfindError", PathfindError.NoPathFound);
27
+ if (path.length < 2)
28
+ return bot.$emit("pathfindError", PathfindError.PathTooShort);
29
+ bot.pathing.activePath = path;
35
30
  bot.pathing.activeNode = bot.pathing.activePath[1];
36
31
  bot.pathing.activeNodeIdx = 1;
37
32
  }
@@ -1,5 +1,7 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [];
4
+
3
5
  export class GoToSpatulaDispatch {
4
6
  validate(bot: Bot): boolean;
5
7
  check(bot: Bot): boolean;
@@ -1,24 +1,21 @@
1
- import AStar from "../pathing/astar.js";
1
+ import { Intents, PathfindError } from "../enums.js";
2
2
 
3
3
  export class GoToSpatulaDispatch {
4
4
  validate(bot) {
5
- return bot.intents.includes(bot.Intents.PATHFINDING);
5
+ return bot.intents.includes(Intents.PATHFINDING);
6
6
  }
7
7
  check(bot) {
8
- return bot.me.playing && bot.game.spatula && bot.game.spatula.coords && bot.game.spatula.coords.x;
8
+ return bot.me.playing && bot.game.spatula && bot.game.spatula.coords && Number.isFinite(bot.game.spatula.coords.x);
9
9
  }
10
10
  execute(bot) {
11
- this.pather = new AStar(bot.pathing.nodeList);
12
- const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
13
- const targetPos = Object.entries(bot.game.spatula.coords).map((entry) => Math.floor(entry[1]));
14
- const myNode = bot.pathing.nodeList.at(...position);
15
- const targetNode = bot.pathing.nodeList.at(...targetPos);
16
- bot.pathing.activePath = this.pather.path(myNode, targetNode);
17
- if (!bot.pathing.activePath)
18
- return bot.processError("no path found");
19
- if (bot.pathing.activePath.length < 2)
20
- return bot.processError("path too short");
21
- bot.pathing.followingPath = true;
11
+ const myNode = bot.pathing.nodeList.atObject(bot.me.position);
12
+ const targetNode = bot.pathing.nodeList.atObject(bot.game.spatula.coords);
13
+ const path = bot.pathing.astar.path(myNode, targetNode);
14
+ if (!path)
15
+ return bot.$emit("pathfindError", PathfindError.NoPathFound);
16
+ if (path.length < 2)
17
+ return bot.$emit("pathfindError", PathfindError.PathTooShort);
18
+ bot.pathing.activePath = path;
22
19
  bot.pathing.activeNode = bot.pathing.activePath[1];
23
20
  bot.pathing.activeNodeIdx = 1;
24
21
  }
@@ -1,9 +1,11 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [idOrName: string];
4
+
3
5
  declare class LookAtDispatch {
4
6
  idOrName: string;
5
7
 
6
- constructor(idOrName: string);
8
+ constructor(...args: Params);
7
9
 
8
10
  validate(bot: Bot): boolean;
9
11
  check(bot: Bot): boolean;
@@ -9,18 +9,20 @@ export class LookAtDispatch {
9
9
  constructor(idOrName) {
10
10
  this.idOrName = idOrName;
11
11
  }
12
- validate(bot) {
13
- const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
14
- return !!target;
12
+ $grabPlayer(bot) {
13
+ return bot.players[this.idOrName.toString()] || Object.values(bot.players).find((player) => player.name === this.idOrName.toString());
14
+ }
15
+ validate() {
16
+ return typeof this.idOrName === "string" || typeof this.idOrName === "number";
15
17
  }
16
18
  check(bot) {
17
19
  if (!bot.me.playing)
18
20
  return false;
19
- const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
20
- return target && target.playing && target.position && target.position.x;
21
+ const target = this.$grabPlayer(bot);
22
+ return target && target.playing && target.position && Number.isFinite(target.position.x);
21
23
  }
22
24
  execute(bot) {
23
- const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
25
+ const target = this.$grabPlayer(bot);
24
26
  const directionVector = {
25
27
  x: target.position.x - bot.me.position.x,
26
28
  y: target.position.y - bot.me.position.y - 0.05,
@@ -1,10 +1,12 @@
1
1
  import Bot from '../bot';
2
2
  import { Position } from '../bot/GamePlayer';
3
3
 
4
+ export type Params = [pos: Position];
5
+
4
6
  export declare class LookAtPosDispatch {
5
7
  pos: Position;
6
8
 
7
- constructor(pos: Position);
9
+ constructor(...args: Params);
8
10
 
9
11
  validate(bot: Bot): boolean;
10
12
  check(bot: Bot): boolean;
@@ -9,7 +9,7 @@ export class LookAtPosDispatch {
9
9
  this.pos = pos;
10
10
  }
11
11
  validate() {
12
- return this.pos && this.pos.x && this.pos.y && this.pos.z;
12
+ return this.pos && Number.isFinite(this.pos.x) && Number.isFinite(this.pos.y) && Number.isFinite(this.pos.z);
13
13
  }
14
14
  check(bot) {
15
15
  return bot.me.playing;
@@ -1,5 +1,7 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [];
4
+
3
5
  export class MeleeDispatch {
4
6
  validate(bot: Bot): boolean;
5
7
  check(bot: Bot): boolean;
@@ -13,12 +13,12 @@ export class MeleeDispatch {
13
13
  const out = new CommOut;
14
14
  out.packInt8(CommCode.melee);
15
15
  out.send(bot.game.socket);
16
- bot.usingMelee = true;
16
+ bot.state.usingMelee = true;
17
17
  setTimeout(() => {
18
- bot.usingMelee = false;
19
- bot.swappingGun = true;
18
+ bot.state.usingMelee = false;
19
+ bot.state.swappingGun = true;
20
20
  setTimeout(() => {
21
- bot.swappingGun = false;
21
+ bot.state.swappingGun = false;
22
22
  }, 0.5 * GunEquipTime);
23
23
  }, 100 / 3 * 17);
24
24
  }
@@ -1,9 +1,11 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [controlKeys: number | number[]];
4
+
3
5
  export class MovementDispatch {
4
6
  inputKeys: number;
5
7
 
6
- constructor(controlKeys: number | number[]);
8
+ constructor(...args: Params);
7
9
 
8
10
  validate(bot: Bot): boolean;
9
11
  check(bot: Bot): boolean;
@@ -4,7 +4,7 @@ export class MovementDispatch {
4
4
  constructor(inputKeys) {
5
5
  if (typeof inputKeys === "number")
6
6
  this.inputKeys = inputKeys;
7
- else if (typeof inputKeys === "object")
7
+ else if (Array.isArray(inputKeys))
8
8
  this.inputKeys = inputKeys.reduce((a, b) => a | b, 0);
9
9
  }
10
10
  validate() {
@@ -1,5 +1,7 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [];
4
+
3
5
  export class PauseDispatch {
4
6
  validate(bot: Bot): boolean;
5
7
  check(bot: Bot): boolean;
@@ -1,5 +1,7 @@
1
1
  import Bot from '../bot';
2
2
 
3
+ export type Params = [];
4
+
3
5
  export class ReloadDispatch {
4
6
  validate(bot: Bot): boolean;
5
7
  check(bot: Bot): boolean;
@@ -6,23 +6,30 @@ export class ReloadDispatch {
6
6
  return true;
7
7
  }
8
8
  check(bot) {
9
- return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee;
9
+ return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee && bot.me.weapons[bot.me.activeGun].ammo?.rounds < bot.me.weapons[bot.me.activeGun].ammo?.capacity && bot.me.weapons[bot.me.activeGun].ammo?.store > 0;
10
10
  }
11
11
  execute(bot) {
12
12
  const out = new CommOut;
13
13
  out.packInt8(CommCode.reload);
14
14
  out.send(bot.game.socket);
15
15
  const playerActiveWeapon = bot.me.weapons[bot.me.activeGun];
16
- if (playerActiveWeapon.ammo) {
17
- const newRounds = Math.min(Math.min(playerActiveWeapon.ammo.capacity, playerActiveWeapon.ammo.reload) - playerActiveWeapon.ammo.rounds, playerActiveWeapon.ammo.store);
18
- playerActiveWeapon.ammo.rounds += newRounds;
19
- playerActiveWeapon.ammo.store -= newRounds;
20
- }
21
- bot.emit("playerReload", bot.me, playerActiveWeapon);
22
- const activeWeapon = bot.me.weapons[bot.me.activeGun];
23
- const isLongTime = activeWeapon.ammo.rounds < 1;
16
+ const isEmpty = playerActiveWeapon.ammo.rounds < 1;
17
+ bot.$emit("playerStartReload", bot.me, playerActiveWeapon);
24
18
  bot.state.reloading = true;
25
- setTimeout(() => bot.state.reloading = false, isLongTime ? activeWeapon.longReloadTime : activeWeapon.shortReloadTime);
19
+ setTimeout(() => {
20
+ if (!bot.me || bot.hasQuit)
21
+ return;
22
+ bot.state.reloading = false;
23
+ const latestWeapon = bot.me.weapons[bot.me.activeGun];
24
+ if (latestWeapon.ammo) {
25
+ const maxLoad = Math.min(latestWeapon.ammo.capacity, latestWeapon.ammo.reload);
26
+ const needed = Math.max(0, maxLoad - latestWeapon.ammo.rounds);
27
+ const newRounds = Math.min(needed, latestWeapon.ammo.store);
28
+ latestWeapon.ammo.rounds += newRounds;
29
+ latestWeapon.ammo.store -= newRounds;
30
+ }
31
+ bot.$emit("playerEndReload", bot.me, latestWeapon);
32
+ }, isEmpty ? playerActiveWeapon.longReloadTime : playerActiveWeapon.shortReloadTime);
26
33
  }
27
34
  }
28
35
  export default ReloadDispatch;
@@ -7,12 +7,14 @@ export interface CheatingReasons {
7
7
  other?: boolean;
8
8
  }
9
9
 
10
+ export type Params = [idOrName: string, reasons?: CheatingReasons];
11
+
10
12
  export class ReportPlayerDispatch {
11
- irOrName: string;
13
+ idOrName: string;
12
14
  reasons: boolean[];
13
15
  reasonInt: number;
14
16
 
15
- constructor(idOrName: string, reasons?: CheatingReasons);
17
+ constructor(...args: Params);
16
18
 
17
19
  check(bot: Bot): boolean;
18
20
  execute(bot: Bot): void;