Greasy Fork

Greasy Fork is available in English.

xbox cloud fortnite

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

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

// ==UserScript==
// @name         xbox cloud fortnite
// @namespace    http://tampermonkey.net/
// @version      0.4
// @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==

// Configuration settings
const AIM_ASSIST_STRENGTH = 0.8; // Aim assist strength (0-1)
const PLAYER_DETECTION_RADIUS = 150; // Player detection radius in pixels
const AIM_ASSIST_SPEED = 5; // Aim assist speed in pixels per frame
const FIRE_RATE = 100; // Time in milliseconds between auto-fire shots

// Flags and variables
let detectedPlayers = [];
let aimAssistEnabled = false;
let aimAssistTarget = null;
let autoFireEnabled = false;

// Create a GUI element
const guiContainer = document.createElement('div');
guiContainer.style.position = 'absolute';
guiContainer.style.top = '10px';
guiContainer.style.right = '10px';
guiContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
guiContainer.style.color = 'white';
guiContainer.style.padding = '10px';
guiContainer.style.borderRadius = '5px';
guiContainer.style.zIndex = '1000';
guiContainer.innerHTML = `
    <h4>Game Assistant</h4>
    <button id="toggleAimAssist">Toggle Aim Assist</button>
    <button id="toggleAutoFire">Toggle Auto Fire</button>
`;
document.body.appendChild(guiContainer);

// Function to detect players based on pixel color
function detectPlayers() {
    const canvas = document.querySelector('canvas');
    if (!canvas) return;

    const ctx = canvas.getContext('2d');
    const width = canvas.width;
    const height = canvas.height;

    detectedPlayers = []; // Reset the array

    // Check every pixel on the canvas for player colors
    for (let x = 0; x < width; x++) {
        for (let y = 0; y < height; y++) {
            const pixelColor = ctx.getImageData(x, y, 1, 1).data;

            // Adjust color matching logic as needed
            if (pixelColor[0] > 100 && pixelColor[1] < 80 && pixelColor[2] < 80) { // Example color check for a player
                detectedPlayers.push({ x, y });
            }
        }
    }
}

// Function to draw boxes around detected players
function drawBoxes() {
    const canvas = document.querySelector('canvas');
    if (!canvas) return;

    const ctx = canvas.getContext('2d');
    ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear previous frames

    ctx.strokeStyle = 'red'; // Box color
    ctx.lineWidth = 2;

    // Draw boxes around each detected player
    detectedPlayers.forEach(player => {
        ctx.strokeRect(player.x - 15, player.y - 15, 30, 30); // Box dimensions
    });
}

// Function to apply the aim assist
function applyAimAssist() {
    const canvas = document.querySelector('canvas');
    if (!canvas || !aimAssistEnabled || !aimAssistTarget) return;

    const crosshairX = canvas.width / 2;
    const crosshairY = canvas.height / 2;

    const aimAssistDirectionX = aimAssistTarget.x - crosshairX;
    const aimAssistDirectionY = aimAssistTarget.y - crosshairY;

    const aimAssistDistance = Math.sqrt(aimAssistDirectionX ** 2 + aimAssistDirectionY ** 2);

    if (aimAssistDistance > 0) {
        const aimAssistSpeedX = (aimAssistDirectionX / aimAssistDistance) * AIM_ASSIST_SPEED;
        const aimAssistSpeedY = (aimAssistDirectionY / aimAssistDistance) * AIM_ASSIST_SPEED;

        // Dispatch mousemove event to apply aim assist
        const aimAssistX = crosshairX + aimAssistSpeedX;
        const aimAssistY = crosshairY + aimAssistSpeedY;
        canvas.dispatchEvent(new MouseEvent('mousemove', { clientX: aimAssistX, clientY: aimAssistY }));
    }
}

// Function to simulate mouse click for auto fire
function simulateClick() {
    const canvas = document.querySelector('canvas');
    if (canvas) {
        const mouseX = canvas.width / 2; // Center mouse
        const mouseY = canvas.height / 2; // Adjust as needed

        canvas.dispatchEvent(new MouseEvent('mousedown', { clientX: mouseX, clientY: mouseY }));
        canvas.dispatchEvent(new MouseEvent('mouseup', { clientX: mouseX, clientY: mouseY }));
    }
}

// Auto-fire loop
function startAutoFire() {
    if (!autoFireEnabled) return;

    simulateClick();
    setTimeout(startAutoFire, FIRE_RATE);
}

// Toggle aim assist state
function toggleAimAssist() {
    aimAssistEnabled = !aimAssistEnabled;
    console.log(`Aim assist ${aimAssistEnabled ? 'enabled' : 'disabled'}`);
}

// Toggle auto fire state
function toggleAutoFire() {
    autoFireEnabled = !autoFireEnabled;
    console.log(`Auto fire ${autoFireEnabled ? 'enabled' : 'disabled'}`);

    if (autoFireEnabled) {
        startAutoFire();
    }
}

// Main loop to run detection, drawing, and apply aim assist
function mainLoop() {
    detectPlayers();
    drawBoxes();
    applyAimAssist();
    requestAnimationFrame(mainLoop); // Loop the function
}

// GUI button event listeners
document.getElementById('toggleAimAssist').addEventListener('click', toggleAimAssist);
document.getElementById('toggleAutoFire').addEventListener('click', toggleAutoFire);

// Start the main loop
mainLoop();