yolkbot 0.1.1-alpha.4 → 0.1.1-alpha.41

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.
package/package.json CHANGED
@@ -1,28 +1,26 @@
1
1
  {
2
2
  "name": "yolkbot",
3
3
  "description": "create a shell shockers (self) bot in under 10 lines.",
4
- "version": "0.1.1-alpha.4",
4
+ "version": "0.1.1-alpha.41",
5
5
  "keywords": [
6
6
  "shell shockers",
7
7
  "shellshock.io",
8
8
  "blue wizard",
9
9
  "yolkbot"
10
10
  ],
11
- "homepage": "https://github.com/enbyte/yolkbot#readme",
11
+ "homepage": "https://github.com/yolkorg/yolkbot#readme",
12
12
  "bugs": {
13
- "url": "https://github.com/enbyte/yolkbot/issues"
13
+ "url": "https://github.com/yolkorg/yolkbot/issues"
14
14
  },
15
- "author": "hijinks",
16
- "contributors": [
17
- "1ust"
18
- ],
15
+ "author": "1ust",
16
+ "contributors": ["hijinks"],
19
17
  "repository": {
20
18
  "type": "git",
21
- "url": "git+https://github.com/enbyte/yolkbot.git"
19
+ "url": "git+https://github.com/yolkorg/yolkbot.git"
22
20
  },
23
21
  "type": "module",
24
22
  "files": [
25
- "build/*.js",
23
+ "browser/build/*.js",
26
24
  "data/*.*",
27
25
  "src/**/*",
28
26
  "package.json",
@@ -35,11 +33,7 @@
35
33
  "import": "./src/api.js",
36
34
  "types": "./src/types/api.d.ts"
37
35
  },
38
- "./bot": {
39
- "import": "./src/bot.js",
40
- "types": "./src/types/bot.d.ts"
41
- },
42
- "./browser": "./build/browser.js",
36
+ "./browser": "./browser/build/module.js",
43
37
  "./comm": "./src/comm/index.js",
44
38
  "./matchmaker": {
45
39
  "import": "./src/matchmaker.js",
@@ -48,6 +42,18 @@
48
42
  "./packets": "./src/packet.js",
49
43
  "./pathing/*": "./src/pathing/*.js",
50
44
  "./pathing/*.js": "./src/pathing/*.js",
45
+ "./bot": {
46
+ "import": "./src/bot.js",
47
+ "types": "./src/types/bot.d.ts"
48
+ },
49
+ "./bot/*": {
50
+ "import": "./src/bot/*.js",
51
+ "types": "./src/types/bot/*.d.ts"
52
+ },
53
+ "./bot/*.js": {
54
+ "import": "./src/bot/*.js",
55
+ "types": "./src/types/bot/*.d.ts"
56
+ },
51
57
  "./constants": {
52
58
  "import": "./src/constants/index.js",
53
59
  "types": "./src/types/constants/index.d.ts"
package/src/api.js CHANGED
@@ -13,6 +13,11 @@ const queryServices = async (request, proxy = '', instance = 'shellshock.io') =>
13
13
  const attempt = async () => {
14
14
  try {
15
15
  ws = new yolkws(`wss://${instance}/services/`, proxy);
16
+ ws.onerror = async (e) => {
17
+ console.error(e);
18
+ await new Promise((resolve) => setTimeout(resolve, 100));
19
+ return await attempt();
20
+ }
16
21
  } catch {
17
22
  await new Promise((resolve) => setTimeout(resolve, 100));
18
23
  await attempt();
@@ -23,7 +28,7 @@ const queryServices = async (request, proxy = '', instance = 'shellshock.io') =>
23
28
 
24
29
  return new Promise((resolve) => {
25
30
  ws.onopen = () => {
26
- // console.log('opened')
31
+ ws.onerror = null;
27
32
  ws.send(JSON.stringify(request));
28
33
  }
29
34
 
@@ -88,8 +93,10 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
88
93
  returnSecureToken: true
89
94
  }, {
90
95
  headers: {
96
+ 'origin': 'https://shellshock.io',
91
97
  'user-agent': UserAgent,
92
- 'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web'
98
+ 'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web',
99
+ 'x-firebase-locale': 'en'
93
100
  },
94
101
  httpsAgent: (ProxiesEnabled && prox) ? new SocksProxyAgent(prox) : false
95
102
  })
@@ -102,6 +109,9 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
102
109
  console.error('loginWithCredentials: Network req failed (auth/network-request-failed), retrying, k =', k);
103
110
  } else if (error.code == 'auth/missing-email') {
104
111
  return 'firebase_no_credentials';
112
+ } else if (error.code == 'ERR_BAD_REQUEST') {
113
+ console.error('loginWithCredentials: Error:', email, password);
114
+ console.error('loginWithCredentials: Error:', error.response?.data || error, 'k =', k);
105
115
  } else {
106
116
  console.error('loginWithCredentials: Error:', email, password);
107
117
  console.error('loginWithCredentials: Error:', error, 'k =', k);
@@ -1,4 +1,4 @@
1
- import { GunList } from '#constants';
1
+ import { GunList, ShellStreaks, SocialMedias } from '#constants';
2
2
  import { Cluck9mm } from '../constants/guns.js';
3
3
 
4
4
  export class GamePlayer {
@@ -6,28 +6,31 @@ export class GamePlayer {
6
6
  this.id = id;
7
7
  this.team = team;
8
8
 
9
- this.data = playerData;
9
+ this.raw = playerData;
10
10
 
11
11
  this.name = playerData.name_;
12
12
  this.uniqueId = playerData.uniqueId_;
13
13
 
14
14
  this.playing = playerData.playing_;
15
15
 
16
- this.social = playerData.social_ && JSON.parse(playerData.social_);
16
+ this.socials = playerData.social_ && JSON.parse(playerData.social_);
17
+ if (this.socials) this.socials.forEach((social) => social.type = SocialMedias[social.id]);
18
+
19
+ this.isVip = playerData.upgradeProductId_ > 0;
17
20
  this.showBadge = !playerData.hideBadge_ || false;
18
21
 
19
22
  this.position = {
20
- x: this.data.x_,
21
- y: this.data.y_,
22
- z: this.data.z_
23
+ x: playerData.x_,
24
+ y: playerData.y_,
25
+ z: playerData.z_
23
26
  };
24
27
 
25
28
  this.jumping = false;
26
29
  this.climbing = false;
27
30
 
28
31
  this.view = {
29
- yaw: this.data.yaw_,
30
- pitch: this.data.pitch_
32
+ yaw: playerData.yaw_,
33
+ pitch: playerData.pitch_
31
34
  };
32
35
 
33
36
  this.character = {
@@ -40,15 +43,14 @@ export class GamePlayer {
40
43
  melee: playerData.meleeItem_
41
44
  }
42
45
 
43
- this.activeGun = this.data.weaponIdx_;
46
+ this.activeGun = playerData.weaponIdx_;
44
47
  this.selectedGun = 0;
45
48
  this.weapons = [{}, {}];
46
49
 
47
50
  if (this.character.primaryGun) {
48
- const weaponClass = GunList[this.character.primaryGun.exclusive_for_class];
49
- this.selectedGun = this.character.primaryGun.exclusive_for_class;
51
+ this.selectedGun = playerData.charClass_;
50
52
 
51
- this.weapons[0] = new weaponClass();
53
+ this.weapons[0] = new GunList[this.selectedGun]();
52
54
  this.weapons[1] = new Cluck9mm();
53
55
  }
54
56
 
@@ -60,11 +62,11 @@ export class GamePlayer {
60
62
  2: {}
61
63
  };
62
64
 
63
- this.kills = 0;
64
- this.hp = 100;
65
+ this.streak = playerData.score_;
66
+ this.hp = playerData.hp_;
65
67
 
66
- this.hpShield = 0;
67
- this.streakRewards = [];
68
+ this.hpShield = playerData.shield_;
69
+ this.streakRewards = Object.values(ShellStreaks).filter(streak => playerData.activeShellStreaks_ & streak);
68
70
 
69
71
  this.randomSeed = 0;
70
72
  this.serverStateIdx = 0;
package/src/bot.js CHANGED
@@ -2,7 +2,7 @@ import { createAccount, loginAnonymously, loginWithCredentials, loginWithRefresh
2
2
 
3
3
  import CommIn from './comm/CommIn.js';
4
4
  import CommOut from './comm/CommOut.js';
5
- import { CommCode } from './comm/Codes.js';
5
+ import { CommCode } from './constants/codes.js';
6
6
 
7
7
  import GamePlayer from './bot/GamePlayer.js';
8
8
  import Matchmaker from './matchmaker.js';
@@ -149,7 +149,13 @@ export class Bot {
149
149
  captureProgress: 0,
150
150
  numCapturing: 0,
151
151
  stageName: '',
152
- capturePercent: 0.0
152
+ capturePercent: 0.0,
153
+
154
+ // egg org
155
+ eggOrg: {
156
+ evil: 0,
157
+ good: 0
158
+ }
153
159
  }
154
160
 
155
161
  this.account = {
@@ -435,7 +441,7 @@ export class Bot {
435
441
  this.game.socket.onmessage = (msg) => this._packetQueue.push(msg.data);
436
442
 
437
443
  if (this.autoUpdate)
438
- setInterval(() => this.update(), this.updateInterval);
444
+ this.updateIntervalId = setInterval(() => this.update(), this.updateInterval);
439
445
 
440
446
  if (this.intents.includes(this.Intents.PING)) {
441
447
  const out = CommOut.getBuffer();
@@ -542,6 +548,11 @@ export class Bot {
542
548
  const attempt = async () => {
543
549
  try {
544
550
  this.game.socket = new yolkws(`wss://${this.game.raw.subdomain}.${this.instance}/game/${this.game.raw.id}`, this.proxy);
551
+ this.game.socket.onerror = async (e) => {
552
+ console.error(e);
553
+ await new Promise((resolve) => setTimeout(resolve, 100));
554
+ return await attempt();
555
+ }
545
556
  } catch {
546
557
  await new Promise((resolve) => setTimeout(resolve, 100));
547
558
  await attempt();
@@ -553,7 +564,7 @@ export class Bot {
553
564
  this.game.socket.binaryType = 'arraybuffer';
554
565
 
555
566
  this.game.socket.onopen = () => {
556
- // console.log('Successfully connected to game server.');
567
+ this.game.socket.onerror = null;
557
568
  }
558
569
 
559
570
  this.game.socket.onmessage = this.#onGameMesssage.bind(this);
@@ -561,6 +572,7 @@ export class Bot {
561
572
  this.game.socket.onclose = (e) => {
562
573
  // console.log('Game socket closed:', e.code, Object.entries(CloseCode).filter(([, v]) => v == e.code));
563
574
  this.emit('close', e.code);
575
+ this.quit(true, true);
564
576
  }
565
577
  }
566
578
 
@@ -724,7 +736,7 @@ export class Bot {
724
736
 
725
737
  return data;
726
738
  } else {
727
- const data = await (await fetch(`https://${this.instance}/maps/${name}.json?${hash}`)).json();
739
+ const data = await (await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${name}.json`)).json();
728
740
  return data;
729
741
  }
730
742
  }
@@ -799,25 +811,21 @@ export class Bot {
799
811
 
800
812
  #processAddPlayerPacket() {
801
813
  const id_ = CommIn.unPackInt8U();
802
- const uniqueId = CommIn.unPackString();
803
- const name = CommIn.unPackString();
804
- const safename = CommIn.unPackString(); // ??? (a)
805
- const charClass = CommIn.unPackInt8U();
806
814
  const findCosmetics = this.intents.includes(this.Intents.COSMETIC_DATA);
807
815
  const playerData = {
808
816
  id_: id_,
809
- uniqueId_: uniqueId,
810
- name_: name,
811
- safename_: safename,
812
- charClass_: charClass,
817
+ uniqueId_: CommIn.unPackString(),
818
+ name_: CommIn.unPackString(),
819
+ safename_: CommIn.unPackString(),
820
+ charClass_: CommIn.unPackInt8U(),
813
821
  team_: CommIn.unPackInt8U(),
814
- primaryWeaponItem_: findItemById(CommIn.unPackInt16U()),
822
+ primaryWeaponItem_: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
815
823
  secondaryWeaponItem_: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
816
824
  shellColor_: CommIn.unPackInt8U(),
817
825
  hatItem_: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
818
826
  stampItem_: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
819
- unknownInt8: CommIn.unPackInt8(), // c
820
- otherUnknownInt8: CommIn.unPackInt8(),
827
+ _unused: CommIn.unPackInt8(),
828
+ _unused2: CommIn.unPackInt8(),
821
829
  grenadeItem_: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
822
830
  meleeItem_: findCosmetics ? findItemById(CommIn.unPackInt16U()) : CommIn.unPackInt16U(),
823
831
  x_: CommIn.unPackFloat(),
@@ -829,6 +837,7 @@ export class Bot {
829
837
  yaw_: CommIn.unPackRadU(),
830
838
  pitch_: CommIn.unPackRad(),
831
839
  score_: CommIn.unPackInt32U(),
840
+ // the following are all stats
832
841
  kills_: CommIn.unPackInt16U(),
833
842
  deaths_: CommIn.unPackInt16U(),
834
843
  streak_: CommIn.unPackInt16U(),
@@ -836,6 +845,7 @@ export class Bot {
836
845
  totalDeaths_: CommIn.unPackInt32U(),
837
846
  bestGameStreak_: CommIn.unPackInt16U(),
838
847
  bestOverallStreak_: CommIn.unPackInt16U(),
848
+ // end stats
839
849
  shield_: CommIn.unPackInt8U(),
840
850
  hp_: CommIn.unPackInt8U(),
841
851
  playing_: CommIn.unPackInt8U(),
@@ -979,15 +989,15 @@ export class Bot {
979
989
 
980
990
  if (killed) {
981
991
  killed.playing = false;
982
- killed.kills = 0;
992
+ killed.streak = 0;
983
993
  killed.lastDeathTime = Date.now();
984
- // console.log(`Player ${killed.name} died.`);
994
+ killed.hp = 100;
995
+ killed.hpShield = 0;
985
996
  }
986
997
 
987
- if (killer) { killer.kills++; }
988
- // console.log(`Player ${killer.name} is on a streak of ${killer.kills} kills.`);
998
+ if (killer) killer.streak++;
989
999
 
990
- this.emit('playerDeath', killed, killer); // killed, killer
1000
+ this.emit('playerDeath', killed, killer);
991
1001
  }
992
1002
 
993
1003
  #processFirePacket() {
@@ -1302,7 +1312,7 @@ export class Bot {
1302
1312
  if (action == GameActions.reset) {
1303
1313
  // console.log('owner reset game');
1304
1314
 
1305
- this.me.kills = 0;
1315
+ Object.values(this.players).forEach((player) => player.streak = 0);
1306
1316
 
1307
1317
  if (this.game.gameModeId !== GameModes.ffa) this.game.teamScore = [0, 0, 0];
1308
1318
 
@@ -1354,7 +1364,7 @@ export class Bot {
1354
1364
  const oldTeam = player.team;
1355
1365
 
1356
1366
  player.team = toTeam;
1357
- player.kills = 0;
1367
+ player.streak = 0;
1358
1368
 
1359
1369
  this.emit('playerSwitchTeam', player, oldTeam, toTeam);
1360
1370
  }
@@ -1376,8 +1386,7 @@ export class Bot {
1376
1386
 
1377
1387
  const findCosmetics = this.intents.includes(this.Intents.COSMETIC_DATA);
1378
1388
 
1379
- const primaryWeaponItem = findItemById(primaryWeaponIdx);
1380
-
1389
+ const primaryWeaponItem = findCosmetics ? findItemById(primaryWeaponIdx) : primaryWeaponIdx;
1381
1390
  const secondaryWeaponItem = findCosmetics ? findItemById(secondaryWeaponIdx) : secondaryWeaponIdx;
1382
1391
  const hatItem = findCosmetics ? findItemById(hatIdx) : hatIdx;
1383
1392
  const stampItem = findCosmetics ? findItemById(stampIdx) : stampIdx;
@@ -1514,6 +1523,26 @@ export class Bot {
1514
1523
  if (player.id == this.me.id) this.refreshChallenges();
1515
1524
  }
1516
1525
 
1526
+ // egg org
1527
+ #processClientReadyPacket() {
1528
+ this.#processEggOrgUpdatePacket();
1529
+ }
1530
+
1531
+ // egg org
1532
+ #processEggOrgUpdatePacket() {
1533
+ const str = CommIn.unPackString();
1534
+
1535
+ try {
1536
+ const eggOrgStats = JSON.parse(str);
1537
+ this.game.eggOrg.evil = eggOrgStats[0];
1538
+ this.game.eggOrg.good = eggOrgStats[1];
1539
+
1540
+ this.emit('eggOrgUpdate', this.game.eggOrg);
1541
+ } catch {
1542
+ // hopefully never =D
1543
+ }
1544
+ }
1545
+
1517
1546
  #handlePacket(packet) {
1518
1547
  CommIn.init(packet);
1519
1548
 
@@ -1521,6 +1550,7 @@ export class Bot {
1521
1550
  this.emit('packet', packet);
1522
1551
 
1523
1552
  let lastCommand = 0;
1553
+ let lastCode = 0;
1524
1554
  let abort = false;
1525
1555
 
1526
1556
  while (CommIn.isMoreDataAvailable() && !abort) {
@@ -1627,6 +1657,11 @@ export class Bot {
1627
1657
  this.#processThrowGrenadePacket();
1628
1658
  break;
1629
1659
 
1660
+ // egg org
1661
+ case CommCode.eggOrgUpdate:
1662
+ this.#processEggOrgUpdatePacket();
1663
+ break;
1664
+
1630
1665
  case CommCode.spawnItem:
1631
1666
  this.#processSpawnItemPacket();
1632
1667
  break;
@@ -1655,9 +1690,13 @@ export class Bot {
1655
1690
  this.#processRespawnDeniedPacket();
1656
1691
  break;
1657
1692
 
1693
+ // egg org
1694
+ case CommCode.clientReady:
1695
+ this.#processClientReadyPacket();
1696
+ break;
1697
+
1658
1698
  // we do not plan to implement these
1659
1699
  // for more info, see comm/codes.js
1660
- case CommCode.clientReady:
1661
1700
  case CommCode.expireUpgrade:
1662
1701
  break;
1663
1702
 
@@ -1666,13 +1705,14 @@ export class Bot {
1666
1705
  break;
1667
1706
 
1668
1707
  default:
1669
- console.error(`handlePacket: I got but did not handle a: ${Object.keys(CommCode).find(k => CommCode[k] === cmd)}`);
1670
- if (lastCommand) console.error(`handlePacket: It may be a result of the ${lastCommand} command.`);
1708
+ console.error(`handlePacket: I got but did not handle a: ${Object.keys(CommCode).find(k => CommCode[k] === cmd)} ${cmd}`);
1709
+ if (lastCommand) console.error(`handlePacket: It may be a result of the ${lastCommand} command (${lastCode}).`);
1671
1710
  abort = true
1672
1711
  break;
1673
1712
  }
1674
1713
 
1675
1714
  lastCommand = Object.keys(CommCode).find(k => CommCode[k] === cmd);
1715
+ lastCode = cmd;
1676
1716
  }
1677
1717
  }
1678
1718
 
@@ -1683,6 +1723,8 @@ export class Bot {
1683
1723
  sessionId: this.account.sessionId
1684
1724
  });
1685
1725
 
1726
+ if (typeof response === 'string') return response;
1727
+
1686
1728
  this.account.cw.limit = response.limit;
1687
1729
  this.account.cw.atLimit = response.limit > 3;
1688
1730
 
@@ -1706,6 +1748,8 @@ export class Bot {
1706
1748
  token: null
1707
1749
  }, this.proxy, this.instance);
1708
1750
 
1751
+ if (typeof response === 'string') return response;
1752
+
1709
1753
  if (response.error) {
1710
1754
  if (response.error == 'RATELIMITED') {
1711
1755
  await this.checkChiknWinner();
@@ -1740,6 +1784,8 @@ export class Bot {
1740
1784
  sessionId: this.account.sessionId
1741
1785
  });
1742
1786
 
1787
+ if (typeof response === 'string') return response;
1788
+
1743
1789
  if (response.result !== 'SUCCESS') {
1744
1790
  console.error('Unknown Chikn Winner reset response', response);
1745
1791
  return 'unknown_error';
@@ -1756,7 +1802,7 @@ export class Bot {
1756
1802
  return this.pathing.nodeList.hasLineOfSight(this.me.position, target.position);
1757
1803
  }
1758
1804
 
1759
- getBestTarget() {
1805
+ getBestTarget(customFilter = () => true) {
1760
1806
  const options = Object.values(this.players)
1761
1807
  .filter((player) => player)
1762
1808
  .filter((player) => player !== this.me)
@@ -1764,7 +1810,8 @@ export class Bot {
1764
1810
  .filter((player) => player.hp > 0)
1765
1811
  .filter((player) => player.name !== this.me.name)
1766
1812
  .filter((player) => this.me.team === 0 || player.team !== this.me.team)
1767
- .filter((player) => this.canSee(player));
1813
+ .filter((player) => this.canSee(player))
1814
+ .filter((player) => !!customFilter(player));
1768
1815
 
1769
1816
  let minDistance = 200;
1770
1817
  let targetPlayer = null;
@@ -1867,15 +1914,18 @@ export class Bot {
1867
1914
  return result;
1868
1915
  }
1869
1916
 
1870
- quit(noCleanup = false) {
1917
+ quit(noCleanup = false, finishDispatches = false) {
1871
1918
  if (this.intents.includes(this.Intents.PLAYER_HEALTH))
1872
1919
  clearInterval(this.healthIntervalId);
1873
1920
 
1874
- clearInterval(this.updateInterval);
1921
+ clearInterval(this.updateIntervalId);
1875
1922
 
1876
- this.game.socket.close();
1923
+ if (this.game) this.game.socket.close();
1877
1924
  this.matchmaker.close();
1878
1925
 
1926
+ if (!finishDispatches) this._dispatches = [];
1927
+ this._packetQueue = [];
1928
+
1879
1929
  if (!noCleanup) {
1880
1930
  delete this.account;
1881
1931
  delete this.game;
package/src/comm/Codes.js CHANGED
@@ -74,76 +74,6 @@ const CommCode = {
74
74
 
75
75
  */
76
76
 
77
- const CommCode = {
78
- swapWeapon: 0,
79
- joinGame: 0,
80
- refreshGameState: 0,
81
- spawnItem: 0,
82
- observeGame: 0,
83
- ping: 0,
84
- bootPlayer: 0,
85
- banPlayer: 0,
86
- loginRequired: 0,
87
- gameLocked: 0,
88
- reportPlayer: 0,
89
- banned: 0,
90
- createPrivateGame: 0,
91
- switchTeam: 0,
92
- changeCharacter: 0,
93
- pause: 0,
94
- gameOptions: 0,
95
- gameAction: 0,
96
- requestGameOptions: 0,
97
- gameJoined: 0,
98
- socketReady: 0,
99
- addPlayer: 0,
100
- removePlayer: 0,
101
- fire: 0,
102
- melee: 0,
103
- throwGrenade: 0,
104
- info: 0,
105
- eventModifier: 0,
106
- hitThem: 0,
107
- hitMe: 0,
108
- collectItem: 0,
109
- chlgPlayerRerollInGame: 0,
110
- playerInGameReward: 0,
111
- playerRewards: 0,
112
- chat: 0,
113
- syncThem: 0,
114
- syncAmmo: 0,
115
- die: 0,
116
- beginShellStreak: 0,
117
- endShellStreak: 0,
118
- startReload: 0,
119
- announcement: 0,
120
- updateBalance: 0,
121
- reload: 0,
122
- respawn: 0,
123
- respawnDenied: 0,
124
- pong: 0,
125
- clientReady: 0,
126
- requestRespawn: 0,
127
- joinPublicGame: 0,
128
- joinPrivateGame: 0,
129
- switchTeamFail: 0,
130
- expireUpgrade: 0,
131
- metaGameState: 0,
132
- syncMe: 0,
133
- explode: 0,
134
- keepAlive: 0,
135
- musicInfo: 0,
136
- hitMeHardBoiled: 0,
137
- playerInfo: 0,
138
- challengeCompleted: 0
139
- };
140
-
141
- let ih = 1;
142
-
143
- Object.keys(CommCode).forEach(e => {
144
- CommCode[e] = ih++;
145
- });
146
-
147
77
  const CloseCode = {
148
78
  gameNotFound: 4000,
149
79
  gameFull: 4001,
@@ -166,7 +96,4 @@ const CloseCode = {
166
96
  locked: 4023
167
97
  }
168
98
 
169
- export {
170
- CommCode,
171
- CloseCode
172
- }
99
+ export { CloseCode }
package/src/comm/index.js CHANGED
@@ -3,7 +3,7 @@ import CommOut from './CommOut.js';
3
3
  import OutBuffer from './OutBuffer.js';
4
4
  import Pool from './Pool.js';
5
5
 
6
- import { CommCode } from './Codes.js';
6
+ import { CommCode } from '../constants/codes.js';
7
7
  import { CloseCode } from './Codes.js';
8
8
 
9
9
  export {
@@ -0,0 +1,45 @@
1
+ /* eslint-disable */
2
+ export const CommCode = {
3
+ "swapWeapon": 0,
4
+ "joinGame": 1,
5
+ "spawnItem": 3,
6
+ "ping": 5,
7
+ "bootPlayer": 6,
8
+ "reportPlayer": 10,
9
+ "switchTeam": 13,
10
+ "changeCharacter": 14,
11
+ "pause": 15,
12
+ "gameOptions": 16,
13
+ "gameAction": 17,
14
+ "requestGameOptions": 18,
15
+ "gameJoined": 19,
16
+ "socketReady": 20,
17
+ "addPlayer": 21,
18
+ "removePlayer": 22,
19
+ "fire": 23,
20
+ "melee": 24,
21
+ "throwGrenade": 25,
22
+ "eventModifier": 27,
23
+ "hitThem": 28,
24
+ "hitMe": 29,
25
+ "collectItem": 30,
26
+ "chat": 34,
27
+ "syncThem": 35,
28
+ "die": 37,
29
+ "beginShellStreak": 38,
30
+ "endShellStreak": 39,
31
+ "updateBalance": 42,
32
+ "reload": 43,
33
+ "respawn": 44,
34
+ "respawnDenied": 45,
35
+ "clientReady": 47,
36
+ "requestRespawn": 48,
37
+ "metaGameState": 53,
38
+ "syncMe": 54,
39
+ "explode": 55,
40
+ "keepAlive": 56,
41
+ "musicInfo": 57,
42
+ "hitMeHardBoiled": 58,
43
+ "challengeCompleted": 60,
44
+ "eggOrgUpdate": 61
45
+ };