Advertisement
hossem147

HOSS++ V1

Mar 20th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.54 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>HOSS++<a id='minionCount' ><font color =#ffffff>V1</font></a><br>_________________ </div>" );
  28.  
  29. socket.on('spawn-count', function (data) {
  30. document.getElementById('minionCount').innerHTML = data;
  31. });
  32.  
  33. var client_uuid = localStorage.getItem('client_uuid');
  34.  
  35. if(client_uuid == null){
  36. console.log("generating a uuid for this user");
  37. client_uuid = Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  38. localStorage.setItem('client_uuid', client_uuid);
  39. }
  40.  
  41. socket.emit("login", client_uuid);
  42.  
  43. $("#instructions").replaceWith('<br><div class="input-group"><span class="input-group-addon" id="basic-addon1"><font color ="#0000FF""><b>CONTACT</b></span><input type="FB/Hamami.Hossem2" value=""</div>');
  44.  
  45. // values in --> window.agar
  46.  
  47. function isMe(cell){
  48. for (var i = 0; i < window.agar.myCells.length; i++){
  49. if (window.agar.myCells[i] == cell.id){
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55.  
  56. function drawMinimap() {
  57. 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))
  58. }
  59.  
  60. function getCell(){
  61. var me = [];
  62. for (var key in window.agar.allCells){
  63. var cell = window.agar.allCells[key];
  64. if (isMe(cell)){
  65. me.push(cell);
  66. }
  67. }
  68. return me[0];
  69. }
  70.  
  71. var skin_var = 0;
  72.  
  73. function emitPosition(){
  74.  
  75. if (skin_var == 0){
  76. skin = "%shark"
  77. skin_var = 1;
  78. }else{
  79. skin = "%kraken"
  80. skin_var = 0;
  81. }
  82.  
  83. for (i = 0; i < agar.myCells.length; i++) {
  84. //agar.allCells[agar.myCells[i]].C = skin
  85. }
  86.  
  87.  
  88.  
  89. x = (mouseX - window.innerWidth / 2) / window.agar.drawScale + window.agar.rawViewport.x;
  90. y = (mouseY - window.innerHeight / 2) / window.agar.drawScale + window.agar.rawViewport.y;
  91.  
  92. if(!movetoMouse)
  93. {
  94. x = getCell().x;
  95. y = getCell().y;
  96. }
  97.  
  98. socket.emit("pos", {"x": x, "y": y, "dimensions": agar.dimensions, "suicide_targets": agar.myCells} );
  99. }
  100.  
  101. function emitSplit(){
  102. socket.emit("cmd", {"name":"split"} );
  103. }
  104.  
  105. function emitMassEject(){
  106. socket.emit("cmd", {"name":"eject"} );
  107. }
  108.  
  109. function toggleMovement(){
  110. canMove = !canMove;
  111.  
  112. switch(canMove)
  113. {
  114. case true:
  115. canvas.onmousemove = moveEvent[0];
  116. moveEvent[0] = null;
  117.  
  118. canvas.onmousedown = moveEvent[1];
  119. moveEvent[1] = null;
  120. break;
  121.  
  122. case false:
  123. canvas.onmousemove({clientX: innerWidth / 2, clientY: innerHeight / 2});
  124.  
  125. moveEvent[0] = canvas.onmousemove;
  126. canvas.onmousemove = null;
  127.  
  128. moveEvent[1] = canvas.onmousedown;
  129. canvas.onmousedown = null;
  130. break;
  131. }
  132. }
  133.  
  134. interval_id = setInterval(function() {
  135. emitPosition();
  136. }, 100);
  137.  
  138. interval_id2 = setInterval(function() {
  139. transmit_game_server_if_changed();
  140. }, 5000);
  141.  
  142. document.addEventListener('keydown',function(e){
  143. var key = e.keyCode || e.which;
  144. switch(key)
  145. {
  146. case 65://a has been pressed. (Toggle Position)
  147. movetoMouse = !movetoMouse;
  148. break;
  149.  
  150. case 68://d has been pressed. (Toggle Movement)
  151. toggleMovement();
  152. break;
  153.  
  154. case 69://e has been pressed. (Split Bots)
  155. emitSplit();
  156. break;
  157.  
  158. case 82://r has been pressed. (Eject Mass from Bots)
  159. emitMassEject();
  160. break;
  161. }
  162. });
  163.  
  164. function transmit_game_server_if_changed(){
  165. if(last_transmited_game_server != window.agar.ws){
  166. transmit_game_server();
  167. }
  168. }
  169.  
  170. function transmit_game_server(){
  171. last_transmited_game_server = window.agar.ws;
  172. socket.emit("cmd", {"name":"connect_server", "ip": last_transmited_game_server } );
  173. }
  174.  
  175. var mouseX = 0;
  176. var mouseY = 0;
  177.  
  178. $("body").mousemove(function( event ) {
  179. mouseX = event.clientX;
  180. mouseY = event.clientY;
  181. });
  182.  
  183. window.agar.minScale = -30;
  184. }, 5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement