Anti Projectile.

Anti bow insta.

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

  1. // ==UserScript==
  2. // @name Anti Projectile.
  3. // @namespace https://sandbox.moomoo.io/
  4. // @version v1.4
  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, enemy, enemyangle, 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. enemy = [];
  53. if(!possibleBowInsta) projectiles = [];
  54. for (let i = 0; i < hooked[1].length / 13; i++) {
  55. let playerInfo = hooked[1].slice(13 * i, 13 * i + 13);
  56. if (playerInfo[0] == ownPlayer.sid) {
  57. ownPlayer.x = playerInfo[1];
  58. ownPlayer.y = playerInfo[2];
  59. ownPlayer.weaponIndex = playerInfo[5];
  60. } else if(playerInfo[7] != ownPlayer.team || playerInfo[7] === null) {
  61. enemy.push(playerInfo);
  62. }
  63. }
  64. if(enemy) {
  65. let nearEnemy = enemy.sort((a, b) => Math.sqrt(Math.pow((ownPlayer.y - a[2]), 2) + Math.pow((ownPlayer.x - a[1]), 2)) - Math.sqrt(Math.pow((ownPlayer.y - b[2]), 2) + Math.pow((ownPlayer.x - b[1]), 2)))[0];
  66. if(nearEnemy) enemyangle = Math.atan2(nearEnemy[2] - ownPlayer.y, nearEnemy[1] - ownPlayer.x);
  67. }
  68. if(moving && !possibleBowInsta) {
  69. setTimeout(() => {
  70. sendMessage("a", null);
  71. moving = false;
  72. }, 300);
  73. }
  74. }
  75. if (hooked[0] == "X") {
  76. projectiles.push({sid: hooked[8], x: hooked[1], y: hooked[2], type: hooked[6]});
  77. let choosedProjectiles = [0, 2, 5];
  78. let filteredProjectiles = projectiles.filter(proj => choosedProjectiles.includes(proj.type));
  79. if(filteredProjectiles[0].type == 0) {
  80. possibleBowInsta = true;
  81. }
  82. let musket = filteredProjectiles.some(proj => proj.type == 2 && filteredProjectiles.length >= 2);
  83. if(musket) {
  84. sendMessage("ch", "ranged sync homo");
  85. place(mill, enemyangle);
  86. }
  87. let hasType2 = filteredProjectiles.some(proj => proj.type == 2);
  88. if(filteredProjectiles.length >= 2 && hasType2 && ![9, 12].includes(ownPlayer.weaponIndex)) {
  89. place(mill, enemyangle);
  90. sendMessage("a", enemyangle + 35);
  91. sendMessage("ch", "ranged insta homo");
  92. moving = true;
  93. possibleBowInsta = false;
  94. }
  95. }
  96.  
  97. update();
  98. });
  99. return socket;
  100. };
  101. let sendMessage = (function(type, ...args) {
  102. if (packetLimitazition.count < packetLimitazition.max) {
  103. const message = [type, args];
  104. const encodedMessage = msgpack_lite.encode(message);
  105. const byteArray = new Uint8Array(encodedMessage);
  106. socket.send(byteArray);
  107. packetLimitazition.count++;
  108. }
  109. });
  110. function place(id, rad) {
  111. sendMessage("G", id, null);
  112. sendMessage("d", 1, rad);
  113. sendMessage("d", 0, rad);
  114. };
  115.  
  116. function isElementVisible(e) {
  117. return (e.offsetParent !== null);
  118. }
  119. function update() {
  120. for (let i=26;i<29;i++){
  121. if (isElementVisible(document.getElementById("actionBarItem" + i.toString()))){
  122. mill = i - 16;
  123. }
  124. }
  125. }
  126. })();