MooMoo.io Gold bots

just fucking gold bots dont care it.

  1. // ==UserScript==
  2. // @name MooMoo.io Gold bots
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description just fucking gold bots dont care it.
  6. // @author Bianos
  7. // @require https://cdn.jsdelivr.net/npm/msgpack-lite@0.1.26/dist/msgpack.min.js
  8. // @license MIT
  9. // @match *://*.moomoo.io/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. let teams = [];
  14. let teammates = [];
  15. let msgpack_lite = window.msgpack
  16. let color;
  17. let name;
  18. let oweb = window.WebSocket;
  19. let socket;
  20. var bot = [];
  21. let ownplayer = {sid: undefined, x: undefined, y: undefined, dir: undefined, skinIndex: undefined, name: undefined}
  22. let getAngleDist = (e, t) => {
  23. const i = Math.abs(t - e) % (Math.PI * 2);
  24. return i > Math.PI ? Math.PI * 2 - i : i
  25. }
  26. function gettoken() {
  27. return new Promise((resolve, reject) => {
  28. window.grecaptcha.ready(() => {
  29. window.grecaptcha.execute('6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP', { action: 'homepage' })
  30. .then(token => resolve(token))
  31. .catch(err => reject(err));
  32. });
  33. });
  34. }
  35. window.WebSocket = function(...args) {
  36. socket = new oweb(...args);
  37. socket.addEventListener('message', async (event) => {
  38. let decoded = msgpack_lite.decode(new Uint8Array(event.data));
  39. let hooked;
  40. if (decoded.length > 1 && Array.isArray(decoded[1])) {
  41. hooked = [decoded[0], ...decoded[1]];
  42. } else {
  43. hooked = decoded
  44. }
  45.  
  46. if(hooked[0] === 'io-init') {
  47. let religion = socket.url.split('/')[2]
  48. for(let i = 0; i <= 3; i++) {
  49. let token = await gettoken();
  50. bot.push(new Bot(religion , token));
  51. }
  52. }
  53.  
  54. if(hooked[0] === "C") {
  55. if(ownplayer.sid == null || ownplayer.sid == undefined) {
  56. ownplayer.sid = hooked[1];
  57. }
  58. }
  59.  
  60. if(hooked[0] === 'D') {
  61. if(hooked[1][1] === ownplayer.sid) {
  62. ownplayer.name = hooked[1][2];
  63. console.log(ownplayer.name);
  64. }
  65. }
  66.  
  67. if (hooked[0] === "a") {
  68. for (let i = 0; i < hooked[1].length / 13; i++) {
  69. let playerInfo = hooked[1].slice(13 * i, 13 * i + 13);
  70. if (playerInfo[0] == ownplayer.sid) {
  71. ownplayer.x = playerInfo[1];
  72. ownplayer.y = playerInfo[2];
  73. ownplayer.dir = playerInfo[3];
  74. ownplayer.skinIndex = playerInfo[9];
  75. }
  76. }
  77. for(let bots of bot) {
  78. bots.autm.x = ownplayer.x
  79. bots.autm.y = ownplayer.y
  80. }
  81. }
  82. });
  83. return socket;
  84. };
  85. let randomhats = [28, 29, 30, 36, 37, 38, 44, 42, 43, 49];
  86. class Bot {
  87. constructor(region, token) {
  88. this.socket = new WebSocket(`wss://${region}/?token=re:${token}`);
  89. this.sid = undefined;
  90. this.x = undefined;
  91. this.y = undefined;
  92. this.dir = undefined;
  93. this.buildIndex = undefined;
  94. this.weaponIndex = undefined;
  95. this.team = undefined;
  96. this.skinIndex = undefined;
  97. this.tailIndex = undefined;
  98. this.health = 100;
  99. this.packetCount = 0;
  100. this.items = [0, 3, 6, 10];
  101. this.oldIndex = 0;
  102. this.oldWeapon;
  103. this.foodCount = 100;
  104. setInterval(() => { this.packetCount = 0 }, 1000);
  105. this.autm = {
  106. x: undefined,
  107. y: undefined,
  108. boolean: true
  109. };
  110.  
  111. this.socket.addEventListener('open', () => {
  112. console.log('websocket true');
  113. this.socket.addEventListener('message', async event => {
  114. let arraybuf;
  115. if (event.data instanceof Blob) {
  116. arraybuf = await event.data.arrayBuffer();
  117. } else {
  118. return;
  119. }
  120. let u8array = new Uint8Array(arraybuf);
  121. let decoded;
  122. try {
  123. decoded = msgpack_lite.decode(u8array);
  124. } catch (error) {
  125. }
  126. var hooked;
  127. if (decoded.length > 1){
  128. hooked = [decoded[0], ...decoded[1]];
  129. if (hooked[1] instanceof Array){
  130. hooked = hooked;
  131. }
  132. } else {
  133. hooked = decoded;
  134. }
  135.  
  136. if(hooked[0] === 'io-init') {
  137. this.spawn(name, color)
  138. }
  139.  
  140. if (hooked[0] === 'A') {
  141. teams = hooked[1];
  142. }
  143.  
  144. if (hooked[0] === 'C') {
  145. if (this.sid == null) {
  146. this.sid = hooked[1];
  147. }
  148. }
  149.  
  150. if(hooked[0] === 'D') {
  151. if(hooked[1][1] === this.sid) {
  152. this.foodCount = 100;
  153. this.health = 100;
  154. }
  155. if(hooked[1][2] === ownplayer.name) {
  156. this.sendMessage('6', 'Hi Owner!');
  157. }
  158. }
  159.  
  160. if(hooked[0] === '6') {
  161. if(hooked[1] === ownplayer.sid) {
  162. this.sendMessage('6', hooked[2]);
  163. }
  164. }
  165.  
  166. if(hooked[0] === 'O') {
  167. if(hooked[1] === this.sid) {
  168. this.health = hooked[2];
  169. }
  170. }
  171.  
  172. if(hooked[0] === 'N') {
  173. let food = hooked.indexOf('food')
  174. if (food !== -1 && food < hooked.length - 1) {
  175. this.foodCount = hooked[food + 1];
  176. } else {
  177. this.foodCount = 0;
  178. }
  179. }
  180.  
  181. if (hooked[0] === 'a') {
  182. teammates = [];
  183. for (let i = 0; i < hooked[1].length / 13; i++) {
  184. let playerInfo = hooked[1].slice(13 * i, 13 * i + 13);
  185. if (playerInfo[0] == this.sid) {
  186. this.x = playerInfo[1];
  187. this.y = playerInfo[2];
  188. this.dir = playerInfo[3]
  189. this.buildIndex = playerInfo[4];
  190. this.weaponIndex = playerInfo[5];
  191. this.team = playerInfo[7];
  192. this.skinIndex = playerInfo[9];
  193. this.tailIndex = playerInfo[10];
  194. } else if (playerInfo[7] == this.team && playerInfo[0] != this.sid) {
  195. teammates.push({ sid: playerInfo[0], x: playerInfo[1], y: playerInfo[2], isOwner: playerInfo[8] });
  196. }
  197. }
  198. this.oldWeapon = this.weaponIndex;
  199. this.equipIndex(0, randomhats[Math.floor(Math.random() * randomhats.length)], 0);
  200. if(this.health < 100) {
  201. let { x, y } = this.autm;
  202. let distance = Math.sqrt(Math.pow(this.y - y, 2) + Math.pow(this.x - x, 2));
  203. if(distance >= 200) {
  204. let hc = (Math.ceil((100 - this.health) / 20));
  205. if(this.foodCount >= 10) {
  206. for(let i = 0; i <= hc; i++) {
  207. setTimeout(() => {
  208. this.place(this.items[0], null);
  209. }, 70);
  210. }
  211. }
  212. }
  213. }
  214. if (this.autm.boolean) {
  215. let { x, y } = this.autm;
  216. let distance = Math.sqrt(Math.pow(this.y - y, 2) + Math.pow(this.x - x, 2));
  217. let angle = Math.atan2(y - this.y, x - this.x);
  218. if(distance >= 105) {
  219. this.sendMessage('a', angle);
  220. } else {
  221. if(getAngleDist(angle, ownplayer.dir) <= (Math.PI / 2.6)) {
  222. this.sendMessage('a', null);
  223. } else {
  224. this.sendMessage('a', ownplayer.dir);
  225. }
  226. }
  227. }
  228. if(this.dir != ownplayer.dir) {
  229. this.sendMessage('D', ownplayer.dir);
  230. }
  231. }
  232. if(hooked[0] === 'P') {
  233. this.spawn(name, color);
  234. }
  235. });
  236. });
  237. }
  238.  
  239. spawn() {
  240. this.sendMessage('M', {
  241. name: 'BianosGoldBot',
  242. moofoll: true,
  243. skin: 0
  244. });
  245. }
  246.  
  247. join(clan) {
  248. this.sendMessage('b', clan);
  249. }
  250.  
  251. equipIndex(buy, id, index) {
  252. this.sendMessage('c', buy, id, index);
  253. }
  254.  
  255. aimAt(angle) {
  256. this.sendMessage('D', angle);
  257. }
  258.  
  259. doHit(hitting, angle) {
  260. this.sendMessage('d', hitting, angle);
  261. }
  262.  
  263. place(id, ang) {
  264. this.sendMessage('G', id);
  265. this.doHit(1, ang);
  266. this.doHit(0, ang);
  267. this.sendMessage('G', this.oldWeapon, true);
  268. }
  269.  
  270. sendMessage(type, ...args) {
  271. if (this.packetCount < 120) {
  272. let message = [type, args];
  273. let eM = msgpack_lite.encode(message);
  274. let mes = new Uint8Array(eM);
  275. this.socket.send(mes);
  276. this.packetCount++;
  277. }
  278. }
  279. }
  280.  
  281.