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
@@ -0,0 +1,63 @@
1
+ import GamePlayer from "../bot/GamePlayer.js";
2
+ import CommIn from "../comm/CommIn.js";
3
+ import { findItemById } from "../constants/findItemById.js";
4
+ import { GameMode } from "../constants/index.js";
5
+ import { Intents } from "../enums.js";
6
+ const processAddPlayerPacket = (bot) => {
7
+ const id = CommIn.unPackInt8U();
8
+ const findCosmetics = bot.intents.includes(Intents.COSMETIC_DATA);
9
+ const playerData = {
10
+ id,
11
+ uniqueId: CommIn.unPackString(),
12
+ name: CommIn.unPackString(),
13
+ safeName: CommIn.unPackString(),
14
+ charClass: CommIn.unPackInt8U(),
15
+ team: CommIn.unPackInt8U(),
16
+ primaryWeaponItem: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
17
+ secondaryWeaponItem: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
18
+ shellColor: CommIn.unPackInt8U(),
19
+ hatItem: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
20
+ stampItem: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
21
+ stampPosX: CommIn.unPackInt8(),
22
+ stampPosY: CommIn.unPackInt8(),
23
+ grenadeItem: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
24
+ meleeItem: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
25
+ x: CommIn.unPackFloat(),
26
+ y: CommIn.unPackFloat(),
27
+ z: CommIn.unPackFloat(),
28
+ $dx: CommIn.unPackFloat(),
29
+ $dy: CommIn.unPackFloat(),
30
+ $dz: CommIn.unPackFloat(),
31
+ yaw: CommIn.unPackRadU(),
32
+ pitch: CommIn.unPackRad(),
33
+ score: CommIn.unPackInt32U(),
34
+ $kills: CommIn.unPackInt16U(),
35
+ $deaths: CommIn.unPackInt16U(),
36
+ $streak: CommIn.unPackInt16U(),
37
+ totalKills: CommIn.unPackInt32U(),
38
+ totalDeaths: CommIn.unPackInt32U(),
39
+ bestStreak: CommIn.unPackInt16U(),
40
+ $bestOverallStreak: CommIn.unPackInt16U(),
41
+ shield: CommIn.unPackInt8U(),
42
+ hp: CommIn.unPackInt8U(),
43
+ playing: CommIn.unPackInt8U(),
44
+ weaponIdx: CommIn.unPackInt8U(),
45
+ $controlKeys: CommIn.unPackInt8U(),
46
+ upgradeProductId: CommIn.unPackInt8U(),
47
+ activeShellStreaks: CommIn.unPackInt8U(),
48
+ social: CommIn.unPackLongString(),
49
+ hideBadge: CommIn.unPackInt8U()
50
+ };
51
+ bot.game.mapIdx = CommIn.unPackInt8U();
52
+ bot.game.isPrivate = CommIn.unPackInt8U() === 1;
53
+ bot.game.gameModeId = CommIn.unPackInt8U();
54
+ const player = new GamePlayer(playerData, bot.game.gameMode === GameMode.KOTC ? bot.game.kotc.activeZone : null);
55
+ if (!bot.players[playerData.id])
56
+ bot.players[playerData.id] = player;
57
+ bot.$emit("playerJoin", player);
58
+ if (bot.me.id === playerData.id) {
59
+ bot.me = player;
60
+ bot.$emit("botJoin", bot.me);
61
+ }
62
+ };
63
+ export default processAddPlayerPacket;
@@ -0,0 +1,44 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { ShellStreak } from "../constants/index.js";
3
+ const processBeginShellStreakPacket = (bot) => {
4
+ const id = CommIn.unPackInt8U();
5
+ const ksType = CommIn.unPackInt8U();
6
+ const player = bot.players[id];
7
+ if (!player)
8
+ return;
9
+ switch (ksType) {
10
+ case ShellStreak.HardBoiled:
11
+ if (id === bot.me.id)
12
+ bot.me.shieldHp = 100;
13
+ player.streakRewards.push(ShellStreak.HardBoiled);
14
+ break;
15
+ case ShellStreak.EggBreaker:
16
+ player.streakRewards.push(ShellStreak.EggBreaker);
17
+ break;
18
+ case ShellStreak.Restock: {
19
+ player.grenades = 3;
20
+ if (player.weapons[0] && player.weapons[0].ammo) {
21
+ player.weapons[0].ammo.rounds = player.weapons[0].ammo.capacity;
22
+ player.weapons[0].ammo.store = player.weapons[0].ammo.storeMax;
23
+ }
24
+ if (player.weapons[1] && player.weapons[1].ammo) {
25
+ player.weapons[1].ammo.rounds = player.weapons[1].ammo.capacity;
26
+ player.weapons[1].ammo.store = player.weapons[1].ammo.storeMax;
27
+ }
28
+ break;
29
+ }
30
+ case ShellStreak.OverHeal:
31
+ player.hp = Math.min(200, player.hp + 100);
32
+ player.streakRewards.push(ShellStreak.OverHeal);
33
+ break;
34
+ case ShellStreak.DoubleEggs:
35
+ player.streakRewards.push(ShellStreak.DoubleEggs);
36
+ break;
37
+ case ShellStreak.MiniEgg:
38
+ player.scale = 0.5;
39
+ player.streakRewards.push(ShellStreak.MiniEgg);
40
+ break;
41
+ }
42
+ bot.$emit("playerBeginStreak", player, ksType);
43
+ };
44
+ export default processBeginShellStreakPacket;
@@ -0,0 +1,16 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { Intents } from "../enums.js";
3
+ const processChallengeCompletedPacket = (bot) => {
4
+ const id = CommIn.unPackInt8U();
5
+ const challengeId = CommIn.unPackInt8U();
6
+ const player = bot.players[id];
7
+ if (!player)
8
+ return;
9
+ if (!bot.intents.includes(Intents.CHALLENGES))
10
+ return bot.$emit("challengeComplete", player, challengeId);
11
+ const challenge = bot.account.challenges.find((c) => c.id === challengeId);
12
+ bot.$emit("challengeComplete", player, challenge);
13
+ if (player.id === bot.me.id)
14
+ bot.refreshChallenges();
15
+ };
16
+ export default processChallengeCompletedPacket;
@@ -0,0 +1,46 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { createGun } from "../util.js";
3
+ import { findItemById } from "../constants/findItemById.js";
4
+ import { GunList } from "../constants/index.js";
5
+ import { Intents } from "../enums.js";
6
+ const processChangeCharacterPacket = (bot) => {
7
+ const id = CommIn.unPackInt8U();
8
+ const weaponIndex = CommIn.unPackInt8U();
9
+ const primaryWeaponIdx = CommIn.unPackInt16U();
10
+ const secondaryWeaponIdx = CommIn.unPackInt16U();
11
+ const shellColor = CommIn.unPackInt8U();
12
+ const hatIdx = CommIn.unPackInt16U();
13
+ const stampIdx = CommIn.unPackInt16U();
14
+ const grenadeIdx = CommIn.unPackInt16U();
15
+ const meleeIdx = CommIn.unPackInt16U();
16
+ const stampPositionX = CommIn.unPackInt8();
17
+ const stampPositionY = CommIn.unPackInt8();
18
+ const findCosmetics = bot.intents.includes(Intents.COSMETIC_DATA);
19
+ const primaryWeaponItem = findCosmetics ? findItemById(primaryWeaponIdx) : primaryWeaponIdx;
20
+ const secondaryWeaponItem = findCosmetics ? findItemById(secondaryWeaponIdx) : secondaryWeaponIdx;
21
+ const hatItem = findCosmetics ? findItemById(hatIdx) : hatIdx;
22
+ const stampItem = findCosmetics ? findItemById(stampIdx) : stampIdx;
23
+ const grenadeItem = findCosmetics ? findItemById(grenadeIdx) : grenadeIdx;
24
+ const meleeItem = findCosmetics ? findItemById(meleeIdx) : meleeIdx;
25
+ const player = bot.players[id];
26
+ if (player) {
27
+ const oldCharacter = structuredClone(player.character);
28
+ const oldWeaponIdx = player.selectedGun;
29
+ player.character.eggColor = shellColor;
30
+ player.character.primaryGun = primaryWeaponItem;
31
+ player.character.secondaryGun = secondaryWeaponItem;
32
+ player.character.stamp = stampItem;
33
+ player.character.hat = hatItem;
34
+ player.character.grenade = grenadeItem;
35
+ player.character.melee = meleeItem;
36
+ player.character.stampPos.x = stampPositionX;
37
+ player.character.stampPos.y = stampPositionY;
38
+ player.selectedGun = weaponIndex;
39
+ player.weapons[0] = createGun(GunList[weaponIndex]);
40
+ if (oldWeaponIdx !== player.selectedGun)
41
+ bot.$emit("playerChangeGun", player, oldWeaponIdx, player.selectedGun);
42
+ if (JSON.stringify(oldCharacter) !== JSON.stringify(player.character))
43
+ bot.$emit("playerChangeCharacter", player, oldCharacter, player.character);
44
+ }
45
+ };
46
+ export default processChangeCharacterPacket;
@@ -0,0 +1,10 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ const processChatPacket = (bot) => {
3
+ const id = CommIn.unPackInt8U();
4
+ const msgFlags = CommIn.unPackInt8U();
5
+ const text = CommIn.unPackString();
6
+ const player = bot.players[id];
7
+ if (player)
8
+ bot.$emit("chat", player, text, msgFlags);
9
+ };
10
+ export default processChatPacket;
@@ -0,0 +1,26 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { CollectType } from "../constants/index.js";
3
+ const processCollectItemPacket = (bot) => {
4
+ const playerId = CommIn.unPackInt8U();
5
+ const type = CommIn.unPackInt8U();
6
+ const applyToWeaponIdx = CommIn.unPackInt8U();
7
+ const id = CommIn.unPackInt16U();
8
+ const player = bot.players[playerId];
9
+ if (!player)
10
+ return;
11
+ bot.game.collectibles[type] = bot.game.collectibles[type].filter((c) => c.id !== id);
12
+ if (type === CollectType.Ammo) {
13
+ const playerWeapon = player.weapons[applyToWeaponIdx];
14
+ if (playerWeapon && playerWeapon.ammo) {
15
+ playerWeapon.ammo.store = Math.min(playerWeapon.ammo.storeMax, playerWeapon.ammo.store + playerWeapon.ammo.pickup);
16
+ bot.$emit("playerCollectAmmo", player, playerWeapon, id);
17
+ }
18
+ }
19
+ if (type === CollectType.Grenade) {
20
+ player.grenades++;
21
+ if (player.grenades > 3)
22
+ player.grenades = 3;
23
+ bot.$emit("playerCollectGrenade", player, id);
24
+ }
25
+ };
26
+ export default processCollectItemPacket;
@@ -0,0 +1,40 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { ZoneLeaveReason } from "../enums.js";
3
+ const processDiePacket = (bot) => {
4
+ const killedId = CommIn.unPackInt8U();
5
+ const killerId = CommIn.unPackInt8U();
6
+ CommIn.unPackInt8U();
7
+ CommIn.unPackInt8U();
8
+ const damageCauseInt = CommIn.unPackInt8U();
9
+ const killed = bot.players[killedId];
10
+ const killer = bot.players[killerId];
11
+ const oldKilled = killed ? structuredClone(killed) : null;
12
+ if (bot.me && killed) {
13
+ if (killed.id === bot.me.id) {
14
+ bot.lastDeathTime = Date.now();
15
+ if (bot.pathing.activePath) {
16
+ bot.pathing.activePath = null;
17
+ bot.pathing.activeNode = null;
18
+ bot.pathing.activeNodeIdx = 0;
19
+ }
20
+ bot.state.controlKeys = 0;
21
+ }
22
+ killed.playing = false;
23
+ killed.streak = 0;
24
+ killed.hp = 100;
25
+ killed.spawnShield = 0;
26
+ killed.stats.totalDeaths++;
27
+ if (killed.inKotcZone) {
28
+ killed.inKotcZone = false;
29
+ bot.$emit("playerLeaveZone", killed, ZoneLeaveReason.Killed);
30
+ }
31
+ }
32
+ if (killer) {
33
+ killer.streak++;
34
+ killer.stats.totalKills++;
35
+ if (killer.streak > killer.stats.bestStreak)
36
+ killer.stats.bestStreak = killer.streak;
37
+ }
38
+ bot.$emit("playerDeath", killed, killer, oldKilled, damageCauseInt);
39
+ };
40
+ export default processDiePacket;
@@ -0,0 +1,21 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { ShellStreak } from "../constants/index.js";
3
+ const timedStreaks = [
4
+ ShellStreak.EggBreaker,
5
+ ShellStreak.OverHeal,
6
+ ShellStreak.DoubleEggs,
7
+ ShellStreak.MiniEgg
8
+ ];
9
+ const processEndShellStreakPacket = (bot) => {
10
+ const id = CommIn.unPackInt8U();
11
+ const ksType = CommIn.unPackInt8U();
12
+ const player = bot.players[id];
13
+ if (!player)
14
+ return;
15
+ if (timedStreaks.includes(ksType) && player.streakRewards.includes(ksType))
16
+ player.streakRewards = player.streakRewards.filter((r) => r !== ksType);
17
+ if (ksType === ShellStreak.MiniEgg)
18
+ player.scale = 1;
19
+ bot.$emit("playerEndStreak", player, ksType);
20
+ };
21
+ export default processEndShellStreakPacket;
@@ -0,0 +1,8 @@
1
+ import CommOut from "../comm/CommOut.js";
2
+ import CommCode from "../constants/CommCode.js";
3
+ const processEventModifierPacket = (bot) => {
4
+ const out = new CommOut;
5
+ out.packInt8(CommCode.eventModifier);
6
+ out.send(bot.game.socket);
7
+ };
8
+ export default processEventModifierPacket;
@@ -0,0 +1,19 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { findItemById, ItemType } from "../constants/index.js";
3
+ import { Intents } from "../enums.js";
4
+ const processExplodePacket = (bot) => {
5
+ const itemType = CommIn.unPackInt8U();
6
+ let item = CommIn.unPackInt16U();
7
+ const x = CommIn.unPackFloat();
8
+ const y = CommIn.unPackFloat();
9
+ const z = CommIn.unPackFloat();
10
+ const damage = CommIn.unPackInt8U();
11
+ const radius = CommIn.unPackFloat();
12
+ if (bot.intents.includes(Intents.COSMETIC_DATA))
13
+ item = findItemById(item);
14
+ if (itemType === ItemType.Grenade)
15
+ bot.$emit("grenadeExplode", item, { x, y, z }, damage, radius);
16
+ else
17
+ bot.$emit("rocketHit", { x, y, z }, damage, radius);
18
+ };
19
+ export default processExplodePacket;
@@ -0,0 +1,21 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ const processFirePacket = (bot) => {
3
+ const id = CommIn.unPackInt8U();
4
+ const bullet = {
5
+ posX: CommIn.unPackFloat(),
6
+ posY: CommIn.unPackFloat(),
7
+ posZ: CommIn.unPackFloat(),
8
+ dirX: CommIn.unPackFloat(),
9
+ dirY: CommIn.unPackFloat(),
10
+ dirZ: CommIn.unPackFloat()
11
+ };
12
+ const player = bot.players[id];
13
+ if (!player)
14
+ return;
15
+ const playerWeapon = player.weapons[player.activeGun];
16
+ if (playerWeapon && playerWeapon.ammo) {
17
+ playerWeapon.ammo.rounds--;
18
+ bot.$emit("playerFire", player, playerWeapon, bullet);
19
+ }
20
+ };
21
+ export default processFirePacket;
@@ -0,0 +1,33 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { CoopState, GameAction, GameMode } from "../constants/index.js";
3
+ const processGameActionPacket = (bot) => {
4
+ const action = CommIn.unPackInt8U();
5
+ if (action === GameAction.Pause) {
6
+ bot.$emit("gameForcePause");
7
+ setTimeout(() => {
8
+ if (bot.me)
9
+ bot.me.playing = false;
10
+ }, 3000);
11
+ }
12
+ if (action === GameAction.Reset) {
13
+ Object.values(bot.players).forEach((player) => player.streak = 0);
14
+ if (bot.game.gameModeId !== GameMode.FFA)
15
+ bot.game.teamScore = [0, 0, 0];
16
+ if (bot.game.gameModeId === GameMode.Spatula) {
17
+ bot.game.spatula.controlledBy = 0;
18
+ bot.game.spatula.controlledByTeam = 0;
19
+ bot.game.spatula.coords = { x: 0, y: 0, z: 0 };
20
+ }
21
+ if (bot.game.gameModeId === GameMode.KOTC) {
22
+ bot.game.kotc.stage = CoopState.Capturing;
23
+ bot.game.kotc.zoneIdx = 0;
24
+ bot.game.kotc.activeZone = null;
25
+ bot.game.kotc.capturing = 0;
26
+ bot.game.kotc.captureProgress = 0;
27
+ bot.game.kotc.numCapturing = 0;
28
+ bot.game.kotc.capturePercent = 0;
29
+ }
30
+ bot.$emit("gameReset");
31
+ }
32
+ };
33
+ export default processGameActionPacket;
@@ -0,0 +1,64 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import CommOut from "../comm/CommOut.js";
3
+ import CommCode from "../constants/CommCode.js";
4
+ import AStar from "../pathing/astar.js";
5
+ import { NodeList } from "../pathing/mapnode.js";
6
+ import { fetchMap, initKotcZones } from "../util.js";
7
+ import { GameMode } from "../constants/index.js";
8
+ import { Intents } from "../enums.js";
9
+ import { Maps } from "../constants/maps.js";
10
+ const GameModeById = Object.fromEntries(Object.entries(GameMode).map(([key, value]) => [value, key]));
11
+ const processGameJoinedPacket = async (bot) => {
12
+ bot.me.id = CommIn.unPackInt8U();
13
+ bot.me.team = CommIn.unPackInt8U();
14
+ bot.game.gameModeId = CommIn.unPackInt8U();
15
+ bot.game.gameMode = GameModeById[bot.game.gameModeId];
16
+ bot.game.mapIdx = CommIn.unPackInt8U();
17
+ bot.game.map = Maps[bot.game.mapIdx];
18
+ bot.game.playerLimit = CommIn.unPackInt8U();
19
+ bot.game.isGameOwner = CommIn.unPackInt8U() === 1;
20
+ bot.game.isPrivate = CommIn.unPackInt8U() === 1 || bot.game.isGameOwner;
21
+ CommIn.unPackInt8U();
22
+ if (bot.intents.includes(Intents.LOAD_MAP) || bot.intents.includes(Intents.PATHFINDING)) {
23
+ const map = await fetchMap(bot.game.map.filename, bot.game.map.hash);
24
+ if (bot.game.map)
25
+ bot.game.map.raw = map;
26
+ if (bot.game.gameModeId === GameMode.KOTC) {
27
+ const meshData = bot.game.map.raw.data["DYNAMIC.capture-zone.none"];
28
+ if (meshData) {
29
+ bot.game.map.zones = initKotcZones(meshData);
30
+ if (!bot.game.kotc.activeZone)
31
+ bot.game.kotc.activeZone = bot.game.map.zones[bot.game.kotc.zoneIdx - 1];
32
+ } else
33
+ delete bot.game.map.zones;
34
+ }
35
+ if (bot.intents.includes(Intents.PATHFINDING)) {
36
+ bot.pathing.nodeList = new NodeList(bot.game.map.raw);
37
+ bot.pathing.astar = new AStar(bot.pathing.nodeList);
38
+ }
39
+ bot.$emit("mapLoad", bot.game.map.raw);
40
+ }
41
+ bot.state.inGame = true;
42
+ bot.lastDeathTime = Date.now();
43
+ const out = new CommOut;
44
+ out.packInt8(CommCode.clientReady);
45
+ out.send(bot.game.socket);
46
+ if (!bot.intents.includes(Intents.MANUAL_UPDATE))
47
+ bot.updateIntervalId = setInterval(() => bot.update(), 100 / 3);
48
+ if (bot.intents.includes(Intents.PING)) {
49
+ bot.lastPingTime = Date.now();
50
+ const out2 = new CommOut;
51
+ out2.packInt8(CommCode.ping);
52
+ out2.send(bot.game.socket);
53
+ }
54
+ if (bot.intents.includes(Intents.NO_AFK_KICK))
55
+ bot.afkKickInterval = setInterval(() => {
56
+ if (bot.state.inGame && !bot.me.playing && Date.now() - bot.lastDeathTime >= 15000) {
57
+ const out3 = new CommOut;
58
+ out3.packInt8(CommCode.keepAlive);
59
+ out3.send(bot.game.socket);
60
+ }
61
+ }, 15000);
62
+ bot.$emit("gameReady");
63
+ };
64
+ export default processGameJoinedPacket;
@@ -0,0 +1,27 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { GameOptionFlag } from "../constants/index.js";
3
+ const CCGameOptionFlag = Object.fromEntries(Object.entries(GameOptionFlag).map(([k, v]) => [k[0].toLowerCase() + k.slice(1), v]));
4
+ const processGameOptionsPacket = (bot) => {
5
+ const oldOptions = structuredClone(bot.game.options);
6
+ let gravity = CommIn.unPackInt8U();
7
+ let damage = CommIn.unPackInt8U();
8
+ let healthRegen = CommIn.unPackInt8U();
9
+ if (gravity < 1 || gravity > 4)
10
+ gravity = 4;
11
+ if (damage < 0 || damage > 8)
12
+ damage = 4;
13
+ if (healthRegen > 16)
14
+ healthRegen = 4;
15
+ bot.game.options.gravity = gravity / 4;
16
+ bot.game.options.damage = damage / 4;
17
+ bot.game.options.healthRegen = healthRegen / 4;
18
+ const rawFlags = CommIn.unPackInt8U();
19
+ Object.keys(CCGameOptionFlag).forEach((optionFlagName) => {
20
+ const value = rawFlags & CCGameOptionFlag[optionFlagName] ? 1 : 0;
21
+ bot.game.options[optionFlagName] = value;
22
+ });
23
+ bot.game.options.weaponsDisabled = Array.from({ length: 7 }, () => CommIn.unPackInt8U() === 1);
24
+ bot.game.options.mustUseSecondary = bot.game.options.weaponsDisabled.every((v) => v);
25
+ bot.$emit("gameOptionsChange", oldOptions, bot.game.options);
26
+ };
27
+ export default processGameOptionsPacket;
@@ -0,0 +1,12 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ const processHitMePacket = (bot) => {
3
+ const hp = CommIn.unPackInt8U();
4
+ CommIn.unPackFloat();
5
+ CommIn.unPackFloat();
6
+ if (bot.me) {
7
+ const oldHealth = bot.me.hp;
8
+ bot.me.hp = hp;
9
+ bot.$emit("playerDamage", bot.me, oldHealth, bot.me.hp);
10
+ }
11
+ };
12
+ export default processHitMePacket;
@@ -0,0 +1,18 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { ShellStreak } from "../constants/index.js";
3
+ const processHitMeHardBoiledPacket = (bot) => {
4
+ const shieldHealth = CommIn.unPackInt8U();
5
+ const playerHealth = CommIn.unPackInt8U();
6
+ const dx = CommIn.unPackFloat();
7
+ const dz = CommIn.unPackFloat();
8
+ if (!bot.me)
9
+ return;
10
+ bot.me.shieldHp = shieldHealth;
11
+ bot.me.hp = playerHealth;
12
+ if (bot.me.shieldHp <= 0) {
13
+ bot.me.streakRewards = bot.me.streakRewards.filter((r) => r !== ShellStreak.HardBoiled);
14
+ bot.$emit("selfShieldLost", bot.me.hp, { dx, dz });
15
+ } else
16
+ bot.$emit("selfShieldHit", bot.me.shieldHp, bot.me.hp, { dx, dz });
17
+ };
18
+ export default processHitMeHardBoiledPacket;
@@ -0,0 +1,12 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ const processHitThemPacket = (bot) => {
3
+ const id = CommIn.unPackInt8U();
4
+ const hp = CommIn.unPackInt8U();
5
+ const player = bot.players[id];
6
+ if (!player)
7
+ return;
8
+ const oldHealth = player.hp;
9
+ player.hp = hp;
10
+ bot.$emit("playerDamage", player, oldHealth, player.hp);
11
+ };
12
+ export default processHitThemPacket;
@@ -0,0 +1,8 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ const processMeleePacket = (bot) => {
3
+ const id = CommIn.unPackInt8U();
4
+ const player = bot.players[id];
5
+ if (player)
6
+ bot.$emit("playerMelee", player);
7
+ };
8
+ export default processMeleePacket;
@@ -0,0 +1,62 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { GameMode } from "../constants/index.js";
3
+ import { ZoneLeaveReason } from "../enums.js";
4
+ const processMetaGameStatePacket = (bot) => {
5
+ if (bot.game.gameModeId === GameMode.Spatula) {
6
+ const oldTeamScores = structuredClone(bot.game.teamScore);
7
+ const oldSpatula = structuredClone(bot.game.spatula);
8
+ bot.game.teamScore[1] = CommIn.unPackInt16U();
9
+ bot.game.teamScore[2] = CommIn.unPackInt16U();
10
+ const spatulaCoords = {
11
+ x: CommIn.unPackFloat(),
12
+ y: CommIn.unPackFloat(),
13
+ z: CommIn.unPackFloat()
14
+ };
15
+ const controlledBy = CommIn.unPackInt8U();
16
+ const controlledByTeam = CommIn.unPackInt8U();
17
+ bot.game.spatula = { coords: spatulaCoords, controlledBy, controlledByTeam };
18
+ bot.$emit("gameStateChange", { teamScore: { before: oldTeamScores, after: bot.game.teamScore }, spatula: { before: oldSpatula, after: bot.game.spatula } });
19
+ } else if (bot.game.gameModeId === GameMode.KOTC) {
20
+ const oldTeamScores = structuredClone(bot.game.teamScore);
21
+ const oldKOTC = structuredClone(bot.game.kotc);
22
+ const oldPlayersOnZone = Object.values(bot.players).filter((p) => p.inKotcZone && p.playing);
23
+ bot.game.kotc.stage = CommIn.unPackInt8U();
24
+ bot.game.kotc.zoneIdx = CommIn.unPackInt8U();
25
+ bot.game.kotc.capturing = CommIn.unPackInt8U();
26
+ bot.game.kotc.captureProgress = CommIn.unPackInt16U();
27
+ bot.game.kotc.numCapturing = CommIn.unPackInt8U();
28
+ bot.game.teamScore[1] = CommIn.unPackInt8U();
29
+ bot.game.teamScore[2] = CommIn.unPackInt8U();
30
+ bot.game.kotc.capturePercent = bot.game.kotc.captureProgress / 1000;
31
+ bot.game.kotc.activeZone = bot.game.map?.zones ? bot.game.map.zones[bot.game.kotc.zoneIdx - 1] : null;
32
+ if (bot.game.kotc.activeZone)
33
+ Object.values(bot.players).forEach((player) => player.updateKotcZone(bot.game.kotc.activeZone));
34
+ if (bot.game.kotc.numCapturing <= 0)
35
+ Object.values(bot.players).forEach((player) => {
36
+ if (player.inKotcZone) {
37
+ player.inKotcZone = false;
38
+ bot.$emit("playerLeaveZone", player, ZoneLeaveReason.RoundEnded);
39
+ }
40
+ });
41
+ const newPlayersOnZone = Object.values(bot.players).filter((p) => p.inKotcZone && p.playing);
42
+ bot.$emit("gameStateChange", {
43
+ teamScore: { before: oldTeamScores, after: bot.game.teamScore },
44
+ kotc: { before: oldKOTC, after: bot.game.kotc },
45
+ playersOnZone: { before: oldPlayersOnZone, after: newPlayersOnZone }
46
+ });
47
+ } else if (bot.game.gameModeId === GameMode.Team) {
48
+ const oldTeamScores = structuredClone(bot.game.teamScore);
49
+ bot.game.teamScore[1] = CommIn.unPackInt16U();
50
+ bot.game.teamScore[2] = CommIn.unPackInt16U();
51
+ bot.$emit("gameStateChange", {
52
+ teamScore: { before: oldTeamScores, after: bot.game.teamScore }
53
+ });
54
+ }
55
+ if (bot.game.gameModeId !== GameMode.Spatula)
56
+ delete bot.game.spatula;
57
+ if (bot.game.gameModeId !== GameMode.KOTC)
58
+ delete bot.game.kotc;
59
+ if (bot.game.gameModeId === GameMode.FFA)
60
+ delete bot.game.teamScore;
61
+ };
62
+ export default processMetaGameStatePacket;
@@ -0,0 +1,17 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ import { ZoneLeaveReason } from "../enums.js";
3
+ const processPausePacket = (bot) => {
4
+ const id = CommIn.unPackInt8U();
5
+ const player = bot.players[id];
6
+ if (player) {
7
+ player.playing = false;
8
+ if (player.streakRewards)
9
+ player.streakRewards = [];
10
+ bot.$emit("playerPause", player);
11
+ if (player.inKotcZone) {
12
+ player.inKotcZone = false;
13
+ bot.$emit("playerLeaveZone", player, ZoneLeaveReason.Despawned);
14
+ }
15
+ }
16
+ };
17
+ export default processPausePacket;
@@ -0,0 +1,19 @@
1
+ import CommOut from "../comm/CommOut.js";
2
+ import CommCode from "../constants/CommCode.js";
3
+ import { Intents } from "../enums.js";
4
+ const processPingPacket = (bot) => {
5
+ if (!bot.intents.includes(Intents.PING))
6
+ return;
7
+ if (bot.pingTimeoutId)
8
+ clearTimeout(bot.pingTimeoutId);
9
+ const oldPing = bot.ping ?? 0;
10
+ bot.ping = bot.lastPingTime ? Date.now() - bot.lastPingTime : 0;
11
+ bot.$emit("pingUpdate", oldPing, bot.ping);
12
+ bot.pingTimeoutId = setTimeout(() => {
13
+ const out = new CommOut;
14
+ out.packInt8(CommCode.ping);
15
+ out.send(bot.game.socket);
16
+ bot.lastPingTime = Date.now();
17
+ }, 1000);
18
+ };
19
+ export default processPingPacket;
@@ -0,0 +1,15 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ const processPlayerInfoPacket = (bot) => {
3
+ const playerId = CommIn.unPackInt8U();
4
+ const playerDBId = CommIn.unPackString(128);
5
+ const playerIp = CommIn.unPackString(32);
6
+ const player = bot.players[playerId];
7
+ if (!player)
8
+ return;
9
+ player.admin = {
10
+ ip: playerIp,
11
+ dbId: playerDBId
12
+ };
13
+ bot.$emit("playerInfo", player, playerIp, playerDBId);
14
+ };
15
+ export default processPlayerInfoPacket;
@@ -0,0 +1,17 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ const processReloadPacket = (bot) => {
3
+ const id = CommIn.unPackInt8U();
4
+ const player = bot.players[id];
5
+ if (!player)
6
+ return;
7
+ const playerActiveWeapon = player.weapons[player.activeGun];
8
+ if (playerActiveWeapon.ammo) {
9
+ const maxLoad = Math.min(playerActiveWeapon.ammo.capacity, playerActiveWeapon.ammo.reload);
10
+ const needed = Math.max(0, maxLoad - playerActiveWeapon.ammo.rounds);
11
+ const newRounds = Math.min(needed, playerActiveWeapon.ammo.store);
12
+ playerActiveWeapon.ammo.rounds += newRounds;
13
+ playerActiveWeapon.ammo.store -= newRounds;
14
+ }
15
+ bot.$emit("playerReload", player, playerActiveWeapon);
16
+ };
17
+ export default processReloadPacket;
@@ -0,0 +1,10 @@
1
+ import CommIn from "../comm/CommIn.js";
2
+ const processRemovePlayerPacket = (bot) => {
3
+ const id = CommIn.unPackInt8U();
4
+ if (!bot.players[id])
5
+ return;
6
+ const removedPlayer = structuredClone(bot.players[id]);
7
+ delete bot.players[id];
8
+ bot.$emit("playerLeave", removedPlayer);
9
+ };
10
+ export default processRemovePlayerPacket;