Josiahiscool73

testconf

Jul 29th, 2025
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.56 KB | None | 0 0
  1. function loadScript(url) {
  2. return new Promise((resolve, reject) => {
  3. const script = document.createElement('script');
  4. script.src = url;
  5. script.onload = resolve;
  6. script.onerror = reject;
  7. document.head.appendChild(script);
  8. });
  9. }
  10.  
  11. console.log("Loading TensorFlow.js core...");
  12. loadScript('https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js')
  13. .then(() => {
  14. console.log("TensorFlow.js core LOADED.");
  15. console.log("Loading WebGPU backend...");
  16. return loadScript('https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf-backend-webgpu.min.js');
  17. })
  18. .then(() => {
  19. console.log("WebGPU backend script LOADED.");
  20. console.log("Setting backend to WebGPU...");
  21.  
  22. return tf.setBackend('webgpu').then(() => tf.ready());
  23. })
  24. .then(() => {
  25. console.log("WebGPU backend set and ready.");
  26. console.log("Loading Pose detection model...");
  27. return loadScript('https://cdn.jsdelivr.net/npm/@tensorflow-models/[email protected]/dist/pose-detection.min.js');
  28. })
  29. .then(() => {
  30. console.log("Pose detection model script LOADED.");
  31. console.log("✅ Libraries and WebGPU backend successfully loaded. You can now run the main script.");
  32. })
  33. .catch(error => {
  34. console.error("❌ Failed to load required libraries:", error);
  35. alert("Error loading dependency scripts. Check the console.");
  36. });
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. (function() {
  53. 'use strict';
  54.  
  55. // =================================================================================================
  56. // CONFIGURATION
  57. // =================================================================================================
  58. const config = {
  59. detection: {
  60. enabled: true, // Toggle AI detection on/off
  61. modelType: poseDetection.SupportedModels.MoveNet, // AI model to use (MoveNet is fastest)
  62. detectorConfig: {
  63. modelType: poseDetection.movenet.modelType.SINGLEPOSE_LIGHTNING, // Lightning model for speed
  64. enableSmoothing: true, // Smooths detection between frames
  65. minPoseScore: 0.25 // Minimum confidence score to consider a detection valid
  66. },
  67. keypointConfidence: 0.20, // Minimum confidence for individual body keypoints
  68. maxDetections: 1, // Maximum number of players to detect
  69. processingInterval: 5, // Process every Nth frame (higher = better performance)
  70. skipFrames: 1, // Additional frames to skip between processing
  71. ignoreSelfRegion: { // Area to ignore (your character)
  72. enabled: true, // Toggle self-region ignore
  73. xPercent: 0.00, // X position (0-1 = left-right)
  74. yPercent: 0.27, // Y position (0-1 = top-bottom)
  75. widthPercent: 0.37, // Width of ignored region
  76. heightPercent: 0.74 // Height of ignored region
  77. }
  78. },
  79. game: {
  80. videoSelector: 'video[aria-label="Game Stream for unknown title"]', // CSS selector for game video
  81. containerSelector: '#game-stream', // CSS selector for game container
  82. autoShoot: false, // Enable automatic shooting when target locked
  83. triggerOptions: {
  84. delayBeforeShoot: 10, // Milliseconds delay before shooting
  85. burstMode: false, // Enable burst fire mode
  86. burstCount: 3, // Number of shots in burst
  87. burstInterval: 100 // Milliseconds between burst shots
  88. }
  89. },
  90. aim: {
  91. activationKey: 'KeyQ', // Hotkey to activate aimbot (KeyQ = Q key)
  92. fovRadius: 250, // Radius in pixels for target acquisition (Increased for slowdown to feel better)
  93. aimPoint: "torso_center", // Where to aim on body (torso_center/head/etc)
  94. headOffset: 0.15, // Vertical offset when aiming for head
  95. bodyOffset: 0.4, // Vertical offset when aiming for body
  96. targetPriority: "center", // Priority targets near screen center or mouse
  97. targetSwitchCooldown: 0.1, // Seconds before switching to new target
  98. triggerThreshold: 0.7, // How close to center before shooting (0-1)
  99. aimSpeed: { // Legacy smooth aiming settings (used if smart slowdown is off)
  100. enabled: true,
  101. speedPercent: 45.0
  102. },
  103. // ==================================================================================
  104. // NEW: SMART SLOWDOWN CONFIGURATION
  105. // ==================================================================================
  106. smartSlowdown: {
  107. enabled: true, // Set to true to enable dynamic speed adjustment
  108. maxSpeed: 95.0, // Speed when the cursor is far from the target (percentage)
  109. minSpeed: 15, // Speed when the cursor is on the target (percentage)
  110. slowdownRadius: 110 // The distance from the target (in pixels) where the slowdown starts
  111. },
  112. prediction: { // Advanced target prediction
  113. enabled: false, // Toggle prediction system
  114. latencyCompensation: 50, // Milliseconds to compensate for delay
  115. jitterBufferSize: 3, // Frames to analyze for smoothing
  116. maxVelocity: 1000, // Maximum predicted speed (pixels/sec)
  117. smoothingFactor: 0.2, // How much to smooth movements (0-1)
  118. predictionScale: 1.2 // How far to predict ahead
  119. }
  120. },
  121. visual: {
  122. showDebugInfo: true, // Show technical info overlay
  123. rainbowMode: { // Fun colorful mode
  124. enabled: true, // Toggle rainbow colors
  125. speed: 0.1 // Rainbow color cycle speed
  126. },
  127. crosshair: { // Crosshair settings
  128. enabled: true, // Toggle crosshair
  129. style: 'dot', // Type: dot/cross/circle
  130. color: 'lime', // Default color
  131. size: 3, // Size in pixels
  132. centerOnGameScreen: true // Lock to game center
  133. },
  134. targetLock: { // Target highlighting
  135. enabled: true, // Toggle target box
  136. color: 'red', // Box color
  137. style: 'full' // Style: full/corners
  138. },
  139. fovCircle: { // Field of view indicator
  140. enabled: true, // Toggle FOV circle
  141. color: 'rgba(255,255,255,0.3)', // Circle color
  142. lineWidth: 1, // Border thickness
  143. centerOnGameScreen: true, // Lock to game center
  144. showOnlyWhenAiming: true // Only show when active
  145. },
  146. performanceMetrics: { // FPS counter
  147. enabled: true, // Toggle performance display
  148. position: 'top-left' // Screen position
  149. },
  150. drawIgnoreRegion: { // Visualize ignored area
  151. enabled: true, // Toggle region display
  152. color: 'rgba(50, 50, 50, 0.4)', // Shading color
  153. lineWidth: 1, // Border thickness
  154. showOnlyWhenAiming: true // Only show when active
  155. }
  156. }
  157. };
  158.  
  159. // =================================================================================================
  160. // STATE
  161. // =================================================================================================
  162. const state = {
  163. gameVideo: null,
  164. detectionModel: null,
  165. modelLoaded: false,
  166. currentTarget: null,
  167. lastTargetSwitch: 0,
  168. frameCount: 0,
  169. lastDetectionTime: 0,
  170. rainbowHue: 0,
  171. performance: {
  172. fps: 0,
  173. framesThisSecond: 0,
  174. lastFpsUpdate: 0,
  175. detectionTime: 0,
  176. avgDetectionTime: 0,
  177. detectionTimeHistory: []
  178. },
  179. ui: {
  180. overlayCanvas: null,
  181. overlayCtx: null,
  182. offscreenCanvas: null,
  183. offscreenCtx: null
  184. },
  185. input: {
  186. lastMouseX: window.innerWidth / 2,
  187. lastMouseY: window.innerHeight / 2,
  188. leftButtonDown: false,
  189. rightButtonDown: false,
  190. shootingStartTime: 0,
  191. activeKeys: new Set()
  192. },
  193. isShooting: false,
  194. currentWeapon: 0,
  195. prediction: {
  196. networkLatency: 0,
  197. lastTargetId: null,
  198. targetHistory: {}, // Stores history for each target
  199. lastPrediction: { x: 0, y: 0 },
  200. backend: 'unknown'
  201. }
  202. };
  203.  
  204. // =================================================================================================
  205. // DEBUGGER
  206. // =================================================================================================
  207. const debug = {
  208. log: (...args) => console.log(`[Capybara AI Aimbot]`, ...args),
  209. warn: (...args) => console.warn(`[Capybara AI Aimbot]`, ...args),
  210. error: (...args) => console.error(`[Capybara AI Aimbot]`, ...args)
  211. };
  212.  
  213. function showNotification(message, type = 'info', duration = 3000) {
  214. const n = document.createElement('div');
  215. n.style.cssText = `position:fixed;top:20px;left:50%;transform:translateX(-50%);padding:10px 20px;border-radius:5px;color:white;z-index:1000000;font-family:sans-serif;font-size:16px;box-shadow:0 2px 10px rgba(0,0,0,0.2);background-color:${
  216. type === 'error' ? 'rgba(255,0,0,0.8)' :
  217. type === 'warning' ? 'rgba(255,165,0,0.8)' :
  218. 'rgba(0,0,0,0.7)'}`;
  219. n.textContent = message;
  220. document.body.appendChild(n);
  221. setTimeout(() => n.remove(), duration);
  222. }
  223.  
  224. // =================================================================================================
  225. // IMPROVED PREDICTION SYSTEM
  226. // =================================================================================================
  227. function initializeTargetHistory(targetId) {
  228. if (!state.prediction.targetHistory[targetId]) {
  229. state.prediction.targetHistory[targetId] = {
  230. positions: [],
  231. timestamps: [],
  232. velocities: [],
  233. smoothedVelocity: { x: 0, y: 0 }
  234. };
  235. }
  236. }
  237.  
  238. function updateTargetHistory(targetId, position, timestamp) {
  239. initializeTargetHistory(targetId);
  240. const history = state.prediction.targetHistory[targetId];
  241.  
  242. history.positions.push({ x: position.x, y: position.y });
  243. history.timestamps.push(timestamp);
  244.  
  245. if (history.positions.length > 1) {
  246. const prevPos = history.positions[history.positions.length - 2];
  247. const prevTime = history.timestamps[history.timestamps.length - 2];
  248. const dt = (timestamp - prevTime) / 1000; // seconds
  249.  
  250. if (dt > 0) {
  251. const vx = (position.x - prevPos.x) / dt;
  252. const vy = (position.y - prevPos.y) / dt;
  253.  
  254. const maxV = config.aim.prediction.maxVelocity;
  255. const limitedVx = Math.max(-maxV, Math.min(maxV, vx));
  256. const limitedVy = Math.max(-maxV, Math.min(maxV, vy));
  257.  
  258. history.velocities.push({ x: limitedVx, y: limitedVy });
  259.  
  260. const smoothing = config.aim.prediction.smoothingFactor;
  261. history.smoothedVelocity.x = history.smoothedVelocity.x * (1 - smoothing) + limitedVx * smoothing;
  262. history.smoothedVelocity.y = history.smoothedVelocity.y * (1 - smoothing) + limitedVy * smoothing;
  263. }
  264. }
  265.  
  266. const bufferSize = config.aim.prediction.jitterBufferSize;
  267. if (history.positions.length > bufferSize) {
  268. history.positions.shift();
  269. history.timestamps.shift();
  270. if (history.velocities.length > 0) history.velocities.shift();
  271. }
  272. }
  273.  
  274. function calculatePredictedPosition(targetId) {
  275. if (!state.prediction.targetHistory[targetId] ||
  276. state.prediction.targetHistory[targetId].positions.length < 2) {
  277. return null;
  278. }
  279.  
  280. const history = state.prediction.targetHistory[targetId];
  281. const currentPos = history.positions[history.positions.length - 1];
  282. const currentTime = history.timestamps[history.timestamps.length - 1];
  283.  
  284. const totalLatency = state.prediction.networkLatency +
  285. state.performance.detectionTime +
  286. config.aim.prediction.latencyCompensation;
  287.  
  288. const vx = history.smoothedVelocity.x;
  289. const vy = history.smoothedVelocity.y;
  290.  
  291. const scale = config.aim.prediction.predictionScale;
  292.  
  293. const predictedX = currentPos.x + (vx * totalLatency / 1000) * scale;
  294. const predictedY = currentPos.y + (vy * totalLatency / 1000) * scale;
  295.  
  296. return {
  297. x: predictedX,
  298. y: predictedY,
  299. velocityX: vx,
  300. velocityY: vy
  301. };
  302. }
  303.  
  304. function updateTargetPrediction(newTarget) {
  305. const now = performance.now();
  306.  
  307. if (!newTarget) {
  308. state.prediction.lastTargetId = null;
  309. return;
  310. }
  311.  
  312. updateTargetHistory(newTarget.id, newTarget.screenPosition, now);
  313. state.prediction.lastTargetId = newTarget.id;
  314. }
  315.  
  316. // =================================================================================================
  317. // BACKEND INITIALIZATION
  318. // =================================================================================================
  319. async function setupTensorFlow() {
  320. try {
  321. debug.log("Initializing TensorFlow.js with optimal backend...");
  322.  
  323. const backends = [
  324. { name: 'webnn', test: () => typeof navigator.ml !== 'undefined' },
  325. { name: 'webgpu', test: () => typeof navigator.gpu !== 'undefined' },
  326. { name: 'webgl', test: () => true }
  327. ];
  328.  
  329. let selectedBackend = null;
  330.  
  331. for (const backend of backends) {
  332. if (backend.test()) {
  333. try {
  334. await tf.setBackend(backend.name);
  335. await tf.ready();
  336.  
  337. if (backend.name === 'webgl') {
  338. tf.env().set('WEBGL_VERSION', 2);
  339. tf.env().set('WEBGL_CPU_FORWARD', false);
  340. tf.env().set('WEBGL_PACK', true);
  341. tf.env().set('WEBGL_FORCE_F16_TEXTURES', true);
  342. tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);
  343. tf.env().set('WEBGL_FLUSH_THRESHOLD', 1.75);
  344. }
  345.  
  346. selectedBackend = backend.name;
  347. state.prediction.backend = backend.name;
  348. debug.log(`Successfully initialized ${backend.name.toUpperCase()} backend`);
  349. break;
  350. } catch (e) {
  351. debug.warn(`Failed to initialize ${backend.name}:`, e.message);
  352. }
  353. }
  354. }
  355.  
  356. if (!selectedBackend) {
  357. throw new Error("Could not initialize any backend");
  358. }
  359.  
  360. return true;
  361. } catch (e) {
  362. debug.error("TF setup failed:", e);
  363. showNotification("Failed to initialize AI backend", "error");
  364. return false;
  365. }
  366. }
  367.  
  368. // =================================================================================================
  369. // MODEL LOADING
  370. // =================================================================================================
  371. async function loadDetectionModel() {
  372. debug.log("Loading MoveNet model...");
  373. try {
  374. if (!await setupTensorFlow()) throw new Error("TF setup failed");
  375. if (typeof poseDetection === "undefined") throw new Error("Pose Detection API not loaded.");
  376.  
  377. state.detectionModel = await poseDetection.createDetector(
  378. config.detection.modelType,
  379. config.detection.detectorConfig
  380. );
  381.  
  382. const tC = document.createElement('canvas');
  383. tC.width = 192;
  384. tC.height = 192;
  385. await state.detectionModel.estimatePoses(tC);
  386.  
  387. state.modelLoaded = true;
  388. debug.log("MoveNet model loaded!");
  389. showNotification(`AI Model Loaded (${state.prediction.backend.toUpperCase()})`, "info");
  390. return true;
  391. } catch (e) {
  392. debug.error("Failed to load MoveNet model:", e);
  393. showNotification("Error loading AI model! Check console.", "error");
  394. return false;
  395. }
  396. }
  397.  
  398. // =================================================================================================
  399. // TARGET DETECTION
  400. // =================================================================================================
  401. function calculateBoundingBoxFromKeypoints(kps) {
  402. if (!kps || kps.length === 0) return null;
  403.  
  404. let mX = Infinity, mY = Infinity, mAX = -Infinity, mAY = -Infinity, vK = 0;
  405. kps.forEach(k => {
  406. if (k.score && k.score >= config.detection.keypointConfidence) {
  407. mX = Math.min(mX, k.x);
  408. mY = Math.min(mY, k.y);
  409. mAX = Math.max(mAX, k.x);
  410. mAY = Math.max(mAY, k.y);
  411. vK++;
  412. }
  413. });
  414.  
  415. if (vK < 5) return null;
  416.  
  417. const w = mAX - mX, h = mAY - mY, pX = 0.1 * w, pY = 0.1 * h;
  418. return {
  419. x: Math.max(0, mX - pX),
  420. y: Math.max(0, mY - pY),
  421. width: w + 2 * pX,
  422. height: h + 2 * pY,
  423. validKeypoints: vK
  424. };
  425. }
  426.  
  427. function calculateAimTarget(pred, vRect) {
  428. if (!pred || !vRect || !state.gameVideo) return null;
  429.  
  430. const [vBx, vBy, vBw, vBh] = pred.bbox || [0, 0, 0, 0];
  431. const sBx = vRect.left + vBx / state.gameVideo.videoWidth * vRect.width;
  432. const sBy = vRect.top + vBy / state.gameVideo.videoHeight * vRect.height;
  433. const sBw = vBw / state.gameVideo.videoWidth * vRect.width;
  434. const sBh = vBh / state.gameVideo.videoHeight * vRect.height;
  435.  
  436. let tX = sBx + sBw / 2;
  437. let tY = sBy + sBh * (config.aim?.bodyOffset || 0.4);
  438.  
  439. return {
  440. x: tX,
  441. y: tY,
  442. width: sBw,
  443. height: sBh,
  444. bboxRaw: pred.bbox
  445. };
  446. }
  447.  
  448. function findBestTarget(predictions) {
  449. if (!predictions || !Array.isArray(predictions)) return null;
  450. if (!state.gameVideo) return null;
  451.  
  452. const videoRect = state.gameVideo.getBoundingClientRect();
  453. if (!videoRect || videoRect.width === 0) return null;
  454.  
  455. const gameScreenCenterX = videoRect.left + videoRect.width / 2;
  456. const gameScreenCenterY = videoRect.top + videoRect.height / 2;
  457. let bestTarget = null;
  458. let bestScore = Infinity;
  459.  
  460. predictions.forEach((prediction, index) => {
  461. const targetInfo = calculateAimTarget(prediction, videoRect);
  462. if (!targetInfo) return;
  463.  
  464. let referenceX, referenceY;
  465. if (config.aim?.targetPriority === "center") {
  466. referenceX = gameScreenCenterX;
  467. referenceY = gameScreenCenterY;
  468. } else {
  469. referenceX = state.input.lastMouseX;
  470. referenceY = state.input.lastMouseY;
  471. }
  472.  
  473. const dx = targetInfo.x - referenceX;
  474. const dy = targetInfo.y - referenceY;
  475. const distanceToPriorityPoint = Math.sqrt(dx * dx + dy * dy);
  476.  
  477. if (distanceToPriorityPoint > (config.aim?.fovRadius || 200)) return;
  478.  
  479. let score = distanceToPriorityPoint * (1.5 - (prediction.score || 0));
  480.  
  481. if (score < bestScore) {
  482. bestScore = score;
  483. bestTarget = {
  484. prediction,
  485. screenPosition: targetInfo,
  486. distance: distanceToPriorityPoint,
  487. score: prediction.score,
  488. id: index
  489. };
  490. }
  491. });
  492.  
  493. return bestTarget;
  494. }
  495.  
  496. // =================================================================================================
  497. // INPUT CONTROLLER
  498. // =================================================================================================
  499. const InputController = {
  500. init: function() {
  501. state.input.lastMouseX = window.innerWidth / 2;
  502. state.input.lastMouseY = window.innerHeight / 2;
  503.  
  504. document.addEventListener('mousemove', e => {
  505. state.input.lastMouseX = e.clientX;
  506. state.input.lastMouseY = e.clientY;
  507. });
  508.  
  509. document.addEventListener('keydown', e => state.input.activeKeys.add(e.code));
  510. document.addEventListener('keyup', e => state.input.activeKeys.delete(e.code));
  511.  
  512. document.addEventListener('mousedown', e => {
  513. if (e.button === 0) {
  514. state.input.leftButtonDown = true;
  515. state.input.shootingStartTime = performance.now();
  516. }
  517. if (e.button === 2) state.input.rightButtonDown = true;
  518. });
  519.  
  520. document.addEventListener('mouseup', e => {
  521. if (e.button === 0) {
  522. state.input.leftButtonDown = false;
  523. state.input.shootingStartTime = 0;
  524. }
  525. if (e.button === 2) state.input.rightButtonDown = false;
  526. });
  527.  
  528. debug.log("Input controller initialized");
  529. return true;
  530. },
  531.  
  532. moveMouseTo: function(tSX, tSY) {
  533. if (!state.gameVideo) return;
  534.  
  535. const vR = state.gameVideo.getBoundingClientRect();
  536. if (!vR || vR.width === 0) return;
  537.  
  538. const gVCX = vR.left + vR.width / 2;
  539. const gVCY = vR.top + vR.height / 2;
  540. let mX = tSX - gVCX;
  541. let mY = tSY - gVCY;
  542.  
  543. const sC = document.querySelector(config.game?.containerSelector) || state.gameVideo || document.documentElement;
  544. const evt = new PointerEvent('pointermove', {
  545. bubbles: true,
  546. cancelable: true,
  547. view: window,
  548. clientX: Math.round(state.input.lastMouseX + mX),
  549. clientY: Math.round(state.input.lastMouseY + mY),
  550. movementX: Math.round(mX),
  551. movementY: Math.round(mY),
  552. pointerType: 'mouse',
  553. isPrimary: true
  554. });
  555. sC.dispatchEvent(evt);
  556. },
  557.  
  558. startShooting: function() {
  559. if (state.isShooting) return;
  560.  
  561. const sC = document.querySelector(config.game?.containerSelector) || state.gameVideo || document.documentElement;
  562. const evt = new PointerEvent('pointerdown', {
  563. bubbles: true,
  564. cancelable: true,
  565. view: window,
  566. clientX: Math.round(state.input.lastMouseX),
  567. clientY: Math.round(state.input.lastMouseY),
  568. button: 0,
  569. buttons: 1,
  570. pointerType: 'mouse',
  571. isPrimary: true
  572. });
  573. sC.dispatchEvent(evt);
  574. state.isShooting = true;
  575. },
  576.  
  577. stopShooting: function() {
  578. if (!state.isShooting) return;
  579.  
  580. const sC = document.querySelector(config.game?.containerSelector) || state.gameVideo || document.documentElement;
  581. const evt = new PointerEvent('pointerup', {
  582. bubbles: true,
  583. cancelable: true,
  584. view: window,
  585. clientX: Math.round(state.input.lastMouseX),
  586. clientY: Math.round(state.input.lastMouseY),
  587. button: 0,
  588. pointerType: 'mouse',
  589. isPrimary: true
  590. });
  591. sC.dispatchEvent(evt);
  592. state.isShooting = false;
  593. }
  594. };
  595.  
  596. // =================================================================================================
  597. // VISUAL OVERLAY (with safe property access)
  598. // =================================================================================================
  599. function createOverlayCanvas() {
  600. if (state.ui.overlayCanvas) return;
  601.  
  602. const c = document.createElement('canvas');
  603. c.id = 'xcloud-aimbot-overlay';
  604. c.width = window.innerWidth;
  605. c.height = window.innerHeight;
  606. c.style.cssText = 'position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:99999;';
  607.  
  608. state.ui.overlayCanvas = c;
  609. state.ui.overlayCtx = c.getContext('2d');
  610. document.body.appendChild(c);
  611.  
  612. window.addEventListener('resize', () => {
  613. c.width = window.innerWidth;
  614. c.height = window.innerHeight;
  615. });
  616. }
  617.  
  618. function drawCrosshair(vR) {
  619. if (!state.ui.overlayCtx || !config.visual?.crosshair?.enabled) return;
  620.  
  621. const ctx = state.ui.overlayCtx;
  622. let cX, cY;
  623.  
  624. if (config.visual.crosshair?.centerOnGameScreen && vR && vR.width > 0) {
  625. cX = vR.left + vR.width / 2;
  626. cY = vR.top + vR.height / 2;
  627. } else {
  628. cX = state.input.lastMouseX;
  629. cY = state.input.lastMouseY;
  630. }
  631.  
  632. const s = config.visual.crosshair?.size || 3;
  633. const color = config.visual?.rainbowMode?.enabled ?
  634. `hsl(${state.rainbowHue}, 100%, 50%)` :
  635. (config.visual.crosshair?.color || 'lime');
  636.  
  637. ctx.strokeStyle = color;
  638. ctx.fillStyle = color;
  639. ctx.lineWidth = 1;
  640.  
  641. switch (config.visual.crosshair?.style || 'dot') {
  642. case 'cross':
  643. ctx.beginPath();
  644. ctx.moveTo(cX - 2 * s, cY);
  645. ctx.lineTo(cX + 2 * s, cY);
  646. ctx.moveTo(cX, cY - 2 * s);
  647. ctx.lineTo(cX, cY + 2 * s);
  648. ctx.stroke();
  649. break;
  650. case 'dot':
  651. ctx.beginPath();
  652. ctx.arc(cX, cY, s, 0, 2 * Math.PI);
  653. ctx.fill();
  654. break;
  655. case 'circle':
  656. ctx.beginPath();
  657. ctx.arc(cX, cY, 2 * s, 0, 2 * Math.PI);
  658. ctx.stroke();
  659. break;
  660. }
  661. }
  662.  
  663. function drawTargetLockIndicator(t, vR) {
  664. if (!config.visual?.targetLock?.enabled || !state.ui.overlayCtx || !t || !vR || !state.gameVideo) return;
  665.  
  666. const ctx = state.ui.overlayCtx;
  667. const bbox = t.prediction?.bbox || [0, 0, 0, 0];
  668. const [vBx, vBy, vBw, vBh] = bbox;
  669. const bSX = vR.left + vBx / state.gameVideo.videoWidth * vR.width;
  670. const bSY = vR.top + vBy / state.gameVideo.videoHeight * vR.height;
  671. const bSW = vBw / state.gameVideo.videoWidth * vR.width;
  672. const bSH = vBh / state.gameVideo.videoHeight * vR.height;
  673.  
  674. ctx.strokeStyle = config.visual?.rainbowMode?.enabled ?
  675. `hsl(${state.rainbowHue}, 100%, 50%)` :
  676. (config.visual.targetLock?.color || 'red');
  677. ctx.lineWidth = 2;
  678.  
  679. const cS = 0.2 * Math.min(bSW, bSH);
  680. switch (config.visual.targetLock?.style || 'full') {
  681. case 'full':
  682. ctx.strokeRect(bSX, bSY, bSW, bSH);
  683. break;
  684. case 'corners':
  685. ctx.beginPath();
  686. ctx.moveTo(bSX + cS, bSY);
  687. ctx.lineTo(bSX, bSY);
  688. ctx.lineTo(bSX, bSY + cS);
  689. ctx.moveTo(bSX + bSW - cS, bSY);
  690. ctx.lineTo(bSX + bSW, bSY);
  691. ctx.lineTo(bSX + bSW, bSY + cS);
  692. ctx.moveTo(bSX + cS, bSY + bSH);
  693. ctx.lineTo(bSX, bSY + bSH);
  694. ctx.lineTo(bSX, bSY + bSH - cS);
  695. ctx.moveTo(bSX + bSW - cS, bSY + bSH);
  696. ctx.lineTo(bSX + bSW, bSY + bSH);
  697. ctx.lineTo(bSX + bSW, bSY + bSH - cS);
  698. ctx.stroke();
  699. break;
  700. }
  701. }
  702.  
  703. function drawFOVCircle(vR) {
  704. if (!config.visual?.fovCircle?.enabled || !state.ui.overlayCtx) return;
  705. if (config.visual.fovCircle?.showOnlyWhenAiming && !state.input.activeKeys.has(config.aim?.activationKey || 'KeyQ')) return;
  706.  
  707. const ctx = state.ui.overlayCtx;
  708. let cX, cY;
  709.  
  710. if (config.visual.fovCircle?.centerOnGameScreen && vR && vR.width > 0) {
  711. cX = vR.left + vR.width / 2;
  712. cY = vR.top + vR.height / 2;
  713. } else {
  714. cX = state.input.lastMouseX;
  715. cY = state.input.lastMouseY;
  716. }
  717.  
  718. ctx.strokeStyle = config.visual?.rainbowMode?.enabled ?
  719. `hsl(${state.rainbowHue}, 100%, 50%)` :
  720. (config.visual.fovCircle?.color || 'rgba(255,255,255,0.3)');
  721. ctx.lineWidth = config.visual.fovCircle?.lineWidth || 1;
  722. ctx.beginPath();
  723. // Make the visual FOV circle match the larger of the two possible radii
  724. const radius = config.aim.smartSlowdown.enabled ?
  725. Math.max(config.aim.fovRadius, config.aim.smartSlowdown.slowdownRadius) :
  726. config.aim.fovRadius;
  727. ctx.arc(cX, cY, radius || 200, 0, 2 * Math.PI);
  728. ctx.stroke();
  729. }
  730.  
  731. function drawDebugInfo() {
  732. if (!config.visual?.showDebugInfo || !state.ui.overlayCtx) return;
  733.  
  734. const ctx = state.ui.overlayCtx;
  735. ctx.font = '12px Arial';
  736. ctx.fillStyle = 'rgba(255,255,0,0.8)';
  737. ctx.fillText(`Backend: ${state.prediction.backend.toUpperCase()}`, 10, 80);
  738. ctx.fillText(`Mouse: X:${state.input.lastMouseX.toFixed(0)} Y:${state.input.lastMouseY.toFixed(0)}`, 10, 96);
  739. }
  740.  
  741. function drawPerformanceMetrics() {
  742. if (!config.visual?.performanceMetrics?.enabled || !state.ui.overlayCtx) return;
  743.  
  744. const ctx = state.ui.overlayCtx;
  745. ctx.font = '14px Arial';
  746. ctx.fillStyle = 'rgba(0,255,0,0.8)';
  747. ctx.fillText(`FPS: ${state.performance.fps}`, 10, 20);
  748. ctx.fillText(`Detect: ${state.performance.detectionTime.toFixed(1)}ms (Avg: ${state.performance.avgDetectionTime.toFixed(1)}ms)`, 10, 36);
  749. ctx.fillStyle = 'rgba(255, 165, 0, 0.9)';
  750. ctx.fillText(`Net Latency: ${state.prediction.networkLatency.toFixed(1)}ms`, 10, 52);
  751.  
  752. if (state.currentTarget && state.prediction.targetHistory[state.currentTarget.id]) {
  753. const history = state.prediction.targetHistory[state.currentTarget.id];
  754. ctx.fillText(`Target Vel: X:${(history.smoothedVelocity.x || 0).toFixed(2)} Y:${(history.smoothedVelocity.y || 0).toFixed(2)}`, 10, 68);
  755. }
  756. }
  757.  
  758. function drawIgnoreSelfRegionVisualization(videoRect) {
  759. if (!config.detection?.ignoreSelfRegion?.enabled ||
  760. !config.visual?.drawIgnoreRegion?.enabled ||
  761. !state.ui.overlayCtx || !videoRect || videoRect.width === 0) return;
  762.  
  763. const ctx = state.ui.overlayCtx;
  764. const region = config.detection.ignoreSelfRegion || {};
  765. const visConfig = config.visual.drawIgnoreRegion || {};
  766.  
  767. const rectX = videoRect.left + videoRect.width * (region.xPercent || 0);
  768. const rectY = videoRect.top + videoRect.height * (region.yPercent || 0);
  769. const rectW = videoRect.width * (region.widthPercent || 0);
  770. const rectH = videoRect.height * (region.heightPercent || 0);
  771.  
  772. ctx.fillStyle = visConfig.color || 'rgba(50, 50, 50, 0.4)';
  773. ctx.fillRect(rectX, rectY, rectW, rectH);
  774. }
  775.  
  776. function drawVisuals(currentTarget) {
  777. if (!state.ui.overlayCtx) return;
  778.  
  779. const ctx = state.ui.overlayCtx;
  780. ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
  781.  
  782. const videoRect = state.gameVideo ? state.gameVideo.getBoundingClientRect() : null;
  783. const isAimKeyHeld = state.input.activeKeys.has(config.aim?.activationKey || 'KeyQ');
  784.  
  785. drawCrosshair(videoRect);
  786.  
  787. if (isAimKeyHeld) {
  788. drawFOVCircle(videoRect);
  789.  
  790. if (config.detection?.ignoreSelfRegion?.enabled &&
  791. config.visual?.drawIgnoreRegion?.enabled &&
  792. videoRect) {
  793. drawIgnoreSelfRegionVisualization(videoRect);
  794. }
  795.  
  796. if (videoRect && videoRect.width > 0 && currentTarget) {
  797. drawTargetLockIndicator(currentTarget, videoRect);
  798. }
  799. }
  800.  
  801. if (config.visual?.performanceMetrics?.enabled) drawPerformanceMetrics();
  802. if (config.visual?.showDebugInfo) drawDebugInfo();
  803. }
  804.  
  805. // =================================================================================================
  806. // DETECTION CORE
  807. // =================================================================================================
  808. async function detectPlayers() {
  809. if (!state.input.activeKeys.has(config.aim?.activationKey || 'KeyQ')) {
  810. return [];
  811. }
  812.  
  813. if (!state.gameVideo || !state.modelLoaded || !state.detectionModel ||
  814. state.gameVideo.paused || state.gameVideo.ended || state.gameVideo.videoWidth === 0) {
  815. return [];
  816. }
  817.  
  818. if (state.frameCount++ % ((config.detection?.skipFrames || 0) + 1) !== 0) {
  819. return [];
  820. }
  821.  
  822. const now = performance.now();
  823. if (now - state.lastDetectionTime < (config.detection?.processingInterval || 0)) {
  824. return [];
  825. }
  826.  
  827. let videoSource = state.gameVideo;
  828.  
  829. if (config.detection?.ignoreSelfRegion?.enabled) {
  830. if (!state.ui.offscreenCanvas) {
  831. state.ui.offscreenCanvas = document.createElement('canvas');
  832. state.ui.offscreenCtx = state.ui.offscreenCanvas.getContext('2d');
  833. }
  834.  
  835. if (state.ui.offscreenCanvas.width !== state.gameVideo.videoWidth ||
  836. state.ui.offscreenCanvas.height !== state.gameVideo.videoHeight) {
  837. state.ui.offscreenCanvas.width = state.gameVideo.videoWidth;
  838. state.ui.offscreenCanvas.height = state.gameVideo.videoHeight;
  839. }
  840.  
  841. const ctx = state.ui.offscreenCtx;
  842. ctx.drawImage(state.gameVideo, 0, 0, state.gameVideo.videoWidth, state.gameVideo.videoHeight);
  843.  
  844. const region = config.detection.ignoreSelfRegion || {};
  845. ctx.fillStyle = 'rgba(0, 0, 0, 1)';
  846. ctx.fillRect(
  847. state.gameVideo.videoWidth * (region.xPercent || 0),
  848. state.gameVideo.videoHeight * (region.yPercent || 0),
  849. state.gameVideo.videoWidth * (region.widthPercent || 0),
  850. state.gameVideo.videoHeight * (region.heightPercent || 0)
  851. );
  852.  
  853. videoSource = state.ui.offscreenCanvas;
  854. }
  855.  
  856. try {
  857. const detectionStart = performance.now();
  858. const poses = await state.detectionModel.estimatePoses(videoSource, { flipHorizontal: false });
  859.  
  860. state.performance.detectionTime = performance.now() - detectionStart;
  861. state.performance.detectionTimeHistory.push(state.performance.detectionTime);
  862.  
  863. if (state.performance.detectionTimeHistory.length > 30) {
  864. state.performance.detectionTimeHistory.shift();
  865. }
  866.  
  867. state.performance.avgDetectionTime = state.performance.detectionTimeHistory.reduce((a, b) => a + b, 0) /
  868. state.performance.detectionTimeHistory.length;
  869. state.lastDetectionTime = now;
  870.  
  871. const results = [];
  872. if (poses && poses.length > 0) {
  873. for (const pose of poses) {
  874. if (pose.score && pose.score >= (config.detection?.detectorConfig?.minPoseScore || 0)) {
  875. const bbox = calculateBoundingBoxFromKeypoints(pose.keypoints);
  876. if (bbox && bbox.width > 0 && bbox.height > 0) {
  877. results.push({
  878. class: 'person',
  879. score: pose.score,
  880. bbox: [bbox.x, bbox.y, bbox.width, bbox.height],
  881. keypoints: pose.keypoints
  882. });
  883. }
  884. }
  885. }
  886. }
  887.  
  888. return results.slice(0, config.detection?.maxDetections || 1);
  889. } catch (err) {
  890. debug.error("Error during pose estimation:", err);
  891. return [];
  892. }
  893. }
  894.  
  895. // =================================================================================================
  896. // AIMING LOGIC
  897. // =================================================================================================
  898. async function processAiming(timestamp) {
  899. const isAimKeyHeld = state.input.activeKeys.has(config.aim?.activationKey || 'KeyQ');
  900. const now = performance.now();
  901.  
  902. if (!isAimKeyHeld || !config.detection?.enabled || !state.modelLoaded) {
  903. state.currentTarget = null;
  904. drawVisuals(null);
  905. if (state.isShooting) InputController.stopShooting();
  906. return;
  907. }
  908.  
  909. const players = await detectPlayers();
  910. const newTarget = findBestTarget(players);
  911.  
  912. updateTargetPrediction(newTarget);
  913.  
  914. if (newTarget) {
  915. if (!state.currentTarget || newTarget.prediction !== state.currentTarget.prediction) {
  916. if (!state.currentTarget || now - state.lastTargetSwitch > (config.aim?.targetSwitchCooldown || 0)) {
  917. state.currentTarget = newTarget;
  918. state.lastTargetSwitch = now;
  919. }
  920. } else {
  921. state.currentTarget = newTarget;
  922. }
  923. } else {
  924. state.currentTarget = null;
  925. }
  926.  
  927. drawVisuals(state.currentTarget);
  928.  
  929. if (state.currentTarget) {
  930. let { x: targetX, y: targetY } = state.currentTarget.screenPosition || { x: 0, y: 0 };
  931.  
  932. if (config.aim.prediction.enabled) {
  933. const predictedPos = calculatePredictedPosition(state.currentTarget.id);
  934. if (predictedPos) {
  935. targetX = predictedPos.x;
  936. targetY = predictedPos.y;
  937. }
  938. }
  939.  
  940. let finalX = targetX;
  941. let finalY = targetY;
  942.  
  943. // ==================================================================================
  944. // MODIFIED: Aim Speed Logic with Smart Slowdown
  945. // ==================================================================================
  946. if (config.aim?.aimSpeed?.enabled) {
  947. const videoRect = state.gameVideo?.getBoundingClientRect();
  948. if (videoRect && videoRect.width > 0) {
  949. const referenceX = videoRect.left + videoRect.width / 2;
  950. const referenceY = videoRect.top + videoRect.height / 2;
  951. let speedDecimal = 1.0; // Default to 100% speed
  952.  
  953. // Check if smart slowdown is enabled
  954. if (config.aim.smartSlowdown.enabled) {
  955. const slowdownCfg = config.aim.smartSlowdown;
  956. const dist = Math.hypot(targetX - referenceX, targetY - referenceY);
  957.  
  958. if (dist < slowdownCfg.slowdownRadius) {
  959. // Target is within slowdown radius, calculate dynamic speed
  960. const slowdownFactor = Math.min(1.0, dist / slowdownCfg.slowdownRadius);
  961. const dynamicSpeed = slowdownCfg.maxSpeed + (slowdownCfg.minSpeed - slowdownCfg.maxSpeed) * (1 - slowdownFactor);
  962. speedDecimal = dynamicSpeed / 100.0;
  963. } else {
  964. // Target is outside radius, use max speed
  965. speedDecimal = slowdownCfg.maxSpeed / 100.0;
  966. }
  967. } else {
  968. // Fallback to original speed percent if smart slowdown is disabled
  969. speedDecimal = (config.aim.aimSpeed.speedPercent || 85) / 100.0;
  970. }
  971.  
  972. finalX = referenceX + (targetX - referenceX) * speedDecimal;
  973. finalY = referenceY + (targetY - referenceY) * speedDecimal;
  974. }
  975. }
  976.  
  977. InputController.moveMouseTo(finalX, finalY);
  978.  
  979. if (config.game?.autoShoot && state.currentTarget.distance < (config.aim?.fovRadius || 200) * (config.aim?.triggerThreshold || 0.7)) {
  980. if (!state.isShooting) {
  981. setTimeout(() => {
  982. if (state.currentTarget && state.input.activeKeys.has(config.aim?.activationKey || 'KeyQ')) {
  983. InputController.startShooting();
  984. }
  985. }, config.game?.triggerOptions?.delayBeforeShoot || 0);
  986. }
  987. } else if (state.isShooting) {
  988. InputController.stopShooting();
  989. }
  990. } else {
  991. if (state.isShooting) InputController.stopShooting();
  992. }
  993. }
  994.  
  995. // =================================================================================================
  996. // MAIN LOOP
  997. // =================================================================================================
  998. function startAimbotLoop() {
  999. async function mainLoop(timestamp) {
  1000. requestAnimationFrame(mainLoop);
  1001.  
  1002. state.performance.framesThisSecond++;
  1003. if (timestamp - state.performance.lastFpsUpdate >= 1000) {
  1004. state.performance.fps = state.performance.framesThisSecond;
  1005. state.performance.framesThisSecond = 0;
  1006. state.performance.lastFpsUpdate = timestamp;
  1007. }
  1008.  
  1009. if (config.visual?.rainbowMode?.enabled) {
  1010. state.rainbowHue = (timestamp * (config.visual.rainbowMode?.speed || 0.1)) % 360;
  1011. }
  1012.  
  1013. if (!state.gameVideo || state.gameVideo.paused || state.gameVideo.ended || state.gameVideo.videoWidth === 0) {
  1014. if (state.isShooting) InputController.stopShooting();
  1015. if (state.ui.overlayCtx) state.ui.overlayCtx.clearRect(0, 0, state.ui.overlayCanvas.width, state.ui.overlayCanvas.height);
  1016. state.currentTarget = null;
  1017. return;
  1018. }
  1019.  
  1020. await processAiming(timestamp);
  1021. }
  1022.  
  1023. requestAnimationFrame(mainLoop);
  1024. }
  1025.  
  1026. // =================================================================================================
  1027. // INITIALIZATION
  1028. // =================================================================================================
  1029. async function initializeAimbot() {
  1030. debug.log(`Initializing Capybara AI Aimbot...`);
  1031.  
  1032. state.gameVideo = document.querySelector(config.game?.videoSelector || 'video');
  1033. if (!state.gameVideo) {
  1034. debug.error("Game video element not found. Retrying...");
  1035. setTimeout(initializeAimbot, 3000);
  1036. return;
  1037. }
  1038.  
  1039. createOverlayCanvas();
  1040.  
  1041. // Performance monitoring worker
  1042. const workerBlob = new Blob(['// Dummy Worker'], { type: 'application/javascript' });
  1043. const workerUrl = URL.createObjectURL(workerBlob);
  1044. new Worker(workerUrl);
  1045.  
  1046. // Network latency observer
  1047. const observer = new PerformanceObserver((list) => {
  1048. const lastEntry = list.getEntries().pop();
  1049. if (lastEntry && lastEntry.name.includes('.svg')) {
  1050. state.prediction.networkLatency = lastEntry.duration;
  1051. }
  1052. });
  1053. observer.observe({ type: "resource", buffered: true });
  1054.  
  1055. InputController.init();
  1056.  
  1057. if (config.detection?.enabled) {
  1058. await loadDetectionModel();
  1059. }
  1060.  
  1061. startAimbotLoop();
  1062. debug.log("Initialization complete. Capybara AI Aimbot is now active.");
  1063. showNotification(`Capybara AI Aimbot Initialized! (${state.prediction.backend.toUpperCase()})`, "info");
  1064. }
  1065.  
  1066. // Start the aimbot
  1067. if (document.readyState === 'complete' || document.readyState === 'interactive') {
  1068. setTimeout(initializeAimbot, 2500);
  1069. } else {
  1070. window.addEventListener('load', () => setTimeout(initializeAimbot, 2500));
  1071. }
  1072. })();
Advertisement
Add Comment
Please, Sign In to add comment