Anti Projectile.

Anti bow insta.

目前为 2024-08-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Anti Projectile.
  3. // @namespace https://sandbox.moomoo.io/
  4. // @version v1.1
  5. // @description Anti bow insta.
  6. // @author Bianos Sozinho, Discord: istisna.bianos
  7. // @match *://*.moomoo.io/*
  8. // @require https://cdn.jsdelivr.net/npm/msgpack-lite@0.1.26/dist/msgpack.min.js
  9. // @icon https://moomoo.io/img/favicon.png?v=1
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. let msgpack_lite = window.msgpack, possibleBowInsta = false, moving = false, ownPlayer = {}, projectiles = [], packetLimitazition = {max: 120, count: 0}, mill, socket, mouseX, mouseY, mouseAngle, height, width, resize, OriginalWebSocket = window.WebSocket;
  17. window.WebSocket = function(...args) {
  18. socket = new OriginalWebSocket(...args);
  19. socket.addEventListener('message', (event) => {
  20. let decoded = msgpack_lite.decode(new Uint8Array(event.data));
  21. let hooked;
  22. if (decoded.length > 1 && Array.isArray(decoded[1])) {
  23. hooked = [decoded[0], ...decoded[1]];
  24. } else {
  25. hooked = decoded
  26. }
  27.  
  28. if(hooked[0] === "io-init") {
  29. let cvs = document.getElementById("gameCanvas");
  30. width = cvs.clientWidth;
  31. height = cvs.clientHeight;
  32. $(window).resize(function() {
  33. width = cvs.clientWidth;
  34. height = cvs.clientHeight;
  35. });
  36. resize = function() {
  37. width = cvs.clientWidth;
  38. height = cvs.clientHeight;
  39. }
  40. cvs.addEventListener("mousemove", e => {
  41. mouseX = e.clientX;
  42. mouseY = e.clientY;
  43. mouseAngle = Math.atan2(mouseY - (height / 2), mouseX - (width / 2));
  44. });
  45. }
  46. if(hooked[0] == "C") {
  47. if(ownPlayer.sid == null || ownPlayer.sid == undefined) {
  48. ownPlayer.sid = hooked[1];
  49. }
  50. }
  51. if (hooked[0] == "a") {
  52. if(!possibleBowInsta) projectiles = [];
  53. for (let i = 0; i < hooked[1].length / 13; i++) {
  54. let playerInfo = hooked[1].slice(13 * i, 13 * i + 13);
  55. if (playerInfo[0] == ownPlayer.sid) {
  56. ownPlayer.x = playerInfo[1];
  57. ownPlayer.y = playerInfo[2];
  58. }
  59. }
  60. if(moving && !possibleBowInsta) {
  61. setTimeout(() => {
  62. sendMessage("a", null);
  63. moving = false;
  64. }, 300);
  65. }
  66. }
  67. if (hooked[0] == "X") {
  68. projectiles.push({x: hooked[1], y: hooked[2], type: hooked[6]});
  69. let choosedProjectiles = [0, 2, 5];
  70. let filteredProjectiles = projectiles.filter(proj => choosedProjectiles.includes(proj.type));
  71. if(filteredProjectiles[0].type == 0) {
  72. possibleBowInsta = true;
  73. }
  74. if(filteredProjectiles.length >= 2 && filteredProjectiles[1].type == 2) {
  75. let getAngle = Math.atan2(filteredProjectiles[0].y - ownPlayer.y, filteredProjectiles[0].x - ownPlayer.x);
  76. place(mill, getAngle);
  77. sendMessage("a", getAngle + 35);
  78. moving = true;
  79. possibleBowInsta = false;
  80. }
  81. }
  82.  
  83. update();
  84. });
  85. return socket;
  86. };
  87. let sendMessage = (function(type, ...args) {
  88. if (packetLimitazition.count < packetLimitazition.max) {
  89. const message = [type, args];
  90. const encodedMessage = msgpack_lite.encode(message);
  91. const byteArray = new Uint8Array(encodedMessage);
  92. socket.send(byteArray);
  93. packetLimitazition.count++;
  94. }
  95. });
  96. function place(id, rad) {
  97. sendMessage("G", id, null);
  98. sendMessage("d", 1, rad);
  99. sendMessage("d", 0, rad);
  100. };
  101.  
  102. function isElementVisible(e) {
  103. return (e.offsetParent !== null);
  104. }
  105. function update() {
  106. for (let i=26;i<29;i++){
  107. if (isElementVisible(document.getElementById("actionBarItem" + i.toString()))){
  108. mill = i - 16;
  109. }
  110. }
  111. }
  112. })();