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.
- package/README.md +2 -2
- package/browser/build/global.js +3 -0
- package/browser/build/module.js +3 -0
- package/package.json +11 -27
- package/src/api.js +56 -34
- package/src/bot/GamePlayer.js +18 -16
- package/src/bot.js +91 -37
- package/src/comm/Codes.js +1 -74
- package/src/comm/index.js +1 -1
- package/src/constants/codes.js +45 -0
- package/src/constants/guns.js +18 -2
- package/src/constants/index.js +11 -1
- package/src/constants/items.js +477 -88
- package/src/constants/maps.js +27 -14
- package/src/dispatches/BootPlayerDispatch.js +6 -2
- package/src/dispatches/ChatDispatch.js +7 -2
- package/src/dispatches/GameOptionsDispatch.js +20 -2
- package/src/dispatches/MeleeDispatch.js +6 -4
- package/src/dispatches/PauseDispatch.js +7 -3
- package/src/dispatches/ReloadDispatch.js +5 -2
- package/src/dispatches/ReportPlayerDispatch.js +7 -2
- package/src/dispatches/SaveLoadoutDispatch.js +11 -6
- package/src/dispatches/SpawnDispatch.js +5 -2
- package/src/dispatches/SwapWeaponDispatch.js +7 -2
- package/src/dispatches/SwitchTeamDispatch.js +5 -2
- package/src/dispatches/ThrowGrenadeDispatch.js +6 -2
- package/src/globals.js +15 -0
- package/src/matchmaker.js +13 -9
- package/src/pathing/astar.js +7 -25
- package/src/pathing/binaryheap.js +6 -6
- package/src/pathing/mapnode.js +4 -53
- package/src/socket.js +4 -10
- package/src/types/bot/GamePlayer.d.ts +39 -15
- package/src/types/bot.d.ts +1 -1
- package/src/types/constants/guns.d.ts +8 -0
- package/src/types/constants/index.d.ts +11 -1
- package/src/types/matchmaker.d.ts +8 -2
- package/build/browser.js +0 -8
- package/src/browser.js +0 -15
- package/src/dispatches/LookDispatch2.js +0 -18
- package/src/packet.js +0 -128
package/package.json
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yolkbot",
|
|
3
|
-
"description": "create a shell shockers
|
|
4
|
-
"version": "0.1.1
|
|
3
|
+
"description": "create a shell shockers bot in under 10 lines.",
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shell shockers",
|
|
7
7
|
"shellshock.io",
|
|
8
8
|
"blue wizard",
|
|
9
9
|
"yolkbot"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://github.com/
|
|
11
|
+
"homepage": "https://github.com/yolkorg/yolkbot#readme",
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/
|
|
13
|
+
"url": "https://github.com/yolkorg/yolkbot/issues"
|
|
14
14
|
},
|
|
15
|
-
"author": "
|
|
16
|
-
"contributors": [
|
|
17
|
-
"1ust"
|
|
18
|
-
],
|
|
15
|
+
"author": "1ust",
|
|
16
|
+
"contributors": ["hijinks"],
|
|
19
17
|
"repository": {
|
|
20
18
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/
|
|
19
|
+
"url": "git+https://github.com/yolkorg/yolkbot.git"
|
|
22
20
|
},
|
|
23
21
|
"type": "module",
|
|
24
22
|
"files": [
|
|
25
|
-
"build/*.js",
|
|
23
|
+
"browser/build/*.js",
|
|
26
24
|
"data/*.*",
|
|
27
25
|
"src/**/*",
|
|
28
26
|
"package.json",
|
|
@@ -35,13 +33,12 @@
|
|
|
35
33
|
"import": "./src/api.js",
|
|
36
34
|
"types": "./src/types/api.d.ts"
|
|
37
35
|
},
|
|
38
|
-
"./browser": "./build/
|
|
36
|
+
"./browser": "./browser/build/module.js",
|
|
39
37
|
"./comm": "./src/comm/index.js",
|
|
40
38
|
"./matchmaker": {
|
|
41
39
|
"import": "./src/matchmaker.js",
|
|
42
40
|
"types": "./src/types/matchmaker.d.ts"
|
|
43
41
|
},
|
|
44
|
-
"./packets": "./src/packet.js",
|
|
45
42
|
"./pathing/*": "./src/pathing/*.js",
|
|
46
43
|
"./pathing/*.js": "./src/pathing/*.js",
|
|
47
44
|
"./bot": {
|
|
@@ -82,8 +79,8 @@
|
|
|
82
79
|
}
|
|
83
80
|
},
|
|
84
81
|
"dependencies": {
|
|
85
|
-
"
|
|
86
|
-
"
|
|
82
|
+
"smallsocks": "^1.0.2",
|
|
83
|
+
"undici": "^7.7.0",
|
|
87
84
|
"ws": "^8.18.0"
|
|
88
85
|
},
|
|
89
86
|
"devDependencies": {
|
|
@@ -92,18 +89,5 @@
|
|
|
92
89
|
"esbuild": "^0.25.0",
|
|
93
90
|
"eslint": "^9.20.1",
|
|
94
91
|
"globals": "^15.15.0"
|
|
95
|
-
},
|
|
96
|
-
"scripts": {
|
|
97
|
-
"lint": "eslint --fix",
|
|
98
|
-
"prod": "./prod.sh",
|
|
99
|
-
"test": "./build.sh"
|
|
100
|
-
},
|
|
101
|
-
"imports": {
|
|
102
|
-
"#api": "./src/api.js",
|
|
103
|
-
"#bot": "./src/bot.js",
|
|
104
|
-
"#constants": "./src/constants/index.js",
|
|
105
|
-
"#dispatch/*": "./src/dispatches/*",
|
|
106
|
-
"#matchmaker": "./src/matchmaker.js",
|
|
107
|
-
"#packet": "./src/packet.js"
|
|
108
92
|
}
|
|
109
93
|
}
|
package/src/api.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import globals from './globals.js';
|
|
3
2
|
import yolkws from './socket.js';
|
|
4
3
|
|
|
5
|
-
import { FirebaseKey,
|
|
6
|
-
|
|
7
|
-
let SocksProxyAgent;
|
|
8
|
-
if (ProxiesEnabled) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
|
|
4
|
+
import { FirebaseKey, UserAgent } from './constants/index.js';
|
|
9
5
|
|
|
10
6
|
const queryServices = async (request, proxy = '', instance = 'shellshock.io') => {
|
|
11
7
|
let ws;
|
|
@@ -13,6 +9,11 @@ const queryServices = async (request, proxy = '', instance = 'shellshock.io') =>
|
|
|
13
9
|
const attempt = async () => {
|
|
14
10
|
try {
|
|
15
11
|
ws = new yolkws(`wss://${instance}/services/`, proxy);
|
|
12
|
+
ws.onerror = async (e) => {
|
|
13
|
+
console.error(e);
|
|
14
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
15
|
+
return await attempt();
|
|
16
|
+
}
|
|
16
17
|
} catch {
|
|
17
18
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
18
19
|
await attempt();
|
|
@@ -23,7 +24,7 @@ const queryServices = async (request, proxy = '', instance = 'shellshock.io') =>
|
|
|
23
24
|
|
|
24
25
|
return new Promise((resolve) => {
|
|
25
26
|
ws.onopen = () => {
|
|
26
|
-
|
|
27
|
+
ws.onerror = null;
|
|
27
28
|
ws.send(JSON.stringify(request));
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -51,11 +52,11 @@ const queryServices = async (request, proxy = '', instance = 'shellshock.io') =>
|
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
async function createAccount(email, password,
|
|
55
|
-
return await loginWithCredentials(email, password,
|
|
55
|
+
async function createAccount(email, password, proxy = '', instance = 'shellshock.io') {
|
|
56
|
+
return await loginWithCredentials(email, password, proxy, instance, true);
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
async function loginWithCredentials(email, password,
|
|
59
|
+
async function loginWithCredentials(email, password, proxy = '', instance = 'shellshock.io', _useRegisterEndpoint) {
|
|
59
60
|
if (!email || !password) return 'firebase_no_credentials';
|
|
60
61
|
|
|
61
62
|
/*
|
|
@@ -82,18 +83,24 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
|
|
|
82
83
|
|
|
83
84
|
while (!SUCCESS) {
|
|
84
85
|
try {
|
|
85
|
-
request = await
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
request = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${endpoint}?key=${FirebaseKey}`, {
|
|
87
|
+
method: 'POST',
|
|
88
|
+
body: JSON.stringify({
|
|
89
|
+
email: email,
|
|
90
|
+
password: password,
|
|
91
|
+
returnSecureToken: true
|
|
92
|
+
}),
|
|
90
93
|
headers: {
|
|
94
|
+
'content-type': 'application/json',
|
|
95
|
+
'origin': 'https://shellshock.io',
|
|
91
96
|
'user-agent': UserAgent,
|
|
92
|
-
'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web'
|
|
97
|
+
'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web',
|
|
98
|
+
'x-firebase-locale': 'en'
|
|
93
99
|
},
|
|
94
|
-
|
|
95
|
-
})
|
|
96
|
-
|
|
100
|
+
dispatcher: proxy ? new globals.ProxyAgent(proxy) : undefined
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
body = await request.json();
|
|
97
104
|
token = body.idToken;
|
|
98
105
|
SUCCESS = true;
|
|
99
106
|
} catch (error) {
|
|
@@ -102,6 +109,9 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
|
|
|
102
109
|
console.error('loginWithCredentials: Network req failed (auth/network-request-failed), retrying, k =', k);
|
|
103
110
|
} else if (error.code == 'auth/missing-email') {
|
|
104
111
|
return 'firebase_no_credentials';
|
|
112
|
+
} else if (error.code == 'ERR_BAD_REQUEST') {
|
|
113
|
+
console.error('loginWithCredentials: Error:', email, password);
|
|
114
|
+
console.error('loginWithCredentials: Error:', error.response?.data || error, 'k =', k);
|
|
105
115
|
} else {
|
|
106
116
|
console.error('loginWithCredentials: Error:', email, password);
|
|
107
117
|
console.error('loginWithCredentials: Error:', error, 'k =', k);
|
|
@@ -120,12 +130,12 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
|
|
|
120
130
|
const response = await queryServices({
|
|
121
131
|
cmd: 'auth',
|
|
122
132
|
firebaseToken: token
|
|
123
|
-
},
|
|
133
|
+
}, proxy, instance);
|
|
124
134
|
|
|
125
135
|
return response;
|
|
126
136
|
}
|
|
127
137
|
|
|
128
|
-
async function loginWithRefreshToken(refreshToken,
|
|
138
|
+
async function loginWithRefreshToken(refreshToken, proxy = '', instance = 'shellshock.io') {
|
|
129
139
|
if (!refreshToken) return 'firebase_no_credentials';
|
|
130
140
|
|
|
131
141
|
const formData = new URLSearchParams();
|
|
@@ -138,14 +148,20 @@ async function loginWithRefreshToken(refreshToken, prox = '', instance = 'shells
|
|
|
138
148
|
|
|
139
149
|
while (!SUCCESS) {
|
|
140
150
|
try {
|
|
141
|
-
request = await
|
|
151
|
+
request = await globals.fetch(`https://securetoken.googleapis.com/v1/token?key=${FirebaseKey}`, {
|
|
152
|
+
method: 'POST',
|
|
153
|
+
body: formData,
|
|
142
154
|
headers: {
|
|
155
|
+
'content-type': 'application/x-www-form-urlencoded',
|
|
156
|
+
'origin': 'https://shellshock.io',
|
|
143
157
|
'user-agent': UserAgent,
|
|
144
|
-
'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web'
|
|
158
|
+
'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web',
|
|
159
|
+
'x-firebase-locale': 'en'
|
|
145
160
|
},
|
|
146
|
-
|
|
147
|
-
})
|
|
148
|
-
|
|
161
|
+
dispatcher: proxy ? new globals.ProxyAgent(proxy) : undefined
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
body = await request.json();
|
|
149
165
|
token = body.id_token;
|
|
150
166
|
SUCCESS = true;
|
|
151
167
|
} catch (error) {
|
|
@@ -172,22 +188,28 @@ async function loginWithRefreshToken(refreshToken, prox = '', instance = 'shells
|
|
|
172
188
|
const response = await queryServices({
|
|
173
189
|
cmd: 'auth',
|
|
174
190
|
firebaseToken: token
|
|
175
|
-
},
|
|
191
|
+
}, proxy, instance);
|
|
176
192
|
|
|
177
193
|
return response;
|
|
178
194
|
}
|
|
179
195
|
|
|
180
|
-
async function loginAnonymously(
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
196
|
+
async function loginAnonymously(proxy = '', instance = 'shellshock.io') {
|
|
197
|
+
const req = await globals.fetch('https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=' + FirebaseKey, {
|
|
198
|
+
method: 'POST',
|
|
199
|
+
body: JSON.stringify({
|
|
200
|
+
returnSecureToken: true
|
|
201
|
+
}),
|
|
184
202
|
headers: {
|
|
203
|
+
'content-type': 'application/json',
|
|
204
|
+
'origin': 'https://shellshock.io',
|
|
185
205
|
'user-agent': UserAgent,
|
|
186
|
-
'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web'
|
|
206
|
+
'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web',
|
|
207
|
+
'x-firebase-locale': 'en'
|
|
187
208
|
},
|
|
188
|
-
|
|
209
|
+
dispatcher: proxy ? new globals.ProxyAgent(proxy) : undefined
|
|
189
210
|
});
|
|
190
211
|
|
|
212
|
+
const body = await req.json();
|
|
191
213
|
const token = body.idToken;
|
|
192
214
|
|
|
193
215
|
if (!token) {
|
|
@@ -198,7 +220,7 @@ async function loginAnonymously(prox = '', instance = 'shellshock.io') {
|
|
|
198
220
|
const response = await queryServices({
|
|
199
221
|
cmd: 'auth',
|
|
200
222
|
firebaseToken: token
|
|
201
|
-
},
|
|
223
|
+
}, proxy, instance);
|
|
202
224
|
|
|
203
225
|
return response;
|
|
204
226
|
}
|
package/src/bot/GamePlayer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GunList } from '
|
|
1
|
+
import { GunList, ShellStreaks, SocialMedias } from '../constants/index.js';
|
|
2
2
|
import { Cluck9mm } from '../constants/guns.js';
|
|
3
3
|
|
|
4
4
|
export class GamePlayer {
|
|
@@ -6,28 +6,31 @@ export class GamePlayer {
|
|
|
6
6
|
this.id = id;
|
|
7
7
|
this.team = team;
|
|
8
8
|
|
|
9
|
-
this.
|
|
9
|
+
this.raw = playerData;
|
|
10
10
|
|
|
11
11
|
this.name = playerData.name_;
|
|
12
12
|
this.uniqueId = playerData.uniqueId_;
|
|
13
13
|
|
|
14
14
|
this.playing = playerData.playing_;
|
|
15
15
|
|
|
16
|
-
this.
|
|
16
|
+
this.socials = playerData.social_ && JSON.parse(playerData.social_);
|
|
17
|
+
if (this.socials) this.socials.forEach((social) => social.type = SocialMedias[social.id]);
|
|
18
|
+
|
|
19
|
+
this.isVip = playerData.upgradeProductId_ > 0;
|
|
17
20
|
this.showBadge = !playerData.hideBadge_ || false;
|
|
18
21
|
|
|
19
22
|
this.position = {
|
|
20
|
-
x:
|
|
21
|
-
y:
|
|
22
|
-
z:
|
|
23
|
+
x: playerData.x_,
|
|
24
|
+
y: playerData.y_,
|
|
25
|
+
z: playerData.z_
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
this.jumping = false;
|
|
26
29
|
this.climbing = false;
|
|
27
30
|
|
|
28
31
|
this.view = {
|
|
29
|
-
yaw:
|
|
30
|
-
pitch:
|
|
32
|
+
yaw: playerData.yaw_,
|
|
33
|
+
pitch: playerData.pitch_
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
this.character = {
|
|
@@ -40,15 +43,14 @@ export class GamePlayer {
|
|
|
40
43
|
melee: playerData.meleeItem_
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
this.activeGun =
|
|
46
|
+
this.activeGun = playerData.weaponIdx_;
|
|
44
47
|
this.selectedGun = 0;
|
|
45
48
|
this.weapons = [{}, {}];
|
|
46
49
|
|
|
47
50
|
if (this.character.primaryGun) {
|
|
48
|
-
|
|
49
|
-
this.selectedGun = this.character.primaryGun.exclusive_for_class;
|
|
51
|
+
this.selectedGun = playerData.charClass_;
|
|
50
52
|
|
|
51
|
-
this.weapons[0] = new
|
|
53
|
+
this.weapons[0] = new GunList[this.selectedGun]();
|
|
52
54
|
this.weapons[1] = new Cluck9mm();
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -60,11 +62,11 @@ export class GamePlayer {
|
|
|
60
62
|
2: {}
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
this.
|
|
64
|
-
this.hp =
|
|
65
|
+
this.streak = playerData.score_;
|
|
66
|
+
this.hp = playerData.hp_;
|
|
65
67
|
|
|
66
|
-
this.hpShield =
|
|
67
|
-
this.streakRewards =
|
|
68
|
+
this.hpShield = playerData.shield_;
|
|
69
|
+
this.streakRewards = Object.values(ShellStreaks).filter(streak => playerData.activeShellStreaks_ & streak);
|
|
68
70
|
|
|
69
71
|
this.randomSeed = 0;
|
|
70
72
|
this.serverStateIdx = 0;
|