Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.91 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Orad
  3. // @namespace Orad
  4. // @version 1.0
  5. // @description its da best
  6. // @author Orad
  7. // @match *://rsagartoolz.tk/mgar/*
  8. // @require https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. setTimeout(function()
  14. {
  15. var real_minx = -7071;
  16. var real_miny = -7071;
  17. var real_maxx = 7071;
  18. var real_maxy = 7071;
  19. var lastsent = {
  20. minx: 0,
  21. miny: 0,
  22. maxx: 0,
  23. maxy: 0
  24. };
  25.  
  26. function valcompare(Y, Z) {
  27. return 0.01 > Y - Z && -0.01 < Y - Z
  28. }
  29. window.v72.hooks.dimensionsUpdated = function(server_minx, server_miny, server_maxx, server_maxy) {
  30. if (valcompare(server_maxx - server_minx, server_maxy - server_miny)) {
  31. real_minx = server_minx;
  32. real_miny = server_miny;
  33. real_maxx = server_maxx;
  34. real_maxy = server_maxy
  35. } else {
  36. if (valcompare(server_minx, lastsent.minx)) {
  37. if (0.01 < server_maxx - lastsent.maxx || -0.01 > server_maxx - lastsent.maxx) {
  38. real_minx = server_minx;
  39. real_maxx = server_minx + 14142.135623730952
  40. }
  41. }
  42. if (0.01 < server_minx - lastsent.minx || -0.01 > server_minx - lastsent.minx) {
  43. if (valcompare(server_maxx, lastsent.maxx)) {
  44. real_maxx = server_maxx;
  45. real_minx = server_maxx - 14142.135623730952
  46. }
  47. }
  48. if (0.01 < server_miny - lastsent.miny || -0.01 > server_miny - lastsent.miny) {
  49. if (valcompare(server_maxy, lastsent.maxy)) {
  50. real_maxy = server_maxy;
  51. real_miny = server_maxy - 14142.135623730952
  52. }
  53. }
  54. if (valcompare(server_miny, lastsent.miny)) {
  55. if (0.01 < server_maxy - lastsent.maxy || -0.01 > server_maxy - lastsent.maxy) {
  56. real_miny = server_miny;
  57. real_maxy = server_miny + 14142.135623730952
  58. }
  59. }
  60. if (server_minx < real_minx) {
  61. real_minx = server_minx;
  62. real_maxx = server_minx + 14142.135623730952
  63. }
  64. if (server_maxx > real_maxx) {
  65. real_maxx = server_maxx;
  66. real_minx = server_maxx - 14142.135623730952
  67. }
  68. if (server_miny < real_miny) {
  69. real_miny = server_miny;
  70. real_maxy = server_miny + 14142.135623730952
  71. }
  72. if (server_maxy > real_maxy) {
  73. real_maxy = server_maxy;
  74. real_miny = server_maxy - 14142.135623730952
  75. }
  76. lastsent.minx = server_minx;
  77. lastsent.miny = server_miny;
  78. lastsent.maxy = server_maxy;
  79. lastsent.maxx = server_maxx
  80. }
  81. offset_x = real_minx || -7071;
  82. offset_y = real_miny || -7071
  83. };
  84. var socket = io.connect('ws://Bots-xhingking1965596.codeanyapp.com:8081');
  85. var canMove = true;
  86. var movetoMouse = true;
  87. var moveEvent = new Array(2);
  88. var canvas = document.getElementById("canvas");
  89. last_transmited_game_server = null;
  90. socket.on('force-login', function(data) {
  91. socket.emit("login", {
  92. "uuid": client_uuid,
  93. "type": "client"
  94. });
  95. transmit_game_server()
  96. });
  97.  
  98. $( "#canvas" ).after( "<div style='background-color: #000000; border-style: solid; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 205px; top: 10px; left: 600px; display: block; position: absolute; text-align: center; font-size: 15px; 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;'><a style='color:#fff600'>TrapKillo Bots</a></div> <div style='color:#ff14e1; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><br>Minions: <a id='minionCount' >Offline</a> </div> <div style='color:#36ff00; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><br>Move To Mouse: <a id='ismoveToMouse' >On</a> </div> <div style='color:#ff0000; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><br>Stop Movement: <a id='isStopMove' >Off</a> </div>" );
  99. socket.on('spawn-count', function(data) {
  100. document.getElementById('minionCount').innerHTML = data
  101. });
  102. var client_uuid = localStorage.getItem('client_uuid');
  103. if (client_uuid == null) {
  104. console.log("generating a uuid for this user");
  105. client_uuid = ""; var ranStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  106. for (var ii = 0; ii < 15; ii++) client_uuid += ranStr.charAt(Math.floor(Math.random() * ranStr.length));
  107. localStorage.setItem('client_uuid', client_uuid)
  108. }
  109. socket.emit("login", client_uuid);
  110. $("#instructions").replaceWith('<br><div class="input-group"><span class="input-group-addon" id="basic-addon1">UUID</span><input type="text" value="' + client_uuid + '" readonly class="form-control"</div>');
  111.  
  112. function isMe(cell) {
  113. for (var i = 0; i < window.v72.myCells.length; i++) {
  114. if (window.v72.myCells[i] == cell.id) {
  115. return true
  116. }
  117. }
  118. return false
  119. }
  120.  
  121. function getCell() {
  122. var me = [];
  123. for (var key in window.v72.allCells) {
  124. var cell = window.v72.allCells[key];
  125. if (isMe(cell)) {
  126. me.push(cell)
  127. }
  128. }
  129. return me[0]
  130. }
  131. var skin_var = 0;
  132.  
  133. function emitPosition() {
  134. for (i = 0; i < window.v72.myCells.length; i++) {}
  135. x = (mouseX - window.innerWidth / 2) / window.v72.drawScale + window.v72.rawViewport.x;
  136. y = (mouseY - window.innerHeight / 2) / window.v72.drawScale + window.v72.rawViewport.y;
  137. if (!movetoMouse) {
  138. x = getCell().x;
  139. y = getCell().y
  140. }
  141. socket.emit("pos", {
  142. "x": x - (real_minx + 7071),
  143. "y": y - (real_miny + 7071),
  144. "dimensions": [-7071, -7071, 7071, 7071]
  145. })
  146. }
  147.  
  148.  
  149. function emitSplit() {
  150. socket.emit("cmd", {
  151. "name": "split"
  152. })
  153. }
  154.  
  155. function emitMassEject() {
  156. socket.emit("cmd", {
  157. "name": "eject"
  158. })
  159. }
  160.  
  161. function toggleMovement() {
  162. canMove = !canMove;
  163. switch (canMove) {
  164. case true:
  165. canvas.onmousemove = moveEvent[0];
  166. moveEvent[0] = null;
  167. canvas.onmousedown = moveEvent[1];
  168. moveEvent[1] = null;
  169. break;
  170. case false:
  171. canvas.onmousemove({
  172. clientX: innerWidth / 2,
  173. clientY: innerHeight / 2
  174. });
  175. moveEvent[0] = canvas.onmousemove;
  176. canvas.onmousemove = null;
  177. moveEvent[1] = canvas.onmousedown;
  178. canvas.onmousedown = null;
  179. break
  180. }
  181. }
  182. interval_id = setInterval(function() {
  183. emitPosition()
  184. }, 100);
  185. interval_id2 = setInterval(function() {
  186. transmit_game_server_if_changed()
  187. }, 5000);
  188. document.addEventListener('keydown', function(e) {
  189. var key = e.keyCode || e.which;
  190. switch (key) {
  191. case 65:
  192. movetoMouse = !movetoMouse;
  193. if(movetoMouse) { document.getElementById('ismoveToMouse').innerHTML = "On"; } else { document.getElementById('ismoveToMouse').innerHTML = "Off"; }
  194. break;
  195. case 68:
  196. toggleMovement();
  197. if(!canMove) { document.getElementById('isStopMove').innerHTML = "On"; } else { document.getElementById('isStopMove').innerHTML = "Off"; }
  198. break;
  199. case 69:
  200. emitSplit();
  201. break;
  202. case 82:
  203. emitMassEject();
  204. break
  205. }
  206. });
  207.  
  208. function transmit_game_server_if_changed() {
  209. if (last_transmited_game_server != window.v72.ws) {
  210. transmit_game_server()
  211. }
  212. }
  213.  
  214. function transmit_game_server() {
  215. last_transmited_game_server = window.v72.ws;
  216. socket.emit("cmd", {
  217. "name": "connect_server",
  218. "ip": last_transmited_game_server
  219. })
  220. }
  221. var mouseX = 0;
  222. var mouseY = 0;
  223. $("body").mousemove(function(event) {
  224. mouseX = event.clientX;
  225. mouseY = event.clientY
  226. });
  227. }, 5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement