Diep.io+ (added Trails)

Quick Tank Upgrades, Highscore saver, Team Switcher, Advanced Auto Respawn, Anti Aim, Zoom hack, Anti AFK Timeout, Sandbox Auto K, Sandbox Arena Increase, Tank Aim lines, Farm Bot

  1. // ==UserScript==
  2. // @name Diep.io+ (added Trails)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.3.0
  5. // @description Quick Tank Upgrades, Highscore saver, Team Switcher, Advanced Auto Respawn, Anti Aim, Zoom hack, Anti AFK Timeout, Sandbox Auto K, Sandbox Arena Increase, Tank Aim lines, Farm Bot
  6. // @author r!PsAw, DimRom
  7. // @match https://diep.io/*
  8. // @icon https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQFMDAvSZe2hsFwAIeAPcDSNx8X2lUMp-rLPA&s
  9. // @grant none
  10. // @license Mi300 don't steal my scripts ;)
  11. // ==/UserScript==
  12.  
  13. const fingerprint = {sdfouhi152037892348iuaosfhuiasfDAJSP: 'This Object exists to differentiate between user inputs and script inputs since both use same functions'};
  14.  
  15. //Linked List
  16. class LinkedList {
  17. #first_element;
  18. #last_element;
  19. #size;
  20. constructor() {
  21. this.#first_element = null;
  22. this.#last_element = null;
  23. this.#size = 0;
  24. }
  25. #create_element(v = undefined, l = null, n = null) {
  26. let temp = {
  27. value: v,
  28. prev: l,
  29. next: n,
  30. };
  31. return temp;
  32. }
  33. addFirst(value) {
  34. this.#size++;
  35. let decide = this.#first_element ? this.#first_element : null;
  36. let obj = this.#create_element(value, null, decide);
  37. if (obj.next) obj.next.prev = obj;
  38. this.#first_element = obj;
  39. if (!this.#last_element) this.#last_element = obj;
  40. }
  41. getFirst() {
  42. return this.#first_element;
  43. }
  44. removeFirst() {
  45. if(this.#size>0) this.#size--;
  46. if (!this.#first_element) return;
  47. this.#first_element = this.#first_element.next;
  48. if (this.#first_element) {
  49. this.#first_element.prev = null;
  50. } else {
  51. this.#last_element = null;
  52. }
  53. }
  54.  
  55. addLast(value) {
  56. this.#size++;
  57. let decide = this.#last_element ? this.#last_element : null;
  58. let obj = this.#create_element(value, decide, null);
  59. if (obj.prev) obj.prev.next = obj;
  60. this.#last_element = obj;
  61. if (!this.#first_element) this.#first_element = obj;
  62. }
  63. getLast() {
  64. return this.#last_element;
  65. }
  66. removeLast() {
  67. if(this.#size > 0) this.#size--;
  68. if (!this.#last_element) return;
  69. this.#last_element = this.#last_element.prev;
  70. if (this.#last_element) {
  71. this.#last_element.next = null;
  72. } else {
  73. this.#first_element = null;
  74. }
  75. }
  76. size(){
  77. return this.#size;
  78. }
  79. }
  80.  
  81. //inner script settings
  82. let deep_debug_properties = {
  83. active: false, //display information in console
  84. canvas: false, //display information on screen
  85. }
  86.  
  87. function deep_debug(...args) {
  88. if (deep_debug_properties.active) {
  89. console.log(...args);
  90. }
  91. }
  92.  
  93. //Information for script
  94. let _c = window.__common__;
  95. function is_fullscreen(){
  96. return ((window.innerHeight == screen.height) && (window.innerWidth == screen.width));
  97. }
  98.  
  99. const diep_keys = [ //document has to be focused to execute these, also C and E don't work right now
  100. "KeyA", "KeyB", "KeyC", "KeyD", "KeyE", "KeyF", "KeyG", "KeyH", "KeyI", "KeyJ", "KeyK", "KeyL", "KeyM", "KeyN", "KeyO", "KeyP", "KeyQ", "KeyR", "KeyS", "KeyT", "KeyU", "KeyV", "KeyW", "KeyX", "KeyY", "KeyZ",
  101. "ArrowUp", "ArrowLeft", "ArrowDown", "ArrowRight", "Tab", "Enter", "NumpadEnter", "ShiftLeft", "ShiftRight", "Space", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9",
  102. "Digit0", "Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "F2", "End", "Home", "Semicolon", "Comma", "NumpadComma", "Period", "Backslash"
  103. ].reduce((n, e, c) => {
  104. n[e] = c + 1;
  105. return n;
  106. }, {});
  107.  
  108. let player = {
  109. connected: false,
  110. inGame: false,
  111. name: '',
  112. team: null,
  113. gamemode: null,
  114. ui_scale: 1,
  115. dpr: 1,
  116. base_value: 1,
  117. };
  118.  
  119. let inputs = {
  120. mouse: {
  121. real: {
  122. x: 0,
  123. y: 0,
  124. },
  125. game: {
  126. x: 0,
  127. y: 0,
  128. },
  129. force: {
  130. x: 0,
  131. y: 0,
  132. },
  133. isForced: false, //input mouse operations flag (overwrites your inputs to forced one's)
  134. isFrozen: false, //Mouse Freeze flag
  135. isShooting: false, //Anti Aim flag
  136. isPaused: false, //Anti Aim flag (different from isFrozen & isForced for better readability)
  137. original: {
  138. onTouchMove: null,
  139. onTouchStart: null,
  140. onTouchEnd: null,
  141. }
  142. },
  143. moving_game: {
  144. KeyW: false,
  145. KeyA: false,
  146. KeyS: false,
  147. KeyD: false,
  148. ArrowUp: false,
  149. ArrowRight: false,
  150. ArrowDown: false,
  151. ArrowLeft: false,
  152. },
  153. moving_real: {
  154. KeyW: false,
  155. KeyA: false,
  156. KeyS: false,
  157. KeyD: false,
  158. ArrowUp: false,
  159. ArrowRight: false,
  160. ArrowDown: false,
  161. ArrowLeft: false,
  162. },
  163. keys_pressed: [],
  164. };
  165.  
  166. function windowScaling() {
  167. const a = canvas.height / 1080;
  168. const b = canvas.width / 1920;
  169. return b < a ? a : b;
  170. }
  171.  
  172. //basic function to construct links
  173. function link(baseUrl, lobby, gamemode, team) {
  174. let str = "";
  175. str += baseUrl + "?s=" + lobby + "&g=" + gamemode + "&l=" + team;
  176. return str;
  177. }
  178.  
  179. function get_baseUrl() {
  180. return location.origin + location.pathname;
  181. }
  182.  
  183. function get_your_lobby() {
  184. return window.lobby_ip;
  185. }
  186.  
  187. function get_gamemode() {
  188. //return window.__common__.active_gamemode;
  189. return window.lobby_gamemode;
  190. }
  191.  
  192. function get_team() {
  193. return window.__common__.party_link;
  194. }
  195.  
  196. //all team links
  197. function get_links(gamemode, lobby, team = get_team()) {
  198. let baseUrl = get_baseUrl();
  199. let colors = ["🔵", "🔴", "🟣", "🟢", "👥❌"];
  200. let final_links = [];
  201. switch (gamemode) {
  202. case "4teams":
  203. for (let i = 0; i < 4; i++) {
  204. final_links.push([colors[i], link(baseUrl, lobby, gamemode, team.split("x")[0] + `x${i}`)]);
  205. }
  206. break
  207. case "teams":
  208. for (let i = 0; i < 2; i++) {
  209. final_links.push([colors[i], link(baseUrl, lobby, gamemode, team.split("x")[0] + `x${i}`)]);
  210. }
  211. break
  212. default:
  213. final_links.push([colors[colors.length - 1], link(baseUrl, lobby, gamemode, team)]);
  214. }
  215. return final_links;
  216. }
  217.  
  218. //dimensions
  219.  
  220. class dimensions_converter {
  221. constructor() {
  222. this.scalingFactor = null; //undetectable without bypass
  223. this.fieldFactor = null; //undetectable without bypass
  224. }
  225. canvas_2_window(a) {
  226. let b = a / (canvas.width / window.innerWidth);
  227. return b;
  228. }
  229.  
  230. window_2_canvas(a) {
  231. let b = a * (canvas.width / window.innerWidth);
  232. return b;
  233. }
  234.  
  235. windowScaling_2_window(a) {
  236. let b = (this.windowScaling_2_canvas(a)) / (canvas.width / window.innerWidth);
  237. return b;
  238. }
  239.  
  240. windowScaling_2_canvas(a) {
  241. let b = a * windowScaling();
  242. deep_debug('windowScaling_2_canvas called! a, b', a, b);
  243. return b;
  244. }
  245. /* DISABLED FOR NOW
  246. diepUnits_2_canvas(a) {
  247. let b = a / scalingFactor;
  248. return b;
  249. }
  250.  
  251. diepUnits_2_window(a) {
  252. let b = (this.diepUnits_2_canvas(a)) / (canvas.width / window.innerWidth);
  253. return b;
  254. }
  255.  
  256. window_2_diepUnits(a) {
  257. let b = (this.canvas_2_diepUnits(a)) * (canvas.width / window.innerWidth);
  258. return b;
  259. }
  260.  
  261. canvas_2_diepUnits(a) {
  262. let b = a * this.scalingFactor;
  263. return b;
  264. }
  265. */
  266.  
  267. window_2_windowScaling(a) {
  268. let b = (this.canvas_2_windowScaling(a)) * (canvas.width / window.innerWidth) * player.ui_scale;
  269. return b;
  270. }
  271.  
  272. canvas_2_windowScaling(a) {
  273. let b = a * windowScaling();
  274. return b;
  275. }
  276. /* DISABLED FOR NOW
  277. diepUnits_2_windowScaling(a) {
  278. let b = (this.diepUnits_2_canvas(a)) * this.fieldFactor;
  279. return b;
  280. }
  281.  
  282. windowScaling_2_diepUntis(a) {
  283. let b = (a / this.fieldFactor) * this.scalingFactor;
  284. return b;
  285. }
  286. */
  287. }
  288.  
  289. let dim_c = new dimensions_converter();
  290.  
  291. function i_e(type, key, ...args) {
  292. switch (type) {
  293. case "input":
  294. input[key](...args);
  295. break
  296. case "extern":
  297. extern[key](...args);
  298. break
  299. }
  300. }
  301.  
  302. function apply_force(x, y) {
  303. inputs.mouse.force = {
  304. x: x,
  305. y: y,
  306. }
  307. inputs.mouse.isForced = true;
  308. }
  309.  
  310. function disable_force() {
  311. inputs.mouse.isForced = false;
  312. }
  313.  
  314. const touchMethods = ['onTouchMove', 'onTouchStart', 'onTouchEnd'];
  315. let canvas = document.getElementById("canvas");
  316. let ctx = canvas.getContext('2d');
  317.  
  318. function define_onTouch() {
  319. touchMethods.forEach(function(method) {
  320. inputs.mouse.original[method] = input[method];
  321. deep_debug('defined input.', method);
  322. });
  323. }
  324.  
  325. function clear_onTouch() {
  326. touchMethods.forEach(function(method) {
  327. input[method] = () => {};
  328. });
  329. }
  330.  
  331. function redefine_onTouch() {
  332. touchMethods.forEach(function(method) {
  333. input[method] = inputs.mouse.original[method];
  334. });
  335. }
  336.  
  337. function start_input_proxies(_filter = false, _single = false, _method = null) {
  338. ((_filter || _single) && !_method) ? console.warn("missing _method at start_input_proxies"): null;
  339. let temp_methods = touchMethods;
  340. if (_filter) {
  341. temp_methods.filter((item) => item != _method);
  342. } else if (_single) {
  343. temp_methods = [_method];
  344. }
  345. temp_methods.forEach(function(method) {
  346. input[method] = new Proxy(input[method], {
  347. apply: function(definition, input_obj, args) {
  348. let x, y, type, new_args;
  349. if (inputs.mouse.isForced) {
  350. x = inputs.mouse.force.x;
  351. y = inputs.mouse.force.y;
  352. } else {
  353. x = args[1];
  354. y = args[2];
  355. }
  356. type = args[0];
  357. new_args = [type, dim_c.window_2_canvas(x / player.dpr), dim_c.window_2_canvas(y / player.dpr)];
  358. inputs.mouse.game = {
  359. x: new_args[1],
  360. y: new_args[2],
  361. }
  362. return Reflect.apply(definition, input_obj, new_args);
  363. }
  364. });
  365. });
  366. }
  367.  
  368. //create ingame Notifications
  369. function rgbToNumber(r, g, b) {
  370. return (r << 16) | (g << 8) | b;
  371. }
  372. const notification_rgbs = {
  373. require: [255, 165, 0], //orange
  374. warning: [255, 0, 0], //red
  375. normal: [0, 0, 128] //blue
  376. }
  377.  
  378. let notifications = [];
  379.  
  380. function new_notification(text, color, duration) {
  381. input.inGameNotification(text, rgbToNumber(...color), duration);
  382. }
  383.  
  384. function one_time_notification(text, color, duration){
  385. if(notifications.includes(text)){
  386. return;
  387. }
  388. if(player.inGame){
  389. new_notification(text, color, duration);
  390. notifications.push(text);
  391. }else{
  392. notifications = [];
  393. }
  394. }
  395.  
  396. //GUI
  397. function n2id(string) {
  398. return string.toLowerCase().replace(/ /g, "-");
  399. }
  400.  
  401. class El {
  402. constructor(
  403. name,
  404. type,
  405. el_color,
  406. width,
  407. height,
  408. opacity = "1",
  409. zindex = "100"
  410. ) {
  411. this.el = document.createElement(type);
  412. this.el.style.backgroundColor = el_color;
  413. this.el.style.width = width;
  414. this.el.style.height = height;
  415. this.el.style.opacity = opacity;
  416. this.el.style.zIndex = zindex;
  417. this.el.id = n2id(name);
  418. this.display = "block"; // store default display
  419. }
  420.  
  421. setBorder(type, width, color, radius = 0) {
  422. const borderStyle = `${width} solid ${color}`;
  423. switch (type) {
  424. case "normal":
  425. this.el.style.border = borderStyle;
  426. break;
  427. case "top":
  428. this.el.style.borderTop = borderStyle;
  429. break;
  430. case "left":
  431. this.el.style.borderLeft = borderStyle;
  432. break;
  433. case "right":
  434. this.el.style.borderRight = borderStyle;
  435. break;
  436. case "bottom":
  437. this.el.style.borderBottom = borderStyle;
  438. break;
  439. }
  440. this.el.style.borderRadius = radius;
  441. }
  442.  
  443. setPosition(
  444. position,
  445. display,
  446. top,
  447. left,
  448. flexDirection,
  449. justifyContent,
  450. translate
  451. ) {
  452. this.el.style.position = position;
  453. this.el.style.display = display;
  454. if (top) this.el.style.top = top;
  455. if (left) this.el.style.left = left;
  456. // Flex properties
  457. if (flexDirection) this.el.style.flexDirection = flexDirection;
  458. if (justifyContent) this.el.style.justifyContent = justifyContent;
  459. if (translate) this.el.style.transform = `translate(${translate})`;
  460. this.display = display;
  461. }
  462.  
  463. margin(top, left, right, bottom) {
  464. this.el.style.margin = `${top} ${right} ${bottom} ${left}`;
  465. }
  466.  
  467. setText(
  468. text,
  469. txtColor,
  470. font,
  471. weight,
  472. fontSize,
  473. stroke,
  474. alignContent,
  475. textAlign
  476. ) {
  477. this.el.innerHTML = text;
  478. this.el.style.color = txtColor;
  479. this.el.style.fontFamily = font;
  480. this.el.style.fontWeight = weight;
  481. this.el.style.fontSize = fontSize;
  482. this.el.style.textShadow = stroke;
  483. this.el.style.alignContent = alignContent;
  484. this.el.style.textAlign = textAlign;
  485. }
  486.  
  487. add(parent) {
  488. parent.appendChild(this.el);
  489. }
  490.  
  491. remove(parent) {
  492. parent.removeChild(this.el);
  493. }
  494.  
  495. toggle(showOrHide) {
  496. this.el.style.display = showOrHide === "hide" ? "none" : this.display;
  497. }
  498. }
  499.  
  500. let mainCont,
  501. header,
  502. subContGray,
  503. subContBlack,
  504. modCont,
  505. settCont,
  506. activeCategory;
  507.  
  508. //logic for saving
  509. let trashed_module_names = (() => {
  510. const saved = localStorage.getItem("[Diep.io+] Trashed names");
  511. if (saved) {
  512. return new Set(JSON.parse(saved));
  513. }
  514. return new Set();
  515. })();
  516.  
  517. let saved_trash_content = [];
  518.  
  519. class Trashbin {
  520. constructor(trash_content) {
  521. this.active = {
  522. trashbin: false,
  523. mover: false,
  524. };
  525. this.trash_content = trash_content;
  526. //element creation
  527.  
  528. //outside
  529. this.trash_container = new El(
  530. "TrashBin Container",
  531. "div",
  532. "rgb(100, 0, 0)",
  533. "100%",
  534. "50px"
  535. );
  536. this.trash_container.setPosition("sticky", "flex", "0", "0", "row");
  537. this.trash_container.el.style.overflowX = "auto";
  538. this.trash_container.el.style.overflowY = "hidden";
  539. this.trash_container.el.style.paddingBottom = "20px";
  540.  
  541. //inside
  542. let temp_cont = new El(
  543. "TrashBinContainer",
  544. "div",
  545. "transparent",
  546. "90px",
  547. "50px"
  548. );
  549. let trashbin = new El("TrashBin", "div", "transparent", "45px", "50px");
  550. trashbin.setPosition("relative", "inline-block");
  551. trashbin.setText(
  552. `${this.trash_content.length}🗑️`,
  553. "white",
  554. "Calibri",
  555. "bold",
  556. "20px",
  557. "2px",
  558. "center",
  559. "center"
  560. );
  561. trashbin.setBorder("normal", "0px", "transparent", "10px");
  562. trashbin.el.addEventListener("mouseover", (e) => {
  563. trashbin.el.style.cursor = "pointer";
  564. trashbin.el.style.backgroundColor = this.active.trashbin
  565. ? "rgb(200, 0, 0)"
  566. : "rgb(50, 0, 0)";
  567. });
  568. trashbin.el.addEventListener("mouseout", (e) => {
  569. trashbin.el.style.cursor = "normal";
  570. trashbin.el.style.backgroundColor = this.active.trashbin
  571. ? "rgb(150, 0, 0)"
  572. : "transparent";
  573. });
  574. trashbin.el.addEventListener("mousedown", (e) => {
  575. if (e.button != 0) return;
  576. this.active.trashbin = !this.active.trashbin;
  577. if (this.active.trashbin) {
  578. trashbin.el.style.backgroundColor = "rgb(100, 0, 0)";
  579. this.show_deleted_buttons();
  580. this.trash_container.add(mainCont.el);
  581. } else {
  582. trashbin.el.style.backgroundColor = "transparent";
  583. this.trash_container.el.innerHTML = ""; //clear previous items first
  584. this.trash_container.remove(mainCont.el);
  585. }
  586. });
  587.  
  588. let mover = new El("Mover", "div", "transparent", "45px", "50px");
  589. mover.setPosition("relative", "inline-block");
  590. mover.setText(
  591. `⬅️`,
  592. "white",
  593. "Calibri",
  594. "bold",
  595. "20px",
  596. "2px",
  597. "center",
  598. "center"
  599. );
  600. mover.setBorder("normal", "0px", "transparent", "10px");
  601. mover.el.addEventListener("mouseover", (e) => {
  602. mover.el.style.cursor = "pointer";
  603. mover.el.style.backgroundColor = this.active.mover
  604. ? "rgb(0, 0, 200)"
  605. : "rgb(0, 0, 50)";
  606. });
  607. mover.el.addEventListener("mouseout", (e) => {
  608. mover.el.style.cursor = "normal";
  609. mover.el.style.backgroundColor = this.active.mover
  610. ? "rgb(0, 0, 150)"
  611. : "transparent";
  612. });
  613. mover.el.addEventListener("mousedown", (e) => {
  614. if (e.button != 0) return;
  615. this.active.mover = !this.active.mover;
  616. mover.el.style.backgroundColor = "rgb(0, 0, 100)";
  617. });
  618. //elements fusion
  619. temp_cont.el.appendChild(trashbin.el);
  620. temp_cont.el.appendChild(mover.el);
  621. this.element = temp_cont.el;
  622. }
  623. add_content(content) {
  624. this.trash_content.push(content);
  625. this.update_text();
  626. }
  627. remove_content(content) {
  628. let index = this.trash_content.indexOf(content);
  629. if (index === -1) return;
  630. this.trash_content.splice(index, 1);
  631. this.update_text();
  632. }
  633. update_text() {
  634. this.element.children[0].innerHTML = `${this.trash_content.length}🗑️`;
  635. }
  636. create_deleted_button(obj) {
  637. let temp = new El(obj.name, "div", "transparent", "170px", "50px");
  638. temp.el.style.backgroundColor = "rgb(200, 100, 0)";
  639. temp.setText(
  640. obj.name,
  641. "lightgray",
  642. "Calibri",
  643. "bold",
  644. "20px",
  645. "2px",
  646. "center",
  647. "center"
  648. );
  649. temp.setBorder("normal", "2px", "rgb(200, 200, 0)", "5px");
  650. temp.el.style.flexShrink = "0";
  651. temp.el.addEventListener("mouseover", (e) => {
  652. temp.el.style.cursor = "pointer";
  653. temp.el.style.backgroundColor = "rgb(250, 150, 0)";
  654. });
  655. temp.el.addEventListener("mouseout", (e) => {
  656. temp.el.style.cursor = "normal";
  657. temp.el.style.backgroundColor = "rgb(200, 100, 0)";
  658. });
  659. temp.el.addEventListener("mousedown", (e) => {
  660. if (e.button != 0) return;
  661. let path = find_module_path(obj.name);
  662. let target_module = modules[path[0]][path[1]];
  663. target_module.trashed = false;
  664. trashed_module_names.delete(target_module.name);
  665. localStorage.setItem(
  666. "[Diep.io+] Trashed names",
  667. JSON.stringify(Array.from(trashed_module_names))
  668. );
  669. if (path[0] === activeCategory) {
  670. for (let child of obj.children) {
  671. modCont.el.appendChild(child);
  672. }
  673. }
  674. this.trash_container.el.removeChild(temp.el);
  675. this.remove_content(obj);
  676. this.update_text();
  677. });
  678. return temp;
  679. }
  680. show_deleted_buttons() {
  681. this.trash_container.el.innerHTML = "";
  682. if (this.trash_content.length > 0) {
  683. for (let obj of this.trash_content) {
  684. let btn = this.create_deleted_button(obj);
  685. btn.add(this.trash_container.el);
  686. }
  687. }
  688. }
  689. }
  690.  
  691. function trash_module(module_name, class_elements) {
  692. if (modCont.el.children.length === 0)
  693. return console.warn("Currently no modules loaded");
  694. let temp_storage = {
  695. name: module_name,
  696. children: [],
  697. };
  698. for (let child of modCont.el.children) {
  699. for (let class_el of class_elements) {
  700. if (child === class_el) {
  701. temp_storage.children.push(child);
  702. }
  703. }
  704. }
  705. for (let element of temp_storage.children) {
  706. modCont.el.removeChild(element);
  707. }
  708. trash.add_content(temp_storage);
  709. }
  710.  
  711. //creation of trashbin class instance
  712. let trash = new Trashbin(saved_trash_content);
  713.  
  714. //new keybinds logic
  715. let keybinds = new Set();
  716.  
  717. class Setting {
  718. constructor(name, type, options, target_class) {
  719. this.name = name;
  720. this.options = options;
  721. this.elements = [];
  722. this.desc = new El(
  723. name + " Setting",
  724. "div",
  725. "transparent",
  726. "170px",
  727. "50px"
  728. );
  729. this.desc.setPosition("relative", "block");
  730. this.desc.setText(
  731. name,
  732. "white",
  733. "Calibri",
  734. "bold",
  735. "15px",
  736. "2px",
  737. "center",
  738. "center"
  739. );
  740. this.elements.push(this.desc.el);
  741.  
  742. switch (type) {
  743. case "title":
  744. this.desc.el.style.backgroundColor = "rgb(50, 50, 50)";
  745. this.desc.setText(
  746. name,
  747. "lightgray",
  748. "Calibri",
  749. "bold",
  750. "20px",
  751. "2px",
  752. "center",
  753. "center"
  754. );
  755. this.desc.setBorder("normal", "2px", "gray", "5px");
  756. break;
  757. case "keybind":
  758. this.kb_state = "idle";
  759. this.previous_key = "";
  760. this.desc.el.style.backgroundColor = "rgb(103, 174, 110)";
  761. this.desc.setText(
  762. name.length > 0 ? name : "Click to Select Keybind",
  763. "rgb(225, 238, 188)",
  764. "Calibri",
  765. "bold",
  766. "15px",
  767. "2px",
  768. "center",
  769. "center"
  770. );
  771. this.desc.setBorder("normal", "2px", "rgb(50, 142, 110)", "5px");
  772. this.desc.el.addEventListener("mouseover", (e) => {
  773. this.desc.el.style.backgroundColor = "rgb(144, 198, 124)";
  774. target_class.desc.setBorder("normal", "2px", "red", "5px");
  775. });
  776. this.desc.el.addEventListener("mouseout", (e) => {
  777. this.desc.el.style.backgroundColor = "rgb(103, 174, 110)";
  778. target_class.desc.setBorder("normal", "0px", "transparent", "0px");
  779. });
  780. this.desc.el.addEventListener("mousedown", (e) => {
  781. if (e.button != 0) return;
  782. this.desc.el.innerHTML = "Press a key";
  783. this.kb_state = "listening";
  784. });
  785. document.addEventListener("keydown", (e) => {
  786. switch (this.kb_state) {
  787. case "set":
  788. if (e.code === this.previous_key) {
  789. target_class.active = !target_class.active;
  790. target_class.update_toggle(target_class.checkbox);
  791. }
  792. break;
  793. case "listening":
  794. if (this.previous_key === e.code) {
  795. this.desc.el.innerHTML = e.code;
  796. this.kb_state = "set";
  797. } else if (keybinds.has(e.code)) {
  798. this.desc.el.innerHTML =
  799. "Keybind already being used, try again!";
  800. } else {
  801. if (e.code === "Backspace" || e.code === "Escape") {
  802. this.desc.el.innerHTML = "Click to Select Keybind";
  803. this.kb_state = "set";
  804. return;
  805. }
  806. keybinds.add(e.code);
  807. if (keybinds.has(this.previous_key))
  808. keybinds.delete(this.previous_key);
  809. this.desc.el.innerHTML = e.code;
  810. this.previous_key = e.code;
  811. this.kb_state = "set";
  812. }
  813. break;
  814. default:
  815. return;
  816. }
  817. });
  818. break;
  819. case "select": {
  820. if (!this.options) return console.warn("Missing Options!");
  821. let index = 0;
  822. this.selected = options[index];
  823. //temp cont
  824. let temp_container = new El(
  825. name + " temp Container",
  826. "div",
  827. "transparent"
  828. );
  829. temp_container.el.style.display = "flex";
  830. temp_container.el.style.alignItems = "center";
  831. temp_container.el.style.justifyContent = "center";
  832. temp_container.el.style.gap = "10px";
  833.  
  834. //displ
  835. let displ = new El(
  836. name + " Setting Display",
  837. "div",
  838. "lightgray",
  839. "125px",
  840. "25px"
  841. );
  842. displ.setText(
  843. this.selected,
  844. "black",
  845. "Calibri",
  846. "bold",
  847. "15px",
  848. "2px",
  849. "center",
  850. "center"
  851. );
  852.  
  853. //left Arrow
  854. let l_arrow = new El(
  855. name + " left Arrow",
  856. "div",
  857. "transparent",
  858. "0px",
  859. "0px"
  860. );
  861. l_arrow.setBorder("bottom", "8px", "transparent");
  862. l_arrow.setBorder("left", "0px", "transparent");
  863. l_arrow.setBorder("right", "16px", "blue");
  864. l_arrow.setBorder("top", "8px", "transparent");
  865.  
  866. l_arrow.el.addEventListener("mouseover", () => {
  867. l_arrow.el.style.cursor = "pointer";
  868. l_arrow.setBorder("right", "16px", "darkblue");
  869. });
  870.  
  871. l_arrow.el.addEventListener("mouseout", () => {
  872. l_arrow.el.style.cursor = "normal";
  873. l_arrow.setBorder("right", "16px", "blue");
  874. });
  875.  
  876. l_arrow.el.addEventListener("mousedown", (e) => {
  877. if (e.button != 0) return;
  878. let limit = options.length - 1;
  879. if (index - 1 < 0) {
  880. index = limit;
  881. } else {
  882. index--;
  883. }
  884. this.selected = options[index];
  885. displ.el.innerHTML = this.selected;
  886. });
  887.  
  888. //right Arrow
  889. let r_arrow = new El(
  890. name + " right Arrow",
  891. "div",
  892. "transparent",
  893. "0px",
  894. "0px"
  895. );
  896. r_arrow.setBorder("bottom", "8px", "transparent");
  897. r_arrow.setBorder("left", "16px", "blue");
  898. r_arrow.setBorder("right", "0px", "transparent");
  899. r_arrow.setBorder("top", "8px", "transparent");
  900.  
  901. r_arrow.el.addEventListener("mouseover", () => {
  902. r_arrow.el.style.cursor = "pointer";
  903. r_arrow.setBorder("left", "16px", "darkblue");
  904. });
  905.  
  906. r_arrow.el.addEventListener("mouseout", () => {
  907. r_arrow.el.style.cursor = "normal";
  908. r_arrow.setBorder("left", "16px", "blue");
  909. });
  910.  
  911. r_arrow.el.addEventListener("mousedown", (e) => {
  912. if (e.button != 0) return;
  913. let limit = options.length - 1;
  914. if (index + 1 > limit) {
  915. index = 0;
  916. } else {
  917. index++;
  918. }
  919. this.selected = options[index];
  920. displ.el.innerHTML = this.selected;
  921. });
  922.  
  923. //connect together
  924. temp_container.el.appendChild(l_arrow.el);
  925. temp_container.el.appendChild(displ.el);
  926. temp_container.el.appendChild(r_arrow.el);
  927.  
  928. //remember them
  929. this.elements.push(temp_container.el);
  930. break;
  931. }
  932. case "toggle": {
  933. this.active = false;
  934. this.desc.el.style.display = "flex";
  935. this.desc.el.style.alignItems = "center";
  936. this.desc.el.style.justifyContent = "space-between";
  937. let empty_checkbox = new El(
  938. this.name + " Setting checkbox",
  939. "div",
  940. "lightgray",
  941. "20px",
  942. "20px"
  943. );
  944. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  945. //event listeners
  946. empty_checkbox.el.addEventListener("mousedown", (e) => {
  947. if (e.button != 0) return;
  948. this.active = !this.active;
  949. this.update_toggle(empty_checkbox);
  950. });
  951. empty_checkbox.el.addEventListener("mouseover", () => {
  952. empty_checkbox.el.style.backgroundColor = this.active
  953. ? "darkgreen"
  954. : "darkgray";
  955. empty_checkbox.el.style.cursor = "pointer";
  956. });
  957. empty_checkbox.el.addEventListener("mouseout", () => {
  958. empty_checkbox.el.style.backgroundColor = this.active
  959. ? "green"
  960. : "lightgray";
  961. });
  962. this.desc.el.appendChild(empty_checkbox.el);
  963. this.checkbox = empty_checkbox;
  964. break;
  965. }
  966. }
  967. }
  968. update_toggle(empty_checkbox) {
  969. if (this.active) {
  970. empty_checkbox.el.innerHTML = "✔";
  971. empty_checkbox.el.style.backgroundColor = "green";
  972. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  973. } else {
  974. empty_checkbox.el.innerHTML = "";
  975. empty_checkbox.el.style.backgroundColor = "lightgray";
  976. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  977. }
  978. }
  979. load() {
  980. this.elements.forEach((element) => settCont.el.appendChild(element));
  981. }
  982.  
  983. unload() {
  984. this.elements.forEach((element) => {
  985. if (settCont.el.contains(element)) {
  986. settCont.el.removeChild(element);
  987. }
  988. });
  989. }
  990. }
  991.  
  992. class Module {
  993. constructor(name, type, settings, callback) {
  994. this.name = name;
  995. this.type = type;
  996. this.trashed = trashed_module_names.has(this.name);
  997. this.callbackFunc = callback;
  998. this.settings = settings;
  999. this.title = new El(name, "div", "transparent", "100%", "50px");
  1000. this.title.setPosition("relative", "block");
  1001. this.title.setText(
  1002. name,
  1003. "white",
  1004. "Calibri",
  1005. "bold",
  1006. "15px",
  1007. "2px",
  1008. "center",
  1009. "center"
  1010. );
  1011. this.title.el.addEventListener("mouseover", (e) => {
  1012. if (!trash.active.mover) return;
  1013. this.title.el.style.color = "rgb(200, 0, 0)";
  1014. });
  1015. this.title.el.addEventListener("mouseout", (e) => {
  1016. if (this.title.el.style.color === "rgb(200, 0, 0)") {
  1017. this.title.el.style.color = "white";
  1018. }
  1019. });
  1020. this.elements = [];
  1021. this.elements.push(this.title.el);
  1022. switch (type) {
  1023. case "toggle": {
  1024. this.active = false;
  1025. this.title.el.style.display = "flex";
  1026. this.title.el.style.alignItems = "center";
  1027. this.title.el.style.justifyContent = "space-between";
  1028. let empty_checkbox = new El(
  1029. this.name + " checkbox",
  1030. "div",
  1031. "lightgray",
  1032. "20px",
  1033. "20px"
  1034. );
  1035. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  1036. //event listeners
  1037. empty_checkbox.el.addEventListener("mousedown", (e) => {
  1038. if (e.button != 0) return;
  1039. this.active = !this.active;
  1040. if (this.active) {
  1041. empty_checkbox.el.innerHTML = "✔";
  1042. empty_checkbox.el.style.backgroundColor = "green";
  1043. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  1044. } else {
  1045. empty_checkbox.el.innerHTML = "";
  1046. empty_checkbox.el.style.backgroundColor = "lightgray";
  1047. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  1048. }
  1049. });
  1050. empty_checkbox.el.addEventListener("mouseover", () => {
  1051. empty_checkbox.el.style.backgroundColor = this.active
  1052. ? "darkgreen"
  1053. : "darkgray";
  1054. empty_checkbox.el.style.cursor = "pointer";
  1055. });
  1056. empty_checkbox.el.addEventListener("mouseout", () => {
  1057. empty_checkbox.el.style.backgroundColor = this.active
  1058. ? "green"
  1059. : "lightgray";
  1060. });
  1061. this.title.el.appendChild(empty_checkbox.el);
  1062. break;
  1063. }
  1064. case "slider": {
  1065. this.value = 100;
  1066. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  1067. const slider = document.createElement("input");
  1068. slider.type = "range";
  1069. slider.value = this.value;
  1070. slider.min = 0;
  1071. slider.max = 100;
  1072.  
  1073. slider.addEventListener("input", () => {
  1074. this.value = slider.value;
  1075. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  1076. });
  1077.  
  1078. this.elements.push(slider);
  1079. break;
  1080. }
  1081. case "button":
  1082. this.title.el.style.width = "100%";
  1083. this.title.el.style.boxSizing = "border-box";
  1084. this.title.el.style.whiteSpace = "normal"; // Allows text wrapping
  1085. this.title.setBorder("normal", "2px", "white", "10px");
  1086. this.title.el.style.cursor = "pointer";
  1087. this.title.el.addEventListener("mousedown", () => {
  1088. if (trash.active.mover) return;
  1089. if (this.callbackFunc) {
  1090. this.callbackFunc();
  1091. }
  1092. });
  1093. break;
  1094. case "open": {
  1095. this.active = false;
  1096. this.title.el.style.display = "flex";
  1097. this.title.el.style.alignItems = "center";
  1098. this.title.el.style.justifyContent = "space-between";
  1099. let opener_box = new El(
  1100. this.name + " opener box",
  1101. "div",
  1102. "rgb(75, 75, 75)",
  1103. "20px",
  1104. "20px"
  1105. );
  1106. opener_box.setBorder("normal", "2px", "gray", "4px");
  1107. opener_box.el.style.display = "flex";
  1108. opener_box.el.style.alignItems = "center";
  1109. opener_box.el.style.justifyContent = "center";
  1110. //
  1111. let triangle = new El(
  1112. name + " triangle",
  1113. "div",
  1114. "transparent",
  1115. "0px",
  1116. "0px"
  1117. );
  1118. triangle.setBorder("bottom", "16px", "lime");
  1119. triangle.setBorder("left", "8px", "transparent");
  1120. triangle.setBorder("right", "8px", "transparent");
  1121. triangle.setBorder("top", "0px", "transparent");
  1122. //
  1123. //event listeners
  1124. opener_box.el.addEventListener("mousedown", (e) => {
  1125. if (e.button != 0) return;
  1126. if (trash.active.mover) return;
  1127. this.active = !this.active;
  1128. if (this.active) {
  1129. triangle.setBorder("bottom", "0px", "transparent");
  1130. triangle.setBorder("left", "8px", "transparent");
  1131. triangle.setBorder("right", "8px", "transparent");
  1132. triangle.setBorder("top", "16px", "red");
  1133. this.loadSettings();
  1134. } else {
  1135. triangle.setBorder("bottom", "16px", "lime");
  1136. triangle.setBorder("left", "8px", "transparent");
  1137. triangle.setBorder("right", "8px", "transparent");
  1138. triangle.setBorder("top", "0px", "transparent");
  1139. this.unloadSettings();
  1140. }
  1141. });
  1142. opener_box.el.addEventListener("mouseover", () => {
  1143. opener_box.el.style.backgroundColor = "rgb(50, 50, 50)";
  1144. opener_box.el.style.cursor = "pointer";
  1145. });
  1146. opener_box.el.addEventListener("mouseout", () => {
  1147. opener_box.el.style.backgroundColor = "rgb(75, 75, 75)";
  1148. });
  1149. opener_box.el.appendChild(triangle.el);
  1150. this.title.el.appendChild(opener_box.el);
  1151. break;
  1152. }
  1153. }
  1154. if (trashed_module_names.has(this.name)) {
  1155. saved_trash_content.push({ name: this.name, children: this.elements });
  1156. trash.update_text();
  1157. }
  1158. this.title.el.addEventListener("mousedown", (e) => {
  1159. if (!trash.active.mover) return;
  1160. trash_module(this.name, this.elements);
  1161. this.trashed = true;
  1162. trashed_module_names.add(this.name);
  1163. localStorage.setItem(
  1164. "[Diep.io+] Trashed names",
  1165. JSON.stringify(Array.from(trashed_module_names))
  1166. );
  1167. this.title.el.style.color = "white";
  1168. trash.show_deleted_buttons();
  1169. });
  1170. }
  1171. load() {
  1172. this.elements.forEach((element) => modCont.el.appendChild(element));
  1173. }
  1174.  
  1175. unload() {
  1176. this.elements.forEach((element) => {
  1177. if (modCont.el.contains(element)) {
  1178. modCont.el.removeChild(element);
  1179. }
  1180. });
  1181. }
  1182.  
  1183. loadSettings() {
  1184. if (!this.settings) return;
  1185. for (let _sett in this.settings) {
  1186. this.settings[_sett].load();
  1187. }
  1188. }
  1189.  
  1190. unloadSettings() {
  1191. if (!this.settings) return;
  1192. for (let _sett in this.settings) {
  1193. this.settings[_sett].unload();
  1194. }
  1195. }
  1196. }
  1197.  
  1198. class Category {
  1199. constructor(name, modules) {
  1200. this.name = name;
  1201. this.element = new El(name, "div", "rgb(38, 38, 38)", "90px", "50px");
  1202. this.element.setPosition("relative", "block");
  1203. this.element.setText(
  1204. name,
  1205. "white",
  1206. "Calibri",
  1207. "bold",
  1208. "20px",
  1209. "2px",
  1210. "center",
  1211. "center"
  1212. );
  1213. this.element.setBorder("normal", "2px", "transparent", "10px");
  1214. this.selected = false;
  1215. this.modules = modules;
  1216.  
  1217. this.element.el.addEventListener("mousedown", (e) => {
  1218. if (e.button !== 0) return;
  1219. this.selected = !this.selected;
  1220. this.element.el.style.backgroundColor = this.selected
  1221. ? "lightgray"
  1222. : "rgb(38, 38, 38)";
  1223. handle_categories_selection(this.name);
  1224. if (!this.selected) unload_modules(this.name);
  1225. });
  1226.  
  1227. this.element.el.addEventListener("mouseover", () => {
  1228. if (!this.selected) {
  1229. this.element.el.style.backgroundColor = "rgb(58, 58, 58)";
  1230. this.element.el.style.cursor = "pointer";
  1231. }
  1232. });
  1233.  
  1234. this.element.el.addEventListener("mouseout", () => {
  1235. if (!this.selected)
  1236. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  1237. });
  1238. }
  1239. unselect() {
  1240. this.selected = false;
  1241. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  1242. }
  1243. }
  1244.  
  1245. //1travel
  1246. let modules = {
  1247. Info: {
  1248. hall_of_Fame: new Module("Hall of Fame", "open", {
  1249. darkdealer_00249: new Setting("darkdealer_00249", "title"),
  1250. Sguanto: new Setting("Sguanto", "title"),
  1251. }),
  1252. q_a1: new Module(
  1253. "Where are the old scripts from diep.io+?",
  1254. "button",
  1255. null,
  1256. () => {
  1257. alert("They're either patched, or not fully integrated yet.");
  1258. }
  1259. ),
  1260. q_a2: new Module("Can you make me a script?", "button", null, () => {
  1261. alert(
  1262. "If it's simple - yes, if not give me a donation or a private script and I will do it for you, unless I don't know how to implement it."
  1263. );
  1264. }),
  1265. q_a3: new Module("This script is so confusing!", "button", null, () => {
  1266. alert(
  1267. "Maybe I will make full tutorial, but for now ask me anything about it. Discord: h3llside"
  1268. );
  1269. }),
  1270. q_a4: new Module(
  1271. "How can I join your discord server?",
  1272. "button",
  1273. null,
  1274. () => {
  1275. alert(
  1276. "Join and follow instructions: https://discord.gg/S3ZzgDNAuG please dm me if the link doesn't work, discord: h3llside"
  1277. );
  1278. }
  1279. ),
  1280. q_a5: new Module("Why do you update it so often?", "button", null, () => {
  1281. alert(
  1282. "I get it, it can be annoying to constantly update the script, but sometimes new ideas come, sometimes game updates and breaks this script so I have no choice but to update frequently"
  1283. );
  1284. }),
  1285. q_a6: new Module("What is the import, export for?", "button", null, () => {
  1286. alert(
  1287. "it's for auto respawn+, mainly spawn type: Random Killer. It basically chooses random saved name and you can share those saved names with each other :)"
  1288. );
  1289. }),
  1290. },
  1291.  
  1292. Visual: {
  1293. Key_inputs_visualiser: new Module("Key Inputs Visualiser", "toggle"),
  1294. destroyer_cooldown: new Module("Destroyer Cooldown", "open", {
  1295. Title: new Setting("Destroyer Cooldown", "title"),
  1296. keybind: new Setting(
  1297. "",
  1298. "keybind",
  1299. null,
  1300. (this.temp = new Setting("enable Destroyer Cooldown", "toggle"))
  1301. ),
  1302. reload: new Setting("Reload?", "select", [0, 1, 2, 3, 4, 5, 6, 7]),
  1303. destroyer_cooldown: this.temp,
  1304. }),
  1305. },
  1306.  
  1307. Functional: {
  1308. CopyLink: new Module("Copy Party Link", "button", null, () => {
  1309. document.getElementById("copy-party-link").click();
  1310. }),
  1311. Predator_stack: new Module("Predator Stack", "button", null, () => {
  1312. predator_stack(get_reload());
  1313. }),
  1314. Sandbox_lvl_up: new Module("Sandbox Auto Level Up", "toggle"),
  1315. Auto_respawn: new Module("Auto Respawn", "open", {
  1316. Title: new Setting("Auto Respawn", "title"),
  1317. keybind: new Setting(
  1318. "",
  1319. "keybind",
  1320. null,
  1321. (this.temp = new Setting("Auto Respawn", "toggle"))
  1322. ),
  1323. Remember: new Setting("Remember and store Killer Names", "toggle"),
  1324. Prevent: new Setting("Prevent respawning after 300k score", "toggle"),
  1325. Name: new Setting("Spawn Name Type: ", "select", [
  1326. "Normal",
  1327. "Glitched",
  1328. "N A M E",
  1329. "Random Killer",
  1330. "Random Symbols",
  1331. "Random Numbers",
  1332. "Random Letters",
  1333. ]),
  1334. Auto_respawn: this.temp,
  1335. }),
  1336. Import_names: new Module(
  1337. "Import Killer Names",
  1338. "button",
  1339. null,
  1340. import_killer_names
  1341. ),
  1342. Export_names: new Module("Export Killer Names", "button", null, () => {
  1343. let exported_string = localStorage.getItem("[Diep.io+] saved names")
  1344. ? localStorage.getItem("[Diep.io+] saved names")
  1345. : -1;
  1346. if (exported_string < 0)
  1347. return alert("not copied, because 0 saved names");
  1348. navigator.clipboard.writeText("'" + exported_string + "'");
  1349. alert(`copied ${JSON.parse(exported_string).length} saved names`);
  1350. }),
  1351. Bot_tab: new Module("Sandbox Arena size increase", "toggle"),
  1352. Tank_upgrades: new Module("Tank Upgrades Keybinds", "open", {
  1353. Title: new Setting("Tank Upgrades Keybinds", "title"),
  1354. visualise: new Setting("Show positions and keys", "toggle"),
  1355. Tank_upgrades: new Setting("enable Tank Upgrades Keybinds", "toggle"),
  1356. }),
  1357. Zoom: new Module("Zoom Out", "slider"),
  1358. },
  1359.  
  1360. Mouse: {
  1361. Anti_aim: new Module("Anti Aim", "open", {
  1362. Title: new Setting("Anti Aim", "title"),
  1363. keybind: new Setting(
  1364. "",
  1365. "keybind",
  1366. null,
  1367. (this.temp = new Setting("enable Anti Aim", "toggle"))
  1368. ),
  1369. Timing: new Setting(
  1370. "Follow mouse on click, how long?",
  1371. "select",
  1372. [50, 100, 150, 200, 250, 300]
  1373. ),
  1374. Anti_aim: this.temp,
  1375. }),
  1376. Freeze_mouse: new Module("Freeze Mouse", "toggle"),
  1377. Anti_timeout: new Module("Anti AFK Timeout", "toggle"),
  1378. Move_2_mouse: new Module("Move to mouse", "open", {
  1379. Title: new Setting("Move to mouse", "title"),
  1380. keybind: new Setting(
  1381. "",
  1382. "keybind",
  1383. null,
  1384. (this.temp = new Setting("enable Move to Mouse", "toggle"))
  1385. ),
  1386. toggle_debug: new Setting("Watch how the script works", "toggle"),
  1387. Approximation: new Setting(
  1388. "Approximation Factor (lower = smoother)",
  1389. "select",
  1390. [10, 25, 40, 65, 80, 100]
  1391. ),
  1392. Time_factor: new Setting(
  1393. "Time Factor (higher = longer)",
  1394. "select",
  1395. [10, 20, 30, 40, 50]
  1396. ),
  1397. Move_2_mouse: this.temp,
  1398. }),
  1399. Custom_auto_spin: new Module("Custom Auto Spin", "open", {
  1400. Title: new Setting("Custom Auto Spin", "title"),
  1401. keybind: new Setting(
  1402. "",
  1403. "keybind",
  1404. null,
  1405. (this.temp = new Setting("enable Custom Auto Spin", "toggle"))
  1406. ),
  1407. Interval: new Setting(
  1408. "Movement Interval",
  1409. "select",
  1410. [
  1411. 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300,
  1412. 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2500, 3000, 3500, 4000,
  1413. 5000,
  1414. ]
  1415. ),
  1416. Smoothness: new Setting("Smoothness", "select", [3, 4, 5, 6, 7, 8]),
  1417. Replace_auto_spin: new Setting("replace Auto Spin", "toggle"),
  1418. Custom_auto_spin: this.temp,
  1419. }),
  1420. },
  1421.  
  1422. DiepConsole: {
  1423. con_toggle: new Module("Show/hide Diep Console", "toggle"),
  1424. net_predict_movement: new Module("predict movement", "toggle"),
  1425. Render: new Module("Render things", "open", {
  1426. Title: new Setting("Rendering", "title"),
  1427. ren_scoreboard: new Setting("Leaderboard", "toggle"),
  1428. ren_scoreboard_names: new Setting("Scoreboard Names", "toggle"),
  1429. ren_fps: new Setting("FPS", "toggle"),
  1430. ren_upgrades: new Setting("Tank Upgrades", "toggle"),
  1431. ren_stats: new Setting("Stat Upgrades", "toggle"),
  1432. ren_names: new Setting("Names", "toggle"),
  1433. }),
  1434. //game builds
  1435. },
  1436.  
  1437. Addons: {
  1438. aim_lines: new Module("Tank Aim lines", "open", {
  1439. Title: new Setting("Tank Aim lines", "title"),
  1440. keybind: new Setting(
  1441. "",
  1442. "keybind",
  1443. null,
  1444. (this.temp = new Setting("Toggle Aim Lines", "toggle"))
  1445. ),
  1446. adjust_length: new Setting(
  1447. "Adjust aim line length",
  1448. "select",
  1449. [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 5, 7.5, 10]
  1450. ),
  1451. toggle_aim_lines: this.temp,
  1452. }),
  1453. farm_bot: new Module("Farm Bot", "open", {
  1454. Title: new Setting("Farm Bot", "title"),
  1455. keybind: new Setting(
  1456. "",
  1457. "keybind",
  1458. null,
  1459. (this.temp = new Setting("Toggle Farm Bot", "toggle"))
  1460. ),
  1461. ignore_shapes: new Setting("Shapes you want to ignore:"),
  1462. toggle_squares: new Setting("Squares", "toggle"),
  1463. toggle_crashers: new Setting("Crashers", "toggle"),
  1464. toggle_pentagons: new Setting("Pentagons", "toggle"),
  1465. toggle_triangles: new Setting("Triangles", "toggle"),
  1466. ignore_outside: new Setting("Ignore Outside base?", "toggle"),
  1467. other_setts: new Setting("Movement:"),
  1468. move_to_shape: new Setting("Move to Shapes", "toggle"),
  1469. visuals: new Setting("Visuals:"),
  1470. toggle_lines: new Setting("Toggle Line to Shape", "toggle"),
  1471. toggle_debug: new Setting("See how script works", "toggle"),
  1472. activation: new Setting("Activation:"),
  1473. toggle_farm_bot: this.temp,
  1474. }),
  1475. world_coords: new Module("World Coordinates", "open", {
  1476. Title: new Setting("World Coordinates", "title"),
  1477. precision: new Setting("Precision Factor", "select", [0, 1, 2, 3, 4]),
  1478. toggle_world_coords: new Setting("Toggle World Coordinates", "toggle"),
  1479. }),
  1480. enemy_tracers: new Module("Enemy Tracers", "toggle"),
  1481. trails: new Module("Trails", "open", {
  1482. Title: new Setting("Trails", "title"),
  1483. update_interval: new Setting("Update Interval", "select", [10, 50, 100, 250, 500]),
  1484. toggle_trails: new Setting("Toggle Trails", "toggle"),
  1485. }),
  1486. },
  1487. };
  1488.  
  1489. console.log(modules);
  1490.  
  1491. let categories = [];
  1492.  
  1493. function create_categories() {
  1494. for (let key in modules) {
  1495. categories.push(new Category(key, modules[key]));
  1496. }
  1497. }
  1498. create_categories();
  1499.  
  1500. //loading / unloading modules
  1501. function load_modules(category_name) {
  1502. activeCategory = category_name;
  1503. const current_category = categories.find(
  1504. (category) => category.name === category_name
  1505. );
  1506. for (let moduleName in current_category.modules) {
  1507. let module = current_category.modules[moduleName];
  1508. if (!module.trashed) module.load();
  1509. if (module.type === "open" && module.active) module.loadSettings();
  1510. }
  1511. }
  1512.  
  1513. function unload_modules(category_name) {
  1514. if (activeCategory === category_name) activeCategory = undefined;
  1515. const current_category = categories.find(
  1516. (category) => category.name === category_name
  1517. );
  1518. for (let moduleName in current_category.modules) {
  1519. let module = current_category.modules[moduleName];
  1520. module.unload();
  1521. module.unloadSettings();
  1522. }
  1523. }
  1524.  
  1525. function find_module_path(_name) {
  1526. for (let category in modules) {
  1527. for (let module in modules[category]) {
  1528. // Iterate over actual modules
  1529. if (modules[category][module].name === _name) {
  1530. return [category, module]; // Return actual category and module
  1531. }
  1532. }
  1533. }
  1534. return -1; // Return -1 if not found
  1535. }
  1536.  
  1537. function handle_categories_selection(current_name) {
  1538. categories.forEach((category) => {
  1539. if (category.name !== current_name && category.selected) {
  1540. category.unselect();
  1541. unload_modules(category.name);
  1542. }
  1543. });
  1544.  
  1545. load_modules(current_name);
  1546. }
  1547.  
  1548. function loadCategories() {
  1549. const categoryCont = document.querySelector("#sub-container-gray");
  1550. categories.forEach((category) =>
  1551. categoryCont.appendChild(category.element.el)
  1552. );
  1553. }
  1554.  
  1555. function load_selected() {
  1556. categories.forEach((category) => {
  1557. if (category.selected) {
  1558. load_modules(category.name);
  1559. }
  1560. });
  1561. }
  1562.  
  1563. function loadGUI() {
  1564. document.body.style.margin = "0";
  1565. document.body.style.display = "flex";
  1566. document.body.style.justifyContent = "left";
  1567.  
  1568. mainCont = new El("Main Cont", "div", "rgb(38, 38, 38)", "500px", "400px");
  1569. mainCont.setBorder("normal", "2px", "lime", "10px");
  1570. mainCont.el.style.display = "flex";
  1571. mainCont.el.style.minHeight = "min-content";
  1572. mainCont.el.style.flexDirection = "column";
  1573. mainCont.add(document.body);
  1574.  
  1575. header = new El("Headline Dp", "div", "transparent", "100%", "40px");
  1576. header.setBorder("bottom", "2px", "rgb(106, 173, 84)");
  1577. header.setText(
  1578. "Diep.io+ by r!PsAw (Hide GUI with J)",
  1579. "white",
  1580. "Calibri",
  1581. "bold",
  1582. "20px",
  1583. "2px",
  1584. "center",
  1585. "center"
  1586. );
  1587. header.add(mainCont.el);
  1588.  
  1589. const contentWrapper = document.createElement("div");
  1590. contentWrapper.style.display = "flex";
  1591. contentWrapper.style.gap = "10px";
  1592. contentWrapper.style.padding = "10px";
  1593. contentWrapper.style.flex = "1";
  1594. mainCont.el.appendChild(contentWrapper);
  1595.  
  1596. subContGray = new El(
  1597. "Sub Container Gray",
  1598. "div",
  1599. "transparent",
  1600. "100px",
  1601. "100%"
  1602. );
  1603. subContGray.el.style.display = "flex";
  1604. subContGray.el.style.flexDirection = "column";
  1605. subContGray.el.style.overflowY = "auto";
  1606. subContGray.add(contentWrapper);
  1607.  
  1608. subContBlack = new El("Sub Container Black", "div", "black", "360px", "100%");
  1609. subContBlack.el.style.display = "flex";
  1610. subContBlack.el.style.gap = "10px";
  1611. subContBlack.add(contentWrapper);
  1612.  
  1613. modCont = new El("Module Container", "div", "transparent", "50%", "100%");
  1614. modCont.el.style.display = "flex";
  1615. modCont.el.style.flexDirection = "column";
  1616. modCont.el.style.overflowY = "auto";
  1617. modCont.setBorder("right", "2px", "white");
  1618. modCont.add(subContBlack.el);
  1619.  
  1620. settCont = new El("Settings Container", "div", "transparent", "50%", "100%");
  1621. settCont.el.style.display = "flex";
  1622. settCont.el.style.flexDirection = "column";
  1623. settCont.el.style.overflowY = "auto";
  1624. settCont.add(subContBlack.el);
  1625.  
  1626. loadCategories();
  1627. load_selected();
  1628.  
  1629. subContGray.el.appendChild(trash.element);
  1630. }
  1631.  
  1632. loadGUI();
  1633. document.addEventListener("keydown", toggleGUI);
  1634.  
  1635. function toggleGUI(e) {
  1636. if (e.key === "j" || e.key === "J") {
  1637. if (mainCont.el) {
  1638. mainCont.remove(document.body);
  1639. mainCont.el = null;
  1640. } else {
  1641. loadGUI();
  1642. }
  1643. }
  1644. }
  1645.  
  1646. //actual logic
  1647.  
  1648. //allow user to interact with the gui while in game
  1649. Event.prototype.preventDefault = new Proxy(Event.prototype.preventDefault, {
  1650. apply: function(target, thisArgs, args){
  1651. //console.log(thisArgs.type);
  1652. if(thisArgs.type === "mousedown" || thisArgs.type === "mouseup") return; //console.log('successfully canceled');
  1653. return Reflect.apply(target, thisArgs, args);
  1654. }
  1655. });
  1656.  
  1657. //Move to Mouse
  1658. function reset_moving_game(keys_to_reset){
  1659. for(let key of keys_to_reset){
  1660. if(inputs.moving_game[key]){
  1661. extern.onKeyUp(diep_keys[key], fingerprint);
  1662. }
  1663. }
  1664. }
  1665.  
  1666. let approximation_factor = modules.Mouse.Move_2_mouse.settings.Approximation.selected; // Higher = faster movement, but less smooth Lower = slower movement, but more smooth
  1667. let distance_time_factor = modules.Mouse.Move_2_mouse.settings.Time_factor.selected; // transform the distance into Time
  1668. let moving_active = false;
  1669. let current_direction = 'none';
  1670. let reset_move_to_mouse_complete = false;
  1671.  
  1672. function calculate_distance(x1, y1, x2, y2) {
  1673. return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
  1674. }
  1675.  
  1676. function get_move_steps(x, y) {
  1677. let center = { x: dim_c.canvas_2_window(canvas.width / 2), y: dim_c.canvas_2_window(canvas.height / 2) };
  1678. let target = { x: x, y: y };
  1679. let full_distance = calculate_distance(center.x, center.y, target.x, target.y);
  1680. let partial_distance = full_distance/approximation_factor;
  1681. let step = { x: (target.x - center.x) / partial_distance, y: (target.y - center.y) / partial_distance };
  1682. return step;
  1683. }
  1684.  
  1685. function move_in_direction(direction, time) {
  1686. moving_active = true;
  1687. current_direction = direction;
  1688. let directions = {
  1689. 'Up': 'KeyW',
  1690. 'Left': 'KeyA',
  1691. 'Down': 'KeyS',
  1692. 'Right': 'KeyD',
  1693. }
  1694. for (let _dir in directions) {
  1695. if (directions[_dir] === undefined) return console.warn("Invalid direction");
  1696. if (_dir === direction) {
  1697. extern.onKeyDown(diep_keys[directions[_dir]], fingerprint);
  1698. } else {
  1699. extern.onKeyUp(diep_keys[directions[_dir]], fingerprint);
  1700. }
  1701. }
  1702. setTimeout(() => {
  1703. moving_active = false;
  1704. }, time);
  1705. }
  1706.  
  1707. function move_to_mouse() {
  1708. window.requestAnimationFrame(move_to_mouse);
  1709. if (modules.Mouse.Move_2_mouse.settings.Move_2_mouse.active) {
  1710. if (moving_active || !player.inGame || !document.hasFocus()) return;
  1711. reset_move_to_mouse_complete = false;
  1712. //update factors
  1713. approximation_factor = modules.Mouse.Move_2_mouse.settings.Approximation.selected;
  1714. distance_time_factor = modules.Mouse.Move_2_mouse.settings.Time_factor.selected;
  1715. //logic
  1716. let step = get_move_steps(inputs.mouse.real.x, inputs.mouse.real.y);
  1717. let horizontal = step.x > 0 ? 'Right' : 'Left';
  1718. let vertical = step.y > 0 ? 'Down' : 'Up';
  1719.  
  1720. switch (current_direction) {
  1721. case "none":
  1722. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1723. break;
  1724. case 'Right':
  1725. move_in_direction(vertical, Math.abs(step.y) * distance_time_factor);
  1726. break;
  1727. case 'Left':
  1728. move_in_direction(vertical, Math.abs(step.y) * distance_time_factor);
  1729. break;
  1730. case 'Up':
  1731. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1732. break
  1733. case 'Down':
  1734. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1735. break
  1736. }
  1737. } else {
  1738. if (!reset_move_to_mouse_complete) {
  1739. reset_moving_game(['KeyW', 'KeyA', 'KeyS', 'KeyD']);
  1740. reset_move_to_mouse_complete = true;
  1741. }
  1742. }
  1743. }
  1744. window.requestAnimationFrame(move_to_mouse);
  1745.  
  1746.  
  1747. // ]-[ HTML RELATED STUFF
  1748. let homescreen = document.getElementById("home-screen");
  1749. let ingamescreen = document.getElementById("in-game-screen");
  1750. let gameOverScreen = document.getElementById('game-over-screen');
  1751. let gameOverScreenContainer = document.querySelector("#game-over-screen > div > div.game-details > div:nth-child(1)");
  1752. function update_scale_option(selector, label, min, max) {
  1753. let element = document.querySelector(selector);
  1754. let label_element = element.closest("div").querySelector("span");
  1755. label_element.innerHTML = `[DIEP.IO+] ${label}`;
  1756. label_element.style.background = "black";
  1757. label_element.style.color = "purple";
  1758. element.min = min;
  1759. element.max = max;
  1760. }
  1761.  
  1762. function new_ranges_for_scales() {
  1763. update_scale_option("#subsetting-option-ui_scale", "UI Scale", '0.01', '1000');
  1764. update_scale_option("#subsetting-option-border_radius", "UI Border Radius", '0.01', '1000');
  1765. update_scale_option("#subsetting-option-border_intensity", "UI Border Intensity", '0.01', '1000');
  1766. }
  1767.  
  1768. new_ranges_for_scales();
  1769.  
  1770. //VISUAL TEAM SWITCH
  1771. //create container
  1772. let team_select_container = document.createElement("div");
  1773. team_select_container.classList.add("labelled");
  1774. team_select_container.id = "team-selector";
  1775. document.querySelector("#server-selector").appendChild(team_select_container);
  1776.  
  1777. //create Text "Team"
  1778. let team_select_label = document.createElement("label");
  1779. team_select_label.innerText = "[Diep.io+] Team Selector";
  1780. team_select_label.style.color = "purple";
  1781. team_select_label.style.backgroundColor = "black";
  1782. team_select_container.appendChild(team_select_label);
  1783.  
  1784. //create Selector
  1785. let team_select_selector = document.createElement("div");
  1786. team_select_selector.classList.add("selector");
  1787. team_select_container.appendChild(team_select_selector);
  1788.  
  1789. //create placeholder "Choose Team"
  1790. let teams_visibility = true;
  1791. let ph_div = document.createElement("div");
  1792. let ph_text_div = document.createElement("div");
  1793. let sel_state;
  1794. ph_text_div.classList.add("dropdown-label");
  1795. ph_text_div.innerHTML = "Choose Team";
  1796. ph_div.style.backgroundColor = "gray";
  1797. ph_div.classList.add("selected");
  1798. ph_div.addEventListener("click", () => {
  1799. //toggle Team List
  1800. toggle_team_list(teams_visibility);
  1801. teams_visibility = !teams_visibility;
  1802. });
  1803.  
  1804. team_select_selector.appendChild(ph_div);
  1805. ph_div.appendChild(document.createElement("div"));
  1806. ph_div.appendChild(ph_text_div);
  1807.  
  1808. // Create refresh button
  1809. /*
  1810. let refresh_btn = document.createElement("button");
  1811. refresh_btn.style.width = "30%";
  1812. refresh_btn.style.height = "10%";
  1813. refresh_btn.style.backgroundColor = "black";
  1814. refresh_btn.textContent = "Refresh";
  1815.  
  1816. refresh_btn.onclick = () => {
  1817. remove_previous_teams();
  1818. links_to_teams_GUI_convert();
  1819. };
  1820.  
  1821. team_select_container.appendChild(refresh_btn);
  1822. */
  1823.  
  1824. //create actual teams
  1825. let team_values = [];
  1826.  
  1827. function create_team_div(text, color, link) {
  1828. team_values.push(text);
  1829. let team_div = document.createElement("div");
  1830. let text_div = document.createElement("div");
  1831. let sel_state;
  1832. text_div.classList.add("dropdown-label");
  1833. text_div.innerHTML = text;
  1834. team_div.style.backgroundColor = color;
  1835. team_div.classList.add("unselected");
  1836. team_div.value = text;
  1837. team_div.addEventListener("click", () => {
  1838. const answer = confirm("You're about to open the link in a new tab, do you want to continue?");
  1839. if (answer) {
  1840. window.open(link, "_blank");
  1841. }
  1842. });
  1843.  
  1844. team_select_selector.appendChild(team_div);
  1845. team_div.appendChild(document.createElement("div"));
  1846. team_div.appendChild(text_div);
  1847. }
  1848.  
  1849. function toggle_team_list(boolean) {
  1850. if (boolean) {
  1851. //true
  1852. team_select_selector.classList.remove("selector");
  1853. team_select_selector.classList.add("selector-active");
  1854. } else {
  1855. //false
  1856. team_select_selector.classList.remove("selector-active");
  1857. team_select_selector.classList.add("selector");
  1858. }
  1859. }
  1860.  
  1861. //example
  1862. //create_team_div("RedTeam", "Red", "https://diep.io/");
  1863. //create_team_div("OrangeTeam", "Orange", "https://diep.io/");
  1864. //create_team_div("YellowTeam", "Yellow", "https://diep.io/");
  1865. function links_to_teams_GUI_convert() {
  1866. let gamemode = get_gamemode();
  1867. let lobby = get_your_lobby();
  1868. let links = get_links(gamemode, lobby);
  1869. let team_names = ["Team-Blue", "Team-Red", "Team-Purple", "Team-Green", "Teamless-Gamemode"];
  1870. let team_colors = ["blue", "red", "purple", "green", "orange"];
  1871. for (let i = 0; i < links.length; i++) {
  1872. !gamemode.includes("teams") ? create_team_div(team_names[team_names.length - 1], team_colors[team_colors.length - 1], links[0][1]) : create_team_div(team_names[i], team_colors[i], links[i][1]);
  1873. }
  1874. }
  1875.  
  1876. function remove_previous_teams() {
  1877. for (let i = team_select_selector.childNodes.length - 1; i >= 0; i--) {
  1878. console.log(team_select_selector);
  1879. let child = team_select_selector.childNodes[i];
  1880. if (child.nodeType === Node.ELEMENT_NODE && child.innerText !== "Choose Team") {
  1881. child.remove();
  1882. }
  1883. }
  1884. }
  1885.  
  1886. let party_link_info = {
  1887. old_link: null,
  1888. current_link: null
  1889. }
  1890. function detect_refresh(){
  1891. if(!party_link_info.old_link || !party_link_info.current_link) return;
  1892. party_link_info.current_link = window.lobby_ip + _c.party_link;
  1893. if(party_link_info.current_link != party_link_info.old_link){
  1894. console.log('Link change detected!');
  1895. remove_previous_teams();
  1896. links_to_teams_GUI_convert();
  1897. party_link_info.old_link = party_link_info.current_link;
  1898. }
  1899. }
  1900.  
  1901. function wait_For_Link() {
  1902. if (_c.party_link === '') {
  1903. setTimeout(() => {
  1904. console.log("[Diep.io+] LOADING...");
  1905. wait_For_Link();
  1906. }, 100);
  1907. } else {
  1908. console.log("[Diep.io+] link loaded!");
  1909. remove_previous_teams();
  1910. links_to_teams_GUI_convert();
  1911. party_link_info.current_link = window.lobby_ip + _c.party_link;
  1912. party_link_info.old_link = party_link_info.current_link;
  1913. }
  1914. }
  1915.  
  1916. wait_For_Link();
  1917.  
  1918. //detect gamemode
  1919. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1920. let last_gamemode = localStorage.getItem(`[Diep.io+] last_gm`);
  1921. localStorage.setItem(`[Diep.io+] last_gm`, gamemode);
  1922.  
  1923. function check_gamemode() {
  1924. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1925. save_gm();
  1926. }
  1927.  
  1928.  
  1929. function save_gm() {
  1930. let saved_gm = localStorage.getItem(`[Diep.io+] last_gm`);
  1931. if (saved_gm != null && saved_gm != gamemode) {
  1932. last_gamemode = saved_gm;
  1933. }
  1934. saved_gm === null ? localStorage.setItem(`[Diep.io+] last_gm}`, gamemode) : null;
  1935. }
  1936.  
  1937. //personal best
  1938. let your_final_score = 0;
  1939. const personal_best = document.createElement('div');
  1940. const gameDetail = document.createElement('div');
  1941. const label = document.createElement('div');
  1942. //applying class
  1943. gameDetail.classList.add("game-detail");
  1944. label.classList.add("label");
  1945. personal_best.classList.add("value");
  1946. //text context
  1947. label.textContent = "Best:";
  1948. //adding to html
  1949. gameOverScreenContainer.appendChild(gameDetail);
  1950. gameDetail.appendChild(label);
  1951. gameDetail.appendChild(personal_best);
  1952.  
  1953. function load_ls() {
  1954. return localStorage.getItem(gamemode);
  1955. }
  1956.  
  1957. function save_ls() {
  1958. localStorage.setItem(gamemode, your_final_score);
  1959. }
  1960.  
  1961. function check_final_score() {
  1962. if (_c.screen_state === "game-over") {
  1963. your_final_score = _c.death_score;
  1964. let saved_score = parseFloat(load_ls());
  1965. personal_best.textContent = saved_score;
  1966. if (saved_score < your_final_score) {
  1967. personal_best.textContent = your_final_score;
  1968. save_ls();
  1969. }
  1970. }
  1971. }
  1972.  
  1973. //remove annoying html elements
  1974. function instant_remove() {
  1975. // Define selectors for elements to remove
  1976. const selectors = [
  1977. "#cmpPersistentLink",
  1978. "#apes-io-promo",
  1979. "#apes-io-promo > img",
  1980. "#last-updated",
  1981. "#diep-io_300x250"
  1982. ];
  1983.  
  1984. // Remove each selected element
  1985. selectors.forEach(selector => {
  1986. const element = document.querySelector(selector);
  1987. if (element) {
  1988. element.remove();
  1989. }
  1990. });
  1991.  
  1992. // If all elements have been removed, clear the interval
  1993. if (selectors.every(selector => !document.querySelector(selector))) {
  1994. deep_debug("Removed all ads, quitting...");
  1995. clearInterval(interval);
  1996. }
  1997. }
  1998.  
  1999. // Set an interval to check for ads
  2000. const interval = setInterval(instant_remove, 100);
  2001.  
  2002. // ]-[
  2003.  
  2004. //Predator Stack
  2005. let predator_reloads = [
  2006. //0
  2007. {
  2008. scd2: 600,
  2009. scd3: 1000,
  2010. wcd1: 1500,
  2011. wcd2: 2900,
  2012. },
  2013. //1
  2014. {
  2015. scd2: 500,
  2016. scd3: 900,
  2017. wcd1: 1400,
  2018. wcd2: 2800,
  2019. },
  2020. //2
  2021. {
  2022. scd2: 500,
  2023. scd3: 900,
  2024. wcd1: 1200,
  2025. wcd2: 2400,
  2026. },
  2027. //3
  2028. {
  2029. scd2: 400,
  2030. scd3: 900,
  2031. wcd1: 1200,
  2032. wcd2: 2300,
  2033. },
  2034. //4
  2035. {
  2036. scd2: 400,
  2037. scd3: 900,
  2038. wcd1: 1000,
  2039. wcd2: 2000,
  2040. },
  2041. //5
  2042. {
  2043. scd2: 400,
  2044. scd3: 800,
  2045. wcd1: 900,
  2046. wcd2: 1800,
  2047. },
  2048. //6
  2049. {
  2050. scd2: 300,
  2051. scd3: 800,
  2052. wcd1: 900,
  2053. wcd2: 1750,
  2054. },
  2055. //7
  2056. {
  2057. scd2: 300,
  2058. scd3: 800,
  2059. wcd1: 750,
  2060. wcd2: 1500,
  2061. },
  2062. ];
  2063.  
  2064.  
  2065. function shoot(cooldown = 100) {
  2066. deep_debug("Shoot started!", cooldown);
  2067. extern.onKeyDown(36);
  2068. setTimeout(() => {
  2069. deep_debug("Ending Shoot!", cooldown);
  2070. extern.onKeyUp(36);
  2071. }, cooldown);
  2072. }
  2073.  
  2074. function get_reload(){
  2075. let arr = [...extern.get_convar("game_stats_build")];
  2076. let counter = 0;
  2077. let l = arr.length;
  2078. for(let i = 0; i < l; i++){
  2079. if(arr[i] === '7'){
  2080. counter++;
  2081. }
  2082. }
  2083. return counter;
  2084. }
  2085.  
  2086. function predator_stack(reload) {
  2087. deep_debug("func called");
  2088. let current = predator_reloads[reload];
  2089. deep_debug(current);
  2090. shoot();
  2091. setTimeout(() => {
  2092. shoot(current.scd2);
  2093. }, current.wcd1);
  2094. setTimeout(() => {
  2095. shoot(current.scd3);
  2096. }, current.wcd2);
  2097. }
  2098.  
  2099. //Bot tab
  2100.  
  2101. //iframe creation
  2102. function createInvisibleIframe(url) {
  2103. let existingIframe = document.getElementById('hiddenIframe');
  2104. if (existingIframe) {
  2105. return;
  2106. }
  2107.  
  2108. let iframe = document.createElement('iframe');
  2109. iframe.src = url;
  2110. iframe.id = 'hiddenIframe';
  2111. document.body.appendChild(iframe);
  2112. }
  2113.  
  2114. function removeIframe() {
  2115. let iframe = document.getElementById('hiddenIframe');
  2116. if (iframe) {
  2117. iframe.remove();
  2118. }
  2119. }
  2120.  
  2121. function bot_tab_active_check(){
  2122. if(modules.Functional.Bot_tab.active){
  2123. createInvisibleIframe(link(get_baseUrl(), get_your_lobby(), get_gamemode(), get_team()));
  2124. }else{
  2125. removeIframe();
  2126. }
  2127. }
  2128.  
  2129. //DiepConsole
  2130. function active_diepconsole_render_default(){
  2131. let defaults = ['ren_scoreboard', 'ren_upgrades', 'ren_stats', 'ren_names', 'ren_scoreboard_names'];
  2132. for(let _def of defaults){
  2133. let _setting = modules.DiepConsole.Render.settings[_def]
  2134. _setting.active = true;
  2135. _setting.update_toggle(_setting.checkbox);
  2136. }
  2137. }
  2138. active_diepconsole_render_default();
  2139.  
  2140. function handle_con_toggle(state){
  2141. if(!extern.isConActive() && state && player.inGame){
  2142. one_time_notification('canceled, due to a bug. Make sure to not enable it while in game', notification_rgbs.warning, 5000);
  2143. return;
  2144. }
  2145. if(extern.isConActive() != state){
  2146. extern.execute('con_toggle');
  2147. }
  2148. }
  2149.  
  2150. function update_diep_console(){
  2151. //Modules
  2152. for(let param in modules.DiepConsole){
  2153. let state = modules.DiepConsole[param].active;
  2154. if(param === "con_toggle"){
  2155. handle_con_toggle(state)
  2156. }else if(modules.DiepConsole[param].name != "Render things"){
  2157. extern.set_convar(param, state);
  2158. }
  2159. }
  2160. //Render Settings
  2161. for(let ren_param in modules.DiepConsole.Render.settings){
  2162. let state = modules.DiepConsole.Render.settings[ren_param].active;
  2163. if(modules.DiepConsole.Render.settings[ren_param].name != "Rendering"){
  2164. extern.set_convar(ren_param, state);
  2165. }
  2166. }
  2167. }
  2168.  
  2169.  
  2170. //////
  2171. //mouse functions
  2172.  
  2173. window.addEventListener('mousemove', function(event) {
  2174. inputs.mouse.real.x = event.clientX;
  2175. inputs.mouse.real.y = event.clientY;
  2176. });
  2177.  
  2178. window.addEventListener('mousedown', function(event) {
  2179. if (modules.Mouse.Anti_aim.settings.Anti_aim.active) {
  2180. if (inputs.mouse.shooting) {
  2181. return;
  2182. }
  2183. inputs.mouse.shooting = true;
  2184. pauseMouseMove();
  2185. //freezeMouseMove();
  2186. setTimeout(function() {
  2187. inputs.mouse.shooting = false;
  2188. mouse_move('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  2189. click_at('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  2190. }, modules.Mouse.Anti_aim.settings.Timing.selected);
  2191. };
  2192. });
  2193.  
  2194. function handle_mouse_functions() {
  2195. window.requestAnimationFrame(handle_mouse_functions);
  2196. if (!player.connected) {
  2197. return;
  2198. }
  2199. modules.Mouse.Freeze_mouse.active ? freezeMouseMove() : unfreezeMouseMove();
  2200. modules.Mouse.Anti_aim.settings.Anti_aim.active ? anti_aim("On") : anti_aim("Off");
  2201. }
  2202. window.requestAnimationFrame(handle_mouse_functions);
  2203.  
  2204. //anti aim
  2205. function detect_corner() {
  2206. deep_debug('corner detect called');
  2207. let w = window.innerWidth;
  2208. let h = window.innerHeight;
  2209. let center = {
  2210. x: w / 2,
  2211. y: h / 2
  2212. };
  2213. let lr, ud;
  2214. inputs.mouse.real.x > center.x ? lr = "r" : lr = "l";
  2215. inputs.mouse.real.y > center.y ? ud = "d" : ud = "u";
  2216. deep_debug('output: ', lr + ud);
  2217. return lr + ud;
  2218. }
  2219.  
  2220. function look_at_corner(corner) {
  2221. deep_debug('look at corner called with corner', corner);
  2222. if (!inputs.mouse.shooting) {
  2223. let w = window.innerWidth;
  2224. let h = window.innerHeight;
  2225. deep_debug('w and h', w, h);
  2226. deep_debug('inputs: ', inputs);
  2227. switch (corner) {
  2228. case "lu":
  2229. anti_aim_at('extern', w, h);
  2230. break
  2231. case "ld":
  2232. anti_aim_at('extern', w, 0);
  2233. break
  2234. case "ru":
  2235. anti_aim_at('extern', 0, h);
  2236. break
  2237. case "rd":
  2238. anti_aim_at('extern', 0, 0);
  2239. break
  2240. }
  2241. }
  2242. }
  2243.  
  2244. function anti_aim(toggle) {
  2245. deep_debug('anti aim called with:', toggle);
  2246. if(!player.inGame) return;
  2247. switch (toggle) {
  2248. case "On":
  2249. if (modules.Mouse.Anti_aim.settings.Anti_aim.active && !inputs.mouse.isFrozen) {
  2250. deep_debug('condition !modules.Mouse.Anti_aim.settings.active met');
  2251. look_at_corner(detect_corner());
  2252. }
  2253. break
  2254. case "Off":
  2255. //(inputs.mouse.isFrozen && !modules.Mouse.Freeze_mouse.active) ? unfreezeMouseMove() : null;
  2256. (inputs.mouse.isPaused && !modules.Mouse.Freeze_mouse.active) ? unpauseMouseMove() : null;
  2257. break
  2258. }
  2259. }
  2260.  
  2261. // Example: Freeze and unfreeze
  2262. function pauseMouseMove() {
  2263. if(!inputs.mouse.isPaused){
  2264. inputs.mouse.isForced = true;
  2265. inputs.mouse.force.x = inputs.mouse.real.x
  2266. inputs.mouse.force.y = inputs.mouse.real.y;
  2267. inputs.mouse.isPaused = true; //tell the script that freezing finished
  2268. }
  2269. }
  2270.  
  2271. function freezeMouseMove() {
  2272. if(!inputs.mouse.isFrozen){
  2273. inputs.mouse.isForced = true;
  2274. inputs.mouse.force.x = inputs.mouse.real.x
  2275. inputs.mouse.force.y = inputs.mouse.real.y;
  2276. inputs.mouse.isFrozen = true; //tell the script that freezing finished
  2277. }
  2278. /*
  2279. if (!inputs.mouse.isFrozen) {
  2280. inputs.mouse.isFrozen = true;
  2281. clear_onTouch();
  2282. deep_debug("Mousemove events are frozen.");
  2283. }
  2284. */
  2285. }
  2286.  
  2287. function unpauseMouseMove(){
  2288. if (inputs.mouse.isPaused && !inputs.mouse.isShooting) {
  2289. inputs.mouse.isForced = false;
  2290. inputs.mouse.isPaused = false; //tell the script that unfreezing finished
  2291. }
  2292. }
  2293.  
  2294. function unfreezeMouseMove() {
  2295. if (inputs.mouse.isFrozen) {
  2296. inputs.mouse.isForced = false;
  2297. inputs.mouse.isFrozen = false; //tell the script that unfreezing finished
  2298. }
  2299. /*
  2300. if (inputs.mouse.isFrozen && !inputs.mouse.isShooting) {
  2301. inputs.mouse.isFrozen = false;
  2302. redefine_onTouch();
  2303. deep_debug("Mousemove events are active.");
  2304. }
  2305. */
  2306. }
  2307.  
  2308. function click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  2309. i_e(input_or_extern, 'onTouchStart', -1, x, y);
  2310. setTimeout(() => {
  2311. i_e(input_or_extern, 'onTouchEnd', -1, x, y);
  2312. }, delay1);
  2313. setTimeout(() => {
  2314. inputs.mouse.shooting = false;
  2315. }, delay2);
  2316. }
  2317.  
  2318. /* it was a bug and is now patched
  2319. function ghost_click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  2320. i_e(input_or_extern, 'onTouchStart', -2, x, y);
  2321. setTimeout(() => {
  2322. i_e(input_or_extern, 'onTouchEnd', -2, x, y);
  2323. }, delay1);
  2324. setTimeout(() => {
  2325. inputs.mouse.shooting = false;
  2326. }, delay2);
  2327. }
  2328. */
  2329.  
  2330. function mouse_move(input_or_extern, x, y) {
  2331. deep_debug('mouse move called with', x, y);
  2332. apply_force(x, y);
  2333. i_e(input_or_extern, 'onTouchMove', -1, x, y);
  2334. disable_force();
  2335. }
  2336.  
  2337. function anti_aim_at(input_or_extern, x, y) {
  2338. deep_debug('frozen, shooting', inputs.mouse.isFrozen, inputs.mouse.isShooting);
  2339. deep_debug('anti aim at called with:', x, y);
  2340. if (inputs.mouse.shooting) {
  2341. deep_debug('quit because inputs.mouse.shooting');
  2342. return;
  2343. }
  2344. mouse_move(input_or_extern, x, y);
  2345. }
  2346. //////
  2347.  
  2348. //Custom Auto Spin
  2349. function getMouseAngle(x, y) {
  2350. const centerX = window.innerWidth / 2;
  2351. const centerY = window.innerHeight / 2;
  2352.  
  2353. const dx = x - centerX;
  2354. const dy = y - centerY;
  2355.  
  2356. let angle = Math.atan2(dy, dx) * (180 / Math.PI);
  2357.  
  2358. return angle < 0 ? angle + 360 : angle;
  2359. }
  2360.  
  2361. function offset_Angle(angle){
  2362. let _angle;
  2363. if(angle <= 360){
  2364. _angle = angle;
  2365. }else{
  2366. _angle = angle-360;
  2367. while(_angle > 360){
  2368. _angle -= 360;
  2369. }
  2370. }
  2371. return _angle;
  2372. }
  2373.  
  2374. function getPointOnCircle(degrees) {
  2375. const centerX = window.innerWidth / 2;
  2376. const centerY = window.innerHeight / 2;
  2377. const radius = Math.min(window.innerWidth, window.innerHeight) / 2;
  2378.  
  2379. const radians = degrees * (Math.PI / 180);
  2380. const x = centerX + radius * Math.cos(radians);
  2381. const y = centerY + radius * Math.sin(radians);
  2382.  
  2383. return { x:x, y:y };
  2384. }
  2385.  
  2386. let cas_force = false;
  2387. let cas_active = false;
  2388. let starting_angle = 0;
  2389. let temp_interval = setInterval(start_custom_spin, modules.Mouse.Custom_auto_spin.settings.Interval.selected);
  2390. function start_keyDown_Proxy(){
  2391. extern.onKeyDown = new Proxy(extern.onKeyDown, {
  2392. apply: function (target, thisArgs, args){
  2393. if(args.length > 1 && args[1] === fingerprint){
  2394. //inputs coming from script
  2395.  
  2396. //inputs_game
  2397. let keys = Object.keys(inputs.moving_game);
  2398. let key_nums = [];
  2399. let l = keys.length;
  2400. for(let i = 0; i < l; i++){
  2401. key_nums[i] = diep_keys[keys[i]];
  2402. }
  2403. if(key_nums.includes(args[0])){
  2404. let i = key_nums.indexOf(args[0]);
  2405. inputs.moving_game[keys[i]] = true;
  2406. }
  2407. }else if(modules.Mouse.Custom_auto_spin.settings.Replace_auto_spin.active && args[0] === diep_keys.KeyC){
  2408. //Auto Spin replacer
  2409. cas_active = !cas_active;
  2410. new_notification(`Custom Auto Spin: ${cas_active?'On':'Off'}`, notification_rgbs.normal, 4000);
  2411. return;
  2412. }else{
  2413. //inputs coming from user
  2414.  
  2415. //inputs_real
  2416. let keys = Object.keys(inputs.moving_real);
  2417. let key_nums = [];
  2418. let l = keys.length;
  2419. for(let i = 0; i < l; i++){
  2420. key_nums[i] = diep_keys[keys[i]];
  2421. }
  2422. if(key_nums.includes(args[0])){
  2423. let i = key_nums.indexOf(args[0]);
  2424. inputs.moving_real[keys[i]] = true;
  2425. }
  2426. }
  2427. return Reflect.apply(target, thisArgs, args);
  2428. }
  2429. });
  2430. }
  2431.  
  2432. function start_keyUp_Proxy(){
  2433. extern.onKeyUp = new Proxy(extern.onKeyUp, {
  2434. apply: function (target, thisArgs, args){
  2435. if(args.length > 1 && args[1] === fingerprint){
  2436. //inputs coming from script
  2437.  
  2438. //moving_game
  2439. let keys = Object.keys(inputs.moving_game);
  2440. let key_nums = [];
  2441. let l = keys.length;
  2442. for(let i = 0; i < l; i++){
  2443. key_nums[i] = diep_keys[keys[i]];
  2444. }
  2445. if(key_nums.includes(args[0])){
  2446. let i = key_nums.indexOf(args[0]);
  2447. inputs.moving_game[keys[i]] = false;
  2448. }
  2449. }else{
  2450. //inputs coming from user
  2451.  
  2452. //moving_real
  2453. let keys = Object.keys(inputs.moving_real);
  2454. let key_nums = [];
  2455. let l = keys.length;
  2456. for(let i = 0; i < l; i++){
  2457. key_nums[i] = diep_keys[keys[i]];
  2458. }
  2459. if(key_nums.includes(args[0])){
  2460. let i = key_nums.indexOf(args[0]);
  2461. inputs.moving_real[keys[i]] = false;
  2462. //make sure script knows if you unpressed a key that it was pressing
  2463. if(inputs.moving_game[keys[i]]) inputs.moving_game[keys[i]] = false;
  2464. }
  2465. }
  2466. return Reflect.apply(target, thisArgs, args);
  2467. }
  2468. });
  2469. }
  2470.  
  2471. function start_custom_spin(){
  2472. clearInterval(temp_interval);
  2473. temp_interval = setInterval(start_custom_spin, modules.Mouse.Custom_auto_spin.settings.Interval.selected);
  2474. if(!player.inGame) return;
  2475. if(!modules.Mouse.Custom_auto_spin.settings.Replace_auto_spin.active) cas_active = modules.Mouse.Custom_auto_spin.settings.Custom_auto_spin.active;
  2476. if(!cas_active){
  2477. starting_angle = getMouseAngle(inputs.mouse.real.x, inputs.mouse.real.y);
  2478. if(inputs.mouse.isForced && cas_force){
  2479. disable_force();
  2480. cas_force = false;
  2481. }
  2482. }else{
  2483. cas_force = true;
  2484. let l = Math.pow(2, modules.Mouse.Custom_auto_spin.settings.Smoothness.selected);
  2485. console.log(l);
  2486. let angle_peace = 360/l;
  2487. console.log(angle_peace);
  2488. let time_peace = modules.Mouse.Custom_auto_spin.settings.Interval.selected/l;
  2489. for(let i = 0; i < l; i++){
  2490. setTimeout(() => {
  2491. let temp_angle = offset_Angle(starting_angle + angle_peace * i);
  2492. let temp_coords = getPointOnCircle(temp_angle);
  2493. apply_force(temp_coords.x, temp_coords.y);
  2494. i_e('extern', 'onTouchMove', -1, temp_coords.x, temp_coords.y);
  2495. }, time_peace*i);
  2496. }
  2497. }
  2498. }
  2499.  
  2500. //Sandbox Auto Lvl up
  2501. function sandbox_lvl_up() {
  2502. if (modules.Functional.Sandbox_lvl_up.active && player.connected && player.inGame && player.gamemode === "sandbox") {
  2503. document.querySelector("#sandbox-max-level").click();
  2504. }
  2505. }
  2506.  
  2507. //START, autorespawn Module
  2508.  
  2509. //name saving logic
  2510. var killer_names = localStorage.getItem("[Diep.io+] saved names") ? JSON.parse(localStorage.getItem("[Diep.io+] saved names")) : ['r!PsAw', 'TestTank'];
  2511. function import_killer_names(){
  2512. let imported_string = prompt('Paste killer names here: ', '["name1", "name2", "name3"]');
  2513. killer_names = killer_names.concat(JSON.parse(imported_string));
  2514. killer_names = [...new Set(killer_names)];
  2515. localStorage.setItem("[Diep.io+] saved names", JSON.stringify(killer_names));
  2516. }
  2517. let banned_names = ["Pentagon", "Triangle", "Square", "Crasher", "Mothership", "Guardian of Pentagons", "Fallen Booster", "Fallen Overlord", "Necromancer", "Defender", "Unnamed Tank"];
  2518. function check_and_save_name(){
  2519. deep_debug(_c.killer_name, !killer_names.includes(_c.killer_name));
  2520. if(_c.screen_state === 'game-over' && !banned_names.includes(_c.killer_name) && !killer_names.includes(_c.killer_name)){
  2521. deep_debug("Condition met!");
  2522. killer_names.push(_c.killer_name);
  2523. deep_debug("Added");
  2524. killer_names = [...new Set(killer_names)];
  2525. if(modules.Functional.Auto_respawn.settings.Remember.active){
  2526. localStorage.setItem("[Diep.io+] saved names", JSON.stringify(killer_names));
  2527. deep_debug("saved list");
  2528. }
  2529. }
  2530. }
  2531.  
  2532. function get_random_killer_name(){
  2533. let l = killer_names.length;
  2534. let index = Math.floor(Math.random() * l);
  2535. return killer_names[index];
  2536. }
  2537.  
  2538. //Random Symbols/Numbers/Letters
  2539. function generate_random_name_string(type){
  2540. let final_result = '';
  2541. let chars = '';
  2542. switch(type){
  2543. case "Symbols":
  2544. chars = '!@#$%^&*()_+=-.,][';
  2545. break
  2546. case "Numbers":
  2547. chars = '1234567890';
  2548. break
  2549. case "Letters":
  2550. chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  2551. break
  2552. }
  2553. for (let i = 0; i < 16; i++) {
  2554. final_result += chars[Math.floor(Math.random() * chars.length)];
  2555. }
  2556. return final_result;
  2557. }
  2558. //ascii inject
  2559. function get_ascii_inject(type){
  2560. let asciiArray = [];
  2561. switch(type){
  2562. case "Glitched":
  2563. asciiArray = [0x110000];
  2564. break
  2565. case "N A M E":
  2566. asciiArray = player.name.split("").flatMap(char => [char.charCodeAt(0), 10]).slice(0, -1);
  2567. break
  2568. }
  2569. let interesting = {
  2570. length: asciiArray.length,
  2571. charCodeAt(i) {
  2572. return asciiArray[i];
  2573. },
  2574. };
  2575. const argument = {
  2576. toString() {
  2577. return interesting;
  2578. },
  2579. };
  2580. return argument;
  2581. }
  2582.  
  2583. //main Loop
  2584. function get_respawn_name_by_type(type){
  2585. let temp_name = '';
  2586. switch(type){
  2587. case "Normal":
  2588. temp_name = player.name;
  2589. break
  2590. case "Glitched":
  2591. temp_name = get_ascii_inject(type);
  2592. break
  2593. case "N A M E":
  2594. temp_name = get_ascii_inject(type);
  2595. break
  2596. case "Random Killer":
  2597. temp_name = get_random_killer_name();
  2598. break
  2599. case "Random Symbols":
  2600. temp_name = generate_random_name_string('Symbols');
  2601. break
  2602. case "Random Numbers":
  2603. temp_name = generate_random_name_string('Numbers');
  2604. break
  2605. case "Random Letters":
  2606. temp_name = generate_random_name_string('Letters');
  2607. break
  2608. }
  2609. return temp_name;
  2610. }
  2611. function respawn() {
  2612. check_and_save_name();
  2613. if (modules.Functional.Auto_respawn.settings.Auto_respawn.active && player.connected && !player.inGame) {
  2614. //prevent respawn after 300k flag
  2615. if(modules.Functional.Auto_respawn.settings.Prevent.active && _c.death_score >= 300000){
  2616. return;
  2617. }
  2618. let type = modules.Functional.Auto_respawn.settings.Name.selected;
  2619. let temp_name = get_respawn_name_by_type(type);
  2620. extern.try_spawn(temp_name);
  2621. }
  2622. }
  2623.  
  2624. //END
  2625.  
  2626. //AntiAfk Timeout
  2627. function AntiAfkTimeout() {
  2628. if (modules.Mouse.Anti_timeout.active && player.connected) {
  2629. extern.onTouchMove(inputs.mouse.real.x, inputs.mouse.real.y);
  2630. }
  2631. }
  2632.  
  2633. //Zoom
  2634. function start_zoom_proxy(){
  2635. input.setScreensizeZoom = new Proxy(input.setScreensizeZoom, {
  2636. apply: function(target, thisArgs, args){
  2637. player.base_value = args[1];
  2638. let factor = modules.Functional.Zoom.value / 100;
  2639. player.dpr = player.base_value * factor;
  2640. let newargs = [args[0], player.dpr];
  2641. return Reflect.apply(target, thisArgs, newargs);
  2642. }
  2643. });
  2644. }
  2645. function HandleZoom() {
  2646. if(player.connected){
  2647. //let base_value = 1;
  2648. //let factor = modules.Functional.Zoom.value / 100;
  2649. //player.dpr = base_value * factor;
  2650. let diepScale = player.base_value * Math.floor(player.ui_scale * windowScaling() * 25) / 25;
  2651. extern.setScreensizeZoom(diepScale, player.base_value);
  2652. extern.updateDPR(player.dpr);
  2653. }
  2654. }
  2655.  
  2656. //ctx helper functions
  2657. function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c, stroke_or_fill = 'fill', _globalAlpha=1, _lineWidth = '2px') {
  2658. let original_ga = ctx.globalAlpha;
  2659. let original_lw = ctx.lineWidth;
  2660. ctx.beginPath();
  2661. ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
  2662. ctx.globalAlpha = _globalAlpha;
  2663. switch(stroke_or_fill){
  2664. case "fill":
  2665. ctx.fillStyle = c;
  2666. ctx.fill();
  2667. break
  2668. case "stroke":
  2669. ctx.lineWidth = _lineWidth;
  2670. ctx.strokeStyle = c;
  2671. ctx.stroke();
  2672. ctx.lineWidth = original_lw;
  2673. break
  2674. }
  2675. ctx.globalAlpha = original_ga;
  2676. }
  2677.  
  2678. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  2679. deep_debug('called crx_text with: ', fcolor, scolor, lineWidth, font, text, textX, textY);
  2680. ctx.fillStyle = fcolor;
  2681. ctx.lineWidth = lineWidth;
  2682. ctx.font = font;
  2683. ctx.strokeStyle = scolor;
  2684. ctx.strokeText(`${text}`, textX, textY)
  2685. ctx.fillText(`${text}`, textX, textY)
  2686. }
  2687.  
  2688. function ctx_rect(x, y, a, b, c) {
  2689. deep_debug('called ctx_rect with: ', x, y, a, b, c);
  2690. ctx.beginPath();
  2691. ctx.strokeStyle = c;
  2692. ctx.strokeRect(x, y, a, b);
  2693. }
  2694.  
  2695. function transparent_rect_fill(x, y, a, b, scolor, fcolor, opacity){
  2696. deep_debug('called transparent_rect_fill with: ', x, y, a, b, scolor, fcolor, opacity);
  2697. ctx.beginPath();
  2698. ctx.rect(x, y, a, b);
  2699.  
  2700. // Set stroke opacity
  2701. ctx.globalAlpha = 1;// Reset to 1 for stroke, or set as needed
  2702. ctx.strokeStyle = scolor;
  2703. ctx.stroke();
  2704.  
  2705. // Set fill opacity
  2706. ctx.globalAlpha = opacity;// Set the opacity for the fill color
  2707. ctx.fillStyle = fcolor;
  2708. ctx.fill();
  2709.  
  2710. // Reset globalAlpha back to 1 for future operations
  2711. ctx.globalAlpha = 1;
  2712. }
  2713.  
  2714. //key visualiser
  2715. let ctx_wasd = {
  2716. square_sizes: { //in windowScaling
  2717. a: 50,
  2718. b: 50
  2719. },
  2720. text_props: {
  2721. lineWidth: 3,
  2722. font: 1 + "em Ubuntu",
  2723. },
  2724. square_colors: {
  2725. stroke: "black",
  2726. unpressed: "yellow",
  2727. pressed: "orange"
  2728. },
  2729. text_colors: {
  2730. stroke: "black",
  2731. unpressed: "orange",
  2732. pressed: "red"
  2733. },
  2734. w: {
  2735. x: 300,
  2736. y: 200,
  2737. pressed: false,
  2738. text: 'W'
  2739. },
  2740. a: {
  2741. x: 350,
  2742. y: 150,
  2743. pressed: false,
  2744. text: 'A'
  2745. },
  2746. s: {
  2747. x: 300,
  2748. y: 150,
  2749. pressed: false,
  2750. text: 'S'
  2751. },
  2752. d: {
  2753. x: 250,
  2754. y: 150,
  2755. pressed: false,
  2756. text: 'D'
  2757. },
  2758. l_m: {
  2759. x: 350,
  2760. y: 75,
  2761. pressed: false,
  2762. text: 'LMC'
  2763. },
  2764. r_m: {
  2765. x: 250,
  2766. y: 75,
  2767. pressed: false,
  2768. text: 'RMC'
  2769. },
  2770. }
  2771.  
  2772. function visualise_keys(){
  2773. let keys = ['w', 'a', 's', 'd', 'l_m', 'r_m'];
  2774. let l = keys.length;
  2775. for(let i = 0; i < l; i++){
  2776. let args = {
  2777. x: canvas.width - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].x),
  2778. y: canvas.height - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].y),
  2779. a: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.a),
  2780. b: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.b),
  2781. s_c: ctx_wasd.square_colors.stroke,
  2782. f_c: ctx_wasd[keys[i]].pressed? ctx_wasd.square_colors.pressed : ctx_wasd.square_colors.unpressed,
  2783. t_s: ctx_wasd.text_colors.stroke,
  2784. t_f: ctx_wasd[keys[i]].pressed? ctx_wasd.text_colors.pressed : ctx_wasd.text_colors.unpressed,
  2785. t_lineWidth: ctx_wasd.text_props.lineWidth,
  2786. t_font: ctx_wasd.text_props.font,
  2787. text: ctx_wasd[keys[i]].text,
  2788. opacity: 0.25
  2789. }
  2790. deep_debug(args);
  2791. transparent_rect_fill(
  2792. args.x,
  2793. args.y,
  2794. args.a,
  2795. args.b,
  2796. args.s_c,
  2797. args.f_c,
  2798. args.opacity
  2799. );
  2800. ctx_text(
  2801. args.t_f,
  2802. args.t_s,
  2803. args.t_lineWidth,
  2804. args.t_font,
  2805. args.text,
  2806. args.x+(args.a/2),
  2807. args.y+(args.b/2)
  2808. );
  2809. }
  2810. }
  2811.  
  2812. //Key Binds for Tank Upgrading
  2813. let selected_box = null;
  2814. let _bp = { //box parameters
  2815. startX: 47,
  2816. startY: 67,
  2817. distX: 13,
  2818. distY: 9,
  2819. width: 86,
  2820. height: 86,
  2821. outer_xy: 2
  2822. }
  2823.  
  2824. let _bo = { //box offsets
  2825. offsetX: _bp.width + (_bp.outer_xy * 2) + _bp.distX,
  2826. offsetY: _bp.height + (_bp.outer_xy * 2) + _bp.distY
  2827. }
  2828.  
  2829. function step_offset(steps, offset){
  2830. let final_offset = 0;
  2831. switch(offset){
  2832. case "x":
  2833. final_offset = _bp.startX + (steps * _bo.offsetX);
  2834. break
  2835. case "y":
  2836. final_offset = _bp.startY + (steps * _bo.offsetY);
  2837. break
  2838. }
  2839. return final_offset;
  2840. }
  2841.  
  2842. const boxes = [
  2843. {
  2844. color: "lightblue",
  2845. LUcornerX: _bp.startX,
  2846. LUcornerY: _bp.startY,
  2847. KeyBind: "R"
  2848. },
  2849. {
  2850. color: "green",
  2851. LUcornerX: _bp.startX + _bo.offsetX,
  2852. LUcornerY: _bp.startY,
  2853. KeyBind: "T"
  2854. },
  2855. {
  2856. color: "red",
  2857. LUcornerX: _bp.startX,
  2858. LUcornerY: _bp.startY + _bo.offsetY,
  2859. KeyBind: "F"
  2860. },
  2861. {
  2862. color: "yellow",
  2863. LUcornerX: _bp.startX + _bo.offsetX,
  2864. LUcornerY: _bp.startY + _bo.offsetY,
  2865. KeyBind: "G"
  2866. },
  2867. {
  2868. color: "blue",
  2869. LUcornerX: _bp.startX,
  2870. LUcornerY: step_offset(2, "y"),
  2871. KeyBind: "V"
  2872. },
  2873. {
  2874. color: "purple",
  2875. LUcornerX: _bp.startX + _bo.offsetX,
  2876. LUcornerY: step_offset(2, "y"),
  2877. KeyBind: "B"
  2878. }
  2879. ]
  2880.  
  2881. //upgrading Tank logic
  2882. function upgrade_get_coords(color){
  2883. let l = boxes.length;
  2884. let upgrade_coords = {x: "not defined", y: "not defined"};
  2885. for(let i = 0; i < l; i++){
  2886. if(boxes[i].color === color){
  2887. upgrade_coords.x = dim_c.windowScaling_2_window(boxes[i].LUcornerX + (_bp.width/2));
  2888. upgrade_coords.y = dim_c.windowScaling_2_window(boxes[i].LUcornerY + (_bp.height/2));
  2889. }
  2890. }
  2891. deep_debug(upgrade_coords);
  2892. return upgrade_coords;
  2893. }
  2894.  
  2895. function upgrade(color, delay = 100, cdelay1, cdelay2){
  2896. let u_coords = upgrade_get_coords(color);
  2897. //ghost_click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2);
  2898. click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2); //using this since ghost_click was patched
  2899. }
  2900. window.upgrade = upgrade;
  2901.  
  2902. function visualise_tank_upgrades(){
  2903. let l = boxes.length;
  2904. for (let i = 0; i < l; i++) {
  2905. let coords = upgrade_get_coords(boxes[i].color);
  2906. ctx_text(boxes[i].color, "black", 6, 1.5 + "em Ubuntu", `[${boxes[i].KeyBind}]`, coords.x, coords.y);
  2907. }
  2908. }
  2909.  
  2910. function check_tu_KeyBind(_KeyBind){
  2911. let l = boxes.length;
  2912. for (let i = 0; i < l; i++) {
  2913. if(_KeyBind === `Key${boxes[i].KeyBind}`){
  2914. deep_debug(_KeyBind, `Key${boxes[i].KeyBind}`, _KeyBind === `Key${boxes[i].KeyBind}`);
  2915. upgrade(boxes[i].color);
  2916. }
  2917. }
  2918. }
  2919.  
  2920. document.body.addEventListener("keydown", function(e) {
  2921. switch(e.code){
  2922. case "KeyW":
  2923. ctx_wasd.w.pressed = true;
  2924. break
  2925. case "KeyA":
  2926. ctx_wasd.a.pressed = true;
  2927. break
  2928. case "KeyS":
  2929. ctx_wasd.s.pressed = true;
  2930. break
  2931. case "KeyD":
  2932. ctx_wasd.d.pressed = true;
  2933. break
  2934. }
  2935. if(modules.Functional.Tank_upgrades.settings.Tank_upgrades.active){
  2936. check_tu_KeyBind(e.code);
  2937. }
  2938. });
  2939.  
  2940. document.body.addEventListener("keyup", function(e) {
  2941. deep_debug(`unpressed ${e.code}`);
  2942. switch(e.code){
  2943. case "KeyW":
  2944. ctx_wasd.w.pressed = false;
  2945. break
  2946. case "KeyA":
  2947. ctx_wasd.a.pressed = false;
  2948. break
  2949. case "KeyS":
  2950. ctx_wasd.s.pressed = false;
  2951. break
  2952. case "KeyD":
  2953. ctx_wasd.d.pressed = false;
  2954. break
  2955. }
  2956. deep_debug('====DID UNPRESS??', ctx_wasd.w.pressed, ctx_wasd.a.pressed, ctx_wasd.s.pressed, ctx_wasd.d.pressed);
  2957. });
  2958.  
  2959. document.body.addEventListener("mousedown", function(e) {
  2960. switch(e.button){
  2961. case 0:
  2962. ctx_wasd.l_m.pressed = true;
  2963. break
  2964. case 2:
  2965. ctx_wasd.r_m.pressed = true;
  2966. break
  2967. }
  2968. });
  2969.  
  2970. document.body.addEventListener("mouseup", function(e) {
  2971. switch(e.button){
  2972. case 0:
  2973. ctx_wasd.l_m.pressed = false;
  2974. break
  2975. case 2:
  2976. ctx_wasd.r_m.pressed = false;
  2977. break
  2978. }
  2979. });
  2980. //destroyer cooldown visualiser
  2981. let times_watcher = {
  2982. waiting: false,
  2983. cooldowns: [2540, 2311, 2201, 1911, 1760, 1681, 1560, 1381],
  2984. }
  2985.  
  2986. function draw_destroyer_cooldown(){
  2987. let c = times_watcher.waiting? 'red' : 'lime' ;
  2988. ctx_arc(inputs.mouse.real.x, inputs.mouse.real.y, 50*player.dpr, 0, 2 * Math.PI, false, c, 'fill', 0.3);
  2989. }
  2990.  
  2991. function handle_cooldown(_cd){
  2992. times_watcher.waiting = true;
  2993. setTimeout(() => {
  2994. times_watcher.waiting = false;
  2995. }, _cd);
  2996. }
  2997. document.body.addEventListener("mousedown", function(e) {
  2998. if(e.button === 0 && !times_watcher.waiting && player.inGame){
  2999. let _cd = times_watcher.cooldowns[modules.Visual.destroyer_cooldown.settings.reload.selected];
  3000. handle_cooldown(_cd);
  3001. }
  3002. });
  3003.  
  3004. document.body.addEventListener("keydown", function(e){
  3005. if(e.keyCode === 32 && !times_watcher.waiting && player.inGame){
  3006. let _cd = times_watcher.cooldowns[modules.Visual.destroyer_cooldown.settings.reload.selected];
  3007. handle_cooldown(_cd);
  3008. }
  3009. });
  3010.  
  3011. //debug function
  3012. function draw_canvas_debug(){
  3013. let temp_textX = canvas.width/2, temp_textY = canvas.height/2;
  3014. let temp_texts = [
  3015. `Your Real mouse position! x: ${inputs.mouse.real.x} y: ${inputs.mouse.real.y}`,
  3016. `Scaled down for the game! x: ${(inputs.mouse.game.x).toFixed(2)} y: ${(inputs.mouse.game.y).toFixed(2)}`,
  3017. `player values! DPR: ${player.dpr} base value: ${player.base_value} ui scale: ${player.ui_scale}`,
  3018. `window Scaling: ${windowScaling()}`,
  3019. `Canvas! width: ${canvas.width} height: ${canvas.height}`,
  3020. `Window! width: ${window.innerWidth} height: ${window.innerHeight}`,
  3021. `Ratio between Window and Canvas: ${dim_c.window_2_canvas(1)}`,
  3022. `Inputs Moving_game: ${inputs.moving_game.KeyW} ${inputs.moving_game.KeyA} ${inputs.moving_game.KeyS} ${inputs.moving_game.KeyD} ${inputs.moving_game.ArrowUp} ${inputs.moving_game.ArrowRight} ${inputs.moving_game.ArrowDown} ${inputs.moving_game.ArrowLeft}`
  3023. ];
  3024. let l = temp_texts.length;
  3025. let _d = (canvas.height/3)/l;
  3026. for(let i = 0; i < l; i++){
  3027. ctx_text('yellow', 'black', 5, 1.5 + "em Ubuntu", temp_texts[i], temp_textX, temp_textY + (i * _d));
  3028. }
  3029. //drawing line from your real mouse position, to your ingame mouse position
  3030. ctx.beginPath();
  3031. ctx.strokeStyle = "Red";
  3032. ctx.moveTo(inputs.mouse.real.x, inputs.mouse.real.y);
  3033. ctx.lineTo(inputs.mouse.game.x*player.dpr, inputs.mouse.game.y*player.dpr);
  3034. ctx.stroke();
  3035. }
  3036.  
  3037. //CANVAS API REQUIRED FOR EVERYTHING HERE
  3038. function compare_versions(version1, version2) {
  3039. if (!version1 || !version2) {
  3040. console.warn('Not enough arguments');
  3041. return;
  3042. }
  3043.  
  3044. const values1 = version1.split('.').map(Number);
  3045. const values2 = version2.split('.').map(Number);
  3046. const maxLength = Math.max(values1.length, values2.length);
  3047.  
  3048. for (let i = 0; i < maxLength; i++) {
  3049. const v1 = values1[i] || 0;
  3050. const v2 = values2[i] || 0;
  3051.  
  3052. if (v1 > v2) return 'newer';
  3053. if (v1 < v2) return 'older';
  3054. }
  3055.  
  3056. return 'equal';
  3057. }
  3058.  
  3059. //maths helper functions
  3060. function get_average(points) {
  3061. let result = [0, 0];
  3062. for (let point of points) {
  3063. result[0] += point[0];
  3064. result[1] += point[1];
  3065. }
  3066. result[0] /= points.length;
  3067. result[1] /= points.length;
  3068. return result;
  3069. }
  3070.  
  3071. //api detecting logic
  3072. let current_tries = 0;
  3073. let notify_after_tries = 100;
  3074. let notified_about_missing = false;
  3075. let api_loaded = false;
  3076. let api_missing = false;
  3077.  
  3078. function notify_about_missing(){
  3079. if(notified_about_missing) return;
  3080. alert('Missing Canvas Api to run addon script, join our discord server to get it: https://discord.gg/S3ZzgDNAuG');
  3081. notified_about_missing = true;
  3082. }
  3083.  
  3084. function await_api(){
  3085. if(current_tries > notify_after_tries) {
  3086. api_missing = true;
  3087. return;
  3088. }
  3089. current_tries++;
  3090. api_loaded = !!window.ripsaw_api;
  3091. console.log('did api load?', api_loaded);
  3092. window.ripsaw_api ? clearInterval(interval_api) : setTimeout(await_api, 100);
  3093. }
  3094. var interval_api = setInterval(await_api, 100);
  3095.  
  3096. //version require
  3097. let req_indexes = new Set();
  3098. let req_bools = [];
  3099. function ra_require(version, index){
  3100. if(api_loaded && !api_missing && !req_bools[index]){
  3101. if(req_indexes.has(index)) return console.warn('index already being used!');
  3102. let compare = ['equal', 'newer'];
  3103. let result = compare.includes(compare_versions(window.ripsaw_api.version, version));
  3104. req_bools[index] = true; //it's to let script know that this function doesn't need to loop after notifying
  3105. req_indexes.add(index);
  3106. if(!result) alert(`Required API version: ${version} and above!\nUpdate in our Discord server :) https://discord.gg/S3ZzgDNAuG`);
  3107. }
  3108. }
  3109.  
  3110. //helper API functions
  3111. function get_your_tank(tanks){
  3112. let closest = null;
  3113. let last_d = Infinity;
  3114. for(let tank of tanks){
  3115. let dx = tank.body[0].x - (canvas.width / 2);
  3116. let dy = tank.body[0].y - (canvas.height / 2);
  3117. let d = Math.hypot(dx, dy);
  3118. if (d < last_d) {
  3119. closest = tank;
  3120. last_d = d;
  3121. }
  3122. }
  3123. if (!closest) return;//console.warn("Your Tank wasn't found yet...");
  3124. return closest;
  3125. }
  3126.  
  3127. function get_your_true_color(tank){
  3128. if(tank.name === "Unknown Tank") return;
  3129. if(tank.body.length === 1) return tank.body[0];
  3130. let i = 1;
  3131. let b1 = tank.body[0];
  3132. let b2 = tank.body[i];
  3133. if(!b1 || !b2) return;
  3134. while(b1.color === b2.color && i < tank.body.length){
  3135. i++;
  3136. b2 = tank.body[i];
  3137. }
  3138. if(b1.color === b2.color) return console.warn('duplicate');
  3139. if(b1.radius < b2.radius) return b1.color;
  3140. if(b2.radius < b1.radius) return b2.color;
  3141. }
  3142.  
  3143. //Enemy Tracers
  3144. function draw_enemy_tracers(){
  3145. let tanks = ripsaw_api.get_tanks();
  3146. let your_tank = get_your_tank(tanks);
  3147.  
  3148. if (tanks && your_tank) {
  3149. let your_team_color = get_your_true_color(your_tank);
  3150. let enemies = [];
  3151.  
  3152. for (let tank of tanks) {
  3153. let temp_team_color = get_your_true_color(tank);
  3154. if (temp_team_color != your_team_color) enemies.push(tank);
  3155. }
  3156.  
  3157. if (enemies.length > 0) {
  3158. for(let enemy of enemies){
  3159. if(enemy.name != 'Unknown Tank'){
  3160. let toX = enemy.body[0].x, toY = enemy.body[0].y, fromX = your_tank.body[0].x, fromY = your_tank.body[0].y;
  3161. const dx = toX - fromX;
  3162. const dy = toY - fromY;
  3163. const distance = Math.hypot(dx, dy);
  3164. if (distance === 0) return; // avoid divide-by-zero
  3165.  
  3166. // Normalize the direction vector and scale it to the desired length
  3167. const headLength = 50;
  3168.  
  3169. let maxLength = Math.min(canvas.width / 2, canvas.height / 2);
  3170. let length = Math.min(maxLength, distance); // cap by distance
  3171.  
  3172. const dirX = (dx / distance) * length;
  3173. const dirY = (dy / distance) * length;
  3174.  
  3175. const endX = fromX + dirX;
  3176. const endY = fromY + dirY;
  3177.  
  3178. const angle = Math.atan2(dirY, dirX);
  3179. let og = ctx.strokeStyle;
  3180. ctx.beginPath();
  3181. ctx.strokeStyle = "red";
  3182.  
  3183. // Draw arrowhead
  3184. ctx.beginPath();
  3185. ctx.moveTo(endX, endY);
  3186. ctx.lineTo(
  3187. endX - headLength * Math.cos(angle - Math.PI / 6),
  3188. endY - headLength * Math.sin(angle - Math.PI / 6)
  3189. );
  3190. ctx.lineTo(
  3191. endX - headLength * Math.cos(angle + Math.PI / 6),
  3192. endY - headLength * Math.sin(angle + Math.PI / 6)
  3193. );
  3194. ctx.lineTo(endX, endY);
  3195. ctx.lineTo(
  3196. endX - headLength * Math.cos(angle - Math.PI / 6),
  3197. endY - headLength * Math.sin(angle - Math.PI / 6)
  3198. );
  3199. ctx.stroke();
  3200. ctx.strokeStyle = og;
  3201. }
  3202. }
  3203. }
  3204. }
  3205. }
  3206.  
  3207.  
  3208. //information about the map
  3209. const world_map = {
  3210. min: {x: 0, y:0},
  3211. max: {x:26000, y:26000},
  3212. }
  3213.  
  3214. const map_bases = {
  3215. t2: {
  3216. width: this.width = 3900,
  3217. height: this.height = world_map.max.y,
  3218. //left upper corner (start), right bottom corner (end)
  3219. blue: {
  3220. start: {x: 0, y: 0},
  3221. end: {x: this.width, y: this.height},
  3222. },
  3223. red: {
  3224. start: {x: world_map.max.x-this.width, y: 0},
  3225. end: {x: world_map.max.x, y: this.height},
  3226. },
  3227. },
  3228. t4: {
  3229. width: this.width = 3900,
  3230. height: this.height = 3900,
  3231. //left upper corner (start), right bottom corner (end)
  3232. blue: {
  3233. start: {x: 0, y: 0},
  3234. end: {x: this.width, y: this.height},
  3235. },
  3236. purple: {
  3237. start: {x: world_map.max.x-this.width, y: 0},
  3238. end: {x: world_map.max.x, y: this.height},
  3239. },
  3240. green: {
  3241. start: {x: 0, y: world_map.max.y-this.height},
  3242. end: {x: this.width, y: world_map.max.y},
  3243. },
  3244. red: {
  3245. start: {x: world_map.max.x-this.width, y: world_map.max.y-this.height},
  3246. end: {x: world_map.max.x, y: world_map.max.y},
  3247. },
  3248. }
  3249. }
  3250.  
  3251. //calculate your world position
  3252.  
  3253. function get_your_world_pos(){
  3254. if(api_missing) {
  3255. notify_about_missing();
  3256. return -1;
  3257. }
  3258. if(!req_bools[1]) ra_require('0.0.8', 1);
  3259. //calculate
  3260. let minimap = window.ripsaw_api.get_minimap().corners;
  3261. let you = window.ripsaw_api.get_arrows().minimap.center;
  3262. let unscaled = {
  3263. x: you[0]-minimap.top_left[0],
  3264. y: you[1]-minimap.top_left[1],
  3265. max: {x: minimap.top_right[0]-minimap.top_left[0], y: minimap.bottom_left[1]-minimap.top_left[1]},
  3266. }
  3267. let precision = modules.Addons.world_coords.settings.precision.selected;
  3268. let world = {
  3269. x: JSON.parse(((unscaled.x/unscaled.max.x)*world_map.max.x).toFixed(precision)),
  3270. y: JSON.parse(((unscaled.y/unscaled.max.y)*world_map.max.y).toFixed(precision)),
  3271. }
  3272. return world;
  3273. }
  3274.  
  3275. /* little debug to check if base positions are correct
  3276. setInterval(() =>{
  3277. let you = get_your_world_pos();
  3278. let keys = ['blue', 'green', 'red', 'purple'];
  3279. console.log(' ');
  3280. for(let key of keys){
  3281. let t = map_bases.t4[key];
  3282. let insideX = (you.x > t.start.x) && (you.x < t.end.x);
  3283. let insideY = (you.y > t.start.y) && (you.y < t.end.y);
  3284. console.log(`%cAre you inside ${key} base?: x ${insideX} y ${insideY}`, `color: ${key}`);
  3285. }
  3286. }, 500);
  3287. */
  3288.  
  3289. //check if you're inside a base
  3290. function is_player_in_base(){
  3291. let you = get_your_world_pos();
  3292. if(you === -1) return -1;
  3293. let t = map_bases.t4[player.team];
  3294. let insideX = (you.x > t.start.x) && (you.x < t.end.x);
  3295. let insideY = (you.y > t.start.y) && (you.y < t.end.y);
  3296. return (insideX && insideY);
  3297. }
  3298.  
  3299. //aim lines
  3300. function draw_aim_lines(len_factor=1){
  3301. let temp_tanks = window.ripsaw_api.get_tanks();
  3302. if(temp_tanks.length <= 0) return;
  3303. for(let temp_tank of temp_tanks){
  3304. for(let temp_turret of temp_tank.turrets){
  3305. switch(temp_turret.source_array){
  3306. case "rectangular":{
  3307. let diff = {
  3308. x: temp_turret.coords.endX - temp_turret.coords.startX,
  3309. y: temp_turret.coords.endY - temp_turret.coords.startY,
  3310. };
  3311. ctx.moveTo(temp_turret.coords.startX, temp_turret.coords.startY);
  3312. ctx.lineTo(temp_turret.coords.startX + (diff.x * len_factor), temp_turret.coords.startY + (diff.y * len_factor));
  3313. ctx_text('yellow', 'black', 5, 1.5 + "em Ubuntu", temp_tank.name, temp_turret.coords.startX + (diff.x * len_factor), temp_turret.coords.startY + (diff.y * len_factor));
  3314. ctx.stroke();
  3315. }
  3316. break
  3317. case "other":{
  3318. if(temp_turret.points.length < 4) return console.warn('less than 4 points');
  3319. let start = get_average([temp_turret.points[0], temp_turret.points[3]]);
  3320. let end = get_average([temp_turret.points[1], temp_turret.points[2]]);
  3321. let diff = [
  3322. end[0]-start[0],
  3323. end[1]-start[1]
  3324. ];
  3325. ctx.moveTo(...start);
  3326. ctx.lineTo(start[0]+(diff[0] * len_factor), start[1]+(diff[1] * len_factor));
  3327. ctx_text('yellow', 'black', 5, 1.5 + "em Ubuntu", temp_tank.name, start[0]+(diff[0] * len_factor), start[1]+(diff[1] * len_factor));
  3328. ctx.stroke();
  3329. }
  3330. break
  3331. }
  3332. }
  3333. }
  3334. }
  3335.  
  3336. //Farm Bot
  3337. let get_closest_update_notified = false;
  3338. let last_shape = [0, 0];
  3339. let resetting_farmbot_movement_complete = false;
  3340.  
  3341. let exposed_sm = {
  3342. points: null,
  3343. closest: null,
  3344. }
  3345.  
  3346. function handle_farmbot_aim(){
  3347. window.requestAnimationFrame(handle_farmbot_aim);
  3348. if(player.connected && player.inGame){
  3349. if(last_shape.length > 0 && modules.Addons.farm_bot.settings.toggle_farm_bot.active){
  3350. let temp = [dim_c.canvas_2_window(last_shape[0]), dim_c.canvas_2_window(last_shape[1])];
  3351. apply_force(...temp);
  3352. i_e('extern', 'onTouchMove', -1, ...temp);
  3353. }else{
  3354. disable_force();
  3355. }
  3356. }
  3357. }
  3358. window.requestAnimationFrame(handle_farmbot_aim);
  3359.  
  3360. function simple_move(x, y){
  3361. let center = {x: canvas.width/2, y: canvas.height/2};
  3362. let len = Math.min(canvas.width, canvas.height)/3;
  3363. let a = {
  3364. posx: center.x + len,
  3365. posy: center.y + len,
  3366. negx: center.x - len,
  3367. negy: center.y - len,
  3368. }
  3369. //diagonals
  3370. let dia = {
  3371. posx: center.x + (len/3)*2,
  3372. posy: center.y + (len/3)*2,
  3373. negx: center.x - (len/3)*2,
  3374. negy: center.y - (len/3)*2,
  3375. }
  3376. let points = {
  3377. LeftTop: {x: dia.negx, y: dia.negy},
  3378. CenterTop: {x: center.x, y: a.negy},
  3379. RightTop: {x: dia.posx, y: dia.negy},
  3380. RightCenter: {x: a.posx, y: center.y},
  3381. RightBottom: {x: dia.posx, y: dia.posy},
  3382. CenterBottom: {x: center.x, y: a.posy},
  3383. LeftBottom: {x: dia.negx, y: dia.posy},
  3384. LeftCenter: {x: a.negx, y: center.y},
  3385. }
  3386. let closest = {
  3387. key: null,
  3388. distance: canvas.width+canvas.height, //ensure to make it large at the start
  3389. }
  3390. let activate_keys = (keys) => {
  3391. let temp = ['KeyW', 'KeyA', 'KeyS', 'KeyD'];
  3392. for(let key of temp){
  3393. if(!document.hasFocus()){
  3394. inputs.moving_game[key] = false;
  3395. one_time_notification('your tab is running in the background!', notification_rgbs.warning, 5000);
  3396. }else{
  3397. notifications.length = 0;
  3398. }
  3399. //press keys from arguments
  3400. if(keys.includes(key) && !inputs.moving_game[key]){
  3401. extern.onKeyDown(diep_keys[key], fingerprint);
  3402. //unpress the rest (of temp) if it's being pressed
  3403. }else if(!keys.includes(key) && inputs.moving_game[key]){
  3404. extern.onKeyUp(diep_keys[key], fingerprint);
  3405. }
  3406. }
  3407. }
  3408. for(let point in points){
  3409. let d = calculate_distance(points[point].x, points[point].y, x, y);
  3410. if(closest.distance > d){
  3411. closest.key = point;
  3412. closest.distance = d;
  3413. }
  3414. }
  3415. exposed_sm.closest = closest;
  3416. exposed_sm.points = points;
  3417. let selected_keys = [];
  3418. switch(closest.key){
  3419. case 'LeftTop':
  3420. selected_keys[0] = 'KeyW';
  3421. selected_keys[1] = 'KeyA';
  3422. break
  3423. case 'CenterTop':
  3424. selected_keys[0] = 'KeyW';
  3425. break
  3426. case 'RightTop':
  3427. selected_keys[0] = 'KeyW';
  3428. selected_keys[1] = 'KeyD';
  3429. break
  3430. case 'RightCenter':
  3431. selected_keys[0] = 'KeyD';
  3432. break
  3433. case 'RightBottom':
  3434. selected_keys[0] = 'KeyS';
  3435. selected_keys[1] = 'KeyD';
  3436. break
  3437. case 'CenterBottom':
  3438. selected_keys[0] = 'KeyS';
  3439. break
  3440. case 'LeftBottom':
  3441. selected_keys[0] = 'KeyS';
  3442. selected_keys[1] = 'KeyA';
  3443. break
  3444. case 'LeftCenter':
  3445. selected_keys[0] = 'KeyA';
  3446. break
  3447. }
  3448. activate_keys(selected_keys);
  3449. }
  3450.  
  3451. function handle_farmbot_movement(){
  3452. window.requestAnimationFrame(handle_farmbot_movement);
  3453. if(modules.Addons.farm_bot.settings.toggle_farm_bot.active){
  3454. if(player.inGame && player.connected){
  3455. resetting_farmbot_movement_complete = false;
  3456. //moving to shape
  3457. if(modules.Addons.farm_bot.settings.move_to_shape.active){
  3458. if(modules.Mouse.Move_2_mouse.settings.Move_2_mouse.active){
  3459. one_time_notification('canceled, disable move to mouse for this to work', notification_rgbs.warning, 5000);
  3460. modules.Addons.farm_bot.settings.move_to_shape.active = false;
  3461. modules.Addons.farm_bot.settings.move_to_shape.update_toggle(modules.Addons.farm_bot.settings.move_to_shape.checkbox);
  3462. return
  3463. }
  3464. if(last_shape.length === 0){
  3465. reset_moving_game(['KeyW', 'KeyA', 'KeyS', 'KeyD']);
  3466. }else{
  3467. simple_move(...last_shape);
  3468. }
  3469. }else{
  3470. reset_moving_game(['KeyW', 'KeyA', 'KeyS', 'KeyD']);
  3471. }
  3472. }
  3473. }else{
  3474. if(!resetting_farmbot_movement_complete){
  3475. reset_moving_game(['KeyW', 'KeyA', 'KeyS', 'KeyD']);
  3476. resetting_farmbot_movement_complete = true;
  3477. }
  3478. }
  3479. }
  3480. window.requestAnimationFrame(handle_farmbot_movement);
  3481.  
  3482. function start_farming(shape_types){
  3483. //I commented this function previously, so I had to update it with the uncommented version
  3484. if(!req_bools[0]) ra_require('0.0.7', 0);
  3485. if(player.inGame && player.connected){
  3486. //argument checking to avoid errors
  3487. let allowed_types = ['crashers', 'pentagons', 'squares', 'triangles'];
  3488. if(!(shape_types instanceof Array)) return console.warn('expected Array at start_farming, quitting...');
  3489. let api_response = window.ripsaw_api.get_shapes();
  3490. let temp_arr = [];
  3491. for(let temp_arg of shape_types){
  3492. if(!allowed_types.includes(temp_arg)) return console.warn(temp_arg, ' was not found in allowed types at start_farming, quitting...');
  3493. if(api_response[temp_arg].length > 0){ //push only if array not empty
  3494. temp_arr.push(...api_response[temp_arg]);
  3495. }
  3496. }
  3497. if(temp_arr.length <= 0) {
  3498. //let the script know that there are no shapes
  3499. last_shape.length = 0;
  3500. return;
  3501. }
  3502. let lol;
  3503. //Ignore shapes outside base
  3504. if(player.team && modules.Addons.farm_bot.settings.ignore_outside.active){
  3505. if(!req_bools[2]) ra_require('0.0.9', 2);
  3506. let base = window.ripsaw_api.get_bases()[player.team];
  3507. let temp_arr2 = [];
  3508. let l = temp_arr.length;
  3509. for(let i = 0; i < l; i++){
  3510. let temp_point = temp_arr[i].get('center');
  3511. let outsideX = (temp_point[0] > base.top_right[0]) || (temp_point[0] < base.top_left[0]);
  3512. let outsideY = (temp_point[1] > base.bottom_left[1]) || (temp_point[1] < base.top_left[1]);
  3513. if(!outsideX && !outsideY) temp_arr2.push(temp_point);
  3514. }
  3515. lol = window.ripsaw_api.get_closest(temp_arr2);
  3516. if(temp_arr2.length === 0) return;
  3517. }else{
  3518. lol = window.ripsaw_api.get_closest(temp_arr);
  3519. }
  3520. //
  3521. last_shape[0] = lol[0];
  3522. last_shape[1] = lol[1];
  3523. //drawing
  3524. let you = window.ripsaw_api.get_your_body().front_arc;
  3525. if(modules.Addons.farm_bot.settings.toggle_lines.active && you && you.x && you.y){
  3526. ctx.beginPath();
  3527. ctx.strokeStyle = "purple";
  3528. ctx.moveTo(you.x, you.y);
  3529. ctx.lineTo(...last_shape);
  3530. ctx.stroke();
  3531. }
  3532. }
  3533. }
  3534.  
  3535. //Trails
  3536. let trail = {
  3537. now: performance.now(),
  3538. list: new LinkedList(),
  3539. }
  3540.  
  3541. function update_trail(){
  3542. if(player.inGame){
  3543. let your_pos = get_your_world_pos();
  3544. if(!your_pos) return;
  3545. trail.list.addLast(your_pos);
  3546. }else{
  3547. trail.list = new LinkedList();
  3548. }
  3549. }
  3550.  
  3551. function draw_trail(){
  3552. let FOV = ripsaw_api.get_FOV();
  3553. let scalingFactor = (modules.Functional.Zoom.value / 100) * windowScaling()*FOV;
  3554. let du_2_point = function(point) {
  3555. return point*scalingFactor;
  3556. };
  3557. let center = {
  3558. x: canvas.width/2,
  3559. y: canvas.height/2,
  3560. };
  3561. let your_pos = trail.list.getLast();
  3562. let toScreen = function(target) {
  3563. return {
  3564. x: center.x+du_2_point(target.x-your_pos.value.x),
  3565. y: center.y+du_2_point(target.y-your_pos.value.y),
  3566. }
  3567. };
  3568. let current_pos = your_pos;
  3569. ctx.beginPath();
  3570. ctx.moveTo(toScreen(current_pos.value).x, toScreen(current_pos.value).y);
  3571. console.log('start');
  3572. while(current_pos.prev){
  3573. console.log(your_pos, FOV, windowScaling(), scalingFactor);
  3574. current_pos = current_pos.prev;
  3575. ctx.lineTo(toScreen(current_pos.value).x, toScreen(current_pos.value).y);
  3576. }
  3577. console.log('end');
  3578. ctx.stroke();
  3579. }
  3580.  
  3581. //canvas gui (try to keep this in the end
  3582. setTimeout(() => {
  3583. let gui = () => {
  3584. if (player.inGame) {
  3585. //DEBUG start
  3586. if(deep_debug_properties.canvas){
  3587. draw_canvas_debug();
  3588. }
  3589. //DEBUG end
  3590. if(modules.Functional.Tank_upgrades.settings.visualise.active){
  3591. visualise_tank_upgrades();
  3592. }
  3593. if (modules.Visual.Key_inputs_visualiser.active) {
  3594. visualise_keys();
  3595. }
  3596. if (modules.Visual.destroyer_cooldown.settings.destroyer_cooldown.active){
  3597. draw_destroyer_cooldown();
  3598. }
  3599. if(modules.Mouse.Move_2_mouse.settings.Move_2_mouse.active && modules.Mouse.Move_2_mouse.settings.toggle_debug.active ){
  3600. //move_to_mouse
  3601. let center = { x: canvas.width / 2, y: canvas.height / 2 };
  3602. let target = { x: inputs.mouse.real.x, y: inputs.mouse.real.y };
  3603. let full_distance = calculate_distance(center.x, center.y, target.x, target.y);
  3604. let partial_distance = full_distance/approximation_factor;
  3605. let step = { x: (target.x - center.x) / partial_distance, y: (target.y - center.y) / partial_distance };
  3606. //main line
  3607. ctx.beginPath();
  3608. ctx.strokeStyle = "black";
  3609. ctx.moveTo(center.x, center.y);
  3610. ctx.lineTo(target.x, target.y);
  3611. ctx.stroke();
  3612. //other lines
  3613. ctx.beginPath();
  3614. ctx.strokeStyle = "yellow";
  3615. ctx.moveTo(center.x, center.y);
  3616. let temp = {
  3617. x: center.x,
  3618. y: center.y,
  3619. }
  3620. let l = Math.floor(partial_distance);
  3621. for(let i = 0; i < l; i++){
  3622. temp.x += step.x * (distance_time_factor/10);
  3623. ctx.lineTo(temp.x, temp.y);
  3624. temp.y += step.y * (distance_time_factor/10);
  3625. ctx.lineTo(temp.x, temp.y);
  3626. }
  3627. ctx.stroke();
  3628. }
  3629. if(modules.Addons.aim_lines.settings.toggle_aim_lines.active){
  3630. if(api_missing) {
  3631. notify_about_missing();
  3632. return;
  3633. }
  3634. draw_aim_lines(modules.Addons.aim_lines.settings.adjust_length.selected);
  3635. }
  3636. if(modules.Addons.farm_bot.settings.toggle_farm_bot.active){
  3637. if(api_missing) {
  3638. notify_about_missing();
  3639. return;
  3640. }
  3641. if(modules.Addons.farm_bot.settings.toggle_debug.active){
  3642. //visualise the script logic
  3643. for(let point in exposed_sm.points){
  3644. //white line from closest direction to shape
  3645. if(point === exposed_sm.closest.key){
  3646. ctx.beginPath();
  3647. ctx.strokeStyle = "white";
  3648. ctx.moveTo(last_shape[0], last_shape[1]);
  3649. ctx.lineTo(exposed_sm.points[point].x, exposed_sm.points[point].y);
  3650. ctx.stroke();
  3651. }
  3652. //all directions black, closest red
  3653. ctx.beginPath();
  3654. ctx.strokeStyle = (point === exposed_sm.closest.key && last_shape.length > 0) ? "red" : "black";
  3655. ctx.moveTo(canvas.width/2, canvas.height/2);
  3656. ctx.lineTo(exposed_sm.points[point].x, exposed_sm.points[point].y);
  3657. ctx.stroke();
  3658. }
  3659. }
  3660. let temp_shape_array = [];
  3661. if(!modules.Addons.farm_bot.settings.toggle_squares.active) temp_shape_array.push('squares');
  3662. if(!modules.Addons.farm_bot.settings.toggle_crashers.active) temp_shape_array.push('crashers');
  3663. if(!modules.Addons.farm_bot.settings.toggle_pentagons.active) temp_shape_array.push('pentagons');
  3664. if(!modules.Addons.farm_bot.settings.toggle_triangles.active) temp_shape_array.push('triangles');
  3665. if(temp_shape_array.length === 0) one_time_notification("You're currently ignoring all shapes, disable at least one of them or the bot won't shoot", notification_rgbs.warning, 5000);
  3666. start_farming(temp_shape_array);
  3667. }
  3668. if(modules.Addons.world_coords.settings.toggle_world_coords.active){
  3669. let world = get_your_world_pos();
  3670. if(world === -1) return;
  3671. let minimap = window.ripsaw_api.get_minimap().corners;
  3672. ctx.beginPath();
  3673. ctx_text('gray', 'black', 3, 1 + "em Ubuntu", `x: ${world.x} y: ${world.y}`, minimap.top_left[0], minimap.top_left[1]-((canvas.height-minimap.top_left[1])*0.3));
  3674. }
  3675. if(modules.Addons.enemy_tracers.active){
  3676. draw_enemy_tracers();
  3677. }
  3678. if(modules.Addons.trails.settings.toggle_trails.active){
  3679. if(api_missing) {
  3680. notify_about_missing();
  3681. return;
  3682. }
  3683. if(req_bools[3]) ra_require('0.0.8', 3);
  3684. if(performance.now() - trail.now >= modules.Addons.trails.settings.update_interval.selected){
  3685. update_trail();
  3686. trail.now = performance.now();
  3687. }
  3688. if(trail.list.size() > 1){
  3689. draw_trail();
  3690. }
  3691. }else{
  3692. trail.list = new LinkedList();
  3693. }
  3694. }
  3695. window.requestAnimationFrame(gui); // Start animation loop
  3696. };
  3697. gui();
  3698. }, 500); // Delay before starting the rendering
  3699.  
  3700. // START ZOOM SCROLL FUNCTIONS V3
  3701.  
  3702. const zoomScrollStep = 5;
  3703. const minZoomValue = 10;
  3704. const maxZoomValue = 500;
  3705.  
  3706. let zoomIndicatorElement = null;
  3707. let zoomIndicatorTimeout = null;
  3708.  
  3709. function ensureZoomIndicatorExists() {
  3710. if (!zoomIndicatorElement) {
  3711. zoomIndicatorElement = document.createElement('div');
  3712. zoomIndicatorElement.id = 'zoom-scroll-indicator-v3';
  3713. Object.assign(zoomIndicatorElement.style, {
  3714. position: 'fixed',
  3715. top: '15px',
  3716. left: '50%',
  3717. transform: 'translateX(-50%)',
  3718. backgroundColor: 'rgba(38, 38, 38, 0.9)',
  3719. color: 'white',
  3720. padding: '6px 15px',
  3721. borderRadius: '0px',
  3722. borderBottom: '3px solid lime',
  3723. fontFamily: '"Ubuntu", Calibri, Arial, sans-serif',
  3724. fontSize: '18px',
  3725. fontWeight: 'bold',
  3726. zIndex: '1001',
  3727. opacity: '0',
  3728. pointerEvents: 'none',
  3729. transition: 'opacity 2s ease-out, top 0.2s ease-out',
  3730. textAlign: 'center',
  3731. minWidth: '80px'
  3732. });
  3733. document.body.appendChild(zoomIndicatorElement);
  3734. }
  3735. }
  3736.  
  3737. function showZoomIndicator(zoomValue) {
  3738. ensureZoomIndicatorExists();
  3739.  
  3740. zoomIndicatorElement.style.top = '10px';
  3741. zoomIndicatorElement.textContent = `🔍 ${zoomValue}%`;
  3742. zoomIndicatorElement.style.opacity = '1';
  3743.  
  3744. if (zoomIndicatorTimeout) {
  3745. clearTimeout(zoomIndicatorTimeout);
  3746. }
  3747.  
  3748. setTimeout(() => {
  3749. zoomIndicatorElement.style.top = '15px';
  3750. }, 50);
  3751.  
  3752.  
  3753. zoomIndicatorTimeout = setTimeout(() => {
  3754. zoomIndicatorElement.style.opacity = '0';
  3755. zoomIndicatorElement.style.top = '10px';
  3756. zoomIndicatorTimeout = null;
  3757. }, 100);
  3758. }
  3759.  
  3760.  
  3761. function handleZoomScroll(e) {
  3762. if (player.inGame && modules.Functional && modules.Functional.Zoom) {
  3763. e.preventDefault();
  3764. let currentZoom = parseFloat(modules.Functional.Zoom.value);
  3765. let newZoom = currentZoom;
  3766. if (e.deltaY < 0) {
  3767. newZoom += zoomScrollStep;
  3768. } else if (e.deltaY > 0) {
  3769. newZoom -= zoomScrollStep;
  3770. }
  3771. newZoom = Math.max(minZoomValue, Math.min(maxZoomValue, newZoom));
  3772. newZoom = Math.round(newZoom);
  3773. if (newZoom !== currentZoom) {
  3774. modules.Functional.Zoom.value = newZoom;
  3775. showZoomIndicator(newZoom);
  3776. try {
  3777. const sliderElement = modules.Functional.Zoom.elements[1];
  3778. if (sliderElement && sliderElement.tagName === 'INPUT' && sliderElement.type === 'range') {
  3779. sliderElement.value = newZoom;
  3780. }
  3781. const titleElement = modules.Functional.Zoom.title.el;
  3782. if (titleElement) {
  3783. titleElement.innerHTML = `${modules.Functional.Zoom.name}: ${newZoom} %`;
  3784. }
  3785. } catch (error) {
  3786. console.warn("[Diep.io+ Zoom Scroll] Could not update GUI slider/title visually:", error);
  3787. }
  3788. }
  3789. }
  3790. }
  3791. document.body.addEventListener('wheel', handleZoomScroll, { passive: false });
  3792.  
  3793. // END ZOOM SCROLL FUNCTIONS V3
  3794.  
  3795. //INTERVALS HANDLE
  3796. let active_static_intervals = new WeakSet();
  3797. let static_intervals = {
  3798. detect_refresh: {
  3799. callbackFunc: detect_refresh,
  3800. wait: 100,
  3801. id: null,
  3802. },
  3803. check_gamemode: {
  3804. callbackFunc: check_gamemode,
  3805. wait: 250,
  3806. id: null,
  3807. },
  3808. check_final_score: {
  3809. callbackFunc: check_final_score,
  3810. wait: 100,
  3811. id: null,
  3812. },
  3813. bot_tab_active_check: {
  3814. callbackFunc: bot_tab_active_check,
  3815. wait: 1000,
  3816. id: null,
  3817. },
  3818. update_diep_console: {
  3819. callbackFunc: update_diep_console,
  3820. wait: 100,
  3821. id: null,
  3822. },
  3823. sandbox_lvl_up: {
  3824. callbackFunc: sandbox_lvl_up,
  3825. wait: 500,
  3826. id: null,
  3827. },
  3828. respawn: {
  3829. callbackFunc: respawn,
  3830. wait: 1000,
  3831. id: null,
  3832. },
  3833. AntiAfkTimeout: {
  3834. callbackFunc: AntiAfkTimeout,
  3835. wait: 1000,
  3836. id: null,
  3837. },
  3838. HandleZoom: {
  3839. callbackFunc: HandleZoom,
  3840. wait: 100,
  3841. id: null,
  3842. },
  3843. };
  3844.  
  3845. function start_static_intervals(){
  3846. for(let i in static_intervals){
  3847. let temp = static_intervals[i];
  3848. if(!active_static_intervals.has(temp) && !temp.id){
  3849. temp.id = setInterval(temp.callbackFunc, temp.wait);
  3850. active_static_intervals.add(temp);
  3851. }
  3852. }
  3853. }
  3854.  
  3855. function start_static_interval(key){
  3856. let temp = static_intervals[key];
  3857. if(!temp) return console.warn('undefined interval');
  3858. if(!active_static_intervals.has(temp) && !temp.id){
  3859. temp.id = setInterval(temp.callbackFunc, temp.wait);
  3860. active_static_intervals.add(temp);
  3861. }
  3862. }
  3863.  
  3864. function clear_static_interval(key){
  3865. let temp = static_intervals[key];
  3866. if(!temp) return console.warn('undefined interval');
  3867. if(active_static_intervals.has(temp) && temp.id){
  3868. clearInterval(temp.id);
  3869. temp.id = null;
  3870. active_static_intervals.delete(temp);
  3871. }else{
  3872. return console.warn('interval was not active');
  3873. }
  3874. }
  3875.  
  3876.  
  3877. //init
  3878.  
  3879. function update_information() {
  3880. window.requestAnimationFrame(update_information);
  3881. let teams = ["blue", "red", "purple", "green"];
  3882. player.connected = !!window.lobby_ip;
  3883. player.connected? player.inGame = !!extern.doesHaveTank() : null;
  3884. player.name = document.getElementById("spawn-nickname").value;
  3885. player.team = teams[parseInt(_c.party_link.split('x')[1])];
  3886. player.gamemode = _c.active_gamemode;
  3887. player.ui_scale = parseFloat(localStorage.getItem("d:ui_scale"));
  3888. }
  3889. window.requestAnimationFrame(update_information);
  3890.  
  3891. function waitForConnection() {
  3892. if (player.connected) {
  3893. define_onTouch();
  3894. start_input_proxies();
  3895. start_zoom_proxy();
  3896. start_keyDown_Proxy();
  3897. start_keyUp_Proxy();
  3898. start_static_intervals();
  3899. } else {
  3900. setTimeout(waitForConnection, 100);
  3901. }
  3902. }
  3903. waitForConnection();