yolkbot 0.1.0 → 0.1.1-alpha.2
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/build/browser.js +5 -5
- package/package.json +1 -1
- package/src/bot.js +78 -36
- package/src/constants/challenges.js +1822 -0
- package/src/dispatches/LookAtPosDispatch.js +0 -2
- package/src/dispatches/LookDispatch2.js +18 -0
- package/src/dispatches/SaveLoadoutDispatch.js +1 -1
- package/src/types/bot.d.ts +45 -1
- package/src/types/constants/challenges.d.ts +19 -0
package/package.json
CHANGED
package/src/bot.js
CHANGED
|
@@ -41,7 +41,8 @@ const intents = {
|
|
|
41
41
|
BUFFERS: 4,
|
|
42
42
|
PING: 5,
|
|
43
43
|
COSMETIC_DATA: 6,
|
|
44
|
-
PLAYER_HEALTH: 7
|
|
44
|
+
PLAYER_HEALTH: 7,
|
|
45
|
+
PACKET_HOOK: 8
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
export class Bot {
|
|
@@ -249,7 +250,7 @@ export class Bot {
|
|
|
249
250
|
this.account.password = pass;
|
|
250
251
|
|
|
251
252
|
const loginData = await createAccount(email, pass, this.proxy, this.instance);
|
|
252
|
-
return this.#processLoginData(loginData);
|
|
253
|
+
return await this.#processLoginData(loginData);
|
|
253
254
|
}
|
|
254
255
|
|
|
255
256
|
async login(email, pass) {
|
|
@@ -257,12 +258,12 @@ export class Bot {
|
|
|
257
258
|
this.account.password = pass;
|
|
258
259
|
|
|
259
260
|
const loginData = await loginWithCredentials(email, pass, this.proxy, this.instance);
|
|
260
|
-
return this.#processLoginData(loginData);
|
|
261
|
+
return await this.#processLoginData(loginData);
|
|
261
262
|
}
|
|
262
263
|
|
|
263
264
|
async loginWithRefreshToken(refreshToken) {
|
|
264
265
|
const loginData = await loginWithRefreshToken(refreshToken, this.proxy, this.instance);
|
|
265
|
-
return this.#processLoginData(loginData);
|
|
266
|
+
return await this.#processLoginData(loginData);
|
|
266
267
|
}
|
|
267
268
|
|
|
268
269
|
async loginAnonymously() {
|
|
@@ -270,10 +271,10 @@ export class Bot {
|
|
|
270
271
|
delete this.account.password;
|
|
271
272
|
|
|
272
273
|
const loginData = await loginAnonymously(this.proxy, this.instance);
|
|
273
|
-
return this.#processLoginData(loginData);
|
|
274
|
+
return await this.#processLoginData(loginData);
|
|
274
275
|
}
|
|
275
276
|
|
|
276
|
-
#processLoginData(loginData) {
|
|
277
|
+
async #processLoginData(loginData) {
|
|
277
278
|
if (typeof loginData == 'string') {
|
|
278
279
|
this.emit('authFail', loginData);
|
|
279
280
|
return false;
|
|
@@ -297,6 +298,29 @@ export class Bot {
|
|
|
297
298
|
this.account.sessionId = loginData.sessionId;
|
|
298
299
|
this.account.vip = loginData.upgradeProductId && !loginData.upgradeIsExpired;
|
|
299
300
|
|
|
301
|
+
if (this.intents.includes(this.Intents.STATS)) this.account.stats = {
|
|
302
|
+
lifetime: loginData.statsLifetime,
|
|
303
|
+
monthly: loginData.statsCurrent
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
if (this.intents.includes(this.Intents.CHALLENGES)) {
|
|
307
|
+
this.account.challenges = [];
|
|
308
|
+
|
|
309
|
+
const { Challenges } = await import('./constants/challenges.js');
|
|
310
|
+
|
|
311
|
+
for (const challenge of loginData.challenges) {
|
|
312
|
+
const challengeData = Challenges.find(c => c.id == challenge.challengeId);
|
|
313
|
+
if (!challengeData) continue;
|
|
314
|
+
|
|
315
|
+
delete challenge.playerId;
|
|
316
|
+
|
|
317
|
+
this.account.challenges.push({
|
|
318
|
+
...challengeData,
|
|
319
|
+
...challenge
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
300
324
|
return this.account;
|
|
301
325
|
}
|
|
302
326
|
|
|
@@ -1476,9 +1500,28 @@ export class Bot {
|
|
|
1476
1500
|
}
|
|
1477
1501
|
}
|
|
1478
1502
|
|
|
1503
|
+
#processChallengeCompletePacket() {
|
|
1504
|
+
const id = CommIn.unPackInt8U();
|
|
1505
|
+
const challengeId = CommIn.unPackInt8U();
|
|
1506
|
+
|
|
1507
|
+
const player = this.players[id];
|
|
1508
|
+
if (!player) return;
|
|
1509
|
+
|
|
1510
|
+
if (!this.intents.includes(this.Intents.CHALLENGES))
|
|
1511
|
+
return this.emit('challengeComplete', player, challengeId);
|
|
1512
|
+
|
|
1513
|
+
const challenge = this.account.challenges.find(c => c.id == challengeId);
|
|
1514
|
+
this.emit('challengeComplete', player, challenge);
|
|
1515
|
+
|
|
1516
|
+
if (player.id == this.me.id) this.refreshChallenges();
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1479
1519
|
#handlePacket(packet) {
|
|
1480
1520
|
CommIn.init(packet);
|
|
1481
1521
|
|
|
1522
|
+
if (this.intents.includes(this.Intents.PACKET_HOOK))
|
|
1523
|
+
this.emit('packet', packet);
|
|
1524
|
+
|
|
1482
1525
|
let lastCommand = 0;
|
|
1483
1526
|
let abort = false;
|
|
1484
1527
|
|
|
@@ -1487,91 +1530,91 @@ export class Bot {
|
|
|
1487
1530
|
|
|
1488
1531
|
switch (cmd) {
|
|
1489
1532
|
case CommCode.syncThem:
|
|
1490
|
-
this.#processSyncThemPacket(
|
|
1533
|
+
this.#processSyncThemPacket();
|
|
1491
1534
|
break;
|
|
1492
1535
|
|
|
1493
1536
|
case CommCode.fire:
|
|
1494
|
-
this.#processFirePacket(
|
|
1537
|
+
this.#processFirePacket();
|
|
1495
1538
|
break;
|
|
1496
1539
|
|
|
1497
1540
|
case CommCode.hitThem:
|
|
1498
|
-
this.#processHitThemPacket(
|
|
1541
|
+
this.#processHitThemPacket();
|
|
1499
1542
|
break;
|
|
1500
1543
|
|
|
1501
1544
|
case CommCode.syncMe:
|
|
1502
|
-
this.#processSyncMePacket(
|
|
1545
|
+
this.#processSyncMePacket();
|
|
1503
1546
|
break;
|
|
1504
1547
|
|
|
1505
1548
|
case CommCode.hitMe:
|
|
1506
|
-
this.#processHitMePacket(
|
|
1549
|
+
this.#processHitMePacket();
|
|
1507
1550
|
break;
|
|
1508
1551
|
|
|
1509
1552
|
case CommCode.swapWeapon:
|
|
1510
|
-
this.#processSwapWeaponPacket(
|
|
1553
|
+
this.#processSwapWeaponPacket();
|
|
1511
1554
|
break;
|
|
1512
1555
|
|
|
1513
1556
|
case CommCode.collectItem:
|
|
1514
|
-
this.#processCollectPacket(
|
|
1557
|
+
this.#processCollectPacket();
|
|
1515
1558
|
break;
|
|
1516
1559
|
|
|
1517
1560
|
case CommCode.respawn:
|
|
1518
|
-
this.#processRespawnPacket(
|
|
1561
|
+
this.#processRespawnPacket();
|
|
1519
1562
|
break;
|
|
1520
1563
|
|
|
1521
1564
|
case CommCode.die:
|
|
1522
|
-
this.#processDeathPacket(
|
|
1565
|
+
this.#processDeathPacket();
|
|
1523
1566
|
break;
|
|
1524
1567
|
|
|
1525
1568
|
case CommCode.pause:
|
|
1526
|
-
this.#processPausePacket(
|
|
1569
|
+
this.#processPausePacket();
|
|
1527
1570
|
break;
|
|
1528
1571
|
|
|
1529
1572
|
case CommCode.chat:
|
|
1530
|
-
this.#processChatPacket(
|
|
1573
|
+
this.#processChatPacket();
|
|
1531
1574
|
break;
|
|
1532
1575
|
|
|
1533
1576
|
case CommCode.addPlayer:
|
|
1534
|
-
this.#processAddPlayerPacket(
|
|
1577
|
+
this.#processAddPlayerPacket();
|
|
1535
1578
|
break;
|
|
1536
1579
|
|
|
1537
1580
|
case CommCode.removePlayer:
|
|
1538
|
-
this.#processRemovePlayerPacket(
|
|
1581
|
+
this.#processRemovePlayerPacket();
|
|
1539
1582
|
break;
|
|
1540
1583
|
|
|
1541
1584
|
case CommCode.eventModifier:
|
|
1542
|
-
this.#processEventModifierPacket(
|
|
1585
|
+
this.#processEventModifierPacket();
|
|
1543
1586
|
break;
|
|
1544
1587
|
|
|
1545
1588
|
case CommCode.metaGameState:
|
|
1546
|
-
this.#processGameStatePacket(
|
|
1589
|
+
this.#processGameStatePacket();
|
|
1547
1590
|
break;
|
|
1548
1591
|
|
|
1549
1592
|
case CommCode.beginShellStreak:
|
|
1550
|
-
this.#processBeginStreakPacket(
|
|
1593
|
+
this.#processBeginStreakPacket();
|
|
1551
1594
|
break;
|
|
1552
1595
|
|
|
1553
1596
|
case CommCode.endShellStreak:
|
|
1554
|
-
this.#processEndStreakPacket(
|
|
1597
|
+
this.#processEndStreakPacket();
|
|
1555
1598
|
break;
|
|
1556
1599
|
|
|
1557
1600
|
case CommCode.hitMeHardBoiled:
|
|
1558
|
-
this.#processHitShieldPacket(
|
|
1601
|
+
this.#processHitShieldPacket();
|
|
1559
1602
|
break;
|
|
1560
1603
|
|
|
1561
1604
|
case CommCode.gameOptions:
|
|
1562
|
-
this.#processGameOptionsPacket(
|
|
1605
|
+
this.#processGameOptionsPacket();
|
|
1563
1606
|
break;
|
|
1564
1607
|
|
|
1565
1608
|
case CommCode.ping:
|
|
1566
|
-
this.#processPingPacket(
|
|
1609
|
+
this.#processPingPacket();
|
|
1567
1610
|
break;
|
|
1568
1611
|
|
|
1569
1612
|
case CommCode.switchTeam:
|
|
1570
|
-
this.#processSwitchTeamPacket(
|
|
1613
|
+
this.#processSwitchTeamPacket();
|
|
1571
1614
|
break;
|
|
1572
1615
|
|
|
1573
1616
|
case CommCode.changeCharacter:
|
|
1574
|
-
this.#processChangeCharacterPacket(
|
|
1617
|
+
this.#processChangeCharacterPacket();
|
|
1575
1618
|
break;
|
|
1576
1619
|
|
|
1577
1620
|
case CommCode.reload:
|
|
@@ -1595,11 +1638,15 @@ export class Bot {
|
|
|
1595
1638
|
break;
|
|
1596
1639
|
|
|
1597
1640
|
case CommCode.updateBalance:
|
|
1598
|
-
this.#processUpdateBalancePacket(
|
|
1641
|
+
this.#processUpdateBalancePacket();
|
|
1642
|
+
break;
|
|
1643
|
+
|
|
1644
|
+
case CommCode.challengeCompleted:
|
|
1645
|
+
this.#processChallengeCompletePacket();
|
|
1599
1646
|
break;
|
|
1600
1647
|
|
|
1601
1648
|
case CommCode.gameAction:
|
|
1602
|
-
this.#processGameActionPacket(
|
|
1649
|
+
this.#processGameActionPacket();
|
|
1603
1650
|
break;
|
|
1604
1651
|
|
|
1605
1652
|
case CommCode.requestGameOptions:
|
|
@@ -1607,7 +1654,7 @@ export class Bot {
|
|
|
1607
1654
|
break;
|
|
1608
1655
|
|
|
1609
1656
|
case CommCode.respawnDenied:
|
|
1610
|
-
this.#processRespawnDeniedPacket(
|
|
1657
|
+
this.#processRespawnDeniedPacket();
|
|
1611
1658
|
break;
|
|
1612
1659
|
|
|
1613
1660
|
// we do not plan to implement these
|
|
@@ -1620,11 +1667,6 @@ export class Bot {
|
|
|
1620
1667
|
CommIn.unPackLongString();
|
|
1621
1668
|
break;
|
|
1622
1669
|
|
|
1623
|
-
case CommCode.challengeCompleted:
|
|
1624
|
-
CommIn.unPackInt8U();
|
|
1625
|
-
CommIn.unPackInt8U();
|
|
1626
|
-
break;
|
|
1627
|
-
|
|
1628
1670
|
default:
|
|
1629
1671
|
console.error(`handlePacket: I got but did not handle a: ${Object.keys(CommCode).find(k => CommCode[k] === cmd)}`);
|
|
1630
1672
|
if (lastCommand) console.error(`handlePacket: It may be a result of the ${lastCommand} command.`);
|