Greasy Fork

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.10
// @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 to create GUI for Aimbot settings
    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}`);
        });

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

    // Function to initialize the script
    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
    }

    // Function to check if a target is within 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;
    }

    // Function to simulate target detection logic
    function detectPlayers() {
        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, // Center x coordinate
                y: rect.y + rect.height / 2   // Center y coordinate
            };
        });
    }

    // Function to draw squares 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';   // Color for the bounding box
            ctx.strokeRect(player.x - 25, player.y - 25, 50, 50); // Draw the bounding box
        });
    }

    // 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) {
            // Calculate new mouse position
            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);

            if (aimAssistDistance > 0) {
                const aimAssistSpeedX = (aimAssistDirectionX / aimAssistDistance) * 5; // Adjust speed as necessary
                const aimAssistSpeedY = (aimAssistDirectionY / aimAssistDistance) * 5;

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

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

    // Monitor for the DOM load
    window.addEventListener('load', initialize);

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