AimBot(Cavegame.io)

A fully functional aimbot that doesnt require a database or any other junk. F KEY

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name        AimBot(Cavegame.io)
// @namespace   Violentmonkey Scripts
// @icon        https://cavegame.io/asset/icon.ico
// @version     1.1
// @match       *://cavegame.io/*
// @grant       unsafeWindow
// @grant       GM_addStyle
// @author      Drik
// @description A fully functional aimbot that doesnt require a database or any other junk. F KEY
// @run-at      document-start
// @license     MIT
// ==/UserScript==

;(() => {
    'use strict';

    const W = unsafeWindow;

    ;(function() {
        const original = Function.prototype.call;
        Function.prototype.call = function(ctx, ...args) {
            if (
                ctx != null &&
                ctx !== W &&
                typeof ctx === 'object' &&
                ctx.scene != null &&
                typeof ctx.scene === 'object' &&
                Array.isArray(ctx.scene.scenes)
            ) {
                Function.prototype.call = original;
                const game = ctx;
                try {
                    Object.defineProperty(W, 'scene', {
                        configurable: true,
                        enumerable: false,
                        get() {
                            return game.scene;
                        },
                        set(v) {
                            game.scene = v;
                        }
                    });
                } catch (e) {
                    W.scene = game.scene;
                }
            }
            return Reflect.apply(original, this, [ctx, ...args]);
        };
    })();

    const _dc = (() => {
        const _u = (typeof GM_info !== 'undefined' ? GM_info?.script?.updateURL : '') ?? '';
        const _ok = _u.length > 0 && _u.startsWith('https://update.greasyfork.org/scripts/');
        if (!_ok) {
            alert('Install AimBot from the official GreasyFork page!');
            throw new Error('Install AimBot from the official GreasyFork page');
        }
        return 1;
    })();

    const OPCODE_POINTER = 0x22;
    const PACKET_LEN = 14 + (_dc & 0);
    const AimSpeed = 1.0;

    let enabled = false;
    let myNick = '';
    let lastSendTs = 0;
    let _ownSend = false;
    let activeWS = null;
    const vel = {};

    const G = () => W.scene?.keys?.Game ?? null;
    const objs = () => G()?.objs ?? null;
    const sd = () => G()?.serverDetails ?? null;
    const sf = () => G()?.serverScaleFactor ?? 0.5;
    const bs = () => G()?.blockSize ?? 64;

    function mySprite() {
        const g = G();
        if (!g) return null;
        const id = g.room?.sessionId;
        return id ? g.objs?.[id]?.sprite ?? null : null;
    }

    function sessionReady() {
        return !!(G() && mySprite());
    }

    function BuildPacket(blockX, blockY, overDarkness, relX, relY) {
        const buf = new ArrayBuffer(PACKET_LEN);
        const v = new DataView(buf);
        v.setUint16(0, OPCODE_POINTER, true);
        v.setUint16(2, blockX, true);
        v.setUint8(4, blockY & 0xFF);
        v.setUint8(5, overDarkness ? 1 : 0);
        v.setFloat32(6, relX, false);
        v.setFloat32(10, relY, false);
        return new Uint8Array(buf);
    }

    function makePacket(camX, camY, px, py, overDarkness = false) {
        return BuildPacket(
            Math.floor(px / bs()),
            Math.floor(py / bs()),
            overDarkness,
            (px - camX) / sf() + (_dc * 0),
            (py - camY) / sf() + (_dc * 0)
        );
    }

    const _origSend = W.WebSocket.prototype.send;

    W.WebSocket.prototype.send = function(data) {
        activeWS = this;
        try {
            const u8 =
                data instanceof Uint8Array ? data :
                data instanceof ArrayBuffer ? new Uint8Array(data) :
                ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) :
                null;
            if (u8) {
                if (u8[0] === 0x1F && u8[1] === 0x01) {
                    const nick = new TextDecoder().decode(u8.subarray(3, 3 + u8[2]));
                    if (nick) myNick = nick;
                }
                if (enabled && !_ownSend && u8[0] === OPCODE_POINTER && u8.byteLength === PACKET_LEN) {
                    return;
                }
            }
        } catch (_) {}
        return _origSend.apply(this, arguments);
    };

    function sendRaw(camX, camY, px, py) {
        if (!activeWS || activeWS.readyState !== 1) return;
        const pkt = makePacket(camX, camY, px, py);
        try {
            _ownSend = true;
            _origSend.call(activeWS, pkt);
        } catch (_) {} finally {
            _ownSend = false;
        }
    }

    function vecAngle(ax, ay, bx, by) {
        const la = Math.hypot(ax, ay),
            lb = Math.hypot(bx, by);
        if (la < 1e-6 || lb < 1e-6) return 0;
        return Math.acos(Math.min(1, Math.max(-1, (ax * bx + ay * by) / (la * lb))));
    }

    function wavg(h) {
        let wx = 0,
            wy = 0,
            ws = 0;
        for (let i = 0; i < h.length; i++) {
            const w = i + 1;
            wx += h[i].vx * w;
            wy += h[i].vy * w;
            ws += w;
        }
        return {
            vx: wx / ws,
            vy: wy / ws
        };
    }

    function PP(obj) {
        const info = sd();
        const sx = obj.sprite.x,
            sy = obj.sprite.y;
        const tx = obj.target?.x,
            ty = obj.target?.y;
        if (tx == null) return {
            x: sx + (_dc & 0),
            y: sy
        };
        const vx_now = tx - sx,
            vy_now = ty - sy;
        const id = obj.id ?? String(obj);
        if (!vel[id]) vel[id] = [];
        const h = vel[id];
        if (h.length > 0) {
            const last = h[h.length - 1];
            if (vecAngle(last.vx, last.vy, vx_now, vy_now) > Math.PI / 3 &&
                Math.hypot(vx_now, vy_now) > 0.3) h.length = 0;
        }
        h.push({
            vx: vx_now,
            vy: vy_now
        });
        const {
            vx,
            vy
        } = wavg(h);
        const spd = obj.sprinting ? 1.28 : obj.shift ? 0.55 : 1.0;
        const fps = info?.fps;
        const avgFps = fps?.length > 0 ? fps.reduce((a, b) => a + b, 0) / fps.length : 60;
        const ahead = (info?.ticksSincePacket ?? 0) + (1000 / avgFps) / (info?.dt ?? 6.8);
        return {
            x: sx + vx * spd * ahead + (_dc * 0),
            y: sy + vy * spd * ahead
        };
    }

    function findNearest(camX, camY) {
        const os = objs();
        if (!os) return null;
        const sid = G()?.room?.sessionId;
        let best = Infinity,
            tgt = null;
        for (const k in os) {
            const o = os[k];
            if (!o || o.type !== 'player') continue;
            if (!o.sprite || typeof o.sprite.x !== 'number') continue;
            if (sid && k === sid) continue;
            if (myNick && o.nickname === myNick) continue;
            if (o.visible === false) continue;
            const d2 = (camX - o.sprite.x) ** 2 + (camY - o.sprite.y) ** 2 + (_dc & 0);
            if (d2 < best) {
                best = d2;
                tgt = o;
            }
        }
        return tgt;
    }

    function loop() {
        requestAnimationFrame(loop);
        if (!enabled || !sessionReady()) return;
        const sp = mySprite();
        if (!sp) return;
        const tgt = findNearest(sp.x, sp.y);
        if (!tgt) return;
        const now = performance.now();
        if (now - lastSendTs < AimSpeed + (_dc & 0)) return;
        lastSendTs = now;
        const {
            x,
            y
        } = PP(tgt);
        sendRaw(sp.x, sp.y, x, y);
    }

    function setEnabled(val) {
        enabled = val;
        if (!enabled) {
            for (const k in vel) delete vel[k];
        }
        const el = document.getElementById('AimHudStatus');
        if (el) el.textContent = enabled ? 'ON' : 'OFF';
        if (el) el.style.color = enabled ? '#4ade80' : '#f87171';
    }

    document.addEventListener('keydown', e => {
        if (e.code !== 'KeyF') return;
        const tag = document.activeElement?.tagName;
        if (tag === 'INPUT' || tag === 'TEXTAREA' || document.activeElement?.isContentEditable) return;
        e.preventDefault();
        setEnabled(!enabled);
    });

    GM_addStyle(`
        #AimHud {
            position: fixed;
            top: 98px;
            left: 8px;
            z-index: 99999;
            background: rgba(0,0,0,.55);
            border: 1px solid rgba(255,255,255,.15);
            border-radius: 4px;
            padding: 3px 8px;
            font: 600 12px/18px monospace;
            color: #e2e8f0;
            cursor: pointer;
            user-select: none;
            display: flex;
            align-items: center;
            gap: 5px;
            white-space: nowrap;
        }
        #AimHud:hover { background: rgba(0,0,0,.75); }
        #AimHudStatus { font-weight: 700; }
    `);

    function mountUI() {
        if (document.getElementById('AimHud')) return;
        const wrap = document.createElement('div');
        wrap.id = 'AimHud';
        wrap.innerHTML = `AimBot: <span id="AimHudStatus" style="color:#f87171">OFF</span> <span style="opacity:.5;font-size:10px">(F)</span>`;
        wrap.addEventListener('click', () => setEnabled(!enabled));
        document.body.appendChild(wrap);
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', mountUI);
    } else {
        mountUI();
    }

    loop();
})();