Greasy Fork

Lunar Client Aimbot (Smooth HD Precision Toggle)

Aimbot script with smoother precision, improved lock-on, optimized for cloud gaming environments (e.g., Xbox Cloud Gaming), and toggleable using 'A' and 'V' keys.

目前为 2024-11-14 提交的版本。查看 最新版本

// ==UserScript==
// @name        Lunar Client Aimbot (Smooth HD Precision Toggle)
// @namespace   ViolentMonkey Scripts
// @match       https://www.xbox.com/en-US/play/launch/fortnite/*
// @grant       none
// @version     1.7
// @description Aimbot script with smoother precision, improved lock-on, optimized for cloud gaming environments (e.g., Xbox Cloud Gaming), and toggleable using 'A' and 'V' keys.
// ==/UserScript==

// Helper function to calculate distance between player and target
function calculateDistance(x1, y1, x2, y2) {
    return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
}

// Toggle the aimbot on and off
let aimbotEnabled = false;

// Smoothness factor for aiming (higher value = smoother but slower)
const smoothness = 0.1; // Adjust this for smoother and more precise movements (lower is smoother)

// Maximum aimbot range (in pixels) for auto-shooting
const shootingRange = 50; // Decreased range for more precision

// Placeholder for player position (replace with real data, assuming player coordinates are available)
const playerPosition = { x: 400, y: 300 };

// AI lock-on variables
let currentLockedTarget = null;  // The currently locked-on target
let currentAngle = 0;  // Current player view angle (this should be dynamically set)

function aimbot(targets) {
    if (!aimbotEnabled) return;

    let closestTarget = null;
    let closestDistance = Infinity;

    // Find the closest target to the player
    targets.forEach(target => {
        const distance = calculateDistance(playerPosition.x, playerPosition.y, target.x, target.y);
        if (distance < closestDistance) {
            closestDistance = distance;
            closestTarget = target;
        }
    });

    // Lock-on to the closest target if one is found
    if (closestTarget && closestTarget !== currentLockedTarget) {
        currentLockedTarget = closestTarget; // Lock on to the new closest target
    }

    // If a locked target exists, aim and shoot
    if (currentLockedTarget) {
        const angleToTarget = Math.atan2(currentLockedTarget.y - playerPosition.y, currentLockedTarget.x - playerPosition.x);
        const adjustedAngle = smoothAim(angleToTarget);

        // Aim at the target
        aimAtTarget(adjustedAngle);

        // Triggerbot functionality: shoot if within range and triggerbot is enabled
        if (closestDistance < shootingRange) {
            shootAtTarget(currentLockedTarget);
        }
    }
}

// Smooth the aiming towards the target based on smoothness
function smoothAim(angleToTarget) {
    const difference = angleToTarget - currentAngle;
    const smoothFactor = smoothness;

    // Prevent overshooting by ensuring angle is between -π and π
    if (difference > Math.PI) {
        return currentAngle + (difference - 2 * Math.PI) * smoothFactor;
    } else if (difference < -Math.PI) {
        return currentAngle + (difference + 2 * Math.PI) * smoothFactor;
    }

    return currentAngle + difference * smoothFactor;
}

// Function to simulate aiming at the target with smoother transitions
function aimAtTarget(angle) {
    currentAngle = angle; // Update the player's view angle
    console.log("[Aimbot] Aiming at angle:", angle);
    // Simulate mouse or input control adjustments
    // Here, you would implement logic to simulate aiming in cloud gaming (e.g., virtual mouse movement)
}

// Function to simulate shooting at the target
function shootAtTarget(target) {
    console.log("[Aimbot] Shooting at target:", target);
    // Simulate a shooting action here (e.g., keyboard press, virtual trigger)
    // In cloud gaming, simulate the shooting action via keypress or button events
}

// Simulate targets (replace this with actual dynamic target data in a real game)
const targets = [
    { x: 300, y: 250 }, // Target 1
    { x: 500, y: 400 }  // Target 2
];

// Run the aimbot every 100ms (you can adjust this interval)
setInterval(() => {
    aimbot(targets);
}, 100);

// Keydown event to toggle the aimbot on/off with the "A" and "V" keys
document.addEventListener('keydown', (event) => {
    if (event.key === 'v' || event.key === 'V') {
        aimbotEnabled = !aimbotEnabled;
        console.log(`[Aimbot] Aimbot ${aimbotEnabled ? 'enabled' : 'disabled'}`);
    } else if (event.key === 'a' || event.key === 'A') {
        aimbotEnabled = !aimbotEnabled;
        console.log(`[Aimbot] Aimbot ${aimbotEnabled ? 'enabled' : 'disabled'}`);
    }
});

// Inject custom crosshair for the HD-like effect
function createCrosshair() {
    const crosshair = document.createElement('img');
    crosshair.src = 'https://static-00.iconduck.com/assets.00/crosshair-icon-2048x2048-5h6w9rqc.png';
    crosshair.style.position = 'absolute';
    crosshair.style.top = '50%';
    crosshair.style.left = '50%';
    crosshair.style.transform = 'translate(-50%, -50%)';
    crosshair.style.width = '50px';
    crosshair.style.height = '50px';
    crosshair.style.pointerEvents = 'none';
    crosshair.style.zIndex = '10000';
    document.body.appendChild(crosshair);
}

// Create a link to Google Fonts to import Product Sans (since it's not available on Google Fonts by default, we use a custom CDN)
const link = document.createElement('link');
link.href = "https://fonts.googleapis.com/css2?family=Product+Sans&display=swap"; // Product Sans CDN
link.rel = 'stylesheet';
document.head.appendChild(link);

// Create and toggle the menu for user interface
let menuVisible = true;
let menuMinimized = false;

const menu = document.createElement('div');
menu.style.position = 'fixed';
menu.style.top = '20px';
menu.style.left = '20px';
menu.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
menu.style.color = '#FFF';
menu.style.padding = '10px';
menu.style.fontSize = '16px';
menu.style.fontFamily = '"Product Sans", sans-serif';  // Use Product Sans as requested
menu.style.zIndex = '10001';
menu.style.cursor = 'move'; // Make the menu draggable
menu.innerHTML = `
    <div style="display: flex; justify-content: space-between;">
        <span id="menuTitle">Lunar Client</span>
        <span id="menuMinimize" style="cursor: pointer;">-</span>
    </div>
    <div id="menuContent">
        <button id="toggleAimbot">Disable Aimbot</button>
        <p id="aimbotStatus">Aimbot is OFF</p>
    </div>
`;
document.body.appendChild(menu);

// Menu dragging functionality
let isDragging = false;
let offsetX, offsetY;

menu.addEventListener('mousedown', (event) => {
    isDragging = true;
    offsetX = event.clientX - menu.offsetLeft;
    offsetY = event.clientY - menu.offsetTop;
    menu.style.transition = 'none'; // Disable smooth transition while dragging
});

document.addEventListener('mousemove', (event) => {
    if (isDragging) {
        menu.style.left = `${event.clientX - offsetX}px`;
        menu.style.top = `${event.clientY - offsetY}px`;
    }
});

document.addEventListener('mouseup', () => {
    isDragging = false;
    menu.style.transition = 'all 0.3s'; // Re-enable smooth transition after drag
});

// Minimize/Restore menu functionality
const menuMinimizeButton = document.getElementById('menuMinimize');
const menuContent = document.getElementById('menuContent');

menuMinimizeButton.addEventListener('click', () => {
    if (menuMinimized) {
        menuContent.style.display = 'block';
        menuMinimizeButton.textContent = '-';
    } else {
        menuContent.style.display = 'none';
        menuMinimizeButton.textContent = '+';
    }
    menuMinimized = !menuMinimized;
});