yolkbot 0.1.3 → 0.1.4-alpha.1

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 (138) hide show
  1. package/browser/build/global.js +1 -1
  2. package/browser/build/module.js +1 -1
  3. package/dist/api.js +3 -0
  4. package/dist/bot/GamePlayer.js +3 -0
  5. package/dist/bot.js +3 -0
  6. package/dist/comm/Codes.js +3 -0
  7. package/dist/comm/CommIn.js +3 -0
  8. package/dist/comm/CommOut.js +3 -0
  9. package/dist/comm/OutBuffer.js +3 -0
  10. package/dist/comm/Pool.js +3 -0
  11. package/dist/comm/index.js +3 -0
  12. package/dist/constants/challenges.js +3 -0
  13. package/dist/constants/changelog.js +3 -0
  14. package/dist/constants/codes.js +3 -0
  15. package/dist/constants/guns.js +3 -0
  16. package/dist/constants/housePromo.js +3 -0
  17. package/dist/constants/index.js +3 -0
  18. package/dist/constants/items.js +3 -0
  19. package/dist/constants/language.js +3 -0
  20. package/dist/constants/maps.js +3 -0
  21. package/dist/constants/shellNews.js +3 -0
  22. package/dist/constants/shellYoutube.js +3 -0
  23. package/dist/constants/shopItems.js +3 -0
  24. package/dist/constants/sounds.js +3 -0
  25. package/dist/dispatches/BootPlayerDispatch.js +3 -0
  26. package/dist/dispatches/ChatDispatch.js +3 -0
  27. package/dist/dispatches/FireDispatch.js +3 -0
  28. package/dist/dispatches/GameOptionsDispatch.js +3 -0
  29. package/dist/dispatches/GoToAmmoDispatch.js +3 -0
  30. package/dist/dispatches/GoToCoopDispatch.js +3 -0
  31. package/dist/dispatches/GoToGrenadeDispatch.js +3 -0
  32. package/dist/dispatches/GoToPlayerDispatch.js +3 -0
  33. package/dist/dispatches/GoToSpatulaDispatch.js +3 -0
  34. package/dist/dispatches/LookAtDispatch.js +3 -0
  35. package/dist/dispatches/LookAtPosDispatch.js +3 -0
  36. package/dist/dispatches/MeleeDispatch.js +3 -0
  37. package/dist/dispatches/MovementDispatch.js +3 -0
  38. package/dist/dispatches/PauseDispatch.js +3 -0
  39. package/dist/dispatches/ReloadDispatch.js +3 -0
  40. package/dist/dispatches/ReportPlayerDispatch.js +3 -0
  41. package/dist/dispatches/SaveLoadoutDispatch.js +3 -0
  42. package/dist/dispatches/SpawnDispatch.js +3 -0
  43. package/dist/dispatches/SwapWeaponDispatch.js +3 -0
  44. package/dist/dispatches/SwitchTeamDispatch.js +3 -0
  45. package/dist/dispatches/ThrowGrenadeDispatch.js +3 -0
  46. package/dist/dispatches/index.js +3 -0
  47. package/dist/globals.js +3 -0
  48. package/dist/index.js +10 -0
  49. package/dist/matchmaker.js +3 -0
  50. package/dist/pathing/astar.js +3 -0
  51. package/dist/pathing/binaryheap.js +3 -0
  52. package/dist/pathing/mapnode.js +3 -0
  53. package/dist/socket.js +3 -0
  54. package/package.json +28 -28
  55. package/src/.DS_Store +0 -0
  56. package/src/api.js +0 -235
  57. package/src/bot/GamePlayer.js +0 -88
  58. package/src/bot.js +0 -1998
  59. package/src/comm/Codes.js +0 -99
  60. package/src/comm/CommIn.js +0 -84
  61. package/src/comm/CommOut.js +0 -16
  62. package/src/comm/OutBuffer.js +0 -60
  63. package/src/comm/Pool.js +0 -55
  64. package/src/comm/index.js +0 -16
  65. package/src/constants/challenges.js +0 -1822
  66. package/src/constants/changelog.js +0 -19
  67. package/src/constants/codes.js +0 -45
  68. package/src/constants/guns.js +0 -368
  69. package/src/constants/housePromo.js +0 -727
  70. package/src/constants/index.js +0 -121
  71. package/src/constants/items.js +0 -42533
  72. package/src/constants/language.js +0 -1669
  73. package/src/constants/maps.js +0 -1095
  74. package/src/constants/shellNews.js +0 -59
  75. package/src/constants/shellYoutube.js +0 -93
  76. package/src/constants/shopItems.js +0 -2032
  77. package/src/constants/sounds.js +0 -1160
  78. package/src/dispatches/BootPlayerDispatch.js +0 -21
  79. package/src/dispatches/ChatDispatch.js +0 -30
  80. package/src/dispatches/FireDispatch.js +0 -20
  81. package/src/dispatches/GameOptionsDispatch.js +0 -46
  82. package/src/dispatches/GoToAmmoDispatch.js +0 -44
  83. package/src/dispatches/GoToCoopDispatch.js +0 -44
  84. package/src/dispatches/GoToGrenadeDispatch.js +0 -44
  85. package/src/dispatches/GoToPlayerDispatch.js +0 -38
  86. package/src/dispatches/GoToSpatulaDispatch.js +0 -32
  87. package/src/dispatches/LookAtDispatch.js +0 -48
  88. package/src/dispatches/LookAtPosDispatch.js +0 -33
  89. package/src/dispatches/MeleeDispatch.js +0 -28
  90. package/src/dispatches/MovementDispatch.js +0 -19
  91. package/src/dispatches/PauseDispatch.js +0 -18
  92. package/src/dispatches/ReloadDispatch.js +0 -36
  93. package/src/dispatches/ReportPlayerDispatch.js +0 -51
  94. package/src/dispatches/SaveLoadoutDispatch.js +0 -119
  95. package/src/dispatches/SpawnDispatch.js +0 -21
  96. package/src/dispatches/SwapWeaponDispatch.js +0 -19
  97. package/src/dispatches/SwitchTeamDispatch.js +0 -34
  98. package/src/dispatches/ThrowGrenadeDispatch.js +0 -26
  99. package/src/dispatches/index.js +0 -69
  100. package/src/globals.js +0 -15
  101. package/src/index.js +0 -14
  102. package/src/matchmaker.js +0 -206
  103. package/src/pathing/astar.js +0 -71
  104. package/src/pathing/binaryheap.js +0 -117
  105. package/src/pathing/mapnode.js +0 -236
  106. package/src/socket.js +0 -19
  107. /package/{src → dist}/types/api.d.ts +0 -0
  108. /package/{src → dist}/types/bot/GamePlayer.d.ts +0 -0
  109. /package/{src → dist}/types/bot.d.ts +0 -0
  110. /package/{src → dist}/types/constants/challenges.d.ts +0 -0
  111. /package/{src → dist}/types/constants/guns.d.ts +0 -0
  112. /package/{src → dist}/types/constants/index.d.ts +0 -0
  113. /package/{src → dist}/types/constants/items.d.ts +0 -0
  114. /package/{src → dist}/types/constants/maps.d.ts +0 -0
  115. /package/{src → dist}/types/dispatches/BootPlayerDispatch.d.ts +0 -0
  116. /package/{src → dist}/types/dispatches/ChatDispatch.d.ts +0 -0
  117. /package/{src → dist}/types/dispatches/FireDispatch.d.ts +0 -0
  118. /package/{src → dist}/types/dispatches/GameOptionsDispatch.d.ts +0 -0
  119. /package/{src → dist}/types/dispatches/GoToAmmoDispatch.d.ts +0 -0
  120. /package/{src → dist}/types/dispatches/GoToCoopDispatch.d.ts +0 -0
  121. /package/{src → dist}/types/dispatches/GoToGrenadeDispatch.d.ts +0 -0
  122. /package/{src → dist}/types/dispatches/GoToPlayerDispatch.d.ts +0 -0
  123. /package/{src → dist}/types/dispatches/GoToSpatulaDispatch.d.ts +0 -0
  124. /package/{src → dist}/types/dispatches/LookAtDispatch.d.ts +0 -0
  125. /package/{src → dist}/types/dispatches/LookAtPosDispatch.d.ts +0 -0
  126. /package/{src → dist}/types/dispatches/MeleeDispatch.d.ts +0 -0
  127. /package/{src → dist}/types/dispatches/MovementDispatch.d.ts +0 -0
  128. /package/{src → dist}/types/dispatches/PauseDispatch.d.ts +0 -0
  129. /package/{src → dist}/types/dispatches/ReloadDispatch.d.ts +0 -0
  130. /package/{src → dist}/types/dispatches/ReportPlayerDispatch.d.ts +0 -0
  131. /package/{src → dist}/types/dispatches/SaveLoadoutDispatch.d.ts +0 -0
  132. /package/{src → dist}/types/dispatches/SpawnDispatch.d.ts +0 -0
  133. /package/{src → dist}/types/dispatches/SwapWeaponDispatch.d.ts +0 -0
  134. /package/{src → dist}/types/dispatches/SwitchTeamDispatch.d.ts +0 -0
  135. /package/{src → dist}/types/dispatches/ThrowGrenadeDispatch.d.ts +0 -0
  136. /package/{src → dist}/types/dispatches/index.d.ts +0 -0
  137. /package/{src → dist}/types/matchmaker.d.ts +0 -0
  138. /package/{src → dist}/types/socket.d.ts +0 -0
@@ -1,21 +0,0 @@
1
- import CommOut from '../comm/CommOut.js';
2
- import { CommCode } from '../constants/codes.js';
3
-
4
- export class BootPlayerDispatch {
5
- constructor(uniqueId) {
6
- this.uniqueId = uniqueId;
7
- }
8
-
9
- check(bot) {
10
- return typeof this.uniqueId == 'string' && bot.game.isGameOwner && bot.players.find((player) => player.uniqueId == this.uniqueId);
11
- }
12
-
13
- execute(bot) {
14
- const out = CommOut.getBuffer();
15
- out.packInt8(CommCode.bootPlayer);
16
- out.packString(this.uniqueId);
17
- out.send(bot.game.socket);
18
- }
19
- }
20
-
21
- export default BootPlayerDispatch;
@@ -1,30 +0,0 @@
1
- import CommOut from '../comm/CommOut.js';
2
- import { CommCode } from '../constants/codes.js';
3
-
4
- export class ChatDispatch {
5
- constructor(msg, noLimit = false) {
6
- this.msg = msg;
7
- this.noLimit = noLimit;
8
- }
9
-
10
- check(bot) {
11
- if (typeof this.msg !== 'string') return false;
12
- if (this.msg.length < 1 || this.msg.length > 64) return false;
13
- if (!bot.state.joinedGame) return false;
14
- if ((bot.lastChatTime + 3000) > Date.now() && !this.noLimit) return false;
15
- if (!bot.game.isPrivate && !bot.account.emailVerified && bot.account.accountAge < (1e3 * 60 * 60 * 12)) return false;
16
-
17
- return true;
18
- }
19
-
20
- execute(bot) {
21
- const out = CommOut.getBuffer();
22
- out.packInt8(CommCode.chat);
23
- out.packString(this.msg);
24
- out.send(bot.game.socket);
25
-
26
- bot.lastChatTime = Date.now();
27
- }
28
- }
29
-
30
- export default ChatDispatch;
@@ -1,20 +0,0 @@
1
- export class FireDispatch {
2
- constructor(amount) {
3
- this.amount = amount || 1;
4
- }
5
-
6
- check(bot) {
7
- return bot.me.playing &&
8
- !bot.state.reloading &
9
- !bot.state.swappingGun &&
10
- !bot.state.usingMelee &&
11
- this.amount >= 1 &&
12
- bot.me.weapons[bot.me.activeGun].ammo.rounds >= this.amount;
13
- }
14
-
15
- execute(bot) {
16
- bot.state.shotsFired += this.amount || 1;
17
- }
18
- }
19
-
20
- export default FireDispatch;
@@ -1,46 +0,0 @@
1
- import CommOut from '../comm/CommOut.js';
2
- import { CommCode } from '../constants/codes.js';
3
-
4
- const regenScale = [0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4];
5
-
6
- export class GameOptionsDispatch {
7
- check(bot) {
8
- if (!bot.game.isGameOwner) return false;
9
-
10
- if (![0.25, 0.5, 0.75, 1].includes(bot.game.options.gravity)) return false;
11
- if (![0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2].includes(bot.game.options.damage)) return false;
12
- if (!regenScale.includes(bot.game.options.healthRegen)) return false;
13
- if (typeof bot.game.options.locked !== 'boolean') return false;
14
- if (typeof bot.game.options.noTeamChange !== 'boolean') return false;
15
- if (typeof bot.game.options.noTeamShuffle !== 'boolean') return false;
16
-
17
- if (!Array.isArray(bot.game.options.weaponsDisabled)) return false;
18
- if (bot.game.options.weaponsDisabled.length !== 7) return false;
19
- if (bot.game.options.weaponsDisabled.some((weapon) => typeof weapon !== 'boolean')) return false;
20
-
21
- return true;
22
- }
23
-
24
- execute(bot) {
25
- const flags =
26
- (bot.game.options.locked ? 1 : 0) |
27
- (bot.game.options.noTeamChange ? 2 : 0) |
28
- (bot.game.options.noTeamShuffle ? 4 : 0);
29
-
30
- const out = CommOut.getBuffer();
31
-
32
- out.packInt8(CommCode.gameOptions);
33
- out.packInt8(bot.game.options.gravity * 4);
34
- out.packInt8(bot.game.options.damage * 4);
35
- out.packInt8(bot.game.options.healthRegen * 4);
36
- out.packInt8(flags);
37
-
38
- bot.game.options.weaponsDisabled.forEach((v) => {
39
- out.packInt8(v ? 1 : 0);
40
- });
41
-
42
- out.send(bot.game.socket);
43
- }
44
- }
45
-
46
- export default GameOptionsDispatch;
@@ -1,44 +0,0 @@
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;
@@ -1,44 +0,0 @@
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;
@@ -1,44 +0,0 @@
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;
@@ -1,38 +0,0 @@
1
- import AStar from '../pathing/astar.js';
2
-
3
- export class GoToPlayerDispatch {
4
- constructor(target) {
5
- this.target = target;
6
- }
7
-
8
- check(bot) {
9
- return bot.me.playing &&
10
- this.target &&
11
- this.target.playing &&
12
- this.target.position &&
13
- bot.intents.includes(bot.Intents.PATHFINDING);
14
- }
15
-
16
- execute(bot) {
17
- this.pather = new AStar(bot.pathing.nodeList);
18
-
19
- const position = Object.entries(bot.me.position).map(entry => Math.floor(entry[1]));
20
- const targetPos = Object.entries(this.target.position).map(entry => Math.floor(entry[1]));
21
-
22
- const myNode = bot.pathing.nodeList.at(...position);
23
- const targetNode = bot.pathing.nodeList.at(...targetPos);
24
-
25
- // console.log('myNode:', !!myNode, 'target:', !!targetNode, 'pathing from my position at', position, 'to', targetPos);
26
-
27
- bot.pathing.activePath = this.pather.path(myNode, targetNode);
28
-
29
- if (!bot.pathing.activePath) return console.error('no path found');
30
- if (bot.pathing.activePath.length < 2) return console.error('path too short');
31
-
32
- bot.pathing.followingPath = true;
33
- bot.pathing.activeNode = bot.pathing.activePath[1];
34
- bot.pathing.activeNodeIdx = 1;
35
- }
36
- }
37
-
38
- export default GoToPlayerDispatch;
@@ -1,32 +0,0 @@
1
- import AStar from '../pathing/astar.js';
2
-
3
- export class GoToSpatulaDispatch {
4
- check(bot) {
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);
10
- }
11
-
12
- execute(bot) {
13
- this.pather = new AStar(bot.pathing.nodeList);
14
-
15
- const position = Object.entries(bot.me.position).map(entry => Math.floor(entry[1]));
16
- const targetPos = Object.entries(this.game.spatula.coords).map(entry => Math.floor(entry[1]));
17
-
18
- const myNode = bot.pathing.nodeList.at(...position);
19
- const targetNode = bot.pathing.nodeList.at(...targetPos);
20
-
21
- bot.pathing.activePath = this.pather.path(myNode, targetNode);
22
-
23
- if (!bot.pathing.activePath) return console.error('no path found');
24
- if (bot.pathing.activePath.length < 2) return console.error('path too short');
25
-
26
- bot.pathing.followingPath = true;
27
- bot.pathing.activeNode = bot.pathing.activePath[1];
28
- bot.pathing.activeNodeIdx = 1;
29
- }
30
- }
31
-
32
- export default GoToSpatulaDispatch;
@@ -1,48 +0,0 @@
1
- const mod = (n, m) => ((n % m) + m) % m;
2
-
3
- const PI2 = Math.PI * 2;
4
-
5
- const setPrecision = (value) => Math.round(value * 8192) / 8192;
6
- const calculateYaw = (pos) => setPrecision(mod(Math.atan2(-pos.x, -pos.z), PI2));
7
- const calculatePitch = (pos) => setPrecision(Math.atan2(pos.y, Math.hypot(pos.x, pos.z)));
8
-
9
- export class LookAtDispatch {
10
- idOrName;
11
-
12
- constructor(idOrName) {
13
- if (typeof idOrName == 'number') this.id = idOrName
14
- else if (typeof idOrName == 'string') this.name = idOrName
15
- }
16
-
17
- check(bot) {
18
- if (!bot.me.playing) return false;
19
-
20
- let target;
21
-
22
- if (this.id !== undefined) target = bot.players[this.id.toString()];
23
- else if (this.name !== undefined) target = bot.players.find(player => player.name == this.name);
24
-
25
- return !!target;
26
- }
27
-
28
- execute(bot) {
29
- let target;
30
-
31
- if (this.id !== undefined) target = bot.players[this.id.toString()];
32
- else if (this.name !== undefined) target = bot.players.find(player => player.name == this.name);
33
-
34
- const directionVector = {
35
- x: target.position.x - bot.me.position.x,
36
- y: target.position.y - bot.me.position.y - 0.05,
37
- z: target.position.z - bot.me.position.z
38
- };
39
-
40
- const yaw = calculateYaw(directionVector);
41
- const pitch = calculatePitch(directionVector);
42
-
43
- bot.me.view.yaw = yaw;
44
- bot.me.view.pitch = pitch;
45
- }
46
- }
47
-
48
- export default LookAtDispatch;
@@ -1,33 +0,0 @@
1
- const mod = (n, m) => ((n % m) + m) % m;
2
-
3
- const PI2 = Math.PI * 2;
4
-
5
- const setPrecision = (value) => Math.round(value * 8192) / 8192;
6
- const calculateYaw = (pos) => setPrecision(mod(Math.atan2(-pos.x, -pos.z), PI2));
7
- const calculatePitch = (pos) => setPrecision(Math.atan2(pos.y, Math.hypot(pos.x, pos.z)));
8
-
9
- export class LookAtPosDispatch {
10
- constructor(pos) {
11
- this.pos = pos;
12
- }
13
-
14
- check(bot) {
15
- return bot.me.playing && this.pos && this.pos.x && this.pos.y && this.pos.z;
16
- }
17
-
18
- execute(bot) {
19
- const directionVector = {
20
- x: this.pos.x - bot.me.position.x,
21
- y: this.pos.y - bot.me.position.y,
22
- z: this.pos.z - bot.me.position.z
23
- };
24
-
25
- const yaw = calculateYaw(directionVector)
26
- const pitch = calculatePitch(directionVector);
27
-
28
- bot.me.view.yaw = yaw;
29
- bot.me.view.pitch = pitch;
30
- }
31
- }
32
-
33
- export default LookAtPosDispatch;
@@ -1,28 +0,0 @@
1
- import CommOut from '../comm/CommOut.js';
2
- import { CommCode } from '../constants/codes.js';
3
-
4
- export class MeleeDispatch {
5
- check(bot) {
6
- return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee;
7
- }
8
-
9
- execute(bot) {
10
- const out = CommOut.getBuffer();
11
- out.packInt8(CommCode.melee);
12
- out.send(bot.game.socket);
13
-
14
- bot.usingMelee = true;
15
-
16
- // gameloop every 33.33 (repeating) ms, 17 ticks, so 566.61 is the closest you get
17
- setTimeout(() => {
18
- bot.usingMelee = false
19
- bot.swappingGun = true
20
-
21
- setTimeout(() => {
22
- bot.swappingGun = false
23
- }, 0.5 * bot.me.weapons[0].equipTime)
24
- }, 566.61);
25
- }
26
- }
27
-
28
- export default MeleeDispatch;
@@ -1,19 +0,0 @@
1
- export class MovementDispatch {
2
- constructor(controlKeys) {
3
- if (typeof controlKeys == typeof 0) {
4
- this.controlKeys = controlKeys;
5
- } else if (typeof controlKeys == typeof []) {
6
- this.controlKeys = controlKeys.reduce((a, b) => a | b, 0);
7
- }
8
- }
9
-
10
- check(bot) {
11
- return bot.me.playing && this.controlKeys;
12
- }
13
-
14
- execute(bot) {
15
- bot.controlKeys = this.controlKeys;
16
- }
17
- }
18
-
19
- export default MovementDispatch;
@@ -1,18 +0,0 @@
1
- import CommOut from '../comm/CommOut.js';
2
- import { CommCode } from '../constants/codes.js';
3
-
4
- export class PauseDispatch {
5
- check(bot) {
6
- return bot.me.playing;
7
- }
8
-
9
- execute(bot) {
10
- const out = CommOut.getBuffer();
11
- out.packInt8(CommCode.pause);
12
- out.send(bot.game.socket);
13
-
14
- setTimeout(() => bot.me.playing = false, 3000);
15
- }
16
- }
17
-
18
- export default PauseDispatch;
@@ -1,36 +0,0 @@
1
- import CommOut from '../comm/CommOut.js';
2
- import { CommCode } from '../constants/codes.js';
3
-
4
- export class ReloadDispatch {
5
- check(bot) {
6
- return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee;
7
- }
8
-
9
- execute(bot) {
10
- const out = CommOut.getBuffer();
11
- out.packInt8(CommCode.reload);
12
- out.send(bot.game.socket);
13
-
14
- const playerActiveWeapon = bot.me.weapons[bot.me.activeGun];
15
-
16
- if (playerActiveWeapon.ammo) {
17
- const newRounds = Math.min(
18
- Math.min(playerActiveWeapon.ammo.capacity, playerActiveWeapon.ammo.reload) - playerActiveWeapon.ammo.rounds,
19
- playerActiveWeapon.ammo.store
20
- );
21
-
22
- playerActiveWeapon.ammo.rounds += newRounds;
23
- playerActiveWeapon.ammo.store -= newRounds;
24
- }
25
-
26
- bot.emit('playerReload', bot.me, playerActiveWeapon);
27
-
28
- const activeWeapon = bot.me.weapons[bot.me.activeGun];
29
- const isLongTime = activeWeapon.ammo.rounds < 1;
30
-
31
- bot.state.reloading = true;
32
- setTimeout(() => bot.state.reloading = false, isLongTime ? activeWeapon.longReloadTime : activeWeapon.shortReloadTime);
33
- }
34
- }
35
-
36
- export default ReloadDispatch;
@@ -1,51 +0,0 @@
1
- import CommOut from '../comm/CommOut.js';
2
- import { CommCode } from '../constants/codes.js';
3
-
4
- export class ReportPlayerDispatch {
5
- constructor(idOrName, reasons = {}) {
6
- if (typeof idOrName == 'number') this.id = idOrName
7
- else if (typeof idOrName == 'string') this.name = idOrName
8
-
9
- this.reasons = [
10
- !!reasons.cheating,
11
- !!reasons.harassment,
12
- !!reasons.offensive,
13
- !!reasons.other
14
- ]
15
-
16
- // assume other if a reason is not specified
17
- if (!this.reasons.includes(true)) this.reasons[3] = true;
18
-
19
- for (let i = 0; i < this.reasons.length; i++)
20
- if (this.reasons[i] == true)
21
- this.reasonInt |= (1 << i);
22
- }
23
-
24
- check(bot) {
25
- if (!bot.state.joinedGame) return false;
26
-
27
- let target;
28
-
29
- if (this.id !== undefined) target = bot.players[this.id.toString()];
30
- else if (this.name !== undefined) target = bot.players.find(player => player.name == this.name);
31
-
32
- return !!target;
33
- }
34
-
35
- execute(bot) {
36
- let target;
37
-
38
- if (this.id !== 'undefined') target = bot.players[this.id.toString()];
39
- else if (this.name !== 'undefined') target = bot.players.find(player => player.name == this.name);
40
-
41
- if (!target) throw new Error('target player for ReportPlayerDispatch not found')
42
-
43
- const out = CommOut.getBuffer();
44
- out.packInt8(CommCode.reportPlayer);
45
- out.packString(target);
46
- out.packInt8(this.reasonInt);
47
- out.send(bot.game.socket);
48
- }
49
- }
50
-
51
- export default ReportPlayerDispatch;