yolkbot 1.4.7 → 1.5.0
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 +1 -1
- package/browser/build/global.js +1 -1
- package/browser/build/module.js +1 -1
- package/dist/api.d.ts +34 -16
- package/dist/api.js +164 -121
- package/dist/bot/GamePlayer.d.ts +2 -2
- package/dist/bot/GamePlayer.js +15 -5
- package/dist/bot.d.ts +121 -83
- package/dist/bot.js +624 -1077
- package/dist/comm/CommIn.js +14 -17
- package/dist/comm/CommOut.js +15 -15
- package/dist/constants/CommCode.js +1 -1
- package/dist/constants/findItemById.js +2 -1
- package/dist/constants/guns.d.ts +16 -41
- package/dist/constants/guns.js +137 -259
- package/dist/constants/index.d.ts +7 -9
- package/dist/constants/index.js +15 -13
- package/dist/dispatches/BanPlayerDispatch.d.ts +3 -1
- package/dist/dispatches/BootPlayerDispatch.d.ts +3 -1
- package/dist/dispatches/ChatDispatch.d.ts +3 -1
- package/dist/dispatches/ChatDispatch.js +3 -3
- package/dist/dispatches/FireDispatch.d.ts +3 -1
- package/dist/dispatches/GameOptionsDispatch.d.ts +3 -1
- package/dist/dispatches/GoToAmmoDispatch.d.ts +2 -0
- package/dist/dispatches/GoToAmmoDispatch.js +15 -16
- package/dist/dispatches/GoToCoopDispatch.d.ts +2 -0
- package/dist/dispatches/GoToCoopDispatch.js +19 -20
- package/dist/dispatches/GoToGrenadeDispatch.d.ts +2 -0
- package/dist/dispatches/GoToGrenadeDispatch.js +15 -16
- package/dist/dispatches/GoToPlayerDispatch.d.ts +3 -1
- package/dist/dispatches/GoToPlayerDispatch.js +16 -21
- package/dist/dispatches/GoToSpatulaDispatch.d.ts +2 -0
- package/dist/dispatches/GoToSpatulaDispatch.js +11 -14
- package/dist/dispatches/LookAtDispatch.d.ts +3 -1
- package/dist/dispatches/LookAtDispatch.js +8 -6
- package/dist/dispatches/LookAtPosDispatch.d.ts +3 -1
- package/dist/dispatches/LookAtPosDispatch.js +1 -1
- package/dist/dispatches/MeleeDispatch.d.ts +2 -0
- package/dist/dispatches/MeleeDispatch.js +4 -4
- package/dist/dispatches/MovementDispatch.d.ts +3 -1
- package/dist/dispatches/MovementDispatch.js +1 -1
- package/dist/dispatches/PauseDispatch.d.ts +2 -0
- package/dist/dispatches/ReloadDispatch.d.ts +2 -0
- package/dist/dispatches/ReloadDispatch.js +17 -10
- package/dist/dispatches/ReportPlayerDispatch.d.ts +4 -2
- package/dist/dispatches/ReportPlayerDispatch.js +8 -6
- package/dist/dispatches/ResetGameDispatch.d.ts +2 -0
- package/dist/dispatches/SaveLoadoutDispatch.d.ts +4 -2
- package/dist/dispatches/SaveLoadoutDispatch.js +9 -8
- package/dist/dispatches/SpawnDispatch.d.ts +2 -0
- package/dist/dispatches/SpawnDispatch.js +5 -1
- package/dist/dispatches/SwapWeaponDispatch.d.ts +3 -1
- package/dist/dispatches/SwapWeaponDispatch.js +1 -1
- package/dist/dispatches/SwitchTeamDispatch.d.ts +2 -0
- package/dist/dispatches/SwitchTeamDispatch.js +2 -1
- package/dist/dispatches/ThrowGrenadeDispatch.d.ts +3 -1
- package/dist/dispatches/index.d.ts +105 -182
- package/dist/dispatches/index.js +24 -25
- package/dist/enums.d.ts +154 -0
- package/dist/enums.js +114 -0
- package/dist/env/fetch.d.ts +15 -0
- package/dist/env/fetch.js +113 -79
- package/dist/env/globals.d.ts +9 -0
- package/dist/env/globals.js +11 -9
- package/dist/index.d.ts +31 -0
- package/dist/index.js +24 -14
- package/dist/packets/addPlayer.js +63 -0
- package/dist/packets/beginShellStreak.js +44 -0
- package/dist/packets/challengeCompleted.js +16 -0
- package/dist/packets/changeCharacter.js +46 -0
- package/dist/packets/chat.js +10 -0
- package/dist/packets/collectItem.js +26 -0
- package/dist/packets/die.js +40 -0
- package/dist/packets/endShellStreak.js +21 -0
- package/dist/packets/eventModifier.js +8 -0
- package/dist/packets/explode.js +19 -0
- package/dist/packets/fire.js +21 -0
- package/dist/packets/gameAction.js +33 -0
- package/dist/packets/gameJoined.js +64 -0
- package/dist/packets/gameOptions.js +27 -0
- package/dist/packets/hitMe.js +12 -0
- package/dist/packets/hitMeHardBoiled.js +18 -0
- package/dist/packets/hitThem.js +12 -0
- package/dist/packets/melee.js +8 -0
- package/dist/packets/metaGameState.js +62 -0
- package/dist/packets/pause.js +17 -0
- package/dist/packets/ping.js +19 -0
- package/dist/packets/playerInfo.js +15 -0
- package/dist/packets/reload.js +17 -0
- package/dist/packets/removePlayer.js +10 -0
- package/dist/packets/respawn.js +31 -0
- package/dist/packets/socketReady.js +16 -0
- package/dist/packets/spawnItem.js +11 -0
- package/dist/packets/swapWeapon.js +11 -0
- package/dist/packets/switchTeam.js +13 -0
- package/dist/packets/syncMe.js +25 -0
- package/dist/packets/syncThem.js +63 -0
- package/dist/packets/throwGrenade.js +17 -0
- package/dist/packets/updateBalance.js +8 -0
- package/dist/pathing/astar.js +33 -20
- package/dist/pathing/mapnode.d.ts +3 -1
- package/dist/pathing/mapnode.js +170 -65
- package/dist/socket.d.ts +21 -6
- package/dist/socket.js +48 -38
- package/dist/util.d.ts +4 -1
- package/dist/util.js +105 -45
- package/dist/wasm/bytes.d.ts +1 -1
- package/dist/wasm/bytes.js +1 -1
- package/dist/wasm/direct.d.ts +1 -1
- package/dist/wasm/direct.js +13 -13
- package/dist/wasm/legacy.d.ts +7 -6
- package/dist/wasm/legacy.js +14 -8
- package/package.json +43 -30
- package/dist/comm/index.d.ts +0 -12
- package/dist/comm/index.js +0 -11
- package/dist/constants/changelog.d.ts +0 -7
- package/dist/constants/housePromo.d.ts +0 -40
- package/dist/constants/language.d.ts +0 -3
- package/dist/constants/notices.d.ts +0 -4
- package/dist/constants/shellNews.d.ts +0 -12
- package/dist/constants/shellYoutube.d.ts +0 -12
- package/dist/constants/shopItems.d.ts +0 -15
- package/dist/constants/sounds.d.ts +0 -10
- package/dist/matchmaker.d.ts +0 -50
- package/dist/matchmaker.js +0 -141
- package/dist/pathing/binaryheap.d.ts +0 -18
- package/dist/pathing/binaryheap.js +0 -79
- package/dist/wasm/util.d.ts +0 -9
- package/dist/wasm/util.js +0 -19
package/dist/constants/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AUG, CSG1, DozenGauge, Eggk47, M24, RPEGG, SMG } from "./guns.js";
|
|
1
|
+
import { AUG, CSG1, DozenGauge, EggK47, M24, RPEGG, SMG } from "./guns.js";
|
|
3
2
|
export { findItemById } from "./findItemById.js";
|
|
4
3
|
export const BanDuration = {
|
|
5
4
|
FiveMinutes: 0,
|
|
@@ -54,7 +53,8 @@ export const CoopState = {
|
|
|
54
53
|
Abandoned: 6,
|
|
55
54
|
Unclaimed: 7
|
|
56
55
|
};
|
|
57
|
-
|
|
56
|
+
const miniCodec = (s, k = 42) => s.split("").map((c) => String.fromCharCode(c.charCodeAt(0) ^ k)).join("");
|
|
57
|
+
export const FirebaseKey = miniCodec("kcPKySnz\x1Eyc@aK]\x1Ck\x1EI\x07P\\LsRciZHo@D\x1BXxDd\x1F\x1A");
|
|
58
58
|
export const FramesBetweenSyncs = 3;
|
|
59
59
|
export const GameAction = {
|
|
60
60
|
Reset: 1,
|
|
@@ -72,7 +72,7 @@ export const GameOptionFlag = {
|
|
|
72
72
|
NoTeamShuffle: 4
|
|
73
73
|
};
|
|
74
74
|
export const GunEquipTime = 13;
|
|
75
|
-
export const GunList = [
|
|
75
|
+
export const GunList = [EggK47, DozenGauge, CSG1, RPEGG, SMG, M24, AUG];
|
|
76
76
|
export const ItemType = {
|
|
77
77
|
Hat: 1,
|
|
78
78
|
Stamp: 2,
|
|
@@ -127,13 +127,15 @@ export const Team = {
|
|
|
127
127
|
Blue: 1,
|
|
128
128
|
Red: 2
|
|
129
129
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
const latestChromeVersion = 143;
|
|
131
|
+
const latestFirefoxVersion = 146;
|
|
132
|
+
const agents = [
|
|
133
|
+
`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${latestChromeVersion}.0.0.0 Safari/537.36`,
|
|
134
|
+
`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${latestChromeVersion}.0.0.0 Safari/537.36`,
|
|
135
|
+
`Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:${latestFirefoxVersion}.0) Gecko/20100101 Firefox/${latestFirefoxVersion}.0`,
|
|
136
|
+
`Mozilla/5.0 (X11; Linux x86_64; rv:${latestFirefoxVersion}.0) Gecko/20100101 Firefox/${latestFirefoxVersion}.0`,
|
|
137
|
+
`Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${latestChromeVersion}.0.0.0 Safari/537.36`,
|
|
138
|
+
`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${latestChromeVersion}.0.0.0 Safari/537.36 Edg/${latestChromeVersion}.0.0.0`,
|
|
139
|
+
`Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:${latestFirefoxVersion}.0) Gecko/20100101 Firefox/${latestFirefoxVersion}.0`
|
|
138
140
|
];
|
|
139
|
-
export const UserAgent =
|
|
141
|
+
export const UserAgent = agents[Math.floor(Math.random() * agents.length)];
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import Bot from '../bot';
|
|
2
2
|
|
|
3
|
+
export type Params = [uniqueId: string, duration: number, reason?: string];
|
|
4
|
+
|
|
3
5
|
export declare class BanPlayerDispatch {
|
|
4
6
|
uniqueId: string;
|
|
5
7
|
duration: number;
|
|
6
8
|
reason?: string;
|
|
7
9
|
|
|
8
|
-
constructor(
|
|
10
|
+
constructor(...args: Params);
|
|
9
11
|
|
|
10
12
|
validate(bot: Bot): boolean;
|
|
11
13
|
check(bot: Bot): boolean;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Bot from '../bot';
|
|
2
2
|
|
|
3
|
+
export type Params = [uniqueId: string];
|
|
4
|
+
|
|
3
5
|
export declare class BootPlayerDispatch {
|
|
4
6
|
uniqueId: string;
|
|
5
7
|
|
|
6
|
-
constructor(
|
|
8
|
+
constructor(...args: Params);
|
|
7
9
|
|
|
8
10
|
validate(bot: Bot): boolean;
|
|
9
11
|
check(bot: Bot): boolean;
|
|
@@ -5,11 +5,13 @@ export class ChatDispatch {
|
|
|
5
5
|
constructor(msg) {
|
|
6
6
|
this.msg = msg;
|
|
7
7
|
}
|
|
8
|
-
validate() {
|
|
8
|
+
validate(bot) {
|
|
9
9
|
if (typeof this.msg !== "string")
|
|
10
10
|
return false;
|
|
11
11
|
if (this.msg.length < 1 || this.msg.length > 64)
|
|
12
12
|
return false;
|
|
13
|
+
if (!bot.game.isPrivate && !bot.account.emailVerified && !bot.account.isAged && !bot.account.isCG)
|
|
14
|
+
return false;
|
|
13
15
|
return true;
|
|
14
16
|
}
|
|
15
17
|
check(bot) {
|
|
@@ -17,8 +19,6 @@ export class ChatDispatch {
|
|
|
17
19
|
return false;
|
|
18
20
|
if (!bot.game.isPrivate && !bot.account.adminRoles && bot.state.chatLines >= 2)
|
|
19
21
|
return false;
|
|
20
|
-
if (!bot.game.isPrivate && !bot.account.emailVerified && !bot.account.isAged)
|
|
21
|
-
return false;
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
execute(bot) {
|
|
@@ -19,10 +19,12 @@ export interface GameOptionChanges {
|
|
|
19
19
|
rawWeaponsDisabled?: boolean[];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
export type Params = [changes: GameOptionChanges];
|
|
23
|
+
|
|
22
24
|
export declare class GameOptionsDispatch {
|
|
23
25
|
changes: GameOptionChanges;
|
|
24
26
|
|
|
25
|
-
constructor(
|
|
27
|
+
constructor(...args: Params);
|
|
26
28
|
|
|
27
29
|
validate(bot: Bot): boolean;
|
|
28
30
|
check(bot: Bot): boolean;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Intents, PathfindError } from "../enums.js";
|
|
2
2
|
|
|
3
3
|
export class GoToAmmoDispatch {
|
|
4
4
|
validate(bot) {
|
|
5
|
-
return bot.intents.includes(
|
|
5
|
+
return bot.intents.includes(Intents.PATHFINDING);
|
|
6
6
|
}
|
|
7
7
|
check(bot) {
|
|
8
|
-
return bot.me.playing && bot.game.
|
|
8
|
+
return bot.me.playing && bot.game.collectibles[0].length;
|
|
9
9
|
}
|
|
10
10
|
execute(bot) {
|
|
11
|
-
|
|
12
|
-
let minDistance = 200;
|
|
11
|
+
let minDistance = 2000;
|
|
13
12
|
let closestAmmo = null;
|
|
14
|
-
for (const ammo of bot.game.
|
|
13
|
+
for (const ammo of bot.game.collectibles[0]) {
|
|
15
14
|
const dx = ammo.x - bot.me.position.x;
|
|
16
15
|
const dy = ammo.y - bot.me.position.y;
|
|
17
16
|
const dz = ammo.z - bot.me.position.z;
|
|
@@ -21,16 +20,16 @@ export class GoToAmmoDispatch {
|
|
|
21
20
|
closestAmmo = ammo;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const myNode = bot.pathing.nodeList.
|
|
27
|
-
const targetNode = bot.pathing.nodeList.
|
|
28
|
-
bot.pathing.
|
|
29
|
-
if (!
|
|
30
|
-
return bot
|
|
31
|
-
if (
|
|
32
|
-
return bot
|
|
33
|
-
bot.pathing.
|
|
23
|
+
if (!closestAmmo)
|
|
24
|
+
return;
|
|
25
|
+
const myNode = bot.pathing.nodeList.atObject(bot.me.position);
|
|
26
|
+
const targetNode = bot.pathing.nodeList.atObject(closestAmmo);
|
|
27
|
+
const path = bot.pathing.astar.path(myNode, targetNode);
|
|
28
|
+
if (!path)
|
|
29
|
+
return bot.$emit("pathfindError", PathfindError.NoPathFound);
|
|
30
|
+
if (path.length < 2)
|
|
31
|
+
return bot.$emit("pathfindError", PathfindError.PathTooShort);
|
|
32
|
+
bot.pathing.activePath = path;
|
|
34
33
|
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
35
34
|
bot.pathing.activeNodeIdx = 1;
|
|
36
35
|
}
|
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Intents, PathfindError } from "../enums.js";
|
|
2
2
|
|
|
3
3
|
export class GoToCoopDispatch {
|
|
4
4
|
validate(bot) {
|
|
5
|
-
return bot.intents.includes(
|
|
5
|
+
return bot.intents.includes(Intents.PATHFINDING);
|
|
6
6
|
}
|
|
7
7
|
check(bot) {
|
|
8
|
-
return bot.me.playing && bot.game.
|
|
8
|
+
return bot.me.playing && bot.game.kotc.zoneIdx && bot.game.kotc.activeZone;
|
|
9
9
|
}
|
|
10
10
|
execute(bot) {
|
|
11
|
-
|
|
12
|
-
let minDistance = 200;
|
|
11
|
+
let minDistance = 20000;
|
|
13
12
|
let closestZone = null;
|
|
14
|
-
for (const
|
|
15
|
-
const dx =
|
|
16
|
-
const dy =
|
|
17
|
-
const dz =
|
|
13
|
+
for (const zoneCoords of bot.game.kotc.activeZone) {
|
|
14
|
+
const dx = zoneCoords.x - bot.me.position.x;
|
|
15
|
+
const dy = zoneCoords.y - bot.me.position.y;
|
|
16
|
+
const dz = zoneCoords.z - bot.me.position.z;
|
|
18
17
|
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
19
18
|
if (distance < minDistance) {
|
|
20
19
|
minDistance = distance;
|
|
21
|
-
closestZone =
|
|
20
|
+
closestZone = zoneCoords;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const myNode = bot.pathing.nodeList.
|
|
27
|
-
const targetNode = bot.pathing.nodeList.
|
|
28
|
-
bot.pathing.
|
|
29
|
-
if (!
|
|
30
|
-
return bot
|
|
31
|
-
if (
|
|
32
|
-
return bot
|
|
33
|
-
bot.pathing.
|
|
23
|
+
if (!closestZone)
|
|
24
|
+
return;
|
|
25
|
+
const myNode = bot.pathing.nodeList.atObject(bot.me.position);
|
|
26
|
+
const targetNode = bot.pathing.nodeList.atObject(closestZone);
|
|
27
|
+
const path = bot.pathing.astar.path(myNode, targetNode);
|
|
28
|
+
if (!path)
|
|
29
|
+
return bot.$emit("pathfindError", PathfindError.NoPathFound);
|
|
30
|
+
if (path.length < 2)
|
|
31
|
+
return bot.$emit("pathfindError", PathfindError.PathTooShort);
|
|
32
|
+
bot.pathing.activePath = path;
|
|
34
33
|
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
35
34
|
bot.pathing.activeNodeIdx = 1;
|
|
36
35
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Intents, PathfindError } from "../enums.js";
|
|
2
2
|
|
|
3
3
|
export class GoToGrenadeDispatch {
|
|
4
4
|
validate(bot) {
|
|
5
|
-
return bot.intents.includes(
|
|
5
|
+
return bot.intents.includes(Intents.PATHFINDING);
|
|
6
6
|
}
|
|
7
7
|
check(bot) {
|
|
8
|
-
return bot.me.playing && bot.game.
|
|
8
|
+
return bot.me.playing && bot.game.collectibles[1].length;
|
|
9
9
|
}
|
|
10
10
|
execute(bot) {
|
|
11
|
-
|
|
12
|
-
let minDistance = 200;
|
|
11
|
+
let minDistance = 2000;
|
|
13
12
|
let closestGrenade = null;
|
|
14
|
-
for (const grenade of bot.game.
|
|
13
|
+
for (const grenade of bot.game.collectibles[1]) {
|
|
15
14
|
const dx = grenade.x - bot.me.position.x;
|
|
16
15
|
const dy = grenade.y - bot.me.position.y;
|
|
17
16
|
const dz = grenade.z - bot.me.position.z;
|
|
@@ -21,16 +20,16 @@ export class GoToGrenadeDispatch {
|
|
|
21
20
|
closestGrenade = grenade;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const myNode = bot.pathing.nodeList.
|
|
27
|
-
const targetNode = bot.pathing.nodeList.
|
|
28
|
-
bot.pathing.
|
|
29
|
-
if (!
|
|
30
|
-
return bot
|
|
31
|
-
if (
|
|
32
|
-
return bot
|
|
33
|
-
bot.pathing.
|
|
23
|
+
if (!closestGrenade)
|
|
24
|
+
return;
|
|
25
|
+
const myNode = bot.pathing.nodeList.atObject(bot.me.position);
|
|
26
|
+
const targetNode = bot.pathing.nodeList.atObject(closestGrenade);
|
|
27
|
+
const path = bot.pathing.astar.path(myNode, targetNode);
|
|
28
|
+
if (!path)
|
|
29
|
+
return bot.$emit("pathfindError", PathfindError.NoPathFound);
|
|
30
|
+
if (path.length < 2)
|
|
31
|
+
return bot.$emit("pathfindError", PathfindError.PathTooShort);
|
|
32
|
+
bot.pathing.activePath = path;
|
|
34
33
|
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
35
34
|
bot.pathing.activeNodeIdx = 1;
|
|
36
35
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Bot from '../bot';
|
|
2
2
|
|
|
3
|
+
export type Params = [idOrName: string];
|
|
4
|
+
|
|
3
5
|
export declare class GoToPlayerDispatch {
|
|
4
6
|
idOrName: string;
|
|
5
7
|
|
|
6
|
-
constructor(
|
|
8
|
+
constructor(...args: Params);
|
|
7
9
|
|
|
8
10
|
validate(bot: Bot): boolean;
|
|
9
11
|
check(bot: Bot): boolean;
|
|
@@ -1,37 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Intents, PathfindError } from "../enums.js";
|
|
2
2
|
|
|
3
3
|
export class GoToPlayerDispatch {
|
|
4
4
|
idOrName;
|
|
5
5
|
constructor(idOrName) {
|
|
6
6
|
this.idOrName = idOrName;
|
|
7
7
|
}
|
|
8
|
+
$grabPlayer(bot) {
|
|
9
|
+
return bot.players[this.idOrName.toString()] || Object.values(bot.players).find((player) => player.name === this.idOrName.toString());
|
|
10
|
+
}
|
|
8
11
|
validate(bot) {
|
|
9
|
-
|
|
10
|
-
return false;
|
|
11
|
-
if (!this.idOrName)
|
|
12
|
-
return false;
|
|
13
|
-
const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
|
|
14
|
-
return !!target;
|
|
12
|
+
return bot.intents.includes(Intents.PATHFINDING) && (typeof this.idOrName === "string" || typeof this.idOrName === "number");
|
|
15
13
|
}
|
|
16
14
|
check(bot) {
|
|
17
15
|
if (!bot.me.playing)
|
|
18
16
|
return false;
|
|
19
|
-
const target =
|
|
20
|
-
return target && target.playing && target.position && target.position.x;
|
|
17
|
+
const target = this.$grabPlayer(bot);
|
|
18
|
+
return target && target.playing && target.position && Number.isFinite(target.position.x);
|
|
21
19
|
}
|
|
22
20
|
execute(bot) {
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (bot.pathing.activePath.length < 2)
|
|
33
|
-
return bot.processError("path too short");
|
|
34
|
-
bot.pathing.followingPath = true;
|
|
21
|
+
const target = this.$grabPlayer(bot);
|
|
22
|
+
const myNode = bot.pathing.nodeList.atObject(bot.me.position);
|
|
23
|
+
const targetNode = bot.pathing.nodeList.atObject(target.position);
|
|
24
|
+
const path = bot.pathing.astar.path(myNode, targetNode);
|
|
25
|
+
if (!path)
|
|
26
|
+
return bot.$emit("pathfindError", PathfindError.NoPathFound);
|
|
27
|
+
if (path.length < 2)
|
|
28
|
+
return bot.$emit("pathfindError", PathfindError.PathTooShort);
|
|
29
|
+
bot.pathing.activePath = path;
|
|
35
30
|
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
36
31
|
bot.pathing.activeNodeIdx = 1;
|
|
37
32
|
}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Intents, PathfindError } from "../enums.js";
|
|
2
2
|
|
|
3
3
|
export class GoToSpatulaDispatch {
|
|
4
4
|
validate(bot) {
|
|
5
|
-
return bot.intents.includes(
|
|
5
|
+
return bot.intents.includes(Intents.PATHFINDING);
|
|
6
6
|
}
|
|
7
7
|
check(bot) {
|
|
8
|
-
return bot.me.playing && bot.game.spatula && bot.game.spatula.coords && bot.game.spatula.coords.x;
|
|
8
|
+
return bot.me.playing && bot.game.spatula && bot.game.spatula.coords && Number.isFinite(bot.game.spatula.coords.x);
|
|
9
9
|
}
|
|
10
10
|
execute(bot) {
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (bot.pathing.activePath.length < 2)
|
|
20
|
-
return bot.processError("path too short");
|
|
21
|
-
bot.pathing.followingPath = true;
|
|
11
|
+
const myNode = bot.pathing.nodeList.atObject(bot.me.position);
|
|
12
|
+
const targetNode = bot.pathing.nodeList.atObject(bot.game.spatula.coords);
|
|
13
|
+
const path = bot.pathing.astar.path(myNode, targetNode);
|
|
14
|
+
if (!path)
|
|
15
|
+
return bot.$emit("pathfindError", PathfindError.NoPathFound);
|
|
16
|
+
if (path.length < 2)
|
|
17
|
+
return bot.$emit("pathfindError", PathfindError.PathTooShort);
|
|
18
|
+
bot.pathing.activePath = path;
|
|
22
19
|
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
23
20
|
bot.pathing.activeNodeIdx = 1;
|
|
24
21
|
}
|
|
@@ -9,18 +9,20 @@ export class LookAtDispatch {
|
|
|
9
9
|
constructor(idOrName) {
|
|
10
10
|
this.idOrName = idOrName;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
$grabPlayer(bot) {
|
|
13
|
+
return bot.players[this.idOrName.toString()] || Object.values(bot.players).find((player) => player.name === this.idOrName.toString());
|
|
14
|
+
}
|
|
15
|
+
validate() {
|
|
16
|
+
return typeof this.idOrName === "string" || typeof this.idOrName === "number";
|
|
15
17
|
}
|
|
16
18
|
check(bot) {
|
|
17
19
|
if (!bot.me.playing)
|
|
18
20
|
return false;
|
|
19
|
-
const target =
|
|
20
|
-
return target && target.playing && target.position && target.position.x;
|
|
21
|
+
const target = this.$grabPlayer(bot);
|
|
22
|
+
return target && target.playing && target.position && Number.isFinite(target.position.x);
|
|
21
23
|
}
|
|
22
24
|
execute(bot) {
|
|
23
|
-
const target =
|
|
25
|
+
const target = this.$grabPlayer(bot);
|
|
24
26
|
const directionVector = {
|
|
25
27
|
x: target.position.x - bot.me.position.x,
|
|
26
28
|
y: target.position.y - bot.me.position.y - 0.05,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import Bot from '../bot';
|
|
2
2
|
import { Position } from '../bot/GamePlayer';
|
|
3
3
|
|
|
4
|
+
export type Params = [pos: Position];
|
|
5
|
+
|
|
4
6
|
export declare class LookAtPosDispatch {
|
|
5
7
|
pos: Position;
|
|
6
8
|
|
|
7
|
-
constructor(
|
|
9
|
+
constructor(...args: Params);
|
|
8
10
|
|
|
9
11
|
validate(bot: Bot): boolean;
|
|
10
12
|
check(bot: Bot): boolean;
|
|
@@ -9,7 +9,7 @@ export class LookAtPosDispatch {
|
|
|
9
9
|
this.pos = pos;
|
|
10
10
|
}
|
|
11
11
|
validate() {
|
|
12
|
-
return this.pos && this.pos.x && this.pos.y && this.pos.z;
|
|
12
|
+
return this.pos && Number.isFinite(this.pos.x) && Number.isFinite(this.pos.y) && Number.isFinite(this.pos.z);
|
|
13
13
|
}
|
|
14
14
|
check(bot) {
|
|
15
15
|
return bot.me.playing;
|
|
@@ -13,12 +13,12 @@ export class MeleeDispatch {
|
|
|
13
13
|
const out = new CommOut;
|
|
14
14
|
out.packInt8(CommCode.melee);
|
|
15
15
|
out.send(bot.game.socket);
|
|
16
|
-
bot.usingMelee = true;
|
|
16
|
+
bot.state.usingMelee = true;
|
|
17
17
|
setTimeout(() => {
|
|
18
|
-
bot.usingMelee = false;
|
|
19
|
-
bot.swappingGun = true;
|
|
18
|
+
bot.state.usingMelee = false;
|
|
19
|
+
bot.state.swappingGun = true;
|
|
20
20
|
setTimeout(() => {
|
|
21
|
-
bot.swappingGun = false;
|
|
21
|
+
bot.state.swappingGun = false;
|
|
22
22
|
}, 0.5 * GunEquipTime);
|
|
23
23
|
}, 100 / 3 * 17);
|
|
24
24
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Bot from '../bot';
|
|
2
2
|
|
|
3
|
+
export type Params = [controlKeys: number | number[]];
|
|
4
|
+
|
|
3
5
|
export class MovementDispatch {
|
|
4
6
|
inputKeys: number;
|
|
5
7
|
|
|
6
|
-
constructor(
|
|
8
|
+
constructor(...args: Params);
|
|
7
9
|
|
|
8
10
|
validate(bot: Bot): boolean;
|
|
9
11
|
check(bot: Bot): boolean;
|
|
@@ -4,7 +4,7 @@ export class MovementDispatch {
|
|
|
4
4
|
constructor(inputKeys) {
|
|
5
5
|
if (typeof inputKeys === "number")
|
|
6
6
|
this.inputKeys = inputKeys;
|
|
7
|
-
else if (
|
|
7
|
+
else if (Array.isArray(inputKeys))
|
|
8
8
|
this.inputKeys = inputKeys.reduce((a, b) => a | b, 0);
|
|
9
9
|
}
|
|
10
10
|
validate() {
|
|
@@ -6,23 +6,30 @@ export class ReloadDispatch {
|
|
|
6
6
|
return true;
|
|
7
7
|
}
|
|
8
8
|
check(bot) {
|
|
9
|
-
return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee;
|
|
9
|
+
return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee && bot.me.weapons[bot.me.activeGun].ammo?.rounds < bot.me.weapons[bot.me.activeGun].ammo?.capacity && bot.me.weapons[bot.me.activeGun].ammo?.store > 0;
|
|
10
10
|
}
|
|
11
11
|
execute(bot) {
|
|
12
12
|
const out = new CommOut;
|
|
13
13
|
out.packInt8(CommCode.reload);
|
|
14
14
|
out.send(bot.game.socket);
|
|
15
15
|
const playerActiveWeapon = bot.me.weapons[bot.me.activeGun];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
playerActiveWeapon.ammo.rounds += newRounds;
|
|
19
|
-
playerActiveWeapon.ammo.store -= newRounds;
|
|
20
|
-
}
|
|
21
|
-
bot.emit("playerReload", bot.me, playerActiveWeapon);
|
|
22
|
-
const activeWeapon = bot.me.weapons[bot.me.activeGun];
|
|
23
|
-
const isLongTime = activeWeapon.ammo.rounds < 1;
|
|
16
|
+
const isEmpty = playerActiveWeapon.ammo.rounds < 1;
|
|
17
|
+
bot.$emit("playerStartReload", bot.me, playerActiveWeapon);
|
|
24
18
|
bot.state.reloading = true;
|
|
25
|
-
setTimeout(() =>
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
if (!bot.me || bot.hasQuit)
|
|
21
|
+
return;
|
|
22
|
+
bot.state.reloading = false;
|
|
23
|
+
const latestWeapon = bot.me.weapons[bot.me.activeGun];
|
|
24
|
+
if (latestWeapon.ammo) {
|
|
25
|
+
const maxLoad = Math.min(latestWeapon.ammo.capacity, latestWeapon.ammo.reload);
|
|
26
|
+
const needed = Math.max(0, maxLoad - latestWeapon.ammo.rounds);
|
|
27
|
+
const newRounds = Math.min(needed, latestWeapon.ammo.store);
|
|
28
|
+
latestWeapon.ammo.rounds += newRounds;
|
|
29
|
+
latestWeapon.ammo.store -= newRounds;
|
|
30
|
+
}
|
|
31
|
+
bot.$emit("playerEndReload", bot.me, latestWeapon);
|
|
32
|
+
}, isEmpty ? playerActiveWeapon.longReloadTime : playerActiveWeapon.shortReloadTime);
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
export default ReloadDispatch;
|
|
@@ -7,12 +7,14 @@ export interface CheatingReasons {
|
|
|
7
7
|
other?: boolean;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export type Params = [idOrName: string, reasons?: CheatingReasons];
|
|
11
|
+
|
|
10
12
|
export class ReportPlayerDispatch {
|
|
11
|
-
|
|
13
|
+
idOrName: string;
|
|
12
14
|
reasons: boolean[];
|
|
13
15
|
reasonInt: number;
|
|
14
16
|
|
|
15
|
-
constructor(
|
|
17
|
+
constructor(...args: Params);
|
|
16
18
|
|
|
17
19
|
check(bot: Bot): boolean;
|
|
18
20
|
execute(bot: Bot): void;
|