// Auto Heal Ultra Rápido (sem atrasos)
const AUTO_HEAL_THRESHOLD = 95; // Inicia a cura quando a vida está abaixo deste
valor
const CRITICAL_HEAL_THRESHOLD = 30; // Ativa a cura crítica abaixo deste valor
const CRITICAL_HEAL_BURST = 4; // Quantidade de itens de comida para usar em modo
crítico
let AUTO_HEAL_ENABLED = true;
let inGame = true;
let currentHealth = 100;
let items = [];
let activeWeaponId = null;
let attackHeld = false;
let lastAttackAngle = 0;
let ws = null;
const OriginalWebSocketSend = WebSocket.prototype.send;
WebSocket.prototype.send = function(...args) {
if (!ws) {
ws = this;
WebSocket.prototype.send = OriginalWebSocketSend;
const gameSocket = this;
gameSocket.send = function(data) {
try {
const decoded = window.msgpack.decode(new Uint8Array(data));
const [ptype, pdata] = decoded;
if (ptype === "F") {
if (pdata[0] === 1) {
attackHeld = true;
lastAttackAngle = pdata[1] || 0;
} else if (pdata[0] === 0) {
attackHeld = false;
}
} else if (ptype === "z") {
if (pdata[1] === true) {
activeWeaponId = pdata[0];
}
}
} catch(e) {}
return OriginalWebSocketSend.call(gameSocket, data);
};
gameSocket.addEventListener('message', function(event) {
const msg = window.msgpack.decode(new Uint8Array(event.data));
const packetType = msg[0];
const data = msg[1];
if (packetType === "C") {
inGame = true;
currentHealth = 100;
items = [0, 3, 6, 10];
} else if (packetType === "P") {
inGame = false;
currentHealth = 0;
} else if (packetType === "O") {
const playerId = data[0];
const newHP = data[1];
if (playerId && inGame) {
currentHealth = newHP;
// Tenta curar imediatamente sem delays ou cooldowns
checkAndHeal();
}
} else if (packetType === "V") {
const updateArr = data[0];
const isWeaponsUpdate = data[1];
if (!isWeaponsUpdate && updateArr) {
items = updateArr;
}
}
});
}
return OriginalWebSocketSend.apply(this, args);
};
function sendPacket(type, ...payload) {
if (!ws) return;
const message = window.msgpack.encode([type, payload]);
ws.send(message);
}
function checkAndHeal() {
if (AUTO_HEAL_ENABLED && inGame) {
if (currentHealth < CRITICAL_HEAL_THRESHOLD) {
useFoodItem(CRITICAL_HEAL_BURST); // Usa a cura crítica
} else if (currentHealth < AUTO_HEAL_THRESHOLD) {
useFoodItem(1); // Usa a cura normal
}
}
}
function useFoodItem(healUses) {
if (!inGame || items.length === 0) return;
const foodItemId = items[0];
if (foodItemId == null) return;
const prevWeapon = activeWeaponId;
// Alterna para o item de cura, usa-o o número de vezes necessário e retorna
para a arma anterior
sendPacket("z", foodItemId, false);
for (let i = 0; i < healUses; i++) {
sendPacket("F", 1, lastAttackAngle);
sendPacket("F", 0, lastAttackAngle);
}
// Removendo a parte de voltar para a arma anterior para evitar "tapas
fantasmas"
// e simplificando a lógica de ataque para ser mais rápido.
if (prevWeapon != null && attackHeld) {
sendPacket("z", prevWeapon, true);
sendPacket("F", 1, lastAttackAngle);
} else if (prevWeapon != null) {
sendPacket("z", prevWeapon, true);
}
}