Diep.io+ (added Enemy Tracer)

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

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