yolkbot 0.1.0-alpha.4 → 0.1.0-alpha.6

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,7 +1,7 @@
1
1
  {
2
2
  "name": "yolkbot",
3
3
  "description": "create a shell shockers (self) bot in under 10 lines.",
4
- "version": "0.1.0-alpha.4",
4
+ "version": "0.1.0-alpha.6",
5
5
  "keywords": [
6
6
  "shell shockers",
7
7
  "shellshock.io",
@@ -31,18 +31,36 @@
31
31
  "exports": {
32
32
  "./package.json": "./package.json",
33
33
  ".": "./src/index.js",
34
- "./api": "./src/api.js",
35
- "./bot": "./src/bot.js",
34
+ "./api": {
35
+ "import": "./src/api.js",
36
+ "types": "./src/types/api.d.ts"
37
+ },
38
+ "./bot": {
39
+ "import": "./src/bot.js",
40
+ "types": "./src/types/bot.d.ts"
41
+ },
36
42
  "./browser": "./build/browser.js",
37
43
  "./comm": "./src/comm/index.js",
38
- "./matchmaker": "./src/matchmaker.js",
44
+ "./matchmaker": {
45
+ "import": "./src/matchmaker.js",
46
+ "types": "./src/types/matchmaker.d.ts"
47
+ },
39
48
  "./packets": "./src/packet.js",
40
49
  "./constants": "./src/constants/index.js",
41
50
  "./constants/*": "./src/constants/*.js",
42
51
  "./constants/*.js": "./src/constants/*.js",
43
- "./dispatch": "./src/dispatches/index.js",
44
- "./dispatch/*": "./src/dispatches/*.js",
45
- "./dispatch/*.js": "./src/dispatches/*.js"
52
+ "./dispatch": {
53
+ "import": "./src/dispatches/index.js",
54
+ "types": "./src/types/dispatches.d.ts"
55
+ },
56
+ "./dispatch/*": {
57
+ "import": "./src/dispatches/*.js",
58
+ "types": "./src/types/dispatches/*.d.ts"
59
+ },
60
+ "./dispatch/*.js": {
61
+ "import": "./src/dispatches/*.js",
62
+ "types": "./src/types/dispatches/*.d.ts"
63
+ }
46
64
  },
47
65
  "dependencies": {
48
66
  "socks-proxy-agent": "^8.0.5",
package/src/api.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import yolkws from './socket.js';
2
2
 
3
- import { UserAgent } from '#constants';
4
-
5
- const firebaseKey = 'AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50';
3
+ import { FirebaseKey, UserAgent } from '#constants';
6
4
 
7
5
  const queryServices = async (request, proxy = '', instance = 'shellshock.io') => {
8
6
  return new Promise((resolve) => {
@@ -62,7 +60,7 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
62
60
 
63
61
  while (!SUCCESS) {
64
62
  try {
65
- request = await fetch('https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=' + firebaseKey, {
63
+ request = await fetch('https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=' + FirebaseKey, {
66
64
  method: 'POST',
67
65
  body: JSON.stringify({
68
66
  email: email,
@@ -108,7 +106,7 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
108
106
  }
109
107
 
110
108
  async function loginAnonymously(prox = '', instance = 'shellshock.io') {
111
- const request = await fetch('https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=' + firebaseKey, {
109
+ const request = await fetch('https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=' + FirebaseKey, {
112
110
  method: 'POST',
113
111
  body: JSON.stringify({ returnSecureToken: true }),
114
112
  headers: {
@@ -19,6 +19,8 @@ export const CoopStates = {
19
19
  unclaimed: 7
20
20
  }
21
21
 
22
+ export const FirebaseKey = 'AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50';
23
+
22
24
  export const GameActions = {
23
25
  reset: 1,
24
26
  pause: 2
@@ -15,6 +15,7 @@ import SaveLoadoutDispatch from './SaveLoadoutDispatch.js';
15
15
  import SpawnDispatch from './SpawnDispatch.js';
16
16
  import SwapWeaponDispatch from './SwapWeaponDispatch.js';
17
17
  import SwitchTeamDispatch from './SwitchTeamDispatch.js';
18
+ import ThrowGrenadeDispatch from './ThrowGrenadeDispatch.js';
18
19
 
19
20
  export {
20
21
  BootPlayerDispatch,
@@ -33,7 +34,8 @@ export {
33
34
  SaveLoadoutDispatch,
34
35
  SpawnDispatch,
35
36
  SwapWeaponDispatch,
36
- SwitchTeamDispatch
37
+ SwitchTeamDispatch,
38
+ ThrowGrenadeDispatch
37
39
  }
38
40
 
39
41
  export default {
@@ -53,5 +55,6 @@ export default {
53
55
  SaveLoadoutDispatch,
54
56
  SpawnDispatch,
55
57
  SwapWeaponDispatch,
56
- SwitchTeamDispatch
58
+ SwitchTeamDispatch,
59
+ ThrowGrenadeDispatch
57
60
  }
@@ -0,0 +1,35 @@
1
+ import { FirebaseKey, UserAgent } from '../constants/index.js';
2
+
3
+ declare module './socket.js' {
4
+ export default class yolkws {
5
+ constructor(url: string, proxy: string);
6
+ onopen: () => void;
7
+ onmessage: (event: { data: string }) => void;
8
+ onerror: () => void;
9
+ onclose: () => void;
10
+ send(data: string): void;
11
+ close(): void;
12
+ }
13
+ }
14
+
15
+ export interface QueryRequest {
16
+ cmd: string;
17
+ firebaseToken?: string;
18
+ }
19
+
20
+ export interface QueryResponse {
21
+ id?: number;
22
+ firebaseId?: string;
23
+ sessionId?: string;
24
+ session?: number;
25
+ kills?: number;
26
+ deaths?: number;
27
+ currentBalance?: number;
28
+ [key: string]: any;
29
+ }
30
+
31
+ export function queryServices(request: QueryRequest, proxy?: string, instance?: string): Promise<QueryResponse | string>;
32
+
33
+ export function loginWithCredentials(email: string, password: string, prox?: string, instance?: string): Promise<QueryResponse | string>;
34
+
35
+ export function loginAnonymously(prox?: string, instance?: string): Promise<QueryResponse | string>;
@@ -0,0 +1,83 @@
1
+ import { GunList } from '#constants';
2
+ import { Cluck9mm } from '../constants/guns.js';
3
+
4
+ export interface Position {
5
+ x: number;
6
+ y: number;
7
+ z: number;
8
+ }
9
+
10
+ export interface View {
11
+ yaw: number;
12
+ pitch: number;
13
+ }
14
+
15
+ export interface Character {
16
+ eggColor: string;
17
+ primaryGun: any;
18
+ secondaryGun: any;
19
+ stamp: any;
20
+ hat: any;
21
+ grenade: any;
22
+ melee: any;
23
+ }
24
+
25
+ export interface Buffer {
26
+ [key: number]: any;
27
+ }
28
+
29
+ export interface PlayerData {
30
+ name_: string;
31
+ uniqueId_: string;
32
+ playing_: boolean;
33
+ social_: string;
34
+ hideBadge_: boolean;
35
+ x_: number;
36
+ y_: number;
37
+ z_: number;
38
+ yaw_: number;
39
+ pitch_: number;
40
+ shellColor_: string;
41
+ primaryWeaponItem_: any;
42
+ secondaryWeaponItem_: any;
43
+ stampItem_: any;
44
+ hatItem_: any;
45
+ grenadeItem_: any;
46
+ meleeItem_: any;
47
+ weaponIdx_: number;
48
+ }
49
+
50
+ export class GamePlayer {
51
+ id: string;
52
+ team: string;
53
+ data: PlayerData;
54
+ name: string;
55
+ uniqueId: string;
56
+ playing: boolean;
57
+ social: any;
58
+ showBadge: boolean;
59
+ position: Position;
60
+ jumping: boolean;
61
+ climbing: boolean;
62
+ view: View;
63
+ character: Character;
64
+ activeGun: number;
65
+ selectedGun: number;
66
+ weapons: any[];
67
+ grenades: number;
68
+ buffer: Buffer;
69
+ kills: number;
70
+ hp: number;
71
+ hpShield: number;
72
+ streakRewards: any[];
73
+ randomSeed: number;
74
+ serverStateIdx: number;
75
+
76
+ constructor(id: string, team: string, playerData: PlayerData);
77
+
78
+ dispatch(): void;
79
+ join(): void;
80
+ update(): void;
81
+ }
82
+
83
+ export default GamePlayer;
@@ -0,0 +1,152 @@
1
+ import { CommCode } from '../comm/Codes.js';
2
+ import { GamePlayer } from '../bot/GamePlayer.js';
3
+ import { Matchmaker } from '../matchmaker.js';
4
+ import { yolkws } from '../socket.js';
5
+ import { NodeList } from '../pathing/mapnode.js';
6
+ import { Maps } from '../constants/maps.js';
7
+
8
+ export interface BotParams {
9
+ name?: string;
10
+ proxy?: string;
11
+ doUpdate?: boolean;
12
+ updateInterval?: number;
13
+ doPing?: boolean;
14
+ pingInterval?: number;
15
+ doPathing?: boolean;
16
+ instance?: string;
17
+ }
18
+
19
+ export interface Account {
20
+ firebaseId: string;
21
+ sessionId: string;
22
+ session: string;
23
+ loadout: {
24
+ hatId: number | null;
25
+ meleeId: number;
26
+ stampId: number | null;
27
+ classIdx: number;
28
+ colorIdx: number;
29
+ grenadeId: number;
30
+ primaryId: number[];
31
+ secondaryId: number[];
32
+ stampPositionX: number;
33
+ stampPositionY: number;
34
+ };
35
+ ownedItemIds: number[];
36
+ vip: boolean;
37
+ accountAge: number;
38
+ emailVerified: boolean;
39
+ eggBalance: number;
40
+ rawLoginData: any;
41
+ }
42
+
43
+ export interface GameOptions {
44
+ gravity: number;
45
+ damage: number;
46
+ healthRegen: number;
47
+ locked: boolean;
48
+ noTeamChange: boolean;
49
+ noTeamShuffle: boolean;
50
+ weaponsDisabled: boolean[];
51
+ mustUseSecondary: boolean;
52
+ }
53
+
54
+ export interface Game {
55
+ raw: any;
56
+ code: string;
57
+ gameModeId: number;
58
+ gameMode: string;
59
+ mapIdx: number;
60
+ map: {
61
+ filename: string;
62
+ hash: string;
63
+ name: string;
64
+ modes: {
65
+ FFA: boolean;
66
+ Teams: boolean;
67
+ Spatula: boolean;
68
+ King: boolean;
69
+ };
70
+ availability: string;
71
+ numPlayers: string;
72
+ raw: any;
73
+ nodes: any;
74
+ };
75
+ playerLimit: number;
76
+ isGameOwner: boolean;
77
+ isPrivate: boolean;
78
+ options: GameOptions;
79
+ collectables: any[][];
80
+ teamScore: number[];
81
+ spatula: {
82
+ coords: { x: number; y: number; z: number };
83
+ controlledBy: number;
84
+ controlledByTeam: number;
85
+ };
86
+ stage: number;
87
+ activeZone: number;
88
+ capturing: number;
89
+ captureProgress: number;
90
+ numCapturing: number;
91
+ stageName: string;
92
+ capturePercent: number;
93
+ }
94
+
95
+ export interface Pathing {
96
+ nodeList: NodeList | null;
97
+ followingPath: boolean;
98
+ activePath: any;
99
+ activeNode: any;
100
+ activeNodeIdx: number;
101
+ }
102
+
103
+ export interface BotState {
104
+ loggedIn: boolean;
105
+ gameFound: boolean;
106
+ reloading: boolean;
107
+ swappingGun: boolean;
108
+ usingMelee: boolean;
109
+ shotsFired: number;
110
+ joinedGame?: boolean;
111
+ }
112
+
113
+ export class Bot {
114
+ proxy: string;
115
+ name: string;
116
+ autoPing: boolean;
117
+ autoUpdate: boolean;
118
+ disablePathing: boolean;
119
+ pingInterval: number;
120
+ updateInterval: number;
121
+ instance: string;
122
+ state: BotState;
123
+ players: Record<string, GamePlayer>;
124
+ me: GamePlayer;
125
+ game: Game;
126
+ account: Account;
127
+ gameSocket: yolkws | null;
128
+ ping: number;
129
+ lastPingTime: number;
130
+ lastDeathTime: number;
131
+ lastChatTime: number;
132
+ lastUpdateTime: number;
133
+ nUpdates: number;
134
+ controlKeys: number;
135
+ initTime: number;
136
+ pathing: Pathing;
137
+ matchmaker: Matchmaker | null;
138
+
139
+ constructor(params?: BotParams);
140
+
141
+ login(email: string, pass: string): Promise<Account | false>;
142
+ dispatch(disp: any): void;
143
+ drain(): void;
144
+ initMatchmaker(): Promise<boolean>;
145
+ createPrivateGame(opts: { region: string; mode: string; map: string }): Promise<any>;
146
+ join(data: string | any): Promise<void>;
147
+ update(): void;
148
+ on(event: string, cb: Function): void;
149
+ onAny(cb: Function): void;
150
+ }
151
+
152
+ export default Bot;
@@ -0,0 +1,10 @@
1
+ export declare class BootPlayerDispatch {
2
+ uniqueId: string;
3
+
4
+ constructor(uniqueId: string);
5
+
6
+ check(bot: any): boolean;
7
+ execute(bot: any): void;
8
+ }
9
+
10
+ export default BootPlayerDispatch;
@@ -0,0 +1,10 @@
1
+ import packet from '#packet';
2
+
3
+ export declare class ChatDispatch {
4
+ constructor(msg: string, noLimit?: boolean);
5
+
6
+ check(bot: Bot): boolean;
7
+ execute(bot: Bot): void;
8
+ }
9
+
10
+ export default ChatDispatch;
@@ -0,0 +1,8 @@
1
+ export declare class FireDispatch {
2
+ constructor(amount: number);
3
+
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default FireDispatch;
@@ -0,0 +1,8 @@
1
+ import packet from '#packet';
2
+
3
+ export declare class GameOptionsDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default GameOptionsDispatch;
@@ -0,0 +1,10 @@
1
+ import AStar from '../pathing/astar.js';
2
+
3
+ export declare class GoToPlayerDispatch {
4
+ constructor(target: GamePlayer);
5
+
6
+ check(bot: Bot): boolean;
7
+ execute(bot: Bot): void;
8
+ }
9
+
10
+ export default GoToPlayerDispatch;
@@ -0,0 +1,8 @@
1
+ import AStar from '../pathing/astar.js';
2
+
3
+ export class GoToSpatulaDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default GoToSpatulaDispatch;
@@ -0,0 +1,14 @@
1
+ import Bot from '../bot';
2
+
3
+ declare class LookAtDispatch {
4
+ idOrName: number | string;
5
+ id?: number;
6
+ name?: string;
7
+
8
+ constructor(idOrName: number | string);
9
+
10
+ check(bot: Bot): boolean;
11
+ execute(bot: Bot): void;
12
+ }
13
+
14
+ export default LookAtDispatch;
@@ -0,0 +1,17 @@
1
+ type Position = {
2
+ x: number;
3
+ y: number;
4
+ z: number;
5
+ }
6
+
7
+ export declare class LookAtPosDispatch {
8
+ idOrName: any;
9
+ pos: Position;
10
+
11
+ constructor(pos: Position);
12
+
13
+ check(bot: Bot): boolean;
14
+ execute(bot: Bot): void;
15
+ }
16
+
17
+ export default LookAtPosDispatch;
@@ -0,0 +1,6 @@
1
+ export class MeleeDispatch {
2
+ check(bot: Bot): boolean;
3
+ execute(bot: Bot): void;
4
+ }
5
+
6
+ export default MeleeDispatch;
@@ -0,0 +1,10 @@
1
+ export class MovementDispatch {
2
+ controlKeys: number;
3
+
4
+ constructor(controlKeys: number | number[]);
5
+
6
+ check(bot: Bot): boolean;
7
+ execute(bot: Bot): void;
8
+ }
9
+
10
+ export default MovementDispatch;
@@ -0,0 +1,6 @@
1
+ export class PauseDispatch {
2
+ check(bot: Bot): boolean;
3
+ execute(bot: Bot): void;
4
+ }
5
+
6
+ export default PauseDispatch;
@@ -0,0 +1,6 @@
1
+ export class ReloadDispatch {
2
+ check(bot: Bot): boolean;
3
+ execute(bot: Bot): void;
4
+ }
5
+
6
+ export default ReloadDispatch;
@@ -0,0 +1,13 @@
1
+ export class ReportPlayerDispatch {
2
+ id?: number;
3
+ name?: string;
4
+ reasons: boolean[];
5
+ reasonInt: number;
6
+
7
+ constructor(idOrName: number | string, reasons?: { cheating?: boolean; harassment?: boolean; offensive?: boolean; other?: boolean });
8
+
9
+ check(bot: Bot): boolean;
10
+ execute(bot: Bot): void;
11
+ }
12
+
13
+ export default ReportPlayerDispatch;
@@ -0,0 +1,32 @@
1
+ type Changes = {
2
+ classIdx?: number;
3
+ hatId?: number;
4
+ stampId?: number;
5
+ grenadeId?: number;
6
+ meleeId?: number;
7
+ colorIdx?: number;
8
+ primaryId?: number[];
9
+ secondaryId?: number[];
10
+ }
11
+
12
+ type Opts = {
13
+ gunId?: number;
14
+ hatId?: number;
15
+ stampId?: number;
16
+ grenadeId?: number;
17
+ meleeId?: number;
18
+ eggColor?: number;
19
+ primaryIds?: number[];
20
+ secondaryIds?: number[];
21
+ }
22
+
23
+ export class SaveLoadoutDispatch {
24
+ changes: Changes;
25
+
26
+ constructor(opts: Opts);
27
+
28
+ check(bot: Bot): boolean;
29
+ execute(bot: Bot): void;
30
+ }
31
+
32
+ export default SaveLoadoutDispatch;
@@ -0,0 +1,6 @@
1
+ export class SpawnDispatch {
2
+ check(bot: Bot): boolean;
3
+ execute(bot: Bot): void;
4
+ }
5
+
6
+ export default SpawnDispatch;
@@ -0,0 +1,6 @@
1
+ export class SwapWeaponDispatch {
2
+ check(bot: Bot): boolean;
3
+ execute(bot: Bot): void;
4
+ }
5
+
6
+ export default SwapWeaponDispatch;
@@ -0,0 +1,6 @@
1
+ export class SwitchTeamDispatch {
2
+ check(bot: Bot): boolean;
3
+ execute(bot: Bot): void;
4
+ }
5
+
6
+ export default SwitchTeamDispatch;
@@ -0,0 +1,7 @@
1
+ export class ThrowGrenadeDispatch {
2
+ constructor(power?: number);
3
+ check(bot: Bot): boolean;
4
+ execute(bot: Bot): void;
5
+ }
6
+
7
+ export default ThrowGrenadeDispatch;