Bloxd.io Auto-Aim + Attack

This is only for test, and i asked chatgpt for injection it kinda dumbass test it yourself

  1. // ==UserScript==
  2. // @name Bloxd.io Auto-Aim + Attack
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description This is only for test, and i asked chatgpt for injection it kinda dumbass test it yourself
  6. // @author zNxrbd
  7. // @match *://*.bloxd.io/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. let mouseDown = false;
  16. let gameLoaded = false;
  17. let sendPacketFunc = null;
  18.  
  19. // Watch for left mouse hold
  20. window.addEventListener('mousedown', e => {
  21. if (e.button === 0) mouseDown = true;
  22. });
  23. window.addEventListener('mouseup', e => {
  24. if (e.button === 0) mouseDown = false;
  25. });
  26.  
  27. // Wait until Noa and packet sender exist
  28. const waitForGame = () => {
  29. const interval = setInterval(() => {
  30. if (window.noa && noa.entities && window.SendPacket) {
  31. sendPacketFunc = window.SendPacket;
  32. gameLoaded = true;
  33. clearInterval(interval);
  34. startAutoAttack();
  35. }
  36. }, 250);
  37. };
  38.  
  39. const getDistance = (a, b) => {
  40. const dx = a[0] - b[0];
  41. const dy = a[1] - b[1];
  42. const dz = a[2] - b[2];
  43. return Math.sqrt(dx * dx + dy * dy + dz * dz);
  44. };
  45.  
  46. const rotateToTarget = (playerPos, targetPos) => {
  47. const dx = targetPos[0] - playerPos[0];
  48. const dz = targetPos[2] - playerPos[2];
  49. const angle = Math.atan2(dz, dx) - Math.PI / 2;
  50. noa.camera.heading = angle;
  51. };
  52.  
  53. const sendAttackPacket = () => {
  54. if (typeof sendPacketFunc === "function") {
  55. sendPacketFunc(2, 'action|attack');
  56. }
  57. };
  58.  
  59. function startAutoAttack() {
  60. function tick() {
  61. if (!mouseDown || !gameLoaded) {
  62. requestAnimationFrame(tick);
  63. return;
  64. }
  65.  
  66. const playerId = noa.playerEntity;
  67. const playerPos = noa.entities.getPosition(playerId);
  68.  
  69. let closest = null;
  70. let closestDist = 3; // max range
  71.  
  72. noa.entities.getAllEntities().forEach(e => {
  73. if (e === playerId) return;
  74. const pos = noa.entities.getPosition(e);
  75. if (!pos) return;
  76. const dist = getDistance(playerPos, pos);
  77. if (dist <= closestDist) {
  78. closest = e;
  79. closestDist = dist;
  80. }
  81. });
  82.  
  83. if (closest) {
  84. const targetPos = noa.entities.getPosition(closest);
  85. rotateToTarget(playerPos, targetPos);
  86. sendAttackPacket();
  87. }
  88.  
  89. requestAnimationFrame(tick);
  90. }
  91.  
  92. requestAnimationFrame(tick);
  93. }
  94.  
  95. waitForGame();
  96. })();