yolkbot 0.1.0-alpha.5 → 0.1.0-alpha.51

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 (60) hide show
  1. package/build/browser.js +6 -6
  2. package/package.json +27 -8
  3. package/src/api.js +97 -23
  4. package/src/bot/GamePlayer.js +3 -3
  5. package/src/bot.js +778 -404
  6. package/src/constants/index.js +23 -1
  7. package/src/constants/items.js +372 -173
  8. package/src/constants/maps.js +51 -12
  9. package/src/dispatches/BootPlayerDispatch.js +1 -1
  10. package/src/dispatches/ChatDispatch.js +1 -1
  11. package/src/dispatches/GameOptionsDispatch.js +1 -1
  12. package/src/dispatches/GoToAmmoDispatch.js +44 -0
  13. package/src/dispatches/GoToCoopDispatch.js +44 -0
  14. package/src/dispatches/GoToGrenadeDispatch.js +44 -0
  15. package/src/dispatches/GoToPlayerDispatch.js +5 -1
  16. package/src/dispatches/GoToSpatulaDispatch.js +5 -1
  17. package/src/dispatches/MeleeDispatch.js +1 -1
  18. package/src/dispatches/PauseDispatch.js +1 -1
  19. package/src/dispatches/ReloadDispatch.js +1 -1
  20. package/src/dispatches/ReportPlayerDispatch.js +1 -1
  21. package/src/dispatches/SaveLoadoutDispatch.js +11 -34
  22. package/src/dispatches/SpawnDispatch.js +1 -1
  23. package/src/dispatches/SwapWeaponDispatch.js +1 -1
  24. package/src/dispatches/SwitchTeamDispatch.js +1 -1
  25. package/src/dispatches/ThrowGrenadeDispatch.js +1 -1
  26. package/src/dispatches/index.js +14 -2
  27. package/src/matchmaker.js +11 -2
  28. package/src/pathing/mapnode.js +33 -4
  29. package/src/socket.js +1 -1
  30. package/src/types/api.d.ts +2 -16
  31. package/src/types/bot/GamePlayer.d.ts +87 -0
  32. package/src/types/bot.d.ts +118 -35
  33. package/src/types/constants/guns.d.ts +240 -0
  34. package/src/types/constants/index.d.ts +100 -0
  35. package/src/types/constants/items.d.ts +21 -0
  36. package/src/types/constants/maps.d.ts +15 -0
  37. package/src/types/dispatches/BootPlayerDispatch.d.ts +12 -0
  38. package/src/types/dispatches/ChatDispatch.d.ts +10 -0
  39. package/src/types/dispatches/FireDispatch.d.ts +10 -0
  40. package/src/types/dispatches/GameOptionsDispatch.d.ts +8 -0
  41. package/src/types/dispatches/GoToAmmoDispatch.d.ts +8 -0
  42. package/src/types/dispatches/GoToCoopDispatch.d.ts +8 -0
  43. package/src/types/dispatches/GoToGrenadeDispatch.d.ts +8 -0
  44. package/src/types/dispatches/GoToPlayerDispatch.d.ts +11 -0
  45. package/src/types/dispatches/GoToSpatulaDispatch.d.ts +8 -0
  46. package/src/types/dispatches/LookAtDispatch.d.ts +14 -0
  47. package/src/types/dispatches/LookAtPosDispatch.d.ts +19 -0
  48. package/src/types/dispatches/MeleeDispatch.d.ts +8 -0
  49. package/src/types/dispatches/MovementDispatch.d.ts +12 -0
  50. package/src/types/dispatches/PauseDispatch.d.ts +8 -0
  51. package/src/types/dispatches/ReloadDispatch.d.ts +8 -0
  52. package/src/types/dispatches/ReportPlayerDispatch.d.ts +22 -0
  53. package/src/types/dispatches/SaveLoadoutDispatch.d.ts +34 -0
  54. package/src/types/dispatches/SpawnDispatch.d.ts +8 -0
  55. package/src/types/dispatches/SwapWeaponDispatch.d.ts +8 -0
  56. package/src/types/dispatches/SwitchTeamDispatch.d.ts +8 -0
  57. package/src/types/dispatches/ThrowGrenadeDispatch.d.ts +10 -0
  58. package/src/types/dispatches/index.d.ts +174 -0
  59. package/src/types/matchmaker.d.ts +19 -14
  60. package/src/types/socket.d.ts +7 -0
@@ -0,0 +1,21 @@
1
+ export interface Item {
2
+ id: number;
3
+ name: string;
4
+ price: number;
5
+ item_type_id: 1 | 2 | 3 | 4 | 5 | 6 | 7;
6
+ item_type_name: 'Hat' | 'Stamp' | 'Primary' | 'Secondary' | 'Melee' | 'Grenade';
7
+ exclusive_for_class: null | 0 | 1 | 2 | 3 | 4 | 5 | 6;
8
+ item_data: {
9
+ meshName: string;
10
+ tags: string[];
11
+ };
12
+ is_available: boolean;
13
+ unlock: 'default' | 'purchase' | 'physical' | 'manual' | 'premium' | 'vip';
14
+ align: {
15
+ x: number;
16
+ y: number;
17
+ z: number;
18
+ };
19
+ }
20
+
21
+ export type Items = Item[];
@@ -0,0 +1,15 @@
1
+ export interface Map {
2
+ filename: string;
3
+ hash: string;
4
+ name: string;
5
+ modes: {
6
+ FFA: boolean;
7
+ Teams: boolean;
8
+ Spatula: boolean;
9
+ King?: boolean;
10
+ };
11
+ availability: string;
12
+ numPlayers: string;
13
+ }
14
+
15
+ export type Maps = Map[];
@@ -0,0 +1,12 @@
1
+ import Bot from '../bot';
2
+
3
+ export declare class BootPlayerDispatch {
4
+ uniqueId: string;
5
+
6
+ constructor(uniqueId: string);
7
+
8
+ check(bot: Bot): boolean;
9
+ execute(bot: Bot): void;
10
+ }
11
+
12
+ export default BootPlayerDispatch;
@@ -0,0 +1,10 @@
1
+ import Bot from '../bot';
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,10 @@
1
+ import Bot from '../bot';
2
+
3
+ export declare class FireDispatch {
4
+ constructor(amount: number);
5
+
6
+ check(bot: Bot): boolean;
7
+ execute(bot: Bot): void;
8
+ }
9
+
10
+ export default FireDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
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,8 @@
1
+ import Bot from '../bot';
2
+
3
+ export class GoToAmmoDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default GoToAmmoDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
2
+
3
+ export class GoToCoopDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default GoToCoopDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
2
+
3
+ export class GoToGrenadeDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default GoToGrenadeDispatch;
@@ -0,0 +1,11 @@
1
+ import Bot from '../bot';
2
+ import GamePlayer from '../bot/GamePlayer';
3
+
4
+ export declare class GoToPlayerDispatch {
5
+ constructor(target: GamePlayer);
6
+
7
+ check(bot: Bot): boolean;
8
+ execute(bot: Bot): void;
9
+ }
10
+
11
+ export default GoToPlayerDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
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,19 @@
1
+ import Bot from '../bot';
2
+
3
+ type Position = {
4
+ x: number;
5
+ y: number;
6
+ z: number;
7
+ }
8
+
9
+ export declare class LookAtPosDispatch {
10
+ idOrName: any;
11
+ pos: Position;
12
+
13
+ constructor(pos: Position);
14
+
15
+ check(bot: Bot): boolean;
16
+ execute(bot: Bot): void;
17
+ }
18
+
19
+ export default LookAtPosDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
2
+
3
+ export class MeleeDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default MeleeDispatch;
@@ -0,0 +1,12 @@
1
+ import Bot from '../bot';
2
+
3
+ export class MovementDispatch {
4
+ controlKeys: number;
5
+
6
+ constructor(controlKeys: number | number[]);
7
+
8
+ check(bot: Bot): boolean;
9
+ execute(bot: Bot): void;
10
+ }
11
+
12
+ export default MovementDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
2
+
3
+ export class PauseDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default PauseDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
2
+
3
+ export class ReloadDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default ReloadDispatch;
@@ -0,0 +1,22 @@
1
+ import Bot from '../bot';
2
+
3
+ type CheatingReasons = {
4
+ cheating?: boolean;
5
+ harassment?: boolean;
6
+ offensive?: boolean;
7
+ other?: boolean;
8
+ }
9
+
10
+ export class ReportPlayerDispatch {
11
+ id?: number;
12
+ name?: string;
13
+ reasons: boolean[];
14
+ reasonInt: number;
15
+
16
+ constructor(idOrName: number | string, reasons?: CheatingReasons);
17
+
18
+ check(bot: Bot): boolean;
19
+ execute(bot: Bot): void;
20
+ }
21
+
22
+ export default ReportPlayerDispatch;
@@ -0,0 +1,34 @@
1
+ import Bot from '../bot';
2
+
3
+ type Changes = {
4
+ classIdx?: number;
5
+ hatId?: number;
6
+ stampId?: number;
7
+ grenadeId?: number;
8
+ meleeId?: number;
9
+ colorIdx?: number;
10
+ primaryId?: number[];
11
+ secondaryId?: number[];
12
+ }
13
+
14
+ type Opts = {
15
+ gunId?: number;
16
+ hatId?: number;
17
+ stampId?: number;
18
+ grenadeId?: number;
19
+ meleeId?: number;
20
+ eggColor?: number;
21
+ primaryIds?: number[];
22
+ secondaryIds?: number[];
23
+ }
24
+
25
+ export class SaveLoadoutDispatch {
26
+ changes: Changes;
27
+
28
+ constructor(opts: Opts);
29
+
30
+ check(bot: Bot): boolean;
31
+ execute(bot: Bot): void;
32
+ }
33
+
34
+ export default SaveLoadoutDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
2
+
3
+ export class SpawnDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default SpawnDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
2
+
3
+ export class SwapWeaponDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default SwapWeaponDispatch;
@@ -0,0 +1,8 @@
1
+ import Bot from '../bot';
2
+
3
+ export class SwitchTeamDispatch {
4
+ check(bot: Bot): boolean;
5
+ execute(bot: Bot): void;
6
+ }
7
+
8
+ export default SwitchTeamDispatch;
@@ -0,0 +1,10 @@
1
+ import Bot from '../bot';
2
+
3
+ export class ThrowGrenadeDispatch {
4
+ constructor(power?: number);
5
+
6
+ check(bot: Bot): boolean;
7
+ execute(bot: Bot): void;
8
+ }
9
+
10
+ export default ThrowGrenadeDispatch;
@@ -0,0 +1,174 @@
1
+ import BootPlayerDispatch from './BootPlayerDispatch';
2
+ import ChatDispatch from './ChatDispatch';
3
+ import FireDispatch from './FireDispatch';
4
+ import GameOptionsDispatch from './GameOptionsDispatch';
5
+ import GoToAmmoDispatch from './GoToAmmoDispatch';
6
+ import GoToCoopDispatch from './GoToCoopDispatch';
7
+ import GoToGrenadeDispatch from './GoToGrenadeDispatch';
8
+ import GoToPlayerDispatch from './GoToPlayerDispatch';
9
+ import GoToSpatulaDispatch from './GoToSpatulaDispatch';
10
+ import LookAtDispatch from './LookAtDispatch';
11
+ import LookAtPosDispatch from './LookAtPosDispatch';
12
+ import MeleeDispatch from './MeleeDispatch';
13
+ import MovementDispatch from './MovementDispatch';
14
+ import PauseDispatch from './PauseDispatch';
15
+ import ReloadDispatch from './ReloadDispatch';
16
+ import ReportPlayerDispatch from './ReportPlayerDispatch';
17
+ import SaveLoadoutDispatch from './SaveLoadoutDispatch';
18
+ import SpawnDispatch from './SpawnDispatch';
19
+ import SwapWeaponDispatch from './SwapWeaponDispatch';
20
+ import SwitchTeamDispatch from './SwitchTeamDispatch';
21
+ import ThrowGrenadeDispatch from './ThrowGrenadeDispatch';
22
+
23
+ declare module 'BootPlayerDispatch' {
24
+ export default BootPlayerDispatch;
25
+ }
26
+
27
+ declare module 'ChatDispatch' {
28
+ export default ChatDispatch;
29
+ }
30
+
31
+ declare module 'FireDispatch' {
32
+ export default FireDispatch;
33
+ }
34
+
35
+ declare module 'GameOptionsDispatch' {
36
+ export default GameOptionsDispatch;
37
+ }
38
+
39
+ declare module 'GoToAmmoDispatch' {
40
+ export default GoToAmmoDispatch;
41
+ }
42
+
43
+ declare module 'GoToCoopDispatch' {
44
+ export default GoToCoopDispatch;
45
+ }
46
+
47
+ declare module 'GoToGrenadeDispatch' {
48
+ export default GoToGrenadeDispatch;
49
+ }
50
+
51
+ declare module 'GoToPlayerDispatch' {
52
+ export default GoToPlayerDispatch;
53
+ }
54
+
55
+ declare module 'GoToSpatulaDispatch' {
56
+ export default GoToSpatulaDispatch;
57
+ }
58
+
59
+ declare module 'LookAtDispatch' {
60
+ export default LookAtDispatch;
61
+ }
62
+
63
+ declare module 'LookAtPosDispatch' {
64
+ export default LookAtPosDispatch;
65
+ }
66
+
67
+ declare module 'MeleeDispatch' {
68
+ export default MeleeDispatch;
69
+ }
70
+
71
+ declare module 'MovementDispatch' {
72
+ export default MovementDispatch;
73
+ }
74
+
75
+ declare module 'PauseDispatch' {
76
+ export default PauseDispatch;
77
+ }
78
+
79
+ declare module 'ReloadDispatch' {
80
+ export default ReloadDispatch;
81
+ }
82
+
83
+ declare module 'ReportPlayerDispatch' {
84
+ export default ReportPlayerDispatch;
85
+ }
86
+
87
+ declare module 'SaveLoadoutDispatch' {
88
+ export default SaveLoadoutDispatch;
89
+ }
90
+
91
+ declare module 'SpawnDispatch' {
92
+ export default SpawnDispatch;
93
+ }
94
+
95
+ declare module 'SwapWeaponDispatch' {
96
+ export default SwapWeaponDispatch;
97
+ }
98
+
99
+ declare module 'SwitchTeamDispatch' {
100
+ export default SwitchTeamDispatch;
101
+ }
102
+
103
+ declare module 'dispatches' {
104
+ export {
105
+ BootPlayerDispatch,
106
+ ChatDispatch,
107
+ FireDispatch,
108
+ GameOptionsDispatch,
109
+ GoToAmmoDispatch,
110
+ GoToCoopDispatch,
111
+ GoToGreandeDispatch,
112
+ GoToPlayerDispatch,
113
+ GoToSpatulaDispatch,
114
+ LookAtDispatch,
115
+ LookAtPosDispatch,
116
+ MeleeDispatch,
117
+ MovementDispatch,
118
+ PauseDispatch,
119
+ ReloadDispatch,
120
+ ReportPlayerDispatch,
121
+ SaveLoadoutDispatch,
122
+ SpawnDispatch,
123
+ SwapWeaponDispatch,
124
+ SwitchTeamDispatch
125
+ }
126
+
127
+ const dispatches: {
128
+ BootPlayerDispatch: typeof BootPlayerDispatch,
129
+ ChatDispatch: typeof ChatDispatch,
130
+ FireDispatch: typeof FireDispatch,
131
+ GameOptionsDispatch: typeof GameOptionsDispatch,
132
+ GoToAmmoDispatch: typeof GoToAmmoDispatch,
133
+ GoToCoopDispatch: typeof GoToCoopDispatch,
134
+ GoToGrenadeDispatch: typeof GoToGrenadeDispatch,
135
+ GoToPlayerDispatch: typeof GoToPlayerDispatch,
136
+ GoToSpatulaDispatch: typeof GoToSpatulaDispatch,
137
+ LookAtDispatch: typeof LookAtDispatch,
138
+ LookAtPosDispatch: typeof LookAtPosDispatch,
139
+ MeleeDispatch: typeof MeleeDispatch,
140
+ MovementDispatch: typeof MovementDispatch,
141
+ PauseDispatch: typeof PauseDispatch,
142
+ ReloadDispatch: typeof ReloadDispatch,
143
+ ReportPlayerDispatch: typeof ReportPlayerDispatch,
144
+ SaveLoadoutDispatch: typeof SaveLoadoutDispatch,
145
+ SpawnDispatch: typeof SpawnDispatch,
146
+ SwapWeaponDispatch: typeof SwapWeaponDispatch,
147
+ SwitchTeamDispatch: typeof SwitchTeamDispatch
148
+ };
149
+
150
+ export default dispatches;
151
+ }
152
+
153
+ export type ADispatch =
154
+ BootPlayerDispatch |
155
+ ChatDispatch |
156
+ FireDispatch |
157
+ GameOptionsDispatch |
158
+ GoToAmmoDispatch |
159
+ GoToCoopDispatch |
160
+ GoToGrenadeDispatch |
161
+ GoToPlayerDispatch |
162
+ GoToSpatulaDispatch |
163
+ LookAtDispatch |
164
+ LookAtPosDispatch |
165
+ MeleeDispatch |
166
+ MovementDispatch |
167
+ PauseDispatch |
168
+ ReloadDispatch |
169
+ ReportPlayerDispatch |
170
+ SaveLoadoutDispatch |
171
+ SpawnDispatch |
172
+ SwapWeaponDispatch |
173
+ SwitchTeamDispatch |
174
+ ThrowGrenadeDispatch;
@@ -1,5 +1,5 @@
1
- import { GameModes, PlayTypes } from '../constants/index.js';
2
- import yolkws from '../socket.js';
1
+ import { GameModes, PlayTypes } from './constants/index.js';
2
+ import yolkws from './socket.js';
3
3
 
4
4
  type MatchmakerParams = {
5
5
  instance?: string;
@@ -17,16 +17,26 @@ type FindGameParams = {
17
17
  mode: keyof typeof GameModes;
18
18
  };
19
19
 
20
- type GameFoundResponse = {
21
- command: 'gameFound';
22
- [key: string]: any;
23
- };
24
-
25
20
  type RegionListResponse = {
26
21
  command: 'regionList';
27
22
  regionList: Region[];
28
23
  };
29
24
 
25
+ export interface RawGameData {
26
+ command: 'gameFound';
27
+ region: string;
28
+ subdomain: string;
29
+ id: string;
30
+ uuid: string;
31
+ private: boolean;
32
+ noobLobby: boolean;
33
+ }
34
+
35
+ type CommandSend = {
36
+ command: string;
37
+ [key: string]: any;
38
+ }
39
+
30
40
  export declare class Matchmaker {
31
41
  connected: boolean;
32
42
  onceConnected: Function[];
@@ -38,13 +48,10 @@ export declare class Matchmaker {
38
48
 
39
49
  constructor(params?: MatchmakerParams);
40
50
 
41
- private createSocket(instance: string): void;
42
- private createSessionId(instance: string): Promise<void>;
43
-
44
- send(msg: any): void;
51
+ send(msg: CommandSend): void;
45
52
  waitForConnect(): Promise<void>;
46
53
  getRegions(): Promise<Region[]>;
47
- findPublicGame(params: FindGameParams): Promise<GameFoundResponse>;
54
+ findPublicGame(params: FindGameParams): Promise<RawGameData>;
48
55
  getRandomRegion(): string;
49
56
  getRandomGameMode(): keyof typeof GameModes;
50
57
  close(): void;
@@ -52,8 +59,6 @@ export declare class Matchmaker {
52
59
  on(event: string, callback: Function): void;
53
60
  once(event: string, callback: Function): void;
54
61
  off(event: string, callback: Function): void;
55
-
56
- private emit(event: string, ...args: any[]): void;
57
62
  }
58
63
 
59
64
  export default Matchmaker;
@@ -0,0 +1,7 @@
1
+ import NodeWebSocket from 'ws';
2
+
3
+ declare class yolkws extends NodeWebSocket {
4
+ constructor(url: string, proxy: string);
5
+ }
6
+
7
+ export default yolkws;