Greasy Fork

Greasy Fork is available in English.

Fortnite Xbox Cloud Aim Assist (Full)

1

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Fortnite Xbox Cloud Aim Assist (Full)
// @namespace    http://tampermonkey.net/
// @version      19
// @description  1
// @author       You
// @match        https://www.xbox.com/en-US/play/launch/fortnite/BT5P2X999VH2
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Configuration: Customize selectors for player and enemy elements
    const config = {
        enemySelector: '.enemy-class', // Replace with actual enemy selector
        playerSelector: '.PlayerInfo-module__container___ROgVL', // Replace with actual player selector
        aimInterval: 100, // Interval in milliseconds for aim checks
        aimSmoothing: 0.2 // Smoothing factor for more natural aim adjustments
    };

    /**
     * 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 enemy.
     * @param {number} angle - The calculated angle to rotate the player.
     */
    function smoothAim(angle) {
        const player = document.querySelector(config.playerSelector);
        if (player) {
            const currentRotation = parseFloat(player.style.transform.replace('rotate(', '').replace('deg)', '')) || 0;
            const targetRotation = angle;
            const smoothedRotation = currentRotation + (targetRotation - currentRotation) * config.aimSmoothing;
            player.style.transform = `rotate(${smoothedRotation}deg)`;
        }
    }

    /**
     * Aim at the closest enemy based on the player's position.
     */
    function aimAtEnemies() {
        const enemy = document.querySelector(config.enemySelector);
        const player = document.querySelector(config.playerSelector);

        // Ensure enemy and player elements exist
        if (!enemy || !player) {
            console.warn('Enemy or player element not found.');
            return;
        }

        // Get bounding rectangles of the enemy and player
        const enemyRect = enemy.getBoundingClientRect();
        const playerRect = player.getBoundingClientRect();

        // Calculate center coordinates for both the enemy and player
        const enemyX = enemyRect.x + enemyRect.width / 2;
        const enemyY = enemyRect.y + enemyRect.height / 2;
        const playerX = playerRect.x + playerRect.width / 2;
        const playerY = playerRect.y + playerRect.height / 2;

        // Calculate the angle to aim at the enemy
        const angle = calculateAngle(enemyX, enemyY, playerX, playerY);

        // Smoothly rotate player to aim at the enemy
        smoothAim(angle);

        console.log(`Aimed at enemy: angle = ${angle.toFixed(2)} degrees`);
    }

    /**
     * Initialize the aim assist functionality.
     */
    function initializeAimAssist() {
        console.log('Aim Assist Initialized');
        setInterval(aimAtEnemies, config.aimInterval);
    }

    // Start the aim assist script
    initializeAimAssist();
})();