yolkbot 0.1.0 → 0.1.1-alpha.11

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.
@@ -71,6 +71,8 @@ export const PlayTypes = {
71
71
  joinPrivate: 2
72
72
  }
73
73
 
74
+ export const ProxiesEnabled = !IsBrowser && typeof Bun == 'undefined';
75
+
74
76
  export const ShellStreaks = {
75
77
  HardBoiled: 1,
76
78
  EggBreaker: 2,
@@ -7,8 +7,6 @@ const calculateYaw = (pos) => setPrecision(mod(Math.atan2(-pos.x, -pos.z), PI2))
7
7
  const calculatePitch = (pos) => setPrecision(Math.atan2(pos.y, Math.hypot(pos.x, pos.z)));
8
8
 
9
9
  export class LookAtPosDispatch {
10
- idOrName;
11
-
12
10
  constructor(pos) {
13
11
  this.pos = pos;
14
12
  }
@@ -0,0 +1,18 @@
1
+ export class LookDispatch2 {
2
+ check(bot) {
3
+ return bot.me.playing;
4
+ }
5
+
6
+ execute(bot) {
7
+ let x = 0;
8
+
9
+ (() => setInterval(() => {
10
+ x += 0.1;
11
+ x %= 2 * Math.PI;
12
+ bot.me.view.yaw = x - Math.PI;
13
+ bot.me.view.pitch = x;
14
+ }, 20))();
15
+ }
16
+ }
17
+
18
+ export default LookDispatch2;
@@ -92,7 +92,7 @@ export class SaveLoadoutDispatch {
92
92
  if (bot.state.joinedGame)
93
93
  new packet.ChangeCharacterPacket(this.changes?.classIdx || bot.me.selectedGun).execute(bot.game.socket);
94
94
 
95
- const findCosmetics = this.intents.includes(this.Intents.COSMETIC_DATA);
95
+ const findCosmetics = bot.intents.includes(bot.Intents.COSMETIC_DATA);
96
96
 
97
97
  // apply changes to the bot
98
98
  Object.entries(this.changes).forEach(([changeKey, changeValue]) => {
package/src/matchmaker.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { loginAnonymously } from '#api';
2
- import { GameModes, IsBrowser, PlayTypes } from '#constants';
2
+ import { GameModes, PlayTypes, ProxiesEnabled } from '#constants';
3
3
 
4
4
  import yolkws from './socket.js';
5
5
 
@@ -21,13 +21,10 @@ export class Matchmaker {
21
21
  constructor(params = {}) {
22
22
  if (!params.instance) params.instance = 'shellshock.io';
23
23
 
24
- if (params.proxy && IsBrowser)
25
- throw new Error('proxies do not work and hence are not supported in the browser');
26
-
27
24
  if (params.sessionId) this.sessionId = params.sessionId;
28
25
  else this.#createSessionId(params.instance);
29
26
 
30
- if (params.proxy && IsBrowser) throw new Error('proxies do not work and hence are not supported in the browser');
27
+ if (params.proxy && !ProxiesEnabled) throw new Error('proxies do not work and hence are not supported in the browser');
31
28
  else if (params.proxy) this.proxy = params.proxy;
32
29
 
33
30
  this.#createSocket(params.instance);
@@ -20,11 +20,14 @@ class NodeList {
20
20
  constructor(raw) {
21
21
  const now = Date.now();
22
22
  this.list = [];
23
- const addedPositions = new Set();
23
+ const addedPositions = {};
24
24
 
25
25
  for (const meshName of Object.keys(raw.data)) {
26
26
  for (const nodeData of raw.data[meshName]) {
27
- addedPositions.add(`${nodeData.x},${nodeData.y},${nodeData.z}`);
27
+ addedPositions[(
28
+ (nodeData.x << 16) |
29
+ (nodeData.y << 8) |
30
+ (nodeData.z))] = true;
28
31
  this.add(new MapNode(meshName, nodeData));
29
32
  }
30
33
  }
@@ -32,8 +35,11 @@ class NodeList {
32
35
  for (let x = 0; x < raw.width; x++) {
33
36
  for (let y = 0; y < raw.height; y++) {
34
37
  for (let z = 0; z < raw.depth; z++) {
35
- const posKey = `${x},${y},${z}`;
36
- if (!addedPositions.has(posKey)) {
38
+ if (!addedPositions[(
39
+ (x << 16) |
40
+ (y << 8) |
41
+ (z)
42
+ )]) {
37
43
  this.add(new MapNode('SPECIAL.__yolkbot_air__.none', { x: x, y: y, z: z }));
38
44
  }
39
45
  }
package/src/socket.js CHANGED
@@ -1,12 +1,11 @@
1
1
  import NodeWebSocket from 'ws';
2
2
 
3
- import { IsBrowser, UserAgent } from '#constants';
3
+ import { IsBrowser, ProxiesEnabled, UserAgent } from '#constants';
4
4
 
5
- // eslint-disable-next-line no-undef
6
5
  const WS = IsBrowser ? window.WebSocket : NodeWebSocket;
7
6
 
8
7
  let SocksProxyAgent;
9
- if (!IsBrowser) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
8
+ if (ProxiesEnabled) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
10
9
 
11
10
  class yolkws extends WS {
12
11
  constructor(url, proxy) {
@@ -1,6 +1,7 @@
1
1
  import { NodeList } from '../pathing/mapnode.js';
2
2
 
3
3
  import { Character, GamePlayer } from './bot/GamePlayer';
4
+ import { Challenge } from './constants/challenges';
4
5
  import { AnyGun } from './constants/guns';
5
6
  import { Map } from './constants/maps';
6
7
  import { ADispatch } from './dispatches/index';
@@ -22,6 +23,44 @@ export interface ChiknWinnerStatus {
22
23
  canPlayAgain: number;
23
24
  }
24
25
 
26
+ export interface StatKD {
27
+ total: number;
28
+ mode: {
29
+ public: number;
30
+ private: number;
31
+ };
32
+ dmgType: {
33
+ pistol: number;
34
+ grenade: number;
35
+ rpegg: number;
36
+ eggk: number;
37
+ scrambler: number;
38
+ ranger: number;
39
+ whpper: number;
40
+ crackshot: number;
41
+ trihard: number;
42
+ melee: number;
43
+ };
44
+ gameType: {
45
+ kotc: number;
46
+ spatula: number;
47
+ ffa: number;
48
+ team: number;
49
+ }
50
+ }
51
+
52
+ export interface Stats {
53
+ streak: number;
54
+ kills: StatKD;
55
+ deaths: StatKD;
56
+ gameType: {
57
+ kotc: {
58
+ captured: number;
59
+ wins: number;
60
+ }
61
+ };
62
+ }
63
+
25
64
  export interface Account {
26
65
  id: number;
27
66
  firebaseId: string;
@@ -45,7 +84,12 @@ export interface Account {
45
84
  accountAge: number;
46
85
  emailVerified: boolean;
47
86
  eggBalance: number;
48
- rawLoginData: any; // i ain't typoing allat
87
+ stats: {
88
+ lifetime: Stats;
89
+ monthly: Stats;
90
+ }
91
+ challenges: Challenge[];
92
+ rawLoginData: any; // i ain't typing allat
49
93
  }
50
94
 
51
95
  export interface GameOptions {
@@ -144,7 +188,9 @@ type intents = {
144
188
  PATHFINDING: 3,
145
189
  BUFFERS: 4,
146
190
  PING: 5,
147
- COSMETIC_DATA: 6
191
+ COSMETIC_DATA: 6,
192
+ PLAYER_HEALTH: 7,
193
+ PACKET_HOOK: 8
148
194
  }
149
195
 
150
196
  export class Bot {
@@ -152,7 +198,6 @@ export class Bot {
152
198
  Intents: intents;
153
199
 
154
200
  proxy: string;
155
- name?: string;
156
201
  autoUpdate: boolean;
157
202
  disablePathing: boolean;
158
203
  updateInterval: number;
@@ -186,7 +231,7 @@ export class Bot {
186
231
  update(): void;
187
232
 
188
233
  canSee(player: GamePlayer): boolean;
189
- getBestTarget(): GamePlayer | undefined;
234
+ getBestTarget(customFilter: (player: GamePlayer) => boolean): GamePlayer | undefined;
190
235
 
191
236
  onAny(cb: Function): void;
192
237
 
@@ -235,6 +280,8 @@ export class Bot {
235
280
  claimURLReward(reward: string): Promise<{ result: string; eggsGiven: number; itemIds: number[]; }>;
236
281
  claimSocialReward(rewardTag: string): Promise<{ result: string; eggsGiven: number; itemIds: number[]; }>;
237
282
  buyItem(itemId: number): Promise<{ result: string; currentBalance: number; itemId: number; }>;
283
+
284
+ quit(noCleanup?: boolean): void;
238
285
  }
239
286
 
240
287
  export default Bot;
@@ -0,0 +1,19 @@
1
+ export interface Challenge {
2
+ id: number;
3
+ loc_ref: string;
4
+ type: number;
5
+ subType: number;
6
+ period: number;
7
+ goal: number;
8
+ reward: number;
9
+ conditional: number;
10
+ value: string;
11
+ valueTwo: string | null;
12
+ tier: number;
13
+ loc: {
14
+ title: string;
15
+ desc: string;
16
+ }
17
+ }
18
+
19
+ export type Challenges = Challenge[];
@@ -71,6 +71,8 @@ export declare const PlayTypes: {
71
71
  joinPrivate: number;
72
72
  };
73
73
 
74
+ export declare const ProxiesEnabled: boolean;
75
+
74
76
  export declare const ShellStreaks: {
75
77
  HardBoiled: number;
76
78
  EggBreaker: number;