yolkbot 1.5.7 → 1.5.9

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 (85) hide show
  1. package/browser/build/global.js +1 -1
  2. package/browser/build/module.js +1 -1
  3. package/dist/api.js +1 -244
  4. package/dist/bot/GamePlayer.js +1 -84
  5. package/dist/bot.js +1 -1226
  6. package/dist/comm/CommIn.js +1 -76
  7. package/dist/comm/CommOut.js +1 -60
  8. package/dist/constants/CloseCode.js +1 -27
  9. package/dist/constants/CommCode.js +1 -53
  10. package/dist/constants/challenges.js +1 -1821
  11. package/dist/constants/findItemById.js +1 -3
  12. package/dist/constants/guns.js +1 -155
  13. package/dist/constants/index.js +1 -141
  14. package/dist/constants/items.js +1 -45979
  15. package/dist/constants/maps.js +1 -1289
  16. package/dist/constants/regions.js +1 -30
  17. package/dist/dispatches/BanPlayerDispatch.js +1 -32
  18. package/dist/dispatches/BootPlayerDispatch.js +1 -21
  19. package/dist/dispatches/ChatDispatch.js +1 -32
  20. package/dist/dispatches/FireDispatch.js +1 -15
  21. package/dist/dispatches/GameOptionsDispatch.js +1 -66
  22. package/dist/dispatches/GoToAmmoDispatch.js +1 -37
  23. package/dist/dispatches/GoToCoopDispatch.js +1 -37
  24. package/dist/dispatches/GoToGrenadeDispatch.js +1 -37
  25. package/dist/dispatches/GoToPlayerDispatch.js +1 -34
  26. package/dist/dispatches/GoToSpatulaDispatch.js +1 -23
  27. package/dist/dispatches/LookAtDispatch.js +1 -37
  28. package/dist/dispatches/LookAtPosDispatch.js +1 -29
  29. package/dist/dispatches/MeleeDispatch.js +1 -26
  30. package/dist/dispatches/MovementDispatch.js +1 -26
  31. package/dist/dispatches/PauseDispatch.js +1 -18
  32. package/dist/dispatches/ReloadDispatch.js +1 -35
  33. package/dist/dispatches/ReportPlayerDispatch.js +1 -44
  34. package/dist/dispatches/ResetGameDispatch.js +1 -19
  35. package/dist/dispatches/SaveLoadoutDispatch.js +1 -106
  36. package/dist/dispatches/SpawnDispatch.js +1 -26
  37. package/dist/dispatches/SwapWeaponDispatch.js +1 -25
  38. package/dist/dispatches/SwitchTeamDispatch.js +1 -34
  39. package/dist/dispatches/ThrowGrenadeDispatch.js +1 -21
  40. package/dist/dispatches/index.js +1 -73
  41. package/dist/enums.js +1 -114
  42. package/dist/env/fetch.js +8 -129
  43. package/dist/env/globals.js +1 -17
  44. package/dist/index.js +1 -22
  45. package/dist/packets/addPlayer.js +1 -63
  46. package/dist/packets/beginShellStreak.js +1 -44
  47. package/dist/packets/challengeCompleted.js +1 -16
  48. package/dist/packets/changeCharacter.js +1 -46
  49. package/dist/packets/chat.js +1 -10
  50. package/dist/packets/collectItem.js +1 -26
  51. package/dist/packets/die.js +1 -40
  52. package/dist/packets/endShellStreak.js +1 -21
  53. package/dist/packets/eventModifier.js +1 -8
  54. package/dist/packets/explode.js +1 -19
  55. package/dist/packets/fire.js +1 -21
  56. package/dist/packets/gameAction.js +1 -33
  57. package/dist/packets/gameJoined.js +1 -64
  58. package/dist/packets/gameOptions.js +1 -27
  59. package/dist/packets/hitMe.js +1 -12
  60. package/dist/packets/hitMeHardBoiled.js +1 -18
  61. package/dist/packets/hitThem.js +1 -12
  62. package/dist/packets/melee.js +1 -8
  63. package/dist/packets/metaGameState.js +1 -62
  64. package/dist/packets/pause.js +1 -17
  65. package/dist/packets/ping.js +1 -19
  66. package/dist/packets/playerInfo.js +1 -15
  67. package/dist/packets/reload.js +1 -17
  68. package/dist/packets/removePlayer.js +1 -10
  69. package/dist/packets/respawn.js +1 -31
  70. package/dist/packets/socketReady.js +1 -16
  71. package/dist/packets/spawnItem.js +1 -11
  72. package/dist/packets/swapWeapon.js +1 -11
  73. package/dist/packets/switchTeam.js +1 -13
  74. package/dist/packets/syncMe.js +1 -25
  75. package/dist/packets/syncThem.js +1 -63
  76. package/dist/packets/throwGrenade.js +1 -17
  77. package/dist/packets/updateBalance.js +1 -8
  78. package/dist/pathing/astar.js +1 -68
  79. package/dist/pathing/mapnode.js +1 -284
  80. package/dist/socket.js +1 -107
  81. package/dist/util.js +1 -128
  82. package/dist/wasm/bytes.js +1 -8
  83. package/dist/wasm/direct.js +1 -84
  84. package/dist/wasm/legacy.js +1 -176
  85. package/package.json +2 -7
@@ -1,30 +1 @@
1
- export const Regions = [
2
- {
3
- id: "germany",
4
- sub: "egs-static-live-germany-5t7y9re9"
5
- },
6
- {
7
- id: "santiago",
8
- sub: "egs-static-live-santiago-1s5w3rbn"
9
- },
10
- {
11
- id: "singapore",
12
- sub: "egs-static-live-singapore-19357z9h"
13
- },
14
- {
15
- id: "sydney",
16
- sub: "egs-static-live-sydney-3v6080dx"
17
- },
18
- {
19
- id: "uscentral",
20
- sub: "egs-static-live-uscentral-2w7m7d9l"
21
- },
22
- {
23
- id: "useast",
24
- sub: "egs-static-live-useast-1u265wed"
25
- },
26
- {
27
- id: "uswest",
28
- sub: "egs-static-live-uswest-451s5eeo"
29
- }
30
- ];
1
+ export const Regions=[{id:"germany",sub:"egs-static-live-germany-5t7y9re9"},{id:"santiago",sub:"egs-static-live-santiago-1s5w3rbn"},{id:"singapore",sub:"egs-static-live-singapore-451s6uaf"},{id:"sydney",sub:"egs-static-live-sydney-3v6080dx"},{id:"uscentral",sub:"egs-static-live-uscentral-2w7m7d9l"},{id:"useast",sub:"egs-static-live-useast-1u265wed"},{id:"uswest",sub:"egs-static-live-uswest-451s5eeo"}];
@@ -1,32 +1 @@
1
- import CommOut from "../comm/CommOut.js";
2
- import CommCode from "../constants/CommCode.js";
3
- import { BanDuration } from "../constants/index.js";
4
-
5
- export class BanPlayerDispatch {
6
- constructor(uniqueId, duration, reason = "") {
7
- this.uniqueId = uniqueId;
8
- this.duration = duration;
9
- this.reason = reason;
10
- }
11
- validate(bot) {
12
- if (typeof this.uniqueId !== "string" || typeof this.reason !== "string")
13
- return false;
14
- if (typeof this.duration !== "number" || !Object.values(BanDuration).some((d) => this.duration === d))
15
- return false;
16
- if (!(bot.account.adminRoles & 4))
17
- return false;
18
- return true;
19
- }
20
- check() {
21
- return true;
22
- }
23
- execute(bot) {
24
- const out = new CommOut;
25
- out.packInt8(CommCode.banPlayer);
26
- out.packString(this.uniqueId);
27
- out.packString(this.reason);
28
- out.packInt8(this.duration);
29
- out.send(bot.game.socket);
30
- }
31
- }
32
- export default BanPlayerDispatch;
1
+ import CommOut from"../comm/CommOut.js";import CommCode from"../constants/CommCode.js";import{BanDuration}from"../constants/index.js";export class BanPlayerDispatch{constructor(uniqueId,duration,reason=""){this.uniqueId=uniqueId;this.duration=duration;this.reason=reason}validate(bot){if(typeof this.uniqueId!=="string"||typeof this.reason!=="string")return false;if(typeof this.duration!=="number"||!Object.values(BanDuration).some((d)=>this.duration===d))return false;if(!(bot.account.adminRoles&4))return false;return true}check(){return true}execute(bot){const out=new CommOut;out.packInt8(CommCode.banPlayer);out.packString(this.uniqueId);out.packString(this.reason);out.packInt8(this.duration);out.send(bot.game.socket)}}export default BanPlayerDispatch;
@@ -1,21 +1 @@
1
- import CommOut from "../comm/CommOut.js";
2
- import CommCode from "../constants/CommCode.js";
3
-
4
- export class BootPlayerDispatch {
5
- constructor(uniqueId) {
6
- this.uniqueId = uniqueId;
7
- }
8
- validate(bot) {
9
- return typeof this.uniqueId === "string" && bot.game.isGameOwner && Object.values(bot.players).find((player) => player.uniqueId === this.uniqueId);
10
- }
11
- check() {
12
- return true;
13
- }
14
- execute(bot) {
15
- const out = new CommOut;
16
- out.packInt8(CommCode.bootPlayer);
17
- out.packString(this.uniqueId);
18
- out.send(bot.game.socket);
19
- }
20
- }
21
- export default BootPlayerDispatch;
1
+ import CommOut from"../comm/CommOut.js";import CommCode from"../constants/CommCode.js";export class BootPlayerDispatch{constructor(uniqueId){this.uniqueId=uniqueId}validate(bot){return typeof this.uniqueId==="string"&&bot.game.isGameOwner&&Object.values(bot.players).find((player)=>player.uniqueId===this.uniqueId)}check(){return true}execute(bot){const out=new CommOut;out.packInt8(CommCode.bootPlayer);out.packString(this.uniqueId);out.send(bot.game.socket)}}export default BootPlayerDispatch;
@@ -1,32 +1 @@
1
- import CommOut from "../comm/CommOut.js";
2
- import CommCode from "../constants/CommCode.js";
3
-
4
- export class ChatDispatch {
5
- constructor(msg) {
6
- this.msg = msg;
7
- }
8
- validate(bot) {
9
- if (typeof this.msg !== "string")
10
- return false;
11
- if (this.msg.length < 1 || this.msg.length > 64)
12
- return false;
13
- if (!bot.game.isPrivate && !bot.account.emailVerified && !bot.account.isAged && !bot.account.isCG)
14
- return false;
15
- return true;
16
- }
17
- check(bot) {
18
- if (!bot.state?.inGame)
19
- return false;
20
- if (!bot.game.isPrivate && !bot.account.adminRoles && bot.state.chatLines >= 2)
21
- return false;
22
- return true;
23
- }
24
- execute(bot) {
25
- bot.state.chatLines++;
26
- const out = new CommOut;
27
- out.packInt8(CommCode.chat);
28
- out.packString(this.msg);
29
- out.send(bot.game.socket);
30
- }
31
- }
32
- export default ChatDispatch;
1
+ import CommOut from"../comm/CommOut.js";import CommCode from"../constants/CommCode.js";export class ChatDispatch{constructor(msg){this.msg=msg}validate(bot){if(typeof this.msg!=="string")return false;if(this.msg.length<1||this.msg.length>64)return false;if(!bot.game.isPrivate&&!bot.account.emailVerified&&!bot.account.isAged&&!bot.account.isCG)return false;return true}check(bot){if(!bot.state?.inGame)return false;if(!bot.game.isPrivate&&!bot.account.adminRoles&&bot.state.chatLines>=2)return false;return true}execute(bot){bot.state.chatLines++;const out=new CommOut;out.packInt8(CommCode.chat);out.packString(this.msg);out.send(bot.game.socket)}}export default ChatDispatch;
@@ -1,15 +1 @@
1
- export class FireDispatch {
2
- constructor(amount) {
3
- this.amount = amount || 1;
4
- }
5
- validate() {
6
- return this.amount >= 1;
7
- }
8
- check(bot) {
9
- return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee && bot.me.weapons[bot.me.activeGun].ammo.rounds >= this.amount;
10
- }
11
- execute(bot) {
12
- bot.state.shotsFired += this.amount || 1;
13
- }
14
- }
15
- export default FireDispatch;
1
+ export class FireDispatch{constructor(amount){this.amount=amount||1}validate(){return this.amount>=1}check(bot){return bot.me.playing&&!bot.state.reloading&&!bot.state.swappingGun&&!bot.state.usingMelee&&bot.me.weapons[bot.me.activeGun].ammo.rounds>=this.amount}execute(bot){bot.state.shotsFired+=this.amount||1}}export default FireDispatch;
@@ -1,66 +1 @@
1
- const gravityScale = Array.from({ length: 4 }, (_, i) => (i + 1) * 0.25);
2
- const damageScale = Array.from({ length: 9 }, (_, i) => i * 0.25);
3
- const regenScale = Array.from({ length: 17 }, (_, i) => i * 0.25);
4
- const whichever = (arg1, arg2) => typeof arg1 === "undefined" ? arg2 : arg1;
5
-
6
- export class GameOptionsDispatch {
7
- constructor(changes) {
8
- this.changes = changes;
9
- }
10
- #constructFinalOutput(bot) {
11
- const output = {};
12
- output.gravity = whichever(this.changes.gravity, bot.game.options.gravity);
13
- output.damage = whichever(this.changes.damage, bot.game.options.damage);
14
- output.healthRegen = whichever(this.changes.healthRegen, bot.game.options.healthRegen);
15
- output.locked = whichever(this.changes.locked, bot.game.options.locked);
16
- output.noTeamChange = whichever(this.changes.noTeamChange, bot.game.options.noTeamChange);
17
- output.noTeamShuffle = whichever(this.changes.noTeamShuffle, bot.game.options.noTeamShuffle);
18
- output.weaponsDisabled = [
19
- whichever(this.changes.disableEggk, bot.game.options.weaponsDisabled[0]),
20
- whichever(this.changes.disableScrambler, bot.game.options.weaponsDisabled[1]),
21
- whichever(this.changes.disableFreeRanger, bot.game.options.weaponsDisabled[2]),
22
- whichever(this.changes.disableRPG, bot.game.options.weaponsDisabled[3]),
23
- whichever(this.changes.disableWhipper, bot.game.options.weaponsDisabled[4]),
24
- whichever(this.changes.disableCrackshot, bot.game.options.weaponsDisabled[5]),
25
- whichever(this.changes.disableTriHard, bot.game.options.weaponsDisabled[6])
26
- ];
27
- if (this.changes.toDisable && Array.isArray(this.changes.toDisable))
28
- this.changes.toDisable.forEach((idx) => output.weaponsDisabled[idx] = true);
29
- if (this.changes.toEnable && Array.isArray(this.changes.toEnable))
30
- this.changes.toEnable.forEach((idx) => output.weaponsDisabled[idx] = false);
31
- if (this.changes.rawWeaponsDisabled && Array.isArray(this.changes.rawWeaponsDisabled) && this.changes.rawWeaponsDisabled.length === 7)
32
- output.weaponsDisabled = this.changes.rawWeaponsDisabled.map((v) => !!v);
33
- output.mustUseSecondary = output.weaponsDisabled.every((v) => v);
34
- return output;
35
- }
36
- validate(bot) {
37
- const wouldBe = this.#constructFinalOutput(bot);
38
- if (!gravityScale.includes(wouldBe.gravity))
39
- return false;
40
- if (!damageScale.includes(wouldBe.damage))
41
- return false;
42
- if (!regenScale.includes(wouldBe.healthRegen))
43
- return false;
44
- if (typeof wouldBe.locked !== "number" && typeof wouldBe.locked !== "boolean")
45
- return false;
46
- if (typeof wouldBe.noTeamChange !== "number" && typeof wouldBe.noTeamChange !== "boolean")
47
- return false;
48
- if (typeof wouldBe.noTeamShuffle !== "number" && typeof wouldBe.noTeamShuffle !== "boolean")
49
- return false;
50
- if (!Array.isArray(wouldBe.weaponsDisabled))
51
- return false;
52
- if (wouldBe.weaponsDisabled.length !== 7)
53
- return false;
54
- if (wouldBe.weaponsDisabled.some((weapon) => typeof weapon !== "number" && typeof weapon !== "boolean"))
55
- return false;
56
- return true;
57
- }
58
- check(bot) {
59
- return bot.game.isGameOwner;
60
- }
61
- execute(bot) {
62
- bot.game.options = this.#constructFinalOutput(bot);
63
- bot.updateGameOptions();
64
- }
65
- }
66
- export default GameOptionsDispatch;
1
+ const gravityScale=Array.from({length:4},(_,i)=>(i+1)*0.25);const damageScale=Array.from({length:9},(_,i)=>i*0.25);const regenScale=Array.from({length:17},(_,i)=>i*0.25);const whichever=(arg1,arg2)=>typeof arg1==="undefined"?arg2:arg1;export class GameOptionsDispatch{constructor(changes){this.changes=changes}#constructFinalOutput(bot){const output={};output.gravity=whichever(this.changes.gravity,bot.game.options.gravity);output.damage=whichever(this.changes.damage,bot.game.options.damage);output.healthRegen=whichever(this.changes.healthRegen,bot.game.options.healthRegen);output.locked=whichever(this.changes.locked,bot.game.options.locked);output.noTeamChange=whichever(this.changes.noTeamChange,bot.game.options.noTeamChange);output.noTeamShuffle=whichever(this.changes.noTeamShuffle,bot.game.options.noTeamShuffle);output.weaponsDisabled=[whichever(this.changes.disableEggk,bot.game.options.weaponsDisabled[0]),whichever(this.changes.disableScrambler,bot.game.options.weaponsDisabled[1]),whichever(this.changes.disableFreeRanger,bot.game.options.weaponsDisabled[2]),whichever(this.changes.disableRPG,bot.game.options.weaponsDisabled[3]),whichever(this.changes.disableWhipper,bot.game.options.weaponsDisabled[4]),whichever(this.changes.disableCrackshot,bot.game.options.weaponsDisabled[5]),whichever(this.changes.disableTriHard,bot.game.options.weaponsDisabled[6])];if(this.changes.toDisable&&Array.isArray(this.changes.toDisable))this.changes.toDisable.forEach((idx)=>output.weaponsDisabled[idx]=true);if(this.changes.toEnable&&Array.isArray(this.changes.toEnable))this.changes.toEnable.forEach((idx)=>output.weaponsDisabled[idx]=false);if(this.changes.rawWeaponsDisabled&&Array.isArray(this.changes.rawWeaponsDisabled)&&this.changes.rawWeaponsDisabled.length===7)output.weaponsDisabled=this.changes.rawWeaponsDisabled.map((v)=>!!v);output.mustUseSecondary=output.weaponsDisabled.every((v)=>v);return output}validate(bot){const wouldBe=this.#constructFinalOutput(bot);if(!gravityScale.includes(wouldBe.gravity))return false;if(!damageScale.includes(wouldBe.damage))return false;if(!regenScale.includes(wouldBe.healthRegen))return false;if(typeof wouldBe.locked!=="number"&&typeof wouldBe.locked!=="boolean")return false;if(typeof wouldBe.noTeamChange!=="number"&&typeof wouldBe.noTeamChange!=="boolean")return false;if(typeof wouldBe.noTeamShuffle!=="number"&&typeof wouldBe.noTeamShuffle!=="boolean")return false;if(!Array.isArray(wouldBe.weaponsDisabled))return false;if(wouldBe.weaponsDisabled.length!==7)return false;if(wouldBe.weaponsDisabled.some((weapon)=>typeof weapon!=="number"&&typeof weapon!=="boolean"))return false;return true}check(bot){return bot.game.isGameOwner}execute(bot){bot.game.options=this.#constructFinalOutput(bot);bot.updateGameOptions()}}export default GameOptionsDispatch;
@@ -1,37 +1 @@
1
- import { Intents, PathfindError } from "../enums.js";
2
-
3
- export class GoToAmmoDispatch {
4
- validate(bot) {
5
- return bot.intents.includes(Intents.PATHFINDING);
6
- }
7
- check(bot) {
8
- return bot.me.playing && bot.game.collectibles[0].length;
9
- }
10
- execute(bot) {
11
- let minDistance = 2000;
12
- let closestAmmo = null;
13
- for (const ammo of bot.game.collectibles[0]) {
14
- const dx = ammo.x - bot.me.position.x;
15
- const dy = ammo.y - bot.me.position.y;
16
- const dz = ammo.z - bot.me.position.z;
17
- const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
18
- if (distance < minDistance) {
19
- minDistance = distance;
20
- closestAmmo = ammo;
21
- }
22
- }
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;
33
- bot.pathing.activeNode = bot.pathing.activePath[1];
34
- bot.pathing.activeNodeIdx = 1;
35
- }
36
- }
37
- export default GoToAmmoDispatch;
1
+ import{Intents,PathfindError}from"../enums.js";export class GoToAmmoDispatch{validate(bot){return bot.intents.includes(Intents.PATHFINDING)}check(bot){return bot.me.playing&&bot.game.collectibles[0].length}execute(bot){let minDistance=2000;let closestAmmo=null;for(const ammo of bot.game.collectibles[0]){const dx=ammo.x-bot.me.position.x;const dy=ammo.y-bot.me.position.y;const dz=ammo.z-bot.me.position.z;const distance=Math.sqrt(dx*dx+dy*dy+dz*dz);if(distance<minDistance){minDistance=distance;closestAmmo=ammo}}if(!closestAmmo)return;const myNode=bot.pathing.nodeList.atObject(bot.me.position);const targetNode=bot.pathing.nodeList.atObject(closestAmmo);const path=bot.pathing.astar.path(myNode,targetNode);if(!path)return bot.$emit("pathfindError",PathfindError.NoPathFound);if(path.length<2)return bot.$emit("pathfindError",PathfindError.PathTooShort);bot.pathing.activePath=path;bot.pathing.activeNode=bot.pathing.activePath[1];bot.pathing.activeNodeIdx=1}}export default GoToAmmoDispatch;
@@ -1,37 +1 @@
1
- import { Intents, PathfindError } from "../enums.js";
2
-
3
- export class GoToCoopDispatch {
4
- validate(bot) {
5
- return bot.intents.includes(Intents.PATHFINDING);
6
- }
7
- check(bot) {
8
- return bot.me.playing && bot.game.kotc.zoneIdx && bot.game.kotc.activeZone;
9
- }
10
- execute(bot) {
11
- let minDistance = 20000;
12
- let closestZone = null;
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;
17
- const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
18
- if (distance < minDistance) {
19
- minDistance = distance;
20
- closestZone = zoneCoords;
21
- }
22
- }
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;
33
- bot.pathing.activeNode = bot.pathing.activePath[1];
34
- bot.pathing.activeNodeIdx = 1;
35
- }
36
- }
37
- export default GoToCoopDispatch;
1
+ import{Intents,PathfindError}from"../enums.js";export class GoToCoopDispatch{validate(bot){return bot.intents.includes(Intents.PATHFINDING)}check(bot){return bot.me.playing&&bot.game.kotc.zoneIdx&&bot.game.kotc.activeZone}execute(bot){let minDistance=20000;let closestZone=null;for(const zoneCoords of bot.game.kotc.activeZone){const dx=zoneCoords.x-bot.me.position.x;const dy=zoneCoords.y-bot.me.position.y;const dz=zoneCoords.z-bot.me.position.z;const distance=Math.sqrt(dx*dx+dy*dy+dz*dz);if(distance<minDistance){minDistance=distance;closestZone=zoneCoords}}if(!closestZone)return;const myNode=bot.pathing.nodeList.atObject(bot.me.position);const targetNode=bot.pathing.nodeList.atObject(closestZone);const path=bot.pathing.astar.path(myNode,targetNode);if(!path)return bot.$emit("pathfindError",PathfindError.NoPathFound);if(path.length<2)return bot.$emit("pathfindError",PathfindError.PathTooShort);bot.pathing.activePath=path;bot.pathing.activeNode=bot.pathing.activePath[1];bot.pathing.activeNodeIdx=1}}export default GoToCoopDispatch;
@@ -1,37 +1 @@
1
- import { Intents, PathfindError } from "../enums.js";
2
-
3
- export class GoToGrenadeDispatch {
4
- validate(bot) {
5
- return bot.intents.includes(Intents.PATHFINDING);
6
- }
7
- check(bot) {
8
- return bot.me.playing && bot.game.collectibles[1].length;
9
- }
10
- execute(bot) {
11
- let minDistance = 2000;
12
- let closestGrenade = null;
13
- for (const grenade of bot.game.collectibles[1]) {
14
- const dx = grenade.x - bot.me.position.x;
15
- const dy = grenade.y - bot.me.position.y;
16
- const dz = grenade.z - bot.me.position.z;
17
- const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
18
- if (distance < minDistance) {
19
- minDistance = distance;
20
- closestGrenade = grenade;
21
- }
22
- }
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;
33
- bot.pathing.activeNode = bot.pathing.activePath[1];
34
- bot.pathing.activeNodeIdx = 1;
35
- }
36
- }
37
- export default GoToGrenadeDispatch;
1
+ import{Intents,PathfindError}from"../enums.js";export class GoToGrenadeDispatch{validate(bot){return bot.intents.includes(Intents.PATHFINDING)}check(bot){return bot.me.playing&&bot.game.collectibles[1].length}execute(bot){let minDistance=2000;let closestGrenade=null;for(const grenade of bot.game.collectibles[1]){const dx=grenade.x-bot.me.position.x;const dy=grenade.y-bot.me.position.y;const dz=grenade.z-bot.me.position.z;const distance=Math.sqrt(dx*dx+dy*dy+dz*dz);if(distance<minDistance){minDistance=distance;closestGrenade=grenade}}if(!closestGrenade)return;const myNode=bot.pathing.nodeList.atObject(bot.me.position);const targetNode=bot.pathing.nodeList.atObject(closestGrenade);const path=bot.pathing.astar.path(myNode,targetNode);if(!path)return bot.$emit("pathfindError",PathfindError.NoPathFound);if(path.length<2)return bot.$emit("pathfindError",PathfindError.PathTooShort);bot.pathing.activePath=path;bot.pathing.activeNode=bot.pathing.activePath[1];bot.pathing.activeNodeIdx=1}}export default GoToGrenadeDispatch;
@@ -1,34 +1 @@
1
- import { Intents, PathfindError } from "../enums.js";
2
-
3
- export class GoToPlayerDispatch {
4
- idOrName;
5
- constructor(idOrName) {
6
- this.idOrName = idOrName;
7
- }
8
- $grabPlayer(bot) {
9
- return bot.players[this.idOrName.toString()] || Object.values(bot.players).find((player) => player.name === this.idOrName.toString());
10
- }
11
- validate(bot) {
12
- return bot.intents.includes(Intents.PATHFINDING) && (typeof this.idOrName === "string" || typeof this.idOrName === "number");
13
- }
14
- check(bot) {
15
- if (!bot.me.playing)
16
- return false;
17
- const target = this.$grabPlayer(bot);
18
- return target && target.playing && target.position && Number.isFinite(target.position.x);
19
- }
20
- execute(bot) {
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;
30
- bot.pathing.activeNode = bot.pathing.activePath[1];
31
- bot.pathing.activeNodeIdx = 1;
32
- }
33
- }
34
- export default GoToPlayerDispatch;
1
+ import{Intents,PathfindError}from"../enums.js";export class GoToPlayerDispatch{idOrName;constructor(idOrName){this.idOrName=idOrName}$grabPlayer(bot){return bot.players[this.idOrName.toString()]||Object.values(bot.players).find((player)=>player.name===this.idOrName.toString())}validate(bot){return bot.intents.includes(Intents.PATHFINDING)&&(typeof this.idOrName==="string"||typeof this.idOrName==="number")}check(bot){if(!bot.me.playing)return false;const target=this.$grabPlayer(bot);return target&&target.playing&&target.position&&Number.isFinite(target.position.x)}execute(bot){const target=this.$grabPlayer(bot);const myNode=bot.pathing.nodeList.atObject(bot.me.position);const targetNode=bot.pathing.nodeList.atObject(target.position);const path=bot.pathing.astar.path(myNode,targetNode);if(!path)return bot.$emit("pathfindError",PathfindError.NoPathFound);if(path.length<2)return bot.$emit("pathfindError",PathfindError.PathTooShort);bot.pathing.activePath=path;bot.pathing.activeNode=bot.pathing.activePath[1];bot.pathing.activeNodeIdx=1}}export default GoToPlayerDispatch;
@@ -1,23 +1 @@
1
- import { Intents, PathfindError } from "../enums.js";
2
-
3
- export class GoToSpatulaDispatch {
4
- validate(bot) {
5
- return bot.intents.includes(Intents.PATHFINDING);
6
- }
7
- check(bot) {
8
- return bot.me.playing && bot.game.spatula && bot.game.spatula.coords && Number.isFinite(bot.game.spatula.coords.x);
9
- }
10
- execute(bot) {
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;
19
- bot.pathing.activeNode = bot.pathing.activePath[1];
20
- bot.pathing.activeNodeIdx = 1;
21
- }
22
- }
23
- export default GoToSpatulaDispatch;
1
+ import{Intents,PathfindError}from"../enums.js";export class GoToSpatulaDispatch{validate(bot){return bot.intents.includes(Intents.PATHFINDING)}check(bot){return bot.me.playing&&bot.game.spatula&&bot.game.spatula.coords&&Number.isFinite(bot.game.spatula.coords.x)}execute(bot){const myNode=bot.pathing.nodeList.atObject(bot.me.position);const targetNode=bot.pathing.nodeList.atObject(bot.game.spatula.coords);const path=bot.pathing.astar.path(myNode,targetNode);if(!path)return bot.$emit("pathfindError",PathfindError.NoPathFound);if(path.length<2)return bot.$emit("pathfindError",PathfindError.PathTooShort);bot.pathing.activePath=path;bot.pathing.activeNode=bot.pathing.activePath[1];bot.pathing.activeNodeIdx=1}}export default GoToSpatulaDispatch;
@@ -1,37 +1 @@
1
- const mod = (n, m) => (n % m + m) % m;
2
- const PI2 = Math.PI * 2;
3
- const setPrecision = (value) => Math.round(value * 8192) / 8192;
4
- const calculateYaw = (pos) => setPrecision(mod(Math.atan2(-pos.x, -pos.z), PI2));
5
- const calculatePitch = (pos) => setPrecision(Math.atan2(pos.y, Math.hypot(pos.x, pos.z)));
6
-
7
- export class LookAtDispatch {
8
- idOrName;
9
- constructor(idOrName) {
10
- this.idOrName = idOrName;
11
- }
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";
17
- }
18
- check(bot) {
19
- if (!bot.me.playing)
20
- return false;
21
- const target = this.$grabPlayer(bot);
22
- return target && target.playing && target.position && Number.isFinite(target.position.x);
23
- }
24
- execute(bot) {
25
- const target = this.$grabPlayer(bot);
26
- const directionVector = {
27
- x: target.position.x - bot.me.position.x,
28
- y: target.position.y - bot.me.position.y - 0.05,
29
- z: target.position.z - bot.me.position.z
30
- };
31
- const yaw = calculateYaw(directionVector);
32
- const pitch = calculatePitch(directionVector);
33
- bot.state.yaw = yaw;
34
- bot.state.pitch = pitch;
35
- }
36
- }
37
- export default LookAtDispatch;
1
+ const mod=(n,m)=>(n%m+m)%m;const PI2=Math.PI*2;const setPrecision=(value)=>Math.round(value*8192)/8192;const calculateYaw=(pos)=>setPrecision(mod(Math.atan2(-pos.x,-pos.z),PI2));const calculatePitch=(pos)=>setPrecision(Math.atan2(pos.y,Math.hypot(pos.x,pos.z)));export class LookAtDispatch{idOrName;constructor(idOrName){this.idOrName=idOrName}$grabPlayer(bot){return bot.players[this.idOrName.toString()]||Object.values(bot.players).find((player)=>player.name===this.idOrName.toString())}validate(){return typeof this.idOrName==="string"||typeof this.idOrName==="number"}check(bot){if(!bot.me.playing)return false;const target=this.$grabPlayer(bot);return target&&target.playing&&target.position&&Number.isFinite(target.position.x)}execute(bot){const target=this.$grabPlayer(bot);const directionVector={x:target.position.x-bot.me.position.x,y:target.position.y-bot.me.position.y-0.05,z:target.position.z-bot.me.position.z};const yaw=calculateYaw(directionVector);const pitch=calculatePitch(directionVector);bot.state.yaw=yaw;bot.state.pitch=pitch}}export default LookAtDispatch;
@@ -1,29 +1 @@
1
- const mod = (n, m) => (n % m + m) % m;
2
- const PI2 = Math.PI * 2;
3
- const setPrecision = (value) => Math.round(value * 8192) / 8192;
4
- const calculateYaw = (pos) => setPrecision(mod(Math.atan2(-pos.x, -pos.z), PI2));
5
- const calculatePitch = (pos) => setPrecision(Math.atan2(pos.y, Math.hypot(pos.x, pos.z)));
6
-
7
- export class LookAtPosDispatch {
8
- constructor(pos) {
9
- this.pos = pos;
10
- }
11
- validate() {
12
- return this.pos && Number.isFinite(this.pos.x) && Number.isFinite(this.pos.y) && Number.isFinite(this.pos.z);
13
- }
14
- check(bot) {
15
- return bot.me.playing;
16
- }
17
- execute(bot) {
18
- const directionVector = {
19
- x: this.pos.x - bot.me.position.x,
20
- y: this.pos.y - bot.me.position.y,
21
- z: this.pos.z - bot.me.position.z
22
- };
23
- const yaw = calculateYaw(directionVector);
24
- const pitch = calculatePitch(directionVector);
25
- bot.state.yaw = yaw;
26
- bot.state.pitch = pitch;
27
- }
28
- }
29
- export default LookAtPosDispatch;
1
+ const mod=(n,m)=>(n%m+m)%m;const PI2=Math.PI*2;const setPrecision=(value)=>Math.round(value*8192)/8192;const calculateYaw=(pos)=>setPrecision(mod(Math.atan2(-pos.x,-pos.z),PI2));const calculatePitch=(pos)=>setPrecision(Math.atan2(pos.y,Math.hypot(pos.x,pos.z)));export class LookAtPosDispatch{constructor(pos){this.pos=pos}validate(){return this.pos&&Number.isFinite(this.pos.x)&&Number.isFinite(this.pos.y)&&Number.isFinite(this.pos.z)}check(bot){return bot.me.playing}execute(bot){const directionVector={x:this.pos.x-bot.me.position.x,y:this.pos.y-bot.me.position.y,z:this.pos.z-bot.me.position.z};const yaw=calculateYaw(directionVector);const pitch=calculatePitch(directionVector);bot.state.yaw=yaw;bot.state.pitch=pitch}}export default LookAtPosDispatch;
@@ -1,26 +1 @@
1
- import CommOut from "../comm/CommOut.js";
2
- import CommCode from "../constants/CommCode.js";
3
- import { GunEquipTime } from "../constants/index.js";
4
-
5
- export class MeleeDispatch {
6
- validate() {
7
- return true;
8
- }
9
- check(bot) {
10
- return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee;
11
- }
12
- execute(bot) {
13
- const out = new CommOut;
14
- out.packInt8(CommCode.melee);
15
- out.send(bot.game.socket);
16
- bot.state.usingMelee = true;
17
- setTimeout(() => {
18
- bot.state.usingMelee = false;
19
- bot.state.swappingGun = true;
20
- setTimeout(() => {
21
- bot.state.swappingGun = false;
22
- }, 0.5 * GunEquipTime);
23
- }, 100 / 3 * 17);
24
- }
25
- }
26
- export default MeleeDispatch;
1
+ import CommOut from"../comm/CommOut.js";import CommCode from"../constants/CommCode.js";import{GunEquipTime}from"../constants/index.js";export class MeleeDispatch{validate(){return true}check(bot){return bot.me.playing&&!bot.state.reloading&&!bot.state.swappingGun&&!bot.state.usingMelee}execute(bot){const out=new CommOut;out.packInt8(CommCode.melee);out.send(bot.game.socket);bot.state.usingMelee=true;setTimeout(()=>{bot.state.usingMelee=false;bot.state.swappingGun=true;setTimeout(()=>{bot.state.swappingGun=false},0.5*GunEquipTime)},100/3*17)}}export default MeleeDispatch;
@@ -1,26 +1 @@
1
- import { Movement } from "../constants/index.js";
2
-
3
- export class MovementDispatch {
4
- constructor(inputKeys) {
5
- if (typeof inputKeys === "number")
6
- this.inputKeys = inputKeys;
7
- else if (Array.isArray(inputKeys))
8
- this.inputKeys = inputKeys.reduce((a, b) => a | b, 0);
9
- }
10
- validate() {
11
- if (typeof this.inputKeys !== "number")
12
- return false;
13
- if (this.inputKeys & Movement.Forward && this.inputKeys & Movement.Backward)
14
- return false;
15
- if (this.inputKeys & Movement.Left && this.inputKeys & Movement.Right)
16
- return false;
17
- return true;
18
- }
19
- check(bot) {
20
- return bot.me.playing;
21
- }
22
- execute(bot) {
23
- bot.state.controlKeys = this.inputKeys;
24
- }
25
- }
26
- export default MovementDispatch;
1
+ import{Movement}from"../constants/index.js";export class MovementDispatch{constructor(inputKeys){if(typeof inputKeys==="number")this.inputKeys=inputKeys;else if(Array.isArray(inputKeys))this.inputKeys=inputKeys.reduce((a,b)=>a|b,0)}validate(){if(typeof this.inputKeys!=="number")return false;if(this.inputKeys&Movement.Forward&&this.inputKeys&Movement.Backward)return false;if(this.inputKeys&Movement.Left&&this.inputKeys&Movement.Right)return false;return true}check(bot){return bot.me.playing}execute(bot){bot.state.controlKeys=this.inputKeys}}export default MovementDispatch;
@@ -1,18 +1 @@
1
- import CommOut from "../comm/CommOut.js";
2
- import CommCode from "../constants/CommCode.js";
3
-
4
- export class PauseDispatch {
5
- validate() {
6
- return true;
7
- }
8
- check(bot) {
9
- return bot.me.playing;
10
- }
11
- execute(bot) {
12
- const out = new CommOut;
13
- out.packInt8(CommCode.pause);
14
- out.send(bot.game.socket);
15
- setTimeout(() => bot.me.playing = false, 3000);
16
- }
17
- }
18
- export default PauseDispatch;
1
+ import CommOut from"../comm/CommOut.js";import CommCode from"../constants/CommCode.js";export class PauseDispatch{validate(){return true}check(bot){return bot.me.playing}execute(bot){const out=new CommOut;out.packInt8(CommCode.pause);out.send(bot.game.socket);setTimeout(()=>bot.me.playing=false,3000)}}export default PauseDispatch;
@@ -1,35 +1 @@
1
- import CommOut from "../comm/CommOut.js";
2
- import CommCode from "../constants/CommCode.js";
3
-
4
- export class ReloadDispatch {
5
- validate() {
6
- return true;
7
- }
8
- check(bot) {
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
- }
11
- execute(bot) {
12
- const out = new CommOut;
13
- out.packInt8(CommCode.reload);
14
- out.send(bot.game.socket);
15
- const playerActiveWeapon = bot.me.weapons[bot.me.activeGun];
16
- const isEmpty = playerActiveWeapon.ammo.rounds < 1;
17
- bot.$emit("playerStartReload", bot.me, playerActiveWeapon);
18
- bot.state.reloading = true;
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);
33
- }
34
- }
35
- export default ReloadDispatch;
1
+ import CommOut from"../comm/CommOut.js";import CommCode from"../constants/CommCode.js";export class ReloadDispatch{validate(){return true}check(bot){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}execute(bot){const out=new CommOut;out.packInt8(CommCode.reload);out.send(bot.game.socket);const playerActiveWeapon=bot.me.weapons[bot.me.activeGun];const isEmpty=playerActiveWeapon.ammo.rounds<1;bot.$emit("playerStartReload",bot.me,playerActiveWeapon);bot.state.reloading=true;setTimeout(()=>{if(!bot.me||bot.hasQuit)return;bot.state.reloading=false;const latestWeapon=bot.me.weapons[bot.me.activeGun];if(latestWeapon.ammo){const maxLoad=Math.min(latestWeapon.ammo.capacity,latestWeapon.ammo.reload);const needed=Math.max(0,maxLoad-latestWeapon.ammo.rounds);const newRounds=Math.min(needed,latestWeapon.ammo.store);latestWeapon.ammo.rounds+=newRounds;latestWeapon.ammo.store-=newRounds}bot.$emit("playerEndReload",bot.me,latestWeapon)},isEmpty?playerActiveWeapon.longReloadTime:playerActiveWeapon.shortReloadTime)}}export default ReloadDispatch;
@@ -1,44 +1 @@
1
- import CommOut from "../comm/CommOut.js";
2
- import CommCode from "../constants/CommCode.js";
3
-
4
- export class ReportPlayerDispatch {
5
- constructor(idOrName, reasons = {}) {
6
- this.idOrName = idOrName;
7
- this.reasons = [
8
- !!reasons.cheating,
9
- !!reasons.harassment,
10
- !!reasons.offensive,
11
- !!reasons.other
12
- ];
13
- if (!this.reasons.includes(true))
14
- this.reasons[3] = true;
15
- for (let i = 0;i < this.reasons.length; i++)
16
- if (this.reasons[i] === true)
17
- this.reasonInt |= 1 << i;
18
- }
19
- $grabPlayer(bot) {
20
- return bot.players[this.idOrName.toString()] || Object.values(bot.players).find((player) => player.name === this.idOrName.toString());
21
- }
22
- validate() {
23
- if (typeof this.idOrName !== "string" && typeof this.idOrName !== "number")
24
- return false;
25
- if (this.reasons.every((reason) => reason === false))
26
- return false;
27
- return true;
28
- }
29
- check(bot) {
30
- if (!bot.state.inGame)
31
- return false;
32
- const target = this.$grabPlayer(bot);
33
- return !!target;
34
- }
35
- execute(bot) {
36
- const target = this.$grabPlayer(bot);
37
- const out = new CommOut;
38
- out.packInt8(CommCode.reportPlayer);
39
- out.packString(target.uniqueId);
40
- out.packInt8(this.reasonInt);
41
- out.send(bot.game.socket);
42
- }
43
- }
44
- export default ReportPlayerDispatch;
1
+ import CommOut from"../comm/CommOut.js";import CommCode from"../constants/CommCode.js";export class ReportPlayerDispatch{constructor(idOrName,reasons={}){this.idOrName=idOrName;this.reasons=[!!reasons.cheating,!!reasons.harassment,!!reasons.offensive,!!reasons.other];if(!this.reasons.includes(true))this.reasons[3]=true;for(let i=0;i<this.reasons.length;i++)if(this.reasons[i]===true)this.reasonInt|=1<<i}$grabPlayer(bot){return bot.players[this.idOrName.toString()]||Object.values(bot.players).find((player)=>player.name===this.idOrName.toString())}validate(){if(typeof this.idOrName!=="string"&&typeof this.idOrName!=="number")return false;if(this.reasons.every((reason)=>reason===false))return false;return true}check(bot){if(!bot.state.inGame)return false;const target=this.$grabPlayer(bot);return!!target}execute(bot){const target=this.$grabPlayer(bot);const out=new CommOut;out.packInt8(CommCode.reportPlayer);out.packString(target.uniqueId);out.packInt8(this.reasonInt);out.send(bot.game.socket)}}export default ReportPlayerDispatch;