IADO Mod (Edited Chimken-Mod)

Turning chimken mod into the best moomoo hack slowly but surely.

  1. // ==UserScript==
  2. // @name IADO Mod (Edited Chimken-Mod)
  3. // @version V1.123456789101112.5
  4. // @author IAmDaOne -IADO-
  5. // @description Turning chimken mod into the best moomoo hack slowly but surely.
  6. // @match *://moomoo.io/*
  7. // @match *https://sandbox.moomoo.io/*
  8. // @icon https://img.freepik.com/premium-photo/intense-devil-art-black-white-wallpaper-with-multiple-filte_899449-50671.jpg
  9. // @grant none
  10. // @license MIT
  11. // @namespace https://gf.qytechs.cn/en/users/1362611
  12. // ==/UserScript==
  13.  
  14. //Note for IADO (Code editor), remember to get the copied version of the Public Autochat when you are editing the code in the future.
  15. //Note for IADO (Code editor), remember to get the copied version of the Public Autochat when you are editing the code in the future.
  16.  
  17. // Game-Ground 2 xD
  18. let whereverifybutton = document.querySelector("#altcha_checkbox")
  19. function clicktheverify() {
  20. if (whereverifybutton) {
  21. whereverifybutton.click()
  22. }
  23. }
  24. setInterval(clicktheverify, 1);
  25. document.getElementById("enterGame").addEventListener("mouseleave", function() {
  26. document.getElementById('enterGame').innerText = "⚜️❗Click here❗⚜️";
  27. document.getElementById("gameName").style.color = "ff0000";
  28. });
  29. document.getElementById('enterGame').innerText = "⚜️❗Click here❗⚜️";
  30. document.getElementById("enterGame").addEventListener("mouseenter", function() {
  31. document.getElementById('enterGame').innerText = "👉❓❗Play❓❗👈";
  32. document.getElementById("gameName").style.color = "ff0000";
  33. });
  34.  
  35. $("#mapDisplay").css({
  36. background: `url('https://i.imgur.com/fgFsQJp.png')`
  37. });
  38.  
  39.  
  40. setTimeout(() => {
  41. document.getElementById('gameName').innerHTML = 'Chimken-Mod!';
  42. setTimeout(() => {
  43. document.getElementById('gameName').innerHTML = ':) Just kidding';
  44. setTimeout(() => {
  45. document.getElementById('gameName').innerHTML = 'Get pranked';
  46. setTimeout(() => {
  47. document.getElementById('gameName').innerHTML = 'IADO Mod';
  48. setTimeout(() => {
  49. document.getElementById('gameName').innerHTML = '';
  50. }, 1100);
  51. }, 1100);
  52. }, 1400);
  53. }, 1100);
  54. }, 1100);
  55.  
  56.  
  57. document.title = "IADO's Moomoo :3";
  58. document.getElementById("mainMenu").style.backgroundSize = "cover";
  59. document.getElementById("mainMenu").style.backgroundPosition = "center";
  60. document.getElementById("mainMenu").style.width = "100%";
  61. document.getElementById("mainMenu").style.height = "100vh";
  62. document.getElementById("gameName").style.textShadow = "#FF2525 -2px -2px 10px, black 0px -5px 1px, white 0px -5px 10px";
  63. document.getElementById("loadingText").innerText="";
  64. document.getElementById("leaderboard").append("IADO-Mod");
  65.  
  66. const createSnowflake = function () {
  67. const snowflake = document.createElement("div");
  68. snowflake.className = "snowflake";
  69. snowflake.style.position = "absolute";
  70. snowflake.style.width = "10px";
  71. snowflake.style.height = "10px";
  72. snowflake.style.background = "#fff";
  73. snowflake.style.borderRadius = "50%";
  74. snowflake.style.zIndex = "9998";
  75. snowflake.style.opacity = Math.random();
  76. snowflake.style.left = Math.random() * 100 + "vw";
  77. snowflake.style.animation = `fall ${Math.random() * 2 + 1}s linear infinite`;
  78. snowflake.addEventListener("animationiteration", function () {
  79. snowflake.style.left = Math.random() * 100 + "vw";
  80. snowflake.style.opacity = Math.random();
  81. });
  82. return snowflake;
  83. };
  84.  
  85.  
  86. const styleSnowflakes = document.createElement("style");
  87. styleSnowflakes.textContent = ` @keyframes fall { 0% { transform: translateY(-10vh); opacity: 1; } 100% { transform: translateY(110vh); opacity: 0; } } .fast-fall { animation-duration: ${Math.random() * 1 + 1}s; } `;
  88. document.head.appendChild(styleSnowflakes);
  89.  
  90. const snowflakeContainer = document.createElement("div");
  91. snowflakeContainer.style.position = "absolute";
  92. snowflakeContainer.style.top = "0";
  93. snowflakeContainer.style.left = "0";
  94. snowflakeContainer.style.width = "100%";
  95. snowflakeContainer.style.height = "100%";
  96. snowflakeContainer.style.pointerEvents = "none";
  97. snowflakeContainer.style.zIndex = "9998";
  98. document.body.appendChild(snowflakeContainer);
  99.  
  100. const maxSnowflakes = 40;
  101. for (let i = 0; i < maxSnowflakes; i++) {
  102. const snowflake = createSnowflake();
  103. if (Math.random() > 0.7) {
  104. snowflake.classList.add("fast-fall");
  105. }
  106. snowflakeContainer.appendChild(snowflake);
  107. }
  108.  
  109. // Add event listener to the "enterGame" element
  110. const enterGameButton = document.getElementById("enterGame");
  111. if (enterGameButton) {
  112. enterGameButton.addEventListener("click", function () {
  113. // Hide the snowflake container when the button is pressed
  114. snowflakeContainer.style.display = "none";
  115. });
  116. }
  117. // Test Auto Reply
  118. let founda = false;
  119. let scriptTags = document.getElementsByTagName("script");
  120. for (let i = 0; i < scriptTags.length; i++) {
  121. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  122. scriptTags[i].remove();
  123. founda = true;
  124. break;
  125. }
  126. }
  127.  
  128.  
  129. var styleItem = document.createElement("style");
  130. styleItem.type = "text/css";
  131. styleItem.appendChild(document.createTextNode(`
  132. #suggestBox {
  133. width: 355px;
  134. border-radius: 3px;
  135. background-color: rgba(0,0,0,0.5);
  136. margin: auto;
  137. text-align: left;
  138. z-index: 49;
  139. pointer-events: auto;
  140. position: relative;
  141. bottom: 3.5px;
  142. overflow-y: auto;
  143. }
  144. #suggestBox div {
  145. background-color: rgba(255,255,255,0);
  146. color: rgba(255,255,255,1);
  147. transition: background-color 0.3s, color 0.3s;
  148. }
  149. #suggestBox div:hover {
  150. background-color: rgba(255,255,255,0.2);
  151. color: rgba(0,0,0,1);
  152. }
  153. .suggestBoxHard {
  154. color: rgba(255,255,255,1);
  155. font-size: 18px;
  156. }
  157. .suggestBoxLight {
  158. color: rgba(255,255,255,0.7);
  159. font-size: 18px;
  160. }
  161. `));
  162. document.head.appendChild(styleItem);
  163.  
  164. window.addEventListener('load', function() {
  165. var allianceButton = document.getElementById('allianceButton');
  166. var storeButton = document.getElementById('storeButton');
  167. if (storeButton) {
  168. storeButton.style.right = '26px';
  169. storeButton.style.top = '420px';
  170. }
  171. if (allianceButton) {
  172. allianceButton.style.right = '26px';
  173. allianceButton.style.top = '479px';
  174. }
  175. });
  176.  
  177. function getEl(id) {
  178. return document.getElementById(id);
  179. }
  180. var EasyStar = function(e) {
  181. var o = {};
  182. function r(t) {
  183. if (o[t]) return o[t].exports;
  184. var n = o[t] = {
  185. i: t,
  186. l: !1,
  187. exports: {}
  188. };
  189. return e[t].call(n.exports, n, n.exports, r), n.l = !0, n.exports
  190. }
  191. return r.m = e, r.c = o, r.d = function(t, n, e) {
  192. r.o(t, n) || Object.defineProperty(t, n, {
  193. enumerable: !0,
  194. get: e
  195. })
  196. }, r.r = function(t) {
  197. "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, {
  198. value: "Module"
  199. }), Object.defineProperty(t, "__esModule", {
  200. value: !0
  201. })
  202. }, r.t = function(n, t) {
  203. if (1 & t && (n = r(n)), 8 & t) return n;
  204. if (4 & t && "object" == typeof n && n && n.__esModule) return n;
  205. var e = Object.create(null);
  206. if (r.r(e), Object.defineProperty(e, "default", {
  207. enumerable: !0,
  208. value: n
  209. }), 2 & t && "string" != typeof n)
  210. for (var o in n) r.d(e, o, function(t) {
  211. return n[t]
  212. }.bind(null, o));
  213. return e
  214. }, r.n = function(t) {
  215. var n = t && t.__esModule ? function() {
  216. return t.default
  217. } : function() {
  218. return t
  219. };
  220. return r.d(n, "a", n), n
  221. }, r.o = function(t, n) {
  222. return Object.prototype.hasOwnProperty.call(t, n)
  223. }, r.p = "/bin/", r(r.s = 0)
  224. }([function(t, n, e) {
  225. var P = {},
  226. M = e(1),
  227. _ = e(2),
  228. A = e(3);
  229. t.exports = P;
  230. var E = 1;
  231. P.js = function() {
  232. var c, i, f, s = 1.4,
  233. p = !1,
  234. u = {},
  235. o = {},
  236. r = {},
  237. l = {},
  238. a = !0,
  239. h = {},
  240. d = [],
  241. y = Number.MAX_VALUE,
  242. v = !1;
  243. this.setAcceptableTiles = function(t) {
  244. t instanceof Array ? f = t : !isNaN(parseFloat(t)) && isFinite(t) && (f = [t])
  245. }, this.enableSync = function() {
  246. p = !0
  247. }, this.disableSync = function() {
  248. p = !1
  249. }, this.enableDiagonals = function() {
  250. v = !0
  251. }, this.disableDiagonals = function() {
  252. v = !1
  253. }, this.setGrid = function(t) {
  254. c = t;
  255. for (var n = 0; n < c.length; n++)
  256. for (var e = 0; e < c[0].length; e++) o[c[n][e]] || (o[c[n][e]] = 1)
  257. }, this.setTileCost = function(t, n) {
  258. o[t] = n
  259. }, this.setAdditionalPointCost = function(t, n, e) {
  260. void 0 === r[n] && (r[n] = {}), r[n][t] = e
  261. }, this.removeAdditionalPointCost = function(t, n) {
  262. void 0 !== r[n] && delete r[n][t]
  263. }, this.removeAllAdditionalPointCosts = function() {
  264. r = {}
  265. }, this.setDirectionalCondition = function(t, n, e) {
  266. void 0 === l[n] && (l[n] = {}), l[n][t] = e
  267. }, this.removeAllDirectionalConditions = function() {
  268. l = {}
  269. }, this.setIterationsPerCalculation = function(t) {
  270. y = t
  271. }, this.avoidAdditionalPoint = function(t, n) {
  272. void 0 === u[n] && (u[n] = {}), u[n][t] = 1
  273. }, this.stopAvoidingAdditionalPoint = function(t, n) {
  274. void 0 !== u[n] && delete u[n][t]
  275. }, this.enableCornerCutting = function() {
  276. a = !0
  277. }, this.disableCornerCutting = function() {
  278. a = !1
  279. }, this.stopAvoidingAllAdditionalPoints = function() {
  280. u = {}
  281. }, this.findPath = function(t, n, e, o, r) {
  282. function i(t) {
  283. p ? r(t) : setTimeout(function() {
  284. r(t)
  285. })
  286. }
  287. if (void 0 === f) throw new Error("You can't set a path without first calling setAcceptableTiles() on EasyStar.");
  288. if (void 0 === c) throw new Error("You can't set a path without first calling setGrid() on EasyStar.");
  289. if (t < 0 || n < 0 || e < 0 || o < 0 || t > c[0].length - 1 || n > c.length - 1 || e > c[0].length - 1 || o > c.length - 1) throw new Error("Your start or end point is outside the scope of your grid.");
  290. if (t !== e || n !== o) {
  291. for (var s = c[o][e], u = !1, l = 0; l < f.length; l++)
  292. if (s === f[l]) {
  293. u = !0;
  294. break
  295. } if (!1 !== u) {
  296. var a = new M;
  297. a.openList = new A(function(t, n) {
  298. return t.bestGuessDistance() - n.bestGuessDistance()
  299. }), a.isDoneCalculating = !1, a.nodeHash = {}, a.startX = t, a.startY = n, a.endX = e, a.endY = o, a.callback = i, a.openList.push(O(a, a.startX, a.startY, null, 1));
  300. o = E++;
  301. return h[o] = a, d.push(o), o
  302. }
  303. i(null)
  304. } else i([])
  305. }, this.cancelPath = function(t) {
  306. return t in h && (delete h[t], !0)
  307. }, this.calculate = function() {
  308. if (0 !== d.length && void 0 !== c && void 0 !== f)
  309. for (i = 0; i < y; i++) {
  310. if (0 === d.length) return;
  311. p && (i = 0);
  312. var t = d[0],
  313. n = h[t];
  314. if (void 0 !== n)
  315. if (0 !== n.openList.size()) {
  316. var e = n.openList.pop();
  317. if (n.endX !== e.x || n.endY !== e.y) (e.list = 0) < e.y && T(n, e, 0, -1, +b(e.x, e.y - 1)), e.x < c[0].length - 1 && T(n, e, 1, 0, +b(e.x + 1, e.y)), e.y < c.length - 1 && T(n, e, 0, 1, +b(e.x, e.y + 1)), 0 < e.x && T(n, e, -1, 0, +b(e.x - 1, e.y)), v && (0 < e.x && 0 < e.y && (a || g(c, f, e.x, e.y - 1, e) && g(c, f, e.x - 1, e.y, e)) && T(n, e, -1, -1, s * b(e.x - 1, e.y - 1)), e.x < c[0].length - 1 && e.y < c.length - 1 && (a || g(c, f, e.x, e.y + 1, e) && g(c, f, e.x + 1, e.y, e)) && T(n, e, 1, 1, s * b(e.x + 1, e.y + 1)), e.x < c[0].length - 1 && 0 < e.y && (a || g(c, f, e.x, e.y - 1, e) && g(c, f, e.x + 1, e.y, e)) && T(n, e, 1, -1, s * b(e.x + 1, e.y - 1)), 0 < e.x && e.y < c.length - 1 && (a || g(c, f, e.x, e.y + 1, e) && g(c, f, e.x - 1, e.y, e)) && T(n, e, -1, 1, s * b(e.x - 1, e.y + 1)));
  318. else {
  319. var o = [];
  320. o.push({
  321. x: e.x,
  322. y: e.y
  323. });
  324. for (var r = e.parent; null != r;) o.push({
  325. x: r.x,
  326. y: r.y
  327. }), r = r.parent;
  328. o.reverse(), n.callback(o), delete h[t], d.shift()
  329. }
  330. } else n.callback(null), delete h[t], d.shift();
  331. else d.shift()
  332. }
  333. };
  334. var T = function(t, n, e, o, r) {
  335. e = n.x + e, o = n.y + o;
  336. void 0 !== u[o] && void 0 !== u[o][e] || !g(c, f, e, o, n) || (void 0 === (o = O(t, e, o, n, r)).list ? (o.list = 1, t.openList.push(o)) : n.costSoFar + r < o.costSoFar && (o.costSoFar = n.costSoFar + r, o.parent = n, t.openList.updateItem(o)))
  337. },
  338. g = function(t, n, e, o, r) {
  339. var i = l[o] && l[o][e];
  340. if (i) {
  341. var s = x(r.x - e, r.y - o);
  342. if (! function() {
  343. for (var t = 0; t < i.length; t++)
  344. if (i[t] === s) return !0;
  345. return !1
  346. }()) return !1
  347. }
  348. for (var u = 0; u < n.length; u++)
  349. if (t[o][e] === n[u]) return !0;
  350. return !1
  351. },
  352. x = function(t, n) {
  353. if (0 === t && -1 === n) return P.TOP;
  354. if (1 === t && -1 === n) return P.TOP_RIGHT;
  355. if (1 === t && 0 === n) return P.RIGHT;
  356. if (1 === t && 1 === n) return P.BOTTOM_RIGHT;
  357. if (0 === t && 1 === n) return P.BOTTOM;
  358. if (-1 === t && 1 === n) return P.BOTTOM_LEFT;
  359. if (-1 === t && 0 === n) return P.LEFT;
  360. if (-1 === t && -1 === n) return P.TOP_LEFT;
  361. throw new Error("These differences are not valid: " + t + ", " + n)
  362. },
  363. b = function(t, n) {
  364. return r[n] && r[n][t] || o[c[n][t]]
  365. },
  366. O = function(t, n, e, o, r) {
  367. if (void 0 !== t.nodeHash[e]) {
  368. if (void 0 !== t.nodeHash[e][n]) return t.nodeHash[e][n]
  369. } else t.nodeHash[e] = {};
  370. var i = m(n, e, t.endX, t.endY),
  371. r = null !== o ? o.costSoFar + r : 0,
  372. i = new _(o, n, e, r, i);
  373. return t.nodeHash[e][n] = i
  374. },
  375. m = function(t, n, e, o) {
  376. var r, i;
  377. return v ? (r = Math.abs(t - e)) < (i = Math.abs(n - o)) ? s * r + i : s * i + r : (r = Math.abs(t - e)) + (i = Math.abs(n - o))
  378. }
  379. }, P.TOP = "TOP", P.TOP_RIGHT = "TOP_RIGHT", P.RIGHT = "RIGHT", P.BOTTOM_RIGHT = "BOTTOM_RIGHT", P.BOTTOM = "BOTTOM", P.BOTTOM_LEFT = "BOTTOM_LEFT", P.LEFT = "LEFT", P.TOP_LEFT = "TOP_LEFT"
  380. }, function(t, n) {
  381. t.exports = function() {
  382. this.pointsToAvoid = {}, this.startX, this.callback, this.startY, this.endX, this.endY, this.nodeHash = {}, this.openList
  383. }
  384. }, function(t, n) {
  385. t.exports = function(t, n, e, o, r) {
  386. this.parent = t, this.x = n, this.y = e, this.costSoFar = o, this.simpleDistanceToTarget = r, this.bestGuessDistance = function() {
  387. return this.costSoFar + this.simpleDistanceToTarget
  388. }
  389. }
  390. }, function(t, n, e) {
  391. t.exports = e(4)
  392. }, function(u, T, t) {
  393. var g, x;
  394. (function() {
  395. var t, p, l, h, d, n, a, e, y, v, o, r, i, c, f;
  396. function s(t) {
  397. this.cmp = null != t ? t : p, this.nodes = []
  398. }
  399. l = Math.floor, v = Math.min, p = function(t, n) {
  400. return t < n ? -1 : n < t ? 1 : 0
  401. }, y = function(t, n, e, o, r) {
  402. var i;
  403. if (null == e && (e = 0), null == r && (r = p), e < 0) throw new Error("lo must be non-negative");
  404. for (null == o && (o = t.length); e < o;) r(n, t[i = l((e + o) / 2)]) < 0 ? o = i : e = i + 1;
  405. return [].splice.apply(t, [e, e - e].concat(n)), n
  406. }, n = function(t, n, e) {
  407. return null == e && (e = p), t.push(n), c(t, 0, t.length - 1, e)
  408. }, d = function(t, n) {
  409. var e, o;
  410. return null == n && (n = p), e = t.pop(), t.length ? (o = t[0], t[0] = e, f(t, 0, n)) : o = e, o
  411. }, e = function(t, n, e) {
  412. var o;
  413. return null == e && (e = p), o = t[0], t[0] = n, f(t, 0, e), o
  414. }, a = function(t, n, e) {
  415. var o;
  416. return null == e && (e = p), t.length && e(t[0], n) < 0 && (n = (o = [t[0], n])[0], t[0] = o[1], f(t, 0, e)), n
  417. }, h = function(e, t) {
  418. var n, o, r, i, s, u;
  419. for (null == t && (t = p), s = [], o = 0, r = (i = function() {
  420. u = [];
  421. for (var t = 0, n = l(e.length / 2); 0 <= n ? t < n : n < t; 0 <= n ? t++ : t--) u.push(t);
  422. return u
  423. }.apply(this).reverse()).length; o < r; o++) n = i[o], s.push(f(e, n, t));
  424. return s
  425. }, i = function(t, n, e) {
  426. if (null == e && (e = p), -1 !== (n = t.indexOf(n))) return c(t, 0, n, e), f(t, n, e)
  427. }, o = function(t, n, e) {
  428. var o, r, i, s, u;
  429. if (null == e && (e = p), !(r = t.slice(0, n)).length) return r;
  430. for (h(r, e), i = 0, s = (u = t.slice(n)).length; i < s; i++) o = u[i], a(r, o, e);
  431. return r.sort(e).reverse()
  432. }, r = function(t, n, e) {
  433. var o, r, i, s, u, l, a, c, f;
  434. if (null == e && (e = p), 10 * n <= t.length) {
  435. if (!(i = t.slice(0, n).sort(e)).length) return i;
  436. for (r = i[i.length - 1], s = 0, l = (a = t.slice(n)).length; s < l; s++) e(o = a[s], r) < 0 && (y(i, o, 0, null, e), i.pop(), r = i[i.length - 1]);
  437. return i
  438. }
  439. for (h(t, e), f = [], u = 0, c = v(n, t.length); 0 <= c ? u < c : c < u; 0 <= c ? ++u : --u) f.push(d(t, e));
  440. return f
  441. }, c = function(t, n, e, o) {
  442. var r, i, s;
  443. for (null == o && (o = p), r = t[e]; n < e && o(r, i = t[s = e - 1 >> 1]) < 0;) t[e] = i, e = s;
  444. return t[e] = r
  445. }, f = function(t, n, e) {
  446. var o, r, i, s, u;
  447. for (null == e && (e = p), r = t.length, i = t[u = n], o = 2 * n + 1; o < r;)(s = o + 1) < r && !(e(t[o], t[s]) < 0) && (o = s), t[n] = t[o], o = 2 * (n = o) + 1;
  448. return t[n] = i, c(t, u, n, e)
  449. }, s.push = n, s.pop = d, s.replace = e, s.pushpop = a, s.heapify = h, s.updateItem = i, s.nlargest = o, s.nsmallest = r, s.prototype.push = function(t) {
  450. return n(this.nodes, t, this.cmp)
  451. }, s.prototype.pop = function() {
  452. return d(this.nodes, this.cmp)
  453. }, s.prototype.peek = function() {
  454. return this.nodes[0]
  455. }, s.prototype.contains = function(t) {
  456. return -1 !== this.nodes.indexOf(t)
  457. }, s.prototype.replace = function(t) {
  458. return e(this.nodes, t, this.cmp)
  459. }, s.prototype.pushpop = function(t) {
  460. return a(this.nodes, t, this.cmp)
  461. }, s.prototype.heapify = function() {
  462. return h(this.nodes, this.cmp)
  463. }, s.prototype.updateItem = function(t) {
  464. return i(this.nodes, t, this.cmp)
  465. }, s.prototype.clear = function() {
  466. return this.nodes = []
  467. }, s.prototype.empty = function() {
  468. return 0 === this.nodes.length
  469. }, s.prototype.size = function() {
  470. return this.nodes.length
  471. }, s.prototype.clone = function() {
  472. var t = new s;
  473. return t.nodes = this.nodes.slice(0), t
  474. }, s.prototype.toArray = function() {
  475. return this.nodes.slice(0)
  476. }, s.prototype.insert = s.prototype.push, s.prototype.top = s.prototype.peek, s.prototype.front = s.prototype.peek, s.prototype.has = s.prototype.contains, s.prototype.copy = s.prototype.clone, t = s, g = [], void 0 === (x = "function" == typeof (x = function() {
  477. return t
  478. }) ? x.apply(T, g) : x) || (u.exports = x)
  479. }).call(this)
  480. }]);
  481. let easystar = new EasyStar.js();
  482. !function(run) {
  483.  
  484. let newFont = document.createElement("link");
  485. newFont.rel = "stylesheet";
  486. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  487. newFont.type = "text/css";
  488. document.body.append(newFont);
  489.  
  490. let min = document.createElement("script");
  491. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  492. document.body.append(min);
  493. window.oncontextmenu = function() {
  494. return false;
  495. };
  496.  
  497. let config = window.config;
  498.  
  499. // CLIENT:
  500. config.clientSendRate = 9; // Aim Packet Send Rate
  501. config.serverUpdateRate = 9;
  502.  
  503. // UI:
  504. config.deathFadeout = 0;
  505.  
  506. config.playerCapacity = 9999;
  507.  
  508. // CHECK IN SANDBOX:
  509. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  510.  
  511. // CUSTOMIZATION:
  512. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  513. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  514. "#8bc373", "#91b2db"
  515. ];
  516. config.weaponVariants = [{
  517. id: 0,
  518. src: "",
  519. xp: 0,
  520. val: 1,
  521. }, {
  522. id: 1,
  523. src: "_g",
  524. xp: 3000,
  525. val: 1.1,
  526. }, {
  527. id: 2,
  528. src: "_d",
  529. xp: 7000,
  530. val: 1.18,
  531. }, {
  532. id: 3,
  533. src: "_r",
  534. poison: true,
  535. xp: 12000,
  536. val: 1.18,
  537. }, {
  538. id: 4,
  539. src: "_e",
  540. poison: true,
  541. heal: true,
  542. xp: 24000,
  543. val: 1.18,
  544. }];
  545.  
  546. // VISUAL:
  547. config.anotherVisual = true;
  548. config.useWebGl = false;
  549. config.resetRender = true;
  550.  
  551. function waitTime(timeout) {
  552. return new Promise((done) => {
  553. setTimeout(() => {
  554. done();
  555. }, timeout);
  556. });
  557. }
  558.  
  559. let botSkts = [];
  560.  
  561. // STORAGE:
  562. let canStore;
  563. if (typeof(Storage) !== "undefined") {
  564. canStore = true;
  565. }
  566.  
  567. function saveVal(name, val) {
  568. if (canStore)
  569. localStorage.setItem(name, val);
  570. }
  571.  
  572. function deleteVal(name) {
  573. if (canStore)
  574. localStorage.removeItem(name);
  575. }
  576.  
  577. function getSavedVal(name) {
  578. if (canStore)
  579. return localStorage.getItem(name);
  580. return null;
  581. }
  582.  
  583. // CONFIGS:
  584. let gC = function(a, b) {
  585. try {
  586. let res = JSON.parse(getSavedVal(a));
  587. if (typeof res === "object") {
  588. return b;
  589. } else {
  590. return res;
  591. }
  592. } catch (e) {
  593. alert("dieskid");
  594. return b;
  595. }
  596. };
  597.  
  598. function setCommands() {
  599. return {
  600. "help": {
  601. desc: "Show Commands",
  602. action: function(message) {
  603. for (let cmds in commands) {
  604. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  605. }
  606. }
  607. },
  608. "clear": {
  609. desc: "Clear Chats",
  610. action: function(message) {
  611. resetMenuChText();
  612. }
  613. },
  614. "debug": {
  615. desc: "Debug Mod For Development",
  616. action: function(message) {
  617. addDeadPlayer(player);
  618. addMenuChText("Debug", "Done", "#99ee99", 1);
  619. }
  620. },
  621. "play": {
  622. desc: "Play Music ( /play [link] )",
  623. action: function(message) {
  624. let link = message.split(" ");
  625. if (link[1]) {
  626. let audio = new Audio(link[1]);
  627. audio.play();
  628. } else {
  629. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  630. }
  631. }
  632. },
  633. "bye": {
  634. desc: "Leave Game",
  635. action: function(message) {
  636. window.leave();
  637. }
  638. },
  639. };
  640. }
  641.  
  642. function setConfigs() {
  643. return {
  644. killChat: true,
  645. alwaysRev: true,
  646. AutoUpgrade: false,
  647. autoBuy: true,
  648. autoBuyEquip: true,
  649. autoPush: true,
  650. revTick: true,
  651. spikeTick: true,
  652. predictTick: true,
  653. autoPlace: true,
  654. autoReplace: true,
  655. autoPrePlace: true,
  656. antiTrap: true,
  657. slowOT: false,
  658. attackDir: false,
  659. showDir: false,
  660. noDir: false,
  661. autoRespawn: false
  662. };
  663. };
  664. let commands = setCommands();
  665. let configs = setConfigs();
  666. window.removeConfigs = function() {
  667. for (let cF in configs) {
  668. deleteVal(cF, configs[cF]);
  669. }
  670. };
  671.  
  672. for (let cF in configs) {
  673. configs[cF] = gC(cF, configs[cF]);
  674. }
  675.  
  676. // MENU FUNCTIONS:
  677. window.changeMenu = function() {};
  678. window.debug = function() {};
  679. window.wasdMode = function() {};
  680.  
  681. // PAGE 1:
  682. window.startGrind = function() {};
  683.  
  684. // PAGE 3:
  685. window.connectFillBots = function() {};
  686. window.destroyFillBots = function() {};
  687. window.tryConnectBots = function() {};
  688. window.destroyBots = function() {};
  689. window.resBuild = function() {};
  690. window.toggleBotsCircle = function() {};
  691. window.toggleVisual = function() {};
  692.  
  693. // SOME FUNCTIONS:
  694. window.prepareUI = function() {};
  695. window.leave = function() {};
  696.  
  697. let hathuxinggai = true;
  698. let ping = 0;
  699. // nah hahahahahhh why good ping
  700. window.ping = hathuxinggai ? 86 : 0;
  701.  
  702. class deadfuturechickenmodrevival {
  703. constructor(flarez, lore) {
  704. this.inGame = false;
  705. this.lover = flarez + lore;
  706. this.baby = "ae86";
  707. this.isBlack = 0;
  708. this.webSocket = undefined;
  709. this.checkBaby = function() {
  710. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  711. if (this.isBlack >= 1) return "bl4cky";
  712. return "noting for you";
  713. };
  714. this.x2 = 0;
  715. this.y2 = 0;
  716. this.chat = "Imagine playing this badass game XDDDDD";
  717. this.summon = function(tmpObj) {
  718. this.x2 = tmpObj.x;
  719. this.y2 = tmpObj.y;
  720. this.chat = tmpObj.name + " ur so bad XDDDD";
  721. };
  722. this.commands = function(cmd) {
  723. cmd == "rv3link" && window.open("https://florr.io/");
  724. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  725. return cmd;
  726. };
  727. this.dayte = "11yearold";
  728. this.memeganoob = "69yearold";
  729. this.startDayteSpawn = function(tmpObj) {
  730. let ratio = setInterval(() => {
  731. this.x2 = tmpObj.x + 20;
  732. this.y2 = tmpObj.y - 20;
  733. this.chat = "UR SO BAD LOL";
  734. if (tmpObj.name == "ae86") {
  735. this.chat = "omg ae86 go run";
  736. setTimeout(() => {
  737. this.inGame = false;
  738. clearInterval(ratio);
  739. }, 1000);
  740. }
  741. }, 1234);
  742. };
  743. this.AntiChickenModV69420 = function(tmpObj) {
  744. return "!c!dc user " + tmpObj.name;
  745. };
  746. }
  747. };
  748. class HtmlAction {
  749. constructor(element) {
  750. this.element = element;
  751. };
  752. add(code) {
  753. if (!this.element) return undefined;
  754. this.element.innerHTML += code;
  755. };
  756. newLine(amount) {
  757. let result = `<br>`;
  758. if (amount > 0) {
  759. result = ``;
  760. for (let i = 0; i < amount; i++) {
  761. result += `<br>`;
  762. }
  763. }
  764. this.add(result);
  765. };
  766. checkBox(setting) {
  767. let newCheck = `<input type = "checkbox"`;
  768. setting.id && (newCheck += ` id = ${setting.id}`);
  769. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  770. setting.class && (newCheck += ` class = ${setting.class}`);
  771. setting.checked && (newCheck += ` checked`);
  772. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  773. newCheck += `>`;
  774. this.add(newCheck);
  775. };
  776. text(setting) {
  777. let newText = `<input type = "text"`;
  778. setting.id && (newText += ` id = ${setting.id}`);
  779. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  780. setting.class && (newText += ` class = ${setting.class}`);
  781. setting.size && (newText += ` size = ${setting.size}`);
  782. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  783. setting.value && (newText += ` value = ${setting.value}`);
  784. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  785. newText += `>`;
  786. this.add(newText);
  787. };
  788. select(setting) {
  789. let newSelect = `<select`;
  790. setting.id && (newSelect += ` id = ${setting.id}`);
  791. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  792. setting.class && (newSelect += ` class = ${setting.class}`);
  793. newSelect += `>`;
  794. for (let options in setting.option) {
  795. newSelect += `<option value = ${setting.option[options].id}`
  796. setting.option[options].selected && (newSelect += ` selected`);
  797. newSelect += `>${options}</option>`;
  798. }
  799. newSelect += `</select>`;
  800. this.add(newSelect);
  801. };
  802. button(setting) {
  803. let newButton = `<button`;
  804. setting.id && (newButton += ` id = ${setting.id}`);
  805. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  806. setting.class && (newButton += ` class = ${setting.class}`);
  807. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  808. newButton += `>`;
  809. setting.innerHTML && (newButton += setting.innerHTML);
  810. newButton += `</button>`;
  811. this.add(newButton);
  812. };
  813. selectMenu(setting) {
  814. let newSelect = `<select`;
  815. if (!setting.id) {
  816. alert("please put id skid");
  817. return;
  818. }
  819. window[setting.id + "Func"] = function() {};
  820. setting.id && (newSelect += ` id = ${setting.id}`);
  821. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  822. setting.class && (newSelect += ` class = ${setting.class}`);
  823. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  824. newSelect += `>`;
  825. let last;
  826. let i = 0;
  827. for (let options in setting.menu) {
  828. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  829. setting.menu[options] && (newSelect += ` checked`);
  830. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  831. i++;
  832. }
  833. newSelect += `</select>`;
  834.  
  835. this.add(newSelect);
  836.  
  837. i = 0;
  838. for (let options in setting.menu) {
  839. window[options + "Func"] = function() {
  840. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  841. saveVal(options, setting.menu[options]);
  842.  
  843. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  844. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  845.  
  846. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  847.  
  848. };
  849. this.checkBox({
  850. id: "check_" + options,
  851. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  852. class: "checkB",
  853. onclick: `window.${options + "Func"}()`,
  854. checked: setting.menu[options]
  855. });
  856. i++;
  857. }
  858.  
  859. last = "check_" + getEl(setting.id).value.split("_")[1];
  860. window[setting.id + "Func"] = function() {
  861. getEl(last).style.display = "none";
  862. last = "check_" + getEl(setting.id).value.split("_")[1];
  863. getEl(last).style.display = "inline-block";
  864.  
  865. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  866.  
  867. };
  868. };
  869. };
  870. class Html {
  871. constructor() {
  872. this.element = null;
  873. this.action = null;
  874. this.divElement = null;
  875. this.startDiv = function(setting, func) {
  876.  
  877. let newDiv = document.createElement("div");
  878. setting.id && (newDiv.id = setting.id);
  879. setting.style && (newDiv.style = setting.style);
  880. setting.class && (newDiv.className = setting.class);
  881. this.element.appendChild(newDiv);
  882. this.divElement = newDiv;
  883.  
  884. let addRes = new HtmlAction(newDiv);
  885. typeof func == "function" && func(addRes);
  886.  
  887. };
  888. this.addDiv = function(setting, func) {
  889.  
  890. let newDiv = document.createElement("div");
  891. setting.id && (newDiv.id = setting.id);
  892. setting.style && (newDiv.style = setting.style);
  893. setting.class && (newDiv.className = setting.class);
  894. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  895. this.divElement = newDiv;
  896.  
  897. let addRes = new HtmlAction(newDiv);
  898. typeof func == "function" && func(addRes);
  899.  
  900. };
  901. };
  902. set(id) {
  903. this.element = getEl(id);
  904. this.action = new HtmlAction(this.element);
  905. };
  906. resetHTML(text) {
  907. if (text) {
  908. this.element.innerHTML = ``;
  909. } else {
  910. this.element.innerHTML = ``;
  911. }
  912. };
  913. setStyle(style) {
  914. this.element.style = style;
  915. };
  916. setCSS(style) {
  917. this.action.add(`<style>` + style + `</style>`);
  918. };
  919. };
  920.  
  921. let HTML = new Html();
  922.  
  923. let menuDiv = document.createElement("div");
  924. menuDiv.id = "menuDiv";
  925. document.body.appendChild(menuDiv);
  926. HTML.set("menuDiv");
  927. HTML.setStyle(`
  928. position: absolute;
  929. left: 20px;
  930. top: 20px;
  931. `);
  932. HTML.resetHTML();
  933. HTML.setCSS(`
  934. .menuClass {
  935. color: #fff;
  936. background-image: url('');
  937. background-size: cover;
  938. background-position: center;
  939. background-repeat: no-repeat;
  940. font-size: 28px;
  941. text-align: center;
  942. padding: 20px;
  943. max-height: 200px;
  944. width: 300px;
  945. background-color: #1f1f1f;
  946. border-radius: 15px;
  947. box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  948. transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out, box-shadow 0.3s ease-in-out, filter 0.4s ease-in-out, border-color 0.3s ease-in-out;
  949. overflow: auto;
  950. filter: none;
  951. border: 2px solid transparent; /* Add a border */
  952. }
  953. .menuClass:hover {
  954. border-color: rgb(255,255,255); /* Change border color on hover to RGB red */
  955. }
  956. .menuClass:hover .menuContent {
  957. background-color: #000; /* Change background color of menu content to darker black on hover */
  958. }
  959. .menuContent {
  960. color: #fff;
  961. }
  962. .menuC {
  963. display: none;
  964. font-family: "Hammersmith One", sans-serif;
  965. font-size: 14px;
  966. max-height: 200px;
  967. overflow-y: auto;
  968. }
  969. .menuB {
  970. text-align: center;
  971. background-color: #1f1f1f;
  972. color: #fff;
  973. border-radius: 25px;
  974. border: 2px solid transparent;
  975. cursor: pointer;
  976. overflow-y: auto;
  977. transition: border-color 0.3s ease-in-out;
  978. }
  979. .menuB:hover {
  980. border-color: #fff;
  981. }
  982. .menuB:active {
  983. color: #fff;
  984. background-color: #1f1f1f;
  985. }
  986. .customText {
  987. color: #000;
  988. border-radius: 25px;
  989. border: 2px solid #000;
  990. padding: 5px;
  991. transition: background-color 1s ease-in-out;
  992. }
  993. .customText:focus {
  994. background-color: #999;
  995. }
  996. .checkB {
  997. position: relative;
  998. top: 2px;
  999. accent-color: #888;
  1000. cursor: pointer;
  1001. }
  1002. .Cselect {
  1003. border-radius: 25px;
  1004. background-color: #1f1f1f;
  1005. color: #fff;
  1006. border: 1px solid #000;
  1007. }
  1008. #menuChanger {
  1009. position: absolute;
  1010. right: 20px;
  1011. top: 20px;
  1012. background-color: rgba(0, 0, 0, 0);
  1013. color: #fff;
  1014. border: none;
  1015. cursor: pointer;
  1016. transition: color 0.3s ease-in-out;
  1017. }
  1018. #menuChanger:hover {
  1019. color: #000;
  1020. }
  1021.  
  1022. ::-webkit-scrollbar {
  1023. width: 0; /* Skryje vertikální scrollbar na WebKit prohlížečích */
  1024. }
  1025. `);
  1026.  
  1027. HTML.startDiv({
  1028. id: "menuHeadLine",
  1029. class: "menuClass"
  1030. }, (html) => {
  1031. html.add(`IADO Mod Menu`);
  1032. html.button({
  1033. id: "menuChanger",
  1034. class: "material-icons",
  1035. innerHTML: `sync`,
  1036. onclick: "window.changeMenu()"
  1037. });
  1038. HTML.addDiv({
  1039. id: "menuButtons",
  1040. style: "display: block; overflow-y: visible;",
  1041. class: "menuC",
  1042. appendID: "menuHeadLine"
  1043. }, (html) => {
  1044. html.button({
  1045. class: "menuB",
  1046. innerHTML: "Debug (Maybe works)",
  1047. onclick: "window.debug()"
  1048. });
  1049. });
  1050. HTML.addDiv({
  1051. id: "menuMain",
  1052. style: "display: block",
  1053. class: "menuC",
  1054. appendID: "menuHeadLine"
  1055. }, (html) => {
  1056. html.button({
  1057. class: "menuB",
  1058. innerHTML: "Useless Button",
  1059. onclick: "window.wasdMode()"
  1060. });
  1061. html.newLine();
  1062. html.add(`Ruby Grind:`);
  1063. html.checkBox({
  1064. id: "weaponGrind",
  1065. class: "checkB",
  1066. onclick: "window.startGrind()"
  1067. });
  1068. html.newLine();
  1069. HTML.addDiv({
  1070. style: "font-size: 20px; color: #99ee99;",
  1071. appendID: "menuMain"
  1072. }, (html) => {
  1073. html.add(`Settings:`);
  1074. });
  1075. html.add(`Push v4:`);
  1076. html.checkBox({
  1077. id: "antipush",
  1078. class: "checkB",
  1079. checked: true
  1080. });
  1081. html.newLine();
  1082. html.add(`Anti heal:`);
  1083. html.checkBox({
  1084. id: "healingBeta",
  1085. class: "checkB",
  1086. checked: true
  1087. });
  1088. html.newLine();
  1089. });
  1090. HTML.addDiv({
  1091. id: "menuConfig",
  1092. class: "menuC",
  1093. appendID: "menuHeadLine"
  1094. }, (html) => {
  1095. html.add(`Placement Tick: `);
  1096. html.text({
  1097. id: "autoPlaceTick",
  1098. class: "customText",
  1099. value: "1",
  1100. size: "2em",
  1101. maxLength: "1"
  1102. });
  1103. html.newLine();
  1104. html.add(`AutoChat `);
  1105. html.checkBox({
  1106. id: "autochat",
  1107. class: "checkB",
  1108. checked: true
  1109. });
  1110. html.newLine();
  1111. html.add(`Options: `);
  1112. html.selectMenu({
  1113. id: "configsChanger",
  1114. class: "Cselect",
  1115. menu: configs
  1116. });
  1117. html.newLine();
  1118. html.add(`AntiBull: `);
  1119. html.select({
  1120. id: "antiBullType",
  1121. class: "Cselect",
  1122. option: {
  1123. "Disable": {
  1124. id: "noab",
  1125. selected: true,
  1126. },
  1127. "When Reloaded": {
  1128. id: "abreload",
  1129. },
  1130. "Always": {
  1131. id: "abalway",
  1132. }
  1133. }
  1134. });
  1135. });
  1136. HTML.addDiv({
  1137. id: "menuOther",
  1138. class: "menuC",
  1139. appendID: "menuHeadLine"
  1140. }, (html) => {
  1141. html.button({
  1142. class: "menuB",
  1143. innerHTML: "Connect Bots",
  1144. onclick: "window.tryConnectBots()"
  1145. });
  1146. html.button({
  1147. class: "menuB",
  1148. innerHTML: "Disconnect Bots",
  1149. onclick: "window.destroyBots()"
  1150. });
  1151. html.newLine();
  1152. html.add(`Break Objects Range: `);
  1153. html.text({
  1154. id: "breakRange",
  1155. class: "customText",
  1156. value: "700",
  1157. size: "3em",
  1158. maxLength: "4"
  1159. });
  1160. html.newLine();
  1161. html.add(`Render Movement: `);
  1162. html.select({
  1163. id: "predictType",
  1164. class: "Cselect",
  1165. option: {
  1166. "Disable Render": {
  1167. id: "disableRender",
  1168. selected: true
  1169. },
  1170. "X/Y and 2": {
  1171. id: "pre2",
  1172. },
  1173. "X/Y and 3": {
  1174. id: "pre3"
  1175. }
  1176. }
  1177. });
  1178. html.newLine();
  1179. html.add(`Render Placers: `);
  1180. html.checkBox({
  1181. id: "placeVis",
  1182. class: "checkB",
  1183. });
  1184. html.newLine();
  1185. html.add(`Safe AntiSpikeTick: `);
  1186. html.checkBox({ id: "safeAntiSpikeTick", class: "checkB", checked: true });
  1187. html.newLine();
  1188. html.add(`BackupNoBull: `);
  1189. html.checkBox({ id: "backupNobull", class: "checkB", checked: false });
  1190. });
  1191. });
  1192. function toFancyTimeFormat(time) {
  1193. let minutes = ~~((time % 3600) / 60);
  1194. let seconds = ~~time % 60;
  1195. if (seconds <= 9) seconds = `0${seconds}`;
  1196. return `${minutes}:${seconds}`;
  1197. }
  1198.  
  1199. let menuChatDiv = document.createElement("div");
  1200. menuChatDiv.id = "menuChatDiv";
  1201. document.body.appendChild(menuChatDiv);
  1202. HTML.set("menuChatDiv");
  1203. HTML.setStyle(`
  1204. position: absolute;
  1205. display: none;
  1206. left: 0px;
  1207. top: 25px;
  1208. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  1209. `);
  1210. HTML.resetHTML();
  1211. HTML.setCSS(`
  1212. .chDiv {
  1213. color: #fff;
  1214. padding: 10px;
  1215. width: 357px;
  1216. height: 217px;
  1217. background-color: rgba(0, 0, 0, 0.2);
  1218. font-family: "HammerSmith One", monospace;
  1219. // border-radius: 15px;
  1220. // box-shadow: black 1px 2px 19px;
  1221. //backdrop-filter: blur(3px);
  1222.  
  1223. }
  1224. .chMainDiv {
  1225. font-family: "Ubuntu";
  1226. font-size: 16px;
  1227. max-height: 215px;
  1228. overflow-y: scroll;
  1229. scrollbar-width: thin;
  1230. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  1231. -webkit-touch-callout: none;
  1232. -webkit-user-select: none;
  1233. -khtml-user-select: none;
  1234. -moz-user-select: none;
  1235. -ms-user-select: none;
  1236. user-select: none;
  1237. overflow-x: hidden;
  1238. }
  1239. .chMainDiv::-webkit-scrollbar {
  1240. width: 8px;
  1241. }
  1242. .chMainDiv::-webkit-scrollbar-thumb {
  1243. background-color: rgba(0, 0, 0, 0.5);
  1244. }
  1245. .chMainDiv::-webkit-scrollbar-thumb:hover {
  1246. background-color: rgba(0, 0, 0, 0.7);
  1247. }
  1248. .chMainBox {
  1249. display:none;
  1250. position: absolute;
  1251. left: 10px;
  1252. bottom: 10px;
  1253. width: 380px;
  1254. height: 25px;
  1255. background-color: rgba(255, 255, 255, 0.1);
  1256. border-radius: 5px;
  1257. color: rgba(255, 255, 255, 0.75);
  1258. font-family: "HammerSmith One";
  1259. font-size: 12px;
  1260. }
  1261. `);
  1262. HTML.startDiv({
  1263. id: "mChDiv",
  1264. class: "chDiv"
  1265. }, (html) => {
  1266. HTML.addDiv({
  1267. id: "mChMain",
  1268. class: "chMainDiv",
  1269. appendID: "mChDiv"
  1270. }, (html) => {});
  1271. html.text({
  1272. id: "mChBox",
  1273. class: "chMainBox",
  1274. // placeHolder: `To chat click here or press "Enter" key`
  1275. });
  1276. });
  1277.  
  1278. let menuChats = getEl("mChMain");
  1279. let menuChatBox = getEl("mChBox");
  1280. let menuCBFocus = false;
  1281. let menuChCounts = 0;
  1282.  
  1283. menuChatBox.value = "";
  1284. menuChatBox.addEventListener("focus", () => {
  1285. menuCBFocus = true;
  1286. });
  1287. menuChatBox.addEventListener("blur", () => {
  1288. menuCBFocus = false;
  1289. });
  1290.  
  1291. function addMenuChText(name, message, color, noTimer) {
  1292. HTML.set("menuChatDiv");
  1293. color = color || "white";
  1294. let time = new Date();
  1295. let min = time.getMinutes();
  1296. let hour = time.getHours();
  1297. let text = ``;
  1298. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1299. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1300. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1301. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1302. html.add(text);
  1303. });
  1304. menuChats.scrollTop = menuChats.scrollHeight;
  1305. menuChCounts++;
  1306. }
  1307. function chch(name, message, color, noTimer) {
  1308. HTML.set("menuChatDiv");
  1309. color = color || "white";
  1310. let time = new Date();
  1311. let text = ``;
  1312. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1313. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1314. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1315. html.add(text);
  1316. });
  1317. menuChats.scrollTop = menuChats.scrollHeight;
  1318. menuChCounts++;
  1319. }
  1320.  
  1321. function resetMenuChText() {
  1322. menuChats.innerHTML = ``;
  1323. menuChCounts = 0;
  1324. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  1325. }
  1326. resetMenuChText();
  1327.  
  1328. let menuIndex = 0;
  1329. let menus = ["menuMain", "menuConfig", "menuOther"];
  1330. window.changeMenu = function() {
  1331. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1332. menuIndex++;
  1333. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1334. };
  1335.  
  1336. let mStatus = document.createElement("div");
  1337. mStatus.id = "status";
  1338. getEl("gameUI").appendChild(mStatus);
  1339. HTML.set("status");
  1340. HTML.setStyle(`
  1341. display: block;
  1342. position: absolute;
  1343. color: #ddd;
  1344. font: 15px HammerSmith One;
  1345. bottom: 215px;
  1346. left: 20px;
  1347. `);
  1348. HTML.resetHTML();
  1349. HTML.setCSS(`
  1350. .sizing {
  1351. font-size: 15px;
  1352. }
  1353. .mod {
  1354. font-size: 15px;
  1355. display: inline-block;
  1356. }
  1357. `);
  1358. HTML.startDiv({
  1359. id: "uehmod",
  1360. class: "sizing"
  1361. }, (html) => {
  1362. html.add(`Ping: `);
  1363. HTML.addDiv({
  1364. id: "pingFps",
  1365. class: "mod",
  1366. appendID: "uehmod"
  1367. }, (html) => {
  1368. html.add("None");
  1369. });
  1370. html.newLine();
  1371. html.add(`Packet: `);
  1372. HTML.addDiv({
  1373. id: "packetStatus",
  1374. class: "mod",
  1375. appendID: "uehmod"
  1376. }, (html) => {
  1377. html.add("None");
  1378. });
  1379. });
  1380.  
  1381. /*function modLog() {
  1382. let logs = [];
  1383. for (let i = 0; i < arguments.length; i++) {
  1384. logs.push(arguments[i]);
  1385. }
  1386. getEl("modLog").innerHTML = logs;
  1387. }*/
  1388.  
  1389. let openMenu = false;
  1390. let log = console.log;
  1391. let WS = undefined;
  1392. let socketID = undefined;
  1393.  
  1394. let useWasd = false;
  1395. let secPacket = 0;
  1396. let secMax = 110;
  1397. let secTime = 1000;
  1398. let firstSend = {
  1399. sec: false
  1400. };
  1401. let game = {
  1402. tick: 0,
  1403. tickQueue: [],
  1404. tickBase: function(set, tick) {
  1405. if (this.tickQueue[this.tick + tick]) {
  1406. this.tickQueue[this.tick + tick].push(set);
  1407. } else {
  1408. this.tickQueue[this.tick + tick] = [set];
  1409. }
  1410. },
  1411. tickRate: (1000 / config.serverUpdateRate),
  1412. tickSpeed: 0,
  1413. lastTick: performance.now()
  1414. };
  1415. let modConsole = [];
  1416.  
  1417. let dontSend = false;
  1418. let fpsTimer = {
  1419. last: 0,
  1420. time: 0,
  1421. ltime: 0
  1422. }
  1423. let lastMoveDir = undefined;
  1424. let lastsp = ["cc", 1, "__proto__"];
  1425.  
  1426. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1427. WebSocket.prototype.send = function(message) {
  1428. if (!WS) {
  1429. WS = this;
  1430. WS.addEventListener("message", function(msg) {
  1431. getMessage(msg);
  1432. });
  1433. WS.addEventListener("close", (event) => {
  1434. if (event.code == 4001) {
  1435. window.location.reload();
  1436. }
  1437. });
  1438. }
  1439. if (WS == this) {
  1440. dontSend = false;
  1441.  
  1442. // EXTRACT DATA ARRAY:
  1443. let data = new Uint8Array(message);
  1444. let parsed = window.msgpack.decode(data);
  1445. let type = parsed[0];
  1446. data = parsed[1];
  1447.  
  1448. // SEND MESSAGE:
  1449. if (type == "6") {
  1450.  
  1451. if (data[0]) {
  1452. // ANTI PROFANITY:
  1453. let profanity = ["cunt", "whore", "fuck", "shit", "faggot", "nigger", "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex", "tits", "penis", "clit", "pussy", "meatcurtain", "jizz", "prune", "douche", "wanker", "damn", "bitch", "dick", "fag", "bastard", ];
  1454. let tmpString;
  1455. profanity.forEach((profany) => {
  1456. if (data[0].indexOf(profany) > -1) {
  1457. tmpString = "";
  1458. for (let i = 0; i < profany.length; ++i) {
  1459. if (i == 1) {
  1460. tmpString += String.fromCharCode(0);
  1461. }
  1462. tmpString += profany[i];
  1463. }
  1464. let re = new RegExp(profany, "g");
  1465. data[0] = data[0].replace(re, tmpString);
  1466. }
  1467. });
  1468.  
  1469. // FIX CHAT:
  1470. data[0] = data[0].slice(0, 30);
  1471. }
  1472.  
  1473. } else if (type == "L") {
  1474. // MAKE SAME CLAN:
  1475. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1476. data[0] = data[0].slice(0, 7);
  1477. } else if (type == "M") {
  1478. // APPLY CYAN COLOR:
  1479. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1480. data[0].moofoll = true;
  1481. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1482. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1483. } else if (type == "D") {
  1484. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1485. dontSend = true;
  1486. } else {
  1487. my.lastDir = data[0];
  1488. }
  1489. } else if (type == "F") {
  1490. if (!data[2]) {
  1491. dontSend = true;
  1492. } else {
  1493. if (![null, undefined].includes(data[1])) {
  1494. my.lastDir = data[1];
  1495. }
  1496. }
  1497. } else if (type == "K") {
  1498. if (!data[1]) {
  1499. dontSend = true;
  1500. }
  1501. } else if (type == "S") {
  1502. instaC.wait = !instaC.wait;
  1503. dontSend = true;
  1504. } else if (type == "f") {
  1505. if (data[1]) {
  1506. if (player.moveDir == data[0]) {
  1507. dontSend = true;
  1508. }
  1509. player.moveDir = data[0];
  1510. } else {
  1511. dontSend = true;
  1512. }
  1513. }
  1514. if (!dontSend) {
  1515. let binary = window.msgpack.encode([type, data]);
  1516. this.nsend(binary);
  1517.  
  1518. // START COUNT:
  1519. if (!firstSend.sec) {
  1520. firstSend.sec = true;
  1521. setTimeout(() => {
  1522. firstSend.sec = false;
  1523. secPacket = 0;
  1524. }, secTime);
  1525. }
  1526.  
  1527. secPacket++;
  1528. }
  1529. } else {
  1530. this.nsend(message);
  1531. }
  1532. }
  1533.  
  1534. function packet(type) {
  1535. if (secPacket < 80) {
  1536. // EXTRACT DATA ARRAY:
  1537. let data = Array.prototype.slice.call(arguments, 1);
  1538. // SEND MESSAGE:
  1539. let binary = window.msgpack.encode([type, data]);
  1540. WS.send(binary);
  1541. }
  1542. }
  1543. function origPacket(type) {
  1544. // EXTRACT DATA ARRAY:
  1545. let data = Array.prototype.slice.call(arguments, 1);
  1546. // SEND MESSAGE:
  1547. let binary = window.msgpack.encode([type, data]);
  1548. WS.nsend(binary);
  1549. }
  1550. window.leave = function() {
  1551. origPacket("kys", {
  1552. "frvr is so bad": true,
  1553. "sidney is too good": true,
  1554. "dev are too weak": true,
  1555. });
  1556. };
  1557. //...lol
  1558. let io = {
  1559. send: packet
  1560. };
  1561. function getMessage(message) {
  1562. let data = new Uint8Array(message.data);
  1563. let parsed = window.msgpack.decode(data);
  1564. let type = parsed[0];
  1565. data = parsed[1];
  1566. let events = {
  1567. A: setInitData,
  1568. //B: disconnect,
  1569. C: setupGame,
  1570. D: addPlayer,
  1571. E: removePlayer,
  1572. a: updatePlayers,
  1573. G: updateLeaderboard,
  1574. H: loadGameObject,
  1575. I: loadAI,
  1576. J: animateAI,
  1577. K: gatherAnimation,
  1578. L: wiggleGameObject,
  1579. M: shootTurret,
  1580. N: updatePlayerValue,
  1581. O: updateHealth,
  1582. P: killPlayer,
  1583. Q: killObject,
  1584. R: killObjects,
  1585. S: updateItemCounts,
  1586. T: updateAge,
  1587. U: updateUpgrades,
  1588. V: updateItems,
  1589. X: addProjectile,
  1590. Y: remProjectile,
  1591.  
  1592. 2: allianceNotification,
  1593. 3: setPlayerTeam,
  1594. 4: setAlliancePlayers,
  1595. 5: updateStoreItems,
  1596. 6: receiveChat,
  1597. 7: updateMinimap,
  1598. 8: showText,
  1599. 9: pingMap,
  1600. };
  1601. if (type == "io-init") {
  1602. socketID = data[0];
  1603. } else {
  1604. if (events[type]) {
  1605. events[type].apply(undefined, data);
  1606. }
  1607. }
  1608. }
  1609. // MATHS:
  1610. Math.lerpAngle = function(value1, value2, amount) {
  1611. let difference = Math.abs(value2 - value1);
  1612. if (difference > Math.PI) {
  1613. if (value1 > value2) {
  1614. value2 += Math.PI * 2;
  1615. } else {
  1616. value1 += Math.PI * 2;
  1617. }
  1618. }
  1619. let value = value2 + ((value1 - value2) * amount);
  1620. if (value >= 0 && value <= Math.PI * 2) return value;
  1621. return value % (Math.PI * 2);
  1622. };
  1623.  
  1624. // REOUNDED RECTANGLE:
  1625. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1626. if (w < 2 * r) r = w / 2;
  1627. if (h < 2 * r) r = h / 2;
  1628. if (r < 0)
  1629. r = 0;
  1630. this.beginPath();
  1631. this.moveTo(x + r, y);
  1632. this.arcTo(x + w, y, x + w, y + h, r);
  1633. this.arcTo(x + w, y + h, x, y + h, r);
  1634. this.arcTo(x, y + h, x, y, r);
  1635. this.arcTo(x, y, x + w, y, r);
  1636. this.closePath();
  1637. return this;
  1638. };
  1639.  
  1640. // GLOBAL VALUES:
  1641. function resetMoveDir() {
  1642. keys = {};
  1643. io.send("e");
  1644. }
  1645.  
  1646. let allChats = [];
  1647. let ticks = {
  1648. tick: 0,
  1649. delay: 0,
  1650. time: [],
  1651. manage: [],
  1652. };
  1653. let ais = [];
  1654. let players = [];
  1655. let alliances = [];
  1656. let alliancePlayers = [];
  1657. let allianceNotifications = [];
  1658. let gameObjects = [];
  1659. let liztobj = [];
  1660. let projectiles = [];
  1661. let deadPlayers = [];
  1662.  
  1663. let breakObjects = [];
  1664.  
  1665. let player;
  1666. let playerSID;
  1667. let tmpObj;
  1668.  
  1669. let enemy = [];
  1670. let nears = [];
  1671. let near = [];
  1672.  
  1673. let my = {
  1674. reloaded: false,
  1675. waitHit: 0,
  1676. autoAim: false,
  1677. revAim: false,
  1678. ageInsta: true,
  1679. reSync: false,
  1680. bullTick: 0,
  1681. anti0Tick: 0,
  1682. antiSync: false,
  1683. age1insta: false,
  1684. safePrimary: function(tmpObj) {
  1685. return [0, 8].includes(tmpObj.primaryIndex);
  1686. },
  1687. safeSecondary: function(tmpObj) {
  1688. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1689. },
  1690. lastDir: 0,
  1691. autoPush: false,
  1692. pushData: {}
  1693. }
  1694.  
  1695. // FIND OBJECTS BY ID/SID:
  1696. function findID(tmpObj, tmp) {
  1697. return tmpObj.find((THIS) => THIS.id == tmp);
  1698. }
  1699.  
  1700. function findSID(tmpObj, tmp) {
  1701. return tmpObj.find((THIS) => THIS.sid == tmp);
  1702. }
  1703.  
  1704. function findPlayerByID(id) {
  1705. return findID(players, id);
  1706. }
  1707.  
  1708. function findPlayerBySID(sid) {
  1709. return findSID(players, sid);
  1710. }
  1711.  
  1712. function findAIBySID(sid) {
  1713. return findSID(ais, sid);
  1714. }
  1715.  
  1716. function findObjectBySid(sid) {
  1717. return findSID(gameObjects, sid);
  1718. }
  1719.  
  1720. function findProjectileBySid(sid) {
  1721. return findSID(gameObjects, sid);
  1722. }
  1723.  
  1724. let gameName = getEl("gameName");
  1725. gameName.innerText = "Chimken-Mod!";
  1726. let adCard = getEl("adCard");
  1727. adCard.remove();
  1728. let promoImageHolder = getEl("promoImgHolder");
  1729. promoImageHolder.remove();
  1730.  
  1731. let chatButton = getEl("chatButton");
  1732. chatButton.remove();
  1733. let autochat = getEl("autochat");
  1734. let profanityList = ["cunt", "whore", "fuck", "shit", "faggot", "nigger",
  1735. "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex",
  1736. "tits", "penis", "clit", "pussy", "meatcurtain", "jizz", "prune",
  1737. "douche", "wanker", "damn", "bitch", "dick", "fag", "bastard"];
  1738. let gameCanvas = getEl("gameCanvas");
  1739. let mainContext = gameCanvas.getContext("2d");
  1740. let mapDisplay = getEl("mapDisplay");
  1741. let mapContext = mapDisplay.getContext("2d");
  1742. mapDisplay.width = 300;
  1743. mapDisplay.height = 300;
  1744. let storeMenu = getEl("storeMenu");
  1745. let storeHolder = getEl("storeHolder");
  1746. let upgradeHolder = getEl("upgradeHolder");
  1747. let upgradeCounter = getEl("upgradeCounter");
  1748. let chatBox = getEl("chatBox");
  1749. chatBox.autocomplete = "off";
  1750. chatBox.style.textAlign = "center";
  1751. chatBox.style.width = "18em";
  1752. let chatHolder = getEl("chatHolder");
  1753. let actionBar = getEl("actionBar");
  1754. let leaderboardData = getEl("leaderboardData");
  1755. let itemInfoHolder = getEl("itemInfoHolder");
  1756. let menuCardHolder = getEl("menuCardHolder");
  1757. let mainMenu = getEl("mainMenu");
  1758. getEl("mainMenu").style.backgroundImage = "url('https://wallpaperaccess.com/full/8733703.jpg')"
  1759. let diedText = getEl("diedText");
  1760. let screenWidth;
  1761. let screenHeight;
  1762. let maxScreenWidth = config.maxScreenWidth;
  1763. let maxScreenHeight = config.maxScreenHeight;
  1764. function zoomVision() {
  1765. if (maxScreenWidth != config.maxScreenWidth * 1.5 || maxScreenHeight != config.maxScreenHeight * 1.5) {
  1766. maxScreenWidth = config.maxScreenWidth * 1.5;
  1767. maxScreenHeight = config.maxScreenHeight * 1.5;
  1768. resize();
  1769. }
  1770. }
  1771. let pixelDensity = 1;
  1772. let delta;
  1773. let now;
  1774. let lastUpdate = performance.now();
  1775. let camX;
  1776. let camY;
  1777. let tmpDir;
  1778. let mouseX = 0;
  1779. let mouseY = 0;
  1780. let allianceMenu = getEl("allianceMenu");
  1781. let waterMult = 1;
  1782. let waterPlus = 0;
  1783.  
  1784. let outlineColor = "#525252";
  1785. let darkOutlineColor = "#3d3f42";
  1786. let outlineWidth = 5.5;
  1787.  
  1788. let firstSetup = true;
  1789. let keys = {};
  1790. let moveKeys = {
  1791. 87: [0, -1],
  1792. 38: [0, -1],
  1793. 83: [0, 1],
  1794. 40: [0, 1],
  1795. 65: [-1, 0],
  1796. 37: [-1, 0],
  1797. 68: [1, 0],
  1798. 39: [1, 0],
  1799. };
  1800. let attackState = 0;
  1801. let inGame = false;
  1802.  
  1803. let macro = {};
  1804. let mills = {
  1805. place: 0,
  1806. placeSpawnPads: 0
  1807. };
  1808. let lastDir;
  1809.  
  1810. let lastLeaderboardData = [];
  1811.  
  1812. // ON LOAD:
  1813. let inWindow = true;
  1814. window.onblur = function() {
  1815. inWindow = false;
  1816. };
  1817. window.onfocus = function() {
  1818. inWindow = true;
  1819. if (player && player.alive) {
  1820. // resetMoveDir();
  1821. }
  1822. };
  1823. let ms = {
  1824. avg: 0,
  1825. max: 0,
  1826. min: 0,
  1827. delay: 0
  1828. }
  1829. function pingSocketResponse() {
  1830. let pingTime = window.pingTime;
  1831. const pingDisplay = document.getElementById("pingDisplay")
  1832. pingDisplay.innerText = "Ping: " + pingTime + " ms`";
  1833. if (pingTime > ms.max || isNaN(ms.max)) {
  1834. ms.max = pingTime;
  1835. }
  1836. if (pingTime < ms.min || isNaN(ms.min)) {
  1837. ms.min = pingTime;
  1838. }
  1839.  
  1840. // if (pingTime >= 90) {
  1841. // doAutoQ = true;
  1842. // } else {
  1843. // doAutoQ = false;
  1844. // }
  1845. }
  1846.  
  1847. let placeVisible = [];
  1848.  
  1849. /** CLASS CODES */
  1850.  
  1851.  
  1852. class Utils {
  1853. constructor() {
  1854.  
  1855. // MATH UTILS:
  1856. let mathABS = Math.abs,
  1857. mathCOS = Math.cos,
  1858. mathSIN = Math.sin,
  1859. mathPOW = Math.pow,
  1860. mathSQRT = Math.sqrt,
  1861. mathATAN2 = Math.atan2,
  1862. mathPI = Math.PI;
  1863.  
  1864. let _this = this;
  1865.  
  1866. // GLOBAL UTILS:
  1867. this.round = function(n, v) {
  1868. return Math.round(n * v) / v;
  1869. };
  1870. this.toRad = function(angle) {
  1871. return angle * (mathPI / 180);
  1872. };
  1873. this.toAng = function(radian) {
  1874. return radian / (mathPI / 180);
  1875. };
  1876. this.randInt = function(min, max) {
  1877. return Math.floor(Math.random() * (max - min + 1)) + min;
  1878. };
  1879. this.randFloat = function(min, max) {
  1880. return Math.random() * (max - min + 1) + min;
  1881. };
  1882. this.lerp = function(value1, value2, amount) {
  1883. return value1 + (value2 - value1) * amount;
  1884. };
  1885. this.decel = function(val, cel) {
  1886. if (val > 0)
  1887. val = Math.max(0, val - cel);
  1888. else if (val < 0)
  1889. val = Math.min(0, val + cel);
  1890. return val;
  1891. };
  1892. this.getDistance = function(x1, y1, x2, y2) {
  1893. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1894. };
  1895. this.getDist = function(tmp1, tmp2, type1, type2) {
  1896. let tmpXY1 = {
  1897. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1898. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1899. };
  1900. let tmpXY2 = {
  1901. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1902. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1903. };
  1904. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1905. };
  1906. this.getDirection = function(x1, y1, x2, y2) {
  1907. return mathATAN2(y1 - y2, x1 - x2);
  1908. };
  1909. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1910. let tmpXY1 = {
  1911. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1912. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1913. };
  1914. let tmpXY2 = {
  1915. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1916. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1917. };
  1918. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1919. };
  1920. this.getAngleDist = function(a, b) {
  1921. let p = mathABS(b - a) % (mathPI * 2);
  1922. return (p > mathPI ? (mathPI * 2) - p : p);
  1923. };
  1924. this.isNumber = function(n) {
  1925. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1926. };
  1927. this.isString = function(s) {
  1928. return (s && typeof s == "string");
  1929. };
  1930. this.kFormat = function(num) {
  1931. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1932. };
  1933. this.sFormat = function(num) {
  1934. let fixs = [{
  1935. num: 1e3,
  1936. string: "k"
  1937. },
  1938. {
  1939. num: 1e6,
  1940. string: "m"
  1941. },
  1942. {
  1943. num: 1e9,
  1944. string: "b"
  1945. },
  1946. {
  1947. num: 1e12,
  1948. string: "q"
  1949. }
  1950. ].reverse();
  1951. let sp = fixs.find(v => num >= v.num);
  1952. if (!sp) return num;
  1953. return (num / sp.num).toFixed(1) + sp.string;
  1954. };
  1955. this.capitalizeFirst = function(string) {
  1956. return string.charAt(0).toUpperCase() + string.slice(1);
  1957. };
  1958. this.fixTo = function(n, v) {
  1959. return parseFloat(n.toFixed(v));
  1960. };
  1961. this.sortByPoints = function(a, b) {
  1962. return parseFloat(b.points) - parseFloat(a.points);
  1963. };
  1964. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1965. let minX = x1;
  1966. let maxX = x2;
  1967. if (x1 > x2) {
  1968. minX = x2;
  1969. maxX = x1;
  1970. }
  1971. if (maxX > recX2)
  1972. maxX = recX2;
  1973. if (minX < recX)
  1974. minX = recX;
  1975. if (minX > maxX)
  1976. return false;
  1977. let minY = y1;
  1978. let maxY = y2;
  1979. let dx = x2 - x1;
  1980. if (Math.abs(dx) > 0.0000001) {
  1981. let a = (y2 - y1) / dx;
  1982. let b = y1 - a * x1;
  1983. minY = a * minX + b;
  1984. maxY = a * maxX + b;
  1985. }
  1986. if (minY > maxY) {
  1987. let tmp = maxY;
  1988. maxY = minY;
  1989. minY = tmp;
  1990. }
  1991. if (maxY > recY2)
  1992. maxY = recY2;
  1993. if (minY < recY)
  1994. minY = recY;
  1995. if (minY > maxY)
  1996. return false;
  1997. return true;
  1998. };
  1999. this.containsPoint = function(element, x, y) {
  2000. let bounds = element.getBoundingClientRect();
  2001. let left = bounds.left + window.scrollX;
  2002. let top = bounds.top + window.scrollY;
  2003. let width = bounds.width;
  2004. let height = bounds.height;
  2005.  
  2006. let insideHorizontal = x > left && x < left + width;
  2007. let insideVertical = y > top && y < top + height;
  2008. return insideHorizontal && insideVertical;
  2009. };
  2010. this.mousifyTouchEvent = function(event) {
  2011. let touch = event.changedTouches[0];
  2012. event.screenX = touch.screenX;
  2013. event.screenY = touch.screenY;
  2014. event.clientX = touch.clientX;
  2015. event.clientY = touch.clientY;
  2016. event.pageX = touch.pageX;
  2017. event.pageY = touch.pageY;
  2018. };
  2019. this.hookTouchEvents = function(element, skipPrevent) {
  2020. let preventDefault = !skipPrevent;
  2021. let isHovering = false;
  2022. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  2023. let passive = false;
  2024. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  2025. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  2026. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  2027. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  2028. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  2029.  
  2030. function touchStart(e) {
  2031. _this.mousifyTouchEvent(e);
  2032. window.setUsingTouch(true);
  2033. if (preventDefault) {
  2034. e.preventDefault();
  2035. e.stopPropagation();
  2036. }
  2037. if (element.onmouseover)
  2038. element.onmouseover(e);
  2039. isHovering = true;
  2040. }
  2041.  
  2042. function touchMove(e) {
  2043. _this.mousifyTouchEvent(e);
  2044. window.setUsingTouch(true);
  2045. if (preventDefault) {
  2046. e.preventDefault();
  2047. e.stopPropagation();
  2048. }
  2049. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  2050. if (!isHovering) {
  2051. if (element.onmouseover)
  2052. element.onmouseover(e);
  2053. isHovering = true;
  2054. }
  2055. } else {
  2056. if (isHovering) {
  2057. if (element.onmouseout)
  2058. element.onmouseout(e);
  2059. isHovering = false;
  2060. }
  2061. }
  2062. }
  2063.  
  2064. function touchEnd(e) {
  2065. _this.mousifyTouchEvent(e);
  2066. window.setUsingTouch(true);
  2067. if (preventDefault) {
  2068. e.preventDefault();
  2069. e.stopPropagation();
  2070. }
  2071. if (isHovering) {
  2072. if (element.onclick)
  2073. element.onclick(e);
  2074. if (element.onmouseout)
  2075. element.onmouseout(e);
  2076. isHovering = false;
  2077. }
  2078. }
  2079. };
  2080. this.removeAllChildren = function(element) {
  2081. while (element.hasChildNodes()) {
  2082. element.removeChild(element.lastChild);
  2083. }
  2084. };
  2085. this.generateElement = function(config) {
  2086. let element = document.createElement(config.tag || "div");
  2087.  
  2088. function bind(configValue, elementValue) {
  2089. if (config[configValue])
  2090. element[elementValue] = config[configValue];
  2091. }
  2092. bind("text", "textContent");
  2093. bind("html", "innerHTML");
  2094. bind("class", "className");
  2095. for (let key in config) {
  2096. switch (key) {
  2097. case "tag":
  2098. case "text":
  2099. case "html":
  2100. case "class":
  2101. case "style":
  2102. case "hookTouch":
  2103. case "parent":
  2104. case "children":
  2105. continue;
  2106. default:
  2107. break;
  2108. }
  2109. element[key] = config[key];
  2110. }
  2111. if (element.onclick)
  2112. element.onclick = this.checkTrusted(element.onclick);
  2113. if (element.onmouseover)
  2114. element.onmouseover = this.checkTrusted(element.onmouseover);
  2115. if (element.onmouseout)
  2116. element.onmouseout = this.checkTrusted(element.onmouseout);
  2117. if (config.style) {
  2118. element.style.cssText = config.style;
  2119. }
  2120. if (config.hookTouch) {
  2121. this.hookTouchEvents(element);
  2122. }
  2123. if (config.parent) {
  2124. config.parent.appendChild(element);
  2125. }
  2126. if (config.children) {
  2127. for (let i = 0; i < config.children.length; i++) {
  2128. element.appendChild(config.children[i]);
  2129. }
  2130. }
  2131. return element;
  2132. };
  2133. this.checkTrusted = function(callback) {
  2134. return function(ev) {
  2135. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  2136. callback(ev);
  2137. } else {
  2138. //console.error("Event is not trusted.", ev);
  2139. }
  2140. };
  2141. };
  2142. this.randomString = function(length) {
  2143. let text = "";
  2144. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  2145. for (let i = 0; i < length; i++) {
  2146. text += possible.charAt(Math.floor(Math.random() * possible.length));
  2147. }
  2148. return text;
  2149. };
  2150. this.countInArray = function(array, val) {
  2151. let count = 0;
  2152. for (let i = 0; i < array.length; i++) {
  2153. if (array[i] === val) count++;
  2154. }
  2155. return count;
  2156. };
  2157. this.hexToRgb = function(hex) {
  2158. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2159. };
  2160. this.getRgb = function(r, g, b) {
  2161. return [r / 255, g / 255, b / 255].join(", ");
  2162. };
  2163. }
  2164. };
  2165. class Animtext {
  2166. // ANIMATED TEXT:
  2167. constructor() {
  2168. // INIT:
  2169. this.init = function(x, y, scale, speed, life, text, color) {
  2170. (this.x = x),
  2171. (this.y = y),
  2172. (this.color = color),
  2173. (this.scale = scale*3.5),
  2174. (this.weight = 50);
  2175. (this.startScale = this.scale * 1.2),
  2176. (this.maxScale = 1.5 * scale),
  2177. (this.minScale = 0.5 * scale),
  2178. (this.scaleSpeed = 0.7),
  2179. (this.speed = speed),
  2180. (this.speedMax = speed),
  2181. (this.life = life),
  2182. (this.maxLife = life),
  2183. (this.text = text),
  2184. this.movSpeed = speed;
  2185. };
  2186.  
  2187. // UPDATE:
  2188. this.update = function(delta) {
  2189. if(this.life){
  2190. this.life -= delta;
  2191. if(this.scaleSpeed != -0.35){
  2192. this.y -= this.speed * delta;
  2193. // (this.x += this.speed * delta);
  2194. } else {
  2195. this.y -= this.speed * delta;
  2196. }
  2197. this.scale -= .8;
  2198. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  2199. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  2200. if(this.scale >= this.maxScale){
  2201. this.scale = this.maxScale;
  2202. this.scaleSpeed *= -.5;
  2203. this.speed = this.speed * .75;
  2204. };
  2205. this.life <= 0 && (this.life = 0)
  2206. };
  2207. };
  2208.  
  2209. // RENDER:
  2210. this.render = function(ctxt, xOff, yOff) {
  2211. ctxt.lineWidth = 10;
  2212. ctxt.strokeStyle = darkOutlineColor; //"black";
  2213. ctxt.fillStyle = this.color;
  2214. ctxt.globalAlpha = 1;
  2215. ctxt.font = this.scale + "px HammerSmith One";
  2216. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2217. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2218. ctxt.globalAlpha = 1;
  2219. };
  2220. }
  2221. };
  2222. class Textmanager {
  2223. // TEXT MANAGER:
  2224. constructor() {
  2225. this.texts = [];
  2226. this.stack = [];
  2227.  
  2228. // UPDATE:
  2229. this.update = function(delta, ctxt, xOff, yOff) {
  2230. ctxt.textBaseline = "middle";
  2231. ctxt.textAlign = "center";
  2232. for (let i = 0; i < this.texts.length; ++i) {
  2233. if (this.texts[i].life) {
  2234. this.texts[i].update(delta);
  2235. this.texts[i].render(ctxt, xOff, yOff);
  2236. }
  2237. }
  2238. };
  2239.  
  2240. // SHOW TEXT:
  2241. this.showText = function(x, y, scale, speed, life, text, color) {
  2242. let tmpText;
  2243. for (let i = 0; i < this.texts.length; ++i) {
  2244. if (!this.texts[i].life) {
  2245. tmpText = this.texts[i];
  2246. break;
  2247. }
  2248. }
  2249. if (!tmpText) {
  2250. tmpText = new Animtext();
  2251. this.texts.push(tmpText);
  2252. }
  2253. tmpText.init(x, y, scale, speed, life, text, color);
  2254. };
  2255. }
  2256. }
  2257.  
  2258. class GameObject {
  2259. constructor(sid) {
  2260. this.sid = sid;
  2261.  
  2262. // INIT:
  2263. this.init = function(x, y, dir, scale, type, data, owner) {
  2264. data = data || {};
  2265. this.sentTo = {};
  2266. this.gridLocations = [];
  2267. this.active = true;
  2268. this.render = true;
  2269. this.doUpdate = data.doUpdate;
  2270. this.x = x;
  2271. this.y = y;
  2272. this.dir = dir;
  2273. this.lastDir = dir;
  2274. this.xWiggle = 0;
  2275. this.yWiggle = 0;
  2276. this.visScale = scale;
  2277. this.scale = scale;
  2278. this.type = type;
  2279. this.id = data.id;
  2280. this.owner = owner;
  2281. this.name = data.name;
  2282. this.isItem = (this.id != undefined);
  2283. this.group = data.group;
  2284. this.maxHealth = data.health;
  2285. this.health = this.maxHealth;
  2286. this.layer = 2;
  2287. if (this.group != undefined) {
  2288. this.layer = this.group.layer;
  2289. } else if (this.type == 0) {
  2290. this.layer = 3;
  2291. } else if (this.type == 2) {
  2292. this.layer = 0;
  2293. } else if (this.type == 4) {
  2294. this.layer = -1;
  2295. }
  2296. this.colDiv = data.colDiv || 1;
  2297. this.blocker = data.blocker;
  2298. this.ignoreCollision = data.ignoreCollision;
  2299. this.dontGather = data.dontGather;
  2300. this.hideFromEnemy = data.hideFromEnemy;
  2301. this.friction = data.friction;
  2302. this.projDmg = data.projDmg;
  2303. this.dmg = data.dmg;
  2304. this.pDmg = data.pDmg;
  2305. this.pps = data.pps;
  2306. this.zIndex = data.zIndex || 0;
  2307. this.turnSpeed = data.turnSpeed;
  2308. this.req = data.req;
  2309. this.trap = data.trap;
  2310. this.healCol = data.healCol;
  2311. this.teleport = data.teleport;
  2312. this.boostSpeed = data.boostSpeed;
  2313. this.projectile = data.projectile;
  2314. this.shootRange = data.shootRange;
  2315. this.shootRate = data.shootRate;
  2316. this.shootCount = this.shootRate;
  2317. this.spawnPoint = data.spawnPoint;
  2318. this.onNear = 0;
  2319. this.breakObj = false;
  2320. this.alpha = data.alpha || 1;
  2321. this.maxAlpha = data.alpha || 1;
  2322. this.damaged = 0;
  2323. };
  2324.  
  2325. // GET HIT:
  2326. this.changeHealth = function(amount, doer) {
  2327. this.health += amount;
  2328. return (this.health <= 0);
  2329. };
  2330.  
  2331. // GET SCALE:
  2332. this.getScale = function(sM, ig) {
  2333. sM = sM || 1;
  2334. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2335. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2336. };
  2337.  
  2338. // VISIBLE TO PLAYER:
  2339. this.visibleToPlayer = function(player) {
  2340. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2341. (this.owner.team && player.team == this.owner.team)));
  2342. };
  2343.  
  2344. // UPDATE:
  2345. this.update = function(delta) {
  2346. if (this.active) {
  2347. if (this.xWiggle) {
  2348. this.xWiggle *= Math.pow(0.99, delta);
  2349. }
  2350. if (this.yWiggle) {
  2351. this.yWiggle *= Math.pow(0.99, delta);
  2352. }
  2353. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2354. if (d2 > 0.01) {
  2355. this.dir += d2 / 5;
  2356. } else {
  2357. this.dir = this.lastDir;
  2358. }
  2359. } else {
  2360. if (this.alive) {
  2361. this.alpha -= delta / (200 / this.maxAlpha);
  2362. this.visScale += delta / (this.scale / 2.5);
  2363. if (this.alpha <= 0) {
  2364. this.alpha = 0;
  2365. this.alive = false;
  2366. }
  2367. }
  2368. }
  2369. };
  2370.  
  2371. // CHECK TEAM:
  2372. this.isTeamObject = function(tmpObj) {
  2373. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2374. };
  2375. }
  2376. }
  2377. class Items {
  2378. constructor() {
  2379. // ITEM GROUPS:
  2380. this.groups = [{
  2381. id: 0,
  2382. name: "food",
  2383. layer: 0
  2384. }, {
  2385. id: 1,
  2386. name: "walls",
  2387. place: true,
  2388. limit: 30,
  2389. layer: 0
  2390. }, {
  2391. id: 2,
  2392. name: "spikes",
  2393. place: true,
  2394. limit: 15,
  2395. layer: 0
  2396. }, {
  2397. id: 3,
  2398. name: "mill",
  2399. place: true,
  2400. limit: 7,
  2401. layer: 1
  2402. }, {
  2403. id: 4,
  2404. name: "mine",
  2405. place: true,
  2406. limit: 1,
  2407. layer: 0
  2408. }, {
  2409. id: 5,
  2410. name: "trap",
  2411. place: true,
  2412. limit: 6,
  2413. layer: -1
  2414. }, {
  2415. id: 6,
  2416. name: "booster",
  2417. place: true,
  2418. limit: 12,
  2419. layer: -1
  2420. }, {
  2421. id: 7,
  2422. name: "turret",
  2423. place: true,
  2424. limit: 2,
  2425. layer: 1
  2426. }, {
  2427. id: 8,
  2428. name: "watchtower",
  2429. place: true,
  2430. limit: 12,
  2431. layer: 1
  2432. }, {
  2433. id: 9,
  2434. name: "buff",
  2435. place: true,
  2436. limit: 4,
  2437. layer: -1
  2438. }, {
  2439. id: 10,
  2440. name: "spawn",
  2441. place: true,
  2442. limit: 1,
  2443. layer: -1
  2444. }, {
  2445. id: 11,
  2446. name: "sapling",
  2447. place: true,
  2448. limit: 2,
  2449. layer: 0
  2450. }, {
  2451. id: 12,
  2452. name: "blocker",
  2453. place: true,
  2454. limit: 3,
  2455. layer: -1
  2456. }, {
  2457. id: 13,
  2458. name: "teleporter",
  2459. place: true,
  2460. limit: 2,
  2461. layer: -1
  2462. }];
  2463.  
  2464. // PROJECTILES:
  2465. this.projectiles = [{
  2466. indx: 0,
  2467. layer: 0,
  2468. src: "arrow_1",
  2469. dmg: 25,
  2470. speed: 1.6,
  2471. scale: 103,
  2472. range: 1000
  2473. }, {
  2474. indx: 1,
  2475. layer: 1,
  2476. dmg: 25,
  2477. scale: 20
  2478. }, {
  2479. indx: 0,
  2480. layer: 0,
  2481. src: "arrow_1",
  2482. dmg: 35,
  2483. speed: 2.5,
  2484. scale: 103,
  2485. range: 1200
  2486. }, {
  2487. indx: 0,
  2488. layer: 0,
  2489. src: "arrow_1",
  2490. dmg: 30,
  2491. speed: 2,
  2492. scale: 103,
  2493. range: 1200
  2494. }, {
  2495. indx: 1,
  2496. layer: 1,
  2497. dmg: 16,
  2498. scale: 20
  2499. }, {
  2500. indx: 0,
  2501. layer: 0,
  2502. src: "bullet_1",
  2503. dmg: 50,
  2504. speed: 3.6,
  2505. scale: 160,
  2506. range: 1400
  2507. }];
  2508.  
  2509. // WEAPONS:
  2510. this.weapons = [{
  2511. id: 0,
  2512. type: 0,
  2513. name: "tool hammer",
  2514. desc: "tool for gathering all resources",
  2515. src: "hammer_1",
  2516. length: 140,
  2517. width: 140,
  2518. xOff: -3,
  2519. yOff: 18,
  2520. dmg: 25,
  2521. range: 65,
  2522. gather: 1,
  2523. speed: 300
  2524. }, {
  2525. id: 1,
  2526. type: 0,
  2527. age: 2,
  2528. name: "hand axe",
  2529. desc: "gathers resources at a higher rate",
  2530. src: "axe_1",
  2531. length: 140,
  2532. width: 140,
  2533. xOff: 3,
  2534. yOff: 24,
  2535. dmg: 30,
  2536. spdMult: 1,
  2537. range: 70,
  2538. gather: 2,
  2539. speed: 400
  2540. }, {
  2541. id: 2,
  2542. type: 0,
  2543. age: 8,
  2544. pre: 1,
  2545. name: "great axe",
  2546. desc: "deal more damage and gather more resources",
  2547. src: "great_axe_1",
  2548. length: 140,
  2549. width: 140,
  2550. xOff: -8,
  2551. yOff: 25,
  2552. dmg: 35,
  2553. spdMult: 1,
  2554. range: 75,
  2555. gather: 4,
  2556. speed: 400
  2557. }, {
  2558. id: 3,
  2559. type: 0,
  2560. age: 2,
  2561. name: "short sword",
  2562. desc: "increased attack power but slower move speed",
  2563. src: "sword_1",
  2564. iPad: 1.3,
  2565. length: 130,
  2566. width: 210,
  2567. xOff: -8,
  2568. yOff: 46,
  2569. dmg: 35,
  2570. spdMult: 0.85,
  2571. range: 110,
  2572. gather: 1,
  2573. speed: 300
  2574. }, {
  2575. id: 4,
  2576. type: 0,
  2577. age: 8,
  2578. pre: 3,
  2579. name: "katana",
  2580. desc: "greater range and damage",
  2581. src: "samurai_1",
  2582. iPad: 1.3,
  2583. length: 130,
  2584. width: 210,
  2585. xOff: -8,
  2586. yOff: 59,
  2587. dmg: 40,
  2588. spdMult: 0.8,
  2589. range: 118,
  2590. gather: 1,
  2591. speed: 300
  2592. }, {
  2593. id: 5,
  2594. type: 0,
  2595. age: 2,
  2596. name: "polearm",
  2597. desc: "long range melee weapon",
  2598. src: "spear_1",
  2599. iPad: 1.3,
  2600. length: 130,
  2601. width: 210,
  2602. xOff: -8,
  2603. yOff: 53,
  2604. dmg: 45,
  2605. knock: 0.2,
  2606. spdMult: 0.82,
  2607. range: 142,
  2608. gather: 1,
  2609. speed: 700
  2610. }, {
  2611. id: 6,
  2612. type: 0,
  2613. age: 2,
  2614. name: "bat",
  2615. desc: "fast long range melee weapon",
  2616. src: "bat_1",
  2617. iPad: 1.3,
  2618. length: 110,
  2619. width: 180,
  2620. xOff: -8,
  2621. yOff: 53,
  2622. dmg: 20,
  2623. knock: 0.7,
  2624. range: 110,
  2625. gather: 1,
  2626. speed: 300
  2627. }, {
  2628. id: 7,
  2629. type: 0,
  2630. age: 2,
  2631. name: "daggers",
  2632. desc: "really fast short range weapon",
  2633. src: "dagger_1",
  2634. iPad: 0.8,
  2635. length: 110,
  2636. width: 110,
  2637. xOff: 18,
  2638. yOff: 0,
  2639. dmg: 20,
  2640. knock: 0.1,
  2641. range: 65,
  2642. gather: 1,
  2643. hitSlow: 0.1,
  2644. spdMult: 1.13,
  2645. speed: 100
  2646. }, {
  2647. id: 8,
  2648. type: 0,
  2649. age: 2,
  2650. name: "stick",
  2651. desc: "great for gathering but very weak",
  2652. src: "stick_1",
  2653. length: 140,
  2654. width: 140,
  2655. xOff: 3,
  2656. yOff: 24,
  2657. dmg: 1,
  2658. spdMult: 1,
  2659. range: 70,
  2660. gather: 7,
  2661. speed: 400
  2662. }, {
  2663. id: 9,
  2664. type: 1,
  2665. age: 6,
  2666. name: "hunting bow",
  2667. desc: "bow used for ranged combat and hunting",
  2668. src: "bow_1",
  2669. req: ["wood", 4],
  2670. length: 120,
  2671. width: 120,
  2672. xOff: -6,
  2673. yOff: 0,
  2674. Pdmg: 25,
  2675. projectile: 0,
  2676. spdMult: 0.75,
  2677. speed: 600
  2678. }, {
  2679. id: 10,
  2680. type: 1,
  2681. age: 6,
  2682. name: "great hammer",
  2683. desc: "hammer used for destroying structures",
  2684. src: "great_hammer_1",
  2685. length: 140,
  2686. width: 140,
  2687. xOff: -9,
  2688. yOff: 25,
  2689. dmg: 10,
  2690. Pdmg: 10,
  2691. spdMult: 0.88,
  2692. range: 75,
  2693. sDmg: 7.5,
  2694. gather: 1,
  2695. speed: 400
  2696. }, {
  2697. id: 11,
  2698. type: 1,
  2699. age: 6,
  2700. name: "wooden shield",
  2701. desc: "blocks projectiles and reduces melee damage",
  2702. src: "shield_1",
  2703. length: 120,
  2704. width: 120,
  2705. shield: 0.2,
  2706. xOff: 6,
  2707. yOff: 0,
  2708. Pdmg: 0,
  2709. spdMult: 0.7
  2710. }, {
  2711. id: 12,
  2712. type: 1,
  2713. age: 8,
  2714. pre: 9,
  2715. name: "crossbow",
  2716. desc: "deals more damage and has greater range",
  2717. src: "crossbow_1",
  2718. req: ["wood", 5],
  2719. aboveHand: true,
  2720. armS: 0.75,
  2721. length: 120,
  2722. width: 120,
  2723. xOff: -4,
  2724. yOff: 0,
  2725. Pdmg: 35,
  2726. projectile: 2,
  2727. spdMult: 0.7,
  2728. speed: 700
  2729. }, {
  2730. id: 13,
  2731. type: 1,
  2732. age: 9,
  2733. pre: 12,
  2734. name: "repeater crossbow",
  2735. desc: "high firerate crossbow with reduced damage",
  2736. src: "crossbow_2",
  2737. req: ["wood", 10],
  2738. aboveHand: true,
  2739. armS: 0.75,
  2740. length: 120,
  2741. width: 120,
  2742. xOff: -4,
  2743. yOff: 0,
  2744. Pdmg: 30,
  2745. projectile: 3,
  2746. spdMult: 0.7,
  2747. speed: 230
  2748. }, {
  2749. id: 14,
  2750. type: 1,
  2751. age: 6,
  2752. name: "mc grabby",
  2753. desc: "steals resources from enemies",
  2754. src: "grab_1",
  2755. length: 130,
  2756. width: 210,
  2757. xOff: -8,
  2758. yOff: 53,
  2759. dmg: 0,
  2760. Pdmg: 0,
  2761. steal: 250,
  2762. knock: 0.2,
  2763. spdMult: 1.05,
  2764. range: 125,
  2765. gather: 0,
  2766. speed: 700
  2767. }, {
  2768. id: 15,
  2769. type: 1,
  2770. age: 9,
  2771. pre: 12,
  2772. name: "musket",
  2773. desc: "slow firerate but high damage and range",
  2774. src: "musket_1",
  2775. req: ["stone", 10],
  2776. aboveHand: true,
  2777. rec: 0.35,
  2778. armS: 0.6,
  2779. hndS: 0.3,
  2780. hndD: 1.6,
  2781. length: 205,
  2782. width: 205,
  2783. xOff: 25,
  2784. yOff: 0,
  2785. Pdmg: 50,
  2786. projectile: 5,
  2787. hideProjectile: true,
  2788. spdMult: 0.6,
  2789. speed: 1500
  2790. }];
  2791.  
  2792. // ITEMS:
  2793. this.list = [{
  2794. group: this.groups[0],
  2795. name: "apple",
  2796. desc: "restores 20 health when consumed",
  2797. req: ["food", 10],
  2798. consume: function(doer) {
  2799. return doer.changeHealth(20, doer);
  2800. },
  2801. scale: 22,
  2802. holdOffset: 15,
  2803. healing: 20,
  2804. itemID: 0,
  2805. itemAID: 16,
  2806. }, {
  2807. age: 3,
  2808. group: this.groups[0],
  2809. name: "cookie",
  2810. desc: "restores 40 health when consumed",
  2811. req: ["food", 15],
  2812. consume: function(doer) {
  2813. return doer.changeHealth(40, doer);
  2814. },
  2815. scale: 27,
  2816. holdOffset: 15,
  2817. healing: 40,
  2818. itemID: 1,
  2819. itemAID: 17,
  2820. }, {
  2821. age: 7,
  2822. group: this.groups[0],
  2823. name: "cheese",
  2824. desc: "restores 30 health and another 50 over 5 seconds",
  2825. req: ["food", 25],
  2826. consume: function(doer) {
  2827. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2828. doer.dmgOverTime.dmg = -10;
  2829. doer.dmgOverTime.doer = doer;
  2830. doer.dmgOverTime.time = 5;
  2831. return true;
  2832. }
  2833. return false;
  2834. },
  2835. scale: 27,
  2836. holdOffset: 15,
  2837. healing: 30,
  2838. itemID: 2,
  2839. itemAID: 18,
  2840. }, {
  2841. group: this.groups[1],
  2842. name: "wood wall",
  2843. desc: "provides protection for your village",
  2844. req: ["wood", 10],
  2845. projDmg: true,
  2846. health: 380,
  2847. scale: 50,
  2848. holdOffset: 20,
  2849. placeOffset: -5,
  2850. itemID: 3,
  2851. itemAID: 19,
  2852. }, {
  2853. age: 3,
  2854. group: this.groups[1],
  2855. name: "stone wall",
  2856. desc: "provides improved protection for your village",
  2857. req: ["stone", 25],
  2858. health: 900,
  2859. scale: 50,
  2860. holdOffset: 20,
  2861. placeOffset: -5,
  2862. itemID: 4,
  2863. itemAID: 20,
  2864. }, {
  2865. age: 7,
  2866. group: this.groups[1],
  2867. name: "castle wall",
  2868. desc: "provides powerful protection for your village",
  2869. req: ["stone", 35],
  2870. health: 1500,
  2871. scale: 52,
  2872. holdOffset: 20,
  2873. placeOffset: -5,
  2874. itemID: 5,
  2875. itemAID: 21,
  2876. }, {
  2877. group: this.groups[2],
  2878. name: "spikes",
  2879. desc: "damages enemies when they touch them",
  2880. req: ["wood", 20, "stone", 5],
  2881. health: 400,
  2882. dmg: 20,
  2883. scale: 49,
  2884. spritePadding: -23,
  2885. holdOffset: 8,
  2886. placeOffset: -5,
  2887. itemID: 6,
  2888. itemAID: 22,
  2889. shadow: {
  2890. offsetX: 5, // Adjust the shadow's X offset as needed
  2891. offsetY: 5, // Adjust the shadow's Y offset as needed
  2892. blur: 20, // Adjust the shadow's blur as needed
  2893. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2894. }
  2895.  
  2896. }, {
  2897. age: 5,
  2898. group: this.groups[2],
  2899. name: "greater spikes",
  2900. desc: "damages enemies when they touch them",
  2901. req: ["wood", 30, "stone", 10],
  2902. health: 500,
  2903. dmg: 35,
  2904. scale: 52,
  2905. spritePadding: -23,
  2906. holdOffset: 8,
  2907. placeOffset: -5,
  2908. itemID: 7,
  2909. itemAID: 23,
  2910. }, {
  2911. age: 9,
  2912. group: this.groups[2],
  2913. name: "poison spikes",
  2914. desc: "poisons enemies when they touch them",
  2915. req: ["wood", 35, "stone", 15],
  2916. health: 600,
  2917. dmg: 30,
  2918. pDmg: 5,
  2919. scale: 52,
  2920. spritePadding: -23,
  2921. holdOffset: 8,
  2922. placeOffset: -5,
  2923. itemID: 8,
  2924. itemAID: 24,
  2925. }, {
  2926. age: 9,
  2927. group: this.groups[2],
  2928. name: "spinning spikes",
  2929. desc: "damages enemies when they touch them",
  2930. req: ["wood", 30, "stone", 20],
  2931. health: 500,
  2932. dmg: 45,
  2933. turnSpeed: 0.003,
  2934. scale: 52,
  2935. spritePadding: -23,
  2936. holdOffset: 8,
  2937. placeOffset: -5,
  2938. itemID: 9,
  2939. itemAID: 25,
  2940. }, {
  2941. group: this.groups[3],
  2942. name: "windmill",
  2943. desc: "generates gold over time",
  2944. req: ["wood", 50, "stone", 10],
  2945. health: 400,
  2946. pps: 1,
  2947. turnSpeed: 0.0016,
  2948. spritePadding: 25,
  2949. iconLineMult: 12,
  2950. scale: 45,
  2951. holdOffset: 20,
  2952. placeOffset: 5,
  2953. itemID: 10,
  2954. itemAID: 26,
  2955. }, {
  2956. age: 5,
  2957. group: this.groups[3],
  2958. name: "faster windmill",
  2959. desc: "generates more gold over time",
  2960. req: ["wood", 60, "stone", 20],
  2961. health: 500,
  2962. pps: 1.5,
  2963. turnSpeed: 0.0025,
  2964. spritePadding: 25,
  2965. iconLineMult: 12,
  2966. scale: 47,
  2967. holdOffset: 20,
  2968. placeOffset: 5,
  2969. itemID: 11,
  2970. itemAID: 27,
  2971. }, {
  2972. age: 8,
  2973. group: this.groups[3],
  2974. name: "power mill",
  2975. desc: "generates more gold over time",
  2976. req: ["wood", 100, "stone", 50],
  2977. health: 800,
  2978. pps: 2,
  2979. turnSpeed: 0.005,
  2980. spritePadding: 25,
  2981. iconLineMult: 12,
  2982. scale: 47,
  2983. holdOffset: 20,
  2984. placeOffset: 5,
  2985. itemID: 12,
  2986. itemAID: 28,
  2987. }, {
  2988. age: 5,
  2989. group: this.groups[4],
  2990. type: 2,
  2991. name: "mine",
  2992. desc: "allows you to mine stone",
  2993. req: ["wood", 20, "stone", 100],
  2994. iconLineMult: 12,
  2995. scale: 65,
  2996. holdOffset: 20,
  2997. placeOffset: 0,
  2998. itemID: 13,
  2999. itemAID: 29,
  3000. }, {
  3001. age: 5,
  3002. group: this.groups[11],
  3003. type: 0,
  3004. name: "sapling",
  3005. desc: "allows you to farm wood",
  3006. req: ["wood", 150],
  3007. iconLineMult: 12,
  3008. colDiv: 0.5,
  3009. scale: 110,
  3010. holdOffset: 50,
  3011. placeOffset: -15,
  3012. itemID: 14,
  3013. itemAID: 30,
  3014. }, {
  3015. age: 4,
  3016. group: this.groups[5],
  3017. name: "pit trap",
  3018. desc: "pit that traps enemies if they walk over it",
  3019. req: ["wood", 30, "stone", 30],
  3020. trap: true,
  3021. ignoreCollision: true,
  3022. hideFromEnemy: true,
  3023. health: 500,
  3024. colDiv: 0.2,
  3025. scale: 50,
  3026. holdOffset: 20,
  3027. placeOffset: -5,
  3028. alpha: 0.6,
  3029. itemID: 15,
  3030. itemAID: 31,
  3031. }, {
  3032. age: 4,
  3033. group: this.groups[6],
  3034. name: "boost pad",
  3035. desc: "provides boost when stepped on",
  3036. req: ["stone", 20, "wood", 5],
  3037. ignoreCollision: true,
  3038. boostSpeed: 1.5,
  3039. health: 150,
  3040. colDiv: 0.7,
  3041. scale: 45,
  3042. holdOffset: 20,
  3043. placeOffset: -5,
  3044. itemID: 16,
  3045. itemAID: 32,
  3046. }, {
  3047. age: 7,
  3048. group: this.groups[7],
  3049. doUpdate: true,
  3050. name: "turret",
  3051. desc: "defensive structure that shoots at enemies",
  3052. req: ["wood", 200, "stone", 150],
  3053. health: 800,
  3054. projectile: 1,
  3055. shootRange: 700,
  3056. shootRate: 2200,
  3057. scale: 43,
  3058. holdOffset: 20,
  3059. placeOffset: -5,
  3060. itemID: 17,
  3061. itemAID: 33,
  3062. }, {
  3063. age: 7,
  3064. group: this.groups[8],
  3065. name: "platform",
  3066. desc: "platform to shoot over walls and cross over water",
  3067. req: ["wood", 20],
  3068. ignoreCollision: true,
  3069. zIndex: 1,
  3070. health: 300,
  3071. scale: 43,
  3072. holdOffset: 20,
  3073. placeOffset: -5,
  3074. itemID: 18,
  3075. itemAID: 34,
  3076. }, {
  3077. age: 7,
  3078. group: this.groups[9],
  3079. name: "healing pad",
  3080. desc: "standing on it will slowly heal you",
  3081. req: ["wood", 30, "food", 10],
  3082. ignoreCollision: true,
  3083. healCol: 15,
  3084. health: 400,
  3085. colDiv: 0.7,
  3086. scale: 45,
  3087. holdOffset: 20,
  3088. placeOffset: -5,
  3089. itemID: 19,
  3090. itemAID: 35,
  3091. }, {
  3092. age: 9,
  3093. group: this.groups[10],
  3094. name: "spawn pad",
  3095. desc: "you will spawn here when you die but it will dissapear",
  3096. req: ["wood", 100, "stone", 100],
  3097. health: 400,
  3098. ignoreCollision: true,
  3099. spawnPoint: true,
  3100. scale: 45,
  3101. holdOffset: 20,
  3102. placeOffset: -5,
  3103. itemID: 20,
  3104. itemAID: 36,
  3105. }, {
  3106. age: 7,
  3107. group: this.groups[12],
  3108. name: "blocker",
  3109. desc: "blocks building in radius",
  3110. req: ["wood", 30, "stone", 25],
  3111. ignoreCollision: true,
  3112. blocker: 300,
  3113. health: 400,
  3114. colDiv: 0.7,
  3115. scale: 45,
  3116. holdOffset: 20,
  3117. placeOffset: -5,
  3118. itemID: 21,
  3119. itemAID: 37,
  3120. }, {
  3121. age: 7,
  3122. group: this.groups[13],
  3123. name: "teleporter",
  3124. desc: "teleports you to a random point on the map",
  3125. req: ["wood", 60, "stone", 60],
  3126. ignoreCollision: true,
  3127. teleport: true,
  3128. health: 200,
  3129. colDiv: 0.7,
  3130. scale: 45,
  3131. holdOffset: 20,
  3132. placeOffset: -5,
  3133. itemID: 22,
  3134. itemAID: 38
  3135. }];
  3136.  
  3137. // CHECK ITEM ID:
  3138. this.checkItem = {
  3139. index: function(id, myItems) {
  3140. return [0, 1, 2].includes(id) ? 0 : [3, 4, 5].includes(id) ? 1 : [6, 7, 8, 9].includes(id) ? 2 : [10, 11, 12].includes(id) ? 3 : [13, 14].includes(id) ? 5 : [15, 16].includes(id) ? 4 : [17, 18, 19, 21, 22].includes(id) ? [13, 14].includes(myItems) ? 6 :
  3141. 5 :
  3142. id == 20 ? [13, 14].includes(myItems) ? 7 :
  3143. 6 :
  3144. undefined;
  3145. }
  3146. }
  3147.  
  3148. // ASSIGN IDS:
  3149. for (let i = 0; i < this.list.length; ++i) {
  3150. this.list[i].id = i;
  3151. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3152. }
  3153.  
  3154. // TROLOLOLOL:
  3155. if (typeof window !== "undefined") {
  3156. function shuffle(a) {
  3157. for (let i = a.length - 1; i > 0; i--) {
  3158. const j = Math.floor(Math.random() * (i + 1));
  3159. [a[i], a[j]] = [a[j], a[i]];
  3160. }
  3161. return a;
  3162. }
  3163. //shuffle(this.list);
  3164. }
  3165. }
  3166. }
  3167. class Objectmanager {
  3168. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3169. let mathFloor = Math.floor,
  3170. mathABS = Math.abs,
  3171. mathCOS = Math.cos,
  3172. mathSIN = Math.sin,
  3173. mathPOW = Math.pow,
  3174. mathSQRT = Math.sqrt;
  3175.  
  3176. this.ignoreAdd = false;
  3177. this.hitObj = [];
  3178.  
  3179. // DISABLE OBJ:
  3180. this.disableObj = function(obj) {
  3181. obj.active = false;
  3182. };
  3183.  
  3184. // ADD NEW:
  3185. let tmpObj;
  3186. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3187. tmpObj = findObjectBySid(sid);
  3188. if (!tmpObj) {
  3189. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3190. if (!tmpObj) {
  3191. tmpObj = new GameObject(sid);
  3192. gameObjects.push(tmpObj);
  3193. }
  3194. }
  3195. if (setSID) {
  3196. tmpObj.sid = sid;
  3197. }
  3198. tmpObj.init(x, y, dir, s, type, data, owner);
  3199. };
  3200.  
  3201. // DISABLE BY SID:
  3202. this.disableBySid = function(sid) {
  3203. let find = findObjectBySid(sid);
  3204. if (find) {
  3205. this.disableObj(find);
  3206. }
  3207. };
  3208.  
  3209. // REMOVE ALL FROM PLAYER:
  3210. this.removeAllItems = function(sid, server) {
  3211. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3212. };
  3213.  
  3214. // CHECK IF PLACABLE:
  3215. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3216. let cantPlace = liztobj.find((tmp) => tmp.active && UTILS.getDistance(x, y, tmp.x, tmp.y) < s + (tmp.blocker ? tmp.blocker : tmp.getScale(sM, tmp.isItem)));
  3217. if (cantPlace) return false;
  3218. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3219. return true;
  3220. };
  3221.  
  3222. }
  3223. }
  3224. class Projectile {
  3225. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3226.  
  3227. // INIT:
  3228. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3229. this.active = true;
  3230. this.tickActive = true;
  3231. this.indx = indx;
  3232. this.x = x;
  3233. this.y = y;
  3234. this.x2 = x;
  3235. this.y2 = y;
  3236. this.dir = dir;
  3237. this.skipMov = true;
  3238. this.speed = spd;
  3239. this.dmg = dmg;
  3240. this.scale = scl;
  3241. this.range = rng;
  3242. this.r2 = rng;
  3243. this.owner = owner;
  3244. };
  3245.  
  3246. // UPDATE:
  3247. this.update = function(delta) {
  3248. if (this.active) {
  3249. let tmpSpeed = this.speed * delta;
  3250. if (!this.skipMov) {
  3251. this.x += tmpSpeed * Math.cos(this.dir);
  3252. this.y += tmpSpeed * Math.sin(this.dir);
  3253. this.range -= tmpSpeed;
  3254. if (this.range <= 0) {
  3255. this.x += this.range * Math.cos(this.dir);
  3256. this.y += this.range * Math.sin(this.dir);
  3257. tmpSpeed = 1;
  3258. this.range = 0;
  3259. this.active = false;
  3260. }
  3261. } else {
  3262. this.skipMov = false;
  3263. }
  3264. }
  3265. };
  3266. this.tickUpdate = function(delta) {
  3267. if (this.tickActive) {
  3268. let tmpSpeed = this.speed * delta;
  3269. if (!this.skipMov) {
  3270. this.x2 += tmpSpeed * Math.cos(this.dir);
  3271. this.y2 += tmpSpeed * Math.sin(this.dir);
  3272. this.r2 -= tmpSpeed;
  3273. if (this.r2 <= 0) {
  3274. this.x2 += this.r2 * Math.cos(this.dir);
  3275. this.y2 += this.r2 * Math.sin(this.dir);
  3276. tmpSpeed = 1;
  3277. this.r2 = 0;
  3278. this.tickActive = false;
  3279. }
  3280. } else {
  3281. this.skipMov = false;
  3282. }
  3283. }
  3284. };
  3285. }
  3286. };
  3287. class Store {
  3288. constructor() {
  3289. // STORE HATS:
  3290. this.hats = [{
  3291. id: 45,
  3292. name: "Shame!",
  3293. dontSell: true,
  3294. price: 0,
  3295. scale: 120,
  3296. desc: "hacks are for winners"
  3297. }, {
  3298. id: 51,
  3299. name: "Moo Cap",
  3300. price: 0,
  3301. scale: 120,
  3302. desc: "coolest mooer around"
  3303. }, {
  3304. id: 50,
  3305. name: "Apple Cap",
  3306. price: 0,
  3307. scale: 120,
  3308. desc: "apple farms remembers"
  3309. }, {
  3310. id: 28,
  3311. name: "Moo Head",
  3312. price: 0,
  3313. scale: 120,
  3314. desc: "no effect"
  3315. }, {
  3316. id: 29,
  3317. name: "Pig Head",
  3318. price: 0,
  3319. scale: 120,
  3320. desc: "no effect"
  3321. }, {
  3322. id: 30,
  3323. name: "Fluff Head",
  3324. price: 0,
  3325. scale: 120,
  3326. desc: "no effect"
  3327. }, {
  3328. id: 36,
  3329. name: "Pandou Head",
  3330. price: 0,
  3331. scale: 120,
  3332. desc: "no effect"
  3333. }, {
  3334. id: 37,
  3335. name: "Bear Head",
  3336. price: 0,
  3337. scale: 120,
  3338. desc: "no effect"
  3339. }, {
  3340. id: 38,
  3341. name: "Monkey Head",
  3342. price: 0,
  3343. scale: 120,
  3344. desc: "no effect"
  3345. }, {
  3346. id: 44,
  3347. name: "Polar Head",
  3348. price: 0,
  3349. scale: 120,
  3350. desc: "no effect"
  3351. }, {
  3352. id: 35,
  3353. name: "Fez Hat",
  3354. price: 0,
  3355. scale: 120,
  3356. desc: "no effect"
  3357. }, {
  3358. id: 42,
  3359. name: "Enigma Hat",
  3360. price: 0,
  3361. scale: 120,
  3362. desc: "join the enigma army"
  3363. }, {
  3364. id: 43,
  3365. name: "Blitz Hat",
  3366. price: 0,
  3367. scale: 120,
  3368. desc: "hey everybody i'm blitz"
  3369. }, {
  3370. id: 49,
  3371. name: "Bob XIII Hat",
  3372. price: 0,
  3373. scale: 120,
  3374. desc: "like and subscribe"
  3375. }, {
  3376. id: 57,
  3377. name: "Pumpkin",
  3378. price: 50,
  3379. scale: 120,
  3380. desc: "Spooooky"
  3381. }, {
  3382. id: 8,
  3383. name: "Bummle Hat",
  3384. price: 100,
  3385. scale: 120,
  3386. desc: "no effect"
  3387. }, {
  3388. id: 2,
  3389. name: "Straw Hat",
  3390. price: 500,
  3391. scale: 120,
  3392. desc: "no effect"
  3393. }, {
  3394. id: 15,
  3395. name: "Winter Cap",
  3396. price: 600,
  3397. scale: 120,
  3398. desc: "allows you to move at normal speed in snow",
  3399. coldM: 1
  3400. }, {
  3401. id: 5,
  3402. name: "Cowboy Hat",
  3403. price: 1000,
  3404. scale: 120,
  3405. desc: "no effect"
  3406. }, {
  3407. id: 4,
  3408. name: "Ranger Hat",
  3409. price: 2000,
  3410. scale: 120,
  3411. desc: "no effect"
  3412. }, {
  3413. id: 18,
  3414. name: "Explorer Hat",
  3415. price: 2000,
  3416. scale: 120,
  3417. desc: "no effect"
  3418. }, {
  3419. id: 31,
  3420. name: "Flipper Hat",
  3421. price: 2500,
  3422. scale: 120,
  3423. desc: "have more control while in water",
  3424. watrImm: true
  3425. }, {
  3426. id: 1,
  3427. name: "Marksman Cap",
  3428. price: 3000,
  3429. scale: 120,
  3430. desc: "increases arrow speed and range",
  3431. aMlt: 1.3
  3432. }, {
  3433. id: 10,
  3434. name: "Bush Gear",
  3435. price: 3000,
  3436. scale: 160,
  3437. desc: "allows you to disguise yourself as a bush"
  3438. }, {
  3439. id: 48,
  3440. name: "Halo",
  3441. price: 3000,
  3442. scale: 120,
  3443. desc: "no effect"
  3444. }, {
  3445. id: 6,
  3446. name: "Soldier Helmet",
  3447. price: 4000,
  3448. scale: 120,
  3449. desc: "reduces damage taken but slows movement",
  3450. spdMult: 0.94,
  3451. dmgMult: 0.75
  3452. }, {
  3453. id: 23,
  3454. name: "Anti Venom Gear",
  3455. price: 4000,
  3456. scale: 120,
  3457. desc: "makes you immune to poison",
  3458. poisonRes: 1
  3459. }, {
  3460. id: 13,
  3461. name: "Medic Gear",
  3462. price: 5000,
  3463. scale: 110,
  3464. desc: "slowly regenerates health over time",
  3465. healthRegen: 3
  3466. }, {
  3467. id: 9,
  3468. name: "Miners Helmet",
  3469. price: 5000,
  3470. scale: 120,
  3471. desc: "earn 1 extra gold per resource",
  3472. extraGold: 1
  3473. }, {
  3474. id: 32,
  3475. name: "Musketeer Hat",
  3476. price: 5000,
  3477. scale: 120,
  3478. desc: "reduces cost of projectiles",
  3479. projCost: 0.5
  3480. }, {
  3481. id: 7,
  3482. name: "Bull Helmet",
  3483. price: 6000,
  3484. scale: 120,
  3485. desc: "increases damage done but drains health",
  3486. healthRegen: -5,
  3487. dmgMultO: 1.5,
  3488. spdMult: 0.96
  3489. }, {
  3490. id: 22,
  3491. name: "Emp Helmet",
  3492. price: 6000,
  3493. scale: 120,
  3494. desc: "turrets won't attack but you move slower",
  3495. antiTurret: 1,
  3496. spdMult: 0.7
  3497. }, {
  3498. id: 12,
  3499. name: "Booster Hat",
  3500. price: 6000,
  3501. scale: 120,
  3502. desc: "increases your movement speed",
  3503. spdMult: 1.16
  3504. }, {
  3505. id: 26,
  3506. name: "Barbarian Armor",
  3507. price: 8000,
  3508. scale: 120,
  3509. desc: "knocks back enemies that attack you",
  3510. dmgK: 0.6
  3511. }, {
  3512. id: 21,
  3513. name: "Plague Mask",
  3514. price: 10000,
  3515. scale: 120,
  3516. desc: "melee attacks deal poison damage",
  3517. poisonDmg: 5,
  3518. poisonTime: 6
  3519. }, {
  3520. id: 46,
  3521. name: "Bull Mask",
  3522. price: 10000,
  3523. scale: 120,
  3524. desc: "bulls won't target you unless you attack them",
  3525. bullRepel: 1
  3526. }, {
  3527. id: 14,
  3528. name: "Windmill Hat",
  3529. topSprite: true,
  3530. price: 10000,
  3531. scale: 120,
  3532. desc: "generates points while worn",
  3533. pps: 1.5
  3534. }, {
  3535. id: 11,
  3536. name: "Spike Gear",
  3537. topSprite: true,
  3538. price: 10000,
  3539. scale: 120,
  3540. desc: "deal damage to players that damage you",
  3541. dmg: 0.45
  3542. }, {
  3543. id: 53,
  3544. name: "Turret Gear",
  3545. topSprite: true,
  3546. price: 10000,
  3547. scale: 120,
  3548. desc: "you become a walking turret",
  3549. turret: {
  3550. proj: 1,
  3551. range: 700,
  3552. rate: 2500
  3553. },
  3554. spdMult: 0.7
  3555. }, {
  3556. id: 20,
  3557. name: "Samurai Armor",
  3558. price: 12000,
  3559. scale: 120,
  3560. desc: "increased attack speed and fire rate",
  3561. atkSpd: 0.78
  3562. }, {
  3563. id: 58,
  3564. name: "Dark Knight",
  3565. price: 12000,
  3566. scale: 120,
  3567. desc: "restores health when you deal damage",
  3568. healD: 0.4
  3569. }, {
  3570. id: 27,
  3571. name: "Scavenger Gear",
  3572. price: 15000,
  3573. scale: 120,
  3574. desc: "earn double points for each kill",
  3575. kScrM: 2
  3576. }, {
  3577. id: 40,
  3578. name: "Tank Gear",
  3579. price: 15000,
  3580. scale: 120,
  3581. desc: "increased damage to buildings but slower movement",
  3582. spdMult: 0.3,
  3583. bDmg: 3.3
  3584. }, {
  3585. id: 52,
  3586. name: "Thief Gear",
  3587. price: 15000,
  3588. scale: 120,
  3589. desc: "steal half of a players gold when you kill them",
  3590. goldSteal: 0.5
  3591. }, {
  3592. id: 55,
  3593. name: "Bloodthirster",
  3594. price: 20000,
  3595. scale: 120,
  3596. desc: "Restore Health when dealing damage. And increased damage",
  3597. healD: 0.25,
  3598. dmgMultO: 1.2,
  3599. }, {
  3600. id: 56,
  3601. name: "Assassin Gear",
  3602. price: 20000,
  3603. scale: 120,
  3604. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3605. noEat: true,
  3606. spdMult: 1.1,
  3607. invisTimer: 1000
  3608. }];
  3609.  
  3610. // STORE ACCESSORIES:
  3611. this.accessories = [{
  3612. id: 12,
  3613. name: "Snowball",
  3614. price: 1000,
  3615. scale: 105,
  3616. xOff: 18,
  3617. desc: "no effect"
  3618. }, {
  3619. id: 9,
  3620. name: "Tree Cape",
  3621. price: 1000,
  3622. scale: 90,
  3623. desc: "no effect"
  3624. }, {
  3625. id: 10,
  3626. name: "Stone Cape",
  3627. price: 1000,
  3628. scale: 90,
  3629. desc: "no effect"
  3630. }, {
  3631. id: 3,
  3632. name: "Cookie Cape",
  3633. price: 1500,
  3634. scale: 90,
  3635. desc: "no effect"
  3636. }, {
  3637. id: 8,
  3638. name: "Cow Cape",
  3639. price: 2000,
  3640. scale: 90,
  3641. desc: "no effect"
  3642. }, {
  3643. id: 11,
  3644. name: "Monkey Tail",
  3645. price: 2000,
  3646. scale: 97,
  3647. xOff: 25,
  3648. desc: "Super speed but reduced damage",
  3649. spdMult: 1.35,
  3650. dmgMultO: 0.2
  3651. }, {
  3652. id: 17,
  3653. name: "Apple Basket",
  3654. price: 3000,
  3655. scale: 80,
  3656. xOff: 12,
  3657. desc: "slowly regenerates health over time",
  3658. healthRegen: 1
  3659. }, {
  3660. id: 6,
  3661. name: "Winter Cape",
  3662. price: 3000,
  3663. scale: 90,
  3664. desc: "no effect"
  3665. }, {
  3666. id: 4,
  3667. name: "Skull Cape",
  3668. price: 4000,
  3669. scale: 90,
  3670. desc: "no effect"
  3671. }, {
  3672. id: 5,
  3673. name: "Dash Cape",
  3674. price: 5000,
  3675. scale: 90,
  3676. desc: "no effect"
  3677. }, {
  3678. id: 2,
  3679. name: "Dragon Cape",
  3680. price: 6000,
  3681. scale: 90,
  3682. desc: "no effect"
  3683. }, {
  3684. id: 1,
  3685. name: "Super Cape",
  3686. price: 8000,
  3687. scale: 90,
  3688. desc: "no effect"
  3689. }, {
  3690. id: 7,
  3691. name: "Troll Cape",
  3692. price: 8000,
  3693. scale: 90,
  3694. desc: "no effect"
  3695. }, {
  3696. id: 14,
  3697. name: "Thorns",
  3698. price: 10000,
  3699. scale: 115,
  3700. xOff: 20,
  3701. desc: "no effect"
  3702. }, {
  3703. id: 15,
  3704. name: "Blockades",
  3705. price: 10000,
  3706. scale: 95,
  3707. xOff: 15,
  3708. desc: "no effect"
  3709. }, {
  3710. id: 20,
  3711. name: "Devils Tail",
  3712. price: 10000,
  3713. scale: 95,
  3714. xOff: 20,
  3715. desc: "no effect"
  3716. }, {
  3717. id: 16,
  3718. name: "Sawblade",
  3719. price: 12000,
  3720. scale: 90,
  3721. spin: true,
  3722. xOff: 0,
  3723. desc: "deal damage to players that damage you",
  3724. dmg: 0.15
  3725. }, {
  3726. id: 13,
  3727. name: "Angel Wings",
  3728. price: 15000,
  3729. scale: 138,
  3730. xOff: 22,
  3731. desc: "slowly regenerates health over time",
  3732. healthRegen: 3
  3733. }, {
  3734. id: 19,
  3735. name: "Shadow Wings",
  3736. price: 15000,
  3737. scale: 138,
  3738. xOff: 22,
  3739. desc: "increased movement speed",
  3740. spdMult: 1.1
  3741. }, {
  3742. id: 18,
  3743. name: "Blood Wings",
  3744. price: 20000,
  3745. scale: 178,
  3746. xOff: 26,
  3747. desc: "restores health when you deal damage",
  3748. healD: 0.2
  3749. }, {
  3750. id: 21,
  3751. name: "Corrupt X Wings",
  3752. price: 20000,
  3753. scale: 178,
  3754. xOff: 26,
  3755. desc: "deal damage to players that damage you",
  3756. dmg: 0.25
  3757. }];
  3758. }
  3759. };
  3760. class ProjectileManager {
  3761. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3762. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3763. let tmpData = items.projectiles[indx];
  3764. let tmpProj;
  3765. for (let i = 0; i < projectiles.length; ++i) {
  3766. if (!projectiles[i].active) {
  3767. tmpProj = projectiles[i];
  3768. break;
  3769. }
  3770. }
  3771. if (!tmpProj) {
  3772. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3773. tmpProj.sid = projectiles.length;
  3774. projectiles.push(tmpProj);
  3775. }
  3776. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3777. tmpProj.ignoreObj = ignoreObj;
  3778. tmpProj.layer = layer || tmpData.layer;
  3779. tmpProj.inWindow = inWindow;
  3780. tmpProj.src = tmpData.src;
  3781. return tmpProj;
  3782. };
  3783. }
  3784. };
  3785. class AiManager {
  3786.  
  3787. // AI MANAGER:
  3788. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3789.  
  3790. // AI TYPES:
  3791. this.aiTypes = [{
  3792. id: 0,
  3793. src: "cow_1",
  3794. killScore: 150,
  3795. health: 500,
  3796. weightM: 0.8,
  3797. speed: 0.00095,
  3798. turnSpeed: 0.001,
  3799. scale: 72,
  3800. drop: ["food", 50]
  3801. }, {
  3802. id: 1,
  3803. src: "pig_1",
  3804. killScore: 200,
  3805. health: 800,
  3806. weightM: 0.6,
  3807. speed: 0.00085,
  3808. turnSpeed: 0.001,
  3809. scale: 72,
  3810. drop: ["food", 80]
  3811. }, {
  3812. id: 2,
  3813. name: "Bull",
  3814. src: "bull_2",
  3815. hostile: true,
  3816. dmg: 20,
  3817. killScore: 1000,
  3818. health: 1800,
  3819. weightM: 0.5,
  3820. speed: 0.00094,
  3821. turnSpeed: 0.00074,
  3822. scale: 78,
  3823. viewRange: 800,
  3824. chargePlayer: true,
  3825. drop: ["food", 100]
  3826. }, {
  3827. id: 3,
  3828. name: "Bully",
  3829. src: "bull_1",
  3830. hostile: true,
  3831. dmg: 20,
  3832. killScore: 2000,
  3833. health: 2800,
  3834. weightM: 0.45,
  3835. speed: 0.001,
  3836. turnSpeed: 0.0008,
  3837. scale: 90,
  3838. viewRange: 900,
  3839. chargePlayer: true,
  3840. drop: ["food", 400]
  3841. }, {
  3842. id: 4,
  3843. name: "Wolf",
  3844. src: "wolf_1",
  3845. hostile: true,
  3846. dmg: 8,
  3847. killScore: 500,
  3848. health: 300,
  3849. weightM: 0.45,
  3850. speed: 0.001,
  3851. turnSpeed: 0.002,
  3852. scale: 84,
  3853. viewRange: 800,
  3854. chargePlayer: true,
  3855. drop: ["food", 200]
  3856. }, {
  3857. id: 5,
  3858. name: "Quack",
  3859. src: "chicken_1",
  3860. dmg: 8,
  3861. killScore: 2000,
  3862. noTrap: true,
  3863. health: 300,
  3864. weightM: 0.2,
  3865. speed: 0.0018,
  3866. turnSpeed: 0.006,
  3867. scale: 70,
  3868. drop: ["food", 100]
  3869. }, {
  3870. id: 6,
  3871. name: "MOOSTAFA",
  3872. nameScale: 50,
  3873. src: "enemy",
  3874. hostile: true,
  3875. dontRun: true,
  3876. fixedSpawn: true,
  3877. spawnDelay: 60000,
  3878. noTrap: true,
  3879. colDmg: 100,
  3880. dmg: 40,
  3881. killScore: 8000,
  3882. health: 18000,
  3883. weightM: 0.4,
  3884. speed: 0.0007,
  3885. turnSpeed: 0.01,
  3886. scale: 80,
  3887. spriteMlt: 1.8,
  3888. leapForce: 0.9,
  3889. viewRange: 1000,
  3890. hitRange: 210,
  3891. hitDelay: 1000,
  3892. chargePlayer: true,
  3893. drop: ["food", 100]
  3894. }, {
  3895. id: 7,
  3896. name: "Treasure",
  3897. hostile: true,
  3898. nameScale: 35,
  3899. src: "crate_1",
  3900. fixedSpawn: true,
  3901. spawnDelay: 120000,
  3902. colDmg: 200,
  3903. killScore: 5000,
  3904. health: 20000,
  3905. weightM: 0.1,
  3906. speed: 0.0,
  3907. turnSpeed: 0.0,
  3908. scale: 70,
  3909. spriteMlt: 1.0
  3910. }, {
  3911. id: 8,
  3912. name: "MOOFIE",
  3913. src: "wolf_2",
  3914. hostile: true,
  3915. fixedSpawn: true,
  3916. dontRun: true,
  3917. hitScare: 4,
  3918. spawnDelay: 30000,
  3919. noTrap: true,
  3920. nameScale: 35,
  3921. dmg: 10,
  3922. colDmg: 100,
  3923. killScore: 3000,
  3924. health: 7000,
  3925. weightM: 0.45,
  3926. speed: 0.0015,
  3927. turnSpeed: 0.002,
  3928. scale: 90,
  3929. viewRange: 800,
  3930. chargePlayer: true,
  3931. drop: ["food", 1000]
  3932. }, {
  3933. id: 9,
  3934. name: "💀MOOFIE",
  3935. src: "wolf_2",
  3936. hostile: !0,
  3937. fixedSpawn: !0,
  3938. dontRun: !0,
  3939. hitScare: 50,
  3940. spawnDelay: 6e4,
  3941. noTrap: !0,
  3942. nameScale: 35,
  3943. dmg: 12,
  3944. colDmg: 100,
  3945. killScore: 3e3,
  3946. health: 9e3,
  3947. weightM: .45,
  3948. speed: .0015,
  3949. turnSpeed: .0025,
  3950. scale: 94,
  3951. viewRange: 1440,
  3952. chargePlayer: !0,
  3953. drop: ["food", 3e3],
  3954. minSpawnRange: .85,
  3955. maxSpawnRange: .9
  3956. }, {
  3957. id: 10,
  3958. name: "💀Wolf",
  3959. src: "wolf_1",
  3960. hostile: !0,
  3961. fixedSpawn: !0,
  3962. dontRun: !0,
  3963. hitScare: 50,
  3964. spawnDelay: 3e4,
  3965. dmg: 10,
  3966. killScore: 700,
  3967. health: 500,
  3968. weightM: .45,
  3969. speed: .00115,
  3970. turnSpeed: .0025,
  3971. scale: 88,
  3972. viewRange: 1440,
  3973. chargePlayer: !0,
  3974. drop: ["food", 400],
  3975. minSpawnRange: .85,
  3976. maxSpawnRange: .9
  3977. }, {
  3978. id: 11,
  3979. name: "💀Bully",
  3980. src: "bull_1",
  3981. hostile: !0,
  3982. fixedSpawn: !0,
  3983. dontRun: !0,
  3984. hitScare: 50,
  3985. dmg: 20,
  3986. killScore: 5e3,
  3987. health: 5e3,
  3988. spawnDelay: 1e5,
  3989. weightM: .45,
  3990. speed: .00115,
  3991. turnSpeed: .0025,
  3992. scale: 94,
  3993. viewRange: 1440,
  3994. chargePlayer: !0,
  3995. drop: ["food", 800],
  3996. minSpawnRange: .85,
  3997. maxSpawnRange: .9
  3998. }];
  3999. // SPAWN AI:
  4000. this.spawn = function(x, y, dir, index) {
  4001. let tmpObj = ais.find((tmp) => !tmp.active);
  4002. if (!tmpObj) {
  4003. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  4004. ais.push(tmpObj);
  4005. }
  4006. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  4007. return tmpObj;
  4008. };
  4009. }
  4010.  
  4011. };
  4012. class AI {
  4013. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  4014. this.sid = sid;
  4015. this.isAI = true;
  4016. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  4017.  
  4018. // INIT:
  4019. this.init = function(x, y, dir, index, data) {
  4020. this.x = x;
  4021. this.y = y;
  4022. this.startX = data.fixedSpawn ? x : null;
  4023. this.startY = data.fixedSpawn ? y : null;
  4024. this.xVel = 0;
  4025. this.yVel = 0;
  4026. this.zIndex = 0;
  4027. this.dir = dir;
  4028. this.dirPlus = 0;
  4029. this.showName = 'YEAHHH';
  4030. this.index = index;
  4031. this.src = data.src;
  4032. if (data.name) this.name = data.name;
  4033. this.weightM = data.weightM;
  4034. this.speed = data.speed;
  4035. this.killScore = data.killScore;
  4036. this.turnSpeed = data.turnSpeed;
  4037. this.scale = data.scale;
  4038. this.maxHealth = data.health;
  4039. this.leapForce = data.leapForce;
  4040. this.health = this.maxHealth;
  4041. this.chargePlayer = data.chargePlayer;
  4042. this.viewRange = data.viewRange;
  4043. this.drop = data.drop;
  4044. this.dmg = data.dmg;
  4045. this.hostile = data.hostile;
  4046. this.dontRun = data.dontRun;
  4047. this.hitRange = data.hitRange;
  4048. this.hitDelay = data.hitDelay;
  4049. this.hitScare = data.hitScare;
  4050. this.spriteMlt = data.spriteMlt;
  4051. this.nameScale = data.nameScale;
  4052. this.colDmg = data.colDmg;
  4053. this.noTrap = data.noTrap;
  4054. this.spawnDelay = data.spawnDelay;
  4055. this.hitWait = 0;
  4056. this.waitCount = 1000;
  4057. this.moveCount = 0;
  4058. this.targetDir = 0;
  4059. this.active = true;
  4060. this.alive = true;
  4061. this.runFrom = null;
  4062. this.chargeTarget = null;
  4063. this.dmgOverTime = {};
  4064. };
  4065.  
  4066. let tmpRatio = 0;
  4067. let animIndex = 0;
  4068. this.animate = function(delta) {
  4069. if (this.animTime > 0) {
  4070. this.animTime -= delta;
  4071. if (this.animTime <= 0) {
  4072. this.animTime = 0;
  4073. this.dirPlus = 0;
  4074. tmpRatio = 0;
  4075. animIndex = 0;
  4076. } else {
  4077. if (animIndex == 0) {
  4078. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4079. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4080. if (tmpRatio >= 1) {
  4081. tmpRatio = 1;
  4082. animIndex = 1;
  4083. }
  4084. } else {
  4085. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4086. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4087. }
  4088. }
  4089. }
  4090. };
  4091.  
  4092. // ANIMATION:
  4093. this.startAnim = function() {
  4094. this.animTime = this.animSpeed = 600;
  4095. this.targetAngle = Math.PI * 0.8;
  4096. tmpRatio = 0;
  4097. animIndex = 0;
  4098. };
  4099.  
  4100. };
  4101.  
  4102. };
  4103. class addCh {
  4104. constructor(x, y, chat, tmpObj) {
  4105. this.x = x;
  4106. this.y = y;
  4107. this.alpha = 0;
  4108. this.active = true;
  4109. this.alive = false;
  4110. this.chat = chat;
  4111. this.owner = tmpObj;
  4112. };
  4113. };
  4114. class DeadPlayer {
  4115. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  4116. this.x = x;
  4117. this.y = y;
  4118. this.lastDir = dir;
  4119. this.dir = dir + Math.PI;
  4120. this.buildIndex = buildIndex;
  4121. this.weaponIndex = weaponIndex;
  4122. this.weaponVariant = weaponVariant;
  4123. this.skinColor = skinColor;
  4124. this.scale = scale;
  4125. this.visScale = 0;
  4126. this.name = name;
  4127. this.alpha = 1;
  4128. this.active = true;
  4129. this.animate = function(delta) {
  4130. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  4131. if (d2 > 0.01) {
  4132. this.dir += d2 / 20;
  4133. } else {
  4134. this.dir = this.lastDir;
  4135. }
  4136. if (this.visScale < this.scale) {
  4137. this.visScale += delta / (this.scale / 2);
  4138. if (this.visScale >= this.scale) {
  4139. this.visScale = this.scale;
  4140. }
  4141. }
  4142. this.alpha -= delta / 30000;
  4143. if (this.alpha <= 0) {
  4144. this.alpha = 0;
  4145. this.active = false;
  4146. }
  4147. }
  4148. }
  4149. };
  4150. class Player {
  4151. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  4152. this.id = id;
  4153. this.sid = sid;
  4154. this.tmpScore = 0;
  4155. this.team = null;
  4156. this.latestSkin = 0;
  4157. this.oldSkinIndex = 0;
  4158. this.skinIndex = 0;
  4159. this.latestTail = 0;
  4160. this.oldTailIndex = 0;
  4161. this.tailIndex = 0;
  4162. this.hitTime = 0;
  4163. this.lastHit = 0;
  4164. this.showName = 'YEAHHH';
  4165. this.tails = {};
  4166. for (let i = 0; i < accessories.length; ++i) {
  4167. if (accessories[i].price <= 0)
  4168. this.tails[accessories[i].id] = 1;
  4169. }
  4170. this.skins = {};
  4171. for (let i = 0; i < hats.length; ++i) {
  4172. if (hats[i].price <= 0)
  4173. this.skins[hats[i].id] = 1;
  4174. }
  4175. this.points = 0;
  4176. this.dt = 0;
  4177. this.hidden = false;
  4178. this.itemCounts = {};
  4179. this.isPlayer = true;
  4180. this.pps = 0;
  4181. this.moveDir = undefined;
  4182. this.skinRot = 0;
  4183. this.lastPing = 0;
  4184. this.iconIndex = 0;
  4185. this.skinColor = 0;
  4186. this.dist2 = 0;
  4187. this.aim2 = 0;
  4188. this.maxSpeed = 1;
  4189. this.chat = {
  4190. message: null,
  4191. count: 0
  4192. };
  4193. this.backupNobull = true;
  4194. this.circle = false;
  4195. this.cAngle = 0;
  4196. // SPAWN:
  4197. this.spawn = function(moofoll) {
  4198. this.attacked = false;
  4199. this.timeDamaged = 0;
  4200. this.timeHealed = 0;
  4201. this.pinge = 0;
  4202. this.millPlace = 'NOOO';
  4203. this.lastshamecount = 0;
  4204. this.death = false;
  4205. this.spinDir = 0;
  4206. this.sync = false;
  4207. this.antiBull = 0;
  4208. this.bullTimer = 0;
  4209. this.poisonTimer = 0;
  4210. this.active = true;
  4211. this.alive = true;
  4212. this.lockMove = false;
  4213. this.lockDir = false;
  4214. this.minimapCounter = 0;
  4215. this.chatCountdown = 0;
  4216. this.shameCount = 0;
  4217. this.shameTimer = 0;
  4218. this.sentTo = {};
  4219. this.gathering = 0;
  4220. this.gatherIndex = 0;
  4221. this.shooting = {};
  4222. this.shootIndex = 9;
  4223. this.autoGather = 0;
  4224. this.animTime = 0;
  4225. this.animSpeed = 0;
  4226. this.mouseState = 0;
  4227. this.buildIndex = -1;
  4228. this.weaponIndex = 0;
  4229. this.weaponCode = 0;
  4230. this.weaponVariant = 0;
  4231. this.primaryIndex = undefined;
  4232. this.secondaryIndex = undefined;
  4233. this.dmgOverTime = {};
  4234. this.noMovTimer = 0;
  4235. this.maxXP = 300;
  4236. this.XP = 0;
  4237. this.age = 1;
  4238. this.kills = 0;
  4239. this.upgrAge = 2;
  4240. this.upgradePoints = 0;
  4241. this.x = 0;
  4242. this.y = 0;
  4243. this.oldXY = {
  4244. x: 0,
  4245. y: 0
  4246. };
  4247. this.zIndex = 0;
  4248. this.xVel = 0;
  4249. this.yVel = 0;
  4250. this.slowMult = 1;
  4251. this.dir = 0;
  4252. this.dirPlus = 0;
  4253. this.targetDir = 0;
  4254. this.targetAngle = 0;
  4255. this.maxHealth = 100;
  4256. this.health = this.maxHealth;
  4257. this.oldHealth = this.maxHealth;
  4258. this.damaged = 0;
  4259. this.scale = config.playerScale;
  4260. this.speed = config.playerSpeed;
  4261. this.resetMoveDir();
  4262. this.resetResources(moofoll);
  4263. this.items = [0, 3, 6, 10];
  4264. this.weapons = [0];
  4265. this.shootCount = 0;
  4266. this.weaponXP = [];
  4267. this.reloads = {
  4268. 0: 0,
  4269. 1: 0,
  4270. 2: 0,
  4271. 3: 0,
  4272. 4: 0,
  4273. 5: 0,
  4274. 6: 0,
  4275. 7: 0,
  4276. 8: 0,
  4277. 9: 0,
  4278. 10: 0,
  4279. 11: 0,
  4280. 12: 0,
  4281. 13: 0,
  4282. 14: 0,
  4283. 15: 0,
  4284. 53: 0,
  4285. };
  4286. this.bowThreat = {
  4287. 9: 0,
  4288. 12: 0,
  4289. 13: 0,
  4290. 15: 0,
  4291. };
  4292. this.damageThreat = 0;
  4293. this.inTrap = false;
  4294. this.canEmpAnti = false;
  4295. this.empAnti = false;
  4296. this.soldierAnti = false;
  4297. this.poisonTick = 0;
  4298. this.bullTick = 0;
  4299. this.setPoisonTick = false;
  4300. this.setBullTick = false;
  4301. this.antiTimer = 2;
  4302. };
  4303.  
  4304. // RESET MOVE DIR:
  4305. this.resetMoveDir = function() {
  4306. this.moveDir = undefined;
  4307. };
  4308.  
  4309. // RESET RESOURCES:
  4310. this.resetResources = function(moofoll) {
  4311. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4312. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4313. }
  4314. };
  4315.  
  4316. // ADD ITEM:
  4317. this.getItemType = function(id) {
  4318. let findindx = this.items.findIndex((ids) => ids == id);
  4319. if (findindx != -1) {
  4320. return findindx;
  4321. } else {
  4322. return items.checkItem.index(id, this.items);
  4323. }
  4324. };
  4325.  
  4326. // SET DATA:
  4327. this.setData = function(data) {
  4328. this.id = data[0];
  4329. this.sid = data[1];
  4330. this.name = data[2];
  4331. this.x = data[3];
  4332. this.y = data[4];
  4333. this.dir = data[5];
  4334. this.health = data[6];
  4335. this.maxHealth = data[7];
  4336. this.scale = data[8];
  4337. this.skinColor = data[9];
  4338. };
  4339.  
  4340. // UPDATE POISON TICK:
  4341. this.updateTimer = function() {
  4342.  
  4343. this.bullTimer -= 1;
  4344. if (this.bullTimer <= 0) {
  4345. this.setBullTick = false;
  4346. this.bullTick = game.tick - 1;
  4347. this.bullTimer = config.serverUpdateRate;
  4348. }
  4349. this.poisonTimer -= 1;
  4350. if (this.poisonTimer <= 0) {
  4351. this.setPoisonTick = false;
  4352. this.poisonTick = game.tick - 1;
  4353. this.poisonTimer = config.serverUpdateRate;
  4354. }
  4355.  
  4356. };
  4357. this.update = function(delta) {
  4358. if (this.active) {
  4359.  
  4360. // MOVE:
  4361. let gear = {
  4362. skin: findID(hats, this.skinIndex),
  4363. tail: findID(accessories, this.tailIndex)
  4364. }
  4365. let spdMult = ((this.buildIndex >= 0) ? 0.5 : 1) * (items.weapons[this.weaponIndex].spdMult || 1) * (gear.skin ? (gear.skin.spdMult || 1) : 1) * (gear.tail ? (gear.tail.spdMult || 1) : 1) * (this.y <= config.snowBiomeTop ? ((gear.skin && gear.skin.coldM) ? 1 : config.snowSpeed) : 1) * this.slowMult;
  4366. this.maxSpeed = spdMult;
  4367.  
  4368. }
  4369. };
  4370.  
  4371. let tmpRatio = 0;
  4372. let animIndex = 0;
  4373. this.animate = function(delta) {
  4374. if (this.animTime > 0) {
  4375. this.animTime -= delta;
  4376. if (this.animTime <= 0) {
  4377. this.animTime = 0;
  4378. this.dirPlus = 0;
  4379. tmpRatio = 0;
  4380. animIndex = 0;
  4381. } else {
  4382. if (animIndex == 0) {
  4383. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4384. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4385. if (tmpRatio >= 1) {
  4386. tmpRatio = 1;
  4387. animIndex = 1;
  4388. }
  4389. } else {
  4390. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4391. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4392. }
  4393. }
  4394. }
  4395. };
  4396.  
  4397. // GATHER ANIMATION:
  4398. this.startAnim = function(didHit, index) {
  4399. this.animTime = this.animSpeed = items.weapons[index].speed;
  4400. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4401. tmpRatio = 0;
  4402. animIndex = 0;
  4403. };
  4404.  
  4405. // CAN SEE:
  4406. this.canSee = function(other) {
  4407. if (!other) return false;
  4408. let dx = Math.abs(other.x - this.x) - other.scale;
  4409. let dy = Math.abs(other.y - this.y) - other.scale;
  4410. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4411. };
  4412.  
  4413. // SHAME SYSTEM:
  4414. this.judgeShame = function() {
  4415. if (this.oldHealth < this.health) {
  4416. if (this.hitTime) {
  4417. let timeSinceHit = game.tick - this.hitTime;
  4418. this.lastHit = game.tick;
  4419. this.hitTime = 0;
  4420. if (timeSinceHit < 2) {
  4421. this.shameCount++;
  4422. } else {
  4423. this.shameCount = Math.max(0, this.shameCount - 2);
  4424. }
  4425. }
  4426. } else if (this.oldHealth > this.health) {
  4427. this.hitTime = game.tick;
  4428. }
  4429. };
  4430. this.addShameTimer = function() {
  4431. this.shameCount = 0;
  4432. this.shameTimer = 30;
  4433. let interval = setInterval(() => {
  4434. this.shameTimer--;
  4435. if (this.shameTimer <= 0) {
  4436. clearInterval(interval);
  4437. }
  4438. }, 1000);
  4439. };
  4440.  
  4441. // CHECK TEAM:
  4442. this.isTeam = function(tmpObj) {
  4443. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4444. };
  4445.  
  4446. // FOR THE PLAYER:
  4447. this.findAllianceBySid = function(sid) {
  4448. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4449. };
  4450. this.checkCanInsta = function(nobull) {
  4451. let totally = 0;
  4452. if (this.alive && inGame) {
  4453. let primary = {
  4454. weapon: this.weapons[0],
  4455. variant: this.primaryVariant,
  4456. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4457. };
  4458. let secondary = {
  4459. weapon: this.weapons[1],
  4460. variant: this.secondaryVariant,
  4461. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4462. };
  4463. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4464. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4465. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4466. totally += primary.dmg * pV * bull;
  4467. }
  4468. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4469. totally += secondary.dmg;
  4470. }
  4471. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4472. totally += 25;
  4473. }
  4474. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4475. return totally;
  4476. }
  4477. return 0;
  4478. };
  4479.  
  4480. // UPDATE WEAPON RELOAD:
  4481. this.manageReload = function() {
  4482. if (this.shooting[53]) {
  4483. this.shooting[53] = 0;
  4484. this.reloads[53] = (2500 - game.tickRate);
  4485. } else {
  4486. if (this.reloads[53] > 0) {
  4487. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4488. }
  4489. }
  4490.  
  4491. // PREPLACER
  4492. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4493. // place(2, getAttackDir());
  4494. let index = this.weaponIndex;
  4495. let nearObja = liztobj.filter((e) => (e.active || e.alive) && e.health < e.maxHealth && e.group !== undefined && UTILS.getDist(e, player, 0, 2) <= (items.weapons[player.weaponIndex].range + e.scale));
  4496. for(let i = 0; i < nearObja.length; i++) {
  4497. let aaa = nearObja[i];
  4498.  
  4499. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4500. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4501. if(aaa.health - (valaa) <= 0 && near.length) {
  4502. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4503. console.log("preplaced");
  4504. }
  4505. }
  4506. }
  4507.  
  4508. if (this.gathering || this.shooting[1]) {
  4509. if (this.gathering) {
  4510. this.gathering = 0;
  4511. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4512. this.attacked = true;
  4513. }
  4514. if (this.shooting[1]) {
  4515. this.shooting[1] = 0;
  4516. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4517. this.attacked = true;
  4518. }
  4519. } else {
  4520. this.attacked = false;
  4521. if (this.buildIndex < 0) {
  4522. if (this.reloads[this.weaponIndex] > 0) {
  4523. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4524. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4525. if (this == player) {
  4526. if (getEl("weaponGrind").checked) {
  4527. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4528. checkPlace(player.getItemType(22), i);
  4529. }
  4530. }
  4531. }
  4532. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4533. this.antiBull++;
  4534. game.tickBase(() => {
  4535. this.antiBull = 0;
  4536. }, 1);
  4537. }
  4538. }
  4539. }
  4540. }
  4541. };
  4542.  
  4543. // FOR ANTI INSTA:
  4544. this.addDamageThreat = function(tmpObj) {
  4545. let primary = {
  4546. weapon: this.primaryIndex,
  4547. variant: this.primaryVariant
  4548. };
  4549. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4550. let secondary = {
  4551. weapon: this.secondaryIndex,
  4552. variant: this.secondaryVariant
  4553. };
  4554. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4555. let bull = 1.5;
  4556. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4557. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4558. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4559. this.damageThreat += primary.dmg * pV * bull;
  4560. }
  4561. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4562. this.damageThreat += secondary.dmg * sV;
  4563. }
  4564. if (this.reloads[53] <= game.tickRate) {
  4565. this.damageThreat += 25;
  4566. }
  4567. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4568. if (!this.isTeam(tmpObj)) {
  4569. if (this.dist2 <= 300) {
  4570. tmpObj.damageThreat += this.damageThreat;
  4571. }
  4572. }
  4573. };
  4574.  
  4575. }
  4576. };
  4577.  
  4578. // SOME CODES:
  4579. function sendUpgrade(index) {
  4580. player.reloads[index] = 0;
  4581. packet("H", index);
  4582. }
  4583.  
  4584. function storeEquip(id, index) {
  4585. packet("c", 0, id, index);
  4586. }
  4587.  
  4588. function storeBuy(id, index) {
  4589. packet("c", 1, id, index);
  4590. }
  4591.  
  4592. function buyEquip(id, index) {
  4593. let nID = player.skins[6] ? 6 : 0;
  4594. if (player.alive && inGame) {
  4595. if (index == 0) {
  4596. if (player.skins[id]) {
  4597. if (player.latestSkin != id) {
  4598. packet("c", 0, id, 0);
  4599. }
  4600. } else {
  4601. if (configs.autoBuyEquip) {
  4602. let find = findID(hats, id);
  4603. if (find) {
  4604. if (player.points >= find.price) {
  4605. packet("c", 1, id, 0);
  4606. packet("c", 0, id, 0);
  4607. } else {
  4608. if (player.latestSkin != nID) {
  4609. packet("c", 0, nID, 0);
  4610. }
  4611. }
  4612. } else {
  4613. if (player.latestSkin != nID) {
  4614. packet("c", 0, nID, 0);
  4615. }
  4616. }
  4617. } else {
  4618. if (player.latestSkin != nID) {
  4619. packet("c", 0, nID, 0);
  4620. }
  4621. }
  4622. }
  4623. } else if (index == 1) {
  4624. if (useWasd && (id != 11 && id != 0)) {
  4625. if (player.latestTail != 0) {
  4626. packet("c", 0, 0, 1);
  4627. }
  4628. return;
  4629. }
  4630. if (player.tails[id]) {
  4631. if (player.latestTail != id) {
  4632. packet("c", 0, id, 1);
  4633. }
  4634. } else {
  4635. if (configs.autoBuyEquip) {
  4636. let find = findID(accessories, id);
  4637. if (find) {
  4638. if (player.points >= find.price) {
  4639. packet("c", 1, id, 1);
  4640. packet("c", 0, id, 1);
  4641. } else {
  4642. if (player.latestTail != 0) {
  4643. packet("c", 0, 0, 1);
  4644. }
  4645. }
  4646. } else {
  4647. if (player.latestTail != 0) {
  4648. packet("c", 0, 0, 1);
  4649. }
  4650. }
  4651. } else {
  4652. if (player.latestTail != 0) {
  4653. packet("c", 0, 0, 1);
  4654. }
  4655. }
  4656. }
  4657. }
  4658. }
  4659. }
  4660.  
  4661. function selectToBuild(index, wpn) {
  4662. packet("z", index, wpn);
  4663. }
  4664.  
  4665. function selectWeapon(index, isPlace) {
  4666. if (!isPlace) {
  4667. player.weaponCode = index;
  4668. }
  4669. packet("z", index, 1);
  4670. }
  4671.  
  4672. function sendAutoGather() {
  4673. packet("K", 1, 1);
  4674. }
  4675.  
  4676. function sendAtck(id, angle) {
  4677. packet("F", id, angle, 1);
  4678. }
  4679.  
  4680. // PLACER:
  4681. function place(id, rad, rmd) {
  4682. try {
  4683. if (id == undefined) return;
  4684. let item = items.list[player.items[id]];
  4685. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4686. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4687. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4688. if ((player.alive && inGame && player.itemCounts[item.group.id] == undefined ? true : player.itemCounts[item.group.id] < (config.isSandbox ? 299 : item.group.limit ? item.group.limit : 99))) {
  4689. selectToBuild(player.items[id]);
  4690. sendAtck(1, rad);
  4691. selectWeapon(player.weaponCode, 1);
  4692. if (rmd && getEl("placeVis").checked) {
  4693. placeVisible.push({
  4694. x: tmpX,
  4695. y: tmpY,
  4696. name: item.name,
  4697. scale: item.scale,
  4698. dir: rad
  4699. });
  4700. game.tickBase(() => {
  4701. placeVisible.shift();
  4702. }, 1)
  4703. }
  4704. }
  4705. } catch (e) {}
  4706. }
  4707.  
  4708. function checkPlace(id, rad) {
  4709. try {
  4710. if (secPacket >= 60) return;
  4711. if (id == undefined) return;
  4712. let item = items.list[player.items[id]];
  4713. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4714. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4715. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4716. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4717. place(id, rad, 1);
  4718. }
  4719. } catch (e) {}
  4720. }
  4721.  
  4722. // HEALING:
  4723. function soldierMult() {
  4724. return player.latestSkin == 6 ? 0.75 : 1;
  4725. }
  4726.  
  4727. function healthBased() {
  4728. if (player.health == 100)
  4729. return 0;
  4730. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4731. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4732. }
  4733. return 0;
  4734. }
  4735.  
  4736. function getAttacker(damaged) {
  4737. let attackers = enemy.filter(tmp => {
  4738. //let damages = new Damages(items);
  4739. //let dmg = damages.weapons[tmp.weaponIndex];
  4740. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4741. let rule = {
  4742. //one: tmp.dist2 <= 300,
  4743. //two: by.includes(damaged),
  4744. three: tmp.attacked
  4745. }
  4746. return /*rule.one && rule.two && */ rule.three;
  4747. });
  4748. return attackers;
  4749. }
  4750.  
  4751. function healer() {
  4752. for (let i = 0; i < healthBased(); i++) {
  4753. place(0, getAttackDir());
  4754. }
  4755. }
  4756.  
  4757. function antiSyncHealing(timearg) {
  4758. my.antiSync = true;
  4759. sendChat("Fuck you syncer. Kill yourself");
  4760. let healAnti = setInterval(() => {
  4761. if (player.shameCount < 5) {
  4762. place(0, getAttackDir());
  4763. }
  4764. }, 75);
  4765. setTimeout(() => {
  4766. clearInterval(healAnti);
  4767. setTimeout(() => {
  4768. my.antiSync = false;
  4769. }, game.tickRate);
  4770. }, game.tickRate);
  4771. }
  4772. function applCxC(value) {
  4773. if (player.health == 100)
  4774. return 0;
  4775. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4776. return Math.ceil(value / items.list[player.items[0]].healing);
  4777. }
  4778. return 0;
  4779. }
  4780. function calcDmg(value) {
  4781. return value * player.skinIndex == 6 ? 0.75 : 1;
  4782. }
  4783. function biomeGear(mover, returns) {
  4784. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4785. if (returns) return 31;
  4786. buyEquip(31, 0);
  4787. } else {
  4788. if (player.y2 <= config.snowBiomeTop) {
  4789. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4790. buyEquip(mover && player.moveDir == undefined ? 6 : 15, 0);
  4791. } else {
  4792. if (returns) return mover && player.moveDir == undefined ? 22 : 6;
  4793. buyEquip(mover && player.moveDir == undefined ? 6 : 12, 0);
  4794. }
  4795. }
  4796. if (returns) return 0;
  4797. }
  4798. let advHeal = [];
  4799.  
  4800. class Traps {
  4801. constructor(UTILS, items) {
  4802. this.dist = 0;
  4803. this.aim = 0;
  4804. this.inTrap = false;
  4805. this.replaced = false;
  4806. this.antiTrapped = false;
  4807. this.info = {};
  4808. this.notFast = function() {
  4809. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4810. }
  4811. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4812. try {
  4813. let item = items.list[player.items[id]];
  4814. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4815. let counts = {
  4816. attempts: 0,
  4817. placed: 0
  4818. };
  4819. let tmpObjects = [];
  4820. gameObjects.forEach((p) => {
  4821. tmpObjects.push({
  4822. x: p.x,
  4823. y: p.y,
  4824. active: p.active,
  4825. blocker: p.blocker,
  4826. scale: p.scale,
  4827. isItem: p.isItem,
  4828. type: p.type,
  4829. colDiv: p.colDiv,
  4830. getScale: function(sM, ig) {
  4831. sM = sM || 1;
  4832. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4833. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4834. },
  4835. });
  4836. });
  4837. for (let i = first; i < repeat; i += plus) {
  4838. counts.attempts++;
  4839. let relAim = radian + i;
  4840. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4841. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4842. let cantPlace = tmpObjects.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  4843. if (cantPlace) continue;
  4844. if (item.id != 19 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4845. if ((!replacer && yaboi) || useWasd) {
  4846. if (useWasd ? false : yaboi.inTrap) {
  4847. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI) {
  4848. place(2, relAim, 1);
  4849. } else {
  4850. player.items[4] == 15 && place(4, relAim, 1);
  4851. }
  4852. } else {
  4853. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 1.5) {
  4854. place(2, relAim, 1);
  4855. } else {
  4856. player.items[4] == 15 && place(4, relAim, 1);
  4857. }
  4858. }
  4859. } else {
  4860. place(id, relAim, 1);
  4861. }
  4862. tmpObjects.push({
  4863. x: tmpX,
  4864. y: tmpY,
  4865. active: true,
  4866. blocker: item.blocker,
  4867. scale: item.scale,
  4868. isItem: true,
  4869. type: null,
  4870. colDiv: item.colDiv,
  4871. getScale: function() {
  4872. return this.scale;
  4873. },
  4874. });
  4875. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4876. counts.placed++;
  4877. }
  4878. }
  4879. if (counts.placed > 0 && replacer && item.dmg) {
  4880. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4881. instaC.canSpikeTick = true;
  4882. }
  4883. }
  4884. } catch (err) {
  4885. }
  4886. };
  4887.  
  4888. this.checkSpikeTick = function() {
  4889. try {
  4890. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4891. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4892. // more range for safe. also testing near.primaryIndex || 5
  4893. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4894. let item = items.list[9];
  4895. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4896. let danger = 0;
  4897. let counts = {
  4898. attempts: 0,
  4899. block: `unblocked`
  4900. };
  4901. for (let i = -1; i <= 1; i += 1 / 10) {
  4902. counts.attempts++;
  4903. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4904. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4905. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4906. let cantPlace = gameObjects.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  4907. if (cantPlace) continue;
  4908. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4909. danger++;
  4910. counts.block = `blocked`;
  4911. break;
  4912. }
  4913. if (danger) {
  4914. my.anti0Tick = 1;
  4915. player.chat.count = 100000;
  4916. return true;
  4917. }
  4918. }
  4919. } catch (err) {
  4920. return null;
  4921. }
  4922. return false;
  4923. }
  4924. this.protect = function(aim) {
  4925. if (!configs.antiTrap) return;
  4926. if (player.items[4]) {
  4927. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4928. this.antiTrapped = true;
  4929. }
  4930. };
  4931. function predictEnemyPosition(enemyPositions, time = 1) {
  4932. const lastKnownPosition = enemyPositions[enemyPositions.length - 1];
  4933.  
  4934. const predictedPosition = {
  4935. x: lastKnownPosition.x + lastKnownPosition.xVel * time,
  4936. y: lastKnownPosition.y + lastKnownPosition.yVel * time
  4937. };
  4938.  
  4939. return predictedPosition;
  4940. }
  4941. /*this.autoPlace = function() {
  4942. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4943. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4944. if (gameObjects.length) {
  4945. let near2 = {
  4946. inTrap: false,
  4947. };
  4948. let nearTrap = gameObjects.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function(a, b) {
  4949. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4950. })[0];
  4951. if (nearTrap) {
  4952. near2.inTrap = true;
  4953. } else {
  4954. near2.inTrap = false;
  4955. }
  4956. if ((near.dist3 <= 450)) {
  4957. if (near.dist3 <= 200) {
  4958. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  4959. inTrap: near2.inTrap
  4960. });
  4961. } else {
  4962. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4963. }
  4964. }
  4965. } else {
  4966. if ((near.dist3 <= 450)) {
  4967. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4968. }
  4969. }
  4970. }
  4971. }
  4972. };*/
  4973. this.autoPlace = function () {
  4974. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4975. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value))||1) === 0) {
  4976. if (gameObjects.length) {
  4977. let near2 = {
  4978. inTrap: false,
  4979. };
  4980. let nearTrap = gameObjects.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function (a, b) {
  4981. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4982. })[0];
  4983. if (nearTrap) {
  4984. near2.inTrap = true;
  4985. } else {
  4986. near2.inTrap = false;
  4987. }
  4988. if ((near.dist2 <= 275)) {
  4989. if (near.dist2 <= 275) {
  4990. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  4991. } else {
  4992. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4993. }
  4994. }
  4995. } else {
  4996. if ((near.dist2 <= 1000)) {
  4997. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4998. }
  4999. }
  5000. }
  5001. }
  5002. };
  5003. this.replacer = function (findObj) {
  5004. if (!findObj || !configs.autoReplace) return;
  5005. if (!inGame) return;
  5006. if (this.antiTrapped) return;
  5007. game.tickBase(() => {
  5008. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5009. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5010. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5011. if (objDst <= 300 && near.dist2 <= 300) {
  5012. let danger = this.checkSpikeTick();
  5013. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5014. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5015. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5016. } else {
  5017. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5018. }
  5019. this.replaced = true;
  5020. }
  5021. }, 1);
  5022. };
  5023. }
  5024. };
  5025. this.replacer = function(findObj) {
  5026. if (!findObj || !configs.autoReplace) return;
  5027. if (!inGame) return;
  5028. if (this.antiTrapped) return;
  5029.  
  5030. game.tickBase(() => {
  5031. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5032. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5033.  
  5034. let perfectAngle = calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y);
  5035.  
  5036. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5037.  
  5038. if (objDst <= 300 && near.dist2 <= 300) {
  5039. if (isObjectBroken(findObj)) {
  5040. let danger = this.checkSpikeTick();
  5041. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5042. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5043. } else {
  5044. if (player.items[4] == 15) {
  5045. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5046. }
  5047. }
  5048. this.replaced = true;
  5049. }
  5050. }
  5051. }, 1);
  5052. }
  5053.  
  5054.  
  5055. function calculatePerfectAngle(x1, y1, x2, y2) {
  5056. return Math.atan2(y2 - y1, x2 - x1);
  5057. }
  5058. function isObjectBroken(object) {
  5059. const healthThreshold = 20;
  5060. return object.health < healthThreshold;
  5061. }
  5062.  
  5063. /*this.replacer = function (findObj) {
  5064. if (!findObj || !configs.autoReplace) return;
  5065. if (!inGame) return;
  5066. if (this.antiTrapped) return;
  5067. game.tickBase(() => {
  5068. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5069. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5070. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5071. if (objDst <= 400 && near.dist2 <= 400) {
  5072. let danger = this.checkSpikeTick();
  5073. if (!danger && near.dist2 <= items.weapons[near.primaryIndex + 5].range + (near.scale * 1.8)) {
  5074. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5075. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5076. } else {
  5077. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5078. }
  5079. this.replaced = true;
  5080. }
  5081. }, 1);
  5082. };
  5083. }
  5084. }*/
  5085. class Instakill {
  5086. constructor() {
  5087. let inantiantibull = false
  5088. this.wait = false;
  5089. this.can = false;
  5090. this.isTrue = false;
  5091. this.nobull = false;
  5092. this.ticking = false;
  5093. this.canSpikeTick = false;
  5094. this.startTick = false;
  5095. this.readyTick = false;
  5096. this.canCounter = false;
  5097. this.revTick = false;
  5098. this.syncHit = false;
  5099. this.age1insta = false;
  5100. this.changeType = function(type) {
  5101. this.wait = false;
  5102. this.isTrue = true;
  5103. my.autoAim = true;
  5104. let instaLog = [type];
  5105. let backupNobull = near.backupNobull;
  5106. near.backupNobull = false;
  5107. game.tickBase(() => {
  5108. instaLog.push(player.skinIndex);
  5109. game.tickBase(() => {
  5110. if (near.skinIndex == 22 && getEl("backupNobull").checked) {
  5111. near.backupNobull = true;
  5112. }
  5113. instaLog.push(player.skinIndex);
  5114. }, 1);
  5115. }, 1);
  5116. if (type == "rev") {
  5117. selectWeapon(player.weapons[1]);
  5118. buyEquip(53, 0);
  5119. buyEquip(21, 1);
  5120. sendAutoGather();
  5121. game.tickBase(() => {
  5122. selectWeapon(player.weapons[0]);
  5123. buyEquip(7, 0);
  5124. buyEquip(21, 1);
  5125. game.tickBase(() => {
  5126. sendAutoGather();
  5127. this.isTrue = false;
  5128. my.autoAim = false;
  5129. }, 1);
  5130. }, 1);
  5131. } else if (type == "nobull") {
  5132. selectWeapon(player.weapons[0]);
  5133. if (getEl("backupNobull").checked && backupNobull) {
  5134. buyEquip(7, 0);
  5135. } else {
  5136. buyEquip(6, 0);
  5137. }
  5138. buyEquip(21, 1);
  5139. sendAutoGather();
  5140. game.tickBase(() => {
  5141. if (near.skinIndex == 22) {
  5142. if (getEl("backupNobull").checked) {
  5143. near.backupNobull = true;
  5144. }
  5145. buyEquip(21, 0);
  5146. } else {
  5147. buyEquip(53, 0);
  5148. }
  5149. selectWeapon(player.weapons[1]);
  5150. buyEquip(21, 1);
  5151. game.tickBase(() => {
  5152. sendAutoGather();
  5153. this.isTrue = false;
  5154. my.autoAim = false;
  5155. }, 1);
  5156. }, 1);
  5157. } else if (type == "normal") {
  5158. selectWeapon(player.weapons[0]);
  5159. buyEquip(7, 0);
  5160. buyEquip(21, 1);
  5161. sendAutoGather();
  5162. game.tickBase(() => {
  5163. selectWeapon(player.weapons[1]);
  5164. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5165. buyEquip(21, 1);
  5166. game.tickBase(() => {
  5167. sendAutoGather();
  5168. this.isTrue = false;
  5169. my.autoAim = false;
  5170. }, 1);
  5171. }, 1);
  5172. } else {
  5173. setTimeout(() => {
  5174. this.isTrue = false;
  5175. my.autoAim = false;
  5176. }, 50);
  5177. }
  5178. };
  5179. this.spikeTickType = function() {
  5180. this.isTrue = true;
  5181. my.autoAim = true;
  5182. selectWeapon(player.weapons[0]);
  5183. buyEquip(7, 0);
  5184. buyEquip(21, 1);
  5185. sendAutoGather();
  5186. game.tickBase(() => {
  5187. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5188. buyEquip(53, 0);
  5189. buyEquip(21, 1);
  5190. selectWeapon(player.weapons[0]);
  5191. game.tickBase(() => {
  5192. sendAutoGather();
  5193. this.isTrue = false;
  5194. my.autoAim = false;
  5195. }, 1);
  5196. }, 1);
  5197. };
  5198. this.syncTry = function() {
  5199. io.send("6", "Fire");
  5200. if (player.weapons[1] == 15) {
  5201. this.isTrue = true;
  5202. my.autoAim = true;
  5203. game.tickBase(() => {
  5204. instaC.isTrue = true;
  5205. selectWeapon(player.weapons[1]);
  5206. buyEquip(53, 0);
  5207. buyEquip(19, 1);
  5208. sendAutoGather();
  5209. game.tickBase(() => {
  5210. my.autoAim = false;
  5211. instaC.isTrue = false;
  5212. this.isTrue = false;
  5213. sendAutoGather();
  5214. }, 1);
  5215. }, 1);
  5216. } else if (player.weapons[1] == 13) {
  5217. this.isTrue = true;
  5218. my.autoAim = true;
  5219. game.tickBase(() => {
  5220. instaC.isTrue = true;
  5221. selectWeapon(player.weapons[1]);
  5222. buyEquip(53, 0);
  5223. buyEquip(19, 1);
  5224. sendAutoGather();
  5225. game.tickBase(() => {
  5226. my.autoAim = false;
  5227. instaC.isTrue = false;
  5228. this.isTrue = false;
  5229. sendAutoGather();
  5230. }, 1);
  5231. }, 1);
  5232. } else if (player.weapons[1] == 12) {
  5233. this.isTrue = true;
  5234. my.autoAim = true;
  5235. game.tickBase(() => {
  5236. instaC.isTrue = true;
  5237. selectWeapon(player.weapons[1]);
  5238. buyEquip(53, 0);
  5239. buyEquip(19, 1);
  5240. sendAutoGather();
  5241. game.tickBase(() => {
  5242. my.autoAim = false;
  5243. instaC.isTrue = false;
  5244. this.isTrue = false;
  5245. sendAutoGather();
  5246. }, 1);
  5247. }, 1);
  5248. } else if (player.weapons[1] == 9) {
  5249. this.isTrue = true;
  5250. my.autoAim = true;
  5251. game.tickBase(() => {
  5252. instaC.isTrue = true;
  5253. selectWeapon(player.weapons[1]);
  5254. buyEquip(53, 0);
  5255. buyEquip(19, 1);
  5256. sendAutoGather();
  5257. game.tickBase(() => {
  5258. my.autoAim = false;
  5259. instaC.isTrue = false;
  5260. this.isTrue = false;
  5261. sendAutoGather();
  5262. }, 1);
  5263. }, 1);
  5264. }
  5265. };
  5266. /* this.spikeTickType = function() {
  5267. this.isTrue = true;
  5268. my.autoAim = true;
  5269. selectWeapon(player.weapons[0]);
  5270. buyEquip(7, 0);
  5271. buyEquip(21, 1);
  5272. sendAutoGather();
  5273. game.tickBase(() => {
  5274. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5275. selectWeapon(player.weapons[0]);
  5276. buyEquip(53, 0);
  5277. buyEquip(21, 1);
  5278. game.tickBase(() => {
  5279. sendAutoGather();
  5280. this.isTrue = false;
  5281. my.autoAim = false;
  5282. }, 1);
  5283. } else {
  5284. sendAutoGather();
  5285. this.isTrue = false;
  5286. my.autoAim = false;
  5287. }
  5288. }, 1);
  5289. };*/
  5290. this.counterType = function() {
  5291. this.isTrue = true;
  5292. my.autoAim = true;
  5293. selectWeapon(player.weapons[0]);
  5294. buyEquip(7, 0);
  5295. buyEquip(21, 1);
  5296. sendAutoGather();
  5297. game.tickBase(() => {
  5298. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5299. selectWeapon(player.weapons[0]);
  5300. buyEquip(53, 0);
  5301. buyEquip(21, 1);
  5302. game.tickBase(() => {
  5303. sendAutoGather();
  5304. this.isTrue = false;
  5305. my.autoAim = false;
  5306. }, 1);
  5307. game.tickBase(() => {
  5308. my.autoAim = false;
  5309. instaC.isTrue = false;
  5310. this.isTrue = false;
  5311. sendAutoGather();
  5312. }, 1);
  5313. }, 1);
  5314. };
  5315. this.antiCounterType = function() {
  5316. my.autoAim = true;
  5317. this.isTrue = true;
  5318. inantiantibull = true;
  5319. selectWeapon(player.weapons[0]);
  5320. buyEquip(6, 0);
  5321. buyEquip(21, 1);
  5322. io.send("D", near.aim2);
  5323. sendAutoGather();
  5324. game.tickBase(() => {
  5325. buyEquip(player.reloads[53] == 0 ? player.skins[53] ? 53 : 6 : 6, 0);
  5326. buyEquip(21, 1);
  5327. game.tickBase(() => {
  5328. sendAutoGather();
  5329. this.isTrue = false;
  5330. my.autoAim = false;
  5331. inantiantibull = false;
  5332. }, 1);
  5333. }, 1)
  5334. };
  5335. this.rangeType = function(type) {
  5336. this.isTrue = true;
  5337. my.autoAim = true;
  5338. if (type == "ageInsta") {
  5339. my.ageInsta = false;
  5340. if (player.items[5] == 18) {
  5341. place(5, near.aim2);
  5342. }
  5343. packet("f", undefined, 1);
  5344. buyEquip(22, 0);
  5345. buyEquip(21, 1);
  5346. game.tickBase(() => {
  5347. selectWeapon(player.weapons[1]);
  5348. buyEquip(53, 0);
  5349. buyEquip(21, 1);
  5350. sendAutoGather();
  5351. game.tickBase(() => {
  5352. sendUpgrade(12);
  5353. selectWeapon(player.weapons[1]);
  5354. buyEquip(53, 0);
  5355. buyEquip(21, 1);
  5356. game.tickBase(() => {
  5357. sendUpgrade(15);
  5358. selectWeapon(player.weapons[1]);
  5359. buyEquip(53, 0);
  5360. buyEquip(21, 1);
  5361. game.tickBase(() => {
  5362. sendAutoGather();
  5363. this.isTrue = false;
  5364. my.autoAim = false;
  5365. }, 1);
  5366. }, 1);
  5367. }, 1);
  5368. }, 1);
  5369. } else {
  5370. selectWeapon(player.weapons[1]);
  5371. if (player.reloads[53] == 0 && near.dist2 <= 1000 && near.skinIndex != 22) {
  5372. buyEquip(53, 0);
  5373. } else {
  5374. buyEquip(20, 0);
  5375. }
  5376. buyEquip(11, 1);
  5377. sendAutoGather();
  5378. game.tickBase(() => {
  5379. sendAutoGather();
  5380. this.isTrue = false;
  5381. my.autoAim = false;
  5382. }, 1);
  5383. }
  5384. };
  5385. this.oneTickType = function() {
  5386. io.send("One-Ticked");
  5387. this.isTrue = true;
  5388. my.autoAim = true;
  5389. selectWeapon(player.weapons[1]);
  5390. buyEquip(53, 0);
  5391. buyEquip(19, 1);
  5392. packet("f", near.aim2, 1);
  5393. if (player.weapons[1] == 15) {
  5394. sendAutoGather();
  5395. }
  5396. game.tickBase(() => {
  5397. selectWeapon(player.weapons[0]);
  5398. buyEquip(7, 0);
  5399. buyEquip(19, 1);
  5400. packet("f", near.aim2, 1);
  5401. if (player.weapons[1] != 15) {
  5402. sendAutoGather();
  5403. }
  5404. game.tickBase(() => {
  5405. sendAutoGather();
  5406. this.isTrue = false;
  5407. my.autoAim = false;
  5408. packet("f", undefined, 1);
  5409. }, 1);
  5410. }, 1);
  5411. };
  5412. this.threeOneTickType = function() {
  5413. io.send("Tick2");
  5414. this.isTrue = true;
  5415. my.autoAim = true;
  5416. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5417. biomeGear();
  5418. buyEquip(19, 1);
  5419. packet("f", near.aim2, 1);
  5420. game.tickBase(() => {
  5421. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5422. buyEquip(53, 0);
  5423. buyEquip(19, 1);
  5424. packet("f", near.aim2, 1);
  5425. game.tickBase(() => {
  5426. selectWeapon(player.weapons[0]);
  5427. buyEquip(7, 0);
  5428. buyEquip(19, 1);
  5429. sendAutoGather();
  5430. packet("f", near.aim2, 1);
  5431. game.tickBase(() => {
  5432. sendAutoGather();
  5433. this.isTrue = false;
  5434. my.autoAim = false;
  5435. packet("f", undefined, 1);
  5436. }, 1);
  5437. }, 1);
  5438. }, 1);
  5439. };
  5440. this.kmTickType = function() {
  5441. this.isTrue = true;
  5442. my.autoAim = true;
  5443. selectWeapon(player.weapons[1]);
  5444. buyEquip(53, 0);
  5445. buyEquip(19, 1);
  5446. sendAutoGather();
  5447. packet("f", near.aim2, 1);
  5448. game.tickBase(() => {
  5449. selectWeapon(player.weapons[0]);
  5450. buyEquip(7, 0);
  5451. buyEquip(19, 1);
  5452. packet("f", near.aim2, 1);
  5453. game.tickBase(() => {
  5454. sendAutoGather();
  5455. this.isTrue = false;
  5456. my.autoAim = false;
  5457. packet("f", undefined, 1);
  5458. }, 1);
  5459. }, 1);
  5460. };
  5461. this.boostTickType = function() {
  5462. /*this.isTrue = true;
  5463. my.autoAim = true;
  5464. selectWeapon(player.weapons[0]);
  5465. buyEquip(53, 0);
  5466. buyEquip(19, 1);
  5467. packet("f", near.aim2);
  5468. game.tickBase(() => {
  5469. place(4, near.aim2);
  5470. selectWeapon(player.weapons[1]);
  5471. biomeGear();
  5472. buyEquip(19, 1);
  5473. sendAutoGather();
  5474. packet("f", near.aim2);
  5475. game.tickBase(() => {
  5476. selectWeapon(player.weapons[0]);
  5477. buyEquip(7, 0);
  5478. buyEquip(19, 1);
  5479. packet("f", near.aim2);
  5480. game.tickBase(() => {
  5481. sendAutoGather();
  5482. this.isTrue = false;
  5483. my.autoAim = false;
  5484. packet("f", undefined);
  5485. }, 1);
  5486. }, 1);
  5487. }, 1);*/
  5488. this.isTrue = true;
  5489. my.autoAim = true;
  5490. biomeGear();
  5491. buyEquip(19, 1);
  5492. packet("f", near.aim2, 1);
  5493. game.tickBase(() => {
  5494. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5495. buyEquip(53, 0);
  5496. buyEquip(19, 1);
  5497. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5498. sendAutoGather();
  5499. }
  5500. packet("f", near.aim2, 1);
  5501. place(4, near.aim2);
  5502. game.tickBase(() => {
  5503. selectWeapon(player.weapons[0]);
  5504. buyEquip(7, 0);
  5505. buyEquip(19, 1);
  5506. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5507. sendAutoGather();
  5508. }
  5509. packet("f", near.aim2, 1);
  5510. game.tickBase(() => {
  5511. sendAutoGather();
  5512. this.isTrue = false;
  5513. my.autoAim = false;
  5514. packet("f", undefined, 1);
  5515. }, 1);
  5516. }, 1);
  5517. }, 1);
  5518. };
  5519. this.age1insta = function() {
  5520. if (player.weapons[0] == 0) {
  5521. this.isTrue = true;
  5522. my.autoAim = true;
  5523. selectWeapon(player.weapons[0]);
  5524. buyEquip(53, 0);
  5525. buyEquip(7, 0);
  5526. buyEquip(21, 1);
  5527. sendAutoGather();
  5528. game.tickBase(() => {
  5529. sendUpgrade(5);
  5530. selectWeapon(player.weapons[0]);
  5531. buyEquip(7, 0);
  5532. buyEquip(21, 1);
  5533. game.tickBase(() => {
  5534. sendAutoGather();
  5535. this.isTrue = false;
  5536. my.autoAim = false;
  5537. }, 1);
  5538. }, 1);
  5539. }
  5540. };
  5541. this.gotoGoal = function(goto, OT) {
  5542. let slowDists = (weeeee) => weeeee * config.playerScale;
  5543. let goal = {
  5544. a: goto - OT,
  5545. b: goto + OT,
  5546. c: goto - slowDists(1),
  5547. d: goto + slowDists(1),
  5548. e: goto - slowDists(2),
  5549. f: goto + slowDists(2),
  5550. g: goto - slowDists(4),
  5551. h: goto + slowDists(4)
  5552. };
  5553. let bQ = function(wwww, awwww) {
  5554. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5555. buyEquip(31, 0);
  5556. } else {
  5557. buyEquip(wwww, awwww);
  5558. }
  5559. }
  5560. if (enemy.length) {
  5561. let dst = near.dist2;
  5562. this.ticking = true;
  5563. if (dst >= goal.a && dst <= goal.b) {
  5564. bQ(6, 0);
  5565. bQ(19, 1);
  5566. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5567. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5568. }
  5569. return {
  5570. dir: undefined,
  5571. action: 1
  5572. };
  5573. } else {
  5574. if (dst < goal.a) {
  5575. if (dst >= goal.g) {
  5576. if (dst >= goal.e) {
  5577. if (dst >= goal.c) {
  5578. bQ(40, 0);
  5579. bQ(19, 1);
  5580. if (configs.none) {
  5581. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5582. } else {
  5583. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5584. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5585. }
  5586. }
  5587. } else {
  5588. bQ(22, 0);
  5589. bQ(19, 1);
  5590. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5591. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5592. }
  5593. }
  5594. } else {
  5595. bQ(6, 0);
  5596. bQ(19, 1);
  5597. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5598. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5599. }
  5600. }
  5601. } else {
  5602. biomeGear();
  5603. bQ(11, 1);
  5604. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5605. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5606. }
  5607. }
  5608. return {
  5609. dir: near.aim2 + Math.PI,
  5610. action: 0
  5611. };
  5612. } else if (dst > goal.b) {
  5613. if (dst <= goal.h) {
  5614. if (dst <= goal.f) {
  5615. if (dst <= goal.d) {
  5616. bQ(40, 0);
  5617. bQ(19, 1);
  5618. if (configs.none) {
  5619. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5620. } else {
  5621. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5622. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5623. }
  5624. }
  5625. } else {
  5626. bQ(22, 0);
  5627. bQ(19, 1);
  5628. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5629. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5630. }
  5631. }
  5632. } else {
  5633. bQ(6, 0);
  5634. bQ(19, 1);
  5635. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5636. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5637. }
  5638. }
  5639. } else {
  5640. biomeGear();
  5641. bQ(11, 1);
  5642. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5643. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5644. }
  5645. }
  5646. return {
  5647. dir: near.aim2,
  5648. action: 0
  5649. };
  5650. }
  5651. return {
  5652. dir: undefined,
  5653. action: 0
  5654. };
  5655. }
  5656. } else {
  5657. this.ticking = false;
  5658. return {
  5659. dir: undefined,
  5660. action: 0
  5661. };
  5662. }
  5663. },
  5664. /** wait 1 tick for better quality */
  5665. this.bowMovement = function() {
  5666. let moveMent = this.gotoGoal(685, 3);
  5667. if (moveMent.action) {
  5668. if (player.reloads[53] == 0 && !this.isTrue) {
  5669. this.rangeType("ageInsta");
  5670. } else {
  5671. packet("f", moveMent.dir, 1);
  5672. }
  5673. } else {
  5674. packet("f", moveMent.dir, 1);
  5675. }
  5676. },
  5677. this.tickMovement = function() {
  5678. let dist = player.weapons[1] == 9 ? 240 : 240;
  5679. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5680. let moveMent = this.gotoGoal(238, 3);
  5681. if (moveMent.action) {
  5682. if (player.reloads[53] == 0 && !this.isTrue) {
  5683. this.boostTickType();
  5684. } else {
  5685. packet("f", moveMent.dir, 1);
  5686. }
  5687. } else {
  5688. packet("f", moveMent.dir, 1);
  5689. }
  5690. },
  5691. this.kmTickMovement = function() {
  5692. let moveMent = this.gotoGoal(240, 3);
  5693. if (moveMent.action) {
  5694. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5695. this.kmTickType();
  5696. } else {
  5697. packet("f", moveMent.dir, 1);
  5698. }
  5699. } else {
  5700. packet("f", moveMent.dir, 1);
  5701. }
  5702. },
  5703. this.boostTickMovement = function() {
  5704. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 140;
  5705. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5706. let moveMent = this.gotoGoal(372, 3);
  5707. if (moveMent.action) {
  5708. if (player.reloads[53] == 0 && !this.isTrue) {
  5709. this.boostTickType();
  5710. } else {
  5711. packet("f", moveMent.dir, 1);
  5712. }
  5713. } else {
  5714. packet("f", moveMent.dir, 1);
  5715. }
  5716. }
  5717. /** wait 1 tick for better quality */
  5718. this.perfCheck = function(pl, nr) {
  5719. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5720. if (![9, 12, 19, 15].includes(player.weapons[1])) return true;
  5721. let pjs = {
  5722. x: nr.x2 + (70 * Math.cos(nr.aim2 + Math.PI)),
  5723. y: nr.y2 + (70 * Math.sin(nr.aim2 + Math.PI))
  5724. };
  5725. if (UTILS.lineInRect(pl.x2 - pl.scale, pl.y2 - pl.scale, pl.x2 + pl.scale, pl.y2 + pl.scale, pjs.x, pjs.y, pjs.x, pjs.y)) {
  5726. return true;
  5727. }
  5728. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5729. if (UTILS.lineInRect(tmp.x2 - tmp.scale, tmp.y2 - tmp.scale, tmp.x2 + tmp.scale, tmp.y2 + tmp.scale, pjs.x, pjs.y, pjs.x, pjs.y)) {
  5730. return true;
  5731. }
  5732. });
  5733. if (finds) return false;
  5734. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5735. let tmpScale = tmp.getScale();
  5736. if (!tmp.ignoreCollision && UTILS.lineInRect(tmp.x - tmpScale, tmp.y - tmpScale, tmp.x + tmpScale, tmp.y + tmpScale, pjs.x, pjs.y, pjs.x, pjs.y)) {
  5737. return true;
  5738. }
  5739. });
  5740. if (finds) return false;
  5741. return true;
  5742. }
  5743. }
  5744. };
  5745. class Autobuy {
  5746. constructor(buyHat, buyAcc) {
  5747. this.hat = function() {
  5748. buyHat.forEach((id) => {
  5749. let find = findID(hats, id);
  5750. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5751. });
  5752. };
  5753. this.acc = function() {
  5754. buyAcc.forEach((id) => {
  5755. let find = findID(accessories, id);
  5756. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5757. });
  5758. };
  5759. }
  5760. };
  5761.  
  5762. class Autoupgrade {
  5763. constructor() {
  5764. this.sb = function(upg) {
  5765. upg(3);
  5766. upg(17);
  5767. upg(31);
  5768. upg(23);
  5769. upg(9);
  5770. upg(38);
  5771. };
  5772. this.kh = function(upg) {
  5773. upg(3);
  5774. upg(17);
  5775. upg(31);
  5776. upg(23);
  5777. upg(10);
  5778. upg(38);
  5779. upg(4);
  5780. upg(25);
  5781. };
  5782. this.pb = function(upg) {
  5783. upg(5);
  5784. upg(17);
  5785. upg(32);
  5786. upg(23);
  5787. upg(9);
  5788. upg(38);
  5789. };
  5790. this.ph = function(upg) {
  5791. upg(5);
  5792. upg(17);
  5793. upg(32);
  5794. upg(23);
  5795. upg(10);
  5796. upg(38);
  5797. upg(28);
  5798. upg(25);
  5799. };
  5800. this.db = function(upg) {
  5801. upg(7);
  5802. upg(17);
  5803. upg(31);
  5804. upg(23);
  5805. upg(9);
  5806. upg(34);
  5807. };
  5808. };
  5809. };
  5810.  
  5811. class Damages {
  5812. constructor(items) {
  5813. // 0.75 1 1.125 1.5
  5814. this.calcDmg = function(dmg, val) {
  5815. return dmg * val;
  5816. };
  5817. this.getAllDamage = function(dmg) {
  5818. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5819. };
  5820. this.weapons = [];
  5821. for (let i = 0; i < items.weapons.length; i++) {
  5822. let wp = items.weapons[i];
  5823. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5824. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5825. this[name] = this.weapons[i];
  5826. }
  5827. }
  5828. }
  5829.  
  5830. /** CLASS CODES */
  5831. // jumpscare code warn
  5832. let tmpList = [];
  5833. var bianosTick = false;
  5834.  
  5835.  
  5836. // LOADING:
  5837. let UTILS = new Utils();
  5838. let items = new Items();
  5839. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5840. let store = new Store();
  5841. let hats = store.hats;
  5842. let accessories = store.accessories;
  5843. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5844. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5845. let textManager = new Textmanager();
  5846.  
  5847. let traps = new Traps(UTILS, items);
  5848. let instaC = new Instakill();
  5849. let autoBuy = new Autobuy([6, 7, 22, 12, 53, 40], [11, 19, 13, 21]);
  5850. let autoUpgrade = new Autoupgrade();
  5851.  
  5852. let lastDeath;
  5853. let minimapData;
  5854. let mapMarker = {};
  5855. let mapPings = [];
  5856. let tmpPing;
  5857.  
  5858. let breakTrackers = [];
  5859.  
  5860. let pathFindTest = 0;
  5861. let grid = [];
  5862. let pathFind = {
  5863. active: false,
  5864. grid: 40,
  5865. scale: 1440,
  5866. x: 14400,
  5867. y: 14400,
  5868. chaseNear: false,
  5869. array: [],
  5870. lastX: this.grid / 2,
  5871. lastY: this.grid / 2
  5872. };
  5873.  
  5874. function sendChat(message) {
  5875. packet("6", message.slice(0, 30));
  5876. }
  5877.  
  5878. let runAtNextTick = [];
  5879.  
  5880. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5881. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5882. let projOffset = config.playerScale * 2;
  5883. let projXY = {
  5884. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5885. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5886. };
  5887. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5888. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5889. })[0];
  5890. if (nearPlayer) {
  5891. if (indx == 1) {
  5892. nearPlayer.shooting[53] = 1;
  5893. } else {
  5894. nearPlayer.shootIndex = weaponIndx;
  5895. nearPlayer.shooting[1] = 1;
  5896. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5897. }
  5898. }
  5899. }
  5900. function predictHeal(times) {
  5901. for (let i in times) {
  5902. place(0, getAttackDir());
  5903. }
  5904. }
  5905. let projectileCount = 0;
  5906. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5907. if (!tmpObj.isTeam(player)) {
  5908. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5909. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5910. tmpObj.bowThreat[weaponIndex]++;
  5911. if (index == 5) {
  5912. projectileCount++;
  5913. }
  5914. setTimeout(() => {
  5915. tmpObj.bowThreat[weaponIndex]--;
  5916. if (index == 5) {
  5917. projectileCount--;
  5918. }
  5919. }, range / speed);
  5920. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5921. place(3, tmpObj.aim2);
  5922. my.anti0Tick = 4;
  5923. if (!my.antiSync) {
  5924. antiSyncHealing(4);
  5925. packet("f", tmpObj.aim2+3.1415926535897932/2, 1)
  5926. game.tickBase(() => {
  5927. packet("f", undefined, 1)
  5928. }, 2)
  5929. }
  5930. } else {
  5931. if (projectileCount >= 2) {
  5932. place(3, tmpObj.aim2);
  5933. packet("f", tmpObj.aim2+3.1415926535897932/2, 1)
  5934. my.anti0Tick = 4;
  5935. predictHeal(2)
  5936. game.tickBase(() => {
  5937. packet("f", undefined, 1)
  5938. }, 4)
  5939. if (!my.antiSync) {
  5940. antiSyncHealing(4);
  5941. }
  5942. }
  5943. }
  5944. }
  5945. }
  5946. }
  5947.  
  5948.  
  5949. // SHOW ITEM INFO:
  5950. function showItemInfo(item, isWeapon, isStoreItem) {
  5951. if (player && item) {
  5952. UTILS.removeAllChildren(itemInfoHolder);
  5953. itemInfoHolder.classList.add("visible");
  5954. UTILS.generateElement({
  5955. id: "itemInfoName",
  5956. text: UTILS.capitalizeFirst(item.name),
  5957. parent: itemInfoHolder
  5958. });
  5959. UTILS.generateElement({
  5960. id: "itemInfoDesc",
  5961. text: item.desc,
  5962. parent: itemInfoHolder
  5963. });
  5964. if (isStoreItem) {
  5965.  
  5966. } else if (isWeapon) {
  5967. UTILS.generateElement({
  5968. class: "itemInfoReq",
  5969. text: !item.type ? "primary" : "secondary",
  5970. parent: itemInfoHolder
  5971. });
  5972. } else {
  5973. for (let i = 0; i < item.req.length; i += 2) {
  5974. UTILS.generateElement({
  5975. class: "itemInfoReq",
  5976. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5977. parent: itemInfoHolder
  5978. });
  5979. }
  5980. if (item.group.limit) {
  5981. UTILS.generateElement({
  5982. class: "itemInfoLmt",
  5983. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5984. parent: itemInfoHolder
  5985. });
  5986. }
  5987. }
  5988. } else {
  5989. itemInfoHolder.classList.remove("visible");
  5990. }
  5991. }
  5992.  
  5993.  
  5994. // RESIZE:
  5995. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5996.  
  5997. function resize() {
  5998. screenWidth = window.innerWidth;
  5999. screenHeight = window.innerHeight;
  6000. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6001. gameCanvas.width = screenWidth * pixelDensity;
  6002. gameCanvas.height = screenHeight * pixelDensity;
  6003. gameCanvas.style.width = screenWidth + "px";
  6004. gameCanvas.style.height = screenHeight + "px";
  6005. mainContext.setTransform(
  6006. scaleFillNative, 0,
  6007. 0, scaleFillNative,
  6008. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  6009. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  6010. );
  6011. }
  6012. resize();
  6013.  
  6014. // MOUSE INPUT:
  6015. var usingTouch;
  6016. const mals = document.getElementById('touch-controls-fullscreen');
  6017. mals.style.display = 'block';
  6018. mals.addEventListener("mousemove", gameInput, false);
  6019.  
  6020. function gameInput(e) {
  6021. mouseX = e.clientX;
  6022. mouseY = e.clientY;
  6023. }
  6024. let clicks = {
  6025. left: false,
  6026. middle: false,
  6027. right: false,
  6028. };
  6029. let clicked = {
  6030. g: false
  6031. }
  6032. mals.addEventListener("mousedown", mouseDown, false);
  6033.  
  6034. function mouseDown(e) {
  6035. if (attackState != 1) {
  6036. attackState = 1;
  6037. if (e.button == 0) {
  6038. clicks.left = true;
  6039. } else if (e.button == 2) {
  6040. clicks.right = true;
  6041. }
  6042. }
  6043. }
  6044. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6045.  
  6046. function mouseUp(e) {
  6047. if (attackState != 0) {
  6048. attackState = 0;
  6049. if (e.button == 0) {
  6050. clicks.left = false;
  6051. } else if (e.button == 1) {
  6052. clicks.middle = false;
  6053. } else if (e.button == 2) {
  6054. clicks.right = false;
  6055. }
  6056. }
  6057. }
  6058. mals.addEventListener("wheel", wheel, false);
  6059.  
  6060. let wbe = 1;
  6061. let mWbe = 1;
  6062. let smothAnim = null;
  6063.  
  6064. function wheel(e, t = [null, 0]) {
  6065. if (e.deltaY < 0) {
  6066. wbe -= 0.05;
  6067. maxScreenWidth = config.maxScreenWidth * wbe;
  6068. maxScreenHeight = config.maxScreenHeight * wbe;
  6069. resize()
  6070. } else {
  6071. wbe += 0.05;
  6072. maxScreenWidth = config.maxScreenWidth * wbe;
  6073. maxScreenHeight = config.maxScreenHeight * wbe;
  6074. resize()
  6075. }
  6076. if (e.deltaY < 0) {
  6077. my.reSync = true;
  6078. } else {
  6079. my.reSync = false;
  6080. }
  6081. }
  6082.  
  6083.  
  6084. // INPUT UTILS:
  6085. function getMoveDir() {
  6086. let dx = 0;
  6087. let dy = 0;
  6088. for (let key in moveKeys) {
  6089. let tmpDir = moveKeys[key];
  6090. dx += !!keys[key] * tmpDir[0];
  6091. dy += !!keys[key] * tmpDir[1];
  6092. }
  6093. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6094. }
  6095.  
  6096. function getSafeDir() {
  6097. if (!player)
  6098. return 0;
  6099. if (!player.lockDir) {
  6100. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  6101. }
  6102. return lastDir || 0;
  6103. }
  6104. let plusDir = 0;
  6105. let lastSpin = Date.now();
  6106. function isNearPlayer() {
  6107. return near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap;
  6108. buyEquip(21, 1);
  6109. }
  6110. function getAttackDir(debug) {
  6111. if (debug) {
  6112. if (!player)
  6113. return "0";
  6114.  
  6115. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6116. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  6117. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6118. lastDir = "getSafeDir()";
  6119. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6120. lastDir = "traps.aim";
  6121. } else if (!player.lockDir) {
  6122. if (configs.noDir) return "undefined";
  6123. lastDir = "getSafeDir()";
  6124. }
  6125.  
  6126. return lastDir;
  6127. } else {
  6128. if (!player)
  6129. return 0;
  6130.  
  6131. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6132. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6133. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6134. lastDir = getSafeDir();
  6135. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6136. lastDir = traps.aim;
  6137. } else if (!player.lockDir) {
  6138. if (configs.noDir) return undefined;
  6139. lastDir = getSafeDir();
  6140. }
  6141.  
  6142. return lastDir || 0;
  6143. }
  6144. }
  6145. function getVisualDir() {
  6146. if (!player)
  6147. return 0;
  6148. lastDir = getSafeDir();
  6149. return lastDir || 0;
  6150. }
  6151.  
  6152. // KEYS:
  6153. function keysActive() {
  6154. return (allianceMenu.style.display != "block" &&
  6155. chatHolder.style.display != "block" &&
  6156. !menuCBFocus);
  6157. }
  6158.  
  6159. function toggleMenuChat() {
  6160. if (menuChatDiv.style.display != "none") {
  6161. // chatHolder.style.display = "none";
  6162. // if (menuChatBox.value != "") {
  6163. //commands[command.slice(1)]
  6164. let cmd = function(command) {
  6165. return {
  6166. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6167. fv: commands[command.slice(1).split(" ")[0]]
  6168. }
  6169. }
  6170. let command = cmd(menuChatBox.value);
  6171. if (command.found) {
  6172. if (typeof command.fv.action === "function") {
  6173. command.fv.action(menuChatBox.value);
  6174. }
  6175. } else {
  6176. sendChat(menuChatBox.value);
  6177. }
  6178. menuChatBox.value = "";
  6179. menuChatBox.blur();
  6180. } else {
  6181. if (menuCBFocus) {
  6182. menuChatBox.blur();
  6183. } else {
  6184. menuChatBox.focus();
  6185. }
  6186. }
  6187. }
  6188.  
  6189. function keyDown(event) {
  6190. let keyNum = event.which || event.keyCode || 0;
  6191. if (player && player.alive && keysActive()) {
  6192. if (!keys[keyNum]) {
  6193. keys[keyNum] = 1;
  6194. macro[event.key] = 1;
  6195. if (keyNum == 27) {
  6196. openMenu = !openMenu;
  6197. $("#menuDiv").toggle();
  6198. } else if (keyNum == 69) {
  6199. sendAutoGather();
  6200. } else if (keyNum == 67) {
  6201. updateMapMarker();
  6202. } else if (keyNum == 71) {
  6203. clicked.g = !clicked.g
  6204. } else if (keyNum == 79) {
  6205. clicked.o = !clicked.o
  6206. } else if (player.weapons[keyNum - 49] != undefined) {
  6207. player.weaponCode = player.weapons[keyNum - 49];
  6208. } else if (moveKeys[keyNum]) {
  6209. sendMoveDir();
  6210. } else if (event.key == "m") {
  6211. mills.placeSpawnPads = !mills.placeSpawnPads;
  6212. } else if (event.key == "z") {
  6213. mills.place = !mills.place;
  6214. } else if (event.key == "=") {
  6215. typeof window.debug == "function" && window.debug();
  6216. } else if (keyNum == 32) {
  6217. packet("F", 1, getSafeDir(), 1);
  6218. packet("F", 0, getSafeDir(), 1);
  6219. }
  6220. }
  6221. }
  6222. }
  6223. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6224.  
  6225. function keyUp(event) {
  6226. if (player && player.alive) {
  6227. let keyNum = event.which || event.keyCode || 0;
  6228. if (keyNum == 13) {
  6229. toggleMenuChat();
  6230. } else if (keysActive()) {
  6231. if (keys[keyNum]) {
  6232. keys[keyNum] = 0;
  6233. macro[event.key] = 0;
  6234. if (moveKeys[keyNum]) {
  6235. sendMoveDir();
  6236. }
  6237. }
  6238. }
  6239. }
  6240. }
  6241. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6242.  
  6243. function sendMoveDir() {
  6244. let newMoveDir = getMoveDir();
  6245. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6246. if (!my.autoPush) {
  6247. packet("f", newMoveDir, 1);
  6248. }
  6249. lastMoveDir = newMoveDir;
  6250. }
  6251. }
  6252.  
  6253. // BUTTON EVENTS:
  6254. function bindEvents() {}
  6255. bindEvents();
  6256.  
  6257. /** PATHFIND TEST */
  6258. function chechPathColl(tmp) {
  6259. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  6260. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  6261. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  6262. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  6263. }
  6264.  
  6265. function checkObject() {
  6266. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  6267. for (let y = 0; y < pathFind.grid; y++) {
  6268. grid[y] = [];
  6269. for (let x = 0; x < pathFind.grid; x++) {
  6270. let tmpXY = {
  6271. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  6272. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  6273. }
  6274. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  6275. pathFind.lastX = x;
  6276. pathFind.lastY = y;
  6277. grid[y][x] = 0;
  6278. continue;
  6279. }
  6280. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  6281. if (find) {
  6282. if (find.trap) {
  6283. grid[y][x] = 0;
  6284. continue;
  6285. }
  6286. grid[y][x] = 1;
  6287. } else {
  6288. grid[y][x] = 0;
  6289. }
  6290. }
  6291. }
  6292. }
  6293.  
  6294. function createPath() {
  6295. grid = [];
  6296. checkObject();
  6297. }
  6298.  
  6299.  
  6300.  
  6301. function Pathfinder() {
  6302. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  6303. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  6304. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6305. packet("f", undefined, 1);
  6306. } else {
  6307. createPath();
  6308. easystar.setGrid(grid);
  6309. easystar.setAcceptableTiles([0]);
  6310. easystar.enableDiagonals();
  6311. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function (path) {
  6312. if (path === null) {
  6313. pathFind.array = [];
  6314. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6315. packet("f", undefined, 1);
  6316. } else {
  6317. packet("f", near.aim2, 1);
  6318. }
  6319. } else {
  6320. pathFind.array = path;
  6321. if (pathFind.array.length > 1) {
  6322. let tmpXY = {
  6323. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  6324. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  6325. }
  6326. packet("f", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  6327. }
  6328. }
  6329. });
  6330. easystar.calculate();
  6331. }
  6332. }
  6333. }
  6334. /** PATHFIND TEST */
  6335.  
  6336. // ITEM COUNT DISPLAY:
  6337. let isItemSetted = [];
  6338.  
  6339. function updateItemCountDisplay(index = undefined) {
  6340. for (let i = 3; i < items.list.length; ++i) {
  6341. let id = items.list[i].group.id;
  6342. let tmpI = items.weapons.length + i;
  6343. if (!isItemSetted[tmpI]) {
  6344. isItemSetted[tmpI] = document.createElement("div");
  6345. isItemSetted[tmpI].id = "itemCount" + tmpI;
  6346. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  6347. isItemSetted[tmpI].style = `
  6348. display: block;
  6349. position: absolute;
  6350. padding-left: 5px;
  6351. font-size: 2em;
  6352. color: #fff;
  6353. `;
  6354. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  6355. } else {
  6356. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  6357. }
  6358. }
  6359. }
  6360.  
  6361. // AUTOPUSH:
  6362. function autoPush() {
  6363. let nearTrap = gameObjects.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  6364. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6365. })[0];
  6366. if (nearTrap) {
  6367. let spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function(a, b) {
  6368. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6369. })[0];
  6370. if (spike) {
  6371. let pushAngle = Math.atan2(near.y2 - spike.y, near.x2 - spike.x)
  6372.  
  6373. /*let pos = {
  6374. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6375. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6376. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))) + Math.cos(25),
  6377. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0))) + Math.sin(25)
  6378. };
  6379. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6380. let tmpScale = tmp.getScale();
  6381. if (!tmp.ignoreCollision && UTILS.lineInRect(tmp.x - tmpScale, tmp.y - tmpScale, tmp.x + tmpScale, tmp.y + tmpScale, player.x2, player.y2, pos.x2, pos.y2)) {
  6382. return true;
  6383. }
  6384. });
  6385. if (finds) {
  6386. if (my.autoPush) {
  6387. my.autoPush = false;
  6388. packet("f", lastMoveDir || undefined, 1);
  6389. }
  6390. } else {*/
  6391. my.autoPush = true;
  6392. sendChat("!I'm pushing you :3!");
  6393. my.pushData = {
  6394. x: spike.x + Math.cos(pushAngle),
  6395. y: spike.y + Math.sin(pushAngle),
  6396. x2: player.x2+30,
  6397. y2: player.y2+30
  6398. };
  6399.  
  6400. let point = {
  6401. x: near.x2 + Math.cos(pushAngle) * 30,
  6402. y: near.y2 + Math.sin(pushAngle) * 60,
  6403. }
  6404.  
  6405. let dir = Math.atan2(point.y - player.y2, point.x - player.x2)
  6406.  
  6407. packet("f", dir, 1)
  6408. /*let scale = (player.scale / 10);
  6409. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6410. packet("f", near.aim2, 1);
  6411. } else {
  6412. packet("f", UTILS.getDirect(pos, player, 2, 2), 1);
  6413. }*/
  6414. //}
  6415. } else {
  6416. if (my.autoPush) {
  6417. my.autoPush = false;
  6418. packet("f", lastMoveDir || undefined, 1);
  6419. }
  6420. }
  6421. } else {
  6422. if (my.autoPush) {
  6423. my.autoPush = false;
  6424. packet("f", lastMoveDir || undefined, 1);
  6425. }
  6426. }
  6427. }
  6428.  
  6429.  
  6430. class AutoPush {
  6431. socket = null;
  6432.  
  6433. findIntersect(vec, vec1, vec2) {
  6434. // Find point of vec1 and vec2 intersection
  6435. const delta = Math.hypot(vec1.x - vec2.x, vec1.y - vec2.y) / 2;
  6436. const tang = Math.tan((vec1.y - vec2.y) / (vec1.x - vec2.x));
  6437. const vec3x = Math.cos(tang) * delta;
  6438. const vec3y = Math.sin(tang) * delta;
  6439. // Find angle from vec to vec3
  6440. const theta = Math.tan((vec.y - vec3y) / (vec.x - vec3x));
  6441.  
  6442. return theta;
  6443. };
  6444.  
  6445. pushEnemy(player, enemy, spike) {
  6446. const angle = this.findIntersect(enemy, spike, player);
  6447. const dist = Math.hypot(player.x - enemy.x, player.y - enemy.y);
  6448.  
  6449. if (dist > 180) return;
  6450.  
  6451. this.socket.send("a", angle);
  6452. };
  6453.  
  6454. constructor(socket) {
  6455. this.socket = socket;
  6456. }
  6457. }
  6458.  
  6459. // ADD DEAD PLAYER:
  6460. function addDeadPlayer(tmpObj) {
  6461. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6462. }
  6463.  
  6464. /** APPLY SOCKET CODES */
  6465.  
  6466. // SET INIT DATA:
  6467. function setInitData(data) {
  6468. alliances = data.teams;
  6469. }
  6470.  
  6471. // SETUP GAME:
  6472. function setupGame(yourSID) {
  6473. keys = {};
  6474. macro = {};
  6475. playerSID = yourSID;
  6476. attackState = 0;
  6477. inGame = true;
  6478. packet("F", 0, getAttackDir(), 1);
  6479. my.ageInsta = true;
  6480. if (firstSetup) {
  6481. firstSetup = false;
  6482. gameObjects.length = 0;
  6483. liztobj.length = 0;
  6484. }
  6485. }
  6486.  
  6487. // ADD NEW PLAYER:
  6488. function addPlayer(data, isYou) {
  6489. let tmpPlayer = findPlayerByID(data[0]);
  6490. if (!tmpPlayer) {
  6491. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6492. objectManager, players, ais, items, hats, accessories);
  6493. players.push(tmpPlayer);
  6494. if (data[1] != playerSID) {
  6495. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6496. }
  6497. } else {
  6498. if (data[1] != playerSID) {
  6499. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6500. }
  6501. }
  6502. tmpPlayer.spawn(isYou ? true : null);
  6503. tmpPlayer.visible = false;
  6504. tmpPlayer.oldPos = {
  6505. x2: undefined,
  6506. y2: undefined
  6507. };
  6508. tmpPlayer.x2 = undefined;
  6509. tmpPlayer.y2 = undefined;
  6510. tmpPlayer.x3 = undefined;
  6511. tmpPlayer.y3 = undefined;
  6512. tmpPlayer.setData(data);
  6513. if (isYou) {
  6514. if (!player) {
  6515. window.prepareUI(tmpPlayer);
  6516. }
  6517. player = tmpPlayer;
  6518. camX = player.x;
  6519. camY = player.y;
  6520. my.lastDir = 0;
  6521. updateItems();
  6522. updateAge();
  6523. updateItemCountDisplay();
  6524. if (player.skins[7]) {
  6525. my.reSync = true;
  6526. if(player.shameCount > 0) {
  6527. my.reSync = true;
  6528. } else {
  6529. my.reSync = false;
  6530. }
  6531. }
  6532. }
  6533. }
  6534.  
  6535. // REMOVE PLAYER:
  6536. function removePlayer(id) {
  6537. for (let i = 0; i < players.length; i++) {
  6538. if (players[i].id == id) {
  6539. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  6540. players.splice(i, 1);
  6541. break;
  6542. }
  6543. }
  6544. }
  6545.  
  6546. // UPDATE HEALTH:
  6547. function updateHealth(sid, value) {
  6548. tmpObj = findPlayerBySID(sid);
  6549. if (tmpObj) {
  6550. tmpObj.oldHealth = tmpObj.health;
  6551. tmpObj.health = value;
  6552. tmpObj.judgeShame();
  6553. if (tmpObj.oldHealth > tmpObj.health) {
  6554. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6555. advHeal.push([sid, value, tmpObj.damaged]);
  6556. } else {}
  6557. if (tmpObj.health <= 0) {
  6558. /*bots.forEach((hmm) => {
  6559. hmm.whyDie = tmpObj.name;
  6560. });*/
  6561. }
  6562. }
  6563. }
  6564.  
  6565.  
  6566. // KILL PLAYER:
  6567. function killPlayer() {
  6568. inGame = false;
  6569. lastDeath = {
  6570. x: player.x,
  6571. y: player.y,
  6572. };
  6573. if (configs.autoRespawn) {
  6574. getEl("diedText").style.display = "none";
  6575. packet("M", {
  6576. name: lastsp[0],
  6577. moofoll: lastsp[1],
  6578. skin: lastsp[2]
  6579. });
  6580. }
  6581. }
  6582.  
  6583. // UPDATE PLAYER ITEM VALUES:
  6584. function updateItemCounts(index, value) {
  6585. if (player) {
  6586. player.itemCounts[index] = value;
  6587. updateItemCountDisplay(index);
  6588. }
  6589. }
  6590.  
  6591. // UPDATE AGE:
  6592. function updateAge(xp, mxp, age) {
  6593. if (xp != undefined){
  6594. }
  6595. player.XP = xp;
  6596. if (mxp != undefined){
  6597. }
  6598. player.maxXP = mxp;
  6599. if (age != undefined){
  6600. }
  6601. player.age = age;
  6602. }
  6603. // UPDATE UPGRADES:
  6604. function updateUpgrades(points, age) {
  6605. player.upgradePoints = points;
  6606. player.upgrAge = age;
  6607. if (points > 0) {
  6608. tmpList.length = 0;
  6609. UTILS.removeAllChildren(upgradeHolder);
  6610. for (let i = 0; i < items.weapons.length; ++i) {
  6611. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6612. let e = UTILS.generateElement({
  6613. id: "upgradeItem" + i,
  6614. class: "actionBarItem",
  6615. onmouseout: function() {
  6616. showItemInfo();
  6617. },
  6618. parent: upgradeHolder
  6619. });
  6620. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6621. tmpList.push(i);
  6622. }
  6623. }
  6624. for (let i = 0; i < items.list.length; ++i) {
  6625. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6626. let tmpI = (items.weapons.length + i);
  6627. let e = UTILS.generateElement({
  6628. id: "upgradeItem" + tmpI,
  6629. class: "actionBarItem",
  6630. onmouseout: function() {
  6631. showItemInfo();
  6632. },
  6633. parent: upgradeHolder
  6634. });
  6635. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6636. tmpList.push(tmpI);
  6637. }
  6638. }
  6639. for (let i = 0; i < tmpList.length; i++) {
  6640. (function(i) {
  6641. let tmpItem = getEl('upgradeItem' + i);
  6642. // tmpItem.onmouseover = function() {
  6643. // if (items.weapons[i]) {
  6644. // showItemInfo(items.weapons[i], true);
  6645. // } else {
  6646. // showItemInfo(items.list[i - items.weapons.length]);
  6647. // }
  6648. // };
  6649. tmpItem.onclick = UTILS.checkTrusted(function() {
  6650. packet("H", i);
  6651. });
  6652. UTILS.hookTouchEvents(tmpItem);
  6653. })(tmpList[i]);
  6654. }
  6655. if (tmpList.length) {
  6656. upgradeHolder.style.display = "block";
  6657. upgradeCounter.style.display = "block";
  6658. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6659. } else {
  6660. upgradeHolder.style.display = "none";
  6661. upgradeCounter.style.display = "none";
  6662. showItemInfo();
  6663. }
  6664. } else {
  6665. upgradeHolder.style.display = "none";
  6666. upgradeCounter.style.display = "none";
  6667. showItemInfo();
  6668. }
  6669. // SMART AUTOUPGRADE:
  6670. if (configs.AutoUpgrade) {
  6671. if(age == 3) {
  6672. sendUpgrade(17)
  6673. } else if (age == 4) {
  6674. sendUpgrade(31)
  6675. } else if (age == 5) {
  6676. sendUpgrade(23)
  6677. } else if (age == 8) {
  6678. if(player.secondaryIndex == 9) {
  6679. sendUpgrade(12)
  6680. } else if(player.primaryIndex == 3) {
  6681. sendUpgrade(4)
  6682. } else {
  6683. sendUpgrade(28)
  6684. }
  6685. } else if (age == 9) {
  6686. if(player.secondaryIndex == 12) {
  6687. sendUpgrade(15)
  6688. } else {
  6689. sendUpgrade(25)
  6690. }
  6691. }// 12 15
  6692. }
  6693. }
  6694. function cdf(e, t) {
  6695. try {
  6696. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6697. } catch (e) {
  6698. return Infinity;
  6699. }
  6700. }
  6701. function caf(e, t) {
  6702. try {
  6703. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6704. } catch (e) {
  6705. return 0;
  6706. }
  6707. }
  6708. function numArr(e = 0, t = 1, act, n = 1) {
  6709. let arr = [];
  6710. for (let i = e; i < t; i += n) {
  6711. arr.push(i);
  6712. typeof act == "function" && act(i);
  6713. }
  6714. return arr;
  6715. }
  6716. function toR(e) {
  6717. var n = (e * Math.PI / 180) % (2 * Math.PI);
  6718. return n > Math.PI ? Math.PI - n : n
  6719. }
  6720. function toD(e) {
  6721. var n = (e / Math.PI * 360) % 360;
  6722. return n >= 360 ? n - 360 : n;
  6723. }
  6724.  
  6725.  
  6726.  
  6727. // KILL OBJECT:
  6728. function killObject(sid) {
  6729. let findObj = findObjectBySid(sid);
  6730. objectManager.disableBySid(sid);
  6731. if (player) {
  6732. for (let i = 0; i < breakObjects.length; i++) {
  6733. if (breakObjects[i].sid == sid) {
  6734. breakObjects.splice(i, 1);
  6735. break;
  6736. }
  6737. }
  6738. if (!player.canSee(findObj)) {
  6739. breakTrackers.push({
  6740. x: findObj.x,
  6741. y: findObj.y
  6742. });
  6743. }
  6744. if (breakTrackers.length > 8) {
  6745. breakTrackers.shift();
  6746. }
  6747. traps.replacer(findObj);
  6748. }
  6749. }
  6750.  
  6751. // KILL ALL OBJECTS BY A PLAYER:
  6752. function killObjects(sid) {
  6753. if (player) objectManager.removeAllItems(sid);
  6754. }
  6755. function setTickout(doo, timeout) {
  6756. if (!ticks.manage[ticks.tick + timeout]) {
  6757. ticks.manage[ticks.tick + timeout] = [doo];
  6758. } else {
  6759. ticks.manage[ticks.tick + timeout].push(doo);
  6760. }
  6761. }
  6762.  
  6763. function caf(e, t) {
  6764. try {
  6765. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6766. } catch (e) {
  6767. return 0;
  6768. }
  6769. }
  6770.  
  6771. let found = false;
  6772. let autoQ = false;
  6773.  
  6774. let autos = {
  6775. insta: {
  6776. todo: false,
  6777. wait: false,
  6778. count: 4,
  6779. shame: 5
  6780. },
  6781. bull: false,
  6782. antibull: 0,
  6783. reloaded: false,
  6784. stopspin: true
  6785. }
  6786.  
  6787. // UPDATE PLAYER DATA:
  6788. function updatePlayers(data) {
  6789. // if(player.shameCount > 0) {
  6790. // my.reSync = true;
  6791. // } else {
  6792. // my.reSync = false;
  6793. // }
  6794.  
  6795. // let movementPrediction = {
  6796. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6797. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6798. // }
  6799.  
  6800. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  6801.  
  6802. // potentialzpiketick.forEach((obj) => {
  6803. // if(cdf(obj, player) <= 200) {
  6804. // packet('f', undefined);
  6805. // }
  6806. // })
  6807.  
  6808. // let newPos = {
  6809. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  6810. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  6811. // }
  6812.  
  6813. function getAngleDifference(angle1, angle2) {
  6814. // Normalize the angles to be between 0 and 2π
  6815. angle1 = angle1 % (2 * Math.PI);
  6816. angle2 = angle2 % (2 * Math.PI);
  6817.  
  6818. // Calculate the absolute difference between the angles
  6819. let diff = Math.abs(angle1 - angle2);
  6820.  
  6821. // Adjust the difference to be between 0 and π
  6822. if (diff > Math.PI) {
  6823. diff = (2 * Math.PI) - diff;
  6824. }
  6825.  
  6826. return diff;
  6827. }
  6828.  
  6829. // function smartMove(oneTickMove) {
  6830. // let dir = player.moveDir;
  6831.  
  6832. // let found = false
  6833. // let buildings = liztobj.sort((a, b) => Math.hypot(player.y2 - a.y, player.x2 - a.x) - Math.hypot(player.y2 - b.y, player.x2 - b.x))
  6834. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  6835.  
  6836. // let newPos = {
  6837. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  6838. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  6839. // }
  6840.  
  6841. // for (let i = 0; i < spikes.length; i++) {
  6842. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  6843. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  6844. // }
  6845. // }
  6846.  
  6847.  
  6848.  
  6849.  
  6850.  
  6851. // if (found != false && !traps.inTrap) {
  6852. // packet("f", undefined);
  6853. // } else {
  6854. // packet("f", dir);
  6855. // }
  6856. // player.oldPos.x2 = player.x2;
  6857. // player.oldPos.y2 = player.y2;
  6858. // }
  6859. // function detectEnemySpikeCollisions(tmpObj) {
  6860. // let buildings = liztobj.sort((a, b) => Math.hypot(tmpObj.y - a.y, tmpObj.x - a.x) - Math.hypot(tmpObj.y - b.y, tmpObj.x - b.x));
  6861. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  6862. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  6863. // let enemy = {
  6864. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  6865. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  6866. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6867. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6868. // }
  6869. // let found = false;
  6870. // for (let i = 0; i < spikes.length; i++) {
  6871. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  6872. // found = true;
  6873. // }
  6874. // }
  6875.  
  6876. // // player.oldPos.x2 = tmpObj.x2;
  6877. // // player.oldPos.y2 = tmpObj.y2;
  6878. // }
  6879.  
  6880. game.tick++;
  6881. enemy = [];
  6882. nears = [];
  6883. near = [];
  6884. game.tickSpeed = performance.now() - game.lastTick;
  6885. game.lastTick = performance.now();
  6886. players.forEach((tmp) => {
  6887. tmp.forcePos = !tmp.visible;
  6888. tmp.visible = false;
  6889. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6890. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6891. });
  6892. for (let i = 0; i < data.length;) {
  6893. tmpObj = findPlayerBySID(data[i]);
  6894. if (tmpObj) {
  6895. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6896. tmpObj.t2 = game.lastTick;
  6897. tmpObj.oldPos.x2 = tmpObj.x2;
  6898. tmpObj.oldPos.y2 = tmpObj.y2;
  6899. tmpObj.x1 = tmpObj.x;
  6900. tmpObj.y1 = tmpObj.y;
  6901. tmpObj.x2 = data[i + 1];
  6902. tmpObj.y2 = data[i + 2];
  6903. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6904. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6905. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6906. tmpObj.d2 = data[i + 3];
  6907. tmpObj.dt = 0;
  6908. tmpObj.buildIndex = data[i + 4];
  6909. tmpObj.weaponIndex = data[i + 5];
  6910. tmpObj.weaponVariant = data[i + 6];
  6911. tmpObj.team = data[i + 7];
  6912. tmpObj.isLeader = data[i + 8];
  6913. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6914. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6915. tmpObj.skinIndex = data[i + 9];
  6916. tmpObj.tailIndex = data[i + 10];
  6917. tmpObj.iconIndex = data[i + 11];
  6918. tmpObj.zIndex = data[i + 12];
  6919. tmpObj.visible = true;
  6920. tmpObj.update(game.tickSpeed);
  6921. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6922. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6923. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6924. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6925. tmpObj.damageThreat = 0;
  6926. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6927. tmpObj.addShameTimer();
  6928. }
  6929. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6930. tmpObj.shameTimer = 0;
  6931. tmpObj.shameCount = 0;
  6932. if (tmpObj == player) {
  6933. healer();
  6934. }
  6935. }
  6936.  
  6937. botSkts.forEach((bot) => {
  6938. bot.showName = 'YEAHHH'
  6939. })
  6940.  
  6941. for(let i = 0; i < players.length; i++) {
  6942. for(let aa = 0; aa < botSkts.length; aa++) {
  6943. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6944.  
  6945. }
  6946. }
  6947.  
  6948. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6949. autoQ = true;
  6950. healer();
  6951. } else {
  6952. if (autoQ) {
  6953. healer();
  6954. }
  6955. autoQ = false;
  6956. }
  6957.  
  6958.  
  6959. if (tmpObj == player) {
  6960. if (liztobj.length) {
  6961. liztobj.forEach((tmp) => {
  6962. tmp.onNear = false;
  6963. if (tmp.active) {
  6964. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6965. tmp.onNear = true;
  6966. }
  6967. if (tmp.isItem && tmp.owner) {
  6968. if (!tmp.pps && tmpObj.sid == tmp.owner.sid && UTILS.getDist(tmp, tmpObj, 0, 2) > (parseInt(getEl("breakRange").value) || 0) && !tmp.breakObj && ![13, 14, 20].includes(tmp.id)) {
  6969. tmp.breakObj = true;
  6970. breakObjects.push({
  6971. x: tmp.x,
  6972. y: tmp.y,
  6973. sid: tmp.sid
  6974. });
  6975. }
  6976. }
  6977. }
  6978. });
  6979. let nearTrap = liztobj.filter(e => e.trap && e.active && UTILS.getDist(e, tmpObj, 0, 2) <= (tmpObj.scale + e.getScale() + 25) && !e.isTeamObject(tmpObj)).sort(function(a, b) {
  6980. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6981. })[0];
  6982. if (nearTrap) {
  6983. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6984. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6985. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  6986.  
  6987. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6988. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6989. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6990. traps.inTrap = true;
  6991. sendChat("Oh no! You got me! :(");
  6992. traps.info = nearTrap;
  6993. } else {
  6994. traps.inTrap = false;
  6995. traps.info = {};
  6996. }
  6997. } else {
  6998. traps.inTrap = false;
  6999. }
  7000. }
  7001. if (tmpObj.weaponIndex < 9) {
  7002. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7003. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7004. } else if (tmpObj.weaponIndex > 8) {
  7005. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7006. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7007. }
  7008. }
  7009. i += 13;
  7010. }
  7011. if (textManager.stack.length) {
  7012. let stacks = [];
  7013. let notstacks = [];
  7014. let num = 0;
  7015. let num2 = 0;
  7016. let pos = {
  7017. x: null,
  7018. y: null
  7019. };
  7020. let pos2 = {
  7021. x: null,
  7022. y: null
  7023. }
  7024. textManager.stack.forEach((text) => {
  7025. if (text.value >= 0) {
  7026. if (num == 0) pos = {
  7027. x: text.x,
  7028. y: text.y
  7029. };
  7030. num += Math.abs(text.value);
  7031. } else {
  7032. if (num2 == 0) pos2 = {
  7033. x: text.x,
  7034. y: text.y
  7035. };
  7036. num2 += Math.abs(text.value);
  7037. }
  7038. });
  7039. if (num2 > 0) {
  7040. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#FF0000");
  7041. }
  7042. if (num > 0) {
  7043. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  7044. }
  7045. textManager.stack = [];
  7046. }
  7047. if (runAtNextTick.length) {
  7048. runAtNextTick.forEach((tmp) => {
  7049. checkProjectileHolder(...tmp);
  7050. });
  7051. runAtNextTick = [];
  7052. }
  7053. for (let i = 0; i < data.length;) {
  7054. tmpObj = findPlayerBySID(data[i]);
  7055. if (tmpObj) {
  7056. if (!tmpObj.isTeam(player)) {
  7057. enemy.push(tmpObj);
  7058. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  7059. nears.push(tmpObj);
  7060. }
  7061. }
  7062. tmpObj.manageReload();
  7063. if (tmpObj != player) {
  7064. tmpObj.addDamageThreat(player);
  7065. }
  7066. }
  7067. i += 13;
  7068. }
  7069. /*projectiles.forEach((proj) => {
  7070. tmpObj = proj;
  7071. if (tmpObj.active) {
  7072. tmpObj.tickUpdate(game.tickSpeed);
  7073. }
  7074. });*/
  7075. if (player && player.alive) {
  7076. if (enemy.length) {
  7077. near = enemy.sort(function(tmp1, tmp2) {
  7078. return tmp1.dist2 - tmp2.dist2;
  7079. })[0];
  7080. } else {
  7081. // console.log("no enemy");
  7082. }
  7083. if (game.tickQueue[game.tick]) {
  7084. game.tickQueue[game.tick].forEach((action) => {
  7085. action();
  7086. });
  7087. game.tickQueue[game.tick] = null;
  7088. }
  7089. if (advHeal.length) {
  7090. advHeal.forEach((updHealth) => {
  7091. if (window.pingTime < 150) {
  7092. let sid = updHealth[0];
  7093. let value = updHealth[1];
  7094. let totalDamage = 100 - value
  7095. let damaged = updHealth[2];
  7096. tmpObj = findPlayerBySID(sid);
  7097. let bullTicked = false;
  7098. if (tmpObj == player) {
  7099. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7100. if (my.reSync) {
  7101. my.reSync = false;
  7102. tmpObj.setBullTick = true;
  7103. }
  7104. bullTicked = true;
  7105. }
  7106. if (inGame) {
  7107. let attackers = getAttacker(damaged);
  7108. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  7109. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  7110. let healTimeout = 140 - window.pingTime;
  7111. let dmg = 100 - player.health;
  7112. let slowHeal = function (timer, tickBase) {
  7113. if (!tickBase) {
  7114. setTimeout(() => {
  7115. healer();
  7116. }, timer);
  7117. } else {
  7118. game.tickBase(() => {
  7119. healer()
  7120. }, 3)
  7121. }
  7122. }
  7123. if (getEl("healingBeta").checked) {
  7124. if (enemy.length) {
  7125. if ([0, 7, 8].includes(near.primaryIndex)) {
  7126. if (damaged < 75) {
  7127. slowHeal(healTimeout)
  7128. } else {
  7129. healer()
  7130. }
  7131. }
  7132. if ([1, 2, 6].includes(near.primaryIndex)) {
  7133. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5) {
  7134. healer()
  7135. } else {
  7136. slowHeal(healTimeout)
  7137. }
  7138. }
  7139. if (near.primaryIndex == 3) {
  7140. if (near.secondaryIndex == 15) {
  7141. if (near.primaryVariant < 2) {
  7142. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  7143. tmpObj.canEmpAnti = true
  7144. tmpObj.antiTimer = game.tick
  7145. healer()
  7146. } else {
  7147. slowHeal(healTimeout)
  7148. }
  7149. } else {
  7150. if (damaged > 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  7151. tmpObj.canEmpAnti = true
  7152. tmpObj.antiTimer = game.tick
  7153. healer()
  7154. } else {
  7155. slowHeal(healTimeout)
  7156. }
  7157. }
  7158. } else {
  7159. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  7160. healer()
  7161. } else {
  7162. slowHeal(healTimeout)
  7163. }
  7164. }
  7165. }
  7166. if (near.primaryIndex == 4) {
  7167. if (near.primaryVariant >= 1) {
  7168. if (damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  7169. healer()
  7170. } else {
  7171. slowHeal(healTimeout)
  7172. }
  7173. } else {
  7174. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3) {
  7175. healer()
  7176. } else {
  7177. slowHeal(healTimeout)
  7178. }
  7179. }
  7180. }
  7181. if ([undefined, 5].includes(near.primaryIndex)) {
  7182. if (near.secondaryIndex == 10) {
  7183. if (dmg >= (includeSpikeDmgs ? 10 : 20) && tmpObj.damageThreat + dmg >= 80 && tmpObj.shameCount < 6) {
  7184. healer()
  7185. } else {
  7186. slowHeal(healTimeout)
  7187. }
  7188. } else
  7189. if (near.primaryVariant >= 2 || near.primaryVariant == undefined) {
  7190. if (dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6) {
  7191. healer()
  7192. } else {
  7193. slowHeal(healTimeout)
  7194. }
  7195. } else
  7196. if ([undefined || 15].includes(near.secondaryIndex)) {
  7197. if (damaged > (includeSpikeDmgs ? 8 : 20) && player.damageThreat >= 25 && (game.tick - player.antiTimer) > 1) {
  7198. if (tmpObj.shameCount < 5) {
  7199. healer()
  7200. } else {
  7201. slowHeal(healTimeout)
  7202. }
  7203. } else {
  7204. slowHeal(healTimeout)
  7205. }
  7206. } else
  7207. if ([9, 12, 13].includes(near.secondaryIndex)) {
  7208. if (dmg >= 25 && player.damageThreat + dmg >= 70 && tmpObj.shameCount < 6) {
  7209. healer()
  7210. } else {
  7211. slowHeal(healTimeout)
  7212. }
  7213. } else {
  7214. if (damaged > 25 && player.damageThreat + dmg >= 95) {
  7215. healer()
  7216. } else {
  7217. slowHeal(healTimeout)
  7218. }
  7219. }
  7220. }
  7221. if (near.primaryIndex == 6) {
  7222. if (near.secondaryIndex == 15) {
  7223. if (damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  7224. healer()
  7225. } else {
  7226. slowHeal(healTimeout)
  7227. }
  7228. } else {
  7229. if (damaged >= 70 && tmpObj.shameCount < 4) {
  7230. healer()
  7231. } else {
  7232. slowHeal(healTimeout)
  7233. }
  7234. }
  7235. }
  7236. if (damaged >= 30 && near.reloads[near.secondaryIndex] == 0 && near.dist2 <= 150 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7237. } else {
  7238. if (damaged >= 70) {
  7239. healer()
  7240. } else {
  7241. slowHeal(healTimeout)
  7242. }
  7243. }
  7244. } else {
  7245. if (damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1) {
  7246. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  7247. tmpObj.canEmpAnti = true;
  7248. } else {
  7249. player.soldierAnti = true;
  7250. }
  7251. tmpObj.antiTimer = game.tick;
  7252. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  7253. if (tmpObj.shameCount < shame) {
  7254. healer();
  7255. } else {
  7256. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  7257. slowHeal(healTimeout)
  7258. } else {
  7259. slowHeal(healTimeout, 1)
  7260. }
  7261. }
  7262. } else {
  7263. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  7264. slowHeal(healTimeout)
  7265. } else {
  7266. slowHeal(healTimeout, 1)
  7267. }
  7268. }
  7269. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7270. }
  7271. } else {
  7272. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7273. tmpObj.setPoisonTick = true;
  7274. }
  7275. }
  7276. }
  7277. } else {
  7278. let [sid, value, damaged] = updHealth;
  7279. let totalDamage = 100 - value;
  7280. let tmpObj = findPlayerBySID(sid);
  7281. let bullTicked = false;
  7282.  
  7283. if (tmpObj == player) {
  7284. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7285. if (my.reSync) {
  7286. my.reSync = false;
  7287. tmpObj.setBullTick = true;
  7288. bullTicked = true;
  7289. }
  7290. }
  7291. if (inGame) {
  7292. let attackers = getAttacker(damaged);
  7293. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  7294. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  7295. let healTimeout = 60;
  7296. let dmg = 100 - player.health;
  7297. let shameCountThreshold = [2, 5][[0, 4, 6, 7, 8].includes(near.primaryIndex) ? 0 : 1];
  7298.  
  7299. let slowHeal = function (timer, tickBase) {
  7300. if (!tickBase) setTimeout(() => healer(), timer);
  7301. else game.tickBase(() => healer(), 2);
  7302. };
  7303.  
  7304. if (getEl("healingBeta").checked) {
  7305. let canHealFast = [0, 7, 8].includes(near.primaryIndex) ? damaged < 75 :
  7306. [1, 2, 6].includes(near.primaryIndex) ? damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 :
  7307. [undefined, 5].includes(near.primaryIndex) ? dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6 :
  7308. near.primaryIndex == 3 && near.secondaryIndex == 15 ? damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1 :
  7309. near.primaryIndex == 4 ? near.primaryVariant >= 1 ? damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  7310. damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3 :
  7311. near.primaryIndex == 6 && near.secondaryIndex == 15 ? damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  7312. damaged >= 25 && player.damageThreat + dmg >= 95;
  7313.  
  7314. canHealFast ? healer() : slowHeal(healTimeout);
  7315. } else {
  7316. let canHealFast = damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1;
  7317.  
  7318. if (canHealFast) {
  7319. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) tmpObj.canEmpAnti = true;
  7320. else player.soldierAnti = true;
  7321. tmpObj.antiTimer = game.tick;
  7322. if (tmpObj.shameCount < shameCountThreshold) healer();
  7323. else slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  7324. } else {
  7325. slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  7326. }
  7327. }
  7328. } else {
  7329. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7330. tmpObj.setPoisonTick = true;
  7331. }
  7332. }
  7333. }
  7334. }
  7335. });
  7336. advHeal = [];
  7337. }
  7338. players.forEach((tmp) => {
  7339. if (!tmp.visible && player != tmp) {
  7340. tmp.reloads = {
  7341. 0: 0,
  7342. 1: 0,
  7343. 2: 0,
  7344. 3: 0,
  7345. 4: 0,
  7346. 5: 0,
  7347. 6: 0,
  7348. 7: 0,
  7349. 8: 0,
  7350. 9: 0,
  7351. 10: 0,
  7352. 11: 0,
  7353. 12: 0,
  7354. 13: 0,
  7355. 14: 0,
  7356. 15: 0,
  7357. 53: 0,
  7358. };
  7359. }
  7360. if (tmp.setBullTick) {
  7361. tmp.bullTimer = 0;
  7362. }
  7363. if (tmp.setPoisonTick) {
  7364. tmp.poisonTimer = 0;
  7365. }
  7366. tmp.updateTimer();
  7367. });
  7368. if (inGame) {
  7369. if (enemy.length) {
  7370. if (player.canEmpAnti) {
  7371. player.canEmpAnti = false;
  7372. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  7373. if (near.reloads[53] == 0) {
  7374. player.empAnti = true;
  7375. player.soldierAnti = false;
  7376. //modLog("EmpAnti");
  7377. } else {
  7378. player.empAnti = false;
  7379. player.soldierAnti = true;
  7380. //modLog("SoldierAnti");
  7381. }
  7382. }
  7383. }
  7384. let prehit = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 3) <= (tmp.scale + near.scale)).sort(function(a, b) {
  7385. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7386. })[0];
  7387. if (prehit) {
  7388. if (near.dist2 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  7389. instaC.canSpikeTick = true;
  7390. instaC.syncHit = true;
  7391. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  7392. instaC.revTick = true;
  7393. }
  7394. }
  7395. }
  7396. let antiSpikeTick = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + player.scale)).sort(function(a, b) {
  7397. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  7398. })[0];
  7399. if (antiSpikeTick && !traps.inTrap) {
  7400. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  7401. my.anti0Tick = 1;
  7402. sendChat("If you can read this, I lived.");
  7403. player.chat.count = 2000;
  7404. }
  7405. }
  7406. }
  7407. if ((useWasd ? true : ((player.checkCanInsta(true) >= 100 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100))) && near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 && (instaC.wait || (useWasd && Math.floor(Math.random() * 5) == 0)) && !instaC.isTrue && !my.waitHit && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0 && (useWasd ? true : (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate))) && instaC.perfCheck(player, near)) {
  7408. if (player.checkCanInsta(true) >= 100) {
  7409. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  7410. } else {
  7411. instaC.nobull = false;
  7412. }
  7413. instaC.can = true;
  7414. } else {
  7415. instaC.can = false;
  7416. }
  7417. macro.q && place(0, getAttackDir());
  7418. macro.f && place(4, getSafeDir());
  7419. macro.v && place(2, getSafeDir());
  7420. macro.y && place(1, getSafeDir());
  7421. macro.h && place(player.getItemType(22), getSafeDir());
  7422. macro.n && place(3, getSafeDir());
  7423. if (game.tick % 3 == 0) {
  7424. if (mills.place) {
  7425. let plcAng = 1.2
  7426. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  7427. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7428. }
  7429. }
  7430. } else {
  7431. if (game.tick % .5 == 0) {
  7432. if (mills.placeSpawnPads) {
  7433. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  7434. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7435. }
  7436. }
  7437. }
  7438. }
  7439. if (instaC.can) {
  7440. instaC.changeType(configs.alwaysRev ? "rev" : "normal");
  7441. }
  7442. if (instaC.canCounter) {
  7443. instaC.canCounter = false;
  7444. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7445. instaC.counterType();
  7446. }
  7447. }
  7448. if (instaC.canSpikeTick) {
  7449. instaC.canSpikeTick = false;
  7450. if (instaC.revTick) {
  7451. instaC.revTick = false;
  7452. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  7453. instaC.changeType("rev");
  7454. chch(null, "[RevSyncHit]", "yellow");
  7455. }
  7456. } else {
  7457. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7458. instaC.spikeTickType();
  7459. if (instaC.syncHit) {
  7460. chch(null, "[SyncHit]", "yellow");
  7461. }
  7462. }
  7463. }
  7464. }
  7465. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  7466. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  7467. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  7468. }
  7469. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7470. sendAutoGather();
  7471. my.waitHit = 1;
  7472. game.tickBase(() => {
  7473. sendAutoGather();
  7474. my.waitHit = 0;
  7475. }, 1);
  7476. }
  7477. }
  7478. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  7479. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  7480. selectWeapon(player.weapons[0]);
  7481. }
  7482. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  7483. sendAutoGather();
  7484. my.waitHit = 1;
  7485. game.tickBase(() => {
  7486. sendAutoGather();
  7487. my.waitHit = 0;
  7488. }, 1);
  7489. }
  7490. }
  7491. if (traps.inTrap) {
  7492. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  7493. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  7494. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  7495. }
  7496. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7497. sendAutoGather();
  7498. my.waitHit = 1;
  7499. game.tickBase(() => {
  7500. sendAutoGather();
  7501. my.waitHit = 0;
  7502. }, 1);
  7503. }
  7504. }
  7505. }
  7506. if (clicked.g && !traps.inTrap) {
  7507. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  7508. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  7509. instaC.bowMovement();
  7510. } else {
  7511. instaC.rangeType();
  7512. }
  7513. }
  7514. }
  7515. if (clicked.o && !traps.inTrap) {
  7516. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0) {
  7517. if (my.age1insta && player.weapons[0] == 0 && player.age >= 2 && enemy.length) {
  7518. instaC.age1insta();
  7519. }
  7520. }
  7521. }
  7522. if (macro.t && !traps.inTrap) {
  7523. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && (player.weapons[1] == 15 ? (player.reloads[player.weapons[1]] == 0) : true) && (player.weapons[0] == 5 || (player.weapons[0] == 4 && player.weapons[1] == 15))) {
  7524. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  7525. }
  7526. }
  7527. if (macro["."] && !traps.inTrap) {
  7528. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  7529. instaC.boostTickMovement();
  7530. }
  7531. }
  7532. if (player.weapons[1] && !clicks.left && !clicks.right && !traps.inTrap && !instaC.isTrue && !(useWasd && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8)) {
  7533. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  7534. if (!my.reloaded) {
  7535. my.reloaded = true;
  7536. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  7537. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  7538. selectWeapon(player.weapons[fastSpeed]);
  7539. }
  7540. }
  7541. // if(useWasd) {
  7542. // if (!autos.stopspin) {
  7543. // setTimeout(()=>{
  7544. // autos.stopspin = true;
  7545. // }, 375);
  7546. // }
  7547. // }
  7548. } else {
  7549. my.reloaded = false;
  7550. if(useWasd) {
  7551. autos.stopspin = false;
  7552. }
  7553. if (player.reloads[player.weapons[0]] > 0) {
  7554. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  7555. selectWeapon(player.weapons[0]);
  7556. }
  7557. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  7558. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  7559. selectWeapon(player.weapons[1]);
  7560. }
  7561. if(useWasd) {
  7562. if (!autos.stopspin) {
  7563. setTimeout(()=>{
  7564. autos.stopspin = true;
  7565. }, 750);
  7566. }
  7567. }
  7568. }
  7569. }
  7570. }
  7571. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  7572. traps.autoPlace();
  7573. }
  7574. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  7575. packet("D", getAttackDir());
  7576. }
  7577. let hatChanger = function() {
  7578. if (my.anti0Tick > 0) {
  7579. buyEquip(6, 0);
  7580. } else {
  7581. if (clicks.left || clicks.right) {
  7582. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7583. buyEquip(7, 0);
  7584. buyEquip(13, 1);
  7585. } else {
  7586. if (clicks.left) {
  7587. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 450 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7588. } else if (clicks.right) {
  7589. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 450 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7590. }
  7591. }
  7592. } else if (traps.inTrap) {
  7593. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7594. buyEquip(40, 0);
  7595. } else {
  7596. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7597. buyEquip(7, 0);
  7598. buyEquip(13, 1);
  7599.  
  7600. } else {
  7601. buyEquip((player.empAnti || near.dist2 > 450 || !enemy.length) ? 22 : 6, 0);
  7602. }
  7603. }
  7604. } else {
  7605. if (player.empAnti || player.soldierAnti) {
  7606. buyEquip(player.empAnti ? 22 : 6, 0);
  7607. buyEquip(13, 1);
  7608. } else {
  7609. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7610. buyEquip(7, 0);
  7611. buyEquip(13, 1);
  7612. } else {
  7613. if (near.dist2 <= 450) {
  7614. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  7615. } else {
  7616. biomeGear(1);
  7617. }
  7618. }
  7619. }
  7620. }
  7621. }
  7622. }
  7623. let accChanger = function () {
  7624. if (clicks.left) {
  7625. buyEquip(19, 1);
  7626. } else if (clicks.right) {
  7627. buyEquip(21, 1);
  7628. } else if (near.dist2 <= 400 && near.dist2 >= 225 && !traps.inTrap && !clicks.left && !clicks.right) {
  7629. buyEquip(19, 1);
  7630. } else if (near.dist2 <= 225 && !traps.inTrap && !clicks.left && !clicks.right) {
  7631. buyEquip(21, 1);
  7632. if ((player.shameCount > 0 && player.skinIndex != 45)) {
  7633. buyEquip(7, 0);
  7634. buyEquip(13, 1);
  7635. my.reSync = true;
  7636. my.reSync = false;
  7637. } else {
  7638. buyEquip(6, 0);
  7639. }
  7640. }else {
  7641. traps.inTrap ? buyEquip(19, 1) : buyEquip(11, 1);
  7642. }
  7643. };
  7644. if (my.anti0Tick > 0) {
  7645. buyEquip(6, 0);
  7646. }
  7647. let wasdGears = function() {
  7648. if (my.anti0Tick > 0) {
  7649. buyEquip(12, 0);
  7650. } else {
  7651. if (clicks.left || clicks.right) {
  7652. if (clicks.left) {
  7653. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  7654. } else if (clicks.right) {
  7655. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  7656. }
  7657. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7658. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  7659. } else if (traps.inTrap) {
  7660. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7661. buyEquip(40, 0);
  7662. } else {
  7663. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7664. buyEquip(7, 0);
  7665. buyEquip(19, 1);
  7666. } else {
  7667. buyEquip(player.empAnti ? 22 : 6, 0);
  7668. }
  7669. }
  7670. } else {
  7671. if (player.empAnti) {
  7672. buyEquip(22, 0);
  7673. } else {
  7674. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7675. buyEquip(7, 0);
  7676. buyEquip(19, 1);
  7677. } else {
  7678. buyEquip(6, 0);
  7679. }
  7680. }
  7681. }
  7682. }
  7683. if (clicks.left || clicks.right) {
  7684. if (clicks.left) {
  7685. buyEquip(0, 1);
  7686. }
  7687. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7688. buyEquip(0, 1);
  7689. } else if (traps.inTrap) {
  7690. buyEquip(0, 1);
  7691. } else {
  7692. buyEquip(11, 1);
  7693. }
  7694. }
  7695. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7696. if (useWasd) {
  7697. wasdGears();
  7698. } else {
  7699. hatChanger();
  7700. accChanger();
  7701. }
  7702. }
  7703. //lastMoveDir = getSafeDir();
  7704. //packet("f", lastMoveDir, 1);
  7705. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7706. autoPush();
  7707. } else {
  7708. if (my.autoPush) {
  7709. my.autoPush = false;
  7710. packet("f", lastMoveDir || undefined, 1);
  7711. }
  7712. }
  7713. if (!my.autoPush && pathFind.active) {
  7714. Pathfinder();
  7715. }
  7716. if (instaC.ticking) {
  7717. instaC.ticking = false;
  7718. }
  7719. if (instaC.syncHit) {
  7720. instaC.syncHit = true;
  7721. }
  7722. if (player.empAnti) {
  7723. player.empAnti = false;
  7724. }
  7725. if (player.soldierAnti) {
  7726. player.soldierAnti = false;
  7727. }
  7728. if (my.anti0Tick > 0) {
  7729. my.anti0Tick--;
  7730. }
  7731. if (traps.replaced) {
  7732. traps.replaced = false;
  7733. }
  7734. if (traps.antiTrapped) {
  7735. traps.antiTrapped = false;
  7736. }
  7737. const getPotentialDamage = (build, user) => {
  7738. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7739. const weap = user.weapons[weapIndex];
  7740. if (player.reloads[weap]) return 0;
  7741. const weapon = items.weapons[weap];
  7742. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  7743. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7744. };
  7745.  
  7746. const AutoReplace = () => {
  7747. const replaceable = [];
  7748. const playerX = player.x;
  7749. const playerY = player.y;
  7750. const gameObjectCount = gameObjects.length;
  7751.  
  7752. for (let i = 0; i < gameObjectCount; i++) {
  7753. const build = gameObjects[i];
  7754. if (build.isItem && build.active && build.health > 0) {
  7755. const item = items.list[build.id];
  7756. const posDist = 35 + item.scale + (item.placeOffset || 0);
  7757. const inDistance = cdf(build, player) <= posDist * 2;
  7758. if (inDistance) {
  7759. let canDeal = 0;
  7760. const playersCount = players.length;
  7761. for (let j = 0; j < playersCount; j++) {
  7762. canDeal += getPotentialDamage(build, players[j]);
  7763. }
  7764. if (build.health <= canDeal) {
  7765. replaceable.push(build);
  7766. }
  7767. }
  7768. }
  7769. }
  7770.  
  7771. const findPlacementAngle = (player, itemId, build) => {
  7772. if (!build) return null;
  7773. const MAX_ANGLE = 2 * Math.PI;
  7774. const ANGLE_STEP = Math.PI / 360;
  7775. const item = items.list[player.items[itemId]];
  7776. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7777. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7778.  
  7779. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7780. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7781. for (let angle of angles) {
  7782. return angle;
  7783. }
  7784. }
  7785. return null;
  7786. };
  7787.  
  7788. const replace = (() => {
  7789. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  7790. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  7791. const buildId = spike ? 4 : 2;
  7792.  
  7793. replaceable.forEach(build => {
  7794. let angle = findPlacementAngle(player, buildId, build);
  7795. if (angle !== null) {
  7796. place(buildId, angle);
  7797. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  7798. }
  7799. });
  7800. });
  7801.  
  7802. if (near && near.dist3 <= 360) {
  7803. replace();
  7804. }
  7805. replace;
  7806. }
  7807. }
  7808. }
  7809. if (botSkts.length) {
  7810. botSkts.forEach((bots) => {
  7811. if (true) {
  7812. bots[0].showName = 'YEAHHH';
  7813. }
  7814. });
  7815. }
  7816. }
  7817. for(var i1 = 0; i1 < liztobj.length; i1++) {
  7818. if (liztobj[i1].active && liztobj[i1].health > 0 && UTILS.getDist(liztobj[i1], player, 0, 2) < 150 && getEl("antipush").checked) { // || liztobj[i1].buildHealth <= items.weapons[nearEnemy.weaponIndex].dmg)
  7819.  
  7820. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  7821. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  7822. selectWeapon(player.weapons[1])
  7823. buyEquip(40, 0);
  7824. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  7825. setTickout( () => {
  7826. buyEquip(6, 0)
  7827. }, 1);
  7828. }
  7829. }
  7830. }
  7831. }
  7832. function ez(context, x, y) {
  7833. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  7834. context.beginPath();
  7835. context.fill();
  7836. context.closePath();
  7837. context.globalAlpha = 1;
  7838. }
  7839. // UPDATE LEADERBOARD:
  7840. function updateLeaderboard(data) {
  7841. lastLeaderboardData = data;
  7842. return;
  7843. UTILS.removeAllChildren(leaderboardData);
  7844. let tmpC = 1;
  7845. for (let i = 0; i < data.length; i += 3) {
  7846. (function(i) {
  7847. UTILS.generateElement({
  7848. class: "leaderHolder",
  7849. parent: leaderboardData,
  7850. children: [
  7851. UTILS.generateElement({
  7852. class: "leaderboardItem",
  7853. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  7854. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  7855. }),
  7856. UTILS.generateElement({
  7857. class: "leaderScore",
  7858. text: UTILS.sFormat(data[i + 2]) || "0"
  7859. })
  7860. ]
  7861. });
  7862. })(i);
  7863. tmpC++;
  7864. }
  7865. }
  7866.  
  7867. // LOAD GAME OBJECT:
  7868. function loadGameObject(data) {
  7869. for (let i = 0; i < data.length;) {
  7870. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7871. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7872. sid: data[i + 7]
  7873. } : null));
  7874. // sid, x, y, dir, s, type, data, setSID, owner
  7875. /*let dist = UTILS.getDist({
  7876. x: data[i + 1],
  7877. y: data[i + 2]
  7878. }, player, 0, 2);
  7879. let aim = UTILS.getDirect({
  7880. x: data[i + 1],
  7881. y: data[i + 2]
  7882. }, player, 0, 2);
  7883. find = findObjectBySid(data[i]);
  7884. if (data[i + 6] == 15) {
  7885. if (find && !find.isTeamObject(player)) {
  7886. if (dist <= 100) {
  7887. traps.dist = dist;
  7888. traps.aim = aim;
  7889. traps.protect(aim);
  7890. }
  7891. }
  7892. }*/
  7893. i += 8;
  7894. }
  7895. }
  7896.  
  7897. // ADD AI:
  7898. function loadAI(data) {
  7899. for (let i = 0; i < ais.length; ++i) {
  7900. ais[i].forcePos = !ais[i].visible;
  7901. ais[i].visible = false;
  7902. }
  7903. if (data) {
  7904. let tmpTime = performance.now();
  7905. for (let i = 0; i < data.length;) {
  7906. tmpObj = findAIBySID(data[i]);
  7907. if (tmpObj) {
  7908. tmpObj.index = data[i + 1];
  7909. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7910. tmpObj.t2 = tmpTime;
  7911. tmpObj.x1 = tmpObj.x;
  7912. tmpObj.y1 = tmpObj.y;
  7913. tmpObj.x2 = data[i + 2];
  7914. tmpObj.y2 = data[i + 3];
  7915. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7916. tmpObj.d2 = data[i + 4];
  7917. tmpObj.health = data[i + 5];
  7918. tmpObj.dt = 0;
  7919. tmpObj.visible = true;
  7920. } else {
  7921. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7922. tmpObj.x2 = tmpObj.x;
  7923. tmpObj.y2 = tmpObj.y;
  7924. tmpObj.d2 = tmpObj.dir;
  7925. tmpObj.health = data[i + 5];
  7926. if (!aiManager.aiTypes[data[i + 1]].name)
  7927. tmpObj.name = config.cowNames[data[i + 6]];
  7928. tmpObj.forcePos = true;
  7929. tmpObj.sid = data[i];
  7930. tmpObj.visible = true;
  7931. }
  7932. i += 7;
  7933. }
  7934. }
  7935. }
  7936.  
  7937. // ANIMATE AI:
  7938. function animateAI(sid) {
  7939. tmpObj = findAIBySID(sid);
  7940. if (tmpObj) tmpObj.startAnim();
  7941. }
  7942.  
  7943. // GATHER ANIMATION:
  7944. function gatherAnimation(sid, didHit, index) {
  7945. tmpObj = findPlayerBySID(sid);
  7946. if (tmpObj) {
  7947. tmpObj.startAnim(didHit, index);
  7948. tmpObj.gatherIndex = index;
  7949. tmpObj.gathering = 1;
  7950.  
  7951. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  7952. // healer();
  7953.  
  7954. if (didHit) {
  7955. let tmpObjects = objectManager.hitObj;
  7956. objectManager.hitObj = [];
  7957. game.tickBase(() => {
  7958. // refind
  7959. tmpObj = findPlayerBySID(sid);
  7960. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * (tmpObj.skinIndex == 40 ? 3.3 : 1);
  7961. tmpObjects.forEach((healthy) => {
  7962. healthy.health -= val;
  7963. });
  7964. }, 1);
  7965. }
  7966. }
  7967. }
  7968.  
  7969. // WIGGLE GAME OBJECT:
  7970. function wiggleGameObject(dir, sid) {
  7971. tmpObj = findObjectBySid(sid);
  7972. if (tmpObj) {
  7973. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7974. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7975. if (tmpObj.health) {
  7976. objectManager.hitObj.push(tmpObj);
  7977. }
  7978. }
  7979. }
  7980.  
  7981. // SHOOT TURRET:
  7982. function shootTurret(sid, dir) {
  7983. tmpObj = findObjectBySid(sid);
  7984. if (tmpObj) {
  7985. if (config.anotherVisual) {
  7986. tmpObj.lastDir = dir;
  7987. } else {
  7988. tmpObj.dir = dir;
  7989. }
  7990. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7991. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7992. }
  7993. }
  7994.  
  7995. // UPDATE PLAYER VALUE:
  7996. function updatePlayerValue(index, value, updateView) {
  7997. if (player) {
  7998. player[index] = value;
  7999. if (index == "points") {
  8000. if (configs.autoBuy) {
  8001. autoBuy.hat();
  8002. autoBuy.acc();
  8003. }
  8004. } else if (index == "kills") {
  8005. if (configs.killChat) {
  8006. sendChat("Kids Annihilated: "+value+"");
  8007. setTimeout(() => {
  8008. sendChat("Why aren't you good?");
  8009. setTimeout(() => {
  8010. sendChat("Mod by IAmDaOne -IADO- :3");
  8011. }, 2000);
  8012. }, 2000);
  8013. }
  8014. }
  8015. }
  8016. }
  8017.  
  8018.  
  8019.  
  8020. // ACTION BAR:
  8021. function updateItems(data, wpn) {
  8022. if (data) {
  8023. if (wpn) {
  8024. player.weapons = data;
  8025. player.primaryIndex = player.weapons[0];
  8026. player.secondaryIndex = player.weapons[1];
  8027. if (!instaC.isTrue) {
  8028. selectWeapon(player.weapons[0]);
  8029. }
  8030. } else {
  8031. player.items = data;
  8032. }
  8033. }
  8034.  
  8035. for (let i = 0; i < items.list.length; i++) {
  8036. let tmpI = items.weapons.length + i;
  8037. let actionBarItem = getEl("actionBarItem" + tmpI);
  8038. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  8039. // Add shadow to the element
  8040. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8041. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8042.  
  8043. }
  8044.  
  8045. for (let i = 0; i < items.weapons.length; i++) {
  8046. let actionBarItem = getEl("actionBarItem" + i);
  8047. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  8048. // Add shadow to the element
  8049. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8050. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8051. }
  8052.  
  8053. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  8054. if (kms) {
  8055. getEl("actionBarItem3").style.display = "none";
  8056. getEl("actionBarItem4").style.display = "inline-block";
  8057. }
  8058. }
  8059.  
  8060. // ADD PROJECTILE:
  8061. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  8062. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  8063. runAtNextTick.push(Array.prototype.slice.call(arguments));
  8064. }
  8065.  
  8066. // REMOVE PROJECTILE:
  8067. function remProjectile(sid, range) {
  8068. for (let i = 0; i < projectiles.length; ++i) {
  8069. if (projectiles[i].sid == sid) {
  8070. projectiles[i].range = range;
  8071. let tmpObjects = objectManager.hitObj;
  8072. objectManager.hitObj = [];
  8073. game.tickBase(() => {
  8074. let val = projectiles[i].dmg;
  8075. tmpObjects.forEach((healthy) => {
  8076. if (healthy.projDmg) {
  8077. healthy.health -= val;
  8078. }
  8079. });
  8080. }, 1);
  8081. }
  8082. }
  8083. }
  8084.  
  8085. // SHOW ALLIANCE MENU:
  8086. function allianceNotification(sid, name) {
  8087. let findBotSID = findSID(bots, sid);
  8088. if (findBotSID) {}
  8089. }
  8090.  
  8091. function setPlayerTeam(team, isOwner) {
  8092. if (player) {
  8093. player.team = team;
  8094. player.isOwner = isOwner;
  8095. if (team == null)
  8096. alliancePlayers = [];
  8097. }
  8098. }
  8099.  
  8100. function setAlliancePlayers(data) {
  8101. alliancePlayers = data;
  8102. }
  8103.  
  8104. // STORE MENU:
  8105. function updateStoreItems(type, id, index) {
  8106. if (index) {
  8107. if (!type)
  8108. player.tails[id] = 1;
  8109. else {
  8110. player.latestTail = id;
  8111. }
  8112. } else {
  8113. if (!type)
  8114. player.skins[id] = 1,
  8115. id == 7 && (my.reSync = true); // testing perfect bulltick...
  8116. else {
  8117. player.latestSkin = id;
  8118. }
  8119. }
  8120. }
  8121. let chatting = false;
  8122. document.addEventListener("keypress", function(e) {
  8123. if (e.key == "Enter") {
  8124. chatting = !chatting
  8125. }
  8126. if (e.key == "/" && !chatting) {
  8127. io.send("6", "Fire");
  8128. console.log("clicked /");
  8129. }
  8130. else if (e.key == "'" && !chatting) {
  8131. io.send("6", "I'm better than you");
  8132. console.log("clicked '");
  8133. }
  8134. });
  8135.  
  8136.  
  8137. // SEND MESSAGE:
  8138. function checkProfanityString(text) {
  8139. var tmpString;
  8140. let alwaysfalse = false;
  8141. if (!alwaysfalse) {
  8142. for (var i = 0; i < profanityList.length; ++i) {
  8143. if (text.indexOf(profanityList[i]) > -1) {
  8144. tmpString = "";
  8145. for (var y = 0; y < profanityList[i].length; ++y) {
  8146. tmpString += tmpString.length ? "o" : "M";
  8147. }
  8148. var re = new RegExp(profanityList[i],"g");
  8149. text = text.replace(re, tmpString);
  8150. }
  8151. }
  8152. }
  8153. return text;
  8154. }
  8155. function isTeam(tmpObj) {
  8156. return (tmpObj == player || (tmpObj.team && tmpObj.team == player.team));
  8157. }
  8158. // this.spikeTickType = function() {
  8159. // this.isTrue = true;
  8160. // my.autoAim = true;
  8161. // selectWeapon(player.weapons[0]);
  8162. // buyEquip(7, 0);
  8163. // buyEquip(21, 1);
  8164. // sendAutoGather();
  8165. // game.tickBase(() => {
  8166. // //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  8167. // buyEquip(53, 0);
  8168. // selectWeapon(player.weapons[0]);
  8169. // buyEquip(53, 0);
  8170. // //buyEquip(21, 1);
  8171. // game.tickBase(() => {
  8172. // sendAutoGather();
  8173. // this.isTrue = false;
  8174. // my.autoAim = false;
  8175. // buyEquip(6, 0);
  8176. // }, 3);
  8177. // }, 1);
  8178. // };
  8179. // SEND MESSAGE:
  8180. function receiveChat(sid, message) {
  8181. let tmpPlayer = findPlayerBySID(sid);
  8182. let countDown = 0;
  8183. let coolDownForAI = false;
  8184. tmpPlayer.chatMessage = ((text) => {
  8185. let tmpString;
  8186. profanityList.forEach((list) => {
  8187. if (text.indexOf(list) > -1) {
  8188. tmpString = "";
  8189. for (var y = 0; y < list.length; ++y) {
  8190. tmpString += tmpString.length ? "o" : "M";
  8191. }
  8192. var re = new RegExp(list, 'g');
  8193. text = text.replace(re, tmpString);
  8194. }
  8195. });
  8196. return text;
  8197. })(message);
  8198. tmpPlayer.chatCountdown = config.chatCountdown;
  8199. if (isTeam(tmpPlayer) || player == tmpPlayer) {
  8200. if (message == "Fire") {
  8201. instaC.syncTry();
  8202. io.send("6", "Fire");
  8203. }
  8204. }
  8205. if (getEl("autochat").checked) {
  8206. if (message.includes("what mod")) {
  8207. packet("6", "The best damn mod there is.")
  8208. }
  8209. if (message.includes("mod")) {
  8210. packet("6", "IADO Mod (edited Chimken)")
  8211. }
  8212. if (message.includes("bad")) {
  8213. io.send("6", "you're the bad one, bro");
  8214. } else if (message.includes("Bad")) {
  8215. io.send("6", "How can one be as Bad as you?");
  8216. } else if (message.includes("lag")) {
  8217. io.send("6", "sounds like a skill issue");
  8218. } else if (message.includes("Lag")) {
  8219. io.send("6", "Sounds like a skill issue");
  8220. } else if (message.includes("chill")) {
  8221. io.send("6", "Be chill bro. It's all good");
  8222. } else if (message.includes("Cringe")) {
  8223. io.send("6", "Why are you so Cringe bro?");
  8224. } else if (message.includes("cringe")) {
  8225. io.send("6", "you're so cringe, bro");
  8226. } else if (message.includes("mad")) {
  8227. io.send("6", "why so mad? it's just a game");
  8228. } else if (message.includes("Mad")) {
  8229. io.send("6", "Calm down bro. It's okay baby.");
  8230. } else if (message.includes("idiot")) {
  8231. io.send("6", "the idiot here is you");
  8232. } else if (message.includes("Idiot")) {
  8233. io.send("6", "The Idiot here is you");
  8234. } else if (message.includes("retard")) {
  8235. io.send("6", "retard? Dont put yourself down");
  8236. } else if (message.includes("Retard")) {
  8237. io.send("6", "Retard? Dont put yourself down");
  8238. } else if (message.includes("ok and?")) {
  8239. io.send("6", "And you are dog water.");
  8240. } else if (message.includes("ok and")) {
  8241. io.send("6", "And you are dog water.");
  8242. } else if (message.includes("get a life")) {
  8243. io.send("6", "I'm going to take your life.");
  8244. } else if (message.includes("cry about it")) {
  8245. io.send("6", "cry about how dumb you are");
  8246. } else if (message.includes("fell off")) {
  8247. io.send("6", "I have never been better.");
  8248. } else if (message.includes("get good")) {
  8249. io.send("6", "I'm already the greatest.");
  8250. } else if (message.includes("stupid")) {
  8251. io.send("6", "Me stupid? Look at yourself");
  8252. } else if (message.includes("Stupid")) {
  8253. io.send("6", "You ain't the sharpest pencil.");
  8254. } else if (message.includes("homo")) {
  8255. io.send("6", "It's okay to be gay bro <3");
  8256. } else if (message.includes("Homo")) {
  8257. io.send("6", "It's okay to be gay bro <3");
  8258. } else if (message.includes("noob")) {
  8259. io.send("6", "only noob here is you");
  8260. } else if (message.includes("dumb")) {
  8261. io.send("6", "get smart bro. you're dumb");
  8262. } else if (message.includes("Dumb")) {
  8263. io.send("6", "get smart bro. you're dumb");
  8264. } else if (message.includes("moron")) {
  8265. io.send("6", "Get a brain, moron");
  8266. } else if (message.includes("Moron")) {
  8267. io.send("6", "Get a brain, moron");
  8268. } else if (message.includes("not fun")) {
  8269. io.send("6", "What!? It's so fun!");
  8270. } else if (message.includes("Noob")) {
  8271. io.send("6", "only Noob here is you");
  8272. } else if (message.includes("nub")) {
  8273. io.send("6", "only nub here is you");
  8274. } else if (message.includes("Nub")) {
  8275. io.send("6", "only Nub here is you");
  8276. } else if (message.includes("nob")) {
  8277. io.send("6", "only nob here is you");
  8278. } else if (message.includes("Nob")) {
  8279. io.send("6", "Only nob here is you");
  8280. } else if (message.includes("nab")) {
  8281. io.send("6", "only nab here is you");
  8282. } else if (message.includes("Nab")) {
  8283. io.send("6", "only Nab here is you");
  8284. } else if (message.includes("Nigga")) {
  8285. io.send("6", "Don't say Nigga, Nigga!");
  8286. } else if (message.includes("Nigger")) {
  8287. io.send("6", "Don't say Nigger, Nigger!");
  8288. } else if (message.includes("niggA")) {
  8289. io.send("6", "Don't say Nigga, Nigga!");
  8290. } else if (message.includes("nigger")) {
  8291. io.send("6", "Don't say Nigger, Nigger!?");
  8292. } else if (message.includes("real")) {
  8293. io.send("6", "I'm super real :D");
  8294. } else if (message.includes("loser")) {
  8295. io.send("6", "L is for loser, which is you");
  8296. } else if (message.includes("!c!dc")) {
  8297. io.send("6", "disconnect this retard");
  8298. } else if (message.includes("gay")) {
  8299. io.send("6", "it's okay if you're gay, bro");
  8300. } else if (message.includes("gae")) {
  8301. io.send("6", "it's okay if you're gae, bro");
  8302. } else if (message.includes("Gae")) {
  8303. io.send("6", "it's okay if you're Gae, bro");
  8304. } else if (message.includes("Gay")) {
  8305. io.send("6", "it's okay if you're Gay, bro");
  8306. } else if (message.includes("love u")) {
  8307. io.send("6", "Love u too <3");
  8308. } else if (message.includes("love you")) {
  8309. io.send("6", "Love you too <3");
  8310. } else if (message.includes("luv you")) {
  8311. io.send("6", "Luv you too <3");
  8312. } else if (message.includes("luv u")) {
  8313. io.send("6", "Luv u too <3");
  8314. } else if (message.includes("shit")) {
  8315. io.send("6", "Watch your mouth, shithead!");
  8316. } else if (message.includes("Shit")) {
  8317. io.send("6", "Watch your mouth, Shithead!");
  8318. } else if (message.includes("chimken")) {
  8319. io.send("6", "Bawk bawk, motherclucker.");
  8320. } else if (message.includes("Chimken")) {
  8321. io.send("6", "Cock-a-doddle-doo, Pussy.");
  8322. } else if (message.includes("chicken")) {
  8323. io.send("6", "Bawk bawk, motherclucker.");
  8324. } else if (message.includes("Chicken")) {
  8325. io.send("6", "Cock-A-Doddle-Doo, Pussy.");
  8326. } else if (message.includes("hi")) {
  8327. io.send("6", "hi there! hope you're well :D");
  8328. } else if (message.includes("ngu")) {
  8329. io.send("6", "ngu = you're stupid?");
  8330. } else if (message.includes("Ngu")) {
  8331. io.send("6", "Ngu = You're Stupid?");
  8332. } else if (message.includes("NGU")) {
  8333. io.send("6", "Ngu = YOU'RE STUPID!?");
  8334. } else if (message.includes("hehe")) {
  8335. io.send("6", "hehe x3 so kawaii");
  8336. } else if (message.includes("haha")) {
  8337. io.send("6", "Haha so funny bro");
  8338. } else if (message.includes("huhu")) {
  8339. io.send("6", "what the hell does that mean");
  8340. } else if (message.includes("ez")) {
  8341. io.send("6", "get good ez noob");
  8342. } else if (message.includes("Ez")) {
  8343. io.send("6", "Why are you so ez?");
  8344. } else if (message.includes("easy")) {
  8345. io.send("6", "you're just so easy");
  8346. } else if (message.includes("Easy")) {
  8347. io.send("6", "Why are you so Easy?");
  8348. } else if (message.includes("nigger")) {
  8349. io.send("6", "Don't say nigger, nigger!");
  8350. } else if (message.includes("nigga")) {
  8351. io.send("6", "Don't say nigga, nigga!");
  8352. } else if (message.includes("gg")) {
  8353. io.send("6", "gg bro. Well played");
  8354. } else if (message.includes("Gg")) {
  8355. io.send("6", "Gg bro. Well played.");
  8356. } else if (message.includes("GG")) {
  8357. io.send("6", "GG bro. Well played.");
  8358. } else if (message.includes("lol")) {
  8359. io.send("6", "laugh out loud");
  8360. } else if (message.includes("Lol")) {
  8361. io.send("6", "Laugh out loud more");
  8362. } else if (message.includes("lmao")) {
  8363. io.send("6", "laughing my ass off haha");
  8364. } else if (message.includes("Lmao")) {
  8365. io.send("6", "Laughing My Ass Off HaHa");
  8366. } else if (message.includes("lvl")) {
  8367. io.send("6", "Why? Do you wish to lose?");
  8368. } else if (message.includes("1v1")) {
  8369. io.send("6", "Why? That's literally suicide.");
  8370. } else if (message.includes("hello")) {
  8371. io.send("6", "Hello there, sir or madam.");
  8372. } else if (message.includes("idk")) {
  8373. io.send("6", "Why don't you know? :/");
  8374. } else if (message.includes("Idk")) {
  8375. io.send("6", "Why don't you know? :/");
  8376. } else if (message.includes("IDK")) {
  8377. io.send("6", "WHY DON'T YOU KNOW!? :/");
  8378. } else if (message.includes("xd")) {
  8379. io.send("6", "XD");
  8380. } else if (message.includes("Xd")) {
  8381. io.send("6", "Ex Dee");
  8382. } else if (message.includes("xD")) {
  8383. io.send("6", "Haha XD");
  8384. } else if (message.includes("XD")) {
  8385. io.send("6", "Ex Dee XD");
  8386. } else if (message.includes(":<")) {
  8387. io.send("6", ":>");
  8388. } else if (message.includes(":(")) {
  8389. io.send("6", ":)");
  8390. } else if (message.includes("):")) {
  8391. io.send("6", "(:");
  8392. } else if (message.includes(":C")) {
  8393. io.send("6", "C:");
  8394. } else if (message.includes(":c")) {
  8395. io.send("6", "c:");
  8396. } else if (message.includes("D:")) {
  8397. io.send("6", ":D");
  8398. } else if (message.includes(":)")) {
  8399. io.send("6", ":) So happy!");
  8400. } else if (message.includes("-_-")) {
  8401. io.send("6", "-u- hehe");
  8402. } else if (message.includes("sb")) {
  8403. io.send("6", "sb is slang for sandbox");
  8404. } else if (message.includes("AutoGG")) {
  8405. io.send("6", "Free kill loser");
  8406. } else if (message.includes("Master Race")) {
  8407. io.send("6", "GG! EZ! Master at sucking!");
  8408. } else if (message.includes("autoclicker")) {
  8409. io.send("6", "autoclicker is so Good");
  8410. } else if (message.includes("auto clicker")) {
  8411. io.send("6", "autoclicker means I'm pro");
  8412. } else if (message.includes("trash")) {
  8413. io.send("6", "I know you're trash, bro.");
  8414. } else if (message.includes("Trash")) {
  8415. io.send("6", "I know you're Trash, bro.");
  8416. } else if (message.includes("suck")) {
  8417. io.send("6", "Suck? You're sucking on me? Ew");
  8418. } else if (message.includes("fatherless")) {
  8419. io.send("6", "Yes, you are fatherless.");
  8420. } else if (message.includes("Fatherless")) {
  8421. io.send("6", "No father? Damn bro.");
  8422. } else if (message.includes("motherless")) {
  8423. io.send("6", "Yes, you are motherless.");
  8424. } else if (message.includes("Motherless")) {
  8425. io.send("6", "No mother? Damn bro.");
  8426. } else if (message.includes("hacker")) {
  8427. io.send("6", "No! I am 100% a real pro!");
  8428. } else if (message.includes("Hacker")) {
  8429. io.send("6", "No! I am 100% a real pro!");
  8430. } else if (message.includes("hakers")) {
  8431. io.send("6", "hakers are such noobs!");
  8432. } else if (message.includes("hax")) {
  8433. io.send("6", "Where? I see no hax.. :)");
  8434. } else if (message.includes("I don't know")) {
  8435. io.send("6", "Then learn how to know, idiot");
  8436. } else if (message.includes("I dont know")) {
  8437. io.send("6", "Then learn how to know, idiot");
  8438. } else if (message.includes("issue")) {
  8439. io.send("6", "You have a skill issue, bud");
  8440. } else if (message.includes("kys")) {
  8441. io.send("6", "I know you should! :3");
  8442. } else if (message.includes("killyourself")) {
  8443. io.send("6", "I know you should! :3");
  8444. } else if (message.includes("kill yourself")) {
  8445. io.send("6", "I know you should! :3");
  8446. } else if (message.includes("hate")) {
  8447. io.send("6", "I hate you too >:(");
  8448. } else if (message.includes("hacks")) {
  8449. io.send("6", "Hacks are for noobs!");
  8450. } else if (message.includes("hack")) {
  8451. io.send("6", "No hacks! All pro! :D");
  8452. } else if (message.includes("pro")) {
  8453. io.send("6", "Pro? That's me! 100% skill");
  8454. } else if (message.includes("skill")) {
  8455. io.send("6", "You have a skill issue, bud");
  8456. } else if (message.includes(":/")) {
  8457. io.send("6", "What? :/");
  8458. } else if (message.includes("erm")) {
  8459. io.send("6", "What the sigma?");
  8460. } else if (message.includes("sigma")) {
  8461. io.send("6", "Is that better than alpha? Idk");
  8462. } else if (message.includes("Sigma")) {
  8463. io.send("6", "The highest form of human");
  8464. } else if (message.includes("disconnect")) {
  8465. io.send("6", "Disconnect? Skill issue");
  8466. } else if (message.includes("Goodbye")) {
  8467. io.send("6", "Goodbye. Have a good day.");
  8468. } else if (message.includes("goodbye")) {
  8469. io.send("6", "Goodbye. Have a good day.");
  8470. } else if (message.includes("bye")) {
  8471. io.send("6", "Goodbye. Have a good day.");
  8472. } else if (message.includes("Bye")) {
  8473. io.send("6", "Goodbye. Have a good day.");
  8474. } else if (message.includes("rip")) {
  8475. io.send("6", "Rest in piece. :(");
  8476. } else if (message.includes("idc")) {
  8477. io.send("6", "I dont care that you dont care");
  8478. } else if (message.includes("Idc")) {
  8479. io.send("6", "I Dont Care That You Dont Care");
  8480. } else if (message.includes("IDC")) {
  8481. io.send("6", "I DONT CARE THAT YOU DONT CARE");
  8482. } else if (message.includes("Moomoo")) {
  8483. io.send("6", "Greatest .io game of all time.");
  8484. } else if (message.includes("chad")) {
  8485. io.send("6", "chad? That's who I am!");
  8486. } else if (message.includes("legit")) {
  8487. io.send("6", "Me? Legit? Duh! Cant you tell?");
  8488. } else if (message.includes("moomoo")) {
  8489. io.send("6", "Greatest .io game of all time.");
  8490. } else if (message.includes("cool")) {
  8491. io.send("6", "I know I'm cool. Thanks!");
  8492. } else if (message.includes("girl")) {
  8493. io.send("6", "Ew! Girls have cooties!");
  8494. } else if (message.includes("mom")) {
  8495. io.send("6", "Your mom does not love you");
  8496. } else if (message.includes("dad")) {
  8497. io.send("6", "Your dad left :(");
  8498. } else if (message.includes(":3")) {
  8499. io.send("6", ":3 hehe uwu");
  8500. } else if (message.includes("ass")) {
  8501. io.send("6", "You are actually so ass");
  8502. } else if (message.includes("Ass")) {
  8503. io.send("6", "You are actually so Ass");
  8504. } else if (message.includes("dog water")) {
  8505. io.send("6", "You're dog water, kid.");
  8506. } else if (message.includes("goat")) {
  8507. io.send("6", "I'm the Greatest of All Time.");
  8508. } else if (message.includes("Goat")) {
  8509. io.send("6", "I'm the Greatest of All Time.");
  8510. } else if (message.includes("broke")) {
  8511. io.send("6", "I know you're broke");
  8512. } else if (message.includes("ok")) {
  8513. io.send("6", "ok bro.. :p");
  8514. } else if (message.includes("Okay")) {
  8515. io.send("6", "Okay retard");
  8516. } else if (message.includes("peace")) {
  8517. io.send("6", "peace?... Hmm...");
  8518. } else if (message.includes("Peace")) {
  8519. io.send("6", "Peace?... Hmm...");
  8520. } else if (message.includes("ong")) {
  8521. io.send("6", "ON GOD, GANG!");
  8522. } else if (message.includes("Ong")) {
  8523. io.send("6", "ON GOD, GANG!");
  8524. } else if (message.includes("team")) {
  8525. io.send("6", "team?... Hmm...");
  8526. } else if (message.includes("Team")) {
  8527. io.send("6", "Team?... Hmm...");
  8528. } else if (message.includes("OK")) {
  8529. io.send("6", "OK BUDDY");
  8530. } else if (message.includes("Ok")) {
  8531. io.send("6", "Ok bucko");
  8532. } else if (message.includes("nice")) {
  8533. io.send("6", "Be nice! Be kind! :3");
  8534. } else if (message.includes("spam")) {
  8535. io.send("6", "Cryin about spam? Just get gud");
  8536. } else if (message.includes("Spam")) {
  8537. io.send("6", "Imagine crying about spam LOL");
  8538. } else if (message.includes("help")) {
  8539. io.send("6", "You're gonna need help, bud.");
  8540. } else if (message.includes("cute")) {
  8541. io.send("6", ":3 hehe you're such a cutie!");
  8542. } else if (message.includes("lame")) {
  8543. io.send("6", "You're a certified lame-o");
  8544. } else if (message.includes(":)")) {
  8545. io.send("6", ":D :3 :P :} :] X3");
  8546. } else if (message.includes("Hi")) {
  8547. io.send("6", "Hi there! How's it going?:D");
  8548. } else if (message.includes("mother")) {
  8549. io.send("6", "Your mother doesn't love you");
  8550. } else if (message.includes("Mother")) {
  8551. io.send("6", "Your Mother doesn't love you");
  8552. } else if (message.includes("father")) {
  8553. io.send("6", "Your father doesn't love you");
  8554. } else if (message.includes("Father")) {
  8555. io.send("6", "Your Father doesn't love you");
  8556. } else if (message.includes("lmfao")) {
  8557. io.send("6", "laughing my Fucking ass off");
  8558. } else if (message.includes("Lmfao")) {
  8559. io.send("6", "Laughing My Fucking Ass Off");
  8560. } else if (message.includes("LMFAO")) {
  8561. io.send("6", "LAUGHING MY FUCKING ASS OFF");
  8562. } else if (message.includes("LMAO")) {
  8563. io.send("6", "LAUGHING MY ASS OFF HAHAHA");
  8564. } else if (message.includes("ily")) {
  8565. io.send("6", ":O Omg! I love you too!");
  8566. } else if (message.includes("hola")) {
  8567. io.send("6", "Hola, mi amigo! Como estas?");
  8568. } else if (message.includes("adios")) {
  8569. io.send("6", "Hasta luego, mi amigo!");
  8570. } else if (message.includes("Hola")) {
  8571. io.send("6", "Hola, mi amigo! Como estas?");
  8572. } else if (message.includes("Adios")) {
  8573. io.send("6", "Hasta luego, mi amigo!");
  8574. } else if (message.includes("toxic")) {
  8575. io.send("6", "why so toxic, bro?");
  8576. } else if (message.includes("Toxic")) {
  8577. io.send("6", "It's just a game bro. Relax");
  8578. } else if (message.includes("TOXIC")) {
  8579. io.send("6", "STOP BEING TOXIC >:(");
  8580. } else if (message.includes("Erm")) {
  8581. io.send("6", "What the sigma?");
  8582. } else if (message.includes("welcome")) {
  8583. io.send("6", "Thanks a bunch!");
  8584. } else if (message.includes("auto")) {
  8585. io.send("6", "I am a robot. Beep boop");
  8586. } else if (message.includes("wild")) {
  8587. io.send("6", "actually crazy fr");
  8588. } else if (message.includes("crazy")) {
  8589. io.send("6", "actually wild fr");
  8590. } else if (message.includes("wompwomp")) {
  8591. io.send("6", "womp womp. get good");
  8592. } else if (message.includes("womp")) {
  8593. io.send("6", "womp womp, dumb nigga");
  8594. } else if (message.includes("Womp")) {
  8595. io.send("6", "womp womp, dumb Nigga");
  8596. } else if (message.includes("Hm")) {
  8597. io.send("6", "Hmm.. i'm thinking");
  8598. } else if (message.includes("hm")) {
  8599. io.send("6", "hmm.. i'm thinking");
  8600. } else if (message.includes("ERM")) {
  8601. io.send("6", "WHAT THE SIGMA?!");
  8602. } else if (message.includes("happy")) {
  8603. io.send("6", "I'm so happy! :D");
  8604. } else if (message.includes("cheater")) {
  8605. io.send("6", "Your mom is the cheater, bud.");
  8606. } else if (message.includes("cheat")) {
  8607. io.send("6", "Me? Cheat?! Never!!");
  8608. } else if (message.includes("skibidi")) {
  8609. io.send("6", "please shut the Fuck up");
  8610. } else if (message.includes("Skibidi")) {
  8611. io.send("6", "Brain rot is an actual cancer");
  8612. } else if (message.includes("ligma")) {
  8613. io.send("6", "ligma balls bro");
  8614. } else if (message.includes("Ligma")) {
  8615. io.send("6", "Didn't Ninja die from this?");
  8616. } else if (message.includes("joe")) {
  8617. io.send("6", "joe mama :p");
  8618. } else if (message.includes("Joe")) {
  8619. io.send("6", "Aint that the name of yo mama?");
  8620. } else if (message.includes("ty")) {
  8621. io.send("6", "You're welcome! :D");
  8622. } else if (message.includes("Ty")) {
  8623. io.send("6", "You're very welcome! :D");
  8624. } else if (message.includes("TY")) {
  8625. io.send("6", "You're very welcome! :D");
  8626. } else if (message.includes("sugma")) {
  8627. io.send("6", "sugma balls bro");
  8628. } else if (message.includes("Sugma")) {
  8629. io.send("6", "Heard you had a bad case of this");
  8630. } else if (message.includes("bruh")) {
  8631. io.send("6", "Absolute bruh moment");
  8632. } else if (message.includes("Bruh")) {
  8633. io.send("6", "Absolute Bruh moment");
  8634. } else if (message.includes("Pew")) {
  8635. io.send("6", "Imagine saying Pew retard LMAO");
  8636. } else if (message.includes("pew")) {
  8637. io.send("6", "Only losers say pew, bro.");
  8638. } else if (message.includes("smd")) {
  8639. io.send("6", "suck my dick, nigga");
  8640. } else if (message.includes("Smd")) {
  8641. io.send("6", "Suck my Dick, Nigga");
  8642. } else if (message.includes("SMD")) {
  8643. io.send("6", "SUCK MY DICK, NIGGA");
  8644. } else if (message.includes("bot")) {
  8645. io.send("6", "You're actually such a bot");
  8646. } else if (message.includes("Bot")) {
  8647. io.send("6", "Beep boop, ya Bot");
  8648. } else if (message.includes("Fag")) {
  8649. io.send("6", "It's okay if you're a Fag <3");
  8650. } else if (message.includes("fag")) {
  8651. io.send("6", "It's okay if you're a fag <3");
  8652. } else if (message.includes("afk")) {
  8653. io.send("6", "away from keyboard");
  8654. } else if (message.includes("Afk")) {
  8655. io.send("6", "Away from keyboard");
  8656. } else if (message.includes("AFK")) {
  8657. io.send("6", "Away From Keyboard");
  8658. } else if (message.includes("ngl")) {
  8659. io.send("6", "You're not gonna lie?");
  8660. } else if (message.includes("nga")) {
  8661. io.send("6", "Pretty sure you meant Nigga");
  8662. } else if (message.includes("Nga")) {
  8663. io.send("6", "Don't you mean Nigga?");
  8664. } else if (message.includes("Fuck")) {
  8665. io.send("6", "bro that's a bad word!");
  8666. } else if (message.includes("fuck")) {
  8667. io.send("6", "Don't say fuck, dumb fuck!");
  8668. } else if (message.includes("pussy")) {
  8669. io.send("6", "You are what you eat.");
  8670. } else if (message.includes("Pussy")) {
  8671. io.send("6", "You are what you eat.");
  8672. } else if (message.includes("iado")) {
  8673. io.send("6", "I am not IADO.");
  8674. } else if (message.includes("Iado")) {
  8675. io.send("6", "I am not IADO.");
  8676. } else if (message.includes("IADO")) {
  8677. io.send("6", "I am not IADO.");
  8678. } else if (message.includes("bitch")) {
  8679. io.send("6", "Don't be such a bitch, bruh");
  8680. } else if (message.includes("Bitch")) {
  8681. io.send("6", "I'm a female dog? Huh?");
  8682. } else if (message.includes("smh")) {
  8683. io.send("6", "shake my head.");
  8684. } else if (message.includes("Smh")) {
  8685. io.send("6", "Shake My Head!");
  8686. } else if (message.includes("SMH")) {
  8687. io.send("6", "SHAKE MY HEAD!?!?!");
  8688. } else if (message.includes("annoy")) {
  8689. io.send("6", "You annoy me, peasant.");
  8690. } else if (message.includes("Annoy")) {
  8691. io.send("6", "I'm going to annoy you.");
  8692. } else if (message.includes("<3")) {
  8693. io.send("6", ":O Omg! I <3 you too! :3");
  8694. }
  8695. }
  8696. }
  8697. // MINIMAP:
  8698. function updateMinimap(data) {
  8699. minimapData = data;
  8700. }
  8701.  
  8702. // SHOW ANIM TEXT:
  8703. function showText(x, y, value, type) {
  8704. // if (config.anotherVisual) {
  8705. textManager.stack.push({
  8706. x: x,
  8707. y: y,
  8708. value: value
  8709. });
  8710. // } else {
  8711. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  8712. // }
  8713. }
  8714.  
  8715. /** APPLY SOCKET CODES */
  8716.  
  8717. // BOT:
  8718. let bots = [];
  8719. let ranLocation = {
  8720. x: UTILS.randInt(35, 14365),
  8721. y: UTILS.randInt(35, 14365)
  8722. };
  8723. setInterval(() => {
  8724. ranLocation = {
  8725. x: UTILS.randInt(35, 14365),
  8726. y: UTILS.randInt(35, 14365)
  8727. };
  8728. }, 60000);
  8729. class Bot {
  8730. constructor(id, sid, hats, accessories) {
  8731. this.millPlace = true;
  8732. this.id = id;
  8733. this.sid = sid;
  8734. this.team = null;
  8735. this.skinIndex = 0;
  8736. this.tailIndex = 0;
  8737. this.hitTime = 0;
  8738. this.iconIndex = 0;
  8739. this.enemy = [];
  8740. this.near = [];
  8741. this.dist2 = 0;
  8742. this.aim2 = 0;
  8743. this.tick = 0;
  8744. this.itemCounts = {};
  8745. this.latestSkin = 0;
  8746. this.latestTail = 0;
  8747. this.points = 0;
  8748. this.tails = {};
  8749. for (let i = 0; i < accessories.length; ++i) {
  8750. if (accessories[i].price <= 0)
  8751. this.tails[accessories[i].id] = 1;
  8752. }
  8753. this.skins = {};
  8754. for (let i = 0; i < hats.length; ++i) {
  8755. if (hats[i].price <= 0)
  8756. this.skins[hats[i].id] = 1;
  8757. }
  8758. this.spawn = function(moofoll) {
  8759. this.upgraded = 0;
  8760. this.enemy = [];
  8761. this.near = [];
  8762. this.active = true;
  8763. this.alive = true;
  8764. this.lockMove = false;
  8765. this.lockDir = false;
  8766. this.minimapCounter = 0;
  8767. this.chatCountdown = 0;
  8768. this.shameCount = 0;
  8769. this.shameTimer = 0;
  8770. this.sentTo = {};
  8771. this.gathering = 0;
  8772. this.autoGather = 0;
  8773. this.animTime = 0;
  8774. this.animSpeed = 0;
  8775. this.mouseState = 0;
  8776. this.buildIndex = -1;
  8777. this.weaponIndex = 0;
  8778. this.dmgOverTime = {};
  8779. this.noMovTimer = 0;
  8780. this.maxXP = 300;
  8781. this.XP = 0;
  8782. this.age = 1;
  8783. this.kills = 0;
  8784. this.upgrAge = 2;
  8785. this.upgradePoints = 0;
  8786. this.x = 0;
  8787. this.y = 0;
  8788. this.zIndex = 0;
  8789. this.xVel = 0;
  8790. this.yVel = 0;
  8791. this.slowMult = 1;
  8792. this.dir = 0;
  8793. this.nDir = 0;
  8794. this.dirPlus = 0;
  8795. this.targetDir = 0;
  8796. this.targetAngle = 0;
  8797. this.maxHealth = 100;
  8798. this.health = this.maxHealth;
  8799. this.oldHealth = this.maxHealth;
  8800. this.scale = config.playerScale;
  8801. this.speed = config.playerSpeed;
  8802. this.resetMoveDir();
  8803. this.resetResources(moofoll);
  8804. this.items = [0, 3, 6, 10];
  8805. this.weapons = [0];
  8806. this.shootCount = 0;
  8807. this.weaponXP = [];
  8808. this.isBot = false;
  8809. this.reloads = {
  8810. 0: 0,
  8811. 1: 0,
  8812. 2: 0,
  8813. 3: 0,
  8814. 4: 0,
  8815. 5: 0,
  8816. 6: 0,
  8817. 7: 0,
  8818. 8: 0,
  8819. 9: 0,
  8820. 10: 0,
  8821. 11: 0,
  8822. 12: 0,
  8823. 13: 0,
  8824. 14: 0,
  8825. 15: 0,
  8826. 53: 0,
  8827. };
  8828. this.timeZinceZpawn = 0;
  8829. this.whyDie = "";
  8830. this.clearRadius = false;
  8831. this.circlee = 0;
  8832. };
  8833.  
  8834. // RESET MOVE DIR:
  8835. this.resetMoveDir = function() {
  8836. this.moveDir = undefined;
  8837. };
  8838.  
  8839. // RESET RESOURCES:
  8840. this.resetResources = function(moofoll) {
  8841. for (let i = 0; i < config.resourceTypes.length; ++i) {
  8842. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  8843. }
  8844. };
  8845.  
  8846. // SET DATA:
  8847. this.setData = function(data) {
  8848. this.id = data[0];
  8849. this.sid = data[1];
  8850. this.name = data[2];
  8851. this.x = data[3];
  8852. this.y = data[4];
  8853. this.dir = data[5];
  8854. this.health = data[6];
  8855. this.maxHealth = data[7];
  8856. this.scale = data[8];
  8857. this.skinColor = data[9];
  8858. };
  8859.  
  8860.  
  8861. // SHAME SYSTEM:
  8862. this.judgeShame = function() {
  8863. if (this.oldHealth < this.health) {
  8864. if (this.hitTime) {
  8865. let timeSinceHit = this.tick - this.hitTime;
  8866. this.hitTime = 0;
  8867. if (timeSinceHit < 2) {
  8868. this.lastshamecount = this.shameCount;
  8869. this.shameCount++;
  8870. } else {
  8871. this.lastshamecount = this.shameCount;
  8872. this.shameCount = Math.max(0, this.shameCount - 2);
  8873. }
  8874. }
  8875. } else if (this.oldHealth > this.health) {
  8876. this.hitTime = this.tick;
  8877. }
  8878. };
  8879.  
  8880. // CHECK TEAM
  8881. this.isTeam = function (tmpObj) {
  8882. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  8883.  
  8884. };
  8885. // UPDATE WEAPON RELOAD:
  8886. this.manageReloadaa = function() {
  8887. if (this.shooting[53]) {
  8888. this.shooting[53] = 0;
  8889. this.reloads[53] = (2500 - 1000/9);
  8890. } else {
  8891. if (this.reloads[53] > 0) {
  8892. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  8893. }
  8894. }
  8895. if (this.gathering || this.shooting[1]) {
  8896. if (this.gathering) {
  8897. this.gathering = 0;
  8898. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8899. this.attacked = true;
  8900. }
  8901. if (this.shooting[1]) {
  8902. this.shooting[1] = 0;
  8903. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8904. this.attacked = true;
  8905. }
  8906. } else {
  8907. this.attacked = false;
  8908. if (this.buildIndex < 0) {
  8909. if (this.reloads[this.weaponIndex] > 0) {
  8910. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  8911. }
  8912. }
  8913. }
  8914. };
  8915.  
  8916. this.closeSockets = function(websc) {
  8917. websc.close();
  8918. };
  8919.  
  8920. this.whyDieChat = function(websc, whydie) {
  8921. websc.sendWS("6", whydie + " Get Raped LoLoLoL");
  8922. };
  8923. }
  8924. };
  8925.  
  8926. class BotObject {
  8927. constructor(sid) {
  8928. this.sid = sid;
  8929. // INIT:
  8930. this.init = function(x, y, dir, scale, type, data, owner) {
  8931. data = data || {};
  8932. this.active = true;
  8933. this.x = x;
  8934. this.y = y;
  8935. this.scale = scale;
  8936. this.owner = owner;
  8937. this.id = data.id;
  8938. this.dmg = data.dmg;
  8939. this.trap = data.trap;
  8940. this.teleport = data.teleport;
  8941. this.isItem = this.id != undefined;
  8942. };
  8943.  
  8944. }
  8945. };
  8946. class BotObjManager {
  8947. constructor(botObj, fOS) {
  8948. // DISABLE OBJ:
  8949. this.disableObj = function(obj) {
  8950. obj.active = false;
  8951. if (config.anotherVisual) {} else {
  8952. obj.alive = false;
  8953. }
  8954. };
  8955.  
  8956. // ADD NEW:
  8957. let tmpObj;
  8958. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  8959. tmpObj = fOS(sid);
  8960. if (!tmpObj) {
  8961. tmpObj = botObj.find((tmp) => !tmp.active);
  8962. if (!tmpObj) {
  8963. tmpObj = new BotObject(sid);
  8964. botObj.push(tmpObj);
  8965. }
  8966. }
  8967. if (setSID) {
  8968. tmpObj.sid = sid;
  8969. }
  8970. tmpObj.init(x, y, dir, s, type, data, owner);
  8971. };
  8972.  
  8973. // DISABLE BY SID:
  8974. this.disableBySid = function(sid) {
  8975. let find = fOS(sid);
  8976. if (find) {
  8977. this.disableObj(find);
  8978. }
  8979. };
  8980.  
  8981. // REMOVE ALL FROM PLAYER:
  8982. this.removeAllItems = function(sid, server) {
  8983. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  8984. };
  8985. }
  8986. };
  8987. let botz = [];
  8988. function botSpawn(id) {
  8989. let bot;
  8990. console.log(WS);
  8991. let t = WS.url.split("wss://")[1].split("?")[0];
  8992. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  8993. let botPlayer = new Map();
  8994. botSkts.push([botPlayer]);
  8995. botz.push([bot]);
  8996. let botSID;
  8997. let botObj = [];
  8998. let nearObj = [];
  8999. let bD = {
  9000. x: 0,
  9001. y: 0,
  9002. inGame: false,
  9003. closeSocket: false,
  9004. whyDie: ""
  9005. };
  9006. let oldXY = {
  9007. x: 0,
  9008. y: 0,
  9009. };
  9010. let izauto = 0;
  9011. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  9012. bot.binaryType = "arraybuffer";
  9013. bot.first = true;
  9014. bot.sendWS = function(type) {
  9015. // EXTRACT DATA ARRAY:
  9016. let data = Array.prototype.slice.call(arguments, 1);
  9017. // SEND MESSAGE:
  9018. let binary = window.msgpack.encode([type, data]);
  9019. bot.send(binary);
  9020. };
  9021. bot.spawn = function() {
  9022. bot.sendWS("M", {
  9023. name: "get bagged",
  9024. moofoll: 1,
  9025. skin: "__proto__"
  9026. });
  9027. };
  9028. bot.sendUpgrade = function(index) {
  9029. bot.sendWS("H", index);
  9030. };
  9031. bot.place = function(id, a) {
  9032. try {
  9033. let item = items.list[botPlayer.items[id]];
  9034. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  9035. bot.sendWS("G", botPlayer.items[id]);
  9036. bot.sendWS("d", 1, a);
  9037. bot.sendWS("G", botPlayer.weaponIndex, true);
  9038. }
  9039. } catch (e) {
  9040. }
  9041. };
  9042. bot.buye = function(id, index) {
  9043. let nID = 0;
  9044. if (botPlayer.alive && botPlayer.inGame) {
  9045. if (index == 0) {
  9046. if (botPlayer.skins[id]) {
  9047. if (/*botPlayer.skinIndex != id*/true) {
  9048. bot.sendWS("c", 0, id, 0);
  9049. }
  9050. } else {
  9051. let find = findID(hats, id);
  9052. if (find) {
  9053. if (botPlayer.points >= find.price) {
  9054. bot.sendWS("c", 1, id, 0);
  9055. bot.sendWS("c", 0, id, 0);
  9056. } else {
  9057. if (/*botPlayer.latestSkin != nID*/true) {
  9058. bot.sendWS("c", 0, nID, 0);
  9059. }
  9060. }
  9061. } else {
  9062. if (/*botPlayer.latestSkin != nID*/true) {
  9063. bot.sendWS("c", 0, nID, 0);
  9064. }
  9065. }
  9066. }
  9067. } else if (index == 1) {
  9068. if (botPlayer.tails[id]) {
  9069. if (botPlayer.latestTail != id) {
  9070. bot.sendWS("c", 0, id, 1);
  9071. }
  9072. } else {
  9073. let find = findID(accessories, id);
  9074. if (find) {
  9075. if (botPlayer.points >= find.price) {
  9076. bot.sendWS("c", 1, id, 1);
  9077. bot.sendWS("c", 0, id, 1);
  9078. } else {
  9079. if (botPlayer.latestTail != 0) {
  9080. bot.sendWS("c", 0, 0, 1);
  9081. }
  9082. }
  9083. } else {
  9084. if (botPlayer.latestTail != 0) {
  9085. bot.sendWS("c", 0, 0, 1);
  9086. }
  9087. }
  9088. }
  9089. }
  9090. }
  9091. };
  9092. bot.fastGear = function() {
  9093. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  9094. bot.buye(31, 0);
  9095. } else {
  9096. if (botPlayer.y2 <= config.snowBiomeTop) {
  9097. bot.buye(15, 0);
  9098. } else {
  9099. bot.buye(12, 0);
  9100. }
  9101. }
  9102. };
  9103. bot.selectWeapon = function(a) {
  9104. packet("z", a, 1);
  9105. }
  9106. function caf(e, t) {
  9107. try {
  9108. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  9109. } catch (e) {
  9110. return 0;
  9111. }
  9112. }
  9113. bot.heal = function() {
  9114. if (botPlayer.health < 100) {
  9115. bot.place(0, 0)
  9116. }
  9117. }
  9118. function cdf (e, t){
  9119. try {
  9120. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9121. } catch(e){
  9122. return Infinity;
  9123. }
  9124. }
  9125. let zoon = 'no';
  9126. bot.zync = function(a) {
  9127. if (!botPlayer.millPlace) {
  9128. zoon = 'yeah';
  9129. bot.place(5, caf(botPlayer, a));
  9130. let NextTickLocation = {
  9131. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9132. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9133. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9134. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9135. };
  9136. function calculateDistance(x1, y1, x2, y2) {
  9137. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  9138. return distance;
  9139. }
  9140. function dotherezt() {
  9141. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  9142. }
  9143. let turretSpeed = UTILS.getDistance(near.x, near.y, botPlayer.x2, botPlayer.y2) / 1.5, musketSpeed = (UTILS.getDistance(near.x, near.y, botPlayer.x2, botPlayer.y2) - 35) / 3.6;
  9144. bot.buye(53, 0);
  9145. let aa = setInterval(()=>{
  9146. dotherezt();
  9147. },100)
  9148. setTimeout(()=>{
  9149. bot.sendWS("G", botPlayer.weapons[1], true);
  9150. if (izauto == 0) {
  9151. bot.sendWS("K", 1);
  9152. izauto = 1;
  9153. }
  9154. setTimeout(() => {
  9155. bot.sendWS("G", botPlayer.weapons[0], true);
  9156. clearInterval(aa)
  9157. }, 1000);
  9158. setTimeout(() => {
  9159. zoon = 'no';
  9160. }, 500);
  9161. },turretSpeed-(musketSpeed*2))
  9162. bot.buye(53, 0);
  9163. }
  9164. };
  9165. bot.onmessage = function(message) {
  9166. let data = new Uint8Array(message.data);
  9167. let parsed = window.msgpack.decode(data);
  9168. let type = parsed[0];
  9169. data = parsed[1];
  9170. if (type == "io-init") {
  9171. bot.spawn();
  9172. }
  9173. if (type == "1") {
  9174. botSID = data[0];
  9175. console.log(botSID)
  9176. setInterval(()=>{
  9177. bot.fastGear();
  9178. },60000)
  9179. }
  9180. if (type == "D") {
  9181. if (data[1]) {
  9182. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  9183. botPlayer.setData(data[0]);
  9184. botPlayer.inGame = true;
  9185. botPlayer.alive = true;
  9186. botPlayer.x2 = undefined;
  9187. botPlayer.y2 = undefined;
  9188. botPlayer.spawn(1);
  9189. botPlayer.oldHealth = 100;
  9190. botPlayer.health = 100;
  9191. botPlayer.showName = 'YEAHHH';
  9192. oldXY = {
  9193. x: data[0][3],
  9194. y: data[0][4]
  9195. }
  9196. bD.inGame = true;
  9197. if (bot.first) {
  9198. bot.first = false;
  9199. bots.push(bD);
  9200. }
  9201. }
  9202. }
  9203. if (type == "P") {
  9204. bot.spawn();
  9205. botPlayer.inGame = false;
  9206. bD.inGame = false;
  9207. }
  9208. if (type == "f") {
  9209. let tmpData = data[0];
  9210. botPlayer.tick++;
  9211. botPlayer.enemy = [];
  9212. botPlayer.near = [];
  9213. bot.showName = 'YEAHHH';
  9214. nearObj = [];
  9215. for (let i = 0; i < tmpData.length;) {
  9216. if (tmpData[i] == botPlayer.sid) {
  9217. botPlayer.x2 = tmpData[i + 1];
  9218. botPlayer.y2 = tmpData[i + 2];
  9219. botPlayer.d2 = tmpData[i + 3];
  9220. botPlayer.buildIndex = tmpData[i + 4];
  9221. botPlayer.weaponIndex = tmpData[i + 5];
  9222. botPlayer.weaponVariant = tmpData[i + 6];
  9223. botPlayer.team = tmpData[i + 7];
  9224. botPlayer.isLeader = tmpData[i + 8];
  9225. botPlayer.skinIndex = tmpData[i + 9];
  9226. botPlayer.tailIndex = tmpData[i + 10];
  9227. botPlayer.iconIndex = tmpData[i + 11];
  9228. botPlayer.zIndex = tmpData[i + 12];
  9229. botPlayer.visible = true;
  9230. bD.x2 = botPlayer.x2;
  9231. bD.y2 = botPlayer.y2;
  9232. }
  9233. i += 13;
  9234. }
  9235. for (let i = 0; i < tmpData.length;) {
  9236. tmpObj = findPlayerBySID(tmpData[i]);
  9237. if (tmpObj) {
  9238. if (!tmpObj.isTeam(botPlayer)) {
  9239. enemy.push(tmpObj);
  9240. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  9241. nears.push(tmpObj);
  9242. }
  9243. }
  9244. }
  9245. i += 13;
  9246. }
  9247. if (enemy.length) {
  9248. //console.log(enemy)
  9249. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  9250. return tmp1.dist2 - tmp2.dist2;
  9251. })[0];
  9252. }
  9253. if (izauto == 1) {
  9254. bot.sendWS("K", 1);
  9255. izauto = 0;
  9256. }
  9257. if (bD.closeSocket) {
  9258. botPlayer.closeSockets(bot);
  9259. }
  9260. if (bD.whyDie != "") {
  9261. botPlayer.whyDieChat(bot, bD.whyDie);
  9262. bD.whyDie = "";
  9263. }
  9264. if (botPlayer.alive) {
  9265. if (player.team) {
  9266. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  9267. botPlayer.team && (bot.sendWS("N"));
  9268. bot.sendWS("b", player.team);
  9269. setTimeout(()=>{bot.push(botPlayer.sid)},2000)
  9270. }
  9271. }
  9272. let item = items.list[botPlayer.items[3]];
  9273. let a = botPlayer.itemCounts[item.group.id]
  9274. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  9275. if (botPlayer.inGame) {
  9276. bot.sendWS("D", botPlayer.moveDir);
  9277. if (izauto == 0) {
  9278. bot.sendWS("K", 1);
  9279. izauto = 1;
  9280. }
  9281. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 200) {
  9282. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9283. bot.place(3, aim + 7.7);
  9284. bot.place(3, aim - 7.7);
  9285. bot.place(3, aim);
  9286. oldXY = {
  9287. x: botPlayer.x2,
  9288. y: botPlayer.y2
  9289. };
  9290. }
  9291. if (botPlayer.tick % 90 === 0) {
  9292. let rand = Math.random() * Math.PI * 2;
  9293. botPlayer.moveDir = rand;
  9294. bot.sendWS("a", botPlayer.moveDir);
  9295. }
  9296. }
  9297. bot.fastGear();
  9298. } else if((a != undefined ? a : 0) > 198 && botPlayer.millPlace) {
  9299. botPlayer.millPlace = false;
  9300. if (izauto == 0) {
  9301. bot.sendWS("K", 1);
  9302. izauto = 1;
  9303. }
  9304. bot.buye(11, 1);
  9305. bot.fastGear();
  9306. } else {
  9307. if (botPlayer.inGame) {
  9308. if (botObj.length > 0) {
  9309. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  9310. if (getEl("mode").value == 'fuckemup') {
  9311. // if (getEl("mode").value == "clear") {
  9312. bot.selectWeapon(botPlayer.weapons[1]);
  9313. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  9314. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  9315. nearObj = botObj.filter((e) => e.active && (findSID(buldingtoawdoin, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale/2)).sort(function(a, b) {
  9316. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9317. })[0];
  9318. if (nearObj) {
  9319. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  9320. if ((gotoDist - isPassed) > 0) {
  9321. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9322. if (botPlayer.moveDir != undefined) {
  9323. botPlayer.moveDir = undefined;
  9324. bot.sendWS("f", botPlayer.moveDir);
  9325. bot.sendWS("D", botPlayer.nDir);
  9326. }
  9327. } else {
  9328. botPlayer.moveDir = gotoAim;
  9329. bot.sendWS("f", botPlayer.moveDir);
  9330. bot.sendWS("D", botPlayer.nDir);
  9331. }
  9332. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9333. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9334. bot.sendWS("D", botPlayer.nDir);
  9335. }
  9336. if (izauto == 0) {
  9337. bot.sendWS("K", 1);
  9338. izauto = 1;
  9339. }
  9340. bot.buye(40, 0);
  9341. } else {
  9342. botPlayer.moveDir = gotoAim;
  9343. bot.sendWS("a", botPlayer.moveDir);
  9344. bot.sendWS("D", botPlayer.nDir);
  9345. bot.fastGear();
  9346. }
  9347. } else {
  9348. botPlayer.moveDir = gotoAim;
  9349. bot.sendWS("a", botPlayer.moveDir);
  9350. bot.sendWS("D", botPlayer.nDir);
  9351. bot.fastGear();
  9352. }
  9353. }
  9354. }
  9355. if (botObj.length > 0) {
  9356. if (getEl("mode").value == 'flex') {
  9357. const circleRadius = 300;
  9358. const circleCenterX = player.x2;
  9359. const circleCenterY = player.y2;
  9360. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  9361. angle -= 0.1;
  9362. const x = circleCenterX + circleRadius * Math.cos(angle);
  9363. const y = circleCenterY + circleRadius * Math.sin(angle);
  9364. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9365. }
  9366.  
  9367. }
  9368.  
  9369. if (botObj.length > 0) {
  9370. if (getEl("mode").value == 'mouse') {
  9371. bot.sendWS("a", Math.atan2((player.y2 - botPlayer.y2) + mouseY - (gameCanvas.height / 1.5), (player.x2- botPlayer.x2) + mouseX - (gameCanvas.width / 1.5)));
  9372. }
  9373.  
  9374. }
  9375.  
  9376. if (botObj.length > 0) {
  9377. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  9378. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9379. })[0];
  9380. if (nearObj&&((getEl("mode").value == 'fight'?(nearObj.isTeamObject(player)?false:true):true))) {//herenigga
  9381. if (izauto == 0) {
  9382. bot.sendWS("K", 1);
  9383. izauto = 1;
  9384. }
  9385. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9386. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9387. bot.sendWS("D", botPlayer.nDir);
  9388. }
  9389. bot.buye(40, 0);
  9390. bot.buye(11, 1);
  9391. } else {
  9392. bot.fastGear();
  9393. bot.buye(11, 1);
  9394. }
  9395. bot.buye(11, 1);
  9396. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  9397. bot.selectWeapon(botPlayer.weapons[1]);
  9398. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  9399. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  9400. nearObj = botObj.filter((e) => e.active && (findSID(breakObjects, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale)).sort(function(a, b) {
  9401. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9402. })[0];
  9403. if (nearObj) {
  9404. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  9405. if ((gotoDist - isPassed) > 0) {
  9406. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9407. // botPlayer.moveDir = undefined;
  9408. bot.sendWS("a", caf);
  9409. bot.sendWS("D", botPlayer.nDir);
  9410. } else {
  9411. // botPlayer.moveDir = gotoAim;
  9412. // bot.sendWS("a", botPlayer.moveDir);
  9413. bot.sendWS("D", botPlayer.nDir);
  9414. }
  9415. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9416. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9417. bot.sendWS("D", botPlayer.nDir);
  9418. }
  9419. if (izauto == 0) {
  9420. bot.sendWS("K", 1);
  9421. izauto = 1;
  9422. }
  9423. bot.buye(40, 0);
  9424. // bot.fastGear();
  9425. bot.buye(11, 1);
  9426. } else {
  9427. botPlayer.moveDir = gotoAim;
  9428. bot.sendWS("a", botPlayer.moveDir);
  9429. bot.sendWS("D", botPlayer.nDir);
  9430. bot.fastGear();
  9431. bot.buye(11, 1);
  9432. }
  9433. } else {
  9434. botPlayer.moveDir = gotoAim;
  9435. bot.sendWS("a", botPlayer.moveDir);
  9436. bot.sendWS("D", botPlayer.nDir);
  9437. bot.fastGear();
  9438. bot.buye(11, 1);
  9439. }
  9440. }
  9441. }
  9442. if (botObj.length > 0 && getEl("mode").value == 'stopp') {
  9443. if (cdf(window.stopSpot, botPlayer) <= 220) {
  9444. bot.sendWS("a", undefined);
  9445. bot.fastGear();
  9446. } else {
  9447. bot.sendWS("a", caf(window.stopSpot, botPlayer) + Math.PI);
  9448. }
  9449. }
  9450. if (botObj.length > 0 && getEl("mode").value == 'fight') {
  9451. if(near.sid) {
  9452. const circleRadius = 100;
  9453. const circleCenterX = near.x;
  9454. const circleCenterY = near.y;
  9455. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  9456. angle -= 0.1;
  9457. const x = circleCenterX + circleRadius * Math.cos(angle);
  9458. const y = circleCenterY + circleRadius * Math.sin(angle);
  9459. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9460. if(UTILS.getDist(near, botPlayer, 0, 2) < 200) {
  9461. bot.place(2, Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9462. }
  9463. if(UTILS.getDist(near, botPlayer, 0, 2) < 400) {
  9464. bot.place(2, Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9465. }
  9466. } else{
  9467. const circleRadius = 100;
  9468. const circleCenterX = player.x2;
  9469. const circleCenterY = player.y2;
  9470. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  9471. angle -= 0.1;
  9472. const x = circleCenterX + circleRadius * Math.cos(angle);
  9473. const y = circleCenterY + circleRadius * Math.sin(angle);
  9474. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9475. }
  9476. }
  9477. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  9478. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale/2));
  9479. if (!wdaawdwad.length) {
  9480. if (zoon == 'no') {
  9481. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9482. }
  9483. if (cdf(player, botPlayer) <= 220) {
  9484. bot.sendWS("a", undefined);
  9485. bot.fastGear();
  9486. } else {
  9487. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9488. }
  9489. } else {
  9490. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  9491. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  9492. let nearObjs = botObj.filter((e) => e.active && (findSID(wdaawdwad, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale/2)).sort(function(a, b) {
  9493. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9494. });
  9495. if (nearObjs.length > 0) {
  9496. let nearObj = nearObjs[0];
  9497. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  9498. if ((gotoDist - isPassed) > 0) {
  9499. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9500. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9501. // if (botPlayer.moveDir != undefined) {
  9502. // botPlayer.moveDir = undefined;
  9503. // bot.sendWS("a", botPlayer.moveDir);
  9504. bot.sendWS("D", botPlayer.nDir);
  9505. // }
  9506. } else {
  9507. bot.sendWS("D", botPlayer.nDir);
  9508. }
  9509. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9510. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9511. bot.sendWS("D", botPlayer.nDir);
  9512. }
  9513. bot.buye(40, 0);
  9514. // bot.fastGear();
  9515. bot.buye(11, 1);
  9516. if (izauto == 0) {
  9517. bot.sendWS("K", 1);
  9518. izauto = 1;
  9519. }
  9520. } else {
  9521. if (zoon == 'no') {
  9522. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  9523. }
  9524. if (cdf(player, botPlayer) <= 220) {
  9525. bot.sendWS("a", undefined);
  9526. } else {
  9527. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9528. }
  9529. }
  9530. } else {
  9531. if (wdaawdwad.length) {
  9532. if (zoon == 'no') {
  9533. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  9534. // if (izauto == 0) {
  9535. // bot.sendWS("K", 1);
  9536. // izauto = 1;
  9537. // }
  9538. }
  9539. if (cdf(player, botPlayer) <= 220) {
  9540. bot.sendWS("a", undefined);
  9541. } else {
  9542. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9543. }
  9544. } else {
  9545. if (zoon == 'no') {
  9546. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9547. }
  9548. if (cdf(player, botPlayer) <= 220) {
  9549. bot.sendWS("a", undefined);
  9550. } else {
  9551. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9552. }
  9553. }
  9554. }
  9555. }
  9556. }
  9557. }
  9558. }
  9559. }
  9560. }
  9561. if (type == "H") {
  9562. let tmpData = data[0];
  9563. for (let i = 0; i < tmpData.length;) {
  9564. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  9565. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  9566. sid: tmpData[i + 7]
  9567. } : null));
  9568. i += 8;
  9569. }
  9570. }
  9571. if (type == "N") {
  9572. let index = data[0];
  9573. let value = data[1];
  9574. if (botPlayer) {
  9575. botPlayer[index] = value;
  9576. }
  9577. }
  9578. if (type == "O") {
  9579. if (data[0] == botPlayer.sid) {
  9580. botPlayer.oldHealth = botPlayer.health;
  9581. botPlayer.health = data[1];
  9582. botPlayer.judgeShame();
  9583. if (botPlayer.oldHealth > botPlayer.health) {
  9584. if (botPlayer.shameCount < 5) {
  9585. for (let i = 0; i < 2; i++) {
  9586. bot.place(0, botPlayer.nDir);
  9587. }
  9588. } else {
  9589. setTimeout(() => {
  9590. for (let i = 0; i < 2; i++) {
  9591. bot.place(0, botPlayer.nDir);
  9592. }
  9593. }, 95);
  9594. }
  9595. }
  9596. }
  9597. }
  9598. if (type == "Q") {
  9599. let sid = data[0];
  9600. botObjManager.disableBySid(sid);
  9601. }
  9602. if (type == "R") {
  9603. let sid = data[0];
  9604. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  9605. }
  9606. if (type == "S") {
  9607. let index = data[0];
  9608. let value = data[1];
  9609. if (botPlayer) {
  9610. botPlayer.itemCounts[index] = value;
  9611. }
  9612. }
  9613. if (type == "U") {
  9614. if (data[0] > 0) {
  9615. if(true) {
  9616. if (botPlayer.upgraded == 0) {
  9617. bot.sendUpgrade(3);
  9618. } else if (botPlayer.upgraded == 1) {
  9619. bot.sendUpgrade(17);
  9620. } else if (botPlayer.upgraded == 2) {
  9621. bot.sendUpgrade(31);
  9622. } else if (botPlayer.upgraded == 3) {
  9623. bot.sendUpgrade(27);
  9624. } else if (botPlayer.upgraded == 4) {
  9625. bot.sendUpgrade(9);
  9626. } else if (botPlayer.upgraded == 5) {
  9627. bot.sendUpgrade(34);
  9628. } else if (botPlayer.upgraded == 6) {
  9629. bot.sendUpgrade(12);
  9630. } else if (botPlayer.upgraded == 7) {
  9631. bot.sendUpgrade(15);
  9632. }
  9633. }
  9634. botPlayer.upgraded++;
  9635. }
  9636. }
  9637. if (type == "V") {
  9638. let tmpData = data[0];
  9639. let wpn = data[1];
  9640. if (tmpData) {
  9641. if (wpn) botPlayer.weapons = tmpData;
  9642. else botPlayer.items = tmpData;
  9643. }
  9644. }
  9645. if (type == "5") {
  9646. let type = data[0];
  9647. let id = data[1];
  9648. let index = data[2];
  9649. if (index) {
  9650. if (!type)
  9651. botPlayer.tails[id] = 1;
  9652. else
  9653. botPlayer.latestTail = id;
  9654. } else {
  9655. if (!type)
  9656. botPlayer.skins[id] = 1;
  9657. else
  9658. botPlayer.latestSkin = id;
  9659. }
  9660. }
  9661. if (type == "6") {
  9662. let id = data[0];
  9663. let mzg = data[1]+'';
  9664. if(id == player.sid && mzg.includes("!e")) {
  9665. //bot.zync(botPlayer.near);
  9666. }
  9667. }
  9668. };
  9669. bot.onclose = function() {
  9670. botPlayer.inGame = false;
  9671. bD.inGame = false;
  9672. };
  9673. }
  9674.  
  9675. // RENDER LEAF:
  9676. function renderLeaf(x, y, l, r, ctxt) {
  9677. let endX = x + (l * Math.cos(r));
  9678. let endY = y + (l * Math.sin(r));
  9679. let width = l * 0.4;
  9680. ctxt.moveTo(x, y);
  9681. ctxt.beginPath();
  9682. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  9683. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  9684. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  9685. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  9686. ctxt.closePath();
  9687. ctxt.fill();
  9688. ctxt.stroke();
  9689. }
  9690.  
  9691. // RENDER CIRCLE:
  9692. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9693. tmpContext = tmpContext || mainContext;
  9694. tmpContext.beginPath();
  9695. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9696. if (!dontFill) tmpContext.fill();
  9697. if (!dontStroke) tmpContext.stroke();
  9698. }
  9699.  
  9700. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9701. tmpContext = tmpContext || mainContext;
  9702. tmpContext.beginPath();
  9703. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9704. if (!dontFill) tmpContext.fill();
  9705. if (!dontStroke) tmpContext.stroke();
  9706. }
  9707.  
  9708. // RENDER STAR SHAPE:
  9709. function renderStar(ctxt, spikes, outer, inner) {
  9710. let rot = Math.PI / 2 * 3;
  9711. let x, y;
  9712. let step = Math.PI / spikes;
  9713. ctxt.beginPath();
  9714. ctxt.moveTo(0, -outer);
  9715. for (let i = 0; i < spikes; i++) {
  9716. x = Math.cos(rot) * outer;
  9717. y = Math.sin(rot) * outer;
  9718. ctxt.lineTo(x, y);
  9719. rot += step;
  9720. x = Math.cos(rot) * inner;
  9721. y = Math.sin(rot) * inner;
  9722. ctxt.lineTo(x, y);
  9723. rot += step;
  9724. }
  9725. ctxt.lineTo(0, -outer);
  9726. ctxt.closePath();
  9727. }
  9728.  
  9729. function renderHealthStar(ctxt, spikes, outer, inner) {
  9730. let rot = Math.PI / 2 * 3;
  9731. let x, y;
  9732. let step = Math.PI / spikes;
  9733. ctxt.beginPath();
  9734. ctxt.moveTo(0, -outer);
  9735. for (let i = 0; i < spikes; i++) {
  9736. x = Math.cos(rot) * outer;
  9737. y = Math.sin(rot) * outer;
  9738. ctxt.lineTo(x, y);
  9739. rot += step;
  9740. x = Math.cos(rot) * inner;
  9741. y = Math.sin(rot) * inner;
  9742. ctxt.lineTo(x, y);
  9743. rot += step;
  9744. }
  9745. ctxt.lineTo(0, -outer);
  9746. ctxt.closePath();
  9747. }
  9748.  
  9749. // RENDER RECTANGLE:
  9750. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9751. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9752. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9753. }
  9754.  
  9755. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9756. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9757. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9758. }
  9759.  
  9760. // RENDER RECTCIRCLE:
  9761. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  9762. ctxt.save();
  9763. ctxt.translate(x, y);
  9764. seg = Math.ceil(seg / 2);
  9765. for (let i = 0; i < seg; i++) {
  9766. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  9767. ctxt.rotate(Math.PI / seg);
  9768. }
  9769. ctxt.restore();
  9770. }
  9771.  
  9772. // RENDER BLOB:
  9773. function renderBlob(ctxt, spikes, outer, inner) {
  9774. let rot = Math.PI / 2 * 3;
  9775. let x, y;
  9776. let step = Math.PI / spikes;
  9777. let tmpOuter;
  9778. ctxt.beginPath();
  9779. ctxt.moveTo(0, -inner);
  9780. for (let i = 0; i < spikes; i++) {
  9781. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  9782. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  9783. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  9784. rot += step * 2;
  9785. }
  9786. ctxt.lineTo(0, -inner);
  9787. ctxt.closePath();
  9788. }
  9789.  
  9790. // RENDER TRIANGLE:
  9791. function renderTriangle(s, ctx) {
  9792. ctx = ctx || mainContext;
  9793. let h = s * (Math.sqrt(3) / 2);
  9794. ctx.beginPath();
  9795. ctx.moveTo(0, -h / 2);
  9796. ctx.lineTo(-s / 2, h / 2);
  9797. ctx.lineTo(s / 2, h / 2);
  9798. ctx.lineTo(0, -h / 2);
  9799. ctx.fill();
  9800. ctx.closePath();
  9801. }
  9802.  
  9803. // PREPARE MENU BACKGROUND:
  9804. function prepareMenuBackground() {
  9805. let tmpMid = config.mapScale / 2;
  9806. let attempts = 0;
  9807. for (let i = 0; i < items.list.length * 3;) {
  9808. if (attempts >= 1000) break;
  9809. attempts++;
  9810. let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  9811. let data = {
  9812. x: tmpMid + UTILS.randFloat(-1000, 1000),
  9813. y: tmpMid + UTILS.randFloat(-600, 600),
  9814. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9815. };
  9816. if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  9817. objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  9818. } else {
  9819. continue;
  9820. }
  9821. i++;
  9822. }
  9823. }
  9824. const speed = 35;
  9825. // RENDER PLAYERS:
  9826. function renderDeadPlayers(xOffset, yOffset) {
  9827. mainContext.fillStyle = "#91b2db";
  9828. const currentTime = Date.now();
  9829. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  9830. if (!dead.startTime) {
  9831. dead.startTime = currentTime;
  9832. dead.angle = 0;
  9833. dead.radius = 0.1;
  9834. }
  9835. const timeElapsed = currentTime - dead.startTime;
  9836. const maxAlpha = 1;
  9837. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  9838. dead.animate(delta);
  9839. mainContext.globalAlpha = dead.alpha;
  9840. mainContext.strokeStyle = outlineColor;
  9841. mainContext.save();
  9842. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  9843. dead.radius -= 0.001;
  9844. dead.angle += 0.0174533;
  9845. const moveSpeed = 1;
  9846. const x = dead.radius * Math.cos(dead.angle);
  9847. const y = dead.radius * Math.sin(dead.angle);
  9848. dead.x += x * moveSpeed;
  9849. dead.y += y * moveSpeed;
  9850. mainContext.rotate(dead.angle);
  9851. renderDeadPlayer(dead, mainContext);
  9852. mainContext.restore();
  9853. mainContext.fillStyle = "#91b2db";
  9854. if (timeElapsed >= 3000) {
  9855. dead.active = false;
  9856. dead.startTime = null;
  9857. }
  9858. });
  9859. }
  9860. // RENDER PLAYERS:
  9861. function renderPlayers(xOffset, yOffset, zIndex) {
  9862. mainContext.globalAlpha = 1;
  9863. mainContext.fillStyle = "#91b2db";
  9864. for (var i = 0; i < players.length; ++i) {
  9865. tmpObj = players[i];
  9866. if (tmpObj.zIndex == zIndex) {
  9867. tmpObj.animate(delta);
  9868. if (tmpObj.visible) {
  9869. tmpObj.skinRot += (0.002 * delta);
  9870. tmpDir = (!configs.showDir && !useWasd && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir||0);
  9871. mainContext.save();
  9872. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9873. // RENDER PLAYER:
  9874. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  9875. renderPlayer(tmpObj, mainContext);
  9876. mainContext.restore();
  9877.  
  9878. }
  9879. }
  9880. }
  9881. }
  9882. // RENDER DEAD PLAYER:
  9883. function renderDeadPlayer(obj, ctxt) {
  9884. ctxt = ctxt || mainContext;
  9885. ctxt.lineWidth = outlineWidth;
  9886. ctxt.lineJoin = "miter";
  9887. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  9888. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  9889. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  9890. // TAIL/CAPE:
  9891. renderTail2(13, ctxt, obj);
  9892. // WEAPON BELLOW HANDS:
  9893. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9894. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  9895. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9896. renderProjectile(obj.scale, 0,
  9897. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9898. }
  9899. }
  9900. // HANDS:
  9901. ctxt.fillStyle = "#ececec";
  9902. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9903. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9904. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9905. // WEAPON ABOVE HANDS:
  9906. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9907. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  9908. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9909. renderProjectile(obj.scale, 0,
  9910. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9911. }
  9912. }
  9913. // BUILD ITEM:
  9914. if (obj.buildIndex >= 0) {
  9915. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9916. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9917. }
  9918. // BODY:
  9919. renderCircle(0, 0, obj.scale, ctxt);
  9920. // SKIN
  9921. renderSkin2(48, ctxt, null, obj)
  9922. }
  9923.  
  9924. // RENDER PLAYER:
  9925. function renderPlayer(obj, ctxt) {
  9926. ctxt = ctxt || mainContext;
  9927. ctxt.lineWidth = outlineWidth;
  9928. ctxt.lineJoin = "miter";
  9929. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  9930. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  9931. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  9932.  
  9933. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  9934.  
  9935. // TAIL/CAPE:
  9936. if (obj.tailIndex > 0) {
  9937. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  9938. }
  9939.  
  9940. // WEAPON BELLOW HANDS:
  9941. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9942. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9943. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9944. renderProjectile(obj.scale, 0,
  9945. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9946. }
  9947. }
  9948.  
  9949. // HANDS:
  9950. ctxt.fillStyle = config.skinColors[obj.skinColor];
  9951. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9952. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9953. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9954.  
  9955. // WEAPON ABOVE HANDS:
  9956. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9957. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9958. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9959. renderProjectile(obj.scale, 0,
  9960. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9961. }
  9962. }
  9963.  
  9964. // BUILD ITEM:
  9965. if (obj.buildIndex >= 0) {
  9966. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9967. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9968. }
  9969.  
  9970. // BODY:
  9971. renderCircle(0, 0, obj.scale, ctxt);
  9972.  
  9973. // SKIN:
  9974. if (obj.skinIndex > 0) {
  9975. ctxt.rotate(Math.PI / 2);
  9976. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  9977. }
  9978.  
  9979. }
  9980.  
  9981. // RENDER NORMAL SKIN
  9982. var skinSprites2 = {};
  9983. var skinPointers2 = {};
  9984. function renderSkin2(index, ctxt, parentSkin, owner) {
  9985. tmpSkin = skinSprites2[index];
  9986. if (!tmpSkin) {
  9987. var tmpImage = new Image();
  9988. tmpImage.onload = function() {
  9989. this.isLoaded = true;
  9990. this.onload = null;
  9991. };
  9992. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9993. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9994. skinSprites2[index] = tmpImage;
  9995. tmpSkin = tmpImage;
  9996. }
  9997. var tmpObj = parentSkin||skinPointers2[index];
  9998. if (!tmpObj) {
  9999. for (var i = 0; i < hats.length; ++i) {
  10000. if (hats[i].id == index) {
  10001. tmpObj = hats[i];
  10002. break;
  10003. }
  10004. }
  10005. skinPointers2[index] = tmpObj;
  10006. }
  10007. if (tmpSkin.isLoaded)
  10008. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  10009. if (!parentSkin && tmpObj.topSprite) {
  10010. ctxt.save();
  10011. ctxt.rotate(owner.skinRot);
  10012. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  10013. ctxt.restore();
  10014. }
  10015. }
  10016.  
  10017. // RENDER SKIN:
  10018. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  10019. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  10020. var tmpImage = new Image();
  10021. tmpImage.onload = function() {
  10022. this.isLoaded = true,
  10023. this.onload = null
  10024. }
  10025. ,
  10026. tmpImage.src = setSkinTextureImage(index, "hat", index),
  10027. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  10028. tmpSkin = tmpImage
  10029. }
  10030. var tmpObj = parentSkin||skinPointers[index];
  10031. if (!tmpObj) {
  10032. for (var i = 0; i < hats.length; ++i) {
  10033. if (hats[i].id == index) {
  10034. tmpObj = hats[i];
  10035. break;
  10036. }
  10037. }
  10038. skinPointers[index] = tmpObj;
  10039. }
  10040. if (tmpSkin.isLoaded)
  10041. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  10042. if (!parentSkin && tmpObj.topSprite) {
  10043. ctxt.save();
  10044. ctxt.rotate(owner.skinRot);
  10045. renderSkin(index + "_top", ctxt, tmpObj, owner);
  10046. ctxt.restore();
  10047. }
  10048. }
  10049.  
  10050. var FlareZHat = {
  10051. 7: "https://i.imgur.com/vAOzlyY.png",
  10052. 15: "https://i.imgur.com/YRQ8Ybq.png",
  10053. 40: "https://i.imgur.com/Xzmg27N.png",
  10054. 26: "https://i.imgur.com/I0xGtyZ.png",
  10055. 55: "https://i.imgur.com/uYgDtcZ.png",
  10056. 20: "https://i.imgur.com/f5uhWCk.png",
  10057. };
  10058.  
  10059. function setSkinTextureImage(id, type, id2) {
  10060. if (true) {
  10061. if(FlareZHat[id] && type == "hat") {
  10062. return FlareZHat[id];
  10063. } else {
  10064. if(type == "acc") {
  10065. return ".././img/accessories/access_" + id + ".png";
  10066. } else if(type == "hat") {
  10067. return ".././img/hats/hat_" + id + ".png";
  10068. } else {
  10069. return ".././img/weapons/" + id + ".png";
  10070. }
  10071. }
  10072. } else {
  10073. if(type == "acc") {
  10074. return ".././img/accessories/access_" + id + ".png";
  10075. } else if(type == "hat") {
  10076. return ".././img/hats/hat_" + id + ".png";
  10077. } else {
  10078. return ".././img/weapons/" + id + ".png";
  10079. }
  10080. }
  10081. }
  10082. // RENDER SKINS:
  10083. let skinSprites = {};
  10084. let skinPointers = {};
  10085. let tmpSkin;
  10086.  
  10087. function renderSkin(index, ctxt, parentSkin, owner) {
  10088. tmpSkin = skinSprites[index];
  10089. if (!tmpSkin) {
  10090. let tmpImage = new Image();
  10091. tmpImage.onload = function() {
  10092. this.isLoaded = true;
  10093. this.onload = null;
  10094. };
  10095. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10096. skinSprites[index] = tmpImage;
  10097. tmpSkin = tmpImage;
  10098. }
  10099. let tmpObj = parentSkin || skinPointers[index];
  10100. if (!tmpObj) {
  10101. for (let i = 0; i < hats.length; ++i) {
  10102. if (hats[i].id == index) {
  10103. tmpObj = hats[i];
  10104. break;
  10105. }
  10106. }
  10107. skinPointers[index] = tmpObj;
  10108. }
  10109. if (tmpSkin.isLoaded)
  10110. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  10111. if (!parentSkin && tmpObj.topSprite) {
  10112. ctxt.save();
  10113. ctxt.rotate(owner.skinRot);
  10114. renderSkin(index + "_top", ctxt, tmpObj, owner);
  10115. ctxt.restore();
  10116. }
  10117. }
  10118.  
  10119. // RENDER TAIL:
  10120. var FlareZAcc = {
  10121. 21: "https://i.imgur.com/4ddZert.png",
  10122. 19: "https://i.imgur.com/sULkUZT.png",
  10123. };
  10124. function setTailTextureImage(id, type, id2) {
  10125. if (true) {
  10126. if(FlareZAcc[id] && type == "acc") {
  10127. return FlareZAcc[id];
  10128. } else {
  10129. if(type == "acc") {
  10130. return ".././img/accessories/access_" + id + ".png";
  10131. } else if(type == "hat") {
  10132. return ".././img/hats/hat_" + id + ".png";
  10133. } else {
  10134. return ".././img/weapons/" + id + ".png";
  10135. }
  10136. }
  10137. } else {
  10138. if(type == "acc") {
  10139. return ".././img/accessories/access_" + id + ".png";
  10140. } else if(type == "hat") {
  10141. return ".././img/hats/hat_" + id + ".png";
  10142. } else {
  10143. return ".././img/weapons/" + id + ".png";
  10144. }
  10145. }
  10146. }
  10147. function renderTailTextureImage(index, ctxt, owner) {
  10148. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  10149. var tmpImage = new Image();
  10150. tmpImage.onload = function() {
  10151. this.isLoaded = true,
  10152. this.onload = null
  10153. }
  10154. ,
  10155. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  10156. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  10157. tmpSkin = tmpImage;
  10158. }
  10159. var tmpObj = accessPointers[index];
  10160. if (!tmpObj) {
  10161. for (var i = 0; i < accessories.length; ++i) {
  10162. if (accessories[i].id == index) {
  10163. tmpObj = accessories[i];
  10164. break;
  10165. }
  10166. }
  10167. accessPointers[index] = tmpObj;
  10168. }
  10169. if (tmpSkin.isLoaded) {
  10170. ctxt.save();
  10171. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10172. if (tmpObj.spin)
  10173. ctxt.rotate(owner.skinRot);
  10174. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10175. ctxt.restore();
  10176. }
  10177. }
  10178.  
  10179. let accessSprites = {};
  10180. let accessPointers = {};
  10181. var txt = true;
  10182.  
  10183. function renderTail(index, ctxt, owner) {
  10184. tmpSkin = accessSprites[index];
  10185. if (!tmpSkin) {
  10186. let tmpImage = new Image();
  10187. tmpImage.onload = function() {
  10188. this.isLoaded = true;
  10189. this.onload = null;
  10190. };
  10191. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10192. accessSprites[index] = tmpImage;
  10193. tmpSkin = tmpImage;
  10194. }
  10195. let tmpObj = accessPointers[index];
  10196. if (!tmpObj) {
  10197. for (let i = 0; i < accessories.length; ++i) {
  10198. if (accessories[i].id == index) {
  10199. tmpObj = accessories[i];
  10200. break;
  10201. }
  10202. }
  10203. accessPointers[index] = tmpObj;
  10204. }
  10205. if (tmpSkin.isLoaded) {
  10206. ctxt.save();
  10207. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  10208. if (tmpObj.spin)
  10209. ctxt.rotate(owner.skinRot);
  10210. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  10211. ctxt.restore();
  10212. }
  10213. }
  10214.  
  10215. var accessSprites2 = {};
  10216. var accessPointers2 = {};
  10217. function renderTail2(index, ctxt, owner) {
  10218. tmpSkin = accessSprites2[index];
  10219. if (!tmpSkin) {
  10220. var tmpImage = new Image();
  10221. tmpImage.onload = function() {
  10222. this.isLoaded = true;
  10223. this.onload = null;
  10224. };
  10225. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10226. accessSprites2[index] = tmpImage;
  10227. tmpSkin = tmpImage;
  10228. }
  10229. var tmpObj = accessPointers2[index];
  10230. if (!tmpObj) {
  10231. for (var i = 0; i < accessories.length; ++i) {
  10232. if (accessories[i].id == index) {
  10233. tmpObj = accessories[i];
  10234. break;
  10235. }
  10236. }
  10237. accessPointers2[index] = tmpObj;
  10238. }
  10239. if (tmpSkin.isLoaded) {
  10240. ctxt.save();
  10241. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10242. if (tmpObj.spin)
  10243. ctxt.rotate(owner.skinRot);
  10244. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10245. ctxt.restore();
  10246. }
  10247. }
  10248.  
  10249. // RENDER TOOL:
  10250. let toolSprites = {};
  10251. function renderTool(obj, variant, x, y, ctxt) {
  10252. let tmpSrc = obj.src + (variant || "");
  10253. let tmpSprite = toolSprites[tmpSrc];
  10254. if (!tmpSprite) {
  10255. tmpSprite = new Image();
  10256. tmpSprite.onload = function() {
  10257. this.isLoaded = true;
  10258. }
  10259. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10260. toolSprites[tmpSrc] = tmpSprite;
  10261. }
  10262. if (tmpSprite.isLoaded)
  10263. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  10264. }
  10265.  
  10266. // RENDER PROJECTILES:
  10267. function renderProjectiles(layer, xOffset, yOffset) {
  10268. for (let i = 0; i < projectiles.length; i++) {
  10269. tmpObj = projectiles[i];
  10270. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  10271. tmpObj.update(delta);
  10272. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  10273. mainContext.save();
  10274. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10275. mainContext.rotate(tmpObj.dir);
  10276. renderProjectile(0, 0, tmpObj, mainContext, 1);
  10277. mainContext.restore();
  10278. }
  10279. }
  10280. };
  10281. }
  10282.  
  10283. // RENDER PROJECTILE:
  10284. let projectileSprites = {};//fz iz zexy
  10285.  
  10286. function renderProjectile(x, y, obj, ctxt, debug) {
  10287. if (obj.src) {
  10288. let tmpSrc = items.projectiles[obj.indx].src;
  10289. let tmpSprite = projectileSprites[tmpSrc];
  10290. if (!tmpSprite) {
  10291. tmpSprite = new Image();
  10292. tmpSprite.onload = function() {
  10293. this.isLoaded = true;
  10294. }
  10295. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10296. projectileSprites[tmpSrc] = tmpSprite;
  10297. }
  10298. if (tmpSprite.isLoaded)
  10299. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  10300. } else if (obj.indx == 1) {
  10301. ctxt.fillStyle = "#939393";
  10302. renderCircle(x, y, obj.scale, ctxt);
  10303. }
  10304. }
  10305.  
  10306. // RENDER AI:
  10307. let aiSprites = {};
  10308.  
  10309. function renderAI(obj, ctxt) {
  10310. let tmpIndx = obj.index;
  10311. let tmpSprite = aiSprites[tmpIndx];
  10312. if (!tmpSprite) {
  10313. let tmpImg = new Image();
  10314. tmpImg.onload = function() {
  10315. this.isLoaded = true;
  10316. this.onload = null;
  10317. };
  10318. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  10319. tmpSprite = tmpImg;
  10320. aiSprites[tmpIndx] = tmpSprite;
  10321. }
  10322. if (tmpSprite.isLoaded) {
  10323. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  10324. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  10325. }
  10326. }
  10327.  
  10328. // RENDER WATER BODIES:
  10329. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  10330.  
  10331. // MIDDLE RIVER:
  10332. let tmpW = config.riverWidth + padding;
  10333. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  10334. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  10335. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  10336. }
  10337. }
  10338.  
  10339. // RENDER GAME OBJECTS:
  10340. let gameObjectSprites = {};
  10341.  
  10342. function getResSprite(obj) {
  10343. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  10344. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  10345. let tmpSprite = gameObjectSprites[tmpIndex];
  10346. if (!tmpSprite) {
  10347. let blurScale = 6;
  10348. let tmpCanvas = document.createElement("canvas");
  10349. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  10350. let tmpContext = tmpCanvas.getContext('2d');
  10351. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10352. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  10353. tmpContext.strokeStyle = outlineColor;
  10354. tmpContext.lineWidth = outlineWidth;
  10355. // if (isNight) {
  10356. // tmpContext.shadowBlur = blurScale;
  10357. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  10358. // }
  10359. if (obj.type == 0) {
  10360. let tmpScale;
  10361. let tmpCount = 8;
  10362. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  10363. for (let i = 0; i < 2; ++i) {
  10364. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  10365. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  10366. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  10367. tmpContext.fill();
  10368. if (!i) {
  10369. tmpContext.stroke();
  10370. tmpContext.shadowBlur = null;
  10371. tmpContext.shadowColor = null;
  10372. tmpContext.globalAlpha = 1;
  10373. }
  10374. }
  10375. } else if (obj.type == 1) {
  10376. if (biomeID == 2) {
  10377. tmpContext.fillStyle = "#606060";
  10378. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  10379. tmpContext.fill();
  10380. tmpContext.stroke();
  10381.  
  10382. //tmpContext.shadowBlur = null;
  10383. //tmpContext.shadowColor = null;
  10384.  
  10385. tmpContext.fillStyle = "#89a54c";
  10386. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  10387. tmpContext.fillStyle = "#a5c65b";
  10388. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  10389. } else {
  10390. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  10391. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  10392. tmpContext.fill();
  10393. tmpContext.stroke();
  10394.  
  10395. //tmpContext.shadowBlur = null;
  10396. //tmpContext.shadowColor = null;
  10397.  
  10398. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  10399. let tmpRange;
  10400. let berries = 4;
  10401. let rotVal = (Math.PI * 2) / berries;
  10402. for (let i = 0; i < berries; ++i) {
  10403. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  10404. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10405. UTILS.randInt(10, 12), tmpContext);
  10406. }
  10407. }
  10408. } else if (obj.type == 2 || obj.type == 3) {
  10409. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  10410. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10411. tmpContext.fill();
  10412. tmpContext.stroke();
  10413.  
  10414. tmpContext.shadowBlur = null;
  10415. tmpContext.shadowColor = null;
  10416.  
  10417. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  10418. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10419. tmpContext.fill();
  10420. }
  10421. tmpSprite = tmpCanvas;
  10422. gameObjectSprites[tmpIndex] = tmpSprite;
  10423. }
  10424. return tmpSprite;
  10425. }
  10426.  
  10427. // GET ITEM SPRITE:
  10428. let itemSprites = [];
  10429.  
  10430. function getItemSprite(obj, asIcon) {
  10431. let tmpSprite = itemSprites[obj.id];
  10432. if (!tmpSprite || asIcon) {
  10433. let blurScale = !asIcon ? 20 : 5;
  10434. let tmpCanvas = document.createElement("canvas");
  10435. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  10436. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  10437.  
  10438. let tmpContext = tmpCanvas.getContext("2d");
  10439. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10440. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  10441. tmpContext.strokeStyle = outlineColor;
  10442. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  10443. if (!asIcon) {
  10444. tmpContext.shadowBlur = 8;
  10445. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  10446. }
  10447.  
  10448. if (obj.name == "apple") {
  10449. tmpContext.fillStyle = "#c15555";
  10450. renderCircle(0, 0, obj.scale, tmpContext);
  10451. tmpContext.fillStyle = "#89a54c";
  10452. let leafDir = -(Math.PI / 2);
  10453. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10454. 25, leafDir + Math.PI / 2, tmpContext);
  10455. } else if (obj.name == "cookie") {
  10456. tmpContext.fillStyle = "#cca861";
  10457. renderCircle(0, 0, obj.scale, tmpContext);
  10458. tmpContext.fillStyle = "#937c4b";
  10459. let chips = 4;
  10460. let rotVal = (Math.PI * 2) / chips;
  10461. let tmpRange;
  10462. for (let i = 0; i < chips; ++i) {
  10463. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10464. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10465. UTILS.randInt(4, 5), tmpContext, true);
  10466. }
  10467. } else if (obj.name == "cheese") {
  10468. tmpContext.fillStyle = "#f4f3ac";
  10469. renderCircle(0, 0, obj.scale, tmpContext);
  10470. tmpContext.fillStyle = "#c3c28b";
  10471. let chips = 4;
  10472. let rotVal = (Math.PI * 2) / chips;
  10473. let tmpRange;
  10474. for (let i = 0; i < chips; ++i) {
  10475. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10476. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10477. UTILS.randInt(4, 5), tmpContext, true);
  10478. }
  10479. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10480. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10481. "#a5974c" : "#939393";
  10482. let sides = (obj.name == "castle wall") ? 4 : 3;
  10483. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10484. tmpContext.fill();
  10485. tmpContext.stroke();
  10486. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10487. "#c9b758" : "#bcbcbc";
  10488. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10489. tmpContext.fill();
  10490. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10491. obj.name == "spinning spikes") {
  10492. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10493. let tmpScale = (obj.scale * 0.6);
  10494. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10495. tmpContext.fill();
  10496. tmpContext.stroke();
  10497. tmpContext.fillStyle = "#a5974c";
  10498. renderCircle(0, 0, tmpScale, tmpContext);
  10499. tmpContext.fillStyle = "#c9b758";
  10500. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10501. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10502. tmpContext.fillStyle = "#a5974c";
  10503. renderCircle(0, 0, reScale, tmpContext);
  10504. tmpContext.fillStyle = "#c9b758";
  10505. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10506. tmpContext.fillStyle = "#a5974c";
  10507. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10508. } else if (obj.name == "mine") {
  10509. tmpContext.fillStyle = "#939393";
  10510. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10511. tmpContext.fill();
  10512. tmpContext.stroke();
  10513. tmpContext.fillStyle = "#bcbcbc";
  10514. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10515. tmpContext.fill();
  10516. } else if (obj.name == "sapling") {
  10517. for (let i = 0; i < 2; ++i) {
  10518. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10519. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10520. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10521. tmpContext.fill();
  10522. if (!i) tmpContext.stroke();
  10523. }
  10524. } else if (obj.name == "pit trap") {
  10525. tmpContext.fillStyle = "#a5974c";
  10526. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10527. tmpContext.fill();
  10528. tmpContext.stroke();
  10529. tmpContext.fillStyle = outlineColor;
  10530. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10531. tmpContext.fill();
  10532. } else if (obj.name == "boost pad") {
  10533. tmpContext.fillStyle = "#7e7f82";
  10534. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10535. tmpContext.fill();
  10536. tmpContext.stroke();
  10537. tmpContext.fillStyle = "#dbd97d";
  10538. renderTriangle(obj.scale * 1, tmpContext);
  10539. } else if (obj.name == "turret") {
  10540. tmpContext.fillStyle = "#a5974c";
  10541. renderCircle(0, 0, obj.scale, tmpContext);
  10542. tmpContext.fill();
  10543. tmpContext.stroke();
  10544. tmpContext.fillStyle = "#939393";
  10545. let tmpLen = 50;
  10546. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10547. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10548. tmpContext.fill();
  10549. tmpContext.stroke();
  10550. } else if (obj.name == "platform") {
  10551. tmpContext.fillStyle = "#cebd5f";
  10552. let tmpCount = 4;
  10553. let tmpS = obj.scale * 2;
  10554. let tmpW = tmpS / tmpCount;
  10555. let tmpX = -(obj.scale / 2);
  10556. for (let i = 0; i < tmpCount; ++i) {
  10557. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10558. tmpContext.fill();
  10559. tmpContext.stroke();
  10560. tmpX += tmpS / tmpCount;
  10561. }
  10562. } else if (obj.name == "healing pad") {
  10563. tmpContext.fillStyle = "#7e7f82";
  10564. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10565. tmpContext.fill();
  10566. tmpContext.stroke();
  10567. tmpContext.fillStyle = "#db6e6e";
  10568. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10569. } else if (obj.name == "spawn pad") {
  10570. tmpContext.fillStyle = "#7e7f82";
  10571. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10572. tmpContext.fill();
  10573. tmpContext.stroke();
  10574. tmpContext.fillStyle = "#71aad6";
  10575. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10576. } else if (obj.name == "blocker") {
  10577. tmpContext.fillStyle = "#7e7f82";
  10578. renderCircle(0, 0, obj.scale, tmpContext);
  10579. tmpContext.fill();
  10580. tmpContext.stroke();
  10581. tmpContext.rotate(Math.PI / 4);
  10582. tmpContext.fillStyle = "#db6e6e";
  10583. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10584. } else if (obj.name == "teleporter") {
  10585. tmpContext.fillStyle = "#7e7f82";
  10586. renderCircle(0, 0, obj.scale, tmpContext);
  10587. tmpContext.fill();
  10588. tmpContext.stroke();
  10589. tmpContext.rotate(Math.PI / 4);
  10590. tmpContext.fillStyle = "#d76edb";
  10591. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10592. }
  10593. tmpSprite = tmpCanvas;
  10594. if (!asIcon){
  10595. itemSprites[obj.id] = tmpSprite;
  10596. }
  10597. }
  10598. return tmpSprite;
  10599. }
  10600.  
  10601. function getItemSprite2(obj, tmpX, tmpY) {
  10602. let tmpContext = mainContext;
  10603. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  10604. tmpContext.save();
  10605. tmpContext.translate(tmpX, tmpY);
  10606. tmpContext.rotate(obj.dir);
  10607. tmpContext.strokeStyle = outlineColor;
  10608. tmpContext.lineWidth = outlineWidth;
  10609. if (obj.name == "apple") {
  10610. tmpContext.fillStyle = "#c15555";
  10611. renderCircle(0, 0, obj.scale, tmpContext);
  10612. tmpContext.fillStyle = "#89a54c";
  10613. let leafDir = -(Math.PI / 2);
  10614. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10615. 25, leafDir + Math.PI / 2, tmpContext);
  10616. } else if (obj.name == "cookie") {
  10617. tmpContext.fillStyle = "#cca861";
  10618. renderCircle(0, 0, obj.scale, tmpContext);
  10619. tmpContext.fillStyle = "#937c4b";
  10620. let chips = 4;
  10621. let rotVal = (Math.PI * 2) / chips;
  10622. let tmpRange;
  10623. for (let i = 0; i < chips; ++i) {
  10624. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10625. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10626. UTILS.randInt(4, 5), tmpContext, true);
  10627. }
  10628. } else if (obj.name == "cheese") {
  10629. tmpContext.fillStyle = "#f4f3ac";
  10630. renderCircle(0, 0, obj.scale, tmpContext);
  10631. tmpContext.fillStyle = "#c3c28b";
  10632. let chips = 4;
  10633. let rotVal = (Math.PI * 2) / chips;
  10634. let tmpRange;
  10635. for (let i = 0; i < chips; ++i) {
  10636. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10637. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10638. UTILS.randInt(4, 5), tmpContext, true);
  10639. }
  10640. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10641. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10642. "#a5974c" : "#939393";
  10643. let sides = (obj.name == "castle wall") ? 4 : 3;
  10644. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10645. tmpContext.fill();
  10646. tmpContext.stroke();
  10647. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10648. "#c9b758" : "#bcbcbc";
  10649. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10650. tmpContext.fill();
  10651. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10652. obj.name == "spinning spikes") {
  10653. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10654. let tmpScale = (obj.scale * 0.6);
  10655. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10656. tmpContext.fill();
  10657. tmpContext.stroke();
  10658. tmpContext.fillStyle = "#a5974c";
  10659. renderCircle(0, 0, tmpScale, tmpContext);
  10660. tmpContext.fillStyle = "#c9b758";
  10661. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10662. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10663. tmpContext.fillStyle = "#a5974c";
  10664. renderCircle(0, 0, reScale, tmpContext);
  10665. tmpContext.fillStyle = "#c9b758";
  10666. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10667. tmpContext.fillStyle = "#a5974c";
  10668. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10669. } else if (obj.name == "mine") {
  10670. tmpContext.fillStyle = "#939393";
  10671. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10672. tmpContext.fill();
  10673. tmpContext.stroke();
  10674. tmpContext.fillStyle = "#bcbcbc";
  10675. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10676. tmpContext.fill();
  10677. } else if (obj.name == "sapling") {
  10678. for (let i = 0; i < 2; ++i) {
  10679. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10680. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10681. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10682. tmpContext.fill();
  10683. if (!i) tmpContext.stroke();
  10684. }
  10685. } else if (obj.name == "pit trap") {
  10686. tmpContext.fillStyle = "#a5974c";
  10687. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10688. tmpContext.fill();
  10689. tmpContext.stroke();
  10690. tmpContext.fillStyle = outlineColor;
  10691. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10692. tmpContext.fill();
  10693. } else if (obj.name == "boost pad") {
  10694. tmpContext.fillStyle = "#7e7f82";
  10695. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10696. tmpContext.fill();
  10697. tmpContext.stroke();
  10698. tmpContext.fillStyle = "#dbd97d";
  10699. renderTriangle(obj.scale * 1, tmpContext);
  10700. } else if (obj.name == "turret") {
  10701. tmpContext.fillStyle = "#a5974c";
  10702. renderCircle(0, 0, obj.scale, tmpContext);
  10703. tmpContext.fill();
  10704. tmpContext.stroke();
  10705. tmpContext.fillStyle = "#939393";
  10706. let tmpLen = 50;
  10707. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10708. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10709. tmpContext.fill();
  10710. tmpContext.stroke();
  10711. } else if (obj.name == "platform") {
  10712. tmpContext.fillStyle = "#cebd5f";
  10713. let tmpCount = 4;
  10714. let tmpS = obj.scale * 2;
  10715. let tmpW = tmpS / tmpCount;
  10716. let tmpX = -(obj.scale / 2);
  10717. for (let i = 0; i < tmpCount; ++i) {
  10718. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10719. tmpContext.fill();
  10720. tmpContext.stroke();
  10721. tmpX += tmpS / tmpCount;
  10722. }
  10723. } else if (obj.name == "healing pad") {
  10724. tmpContext.fillStyle = "#7e7f82";
  10725. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10726. tmpContext.fill();
  10727. tmpContext.stroke();
  10728. tmpContext.fillStyle = "#db6e6e";
  10729. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10730. } else if (obj.name == "spawn pad") {
  10731. tmpContext.fillStyle = "#7e7f82";
  10732. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10733. tmpContext.fill();
  10734. tmpContext.stroke();
  10735. tmpContext.fillStyle = "#71aad6";
  10736. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10737. } else if (obj.name == "blocker") {
  10738. tmpContext.fillStyle = "#7e7f82";
  10739. renderCircle(0, 0, obj.scale, tmpContext);
  10740. tmpContext.fill();
  10741. tmpContext.stroke();
  10742. tmpContext.rotate(Math.PI / 4);
  10743. tmpContext.fillStyle = "#db6e6e";
  10744. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10745. } else if (obj.name == "teleporter") {
  10746. tmpContext.fillStyle = "#7e7f82";
  10747. renderCircle(0, 0, obj.scale, tmpContext);
  10748. tmpContext.fill();
  10749. tmpContext.stroke();
  10750. tmpContext.rotate(Math.PI / 4);
  10751. tmpContext.fillStyle = "#d76edb";
  10752. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10753. }
  10754. tmpContext.restore();
  10755. }
  10756.  
  10757. let objSprites = [];
  10758.  
  10759. function getObjSprite(obj) {
  10760. let tmpSprite = objSprites[obj.id];
  10761. if (!tmpSprite) {
  10762. // let blurScale = isNight ? 20 : 0;
  10763. let tmpCanvas = document.createElement("canvas");
  10764. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  10765. let tmpContext = tmpCanvas.getContext("2d");
  10766. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  10767. tmpContext.rotate(Math.PI / 2);
  10768. tmpContext.strokeStyle = outlineColor;
  10769. tmpContext.lineWidth = outlineWidth;
  10770. // if (isNight) {
  10771. // tmpContext.shadowBlur = 20;
  10772. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  10773. // }
  10774. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10775. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  10776. let tmpScale = obj.scale * 0.6;
  10777. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10778. tmpContext.fill();
  10779. tmpContext.stroke();
  10780. tmpContext.fillStyle = "#a5974c";
  10781. renderCircle(0, 0, tmpScale, tmpContext);
  10782. tmpContext.fillStyle = "#cc5151";
  10783. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10784. } else if (obj.name == "pit trap") {
  10785. tmpContext.fillStyle = "#a5974c";
  10786. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10787. tmpContext.fill();
  10788. tmpContext.stroke();
  10789. tmpContext.fillStyle = "#cc5151";
  10790. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10791. tmpContext.fill();
  10792. }
  10793. tmpSprite = tmpCanvas;
  10794. objSprites[obj.id] = tmpSprite;
  10795. }
  10796. return tmpSprite;
  10797. }
  10798.  
  10799. // GET MARK SPRITE:
  10800. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  10801. let center = {
  10802. x: screenWidth / 2,
  10803. y: screenHeight / 2,
  10804. };
  10805. tmpContext.lineWidth = outlineWidth;
  10806. mainContext.globalAlpha = 0.2;
  10807. tmpContext.strokeStyle = outlineColor;
  10808. tmpContext.save();
  10809. tmpContext.translate(tmpX, tmpY);
  10810. tmpContext.rotate(90**10);
  10811. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10812. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  10813. var tmpScale = (obj.scale);
  10814. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  10815. tmpContext.fill();
  10816. tmpContext.stroke();
  10817. tmpContext.fillStyle = "#a5974c";
  10818. renderCircle(0, 0, tmpScale, tmpContext);
  10819. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10820. tmpContext.fillStyle = "#a34040";
  10821. } else {
  10822. tmpContext.fillStyle = "#c9b758";
  10823. }
  10824. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  10825. } else if (obj.name == "turret") {
  10826. renderCircle(0, 0, obj.scale, tmpContext);
  10827. tmpContext.fill();
  10828. tmpContext.stroke();
  10829. tmpContext.fillStyle = "#939393";
  10830. let tmpLen = 50;
  10831. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10832. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10833. tmpContext.fill();
  10834. tmpContext.stroke();
  10835. } else if (obj.name == "teleporter") {
  10836. tmpContext.fillStyle = "#7e7f82";
  10837. renderCircle(0, 0, obj.scale, tmpContext);
  10838. tmpContext.fill();
  10839. tmpContext.stroke();
  10840. tmpContext.rotate(Math.PI / 4);
  10841. tmpContext.fillStyle = "#d76edb";
  10842. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10843. } else if (obj.name == "platform") {
  10844. tmpContext.fillStyle = "#cebd5f";
  10845. let tmpCount = 4;
  10846. let tmpS = obj.scale * 2;
  10847. let tmpW = tmpS / tmpCount;
  10848. let tmpX = -(obj.scale / 2);
  10849. for (let i = 0; i < tmpCount; ++i) {
  10850. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10851. tmpContext.fill();
  10852. tmpContext.stroke();
  10853. tmpX += tmpS / tmpCount;
  10854. }
  10855. } else if (obj.name == "healing pad") {
  10856. tmpContext.fillStyle = "#7e7f82";
  10857. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10858. tmpContext.fill();
  10859. tmpContext.stroke();
  10860. tmpContext.fillStyle = "#db6e6e";
  10861. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10862. } else if (obj.name == "spawn pad") {
  10863. tmpContext.fillStyle = "#7e7f82";
  10864. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10865. tmpContext.fill();
  10866. tmpContext.stroke();
  10867. tmpContext.fillStyle = "#71aad6";
  10868. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10869. } else if (obj.name == "blocker") {
  10870. tmpContext.fillStyle = "#7e7f82";
  10871. renderCircle(0, 0, obj.scale, tmpContext);
  10872. tmpContext.fill();
  10873. tmpContext.stroke();
  10874. tmpContext.rotate(Math.PI / 4);
  10875. tmpContext.fillStyle = "#db6e6e";
  10876. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10877. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10878. tmpContext.fillStyle = "#a5974c";
  10879. renderCircle(0, 0, obj.scale, tmpContext);
  10880. tmpContext.fillStyle = "#c9b758";
  10881. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  10882. tmpContext.fillStyle = "#a5974c";
  10883. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  10884.  
  10885. } else if (obj.name == "pit trap") {
  10886. tmpContext.fillStyle = "#a5974c";
  10887. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10888. tmpContext.fill();
  10889. tmpContext.stroke();
  10890. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10891. tmpContext.fillStyle = "#a34040";
  10892. } else {
  10893. tmpContext.fillStyle = outlineColor;
  10894. }
  10895. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10896. tmpContext.fill();
  10897. }
  10898. tmpContext.restore();
  10899. }
  10900.  
  10901. // OBJECT ON SCREEN:
  10902. function isOnScreen(x, y, s) {
  10903. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  10904. s,
  10905. maxScreenHeight));
  10906. }
  10907.  
  10908. // RENDER GAME OBJECTS:
  10909. function renderGameObjects(layer, xOffset, yOffset) {
  10910. let tmpSprite;
  10911. let tmpX;
  10912. let tmpY;
  10913. liztobj.forEach((tmp) => {
  10914. tmpObj = tmp;
  10915. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  10916. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  10917. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  10918. if (layer == 0) {
  10919. tmpObj.update(delta);
  10920. }
  10921. mainContext.globalAlpha = tmpObj.alpha;
  10922. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  10923. if (tmpObj.isItem) {
  10924. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  10925. tmpSprite = getObjSprite(tmpObj);
  10926. } else {
  10927. tmpSprite = getItemSprite(tmpObj);
  10928. }
  10929.  
  10930. mainContext.save();
  10931. mainContext.translate(tmpX, tmpY);
  10932. mainContext.rotate(tmpObj.dir);
  10933. if (!tmpObj.active) {
  10934. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  10935. }
  10936. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  10937.  
  10938. if (tmpObj.blocker) {
  10939. mainContext.strokeStyle = "#db6e6e";
  10940. mainContext.globalAlpha = 0.3;
  10941. mainContext.lineWidth = 6;
  10942. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  10943. }
  10944. mainContext.restore();
  10945. } else {
  10946. tmpSprite = getResSprite(tmpObj);
  10947. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  10948. }
  10949. }
  10950. if (layer == 3 && !useWasd) {
  10951. if (tmpObj.health < tmpObj.maxHealth) {
  10952. // HEALTH HOLDER:
  10953. mainContext.fillStyle = darkOutlineColor;
  10954. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  10955. mainContext.fill();
  10956.  
  10957. // HEALTH BAR:
  10958. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  10959. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  10960. mainContext.fill();
  10961. }
  10962. }
  10963. }
  10964. });
  10965.  
  10966. // PLACE VISIBLE:
  10967. if (layer == 0) {
  10968. if (placeVisible.length) {
  10969. placeVisible.forEach((places) => {
  10970. tmpX = places.x - xOffset;
  10971. tmpY = places.y - yOffset;
  10972. markObject(places, tmpX, tmpY);
  10973. });
  10974. }
  10975. }
  10976. }
  10977.  
  10978. function markObject(tmpObj, tmpX, tmpY) {
  10979. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  10980. }
  10981.  
  10982. // RENDER MINIMAP:
  10983. class MapPing {
  10984. constructor(color, scale) {
  10985. this.init = function(x, y) {
  10986. this.scale = 0;
  10987. this.x = x;
  10988. this.y = y;
  10989. this.active = true;
  10990. };
  10991. this.update = function(ctxt, delta) {
  10992. if (this.active) {
  10993. this.scale += 0.05 * delta;
  10994. if (this.scale >= scale) {
  10995. this.active = false;
  10996. } else {
  10997. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  10998. ctxt.beginPath();
  10999. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  11000. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  11001. ctxt.stroke();
  11002. }
  11003. }
  11004. };
  11005. this.color = color;
  11006. }
  11007. }
  11008.  
  11009. function pingMap(x, y) {
  11010. tmpPing = mapPings.find(pings => !pings.active);
  11011. if (!tmpPing) {
  11012. tmpPing = new MapPing("#fff", config.mapPingScale);
  11013. mapPings.push(tmpPing);
  11014. }
  11015. tmpPing.init(x, y);
  11016. }
  11017.  
  11018. function updateMapMarker() {
  11019. mapMarker.x = player.x;
  11020. mapMarker.y = player.y;
  11021. }
  11022.  
  11023. function renderMinimap(delta) {
  11024. if (player && player.alive) {
  11025. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  11026.  
  11027. // RENDER PINGS:
  11028. mapContext.lineWidth = 4;
  11029. for (let i = 0; i < mapPings.length; ++i) {
  11030. tmpPing = mapPings[i];
  11031. mapContext.strokeStyle = tmpPing.color;
  11032. tmpPing.update(mapContext, delta);
  11033. }
  11034.  
  11035. // RENDER BREAK TRACKS:
  11036. mapContext.globalAlpha = 1;
  11037. mapContext.fillStyle = "#ff0000";
  11038. if (breakTrackers.length) {
  11039. mapContext.fillStyle = "#abcdef";
  11040. mapContext.font = "34px HammerSmith One";
  11041. mapContext.textBaseline = "middle";
  11042. mapContext.textAlign = "center";
  11043. for (let i = 0; i < breakTrackers.length;) {
  11044. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  11045. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  11046. i += 2;
  11047. }
  11048. }
  11049.  
  11050. // RENDER PLAYERS:
  11051. mapContext.globalAlpha = 1;
  11052. mapContext.fillStyle = "#fff";
  11053. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  11054. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  11055. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  11056. if (player.team && minimapData) {
  11057. for (let i = 0; i < minimapData.length;) {
  11058. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  11059. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  11060. i += 2;
  11061. }
  11062. }
  11063.  
  11064. // RENDER BOTS:
  11065. if (bots.length) {
  11066. bots.forEach((tmp) => {
  11067. if (tmp.inGame) {
  11068. mapContext.globalAlpha = 1;
  11069. mapContext.strokeStyle = "#cc5151";
  11070. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  11071. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  11072. }
  11073. });
  11074. }
  11075.  
  11076. // DEATH LOCATION:
  11077. if (lastDeath) {
  11078. mapContext.fillStyle = "#fc5553";
  11079. mapContext.font = "34px HammerSmith One";
  11080. mapContext.textBaseline = "middle";
  11081. mapContext.textAlign = "center";
  11082. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  11083. (lastDeath.y / config.mapScale) * mapDisplay.height);
  11084. }
  11085.  
  11086. // MAP MARKER:
  11087. if (mapMarker) {
  11088. mapContext.fillStyle = "#fff";
  11089. mapContext.font = "34px HammerSmith One";
  11090. mapContext.textBaseline = "middle";
  11091. mapContext.textAlign = "center";
  11092. mapContext.fillText("✶", (mapMarker.x / config.mapScale) * mapDisplay.width,
  11093. (mapMarker.y / config.mapScale) * mapDisplay.height);
  11094. }
  11095. }
  11096. }
  11097.  
  11098. // ICONS:
  11099. let crossHairs = ["https://cdn.discordapp.com/attachments/1233117653716172952/1235681807262027866/image-from-rawpixel-id-14718496-png_1.png?ex=66373c1c&is=6635ea9c&hm=ab0a218822ebb30965197d2268459c4f8335d369e31255e4c62a133a3cadbcc9&", "https://cdn.discordapp.com/attachments/1233117653716172952/1235681807262027866/image-from-rawpixel-id-14718496-png_1.png?ex=66373c1c&is=6635ea9c&hm=ab0a218822ebb30965197d2268459c4f8335d369e31255e4c62a133a3cadbcc9&"];
  11100. let crossHairSprites = {};
  11101. let iconSprites = {};
  11102. let icons = ["crown", "skull"];
  11103.  
  11104. function loadIcons() {
  11105. for (let i = 0; i < icons.length; ++i) {
  11106. let tmpSprite = new Image();
  11107. tmpSprite.onload = function() {
  11108. this.isLoaded = true;
  11109. };
  11110. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  11111. iconSprites[icons[i]] = tmpSprite;
  11112. }
  11113. for (let i = 0; i < crossHairs.length; ++i) {
  11114. let tmpSprite = new Image();
  11115. tmpSprite.onload = function() {
  11116. this.isLoaded = true;
  11117. };
  11118. tmpSprite.src = crossHairs[i];
  11119. crossHairSprites[i] = tmpSprite;
  11120. }
  11121. }
  11122. loadIcons();
  11123.  
  11124. function cdf (e, t){
  11125. try {
  11126. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  11127. } catch(e){
  11128. return Infinity;
  11129. }
  11130. }
  11131. // UPDATE GAME:
  11132. function updateGame() {
  11133. if(gameObjects.length && inGame) {
  11134. gameObjects.forEach((tmp) => {
  11135. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  11136. if(!liztobj.includes(tmp)) {
  11137. liztobj.push(tmp);
  11138. tmp.render = true;
  11139. }
  11140. } else {
  11141. if(liztobj.includes(tmp)) {
  11142. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11143. tmp.render = false;
  11144. const index = liztobj.indexOf(tmp);
  11145. if (index > -1) { // only splice array when item is found
  11146. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11147. }
  11148. }
  11149. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11150. tmp.render = false;
  11151. const index = liztobj.indexOf(tmp);
  11152. if (index > -1) { // only splice array when item is found
  11153. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11154. }
  11155. } else {
  11156. tmp.render = false;
  11157. const index = liztobj.indexOf(tmp);
  11158. if (index > -1) { // only splice array when item is found
  11159. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11160. }
  11161. }
  11162. }
  11163. })
  11164. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  11165. }
  11166.  
  11167. // if (config.resetRender) {
  11168. mainContext.beginPath();
  11169. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  11170. // }
  11171. mainContext.globalAlpha = 1;
  11172.  
  11173. // MOVE CAMERA:
  11174. if (player) {
  11175. if (false) {
  11176. camX = player.x;
  11177. camY = player.y;
  11178. } else {
  11179. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  11180. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  11181. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  11182. if (tmpDist > 0.05) {
  11183. camX += camSpd * Math.cos(tmpDir);
  11184. camY += camSpd * Math.sin(tmpDir);
  11185. } else {
  11186. camX = player.x;
  11187. camY = player.y;
  11188. }
  11189. }
  11190. } else {
  11191. camX = config.mapScale / 2 + config.riverWidth;
  11192. camY = config.mapScale / 2;
  11193. }
  11194. // PATHFINDER LINE
  11195. if (pathFind.active) {
  11196. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  11197. mainContext.lineWidth = player.scale / 5;
  11198. mainContext.globalAlpha = 1;
  11199. mainContext.strokeStyle = "red";
  11200. mainContext.beginPath();
  11201. pathFind.array.forEach((path, i) => {
  11202. let pathXY = {
  11203. x: (pathFind.scale / pathFind.grid) * path.x,
  11204. y: (pathFind.scale / pathFind.grid) * path.y
  11205. }
  11206. let render = {
  11207. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  11208. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  11209. }
  11210. if (i == 0) {
  11211. mainContext.moveTo(render.x, render.y);
  11212. } else {
  11213. mainContext.lineTo(render.x, render.y);
  11214. }
  11215. });
  11216. mainContext.stroke();
  11217. }
  11218. }
  11219. // INTERPOLATE PLAYERS AND AI:
  11220. let lastTime = now - (1000 / config.serverUpdateRate);
  11221. let tmpDiff;
  11222. for (let i = 0; i < players.length + ais.length; ++i) {
  11223. tmpObj = players[i] || ais[i - players.length];
  11224. if (tmpObj && tmpObj.visible) {
  11225. if (tmpObj.forcePos) {
  11226. tmpObj.x = tmpObj.x2;
  11227. tmpObj.y = tmpObj.y2;
  11228. tmpObj.dir = tmpObj.d2;
  11229. } else {
  11230. let total = tmpObj.t2 - tmpObj.t1;
  11231. let fraction = lastTime - tmpObj.t1;
  11232. let ratio = (fraction / total);
  11233. let rate = 170;
  11234. tmpObj.dt += delta;
  11235. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  11236. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  11237. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  11238. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  11239. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  11240. if (config.anotherVisual) {
  11241. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11242. } else {
  11243. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11244. }
  11245. }
  11246. }
  11247. }
  11248.  
  11249. // RENDER CORDS:
  11250. let xOffset = camX - (maxScreenWidth / 2);
  11251. let yOffset = camY - (maxScreenHeight / 2);
  11252.  
  11253. // RENDER BACKGROUND:
  11254. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11255. mainContext.fillStyle = "#b6db66";
  11256. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11257. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  11258. mainContext.fillStyle = "#dbc666";
  11259. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11260. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11261. mainContext.fillStyle = "#fff";
  11262. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11263. } else if (config.snowBiomeTop - yOffset >= 0) {
  11264. mainContext.fillStyle = "#fff";
  11265. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  11266. mainContext.fillStyle = "#b6db66";
  11267. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  11268. maxScreenHeight - (config.snowBiomeTop - yOffset));
  11269. } else {
  11270. mainContext.fillStyle = "#b6db66";
  11271. mainContext.fillRect(0, 0, maxScreenWidth,
  11272. (config.mapScale - config.snowBiomeTop - yOffset));
  11273. mainContext.fillStyle = "#dbc666";
  11274. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  11275. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  11276. }
  11277.  
  11278. // RENDER WATER AREAS:
  11279. if (!firstSetup) {
  11280. waterMult += waterPlus * config.waveSpeed * delta;
  11281. if (waterMult >= config.waveMax) {
  11282. waterMult = config.waveMax;
  11283. waterPlus = -1;
  11284. } else if (waterMult <= 1) {
  11285. waterMult = waterPlus = 1;
  11286. }
  11287. mainContext.globalAlpha = 1;
  11288. mainContext.fillStyle = "#dbc666";
  11289. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  11290. mainContext.fillStyle = "#91b2db";
  11291. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  11292. }
  11293.  
  11294. // RENDER DEAD PLAYERS:
  11295. mainContext.globalAlpha = 1;
  11296. mainContext.strokeStyle = outlineColor;
  11297. renderDeadPlayers(xOffset, yOffset);
  11298.  
  11299. // RENDER BOTTOM LAYER:
  11300. mainContext.globalAlpha = 1;
  11301. mainContext.strokeStyle = outlineColor;
  11302. renderGameObjects(-1, xOffset, yOffset);
  11303.  
  11304. // RENDER PROJECTILES:
  11305. mainContext.globalAlpha = 1;
  11306. mainContext.lineWidth = outlineWidth;
  11307. renderProjectiles(0, xOffset, yOffset);
  11308.  
  11309. // RENDER PLAYERS:
  11310. renderPlayers(xOffset, yOffset, 0);
  11311.  
  11312. // RENDER AI:
  11313. mainContext.globalAlpha = 1;
  11314. for (let i = 0; i < ais.length; ++i) {
  11315. tmpObj = ais[i];
  11316. if (tmpObj.active && tmpObj.visible) {
  11317. tmpObj.animate(delta);
  11318. mainContext.save();
  11319. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11320. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  11321. renderAI(tmpObj, mainContext);
  11322. mainContext.restore();
  11323. }
  11324. }
  11325.  
  11326. // RENDER GAME OBJECTS (LAYERED):
  11327. renderGameObjects(0, xOffset, yOffset);
  11328. renderProjectiles(1, xOffset, yOffset);
  11329. renderGameObjects(1, xOffset, yOffset);
  11330. renderPlayers(xOffset, yOffset, 1);
  11331. renderGameObjects(2, xOffset, yOffset);
  11332. renderGameObjects(3, xOffset, yOffset);
  11333.  
  11334. // MAP BOUNDARIES:
  11335. mainContext.fillStyle = "#000";
  11336. mainContext.globalAlpha = 0.09;
  11337. if (xOffset <= 0) {
  11338. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  11339. }
  11340. if (config.mapScale - xOffset <= maxScreenWidth) {
  11341. let tmpY = Math.max(0, -yOffset);
  11342. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  11343. }
  11344. if (yOffset <= 0) {
  11345. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  11346. }
  11347. if (config.mapScale - yOffset <= maxScreenHeight) {
  11348. let tmpX = Math.max(0, -xOffset);
  11349. let tmpMin = 0;
  11350. if (config.mapScale - xOffset <= maxScreenWidth)
  11351. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  11352. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  11353. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  11354. }
  11355. // RENDER DAY/NIGHT TIME:
  11356. mainContext.globalAlpha = 1;
  11357. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  11358. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11359.  
  11360. // RENDER PLAYER AND AI UI:
  11361. mainContext.strokeStyle = darkOutlineColor;
  11362. mainContext.globalAlpha = 1;
  11363.  
  11364. for (let i = 0; i < players.length + ais.length; ++i) {
  11365. tmpObj = players[i] || ais[i - players.length];
  11366. if (tmpObj.visible && tmpObj.showName === 'YEAHHH') {
  11367. mainContext.strokeStyle = darkOutlineColor;
  11368.  
  11369. // NAME AND HEALTH:
  11370.  
  11371. // let izbot = false;
  11372.  
  11373. // bots.forEach((bot) => {
  11374. // if (tmpObj.sid == bot.sid) izbot = true
  11375. // else izbot = false;
  11376. // });
  11377.  
  11378. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  11379. if (tmpText != "" && tmpObj.name != "Trash Slave") {
  11380. // bots.forEach((bot) => {
  11381. // if (tmpObj.sid == bot.sid) return;
  11382. // });
  11383.  
  11384. mainContext.font = (tmpObj.nameScale || 30) + "px HammerSmith One";
  11385. mainContext.fillStyle = "#fff";
  11386. mainContext.textBaseline = "middle";
  11387. mainContext.textAlign = "center";
  11388. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  11389. mainContext.lineJoin = "round";
  11390. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11391. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11392. if (tmpObj.isLeader && iconSprites.crown.isLoaded) {
  11393. let tmpS = config.crownIconScale;
  11394. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  11395. mainContext.drawImage(iconSprites.crown, tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11396. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11397. }
  11398. if (tmpObj.iconIndex == 1 && iconSprites.skull.isLoaded) {
  11399. let tmpS = config.crownIconScale;
  11400. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  11401. mainContext.drawImage(iconSprites.skull, tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11402. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11403. }
  11404. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (crossHairSprites[1].isLoaded) && enemy.length && !useWasd) {
  11405. let tmpS = tmpObj.scale * 2.2;
  11406. mainContext.drawImage((crossHairSprites[1]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  11407. }
  11408. // izbot = false;
  11409. }
  11410. if (tmpObj.health > 0) {
  11411.  
  11412. if(tmpObj.name != "Trash Slave") {
  11413. // HEALTH HOLDER:
  11414. mainContext.fillStyle = darkOutlineColor;
  11415. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  11416. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  11417. (config.healthBarPad * 2), 17, 8);
  11418. mainContext.fill();
  11419.  
  11420. // HEALTH BAR:
  11421. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  11422. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  11423. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  11424. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  11425. mainContext.fill();
  11426. }
  11427.  
  11428. if (tmpObj.isPlayer) {
  11429. mainContext.globalAlpha = 1;
  11430. let targetReloads = {
  11431. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  11432. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  11433. turret: (2500 - tmpObj.reloads[53]) / 2500
  11434. };
  11435. if (!tmpObj.currentReloads) {
  11436. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  11437. primary: targetReloads.primary,
  11438. secondary: targetReloads.secondary,
  11439. turret: targetReloads.turret
  11440. };
  11441. }
  11442. const lerpFactor = 0.3;
  11443. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  11444. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  11445. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  11446.  
  11447. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  11448. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  11449. const centerX = tmpObj.x - xOffset;
  11450. const centerY = tmpObj.y - yOffset;
  11451. const barRadius = 35;
  11452. const barWidth = 15;
  11453. const totalAngle = (Math.PI*2)/3; // Half circle
  11454. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  11455. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  11456. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  11457. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  11458.  
  11459. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  11460. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  11461. function returncoolcolor(RainbowCycle) {
  11462. return `hsl(${RainbowCycle-50}, 85%, 50%, 30)`;
  11463. }
  11464.  
  11465. mainContext.save();
  11466. if (tmpObj.currentReloads.primary < 0.999) {
  11467. mainContext.beginPath();
  11468. mainContext.lineCap = 'round';
  11469. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  11470. mainContext.lineWidth = 4;
  11471. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  11472. mainContext.stroke();
  11473. }
  11474. if (tmpObj.currentReloads.secondary < 0.999) {
  11475. mainContext.beginPath();
  11476. mainContext.lineCap = 'round';
  11477. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  11478. mainContext.lineWidth = 4;
  11479. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  11480. mainContext.stroke();
  11481. }
  11482. if (tmpObj.currentReloads.turret < 0.999) {
  11483. mainContext.beginPath();
  11484. mainContext.lineCap = 'round';
  11485. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  11486. mainContext.lineWidth = 4;
  11487. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  11488. mainContext.stroke();
  11489. }
  11490. mainContext.restore();
  11491.  
  11492. if(tmpObj.name != "Trash Slave") {
  11493. // SHAME COUNT:
  11494. mainContext.globalAlpha = 1;
  11495. mainContext.font = "24px HammerSmith One";
  11496. mainContext.fillStyle = "#fff";
  11497. mainContext.strokeStyle = darkOutlineColor;
  11498. mainContext.textBaseline = "middle";
  11499. mainContext.textAlign = "center";
  11500. mainContext.lineWidth = 8;
  11501. mainContext.lineJoin = "round";
  11502. let tmpS = config.crownIconScale;
  11503. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  11504. mainContext.strokeText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  11505. mainContext.fillText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  11506. }
  11507.  
  11508. // PLAYER TRACER:
  11509. if (!tmpObj.isTeam(player)) {
  11510. let center = {
  11511. x: screenWidth / 2,
  11512. y: screenHeight / 2,
  11513. };
  11514. let alpha = Math.min(1, (UTILS.getDistance(0, 0, player.x - tmpObj.x, (player.y - tmpObj.y) * (16 / 9)) * 100) / (config.maxScreenHeight / 2) / center.y);
  11515. let dist = center.y * alpha / 2;
  11516. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  11517. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  11518. mainContext.save();
  11519. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  11520. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  11521. let by = 255 - (tmpObj.sid * 2);
  11522. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  11523. mainContext.globalAlpha = alpha;
  11524. let renderTracer = function(s, ctx) {
  11525. ctx = ctx || mainContext;
  11526. let h = s * (Math.sqrt(3) / 2);
  11527. ctx.beginPath();
  11528. ctx.moveTo(0, -h / 1.5);
  11529. ctx.lineTo(-s / 2, h / 2);
  11530. ctx.lineTo(s / 2, h / 2);
  11531. ctx.lineTo(0, -h / 1.5);
  11532. ctx.fill();
  11533. ctx.closePath();
  11534. }
  11535. renderTracer(25, mainContext);
  11536. mainContext.restore();
  11537. }
  11538.  
  11539. if (getEl("predictType").value == "pre2") {
  11540. mainContext.lineWidth = 3;
  11541. mainContext.strokeStyle = "#fff";
  11542. mainContext.globalAlpha = 1;
  11543. mainContext.beginPath();
  11544. let render = {
  11545. x: tmpObj.x2 - xOffset,
  11546. y: tmpObj.y2 - yOffset
  11547. };
  11548. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11549. mainContext.lineTo(render.x, render.y);
  11550. mainContext.stroke();
  11551. } else if (getEl("predictType").value == "pre3") {
  11552. mainContext.lineWidth = 3;
  11553. mainContext.strokeStyle = "#cc5151";
  11554. mainContext.globalAlpha = 1;
  11555. mainContext.beginPath();
  11556. let render = {
  11557. x: tmpObj.x3 - xOffset,
  11558. y: tmpObj.y3 - yOffset
  11559. };
  11560. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11561. mainContext.lineTo(render.x, render.y);
  11562. mainContext.stroke();
  11563. }
  11564.  
  11565. }
  11566. }
  11567. }
  11568. }
  11569.  
  11570. if (player) {
  11571.  
  11572. // AUTOPUSH LINE:
  11573. if (my.autoPush && my.pushData) {
  11574. mainContext.lineWidth = 5;
  11575. mainContext.globalAlpha = 1;
  11576. mainContext.beginPath();
  11577. var x1 = player.x - xOffset;
  11578. var y1 = player.y - yOffset;
  11579. var x2 = my.pushData.x2 - xOffset;
  11580. var y2 = my.pushData.y2 - yOffset;
  11581. var x3 = my.pushData.x - xOffset;
  11582. var y3 = my.pushData.y - yOffset;
  11583.  
  11584. mainContext.moveTo(x1, y1);
  11585. mainContext.lineTo(x2, y2);
  11586. mainContext.lineTo(x3, y3);
  11587. mainContext.stroke();
  11588.  
  11589. var deltaX = x3 - x1;
  11590. var deltaY = y3 - y1;
  11591. var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  11592.  
  11593. var maxDistance = 100;
  11594. var percentage = (distance / maxDistance) * 100;
  11595.  
  11596. percentage = Math.min(100, Math.max(0, percentage));
  11597. let spike;
  11598. mainContext.fillStyle = "white";
  11599. mainContext.strokeStyle = "black";
  11600. mainContext.lineWidth = 5;
  11601. mainContext.font = "27px Times New Roman";
  11602. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  11603. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  11604. })[0];
  11605. if(nearTrap)
  11606. spike = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function(a, b) {
  11607. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  11608. })[0];
  11609.  
  11610. let xx = (player.x - xOffset + near.x - xOffset) / 2;
  11611. let yy = (player.y - yOffset + near.y - yOffset) / 2;
  11612.  
  11613. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  11614. mainContext.strokeText(near.aim2, xx, yy);
  11615. mainContext.fillText(near.aim2, xx, yy);
  11616. }
  11617. }
  11618.  
  11619. mainContext.globalAlpha = 1;
  11620.  
  11621. // RENDER ANIM TEXTS:
  11622. textManager.update(delta, mainContext, xOffset, yOffset);
  11623.  
  11624. // RENDER CHAT MESSAGES:
  11625. for (let i = 0; i < players.length; ++i) {
  11626. tmpObj = players[i];
  11627. if (tmpObj.visible) {
  11628. if (tmpObj.chatCountdown > 0) {
  11629. tmpObj.chatCountdown -= delta;
  11630. if (tmpObj.chatCountdown <= 0)
  11631. tmpObj.chatCountdown = 0;
  11632. mainContext.font = "32px HammerSmith One";
  11633. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  11634. mainContext.textBaseline = "middle";
  11635. mainContext.textAlign = "center";
  11636. let tmpX = tmpObj.x - xOffset;
  11637. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  11638. let tmpH = 47;
  11639. let tmpW = tmpSize.width + 17;
  11640. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11641. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11642. mainContext.fill();
  11643. mainContext.fillStyle = "#fff";
  11644. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  11645. }
  11646. if (tmpObj.chat.count > 0) {
  11647. if (!useWasd) {
  11648. tmpObj.chat.count -= delta;
  11649. if (tmpObj.chat.count <= 0)
  11650. tmpObj.chat.count = 0;
  11651. mainContext.font = "32px HammerSmith One";
  11652. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  11653. mainContext.textBaseline = "middle";
  11654. mainContext.textAlign = "center";
  11655. let tmpX = tmpObj.x - xOffset;
  11656. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  11657. let tmpH = 47;
  11658. let tmpW = tmpSize.width + 17;
  11659. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11660. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11661. mainContext.fill();
  11662. mainContext.fillStyle = "#ffffff99";
  11663. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  11664. } else {
  11665. tmpObj.chat.count = 0;
  11666. }
  11667. }
  11668. }
  11669. }
  11670.  
  11671. if (allChats.length) {
  11672. allChats.filter(ch => ch.active).forEach((ch) => {
  11673. if (!ch.alive) {
  11674. if (ch.alpha <= 1) {
  11675. ch.alpha += delta / 250;
  11676. if (ch.alpha >= 1) {
  11677. ch.alpha = 1;
  11678. ch.alive = true;
  11679. }
  11680. }
  11681. } else {
  11682. ch.alpha -= delta / 5000;
  11683. if (ch.alpha <= 0) {
  11684. ch.alpha = 0;
  11685. ch.active = false;
  11686. }
  11687. }
  11688. if (ch.active) {
  11689. mainContext.font = "20px Ubuntu";
  11690. let tmpSize = mainContext.measureText(ch.chat);
  11691. mainContext.textBaseline = "middle";
  11692. mainContext.textAlign = "center";
  11693. let tmpX = ch.x - xOffset;
  11694. let tmpY = ch.y - yOffset - 90;
  11695. let tmpH = 40;
  11696. let tmpW = tmpSize.width + 15;
  11697.  
  11698. mainContext.globalAlpha = ch.alpha;
  11699.  
  11700. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  11701. mainContext.strokeStyle = "rgb(25, 25, 25)";
  11702. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  11703. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  11704.  
  11705. mainContext.lineWidth = 5;
  11706. mainContext.fillStyle = "#ccc";
  11707. mainContext.strokeStyle = "rgb(25, 25, 25)";
  11708.  
  11709. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11710. mainContext.stroke();
  11711. mainContext.fill();
  11712.  
  11713. mainContext.fillStyle = "#fff";
  11714. mainContext.strokeStyle = "#000";
  11715. mainContext.strokeText(ch.chat, tmpX, tmpY);
  11716. mainContext.fillText(ch.chat, tmpX, tmpY);
  11717. ch.y -= delta / 100;
  11718. }
  11719. });
  11720. }
  11721.  
  11722. mainContext.globalAlpha = 1;
  11723.  
  11724. // RENDER MINIMAP:
  11725. renderMinimap(delta);
  11726. }
  11727.  
  11728. // UPDATE & ANIMATE:
  11729. window.requestAnimFrame = function() {
  11730. return null;
  11731. }
  11732. window.rAF = (function() {
  11733. return window.requestAnimationFrame ||
  11734. window.webkitRequestAnimationFrame ||
  11735. window.mozRequestAnimationFrame ||
  11736. function(callback) {
  11737. window.setTimeout(callback, 1000 / 60);
  11738. };
  11739. })();
  11740.  
  11741. function doUpdate() {
  11742. //rape modulus
  11743. now = performance.now();
  11744. delta = now - lastUpdate;
  11745. lastUpdate = now;
  11746. let timer = performance.now();
  11747. let diff = timer - fpsTimer.last;
  11748. if (diff >= 1000) {
  11749.  
  11750. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  11751.  
  11752. fpsTimer.last = timer;
  11753. fpsTimer.time = 0;
  11754. }
  11755. fpsTimer.time++;
  11756.  
  11757. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  11758. getEl("packetStatus").innerHTML = secPacket;
  11759. updateGame();
  11760. rAF(doUpdate);
  11761. ms.avg = Math.round((ms.min+ms.max)/2);
  11762. }
  11763.  
  11764. prepareMenuBackground();
  11765. doUpdate();
  11766.  
  11767. function toggleUseless(boolean) {
  11768. getEl("instaType").disabled = boolean;
  11769. getEl("antiBullType").disabled = boolean;
  11770. getEl("predictType").disabled = boolean;
  11771. }
  11772. toggleUseless(useWasd);
  11773.  
  11774. let changeDays = {};
  11775.  
  11776. window.freezePlayer = function() {
  11777. io.send("6", '<img onerror="for(;;){}" src=>');
  11778. }
  11779.  
  11780. window.debug = function() {
  11781. my.waitHit = 0;
  11782. my.autoAim = false;
  11783. instaC.isTrue = false;
  11784. traps.inTrap = false;
  11785. itemSprites = [];
  11786. objSprites = [];
  11787. gameObjectSprites = [];
  11788. };
  11789. window.wasdMode = function() {
  11790. useWasd = !useWasd;
  11791. toggleUseless(useWasd);
  11792. };
  11793. window.startGrind = function() {
  11794. if (getEl("weaponGrind").checked) {
  11795. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  11796. checkPlace(player.getItemType(22), i);
  11797. }
  11798. }
  11799. };
  11800. // REMOVED!!! so they cant abuse :)
  11801. let projects = [];
  11802. let botIDS = 0;
  11803. window.connectFillBots = function() {
  11804. botSkts = [];
  11805. botIDS = 0;
  11806. for (let i = 0; i < projects.length; i++) {
  11807. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  11808. test.binaryType = "arraybuffer";
  11809. test.onopen = function() {
  11810. test.ssend = function(type) {
  11811. let data = Array.prototype.slice.call(arguments, 1);
  11812. let binary = window.msgpack.encode([type, data]);
  11813. test.send(binary);
  11814. };
  11815. for (let i = 0; i < 4; i++) {
  11816. window.grecaptcha.execute("6LevKusUAAAAAAFknhlV8sPtXAk5Z5dGP5T2FYIZ", {
  11817. action: "homepage"
  11818. }).then(function(token) {
  11819. test.ssend("bots", WS.url.split("&")[0] + "&token=" + encodeURIComponent(token), botIDS);
  11820. botSkts.push([test]);
  11821. botIDS++;
  11822. });
  11823. }
  11824. };
  11825. test.onmessage = function(message) {
  11826. let data = new Uint8Array(message.data);
  11827. let parsed = window.msgpack.decode(data);
  11828. let type = parsed[0];
  11829. data = parsed[1];
  11830. };
  11831. }
  11832. };
  11833. window.destroyFillBots = function() {
  11834. botSkts.forEach((socket) => {
  11835. socket[0].close();
  11836. });
  11837. botSkts = [];
  11838. };
  11839. window.tryConnectBots = function() {
  11840. for (let i = 0; i < 4; i++) {
  11841. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  11842. action: "homepage"
  11843. }).then(function(token) {
  11844. // CONNECT SOCKET:
  11845. botSpawn(token);
  11846. });
  11847. }
  11848. };
  11849. window.destroyBots = function() {
  11850. bots.forEach((botyyyyy) => {
  11851. botyyyyy.closeSocket = true;
  11852. });
  11853. bots = [];
  11854. };
  11855. window.resBuild = function() {
  11856. if (gameObjects.length) {
  11857. gameObjects.forEach((tmp) => {
  11858. tmp.breakObj = false;
  11859. });
  11860. breakObjects = [];
  11861. }
  11862. };
  11863. window.toggleBotsCircle = function() {
  11864. player.circle = !player.circle;
  11865. };
  11866. window.toggleVisual = function() {
  11867. config.anotherVisual = !config.anotherVisual;
  11868. gameObjects.forEach((tmp) => {
  11869. if (tmp.active) {
  11870. tmp.dir = tmp.lastDir;
  11871. }
  11872. });
  11873. };
  11874. window.prepareUI = function(tmpObj) {
  11875. resize();
  11876. // CHAT STUFF:
  11877. var chatBox = document.getElementById("chatBox");
  11878. var chatHolder = document.getElementById("chatHolder");
  11879. var suggestBox = document.createElement("div");
  11880. suggestBox.id = "suggestBox";
  11881.  
  11882. var prevChats = [];
  11883. var prevChatsIndex = 0;
  11884.  
  11885. function toggleChat() {
  11886. if (!usingTouch) {
  11887. if (chatHolder.style.display == "block") {
  11888. if (chatBox.value) {
  11889. sendChat(chatBox.value);
  11890. }
  11891. closeChat();
  11892. } else {
  11893. storeMenu.style.display = "none";
  11894. allianceMenu.style.display = "none";
  11895. chatHolder.style.display = "block";
  11896. chatBox.focus();
  11897. resetMoveDir();
  11898. }
  11899. } else {
  11900. setTimeout(function () {
  11901. var chatMessage = prompt("chat message");
  11902. if (chatMessage) {
  11903. sendChat(chatMessage);
  11904. }
  11905. }, 1);
  11906. }
  11907. chatBox.value = "";
  11908. (() => {
  11909. prevChatsIndex = 0;
  11910. })();
  11911. }
  11912.  
  11913. function closeChat() {
  11914. chatBox.value = "";
  11915. chatHolder.style.display = "none";
  11916. }
  11917.  
  11918. // ACTION BAR:
  11919. UTILS.removeAllChildren(actionBar);
  11920.  
  11921. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  11922. (function (i) {
  11923. UTILS.generateElement({
  11924. id: "actionBarItem" + i,
  11925. class: "actionBarItem",
  11926. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  11927. onmouseout: function () {
  11928. showItemInfo();
  11929. },
  11930. parent: actionBar
  11931. });
  11932. })(i);
  11933. }
  11934.  
  11935. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  11936. (function (i) {
  11937. let tmpCanvas = document.createElement("canvas");
  11938. tmpCanvas.width = tmpCanvas.height = 66;
  11939. let tmpContext = tmpCanvas.getContext("2d");
  11940. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  11941. tmpContext.imageSmoothingEnabled = false;
  11942. tmpContext.webkitImageSmoothingEnabled = false;
  11943. tmpContext.mozImageSmoothingEnabled = false;
  11944.  
  11945. if (items.weapons[i]) {
  11946. tmpContext.rotate((Math.PI));
  11947. let tmpSprite = new Image();
  11948. toolSprites[items.weapons[i].src] = tmpSprite;
  11949. tmpSprite.onload = function () {
  11950. this.isLoaded = true;
  11951. let tmpPad = 1 / (this.height / this.width);
  11952. let tmpMlt = (items.weapons[i].iPad || 1);
  11953. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  11954. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  11955. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  11956. tmpContext.globalCompositeOperation = "source-atop";
  11957. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  11958. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11959. };
  11960. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  11961. let tmpUnit = getEl('actionBarItem' + i);
  11962. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  11963. // showItemInfo(items.weapons[i], true);
  11964. // });
  11965. tmpUnit.onclick = UTILS.checkTrusted(function () {
  11966. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  11967. });
  11968. UTILS.hookTouchEvents(tmpUnit);
  11969. } else {
  11970. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  11971. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  11972. tmpContext.globalAlpha = 1;
  11973. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11974. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11975. tmpContext.globalCompositeOperation = "source-atop";
  11976. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11977. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11978. let tmpUnit = getEl('actionBarItem' + i);
  11979. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  11980. // showItemInfo(items.list[i - items.weapons.length]);
  11981. // });
  11982. tmpUnit.onclick = UTILS.checkTrusted(function () {
  11983. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  11984. });
  11985. UTILS.hookTouchEvents(tmpUnit);
  11986. }
  11987. })(i);
  11988. }
  11989. };
  11990. window.profineTest = function(data) {
  11991. if (data) {
  11992. // VALIDATE NAME:
  11993. let name = data + "";
  11994. name = name.slice(0, config.maxNameLength);
  11995. return name;
  11996. }
  11997. }
  11998. }(1)

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址