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