Diep.io+ (Sandbox hacks final version)

autorespawn(auto ad watcher with 2min timer), leader arrow + minimap arrow, FOV & diepUnits & windowScaling() calculator, Factory controls overlay, bullet distance (FOR EVERY BULLET SPEED BUILD) of 75% tanks, copy party link, leave game, no privacy settings button, no apes.io advertisment, net_predict_movement false

当前为 2024-12-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Diep.io+ (Sandbox hacks final version)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.1.4.4
  5. // @description autorespawn(auto ad watcher with 2min timer), leader arrow + minimap arrow, FOV & diepUnits & windowScaling() calculator, Factory controls overlay, bullet distance (FOR EVERY BULLET SPEED BUILD) of 75% tanks, copy party link, leave game, no privacy settings button, no apes.io advertisment, net_predict_movement false
  6. // @author r!PsAw
  7. // @match https://diep.io/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=diep.io
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. //!!!WARNING!!! Ui scale has to be at 0.9x for this script to work//
  14.  
  15. //access all lobbies and servers through built in API and update it
  16. let servers, regions, regionNames;
  17.  
  18. async function s() {
  19. try {
  20. // Fetch data and parse it as JSON
  21. const response = await fetch('https://lb.diep.io/api/lb/pc');
  22. const data = await response.json();
  23.  
  24. // Update the servers variable
  25. servers = data;
  26. regions = data.regions.map(region => region.region);
  27. regionNames = data.regions.map(regionName => regionName.regionName);
  28. } catch (error) {
  29. console.error('Error fetching data:', error);
  30. }
  31. }
  32.  
  33. setInterval(s, 3000);
  34.  
  35. let pt = '';
  36. //store useful info about yourself here
  37. let player = {
  38. unbannable: true, // turn this true, while you're making bannable code
  39. name: "",
  40. last_level: 0,
  41. level: 0,
  42. tank: "",
  43. raw_build: "",
  44. real_time_build: "",
  45. team_index: 0
  46. };
  47.  
  48. //detect if dead or alive & server loaded or not & region
  49. let connected = false;
  50. let state = "idk yet";
  51. let region;
  52.  
  53. function check_state() {
  54. //server loaded?
  55. connected = !!window.lobby_ip;
  56.  
  57. //dead or alive
  58. if(connected){
  59. switch (input.doesHaveTank()) {
  60. case 0:
  61. state = "in menu";
  62. break
  63. case 1:
  64. state = "in game";
  65. break
  66. }
  67.  
  68. //check region
  69. region = document.querySelector("#region-selector > div > div.selected > div.dropdown-label").innerHTML;
  70. console.log(region);
  71. }
  72. }
  73.  
  74. setInterval(check_state, 100);
  75. //
  76.  
  77. //basic function to construct links
  78. function link(baseUrl, lobby, gamemode, team) {
  79. let str = "";
  80. str += baseUrl + "?s=" + lobby + "&g=" + gamemode + "&l=" + team;
  81. return str;
  82. }
  83.  
  84. function get_baseUrl() {
  85. return location.origin + location.pathname;
  86. }
  87.  
  88. function get_your_lobby() {
  89. return window.lobby_ip.split(".")[0];
  90. }
  91.  
  92. function get_gamemode() {
  93. //return window.__common__.active_gamemode;
  94. return window.lobby_gamemode;
  95. }
  96.  
  97. function get_team() {
  98. return window.__common__.party_link;
  99. }
  100.  
  101. //all team links
  102. function get_links(gamemode, lobby, team = get_team()) {
  103. let baseUrl = get_baseUrl();
  104. let colors = ["🔵", "🔴", "🟣", "🟢", "👥❌"];
  105. let final_links = [];
  106. switch (gamemode) {
  107. case "4teams":
  108. for (let i = 0; i < 4; i++) {
  109. final_links.push([colors[i], link(baseUrl, lobby, gamemode, team.split("x")[0] + `x${i}`)]);
  110. }
  111. break
  112. case "teams":
  113. for (let i = 0; i < 2; i++) {
  114. final_links.push([colors[i], link(baseUrl, lobby, gamemode, team.split("x")[0] + `x${i}`)]);
  115. }
  116. break
  117. default:
  118. final_links.push([colors[colors.length - 1], link(baseUrl, lobby, gamemode, team)]);
  119. }
  120. return final_links;
  121. }
  122.  
  123. //working with servers (unfinished)
  124. function find_lobbies(region){
  125. let result;
  126. result = servers.regions[servers.regions.findIndex(item => item.region === region)].lobbies;
  127. return result;
  128. }
  129.  
  130. function ips_to_links(){
  131. if(regions){
  132. let temp_cont = [];
  133. let l1 = regions.length;
  134. for(let i = 0; i < l1; i++){
  135. let current_region = regions[i];
  136. let lobbies_cont = find_lobbies(current_region);
  137. let l2 = lobbies_cont.length;
  138. for(let j = 0; j < l2; j++){
  139. lobbies_cont[j].ip = get_links(lobbies_cont[j].gamemode, lobbies_cont[j].ip.split(".")[0], "0x0");
  140. }
  141. temp_cont.push([regionNames[i], lobbies_cont]);
  142. }
  143. return temp_cont;
  144. }else{
  145. console.log("wait until regions are defined");
  146. }
  147. }
  148.  
  149. function formatAllLinks(regionsData) {
  150. let result = "";
  151.  
  152. for (const [regionName, lobbies] of regionsData) {
  153. result += `${regionName}:\n`; // Add the region name
  154. for (const lobby of lobbies) {
  155. result += ` ${capitalize(lobby.gamemode)}:\n`; // Add the gamemode
  156. for (const [symbol, link] of lobby.ip) {
  157. result += ` ${symbol}: ${link} (${lobby.numPlayers})\n`; // Add each IP entry
  158. }
  159. }
  160. }
  161.  
  162. return result;
  163. }
  164.  
  165. function capitalize(str) {
  166. return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
  167. }
  168.  
  169.  
  170. function copy_links(){
  171. let formattedContent = formatAllLinks(ips_to_links());
  172. navigator.clipboard.writeText(formattedContent);
  173. }
  174.  
  175. //key press functions
  176. const RAW_MAPPING = [
  177. "KeyA",
  178. "KeyB",
  179. "KeyC",
  180. "KeyD",
  181. "KeyE",
  182. "KeyF",
  183. "KeyG",
  184. "KeyH",
  185. "KeyI",
  186. "KeyJ",
  187. "KeyK",
  188. "KeyL",
  189. "KeyM",
  190. "KeyN",
  191. "KeyO",
  192. "KeyP",
  193. "KeyQ",
  194. "KeyR",
  195. "KeyS",
  196. "KeyT",
  197. "KeyU",
  198. "KeyV",
  199. "KeyW",
  200. "KeyX",
  201. "KeyY",
  202. "KeyZ",
  203. "ArrowUp",
  204. "ArrowLeft",
  205. "ArrowDown",
  206. "ArrowRight",
  207. "Tab",
  208. "Enter",
  209. "NumpadEnter",
  210. "ShiftLeft",
  211. "ShiftRight",
  212. "Space",
  213. "Numpad0",
  214. "Numpad1",
  215. "Numpad2",
  216. "Numpad3",
  217. "Numpad4",
  218. "Numpad5",
  219. "Numpad6",
  220. "Numpad7",
  221. "Numpad8",
  222. "Numpad9",
  223. "Digit0",
  224. "Digit1",
  225. "Digit2",
  226. "Digit3",
  227. "Digit4",
  228. "Digit5",
  229. "Digit6",
  230. "Digit7",
  231. "Digit8",
  232. "Digit9",
  233. "F2",
  234. "End",
  235. "Home",
  236. "Semicolon",
  237. "Comma",
  238. "NumpadComma",
  239. "Period",
  240. "Backslash",
  241. ];
  242.  
  243. function key_down(keyString) {
  244. const index = RAW_MAPPING.indexOf(keyString);
  245. if (index === -1) {
  246. console.error(`Invalid key string: ${keyString}`);
  247. return;
  248. }
  249. const result = index + 1; // Add 1 to the index as per your requirement
  250. input.onKeyDown(result);
  251. }
  252.  
  253. function key_up(keyString) {
  254. const index = RAW_MAPPING.indexOf(keyString);
  255. if (index === -1) {
  256. console.error(`Invalid key string: ${keyString}`);
  257. return;
  258. }
  259. const result = index + 1; // Add 1 to the index as per your requirement
  260. input.onKeyUp(result);
  261. }
  262.  
  263. function key_press(keyString, delay=100){
  264. key_down(keyString);
  265. setTimeout(() => {
  266. key_up(keyString)
  267. }, delay);
  268. }
  269.  
  270. //mouse functions
  271. let isFrozen = false;
  272. let shooting = false;
  273. let coords = {x: 0, y: 0};
  274.  
  275. document.onmousemove = function(event) {
  276. coords.x = event.clientX;
  277. coords.y = event.clientY;
  278. if (isFrozen) {
  279. event.stopImmediatePropagation();
  280. //console.log("Mousemove event blocked.");
  281. }
  282. };
  283.  
  284. document.onmousedown = function(event) {
  285. if(toggleButtons.Mouse["Anti Aim"]){
  286. if(shooting){
  287. return;
  288. }
  289. shooting = true;
  290. event.stopImmediatePropagation;
  291. setTimeout(function(){
  292. shooting = false;
  293. mouse_move(coords.x, coords.y);
  294. click_at(coords.x, coords.y);
  295. }, 100);
  296. };
  297. }
  298.  
  299. function handle_mouse_functions(){
  300. window.requestAnimationFrame(handle_mouse_functions);
  301. toggleButtons.Mouse["Freeze Mouse"]?freezeMouseMove():unfreezeMouseMove();
  302. toggleButtons.Mouse["Anti Aim"]?anti_aim("On"):anti_aim("Off");
  303. }
  304. window.requestAnimationFrame(handle_mouse_functions);
  305.  
  306. //anti aim
  307. function detect_corner(){
  308. let w = window.innerWidth;
  309. let h = window.innerHeight;
  310. let center = {
  311. x: w/2,
  312. y: h/2
  313. };
  314. let lr, ud;
  315. coords.x > center.x? lr = "r": lr = "l";
  316. coords.y > center.y? ud = "d": ud = "u";
  317. return lr + ud;
  318. }
  319.  
  320. function look_at_corner(corner){
  321. if(!shooting){
  322. let w = window.innerWidth;
  323. let h = window.innerHeight;
  324. switch(corner) {
  325. case "lu":
  326. anti_aim_at(w, h);
  327. break
  328. case "ld":
  329. anti_aim_at(w, 0);
  330. break
  331. case "ru":
  332. anti_aim_at(0, h);
  333. break
  334. case "rd":
  335. anti_aim_at(0, 0);
  336. break
  337. }
  338. }
  339. }
  340.  
  341. function anti_aim(toggle){
  342. switch (toggle) {
  343. case "On":
  344. if(!toggleButtons.Mouse["Freeze Mouse"]){
  345. freezeMouseMove();
  346. look_at_corner(detect_corner());
  347. }
  348. break
  349. case "Off":
  350. (isFrozen && !toggleButtons.Mouse["Freeze Mouse"])?unfreezeMouseMove():null;
  351. break
  352. }
  353. }
  354.  
  355. // Example: Freeze and unfreeze
  356. function freezeMouseMove() {
  357. isFrozen = true;
  358. //console.log("Mousemove events are frozen.");
  359. }
  360.  
  361. function unfreezeMouseMove() {
  362. isFrozen = false;
  363. //console.log("Mousemove events are active.");
  364. }
  365.  
  366. function click_at(x, y, delay1 = 150, delay2 = 500){
  367. input.onTouchStart(-1, x, y);
  368. setTimeout(() => {
  369. input.onTouchEnd(-1, x, y);
  370. }, delay1);
  371. setTimeout(() => {
  372. shooting = false;
  373. }, delay2);
  374. }
  375.  
  376. function ghost_click_at(x, y, delay1 = 150, delay2 = 500){
  377. input.onTouchStart(0, x, y);
  378. setTimeout(() => {
  379. input.onTouchEnd(0, x, y);
  380. }, delay1);
  381. setTimeout(() => {
  382. shooting = false;
  383. }, delay2);
  384. }
  385.  
  386. function mouse_move(x, y) {
  387. input.onTouchMove(-1, x, y);
  388. }
  389.  
  390. function anti_aim_at(x, y){
  391. if(shooting){
  392. return;
  393. }
  394. mouse_move(x, y);
  395. }
  396.  
  397. //VISUAL TEAM SWITCH
  398. //create container
  399. let team_select_container = document.createElement("div");
  400. team_select_container.classList.add("labelled");
  401. team_select_container.id = "team-selector";
  402. document.querySelector("#server-selector").appendChild(team_select_container);
  403.  
  404. //create Text "Team"
  405. let team_select_label = document.createElement("label");
  406. team_select_label.innerText = "[Diep.io+] Team (beta)";
  407. team_select_label.style.color = "purple";
  408. team_select_label.style.backgroundColor = "black";
  409. team_select_container.appendChild(team_select_label);
  410.  
  411. //create Selector
  412. let team_select_selector = document.createElement("div");
  413. team_select_selector.classList.add("selector");
  414. team_select_container.appendChild(team_select_selector);
  415.  
  416. //create placeholder "Choose Team"
  417. let teams_visibility = true;
  418. let ph_div = document.createElement("div");
  419. let ph_text_div = document.createElement("div");
  420. let sel_state;
  421. ph_text_div.classList.add("dropdown-label");
  422. ph_text_div.innerHTML = "Choose Team";
  423. ph_div.style.backgroundColor = "gray";
  424. ph_div.classList.add("selected");
  425. ph_div.addEventListener("click", () => {
  426. //toggle Team List
  427. toggle_team_list(teams_visibility);
  428. teams_visibility = !teams_visibility;
  429. });
  430.  
  431. team_select_selector.appendChild(ph_div);
  432. ph_div.appendChild(document.createElement("div"));
  433. ph_div.appendChild(ph_text_div);
  434.  
  435. // Create refresh button
  436. let refresh_btn = document.createElement("button");
  437. refresh_btn.style.width = "30%";
  438. refresh_btn.style.height = "10%";
  439. refresh_btn.style.backgroundColor = "black";
  440. refresh_btn.textContent = "Refresh";
  441.  
  442. refresh_btn.onclick = () => {
  443. remove_previous_teams();
  444. links_to_teams_GUI_convert();
  445. };
  446.  
  447. team_select_container.appendChild(refresh_btn);
  448.  
  449. //create actual teams
  450. let team_values = [];
  451.  
  452. function create_team_div(text, color, link) {
  453. team_values.push(text);
  454. let team_div = document.createElement("div");
  455. let text_div = document.createElement("div");
  456. let sel_state;
  457. text_div.classList.add("dropdown-label");
  458. text_div.innerHTML = text;
  459. team_div.style.backgroundColor = color;
  460. team_div.classList.add("unselected");
  461. team_div.value = text;
  462. team_div.addEventListener("click", () => {
  463. const answer = confirm("You're about to open the link in a new tab, do you want to continue?");
  464. if (answer) {
  465. window.open(link, "_blank");
  466. }
  467. });
  468.  
  469. team_select_selector.appendChild(team_div);
  470. team_div.appendChild(document.createElement("div"));
  471. team_div.appendChild(text_div);
  472. }
  473.  
  474. function toggle_team_list(boolean) {
  475. if (boolean) {
  476. //true
  477. team_select_selector.classList.remove("selector");
  478. team_select_selector.classList.add("selector-active");
  479. } else {
  480. //false
  481. team_select_selector.classList.remove("selector-active");
  482. team_select_selector.classList.add("selector");
  483. }
  484. }
  485.  
  486. //example
  487. //create_team_div("RedTeam", "Red", "https://diep.io/");
  488. //create_team_div("OrangeTeam", "Orange", "https://diep.io/");
  489. //create_team_div("YellowTeam", "Yellow", "https://diep.io/");
  490. function links_to_teams_GUI_convert() {
  491. let gamemode = get_gamemode();
  492. let lobby = get_your_lobby();
  493. let links = get_links(gamemode, lobby);
  494. let team_names = ["Team-Blue", "Team-Red", "Team-Purple", "Team-Green", "Teamless-Gamemode"];
  495. let team_colors = ["blue", "red", "purple", "green", "orange"];
  496. for (let i = 0; i < links.length; i++) {
  497. !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]);
  498. }
  499. }
  500.  
  501. function remove_previous_teams() {
  502. for (let i = team_select_selector.childNodes.length - 1; i >= 0; i--) {
  503. console.log(team_select_selector);
  504. let child = team_select_selector.childNodes[i];
  505. if (child.nodeType === Node.ELEMENT_NODE && child.innerText !== "Choose Team") {
  506. child.remove();
  507. }
  508. }
  509. }
  510.  
  511.  
  512. function wait_For_Link() {
  513. if (window.__common__.party_link === '') {
  514. setTimeout(() => {
  515. console.log("LOADING...");
  516. wait_For_Link();
  517. }, 100);
  518. } else {
  519. console.log("link loaded!");
  520. remove_previous_teams();
  521. links_to_teams_GUI_convert();
  522. }
  523. }
  524.  
  525. wait_For_Link();
  526.  
  527. //create ingame Notifications
  528. function rgbToNumber(r, g, b) {
  529. return (r << 16) | (g << 8) | b;
  530. }
  531. const notification_rbgs = {
  532. require: [255, 165, 0], //orange
  533. warning: [255, 0, 0], //red
  534. normal: [0, 0, 128] //blue
  535. }
  536.  
  537. let notifications = [];
  538.  
  539. function new_notification(text, color, duration) {
  540. input.inGameNotification(text, color, duration);
  541. }
  542.  
  543. function one_time_notification(text, color, duration){
  544. if(notifications.includes(text)){
  545. return;
  546. }
  547. if(state === "in menu"){
  548. notifications = [];
  549. }
  550. if(state === "in game"){
  551. new_notification(text, color, duration);
  552. notifications.push(text);
  553. }
  554. }
  555.  
  556. //auto ui scale = 0.9x
  557. var ui_scale = parseFloat(localStorage.getItem("d:ui_scale"));
  558.  
  559. function correct_ui_scale() {
  560. ui_scale = parseFloat(localStorage.getItem("d:ui_scale"));
  561. new_notification(`invalid UI scale detected! ${ui_scale}`, rgbToNumber(...notification_rbgs.warning), 10000);
  562. localStorage.setItem("d:ui_scale", 0.9);
  563. new_notification("Automatically changed to 0.9 for Diep.io+ :)", rgbToNumber(...notification_rbgs.normal), 10000);
  564. ui_scale = parseFloat(localStorage.getItem("d:ui_scale"));
  565. }
  566.  
  567. function update_scale_option(selector, label, min, max) {
  568. let element = document.querySelector(selector);
  569. let label_element = element.closest("div").querySelector("span");
  570. label_element.innerHTML = `[DIEP.IO+] ${label}`;
  571. label_element.style.background = "black";
  572. label_element.style.color = "purple";
  573. element.min = min;
  574. element.max = max;
  575. }
  576.  
  577. function new_ranges_for_scales() {
  578. update_scale_option("#subsetting-option-ui_scale", "UI Scale", '0.01', '1000');
  579. update_scale_option("#subsetting-option-border_radius", "UI Border Radius", '0.01', '1000');
  580. update_scale_option("#subsetting-option-border_intensity", "UI Border Intensity", '0.01', '1000');
  581. }
  582.  
  583. new_ranges_for_scales();
  584.  
  585.  
  586. function ui_scale_check() {
  587. if (homescreen.classList.contains("screen") && homescreen.classList.contains("active")) {
  588. if (ui_scale != 0.9) {
  589. //new_notification("please change your ui_scale to 0.9x in Menu -> Settings", rgbToNumber(...notification_rbgs.warning), 10000);
  590. correct_ui_scale();
  591. } else {
  592. console.log("no alert");
  593. }
  594. clearInterval(interval_for_ui_scale);
  595. }
  596. }
  597. let interval_for_ui_scale = setInterval(ui_scale_check, 100);
  598.  
  599. //string generator
  600. function newString(length) {
  601. let final_result = "";
  602. let chars =
  603. "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=/.,".split(
  604. ""
  605. );
  606. for (let i = 0; i < length; i++) {
  607. final_result += chars[Math.floor(Math.random() * chars.length)];
  608. }
  609. return final_result;
  610. }
  611.  
  612. //encryption
  613. function convert_numeric(number, from, to) {
  614. return parseInt(number, from).toString(to);
  615. }
  616.  
  617. let ls_cnfgs = new Map();
  618. let _names = ["banned", "nickname", "gui", "player_token", "console", "addons", "last_gm"];
  619. _names.forEach((name, index) => {
  620. ls_cnfgs.set(name, index + 3);
  621. });
  622.  
  623. let els_args = new Uint8Array([3, 10, 16]);
  624.  
  625. function els(type) {
  626. return convert_numeric(Math.pow(ls_cnfgs.get(type), els_args[0]), els_args[1], els_args[2]);
  627. }
  628. //
  629. function aYsGH() {
  630. let ytS = "d:nas_logged_in";
  631. localStorage.getItem(ytS) === null ? localStorage.setItem(ytS, true) : localStorage.getItem(`[Diep.io+] ${els('nickname')}`) === null ? HdSoyr_() : null;
  632. IjHGfoas();
  633. ASgddisfPAW();
  634. }
  635.  
  636. const originalRemoveItem = localStorage.removeItem;
  637.  
  638. localStorage.removeItem = function(key) {
  639. if (key.includes("[Diep.io+]" && !player.unbannable)) {
  640. //crash();
  641. alert("you tried removing [Diep.io+] from localStorage");
  642. }
  643. originalRemoveItem.call(this, key);
  644. };
  645.  
  646. function IjHGfoas() {
  647. let str = localStorage.getItem(`[Diep.io+] ${els('nickname')}`);
  648. const keywords = /o2|NX|Ponyo|rbest|c8|Sprunk/i;
  649.  
  650. if (keywords.test(str) && !player.unbannable) {
  651. //crash(str);
  652. alert(`${str} is not allowed to use Diep.io+`);
  653. }
  654. }
  655.  
  656. function ASgddisfPAW() {
  657. let SfsaAG = localStorage.getItem(`[Diep.io+] ${els('player_token')}`);
  658. SfsaAG === null ? localStorage.setItem(`[Diep.io+] ${els('player_token')}`, newString(25)) : pt = SfsaAG;
  659. pt = localStorage.getItem(`[Diep.io+] ${els('player_token')}`);
  660. }
  661.  
  662. aYsGH();
  663. //
  664. let homescreen = document.getElementById("home-screen");
  665. let ingamescreen = document.getElementById("in-game-screen");
  666. let gameOverScreen = document.getElementById('game-over-screen');
  667. let gameOverScreenContainer = document.querySelector("#game-over-screen > div > div.game-details > div:nth-child(1)");
  668.  
  669. function u_ln() {
  670. if (state === "in game") {
  671. player.name = window.localStorage["d:last_spawn_name"];
  672. localStorage.setItem(`[Diep.io+] ${els('nickname')}`, player.name);
  673. }
  674. //get your team index
  675. player.team_index = parseFloat(get_team().split("x")[1]);
  676. }
  677. setInterval(u_ln, 500);
  678. let new_FOVs = [
  679. {
  680. name: "Tank",
  681. fieldFactor: 1,
  682. FOV: null
  683. },
  684. {
  685. name: "Sniper",
  686. fieldFactor: 0.899,
  687. FOV: null
  688. },
  689. {
  690. name: "Predator",
  691. fieldFactor: 0.85,
  692. FOV: null
  693. },
  694. {
  695. name: "Assassin",
  696. fieldFactor: 0.8,
  697. FOV: null
  698. },
  699. {
  700. name: "Ranger",
  701. fieldFactor: 0.699,
  702. FOV: null
  703. },
  704. {
  705. name: "Ranger+",
  706. fieldFactor: 0.599,
  707. FOV: null
  708. },
  709. {
  710. name: "Background",
  711. FOV: 0.3499999940395355
  712. }
  713. ]
  714.  
  715. //config for sandbox hacks
  716. let triflank = false;
  717. let sandbox_hax_modes = [{
  718. name: "Trap Flip",
  719. tank: "Gunner Trapper",
  720. color: "green",
  721. unique: true
  722. }, {
  723. name: "Shotgun",
  724. tank: ["Triple Shot", "Triplet"],
  725. color: "lightblue",
  726. unique: true
  727. }, {
  728. name: "Trapper Spam",
  729. tank: "Gunner Trapper",
  730. color: "green",
  731. unique: false
  732. }, {
  733. name: "Triflank",
  734. tank: "Tri-Angle",
  735. color: "lightblue",
  736. unique: false
  737. }, {
  738. name: "Twin spam",
  739. tank: "Twin",
  740. color: "lightblue",
  741. unique: false
  742. }, {
  743. name: "DeathStar",
  744. tank: "Octo Tank",
  745. color: "lightblue",
  746. unique: false
  747. }, {
  748. name: "Mega spam",
  749. tank: "Mega Trapper",
  750. color: "yellow",
  751. unique: false
  752. }, {
  753. name: "Bomber",
  754. tank: "Destroyer",
  755. color: "lightblue",
  756. unique: false
  757. }];
  758. let sandbox_hax_index = 0;
  759.  
  760. //moved leader arrow script here
  761. window.choose_color = "#000000";
  762. window.arrowv2_debug = false;
  763. function windowScaling() {
  764. const a = canvas.height / 1080;
  765. const b = canvas.width / 1920;
  766. return b < a ? a : b;
  767. }
  768.  
  769. //credits to mi300
  770. const ARENA_WIDTH = 26000;
  771. const ARENA_HEIGHT = 26000;
  772. let playerPos = [0, 0];
  773. function hook(target, callback){
  774.  
  775. function check(){
  776. window.requestAnimationFrame(check)
  777.  
  778. const func = CanvasRenderingContext2D.prototype[target]
  779.  
  780. if(func.toString().includes(target)){
  781.  
  782. CanvasRenderingContext2D.prototype[target] = new Proxy (func, {
  783. apply (method, thisArg, args) {
  784. callback(thisArg, args)
  785.  
  786. return Reflect.apply (method, thisArg, args)
  787. }
  788. });
  789. }
  790. }
  791. window.requestAnimationFrame(check)
  792. }
  793.  
  794. function getPlayerPos(){
  795. const dX = minimapArrow[0] - minimapPos[0];
  796. const dY = minimapArrow[1] - minimapPos[1];
  797.  
  798. const x = (dX / minimapDim[0]) * ARENA_WIDTH;
  799. const y = (dY / minimapDim[1]) * ARENA_HEIGHT;
  800.  
  801. return [x, y]
  802. }
  803.  
  804. function main(){
  805. window.requestAnimationFrame(main)
  806. playerPos = getPlayerPos();
  807. }
  808. window.requestAnimationFrame(main)
  809.  
  810. let minimapArrow = [0, 0];
  811. let square_pos = [0, 0]
  812. let leaderArrow = [0, 0];
  813. let minimapPos = [0, 0];
  814. let minimapDim = [0, 0];
  815.  
  816. let calls = 0;
  817. let points = [];
  818.  
  819. hook('beginPath', function(thisArg, args){
  820. calls = 1;
  821. points = [];
  822. });
  823. hook('moveTo', function(thisArg, args){
  824. if (calls == 1) {
  825. calls+=1;
  826. points.push(args)
  827. } else {
  828. calls = 0;
  829. }
  830. });
  831. hook('lineTo', function(thisArg, args){
  832. if (calls >= 2 && calls <= 6) {
  833. calls+=1;
  834. points.push(args)
  835. } else {
  836. calls = 0;
  837. }
  838. });
  839.  
  840.  
  841. function getCentre(vertices) {
  842. let centre = [0, 0];
  843. vertices.forEach (vertex => {
  844. centre [0] += vertex[0]
  845. centre [1] += vertex[1]
  846. });
  847. centre[0] /= vertices.length;
  848. centre[1] /= vertices.length;
  849. return centre;
  850. }
  851.  
  852. hook('fill', function(thisArg, args){
  853. if(calls >= 4 && calls <= 6) {
  854. if(thisArg.fillStyle === "#000000" && thisArg.globalAlpha > 0.9){
  855. minimapArrow = getCentre(points);
  856. window.M_X = minimapArrow[0];
  857. window.M_Y = minimapArrow[1];
  858. square_pos = [minimapArrow[0]-(12.5*windowScaling()), minimapArrow[1]-(7*windowScaling())];
  859. return;
  860. }else if(thisArg.fillStyle === "#000000" && thisArg.globalAlpha === 0.3499999940395355 || thisArg.fillStyle === window.choose_color && thisArg.globalAlpha === 0.3499999940395355){
  861. thisArg.fillStyle = window.choose_color;
  862. leaderArrow = getCentre(points);
  863. window.L_X = leaderArrow[0];
  864. window.L_Y = leaderArrow[1];
  865. return;
  866. }
  867. } else {
  868. calls = 0;
  869. }
  870. });
  871. /*
  872. hook('fill', function(thisArg, args){
  873. if(calls >= 4 && calls <= 6) {
  874. if(thisArg.fillStyle === "#000000"){
  875. thisArg.globalAlpha = 0.3499999940395355;
  876. }
  877. } else {
  878. calls = 0;
  879. }
  880. });
  881. */
  882.  
  883. hook('strokeRect', function(thisArg, args) {
  884. const t = thisArg.getTransform();
  885. minimapPos = [t.e, t.f];
  886. minimapDim = [t.a, t.d];
  887. });
  888.  
  889. const ctx = canvas.getContext('2d');
  890. function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c) {
  891. ctx.beginPath();
  892. ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
  893. ctx.fillStyle = c;
  894. ctx.fill();
  895. }
  896.  
  897. function draw_arrow(x, y, c) {
  898. ctx_arc(x, y, 2, 0, 2 * Math.PI, false, c);
  899. }
  900.  
  901. function draw_viewport(){
  902. ctx.beginPath();
  903. ctx.stokeStyle = "black";
  904. ctx.lineWidth = 0.5;
  905. ctx.strokeRect(square_pos[0], square_pos[1], 25*windowScaling(), 14*windowScaling());
  906. ctx.stroke();
  907. }
  908.  
  909. setTimeout(() => {
  910. let gui = () => {
  911. if(window.arrowv2_debug){
  912. draw_arrow(minimapArrow[0], minimapArrow[1], "lime");
  913. draw_viewport();
  914. draw_arrow(leaderArrow[0], leaderArrow[1], "pink");
  915. draw_arrow(minimapPos[0], minimapPos[1], "purple");
  916. }
  917. window.requestAnimationFrame(gui);
  918. };
  919. gui();
  920. setTimeout(() => {
  921. gui();
  922. }, 5000);
  923. }, 1000);
  924.  
  925. //GUI
  926. const container = document.createElement('div');
  927. container.style.position = 'fixed';
  928. container.style.top = '10px';
  929. container.style.left = '75px';
  930. container.style.padding = '15px';
  931. container.style.backgroundImage = 'linear-gradient(#ffffff, #79c7ff)';
  932. container.style.color = 'white';
  933. container.style.borderRadius = '10px';
  934. container.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
  935. container.style.minWidth = '200px';
  936. container.style.zIndex = '10';
  937.  
  938. container.addEventListener('mouseover', () => {
  939. input.execute('ren_upgrades false');
  940. });
  941.  
  942. container.addEventListener('mouseout', () => {
  943. input.execute('ren_upgrades true');
  944. });
  945.  
  946. const title = document.createElement('h1');
  947. title.textContent = 'Diep.io+ (hide with J)';
  948. title.style.margin = '0 0 5px 0';
  949. title.style.fontSize = '24px';
  950. title.style.textAlign = 'center';
  951. title.style.color = '#fb2a7b';
  952. title.style.zIndex = '11';
  953. container.appendChild(title);
  954.  
  955. const subtitle = document.createElement('h3');
  956. subtitle.textContent = 'made by r!PsAw';
  957. subtitle.style.margin = '0 0 15px 0';
  958. subtitle.style.fontSize = '14px';
  959. subtitle.style.textAlign = 'center';
  960. subtitle.style.color = '#6fa8dc';
  961. subtitle.style.zIndex = '11';
  962. container.appendChild(subtitle);
  963.  
  964. const categories = ['Debug', 'Visual', 'Functional', 'Mouse', 'Addons'];
  965. const categoryButtons = {};
  966. const categoryContainer = document.createElement('div');
  967. categoryContainer.style.display = 'flex';
  968. categoryContainer.style.justifyContent = 'space-between';
  969. categoryContainer.style.marginBottom = '15px';
  970. categoryContainer.style.zIndex = '12';
  971.  
  972. categories.forEach(category => {
  973. const button = document.createElement('button');
  974. button.textContent = category;
  975. button.style.flex = '1';
  976. button.style.padding = '8px';
  977. button.style.margin = '0 5px';
  978. button.style.cursor = 'pointer';
  979. button.style.border = 'none';
  980. button.style.borderRadius = '5px';
  981. button.style.backgroundColor = '#fb2a7b';
  982. button.style.color = 'white';
  983. button.style.transition = 'background-color 0.3s';
  984. button.style.zIndex = '13';
  985.  
  986. button.addEventListener('mouseover', () => {
  987. button.style.backgroundColor = '#0000ff';
  988. });
  989. button.addEventListener('mouseout', () => {
  990. button.style.backgroundColor = '#fb2a7b';
  991. });
  992.  
  993. categoryContainer.appendChild(button);
  994. categoryButtons[category] = button;
  995. });
  996.  
  997. container.appendChild(categoryContainer);
  998.  
  999. const contentArea = document.createElement('div');
  1000. contentArea.style.marginTop = '15px';
  1001. contentArea.style.zIndex = '12';
  1002. container.appendChild(contentArea);
  1003.  
  1004. let FOVindex = 0;
  1005. let toggleButtons = {
  1006. Debug: {
  1007. 'Toggle Text': false,
  1008. 'Toggle Middle Circle': false,
  1009. 'Toggle Upgrades': false,
  1010. 'Toggle Arrow pos': false
  1011. },
  1012. Visual: {
  1013. 'Change Leader Arrow Color': '#000000',
  1014. 'Toggle Aim Lines': false,
  1015. 'Toggle Bullet Distance': false,
  1016. 'Toggle Minimap': true,
  1017. 'Toggle Leader Angle': false,
  1018. 'Highlight Leader Score': false
  1019. },
  1020. Functional: {
  1021. 'Auto Respawn': false,
  1022. 'Auto Bonus Level': false,
  1023. 'Toggle Leave Button': false,
  1024. 'Toggle Base Zones': false,
  1025. 'Toggle Level Seeker': false,
  1026. 'Stats': false,
  1027. },
  1028. Mouse: {
  1029. // 'Flipfire': false,
  1030. 'Anti Aim': false,
  1031. 'Freeze Mouse': false,
  1032. 'Sandbox Hacks': false,
  1033. 'Switch Name': null
  1034. },
  1035. Addons: {
  1036. 'FOV changer': false,
  1037. 'selected': null
  1038. }
  1039. };
  1040.  
  1041. function saveSettings() {
  1042. localStorage.setItem(`[Diep.io+] ${els('gui')}`, JSON.stringify({
  1043. toggleButtons: toggleButtons,
  1044. FOVindex: FOVindex
  1045. }));
  1046. }
  1047.  
  1048. /*
  1049. function loadSettings() {
  1050. try {
  1051. const savedData = localStorage.getItem(`[Diep.io+] ${els('gui')}`);
  1052. if (savedData) {
  1053. const parsed = JSON.parse(savedData);
  1054. if (parsed.toggleButtons) {
  1055. // Merge saved settings with default settings to handle new options
  1056. categories.forEach(category => {
  1057. toggleButtons[category] = {
  1058. ...toggleButtons[category], // Keep default values
  1059. ...parsed.toggleButtons[category] // Override with saved values
  1060. };
  1061. });
  1062. }
  1063. if (typeof parsed.FOVindex === 'number') {
  1064. FOVindex = parsed.FOVindex;
  1065. }
  1066. }
  1067. } catch (error) {
  1068. console.error('Error loading settings:', error);
  1069. }
  1070. }
  1071. */
  1072.  
  1073. function createToggleButton(text, initialState) {
  1074. const button = document.createElement('button');
  1075. if (text.startsWith('selected')) {
  1076. button.textContent = `selected ${new_FOVs[FOVindex].name}`;
  1077. } else if(text.startsWith('Switch Name')){
  1078. button.textContent = `Switch Name ${sandbox_hax_modes[sandbox_hax_index].name}`;
  1079. }else{
  1080. button.textContent = text;
  1081. }
  1082. button.style.display = 'block';
  1083. button.style.width = '100%';
  1084. button.style.marginBottom = '10px';
  1085. button.style.padding = '8px';
  1086. button.style.cursor = 'pointer';
  1087. button.style.border = 'none';
  1088. button.style.borderRadius = '5px';
  1089. button.style.transition = 'background-color 0.3s';
  1090. button.style.zIndex = '13';
  1091. if (text.startsWith('selected')) {
  1092. button.style.backgroundColor = '#7a143b';
  1093. button.style.color = 'white';
  1094. button.addEventListener('click', () => {
  1095. let l = new_FOVs.length;
  1096. if (FOVindex < l - 1) {
  1097. FOVindex += 1;
  1098. } else {
  1099. FOVindex = 0;
  1100. }
  1101. button.textContent = `selected ${new_FOVs[FOVindex].name}`;
  1102. saveSettings();
  1103. });
  1104. } else if(text.startsWith('Switch Name')){
  1105. button.style.backgroundColor = '#7a143b';
  1106. button.style.color = 'white';
  1107. button.addEventListener('click', () => {
  1108. let l = sandbox_hax_modes.length;
  1109. if (sandbox_hax_index < l - 1) {
  1110. sandbox_hax_index += 1;
  1111. } else {
  1112. sandbox_hax_index = 0;
  1113. }
  1114. button.textContent = `Switch Name ${sandbox_hax_modes[sandbox_hax_index].name}`;
  1115. saveSettings();
  1116. });
  1117. }else if (text === 'Change Leader Arrow Color') {
  1118. updateButtonColor(button, initialState);
  1119. button.addEventListener('click', () => {
  1120. const colorPicker = document.createElement('input');
  1121. colorPicker.type = 'color';
  1122. colorPicker.value = toggleButtons[currentCategory][text];
  1123. colorPicker.style.display = 'none';
  1124. document.body.appendChild(colorPicker);
  1125.  
  1126. colorPicker.addEventListener('change', (event) => {
  1127. const newColor = event.target.value;
  1128. toggleButtons[currentCategory][text] = newColor;
  1129. updateButtonColor(button, newColor);
  1130. document.body.removeChild(colorPicker);
  1131. saveSettings();
  1132. });
  1133.  
  1134. colorPicker.click();
  1135. });
  1136. }else {
  1137. updateButtonColor(button, initialState);
  1138. button.addEventListener('click', () => {
  1139. toggleButtons[currentCategory][text] = !toggleButtons[currentCategory][text];
  1140. updateButtonColor(button, toggleButtons[currentCategory][text]);
  1141. saveSettings();
  1142. });
  1143. }
  1144.  
  1145. return button;
  1146. }
  1147.  
  1148. //loadSettings();
  1149.  
  1150. function updateButtonColor(button, state) {
  1151. if (typeof state === 'string') {
  1152. // For color picker button
  1153. button.style.backgroundColor = state;
  1154. window.choose_color = state;
  1155. button.style.color = 'white';
  1156. } else {
  1157. // For toggle buttons
  1158. if (state) {
  1159. button.style.backgroundColor = '#63a5d4';
  1160. button.style.color = 'white';
  1161. } else {
  1162. button.style.backgroundColor = '#a11a4e';
  1163. button.style.color = 'white';
  1164. }
  1165. }
  1166. }
  1167.  
  1168. let currentCategory = '';
  1169. let modes = ["in-game", "awaiting-spawn", "game-over"];
  1170. let selected_index = 0;
  1171. let button2_state = false;
  1172. let intervalId = null;
  1173.  
  1174. function showCategory(category) {
  1175. contentArea.innerHTML = '';
  1176. currentCategory = category;
  1177.  
  1178. Object.keys(categoryButtons).forEach(cat => {
  1179. if (cat === category) {
  1180. categoryButtons[cat].style.backgroundColor = '#0000ff';
  1181. } else {
  1182. categoryButtons[cat].style.backgroundColor = '#fb2a7b';
  1183. }
  1184. });
  1185.  
  1186. if (category === 'Functional') {
  1187. const copyLinkButton = document.createElement('button');
  1188. copyLinkButton.textContent = 'Copy Party Link';
  1189. copyLinkButton.style.display = 'block';
  1190. copyLinkButton.style.width = '100%';
  1191. copyLinkButton.style.marginBottom = '10px';
  1192. copyLinkButton.style.padding = '8px';
  1193. copyLinkButton.style.cursor = 'pointer';
  1194. copyLinkButton.style.border = 'none';
  1195. copyLinkButton.style.borderRadius = '5px';
  1196. copyLinkButton.style.backgroundColor = '#2196F3';
  1197. copyLinkButton.style.color = 'white';
  1198. copyLinkButton.style.transition = 'background-color 0.3s';
  1199. copyLinkButton.style.zIndex = '13';
  1200.  
  1201. copyLinkButton.addEventListener('mouseover', () => {
  1202. copyLinkButton.style.backgroundColor = '#1E88E5';
  1203. });
  1204. copyLinkButton.addEventListener('mouseout', () => {
  1205. copyLinkButton.style.backgroundColor = '#2196F3';
  1206. });
  1207.  
  1208. copyLinkButton.addEventListener('click', () => {
  1209. document.getElementById("copy-party-link").click();
  1210. });
  1211.  
  1212. const copyLinksButton = document.createElement('button');
  1213. copyLinksButton.textContent = 'Copy All Links';
  1214. copyLinksButton.style.display = 'block';
  1215. copyLinksButton.style.width = '100%';
  1216. copyLinksButton.style.marginBottom = '10px';
  1217. copyLinksButton.style.padding = '8px';
  1218. copyLinksButton.style.cursor = 'pointer';
  1219. copyLinksButton.style.border = 'none';
  1220. copyLinksButton.style.borderRadius = '5px';
  1221. copyLinksButton.style.backgroundColor = '#2196F3';
  1222. copyLinksButton.style.color = 'white';
  1223. copyLinksButton.style.transition = 'background-color 0.3s';
  1224. copyLinksButton.style.zIndex = '13';
  1225.  
  1226. copyLinksButton.addEventListener('mouseover', () => {
  1227. copyLinksButton.style.backgroundColor = '#1E88E5';
  1228. });
  1229. copyLinksButton.addEventListener('mouseout', () => {
  1230. copyLinksButton.style.backgroundColor = '#2196F3';
  1231. });
  1232.  
  1233. copyLinksButton.addEventListener('click', () => {
  1234. copy_links();
  1235. });
  1236.  
  1237. const copyInfoButton = document.createElement('button');
  1238. copyInfoButton.textContent = 'Copy Info';
  1239. copyInfoButton.style.display = 'block';
  1240. copyInfoButton.style.width = '100%';
  1241. copyInfoButton.style.marginBottom = '10px';
  1242. copyInfoButton.style.padding = '8px';
  1243. copyInfoButton.style.cursor = 'pointer';
  1244. copyInfoButton.style.border = 'none';
  1245. copyInfoButton.style.borderRadius = '5px';
  1246. copyInfoButton.style.backgroundColor = '#2196F3';
  1247. copyInfoButton.style.color = 'white';
  1248. copyInfoButton.style.transition = 'background-color 0.3s';
  1249. copyInfoButton.style.zIndex = '13';
  1250.  
  1251. copyInfoButton.addEventListener('mouseover', () => {
  1252. copyInfoButton.style.backgroundColor = '#1E88E5';
  1253. });
  1254. copyInfoButton.addEventListener('mouseout', () => {
  1255. copyInfoButton.style.backgroundColor = '#2196F3';
  1256. });
  1257.  
  1258. copyInfoButton.addEventListener('click', () => {
  1259. get_info();
  1260. });
  1261.  
  1262. contentArea.appendChild(copyLinkButton);
  1263. contentArea.appendChild(copyLinksButton);
  1264. contentArea.appendChild(copyInfoButton);
  1265.  
  1266. const newButtonsContainer = document.createElement('div');
  1267. newButtonsContainer.style.display = 'flex';
  1268. newButtonsContainer.style.justifyContent = 'space-between';
  1269. newButtonsContainer.style.marginBottom = '10px';
  1270.  
  1271. const button1 = document.createElement('button');
  1272. button1.textContent = modes[selected_index];
  1273. button1.style.flex = '1';
  1274. button1.style.marginRight = '5px';
  1275. button1.style.padding = '8px';
  1276. button1.style.cursor = 'pointer';
  1277. button1.style.border = 'none';
  1278. button1.style.borderRadius = '5px';
  1279. button1.style.backgroundColor = '#2196F3';
  1280. button1.style.color = 'white';
  1281. button1.style.transition = 'background-color 0.3s';
  1282.  
  1283. button1.addEventListener('mouseover', () => {
  1284. button1.style.backgroundColor = '#1E88E5';
  1285. });
  1286. button1.addEventListener('mouseout', () => {
  1287. button1.style.backgroundColor = '#2196F3';
  1288. });
  1289. button1.addEventListener('click', () => {
  1290. selected_index = (selected_index + 1) % modes.length;
  1291. button1.textContent = modes[selected_index];
  1292. });
  1293.  
  1294. // Button 2: Toggle loop
  1295. const button2 = document.createElement('button');
  1296. button2.textContent = 'Start Loop';
  1297. button2.style.flex = '1';
  1298. button2.style.marginLeft = '5px';
  1299. button2.style.padding = '8px';
  1300. button2.style.cursor = 'pointer';
  1301. button2.style.border = 'none';
  1302. button2.style.borderRadius = '5px';
  1303. button2.style.backgroundColor = '#f44336';
  1304. button2.style.color = 'white';
  1305. button2.style.transition = 'background-color 0.3s';
  1306.  
  1307. button2.addEventListener('click', () => {
  1308. button2_state = !button2_state;
  1309. if (button2_state) {
  1310. button2.textContent = 'Stop Loop';
  1311. button2.style.backgroundColor = '#4CAF50';
  1312. intervalId = setInterval(() => {
  1313. window.__common__.screen_state = modes[selected_index];
  1314. }, 100); // Adjust the interval as needed
  1315. } else {
  1316. button2.textContent = 'Start Loop';
  1317. button2.style.backgroundColor = '#f44336';
  1318. if (intervalId !== null) {
  1319. clearInterval(intervalId);
  1320. intervalId = null;
  1321. }
  1322. }
  1323. });
  1324.  
  1325. newButtonsContainer.appendChild(button1);
  1326. newButtonsContainer.appendChild(button2);
  1327. contentArea.appendChild(newButtonsContainer);
  1328. }
  1329.  
  1330. Object.keys(toggleButtons[category]).forEach(text => {
  1331. const button = createToggleButton(text, toggleButtons[category][text]);
  1332. contentArea.appendChild(button);
  1333. });
  1334. }
  1335.  
  1336. Object.keys(categoryButtons).forEach(category => {
  1337. categoryButtons[category].addEventListener('click', () => showCategory(category));
  1338. });
  1339.  
  1340. document.body.appendChild(container);
  1341.  
  1342. //you can't use my script >:(
  1343. function waitForInput(callback, checkInterval = 100, timeout = 10000) {
  1344. const startTime = Date.now();
  1345.  
  1346. function checkInput() {
  1347. if (typeof input !== 'undefined' && input && input.try_spawn) {
  1348. callback();
  1349. } else if (Date.now() - startTime < timeout) {
  1350. setTimeout(checkInput, checkInterval);
  1351. }
  1352. }
  1353.  
  1354. checkInput();
  1355. }
  1356.  
  1357. function crash(name) {
  1358. if(player.unbannable){
  1359. console.log("canceled crash");
  1360. return;
  1361. }
  1362. let nn = typeof name === "undefined" ? window.localStorage.getItem("d:last_spawn_name") : name;
  1363. alert(`${nn} is blacklisted from using Diep.io+, crashing...`);
  1364. localStorage.setItem(`[Diep.io+] ${els('banned')}`, true);
  1365. localStorage.setItem(`[Diep.io+] ${els('nickname')}`, nn);
  1366. while (true) {}
  1367. }
  1368.  
  1369. function HdSoyr_() {
  1370. if(player.unbannable){
  1371. return;
  1372. }
  1373. //crash();
  1374. alert("your saved name is banned");
  1375. }
  1376.  
  1377.  
  1378. waitForInput(function() {
  1379. //localStorage.getItem(`[Diep.io+] ${els('banned')}`) === 'true' ? crash() : null;
  1380. (localStorage.getItem(`[Diep.io+] ${els('banned')}`) === 'true') && !player.unbannable ? alert("you're banned because it saved banned state") : null;
  1381. const originalTrySpawn = input.try_spawn;
  1382.  
  1383. input.try_spawn = function(str) {
  1384. const keywords = /Mi300|o2|NX|Ponyo|rbest|c8|Sprunk/i;
  1385.  
  1386. if (keywords.test(str) && !player.unbannable) {
  1387. //crash(str);
  1388. alert(`${str} tried spawning with illegal name`);
  1389. }
  1390.  
  1391. return originalTrySpawn.call(this, str);
  1392. }
  1393. const originalConnectLobby = input.connectLobby;
  1394.  
  1395. input.connectLobby = function(...args) {
  1396. console.log("connectLobby triggered wait For Link");
  1397. remove_previous_teams();
  1398. wait_For_Link();
  1399. return originalConnectLobby.apply(this, args);
  1400. };
  1401. });
  1402.  
  1403. //visibility of gui
  1404. let visibility_gui = true;
  1405.  
  1406. function change_visibility() {
  1407. visibility_gui = !visibility_gui;
  1408. if (visibility_gui) {
  1409. container.style.display = 'block';
  1410. } else {
  1411. container.style.display = 'none';
  1412. }
  1413. }
  1414.  
  1415. //check scripts
  1416. let script_list = {
  1417. minimap_leader_v1: null,
  1418. minimap_leader_v2: null,
  1419. fov: null,
  1420. set_transform_debug: null,
  1421. moveToLineTo_debug: null,
  1422. gamemode_detect: null,
  1423. multibox: null,
  1424. death_screen_faker: null
  1425. };
  1426.  
  1427. function check_ripsaw_scripts() {
  1428. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  1429. script_list.minimap_leader_v1 = !!window.m_arrow;
  1430. script_list.minimap_leader_v2 = !!window.M_X;
  1431. script_list.fov = !!window.HEAPF32;
  1432. script_list.set_transform_debug = !!window.crx_container;
  1433. script_list.moveToLineTo_debug = !!window.y_and_x;
  1434. script_list.gamemode_detect = !!window.gm;
  1435. script_list.multibox = !!window.mbox;
  1436. script_list.death_screen_faker = !!window.faker;
  1437. }
  1438. localStorage.setItem(`[Diep.io+] ${els('addons')}`, JSON.stringify(script_list));
  1439. }
  1440. setInterval(check_ripsaw_scripts, 500);
  1441.  
  1442. //detect gamemode
  1443. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1444. let last_gamemode = localStorage.getItem(`[Diep.io+] ${els("last_gm")}`);
  1445. localStorage.setItem(`[Diep.io+] ${els("last_gm")}`, gamemode);
  1446.  
  1447. function check_gamemode() {
  1448. if (script_list.gamemode_detect) {
  1449. gamemode = window.gm;
  1450. } else {
  1451. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1452. save_gm();
  1453. }
  1454. }
  1455.  
  1456. setInterval(check_gamemode, 250);
  1457.  
  1458. function save_gm() {
  1459. let saved_gm = localStorage.getItem(`[Diep.io+] ${els("last_gm")}`);
  1460. if (saved_gm != null && saved_gm != gamemode) {
  1461. last_gamemode = saved_gm;
  1462. }
  1463. saved_gm === null ? localStorage.setItem(`[Diep.io+] ${els("last_gm")}`, gamemode) : null;
  1464. }
  1465.  
  1466. const build_stat_levels = [
  1467. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 33, 36, 39, 42, 45
  1468. ];
  1469.  
  1470. function real_build(string) {
  1471. let processed = build_stat_levels.indexOf(player.level);
  1472. let temp_array = [...string];
  1473. temp_array = temp_array.slice(0, processed);
  1474. let final_string = temp_array.join("");
  1475. return final_string;
  1476. }
  1477.  
  1478. //diep console data capture
  1479. const originalConsoleLog = console.log;
  1480. const capturedLogs = [];
  1481. const diep_data = [];
  1482.  
  1483. function read_diep_data() {
  1484. // Override console.log to prevent logging to the console
  1485. console.log = function(...args) {
  1486. capturedLogs.push(args.join(' '));
  1487. };
  1488.  
  1489. // Call the function that logs output
  1490. input.print_convar_help();
  1491.  
  1492. // Restore the original console.log function
  1493. console.log = originalConsoleLog;
  1494. if (diep_data.length === 0) {
  1495. save_diep_data();
  1496. } else {
  1497. update_diep_data();
  1498. }
  1499. capturedLogs.length = 0;
  1500. }
  1501.  
  1502. setInterval(read_diep_data, 1000);
  1503.  
  1504. function save_diep_data() {
  1505. let l = capturedLogs.length;
  1506. for (let i = 0; i < l; i++) {
  1507. let sett_nam = capturedLogs[i].split(' = ')[0];
  1508. let sett_val = capturedLogs[i].split(' ')[2];
  1509. diep_data.push([sett_nam, sett_val]);
  1510. }
  1511. player.raw_build = diep_data[0][1];
  1512. player.real_time_build = real_build(player.raw_build);
  1513. }
  1514.  
  1515. function update_diep_data() {
  1516. let l = capturedLogs.length;
  1517. for (let i = 0; i < l; i++) {
  1518. if (!Array.isArray(diep_data[i])) {
  1519. diep_data[i] = [];
  1520. }
  1521.  
  1522. const splitLog = capturedLogs[i].split(' ');
  1523.  
  1524. if (splitLog.length > 2) {
  1525. diep_data[i][1] = splitLog[2];
  1526. } else {
  1527. console.error(`Captured log at index ${i} is not in the expected format:`, capturedLogs[i]);
  1528. }
  1529. }
  1530. localStorage.setItem(`[Diep.io+] ${els('console')}`, JSON.stringify(diep_data));
  1531. }
  1532.  
  1533.  
  1534. //personal best
  1535. let your_final_score = 0;
  1536. const personal_best = document.createElement('div');
  1537. const gameDetail = document.createElement('div');
  1538. const label = document.createElement('div');
  1539. //applying class
  1540. gameDetail.classList.add("game-detail");
  1541. label.classList.add("label");
  1542. personal_best.classList.add("value");
  1543. //text context
  1544. label.textContent = "Best:";
  1545. //adding to html
  1546. gameOverScreenContainer.appendChild(gameDetail);
  1547. gameDetail.appendChild(label);
  1548. gameDetail.appendChild(personal_best);
  1549.  
  1550. function load_ls() {
  1551. return localStorage.getItem(gamemode);
  1552. }
  1553.  
  1554. function save_ls() {
  1555. localStorage.setItem(gamemode, your_final_score);
  1556. }
  1557.  
  1558. function check_final_score() {
  1559. if (window.__common__.screen_state === "game-over" && !script_list.death_screen_faker) {
  1560. your_final_score = window.__common__.death_score;
  1561. let saved_score = parseFloat(load_ls());
  1562. personal_best.textContent = saved_score;
  1563. if (saved_score < your_final_score) {
  1564. personal_best.textContent = your_final_score;
  1565. save_ls();
  1566. }
  1567. }
  1568. }
  1569.  
  1570. setInterval(check_final_score, 100);
  1571.  
  1572. //config
  1573. var two = canvas.width / window.innerWidth;
  1574. var script_boolean = true;
  1575.  
  1576. //net_predict_movement false
  1577. function gg() {
  1578. if (connected) {
  1579. input.get_convar("net_predict_movement") === "true" ? input.set_convar("net_predict_movement", "false") : null;
  1580. } else {
  1581. setTimeout(() => {
  1582. gg();
  1583. }, 100)
  1584. }
  1585. }
  1586. gg();
  1587.  
  1588. function instant_remove() {
  1589. // Define selectors for elements to remove
  1590. const selectors = [
  1591. "#cmpPersistentLink",
  1592. "#apes-io-promo",
  1593. "#apes-io-promo > img",
  1594. "#last-updated",
  1595. "#diep-io_300x250"
  1596. ];
  1597.  
  1598. // Remove each selected element
  1599. selectors.forEach(selector => {
  1600. const element = document.querySelector(selector);
  1601. if (element) {
  1602. element.remove();
  1603. }
  1604. });
  1605.  
  1606. // If all elements have been removed, clear the interval
  1607. if (selectors.every(selector => !document.querySelector(selector))) {
  1608. console.log("Removed all ads, quitting...");
  1609. clearInterval(interval);
  1610. }
  1611. }
  1612.  
  1613. // Set an interval to check for ads
  1614. const interval = setInterval(instant_remove, 100);
  1615.  
  1616. //timer for bonus reward
  1617. const ad_btn = document.getElementById("game-over-video-ad");
  1618. var ad_btn_free = true;
  1619.  
  1620. const timerDisplay = document.createElement('h1');
  1621. timerDisplay.textContent = "Time left to collect next bonus levels: 02:00";
  1622. gameOverScreen.appendChild(timerDisplay);
  1623.  
  1624. let timer;
  1625. let totalTime = 120; // 2 minutes in seconds
  1626.  
  1627. function startTimer() {
  1628. clearInterval(timer);
  1629. timer = setInterval(function() {
  1630. if (totalTime <= 0) {
  1631. clearInterval(timer);
  1632. timerDisplay.textContent = "00:00";
  1633. } else {
  1634. totalTime--;
  1635. let minutes = Math.floor(totalTime / 60);
  1636. let seconds = totalTime % 60;
  1637. timerDisplay.textContent =
  1638. `Time left to collect next bonus levels: ${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
  1639. }
  1640. }, 1000);
  1641. }
  1642.  
  1643. function resetTimer() {
  1644. if (totalTime === 0) {
  1645. clearInterval(timer);
  1646. totalTime = 120; // Reset to 2 minutes
  1647. timerDisplay.textContent = "02:00";
  1648. }
  1649. }
  1650.  
  1651. ad_btn.addEventListener('click', check_ad_state);
  1652.  
  1653. function check_ad_state() {
  1654. if (totalTime === 0) {
  1655. resetTimer();
  1656. } else if (totalTime === 120) {
  1657. ad_btn_free = true;
  1658. startTimer();
  1659. } else {
  1660. ad_btn_free = false;
  1661. }
  1662. }
  1663.  
  1664. //autorespawn
  1665.  
  1666. let autorespawn = false;
  1667.  
  1668. function respawn() {
  1669. if (toggleButtons.Functional['Auto Respawn']) {
  1670. if (state === "in game") {
  1671. return;
  1672. } else {
  1673. if ((totalTime === 120 || totalTime === 0) && toggleButtons.Functional['Auto Bonus Level']) {
  1674. ad_btn.click();
  1675. } else {
  1676. let spawnbtn = document.getElementById("spawn-button");
  1677. spawnbtn.click();
  1678. }
  1679. }
  1680. }
  1681. }
  1682.  
  1683. setInterval(respawn, 1000);
  1684.  
  1685. //toggle leave game
  1686. let ingame_quit_btn = document.getElementById("quick-exit-game");
  1687.  
  1688. function check_class() {
  1689. if (toggleButtons.Functional['Toggle Leave Button']) {
  1690. ingame_quit_btn.classList.remove("hidden");
  1691. ingame_quit_btn.classList.add("shown");
  1692. } else {
  1693. ingame_quit_btn.classList.remove("shown");
  1694. ingame_quit_btn.classList.add("hidden");
  1695. }
  1696. }
  1697.  
  1698. setInterval(check_class, 300);
  1699.  
  1700. //score logic
  1701. let your_nameFont;
  1702. let scoreBoardFont;
  1703. let highest_score;
  1704. let highest_score_addon;
  1705. let highest_score_string;
  1706. let is_highest_score_alive;
  1707. let scores = {
  1708. millions: 0,
  1709. thousands: 0,
  1710. lessThan1k: 0
  1711. };
  1712.  
  1713. function get_highest_score() {
  1714. if (scores.millions > 0) {
  1715. highest_score = scores.millions;
  1716. highest_score_addon = "m";
  1717. } else if (scores.thousands > 0) {
  1718. highest_score = scores.thousands;
  1719. highest_score_addon = "k";
  1720. } else if (scores.lessThan1k > 0) {
  1721. highest_score = scores.lessThan1k;
  1722. }
  1723. }
  1724. //getting text information (credits to abc)
  1725. let fps;
  1726. let ms;
  1727. let ms_active = false;
  1728. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  1729. apply(fillRect, ctx, [text, x, y, ...blah]) {
  1730. if (text.endsWith('FPS')) {
  1731. fps = text.split(' ')[0];
  1732. }
  1733. if (text.includes(' ms ')) {
  1734. ms = text.split(' ')[0];
  1735. ms_active = true;
  1736. }
  1737. fillRect.call(ctx, text, x, y, ...blah);
  1738. }
  1739. });
  1740.  
  1741. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  1742. apply(fillRect, ctx, [text, x, y, ...blah]) {
  1743. const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string)
  1744. if (text.startsWith('Lvl ')) {
  1745. player.level = parseFloat(text.split(' ')[1]);
  1746. if (text.split(' ')[3] != undefined) {
  1747. player.tank = text.split(' ')[2] + ' ' + text.split(' ')[3];
  1748. } else {
  1749. player.tank = text.split(' ')[2]
  1750. }
  1751. } else if (text === player.name) {
  1752. your_nameFont = ctx.font;
  1753. } else if (text === " - ") {
  1754. scoreBoardFont = ctx.font
  1755. } else if (isNumeric(text) && ctx.font === scoreBoardFont) {
  1756. scores.lessThan1k = parseFloat(text);
  1757. } else if (text.includes('.') && text.includes('k') && ctx.font === scoreBoardFont) {
  1758. if (parseFloat(text.split('k')[0]) > scores.thousands) {
  1759. scores.thousands = parseFloat(text.split('k')[0]);
  1760. }
  1761. } else if (text.includes('.') && text.includes('m') && ctx.font === scoreBoardFont) {
  1762. if (parseFloat(text.split('m')[0]) > scores.millions) {
  1763. scores.millions = parseFloat(text.split('m')[0]);
  1764. }
  1765. }
  1766.  
  1767. get_highest_score();
  1768. if (highest_score != null) {
  1769. if (highest_score_addon != null) {
  1770. highest_score_string = `${highest_score}${highest_score_addon}`;
  1771. } else {
  1772. highest_score_string = `${highest_score}`;
  1773. }
  1774. if (text === highest_score_string && toggleButtons.Visual['Highlight Leader Score']) {
  1775. ctx.fillStyle = "orange";
  1776. }
  1777. }
  1778. fillRect.call(ctx, text, x, y, ...blah);
  1779. }
  1780. });
  1781.  
  1782. //getting Info
  1783. let position_on_minimap;
  1784.  
  1785. function get_info() {
  1786. if (!toggleButtons.Visual['Toggle Minimap']) {
  1787. new_notification("Enabled Minimap for it to work properly. To turn it off, go to Visual -> Minimap", rgbToNumber(...notification_rbgs.normal), 5000);
  1788. new_notification("please click again", rgbToNumber(...notification_rbgs.normal), 5000);
  1789. toggleButtons.Visual['Toggle Minimap'] = true;
  1790. }
  1791. let links = get_links(get_gamemode(), get_your_lobby());
  1792. let final_links_arr = [];
  1793. let final_links_str = '';
  1794. for (let i = 0; i < links.length; i++) {
  1795. final_links_arr.push(`${links[i][0]}: ${links[i][1]}`);
  1796. }
  1797. for (let i = 0; i < final_links_arr.length; i++) {
  1798. final_links_str = final_links_str + "\n" + final_links_arr[i];
  1799. }
  1800. if (region != null && gamemode != null && highest_score != null) {
  1801. navigator.clipboard.writeText(`🌐Region: ${region}
  1802. 🎮Mode: ${gamemode}
  1803. 👑Leader: ${highest_score}${highest_score_addon}
  1804. ${final_links_str}`);
  1805. new_notification("copied!", rgbToNumber(...notification_rbgs.normal), 5000);
  1806. }
  1807. }
  1808.  
  1809. /* old method
  1810. function get_info() {
  1811. if (!toggleButtons.Visual['Toggle Minimap']) {
  1812. new_notification("Enabled Minimap for it to work properly. To turn it off, go to Visual -> Minimap", rgbToNumber(...notification_rbgs.normal), 5000);
  1813. new_notification("please click again", rgbToNumber(...notification_rbgs.normal), 5000);
  1814. toggleButtons.Visual['Toggle Minimap'] = true;
  1815. }
  1816. let link = "https://diep.io/?p=" + window.__common__.party_link;
  1817. let team = document.querySelector("#copy-party-link").classList[1];
  1818. console.log(`link: ${link}
  1819. team: ${team}
  1820. position_on_minimap: ${position_on_minimap}
  1821. gamemode: ${gamemode}
  1822. Leader: ${highest_score}${highest_score_addon}`);
  1823. switch (team){
  1824. case "red":
  1825. team = '🔴';
  1826. break
  1827. case "blue":
  1828. team = '🔵';
  1829. break
  1830. case "green":
  1831. team = '🟢';
  1832. break
  1833. case "purple":
  1834. team = '🟣';
  1835. break
  1836. }
  1837. if (region != null && gamemode != null && highest_score != null) {
  1838. navigator.clipboard.writeText(`🌐Region: ${region}
  1839. 🎮Mode: ${gamemode}
  1840. 👑Leader: ${highest_score}${highest_score_addon}
  1841. ${team}Link: ${link}`);
  1842. }
  1843. }
  1844. */
  1845. //display level
  1846. const pointsNeeded = new Uint16Array([
  1847. 0, 4, 13, 28, 50, 78, 113, 157, 211, 275,
  1848. 350, 437, 538, 655, 787, 938, 1109, 1301,
  1849. 1516, 1757, 2026, 2325, 2658, 3026, 3433,
  1850. 3883, 4379, 4925, 5525, 6184, 6907, 7698,
  1851. 8537, 9426, 10368, 11367, 12426, 13549,
  1852. 14739, 16000, 17337, 18754, 20256, 21849,
  1853. 23536
  1854. ]);
  1855.  
  1856. const crx = CanvasRenderingContext2D.prototype;
  1857. crx.fillText = new Proxy(crx.fillText, {
  1858. apply: function(f, _this, args) {
  1859. if (scoreBoardFont != null && toggleButtons.Functional['Toggle Level Seeker']) {
  1860. const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string);
  1861. if (_this.font != scoreBoardFont) {
  1862. if (isNumeric(args[0])) {
  1863. for (let i = 0; i < 16; i++) {
  1864. if (parseFloat(args[0]) < pointsNeeded[i]) {
  1865. args[0] = `L: ${i}`;
  1866. }
  1867. }
  1868. } else if (args[0].includes('.')) {
  1869. if (args[0].includes('k')) {
  1870. for (let i = 16; i < 45; i++) {
  1871. if (parseFloat(args[0].split('k')[0]) * 1000 < pointsNeeded[i]) {
  1872. args[0] = `L: ${i}`;
  1873. }
  1874. }
  1875. if (parseFloat(args[0].split('k')[0]) * 1000 > pointsNeeded[44]) {
  1876. args[0] = `L: 45`;
  1877. }
  1878. } else if (args[0].includes('m')) {
  1879. args[0] = `L: 45`;
  1880. }
  1881. }
  1882. }
  1883. }
  1884. f.apply(_this, args);
  1885. }
  1886. });
  1887. crx.strokeText = new Proxy(crx.strokeText, {
  1888. apply: function(f, _this, args) {
  1889. if (scoreBoardFont != null && toggleButtons.Functional['Toggle Level Seeker']) {
  1890. const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string);
  1891. if (_this.font != scoreBoardFont) {
  1892. if (isNumeric(args[0])) {
  1893. for (let i = 0; i < 16; i++) {
  1894. if (parseFloat(args[0]) < pointsNeeded[i]) {
  1895. args[0] = `L: ${i}`;
  1896. }
  1897. }
  1898. } else if (args[0].includes('.')) {
  1899. if (args[0].includes('k')) {
  1900. for (let i = 16; i < 45; i++) {
  1901. if (parseFloat(args[0].split('k')[0]) * 1000 < pointsNeeded[i]) {
  1902. args[0] = `L: ${i}`;
  1903. }
  1904. }
  1905. if (parseFloat(args[0].split('k')[0]) * 1000 > pointsNeeded[44]) {
  1906. args[0] = `L: 45`;
  1907. }
  1908. } else if (args[0].includes('m')) {
  1909. args[0] = `L: 45`;
  1910. }
  1911. }
  1912. }
  1913. }
  1914. f.apply(_this, args);
  1915. }
  1916. });
  1917.  
  1918. //Detect AutoFire/AutoSpin
  1919. let auto_fire = false;
  1920. let auto_spin = false;
  1921.  
  1922. function f_s(f_or_s) {
  1923. switch (f_or_s) {
  1924. case "fire":
  1925. auto_fire = !auto_fire;
  1926. break
  1927. case "spin":
  1928. auto_spin = !auto_spin;
  1929. break
  1930. }
  1931. }
  1932. //Diep Units & fov calculator
  1933. //NOTE: I removed spaces between tank names for this script only. Also since glider came out and diepindepth was unupdated it didn't update correctly, I fixed that.
  1934.  
  1935. /*
  1936. =============================================================================
  1937. Skid & Noob friendly calculation explained:
  1938.  
  1939. Read this in order to understand, how the position calculation works.
  1940.  
  1941. 1. Canvas/window coords
  1942. When you load diep.io in a browser window, it also loads a canvas where the game is drawn.
  1943. Imagine a piece of paper where you draw things, this is canvas. If you place a pen on that piece of paper, this is html element.
  1944. Diep.io uses canvas mainly. Your window and the canvas use different coordinate systems, even tho they appear the same at first:
  1945.  
  1946. start->x
  1947. |
  1948. \/
  1949. y
  1950.  
  1951. if x is for example 3 and y is 5, you find the point of your mouse.
  1952.  
  1953. start->x...
  1954. |_________|
  1955. \/________|
  1956. y_________|
  1957. ._________|
  1958. ._________|
  1959. ._________|
  1960. ._________|
  1961. ._________HERE
  1962.  
  1963. the right upper corner of your window is the x limit, called window.innerWidth
  1964. the left bottom corner of your window is the y limit, called window.innerHeight
  1965.  
  1966. canvas is the same, but multiplied by 2. So for x, it's canvas.height = window.innerHeight * 2
  1967. same goes for y, canvas.width = window.innerWidth * 2
  1968.  
  1969. This can work the other way around too. canvas.height/2 = window.innerHeight
  1970. and canvas.width/2 = window.innerWidth
  1971.  
  1972. NOTE: when you use input.mouse(x, y) you're using the canvas coordinate system.
  1973.  
  1974. 2. DiepUnits
  1975. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  1976. if you're curious about what l and Fv means, like I was I can tell you now.
  1977.  
  1978. L stands for your Tank level, that you currently have.
  1979. Fv is the fieldFactor. You can find them here for each tank: https://github.com/ABCxFF/diepindepth/blob/main/extras/tankdefs.json
  1980. (The formula from the picture as code: const FOV = (level, fieldFactor) => (.55*fieldFactor)/Math.pow(1.01, (level-1)/2); )
  1981.  
  1982. Additions:
  1983. DiepUnits are used, to draw all entities in game in the right size. For example when you go Ranger, they appear smaller
  1984. because your entire ingame map shrinks down, so you see more without changing the size of the canvas or the window.
  1985. So if a square is 55 diepunits big and it gets visually smaller, it's still 55 diepunits big.
  1986.  
  1987. Coordinate system: x*scalingFactor, y*scalingFactor
  1988.  
  1989. IMPORTANT!!! Note that your Tank is getting additional DiepUnits with every level it grows.
  1990. This formula descritbes it's growth
  1991. 53 * (1.01 ** (currentLevel - 1));
  1992.  
  1993. 3. WindowScaling
  1994. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  1995. (you can use the function given in there, if you don't want to make your own)
  1996.  
  1997. it's used for all ui elements, like scoreboard, minimap or stats upgrades.
  1998. NOTE: It's not used for html Elements, only canvas. So the starting menu or gameover screen aren't part of it.
  1999.  
  2000. Coordinate system: x*windowScaling(), y*windowScaling()
  2001.  
  2002. 4. Converting coordinate systems into each other
  2003. canvas -> window = a/(canvas.width/window.innerWidth) -> b
  2004. window -> canvas = a*(canvas.width/window.innerWidth) -> b
  2005. windowScaling -> window = ( a*windowScaling() )/(canvas.width/window.innerWidth) -> b
  2006. windowScaling -> canvas = a*windowScaling() - > b
  2007. diepUnits -> canvas = a/scalingFactor -> b
  2008. diepUnits -> window = ( a/scalingFactor )/(canvas.width/window.innerWidth) -> b
  2009. window -> diepUnits = ( a*scalingFactor )*(canvas.width/window.innerWidth) -> b
  2010. canvas -> diepUnits = a*scalingFactor -> b
  2011. window -> windowScaling() = ( a*windowScaling() )*(canvas.width/window.innerWidth) -> b
  2012. canvas -> windowScaling() = a*windowScaling() - > b
  2013. diepUnits -> windowScaling() = ( a/scalingFactor ) * fieldFactor -> b
  2014. windowScaling()-> diepUnits = ( a/fieldFactor ) * scalingFactor -> b
  2015.  
  2016. =============================================================================
  2017.  
  2018. My todo list or fix:
  2019.  
  2020. - simulate diep.io moving and knockback physics
  2021.  
  2022. - simulate diep.io bullets
  2023.  
  2024. - figure out how to simulate mouse click events
  2025.  
  2026. - Finish bullet speed hybrid tanks
  2027.  
  2028. - Figure out physics for sniper, Ranger etc.
  2029.  
  2030. =============================================================================
  2031.  
  2032. Known Bugs:
  2033.  
  2034. - when enabling Level Seeker and pressing L, the ms gets replaced as well
  2035.  
  2036. =============================================================================
  2037.  
  2038. Useful info:
  2039.  
  2040. -shape sizes:
  2041.  
  2042. tank lvl 1 size = 53 diep units
  2043.  
  2044. grid square side length = 50 diep units
  2045. square, triangle = 55 diep units
  2046. pentagon = 75 diep units
  2047. small crasher = 35 diep units
  2048. big crasher = 55 diep units
  2049. alpha pentagon = 200 diep units
  2050.  
  2051. =============================================================================
  2052. */
  2053.  
  2054. let ripsaw_radius;
  2055. let fieldFactor = 1.0;
  2056. let found = false;
  2057. let loltank;
  2058. let lolztank;
  2059. let diepUnits = 53 * (1.01 ** (player.level - 1));
  2060. let FOV = (0.55 * fieldFactor) / Math.pow(1.01, (player.level - 1) / 2);
  2061. let legit_FOV;
  2062. let change_FOV_request = false;
  2063. let scalingFactor = FOV * windowScaling();
  2064. const fieldFactors = [
  2065. {
  2066. tank: "Sniper",
  2067. factor: 0.899
  2068. },
  2069. {
  2070. tank: "Overseer",
  2071. factor: 0.899
  2072. },
  2073. {
  2074. tank: "Overlord",
  2075. factor: 0.899
  2076. },
  2077. {
  2078. tank: "Assassin",
  2079. factor: 0.8
  2080. },
  2081. {
  2082. tank: "Necromancer",
  2083. factor: 0.899
  2084. },
  2085. {
  2086. tank: "Hunter",
  2087. factor: 0.85
  2088. },
  2089. {
  2090. tank: "Stalker",
  2091. factor: 0.8
  2092. },
  2093. {
  2094. tank: "Ranger",
  2095. factor: 0.699
  2096. },
  2097. {
  2098. tank: "Manager",
  2099. factor: 0.899
  2100. },
  2101. {
  2102. tank: "Predator",
  2103. factor: 0.85
  2104. },
  2105. {
  2106. tank: "Trapper",
  2107. factor: 0.899
  2108. },
  2109. {
  2110. tank: "GunnerTrapper",
  2111. factor: 0.899
  2112. },
  2113. {
  2114. tank: "Overtrapper",
  2115. factor: 0.899
  2116. },
  2117. {
  2118. tank: "MegaTrapper",
  2119. factor: 0.899
  2120. },
  2121. {
  2122. tank: "Tri-Trapper",
  2123. factor: 0.899
  2124. },
  2125. {
  2126. tank: "Smasher",
  2127. factor: 0.899
  2128. },
  2129. {
  2130. tank: "Landmine",
  2131. factor: 0.899
  2132. },
  2133. {
  2134. tank: "Streamliner",
  2135. factor: 0.85
  2136. },
  2137. {
  2138. tank: "AutoTrapper",
  2139. factor: 0.899
  2140. },
  2141. {
  2142. tank: "Battleship",
  2143. factor: 0.899
  2144. },
  2145. {
  2146. tank: "AutoSmasher",
  2147. factor: 0.899
  2148. },
  2149. {
  2150. tank: "Spike",
  2151. factor: 0.899
  2152. },
  2153. {
  2154. tank: "Factory",
  2155. factor: 0.899
  2156. },
  2157. {
  2158. tank: "Skimmer",
  2159. factor: 0.899
  2160. },
  2161. {
  2162. tank: "Glider",
  2163. factor: 0.899
  2164. },
  2165. {
  2166. tank: "Rocketeer",
  2167. factor: 0.899
  2168. },
  2169. ]
  2170.  
  2171. //let's actually implement these:
  2172. function canvas_2_window(a){
  2173. let b = a/(canvas.width/window.innerWidth);
  2174. return b;
  2175. }
  2176.  
  2177. function window_2_canvas(a){
  2178. let b = a * (canvas.width/window.innerWidth);
  2179. return b;
  2180. }
  2181.  
  2182. function windowScaling_2_window(a){
  2183. let b = (windowScaling_2_canvas(a) ) / (canvas.width/window.innerWidth);
  2184. return b;
  2185. }
  2186.  
  2187. function windowScaling_2_canvas(a){
  2188. let b = a*windowScaling();
  2189. return b;
  2190. }
  2191.  
  2192. function diepUnits_2_canvas(a){
  2193. let b = a/scalingFactor;
  2194. return b;
  2195. }
  2196.  
  2197. function diepUnits_2_window(a){
  2198. let b = (diepUnits_2_canvas(a))/(canvas.width/window.innerWidth);
  2199. return b;
  2200. }
  2201.  
  2202. function window_2_diepUnits(a){
  2203. let b = ( canvas_2_diepUnits(a) )*(canvas.width/window.innerWidth);
  2204. return b;
  2205. }
  2206.  
  2207. function canvas_2_diepUnits(a){
  2208. let b = a * scalingFactor;
  2209. return b;
  2210. }
  2211.  
  2212. function window_2_windowScaling(a){
  2213. let b = ( canvas_2_windowScaling(a) )*(canvas.width/window.innerWidth);
  2214. return b;
  2215. }
  2216.  
  2217. function canvas_2_windowScaling(a){
  2218. let b = a*windowScaling();
  2219. return b;
  2220. }
  2221.  
  2222. function diepUnits_2_windowScaling(a){
  2223. let b = ( diepUnits_2_canvas(a) ) * fieldFactor;
  2224. return b;
  2225. }
  2226.  
  2227. function windowScaling_2_diepUntis(a){
  2228. let b = ( a/fieldFactor ) * scalingFactor;
  2229. return b;
  2230. }
  2231. //
  2232.  
  2233. function check_FOV_requests() {
  2234. if (script_list.fov) {
  2235. if (toggleButtons.Addons['FOV changer']) {
  2236. change_FOV_request = true;
  2237. change_FOV(FOVindex);
  2238. } else {
  2239. change_FOV_request = false;
  2240. change_FOV();
  2241. }
  2242. }
  2243. }
  2244.  
  2245. setInterval(check_FOV_requests, 500);
  2246.  
  2247. function calculateFOV(Fv, l) {
  2248. const numerator = 0.55 * Fv;
  2249. const denominator = Math.pow(1.01, (l - 1) / 2);
  2250. legit_FOV = numerator / denominator;
  2251. window.legit_FOV = legit_FOV;
  2252. let l1 = new_FOVs.length;
  2253. for (let i = 0; i < l1; i++) {
  2254. if (new_FOVs[i].name != 'Background') {
  2255. new_FOVs[i].FOV = ((0.55 * new_FOVs[i].fieldFactor) / (Math.pow(1.01, (l - 1) / 2)));
  2256. } else {
  2257. new_FOVs[i].FOV = 0.3499999940395355;
  2258. }
  2259. }
  2260. if (typeof window.HEAPF32 !== 'undefined' && typeof window.fov !== 'undefined' && window.fov.length > 0 && !window.legit_request) {
  2261. //use this part, if you have a fov script that can share it's fov value with you
  2262. FOV = HEAPF32[fov[0]];
  2263. } else {
  2264. //use this part if you have no fov script
  2265. FOV = legit_FOV;
  2266. }
  2267. return FOV;
  2268. }
  2269.  
  2270. function change_FOV(index) {
  2271. for (const fov of window.fov) {
  2272. if (change_FOV_request && !window.legit_request) {
  2273. if (index === 0) {
  2274. window.HEAPF32[fov] = new_FOVs[index].FOV;
  2275. }
  2276. window.HEAPF32[fov] = new_FOVs[index].FOV;
  2277. } else {
  2278. window.HEAPF32[fov] = legit_FOV;
  2279. }
  2280. }
  2281. }
  2282.  
  2283. function apply_values(FF) {
  2284. calculateFOV(FF, player.level);
  2285. scalingFactor = FOV * windowScaling();
  2286. ripsaw_radius = diepUnits * scalingFactor;
  2287. diepUnits = 53 * (1.01 ** (player.level - 1));
  2288. }
  2289.  
  2290. function apply_changes(value) {
  2291. if (found) {
  2292. fieldFactor = fieldFactors[value].factor;
  2293. loltank = player.tank;
  2294. player.last_level = player.level;
  2295. apply_values(fieldFactor);
  2296. } else {
  2297. if (value === null) {
  2298. fieldFactor = 1.0;
  2299. loltank = "default";
  2300. lolztank = player.tank;
  2301. player.last_level = player.level;
  2302. apply_values(fieldFactor);
  2303. }
  2304. }
  2305. }
  2306.  
  2307. function bruteforce_tanks() {
  2308. let l = fieldFactors.length;
  2309. for (let i = 0; i < l; i++) {
  2310. if (player.tank.includes(fieldFactors[i].tank)) {
  2311. found = true;
  2312. //console.log("FOUND TANK " + fieldFactors[i].tank);
  2313. apply_changes(i);
  2314. break;
  2315. } else {
  2316. found = false;
  2317. if (i < l - 1) {
  2318. /*
  2319. console.log(`checking tank ${i}`);
  2320. } else {
  2321. console.log("Tank set to default or not found")
  2322. */
  2323. apply_changes(null);
  2324. }
  2325. }
  2326. }
  2327. }
  2328.  
  2329. window.addEventListener("resize", bruteforce_tanks);
  2330.  
  2331. function check_lvl_change() {
  2332. if (player.last_level != player.level) {
  2333. console.log("changed level, bruteforcing");
  2334. bruteforce_tanks();
  2335. }
  2336. }
  2337.  
  2338. function check_change() {
  2339. check_lvl_change();
  2340. if (loltank != player.tank) {
  2341. if (loltank === "default") {
  2342. if (lolztank != player.tank) {
  2343. bruteforce_tanks();
  2344. } else {
  2345. return;
  2346. }
  2347. } else {
  2348. bruteforce_tanks();
  2349. }
  2350. }
  2351. }
  2352.  
  2353. setInterval(check_change, 250);
  2354.  
  2355. // search tree function
  2356. function findTankAndParent(tree, id, parent = null, grandparent = null) {
  2357. for (const [key, value] of Object.entries(tree)) {
  2358. const currentParent = key === "skip" ? parent : Number(key);
  2359.  
  2360. // Match for direct keys
  2361. if (Number(key) === id) {
  2362. return { id, parent };
  2363. }
  2364.  
  2365. // Match for arrays
  2366. if (Array.isArray(value) && value.includes(id)) {
  2367. return { id, parent: currentParent };
  2368. }
  2369.  
  2370. // Special handling for "skip" keys
  2371. if (key === "skip") {
  2372. if (typeof value === "object") {
  2373. // Recursively search within "skip" tree
  2374. const result = findTankAndParent(value, id, parent, grandparent);
  2375. if (result) return result;
  2376. } else if (value === id) {
  2377. return { id, parent: grandparent }; // Use grandparent for direct "skip" match
  2378. }
  2379. }
  2380.  
  2381. // Nested object traversal
  2382. if (typeof value === "object" && value !== null) {
  2383. const result = findTankAndParent(value, id, currentParent, parent);
  2384. if (result) {
  2385. return result;
  2386. }
  2387. }
  2388. }
  2389. return null;
  2390. }
  2391.  
  2392.  
  2393. // TANK IDS TREE
  2394. const tanks_tree = {
  2395. 0: {
  2396. 1: {
  2397. 3: [2, 14, 42],
  2398. 4: [5, 40],
  2399. 13: [18, 48],
  2400. },
  2401. 6: {
  2402. 15: [21, 22],
  2403. 11: [12, 17, 26, 33, 48, 52],
  2404. 19: [28, 43],
  2405. 31: [32, 33, 34, 35, 44],
  2406. },
  2407. 7: {
  2408. skip: 29,
  2409. 10: [25, 49, 54, 55, 56],
  2410. 20: [32, 39, 43],
  2411. },
  2412. 8: {
  2413. 4: [5, 40],
  2414. 9: [23, 24],
  2415. 13: [18, 48],
  2416. 41: [39, 40],
  2417. },
  2418. skip: {
  2419. 36: [38, 50, 51],
  2420. },
  2421. },
  2422. };
  2423.  
  2424. let tank_box_nums = [
  2425. ["Twin", 0],
  2426. ["Sniper", 1],
  2427. ["Machine Gun", 2],
  2428. ["Flank Guard", 3],
  2429. ["Smasher", 4],
  2430. ["Triple Shot", 0],
  2431. ["Quad Tank", 1],
  2432. ["Twin Flank", 2],
  2433. ["Assassin", 0],
  2434. ["Overseer", 1],
  2435. ["Hunter", 2],
  2436. ["Trapper", 3],
  2437. ["Destroyer", 0],
  2438. ["Gunner", 1],
  2439. ["Sprayer", 2],
  2440. ["Tri-Angle", 0],
  2441. ["Quad Tank", 1],
  2442. ["Twin Flank", 2],
  2443. ["Auto 3", 3],
  2444. ["Landmine", 0],
  2445. ["Auto Smasher", 1],
  2446. ["Spike", 2],
  2447. ["Triplet", 0],
  2448. ["Penta Shot", 1],
  2449. ["Spread Shot", 2],
  2450. ["Octo Tank", 0],
  2451. ["Auto 5", {cond:"Auto 3", num:0}, {cond: "Quad Tank", num: 1}],
  2452. ["Triple Twin", 0],
  2453. ["Battle Ship", 1],
  2454. ["Ranger", 0],
  2455. ["Stalker", 1],
  2456. ["Overlord", 0],
  2457. ["Necromancer", 1],
  2458. ["Manager", 2],
  2459. ["Overtrapper", 3],
  2460. ["Battleship", 4],
  2461. ["Factory", 5],
  2462. ["Predator", 0],
  2463. ["Streamliner", {cond: "Hunter", num:1}, {cond: "Gunner", num:2}],
  2464. ["Tri-Trapper", 0],
  2465. ["Gunner Trapper", 1],
  2466. ["Overtrapper", 2],
  2467. ["Mega Trapper", 3],
  2468. ["Auto Trapper", 4],
  2469. ["Hybrid", 0],
  2470. ["Annihilator", 1],
  2471. ["Skimmer", 2],
  2472. ["Rocketeer", 3],
  2473. ["Glider", 4],
  2474. ["Auto Gunner", {cond: "Gunner", num: 0}, {cond: "Auto 3", num: 1}],
  2475. ["Booster", 0],
  2476. ["Fighter", 1],
  2477. ["Landmine", 0],
  2478. ["Auto Smasher", 1],
  2479. ["Spike", 2],
  2480. ];
  2481.  
  2482. function convert_id_name(type, value) {
  2483. const tank = window.__common__.tanks.find(
  2484. type === "id to name"
  2485. ? (tank) => tank.id === value
  2486. : (tank) => tank.name === value
  2487. );
  2488.  
  2489. if (!tank) {
  2490. console.error(`Tank not found for ${type}: ${value}`);
  2491. return null;
  2492. }
  2493.  
  2494. return type === "id to name" ? tank.name : tank.id;
  2495. }
  2496.  
  2497.  
  2498. function find_upgrade_cond(tank_name) {
  2499. const target_id = convert_id_name("name to id", tank_name);
  2500. if (!target_id) {
  2501. console.error("Target ID not found");
  2502. return null;
  2503. }
  2504.  
  2505. console.log(`Target ID for ${tank_name}: ${target_id}`);
  2506.  
  2507. const tree_result = findTankAndParent(tanks_tree, target_id);
  2508. if (!tree_result) {
  2509. console.error(`Tank not found in tree for ID: ${target_id}`);
  2510. return null;
  2511. }
  2512.  
  2513. const cond_id = tree_result.parent;
  2514.  
  2515. const cond_name = convert_id_name("id to name", cond_id);
  2516. if (!cond_name) {
  2517. console.error("Condition name not found");
  2518. return null;
  2519. }
  2520.  
  2521. return cond_name;
  2522. }
  2523.  
  2524. function get_full_path(Tank){
  2525. let current_tank = Tank;
  2526. let temp_arr = [];
  2527. temp_arr.push(Tank);
  2528. while(find_upgrade_cond(current_tank) != null){
  2529. current_tank = find_upgrade_cond(current_tank);
  2530. temp_arr.push(current_tank);
  2531. }
  2532. temp_arr.reverse();
  2533. return temp_arr;
  2534. }
  2535.  
  2536. function auto_upgrade(Tank){
  2537. if(player.tank === Tank){
  2538. console.log("you are already that tank");
  2539. return;
  2540. }
  2541. let temp_arr = get_full_path(Tank);
  2542. let l = temp_arr.length;
  2543. let bool = false;
  2544. for(let i = 0; i < l; i++){
  2545. if(player.tank === temp_arr[i] && i != l){
  2546. console.log(`upgrading to ${temp_arr[i+1]}`);
  2547. handle_tank_upgrades(temp_arr[i+1]);
  2548. bool = true;
  2549. break;
  2550. }
  2551. }
  2552. !bool?console.warn("something went wrong"):null;
  2553. }
  2554.  
  2555. function handle_tank_upgrades(Tank){
  2556. let l = tank_box_nums.length;
  2557. let temp_arr = [];
  2558. let cond_num = -1;
  2559. for(let i = 0; i < l; i++){
  2560. let target = tank_box_nums[i];
  2561. if(target[0] === Tank){
  2562. temp_arr = tank_box_nums[i];
  2563. break
  2564. }
  2565. }
  2566. switch(true){
  2567. case temp_arr.length === 2:
  2568. cond_num = temp_arr[1];
  2569. break
  2570. case temp_arr.length > 2:
  2571. for(let j = 1; j < temp_arr.length; j++){
  2572. if(player.tank === temp_arr[j].cond){
  2573. cond_num = temp_arr[j].num;
  2574. }
  2575. }
  2576. break
  2577. default:
  2578. console.warn("temp_arr in illegal state, quitting...");
  2579. return
  2580. }
  2581. window.upgrading = true;
  2582. upgrade(boxes[cond_num].color);
  2583. }
  2584.  
  2585. let test_tank = "Auto Trapper";
  2586. function upgrade_func(){
  2587. if(state === "in game" && player.level >= 45 && player.tank != test_tank){
  2588. auto_upgrade(test_tank);
  2589. }else{
  2590. window.upgrading = false;
  2591. }
  2592. }
  2593.  
  2594. //setInterval(upgrade_func, 100);
  2595.  
  2596. //canvas gui
  2597. let offsetX = 0;
  2598. let offsetY = 0;
  2599. //for canvas text height and space between it
  2600. let text_startingY = canvas_2_windowScaling(450);
  2601. let textAdd = canvas_2_windowScaling(25);
  2602. let selected_box = null;
  2603. let _bp = { //box parameters
  2604. startX: 47,
  2605. startY: 67,
  2606. distX: 13,
  2607. distY: 9,
  2608. width: 86,
  2609. height: 86,
  2610. outer_xy: 2
  2611. }
  2612.  
  2613. let _bo = { //box offsets
  2614. offsetX: _bp.width + (_bp.outer_xy * 2) + _bp.distX,
  2615. offsetY: _bp.height + (_bp.outer_xy * 2) + _bp.distY
  2616. }
  2617.  
  2618. function step_offset(steps, offset){
  2619. let final_offset = 0;
  2620. switch(offset){
  2621. case "x":
  2622. final_offset = _bp.startX + (steps * _bo.offsetX);
  2623. break
  2624. case "y":
  2625. final_offset = _bp.startY + (steps * _bo.offsetY);
  2626. break
  2627. }
  2628. return final_offset;
  2629. }
  2630.  
  2631. const boxes = [
  2632. {
  2633. color: "lightblue",
  2634. LUcornerX: _bp.startX,
  2635. LUcornerY: _bp.startY
  2636. },
  2637. {
  2638. color: "green",
  2639. LUcornerX: _bp.startX + _bo.offsetX,
  2640. LUcornerY: _bp.startY
  2641. },
  2642. {
  2643. color: "red",
  2644. LUcornerX: _bp.startX,
  2645. LUcornerY: _bp.startY + _bo.offsetY
  2646. },
  2647. {
  2648. color: "yellow",
  2649. LUcornerX: _bp.startX + _bo.offsetX,
  2650. LUcornerY: _bp.startY + _bo.offsetY
  2651. },
  2652. {
  2653. color: "blue",
  2654. LUcornerX: _bp.startX,
  2655. LUcornerY: step_offset(2, "y")
  2656. },
  2657. {
  2658. color: "rainbow",
  2659. LUcornerX: _bp.startX + _bo.offsetX,
  2660. LUcornerY: step_offset(2, "y")
  2661. }
  2662. ]
  2663.  
  2664. //new upgrading Tank logic
  2665. function upgrade_get_coords(color){
  2666. let l = boxes.length;
  2667. let upgrade_coords = {x: "not defined", y: "not defined"};
  2668. for(let i = 0; i < l; i++){
  2669. if(boxes[i].color === color){
  2670. upgrade_coords.x = windowScaling_2_window(boxes[i].LUcornerX + (_bp.width/2));
  2671. upgrade_coords.y = windowScaling_2_window(boxes[i].LUcornerY + (_bp.height/2));
  2672. }
  2673. }
  2674. return upgrade_coords;
  2675. }
  2676.  
  2677. function get_invert_mouse_coords(){
  2678. let _x = coords.x;
  2679. let _y = coords.y;
  2680. let center = {x: window.innerWidth/2, y: window.innerHeight/2};
  2681. let d = {x: _x-center.x, y: _y-center.y};
  2682. let inverted_coords = {x: center.x-d.x, y: center.y-d.y};
  2683. return inverted_coords;
  2684. }
  2685.  
  2686. let inverted = false;
  2687.  
  2688. function invert_mouse(){
  2689. window.requestAnimationFrame(invert_mouse);
  2690. if(toggleButtons.Mouse["Anti Aim"] || toggleButtons.Mouse["Freeze Mouse"]){
  2691. return;
  2692. }
  2693. if(!inverted){
  2694. mouse_move(coords.x, coords.y);
  2695. return;
  2696. }
  2697. let new_coords = get_invert_mouse_coords();
  2698. freezeMouseMove();
  2699. mouse_move(new_coords.x, new_coords.y);
  2700. }
  2701. window.requestAnimationFrame(invert_mouse);
  2702.  
  2703. function handle_sandbox_checks(){
  2704. if(toggleButtons.Mouse["Sandbox Hacks"]){
  2705. if(gamemode != "Sandbox"){
  2706. one_time_notification("To use sandbox hacks, switch to a sandbox server", rgbToNumber(...notification_rbgs.warning), 2500);
  2707. return;
  2708. }
  2709. if(input.get_convar("ren_upgrades") != 'true'){
  2710. input.set_convar("ren_upgrades", 'true');
  2711. one_time_notification(`force enabled ren_upgrades for the script`, rgbToNumber(...notification_rbgs.require), 2500);
  2712. }
  2713. triflank = true;
  2714. one_time_notification(`To start, upgrade to ${sandbox_hax_modes[sandbox_hax_index].tank}`, rgbToNumber(...notification_rbgs.normal), 2500);
  2715. }else{
  2716. triflank = false;
  2717. }
  2718. }
  2719.  
  2720. function smart_shgun(){
  2721. handle_sandbox_checks();
  2722. if(triflank && sandbox_hax_modes[sandbox_hax_index].name === "Shotgun"){
  2723. shotgun(sandbox_hax_index);
  2724. }
  2725. }
  2726. setInterval(smart_shgun, 200);
  2727.  
  2728. function smart_trap(){
  2729. handle_sandbox_checks();
  2730. if(triflank && sandbox_hax_modes[sandbox_hax_index].name === "Trap Flip"){
  2731. one_time_notification("Warning! Trap Flip uses flip fire, which might be incosistent on laggy servers", rgbToNumber(...notification_rbgs.warning), 2500);
  2732. flip_trap1(sandbox_hax_index);
  2733. }else{
  2734. inverted?inverted = false: null;
  2735. }
  2736. }
  2737.  
  2738. setInterval(smart_trap, 250);
  2739.  
  2740. function smart_triflank(){
  2741. handle_sandbox_checks();
  2742. if(triflank && !sandbox_hax_modes[sandbox_hax_index].unique){
  2743. sandbox_hax_loop(sandbox_hax_index);
  2744. }
  2745. }
  2746.  
  2747. setInterval(smart_triflank, 200);
  2748.  
  2749. function is_between(Tank){
  2750. //USE FOR SANDBOX ONLY
  2751. let start = find_upgrade_cond(Tank);
  2752. let end = Tank;
  2753. let interval = [convert_id_name("name to id", start), convert_id_name("name to id", end)];
  2754. let ids = [];
  2755. for(let i = interval[1]; i >= interval[0]; i--){
  2756. let name = convert_id_name("id to name", i);
  2757. ids.push(name);
  2758. }
  2759. return ids.includes(player.tank);
  2760. }
  2761.  
  2762. function sandbox_hax_loop(i){
  2763. if(player.tank === find_upgrade_cond(sandbox_hax_modes[i].tank)){
  2764. //auto_spin?null:key_press("KeyC", 100 * multiplier);
  2765. //auto_spin = !auto_spin;
  2766. setTimeout(() => {
  2767. upgrade(sandbox_hax_modes[i].color, 0, 0, 0);
  2768. }, 100);
  2769. setTimeout(() => {
  2770. mouse_move(coords.x, coords.y);
  2771. }, 100);
  2772. }else if(is_between(sandbox_hax_modes[i].tank)){
  2773. //auto_spin?key_press("KeyC", 250 * multiplier):null;
  2774. //auto_spin = !auto_spin;
  2775. key_press("Backslash", 100);
  2776. }
  2777. }
  2778.  
  2779. function flip_trap1(i){
  2780. if(player.tank === find_upgrade_cond(sandbox_hax_modes[i].tank)){
  2781. setTimeout(() => {
  2782. inverted = true;
  2783. }, 200);
  2784. setTimeout(() => {
  2785. upgrade(sandbox_hax_modes[i].color, 0, 0, 0);
  2786. }, 250);
  2787. }else if(is_between(sandbox_hax_modes[i].tank)){
  2788. setTimeout(() => {
  2789. inverted = false;
  2790. }, 50);
  2791. setTimeout(() => {
  2792. key_press("Backslash");
  2793. }, 75);
  2794. }
  2795. }
  2796.  
  2797. function shotgun(i){
  2798. console.log(sandbox_hax_modes[i].tank);
  2799. if(player.tank === find_upgrade_cond(sandbox_hax_modes[i].tank[0]) || player.tank === find_upgrade_cond(sandbox_hax_modes[i].tank[1])){
  2800. upgrade(sandbox_hax_modes[i].color, 0, 0, 0);
  2801. mouse_move(coords.x, coords.y);
  2802. // }else if(is_between(sandbox_hax_modes[i].tank[1])){
  2803. }else if(player.tank === sandbox_hax_modes[i].tank[1]){
  2804. key_press("Backslash", 0);
  2805. }
  2806. }
  2807.  
  2808. function upgrade(color, delay = 100, cdelay1, cdelay2){
  2809. let u_coords = upgrade_get_coords(color);
  2810. ghost_click_at(u_coords.x, u_coords.y, cdelay1, cdelay2);
  2811. }
  2812.  
  2813. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  2814. ctx.fillStyle = fcolor;
  2815. ctx.lineWidth = lineWidth;
  2816. ctx.font = font;
  2817. ctx.strokeStyle = scolor;
  2818. ctx.strokeText(`${text}`, textX, textY)
  2819. ctx.fillText(`${text}`, textX, textY)
  2820. }
  2821.  
  2822. function ctx_rect(x, y, a, b, c) {
  2823. ctx.beginPath();
  2824. ctx.strokeStyle = c;
  2825. ctx.strokeRect(x, y, a, b);
  2826. }
  2827.  
  2828. //use this for game entities
  2829. function dot_in_diepunits(diepunits_X, diepunits_Y) {
  2830. ctx_arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, 5, 0, 2 * Math.PI, false, "lightblue");
  2831. }
  2832.  
  2833. function circle_in_diepunits(diepunits_X, diepunits_Y, diepunits_R, c) {
  2834. ctx.beginPath();
  2835. ctx.arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, diepunits_R * scalingFactor, 0, 2 * Math.PI, false);
  2836. ctx.strokeStyle = c;
  2837. ctx.stroke();
  2838. }
  2839.  
  2840. function big_half_circle(diepunits_X, diepunits_Y, diepunits_R, c) {
  2841. let centerY = diepunits_Y * scalingFactor;
  2842. let centerX = diepunits_X * scalingFactor;
  2843. let angle = Math.atan2(coords.y - centerY, coords.x - centerX);
  2844. ctx.beginPath();
  2845. ctx.arc(centerX, centerY, diepunits_R * scalingFactor, angle - Math.PI / 2, angle + Math.PI / 2, false);
  2846. ctx.strokeStyle = c;
  2847. ctx.stroke();
  2848. }
  2849.  
  2850. function small_half_circle(diepunits_X, diepunits_Y, diepunits_R, c) {
  2851. let centerY = diepunits_Y * scalingFactor;
  2852. let centerX = diepunits_X * scalingFactor;
  2853. let angle = Math.atan2(coords.y - centerY, coords.x - centerX);
  2854. ctx.beginPath();
  2855. ctx.arc(centerX, centerY, diepunits_R * scalingFactor, angle + Math.PI / 2, angle - Math.PI / 2, false);
  2856. ctx.strokeStyle = c;
  2857. ctx.stroke();
  2858. }
  2859.  
  2860. //use this for ui elements like upgrades or scoreboard
  2861. function dot_in_diepunits_FOVless(diepunits_X, diepunits_Y) {
  2862. ctx_arc(canvas_2_windowScaling(diepunits_X), canvas_2_windowScaling(diepunits_Y), 5, 0, 2 * Math.PI, false, "lightblue");
  2863. }
  2864.  
  2865. function square_for_grid(x, y, a, b, color) {
  2866. ctx.beginPath();
  2867. ctx.rect(canvas_2_windowScaling(x), canvas_2_windowScaling(y), canvas_2_windowScaling(a), canvas_2_windowScaling(b));
  2868. ctx.strokeStyle = color;
  2869. ctx.stroke();
  2870. }
  2871.  
  2872. function draw_upgrade_grid() {
  2873. let box = {width: 86, height: 86}; //in windowScaling
  2874. let l = boxes.length;
  2875. for (let i = 0; i < l; i++) {
  2876. let start_x = windowScaling_2_window(boxes[i].LUcornerX);
  2877. let start_y = windowScaling_2_window(boxes[i].LUcornerY);
  2878. let end_x = windowScaling_2_window(boxes[i].LUcornerX + box.width);
  2879. let end_y = windowScaling_2_window(boxes[i].LUcornerY + box.height);
  2880. let temp_color = "black";
  2881. if (coords.x > start_x && coords.y > start_y && coords.x < end_x && coords.y < end_y) {
  2882. temp_color = "red";
  2883. selected_box = i;
  2884. } else {
  2885. temp_color = "black";
  2886. selected_box = null;
  2887. }
  2888. square_for_grid(boxes[i].LUcornerX, boxes[i].LUcornerY, 86, 86, temp_color);
  2889. }
  2890. for (let i = 0; i < l; i++) {
  2891. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY);
  2892. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width/2, boxes[i].LUcornerY);
  2893. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width, boxes[i].LUcornerY);
  2894. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width, boxes[i].LUcornerY + box.height/2);
  2895. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width, boxes[i].LUcornerY + box.height);
  2896. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY + box.height/2);
  2897. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY + box.height);
  2898. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width, boxes[i].LUcornerY + box.height/2);
  2899. }
  2900. }
  2901.  
  2902. const gradients = ["#94b3d0", "#96b0c7", "#778daa", "#4c7299", "#52596c", "#19254e", "#2d445f", "#172631"];
  2903. const tank_group1 = ["Trapper", "Overtrapper", "Mega Trapper", "Tri-Trapper"]; //Traps only
  2904. const tank_group2 = ["Tank", "Twin", "Triple Shot", "Spread Shot", "Penta Shot", "Machine Gun", "Sprayer", "Triplet"]; //constant bullets [initial speed = 0.699]
  2905. const tank_group2round = ["Twin Flank", "Triple Twin", "Quad Tank", "OctoT ank", "Flank Guard"];
  2906. const tank_group3 = ["GunnerTrapper"]; //Traps AND constant bullets
  2907. const tank_group4 = ["Fighter", "Booster", "Tri-Angle"]; // fast tanks
  2908. const tank_group5 = ["Sniper", "Assassin", "Stalker", "Ranger"]; //sniper+ bullets
  2909. const tank_group6 = ["Destroyer", "Hybrid", "Annihilator"]; //slower bullets [intitial speed = 0.699]
  2910. //const tank_group7 = ["Overseer", "Overlord", "Manager", "Necromancer"]; //infinite bullets(drones) (UNFINISHED)
  2911. const tank_group8 = ["Factory"]; //drones with spreading abilities
  2912. const tank_group9 = ["Battleship"]; //special case
  2913. const tank_group10 = ["Streamliner"]; // special case
  2914. const tank_group11 = ["Gunner", "AutoGunner"] // (UNFINISHED)
  2915.  
  2916. //get bullet speed
  2917. function count_fours(string) {
  2918. let fours_count = 0;
  2919. let temp_array = [...string];
  2920. for (let i = 0; i < temp_array.length; i++) {
  2921. if (temp_array[i] === "4") {
  2922. fours_count++;
  2923. }
  2924. }
  2925. return fours_count;
  2926. }
  2927.  
  2928. function draw_cirle_radius_for_tank() {
  2929. let b_s;
  2930. if (diep_data.length > 0) {
  2931. player.raw_build = diep_data[0][1];
  2932. player.real_time_build = real_build(player.raw_build);
  2933. b_s = count_fours(player.real_time_build);
  2934. } else {
  2935. b_s = 0;
  2936. }
  2937.  
  2938. if (tank_group1.includes(player.tank)) {
  2939. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 485 + (52.5 * b_s), gradients[b_s]);
  2940. } else if (tank_group2.includes(player.tank)) {
  2941. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  2942. } else if (tank_group2round.includes(player.tank)) {
  2943. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  2944. } else if (tank_group3.includes(player.tank)) {
  2945. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  2946. small_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 485 + (52.5 * b_s), gradients[b_s]);
  2947. } else if (tank_group4.includes(player.tank)) {
  2948. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  2949. small_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1135 + (100 * b_s), gradients[b_s]);
  2950. } else if (tank_group5.includes(player.tank)) {
  2951. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 2680 + (350 * b_s), gradients[b_s]);
  2952. } else if (tank_group6.includes(player.tank)) {
  2953. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1443.21 + (146.79 * b_s), gradients[b_s]);
  2954. /*
  2955. }else if(tank_group7.includes(player.tank)){
  2956. circle_in_diepunits( canvas.width/2/scalingFactor , canvas.height/2/scalingFactor, 1607 + (145*b_s), gradients[b_s]);
  2957. circle_in_diepunits( coords.x*2/scalingFactor , coords.y*2/scalingFactor, 1607 + (145*i), gradients[b_s]);
  2958. */
  2959. } else if (tank_group8.includes(player.tank)) {
  2960. if (!auto_fire) {
  2961. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 200, gradients[0]);
  2962. } else {
  2963. circle_in_diepunits(coords.x * two / scalingFactor, coords.y * two / scalingFactor, 800, gradients[1]);
  2964. circle_in_diepunits(coords.x * two / scalingFactor, coords.y * two / scalingFactor, 900, gradients[2]);
  2965. }
  2966. } else if (tank_group9.includes(player.tank)) {
  2967. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1640 + (210 * b_s), gradients[b_s]);
  2968. } else if (tank_group10.includes(player.tank)) {
  2969. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1750 + (190 * b_s), gradients[b_s]);
  2970. } else {
  2971. return;
  2972. }
  2973.  
  2974. }
  2975.  
  2976. //let's calculate the angle
  2977. var vector_l = [null, null];
  2978. var angle_l = 0;
  2979.  
  2980. function calc_leader() {
  2981. if (script_list.minimap_leader_v1) {
  2982. let xc = canvas.width / 2;
  2983. let yc = canvas.height / 2;
  2984. vector_l[0] = window.l_arrow.xl - xc;
  2985. vector_l[1] = window.l_arrow.yl - yc;
  2986. angle_l = Math.atan2(vector_l[1], vector_l[0]) * (180 / Math.PI);
  2987. } else if (script_list.minimap_leader_v2) {
  2988. let xc = canvas.width / 2;
  2989. let yc = canvas.height / 2;
  2990. vector_l[0] = window.L_X - xc;
  2991. vector_l[1] = window.L_Y - yc;
  2992. angle_l = Math.atan2(vector_l[1], vector_l[0]) * (180 / Math.PI);
  2993. } else {
  2994. console.log("waiting for leader script to give us values");
  2995. }
  2996. }
  2997.  
  2998. // Minimap logic
  2999. var minimap_elements = [
  3000. {
  3001. name: "minimap",
  3002. x: 177.5,
  3003. y: 177.5,
  3004. width: 162.5,
  3005. height: 162.5,
  3006. color: "purple"
  3007. },
  3008. {
  3009. name: "2 Teams Blue Team",
  3010. x: 177.5,
  3011. y: 177.5,
  3012. width: 17.5,
  3013. height: 162.5,
  3014. color: "blue"
  3015. },
  3016. {
  3017. name: "2 Teams Blue Team zone",
  3018. x: 160.0,
  3019. y: 177.5,
  3020. width: 17.5,
  3021. height: 162.5,
  3022. color: "SlateBlue"
  3023. },
  3024. {
  3025. name: "2 Teams Red Team",
  3026. x: 32.5,
  3027. y: 177.5,
  3028. width: 17.5,
  3029. height: 162.5,
  3030. color: "red"
  3031. },
  3032. {
  3033. name: "2 Teams Red Team zone",
  3034. x: 50,
  3035. y: 177.5,
  3036. width: 17.5,
  3037. height: 162.5,
  3038. color: "orangeRed"
  3039. },
  3040. {
  3041. name: "4 Teams Blue Team",
  3042. x: 177.5,
  3043. y: 177.5,
  3044. width: 25,
  3045. height: 25,
  3046. color: "blue"
  3047. },
  3048. {
  3049. name: "4 Teams Blue zone",
  3050. x: 177.5,
  3051. y: 177.5,
  3052. width: 40,
  3053. height: 40,
  3054. color: "SlateBlue"
  3055. },
  3056. {
  3057. name: "4 Teams Purple Team",
  3058. x: 40,
  3059. y: 177.5,
  3060. width: 25,
  3061. height: 25,
  3062. color: "purple"
  3063. },
  3064. {
  3065. name: "4 Teams Purple zone",
  3066. x: 55,
  3067. y: 177.5,
  3068. width: 40,
  3069. height: 40,
  3070. color: "Violet"
  3071. },
  3072. {
  3073. name: "4 Teams Green Team",
  3074. x: 177.5,
  3075. y: 40,
  3076. width: 25,
  3077. height: 25,
  3078. color: "green"
  3079. },
  3080. {
  3081. name: "4 Teams Green zone",
  3082. x: 177.5,
  3083. y: 55,
  3084. width: 40,
  3085. height: 40,
  3086. color: "LimeGreen"
  3087. },
  3088. {
  3089. name: "4 Teams Red Team",
  3090. x: 40,
  3091. y: 40,
  3092. width: 25,
  3093. height: 25,
  3094. color: "orangeRed"
  3095. },
  3096. {
  3097. name: "4 Teams Red zone",
  3098. x: 55,
  3099. y: 55,
  3100. width: 40,
  3101. height: 40,
  3102. color: "red"
  3103. },
  3104. ];
  3105.  
  3106. var m_e_ctx_coords = [
  3107. {
  3108. name: "minimap",
  3109. startx: null,
  3110. stary: null,
  3111. endx: null,
  3112. endy: null
  3113. },
  3114. {
  3115. name: "2 Teams Blue Team",
  3116. startx: null,
  3117. stary: null,
  3118. endx: null,
  3119. endy: null
  3120. },
  3121. {
  3122. name: "2 Teams Blue Team Zone",
  3123. startx: null,
  3124. stary: null,
  3125. endx: null,
  3126. endy: null
  3127. },
  3128. {
  3129. name: "2 Teams Red Team",
  3130. startx: null,
  3131. stary: null,
  3132. endx: null,
  3133. endy: null
  3134. },
  3135. {
  3136. name: "2 Teams Red Team Zone",
  3137. startx: null,
  3138. stary: null,
  3139. endx: null,
  3140. endy: null
  3141. },
  3142. {
  3143. name: "4 Teams Blue Team",
  3144. startx: null,
  3145. stary: null,
  3146. endx: null,
  3147. endy: null
  3148. },
  3149. {
  3150. name: "4 Teams Blue zone",
  3151. startx: null,
  3152. stary: null,
  3153. endx: null,
  3154. endy: null
  3155. },
  3156. {
  3157. name: "4 Teams Purple Team",
  3158. startx: null,
  3159. stary: null,
  3160. endx: null,
  3161. endy: null
  3162. },
  3163. {
  3164. name: "4 Teams Purple zone",
  3165. startx: null,
  3166. stary: null,
  3167. endx: null,
  3168. endy: null
  3169. },
  3170. {
  3171. name: "4 Teams Green Team",
  3172. startx: null,
  3173. stary: null,
  3174. endx: null,
  3175. endy: null
  3176. },
  3177. {
  3178. name: "4 Teams Green zone",
  3179. startx: null,
  3180. stary: null,
  3181. endx: null,
  3182. endy: null
  3183. },
  3184. {
  3185. name: "4 Teams Red Team",
  3186. startx: null,
  3187. stary: null,
  3188. endx: null,
  3189. endy: null
  3190. },
  3191. {
  3192. name: "4 Teams Red zone",
  3193. startx: null,
  3194. stary: null,
  3195. endx: null,
  3196. endy: null
  3197. }
  3198. ]
  3199.  
  3200. function draw_minimap() {
  3201. let l = minimap_elements.length;
  3202. switch (gamemode) {
  3203. case "2 Teams":
  3204. for (let i = 0; i < 5; i++) {
  3205. if (i === 2 || i === 4) {
  3206. if (toggleButtons.Functional['Toggle Base Zones']) {
  3207. updateAndDrawElement(i);
  3208. }
  3209. } else {
  3210. updateAndDrawElement(i);
  3211. }
  3212. }
  3213. break;
  3214. case "4 Teams":
  3215. updateAndDrawElement(0);
  3216. for (let i = 5; i < l; i++) {
  3217. if (i === 6 || i === 8 || i === 10 || i === 12) {
  3218. if (toggleButtons.Functional['Toggle Base Zones']) {
  3219. updateAndDrawElement(i);
  3220. }
  3221. } else {
  3222. updateAndDrawElement(i);
  3223. }
  3224. }
  3225. break;
  3226. }
  3227. if (script_list.minimap_leader_v1 || script_list.minimap_leader_v2) {
  3228. minimap_collision_check();
  3229. }
  3230. }
  3231.  
  3232. function updateAndDrawElement(index) {
  3233. // Update their real-time position
  3234. m_e_ctx_coords[index].startx = canvas.width - (minimap_elements[index].x * windowScaling());
  3235. m_e_ctx_coords[index].starty = canvas.height - (minimap_elements[index].y * windowScaling());
  3236. m_e_ctx_coords[index].endx = m_e_ctx_coords[index].startx + minimap_elements[index].width * windowScaling();
  3237. m_e_ctx_coords[index].endy = m_e_ctx_coords[index].starty + minimap_elements[index].height * windowScaling();
  3238.  
  3239. // Draw the element
  3240. ctx.beginPath();
  3241. ctx.rect(m_e_ctx_coords[index].startx, m_e_ctx_coords[index].starty, minimap_elements[index].width * windowScaling(), minimap_elements[index].height * windowScaling());
  3242. ctx.lineWidth = "1";
  3243. ctx.strokeStyle = minimap_elements[index].color;
  3244. ctx.stroke();
  3245. }
  3246.  
  3247. function minimap_collision_check() {
  3248. if (script_list.minimap_leader_v1 || script_list.minimap_leader_v2) {
  3249. let x = script_list.minimap_leader_v1 ? window.m_arrow.xl : window.M_X;
  3250. let y = script_list.minimap_leader_v1 ? window.m_arrow.yl : window.M_Y;
  3251.  
  3252. if (m_e_ctx_coords[0].startx < x &&
  3253. m_e_ctx_coords[0].starty < y &&
  3254. m_e_ctx_coords[0].endx > x &&
  3255. m_e_ctx_coords[0].endy > y) {
  3256.  
  3257. if (gamemode === "2 Teams") {
  3258. if (checkWithinBase(1, x, y)) position_on_minimap = "blue base";
  3259. else if (checkWithinBase(2, x, y)) position_on_minimap = "blue drones";
  3260. else if (checkWithinBase(3, x, y)) position_on_minimap = "red base";
  3261. else if (checkWithinBase(4, x, y)) position_on_minimap = "red drones";
  3262. else position_on_minimap = "not in the base";
  3263. } else if (gamemode === "4 Teams") {
  3264. if (checkWithinBase(6, x, y)) {
  3265. if (checkWithinBase(5, x, y)) {
  3266. position_on_minimap = "blue base"
  3267. } else {
  3268. position_on_minimap = "blue drones";
  3269. }
  3270. } else if (checkWithinBase(8, x, y)) {
  3271. if (checkWithinBase(7, x, y)) {
  3272. position_on_minimap = "purple base"
  3273. } else {
  3274. position_on_minimap = "purple drones";
  3275. }
  3276. } else if (checkWithinBase(10, x, y)) {
  3277. if (checkWithinBase(9, x, y)) {
  3278. position_on_minimap = "green base"
  3279. } else {
  3280. position_on_minimap = "green drones";
  3281. }
  3282. } else if (checkWithinBase(12, x, y)) {
  3283. if (checkWithinBase(11, x, y)) {
  3284. position_on_minimap = "red base"
  3285. } else {
  3286. position_on_minimap = "red drones";
  3287. }
  3288. } else {
  3289. position_on_minimap = "not in the base";
  3290. }
  3291. } else {
  3292. position_on_minimap = "Warning! not on minimap";
  3293. }
  3294. }
  3295. }
  3296. }
  3297.  
  3298. function checkWithinBase(baseIndex, x, y) {
  3299. return m_e_ctx_coords[baseIndex].startx < x &&
  3300. m_e_ctx_coords[baseIndex].starty < y &&
  3301. m_e_ctx_coords[baseIndex].endx > x &&
  3302. m_e_ctx_coords[baseIndex].endy > y;
  3303. }
  3304.  
  3305. //notify player about entering base zones
  3306. let alerted = false;
  3307.  
  3308. function alert_about_drones() {
  3309. if (position_on_minimap.includes('drones')) {
  3310. if (!alerted) {
  3311. new_notification("Warning drones!", rgbToNumber(...notification_rbgs.warning), 2500);
  3312. alerted = true;
  3313. }
  3314. } else {
  3315. alerted = false;
  3316. }
  3317. }
  3318.  
  3319. //let's try drawing a line to the leader
  3320.  
  3321. function apply_vector_on_minimap() {
  3322. if (script_list.minimap_leader_v1) {
  3323. let x = window.m_arrow.xl;
  3324. let y = window.m_arrow.yl;
  3325. let thetaRadians = angle_l * (Math.PI / 180);
  3326. let r = m_e_ctx_coords[0].endx - m_e_ctx_coords[0].startx;
  3327. let x2 = x + r * Math.cos(thetaRadians);
  3328. let y2 = y + r * Math.sin(thetaRadians);
  3329. ctx.beginPath();
  3330. ctx.moveTo(x, y);
  3331. ctx.lineTo(x2, y2);
  3332. ctx.stroke();
  3333. } else if (script_list.minimap_leader_v2) {
  3334. let x = window.M_X;
  3335. let y = window.M_Y;
  3336. let thetaRadians = angle_l * (Math.PI / 180);
  3337. let r = m_e_ctx_coords[0].endx - m_e_ctx_coords[0].startx;
  3338. let x2 = x + r * Math.cos(thetaRadians);
  3339. let y2 = y + r * Math.sin(thetaRadians);
  3340. ctx.beginPath();
  3341. ctx.moveTo(x, y);
  3342. ctx.lineTo(x2, y2);
  3343. ctx.stroke();
  3344. }
  3345. }
  3346.  
  3347.  
  3348. //drawing the limit of the server (needs rework)
  3349. function draw_server_border(a, b) {
  3350. ctx.beginPath();
  3351. ctx.rect(canvas.width / 2 - (a / 2 * scalingFactor), canvas.height / 2 - (b / 2 * scalingFactor), a * scalingFactor, b * scalingFactor);
  3352. ctx.strokeStyle = "red";
  3353. ctx.stroke();
  3354. }
  3355.  
  3356. const circle_gradients = [
  3357. "#FF0000", // Red
  3358. "#FF4D00", // Orange Red
  3359. "#FF8000", // Orange
  3360. "#FFB300", // Dark Goldenrod
  3361. "#FFD700", // Gold
  3362. "#FFEA00", // Yellow
  3363. "#D6FF00", // Light Yellow Green
  3364. "#A3FF00", // Yellow Green
  3365. "#6CFF00", // Lime Green
  3366. "#00FF4C", // Medium Spring Green
  3367. "#00FF9D", // Turquoise
  3368. "#00D6FF", // Sky Blue
  3369. "#006CFF", // Blue
  3370. "#0000FF" // Dark Blue
  3371. ];
  3372.  
  3373. function draw_crx_events() {
  3374. //you need either leader arrow or moveTo/lineTo script from h3llside for this part
  3375. if (script_list.moveToLineTo_debug) {
  3376. let l = window.y_and_x.length;
  3377. for (let i = 0; i < l; i++) {
  3378. ctx_arc(window.y_and_x[i][0], window.y_and_x[i][1], 10, 0, 2 * Math.PI, false, circle_gradients[i]);
  3379. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", i, window.y_and_x[i][0], window.y_and_x[i][1]);
  3380. }
  3381. } else if (script_list.minimap_leader_v1) {
  3382. //ctx_arc(window.l_arrow.xm, window.l_arrow.ym, 15, 0, 2 * Math.PI, false, window.l_arrow.color);
  3383. //ctx_arc(window.m_arrow.xm, window.m_arrow.ym, 1, 0, 2 * Math.PI, false, "yellow");
  3384. ctx_arc(window.l_arrow.xl, window.l_arrow.yl, 5, 0, 2 * Math.PI, false, window.l_arrow.color);
  3385. ctx_arc(window.m_arrow.xl, window.m_arrow.yl, 1, 0, 2 * Math.PI, false, "yellow");
  3386. }
  3387. }
  3388.  
  3389. //tank aim lines
  3390. let TurretRatios = [
  3391. {
  3392. name: "Destroyer",
  3393. ratio: 95 / 71.4,
  3394. color: "red"
  3395. },
  3396. {
  3397. name: "Anni",
  3398. ratio: 95 / 96.6,
  3399. color: "darkred"
  3400. },
  3401. {
  3402. name: "Fighter",
  3403. ratio: 80 / 42,
  3404. color: "orange"
  3405. },
  3406. {
  3407. name: "Booster",
  3408. ratio: 70 / 42,
  3409. color: "green"
  3410. },
  3411. {
  3412. name: "Tank",
  3413. ratio: 95 / 42,
  3414. color: "yellow"
  3415. },
  3416. {
  3417. name: "Sniper",
  3418. ratio: 110 / 42,
  3419. color: "yellow"
  3420. },
  3421. {
  3422. name: "Ranger",
  3423. ratio: 120 / 42,
  3424. color: "orange"
  3425. },
  3426. {
  3427. name: "Hunter",
  3428. ratio: 95 / 56.7,
  3429. color: "orange"
  3430. },
  3431. {
  3432. name: "Predator",
  3433. ratio: 80 / 71.4,
  3434. color: "darkorange"
  3435. },
  3436. {
  3437. name: "Mega Trapper",
  3438. ratio: 60 / 54.6,
  3439. color: "red"
  3440. },
  3441. {
  3442. name: "Trapper",
  3443. ratio: 60 / 42,
  3444. color: "orange"
  3445. },
  3446. {
  3447. name: "Gunner Trapper",
  3448. ratio: 95 / 26.6,
  3449. color: "yellow"
  3450. },
  3451. {
  3452. name: "Predator",
  3453. ratio: 95 / 84.8,
  3454. color: "red"
  3455. },
  3456. {
  3457. name: "Gunner(small)",
  3458. ratio: 65 / 25.2,
  3459. color: "lightgreen"
  3460. },
  3461. {
  3462. name: "Gunner(big)",
  3463. ratio: 85 / 25.2,
  3464. color: "green"
  3465. },
  3466. {
  3467. name: "Spread1",
  3468. ratio: 89 / 29.4,
  3469. color: "orange"
  3470. },
  3471. {
  3472. name: "Spread2",
  3473. ratio: 83 / 29.4,
  3474. color: "orange"
  3475. },
  3476. {
  3477. name: "Spread3",
  3478. ratio: 71 / 29.4,
  3479. color: "orange"
  3480. },
  3481. {
  3482. name: "Spread4",
  3483. ratio: 65 / 29.4,
  3484. color: "orange"
  3485. },
  3486. //{name: "bullet", ratio: 1, color: "pink"},
  3487. ];
  3488.  
  3489. function drawTheThing(x, y, r, index) {
  3490. if (toggleButtons.Visual['Toggle Aim Lines']) {
  3491. if (TurretRatios[index].name != "bullet") {
  3492. ctx.strokeStyle = TurretRatios[index].color;
  3493. ctx.lineWidth = 5;
  3494.  
  3495. let extendedR = 300 * scalingFactor;
  3496.  
  3497. // Reverse the angle to switch the direction
  3498. const reversedAngle = -angle;
  3499.  
  3500. // Calculate the end point of the line
  3501. const endX = x + extendedR * Math.cos(reversedAngle);
  3502. const endY = y + extendedR * Math.sin(reversedAngle);
  3503.  
  3504. // Draw the line
  3505. ctx.beginPath();
  3506. ctx.moveTo(x, y);
  3507. ctx.lineTo(endX, endY);
  3508. ctx.stroke();
  3509.  
  3510. // Draw text at the end of the line
  3511. ctx.font = "20px Arial";
  3512. ctx.fillStyle = TurretRatios[index].color;
  3513. ctx.strokeStyle = "black";
  3514. ctx.strokeText(TurretRatios[index].name, endX, endY);
  3515. ctx.fillText(TurretRatios[index].name, endX, endY);
  3516. ctx.beginPath();
  3517. } else {
  3518. ctx.strokeStyle = TurretRatios[index].color;
  3519. ctx.lineWidth = 5;
  3520.  
  3521. // Draw text at the end of the line
  3522. ctx.font = "15px Arial";
  3523. ctx.fillStyle = TurretRatios[index].color;
  3524. ctx.strokeStyle = "black";
  3525. let tankRadiusesTrans = [];
  3526. for (let i = 1; i <= 45; i++) {
  3527. let value = Math.abs((48.589 * (1.01 ** (i - 1))) * Math.abs(scalingFactor).toFixed(4)).toFixed(3);
  3528. tankRadiusesTrans.push(value);
  3529. }
  3530.  
  3531. let r_abs = Math.abs(r).toFixed(3);
  3532. if (r_abs < tankRadiusesTrans[0]) {
  3533. ctx.beginPath();
  3534. ctx.strokeStyle = TurretRatios[index].color;
  3535. ctx.arc(x, y - r / 2, r * 2, 0, 2 * Math.PI);
  3536. ctx.stroke();
  3537. ctx.beginPath();
  3538. } else {
  3539.  
  3540. // Find the closest value in the array
  3541. let closestValue = tankRadiusesTrans.reduce((prev, curr) => {
  3542. return (Math.abs(curr - r_abs) < Math.abs(prev - r_abs) ? curr : prev);
  3543. });
  3544.  
  3545. // Find the index of the closest value
  3546. let closestIndex = tankRadiusesTrans.indexOf(closestValue);
  3547.  
  3548. if (closestIndex !== -1) {
  3549. let r_name = `Level ${closestIndex + 1}`;
  3550. ctx.strokeText(r_name, x, y + 50 * scalingFactor);
  3551. ctx.fillText(r_name, x, y + 50 * scalingFactor);
  3552. ctx.beginPath();
  3553. } else {
  3554.  
  3555. let r_name = `radius: ${Math.abs(r).toFixed(4)} 1: ${tankRadiusesTrans[0]} 2: ${tankRadiusesTrans[1]} 3: ${tankRadiusesTrans[2]}`;
  3556. ctx.strokeText(r_name, x, y);
  3557. ctx.fillText(r_name, x, y);
  3558. ctx.beginPath();
  3559. }
  3560. /*
  3561. ctx.strokeText(TurretRatios[index].name, x, y);
  3562. ctx.fillText(TurretRatios[index].name, x, y);
  3563. */
  3564. }
  3565. }
  3566. }
  3567. }
  3568.  
  3569. var angle, a, b, width;
  3570. let perm_cont = [];
  3571.  
  3572. CanvasRenderingContext2D.prototype.setTransform = new Proxy(CanvasRenderingContext2D.prototype.setTransform, {
  3573. apply(target, thisArgs, args) {
  3574. // Check if the ratio matches the specified conditions
  3575. let l = TurretRatios.length;
  3576. for (let i = 0; i < l; i++) {
  3577. if (Math.abs(args[0] / args[3]).toFixed(3) == (TurretRatios[i].ratio).toFixed(3)) {
  3578. if (TurretRatios[i].name === "bullet") {
  3579. if (args[0] != 1 && args[0] > 10 && args[0] < 100 && args[4] > 1 && args[5] > 1 && args[4] != args[5] &&
  3580. thisArgs.globalAlpha != 0.10000000149011612 && thisArgs.globalAlpha != 0.3499999940395355) {
  3581. if (!perm_cont.includes(thisArgs)) {
  3582. perm_cont.push(thisArgs);
  3583. //console.log(perm_cont);
  3584. }
  3585. angle = Math.atan2(args[2], args[3]) || 0;
  3586. width = Math.hypot(args[3], args[2]);
  3587. a = args[4] - Math.cos(angle + Math.PI / 2) * width / 2;
  3588. b = args[5] + Math.sin(angle + Math.PI / 2) * width / 2;
  3589. //console.log(b);
  3590. if (a > 0 && b > 0 && thisArgs.fillStyle != "#1B1B1B") { //OUTLINE COLOR
  3591. drawTheThing(a, b, Math.hypot(args[3], args[2]), i);
  3592. }
  3593. }
  3594. } else {
  3595. angle = Math.atan2(args[2], args[3]) || 0;
  3596. width = Math.hypot(args[3], args[2]);
  3597. a = args[4] - Math.cos(angle + Math.PI / 2) * width / 2;
  3598. b = args[5] + Math.sin(angle + Math.PI / 2) * width / 2;
  3599. drawTheThing(a, b, Math.hypot(args[3], args[2]), i);
  3600. }
  3601. }
  3602. }
  3603. return Reflect.apply(target, thisArgs, args);
  3604. }
  3605. });
  3606.  
  3607. const ms_fps_clrs = ["lime", "green", "yellow", "orange", "darkorange", "red", "darkred"];
  3608. const ms_filters = new Uint16Array([15, 26, 50, 90, 170, 380, 1000]);
  3609. const fps_filters = new Uint16Array([59, 55, 50, 35, 20, 10, 5]);
  3610.  
  3611. function pick_fps_color() {
  3612. let fps_num = parseFloat(fps);
  3613. let l = fps_filters.length;
  3614. for (let i = 0; i < l; i++) {
  3615. if (fps_num > fps_filters[i]) {
  3616. ctx_text(ms_fps_clrs[i], "black", 4, 1 + "em Ubuntu", fps + "fps", canvas.width / 2, canvas.height / 2);
  3617. return;
  3618. }
  3619. }
  3620. }
  3621.  
  3622. function pick_ms_color() {
  3623. let ms_num = parseFloat(ms);
  3624. for (let i = 0; i < ms_filters.length; i++) {
  3625. if (ms_num < ms_filters[i]) {
  3626. ctx_text(ms_fps_clrs[i], "black", 4, 1 + "em Ubuntu", ms + "ms", canvas.width / 2, canvas.height / 2 + 20);
  3627. return;
  3628. }
  3629. }
  3630. }
  3631.  
  3632. setTimeout(() => {
  3633. let gui = () => {
  3634. check_addon_scripts();
  3635. text_startingY = canvas_2_windowScaling(450);
  3636. textAdd = canvas_2_windowScaling(25);
  3637. if (state === "in game") {
  3638. if (ms_active) {
  3639. pick_fps_color();
  3640. pick_ms_color();
  3641. }
  3642. if (toggleButtons.Visual['Toggle Minimap']) {
  3643. draw_minimap();
  3644. }
  3645. if (toggleButtons.Functional['Toggle Base Zones']) {
  3646. toggleButtons.Visual['Toggle Minimap'] = true;
  3647. alert_about_drones();
  3648. }
  3649. if (script_list.minimap_leader_v2) {
  3650. if (toggleButtons.Visual['Toggle Leader Angle']) {
  3651. if (!script_list.minimap_leader_v2) {
  3652. new_notification("missing Leader & Minimap Arrow(Mi300)", rgbToNumber(...notification_rbgs.require), 5000);
  3653. }
  3654. if (!toggleButtons.Visual['Toggle Minimap']) {
  3655. new_notification("Enabled Minimap for it to work properly. To turn it off, go to Visual -> Minimap", rgbToNumber(...notification_rbgs.normal), 5000);
  3656. toggleButtons.Visual['Toggle Minimap'] = true;
  3657. } else {
  3658. calc_leader();
  3659. apply_vector_on_minimap();
  3660. }
  3661. }
  3662. }
  3663. if (toggleButtons.Debug['Toggle Arrow pos']) {
  3664. window.arrowv2_debug = true;
  3665. } else {
  3666. window.arrowv2_debug = false;
  3667. }
  3668. if (script_list.set_transform_debug) {
  3669. ctx_arc(window.crx_container[2], window.crx_container[3], 50, 0, 2 * Math.PI, false, "yellow");
  3670. }
  3671. if (toggleButtons.Debug['Toggle Text']) {
  3672. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "canvas Lvl:" + player.level, canvas.width / 20 + 10, text_startingY + (textAdd * 0));
  3673. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "canvas tank: " + player.tank, canvas.width / 20 + 10, text_startingY + (textAdd * 1));
  3674. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "radius: " + ripsaw_radius, canvas.width / 20 + 10, text_startingY + (textAdd * 2));
  3675. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "scaling Factor: " + scalingFactor, canvas.width / 20 + 10, text_startingY + (textAdd * 3));
  3676. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "diep Units: " + diepUnits, canvas.width / 20 + 10, text_startingY + (textAdd * 4));
  3677. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "Fov: " + FOV, canvas.width / 20 + 10, text_startingY + (textAdd * 5));
  3678. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "current Tick: " + currentTick, canvas.width / 20 + 10, text_startingY + (textAdd * 6));
  3679. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "vector: " + Math.floor(vector_l[0]) + ", " + Math.floor(vector_l[1]) + "angle: " + Math.floor(angle_l), canvas.width / 20 + 10, text_startingY + (textAdd * 7));
  3680. //ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "realX: " + coords.x + "realY: " + coords.y + "newX: " + coords.x*windowScaling() + "newY: " + coords.y*windowScaling(), coords.x*2, coords.y*2);
  3681.  
  3682. //points at mouse
  3683. ctx_arc(coords.x * two, coords.y * two, 5, 0, 2 * Math.PI, false, "purple");
  3684. /*
  3685. circle_in_diepunits(coords.x*2/scalingFactor, coords.y*2/scalingFactor, 35, "pink");
  3686. circle_in_diepunits(coords.x*2/scalingFactor, coords.y*2/scalingFactor, 55, "yellow");
  3687. circle_in_diepunits(coords.x*2/scalingFactor, coords.y*2/scalingFactor, 75, "purple");
  3688. circle_in_diepunits(coords.x*2/scalingFactor, coords.y*2/scalingFactor, 200, "blue");
  3689. */
  3690.  
  3691. //coords at mouse
  3692. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "realX: " + coords.x * two + "realY: " + coords.y * two, coords.x * two, coords.y * two);
  3693. }
  3694.  
  3695. if (player.level != null && player.tank != null) {
  3696. if (toggleButtons.Debug['Toggle Middle Circle']) {
  3697. ctx.beginPath();
  3698. ctx.moveTo(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY);
  3699. ctx.lineTo(coords.x * two, coords.y * two);
  3700. ctx.stroke();
  3701. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius, 0, 2 * Math.PI, false, "darkblue");
  3702. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius * 0.9, 0, 2 * Math.PI, false, "lightblue");
  3703. }
  3704. if (toggleButtons.Debug['Toggle Upgrades']) {
  3705. draw_upgrade_grid();
  3706. }
  3707. //draw_server_border(4000, 2250);
  3708. draw_crx_events();
  3709. if (toggleButtons.Visual['Toggle Bullet Distance']) {
  3710. draw_cirle_radius_for_tank();
  3711. }
  3712. };
  3713. }
  3714. window.requestAnimationFrame(gui);
  3715. }
  3716. gui();
  3717. setTimeout(() => {
  3718. gui();
  3719. }, 5000);
  3720. }, 1000);
  3721.  
  3722. // Alert players about missing scripts (for addons)
  3723. let notified = {};
  3724.  
  3725. function require(category, toggleButton, script) {
  3726. if (state === "in game") {
  3727. const notificationKey = `${category}-${toggleButton}-${script}`;
  3728. if (toggleButtons[category]?.[toggleButton] && !script_list[script] && !notified[notificationKey]) {
  3729. new_notification(`${toggleButton} requires ${script} to be active!`, rgbToNumber(...notification_rbgs.require), 7500);
  3730. notified[notificationKey] = true;
  3731. }
  3732. }
  3733. }
  3734.  
  3735. function check_addon_scripts() {
  3736. require('Addons', 'FOV changer', 'fov');
  3737. }
  3738.  
  3739. //cooldowns (unfinished)
  3740. let c_cd = "red";
  3741. let c_r = "green";
  3742. const cooldowns = [
  3743. {
  3744. Tank: "Destroyer",
  3745. cooldown0: 109,
  3746. cooldown1: 94,
  3747. cooldown2: 81,
  3748. cooldown3: 86
  3749. },
  3750. ]
  3751.  
  3752. //detect which slot was clicked
  3753. document.addEventListener('mousedown', checkPos)
  3754.  
  3755. function checkPos(e) {
  3756. console.log(boxes[selected_box]);
  3757. }
  3758.  
  3759.  
  3760. //warns you about annis, destroyers
  3761. /*
  3762. function drawTheThing(x,y,r) {
  3763. if(script_boolean){
  3764. let a = ctx.fillStyle;
  3765. ctx.fillStyle = "#FF000044";
  3766. ctx.beginPath();
  3767. ctx.arc(x,y,4*r,0,2*Math.PI);
  3768. ctx.fill();
  3769. ctx.fillStyle = "#FF000066";
  3770. ctx.beginPath();
  3771. ctx.arc(x,y,2*r,0,2*Math.PI);
  3772. ctx.fill();
  3773. ctx.beginPath();
  3774. }
  3775. }
  3776. var angle,a,b,width;
  3777. CanvasRenderingContext2D.prototype.setTransform = new Proxy(CanvasRenderingContext2D.prototype.setTransform, {
  3778. apply(target, thisArgs, args) {
  3779. //console.log(thisArgs)
  3780. if (Math.abs(args[0]/args[3]).toFixed(3) == (95/71.4).toFixed(3) || Math.abs(args[0]/args[3]).toFixed(3) == (95/96.6).toFixed(3)) {
  3781. angle = Math.atan2(args[2],args[3]) || 0;
  3782. width = Math.hypot(args[3], args[2]);
  3783. a = args[4]-Math.cos(angle+Math.PI/2)*width/2;
  3784. b = args[5]+Math.sin(angle+Math.PI/2)*width/2;
  3785. drawTheThing(a,b, Math.hypot(args[3],args[2]));
  3786. }
  3787. return Reflect.apply(target, thisArgs, args);
  3788. }
  3789. });
  3790. */
  3791.  
  3792. //physics for movement (UNFINISHED)
  3793. /*
  3794. //movement speed ingame stat
  3795. let m_s = [0, 1, 2, 3, 4, 5, 6, 7];
  3796.  
  3797. function accelarate(A_o){
  3798. //Accelaration
  3799. let sum = 0;
  3800. runForTicks((ticksPassed, currentTick) => {
  3801. console.log("sum is being calculated...");
  3802. sum += A_o * Math.pow(0.9, ticksPassed - 1);
  3803. offsetX = Math.floor(sum * scalingFactor);
  3804. console.log(offsetX);
  3805. }, 50);
  3806. //decelerate(sum);
  3807. }
  3808.  
  3809. function decelerate(sum){
  3810. //deceleration
  3811. let res = 0;
  3812. runForTicks((ticksPassed, currentTick) => {
  3813. console.log("res is being calculated...");
  3814. res = sum * Math.pow(0.9, ticksPassed);
  3815. offsetX = Math.floor(res * scalingFactor);
  3816. console.log(offsetX);
  3817. }, 50);
  3818. }
  3819. function calculate_speed(movement_speed_stat){
  3820. console.log("calculate_speed function called");
  3821. //use Accelaration for first 50 ticks, then deceleration until ticks hit 100, then stop moving
  3822.  
  3823. //calculating base value, we'll need this later
  3824. let a = (1.07**movement_speed_stat);
  3825. let b = (1.015**(player.level - 1));
  3826. let A_o = 2.55*(a/b);
  3827. accelarate(A_o);
  3828. }
  3829. */
  3830.  
  3831. //handle Key presses
  3832. let key_storage = [];
  3833. let keyHeld = {};
  3834.  
  3835. document.onkeydown = function(e) {
  3836. if (!keyHeld[e.key]) {
  3837. keyHeld[e.key] = true;
  3838. key_storage.push(e.key);
  3839. analyse_keys();
  3840. }
  3841. console.log(key_storage);
  3842. };
  3843.  
  3844. document.onkeyup = function(e) {
  3845. if (key_storage.includes(e.key)) {
  3846. key_storage.splice(key_storage.indexOf(e.key), 1);
  3847. }
  3848. keyHeld[e.key] = false;
  3849. console.log(key_storage);
  3850. analyse_keys();
  3851. };
  3852.  
  3853. function analyse_keys() {
  3854. if (key_storage.includes("j")) { //J
  3855. change_visibility();
  3856. //auto spin && auto fire
  3857. } else if (key_storage.includes("l")) {
  3858. ms_active = !ms_active;
  3859. } else if (key_storage.includes("e")) { //E
  3860. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  3861. f_s("fire");
  3862. } else {
  3863. auto_fire = false;
  3864. }
  3865. console.log(auto_fire);
  3866. }else if (key_storage.includes("c")) {
  3867. console.log(auto_spin);
  3868. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  3869. f_s("spin");
  3870. } else {
  3871. auto_spin = false;
  3872. }
  3873. console.log(auto_spin);
  3874. //stats
  3875. } else if (toggleButtons.Functional['Stats']) {
  3876. if (key_storage.includes("u")) {
  3877. if (key_storage.includes("r")) {
  3878. reset_stats();
  3879. }
  3880. if (!document.body.contains(upgrade_box)) {
  3881. document.body.appendChild(upgrade_box);
  3882. }
  3883. update_stats();
  3884. if (stats_limit >= 0) {
  3885. for (let i = 1; i < 9; i++) {
  3886. if (key_storage.includes(`${i}`) && stats[i] < 7) {
  3887. stats[i] += 1;
  3888. stats_limit -= 1;
  3889. }
  3890. }
  3891. }
  3892. } else {
  3893. if (document.body.contains(upgrade_box)) {
  3894. document.body.removeChild(upgrade_box);
  3895. }
  3896. use_stats_ingame();
  3897. }
  3898. }
  3899. }
  3900.  
  3901. //stats handler
  3902. var stats_instructions_showed = false;
  3903.  
  3904. function show_stats_instructions() {
  3905. if (toggleButtons.Functional['Stats']) {
  3906. input.execute("ren_stats false");
  3907. if (!stats_instructions_showed) {
  3908. if (state === "in game") {
  3909. use_stats_ingame();
  3910. new_notification("Usage: hold 'u' button and then press a number between 1 and 9", rgbToNumber(...notification_rbgs.normal), 5000);
  3911. new_notification("Explanation: this module lets you choose a tank build that will stay even after you die", rgbToNumber(...notification_rbgs.normal), 5100);
  3912. new_notification("unless you press r while pressing u", rgbToNumber(...notification_rbgs.normal), 5200);
  3913. stats_instructions_showed = true;
  3914. }
  3915. } else {
  3916. if (state === "in menu") {
  3917. stats_instructions_showed = false;
  3918. }
  3919. }
  3920. } else {
  3921. input.execute("ren_stats true");
  3922. }
  3923. }
  3924.  
  3925. setInterval(show_stats_instructions, 500);
  3926. let stats = ["don't use this", 0, 0, 0, 0, 0, 0, 0, 0];
  3927. let stats_limit = 32;
  3928.  
  3929. function update_stats() {
  3930. let l = stats.length;
  3931. for (let i = 1; i < l; i++) {
  3932. let stat_steps = stats[i];
  3933. for (let j = 1; j < stat_steps + 1; j++) {
  3934. let stat_row = document.querySelector(`#row${[i]} > #s_box${j}`);
  3935. stat_row.style.backgroundColor = `${upgrade_name_colors[i]}`;
  3936. }
  3937. }
  3938. }
  3939.  
  3940. function reset_stats() {
  3941. let l = stats.length;
  3942. for (let i = 1; i < l; i++) {
  3943. let stat_steps = stats[i];
  3944. for (let j = 1; j < stat_steps + 1; j++) {
  3945. let stat_row = document.querySelector(`#row${[i]} > #s_box${j}`);
  3946. stat_row.style.backgroundColor = "black";
  3947. }
  3948. }
  3949. stats = ["don't use this", 0, 0, 0, 0, 0, 0, 0, 0];
  3950. stats_limit = 32;
  3951. }
  3952.  
  3953. function use_stats_ingame() {
  3954. let final_decision = "";
  3955. for (let i = 5; i < 9; i++) {
  3956. for (let j = 0; j < stats[i]; j++) {
  3957. final_decision += `${i}`;
  3958. }
  3959. }
  3960. for (let i = 1; i < 5; i++) {
  3961. for (let j = 0; j < stats[i]; j++) {
  3962. final_decision += `${i}`;
  3963. }
  3964. }
  3965. input.execute(`game_stats_build ${final_decision}`);
  3966. }
  3967.  
  3968. const upgrade_names = [
  3969. "don't use this",
  3970. "Health Regen",
  3971. "Max Health",
  3972. "Body Damage",
  3973. "Bullet Speed",
  3974. "Bullet Penetration",
  3975. "Bullet Damage",
  3976. "Reload",
  3977. "Movement Speed",
  3978. ];
  3979.  
  3980. const upgrade_name_colors = [
  3981. "don't use this",
  3982. "DarkSalmon",
  3983. "pink",
  3984. "DarkViolet",
  3985. "DodgerBlue",
  3986. "yellow",
  3987. "red",
  3988. "lime",
  3989. "lightblue",
  3990. ];
  3991.  
  3992. const upgrade_box = document.createElement("div");
  3993. upgrade_box.style.width = "400px";
  3994. upgrade_box.style.height = "300px";
  3995. upgrade_box.style.backgroundColor = "lightGray";
  3996. upgrade_box.style.position = "fixed";
  3997. upgrade_box.style.display = "block";
  3998. upgrade_box.style.bottom = "10px";
  3999. upgrade_box.style.zIndex = 100;
  4000.  
  4001. for (let i = 1; i < 9; i++) {
  4002. create_upgrades(`row${i}`, i);
  4003. }
  4004.  
  4005. function create_upgrades(name, rownum) {
  4006. let black_box = document.createElement("div");
  4007. black_box.id = name;
  4008. black_box.style.width = "350px";
  4009. black_box.style.height = "20px";
  4010. black_box.style.position = "relative";
  4011. black_box.style.display = "block";
  4012. black_box.style.marginTop = "15px";
  4013. black_box.style.left = "25px";
  4014. for (let i = 1; i < 8; i++) {
  4015. let small_box = document.createElement("div");
  4016. small_box.id = `s_box${i}`;
  4017. small_box.style.width = "20px";
  4018. small_box.style.height = "20px";
  4019. small_box.style.backgroundColor = "black";
  4020. small_box.style.display = "inline-block";
  4021. small_box.style.border = "2px solid white";
  4022.  
  4023. black_box.appendChild(small_box);
  4024. }
  4025. let upgrade_btn = document.createElement("button");
  4026. upgrade_btn.id = upgrade_names[rownum];
  4027. upgrade_btn.style.color = "black";
  4028. upgrade_btn.innerHTML = "+";
  4029. upgrade_btn.style.width = "20px";
  4030. upgrade_btn.style.height = "20px";
  4031. upgrade_btn.style.backgroundColor = upgrade_name_colors[rownum];
  4032. upgrade_btn.style.display = "inline-block";
  4033. upgrade_btn.style.border = "2px solid black";
  4034. upgrade_btn.style.cursor = "pointer";
  4035. black_box.appendChild(upgrade_btn);
  4036.  
  4037. let text_el = document.createElement("h3");
  4038. text_el.innerText = `[${rownum}] ${upgrade_names[rownum]}`;
  4039. text_el.style.fontSize = "15px";
  4040. text_el.style.display = "inline-block";
  4041. black_box.appendChild(text_el);
  4042. upgrade_box.appendChild(black_box);
  4043. }
  4044. // Handle key presses for moving the center (UNFINISHED)
  4045.  
  4046. /*
  4047. function return_to_center(XorY, posOrNeg){
  4048. console.log("function called with: " + XorY + posOrNeg);
  4049. if(XorY === "x"){
  4050. if(posOrNeg === "pos"){
  4051. while(offsetX < 0){
  4052. offsetX += 0.5*scalingFactor;
  4053. }
  4054. }else if(posOrNeg === "neg"){
  4055. while(offsetX > 0){
  4056. offsetX -= 0.5*scalingFactor;
  4057. }
  4058. }else{
  4059. console.log("invalid posOrNeg at return_to_center();")
  4060. }
  4061. }else if(XorY === "y"){
  4062. if(posOrNeg === "pos"){
  4063. while(offsetY < 0){
  4064. offsetY += 0.5*scalingFactor;
  4065. }
  4066. }else if(posOrNeg === "neg"){
  4067. while(offsetY > 0){
  4068. offsetY -= 0.5*scalingFactor;
  4069. }
  4070. }else{
  4071. console.log("invalid posOrNeg at return_to_center();")
  4072. }
  4073. }else{
  4074. console.log("invalid XorY at return_to_center();");
  4075. }
  4076. }
  4077.  
  4078. document.onkeydown = function(e) {
  4079. switch (e.keyCode) {
  4080. case 87: // 'W' key
  4081. console.log("W");
  4082. if(offsetY >= -87.5*scalingFactor){
  4083. offsetY -= 12.5*scalingFactor;
  4084. }
  4085. break
  4086. case 83: // 'S' key
  4087. console.log("S");
  4088. if(offsetY <= 87.5*scalingFactor){
  4089. offsetY += 12.5*scalingFactor;
  4090. }
  4091. break;
  4092. case 68: // 'D' key
  4093. console.log("D");
  4094. if(offsetX <= 87.5*scalingFactor){
  4095. offsetX += 12.5*scalingFactor;
  4096. }
  4097. break
  4098. case 65: // 'A' key
  4099. console.log("A");
  4100. if(offsetX >= -87.5*scalingFactor){
  4101. offsetX -= 12.5*scalingFactor;
  4102. }
  4103. break
  4104. }
  4105. }
  4106.  
  4107. document.onkeyup = function(e) {
  4108. switch (e.keyCode) {
  4109. case 87: // 'W' key
  4110. console.log("W unpressed");
  4111. return_to_center("y", "pos");
  4112. break
  4113. case 83: // 'S' key
  4114. console.log("S unpressed");
  4115. return_to_center("y", "neg");
  4116. break;
  4117. case 68: // 'D' key
  4118. console.log("D unpressed");
  4119. return_to_center("x", "neg");
  4120. break
  4121. case 65:
  4122. console.log("A unpressed");
  4123. return_to_center("x", "pos");
  4124. }
  4125. }
  4126. */