MooMoo.io Bot

Bot para MooMoo.io que segue o jogador principal e pode gerar mais bots usando comandos de chat.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         MooMoo.io Bot
// @namespace    https://greasyfork.org
// @version      1.2
// @description  Bot para MooMoo.io que segue o jogador principal e pode gerar mais bots usando comandos de chat.
// @author       EmersonxD
// @license      MIT
// @match        https://moomoo.io/
// @grant        none
// ==/UserScript==

(function() {
    const MooMoo = (function() {}) [69];
    const BOT_NAME = "Nuro";
    const BOT_SKIN = 1;
    const BOT_MOOFOLL = true;
    const BOT_CONNECT_EVENT = "connected";
    const BOT_PACKET_EVENT = "packet";
    const BOT_JOIN_REGION_INDEX = "join";
    const BOT_POSITION_UPDATE_INTERVAL = 100;
    const BOT_POSITION_UPDATE_PACKET = "33";
    const COMMAND_PREFIX = "/";
    const COMMAND_NAME_SEND = "send";
    const COMMAND_NAME_DISCONNECT = "disconnect";
    const COMMAND_RESPONSE_SEND = "sending 4 more bots...";
    const COMMAND_RESPONSE_DISCONNECT = "disconnecting bots...";
    const BOT_COUNT_TO_ADD = 4;
    const IP_LIMIT = 4;
    const BOT_COUNT = 3;

    let botManager = MooMoo.BotManager;
    let commandManager = MooMoo.CommandManager;
    commandManager.setPrefix(COMMAND_PREFIX);

    /**
     * Generate a bot and add it to the bot manager
     * @param {BotManager} botManager - The bot manager to add the bot to
     */
    function generateBot(botManager) {
        let bot = new MooMoo.Bot(true, {
            name: BOT_NAME,
            skin: BOT_SKIN,
            moofoll: BOT_MOOFOLL
        });

        bot.addEventListener(BOT_CONNECT_EVENT, () => {
            bot.spawn();
        });

        bot.addEventListener(BOT_PACKET_EVENT, (event) => {
            if (event.packet === "11") {
                bot.spawn();
            }
        });

        let { region, index } = MooMoo.ServerManager.extractRegionAndIndex();
        bot.join([region, index]);
        botManager.addBot(bot);

        setInterval(() => {
            if (!bot.x || !bot.y) return;
            let angle = Math.atan2(MooMoo.myPlayer.y - bot.y, MooMoo.myPlayer.x - bot.x);
            bot.sendPacket(BOT_POSITION_UPDATE_PACKET, angle);
        }, BOT_POSITION_UPDATE_INTERVAL);
    }

    // Add event listener to generate bots when a packet is received
    MooMoo.addEventListener(BOT_PACKET_EVENT, () => {
        if (MooMoo.myPlayer && botManager._bots.size < BOT_COUNT) {
            generateBot(botManager);
        }
    });

    // Register chat commands to generate and disconnect bots
    commandManager.registerCommand(COMMAND_NAME_SEND, (command, args) => {
        command.reply(COMMAND_RESPONSE_SEND);
        for (let i = 0; i < BOT_COUNT_TO_ADD; i++) {
            generateBot(botManager);
        }
    });

    commandManager.registerCommand(COMMAND_NAME_DISCONNECT, (command, args) => {
        command.reply(COMMAND_RESPONSE_DISCONNECT);
        botManager._bots.forEach(bot => {
            bot.ws.close();
        });
        botManager._bots.clear();
    });

    console.log("MooMoo.io Bot is running!");
})();