yolkbot 0.1.1-alpha.9 → 0.1.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 (41) hide show
  1. package/README.md +2 -2
  2. package/browser/build/global.js +3 -0
  3. package/browser/build/module.js +3 -0
  4. package/package.json +11 -27
  5. package/src/api.js +56 -34
  6. package/src/bot/GamePlayer.js +18 -16
  7. package/src/bot.js +91 -37
  8. package/src/comm/Codes.js +1 -74
  9. package/src/comm/index.js +1 -1
  10. package/src/constants/codes.js +45 -0
  11. package/src/constants/guns.js +18 -2
  12. package/src/constants/index.js +11 -1
  13. package/src/constants/items.js +477 -88
  14. package/src/constants/maps.js +27 -14
  15. package/src/dispatches/BootPlayerDispatch.js +6 -2
  16. package/src/dispatches/ChatDispatch.js +7 -2
  17. package/src/dispatches/GameOptionsDispatch.js +20 -2
  18. package/src/dispatches/MeleeDispatch.js +6 -4
  19. package/src/dispatches/PauseDispatch.js +7 -3
  20. package/src/dispatches/ReloadDispatch.js +5 -2
  21. package/src/dispatches/ReportPlayerDispatch.js +7 -2
  22. package/src/dispatches/SaveLoadoutDispatch.js +11 -6
  23. package/src/dispatches/SpawnDispatch.js +5 -2
  24. package/src/dispatches/SwapWeaponDispatch.js +7 -2
  25. package/src/dispatches/SwitchTeamDispatch.js +5 -2
  26. package/src/dispatches/ThrowGrenadeDispatch.js +6 -2
  27. package/src/globals.js +15 -0
  28. package/src/matchmaker.js +13 -9
  29. package/src/pathing/astar.js +7 -25
  30. package/src/pathing/binaryheap.js +6 -6
  31. package/src/pathing/mapnode.js +4 -53
  32. package/src/socket.js +4 -10
  33. package/src/types/bot/GamePlayer.d.ts +39 -15
  34. package/src/types/bot.d.ts +1 -1
  35. package/src/types/constants/guns.d.ts +8 -0
  36. package/src/types/constants/index.d.ts +11 -1
  37. package/src/types/matchmaker.d.ts +8 -2
  38. package/build/browser.js +0 -8
  39. package/src/browser.js +0 -15
  40. package/src/dispatches/LookDispatch2.js +0 -18
  41. package/src/packet.js +0 -128
@@ -1,24 +1,7 @@
1
1
  /* eslint-disable stylistic/max-len */
2
- /*function stringifyCircular(obj) {
3
- const cache = [];
4
- return JSON.stringify(obj, (_, value) => {
5
- if (typeof value === 'object' && value !== null) {
6
-
7
- // Duplicate reference found, discard key
8
- if (cache.includes(value)) {
9
- return '* Circular';
10
- }
11
-
12
- // Store value in our collection
13
- cache.push(value);
14
- }
15
- return value;
16
- }, 4);
17
- }*/
18
2
 
19
3
  class NodeList {
20
4
  constructor(raw) {
21
- const now = Date.now();
22
5
  this.list = [];
23
6
  const addedPositions = {};
24
7
 
@@ -28,7 +11,7 @@ class NodeList {
28
11
  (nodeData.x << 16) |
29
12
  (nodeData.y << 8) |
30
13
  (nodeData.z))] = true;
31
- this.add(new MapNode(meshName, nodeData));
14
+ this.list.push(new MapNode(meshName, nodeData));
32
15
  }
33
16
  }
34
17
 
@@ -40,7 +23,7 @@ class NodeList {
40
23
  (y << 8) |
41
24
  (z)
42
25
  )]) {
43
- this.add(new MapNode('SPECIAL.__yolkbot_air__.none', { x: x, y: y, z: z }));
26
+ this.list.push(new MapNode('SPECIAL.air.none', { x: x, y: y, z: z }));
44
27
  }
45
28
  }
46
29
  }
@@ -69,16 +52,6 @@ class NodeList {
69
52
  }
70
53
  }
71
54
  }
72
-
73
- console.log(`NodeList created in ${Date.now() - now}ms`);
74
- }
75
-
76
- add(node) {
77
- this.list.push(node);
78
- }
79
-
80
- remove(node) {
81
- this.list.splice(this.list.indexOf(node), 1);
82
55
  }
83
56
 
84
57
  at(x, y, z) {
@@ -122,9 +95,7 @@ class NodeList {
122
95
 
123
96
  for (let i = 0; i <= steps; i++) {
124
97
  const node = this.at(Math.round(x), Math.round(y), Math.round(z));
125
- if (node && node.isSolid()) {
126
- return false;
127
- }
98
+ if (node && node.isSolid()) return false;
128
99
  x += xStep;
129
100
  y += yStep;
130
101
  z += zStep;
@@ -189,10 +160,6 @@ class MapNode {
189
160
  return this.meshType == 'none';
190
161
  }
191
162
 
192
- canPassThroughOnAllFaces() {
193
- return this.isAir();
194
- }
195
-
196
163
  canLink(node, list) {
197
164
  const dx0 = this.x - node.x;
198
165
  const dz0 = this.z - node.z;
@@ -208,10 +175,7 @@ class MapNode {
208
175
 
209
176
  const belowMe = list.at(this.x, this.y - 1, this.z);
210
177
  const belowOther = list.at(node.x, node.y - 1, node.z);
211
-
212
- if (!belowMe || !belowOther) {
213
- return false;
214
- }
178
+ if (!belowMe || !belowOther) return false;
215
179
 
216
180
  const FORWARD_RY_WEDGE_MAPPING = {
217
181
  0: { x: 0, z: -1 },
@@ -246,14 +210,6 @@ class MapNode {
246
210
  }
247
211
  }
248
212
 
249
- trueCenter() {
250
- return {
251
- x: this.x + 0.5,
252
- y: this.y + 0.5,
253
- z: this.z + 0.5
254
- }
255
- }
256
-
257
213
  flatCenter() {
258
214
  return {
259
215
  x: this.x + 0.5,
@@ -267,11 +223,6 @@ class MapNode {
267
223
  return Math.hypot(pos.x - position.x, pos.z - position.z);
268
224
  }
269
225
 
270
- floorCollides(position) {
271
- const posFloor = Object.entries(position).map(entry => Math.floor(entry[1]));
272
- return this.x == posFloor[0] && this.y == posFloor[1] && this.z == posFloor[2];
273
- }
274
-
275
226
  positionStr() {
276
227
  return `${this.x},${this.y},${this.z}`;
277
228
  }
package/src/socket.js CHANGED
@@ -1,18 +1,12 @@
1
- import NodeWebSocket from 'ws';
1
+ import globals from './globals.js';
2
+ import { IsBrowser, UserAgent } from './constants/index.js';
2
3
 
3
- import { IsBrowser, ProxiesEnabled, UserAgent } from '#constants';
4
-
5
- const WS = IsBrowser ? window.WebSocket : NodeWebSocket;
6
-
7
- let SocksProxyAgent;
8
- if (ProxiesEnabled) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
9
-
10
- class yolkws extends WS {
4
+ class yolkws extends globals.WebSocket {
11
5
  constructor(url, proxy) {
12
6
  if (IsBrowser) super(url);
13
7
  else {
14
8
  super(url, {
15
- agent: proxy ? new SocksProxyAgent(proxy) : undefined,
9
+ agent: proxy ? new globals.SocksProxyAgent(proxy) : undefined,
16
10
  headers: {
17
11
  'user-agent': UserAgent,
18
12
  'accept-language': 'en-US,en;q=0.9'
@@ -14,7 +14,7 @@ export interface View {
14
14
 
15
15
  export interface Character {
16
16
  eggColor: string;
17
- primaryGun: Item;
17
+ primaryGun: Item | number;
18
18
  secondaryGun: Item | number;
19
19
  stamp: Item | number;
20
20
  hat: Item | number;
@@ -29,28 +29,51 @@ export interface Buffer {
29
29
  }
30
30
 
31
31
  export interface PlayerData {
32
- name_: string;
32
+ id_: string;
33
33
  uniqueId_: string;
34
- playing_: boolean;
35
- social_: string;
36
- hideBadge_: boolean;
34
+ name_: string;
35
+ safename_: string;
36
+ charClass_: number;
37
+ team_: 0 | 1 | 2;
38
+ primaryWeaponItem_: Item | number;
39
+ secondaryWeaponItem_: Item | number;
40
+ shellColor_: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13;
41
+ hatItem_: Item | number;
42
+ stampItem_: Item | number;
43
+ _unused: number;
44
+ _unused2: number;
45
+ grenadeItem_: Item | number;
46
+ meleeItem_: Item | number;
37
47
  x_: number;
38
48
  y_: number;
39
49
  z_: number;
50
+ dx_: number;
51
+ dy_: number;
52
+ dz_: number;
40
53
  yaw_: number;
41
54
  pitch_: number;
42
- shellColor_: string;
43
- primaryWeaponItem_: Item;
44
- secondaryWeaponItem_: Item | number;
45
- stampItem_: Item | number;
46
- hatItem_: Item | number;
47
- grenadeItem_: Item | number;
48
- meleeItem_: Item | number;
55
+ score_: number;
56
+ kills_: number;
57
+ deaths_: number;
58
+ streak_: number;
59
+ totalKills_: number;
60
+ totalDeaths_: number;
61
+ bestGameStreak_: number;
62
+ bestOverallStreak_: number;
63
+ shield_: number;
64
+ hp_: number;
65
+ playing_: boolean;
49
66
  weaponIdx_: number;
67
+ controlKeys_: number;
68
+ upgradeProductId_: number;
69
+ activeShellStreaks_: number;
70
+ social_: string;
71
+ hideBadge_: boolean;
50
72
  }
51
73
 
52
74
  export interface Social {
53
75
  id: number;
76
+ type: 'Facebook' | 'Instagram' | 'Tiktok' | 'Discord' | 'Youtube' | 'Twitter' | 'Twitch';
54
77
  url: string;
55
78
  active: boolean;
56
79
  }
@@ -58,11 +81,12 @@ export interface Social {
58
81
  export class GamePlayer {
59
82
  id: string;
60
83
  team: 0 | 1 | 2;
61
- data: PlayerData;
84
+ raw: PlayerData;
62
85
  name: string;
63
86
  uniqueId: string;
64
87
  playing: boolean;
65
- social: Social[];
88
+ socials: Social[];
89
+ isVip: boolean;
66
90
  showBadge: boolean;
67
91
  position: Position;
68
92
  jumping: boolean;
@@ -74,7 +98,7 @@ export class GamePlayer {
74
98
  weapons: AnyGun[];
75
99
  grenades: number;
76
100
  buffer: Buffer;
77
- kills: number;
101
+ streak: number;
78
102
  hp: number;
79
103
  hpShield: number;
80
104
  streakRewards: number[];
@@ -231,7 +231,7 @@ export class Bot {
231
231
  update(): void;
232
232
 
233
233
  canSee(player: GamePlayer): boolean;
234
- getBestTarget(): GamePlayer | undefined;
234
+ getBestTarget(customFilter: (player: GamePlayer) => boolean): GamePlayer | undefined;
235
235
 
236
236
  onAny(cb: Function): void;
237
237
 
@@ -30,6 +30,7 @@ declare class Eggk47 extends Gun {
30
30
  longReloadTime: number;
31
31
  shortReloadTime: number;
32
32
  weaponName: string;
33
+ internalName: string;
33
34
  standardMeshName: string;
34
35
  rof: number;
35
36
  recoil: number;
@@ -53,6 +54,7 @@ declare class DozenGauge extends Gun {
53
54
  longReloadTime: number;
54
55
  shortReloadTime: number;
55
56
  weaponName: string;
57
+ internalName: string;
56
58
  standardMeshName: string;
57
59
  rof: number;
58
60
  recoil: number;
@@ -80,6 +82,7 @@ declare class CSG1 extends Gun {
80
82
  shortReloadTime: number;
81
83
  highPrecision: boolean;
82
84
  weaponName: string;
85
+ internalName: string;
83
86
  standardMeshName: string;
84
87
  rof: number;
85
88
  recoil: number;
@@ -103,6 +106,7 @@ declare class Cluck9mm extends Gun {
103
106
  longReloadTime: number;
104
107
  shortReloadTime: number;
105
108
  weaponName: string;
109
+ internalName: string;
106
110
  standardMeshName: string;
107
111
  rof: number;
108
112
  recoil: number;
@@ -129,6 +133,7 @@ declare class RPEGG extends Gun {
129
133
  longReloadTime: number;
130
134
  shortReloadTime: number;
131
135
  weaponName: string;
136
+ internalName: string;
132
137
  standardMeshName: string;
133
138
  rof: number;
134
139
  recoil: number;
@@ -158,6 +163,7 @@ declare class SMG extends Gun {
158
163
  longReloadTime: number;
159
164
  shortReloadTime: number;
160
165
  weaponName: string;
166
+ internalName: string;
161
167
  standardMeshName: string;
162
168
  rof: number;
163
169
  recoil: number;
@@ -184,6 +190,7 @@ declare class M24 extends Gun {
184
190
  longReloadTime: number;
185
191
  shortReloadTime: number;
186
192
  weaponName: string;
193
+ internalName: string;
187
194
  standardMeshName: string;
188
195
  rof: number;
189
196
  recoil: number;
@@ -210,6 +217,7 @@ declare class AUG extends Gun {
210
217
  longReloadTime: number;
211
218
  shortReloadTime: number;
212
219
  weaponName: string;
220
+ internalName: string;
213
221
  standardMeshName: string;
214
222
  rof: number;
215
223
  recoil: number;
@@ -82,6 +82,16 @@ export declare const ShellStreaks: {
82
82
  MiniEgg: number;
83
83
  };
84
84
 
85
+ export declare const SocialMedias: {
86
+ 0: string;
87
+ 1: string;
88
+ 2: string;
89
+ 3: string;
90
+ 4: string;
91
+ 5: string;
92
+ 6: string;
93
+ };
94
+
85
95
  export declare const SocialRewards: {
86
96
  Discord: string;
87
97
  Tiktok: string;
@@ -99,4 +109,4 @@ export declare const Teams: {
99
109
 
100
110
  export declare const URLRewards: string[];
101
111
 
102
- export declare const UserAgent: string;
112
+ export declare const UserAgent: string | undefined;
@@ -40,20 +40,26 @@ type CommandSend = {
40
40
  export declare class Matchmaker {
41
41
  connected: boolean;
42
42
  onceConnected: Function[];
43
+
43
44
  proxy: string | null;
44
45
  sessionId: string;
45
- forceClose: boolean;
46
46
  onListeners: Map<string, Function[]>;
47
47
  onceListeners: Map<string, Function[]>;
48
48
 
49
+ regionList: Region[] | null;
50
+ ws: yolkws;
51
+
49
52
  constructor(params?: MatchmakerParams);
50
53
 
51
54
  send(msg: CommandSend): void;
52
- waitForConnect(): Promise<void>;
55
+
53
56
  getRegions(): Promise<Region[]>;
54
57
  findPublicGame(params: FindGameParams): Promise<RawGameData>;
58
+
55
59
  getRandomRegion(): string;
56
60
  getRandomGameMode(): keyof typeof GameModes;
61
+
62
+ waitForConnect(): Promise<void>;
57
63
  close(): void;
58
64
 
59
65
  on(event: string, callback: Function): void;