Advertisement
hossem147

Untitled

Mar 20th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.59 KB | None | 0 0
  1. setTimeout(function() {
  2.  
  3. image = new Image();
  4. image.crossOrigin = 'anonymous';
  5. image.src = 'http://i.imgur.com/dOFpphQ.png';
  6. window.agar.hooks.cellSkin = function(cell, old_skin) {
  7. if (cell.name == "Bot") return image;
  8. return old_skin;
  9. }
  10.  
  11. var socket = io.connect('ws://127.0.0.1:8081');
  12. var canMove = true;
  13. var movetoMouse = true;
  14. var moveEvent = new Array(2);
  15. var canvas = document.getElementById("canvas");
  16. last_transmited_game_server = null;
  17.  
  18. socket.on('force-login', function (data) {
  19. socket.emit("login", {"uuid":client_uuid, "type":"client"});
  20. transmit_game_server();
  21. });
  22.  
  23. socket.on('spawn-count', function (data) {
  24. console.log("Bot Count: " + data);
  25. });
  26.  
  27. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 205px; top: 10px; left: 10px; display: block; position: absolute; text-align: center; font-size: 20px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><font color =#01DF01>☢</font>HOSSEM ++<a id='minionCount' ><font color =#ffffff>0</font></a><br>_______:D_______ </div>" );
  28. socket.on('spawn-count', function (data) {
  29. document.getElementById('minionCount').innerHTML = data;
  30. });
  31.  
  32. var client_uuid = localStorage.getItem('client_uuid');
  33.  
  34. if(client_uuid == null){
  35. console.log("generating a uuid for this user");
  36. client_uuid = Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  37. localStorage.setItem('client_uuid', client_uuid);
  38. }
  39.  
  40. socket.emit("login", client_uuid);
  41.  
  42. $("#instructions").replaceWith('<br><div class="input-group"><span class="input-group-addon" id="basic-addon1"><font color ="#0000FF""><b>FACEBOOK</b></span><input type="www.FB.com/Hamami.Hossem2" value="' + clienid + '" readonlass="formntrol"</div>');
  43.  
  44. // values in --> window.agar
  45.  
  46. function isMe(cell){
  47. for (var i = 0; i < window.agar.myCells.length; i++){
  48. if (window.agar.myCells[i] == cell.id){
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54.  
  55. function drawMinimap() {
  56. minimap = e(_0xfbfe[0])[0], xPos = Number(localStorage[_0xfbfe[1]]), yPos = Number(localStorage[_0xfbfe[2]]), xRatio = 0 > Ba ? (xPos + Da) / (2 * Da) : xPos / Da, yRatio = 0 > Ca ? (yPos + Ea) / (2 * Ea) : yPos / Ea, xMap = xRatio * minimap[_0xfbfe[3]], yMap = yRatio * minimap[_0xfbfe[4]], ctx = minimap[_0xfbfe[6]](_0xfbfe[5]), ctx[_0xfbfe[7]](0, 0, minimap[_0xfbfe[3]], minimap[_0xfbfe[4]]), ctx[_0xfbfe[8]] = .2, ctx[_0xfbfe[9]] = _0xfbfe[10], ctx[_0xfbfe[11]](0, 0, minimap[_0xfbfe[3]], minimap[_0xfbfe[4]]), ctx[_0xfbfe[8]] = 1, ctx[_0xfbfe[12]] = 1, ctx[_0xfbfe[13]](), ctx[_0xfbfe[14]](0, yMap), ctx[_0xfbfe[15]](minimap[_0xfbfe[3]], yMap), ctx[_0xfbfe[14]](xMap, 0), ctx[_0xfbfe[15]](xMap, minimap[_0xfbfe[4]]), ctx[_0xfbfe[16]](), ctx[_0xfbfe[17]] = _0xfbfe[18], ctx[_0xfbfe[19]](), l[_0xfbfe[20]] > 0 && (ctx[_0xfbfe[13]](), ctx[_0xfbfe[9]] = _0xfbfe[21], ctx[_0xfbfe[23]](xMap, yMap, 7, 0, 2 * Math[_0xfbfe[22]]), ctx[_0xfbfe[24]](), ctx[_0xfbfe[16]](), ctx[_0xfbfe[24]]()), typeof lDPos == _0xfbfe[25] && (xRatio = 0 > Ba ? (Number(lDPos[_0xfbfe[27]](_0xfbfe[26])[0]) + Da) / (2 * Da) : Number(lDPos[_0xfbfe[27]](_0xfbfe[26])[0]) / Da, yRatio = 0 > Ca ? (Number(lDPos[_0xfbfe[27]](_0xfbfe[26])[1]) + Ea) / (2 * Ea) : Number(lDPos[_0xfbfe[27]](_0xfbfe[26])[1]) / Ea, ctx[_0xfbfe[28]] = _0xfbfe[29], ctx[_0xfbfe[9]] = _0xfbfe[30], ctx[_0xfbfe[31]](_0xfbfe[1], xRatio * minimap[_0xfbfe[3]] - 4, yRatio * minimap[_0xfbfe[4]] + 4))
  57. }
  58.  
  59. function getCell(){
  60. var me = [];
  61. for (var key in window.agar.allCells){
  62. var cell = window.agar.allCells[key];
  63. if (isMe(cell)){
  64. me.push(cell);
  65. }
  66. }
  67. return me[0];
  68. }
  69.  
  70. var skin_var = 0;
  71.  
  72. function emitPosition(){
  73.  
  74. if (skin_var == 0){
  75. skin = "%shark"
  76. skin_var = 1;
  77. }else{
  78. skin = "%kraken"
  79. skin_var = 0;
  80. }
  81.  
  82. for (i = 0; i < agar.myCells.length; i++) {
  83. //agar.allCells[agar.myCells[i]].C = skin
  84. }
  85.  
  86.  
  87.  
  88. x = (mouseX - window.innerWidth / 2) / window.agar.drawScale + window.agar.rawViewport.x;
  89. y = (mouseY - window.innerHeight / 2) / window.agar.drawScale + window.agar.rawViewport.y;
  90.  
  91. if(!movetoMouse)
  92. {
  93. x = getCell().x;
  94. y = getCell().y;
  95. }
  96.  
  97. socket.emit("pos", {"x": x, "y": y, "dimensions": agar.dimensions, "suicide_targets": agar.myCells} );
  98. }
  99.  
  100. function emitSplit(){
  101. socket.emit("cmd", {"name":"split"} );
  102. }
  103.  
  104. function emitMassEject(){
  105. socket.emit("cmd", {"name":"eject"} );
  106. }
  107.  
  108. function toggleMovement(){
  109. canMove = !canMove;
  110.  
  111. switch(canMove)
  112. {
  113. case true:
  114. canvas.onmousemove = moveEvent[0];
  115. moveEvent[0] = null;
  116.  
  117. canvas.onmousedown = moveEvent[1];
  118. moveEvent[1] = null;
  119. break;
  120.  
  121. case false:
  122. canvas.onmousemove({clientX: innerWidth / 2, clientY: innerHeight / 2});
  123.  
  124. moveEvent[0] = canvas.onmousemove;
  125. canvas.onmousemove = null;
  126.  
  127. moveEvent[1] = canvas.onmousedown;
  128. canvas.onmousedown = null;
  129. break;
  130. }
  131. }
  132.  
  133. interval_id = setInterval(function() {
  134. emitPosition();
  135. }, 100);
  136.  
  137. interval_id2 = setInterval(function() {
  138. transmit_game_server_if_changed();
  139. }, 5000);
  140.  
  141. document.addEventListener('keydown',function(e){
  142. var key = e.keyCode || e.which;
  143. switch(key)
  144. {
  145. case 65://a has been pressed. (Toggle Position)
  146. movetoMouse = !movetoMouse;
  147. break;
  148.  
  149. case 68://d has been pressed. (Toggle Movement)
  150. toggleMovement();
  151. break;
  152.  
  153. case 69://e has been pressed. (Split Bots)
  154. emitSplit();
  155. break;
  156.  
  157. case 82://r has been pressed. (Eject Mass from Bots)
  158. emitMassEject();
  159. break;
  160. }
  161. });
  162.  
  163. function transmit_game_server_if_changed(){
  164. if(last_transmited_game_server != window.agar.ws){
  165. transmit_game_server();
  166. }
  167. }
  168.  
  169. function transmit_game_server(){
  170. last_transmited_game_server = window.agar.ws;
  171. socket.emit("cmd", {"name":"connect_server", "ip": last_transmited_game_server } );
  172. }
  173.  
  174. var mouseX = 0;
  175. var mouseY = 0;
  176.  
  177. $("body").mousemove(function( event ) {
  178. mouseX = event.clientX;
  179. mouseY = event.clientY;
  180. });
  181.  
  182. window.agar.minScale = -30;
  183. }, 5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement