Greasy Fork

Greasy Fork is available in English.

Xbox Cloud Fortnite Aimbot with FOV

Draw boxes around detected players, aim assist, and auto fire for Fortnite

当前为 2024-12-10 提交的版本,查看 最新版本

// ==UserScript==
// @name         Xbox Cloud Fortnite Aimbot with FOV
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Draw boxes around detected players, aim assist, and auto fire for Fortnite
// @author       You
// @match        https://www.xbox.com/en-US/play/launch/fortnite/BT5P2X999VH2
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let aimAssistEnabled = false;
    let fov = 90; // Default FOV value in degrees
    let canvas;

    function createGUI() {
        // Create an overlay GUI for settings
        const gui = document.createElement('div');
        gui.style.position = 'absolute';
        gui.style.top = '10px';
        gui.style.left = '10px';
        gui.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
        gui.style.color = 'white';
        gui.style.padding = '10px';
        gui.style.zIndex = '9999';
        gui.innerHTML = `
            <h4>Aimbot Settings</h4>
            <label>
                <input type="checkbox" id="aimAssistToggle"> Enable Aim Assist
            </label><br>
            <label>
                FOV: <input type="number" id="fovInput" value="${fov}" min="30" max="180">
            </label><br>
            <button id="resetButton">Reset FOV</button>
        `;
        document.body.appendChild(gui);

        // Event listeners for GUI elements
        document.getElementById('aimAssistToggle').addEventListener('change', (event) => {
            aimAssistEnabled = event.target.checked;
            console.log(`Aim assist ${aimAssistEnabled ? 'enabled' : 'disabled'}`);
        });

        document.getElementById('fovInput').addEventListener('input', (event) => {
            fov = Math.max(30, Math.min(180, event.target.value));
            console.log(`FOV set to: ${fov}`);
        });

        document.getElementById('resetButton').addEventListener('click', () => {
            fov = 90; // Reset FOV to default
            document.getElementById('fovInput').value = fov;
            console.log(`FOV reset to default: ${fov}`);
        });
    }

    function monitorForCanvas() {
        const checkCanvasInterval = setInterval(() => {
            canvas = document.querySelector('canvas');
            if (canvas) {
                clearInterval(checkCanvasInterval);
                console.log("Canvas found. Aim assist is ready.");
                createGUI(); // Create the GUI when the canvas is found
                setInterval(applyAimAssist, 16); // 60fps
            }
        }, 1000); // Check every second
    }

    function isTargetInFOV(targetX, targetY) {
        const crosshairX = canvas.width / 2;
        const crosshairY = canvas.height / 2;
        const angleToTarget = Math.atan2(targetY - crosshairY, targetX - crosshairX) * (180 / Math.PI);
        const fovHalf = fov / 2;

        return Math.abs(angleToTarget) <= fovHalf;
    }

    function detectPlayers() {
        // Logic to find players in the game
        const players = document.querySelectorAll('.target-element'); // Replace this selector with the actual player class
        return Array.from(players).map(player => {
            const rect = player.getBoundingClientRect();
            return {
                x: rect.x + rect.width / 2,
                y: rect.y + rect.height / 2
            };
        });
    }

    function drawPlayerBoxes(players) {
        const ctx = canvas.getContext('2d');
        ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear previous frames
        players.forEach(player => {
            ctx.strokeStyle = 'red';   // Change color as needed
            ctx.strokeRect(
                player.x - 25, // Adjust width as needed
                player.y - 25, // Adjust height as needed
                50,            // Width of the box
                50             // Height of the box
            );
        });
    }

    function applyAimAssist() {
        if (!aimAssistEnabled || !canvas) return;

        const players = detectPlayers();
        const crosshairX = canvas.width / 2;
        const crosshairY = canvas.height / 2;

        let target;
        for (const player of players) {
            if (isTargetInFOV(player.x, player.y)) {
                target = player; // Only consider the first found target for simplicity
                break;
            }
        }

        if (target) {
            const aimAssistDirectionX = target.x - crosshairX;
            const aimAssistDirectionY = target.y - crosshairY;
            const aimAssistDistance = Math.sqrt(aimAssistDirectionX ** 2 + aimAssistDirectionY ** 2);
            
            // Avoid division by zero
            if (aimAssistDistance > 0) { 
                const aimAssistSpeedX = (aimAssistDirectionX / aimAssistDistance) * 5; // Adjust speed
                const aimAssistSpeedY = (aimAssistDirectionY / aimAssistDistance) * 5;

                const aimAssistX = crosshairX + aimAssistSpeedX;
                const aimAssistY = crosshairY + aimAssistSpeedY;

                // Move the mouse cursor
                canvas.dispatchEvent(new MouseEvent('mousemove', { clientX: aimAssistX, clientY: aimAssistY }));
            }
        }

        drawPlayerBoxes(players);
    }

    // Start monitoring for the canvas once the window loads
    window.addEventListener('load', monitorForCanvas);

    console.log("Tampermonkey script loaded for Fortnite with FOV and GUI!");
})();