Diep.io+ (added move to mouse)

Quick Tank Upgrades, Highscore saver, Advanced Auto Respawn, Anti Aim, Zoom hack, Anti AFK Timeout, Sandbox Auto K, Sandbox Arena Increase

当前为 2025-03-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Diep.io+ (added move to mouse)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2.1.8
  5. // @description Quick Tank Upgrades, Highscore saver, Advanced Auto Respawn, Anti Aim, Zoom hack, Anti AFK Timeout, Sandbox Auto K, Sandbox Arena Increase
  6. // @author r!PsAw
  7. // @match https://diep.io/*
  8. // @icon https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQFMDAvSZe2hsFwAIeAPcDSNx8X2lUMp-rLPA&s
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. //inner script settings
  14. let deep_debug_properties = {
  15. active: false, //display information in console
  16. canvas: false, //display information on screen
  17. }
  18.  
  19. function deep_debug(...args) {
  20. if (deep_debug_properties.active) {
  21. console.log(...args);
  22. }
  23. }
  24.  
  25. //Information for script
  26. let _c = window.__common__;
  27.  
  28. const diep_keys = [ //document has to be focused to execute these, also C and E don't work right now
  29. "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",
  30. "ArrowUp", "ArrowLeft", "ArrowDown", "ArrowRight", "Tab", "Enter", "NumpadEnter", "ShiftLeft", "ShiftRight", "Space", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9",
  31. "Digit0", "Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "F2", "End", "Home", "Semicolon", "Comma", "NumpadComma", "Period", "Backslash"
  32. ].reduce((n, e, c) => {
  33. n[e] = c + 1;
  34. return n;
  35. }, {});
  36.  
  37. let player = {
  38. connected: false,
  39. inGame: false,
  40. name: '',
  41. team: null,
  42. gamemode: null,
  43. ui_scale: 1,
  44. dpr: 1,
  45. base_value: 1,
  46. };
  47.  
  48. let inputs = {
  49. mouse: {
  50. real: {
  51. x: 0,
  52. y: 0,
  53. },
  54. game: {
  55. x: 0,
  56. y: 0,
  57. },
  58. force: {
  59. x: 0,
  60. y: 0,
  61. },
  62. isForced: false, //input mouse operations flag (overwrites your inputs to forced one's)
  63. isFrozen: false, //Mouse Freeze flag
  64. isShooting: false, //Anti Aim flag
  65. isPaused: false, //Anti Aim flag (different from isFrozen & isForced for better readability)
  66. original: {
  67. onTouchMove: null,
  68. onTouchStart: null,
  69. onTouchEnd: null,
  70. }
  71. },
  72. keys_pressed: [],
  73. };
  74.  
  75. function windowScaling() {
  76. const a = canvas.height / 1080;
  77. const b = canvas.width / 1920;
  78. return b < a ? a : b;
  79. }
  80.  
  81. //basic function to construct links
  82. function link(baseUrl, lobby, gamemode, team) {
  83. let str = "";
  84. str += baseUrl + "?s=" + lobby + "&g=" + gamemode + "&l=" + team;
  85. return str;
  86. }
  87.  
  88. function get_baseUrl() {
  89. return location.origin + location.pathname;
  90. }
  91.  
  92. function get_your_lobby() {
  93. return window.lobby_ip;
  94. }
  95.  
  96. function get_gamemode() {
  97. //return window.__common__.active_gamemode;
  98. return window.lobby_gamemode;
  99. }
  100.  
  101. function get_team() {
  102. return window.__common__.party_link;
  103. }
  104.  
  105. //dimensions
  106.  
  107. class dimensions_converter {
  108. constructor() {
  109. this.scalingFactor = null; //undetectable without bypass
  110. this.fieldFactor = null; //undetectable without bypass
  111. }
  112. canvas_2_window(a) {
  113. let b = a / (canvas.width / window.innerWidth);
  114. return b;
  115. }
  116.  
  117. window_2_canvas(a) {
  118. let b = a * (canvas.width / window.innerWidth);
  119. return b;
  120. }
  121.  
  122. windowScaling_2_window(a) {
  123. let b = (this.windowScaling_2_canvas(a)) / (canvas.width / window.innerWidth);
  124. return b;
  125. }
  126.  
  127. windowScaling_2_canvas(a) {
  128. let b = a * windowScaling();
  129. deep_debug('windowScaling_2_canvas called! a, b', a, b);
  130. return b;
  131. }
  132. /* DISABLED FOR NOW
  133. diepUnits_2_canvas(a) {
  134. let b = a / scalingFactor;
  135. return b;
  136. }
  137.  
  138. diepUnits_2_window(a) {
  139. let b = (this.diepUnits_2_canvas(a)) / (canvas.width / window.innerWidth);
  140. return b;
  141. }
  142.  
  143. window_2_diepUnits(a) {
  144. let b = (this.canvas_2_diepUnits(a)) * (canvas.width / window.innerWidth);
  145. return b;
  146. }
  147.  
  148. canvas_2_diepUnits(a) {
  149. let b = a * this.scalingFactor;
  150. return b;
  151. }
  152. */
  153.  
  154. window_2_windowScaling(a) {
  155. let b = (this.canvas_2_windowScaling(a)) * (canvas.width / window.innerWidth) * player.ui_scale;
  156. return b;
  157. }
  158.  
  159. canvas_2_windowScaling(a) {
  160. let b = a * windowScaling();
  161. return b;
  162. }
  163. /* DISABLED FOR NOW
  164. diepUnits_2_windowScaling(a) {
  165. let b = (this.diepUnits_2_canvas(a)) * this.fieldFactor;
  166. return b;
  167. }
  168.  
  169. windowScaling_2_diepUntis(a) {
  170. let b = (a / this.fieldFactor) * this.scalingFactor;
  171. return b;
  172. }
  173. */
  174. }
  175.  
  176. let dim_c = new dimensions_converter();
  177.  
  178. function i_e(type, key, ...args) {
  179. switch (type) {
  180. case "input":
  181. input[key](...args);
  182. break
  183. case "extern":
  184. extern[key](...args);
  185. break
  186. }
  187. }
  188.  
  189. function apply_force(x, y) {
  190. inputs.mouse.force = {
  191. x: x,
  192. y: y,
  193. }
  194. inputs.mouse.isForced = true;
  195. }
  196.  
  197. function disable_force() {
  198. inputs.mouse.isForced = false;
  199. }
  200.  
  201. const touchMethods = ['onTouchMove', 'onTouchStart', 'onTouchEnd'];
  202. let canvas = document.getElementById("canvas");
  203. let ctx = canvas.getContext('2d');
  204.  
  205. function define_onTouch() {
  206. touchMethods.forEach(function(method) {
  207. inputs.mouse.original[method] = input[method];
  208. deep_debug('defined input.', method);
  209. });
  210. }
  211.  
  212. function clear_onTouch() {
  213. touchMethods.forEach(function(method) {
  214. input[method] = () => {};
  215. });
  216. }
  217.  
  218. function redefine_onTouch() {
  219. touchMethods.forEach(function(method) {
  220. input[method] = inputs.mouse.original[method];
  221. });
  222. }
  223.  
  224. function start_input_proxies(_filter = false, _single = false, _method = null) {
  225. ((_filter || _single) && !_method) ? console.warn("missing _method at start_input_proxies"): null;
  226. let temp_methods = touchMethods;
  227. if (_filter) {
  228. temp_methods.filter((item) => item != _method);
  229. } else if (_single) {
  230. temp_methods = [_method];
  231. }
  232. temp_methods.forEach(function(method) {
  233. input[method] = new Proxy(input[method], {
  234. apply: function(definition, input_obj, args) {
  235. let x, y, type, new_args;
  236. if (inputs.mouse.isForced) {
  237. x = inputs.mouse.force.x;
  238. y = inputs.mouse.force.y;
  239. } else {
  240. x = args[1];
  241. y = args[2];
  242. }
  243. type = args[0];
  244. new_args = [type, x / player.dpr, y / player.dpr];
  245. inputs.mouse.game = {
  246. x: new_args[1],
  247. y: new_args[2],
  248. }
  249. return Reflect.apply(definition, input_obj, new_args);
  250. }
  251. });
  252. });
  253. }
  254.  
  255. function update_information() {
  256. window.requestAnimationFrame(update_information);
  257. let teams = ["blue", "red", "purple", "green"];
  258. player.connected = !!window.lobby_ip;
  259. player.connected? player.inGame = !!extern.doesHaveTank() : null;
  260. player.name = document.querySelector("#spawn-nickname").value;
  261. player.team = teams[parseInt(_c.party_link.split('x')[1])];
  262. player.gamemode = _c.active_gamemode;
  263. player.ui_scale = parseFloat(localStorage.getItem("d:ui_scale"))
  264. }
  265. window.requestAnimationFrame(update_information);
  266.  
  267. function waitForConnection() {
  268. if (player.connected) {
  269. define_onTouch();
  270. start_input_proxies();
  271. start_zoom_proxy();
  272. } else {
  273. setTimeout(waitForConnection, 100);
  274. }
  275. }
  276. waitForConnection();
  277.  
  278. //GUI
  279. function n2id(string) {
  280. return string.toLowerCase().replace(/ /g, "-");
  281. }
  282.  
  283. class El {
  284. constructor(
  285. name,
  286. type,
  287. el_color,
  288. width,
  289. height,
  290. opacity = "1",
  291. zindex = "100"
  292. ) {
  293. this.el = document.createElement(type);
  294. this.el.style.backgroundColor = el_color;
  295. this.el.style.width = width;
  296. this.el.style.height = height;
  297. this.el.style.opacity = opacity;
  298. this.el.style.zIndex = zindex;
  299. this.el.id = n2id(name);
  300. this.display = "block"; // store default display
  301. }
  302.  
  303. setBorder(type, width, color, radius = 0) {
  304. const borderStyle = `${width} solid ${color}`;
  305. switch (type) {
  306. case "normal":
  307. this.el.style.border = borderStyle;
  308. break;
  309. case "top":
  310. this.el.style.borderTop = borderStyle;
  311. break;
  312. case "left":
  313. this.el.style.borderLeft = borderStyle;
  314. break;
  315. case "right":
  316. this.el.style.borderRight = borderStyle;
  317. break;
  318. case "bottom":
  319. this.el.style.borderBottom = borderStyle;
  320. break;
  321. }
  322. this.el.style.borderRadius = radius;
  323. }
  324.  
  325. setPosition(
  326. position,
  327. display,
  328. top,
  329. left,
  330. flexDirection,
  331. justifyContent,
  332. translate
  333. ) {
  334. this.el.style.position = position;
  335. this.el.style.display = display;
  336. if (top) this.el.style.top = top;
  337. if (left) this.el.style.left = left;
  338. // Flex properties
  339. if (flexDirection) this.el.style.flexDirection = flexDirection;
  340. if (justifyContent) this.el.style.justifyContent = justifyContent;
  341. if (translate) this.el.style.transform = `translate(${translate})`;
  342. this.display = display;
  343. }
  344.  
  345. margin(top, left, right, bottom) {
  346. this.el.style.margin = `${top} ${right} ${bottom} ${left}`;
  347. }
  348.  
  349. setText(
  350. text,
  351. txtColor,
  352. font,
  353. weight,
  354. fontSize,
  355. stroke,
  356. alignContent,
  357. textAlign
  358. ) {
  359. this.el.innerHTML = text;
  360. this.el.style.color = txtColor;
  361. this.el.style.fontFamily = font;
  362. this.el.style.fontWeight = weight;
  363. this.el.style.fontSize = fontSize;
  364. this.el.style.textShadow = stroke;
  365. this.el.style.alignContent = alignContent;
  366. this.el.style.textAlign = textAlign;
  367. }
  368.  
  369. add(parent) {
  370. parent.appendChild(this.el);
  371. }
  372.  
  373. remove(parent) {
  374. parent.removeChild(this.el);
  375. }
  376.  
  377. toggle(showOrHide) {
  378. this.el.style.display = showOrHide === "hide" ? "none" : this.display;
  379. }
  380. }
  381.  
  382. let mainCont, header, subContGray, subContBlack, modCont, settCont;
  383.  
  384. class Setting {
  385. constructor(name, type, options) {
  386. this.name = name;
  387. this.options = options;
  388. this.elements = [];
  389. this.desc = new El(
  390. name + " Setting",
  391. "div",
  392. "transparent",
  393. "170px",
  394. "50px"
  395. );
  396. this.desc.setPosition("relative", "block");
  397. this.desc.setText(
  398. name,
  399. "white",
  400. "Calibri",
  401. "bold",
  402. "15px",
  403. "2px",
  404. "center",
  405. "center"
  406. );
  407. this.elements.push(this.desc.el);
  408.  
  409. switch (type) {
  410. case "title":
  411. this.desc.el.style.backgroundColor = "rgb(50, 50, 50)";
  412. this.desc.setText(
  413. name,
  414. "lightgray",
  415. "Calibri",
  416. "bold",
  417. "20px",
  418. "2px",
  419. "center",
  420. "center"
  421. );
  422. this.desc.setBorder("normal", "2px", "gray", "5px");
  423. break;
  424. case "select": {
  425. if (!this.options) return console.warn("Missing Options!");
  426. let index = 0;
  427. this.selected = options[index];
  428. //temp cont
  429. let temp_container = new El(
  430. name + " temp Container",
  431. "div",
  432. "transparent"
  433. );
  434. temp_container.el.style.display = "flex";
  435. temp_container.el.style.alignItems = "center";
  436. temp_container.el.style.justifyContent = "center";
  437. temp_container.el.style.gap = "10px";
  438.  
  439. //displ
  440. let displ = new El(
  441. name + " Setting Display",
  442. "div",
  443. "lightgray",
  444. "125px",
  445. "25px"
  446. );
  447. displ.setText(
  448. this.selected,
  449. "black",
  450. "Calibri",
  451. "bold",
  452. "15px",
  453. "2px",
  454. "center",
  455. "center"
  456. );
  457.  
  458. //left Arrow
  459. let l_arrow = new El(
  460. name + " left Arrow",
  461. "div",
  462. "transparent",
  463. "0px",
  464. "0px"
  465. );
  466. l_arrow.setBorder("bottom", "8px", "transparent");
  467. l_arrow.setBorder("left", "0px", "transparent");
  468. l_arrow.setBorder("right", "16px", "blue");
  469. l_arrow.setBorder("top", "8px", "transparent");
  470.  
  471. l_arrow.el.addEventListener("mouseover", () => {
  472. l_arrow.el.style.cursor = "pointer";
  473. l_arrow.setBorder("right", "16px", "darkblue");
  474. });
  475.  
  476. l_arrow.el.addEventListener("mouseout", () => {
  477. l_arrow.el.style.cursor = "normal";
  478. l_arrow.setBorder("right", "16px", "blue");
  479. });
  480.  
  481. l_arrow.el.addEventListener("mousedown", (e) => {
  482. if (e.button != 0) return;
  483. let limit = options.length - 1;
  484. if (index - 1 < 0) {
  485. index = limit;
  486. } else {
  487. index--;
  488. }
  489. this.selected = options[index];
  490. displ.el.innerHTML = this.selected;
  491. });
  492.  
  493. //right Arrow
  494. let r_arrow = new El(
  495. name + " right Arrow",
  496. "div",
  497. "transparent",
  498. "0px",
  499. "0px"
  500. );
  501. r_arrow.setBorder("bottom", "8px", "transparent");
  502. r_arrow.setBorder("left", "16px", "blue");
  503. r_arrow.setBorder("right", "0px", "transparent");
  504. r_arrow.setBorder("top", "8px", "transparent");
  505.  
  506. r_arrow.el.addEventListener("mouseover", () => {
  507. r_arrow.el.style.cursor = "pointer";
  508. r_arrow.setBorder("left", "16px", "darkblue");
  509. });
  510.  
  511. r_arrow.el.addEventListener("mouseout", () => {
  512. r_arrow.el.style.cursor = "normal";
  513. r_arrow.setBorder("left", "16px", "blue");
  514. });
  515.  
  516. r_arrow.el.addEventListener("mousedown", (e) => {
  517. if (e.button != 0) return;
  518. let limit = options.length - 1;
  519. if (index + 1 > limit) {
  520. index = 0;
  521. } else {
  522. index++;
  523. }
  524. this.selected = options[index];
  525. displ.el.innerHTML = this.selected;
  526. });
  527.  
  528. //connect together
  529. temp_container.el.appendChild(l_arrow.el);
  530. temp_container.el.appendChild(displ.el);
  531. temp_container.el.appendChild(r_arrow.el);
  532.  
  533. //remember them
  534. this.elements.push(temp_container.el);
  535. break;
  536. }
  537. case "toggle": {
  538. this.active = false;
  539. this.desc.el.style.display = "flex";
  540. this.desc.el.style.alignItems = "center";
  541. this.desc.el.style.justifyContent = "space-between";
  542. let empty_checkbox = new El(
  543. this.name + " Setting checkbox",
  544. "div",
  545. "lightgray",
  546. "20px",
  547. "20px"
  548. );
  549. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  550. //event listeners
  551. empty_checkbox.el.addEventListener("mousedown", (e) => {
  552. if (e.button != 0) return;
  553. this.active = !this.active;
  554. if (this.active) {
  555. empty_checkbox.el.innerHTML = "✔";
  556. empty_checkbox.el.style.backgroundColor = "green";
  557. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  558. } else {
  559. empty_checkbox.el.innerHTML = "";
  560. empty_checkbox.el.style.backgroundColor = "lightgray";
  561. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  562. }
  563. });
  564. empty_checkbox.el.addEventListener("mouseover", () => {
  565. empty_checkbox.el.style.backgroundColor = this.active
  566. ? "darkgreen"
  567. : "darkgray";
  568. empty_checkbox.el.style.cursor = "pointer";
  569. });
  570. empty_checkbox.el.addEventListener("mouseout", () => {
  571. empty_checkbox.el.style.backgroundColor = this.active
  572. ? "green"
  573. : "lightgray";
  574. });
  575. this.desc.el.appendChild(empty_checkbox.el);
  576. break;
  577. }
  578. }
  579. }
  580. load() {
  581. this.elements.forEach((element) => settCont.el.appendChild(element));
  582. }
  583.  
  584. unload() {
  585. this.elements.forEach((element) => {
  586. if (settCont.el.contains(element)) {
  587. settCont.el.removeChild(element);
  588. }
  589. });
  590. }
  591. }
  592.  
  593. class Module {
  594. constructor(name, type, settings, callback) {
  595. this.name = name;
  596. this.type = type;
  597. this.callbackFunc = callback;
  598. this.settings = settings;
  599. this.title = new El(name, "div", "transparent", "100%", "50px");
  600. this.title.setPosition("relative", "block");
  601. this.title.setText(
  602. name,
  603. "white",
  604. "Calibri",
  605. "bold",
  606. "15px",
  607. "2px",
  608. "center",
  609. "center"
  610. );
  611. this.elements = [];
  612. this.elements.push(this.title.el);
  613. switch (type) {
  614. case "toggle": {
  615. this.active = false;
  616. this.title.el.style.display = "flex";
  617. this.title.el.style.alignItems = "center";
  618. this.title.el.style.justifyContent = "space-between";
  619. let empty_checkbox = new El(
  620. this.name + " checkbox",
  621. "div",
  622. "lightgray",
  623. "20px",
  624. "20px"
  625. );
  626. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  627. //event listeners
  628. empty_checkbox.el.addEventListener("mousedown", (e) => {
  629. if (e.button != 0) return;
  630. this.active = !this.active;
  631. if (this.active) {
  632. empty_checkbox.el.innerHTML = "✔";
  633. empty_checkbox.el.style.backgroundColor = "green";
  634. empty_checkbox.setBorder("normal", "2px", "lime", "4px");
  635. } else {
  636. empty_checkbox.el.innerHTML = "";
  637. empty_checkbox.el.style.backgroundColor = "lightgray";
  638. empty_checkbox.setBorder("normal", "2px", "gray", "4px");
  639. }
  640. });
  641. empty_checkbox.el.addEventListener("mouseover", () => {
  642. empty_checkbox.el.style.backgroundColor = this.active
  643. ? "darkgreen"
  644. : "darkgray";
  645. empty_checkbox.el.style.cursor = "pointer";
  646. });
  647. empty_checkbox.el.addEventListener("mouseout", () => {
  648. empty_checkbox.el.style.backgroundColor = this.active
  649. ? "green"
  650. : "lightgray";
  651. });
  652. this.title.el.appendChild(empty_checkbox.el);
  653. break;
  654. }
  655. case "slider": {
  656. this.value = 100;
  657. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  658. const slider = document.createElement("input");
  659. slider.type = "range";
  660. slider.value = this.value;
  661. slider.min = 0;
  662. slider.max = 100;
  663.  
  664. slider.addEventListener("input", () => {
  665. this.value = slider.value;
  666. this.title.el.innerHTML = `${this.name}: ${this.value} %`;
  667. });
  668.  
  669. this.elements.push(slider);
  670. break;
  671. }
  672. case "button":
  673. this.title.el.style.width = "100%";
  674. this.title.el.style.boxSizing = "border-box";
  675. this.title.el.style.whiteSpace = "normal"; // Allows text wrapping
  676. this.title.setBorder("normal", "2px", "white", "10px");
  677. this.title.el.style.cursor = "pointer";
  678. this.title.el.addEventListener("mousedown", () => {
  679. if (this.callbackFunc) {
  680. this.callbackFunc();
  681. }
  682. });
  683. break;
  684. case "open": {
  685. this.active = false;
  686. this.title.el.style.display = "flex";
  687. this.title.el.style.alignItems = "center";
  688. this.title.el.style.justifyContent = "space-between";
  689. let opener_box = new El(
  690. this.name + " opener box",
  691. "div",
  692. "rgb(75, 75, 75)",
  693. "20px",
  694. "20px"
  695. );
  696. opener_box.setBorder("normal", "2px", "gray", "4px");
  697. opener_box.el.style.display = "flex";
  698. opener_box.el.style.alignItems = "center";
  699. opener_box.el.style.justifyContent = "center";
  700. //
  701. let triangle = new El(
  702. name + " triangle",
  703. "div",
  704. "transparent",
  705. "0px",
  706. "0px"
  707. );
  708. triangle.setBorder("bottom", "16px", "lime");
  709. triangle.setBorder("left", "8px", "transparent");
  710. triangle.setBorder("right", "8px", "transparent");
  711. triangle.setBorder("top", "0px", "transparent");
  712. //
  713. //event listeners
  714. opener_box.el.addEventListener("mousedown", (e) => {
  715. if (e.button != 0) return;
  716. this.active = !this.active;
  717. if (this.active) {
  718. triangle.setBorder("bottom", "0px", "transparent");
  719. triangle.setBorder("left", "8px", "transparent");
  720. triangle.setBorder("right", "8px", "transparent");
  721. triangle.setBorder("top", "16px", "red");
  722. this.loadSettings();
  723. } else {
  724. triangle.setBorder("bottom", "16px", "lime");
  725. triangle.setBorder("left", "8px", "transparent");
  726. triangle.setBorder("right", "8px", "transparent");
  727. triangle.setBorder("top", "0px", "transparent");
  728. this.unloadSettings();
  729. }
  730. });
  731. opener_box.el.addEventListener("mouseover", () => {
  732. opener_box.el.style.backgroundColor = "rgb(50, 50, 50)";
  733. opener_box.el.style.cursor = "pointer";
  734. });
  735. opener_box.el.addEventListener("mouseout", () => {
  736. opener_box.el.style.backgroundColor = "rgb(75, 75, 75)";
  737. });
  738. opener_box.el.appendChild(triangle.el);
  739. this.title.el.appendChild(opener_box.el);
  740. break;
  741. }
  742. }
  743. }
  744. load() {
  745. this.elements.forEach((element) => modCont.el.appendChild(element));
  746. }
  747.  
  748. unload() {
  749. this.elements.forEach((element) => {
  750. if (modCont.el.contains(element)) {
  751. modCont.el.removeChild(element);
  752. }
  753. });
  754. }
  755.  
  756. loadSettings() {
  757. if (!this.settings) return;
  758. for (let _sett in this.settings) {
  759. this.settings[_sett].load();
  760. }
  761. }
  762.  
  763. unloadSettings() {
  764. if (!this.settings) return;
  765. for (let _sett in this.settings) {
  766. this.settings[_sett].unload();
  767. }
  768. }
  769. }
  770.  
  771. class Category {
  772. constructor(name, modules) {
  773. this.name = name;
  774. this.element = new El(name, "div", "rgb(38, 38, 38)", "90px", "50px");
  775. this.element.setPosition("relative", "block");
  776. this.element.setText(
  777. name,
  778. "white",
  779. "Calibri",
  780. "bold",
  781. "20px",
  782. "2px",
  783. "center",
  784. "center"
  785. );
  786. this.element.setBorder("normal", "2px", "transparent", "10px");
  787. this.selected = false;
  788. this.modules = modules;
  789.  
  790. this.element.el.addEventListener("mousedown", (e) => {
  791. if (e.button !== 0) return;
  792. this.selected = !this.selected;
  793. this.element.el.style.backgroundColor = this.selected
  794. ? "lightgray"
  795. : "rgb(38, 38, 38)";
  796. handle_categories_selection(this.name);
  797. if (!this.selected) unload_modules(this.name);
  798. });
  799.  
  800. this.element.el.addEventListener("mouseover", () => {
  801. if (!this.selected) {
  802. this.element.el.style.backgroundColor = "rgb(58, 58, 58)";
  803. this.element.el.style.cursor = "pointer";
  804. }
  805. });
  806.  
  807. this.element.el.addEventListener("mouseout", () => {
  808. if (!this.selected)
  809. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  810. });
  811. }
  812. unselect() {
  813. this.selected = false;
  814. this.element.el.style.backgroundColor = "rgb(38, 38, 38)";
  815. }
  816. }
  817.  
  818. //1travel
  819. let modules = {
  820. Info: {
  821. hall_of_Fame: new Module("Hall of Fame", "open", {
  822. darkdealer_00249: new Setting("darkdealer_00249", "title"),
  823. }),
  824. q_a1: new Module(
  825. "Where is the rest of the scripts?",
  826. "button",
  827. null,
  828. () => {
  829. alert(
  830. "They're patched, I can't make the bypass public for now, because it will be patched too"
  831. );
  832. }
  833. ),
  834. q_a2: new Module("Why no updates so long?", "button", null, () => {
  835. alert(
  836. "I had some things to do in the university + I was working on a big canvas API, that no longer works due to the patch"
  837. );
  838. }),
  839. q_a3: new Module(
  840. "I have a problem/question where can I contact you?",
  841. "button",
  842. null,
  843. () => {
  844. alert("Dm me on discord. My tag is: h3llside");
  845. }
  846. ),
  847. q_a4: new Module(
  848. "What will happen to Diep.io+ after Diep Police Department?",
  849. "button",
  850. null,
  851. () => {
  852. alert(`
  853. There are two possbile outcomes:
  854. 1. I will make it a Ghost client, meaning it will contain helpful functions that make your life easier, but don't give you any advantages public and move everything else to Addons (make it private) OR
  855. 2. I will make bannable cheats less detectable
  856. `);
  857. }
  858. ),
  859. q_a5: new Module(
  860. "I really want to have access for Addons, can I have it?",
  861. "button",
  862. null,
  863. () => {
  864. alert(`
  865. No, unless you give me something in return. For example some useful information for bypassing or someone's private script
  866. `);
  867. }
  868. ),
  869. q_a6: new Module(
  870. "I want you to make a script for me, can you do it?",
  871. "button",
  872. null,
  873. () => {
  874. alert(`
  875. If it's simple - yes. If not, well I want a reward then in any form, because my time and energy are limited, to waste hours on someone who wants some personalised script
  876. `);
  877. }
  878. ),
  879. },
  880.  
  881. Visual: {
  882. Key_inputs_visualiser: new Module("Key Inputs Visualiser", "toggle"),
  883. display_hotkeys: new Module("Show Tank Upgrade Hotkeys", "toggle"),
  884. destroyer_cooldown: new Module("Destroyer Cooldown", "open", {
  885. Title: new Setting("Destroyer Cooldown", "title"),
  886. reload: new Setting("Reload?", "select", [0, 1, 2, 3, 4, 5, 6, 7]),
  887. destroyer_cooldown: new Setting("enable Destroyer Cooldown", "toggle"),
  888. }),
  889. },
  890.  
  891. Functional: {
  892. CopyLink: new Module("Copy Party Link", "button", null, () => {
  893. document.getElementById("copy-party-link").click();
  894. }),
  895. Sandbox_lvl_up: new Module("Sandbox Auto Level Up", "toggle"),
  896. Auto_respawn: new Module("Auto Respawn", "open", {
  897. Title: new Setting("Auto Respawn", "title"),
  898. Remember: new Setting("Remember and store Killer Names", "toggle"),
  899. Prevent: new Setting("Prevent respawning after 300k score", "toggle"),
  900. Name: new Setting("Spawn Name Type: ", "select", [
  901. "Normal",
  902. "Glitched",
  903. "N A M E",
  904. "Random Killer",
  905. "Random Symbols",
  906. "Random Numbers",
  907. "Random Letters",
  908. ]),
  909. Auto_respawn: new Setting("Auto Respawn", "toggle"),
  910. }),
  911. Bot_tab: new Module("Sandbox Arena size increase", "toggle"),
  912. Zoom: new Module("Zoom Out", "slider"),
  913. Predator_stack: new Module("Predator Stack", "button", null, () => {
  914. predator_stack(get_reload());
  915. }),
  916. },
  917.  
  918. Mouse: {
  919. Anti_aim: new Module("Anti Aim", "open", {
  920. Title: new Setting("Anti Aim", "title"),
  921. Timing: new Setting(
  922. "Follow mouse on click, how long?",
  923. "select",
  924. [50, 100, 150, 200, 250, 300]
  925. ),
  926. Anti_aim: new Setting("enable Anti Aim", "toggle"),
  927. }),
  928. Freeze_mouse: new Module("Freeze Mouse", "toggle"),
  929. Anti_timeout: new Module("Anti AFK Timeout", "toggle"),
  930. Move_2_mouse: new Module("Move to mouse", "open", {
  931. Title: new Setting("Move to mouse", "title"),
  932. Approximation: new Setting(
  933. "Approximation Factor (lower = smoother)",
  934. "select",
  935. [10, 25, 40, 65, 80, 100]
  936. ),
  937. Time_factor: new Setting(
  938. "Time Factor (higher = longer)",
  939. "select",
  940. [10, 20, 30, 40, 50]
  941. ),
  942. Move_2_mouse: new Setting("enable Move to Mouse", "toggle"),
  943. }),
  944. },
  945.  
  946. DiepConsole: {
  947. con_toggle: new Module("Show/hide Diep Console", "toggle"),
  948. net_predict_movement: new Module("predict movement", "toggle"),
  949. Render: new Module("Render things", "open", {
  950. Title: new Setting("Rendering", "title"),
  951. ren_scoreboard: new Setting("Leaderboard", "toggle"),
  952. ren_scoreboard_names: new Setting("Scoreboard Names", "toggle"),
  953. ren_fps: new Setting("FPS", "toggle"),
  954. ren_upgrades: new Setting("Tank Upgrades", "toggle"),
  955. ren_stats: new Setting("Stat Upgrades", "toggle"),
  956. ren_names: new Setting("Names", "toggle"),
  957. }),
  958. //game builds
  959. },
  960.  
  961. Addons: {},
  962. };
  963.  
  964. console.log(modules);
  965.  
  966. let categories = [];
  967.  
  968. function create_categories() {
  969. for (let key in modules) {
  970. categories.push(new Category(key, modules[key]));
  971. }
  972. }
  973. create_categories();
  974.  
  975. //loading / unloading modules
  976. function load_modules(category_name) {
  977. const current_category = categories.find(
  978. (category) => category.name === category_name
  979. );
  980. for (let moduleName in current_category.modules) {
  981. let module = current_category.modules[moduleName];
  982. module.load();
  983. if (module.type === "open" && module.active) module.loadSettings();
  984. }
  985. }
  986.  
  987. function unload_modules(category_name) {
  988. const current_category = categories.find(
  989. (category) => category.name === category_name
  990. );
  991. for (let moduleName in current_category.modules) {
  992. let module = current_category.modules[moduleName];
  993. module.unload();
  994. module.unloadSettings();
  995. }
  996. }
  997.  
  998. function find_module_path(_name) {
  999. for (let category in modules) {
  1000. for (let module in modules[category]) {
  1001. // Iterate over actual modules
  1002. if (modules[category][module].name === _name) {
  1003. return [category, module]; // Return actual category and module
  1004. }
  1005. }
  1006. }
  1007. return -1; // Return -1 if not found
  1008. }
  1009.  
  1010. function handle_categories_selection(current_name) {
  1011. categories.forEach((category) => {
  1012. if (category.name !== current_name && category.selected) {
  1013. category.unselect();
  1014. unload_modules(category.name);
  1015. }
  1016. });
  1017.  
  1018. load_modules(current_name);
  1019. }
  1020.  
  1021. function loadCategories() {
  1022. const categoryCont = document.querySelector("#sub-container-gray");
  1023. categories.forEach((category) =>
  1024. categoryCont.appendChild(category.element.el)
  1025. );
  1026. }
  1027.  
  1028. function load_selected() {
  1029. categories.forEach((category) => {
  1030. if (category.selected) {
  1031. load_modules(category.name);
  1032. }
  1033. });
  1034. }
  1035.  
  1036. function loadGUI() {
  1037. document.body.style.margin = "0";
  1038. document.body.style.display = "flex";
  1039. document.body.style.justifyContent = "left";
  1040.  
  1041. mainCont = new El("Main Cont", "div", "rgb(38, 38, 38)", "500px", "400px");
  1042. mainCont.setBorder("normal", "2px", "lime", "10px");
  1043. mainCont.el.style.display = "flex";
  1044. mainCont.el.style.minHeight = "min-content";
  1045. mainCont.el.style.flexDirection = "column";
  1046. mainCont.add(document.body);
  1047.  
  1048. header = new El("Headline Dp", "div", "transparent", "100%", "40px");
  1049. header.setBorder("bottom", "2px", "rgb(106, 173, 84)");
  1050. header.setText(
  1051. "Diep.io+ by r!PsAw (Hide GUI with J)",
  1052. "white",
  1053. "Calibri",
  1054. "bold",
  1055. "20px",
  1056. "2px",
  1057. "center",
  1058. "center"
  1059. );
  1060. header.add(mainCont.el);
  1061.  
  1062. const contentWrapper = document.createElement("div");
  1063. contentWrapper.style.display = "flex";
  1064. contentWrapper.style.gap = "10px";
  1065. contentWrapper.style.padding = "10px";
  1066. contentWrapper.style.flex = "1";
  1067. mainCont.el.appendChild(contentWrapper);
  1068.  
  1069. subContGray = new El(
  1070. "Sub Container Gray",
  1071. "div",
  1072. "transparent",
  1073. "100px",
  1074. "100%"
  1075. );
  1076. subContGray.el.style.display = "flex";
  1077. subContGray.el.style.flexDirection = "column";
  1078. subContGray.el.style.overflowY = "auto";
  1079. subContGray.add(contentWrapper);
  1080.  
  1081. subContBlack = new El("Sub Container Black", "div", "black", "360px", "100%");
  1082. subContBlack.el.style.display = "flex";
  1083. subContBlack.el.style.gap = "10px";
  1084. subContBlack.add(contentWrapper);
  1085.  
  1086. modCont = new El("Module Container", "div", "transparent", "50%", "100%");
  1087. modCont.el.style.display = "flex";
  1088. modCont.el.style.flexDirection = "column";
  1089. modCont.el.style.overflowY = "auto";
  1090. modCont.setBorder("right", "2px", "white");
  1091. modCont.add(subContBlack.el);
  1092.  
  1093. settCont = new El("Settings Container", "div", "transparent", "50%", "100%");
  1094. settCont.el.style.display = "flex";
  1095. settCont.el.style.flexDirection = "column";
  1096. settCont.el.style.overflowY = "auto";
  1097. settCont.add(subContBlack.el);
  1098.  
  1099. loadCategories();
  1100. load_selected();
  1101. }
  1102.  
  1103. loadGUI();
  1104. document.addEventListener("keydown", toggleGUI);
  1105.  
  1106. function toggleGUI(e) {
  1107. if (e.key === "j" || e.key === "J") {
  1108. if (mainCont.el) {
  1109. mainCont.remove(document.body);
  1110. mainCont.el = null;
  1111. } else {
  1112. loadGUI();
  1113. }
  1114. }
  1115. }
  1116.  
  1117.  
  1118. //actual logic
  1119. let approximation_factor = modules.Mouse.Move_2_mouse.settings.Approximation.selected; // Higher = faster movement, but less smooth Lower = slower movement, but more smooth
  1120. let distance_time_factor = modules.Mouse.Move_2_mouse.settings.Time_factor.selected; // transform the distance into Time
  1121. let moving_active = false;
  1122. let current_direction = 'none';
  1123.  
  1124. function calculate_distance(x1, y1, x2, y2) {
  1125. return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
  1126. }
  1127.  
  1128. function get_mouse_move_steps() {
  1129. let center = { x: canvas.width / 2, y: canvas.height / 2 };
  1130. let target = { x: inputs.mouse.real.x, y: inputs.mouse.real.y };
  1131. let full_distance = calculate_distance(center.x, center.y, target.x, target.y);
  1132. let partial_distance = full_distance / approximation_factor;
  1133. let step = { x: (target.x - center.x) / partial_distance, y: (target.y - center.y) / partial_distance };
  1134. return step;
  1135. }
  1136.  
  1137. function move_in_direction(direction, time) {
  1138. moving_active = true;
  1139. current_direction = direction;
  1140. let directions = {
  1141. 'Up': 'KeyW',
  1142. 'Left': 'KeyA',
  1143. 'Down': 'KeyS',
  1144. 'Right': 'KeyD',
  1145. }
  1146. for (let _dir in directions) {
  1147. if (directions[_dir] === undefined) return console.warn("Invalid direction");
  1148. if (_dir === direction) {
  1149. extern.onKeyDown(diep_keys[directions[_dir]]);
  1150. } else {
  1151. extern.onKeyUp(diep_keys[directions[_dir]]);
  1152. }
  1153. }
  1154. setTimeout(() => {
  1155. moving_active = false;
  1156. }, time);
  1157. }
  1158.  
  1159. function move_to_mouse() {
  1160. window.requestAnimationFrame(move_to_mouse);
  1161. if (!modules.Mouse.Move_2_mouse.settings.Move_2_mouse.active || moving_active || !player.inGame || !document.hasFocus()) return;
  1162. //update factors
  1163. approximation_factor = modules.Mouse.Move_2_mouse.settings.Approximation.selected;
  1164. distance_time_factor = modules.Mouse.Move_2_mouse.settings.Time_factor.selected;
  1165. //logic
  1166. let step = get_mouse_move_steps();
  1167. let horizontal = step.x > 0 ? 'Right' : 'Left';
  1168. let vertical = step.y > 0 ? 'Down' : 'Up';
  1169.  
  1170. switch (current_direction) {
  1171. case "none":
  1172. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1173. break;
  1174. case 'Right':
  1175. move_in_direction(vertical, Math.abs(step.y) * distance_time_factor);
  1176. break;
  1177. case 'Left':
  1178. move_in_direction(vertical, Math.abs(step.y) * distance_time_factor);
  1179. break;
  1180. case 'Up':
  1181. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1182. break
  1183. case 'Down':
  1184. move_in_direction(horizontal, Math.abs(step.x) * distance_time_factor);
  1185. break
  1186. }
  1187. }
  1188. window.requestAnimationFrame(move_to_mouse);
  1189.  
  1190.  
  1191. // ]-[ HTML RELATED STUFF
  1192. let homescreen = document.getElementById("home-screen");
  1193. let ingamescreen = document.getElementById("in-game-screen");
  1194. let gameOverScreen = document.getElementById('game-over-screen');
  1195. let gameOverScreenContainer = document.querySelector("#game-over-screen > div > div.game-details > div:nth-child(1)");
  1196. function update_scale_option(selector, label, min, max) {
  1197. let element = document.querySelector(selector);
  1198. let label_element = element.closest("div").querySelector("span");
  1199. label_element.innerHTML = `[DIEP.IO+] ${label}`;
  1200. label_element.style.background = "black";
  1201. label_element.style.color = "purple";
  1202. element.min = min;
  1203. element.max = max;
  1204. }
  1205.  
  1206. function new_ranges_for_scales() {
  1207. update_scale_option("#subsetting-option-ui_scale", "UI Scale", '0.01', '1000');
  1208. update_scale_option("#subsetting-option-border_radius", "UI Border Radius", '0.01', '1000');
  1209. update_scale_option("#subsetting-option-border_intensity", "UI Border Intensity", '0.01', '1000');
  1210. }
  1211.  
  1212. new_ranges_for_scales();
  1213.  
  1214. //detect gamemode
  1215. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1216. let last_gamemode = localStorage.getItem(`[Diep.io+] last_gm`);
  1217. localStorage.setItem(`[Diep.io+] last_gm}`, gamemode);
  1218.  
  1219. function check_gamemode() {
  1220. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1221. save_gm();
  1222. }
  1223.  
  1224. setInterval(check_gamemode, 250);
  1225.  
  1226. function save_gm() {
  1227. let saved_gm = localStorage.getItem(`[Diep.io+] last_gm`);
  1228. if (saved_gm != null && saved_gm != gamemode) {
  1229. last_gamemode = saved_gm;
  1230. }
  1231. saved_gm === null ? localStorage.setItem(`[Diep.io+] last_gm}`, gamemode) : null;
  1232. }
  1233.  
  1234. //personal best
  1235. let your_final_score = 0;
  1236. const personal_best = document.createElement('div');
  1237. const gameDetail = document.createElement('div');
  1238. const label = document.createElement('div');
  1239. //applying class
  1240. gameDetail.classList.add("game-detail");
  1241. label.classList.add("label");
  1242. personal_best.classList.add("value");
  1243. //text context
  1244. label.textContent = "Best:";
  1245. //adding to html
  1246. gameOverScreenContainer.appendChild(gameDetail);
  1247. gameDetail.appendChild(label);
  1248. gameDetail.appendChild(personal_best);
  1249.  
  1250. function load_ls() {
  1251. return localStorage.getItem(gamemode);
  1252. }
  1253.  
  1254. function save_ls() {
  1255. localStorage.setItem(gamemode, your_final_score);
  1256. }
  1257.  
  1258. function check_final_score() {
  1259. if (_c.screen_state === "game-over") {
  1260. your_final_score = _c.death_score;
  1261. let saved_score = parseFloat(load_ls());
  1262. personal_best.textContent = saved_score;
  1263. if (saved_score < your_final_score) {
  1264. personal_best.textContent = your_final_score;
  1265. save_ls();
  1266. }
  1267. }
  1268. }
  1269.  
  1270. setInterval(check_final_score, 100);
  1271.  
  1272. //remove annoying html elements
  1273. function instant_remove() {
  1274. // Define selectors for elements to remove
  1275. const selectors = [
  1276. "#cmpPersistentLink",
  1277. "#apes-io-promo",
  1278. "#apes-io-promo > img",
  1279. "#last-updated",
  1280. "#diep-io_300x250"
  1281. ];
  1282.  
  1283. // Remove each selected element
  1284. selectors.forEach(selector => {
  1285. const element = document.querySelector(selector);
  1286. if (element) {
  1287. element.remove();
  1288. }
  1289. });
  1290.  
  1291. // If all elements have been removed, clear the interval
  1292. if (selectors.every(selector => !document.querySelector(selector))) {
  1293. deep_debug("Removed all ads, quitting...");
  1294. clearInterval(interval);
  1295. }
  1296. }
  1297.  
  1298. // Set an interval to check for ads
  1299. const interval = setInterval(instant_remove, 100);
  1300.  
  1301. // ]-[
  1302.  
  1303. //Predator Stack
  1304. let predator_reloads = [
  1305. //0
  1306. {
  1307. scd2: 600,
  1308. scd3: 1000,
  1309. wcd1: 1500,
  1310. wcd2: 2900,
  1311. },
  1312. //1
  1313. {
  1314. scd2: 500,
  1315. scd3: 900,
  1316. wcd1: 1400,
  1317. wcd2: 2800,
  1318. },
  1319. //2
  1320. {
  1321. scd2: 500,
  1322. scd3: 900,
  1323. wcd1: 1200,
  1324. wcd2: 2400,
  1325. },
  1326. //3
  1327. {
  1328. scd2: 400,
  1329. scd3: 900,
  1330. wcd1: 1200,
  1331. wcd2: 2300,
  1332. },
  1333. //4
  1334. {
  1335. scd2: 400,
  1336. scd3: 900,
  1337. wcd1: 1000,
  1338. wcd2: 2000,
  1339. },
  1340. //5
  1341. {
  1342. scd2: 400,
  1343. scd3: 800,
  1344. wcd1: 900,
  1345. wcd2: 1800,
  1346. },
  1347. //6
  1348. {
  1349. scd2: 300,
  1350. scd3: 800,
  1351. wcd1: 900,
  1352. wcd2: 1750,
  1353. },
  1354. //7
  1355. {
  1356. scd2: 300,
  1357. scd3: 800,
  1358. wcd1: 750,
  1359. wcd2: 1500,
  1360. },
  1361. ];
  1362.  
  1363.  
  1364. function shoot(cooldown = 100) {
  1365. deep_debug("Shoot started!", cooldown);
  1366. extern.onKeyDown(36);
  1367. setTimeout(() => {
  1368. deep_debug("Ending Shoot!", cooldown);
  1369. extern.onKeyUp(36);
  1370. }, cooldown);
  1371. }
  1372.  
  1373. function get_reload(){
  1374. let arr = [...extern.get_convar("game_stats_build")];
  1375. let counter = 0;
  1376. let l = arr.length;
  1377. for(let i = 0; i < l; i++){
  1378. if(arr[i] === '7'){
  1379. counter++;
  1380. }
  1381. }
  1382. return counter;
  1383. }
  1384.  
  1385. function predator_stack(reload) {
  1386. deep_debug("func called");
  1387. let current = predator_reloads[reload];
  1388. deep_debug(current);
  1389. shoot();
  1390. setTimeout(() => {
  1391. shoot(current.scd2);
  1392. }, current.wcd1);
  1393. setTimeout(() => {
  1394. shoot(current.scd3);
  1395. }, current.wcd2);
  1396. }
  1397.  
  1398. //Bot tab
  1399.  
  1400. //iframe creation
  1401. function createInvisibleIframe(url) {
  1402. let existingIframe = document.getElementById('hiddenIframe');
  1403. if (existingIframe) {
  1404. return;
  1405. }
  1406.  
  1407. let iframe = document.createElement('iframe');
  1408. iframe.src = url;
  1409. iframe.id = 'hiddenIframe';
  1410. document.body.appendChild(iframe);
  1411. }
  1412.  
  1413. function removeIframe() {
  1414. let iframe = document.getElementById('hiddenIframe');
  1415. if (iframe) {
  1416. iframe.remove();
  1417. }
  1418. }
  1419.  
  1420. function bot_tab_active_check(){
  1421. if(modules.Functional.Bot_tab.active){
  1422. createInvisibleIframe(link(get_baseUrl(), get_your_lobby(), get_gamemode(), get_team()));
  1423. }else{
  1424. removeIframe();
  1425. }
  1426. }
  1427. setInterval(bot_tab_active_check, 1000);
  1428.  
  1429. //DiepConsole
  1430. function active_diepconsole_render_default(){
  1431. let defaults = ['ren_scoreboard', 'ren_upgrades', 'ren_stats', 'ren_names', 'ren_scoreboard_names'];
  1432. for(let _def of defaults){
  1433. let _setting = modules.DiepConsole.Render.settings[_def]
  1434. _setting.active = true;
  1435. }
  1436. }
  1437. active_diepconsole_render_default();
  1438.  
  1439. function handle_con_toggle(state){
  1440. if(extern.isConActive() != state){
  1441. extern.execute('con_toggle');
  1442. }
  1443. }
  1444.  
  1445. function update_diep_console(){
  1446. //Modules
  1447. for(let param in modules.DiepConsole){
  1448. let state = modules.DiepConsole[param].active;
  1449. if(param === "con_toggle"){
  1450. handle_con_toggle(state)
  1451. }else if(modules.DiepConsole[param].name != "Render things"){
  1452. extern.set_convar(param, state);
  1453. }
  1454. }
  1455. //Render Settings
  1456. for(let ren_param in modules.DiepConsole.Render.settings){
  1457. let state = modules.DiepConsole.Render.settings[ren_param].active;
  1458. if(modules.DiepConsole.Render.settings[ren_param].name != "Rendering"){
  1459. extern.set_convar(ren_param, state);
  1460. }
  1461. }
  1462. }
  1463. setInterval(update_diep_console, 100);
  1464.  
  1465.  
  1466. //////
  1467. //mouse functions
  1468.  
  1469. window.addEventListener('mousemove', function(event) {
  1470. inputs.mouse.real.x = event.clientX;
  1471. inputs.mouse.real.y = event.clientY;
  1472. });
  1473.  
  1474. window.addEventListener('mousedown', function(event) {
  1475. if (modules.Mouse.Anti_aim.settings.Anti_aim.active) {
  1476. if (inputs.mouse.shooting) {
  1477. return;
  1478. }
  1479. inputs.mouse.shooting = true;
  1480. pauseMouseMove();
  1481. //freezeMouseMove();
  1482. setTimeout(function() {
  1483. inputs.mouse.shooting = false;
  1484. mouse_move('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  1485. click_at('extern', inputs.mouse.real.x, inputs.mouse.real.y);
  1486. }, modules.Mouse.Anti_aim.settings.Timing.selected);
  1487. };
  1488. });
  1489.  
  1490. function handle_mouse_functions() {
  1491. window.requestAnimationFrame(handle_mouse_functions);
  1492. if (!player.connected) {
  1493. return;
  1494. }
  1495. modules.Mouse.Freeze_mouse.active ? freezeMouseMove() : unfreezeMouseMove();
  1496. modules.Mouse.Anti_aim.settings.Anti_aim.active ? anti_aim("On") : anti_aim("Off");
  1497. }
  1498. window.requestAnimationFrame(handle_mouse_functions);
  1499.  
  1500. //anti aim
  1501. function detect_corner() {
  1502. deep_debug('corner detect called');
  1503. let w = window.innerWidth;
  1504. let h = window.innerHeight;
  1505. let center = {
  1506. x: w / 2,
  1507. y: h / 2
  1508. };
  1509. let lr, ud;
  1510. inputs.mouse.real.x > center.x ? lr = "r" : lr = "l";
  1511. inputs.mouse.real.y > center.y ? ud = "d" : ud = "u";
  1512. deep_debug('output: ', lr + ud);
  1513. return lr + ud;
  1514. }
  1515.  
  1516. function look_at_corner(corner) {
  1517. deep_debug('look at corner called with corner', corner);
  1518. if (!inputs.mouse.shooting) {
  1519. let w = window.innerWidth;
  1520. let h = window.innerHeight;
  1521. deep_debug('w and h', w, h);
  1522. deep_debug('inputs: ', inputs);
  1523. switch (corner) {
  1524. case "lu":
  1525. anti_aim_at('extern', w, h);
  1526. break
  1527. case "ld":
  1528. anti_aim_at('extern', w, 0);
  1529. break
  1530. case "ru":
  1531. anti_aim_at('extern', 0, h);
  1532. break
  1533. case "rd":
  1534. anti_aim_at('extern', 0, 0);
  1535. break
  1536. }
  1537. }
  1538. }
  1539.  
  1540. function anti_aim(toggle) {
  1541. deep_debug('anti aim called with:', toggle);
  1542. if(!player.inGame) return;
  1543. switch (toggle) {
  1544. case "On":
  1545. if (modules.Mouse.Anti_aim.settings.Anti_aim.active && !inputs.mouse.isFrozen) {
  1546. deep_debug('condition !modules.Mouse.Anti_aim.settings.active met');
  1547. look_at_corner(detect_corner());
  1548. }
  1549. break
  1550. case "Off":
  1551. //(inputs.mouse.isFrozen && !modules.Mouse.Freeze_mouse.active) ? unfreezeMouseMove() : null;
  1552. (inputs.mouse.isPaused && !modules.Mouse.Freeze_mouse.active) ? unpauseMouseMove() : null;
  1553. break
  1554. }
  1555. }
  1556.  
  1557. // Example: Freeze and unfreeze
  1558. function pauseMouseMove() {
  1559. if(!inputs.mouse.isPaused){
  1560. inputs.mouse.isForced = true;
  1561. inputs.mouse.force.x = inputs.mouse.real.x
  1562. inputs.mouse.force.y = inputs.mouse.real.y;
  1563. inputs.mouse.isPaused = true; //tell the script that freezing finished
  1564. }
  1565. }
  1566.  
  1567. function freezeMouseMove() {
  1568. if(!inputs.mouse.isFrozen){
  1569. inputs.mouse.isForced = true;
  1570. inputs.mouse.force.x = inputs.mouse.real.x
  1571. inputs.mouse.force.y = inputs.mouse.real.y;
  1572. inputs.mouse.isFrozen = true; //tell the script that freezing finished
  1573. }
  1574. /*
  1575. if (!inputs.mouse.isFrozen) {
  1576. inputs.mouse.isFrozen = true;
  1577. clear_onTouch();
  1578. deep_debug("Mousemove events are frozen.");
  1579. }
  1580. */
  1581. }
  1582.  
  1583. function unpauseMouseMove(){
  1584. if (inputs.mouse.isPaused && !inputs.mouse.isShooting) {
  1585. inputs.mouse.isForced = false;
  1586. inputs.mouse.isPaused = false; //tell the script that unfreezing finished
  1587. }
  1588. }
  1589.  
  1590. function unfreezeMouseMove() {
  1591. if (inputs.mouse.isFrozen) {
  1592. inputs.mouse.isForced = false;
  1593. inputs.mouse.isFrozen = false; //tell the script that unfreezing finished
  1594. }
  1595. /*
  1596. if (inputs.mouse.isFrozen && !inputs.mouse.isShooting) {
  1597. inputs.mouse.isFrozen = false;
  1598. redefine_onTouch();
  1599. deep_debug("Mousemove events are active.");
  1600. }
  1601. */
  1602. }
  1603.  
  1604. function click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  1605. i_e(input_or_extern, 'onTouchStart', -1, x, y);
  1606. setTimeout(() => {
  1607. i_e(input_or_extern, 'onTouchEnd', -1, x, y);
  1608. }, delay1);
  1609. setTimeout(() => {
  1610. inputs.mouse.shooting = false;
  1611. }, delay2);
  1612. }
  1613.  
  1614. /* it was a bug and is now patched
  1615. function ghost_click_at(input_or_extern, x, y, delay1 = 150, delay2 = 500) {
  1616. i_e(input_or_extern, 'onTouchStart', -2, x, y);
  1617. setTimeout(() => {
  1618. i_e(input_or_extern, 'onTouchEnd', -2, x, y);
  1619. }, delay1);
  1620. setTimeout(() => {
  1621. inputs.mouse.shooting = false;
  1622. }, delay2);
  1623. }
  1624. */
  1625.  
  1626. function mouse_move(input_or_extern, x, y) {
  1627. deep_debug('mouse move called with', x, y);
  1628. apply_force(x, y);
  1629. i_e(input_or_extern, 'onTouchMove', -1, x, y);
  1630. disable_force();
  1631. }
  1632.  
  1633. function anti_aim_at(input_or_extern, x, y) {
  1634. deep_debug('frozen, shooting', inputs.mouse.isFrozen, inputs.mouse.isShooting);
  1635. deep_debug('anti aim at called with:', x, y);
  1636. if (inputs.mouse.shooting) {
  1637. deep_debug('quit because inputs.mouse.shooting');
  1638. return;
  1639. }
  1640. mouse_move(input_or_extern, x, y);
  1641. }
  1642. //////
  1643.  
  1644. //Sandbox Auto Lvl up
  1645. function sandbox_lvl_up() {
  1646. if (modules.Functional.Sandbox_lvl_up.active && player.connected && player.inGame && player.gamemode === "sandbox") {
  1647. document.querySelector("#sandbox-max-level").click();
  1648. }
  1649. }
  1650. setInterval(sandbox_lvl_up, 500);
  1651.  
  1652. //START, autorespawn Module
  1653.  
  1654. //name saving logic
  1655. let killer_names = localStorage.getItem("[Diep.io+] saved names") ? JSON.parse(localStorage.getItem("[Diep.io+] saved names")) : ['r!PsAw', 'TestTank'];
  1656. let banned_names = ["Pentagon", "Triangle", "Square", "Crasher", "Mothership", "Guardian of Pentagons", "Fallen Booster", "Fallen Overlord", "Necromancer", "Defender", "Unnamed Tank"];
  1657. function check_and_save_name(){
  1658. deep_debug(_c.killer_name, !killer_names.includes(_c.killer_name));
  1659. if(_c.screen_state === 'game-over' && !banned_names.includes(_c.killer_name) && !killer_names.includes(_c.killer_name)){
  1660. deep_debug("Condition met!");
  1661. killer_names.push(_c.killer_name);
  1662. deep_debug("Added");
  1663. killer_names = [...new Set(killer_names)];
  1664. if(modules.Functional.Auto_respawn.settings.Remember.active){
  1665. localStorage.setItem("[Diep.io+] saved names", JSON.stringify(killer_names));
  1666. deep_debug("saved list");
  1667. }
  1668. }
  1669. }
  1670.  
  1671. function get_random_killer_name(){
  1672. let l = killer_names.length;
  1673. let index = Math.floor(Math.random() * l);
  1674. return killer_names[index];
  1675. }
  1676.  
  1677. //Random Symbols/Numbers/Letters
  1678. function generate_random_name_string(type){
  1679. let final_result = '';
  1680. let chars = '';
  1681. switch(type){
  1682. case "Symbols":
  1683. chars = '!@#$%^&*()_+=-.,][';
  1684. break
  1685. case "Numbers":
  1686. chars = '1234567890';
  1687. break
  1688. case "Letters":
  1689. chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  1690. break
  1691. }
  1692. for (let i = 0; i < 16; i++) {
  1693. final_result += chars[Math.floor(Math.random() * chars.length)];
  1694. }
  1695. return final_result;
  1696. }
  1697. //ascii inject
  1698. function get_ascii_inject(type){
  1699. let asciiArray = [];
  1700. switch(type){
  1701. case "Glitched":
  1702. asciiArray = [0x110000];
  1703. break
  1704. case "N A M E":
  1705. asciiArray = player.name.split("").flatMap(char => [char.charCodeAt(0), 10]).slice(0, -1);
  1706. break
  1707. }
  1708. let interesting = {
  1709. length: asciiArray.length,
  1710. charCodeAt(i) {
  1711. return asciiArray[i];
  1712. },
  1713. };
  1714. const argument = {
  1715. toString() {
  1716. return interesting;
  1717. },
  1718. };
  1719. return argument;
  1720. }
  1721.  
  1722. //main Loop
  1723. function get_respawn_name_by_type(type){
  1724. let temp_name = '';
  1725. switch(type){
  1726. case "Normal":
  1727. temp_name = player.name;
  1728. break
  1729. case "Glitched":
  1730. temp_name = get_ascii_inject(type);
  1731. break
  1732. case "N A M E":
  1733. temp_name = get_ascii_inject(type);
  1734. break
  1735. case "Random Killer":
  1736. temp_name = get_random_killer_name();
  1737. break
  1738. case "Random Symbols":
  1739. temp_name = generate_random_name_string('Symbols');
  1740. break
  1741. case "Random Numbers":
  1742. temp_name = generate_random_name_string('Numbers');
  1743. break
  1744. case "Random Letters":
  1745. temp_name = generate_random_name_string('Letters');
  1746. break
  1747. }
  1748. return temp_name;
  1749. }
  1750. function respawn() {
  1751. check_and_save_name();
  1752. if (modules.Functional.Auto_respawn.settings.Auto_respawn.active && player.connected && !player.inGame) {
  1753. //prevent respawn after 300k flag
  1754. if(modules.Functional.Auto_respawn.settings.Prevent.active && _c.death_score >= 300000){
  1755. return;
  1756. }
  1757. let type = modules.Functional.Auto_respawn.settings.Name.selected;
  1758. let temp_name = get_respawn_name_by_type(type);
  1759. extern.try_spawn(temp_name);
  1760. }
  1761. }
  1762.  
  1763. setInterval(respawn, 1000);
  1764.  
  1765. //END
  1766.  
  1767. //AntiAfk Timeout
  1768. function AntiAfkTimeout() {
  1769. if (modules.Mouse.Anti_timeout.active && player.connected) {
  1770. extern.onTouchMove(inputs.mouse.real.x, inputs.mouse.real.y);
  1771. }
  1772. }
  1773. setInterval(AntiAfkTimeout, 1000);
  1774.  
  1775. //Zoom
  1776. function start_zoom_proxy(){
  1777. input.setScreensizeZoom = new Proxy(input.setScreensizeZoom, {
  1778. apply: function(target, thisArgs, args){
  1779. player.base_value = args[1];
  1780. let factor = modules.Functional.Zoom.value / 100;
  1781. player.dpr = player.base_value * factor;
  1782. let newargs = [args[0], player.dpr];
  1783. return Reflect.apply(target, thisArgs, newargs);
  1784. }
  1785. });
  1786. }
  1787. function HandleZoom() {
  1788. if(player.connected){
  1789. //let base_value = 1;
  1790. //let factor = modules.Functional.Zoom.value / 100;
  1791. //player.dpr = base_value * factor;
  1792. let diepScale = player.base_value * Math.floor(player.ui_scale * windowScaling() * 25) / 25;
  1793. extern.setScreensizeZoom(diepScale, player.base_value);
  1794. extern.updateDPR(player.dpr);
  1795. }
  1796. }
  1797. setInterval(HandleZoom, 100);
  1798.  
  1799. //ctx helper functions
  1800. function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c, stroke_or_fill = 'fill', _globalAlpha=1, _lineWidth = '2px') {
  1801. let original_ga = ctx.globalAlpha;
  1802. let original_lw = ctx.lineWidth;
  1803. ctx.beginPath();
  1804. ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
  1805. ctx.globalAlpha = _globalAlpha;
  1806. switch(stroke_or_fill){
  1807. case "fill":
  1808. ctx.fillStyle = c;
  1809. ctx.fill();
  1810. break
  1811. case "stroke":
  1812. ctx.lineWidth = _lineWidth;
  1813. ctx.strokeStyle = c;
  1814. ctx.stroke();
  1815. ctx.lineWidth = original_lw;
  1816. break
  1817. }
  1818. ctx.globalAlpha = original_ga;
  1819. }
  1820.  
  1821. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  1822. deep_debug('called crx_text with: ', fcolor, scolor, lineWidth, font, text, textX, textY);
  1823. ctx.fillStyle = fcolor;
  1824. ctx.lineWidth = lineWidth;
  1825. ctx.font = font;
  1826. ctx.strokeStyle = scolor;
  1827. ctx.strokeText(`${text}`, textX, textY)
  1828. ctx.fillText(`${text}`, textX, textY)
  1829. }
  1830.  
  1831. function ctx_rect(x, y, a, b, c) {
  1832. deep_debug('called ctx_rect with: ', x, y, a, b, c);
  1833. ctx.beginPath();
  1834. ctx.strokeStyle = c;
  1835. ctx.strokeRect(x, y, a, b);
  1836. }
  1837.  
  1838. function transparent_rect_fill(x, y, a, b, scolor, fcolor, opacity){
  1839. deep_debug('called transparent_rect_fill with: ', x, y, a, b, scolor, fcolor, opacity);
  1840. ctx.beginPath();
  1841. ctx.rect(x, y, a, b);
  1842.  
  1843. // Set stroke opacity
  1844. ctx.globalAlpha = 1;// Reset to 1 for stroke, or set as needed
  1845. ctx.strokeStyle = scolor;
  1846. ctx.stroke();
  1847.  
  1848. // Set fill opacity
  1849. ctx.globalAlpha = opacity;// Set the opacity for the fill color
  1850. ctx.fillStyle = fcolor;
  1851. ctx.fill();
  1852.  
  1853. // Reset globalAlpha back to 1 for future operations
  1854. ctx.globalAlpha = 1;
  1855. }
  1856.  
  1857. //key visualiser
  1858. let ctx_wasd = {
  1859. square_sizes: { //in windowScaling
  1860. a: 50,
  1861. b: 50
  1862. },
  1863. text_props: {
  1864. lineWidth: 3,
  1865. font: 1 + "em Ubuntu",
  1866. },
  1867. square_colors: {
  1868. stroke: "black",
  1869. unpressed: "yellow",
  1870. pressed: "orange"
  1871. },
  1872. text_colors: {
  1873. stroke: "black",
  1874. unpressed: "orange",
  1875. pressed: "red"
  1876. },
  1877. w: {
  1878. x: 300,
  1879. y: 200,
  1880. pressed: false,
  1881. text: 'W'
  1882. },
  1883. a: {
  1884. x: 350,
  1885. y: 150,
  1886. pressed: false,
  1887. text: 'A'
  1888. },
  1889. s: {
  1890. x: 300,
  1891. y: 150,
  1892. pressed: false,
  1893. text: 'S'
  1894. },
  1895. d: {
  1896. x: 250,
  1897. y: 150,
  1898. pressed: false,
  1899. text: 'D'
  1900. },
  1901. l_m: {
  1902. x: 350,
  1903. y: 75,
  1904. pressed: false,
  1905. text: 'LMC'
  1906. },
  1907. r_m: {
  1908. x: 250,
  1909. y: 75,
  1910. pressed: false,
  1911. text: 'RMC'
  1912. },
  1913. }
  1914.  
  1915. function visualise_keys(){
  1916. let keys = ['w', 'a', 's', 'd', 'l_m', 'r_m'];
  1917. let l = keys.length;
  1918. for(let i = 0; i < l; i++){
  1919. let args = {
  1920. x: canvas.width - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].x),
  1921. y: canvas.height - dim_c.windowScaling_2_canvas(ctx_wasd[keys[i]].y),
  1922. a: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.a),
  1923. b: dim_c.windowScaling_2_canvas(ctx_wasd.square_sizes.b),
  1924. s_c: ctx_wasd.square_colors.stroke,
  1925. f_c: ctx_wasd[keys[i]].pressed? ctx_wasd.square_colors.pressed : ctx_wasd.square_colors.unpressed,
  1926. t_s: ctx_wasd.text_colors.stroke,
  1927. t_f: ctx_wasd[keys[i]].pressed? ctx_wasd.text_colors.pressed : ctx_wasd.text_colors.unpressed,
  1928. t_lineWidth: ctx_wasd.text_props.lineWidth,
  1929. t_font: ctx_wasd.text_props.font,
  1930. text: ctx_wasd[keys[i]].text,
  1931. opacity: 0.25
  1932. }
  1933. deep_debug(args);
  1934. transparent_rect_fill(
  1935. args.x,
  1936. args.y,
  1937. args.a,
  1938. args.b,
  1939. args.s_c,
  1940. args.f_c,
  1941. args.opacity
  1942. );
  1943. ctx_text(
  1944. args.t_f,
  1945. args.t_s,
  1946. args.t_lineWidth,
  1947. args.t_font,
  1948. args.text,
  1949. args.x+(args.a/2),
  1950. args.y+(args.b/2)
  1951. );
  1952. }
  1953. }
  1954.  
  1955. //Key Binds for Tank Upgrading
  1956. let selected_box = null;
  1957. let _bp = { //box parameters
  1958. startX: 47,
  1959. startY: 67,
  1960. distX: 13,
  1961. distY: 9,
  1962. width: 86,
  1963. height: 86,
  1964. outer_xy: 2
  1965. }
  1966.  
  1967. let _bo = { //box offsets
  1968. offsetX: _bp.width + (_bp.outer_xy * 2) + _bp.distX,
  1969. offsetY: _bp.height + (_bp.outer_xy * 2) + _bp.distY
  1970. }
  1971.  
  1972. function step_offset(steps, offset){
  1973. let final_offset = 0;
  1974. switch(offset){
  1975. case "x":
  1976. final_offset = _bp.startX + (steps * _bo.offsetX);
  1977. break
  1978. case "y":
  1979. final_offset = _bp.startY + (steps * _bo.offsetY);
  1980. break
  1981. }
  1982. return final_offset;
  1983. }
  1984.  
  1985. const boxes = [
  1986. {
  1987. color: "lightblue",
  1988. LUcornerX: _bp.startX,
  1989. LUcornerY: _bp.startY,
  1990. KeyBind: "R"
  1991. },
  1992. {
  1993. color: "green",
  1994. LUcornerX: _bp.startX + _bo.offsetX,
  1995. LUcornerY: _bp.startY,
  1996. KeyBind: "T"
  1997. },
  1998. {
  1999. color: "red",
  2000. LUcornerX: _bp.startX,
  2001. LUcornerY: _bp.startY + _bo.offsetY,
  2002. KeyBind: "F"
  2003. },
  2004. {
  2005. color: "yellow",
  2006. LUcornerX: _bp.startX + _bo.offsetX,
  2007. LUcornerY: _bp.startY + _bo.offsetY,
  2008. KeyBind: "G"
  2009. },
  2010. {
  2011. color: "blue",
  2012. LUcornerX: _bp.startX,
  2013. LUcornerY: step_offset(2, "y"),
  2014. KeyBind: "V"
  2015. },
  2016. {
  2017. color: "purple",
  2018. LUcornerX: _bp.startX + _bo.offsetX,
  2019. LUcornerY: step_offset(2, "y"),
  2020. KeyBind: "B"
  2021. }
  2022. ]
  2023.  
  2024. //upgrading Tank logic
  2025. function upgrade_get_coords(color){
  2026. let l = boxes.length;
  2027. let upgrade_coords = {x: "not defined", y: "not defined"};
  2028. for(let i = 0; i < l; i++){
  2029. if(boxes[i].color === color){
  2030. upgrade_coords.x = dim_c.windowScaling_2_window(boxes[i].LUcornerX + (_bp.width/2));
  2031. upgrade_coords.y = dim_c.windowScaling_2_window(boxes[i].LUcornerY + (_bp.height/2));
  2032. }
  2033. }
  2034. deep_debug(upgrade_coords);
  2035. return upgrade_coords;
  2036. }
  2037.  
  2038. function upgrade(color, delay = 100, cdelay1, cdelay2){
  2039. let u_coords = upgrade_get_coords(color);
  2040. //ghost_click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2);
  2041. click_at('extern', u_coords.x, u_coords.y, cdelay1, cdelay2); //using this since ghost_click was patched
  2042. }
  2043.  
  2044. function visualise_tank_upgrades(){
  2045. let l = boxes.length;
  2046. for (let i = 0; i < l; i++) {
  2047. let coords = upgrade_get_coords(boxes[i].color);
  2048. ctx_text(boxes[i].color, "black", 6, 1.5 + "em Ubuntu", `[${boxes[i].KeyBind}]`, coords.x, coords.y);
  2049. }
  2050. }
  2051.  
  2052. function check_tu_KeyBind(_KeyBind){
  2053. let l = boxes.length;
  2054. for (let i = 0; i < l; i++) {
  2055. if(_KeyBind === `Key${boxes[i].KeyBind}`){
  2056. deep_debug(_KeyBind, `Key${boxes[i].KeyBind}`, _KeyBind === `Key${boxes[i].KeyBind}`);
  2057. upgrade(boxes[i].color);
  2058. }
  2059. }
  2060. }
  2061.  
  2062. document.body.addEventListener("keydown", function(e) {
  2063. switch(e.code){
  2064. case "KeyW":
  2065. ctx_wasd.w.pressed = true;
  2066. break
  2067. case "KeyA":
  2068. ctx_wasd.a.pressed = true;
  2069. break
  2070. case "KeyS":
  2071. ctx_wasd.s.pressed = true;
  2072. break
  2073. case "KeyD":
  2074. ctx_wasd.d.pressed = true;
  2075. break
  2076. }
  2077. check_tu_KeyBind(e.code);
  2078. });
  2079.  
  2080. document.body.addEventListener("keyup", function(e) {
  2081. deep_debug(`unpressed ${e.code}`);
  2082. switch(e.code){
  2083. case "KeyW":
  2084. ctx_wasd.w.pressed = false;
  2085. break
  2086. case "KeyA":
  2087. ctx_wasd.a.pressed = false;
  2088. break
  2089. case "KeyS":
  2090. ctx_wasd.s.pressed = false;
  2091. break
  2092. case "KeyD":
  2093. ctx_wasd.d.pressed = false;
  2094. break
  2095. }
  2096. deep_debug('====DID UNPRESS??', ctx_wasd.w.pressed, ctx_wasd.a.pressed, ctx_wasd.s.pressed, ctx_wasd.d.pressed);
  2097. });
  2098.  
  2099. document.body.addEventListener("mousedown", function(e) {
  2100. switch(e.button){
  2101. case 0:
  2102. ctx_wasd.l_m.pressed = true;
  2103. break
  2104. case 2:
  2105. ctx_wasd.r_m.pressed = true;
  2106. break
  2107. }
  2108. });
  2109.  
  2110. document.body.addEventListener("mouseup", function(e) {
  2111. switch(e.button){
  2112. case 0:
  2113. ctx_wasd.l_m.pressed = false;
  2114. break
  2115. case 2:
  2116. ctx_wasd.r_m.pressed = false;
  2117. break
  2118. }
  2119. });
  2120. //destroyer cooldown visualiser
  2121. let times_watcher = {
  2122. waiting: false,
  2123. cooldowns: [2540, 2311, 2201, 1911, 1760, 1681, 1560, 1381],
  2124. }
  2125.  
  2126. function draw_destroyer_cooldown(){
  2127. let c = times_watcher.waiting? 'red' : 'lime' ;
  2128. ctx_arc(inputs.mouse.real.x, inputs.mouse.real.y, 50*player.dpr, 0, 2 * Math.PI, false, c, 'fill', 0.3);
  2129. }
  2130.  
  2131. function handle_cooldown(_cd){
  2132. times_watcher.waiting = true;
  2133. setTimeout(() => {
  2134. times_watcher.waiting = false;
  2135. }, _cd);
  2136. }
  2137. document.body.addEventListener("mousedown", function(e) {
  2138. if(e.button === 0 && !times_watcher.waiting && player.inGame){
  2139. let _cd = times_watcher.cooldowns[modules.Visual.destroyer_cooldown.settings.reload.selected];
  2140. handle_cooldown(_cd);
  2141. }
  2142. });
  2143.  
  2144. document.body.addEventListener("keydown", function(e){
  2145. if(e.keyCode === 32 && !times_watcher.waiting && player.inGame){
  2146. let _cd = times_watcher.cooldowns[modules.Visual.destroyer_cooldown.settings.reload.selected];
  2147. handle_cooldown(_cd);
  2148. }
  2149. });
  2150.  
  2151. //debug function
  2152. function draw_canvas_debug(){
  2153. let temp_textX = canvas.width/2, temp_textY = canvas.height/2;
  2154. let temp_texts = [
  2155. `Your Real mouse position! x: ${inputs.mouse.real.x} y: ${inputs.mouse.real.y}`,
  2156. `Scaled down for the game! x: ${(inputs.mouse.game.x).toFixed(2)} y: ${(inputs.mouse.game.y).toFixed(2)}`,
  2157. `player values! DPR: ${player.dpr} base value: ${player.base_value} ui scale: ${player.ui_scale}`,
  2158. `window Scaling: ${windowScaling()}`,
  2159. `Canvas! width: ${canvas.width} height: ${canvas.height}`,
  2160. `Window! width: ${window.innerWidth} height: ${window.innerHeight}`,
  2161. `Ratio between Window and Canvas: ${dim_c.window_2_canvas(1)}`
  2162. ];
  2163. let l = temp_texts.length;
  2164. let _d = (canvas.height/3)/l;
  2165. for(let i = 0; i < l; i++){
  2166. ctx_text('yellow', 'black', 5, 1.5 + "em Ubuntu", temp_texts[i], temp_textX, temp_textY + (i * _d));
  2167. }
  2168. //drawing line from your real mouse position, to your ingame mouse position
  2169. ctx.beginPath();
  2170. ctx.strokeStyle = "Red";
  2171. ctx.moveTo(inputs.mouse.real.x, inputs.mouse.real.y);
  2172. ctx.lineTo(inputs.mouse.game.x*player.dpr, inputs.mouse.game.y*player.dpr);
  2173. ctx.stroke();
  2174. }
  2175.  
  2176. //canvas gui (try to keep this in the end
  2177. setTimeout(() => {
  2178. let gui = () => {
  2179. if (player.inGame) {
  2180. //DEBUG start
  2181. if(deep_debug_properties.canvas){
  2182. draw_canvas_debug();
  2183. }
  2184. //DEBUG end
  2185. if(modules.Visual.display_hotkeys.active){
  2186. visualise_tank_upgrades();
  2187. }
  2188. if (modules.Visual.Key_inputs_visualiser.active) {
  2189. visualise_keys();
  2190. }
  2191. if (modules.Visual.destroyer_cooldown.settings.destroyer_cooldown.active){
  2192. draw_destroyer_cooldown();
  2193. }
  2194. }
  2195. window.requestAnimationFrame(gui); // Start animation loop
  2196. };
  2197. gui();
  2198. }, 500); // Delay before starting the rendering