yolkbot 0.1.0-alpha.5 → 0.1.0-alpha.7

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.5",
4
+ "version": "0.1.0-alpha.7",
5
5
  "keywords": [
6
6
  "shell shockers",
7
7
  "shellshock.io",
@@ -49,9 +49,18 @@
49
49
  "./constants": "./src/constants/index.js",
50
50
  "./constants/*": "./src/constants/*.js",
51
51
  "./constants/*.js": "./src/constants/*.js",
52
- "./dispatch": "./src/dispatches/index.js",
53
- "./dispatch/*": "./src/dispatches/*.js",
54
- "./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
+ }
55
64
  },
56
65
  "dependencies": {
57
66
  "socks-proxy-agent": "^8.0.5",
@@ -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,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;
@@ -1,10 +1,11 @@
1
1
  import { CommCode } from '../comm/Codes.js';
2
- import { GamePlayer } from '../bot/GamePlayer.js';
3
2
  import { Matchmaker } from '../matchmaker.js';
4
3
  import { yolkws } from '../socket.js';
5
4
  import { NodeList } from '../pathing/mapnode.js';
6
5
  import { Maps } from '../constants/maps.js';
7
6
 
7
+ import { GamePlayer } from './bot/GamePlayer.js';
8
+
8
9
  export interface BotParams {
9
10
  name?: string;
10
11
  proxy?: string;
@@ -51,8 +52,32 @@ export interface GameOptions {
51
52
  mustUseSecondary: boolean;
52
53
  }
53
54
 
55
+ export interface RawGameData {
56
+ command: 'gameFound';
57
+ region: string;
58
+ subdomain: string;
59
+ id: string;
60
+ uuid: string;
61
+ private: boolean;
62
+ noobLobby: boolean;
63
+ }
64
+
65
+ export interface RawMapData {
66
+ filename: string;
67
+ hash: string;
68
+ name: string;
69
+ modes: {
70
+ FFA: boolean;
71
+ Teams: boolean;
72
+ Spatula: boolean;
73
+ King?: boolean;
74
+ };
75
+ availability: string;
76
+ numPlayers: string;
77
+ }
78
+
54
79
  export interface Game {
55
- raw: any;
80
+ raw: RawGameData;
56
81
  code: string;
57
82
  gameModeId: number;
58
83
  gameMode: string;
@@ -69,7 +94,7 @@ export interface Game {
69
94
  };
70
95
  availability: string;
71
96
  numPlayers: string;
72
- raw: any;
97
+ raw: RawMapData;
73
98
  nodes: any;
74
99
  };
75
100
  playerLimit: number;
@@ -119,16 +144,11 @@ export class Bot {
119
144
  pingInterval: number;
120
145
  updateInterval: number;
121
146
  instance: string;
122
- _hooks: Record<string, Function[]>;
123
- _globalHooks: Function[];
124
- _liveCallbacks: Function[];
125
147
  state: BotState;
126
148
  players: Record<string, GamePlayer>;
127
149
  me: GamePlayer;
128
150
  game: Game;
129
151
  account: Account;
130
- _dispatches: any[];
131
- _packetQueue: any[];
132
152
  gameSocket: yolkws | null;
133
153
  ping: number;
134
154
  lastPingTime: number;
@@ -147,8 +167,8 @@ export class Bot {
147
167
  dispatch(disp: any): void;
148
168
  drain(): void;
149
169
  initMatchmaker(): Promise<boolean>;
150
- createPrivateGame(opts: { region: string; mode: string; map: string }): Promise<any>;
151
- join(data: string | any): Promise<void>;
170
+ createPrivateGame(opts: { region: string; mode: string; map: string }): Promise<RawGameData>;
171
+ join(data: string | RawGameData): Promise<void>;
152
172
  update(): void;
153
173
  on(event: string, cb: Function): void;
154
174
  onAny(cb: Function): void;
@@ -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;
@@ -0,0 +1,130 @@
1
+ import BootPlayerDispatch from './BootPlayerDispatch';
2
+ import ChatDispatch from './ChatDispatch';
3
+ import FireDispatch from './FireDispatch';
4
+ import GameOptionsDispatch from './GameOptionsDispatch';
5
+ import GoToPlayerDispatch from './GoToPlayerDispatch';
6
+ import GoToSpatulaDispatch from './GoToSpatulaDispatch';
7
+ import LookAtDispatch from './LookAtDispatch';
8
+ import LookAtPosDispatch from './LookAtPosDispatch';
9
+ import MeleeDispatch from './MeleeDispatch';
10
+ import MovementDispatch from './MovementDispatch';
11
+ import PauseDispatch from './PauseDispatch';
12
+ import ReloadDispatch from './ReloadDispatch';
13
+ import ReportPlayerDispatch from './ReportPlayerDispatch';
14
+ import SaveLoadoutDispatch from './SaveLoadoutDispatch';
15
+ import SpawnDispatch from './SpawnDispatch';
16
+ import SwapWeaponDispatch from './SwapWeaponDispatch';
17
+ import SwitchTeamDispatch from './SwitchTeamDispatch';
18
+ import ThrowGrenadeDispatch from './ThrowGrenadeDispatch';
19
+
20
+ declare module 'BootPlayerDispatch' {
21
+ export default BootPlayerDispatch;
22
+ }
23
+
24
+ declare module 'ChatDispatch' {
25
+ export default ChatDispatch;
26
+ }
27
+
28
+ declare module 'FireDispatch' {
29
+ export default FireDispatch;
30
+ }
31
+
32
+ declare module 'GameOptionsDispatch' {
33
+ export default GameOptionsDispatch;
34
+ }
35
+
36
+ declare module 'GoToPlayerDispatch' {
37
+ export default GoToPlayerDispatch;
38
+ }
39
+
40
+ declare module 'GoToSpatulaDispatch' {
41
+ export default GoToSpatulaDispatch;
42
+ }
43
+
44
+ declare module 'LookAtDispatch' {
45
+ export default LookAtDispatch;
46
+ }
47
+
48
+ declare module 'LookAtPosDispatch' {
49
+ export default LookAtPosDispatch;
50
+ }
51
+
52
+ declare module 'MeleeDispatch' {
53
+ export default MeleeDispatch;
54
+ }
55
+
56
+ declare module 'MovementDispatch' {
57
+ export default MovementDispatch;
58
+ }
59
+
60
+ declare module 'PauseDispatch' {
61
+ export default PauseDispatch;
62
+ }
63
+
64
+ declare module 'ReloadDispatch' {
65
+ export default ReloadDispatch;
66
+ }
67
+
68
+ declare module 'ReportPlayerDispatch' {
69
+ export default ReportPlayerDispatch;
70
+ }
71
+
72
+ declare module 'SaveLoadoutDispatch' {
73
+ export default SaveLoadoutDispatch;
74
+ }
75
+
76
+ declare module 'SpawnDispatch' {
77
+ export default SpawnDispatch;
78
+ }
79
+
80
+ declare module 'SwapWeaponDispatch' {
81
+ export default SwapWeaponDispatch;
82
+ }
83
+
84
+ declare module 'SwitchTeamDispatch' {
85
+ export default SwitchTeamDispatch;
86
+ }
87
+
88
+ declare module 'dispatches' {
89
+ export {
90
+ BootPlayerDispatch,
91
+ ChatDispatch,
92
+ FireDispatch,
93
+ GameOptionsDispatch,
94
+ GoToPlayerDispatch,
95
+ GoToSpatulaDispatch,
96
+ LookAtDispatch,
97
+ LookAtPosDispatch,
98
+ MeleeDispatch,
99
+ MovementDispatch,
100
+ PauseDispatch,
101
+ ReloadDispatch,
102
+ ReportPlayerDispatch,
103
+ SaveLoadoutDispatch,
104
+ SpawnDispatch,
105
+ SwapWeaponDispatch,
106
+ SwitchTeamDispatch
107
+ }
108
+
109
+ const dispatches: {
110
+ BootPlayerDispatch: typeof BootPlayerDispatch,
111
+ ChatDispatch: typeof ChatDispatch,
112
+ FireDispatch: typeof FireDispatch,
113
+ GameOptionsDispatch: typeof GameOptionsDispatch,
114
+ GoToPlayerDispatch: typeof GoToPlayerDispatch,
115
+ GoToSpatulaDispatch: typeof GoToSpatulaDispatch,
116
+ LookAtDispatch: typeof LookAtDispatch,
117
+ LookAtPosDispatch: typeof LookAtPosDispatch,
118
+ MeleeDispatch: typeof MeleeDispatch,
119
+ MovementDispatch: typeof MovementDispatch,
120
+ PauseDispatch: typeof PauseDispatch,
121
+ ReloadDispatch: typeof ReloadDispatch,
122
+ ReportPlayerDispatch: typeof ReportPlayerDispatch,
123
+ SaveLoadoutDispatch: typeof SaveLoadoutDispatch,
124
+ SpawnDispatch: typeof SpawnDispatch,
125
+ SwapWeaponDispatch: typeof SwapWeaponDispatch,
126
+ SwitchTeamDispatch: typeof SwitchTeamDispatch
127
+ };
128
+
129
+ export default dispatches;
130
+ }