MichuuBotv2

Boty do gry agar.io!

  1. // ==UserScript==
  2. // @name MichuuBotv2
  3. // @namespace MichuuBest
  4. // @description Boty do gry agar.io!
  5. // @include http://agar.io/
  6. // @version 3.01
  7. // @grant none
  8. // @author twitch.tv/michalped23
  9. // ==/UserScript==
  10.  
  11. var totalBotCount = 0;
  12.  
  13. function game(h, r, bot, botUrl, botName) {
  14.  
  15. var window = h;
  16. var canvas;
  17. var botsUrl;
  18. var botsCount = 15;
  19. var botsCreated = false;
  20. if(bot){
  21. totalBotCount++;
  22. botName = botName + "_b" + totalBotCount;
  23. }
  24.  
  25. function init() {
  26.  
  27.  
  28. if(bot){
  29. console.log("bot - " + botName);
  30. connectTo(botUrl);
  31. setInterval(sendPosition, 100);
  32. return;
  33. }
  34.  
  35. //! bot
  36. loadRegions();
  37. setInterval(loadRegions, 18E4);
  38.  
  39. A = X = document.getElementById("canvas");
  40. canvas = A;
  41. d = canvas.getContext("2d");
  42.  
  43. canvas.onmousedown = function(a) {
  44. if (fa) {
  45. var b = a.clientX - (5 + k / 5 / 2), c = a.clientY - (5 + k / 5 / 2);
  46. if (Math.sqrt(b * b + c * c) <= k / 5 / 2) {
  47. sendPosition();
  48. sendCommand(17);
  49. return
  50. }
  51. }
  52. O = a.clientX;
  53. P = a.clientY;
  54. Y();
  55. sendPosition()
  56. };
  57. canvas.onmousemove = function(e) {
  58. O = e.clientX;
  59. P = e.clientY;
  60. Y()
  61. };
  62. canvas.onmouseup = function() {};
  63.  
  64. var a = !1, b = !1, c = !1;
  65. if(!bot) window.onkeydown = function(e) {
  66. 32 != e.keyCode || a || (sendPosition(), sendCommand(17), a = !0);
  67. 81 != e.keyCode || b || (sendCommand(18), b = !0);
  68. 87 != e.keyCode || c || (sendPosition(), sendCommand(21), c = !0);
  69. 27 == e.keyCode && r("#overlays").fadeIn(200)
  70. };
  71. if(!bot) window.onkeyup = function(e) {
  72. 32 == e.keyCode && (a = !1);
  73. 87 == e.keyCode && (c = !1);
  74. 81 == e.keyCode && b && (sendCommand(19), b = !1)
  75. };
  76. if(!bot) window.onblur = function() {
  77. sendCommand(19);
  78. c = b = a = !1
  79. };
  80. h.onresize = ga;
  81. ga();
  82.  
  83. window.requestAnimationFrame ? window.requestAnimationFrame(ha) : setInterval(Z, 1E3 / 60);
  84.  
  85. setInterval(sendPosition, 100);
  86.  
  87. ia(r("#region").val())
  88.  
  89. }
  90.  
  91.  
  92.  
  93. function va() {
  94. if (.5 > g)
  95. G = null;
  96. else {
  97. for (var a = Number.POSITIVE_INFINITY, b = Number.POSITIVE_INFINITY, c = Number.NEGATIVE_INFINITY, e = Number.NEGATIVE_INFINITY, d = 0, f = 0; f < p.length; f++)
  98. p[f].shouldRender() && (d = Math.max(p[f].size, d), a = Math.min(p[f].x, a), b = Math.min(p[f].y, b), c = Math.max(p[f].x, c), e = Math.max(p[f].y, e));
  99. G = QUAD.init({minX: a - (d + 100),minY: b - (d + 100),maxX: c + (d + 100),maxY: e + (d + 100)});
  100. for (f = 0; f < p.length; f++)
  101. if (a = p[f], a.shouldRender())
  102. for (b = 0; b < a.points.length; ++b)
  103. G.insert(a.points[b])
  104. }
  105. }
  106. function Y() {
  107. Q = (O - k / 2) / g + s;
  108. R = (P - q / 2) / g + t
  109. }
  110. function loadRegions() {
  111. null == S && (S = {}, r("#region").children().each(function() {
  112. var a = r(this), b = a.val();
  113. b && (S[b] = a.text())
  114. }));
  115. r.get("http://m.agar.io/info", function(a) {
  116. for (var b in a.regions)
  117. r('#region option[value="' +
  118. b + '"]').text(S[b] + " (" + a.regions[b].numPlayers + " players)")
  119. }, "json")
  120. }
  121. function hideMenu() {
  122. if(bot) return;
  123. r("#adsBottom").hide();
  124. r("#overlays").hide()
  125. //autoRestart = true;
  126. }
  127. function ia(a) {
  128. a && a != $ && ($ = a, ka())
  129. }
  130. function la() {
  131. r.ajax("http://m.agar.io/",
  132. {
  133. error: function() {
  134. setTimeout(la, 1E3)
  135. },
  136. success: function(a) {
  137. a = a.split("\n");
  138. connectTo("ws://" + a[0])
  139. },
  140. dataType: "text",
  141. method: "POST",
  142. cache: false,
  143. crossDomain: !0,
  144. data: $ || "?"})
  145. }
  146. function ka() {
  147. if(!bot) r("#connecting").show();
  148. la()
  149. }
  150. function connectTo(url) {
  151. l && (l.onopen = null, l.onmessage = null, l.onclose = null, l.close(), l = null);
  152. C = [];
  153. m = [];
  154. w = {};
  155. p = [];
  156. D = [];
  157. u = [];
  158. console.log("Connecting to " + url);
  159. l = new WebSocket(url);
  160. l.binaryType = "arraybuffer";
  161. l.onopen = function(){
  162. onConnected(url)
  163. };
  164. l.onmessage = xa;
  165. l.onclose = ya;
  166. l.onerror = function() {
  167. console.log("socket error")
  168. }
  169. }
  170. function onConnected(url) {
  171. r("#connecting").hide();
  172. console.log("socket open");
  173.  
  174. botsUrl = url;
  175.  
  176. var a = new ArrayBuffer(5);
  177. var b = new DataView(a);
  178. b.setUint8(0, 255);
  179. b.setUint32(1, 1, !0);
  180. l.send(a);
  181.  
  182. restartGame()
  183. }
  184. function ya(a) {
  185. console.log("socket close");
  186. setTimeout(ka, 500)
  187. }
  188. function xa(a) {
  189. function b() {
  190. for (var a = ""; ; ) {
  191. var b = e.getUint16(c, !0);
  192. c += 2;
  193. if (0 == b)
  194. break;
  195. a += String.fromCharCode(b)
  196. }
  197. return a
  198. }
  199. var c = 1, e = new DataView(a.data);
  200. switch (e.getUint8(0)) {
  201. case 16:
  202. za(e);
  203. break;
  204. case 17:
  205. x = e.getFloat64(1, !0);
  206. y = e.getFloat64(9, !0);
  207. H = e.getFloat64(17, !0);
  208. break;
  209. case 20:
  210. m = [];
  211. C = [];
  212. break;
  213. case 32:
  214. C.push(e.getUint32(1, !0));
  215. break;
  216. case 48:
  217. for (u = []; c < e.byteLength; )
  218. u.push({id: 0,name: b()});
  219. oa();
  220. break;
  221. case 49:
  222. a = e.getUint32(c, !0);
  223. c += 4;
  224. u = [];
  225. for (var d = 0; d < a; ++d) {
  226. var f = e.getUint32(c, !0), c = c + 4;
  227. u.push({id: f,name: b()})
  228. }
  229. oa();
  230. break;
  231. case 64:
  232. I = e.getFloat64(1, !0), J = e.getFloat64(9, !0), K = e.getFloat64(17, !0), L = e.getFloat64(25, !0), x = (K + I) / 2, y = (L + J) / 2, H = 1, 0 == m.length && (s = x, t = y, g = H)
  233. }
  234. }
  235. function za(a) {
  236. E = +new Date;
  237. var b = Math.random(), c = 1;
  238. aa = !1;
  239. for (var e = a.getUint16(c, !0), c = c + 2, d = 0; d < e; ++d) {
  240. var f = w[a.getUint32(c, !0)], g = w[a.getUint32(c + 4, !0)], c = c + 8;
  241. f && g && (g.destroy(), g.ox = g.x, g.oy = g.y, g.oSize = g.size, g.nx = f.x, g.ny = f.y, g.nSize = g.size, g.updateTime = E)
  242. }
  243. for (; ; ) {
  244. e = a.getUint32(c, !0);
  245. c += 4;
  246. if (0 == e)
  247. break;
  248. d = a.getFloat64(c, !0);
  249. c += 8;
  250. f = a.getFloat64(c, !0);
  251. c += 8;
  252. g = a.getFloat64(c, !0);
  253. c += 8;
  254. a.getUint8(c++);
  255. for (var h = a.getUint8(c++), l = a.getUint8(c++), k =
  256. a.getUint8(c++), h = (h << 16 | l << 8 | k).toString(16); 6 > h.length; )
  257. h = "0" + h;
  258. h = "#" + h;
  259. k = a.getUint8(c++);
  260. l = !!(k & 1);
  261. k & 2 && (c += 4);
  262. k & 4 && (c += 8);
  263. k & 8 && (c += 16);
  264. for (k = ""; ; ) {
  265. var n = a.getUint16(c, !0), c = c + 2;
  266. if (0 == n)
  267. break;
  268. k += String.fromCharCode(n)
  269. }
  270. n = null;
  271. w.hasOwnProperty(e) ? (n = w[e], n.updatePos(), n.ox = n.x, n.oy = n.y, n.oSize = n.size, n.color = h) : (n = new pa(e, d, f, g, h, l, k), n.pX = d, n.pY = f);
  272. n.nx = d;
  273. n.ny = f;
  274. n.nSize = g;
  275. n.updateCode = b;
  276. n.updateTime = E;
  277. -1 != C.indexOf(e) && -1 == m.indexOf(n) && (document.getElementById("overlays").style.display = "none", m.push(n), 1 == m.length && (s = n.x, t = n.y))
  278. }
  279. a.getUint16(c, !0);
  280. c += 2;
  281. f = a.getUint32(c, !0);
  282. c += 4;
  283. for (d = 0; d < f; d++)
  284. e = a.getUint32(c, !0), c += 4, w[e] && (w[e].updateCode = b);
  285. for (d = 0; d < p.length; d++)
  286. p[d].updateCode != b && p[d--].destroy();
  287. aa && 0 == m.length
  288. && showOverlays()
  289. }
  290.  
  291. function showOverlays(){
  292. if(! bot)
  293. r("#overlays").fadeIn(3E3);
  294. else
  295. restartGame();
  296. }
  297.  
  298. function sendPosition() {
  299. if (null != l && l.readyState == l.OPEN) {
  300. var a = O - k / 2, b = P - q / 2;
  301. 64 > a * a + b * b || qa == Q && ra == R;
  302. qa = Q;
  303. ra = R;
  304. var x = Q;
  305. var y = R;
  306.  
  307. if(!bot){
  308. clientX = x;
  309. clientY = y;
  310. } else {
  311. x = clientX;
  312. y = clientY;
  313. }
  314.  
  315. a = new ArrayBuffer(21);
  316. b = new DataView(a);
  317. b.setUint8(0, 16);
  318. b.setFloat64(1, x, !0);
  319. b.setFloat64(9, y, !0);
  320. b.setUint32(17, 0, !0);
  321. //if(bot) console.log("X="+x+", Y="+y);
  322.  
  323. l.send(a);
  324. }
  325. }
  326. function restartGame() {
  327. if (null != l && l.readyState == l.OPEN && null != M) {
  328. var a = new ArrayBuffer(1 + 2 * M.length), b = new DataView(a);
  329. b.setUint8(0, 0);
  330. for (var c = 0; c < M.length; ++c)
  331. b.setUint16(1 + 2 * c, M.charCodeAt(c), !0);
  332. l.send(a)
  333. }
  334. }
  335. function sendCommand(a) {
  336. if (null != l && l.readyState == l.OPEN) {
  337. var b = new ArrayBuffer(1);
  338. (new DataView(b)).setUint8(0, a);
  339. l.send(b)
  340. }
  341. }
  342. function ha() {
  343. Z();
  344. h.requestAnimationFrame(ha)
  345. }
  346. function ga() {
  347. k = h.innerWidth;
  348. q = h.innerHeight;
  349. X.width = A.width = k;
  350. X.height = A.height = q;
  351. Z()
  352. }
  353. function Aa() {
  354. if (0 != m.length) {
  355. for (var a = 0, b = 0; b < m.length; b++)
  356. a += m[b].size;
  357. a = Math.pow(Math.min(64 / a, 1), .4) * Math.max(q / 1080, k / 1920);
  358. g = (9 * g + a) / 10
  359. }
  360. }
  361. function Z() {
  362.  
  363. if(bot) return;
  364.  
  365. var g = 0.5;
  366. var a = +new Date;
  367. ++Ba;
  368. E = +new Date;
  369. if (0 < m.length) {
  370. Aa();
  371. for (var b = 0, c = 0, e = 0; e < m.length; e++)
  372. m[e].updatePos(), b += m[e].x / m.length, c += m[e].y / m.length;
  373. x = b;
  374. y = c;
  375. H = g;
  376. s = (s + b) / 2;
  377. t = (t + c) / 2
  378. } else
  379. x > K - (k / 2 - 100) / g && (x = K - (k / 2 - 100) / g), y > L - (q / 2 - 100) / g && (y = L - (q / 2 - 100) / g), x < I + (k / 2 - 100) / g && (x = (I + k / 2 - 100) / g), y < J + (q / 2 - 100) / g && (y = (J + q / 2 - 100) / g), s = (29 * s + x) / 30, t = (29 * t + y) / 30, g = (9 * g + H) / 10;
  380. va();
  381. Y();
  382. d.clearRect(0, 0, k, q);
  383. d.fillStyle = ba ? "#111111" : "#F2FBFF";
  384. d.fillRect(0, 0, k, q);
  385. d.save();
  386. d.strokeStyle = ba ? "#AAAAAA" : "#000000";
  387. d.globalAlpha = .2;
  388. d.scale(g, g);
  389. b = k / g;
  390. c = q / g;
  391. for (e = -.5 + (-s + b / 2) % 50; e < b; e += 50)
  392. d.beginPath(), d.moveTo(e, 0), d.lineTo(e, c), d.stroke();
  393. for (e = -.5 + (-t + c / 2) % 50; e < c; e += 50)
  394. d.beginPath(), d.moveTo(0, e), d.lineTo(b, e), d.stroke();
  395. d.restore();
  396. p.sort(function(a, b) {
  397. return a.size == b.size ? a.id - b.id : a.size - b.size
  398. });
  399. d.save();
  400. d.translate(k / 2, q / 2);
  401. d.scale(g, g);
  402. d.translate(-s, -t);
  403. for (e = 0; e < D.length; e++)
  404. D[e].draw();
  405. for (e = 0; e < p.length; e++)
  406. p[e].draw();
  407. d.restore();
  408. z && 0 != u.length && d.drawImage(z, k - z.width - 10, 10);
  409. N = Math.max(N, Ca());
  410. 0 != N && (null == T && (T = new U(24, "#FFFFFF")), T.setValue("Score: " + ~~(N / 100)), c = T.render(), b = c.width, d.globalAlpha = .2, d.fillStyle = "#000000", d.fillRect(10, q - 10 - 24 - 10, b + 10, 34), d.globalAlpha = 1, d.drawImage(c, 15, q - 10 - 24 - 5));
  411. Da();
  412. a = +new Date - a;
  413. a > 1E3 / 60 ? v -= .01 : a < 1E3 / 65 && (v += .01);
  414. .4 > v && (v = .4);
  415. 1 < v && (v = 1)
  416. }
  417. function Da() {
  418. if (fa && ca.width) {
  419. var a = k / 5;
  420. d.drawImage(ca, 5, 5, a, a)
  421. }
  422. }
  423. function Ca() {
  424. for (var a = 0, b = 0; b < m.length; b++)
  425. a += m[b].nSize * m[b].nSize;
  426. return a
  427. }
  428. function oa() {
  429. if(bot) return;
  430. if (0 != u.length)
  431. if (V) {
  432. z = document.createElement("canvas");
  433. var a = z.getContext("2d"), b = 60 + 24 * u.length, c = Math.min(200, .3 * k) / 200;
  434. z.width = 200 * c;
  435. z.height = b * c;
  436. a.scale(c, c);
  437. a.globalAlpha = .4;
  438. a.fillStyle = "#000000";
  439. a.fillRect(0, 0, 200, b);
  440. a.globalAlpha = 1;
  441. a.fillStyle = "#FFFFFF";
  442. c = null;
  443. c = "Leaderboard";
  444. a.font = "30px Ubuntu";
  445. a.fillText(c, 100 - a.measureText(c).width / 2, 40);
  446. a.font = "20px Ubuntu";
  447. for (b = 0; b < u.length; ++b)
  448. c = u[b].name || "An unnamed cell", V || (c = "An unnamed cell"), -1 != C.indexOf(u[b].id) ? (m[0].name &&
  449. (c = m[0].name), a.fillStyle = "#FFAAAA") : a.fillStyle = "#FFFFFF", c = b + 1 + ". " + c, a.fillText(c, 100 - a.measureText(c).width / 2, 70 + 24 * b)
  450. } else
  451. z = null
  452. }
  453. function pa(a, b, c, e, d, f, g) {
  454. p.push(this);
  455. w[a] = this;
  456. this.id = a;
  457. this.ox = this.x = b;
  458. this.oy = this.y = c;
  459. this.oSize = this.size = e;
  460. this.color = d;
  461. this.isVirus = f;
  462. this.points = [];
  463. this.pointsAcc = [];
  464. this.createPoints();
  465. this.setName(g)
  466. }
  467. function U(a, b, c, e) {
  468. a && (this._size = a);
  469. b && (this._color = b);
  470. this._stroke = !!c;
  471. e && (this._strokeColor = e)
  472. }
  473.  
  474.  
  475.  
  476. var X, d, A, k, q, G = null, l = null, s = 0, t = 0, C = [], m = [], w = {}, p = [], D = [], u = [], O = 0, P = 0, Q = -1, R = -1, Ba = 0, E = 0, M = null, I = 0, J = 0, K = 1E4, L = 1E4, g = 1, $ = null, sa = !0, V = !0, da = !1, aa = !1, N = 0, ba = !1, ta = !1, x = 0, y = 0, H = 1, fa = "ontouchstart" in h && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), ca = new Image;
  477. ca.src = "img/split.png";
  478. var S = null;
  479.  
  480.  
  481. if(!bot) h.setNick = function(a) {
  482. hideMenu();
  483. M = a;
  484. restartGame();
  485. N = 0
  486.  
  487. if( !bot && ! botsCreated){
  488.  
  489. console.log("create bots...");
  490. botsCreated = true;
  491. for (i = 0; i < botsCount; i++) {
  492. //нужно делать паузу перед новым ботом,
  493. //чтобы сервер не отклонил слишком частые соединения
  494. setTimeout(function(){
  495. game(window, r, true, botsUrl, M);
  496. }, 500);
  497. }
  498.  
  499. }
  500.  
  501. };
  502. else {
  503. M = botName;
  504. }
  505.  
  506.  
  507.  
  508. if(!bot) h.setRegion = ia;
  509. if(!bot) h.setSkins = function(a) {
  510. sa = a
  511. };
  512. if(!bot) h.setNames = function(a) {
  513. V = a
  514. };
  515. if(!bot) h.setDarkTheme = function(a) {
  516. ba = a
  517. };
  518. if(!bot) h.setColors = function(a) {
  519. da = a
  520. };
  521. if(!bot) h.setShowMass = function(a) {
  522. ta = a
  523. };
  524. if(!bot) h.spectate = function() {
  525. sendCommand(1);
  526. hideMenu()
  527. };
  528. if(!bot) h.connect = loadRegions;
  529. var qa = -1, ra = -1, z = null, v = 1, T = null, W = {}, Ea = "poland;usa;china;russia;canada;australia;spain;brazil;germany;ukraine;france;sweden;hitler;north korea;south korea;japan;united kingdom;earth;greece;latvia;lithuania;estonia;finland;norway;cia;maldivas;austria;nigeria;reddit;yaranaika;confederate;9gag;indiana;4chan;italy;ussr;pewdiepie;bulgaria;tumblr;2ch.hk;hong kong;portugal;jamaica;german empire;mexico;sanik;switzerland;croatia;chile;indonesia;bangladesh;thailand;iran;iraq;peru;moon;botswana;bosnia;netherlands;european union;taiwan;pakistan;hungary;satanist;qing dynasty;nazi;matriarchy;patriarchy;feminism;ireland;texas;facepunch;prodota;cambodia;steam;piccolo;ea;india;kc;denmark;quebec;ayy lmao;sealand;bait;tsarist russia;origin;vinesauce;stalin;belgium;luxembourg;stussy;prussia;8ch;argentina;scotland;sir;romania;belarus;wojak;isis;doge".split(";"), Fa = ["m'blob"];
  530. pa.prototype = {id: 0,points: null,pointsAcc: null,name: null,nameCache: null,sizeCache: null,x: 0,y: 0,size: 0,ox: 0,oy: 0,oSize: 0,nx: 0,ny: 0,nSize: 0,updateTime: 0,updateCode: 0,drawTime: 0,destroyed: !1,isVirus: !1,destroy: function() {
  531. var a;
  532. for (a = 0; a < p.length; a++)
  533. if (p[a] == this) {
  534. p.splice(a, 1);
  535. break
  536. }
  537. delete w[this.id];
  538. a = m.indexOf(this);
  539. -1 != a && (aa = !0, m.splice(a, 1));
  540. a = C.indexOf(this.id);
  541. -1 != a && C.splice(a, 1);
  542. this.destroyed = !0;
  543. D.push(this)
  544. },getNameSize: function() {
  545. return Math.max(~~(.3 * this.size), 24)
  546. },setName: function(a) {
  547. if (this.name = a)
  548. null == this.nameCache ? this.nameCache = new U(this.getNameSize(), "#FFFFFF", !0, "#000000") : this.nameCache.setSize(this.getNameSize()), this.nameCache.setValue(this.name)
  549. },createPoints: function() {
  550. for (var a = this.getNumPoints(); this.points.length > a; ) {
  551. var b = ~~(Math.random() * this.points.length);
  552. this.points.splice(b, 1);
  553. this.pointsAcc.splice(b, 1)
  554. }
  555. 0 == this.points.length && 0 < a && (this.points.push({c: this,v: this.size,x: this.x,y: this.y}), this.pointsAcc.push(Math.random() - .5));
  556. for (; this.points.length < a; ) {
  557. var b = ~~(Math.random() * this.points.length), c = this.points[b];
  558. this.points.splice(b, 0, {c: this,v: c.v,x: c.x,y: c.y});
  559. this.pointsAcc.splice(b, 0, this.pointsAcc[b])
  560. }
  561. },getNumPoints: function() {
  562. var a = 10;
  563. 20 > this.size && (a = 5);
  564. this.isVirus && (a = 30);
  565. return ~~Math.max(this.size * g * (this.isVirus ? Math.min(2 * v, 1) : v), a)
  566. },movePoints: function() {
  567. this.createPoints();
  568. for (var a = this.points, b = this.pointsAcc, c = b.concat(), e = a.concat(), d = e.length, f = 0; f < d; ++f) {
  569. var g = c[(f - 1 + d) % d], h = c[(f + 1) % d];
  570. b[f] += Math.random() - .5;
  571. b[f] *= .7;
  572. 10 < b[f] && (b[f] = 10);
  573. -10 > b[f] && (b[f] = -10);
  574. b[f] = (g + h + 8 * b[f]) / 10
  575. }
  576. for (var k = this, f = 0; f < d; ++f) {
  577. c = e[f].v;
  578. g = e[(f - 1 + d) % d].v;
  579. h = e[(f + 1) % d].v;
  580. if (15 < this.size && null != G) {
  581. var l = !1, n = a[f].x, m = a[f].y;
  582. G.retrieve2(n - 5, m - 5, 10, 10, function(a) {
  583. a.c != k && 25 > (n - a.x) * (n - a.x) + (m - a.y) * (m - a.y) && (l = !0)
  584. });
  585. !l && (a[f].x < I || a[f].y < J || a[f].x > K || a[f].y > L) && (l = !0);
  586. l && (0 < b[f] && (b[f] = 0), b[f] -= 1)
  587. }
  588. c += b[f];
  589. 0 > c && (c = 0);
  590. c = (12 * c + this.size) / 13;
  591. a[f].v = (g + h + 8 * c) / 10;
  592. g = 2 * Math.PI / d;
  593. h = this.points[f].v;
  594. this.isVirus && 0 == f % 2 && (h += 5);
  595. a[f].x = this.x + Math.cos(g * f) * h;
  596. a[f].y = this.y + Math.sin(g * f) *
  597. h
  598. }
  599. },updatePos: function() {
  600. var a;
  601. a = (E - this.updateTime) / 120;
  602. a = 0 > a ? 0 : 1 < a ? 1 : a;
  603. a = a * a * (3 - 2 * a);
  604. this.getNameSize();
  605. if (this.destroyed && 1 <= a) {
  606. var b = D.indexOf(this);
  607. -1 != b && D.splice(b, 1)
  608. }
  609. this.x = a * (this.nx - this.ox) + this.ox;
  610. this.y = a * (this.ny - this.oy) + this.oy;
  611. this.size = a * (this.nSize - this.oSize) + this.oSize;
  612. return a
  613. },shouldRender: function() {
  614. return this.x + this.size + 40 < s - k / 2 / g || this.y + this.size + 40 < t - q / 2 / g || this.x - this.size - 40 > s + k / 2 / g || this.y - this.size - 40 > t + q / 2 / g ? !1 : !0
  615. },draw: function() {
  616. if (this.shouldRender()) {
  617. var a = !this.isVirus &&
  618. .5 > g;
  619. d.save();
  620. this.drawTime = E;
  621. var b = this.updatePos();
  622. this.destroyed && (d.globalAlpha *= 1 - b);
  623. d.lineWidth = 10;
  624. d.lineCap = "round";
  625. d.lineJoin = this.isVirus ? "mitter" : "round";
  626. da ? (d.fillStyle = "#FFFFFF", d.strokeStyle = "#AAAAAA") : (d.fillStyle = this.color, d.strokeStyle = this.color);
  627. if (a)
  628. d.beginPath(), d.arc(this.x, this.y, this.size, 0, 2 * Math.PI, !1);
  629. else
  630. for (this.movePoints(), d.beginPath(), a = this.getNumPoints(), d.moveTo(this.points[0].x, this.points[0].y), b = 1; b <= a; ++b) {
  631. var c = b % a;
  632. d.lineTo(this.points[c].x, this.points[c].y)
  633. }
  634. d.closePath();
  635. a = this.name.toLowerCase();
  636. sa ? -1 != Ea.indexOf(a) ? (W.hasOwnProperty(a) || (W[a] = new Image, W[a].src = "skins/" + a + ".png"), b = W[a]) : b = null : b = null;
  637. a = b ? -1 != Fa.indexOf(a) : !1;
  638. d.stroke();
  639. d.fill();
  640. null != b && 0 < b.width && !a && (d.save(), d.clip(), d.drawImage(b, this.x - this.size, this.y - this.size, 2 * this.size, 2 * this.size), d.restore());
  641. if (da || 15 < this.size)
  642. d.strokeStyle = "#000000", d.globalAlpha *= .1, d.stroke();
  643. d.globalAlpha = 1;
  644. null != b && 0 < b.width && a && d.drawImage(b, this.x - 2 * this.size, this.y - 2 * this.size, 4 * this.size, 4 * this.size);
  645. b = -1 != m.indexOf(this);
  646. a = ~~this.y;
  647. if ((V || b) && this.name && this.nameCache) {
  648. var e = this.nameCache;
  649. e.setValue(this.name);
  650. e.setSize(this.getNameSize());
  651. c = Math.ceil(10 * g) / 10;
  652. e.setScale(c);
  653. var e = e.render(), h = ~~(e.width / c), c = ~~(e.height / c);
  654. d.drawImage(e, ~~this.x - ~~(h / 2), a - ~~(c / 2), h, c);
  655. a += e.height / 2 + 4
  656. }
  657. ta && b && (null == this.sizeCache && (this.sizeCache = new U(this.getNameSize() / 2, "#FFFFFF", !0, "#000000")), b = this.sizeCache, b.setSize(this.getNameSize() / 2), b.setValue(~~(this.size * this.size / 100)), c = Math.ceil(10 * g) / 10, b.setScale(c),
  658. e = b.render(), h = ~~(e.width / c), c = ~~(e.height / c), d.drawImage(e, ~~this.x - ~~(h / 2), a - ~~(c / 2), h, c));
  659. d.restore()
  660. }
  661. }};
  662. U.prototype = {_value: "",_color: "#000000",_stroke: !1,_strokeColor: "#000000",_size: 16,_canvas: null,_ctx: null,_dirty: !1,_scale: 1,setSize: function(a) {
  663. this._size != a && (this._size = a, this._dirty = !0)
  664. },setScale: function(a) {
  665. this._scale != a && (this._scale = a, this._dirty = !0)
  666. },setColor: function(a) {
  667. this._color != a && (this._color = a, this._dirty = !0)
  668. },setStroke: function(a) {
  669. this._stroke != a && (this._stroke = a, this._dirty = !0)
  670. },setStrokeColor: function(a) {
  671. this._strokeColor != a && (this._strokeColor = a, this._dirty = !0)
  672. },setValue: function(a) {
  673. a != this._value && (this._value = a, this._dirty = !0)
  674. },render: function() {
  675. null == this._canvas && (this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"));
  676. if (this._dirty) {
  677. this._dirty = !1;
  678. var a = this._canvas, b = this._ctx, c = this._value, d = this._scale, g = this._size, f = g + "px Ubuntu";
  679. b.font = f;
  680. var h = b.measureText(c).width, k = ~~(.2 * g);
  681. a.width = (h + 6) * d;
  682. a.height = (g + k) * d;
  683. b.font = f;
  684. b.scale(d, d);
  685. b.globalAlpha = 1;
  686. b.lineWidth = 3;
  687. b.strokeStyle = this._strokeColor;
  688. b.fillStyle = this._color;
  689. this._stroke && b.strokeText(c, 3, g - k / 2);
  690. b.fillText(c, 3, g - k / 2)
  691. }
  692. return this._canvas
  693. }};
  694.  
  695.  
  696.  
  697. if(!bot) h.onload = init;
  698. else init();
  699.  
  700. }
  701.  
  702. var playerX = 0;
  703. var playerY = 0;
  704.  
  705. game(window, jQuery);