Diep.io+ (small changes & bug fixes)

Auto Respawn, Anti Aim, Base Warning, Bullet Distance, Leader Arrow Color, Watch enemies Level, copy party link, Team Switcher, Triflank, Freeze Mouse, Tank Aim Lines

目前为 2025-01-02 提交的版本,查看 最新版本

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