yolkbot 1.4.5 → 1.4.6
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/browser/build/global.js +1 -1
- package/browser/build/module.js +1 -1
- package/dist/api.js +200 -1
- package/dist/bot/GamePlayer.js +74 -1
- package/dist/bot.js +1679 -1
- package/dist/comm/CommIn.js +79 -1
- package/dist/comm/CommOut.js +60 -1
- package/dist/comm/index.js +11 -1
- package/dist/constants/CloseCode.js +27 -1
- package/dist/constants/CommCode.js +53 -1
- package/dist/constants/challenges.js +1821 -1
- package/dist/constants/findItemById.js +2 -3
- package/dist/constants/guns.js +277 -1
- package/dist/constants/index.js +139 -1
- package/dist/constants/items.js +45042 -1
- package/dist/constants/maps.js +1263 -1
- package/dist/constants/regions.js +30 -1
- package/dist/dispatches/BanPlayerDispatch.js +32 -1
- package/dist/dispatches/BootPlayerDispatch.js +21 -1
- package/dist/dispatches/ChatDispatch.js +32 -1
- package/dist/dispatches/FireDispatch.js +15 -1
- package/dist/dispatches/GameOptionsDispatch.js +66 -1
- package/dist/dispatches/GoToAmmoDispatch.js +38 -1
- package/dist/dispatches/GoToCoopDispatch.js +38 -1
- package/dist/dispatches/GoToGrenadeDispatch.js +38 -1
- package/dist/dispatches/GoToPlayerDispatch.js +39 -1
- package/dist/dispatches/GoToSpatulaDispatch.js +26 -1
- package/dist/dispatches/LookAtDispatch.js +35 -1
- package/dist/dispatches/LookAtPosDispatch.js +29 -1
- package/dist/dispatches/MeleeDispatch.js +26 -1
- package/dist/dispatches/MovementDispatch.js +26 -1
- package/dist/dispatches/PauseDispatch.js +18 -1
- package/dist/dispatches/ReloadDispatch.js +28 -1
- package/dist/dispatches/ReportPlayerDispatch.js +42 -1
- package/dist/dispatches/ResetGameDispatch.js +19 -1
- package/dist/dispatches/SaveLoadoutDispatch.js +105 -1
- package/dist/dispatches/SpawnDispatch.js +22 -1
- package/dist/dispatches/SwapWeaponDispatch.js +25 -1
- package/dist/dispatches/SwitchTeamDispatch.js +33 -1
- package/dist/dispatches/ThrowGrenadeDispatch.js +21 -1
- package/dist/dispatches/index.js +74 -1
- package/dist/env/fetch.js +97 -10
- package/dist/env/globals.js +15 -1
- package/dist/index.js +14 -2
- package/dist/matchmaker.js +141 -1
- package/dist/pathing/astar.js +55 -1
- package/dist/pathing/binaryheap.js +79 -1
- package/dist/pathing/mapnode.js +179 -1
- package/dist/socket.js +97 -1
- package/dist/util.js +68 -1
- package/dist/wasm/bytes.js +8 -1
- package/dist/wasm/direct.js +84 -1
- package/dist/wasm/legacy.js +170 -1
- package/dist/wasm/util.js +19 -1
- package/package.json +38 -39
- /package/dist/{types/api.d.ts → api.d.ts} +0 -0
- /package/dist/{types/bot → bot}/GamePlayer.d.ts +0 -0
- /package/dist/{types/bot.d.ts → bot.d.ts} +0 -0
- /package/dist/{types/comm → comm}/CommIn.d.ts +0 -0
- /package/dist/{types/comm → comm}/CommOut.d.ts +0 -0
- /package/dist/{types/comm → comm}/index.d.ts +0 -0
- /package/dist/{types/constants → constants}/CloseCode.d.ts +0 -0
- /package/dist/{types/constants → constants}/CommCode.d.ts +0 -0
- /package/dist/{types/constants → constants}/challenges.d.ts +0 -0
- /package/dist/{types/constants → constants}/changelog.d.ts +0 -0
- /package/dist/{types/constants → constants}/findItemById.d.ts +0 -0
- /package/dist/{types/constants → constants}/guns.d.ts +0 -0
- /package/dist/{types/constants → constants}/housePromo.d.ts +0 -0
- /package/dist/{types/constants → constants}/index.d.ts +0 -0
- /package/dist/{types/constants → constants}/items.d.ts +0 -0
- /package/dist/{types/constants → constants}/language.d.ts +0 -0
- /package/dist/{types/constants → constants}/maps.d.ts +0 -0
- /package/dist/{types/constants → constants}/notices.d.ts +0 -0
- /package/dist/{types/constants → constants}/regions.d.ts +0 -0
- /package/dist/{types/constants → constants}/shellNews.d.ts +0 -0
- /package/dist/{types/constants → constants}/shellYoutube.d.ts +0 -0
- /package/dist/{types/constants → constants}/shopItems.d.ts +0 -0
- /package/dist/{types/constants → constants}/sounds.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/BanPlayerDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/BootPlayerDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ChatDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/FireDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GameOptionsDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToAmmoDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToCoopDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToGrenadeDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToPlayerDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToSpatulaDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/LookAtDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/LookAtPosDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/MeleeDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/MovementDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/PauseDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ReloadDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ReportPlayerDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ResetGameDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/SaveLoadoutDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/SpawnDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/SwapWeaponDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/SwitchTeamDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ThrowGrenadeDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/index.d.ts +0 -0
- /package/dist/{types/matchmaker.d.ts → matchmaker.d.ts} +0 -0
- /package/dist/{types/pathing → pathing}/astar.d.ts +0 -0
- /package/dist/{types/pathing → pathing}/binaryheap.d.ts +0 -0
- /package/dist/{types/pathing → pathing}/mapnode.d.ts +0 -0
- /package/dist/{types/socket.d.ts → socket.d.ts} +0 -0
- /package/dist/{types/util.d.ts → util.d.ts} +0 -0
- /package/dist/{types/wasm → wasm}/bytes.d.ts +0 -0
- /package/dist/{types/wasm → wasm}/direct.d.ts +0 -0
- /package/dist/{types/wasm → wasm}/legacy.d.ts +0 -0
- /package/dist/{types/wasm → wasm}/util.d.ts +0 -0
|
@@ -1 +1,30 @@
|
|
|
1
|
-
export const Regions=[
|
|
1
|
+
export const Regions = [
|
|
2
|
+
{
|
|
3
|
+
id: "germany",
|
|
4
|
+
sub: "egs-static-live-germany-287o43bv"
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
id: "santiago",
|
|
8
|
+
sub: "egs-static-live-santiago-1s5w3cdc"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: "singapore",
|
|
12
|
+
sub: "egs-static-live-singapore-5r545eei"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "sydney",
|
|
16
|
+
sub: "egs-static-live-sydney-302pa99o"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "uscentral",
|
|
20
|
+
sub: "egs-static-live-uscentral-451sa2ap"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "useast",
|
|
24
|
+
sub: "egs-static-live-useast-191w3fe4"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "uswest",
|
|
28
|
+
sub: "egs-static-live-uswest-192r5xds"
|
|
29
|
+
}
|
|
30
|
+
];
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CommOut from "../comm/CommOut.js";
|
|
2
|
+
import CommCode from "../constants/CommCode.js";
|
|
3
|
+
import { BanDuration } from "../constants/index.js";
|
|
4
|
+
|
|
5
|
+
export class BanPlayerDispatch {
|
|
6
|
+
constructor(uniqueId, duration, reason = "") {
|
|
7
|
+
this.uniqueId = uniqueId;
|
|
8
|
+
this.duration = duration;
|
|
9
|
+
this.reason = reason;
|
|
10
|
+
}
|
|
11
|
+
validate(bot) {
|
|
12
|
+
if (typeof this.uniqueId !== "string" || typeof this.reason !== "string")
|
|
13
|
+
return false;
|
|
14
|
+
if (typeof this.duration !== "number" || !Object.values(BanDuration).some((d) => this.duration === d))
|
|
15
|
+
return false;
|
|
16
|
+
if (!(bot.account.adminRoles & 4))
|
|
17
|
+
return false;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
check() {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
execute(bot) {
|
|
24
|
+
const out = new CommOut;
|
|
25
|
+
out.packInt8(CommCode.banPlayer);
|
|
26
|
+
out.packString(this.uniqueId);
|
|
27
|
+
out.packString(this.reason);
|
|
28
|
+
out.packInt8(this.duration);
|
|
29
|
+
out.send(bot.game.socket);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export default BanPlayerDispatch;
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CommOut from "../comm/CommOut.js";
|
|
2
|
+
import CommCode from "../constants/CommCode.js";
|
|
3
|
+
|
|
4
|
+
export class BootPlayerDispatch {
|
|
5
|
+
constructor(uniqueId) {
|
|
6
|
+
this.uniqueId = uniqueId;
|
|
7
|
+
}
|
|
8
|
+
validate(bot) {
|
|
9
|
+
return typeof this.uniqueId === "string" && bot.game.isGameOwner && Object.values(bot.players).find((player) => player.uniqueId === this.uniqueId);
|
|
10
|
+
}
|
|
11
|
+
check() {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
execute(bot) {
|
|
15
|
+
const out = new CommOut;
|
|
16
|
+
out.packInt8(CommCode.bootPlayer);
|
|
17
|
+
out.packString(this.uniqueId);
|
|
18
|
+
out.send(bot.game.socket);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export default BootPlayerDispatch;
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CommOut from "../comm/CommOut.js";
|
|
2
|
+
import CommCode from "../constants/CommCode.js";
|
|
3
|
+
|
|
4
|
+
export class ChatDispatch {
|
|
5
|
+
constructor(msg) {
|
|
6
|
+
this.msg = msg;
|
|
7
|
+
}
|
|
8
|
+
validate() {
|
|
9
|
+
if (typeof this.msg !== "string")
|
|
10
|
+
return false;
|
|
11
|
+
if (this.msg.length < 1 || this.msg.length > 64)
|
|
12
|
+
return false;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
check(bot) {
|
|
16
|
+
if (!bot.state?.inGame)
|
|
17
|
+
return false;
|
|
18
|
+
if (!bot.game.isPrivate && !bot.account.adminRoles && bot.state.chatLines >= 2)
|
|
19
|
+
return false;
|
|
20
|
+
if (!bot.game.isPrivate && !bot.account.emailVerified && !bot.account.isAged)
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
execute(bot) {
|
|
25
|
+
bot.state.chatLines++;
|
|
26
|
+
const out = new CommOut;
|
|
27
|
+
out.packInt8(CommCode.chat);
|
|
28
|
+
out.packString(this.msg);
|
|
29
|
+
out.send(bot.game.socket);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export default ChatDispatch;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
export class FireDispatch
|
|
1
|
+
export class FireDispatch {
|
|
2
|
+
constructor(amount) {
|
|
3
|
+
this.amount = amount || 1;
|
|
4
|
+
}
|
|
5
|
+
validate() {
|
|
6
|
+
return this.amount >= 1;
|
|
7
|
+
}
|
|
8
|
+
check(bot) {
|
|
9
|
+
return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee && bot.me.weapons[bot.me.activeGun].ammo.rounds >= this.amount;
|
|
10
|
+
}
|
|
11
|
+
execute(bot) {
|
|
12
|
+
bot.state.shotsFired += this.amount || 1;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export default FireDispatch;
|
|
@@ -1 +1,66 @@
|
|
|
1
|
-
const
|
|
1
|
+
const gravityScale = Array.from({ length: 4 }, (_, i) => (i + 1) * 0.25);
|
|
2
|
+
const damageScale = Array.from({ length: 9 }, (_, i) => i * 0.25);
|
|
3
|
+
const regenScale = Array.from({ length: 17 }, (_, i) => i * 0.25);
|
|
4
|
+
const whichever = (arg1, arg2) => typeof arg1 === "undefined" ? arg2 : arg1;
|
|
5
|
+
|
|
6
|
+
export class GameOptionsDispatch {
|
|
7
|
+
constructor(changes) {
|
|
8
|
+
this.changes = changes;
|
|
9
|
+
}
|
|
10
|
+
#constructFinalOutput(bot) {
|
|
11
|
+
const output = {};
|
|
12
|
+
output.gravity = whichever(this.changes.gravity, bot.game.options.gravity);
|
|
13
|
+
output.damage = whichever(this.changes.damage, bot.game.options.damage);
|
|
14
|
+
output.healthRegen = whichever(this.changes.healthRegen, bot.game.options.healthRegen);
|
|
15
|
+
output.locked = whichever(this.changes.locked, bot.game.options.locked);
|
|
16
|
+
output.noTeamChange = whichever(this.changes.noTeamChange, bot.game.options.noTeamChange);
|
|
17
|
+
output.noTeamShuffle = whichever(this.changes.noTeamShuffle, bot.game.options.noTeamShuffle);
|
|
18
|
+
output.weaponsDisabled = [
|
|
19
|
+
whichever(this.changes.disableEggk, bot.game.options.weaponsDisabled[0]),
|
|
20
|
+
whichever(this.changes.disableScrambler, bot.game.options.weaponsDisabled[1]),
|
|
21
|
+
whichever(this.changes.disableFreeRanger, bot.game.options.weaponsDisabled[2]),
|
|
22
|
+
whichever(this.changes.disableRPG, bot.game.options.weaponsDisabled[3]),
|
|
23
|
+
whichever(this.changes.disableWhipper, bot.game.options.weaponsDisabled[4]),
|
|
24
|
+
whichever(this.changes.disableCrackshot, bot.game.options.weaponsDisabled[5]),
|
|
25
|
+
whichever(this.changes.disableTriHard, bot.game.options.weaponsDisabled[6])
|
|
26
|
+
];
|
|
27
|
+
if (this.changes.toDisable && Array.isArray(this.changes.toDisable))
|
|
28
|
+
this.changes.toDisable.forEach((idx) => output.weaponsDisabled[idx] = true);
|
|
29
|
+
if (this.changes.toEnable && Array.isArray(this.changes.toEnable))
|
|
30
|
+
this.changes.toEnable.forEach((idx) => output.weaponsDisabled[idx] = false);
|
|
31
|
+
if (this.changes.rawWeaponsDisabled && Array.isArray(this.changes.rawWeaponsDisabled) && this.changes.rawWeaponsDisabled.length === 7)
|
|
32
|
+
output.weaponsDisabled = this.changes.rawWeaponsDisabled.map((v) => !!v);
|
|
33
|
+
output.mustUseSecondary = output.weaponsDisabled.every((v) => v);
|
|
34
|
+
return output;
|
|
35
|
+
}
|
|
36
|
+
validate(bot) {
|
|
37
|
+
const wouldBe = this.#constructFinalOutput(bot);
|
|
38
|
+
if (!gravityScale.includes(wouldBe.gravity))
|
|
39
|
+
return false;
|
|
40
|
+
if (!damageScale.includes(wouldBe.damage))
|
|
41
|
+
return false;
|
|
42
|
+
if (!regenScale.includes(wouldBe.healthRegen))
|
|
43
|
+
return false;
|
|
44
|
+
if (typeof wouldBe.locked !== "number" && typeof wouldBe.locked !== "boolean")
|
|
45
|
+
return false;
|
|
46
|
+
if (typeof wouldBe.noTeamChange !== "number" && typeof wouldBe.noTeamChange !== "boolean")
|
|
47
|
+
return false;
|
|
48
|
+
if (typeof wouldBe.noTeamShuffle !== "number" && typeof wouldBe.noTeamShuffle !== "boolean")
|
|
49
|
+
return false;
|
|
50
|
+
if (!Array.isArray(wouldBe.weaponsDisabled))
|
|
51
|
+
return false;
|
|
52
|
+
if (wouldBe.weaponsDisabled.length !== 7)
|
|
53
|
+
return false;
|
|
54
|
+
if (wouldBe.weaponsDisabled.some((weapon) => typeof weapon !== "number" && typeof weapon !== "boolean"))
|
|
55
|
+
return false;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
check(bot) {
|
|
59
|
+
return bot.game.isGameOwner;
|
|
60
|
+
}
|
|
61
|
+
execute(bot) {
|
|
62
|
+
bot.game.options = this.#constructFinalOutput(bot);
|
|
63
|
+
bot.updateGameOptions();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export default GameOptionsDispatch;
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import AStar from "../pathing/astar.js";
|
|
2
|
+
|
|
3
|
+
export class GoToAmmoDispatch {
|
|
4
|
+
validate(bot) {
|
|
5
|
+
return bot.intents.includes(bot.Intents.PATHFINDING);
|
|
6
|
+
}
|
|
7
|
+
check(bot) {
|
|
8
|
+
return bot.me.playing && bot.game.collectables[0].length;
|
|
9
|
+
}
|
|
10
|
+
execute(bot) {
|
|
11
|
+
this.pather = new AStar(bot.pathing.nodeList);
|
|
12
|
+
let minDistance = 200;
|
|
13
|
+
let closestAmmo = null;
|
|
14
|
+
for (const ammo of bot.game.collectables[0]) {
|
|
15
|
+
const dx = ammo.x - bot.me.position.x;
|
|
16
|
+
const dy = ammo.y - bot.me.position.y;
|
|
17
|
+
const dz = ammo.z - bot.me.position.z;
|
|
18
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
19
|
+
if (distance < minDistance) {
|
|
20
|
+
minDistance = distance;
|
|
21
|
+
closestAmmo = ammo;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
|
|
25
|
+
const targetPos = Object.entries(closestAmmo).map((entry) => Math.floor(entry[1]));
|
|
26
|
+
const myNode = bot.pathing.nodeList.at(...position);
|
|
27
|
+
const targetNode = bot.pathing.nodeList.at(...targetPos);
|
|
28
|
+
bot.pathing.activePath = this.pather.path(myNode, targetNode);
|
|
29
|
+
if (!bot.pathing.activePath)
|
|
30
|
+
return bot.processError("no path found");
|
|
31
|
+
if (bot.pathing.activePath.length < 2)
|
|
32
|
+
return bot.processError("path too short");
|
|
33
|
+
bot.pathing.followingPath = true;
|
|
34
|
+
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
35
|
+
bot.pathing.activeNodeIdx = 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export default GoToAmmoDispatch;
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import AStar from "../pathing/astar.js";
|
|
2
|
+
|
|
3
|
+
export class GoToCoopDispatch {
|
|
4
|
+
validate(bot) {
|
|
5
|
+
return bot.intents.includes(bot.Intents.PATHFINDING);
|
|
6
|
+
}
|
|
7
|
+
check(bot) {
|
|
8
|
+
return bot.me.playing && bot.game.zoneNumber && bot.game.activeZone;
|
|
9
|
+
}
|
|
10
|
+
execute(bot) {
|
|
11
|
+
this.pather = new AStar(bot.pathing.nodeList);
|
|
12
|
+
let minDistance = 200;
|
|
13
|
+
let closestZone = null;
|
|
14
|
+
for (const zone of bot.game.activeZone) {
|
|
15
|
+
const dx = zone.x - bot.me.position.x;
|
|
16
|
+
const dy = zone.y - bot.me.position.y;
|
|
17
|
+
const dz = zone.z - bot.me.position.z;
|
|
18
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
19
|
+
if (distance < minDistance) {
|
|
20
|
+
minDistance = distance;
|
|
21
|
+
closestZone = zone;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
|
|
25
|
+
const targetPos = Object.entries(closestZone).map((entry) => Math.floor(entry[1]));
|
|
26
|
+
const myNode = bot.pathing.nodeList.at(...position);
|
|
27
|
+
const targetNode = bot.pathing.nodeList.at(...targetPos);
|
|
28
|
+
bot.pathing.activePath = this.pather.path(myNode, targetNode);
|
|
29
|
+
if (!bot.pathing.activePath)
|
|
30
|
+
return bot.processError("no path found");
|
|
31
|
+
if (bot.pathing.activePath.length < 2)
|
|
32
|
+
return bot.processError("path too short");
|
|
33
|
+
bot.pathing.followingPath = true;
|
|
34
|
+
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
35
|
+
bot.pathing.activeNodeIdx = 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export default GoToCoopDispatch;
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import AStar from "../pathing/astar.js";
|
|
2
|
+
|
|
3
|
+
export class GoToGrenadeDispatch {
|
|
4
|
+
validate(bot) {
|
|
5
|
+
return bot.intents.includes(bot.Intents.PATHFINDING);
|
|
6
|
+
}
|
|
7
|
+
check(bot) {
|
|
8
|
+
return bot.me.playing && bot.game.collectables[1].length;
|
|
9
|
+
}
|
|
10
|
+
execute(bot) {
|
|
11
|
+
this.pather = new AStar(bot.pathing.nodeList);
|
|
12
|
+
let minDistance = 200;
|
|
13
|
+
let closestGrenade = null;
|
|
14
|
+
for (const grenade of bot.game.collectables[1]) {
|
|
15
|
+
const dx = grenade.x - bot.me.position.x;
|
|
16
|
+
const dy = grenade.y - bot.me.position.y;
|
|
17
|
+
const dz = grenade.z - bot.me.position.z;
|
|
18
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
19
|
+
if (distance < minDistance) {
|
|
20
|
+
minDistance = distance;
|
|
21
|
+
closestGrenade = grenade;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
|
|
25
|
+
const targetPos = Object.entries(closestGrenade).map((entry) => Math.floor(entry[1]));
|
|
26
|
+
const myNode = bot.pathing.nodeList.at(...position);
|
|
27
|
+
const targetNode = bot.pathing.nodeList.at(...targetPos);
|
|
28
|
+
bot.pathing.activePath = this.pather.path(myNode, targetNode);
|
|
29
|
+
if (!bot.pathing.activePath)
|
|
30
|
+
return bot.processError("no path found");
|
|
31
|
+
if (bot.pathing.activePath.length < 2)
|
|
32
|
+
return bot.processError("path too short");
|
|
33
|
+
bot.pathing.followingPath = true;
|
|
34
|
+
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
35
|
+
bot.pathing.activeNodeIdx = 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export default GoToGrenadeDispatch;
|
|
@@ -1 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import AStar from "../pathing/astar.js";
|
|
2
|
+
|
|
3
|
+
export class GoToPlayerDispatch {
|
|
4
|
+
idOrName;
|
|
5
|
+
constructor(idOrName) {
|
|
6
|
+
this.idOrName = idOrName;
|
|
7
|
+
}
|
|
8
|
+
validate(bot) {
|
|
9
|
+
if (!bot.intents.includes(bot.Intents.PATHFINDING))
|
|
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;
|
|
15
|
+
}
|
|
16
|
+
check(bot) {
|
|
17
|
+
if (!bot.me.playing)
|
|
18
|
+
return false;
|
|
19
|
+
const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
|
|
20
|
+
return target && target.playing && target.position && target.position.x;
|
|
21
|
+
}
|
|
22
|
+
execute(bot) {
|
|
23
|
+
this.pather = new AStar(bot.pathing.nodeList);
|
|
24
|
+
const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
|
|
25
|
+
const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
|
|
26
|
+
const targetPos = Object.entries(target.position).map((entry) => Math.floor(entry[1]));
|
|
27
|
+
const myNode = bot.pathing.nodeList.at(...position);
|
|
28
|
+
const targetNode = bot.pathing.nodeList.at(...targetPos);
|
|
29
|
+
bot.pathing.activePath = this.pather.path(myNode, targetNode);
|
|
30
|
+
if (!bot.pathing.activePath)
|
|
31
|
+
return bot.processError("no path found");
|
|
32
|
+
if (bot.pathing.activePath.length < 2)
|
|
33
|
+
return bot.processError("path too short");
|
|
34
|
+
bot.pathing.followingPath = true;
|
|
35
|
+
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
36
|
+
bot.pathing.activeNodeIdx = 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export default GoToPlayerDispatch;
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import AStar from "../pathing/astar.js";
|
|
2
|
+
|
|
3
|
+
export class GoToSpatulaDispatch {
|
|
4
|
+
validate(bot) {
|
|
5
|
+
return bot.intents.includes(bot.Intents.PATHFINDING);
|
|
6
|
+
}
|
|
7
|
+
check(bot) {
|
|
8
|
+
return bot.me.playing && bot.game.spatula && bot.game.spatula.coords && bot.game.spatula.coords.x;
|
|
9
|
+
}
|
|
10
|
+
execute(bot) {
|
|
11
|
+
this.pather = new AStar(bot.pathing.nodeList);
|
|
12
|
+
const position = Object.entries(bot.me.position).map((entry) => Math.floor(entry[1]));
|
|
13
|
+
const targetPos = Object.entries(bot.game.spatula.coords).map((entry) => Math.floor(entry[1]));
|
|
14
|
+
const myNode = bot.pathing.nodeList.at(...position);
|
|
15
|
+
const targetNode = bot.pathing.nodeList.at(...targetPos);
|
|
16
|
+
bot.pathing.activePath = this.pather.path(myNode, targetNode);
|
|
17
|
+
if (!bot.pathing.activePath)
|
|
18
|
+
return bot.processError("no path found");
|
|
19
|
+
if (bot.pathing.activePath.length < 2)
|
|
20
|
+
return bot.processError("path too short");
|
|
21
|
+
bot.pathing.followingPath = true;
|
|
22
|
+
bot.pathing.activeNode = bot.pathing.activePath[1];
|
|
23
|
+
bot.pathing.activeNodeIdx = 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export default GoToSpatulaDispatch;
|
|
@@ -1 +1,35 @@
|
|
|
1
|
-
const
|
|
1
|
+
const mod = (n, m) => (n % m + m) % m;
|
|
2
|
+
const PI2 = Math.PI * 2;
|
|
3
|
+
const setPrecision = (value) => Math.round(value * 8192) / 8192;
|
|
4
|
+
const calculateYaw = (pos) => setPrecision(mod(Math.atan2(-pos.x, -pos.z), PI2));
|
|
5
|
+
const calculatePitch = (pos) => setPrecision(Math.atan2(pos.y, Math.hypot(pos.x, pos.z)));
|
|
6
|
+
|
|
7
|
+
export class LookAtDispatch {
|
|
8
|
+
idOrName;
|
|
9
|
+
constructor(idOrName) {
|
|
10
|
+
this.idOrName = idOrName;
|
|
11
|
+
}
|
|
12
|
+
validate(bot) {
|
|
13
|
+
const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
|
|
14
|
+
return !!target;
|
|
15
|
+
}
|
|
16
|
+
check(bot) {
|
|
17
|
+
if (!bot.me.playing)
|
|
18
|
+
return false;
|
|
19
|
+
const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
|
|
20
|
+
return target && target.playing && target.position && target.position.x;
|
|
21
|
+
}
|
|
22
|
+
execute(bot) {
|
|
23
|
+
const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
|
|
24
|
+
const directionVector = {
|
|
25
|
+
x: target.position.x - bot.me.position.x,
|
|
26
|
+
y: target.position.y - bot.me.position.y - 0.05,
|
|
27
|
+
z: target.position.z - bot.me.position.z
|
|
28
|
+
};
|
|
29
|
+
const yaw = calculateYaw(directionVector);
|
|
30
|
+
const pitch = calculatePitch(directionVector);
|
|
31
|
+
bot.state.yaw = yaw;
|
|
32
|
+
bot.state.pitch = pitch;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default LookAtDispatch;
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
const
|
|
1
|
+
const mod = (n, m) => (n % m + m) % m;
|
|
2
|
+
const PI2 = Math.PI * 2;
|
|
3
|
+
const setPrecision = (value) => Math.round(value * 8192) / 8192;
|
|
4
|
+
const calculateYaw = (pos) => setPrecision(mod(Math.atan2(-pos.x, -pos.z), PI2));
|
|
5
|
+
const calculatePitch = (pos) => setPrecision(Math.atan2(pos.y, Math.hypot(pos.x, pos.z)));
|
|
6
|
+
|
|
7
|
+
export class LookAtPosDispatch {
|
|
8
|
+
constructor(pos) {
|
|
9
|
+
this.pos = pos;
|
|
10
|
+
}
|
|
11
|
+
validate() {
|
|
12
|
+
return this.pos && this.pos.x && this.pos.y && this.pos.z;
|
|
13
|
+
}
|
|
14
|
+
check(bot) {
|
|
15
|
+
return bot.me.playing;
|
|
16
|
+
}
|
|
17
|
+
execute(bot) {
|
|
18
|
+
const directionVector = {
|
|
19
|
+
x: this.pos.x - bot.me.position.x,
|
|
20
|
+
y: this.pos.y - bot.me.position.y,
|
|
21
|
+
z: this.pos.z - bot.me.position.z
|
|
22
|
+
};
|
|
23
|
+
const yaw = calculateYaw(directionVector);
|
|
24
|
+
const pitch = calculatePitch(directionVector);
|
|
25
|
+
bot.state.yaw = yaw;
|
|
26
|
+
bot.state.pitch = pitch;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default LookAtPosDispatch;
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CommOut from "../comm/CommOut.js";
|
|
2
|
+
import CommCode from "../constants/CommCode.js";
|
|
3
|
+
import { GunEquipTime } from "../constants/index.js";
|
|
4
|
+
|
|
5
|
+
export class MeleeDispatch {
|
|
6
|
+
validate() {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
check(bot) {
|
|
10
|
+
return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee;
|
|
11
|
+
}
|
|
12
|
+
execute(bot) {
|
|
13
|
+
const out = new CommOut;
|
|
14
|
+
out.packInt8(CommCode.melee);
|
|
15
|
+
out.send(bot.game.socket);
|
|
16
|
+
bot.usingMelee = true;
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
bot.usingMelee = false;
|
|
19
|
+
bot.swappingGun = true;
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
bot.swappingGun = false;
|
|
22
|
+
}, 0.5 * GunEquipTime);
|
|
23
|
+
}, 100 / 3 * 17);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export default MeleeDispatch;
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import{Movement
|
|
1
|
+
import { Movement } from "../constants/index.js";
|
|
2
|
+
|
|
3
|
+
export class MovementDispatch {
|
|
4
|
+
constructor(inputKeys) {
|
|
5
|
+
if (typeof inputKeys === "number")
|
|
6
|
+
this.inputKeys = inputKeys;
|
|
7
|
+
else if (typeof inputKeys === "object")
|
|
8
|
+
this.inputKeys = inputKeys.reduce((a, b) => a | b, 0);
|
|
9
|
+
}
|
|
10
|
+
validate() {
|
|
11
|
+
if (typeof this.inputKeys !== "number")
|
|
12
|
+
return false;
|
|
13
|
+
if (this.inputKeys & Movement.Forward && this.inputKeys & Movement.Backward)
|
|
14
|
+
return false;
|
|
15
|
+
if (this.inputKeys & Movement.Left && this.inputKeys & Movement.Right)
|
|
16
|
+
return false;
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
check(bot) {
|
|
20
|
+
return bot.me.playing;
|
|
21
|
+
}
|
|
22
|
+
execute(bot) {
|
|
23
|
+
bot.state.controlKeys = this.inputKeys;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export default MovementDispatch;
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CommOut from "../comm/CommOut.js";
|
|
2
|
+
import CommCode from "../constants/CommCode.js";
|
|
3
|
+
|
|
4
|
+
export class PauseDispatch {
|
|
5
|
+
validate() {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
check(bot) {
|
|
9
|
+
return bot.me.playing;
|
|
10
|
+
}
|
|
11
|
+
execute(bot) {
|
|
12
|
+
const out = new CommOut;
|
|
13
|
+
out.packInt8(CommCode.pause);
|
|
14
|
+
out.send(bot.game.socket);
|
|
15
|
+
setTimeout(() => bot.me.playing = false, 3000);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export default PauseDispatch;
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CommOut from "../comm/CommOut.js";
|
|
2
|
+
import CommCode from "../constants/CommCode.js";
|
|
3
|
+
|
|
4
|
+
export class ReloadDispatch {
|
|
5
|
+
validate() {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
check(bot) {
|
|
9
|
+
return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee;
|
|
10
|
+
}
|
|
11
|
+
execute(bot) {
|
|
12
|
+
const out = new CommOut;
|
|
13
|
+
out.packInt8(CommCode.reload);
|
|
14
|
+
out.send(bot.game.socket);
|
|
15
|
+
const playerActiveWeapon = bot.me.weapons[bot.me.activeGun];
|
|
16
|
+
if (playerActiveWeapon.ammo) {
|
|
17
|
+
const newRounds = Math.min(Math.min(playerActiveWeapon.ammo.capacity, playerActiveWeapon.ammo.reload) - playerActiveWeapon.ammo.rounds, playerActiveWeapon.ammo.store);
|
|
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;
|
|
24
|
+
bot.state.reloading = true;
|
|
25
|
+
setTimeout(() => bot.state.reloading = false, isLongTime ? activeWeapon.longReloadTime : activeWeapon.shortReloadTime);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export default ReloadDispatch;
|
|
@@ -1 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CommOut from "../comm/CommOut.js";
|
|
2
|
+
import CommCode from "../constants/CommCode.js";
|
|
3
|
+
|
|
4
|
+
export class ReportPlayerDispatch {
|
|
5
|
+
constructor(idOrName, reasons = {}) {
|
|
6
|
+
this.idOrName = idOrName;
|
|
7
|
+
this.reasons = [
|
|
8
|
+
!!reasons.cheating,
|
|
9
|
+
!!reasons.harassment,
|
|
10
|
+
!!reasons.offensive,
|
|
11
|
+
!!reasons.other
|
|
12
|
+
];
|
|
13
|
+
if (!this.reasons.includes(true))
|
|
14
|
+
this.reasons[3] = true;
|
|
15
|
+
for (let i = 0;i < this.reasons.length; i++)
|
|
16
|
+
if (this.reasons[i] === true)
|
|
17
|
+
this.reasonInt |= 1 << i;
|
|
18
|
+
}
|
|
19
|
+
validate(bot) {
|
|
20
|
+
if (this.reasons.every((reason) => reason === false))
|
|
21
|
+
return false;
|
|
22
|
+
const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
|
|
23
|
+
if (!target)
|
|
24
|
+
return false;
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
check(bot) {
|
|
28
|
+
if (!bot.state.inGame)
|
|
29
|
+
return false;
|
|
30
|
+
const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
|
|
31
|
+
return !!target;
|
|
32
|
+
}
|
|
33
|
+
execute(bot) {
|
|
34
|
+
const target = bot.players[this.idOrName.toString()] || bot.players.find((player) => player.name === this.idOrName);
|
|
35
|
+
const out = new CommOut;
|
|
36
|
+
out.packInt8(CommCode.reportPlayer);
|
|
37
|
+
out.packString(target.uniqueId);
|
|
38
|
+
out.packInt8(this.reasonInt);
|
|
39
|
+
out.send(bot.game.socket);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export default ReportPlayerDispatch;
|