Enhanced Krunker.IO Aimbot, ESP, and Recoil Control

Aimbot, ESP, and recoil control system with GUI for toggles in-game.

目前為 2024-12-13 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Enhanced Krunker.IO Aimbot, ESP, and Recoil Control
// @namespace    http://tampermonkey.net/
// @version      1.4.0
// @description  Aimbot, ESP, and recoil control system with GUI for toggles in-game.
// @author       Loki
// @match        *://krunker.io/*
// @exclude      *://krunker.io/social*
// @exclude      *://krunker.io/editor*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(() => {
    const config = {
        aimbot: { enabled: true, mode: 'snap' },
        esp: { enabled: true },
        recoilControl: { enabled: true, intensity: 0.8 }, // Adjust intensity (0 to 1)
    };

    let gameState = { scene: null, players: [], myPlayer: null };

    /** Hook into game scene */
    const hookScene = () => {
        const originalAdd = Object.prototype.add;
        Object.prototype.add = function (obj) {
            if (obj?.type === 'Scene' && obj.name === 'Main') {
                gameState.scene = obj;
                console.log('Scene hooked successfully!');
            }
            return originalAdd?.call(this, obj);
        };
    };

    /** Find players and my player */
    const findPlayers = () => {
        const { scene } = gameState;
        if (!scene) return { players: [], myPlayer: null };

        const players = [];
        let myPlayer = null;

        scene.children.forEach((child) => {
            if (child.type !== 'Object3D') return;

            const camera = child.children[0]?.children[0];
            if (camera?.type === 'PerspectiveCamera') {
                myPlayer = child;
            } else if (child.children[0]) {
                players.push(child);
            }
        });

        return { players, myPlayer };
    };

    /** Aimbot logic */
    const aimbotLogic = (targetPlayer, myPlayer) => {
        if (!config.aimbot.enabled || !targetPlayer || !myPlayer) return;
        const targetPos = targetPlayer.children[0]?.children[0]?.getWorldPosition(new THREE.Vector3());
        const direction = targetPos?.sub(myPlayer.position).normalize();

        if (config.aimbot.mode === 'snap') {
            myPlayer.lookAt(targetPos);
        } else {
            const factor = config.aimbot.mode === 'soft' ? 0.1 : 0.05;
            myPlayer.rotation.x = THREE.MathUtils.lerp(myPlayer.rotation.x, direction.x, factor);
            myPlayer.rotation.y = THREE.MathUtils.lerp(myPlayer.rotation.y, direction.y, factor);
        }
    };

    /** ESP logic */
    const renderESP = (players) => {
        if (!config.esp.enabled) return;

        const canvas = document.getElementById('espCanvas') || createCanvas();
        const ctx = canvas.getContext('2d');
        ctx.clearRect(0, 0, canvas.width, canvas.height);

        players.forEach((player) => {
            const screenPos = toScreenPosition(player.position, gameState.myPlayer.children[0]?.children[0]);
            if (!screenPos) return;

            ctx.beginPath();
            ctx.moveTo(screenPos.x, screenPos.y);
            ctx.lineTo(window.innerWidth / 2, window.innerHeight); // Example: line to bottom center
            ctx.strokeStyle = 'red';
            ctx.stroke();
        });
    };

    const createCanvas = () => {
        const canvas = document.createElement('canvas');
        canvas.id = 'espCanvas';
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
        canvas.style.position = 'absolute';
        canvas.style.top = '0';
        canvas.style.left = '0';
        canvas.style.pointerEvents = 'none';
        document.body.appendChild(canvas);
        return canvas;
    };

    const toScreenPosition = (position, camera) => {
        if (!camera) return null;
        const vector = position.clone().project(camera);
        return {
            x: (vector.x + 1) * window.innerWidth / 2,
            y: (-vector.y + 1) * window.innerHeight / 2,
        };
    };

    /** Recoil Control System */
    const controlRecoil = (myPlayer) => {
        if (!config.recoilControl.enabled || !myPlayer) return;

        // Simulate recoil reduction by adjusting the player's rotation
        const recoilIntensity = config.recoilControl.intensity;
        myPlayer.rotation.x -= Math.random() * 0.005 * recoilIntensity;
        myPlayer.rotation.y -= Math.random() * 0.005 * recoilIntensity;
    };

    /** GUI creation */
    const createGUI = () => {
        // Create hacks button
        const button = document.createElement('button');
        button.innerHTML = 'Hacks';
        button.style.position = 'absolute';
        button.style.top = '10px';
        button.style.left = '10px';
        button.style.padding = '10px';
        button.style.zIndex = '10000';
        button.style.backgroundColor = '#333';
        button.style.color = '#fff';
        button.style.border = 'none';
        button.style.borderRadius = '5px';
        button.style.cursor = 'pointer';
        button.onclick = toggleGUI;

        // Create GUI container
        const gui = document.createElement('div');
        gui.id = 'hacksGUI';
        gui.style.position = 'absolute';
        gui.style.top = '50px';
        gui.style.left = '10px';
        gui.style.padding = '10px';
        gui.style.backgroundColor = '#222';
        gui.style.color = '#fff';
        gui.style.border = '1px solid #444';
        gui.style.borderRadius = '5px';
        gui.style.display = 'none';
        gui.style.zIndex = '10000';

        // Add toggles
        const aimbotToggle = createToggle('Enable Aimbot', config.aimbot, 'enabled');
        const espToggle = createToggle('Enable ESP', config.esp, 'enabled');
        const recoilToggle = createToggle('Recoil Control', config.recoilControl, 'enabled');
        const modeToggle = createButton('Toggle Aimbot Mode', () => {
            const modes = ['snap', 'soft', 'assist'];
            const currentIndex = modes.indexOf(config.aimbot.mode);
            config.aimbot.mode = modes[(currentIndex + 1) % modes.length];
            alert(`Aimbot mode: ${config.aimbot.mode}`);
        });

        gui.appendChild(aimbotToggle);
        gui.appendChild(espToggle);
        gui.appendChild(recoilToggle);
        gui.appendChild(modeToggle);
        document.body.appendChild(button);
        document.body.appendChild(gui);
    };

    const createToggle = (label, obj, key) => {
        const container = document.createElement('div');
        const checkbox = document.createElement('input');
        checkbox.type = 'checkbox';
        checkbox.checked = obj[key];
        checkbox.onchange = () => {
            obj[key] = checkbox.checked;
            alert(`${label}: ${obj[key]}`);
        };

        const labelElement = document.createElement('label');
        labelElement.innerText = label;
        labelElement.style.marginLeft = '5px';

        container.appendChild(checkbox);
        container.appendChild(labelElement);
        return container;
    };

    const createButton = (label, onClick) => {
        const button = document.createElement('button');
        button.innerHTML = label;
        button.style.marginTop = '5px';
        button.style.display = 'block';
        button.onclick = onClick;
        return button;
    };

    const toggleGUI = () => {
        const gui = document.getElementById('hacksGUI');
        gui.style.display = gui.style.display === 'none' ? 'block' : 'none';
    };

    /** Game loop */
    const gameLoop = () => {
        requestAnimationFrame(gameLoop);

        const { players, myPlayer } = findPlayers();
        gameState.players = players;
        gameState.myPlayer = myPlayer;

        if (!players.length || !myPlayer) return;

        let closestPlayer = null;
        let minDist = Infinity;

        players.forEach((player) => {
            const dist = player.position.distanceTo(myPlayer.position);
            if (dist < minDist) {
                minDist = dist;
                closestPlayer = player;
            }
        });

        aimbotLogic(closestPlayer, myPlayer);
        renderESP(players);
        controlRecoil(myPlayer);
    };

    const initialize = () => {
        hookScene();
        createGUI();
        gameLoop();
    };

    initialize();
})();