Greasy Fork

Greasy Fork is available in English.

Fortnite Xbox Cloud Aimbot with Canvas Detection

Aimbot for Fortnite on Xbox Cloud using Canvas detection, no DOM enemy elements required.

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

// ==UserScript==
// @name         Fortnite Xbox Cloud Aimbot with Canvas Detection
// @namespace    http://tampermonkey.net/
// @version      25
// @description  Aimbot for Fortnite on Xbox Cloud using Canvas detection, no DOM enemy elements required.
// @author       Your Name
// @match        https://www.xbox.com/en-US/play/launch/fortnite/BT5P2X999VH2
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const config = {
        aimInterval: 100, // Interval in milliseconds for aim checks
        aimSmoothing: 0.3, // Smoothing for aim adjustments
        fov: 60, // Field of View in degrees
        fovEnabled: true, // Toggle FOV
        autoShoot: true, // Auto-shoot feature
        enemyColor: [255, 0, 0], // RGB color of enemy (adjust based on game visuals)
        canvasSelector: 'canvas', // Selector for the game canvas
    };

    let canvas, ctx;

    /**
     * Initialize the canvas and its context
     */
    function initializeCanvas() {
        canvas = document.querySelector(config.canvasSelector);
        if (!canvas) {
            console.error('Game canvas not found!');
            return;
        }
        ctx = canvas.getContext('2d');
        console.log('Canvas initialized:', canvas);
    }

    /**
     * Detect enemies by scanning the canvas for specific colors
     * @returns {Array} List of detected enemy positions
     */
    function detectEnemiesFromCanvas() {
        if (!ctx || !canvas) return [];

        const enemies = [];
        const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;

        // Iterate through pixels to detect enemies based on color
        for (let i = 0; i < imageData.length; i += 4) {
            const r = imageData[i];
            const g = imageData[i + 1];
            const b = imageData[i + 2];

            if (
                Math.abs(r - config.enemyColor[0]) < 10 &&
                Math.abs(g - config.enemyColor[1]) < 10 &&
                Math.abs(b - config.enemyColor[2]) < 10
            ) {
                const x = (i / 4) % canvas.width;
                const y = Math.floor(i / 4 / canvas.width);
                enemies.push({ x, y });
            }
        }

        return enemies;
    }

    /**
     * Calculate the angle between two points
     * @param {number} targetX - Target X coordinate
     * @param {number} targetY - Target Y coordinate
     * @param {number} playerX - Player X coordinate
     * @param {number} playerY - Player Y coordinate
     * @returns {number} Angle in degrees
     */
    function calculateAngle(targetX, targetY, playerX, playerY) {
        return Math.atan2(targetY - playerY, targetX - playerX) * (180 / Math.PI);
    }

    /**
     * Smoothly rotate the player towards the target
     * @param {number} targetAngle - The calculated angle to rotate towards
     */
    function smoothAim(targetAngle) {
        const player = { x: canvas.width / 2, y: canvas.height / 2 }; // Assume player is at canvas center
        const angleDiff = targetAngle - (player.rotation || 0);

        player.rotation = angleDiff * config.aimSmoothing + (player.rotation || 0);
        console.log('Aiming at angle:', player.rotation);

        // Simulate mouse movement
        simulateMouseMovement(player.rotation);
    }

    /**
     * Simulate mouse movement
     * @param {number} angle - Angle to simulate movement towards
     */
    function simulateMouseMovement(angle) {
        const event = new MouseEvent('mousemove', {
            clientX: angle * 10,
            clientY: 0,
        });
        document.dispatchEvent(event);
    }

    /**
     * Simulate shooting by dispatching a click event
     */
    function simulateShooting() {
        const event = new MouseEvent('click', { bubbles: true, cancelable: true });
        document.dispatchEvent(event);
        console.log('Shooting at enemy!');
    }

    /**
     * Main aimbot logic
     */
    function aimAtEnemies() {
        if (!config.enableAimbot || !canvas) return;

        const playerX = canvas.width / 2;
        const playerY = canvas.height / 2;

        const enemies = detectEnemiesFromCanvas();
        if (enemies.length === 0) {
            console.log('No enemies detected.');
            return;
        }

        // Find the closest enemy within the FOV
        let closestEnemy = null;
        let closestAngle = Infinity;

        for (const enemy of enemies) {
            const angle = calculateAngle(enemy.x, enemy.y, playerX, playerY);

            if (config.fovEnabled && Math.abs(angle) > config.fov / 2) {
                continue; // Skip enemies outside the FOV
            }

            if (Math.abs(angle) < Math.abs(closestAngle)) {
                closestEnemy = enemy;
                closestAngle = angle;
            }
        }

        if (closestEnemy) {
            console.log('Locking on to enemy:', closestEnemy);
            smoothAim(closestAngle);

            if (config.autoShoot) {
                simulateShooting();
            }
        }
    }

    /**
     * Initialize the aimbot functionality
     */
    function initializeAimAssist() {
        initializeCanvas();
        console.log('Aimbot initialized.');

        setInterval(() => {
            aimAtEnemies();
        }, config.aimInterval);
    }

    // Run the script
    initializeAimAssist();
})();