Advertisement
RealRAINBOW

AGAR BOTS!!! ((UPDATE!!!))

Oct 20th, 2017
218
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. runBots = function(ip, token) {
  2.         if (jQuery('#token').val().length > 8) {
  3.                 alert('You must to create a Party first or connect to a private server.');
  4.                 return true;
  5.         } else if (jQuery('#token').val().length > 0) {
  6.                 mAB = 4;
  7.         } else {
  8.                 mAB = 10;
  9.         }
  10.  
  11.         bots = [];
  12.         currentServer = ip;
  13.  
  14.         for (i = 0; i < mAB; i++) {
  15.                 bots.push(new WebSocket(ip));
  16.                 bots[i].binaryType = "arraybuffer";
  17.                 bots[i].bot = i;
  18.                 bots[i].id = null;
  19.  
  20.                 bots[i].onopen = function() {
  21.                         a = new DataView(new ArrayBuffer(5));
  22.                         a.setUint8(0, 254);
  23.                         a.setUint32(1,
  24.                                 5, !0);
  25.                         this.send(a.buffer);
  26.                         a = new DataView(new ArrayBuffer(5));
  27.                         a.setUint8(0, 255);
  28.                         a.setUint32(1, 154669603, !0);
  29.                         this.send(a.buffer);
  30.                         a = new DataView(new ArrayBuffer(1 + token.length));
  31.                         a.setUint8(0, 80);
  32.                         for (var c = 0; c < token.length; ++c) a.setUint8(c + 1, token.charCodeAt(c));
  33.                         this.send(a.buffer);
  34.  
  35.                         console.log("Bot " + this.bot + " connected.");
  36.                 };
  37.                 bots[i].onmessage = function() {
  38.                         if (playing()) {
  39.                                 this.setNick(jQuery("#botsNick").val());
  40.                                 xx = jQuery("[name='botsFollow']:checked").val() == "mouse" ? ra : localStorage["x"]; // ra: target x
  41.                                 yy = jQuery("[name='botsFollow']:checked").val() == "mouse" ? sa : localStorage["y"]; // sa: target y
  42.                                 this.setDirection(xx, yy);
  43.                         }
  44.                 };
  45.                 bots[i].onclose = function() {
  46.                         bots.splice(this.bot, 1);
  47.                         console.log("Bot " + this.bot + " closed.");
  48.                 };
  49.                 bots[i].onerror = function() {
  50.                         bots.splice(this.bot, 1);
  51.                         console.log("Bot " + this.bot + " got an error.");
  52.                 };
  53.                 bots[i].setNick = function(nick) {
  54.                         if (typeof bots[this.bot] == "undefined") {
  55.                                 return true;
  56.                         }
  57.  
  58.                         var a = new DataView(new ArrayBuffer(1 + 2 * nick.length));
  59.                         a.setUint8(0, 0);
  60.                         for (var b = 0; b < nick.length; ++b) a.setUint16(1 + 2 * b, nick.charCodeAt(b), !0);
  61.                         bots[this.bot].send(a.buffer);
  62.                 };
  63.                 bots[i].setDirection = function(x, y) {
  64.                         if (typeof bots[this.bot] == "undefined") {
  65.                                 return true;
  66.                         }
  67.  
  68.                         a = new DataView(new ArrayBuffer(13));
  69.                         a.setUint8(0, 16);
  70.                         a.setInt32(1, x, !0);
  71.                         a.setInt32(5, y, !0);
  72.                         a.setUint32(9, 0, !0);
  73.                         bots[this.bot].send(a.buffer);
  74.                 }
  75.         }
  76. };
  77. stopBots = function() {
  78.         if (typeof bots != "undefined") for (i = 0; i < bots.length; i++) { bots[i].close(); }
  79.  
  80.         bots = [];
  81. };runBots = function(ip, token) {
  82.         if (jQuery('#token').val().length > 8) {
  83.                 alert('You must to create a Party first or connect to a private server.');
  84.                 return true;
  85.         } else if (jQuery('#token').val().length > 0) {
  86.                 mAB = 4;
  87.         } else {
  88.                 mAB = 10;
  89.         }
  90.  
  91.         bots = [];
  92.         currentServer = ip;
  93.  
  94.         for (i = 0; i < mAB; i++) {
  95.                 bots.push(new WebSocket(ip));
  96.                 bots[i].binaryType = "arraybuffer";
  97.                 bots[i].bot = i;
  98.                 bots[i].id = null;
  99.  
  100.                 bots[i].onopen = function() {
  101.                         a = new DataView(new ArrayBuffer(5));
  102.                         a.setUint8(0, 254);
  103.                         a.setUint32(1,
  104.                                 5, !0);
  105.                         this.send(a.buffer);
  106.                         a = new DataView(new ArrayBuffer(5));
  107.                         a.setUint8(0, 255);
  108.                         a.setUint32(1, 154669603, !0);
  109.                         this.send(a.buffer);
  110.                         a = new DataView(new ArrayBuffer(1 + token.length));
  111.                         a.setUint8(0, 80);
  112.                         for (var c = 0; c < token.length; ++c) a.setUint8(c + 1, token.charCodeAt(c));
  113.                         this.send(a.buffer);
  114.  
  115.                         console.log("Bot " + this.bot + " connected.");
  116.                 };
  117.                 bots[i].onmessage = function() {
  118.                         if (playing()) {
  119.                                 this.setNick(jQuery("#botsNick").val());
  120.                                 xx = jQuery("[name='botsFollow']:checked").val() == "mouse" ? ra : localStorage["x"]; // ra: target x
  121.                                 yy = jQuery("[name='botsFollow']:checked").val() == "mouse" ? sa : localStorage["y"]; // sa: target y
  122.                                 this.setDirection(xx, yy);
  123.                         }
  124.                 };
  125.                 bots[i].onclose = function() {
  126.                         bots.splice(this.bot, 1);
  127.                         console.log("Bot " + this.bot + " closed.");
  128.                 };
  129.                 bots[i].onerror = function() {
  130.                         bots.splice(this.bot, 1);
  131.                         console.log("Bot " + this.bot + " got an error.");
  132.                 };
  133.                 bots[i].setNick = function(nick) {
  134.                         if (typeof bots[this.bot] == "undefined") {
  135.                                 return true;
  136.                         }
  137.  
  138.                         var a = new DataView(new ArrayBuffer(1 + 2 * nick.length));
  139.                         a.setUint8(0, 0);
  140.                         for (var b = 0; b < nick.length; ++b) a.setUint16(1 + 2 * b, nick.charCodeAt(b), !0);
  141.                         bots[this.bot].send(a.buffer);
  142.                 };
  143.                 bots[i].setDirection = function(x, y) {
  144.                         if (typeof bots[this.bot] == "undefined") {
  145.                                 return true;
  146.                         }
  147.  
  148.                         a = new DataView(new ArrayBuffer(13));
  149.                         a.setUint8(0, 16);
  150.                         a.setInt32(1, x, !0);
  151.                         a.setInt32(5, y, !0);
  152.                         a.setUint32(9, 0, !0);
  153.                         bots[this.bot].send(a.buffer);
  154.                 }
  155.         }
  156. };
  157. stopBots = function() {
  158.         if (typeof bots != "undefined") for (i = 0; i < bots.length; i++) { bots[i].close(); }
  159.  
  160.         bots = [];
  161. };
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement