Diep.io+ (BestScore NaN removed & Farmbot update)

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