// ==UserScript==
// @name MOOMOO BOT SCRIPT - ENHANCED 2024
// @namespace http://tampermonkey.net/
// @description Bodyguard bots that attack players you click on or retaliate against attackers. Includes strategic behavior and anti-cheat safeguards.
// @version 2.0
// @author Blue Cyclone
// @match *://*.moomoo.io/*
// @icon none
// @grant none
// @license MIT
// @require https://greasyfork.org/scripts/423602-msgpack/code/msgpack.js
// ==/UserScript==
let msgpack = window.msgpack;
const originalSend = WebSocket.prototype.send;
window.playerSocket = null;
window.botSockets = [];
window.targetSid = null; // Current target SID
window.attackerSid = null; // Current attacker SID
window.autoAttack = false; // Automatic attack mode
window.targeting = false; // Manual targeting mode
let healSpeed = 125;
let ahth = 50; // Heal threshold
let ahrp = 2; // Heal repetitions
let healOn = true;
WebSocket.prototype.send = function (...args) {
this.addEventListener("message", (e) => {
const [packet, data] = msgpack.decode(new Uint8Array(e.data));
if (packet === "C" && myPlayer.sid == null) {
console.log("Game started");
myPlayer.dead = false;
myPlayer.sid = data[0];
}
if (packet === "M" && myPlayer.dead) {
myPlayer.dead = false;
}
if (packet === "H") {
detectIncomingAttack(data); // Check for incoming attacks
}
});
if (window.playerSocket == null) {
window.playerSocket = this;
}
originalSend.call(this, ...args);
};
// Wait for the WebSocket connection to stabilize
const checkChange = setInterval(() => {
if (window.playerSocket != null) {
socketFound(window.playerSocket, -1);
clearInterval(checkChange);
botJoin(3); // Spawn 3 bots
}
}, 100);
// Bot join logic
function botJoin(amount) {
let t = window.playerSocket.url.split("wss://")[1].split("?")[0];
for (let i = 0; i < amount; i++) {
window.grecaptcha
.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", { action: "homepage" })
.then((a) => {
window.botSockets.push(
new WebSocket(
"wss://" + t + "?token=" + "re:" + encodeURIComponent(a)
)
);
if (i == amount - 1) {
window.botSockets.forEach((botSocket) => {
botSocket.binaryType = "arraybuffer";
botSocket.onopen = () => {
window.bots.push({
sid: null,
x: null,
y: null,
dead: true,
health: 100,
items: [0, 3, 6, 10],
});
let packet = "M";
let data = [{ moofoll: "1", name: atob("Qm90IDop"), skin: 0 }];
sendPacket(botSocket, packet, data);
socketFound(botSocket, window.botSockets.indexOf(botSocket));
};
});
}
});
}
}
// Define player
const myPlayer = {
sid: null,
x: null,
y: null,
dead: true,
health: 100,
};
window.player = myPlayer;
window.bots = [];
// Enhanced targeting and detection
document.addEventListener("click", (event) => {
const clickedPlayer = getPlayerFromClick(event.clientX, event.clientY);
if (clickedPlayer) {
window.targetSid = clickedPlayer.sid;
window.targeting = true;
window.autoAttack = false;
console.log(`Manually targeting player with SID: ${window.targetSid}`);
sendBotsToAttack(window.targetSid);
}
});
function detectIncomingAttack(data) {
if (data[1] === myPlayer.sid) {
const attackerSid = data[0];
if (window.attackerSid !== attackerSid) {
console.log(`Player ${attackerSid} is attacking you!`);
window.attackerSid = attackerSid;
window.autoAttack = true;
window.targetSid = attackerSid; // Set attacker as the target
sendBotsToAttack(attackerSid);
}
}
}
// Enhanced bot strategy
function sendBotsToAttack(targetSid) {
window.bots.forEach((bot, index) => {
if (!bot.dead) {
const botSocket = window.botSockets[index];
const attackAngle = calculateAngle(bot.x, bot.y, targetSid);
sendPacket(botSocket, "D", [attackAngle]); // Rotate bot to face the target
sendPacket(botSocket, "a", [attackAngle]); // Move bot toward the target
// Simulate randomness to avoid detection
setTimeout(() => {
sendPacket(botSocket, "a", [attackAngle + Math.random() * 0.1 - 0.05]);
}, 500 + Math.random() * 300);
console.log(`Bot ${index} attacking target SID: ${targetSid}`);
}
});
}
function calculateAngle(botX, botY, targetSid) {
const target = getPlayerBySid(targetSid);
return Math.atan2(target.y - botY, target.x - botX);
}
function getPlayerBySid(sid) {
// Placeholder function for retrieving player data by SID
// Replace this with actual logic from the game
return { x: 100, y: 200 }; // Example data
}
// Placeholder to simulate detecting players from click events
function getPlayerFromClick(x, y) {
return { sid: "example_player_sid" }; // Replace this with actual logic
}
// Strategic healing logic
function performHealing(bot) {
if (healOn && bot.health < ahth && !bot.dead) {
for (let i = 0; i < ahrp; i++) {
sendPacket(window.playerSocket, "G", [bot.items[0]]);
sendPacket(window.playerSocket, "d", [1]);
sendPacket(window.playerSocket, "d", [0]);
}
console.log(`Bot healed to ${bot.health}`);
}
}
// Middleware and event handling
function socketFound(socket, indexOfSocket) {
socket.addEventListener("message", (message) => {
viewMessage(message, indexOfSocket);
});
if (indexOfSocket !== -1 && window.bots[indexOfSocket] && !myPlayer.dead) {
setInterval(() => {
if ((window.targeting || window.autoAttack) && window.targetSid) {
sendBotsToAttack(window.targetSid);
}
performHealing(window.bots[indexOfSocket]); // Heal when needed
}, 1000);
}
}
function viewMessage(m, indexOfSocket) {
const [packet, data] = msgpack.decode(new Uint8Array(m.data));
if (packet === "C" && indexOfSocket !== -1) {
window.bots[indexOfSocket].sid = data[0];
window.bots[indexOfSocket].dead = false;
window.bots[indexOfSocket].health = 100;
}
if (packet === "P") {
if (indexOfSocket === -1) {
myPlayer.dead = true;
} else {
window.bots[indexOfSocket].dead = true;
}
}
}
// Utility function to send packets
function sendPacket(socket, packet, data) {
const arr = new Uint8Array(Array.from(msgpack.encode([packet, data])));
socket.send(arr);
}