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 with FOV adjustment and controller support.

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

// ==UserScript==
// @name         Xbox Cloud Fortnite Aimbot with FOV
// @namespace    http://tampermonkey.net/
// @version      12
// @description  Draw boxes around detected players, aim assist, and auto fire for Fortnite with FOV adjustment and controller support.
// @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;

    // Create GUI for the aimbot
    function createGUI() {
        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)); // Ensure FOV is within limits
            console.log(`FOV set to: ${fov}`);
            drawFOVBox(); // Update FOV box whenever the FOV changes
        });

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

    // Initialize the script once the game is loaded
    function initialize() {
        canvas = document.querySelector('canvas'); // Ensure the game canvas is present
        if (!canvas) {
            console.error("Canvas not found. Please ensure the game is loaded.");
            setTimeout(initialize, 1000); // Retry after a second
            return;
        }
        console.log("Canvas found. Aim assist is ready.");
        createGUI(); // Create the GUI when the canvas is found
    }

    // Check if a target is in the FOV
    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;
    }

    // Simulated player detection; replace with actual logic
    function detectPlayers() {
        const players = document.querySelectorAll('.target-element'); // Replace with the most accurate player class in the game
        return Array.from(players).map(player => {
            const rect = player.getBoundingClientRect();
            return {
                x: rect.x + rect.width / 2, // Center x coordinate
                y: rect.y + rect.height / 2   // Center y coordinate
            };
        });
    }

    // Draw boxes around detected players
    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
            );
        });
    }

    // Draw the FOV box
    function drawFOVBox() {
        const ctx = canvas.getContext('2d');
        const crosshairX = canvas.width / 2;
        const crosshairY = canvas.height / 2;
        const fovHalfSize = fov; // You can adjust this for better visualization
        
        ctx.strokeStyle = 'green'; // FOV box color
        ctx.strokeRect(crosshairX - fovHalfSize / 2, crosshairY - fovHalfSize / 2, fovHalfSize, fovHalfSize);
    }

    // Function to apply aim assist logic
    function applyAimAssist() {
        if (!aimAssistEnabled || !canvas) return;

        const players = detectPlayers(); // Detect players on the screen
        let target;

        // Find the first player within FOV to aim at
        for (const player of players) {
            if (isTargetInFOV(player.x, player.y)) {
                target = player;
                break; // Use the first target found within FOV
            }
        }

        if (target) {
            const currentX = pyautogui.position().x;
            const currentY = pyautogui.position().y;

            const aimAssistDirectionX = target.x - currentX;
            const aimAssistDirectionY = target.y - currentY;
            const aimAssistDistance = Math.sqrt(aimAssistDirectionX ** 2 + aimAssistDirectionY ** 2);

            // Move the mouse cursor gradually
            if (aimAssistDistance > 0) {
                const aimAssistSpeedX = (aimAssistDirectionX / aimAssistDistance) * 5; // Adjust speed as needed
                const aimAssistSpeedY = (aimAssistDirectionY / aimAssistDistance) * 5;

                // Move the mouse cursor
                pyautogui.moveTo(currentX + aimAssistSpeedX, currentY + aimAssistSpeedY);
            }
        }

        drawPlayerBoxes(players); // Draw boxes around detected players
    }

    // Trigger initialization when the window loads
    window.addEventListener('load', initialize);

    // Start the interval for aim assist
    setInterval(applyAimAssist, 16); // 60fps

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