Diep.io+ (new Logo)

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-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Diep.io+ (new Logo)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.1.5.4
  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 (clump mode is weird tho)
  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(-1000, 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. /*
  783. communcationArr content:
  784. 0: minimapArrow [x, y]
  785. 1: leaderArrow [x, y]
  786. 2: minimapPos [x, y]
  787. 3: minimapDim [x, y]
  788. */
  789. let communicationArr = [[0, 0], [0, 0], [0, 0], [0, 0]];
  790.  
  791. function hook(target, callback){
  792.  
  793. function check(){
  794. window.requestAnimationFrame(check)
  795. window.arrows = communicationArr;
  796. const func = CanvasRenderingContext2D.prototype[target]
  797.  
  798. if(func.toString().includes(target)){
  799.  
  800. CanvasRenderingContext2D.prototype[target] = new Proxy (func, {
  801. apply (method, thisArg, args) {
  802. callback(thisArg, args)
  803.  
  804. return Reflect.apply (method, thisArg, args)
  805. }
  806. });
  807. }
  808. }
  809. window.requestAnimationFrame(check)
  810. }
  811.  
  812. let minimapArrow = [0, 0];
  813. let square_pos = [0, 0]
  814. let leaderArrow = [0, 0];
  815. let minimapPos = [0, 0];
  816. let minimapDim = [0, 0];
  817.  
  818. let calls = 0;
  819. let points = [];
  820.  
  821. hook('beginPath', function(thisArg, args){
  822. calls = 1;
  823. points = [];
  824. });
  825. hook('moveTo', function(thisArg, args){
  826. if (calls == 1) {
  827. calls+=1;
  828. points.push(args)
  829. } else {
  830. calls = 0;
  831. }
  832. });
  833. hook('lineTo', function(thisArg, args){
  834. if (calls >= 2 && calls <= 6) {
  835. calls+=1;
  836. points.push(args)
  837. } else {
  838. calls = 0;
  839. }
  840. });
  841.  
  842.  
  843. function getCentre(vertices) {
  844. let centre = [0, 0];
  845. vertices.forEach (vertex => {
  846. centre [0] += vertex[0]
  847. centre [1] += vertex[1]
  848. });
  849. centre[0] /= vertices.length;
  850. centre[1] /= vertices.length;
  851. return centre;
  852. }
  853.  
  854. hook('fill', function(thisArg, args){
  855. if(calls >= 4 && calls <= 6) {
  856. if(thisArg.fillStyle === "#000000" && thisArg.globalAlpha > 0.9){
  857. minimapArrow = getCentre(points);
  858. communicationArr[0] = minimapArrow;
  859. square_pos = [minimapArrow[0]-(12.5*windowScaling()), minimapArrow[1]-(7*windowScaling())];
  860. return;
  861. }else if(thisArg.fillStyle === "#000000" && thisArg.globalAlpha === 0.3499999940395355 || thisArg.fillStyle === window.choose_color && thisArg.globalAlpha === 0.3499999940395355){
  862. thisArg.fillStyle = window.choose_color;
  863. leaderArrow = getCentre(points);
  864. communicationArr[1] = leaderArrow;
  865. return;
  866. }
  867. } else {
  868. calls = 0;
  869. }
  870. });
  871. /*
  872. hook('fill', function(thisArg, args){
  873. if(calls >= 4 && calls <= 6) {
  874. if(thisArg.fillStyle === "#000000"){
  875. thisArg.globalAlpha = 0.3499999940395355;
  876. }
  877. } else {
  878. calls = 0;
  879. }
  880. });
  881. */
  882.  
  883. hook('strokeRect', function(thisArg, args) {
  884. const t = thisArg.getTransform();
  885. minimapPos = [t.e, t.f];
  886. minimapDim = [t.a, t.d];
  887. communicationArr[2] = minimapPos;
  888. communicationArr[3] = minimapDim;
  889. });
  890.  
  891. const ctx = canvas.getContext('2d');
  892. function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c) {
  893. ctx.beginPath();
  894. ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
  895. ctx.fillStyle = c;
  896. ctx.fill();
  897. }
  898.  
  899. function draw_arrow(x, y, c) {
  900. ctx_arc(x, y, 2, 0, 2 * Math.PI, false, c);
  901. }
  902.  
  903. function draw_viewport(){
  904. ctx.beginPath();
  905. ctx.stokeStyle = "black";
  906. ctx.lineWidth = 0.5;
  907. ctx.strokeRect(square_pos[0], square_pos[1], 25*windowScaling(), 14*windowScaling());
  908. ctx.stroke();
  909. }
  910.  
  911. //GUI
  912. const container = document.createElement('div');
  913. container.style.position = 'fixed';
  914. container.style.top = '10px';
  915. container.style.left = '75px';
  916. container.style.padding = '15px';
  917. container.style.backgroundImage = 'linear-gradient(#ffffff, #79c7ff)';
  918. container.style.color = 'white';
  919. container.style.borderRadius = '10px';
  920. container.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
  921. container.style.minWidth = '200px';
  922. container.style.zIndex = '10';
  923.  
  924. container.addEventListener('mouseover', () => {
  925. input.execute('ren_upgrades false');
  926. });
  927.  
  928. container.addEventListener('mouseout', () => {
  929. input.execute('ren_upgrades true');
  930. });
  931.  
  932. const title = document.createElement('h1');
  933. title.textContent = 'Diep.io+ (hide with J)';
  934. title.style.margin = '0 0 5px 0';
  935. title.style.fontSize = '24px';
  936. title.style.textAlign = 'center';
  937. title.style.color = '#fb2a7b';
  938. title.style.zIndex = '11';
  939. container.appendChild(title);
  940.  
  941. const subtitle = document.createElement('h3');
  942. subtitle.textContent = 'made by r!PsAw';
  943. subtitle.style.margin = '0 0 15px 0';
  944. subtitle.style.fontSize = '14px';
  945. subtitle.style.textAlign = 'center';
  946. subtitle.style.color = '#6fa8dc';
  947. subtitle.style.zIndex = '11';
  948. container.appendChild(subtitle);
  949.  
  950. const categories = ['Debug', 'Visual', 'Functional', 'Mouse', 'Addons'];
  951. const categoryButtons = {};
  952. const categoryContainer = document.createElement('div');
  953. categoryContainer.style.display = 'flex';
  954. categoryContainer.style.justifyContent = 'space-between';
  955. categoryContainer.style.marginBottom = '15px';
  956. categoryContainer.style.zIndex = '12';
  957.  
  958. categories.forEach(category => {
  959. const button = document.createElement('button');
  960. button.textContent = category;
  961. button.style.flex = '1';
  962. button.style.padding = '8px';
  963. button.style.margin = '0 5px';
  964. button.style.cursor = 'pointer';
  965. button.style.border = 'none';
  966. button.style.borderRadius = '5px';
  967. button.style.backgroundColor = '#fb2a7b';
  968. button.style.color = 'white';
  969. button.style.transition = 'background-color 0.3s';
  970. button.style.zIndex = '13';
  971.  
  972. button.addEventListener('mouseover', () => {
  973. button.style.backgroundColor = '#0000ff';
  974. });
  975. button.addEventListener('mouseout', () => {
  976. button.style.backgroundColor = '#fb2a7b';
  977. });
  978.  
  979. categoryContainer.appendChild(button);
  980. categoryButtons[category] = button;
  981. });
  982.  
  983. container.appendChild(categoryContainer);
  984.  
  985. const contentArea = document.createElement('div');
  986. contentArea.style.marginTop = '15px';
  987. contentArea.style.zIndex = '12';
  988. container.appendChild(contentArea);
  989.  
  990. let FOVindex = 0;
  991. let toggleButtons = {
  992. Debug: {
  993. 'Toggle Text': false,
  994. 'Toggle Middle Circle': false,
  995. 'Toggle Upgrades': false,
  996. 'Toggle Arrow pos': false,
  997. 'Toggle Minimap': false
  998. },
  999. Visual: {
  1000. 'Change Leader Arrow Color': '#000000',
  1001. 'Toggle Aim Lines': false,
  1002. 'Toggle Bullet Distance': false,
  1003. 'Toggle Leader Angle': false,
  1004. 'Highlight Leader Score': false,
  1005. 'Wasd & Mouse press visualiser': false
  1006. },
  1007. Functional: {
  1008. 'Auto Respawn': false,
  1009. 'Auto Bonus Level': false,
  1010. 'Toggle Leave Button': false,
  1011. 'Toggle Base Zones': false,
  1012. 'Toggle Level Seeker': false,
  1013. 'Stats': false,
  1014. },
  1015. Mouse: {
  1016. // 'Flipfire': false,
  1017. 'Anti Aim': false,
  1018. 'Upgrade to Auto Gunner': false,
  1019. 'Freeze Mouse': false,
  1020. 'Sandbox Hacks': false,
  1021. 'Switch Name': null
  1022. },
  1023. Addons: {
  1024. 'FOV changer': false,
  1025. 'selected': null
  1026. }
  1027. };
  1028.  
  1029. function saveSettings() {
  1030. localStorage.setItem(`[Diep.io+] ${els('gui')}`, JSON.stringify({
  1031. toggleButtons: toggleButtons,
  1032. FOVindex: FOVindex
  1033. }));
  1034. }
  1035.  
  1036. /*
  1037. function loadSettings() {
  1038. try {
  1039. const savedData = localStorage.getItem(`[Diep.io+] ${els('gui')}`);
  1040. if (savedData) {
  1041. const parsed = JSON.parse(savedData);
  1042. if (parsed.toggleButtons) {
  1043. // Merge saved settings with default settings to handle new options
  1044. categories.forEach(category => {
  1045. toggleButtons[category] = {
  1046. ...toggleButtons[category], // Keep default values
  1047. ...parsed.toggleButtons[category] // Override with saved values
  1048. };
  1049. });
  1050. }
  1051. if (typeof parsed.FOVindex === 'number') {
  1052. FOVindex = parsed.FOVindex;
  1053. }
  1054. }
  1055. } catch (error) {
  1056. console.error('Error loading settings:', error);
  1057. }
  1058. }
  1059. */
  1060.  
  1061. function createToggleButton(text, initialState) {
  1062. const button = document.createElement('button');
  1063. if (text.startsWith('selected')) {
  1064. button.textContent = `selected ${new_FOVs[FOVindex].name}`;
  1065. } else if(text.startsWith('Switch Name')){
  1066. button.textContent = `Switch Name ${sandbox_hax_modes[sandbox_hax_index].name}`;
  1067. }else{
  1068. button.textContent = text;
  1069. }
  1070. button.style.display = 'block';
  1071. button.style.width = '100%';
  1072. button.style.marginBottom = '10px';
  1073. button.style.padding = '8px';
  1074. button.style.cursor = 'pointer';
  1075. button.style.border = 'none';
  1076. button.style.borderRadius = '5px';
  1077. button.style.transition = 'background-color 0.3s';
  1078. button.style.zIndex = '13';
  1079. if (text.startsWith('selected')) {
  1080. button.style.backgroundColor = '#7a143b';
  1081. button.style.color = 'white';
  1082. button.addEventListener('click', () => {
  1083. let l = new_FOVs.length;
  1084. if (FOVindex < l - 1) {
  1085. FOVindex += 1;
  1086. } else {
  1087. FOVindex = 0;
  1088. }
  1089. button.textContent = `selected ${new_FOVs[FOVindex].name}`;
  1090. saveSettings();
  1091. });
  1092. } else if(text.startsWith('Switch Name')){
  1093. button.style.backgroundColor = '#7a143b';
  1094. button.style.color = 'white';
  1095. button.addEventListener('click', () => {
  1096. let l = sandbox_hax_modes.length;
  1097. if (sandbox_hax_index < l - 1) {
  1098. sandbox_hax_index += 1;
  1099. } else {
  1100. sandbox_hax_index = 0;
  1101. }
  1102. button.textContent = `Switch Name ${sandbox_hax_modes[sandbox_hax_index].name}`;
  1103. saveSettings();
  1104. });
  1105. }else if (text === 'Change Leader Arrow Color') {
  1106. updateButtonColor(button, initialState);
  1107. button.addEventListener('click', () => {
  1108. const colorPicker = document.createElement('input');
  1109. colorPicker.type = 'color';
  1110. colorPicker.value = toggleButtons[currentCategory][text];
  1111. colorPicker.style.display = 'none';
  1112. document.body.appendChild(colorPicker);
  1113.  
  1114. colorPicker.addEventListener('change', (event) => {
  1115. const newColor = event.target.value;
  1116. toggleButtons[currentCategory][text] = newColor;
  1117. updateButtonColor(button, newColor);
  1118. document.body.removeChild(colorPicker);
  1119. saveSettings();
  1120. });
  1121.  
  1122. colorPicker.click();
  1123. });
  1124. }else {
  1125. updateButtonColor(button, initialState);
  1126. button.addEventListener('click', () => {
  1127. toggleButtons[currentCategory][text] = !toggleButtons[currentCategory][text];
  1128. updateButtonColor(button, toggleButtons[currentCategory][text]);
  1129. saveSettings();
  1130. });
  1131. }
  1132.  
  1133. return button;
  1134. }
  1135.  
  1136. //loadSettings();
  1137.  
  1138. function updateButtonColor(button, state) {
  1139. if (typeof state === 'string') {
  1140. // For color picker button
  1141. button.style.backgroundColor = state;
  1142. window.choose_color = state;
  1143. button.style.color = 'white';
  1144. } else {
  1145. // For toggle buttons
  1146. if (state) {
  1147. button.style.backgroundColor = '#63a5d4';
  1148. button.style.color = 'white';
  1149. } else {
  1150. button.style.backgroundColor = '#a11a4e';
  1151. button.style.color = 'white';
  1152. }
  1153. }
  1154. }
  1155.  
  1156. let currentCategory = '';
  1157. let modes = ["in-game", "awaiting-spawn", "game-over"];
  1158. let selected_index = 0;
  1159. let button2_state = false;
  1160. let intervalId = null;
  1161.  
  1162. function showCategory(category) {
  1163. contentArea.innerHTML = '';
  1164. currentCategory = category;
  1165.  
  1166. Object.keys(categoryButtons).forEach(cat => {
  1167. if (cat === category) {
  1168. categoryButtons[cat].style.backgroundColor = '#0000ff';
  1169. } else {
  1170. categoryButtons[cat].style.backgroundColor = '#fb2a7b';
  1171. }
  1172. });
  1173.  
  1174. if (category === 'Functional') {
  1175. const copyLinkButton = document.createElement('button');
  1176. copyLinkButton.textContent = 'Copy Party Link';
  1177. copyLinkButton.style.display = 'block';
  1178. copyLinkButton.style.width = '100%';
  1179. copyLinkButton.style.marginBottom = '10px';
  1180. copyLinkButton.style.padding = '8px';
  1181. copyLinkButton.style.cursor = 'pointer';
  1182. copyLinkButton.style.border = 'none';
  1183. copyLinkButton.style.borderRadius = '5px';
  1184. copyLinkButton.style.backgroundColor = '#2196F3';
  1185. copyLinkButton.style.color = 'white';
  1186. copyLinkButton.style.transition = 'background-color 0.3s';
  1187. copyLinkButton.style.zIndex = '13';
  1188.  
  1189. copyLinkButton.addEventListener('mouseover', () => {
  1190. copyLinkButton.style.backgroundColor = '#1E88E5';
  1191. });
  1192. copyLinkButton.addEventListener('mouseout', () => {
  1193. copyLinkButton.style.backgroundColor = '#2196F3';
  1194. });
  1195.  
  1196. copyLinkButton.addEventListener('click', () => {
  1197. document.getElementById("copy-party-link").click();
  1198. });
  1199.  
  1200. const copyLinksButton = document.createElement('button');
  1201. copyLinksButton.textContent = 'Copy All Links';
  1202. copyLinksButton.style.display = 'block';
  1203. copyLinksButton.style.width = '100%';
  1204. copyLinksButton.style.marginBottom = '10px';
  1205. copyLinksButton.style.padding = '8px';
  1206. copyLinksButton.style.cursor = 'pointer';
  1207. copyLinksButton.style.border = 'none';
  1208. copyLinksButton.style.borderRadius = '5px';
  1209. copyLinksButton.style.backgroundColor = '#2196F3';
  1210. copyLinksButton.style.color = 'white';
  1211. copyLinksButton.style.transition = 'background-color 0.3s';
  1212. copyLinksButton.style.zIndex = '13';
  1213.  
  1214. copyLinksButton.addEventListener('mouseover', () => {
  1215. copyLinksButton.style.backgroundColor = '#1E88E5';
  1216. });
  1217. copyLinksButton.addEventListener('mouseout', () => {
  1218. copyLinksButton.style.backgroundColor = '#2196F3';
  1219. });
  1220.  
  1221. copyLinksButton.addEventListener('click', () => {
  1222. copy_links();
  1223. });
  1224.  
  1225. const copyInfoButton = document.createElement('button');
  1226. copyInfoButton.textContent = 'Copy Info';
  1227. copyInfoButton.style.display = 'block';
  1228. copyInfoButton.style.width = '100%';
  1229. copyInfoButton.style.marginBottom = '10px';
  1230. copyInfoButton.style.padding = '8px';
  1231. copyInfoButton.style.cursor = 'pointer';
  1232. copyInfoButton.style.border = 'none';
  1233. copyInfoButton.style.borderRadius = '5px';
  1234. copyInfoButton.style.backgroundColor = '#2196F3';
  1235. copyInfoButton.style.color = 'white';
  1236. copyInfoButton.style.transition = 'background-color 0.3s';
  1237. copyInfoButton.style.zIndex = '13';
  1238.  
  1239. copyInfoButton.addEventListener('mouseover', () => {
  1240. copyInfoButton.style.backgroundColor = '#1E88E5';
  1241. });
  1242. copyInfoButton.addEventListener('mouseout', () => {
  1243. copyInfoButton.style.backgroundColor = '#2196F3';
  1244. });
  1245.  
  1246. copyInfoButton.addEventListener('click', () => {
  1247. get_info();
  1248. });
  1249.  
  1250. contentArea.appendChild(copyLinkButton);
  1251. contentArea.appendChild(copyLinksButton);
  1252. contentArea.appendChild(copyInfoButton);
  1253.  
  1254. const newButtonsContainer = document.createElement('div');
  1255. newButtonsContainer.style.display = 'flex';
  1256. newButtonsContainer.style.justifyContent = 'space-between';
  1257. newButtonsContainer.style.marginBottom = '10px';
  1258.  
  1259. const button1 = document.createElement('button');
  1260. button1.textContent = modes[selected_index];
  1261. button1.style.flex = '1';
  1262. button1.style.marginRight = '5px';
  1263. button1.style.padding = '8px';
  1264. button1.style.cursor = 'pointer';
  1265. button1.style.border = 'none';
  1266. button1.style.borderRadius = '5px';
  1267. button1.style.backgroundColor = '#2196F3';
  1268. button1.style.color = 'white';
  1269. button1.style.transition = 'background-color 0.3s';
  1270.  
  1271. button1.addEventListener('mouseover', () => {
  1272. button1.style.backgroundColor = '#1E88E5';
  1273. });
  1274. button1.addEventListener('mouseout', () => {
  1275. button1.style.backgroundColor = '#2196F3';
  1276. });
  1277. button1.addEventListener('click', () => {
  1278. selected_index = (selected_index + 1) % modes.length;
  1279. button1.textContent = modes[selected_index];
  1280. });
  1281.  
  1282. // Button 2: Toggle loop
  1283. const button2 = document.createElement('button');
  1284. button2.textContent = 'Start Loop';
  1285. button2.style.flex = '1';
  1286. button2.style.marginLeft = '5px';
  1287. button2.style.padding = '8px';
  1288. button2.style.cursor = 'pointer';
  1289. button2.style.border = 'none';
  1290. button2.style.borderRadius = '5px';
  1291. button2.style.backgroundColor = '#f44336';
  1292. button2.style.color = 'white';
  1293. button2.style.transition = 'background-color 0.3s';
  1294.  
  1295. button2.addEventListener('click', () => {
  1296. button2_state = !button2_state;
  1297. if (button2_state) {
  1298. button2.textContent = 'Stop Loop';
  1299. button2.style.backgroundColor = '#4CAF50';
  1300. intervalId = setInterval(() => {
  1301. window.__common__.screen_state = modes[selected_index];
  1302. }, 100); // Adjust the interval as needed
  1303. } else {
  1304. button2.textContent = 'Start Loop';
  1305. button2.style.backgroundColor = '#f44336';
  1306. if (intervalId !== null) {
  1307. clearInterval(intervalId);
  1308. intervalId = null;
  1309. }
  1310. }
  1311. });
  1312.  
  1313. newButtonsContainer.appendChild(button1);
  1314. newButtonsContainer.appendChild(button2);
  1315. contentArea.appendChild(newButtonsContainer);
  1316. }
  1317.  
  1318. Object.keys(toggleButtons[category]).forEach(text => {
  1319. const button = createToggleButton(text, toggleButtons[category][text]);
  1320. contentArea.appendChild(button);
  1321. });
  1322. }
  1323.  
  1324. Object.keys(categoryButtons).forEach(category => {
  1325. categoryButtons[category].addEventListener('click', () => showCategory(category));
  1326. });
  1327.  
  1328. document.body.appendChild(container);
  1329.  
  1330. //you can't use my script >:(
  1331. function waitForInput(callback, checkInterval = 100, timeout = 10000) {
  1332. const startTime = Date.now();
  1333.  
  1334. function checkInput() {
  1335. if (typeof input !== 'undefined' && input && input.try_spawn) {
  1336. callback();
  1337. } else if (Date.now() - startTime < timeout) {
  1338. setTimeout(checkInput, checkInterval);
  1339. }
  1340. }
  1341.  
  1342. checkInput();
  1343. }
  1344.  
  1345. function crash(name) {
  1346. if(player.unbannable){
  1347. console.log("canceled crash");
  1348. return;
  1349. }
  1350. let nn = typeof name === "undefined" ? window.localStorage.getItem("d:last_spawn_name") : name;
  1351. alert(`${nn} is blacklisted from using Diep.io+, crashing...`);
  1352. localStorage.setItem(`[Diep.io+] ${els('banned')}`, true);
  1353. localStorage.setItem(`[Diep.io+] ${els('nickname')}`, nn);
  1354. while (true) {}
  1355. }
  1356.  
  1357. function HdSoyr_() {
  1358. if(player.unbannable){
  1359. return;
  1360. }
  1361. //crash();
  1362. alert("your saved name is banned");
  1363. }
  1364.  
  1365.  
  1366. waitForInput(function() {
  1367. //localStorage.getItem(`[Diep.io+] ${els('banned')}`) === 'true' ? crash() : null;
  1368. (localStorage.getItem(`[Diep.io+] ${els('banned')}`) === 'true') && !player.unbannable ? alert("you're banned because it saved banned state") : null;
  1369. });
  1370.  
  1371. //visibility of gui
  1372. let visibility_gui = true;
  1373.  
  1374. function change_visibility() {
  1375. visibility_gui = !visibility_gui;
  1376. if (visibility_gui) {
  1377. container.style.display = 'block';
  1378. } else {
  1379. container.style.display = 'none';
  1380. }
  1381. }
  1382.  
  1383. //check scripts
  1384. let script_list = {
  1385. minimap_leader_v1: null,
  1386. minimap_leader_v2: null,
  1387. fov: null,
  1388. set_transform_debug: null,
  1389. moveToLineTo_debug: null,
  1390. gamemode_detect: null,
  1391. multibox: null,
  1392. death_screen_faker: null
  1393. };
  1394.  
  1395. function check_ripsaw_scripts() {
  1396. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  1397. script_list.minimap_leader_v1 = !!window.m_arrow;
  1398. script_list.minimap_leader_v2 = !!window.arrows;
  1399. script_list.fov = !!window.HEAPF32;
  1400. script_list.set_transform_debug = !!window.crx_container;
  1401. script_list.moveToLineTo_debug = !!window.y_and_x;
  1402. script_list.gamemode_detect = !!window.gm;
  1403. script_list.multibox = !!window.mbox;
  1404. script_list.death_screen_faker = !!window.faker;
  1405. }
  1406. localStorage.setItem(`[Diep.io+] ${els('addons')}`, JSON.stringify(script_list));
  1407. }
  1408. setInterval(check_ripsaw_scripts, 500);
  1409.  
  1410. //detect gamemode
  1411. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1412. let last_gamemode = localStorage.getItem(`[Diep.io+] ${els("last_gm")}`);
  1413. localStorage.setItem(`[Diep.io+] ${els("last_gm")}`, gamemode);
  1414.  
  1415. function check_gamemode() {
  1416. if (script_list.gamemode_detect) {
  1417. gamemode = window.gm;
  1418. } else {
  1419. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  1420. save_gm();
  1421. }
  1422. }
  1423.  
  1424. setInterval(check_gamemode, 250);
  1425.  
  1426. function save_gm() {
  1427. let saved_gm = localStorage.getItem(`[Diep.io+] ${els("last_gm")}`);
  1428. if (saved_gm != null && saved_gm != gamemode) {
  1429. last_gamemode = saved_gm;
  1430. }
  1431. saved_gm === null ? localStorage.setItem(`[Diep.io+] ${els("last_gm")}`, gamemode) : null;
  1432. }
  1433.  
  1434. const build_stat_levels = [
  1435. 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
  1436. ];
  1437.  
  1438. function real_build(string) {
  1439. let processed = build_stat_levels.indexOf(player.level);
  1440. let temp_array = [...string];
  1441. temp_array = temp_array.slice(0, processed);
  1442. let final_string = temp_array.join("");
  1443. return final_string;
  1444. }
  1445.  
  1446. //diep console data capture
  1447. const originalConsoleLog = console.log;
  1448. const capturedLogs = [];
  1449. const diep_data = [];
  1450.  
  1451. function read_diep_data() {
  1452. // Override console.log to prevent logging to the console
  1453. console.log = function(...args) {
  1454. capturedLogs.push(args.join(' '));
  1455. };
  1456.  
  1457. // Call the function that logs output
  1458. input.print_convar_help();
  1459.  
  1460. // Restore the original console.log function
  1461. console.log = originalConsoleLog;
  1462. if (diep_data.length === 0) {
  1463. save_diep_data();
  1464. } else {
  1465. update_diep_data();
  1466. }
  1467. capturedLogs.length = 0;
  1468. }
  1469.  
  1470. setInterval(read_diep_data, 1000);
  1471.  
  1472. function save_diep_data() {
  1473. let l = capturedLogs.length;
  1474. for (let i = 0; i < l; i++) {
  1475. let sett_nam = capturedLogs[i].split(' = ')[0];
  1476. let sett_val = capturedLogs[i].split(' ')[2];
  1477. diep_data.push([sett_nam, sett_val]);
  1478. }
  1479. player.raw_build = diep_data[0][1];
  1480. player.real_time_build = real_build(player.raw_build);
  1481. }
  1482.  
  1483. function update_diep_data() {
  1484. let l = capturedLogs.length;
  1485. for (let i = 0; i < l; i++) {
  1486. if (!Array.isArray(diep_data[i])) {
  1487. diep_data[i] = [];
  1488. }
  1489.  
  1490. const splitLog = capturedLogs[i].split(' ');
  1491.  
  1492. if (splitLog.length > 2) {
  1493. diep_data[i][1] = splitLog[2];
  1494. } else {
  1495. console.error(`Captured log at index ${i} is not in the expected format:`, capturedLogs[i]);
  1496. }
  1497. }
  1498. localStorage.setItem(`[Diep.io+] ${els('console')}`, JSON.stringify(diep_data));
  1499. }
  1500.  
  1501.  
  1502. //personal best
  1503. let your_final_score = 0;
  1504. const personal_best = document.createElement('div');
  1505. const gameDetail = document.createElement('div');
  1506. const label = document.createElement('div');
  1507. //applying class
  1508. gameDetail.classList.add("game-detail");
  1509. label.classList.add("label");
  1510. personal_best.classList.add("value");
  1511. //text context
  1512. label.textContent = "Best:";
  1513. //adding to html
  1514. gameOverScreenContainer.appendChild(gameDetail);
  1515. gameDetail.appendChild(label);
  1516. gameDetail.appendChild(personal_best);
  1517.  
  1518. function load_ls() {
  1519. return localStorage.getItem(gamemode);
  1520. }
  1521.  
  1522. function save_ls() {
  1523. localStorage.setItem(gamemode, your_final_score);
  1524. }
  1525.  
  1526. function check_final_score() {
  1527. if (window.__common__.screen_state === "game-over" && !script_list.death_screen_faker) {
  1528. your_final_score = window.__common__.death_score;
  1529. let saved_score = parseFloat(load_ls());
  1530. personal_best.textContent = saved_score;
  1531. if (saved_score < your_final_score) {
  1532. personal_best.textContent = your_final_score;
  1533. save_ls();
  1534. }
  1535. }
  1536. }
  1537.  
  1538. setInterval(check_final_score, 100);
  1539.  
  1540. //config
  1541. var two = canvas.width / window.innerWidth;
  1542. var script_boolean = true;
  1543.  
  1544. //net_predict_movement false
  1545. function gg() {
  1546. if (connected) {
  1547. input.get_convar("net_predict_movement") === "true" ? input.set_convar("net_predict_movement", "false") : null;
  1548. } else {
  1549. setTimeout(() => {
  1550. gg();
  1551. }, 100)
  1552. }
  1553. }
  1554. gg();
  1555.  
  1556. //restyle diep.io
  1557. let sources = {
  1558. logo: 'https://media.discordapp.net/attachments/1006345393862365295/1328746314778808382/Diep.io___by_r_PsAw_-removebg-preview.png?ex=6787d2f0&is=67868170&hm=b89b01c9676c1686d4eb9d3f3c400c6b55b93f96ca58fa0d628ee7dafc20db29&=&format=webp&quality=lossless&width=1210&height=424',
  1559. }
  1560.  
  1561. function restyle(){
  1562. if(!document.querySelector("#logo")){
  1563. setTimeout(() => {
  1564. restyle();
  1565. }, 100);
  1566. }
  1567. document.querySelector("#logo").src = sources.logo;
  1568. }
  1569. restyle();
  1570.  
  1571. //remove annoying html elements
  1572. function instant_remove() {
  1573. // Define selectors for elements to remove
  1574. const selectors = [
  1575. "#cmpPersistentLink",
  1576. "#apes-io-promo",
  1577. "#apes-io-promo > img",
  1578. "#last-updated",
  1579. "#diep-io_300x250"
  1580. ];
  1581.  
  1582. // Remove each selected element
  1583. selectors.forEach(selector => {
  1584. const element = document.querySelector(selector);
  1585. if (element) {
  1586. element.remove();
  1587. }
  1588. });
  1589.  
  1590. // If all elements have been removed, clear the interval
  1591. if (selectors.every(selector => !document.querySelector(selector))) {
  1592. console.log("Removed all ads, quitting...");
  1593. clearInterval(interval);
  1594. }
  1595. }
  1596.  
  1597. // Set an interval to check for ads
  1598. const interval = setInterval(instant_remove, 100);
  1599.  
  1600. //timer for bonus reward
  1601. const ad_btn = document.getElementById("game-over-video-ad");
  1602. var ad_btn_free = true;
  1603.  
  1604. const timerDisplay = document.createElement('h1');
  1605. timerDisplay.textContent = "Time left to collect next bonus levels: 02:00";
  1606. gameOverScreen.appendChild(timerDisplay);
  1607.  
  1608. let timer;
  1609. let totalTime = 120; // 2 minutes in seconds
  1610.  
  1611. function startTimer() {
  1612. clearInterval(timer);
  1613. timer = setInterval(function() {
  1614. if (totalTime <= 0) {
  1615. clearInterval(timer);
  1616. timerDisplay.textContent = "00:00";
  1617. } else {
  1618. totalTime--;
  1619. let minutes = Math.floor(totalTime / 60);
  1620. let seconds = totalTime % 60;
  1621. timerDisplay.textContent =
  1622. `Time left to collect next bonus levels: ${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
  1623. }
  1624. }, 1000);
  1625. }
  1626.  
  1627. function resetTimer() {
  1628. if (totalTime === 0) {
  1629. clearInterval(timer);
  1630. totalTime = 120; // Reset to 2 minutes
  1631. timerDisplay.textContent = "02:00";
  1632. }
  1633. }
  1634.  
  1635. ad_btn.addEventListener('click', check_ad_state);
  1636.  
  1637. function check_ad_state() {
  1638. if (totalTime === 0) {
  1639. resetTimer();
  1640. } else if (totalTime === 120) {
  1641. ad_btn_free = true;
  1642. startTimer();
  1643. } else {
  1644. ad_btn_free = false;
  1645. }
  1646. }
  1647.  
  1648. //autorespawn
  1649.  
  1650. let autorespawn = false;
  1651.  
  1652. function respawn() {
  1653. if (toggleButtons.Functional['Auto Respawn']) {
  1654. if (state === "in game") {
  1655. return;
  1656. } else {
  1657. if ((totalTime === 120 || totalTime === 0) && toggleButtons.Functional['Auto Bonus Level']) {
  1658. ad_btn.click();
  1659. } else {
  1660. let spawnbtn = document.getElementById("spawn-button");
  1661. spawnbtn.click();
  1662. }
  1663. }
  1664. }
  1665. }
  1666.  
  1667. setInterval(respawn, 1000);
  1668.  
  1669. //toggle leave game
  1670. let ingame_quit_btn = document.getElementById("quick-exit-game");
  1671.  
  1672. function check_class() {
  1673. if (toggleButtons.Functional['Toggle Leave Button']) {
  1674. ingame_quit_btn.classList.remove("hidden");
  1675. ingame_quit_btn.classList.add("shown");
  1676. } else {
  1677. ingame_quit_btn.classList.remove("shown");
  1678. ingame_quit_btn.classList.add("hidden");
  1679. }
  1680. }
  1681.  
  1682. setInterval(check_class, 300);
  1683.  
  1684. //score logic
  1685. let your_nameFont;
  1686. let scoreBoardFont;
  1687. let highest_score;
  1688. let highest_score_addon;
  1689. let highest_score_string;
  1690. let is_highest_score_alive;
  1691. let scores = {
  1692. millions: 0,
  1693. thousands: 0,
  1694. lessThan1k: 0
  1695. };
  1696.  
  1697. function get_highest_score() {
  1698. if (scores.millions > 0) {
  1699. highest_score = scores.millions;
  1700. highest_score_addon = "m";
  1701. } else if (scores.thousands > 0) {
  1702. highest_score = scores.thousands;
  1703. highest_score_addon = "k";
  1704. } else if (scores.lessThan1k > 0) {
  1705. highest_score = scores.lessThan1k;
  1706. }
  1707. }
  1708. //getting text information (credits to abc)
  1709. let fps;
  1710. let ms;
  1711. let ms_active = false;
  1712. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  1713. apply(fillRect, ctx, [text, x, y, ...blah]) {
  1714. if (text.endsWith('FPS')) {
  1715. fps = text.split(' ')[0];
  1716. }
  1717. if (text.includes(' ms ')) {
  1718. ms = text.split(' ')[0];
  1719. ms_active = true;
  1720. }
  1721. fillRect.call(ctx, text, x, y, ...blah);
  1722. }
  1723. });
  1724.  
  1725. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  1726. apply(fillRect, ctx, [text, x, y, ...blah]) {
  1727. const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string)
  1728. if (text.startsWith('Lvl ')) {
  1729. player.level = parseFloat(text.split(' ')[1]);
  1730. console.log(`
  1731. 1 ${text.split(' ')}
  1732. 2 ${text.split(' ').slice(2)}
  1733. 3 ${text.split(' ').slice(2).join(" ")}
  1734. 4 ${text.split(' ').slice(2).join(" ").trim()}
  1735. `);
  1736. player.tank = text.split(' ').slice(2).join(" ").trim();
  1737. } else if (text === player.name) {
  1738. your_nameFont = ctx.font;
  1739. } else if (text === " - ") {
  1740. scoreBoardFont = ctx.font
  1741. } else if (isNumeric(text) && ctx.font === scoreBoardFont) {
  1742. scores.lessThan1k = parseFloat(text);
  1743. } else if (text.includes('.') && text.includes('k') && ctx.font === scoreBoardFont) {
  1744. if (parseFloat(text.split('k')[0]) > scores.thousands) {
  1745. scores.thousands = parseFloat(text.split('k')[0]);
  1746. }
  1747. } else if (text.includes('.') && text.includes('m') && ctx.font === scoreBoardFont) {
  1748. if (parseFloat(text.split('m')[0]) > scores.millions) {
  1749. scores.millions = parseFloat(text.split('m')[0]);
  1750. }
  1751. }
  1752.  
  1753. get_highest_score();
  1754. if (highest_score != null) {
  1755. if (highest_score_addon != null) {
  1756. highest_score_string = `${highest_score}${highest_score_addon}`;
  1757. } else {
  1758. highest_score_string = `${highest_score}`;
  1759. }
  1760. if (text === highest_score_string && toggleButtons.Visual['Highlight Leader Score']) {
  1761. ctx.fillStyle = "orange";
  1762. }
  1763. }
  1764. fillRect.call(ctx, text, x, y, ...blah);
  1765. }
  1766. });
  1767.  
  1768. //getting Info
  1769. let position_on_minimap = '';
  1770.  
  1771. function get_info() {
  1772. if (!toggleButtons.Visual['Toggle Minimap']) {
  1773. new_notification("Enabled Minimap for it to work properly. To turn it off, go to Visual -> Minimap", rgbToNumber(...notification_rbgs.normal), 5000);
  1774. new_notification("please click again", rgbToNumber(...notification_rbgs.normal), 5000);
  1775. toggleButtons.Visual['Toggle Minimap'] = true;
  1776. }
  1777. let links = get_links(get_gamemode(), get_your_lobby());
  1778. let final_links_arr = [];
  1779. let final_links_str = '';
  1780. for (let i = 0; i < links.length; i++) {
  1781. final_links_arr.push(`${links[i][0]}: ${links[i][1]}`);
  1782. }
  1783. for (let i = 0; i < final_links_arr.length; i++) {
  1784. final_links_str = final_links_str + "\n" + final_links_arr[i];
  1785. }
  1786. if (region != null && gamemode != null && highest_score != null) {
  1787. navigator.clipboard.writeText(`🌐Region: ${region}
  1788. 🎮Mode: ${gamemode}
  1789. 👑Leader: ${highest_score}${highest_score_addon}
  1790. ${final_links_str}`);
  1791. new_notification("copied!", rgbToNumber(...notification_rbgs.normal), 5000);
  1792. }
  1793. }
  1794.  
  1795. /* old method
  1796. function get_info() {
  1797. if (!toggleButtons.Visual['Toggle Minimap']) {
  1798. new_notification("Enabled Minimap for it to work properly. To turn it off, go to Visual -> Minimap", rgbToNumber(...notification_rbgs.normal), 5000);
  1799. new_notification("please click again", rgbToNumber(...notification_rbgs.normal), 5000);
  1800. toggleButtons.Visual['Toggle Minimap'] = true;
  1801. }
  1802. let link = "https://diep.io/?p=" + window.__common__.party_link;
  1803. let team = document.querySelector("#copy-party-link").classList[1];
  1804. console.log(`link: ${link}
  1805. team: ${team}
  1806. position_on_minimap: ${position_on_minimap}
  1807. gamemode: ${gamemode}
  1808. Leader: ${highest_score}${highest_score_addon}`);
  1809. switch (team){
  1810. case "red":
  1811. team = '🔴';
  1812. break
  1813. case "blue":
  1814. team = '🔵';
  1815. break
  1816. case "green":
  1817. team = '🟢';
  1818. break
  1819. case "purple":
  1820. team = '🟣';
  1821. break
  1822. }
  1823. if (region != null && gamemode != null && highest_score != null) {
  1824. navigator.clipboard.writeText(`🌐Region: ${region}
  1825. 🎮Mode: ${gamemode}
  1826. 👑Leader: ${highest_score}${highest_score_addon}
  1827. ${team}Link: ${link}`);
  1828. }
  1829. }
  1830. */
  1831. //display level
  1832. const pointsNeeded = new Uint16Array([
  1833. 0, 4, 13, 28, 50, 78, 113, 157, 211, 275,
  1834. 350, 437, 538, 655, 787, 938, 1109, 1301,
  1835. 1516, 1757, 2026, 2325, 2658, 3026, 3433,
  1836. 3883, 4379, 4925, 5525, 6184, 6907, 7698,
  1837. 8537, 9426, 10368, 11367, 12426, 13549,
  1838. 14739, 16000, 17337, 18754, 20256, 21849,
  1839. 23536
  1840. ]);
  1841.  
  1842. const crx = CanvasRenderingContext2D.prototype;
  1843. crx.fillText = new Proxy(crx.fillText, {
  1844. apply: function(f, _this, args) {
  1845. if (scoreBoardFont != null && toggleButtons.Functional['Toggle Level Seeker']) {
  1846. const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string);
  1847. if (_this.font != scoreBoardFont) {
  1848. if (isNumeric(args[0])) {
  1849. for (let i = 0; i < 16; i++) {
  1850. if (parseFloat(args[0]) < pointsNeeded[i]) {
  1851. args[0] = `L: ${i}`;
  1852. }
  1853. }
  1854. } else if (args[0].includes('.')) {
  1855. if (args[0].includes('k')) {
  1856. for (let i = 16; i < 45; i++) {
  1857. if (parseFloat(args[0].split('k')[0]) * 1000 < pointsNeeded[i]) {
  1858. args[0] = `L: ${i}`;
  1859. }
  1860. }
  1861. if (parseFloat(args[0].split('k')[0]) * 1000 > pointsNeeded[44]) {
  1862. args[0] = `L: 45`;
  1863. }
  1864. } else if (args[0].includes('m')) {
  1865. args[0] = `L: 45`;
  1866. }
  1867. }
  1868. }
  1869. }
  1870. f.apply(_this, args);
  1871. }
  1872. });
  1873. crx.strokeText = new Proxy(crx.strokeText, {
  1874. apply: function(f, _this, args) {
  1875. if (scoreBoardFont != null && toggleButtons.Functional['Toggle Level Seeker']) {
  1876. const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string);
  1877. if (_this.font != scoreBoardFont) {
  1878. if (isNumeric(args[0])) {
  1879. for (let i = 0; i < 16; i++) {
  1880. if (parseFloat(args[0]) < pointsNeeded[i]) {
  1881. args[0] = `L: ${i}`;
  1882. }
  1883. }
  1884. } else if (args[0].includes('.')) {
  1885. if (args[0].includes('k')) {
  1886. for (let i = 16; i < 45; i++) {
  1887. if (parseFloat(args[0].split('k')[0]) * 1000 < pointsNeeded[i]) {
  1888. args[0] = `L: ${i}`;
  1889. }
  1890. }
  1891. if (parseFloat(args[0].split('k')[0]) * 1000 > pointsNeeded[44]) {
  1892. args[0] = `L: 45`;
  1893. }
  1894. } else if (args[0].includes('m')) {
  1895. args[0] = `L: 45`;
  1896. }
  1897. }
  1898. }
  1899. }
  1900. f.apply(_this, args);
  1901. }
  1902. });
  1903.  
  1904. //Detect AutoFire/AutoSpin
  1905. let auto_fire = false;
  1906. let auto_spin = false;
  1907.  
  1908. function f_s(f_or_s) {
  1909. switch (f_or_s) {
  1910. case "fire":
  1911. auto_fire = !auto_fire;
  1912. break
  1913. case "spin":
  1914. auto_spin = !auto_spin;
  1915. break
  1916. }
  1917. }
  1918. //Diep Units & fov calculator
  1919. //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.
  1920.  
  1921. /*
  1922. =============================================================================
  1923. Skid & Noob friendly calculation explained:
  1924.  
  1925. Read this in order to understand, how the position calculation works.
  1926.  
  1927. 1. Canvas/window coords
  1928. When you load diep.io in a browser window, it also loads a canvas where the game is drawn.
  1929. 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.
  1930. Diep.io uses canvas mainly. Your window and the canvas use different coordinate systems, even tho they appear the same at first:
  1931.  
  1932. start->x
  1933. |
  1934. \/
  1935. y
  1936.  
  1937. if x is for example 3 and y is 5, you find the point of your mouse.
  1938.  
  1939. start->x...
  1940. |_________|
  1941. \/________|
  1942. y_________|
  1943. ._________|
  1944. ._________|
  1945. ._________|
  1946. ._________|
  1947. ._________HERE
  1948.  
  1949. the right upper corner of your window is the x limit, called window.innerWidth
  1950. the left bottom corner of your window is the y limit, called window.innerHeight
  1951.  
  1952. canvas is the same, but multiplied by 2. So for x, it's canvas.height = window.innerHeight * 2
  1953. same goes for y, canvas.width = window.innerWidth * 2
  1954.  
  1955. This can work the other way around too. canvas.height/2 = window.innerHeight
  1956. and canvas.width/2 = window.innerWidth
  1957.  
  1958. NOTE: when you use input.mouse(x, y) you're using the canvas coordinate system.
  1959.  
  1960. 2. DiepUnits
  1961. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  1962. if you're curious about what l and Fv means, like I was I can tell you now.
  1963.  
  1964. L stands for your Tank level, that you currently have.
  1965. Fv is the fieldFactor. You can find them here for each tank: https://github.com/ABCxFF/diepindepth/blob/main/extras/tankdefs.json
  1966. (The formula from the picture as code: const FOV = (level, fieldFactor) => (.55*fieldFactor)/Math.pow(1.01, (level-1)/2); )
  1967.  
  1968. Additions:
  1969. DiepUnits are used, to draw all entities in game in the right size. For example when you go Ranger, they appear smaller
  1970. because your entire ingame map shrinks down, so you see more without changing the size of the canvas or the window.
  1971. So if a square is 55 diepunits big and it gets visually smaller, it's still 55 diepunits big.
  1972.  
  1973. Coordinate system: x*scalingFactor, y*scalingFactor
  1974.  
  1975. IMPORTANT!!! Note that your Tank is getting additional DiepUnits with every level it grows.
  1976. This formula descritbes it's growth
  1977. 53 * (1.01 ** (currentLevel - 1));
  1978.  
  1979. 3. WindowScaling
  1980. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  1981. (you can use the function given in there, if you don't want to make your own)
  1982.  
  1983. it's used for all ui elements, like scoreboard, minimap or stats upgrades.
  1984. NOTE: It's not used for html Elements, only canvas. So the starting menu or gameover screen aren't part of it.
  1985.  
  1986. Coordinate system: x*windowScaling(), y*windowScaling()
  1987.  
  1988. 4. Converting coordinate systems into each other
  1989. canvas -> window = a/(canvas.width/window.innerWidth) -> b
  1990. window -> canvas = a*(canvas.width/window.innerWidth) -> b
  1991. windowScaling -> window = ( a*windowScaling() )/(canvas.width/window.innerWidth) -> b
  1992. windowScaling -> canvas = a*windowScaling() - > b
  1993. diepUnits -> canvas = a/scalingFactor -> b
  1994. diepUnits -> window = ( a/scalingFactor )/(canvas.width/window.innerWidth) -> b
  1995. window -> diepUnits = ( a*scalingFactor )*(canvas.width/window.innerWidth) -> b
  1996. canvas -> diepUnits = a*scalingFactor -> b
  1997. window -> windowScaling() = ( a*windowScaling() )*(canvas.width/window.innerWidth) -> b
  1998. canvas -> windowScaling() = a*windowScaling() - > b
  1999. diepUnits -> windowScaling() = ( a/scalingFactor ) * fieldFactor -> b
  2000. windowScaling()-> diepUnits = ( a/fieldFactor ) * scalingFactor -> b
  2001.  
  2002. =============================================================================
  2003.  
  2004. My todo list or fix:
  2005.  
  2006. - simulate diep.io moving and knockback physics
  2007.  
  2008. - simulate diep.io bullets
  2009.  
  2010. - figure out how to simulate mouse click events
  2011.  
  2012. - Finish bullet speed hybrid tanks
  2013.  
  2014. - Figure out physics for sniper, Ranger etc.
  2015.  
  2016. =============================================================================
  2017.  
  2018. Known Bugs:
  2019.  
  2020. - when enabling Level Seeker and pressing L, the ms gets replaced as well
  2021.  
  2022. =============================================================================
  2023.  
  2024. Useful info:
  2025.  
  2026. -shape sizes:
  2027.  
  2028. tank lvl 1 size = 53 diep units
  2029.  
  2030. grid square side length = 50 diep units
  2031. square, triangle = 55 diep units
  2032. pentagon = 75 diep units
  2033. small crasher = 35 diep units
  2034. big crasher = 55 diep units
  2035. alpha pentagon = 200 diep units
  2036.  
  2037. =============================================================================
  2038. */
  2039.  
  2040. let ripsaw_radius;
  2041. let fieldFactor = 1.0;
  2042. let found = false;
  2043. let loltank;
  2044. let lolztank;
  2045. let diepUnits = 53 * (1.01 ** (player.level - 1));
  2046. let FOV = (0.55 * fieldFactor) / Math.pow(1.01, (player.level - 1) / 2);
  2047. let legit_FOV;
  2048. let change_FOV_request = false;
  2049. let scalingFactor = FOV * windowScaling();
  2050. const fieldFactors = [
  2051. {
  2052. tank: "Sniper",
  2053. factor: 0.899
  2054. },
  2055. {
  2056. tank: "Overseer",
  2057. factor: 0.899
  2058. },
  2059. {
  2060. tank: "Overlord",
  2061. factor: 0.899
  2062. },
  2063. {
  2064. tank: "Assassin",
  2065. factor: 0.8
  2066. },
  2067. {
  2068. tank: "Necromancer",
  2069. factor: 0.899
  2070. },
  2071. {
  2072. tank: "Hunter",
  2073. factor: 0.85
  2074. },
  2075. {
  2076. tank: "Stalker",
  2077. factor: 0.8
  2078. },
  2079. {
  2080. tank: "Ranger",
  2081. factor: 0.699
  2082. },
  2083. {
  2084. tank: "Manager",
  2085. factor: 0.899
  2086. },
  2087. {
  2088. tank: "Predator",
  2089. factor: 0.85
  2090. },
  2091. {
  2092. tank: "Trapper",
  2093. factor: 0.899
  2094. },
  2095. {
  2096. tank: "Gunner Trapper",
  2097. factor: 0.899
  2098. },
  2099. {
  2100. tank: "Overtrapper",
  2101. factor: 0.899
  2102. },
  2103. {
  2104. tank: "MegaTrapper",
  2105. factor: 0.899
  2106. },
  2107. {
  2108. tank: "Tri-Trapper",
  2109. factor: 0.899
  2110. },
  2111. {
  2112. tank: "Smasher",
  2113. factor: 0.899
  2114. },
  2115. {
  2116. tank: "Landmine",
  2117. factor: 0.899
  2118. },
  2119. {
  2120. tank: "Streamliner",
  2121. factor: 0.85
  2122. },
  2123. {
  2124. tank: "Auto Trapper",
  2125. factor: 0.899
  2126. },
  2127. {
  2128. tank: "Battleship",
  2129. factor: 0.899
  2130. },
  2131. {
  2132. tank: "Auto Smasher",
  2133. factor: 0.899
  2134. },
  2135. {
  2136. tank: "Spike",
  2137. factor: 0.899
  2138. },
  2139. {
  2140. tank: "Factory",
  2141. factor: 0.899
  2142. },
  2143. {
  2144. tank: "Skimmer",
  2145. factor: 0.899
  2146. },
  2147. {
  2148. tank: "Glider",
  2149. factor: 0.899
  2150. },
  2151. {
  2152. tank: "Rocketeer",
  2153. factor: 0.899
  2154. },
  2155. ]
  2156.  
  2157. //let's actually implement these:
  2158. function canvas_2_window(a){
  2159. let b = a/(canvas.width/window.innerWidth);
  2160. return b;
  2161. }
  2162.  
  2163. function window_2_canvas(a){
  2164. let b = a * (canvas.width/window.innerWidth);
  2165. return b;
  2166. }
  2167.  
  2168. function windowScaling_2_window(a){
  2169. let b = (windowScaling_2_canvas(a) ) / (canvas.width/window.innerWidth);
  2170. return b;
  2171. }
  2172.  
  2173. function windowScaling_2_canvas(a){
  2174. let b = a*windowScaling();
  2175. return b;
  2176. }
  2177.  
  2178. function diepUnits_2_canvas(a){
  2179. let b = a/scalingFactor;
  2180. return b;
  2181. }
  2182.  
  2183. function diepUnits_2_window(a){
  2184. let b = (diepUnits_2_canvas(a))/(canvas.width/window.innerWidth);
  2185. return b;
  2186. }
  2187.  
  2188. function window_2_diepUnits(a){
  2189. let b = ( canvas_2_diepUnits(a) )*(canvas.width/window.innerWidth);
  2190. return b;
  2191. }
  2192.  
  2193. function canvas_2_diepUnits(a){
  2194. let b = a * scalingFactor;
  2195. return b;
  2196. }
  2197.  
  2198. function window_2_windowScaling(a){
  2199. let b = ( canvas_2_windowScaling(a) )*(canvas.width/window.innerWidth);
  2200. return b;
  2201. }
  2202.  
  2203. function canvas_2_windowScaling(a){
  2204. let b = a*windowScaling();
  2205. return b;
  2206. }
  2207.  
  2208. function diepUnits_2_windowScaling(a){
  2209. let b = ( diepUnits_2_canvas(a) ) * fieldFactor;
  2210. return b;
  2211. }
  2212.  
  2213. function windowScaling_2_diepUntis(a){
  2214. let b = ( a/fieldFactor ) * scalingFactor;
  2215. return b;
  2216. }
  2217. //
  2218.  
  2219. function check_FOV_requests() {
  2220. if (script_list.fov) {
  2221. if (toggleButtons.Addons['FOV changer']) {
  2222. change_FOV_request = true;
  2223. change_FOV(FOVindex);
  2224. } else {
  2225. change_FOV_request = false;
  2226. change_FOV();
  2227. }
  2228. }
  2229. }
  2230.  
  2231. setInterval(check_FOV_requests, 500);
  2232.  
  2233. function calculateFOV(Fv, l) {
  2234. let dpr = 1;
  2235. if(window.dpr){
  2236. dpr = window.dpr;
  2237. }
  2238. const numerator = 0.55 * Fv;
  2239. const denominator = Math.pow(1.01, (l - 1) / 2);
  2240. legit_FOV = numerator / denominator;
  2241. window.legit_FOV = legit_FOV;
  2242. let l1 = new_FOVs.length;
  2243. for (let i = 0; i < l1; i++) {
  2244. if (new_FOVs[i].name != 'Background') {
  2245. new_FOVs[i].FOV = ((0.55 * new_FOVs[i].fieldFactor) / (Math.pow(1.01, (l - 1) / 2)));
  2246. } else {
  2247. new_FOVs[i].FOV = 0.3499999940395355;
  2248. }
  2249. }
  2250. if (typeof window.HEAPF32 !== 'undefined' && typeof window.fov !== 'undefined' && window.fov.length > 0 && !window.legit_request) {
  2251. //use this part, if you have a fov script that can share it's fov value with you
  2252. FOV = HEAPF32[fov[0]] * dpr;
  2253. } else {
  2254. //use this part if you have no fov script
  2255. FOV = legit_FOV * dpr;
  2256. }
  2257. return FOV;
  2258. }
  2259.  
  2260. function change_FOV(index) {
  2261. for (const fov of window.fov) {
  2262. if (change_FOV_request && !window.legit_request) {
  2263. if (index === 0) {
  2264. window.HEAPF32[fov] = new_FOVs[index].FOV;
  2265. }
  2266. window.HEAPF32[fov] = new_FOVs[index].FOV;
  2267. } else {
  2268. window.HEAPF32[fov] = legit_FOV;
  2269. }
  2270. }
  2271. }
  2272.  
  2273. function apply_values(FF) {
  2274. calculateFOV(FF, player.level);
  2275. scalingFactor = FOV * windowScaling();
  2276. ripsaw_radius = diepUnits * scalingFactor;
  2277. diepUnits = 53 * (1.01 ** (player.level - 1));
  2278. }
  2279.  
  2280. function apply_changes(value) {
  2281. if (found) {
  2282. fieldFactor = fieldFactors[value].factor;
  2283. loltank = player.tank;
  2284. player.last_level = player.level;
  2285. apply_values(fieldFactor);
  2286. } else {
  2287. if (value === null) {
  2288. fieldFactor = 1.0;
  2289. loltank = "default";
  2290. lolztank = player.tank;
  2291. player.last_level = player.level;
  2292. apply_values(fieldFactor);
  2293. }
  2294. }
  2295. }
  2296.  
  2297. function bruteforce_tanks() {
  2298. let l = fieldFactors.length;
  2299. for (let i = 0; i < l; i++) {
  2300. if (player.tank.includes(fieldFactors[i].tank)) {
  2301. found = true;
  2302. //console.log("FOUND TANK " + fieldFactors[i].tank);
  2303. apply_changes(i);
  2304. break;
  2305. } else {
  2306. found = false;
  2307. if (i < l - 1) {
  2308. /*
  2309. console.log(`checking tank ${i}`);
  2310. } else {
  2311. console.log("Tank set to default or not found")
  2312. */
  2313. apply_changes(null);
  2314. }
  2315. }
  2316. }
  2317. }
  2318.  
  2319. window.addEventListener("resize", bruteforce_tanks);
  2320.  
  2321. function check_lvl_change() {
  2322. if (player.last_level != player.level) {
  2323. bruteforce_tanks();
  2324. }
  2325. }
  2326.  
  2327. function check_change() {
  2328. check_lvl_change();
  2329. if (loltank != player.tank) {
  2330. if (loltank === "default") {
  2331. if (lolztank != player.tank) {
  2332. bruteforce_tanks();
  2333. } else {
  2334. return;
  2335. }
  2336. } else {
  2337. bruteforce_tanks();
  2338. }
  2339. }
  2340. }
  2341.  
  2342. setInterval(check_change, 250);
  2343.  
  2344. // search tree function
  2345. function findTankAndParent(tree, id, parent = null, grandparent = null) {
  2346. for (const [key, value] of Object.entries(tree)) {
  2347. const currentParent = key === "skip" ? parent : Number(key);
  2348.  
  2349. // Match for direct keys
  2350. if (Number(key) === id) {
  2351. return { id, parent };
  2352. }
  2353.  
  2354. // Match for arrays
  2355. if (Array.isArray(value) && value.includes(id)) {
  2356. return { id, parent: currentParent };
  2357. }
  2358.  
  2359. // Special handling for "skip" keys
  2360. if (key === "skip") {
  2361. if (typeof value === "object") {
  2362. // Recursively search within "skip" tree
  2363. const result = findTankAndParent(value, id, parent, grandparent);
  2364. if (result) return result;
  2365. } else if (value === id) {
  2366. return { id, parent: grandparent }; // Use grandparent for direct "skip" match
  2367. }
  2368. }
  2369.  
  2370. // Nested object traversal
  2371. if (typeof value === "object" && value !== null) {
  2372. const result = findTankAndParent(value, id, currentParent, parent);
  2373. if (result) {
  2374. return result;
  2375. }
  2376. }
  2377. }
  2378. return null;
  2379. }
  2380.  
  2381.  
  2382. // TANK IDS TREE
  2383. const tanks_tree = {
  2384. 0: {
  2385. 1: {
  2386. 3: [2, 14, 42],
  2387. 4: [5, 40],
  2388. 13: [18, 48],
  2389. },
  2390. 6: {
  2391. 15: [21, 22],
  2392. 11: [12, 17, 26, 33, 48, 52],
  2393. 19: [28, 43],
  2394. 31: [32, 33, 34, 35, 44],
  2395. },
  2396. 7: {
  2397. skip: 29,
  2398. 10: [25, 49, 54, 55, 56],
  2399. 20: [32, 39, 43],
  2400. },
  2401. 8: {
  2402. 4: [5, 40],
  2403. 9: [23, 24],
  2404. 13: [18, 48],
  2405. 41: [39, 40],
  2406. },
  2407. skip: {
  2408. 36: [38, 50, 51],
  2409. },
  2410. },
  2411. };
  2412.  
  2413. let tank_box_nums = [
  2414. ["Twin", 0],
  2415. ["Sniper", 1],
  2416. ["Machine Gun", 2],
  2417. ["Flank Guard", 3],
  2418. ["Smasher", 4],
  2419. ["Triple Shot", 0],
  2420. ["Quad Tank", 1],
  2421. ["Twin Flank", 2],
  2422. ["Assassin", 0],
  2423. ["Overseer", 1],
  2424. ["Hunter", 2],
  2425. ["Trapper", 3],
  2426. ["Destroyer", 0],
  2427. ["Gunner", 1],
  2428. ["Sprayer", 2],
  2429. ["Tri-Angle", 0],
  2430. ["Quad Tank", 1],
  2431. ["Twin Flank", 2],
  2432. ["Auto 3", 3],
  2433. ["Landmine", 0],
  2434. ["Auto Smasher", 1],
  2435. ["Spike", 2],
  2436. ["Triplet", 0],
  2437. ["Penta Shot", 1],
  2438. ["Spread Shot", 2],
  2439. ["Octo Tank", 0],
  2440. ["Auto 5", {cond:"Auto 3", num:0}, {cond: "Quad Tank", num: 1}],
  2441. ["Triple Twin", 0],
  2442. ["Battle Ship", 1],
  2443. ["Ranger", 0],
  2444. ["Stalker", 1],
  2445. ["Overlord", 0],
  2446. ["Necromancer", 1],
  2447. ["Manager", 2],
  2448. ["Overtrapper", 3],
  2449. ["Battleship", 4],
  2450. ["Factory", 5],
  2451. ["Predator", 0],
  2452. ["Streamliner", {cond: "Hunter", num:1}, {cond: "Gunner", num:2}],
  2453. ["Tri-Trapper", 0],
  2454. ["Gunner Trapper", 1],
  2455. ["Overtrapper", 2],
  2456. ["Mega Trapper", 3],
  2457. ["Auto Trapper", 4],
  2458. ["Hybrid", 0],
  2459. ["Annihilator", 1],
  2460. ["Skimmer", 2],
  2461. ["Rocketeer", 3],
  2462. ["Glider", 4],
  2463. ["Auto Gunner", {cond: "Gunner", num: 0}, {cond: "Auto 3", num: 1}],
  2464. ["Booster", 0],
  2465. ["Fighter", 1],
  2466. ["Landmine", 0],
  2467. ["Auto Smasher", 1],
  2468. ["Spike", 2],
  2469. ];
  2470.  
  2471. function convert_id_name(type, value) {
  2472. const tank = window.__common__.tanks.find(
  2473. type === "id to name"
  2474. ? (tank) => tank.id === value
  2475. : (tank) => tank.name === value
  2476. );
  2477.  
  2478. if (!tank) {
  2479. console.error(`Tank not found for ${type}: ${value}`);
  2480. return null;
  2481. }
  2482.  
  2483. return type === "id to name" ? tank.name : tank.id;
  2484. }
  2485.  
  2486.  
  2487. function find_upgrade_cond(tank_name) {
  2488. const target_id = convert_id_name("name to id", tank_name);
  2489. if (!target_id) {
  2490. console.error("Target ID not found");
  2491. return null;
  2492. }
  2493.  
  2494. console.log(`Target ID for ${tank_name}: ${target_id}`);
  2495.  
  2496. const tree_result = findTankAndParent(tanks_tree, target_id);
  2497. if (!tree_result) {
  2498. console.error(`Tank not found in tree for ID: ${target_id}`);
  2499. return null;
  2500. }
  2501.  
  2502. const cond_id = tree_result.parent;
  2503.  
  2504. const cond_name = convert_id_name("id to name", cond_id);
  2505. if (!cond_name) {
  2506. console.error("Condition name not found");
  2507. return null;
  2508. }
  2509.  
  2510. return cond_name;
  2511. }
  2512.  
  2513. function get_full_path(Tank){
  2514. let current_tank = Tank;
  2515. let temp_arr = [];
  2516. temp_arr.push(Tank);
  2517. while(find_upgrade_cond(current_tank) != null){
  2518. current_tank = find_upgrade_cond(current_tank);
  2519. temp_arr.push(current_tank);
  2520. }
  2521. temp_arr.reverse();
  2522. return temp_arr;
  2523. }
  2524.  
  2525. function auto_upgrade(Tank){
  2526. if(player.tank === Tank){
  2527. console.log("you are already that tank");
  2528. return;
  2529. }
  2530. let temp_arr = get_full_path(Tank);
  2531. let l = temp_arr.length;
  2532. let bool = false;
  2533. for(let i = 0; i < l; i++){
  2534. if(player.tank === temp_arr[i] && i != l){
  2535. console.log(`upgrading to ${temp_arr[i+1]}`);
  2536. handle_tank_upgrades(temp_arr[i+1]);
  2537. bool = true;
  2538. break;
  2539. }
  2540. }
  2541. !bool?console.warn("something went wrong"):null;
  2542. }
  2543.  
  2544. function handle_tank_upgrades(Tank){
  2545. if(player.tank === Tank){
  2546. return;
  2547. }
  2548. let l = tank_box_nums.length;
  2549. let temp_arr = [];
  2550. let cond_num = -1;
  2551. for(let i = 0; i < l; i++){
  2552. let target = tank_box_nums[i];
  2553. if(target[0] === Tank){
  2554. temp_arr = tank_box_nums[i];
  2555. break
  2556. }
  2557. }
  2558. switch(true){
  2559. case temp_arr.length === 2:
  2560. cond_num = temp_arr[1];
  2561. break
  2562. case temp_arr.length > 2:
  2563. for(let j = 1; j < temp_arr.length; j++){
  2564. if(player.tank === temp_arr[j].cond){
  2565. cond_num = temp_arr[j].num;
  2566. }
  2567. }
  2568. break
  2569. default:
  2570. console.warn("temp_arr in illegal state, quitting...");
  2571. return
  2572. }
  2573. window.upgrading = true;
  2574. upgrade(boxes[cond_num].color);
  2575. }
  2576.  
  2577. let test_tank = "Auto Gunner";
  2578.  
  2579. function upgrade_func(){
  2580. if(state === "in game" && player.tank != test_tank && toggleButtons.Mouse["Upgrade to Auto Gunner"]){
  2581. auto_upgrade(test_tank);
  2582. }else{
  2583. window.upgrading = false;
  2584. }
  2585. }
  2586.  
  2587. setInterval(upgrade_func, 100);
  2588.  
  2589. //canvas gui
  2590. let offsetX = 0;
  2591. let offsetY = 0;
  2592. //for canvas text height and space between it
  2593. let text_startingY = canvas_2_windowScaling(450);
  2594. let textAdd = canvas_2_windowScaling(25);
  2595. let selected_box = null;
  2596. let _bp = { //box parameters
  2597. startX: 47,
  2598. startY: 67,
  2599. distX: 13,
  2600. distY: 9,
  2601. width: 86,
  2602. height: 86,
  2603. outer_xy: 2
  2604. }
  2605.  
  2606. let _bo = { //box offsets
  2607. offsetX: _bp.width + (_bp.outer_xy * 2) + _bp.distX,
  2608. offsetY: _bp.height + (_bp.outer_xy * 2) + _bp.distY
  2609. }
  2610.  
  2611. function step_offset(steps, offset){
  2612. let final_offset = 0;
  2613. switch(offset){
  2614. case "x":
  2615. final_offset = _bp.startX + (steps * _bo.offsetX);
  2616. break
  2617. case "y":
  2618. final_offset = _bp.startY + (steps * _bo.offsetY);
  2619. break
  2620. }
  2621. return final_offset;
  2622. }
  2623.  
  2624. const boxes = [
  2625. {
  2626. color: "lightblue",
  2627. LUcornerX: _bp.startX,
  2628. LUcornerY: _bp.startY
  2629. },
  2630. {
  2631. color: "green",
  2632. LUcornerX: _bp.startX + _bo.offsetX,
  2633. LUcornerY: _bp.startY
  2634. },
  2635. {
  2636. color: "red",
  2637. LUcornerX: _bp.startX,
  2638. LUcornerY: _bp.startY + _bo.offsetY
  2639. },
  2640. {
  2641. color: "yellow",
  2642. LUcornerX: _bp.startX + _bo.offsetX,
  2643. LUcornerY: _bp.startY + _bo.offsetY
  2644. },
  2645. {
  2646. color: "blue",
  2647. LUcornerX: _bp.startX,
  2648. LUcornerY: step_offset(2, "y")
  2649. },
  2650. {
  2651. color: "rainbow",
  2652. LUcornerX: _bp.startX + _bo.offsetX,
  2653. LUcornerY: step_offset(2, "y")
  2654. }
  2655. ]
  2656.  
  2657. //new upgrading Tank logic
  2658. function upgrade_get_coords(color){
  2659. let l = boxes.length;
  2660. let upgrade_coords = {x: "not defined", y: "not defined"};
  2661. for(let i = 0; i < l; i++){
  2662. if(boxes[i].color === color){
  2663. upgrade_coords.x = windowScaling_2_window(boxes[i].LUcornerX + (_bp.width/2));
  2664. upgrade_coords.y = windowScaling_2_window(boxes[i].LUcornerY + (_bp.height/2));
  2665. }
  2666. }
  2667. return upgrade_coords;
  2668. }
  2669.  
  2670. function get_invert_mouse_coords(){
  2671. let _x = coords.x;
  2672. let _y = coords.y;
  2673. let center = {x: window.innerWidth/2, y: window.innerHeight/2};
  2674. let d = {x: _x-center.x, y: _y-center.y};
  2675. let inverted_coords = {x: center.x-d.x, y: center.y-d.y};
  2676. return inverted_coords;
  2677. }
  2678.  
  2679. let inverted = false;
  2680.  
  2681. function invert_mouse(){
  2682. window.requestAnimationFrame(invert_mouse);
  2683. if(!connected){
  2684. return;
  2685. }
  2686. if((toggleButtons.Mouse["Anti Aim"] || toggleButtons.Mouse["Freeze Mouse"]) && !toggleButtons.Mouse["Sandbox Hacks"]){
  2687. return;
  2688. }
  2689. if(!inverted){
  2690. mouse_move(coords.x, coords.y);
  2691. return;
  2692. }
  2693. let new_coords = get_invert_mouse_coords();
  2694. freezeMouseMove();
  2695. mouse_move(new_coords.x, new_coords.y);
  2696. }
  2697. window.requestAnimationFrame(invert_mouse);
  2698.  
  2699. function handle_sandbox_checks(){
  2700. if(toggleButtons.Mouse["Sandbox Hacks"]){
  2701. if(gamemode != "Sandbox"){
  2702. one_time_notification("To use sandbox hacks, switch to a sandbox server", rgbToNumber(...notification_rbgs.warning), 2500);
  2703. return;
  2704. }
  2705. if(input.get_convar("ren_upgrades") != 'true'){
  2706. input.set_convar("ren_upgrades", 'true');
  2707. one_time_notification(`force enabled ren_upgrades for the script`, rgbToNumber(...notification_rbgs.require), 2500);
  2708. }
  2709. triflank = true;
  2710. one_time_notification(`To start, upgrade to ${sandbox_hax_modes[sandbox_hax_index].tank}`, rgbToNumber(...notification_rbgs.normal), 2500);
  2711. }else{
  2712. triflank = false;
  2713. }
  2714. }
  2715.  
  2716. function smart_shgun(){
  2717. handle_sandbox_checks();
  2718. if(triflank && sandbox_hax_modes[sandbox_hax_index].name === "Shotgun"){
  2719. shotgun(sandbox_hax_index);
  2720. }
  2721. }
  2722. setInterval(smart_shgun, 0);
  2723.  
  2724. function smart_trap(){
  2725. handle_sandbox_checks();
  2726. if(triflank && sandbox_hax_modes[sandbox_hax_index].name === "Trap Flip"){
  2727. one_time_notification("Warning! Trap Flip uses flip fire, which might be incosistent on laggy servers", rgbToNumber(...notification_rbgs.warning), 2500);
  2728. flip_trap1(sandbox_hax_index);
  2729. }else{
  2730. inverted?inverted = false: null;
  2731. }
  2732. }
  2733.  
  2734. setInterval(smart_trap, 250);
  2735.  
  2736. function smart_triflank(){
  2737. handle_sandbox_checks();
  2738. if(triflank && !sandbox_hax_modes[sandbox_hax_index].unique){
  2739. sandbox_hax_loop(sandbox_hax_index);
  2740. }
  2741. }
  2742.  
  2743. setInterval(smart_triflank, 200);
  2744.  
  2745. function is_between(Tank){
  2746. //USE FOR SANDBOX ONLY
  2747. let start = find_upgrade_cond(Tank);
  2748. let end = Tank;
  2749. let interval = [convert_id_name("name to id", start), convert_id_name("name to id", end)];
  2750. let ids = [];
  2751. for(let i = interval[1]; i >= interval[0]; i--){
  2752. let name = convert_id_name("id to name", i);
  2753. ids.push(name);
  2754. }
  2755. return ids.includes(player.tank);
  2756. }
  2757.  
  2758. function sandbox_hax_loop(i){
  2759. if(player.tank === find_upgrade_cond(sandbox_hax_modes[i].tank)){
  2760. //auto_spin?null:key_press("KeyC", 100 * multiplier);
  2761. //auto_spin = !auto_spin;
  2762. setTimeout(() => {
  2763. upgrade(sandbox_hax_modes[i].color, 0, 0, 0);
  2764. }, 100);
  2765. setTimeout(() => {
  2766. mouse_move(coords.x, coords.y);
  2767. }, 100);
  2768. }else if(is_between(sandbox_hax_modes[i].tank)){
  2769. //auto_spin?key_press("KeyC", 250 * multiplier):null;
  2770. //auto_spin = !auto_spin;
  2771. key_press("Backslash", 100);
  2772. }
  2773. }
  2774.  
  2775. function flip_trap1(i){
  2776. if(player.tank === find_upgrade_cond(sandbox_hax_modes[i].tank)){
  2777. setTimeout(() => {
  2778. inverted = true;
  2779. }, 200);
  2780. setTimeout(() => {
  2781. upgrade(sandbox_hax_modes[i].color, 0, 0, 0);
  2782. }, 250);
  2783. }else if(is_between(sandbox_hax_modes[i].tank)){
  2784. setTimeout(() => {
  2785. inverted = false;
  2786. }, 50);
  2787. setTimeout(() => {
  2788. key_press("Backslash");
  2789. }, 75);
  2790. }
  2791. }
  2792.  
  2793. function shotgun(i){
  2794. console.log(sandbox_hax_modes[i].tank);
  2795. if(player.tank === find_upgrade_cond(sandbox_hax_modes[i].tank[0]) || player.tank === find_upgrade_cond(sandbox_hax_modes[i].tank[1])){
  2796. upgrade(sandbox_hax_modes[i].color, 0, 0, 0);
  2797. mouse_move(coords.x, coords.y);
  2798. // }else if(is_between(sandbox_hax_modes[i].tank[1])){
  2799. }else if(player.tank === sandbox_hax_modes[i].tank[1]){
  2800. key_press("Backslash", 0);
  2801. }
  2802. }
  2803.  
  2804. function upgrade(color, delay = 100, cdelay1, cdelay2){
  2805. let u_coords = upgrade_get_coords(color);
  2806. ghost_click_at(u_coords.x, u_coords.y, cdelay1, cdelay2);
  2807. }
  2808.  
  2809. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  2810. ctx.fillStyle = fcolor;
  2811. ctx.lineWidth = lineWidth;
  2812. ctx.font = font;
  2813. ctx.strokeStyle = scolor;
  2814. ctx.strokeText(`${text}`, textX, textY)
  2815. ctx.fillText(`${text}`, textX, textY)
  2816. }
  2817.  
  2818. function ctx_rect(x, y, a, b, c) {
  2819. ctx.beginPath();
  2820. ctx.strokeStyle = c;
  2821. ctx.strokeRect(x, y, a, b);
  2822. }
  2823.  
  2824. //use this for game entities
  2825. function dot_in_diepunits(diepunits_X, diepunits_Y) {
  2826. ctx_arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, 5, 0, 2 * Math.PI, false, "lightblue");
  2827. }
  2828.  
  2829. function circle_in_diepunits(diepunits_X, diepunits_Y, diepunits_R, c) {
  2830. ctx.beginPath();
  2831. ctx.arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, diepunits_R * scalingFactor, 0, 2 * Math.PI, false);
  2832. ctx.strokeStyle = c;
  2833. ctx.stroke();
  2834. }
  2835.  
  2836. function big_half_circle(diepunits_X, diepunits_Y, diepunits_R, c) {
  2837. let centerY = diepunits_Y * scalingFactor;
  2838. let centerX = diepunits_X * scalingFactor;
  2839. let angle = Math.atan2(coords.y - centerY, coords.x - centerX);
  2840. ctx.beginPath();
  2841. ctx.arc(centerX, centerY, diepunits_R * scalingFactor, angle - Math.PI / 2, angle + Math.PI / 2, false);
  2842. ctx.strokeStyle = c;
  2843. ctx.stroke();
  2844. }
  2845.  
  2846. function small_half_circle(diepunits_X, diepunits_Y, diepunits_R, c) {
  2847. let centerY = diepunits_Y * scalingFactor;
  2848. let centerX = diepunits_X * scalingFactor;
  2849. let angle = Math.atan2(coords.y - centerY, coords.x - centerX);
  2850. ctx.beginPath();
  2851. ctx.arc(centerX, centerY, diepunits_R * scalingFactor, angle + Math.PI / 2, angle - Math.PI / 2, false);
  2852. ctx.strokeStyle = c;
  2853. ctx.stroke();
  2854. }
  2855.  
  2856. //use this for ui elements like upgrades or scoreboard
  2857. function dot_in_diepunits_FOVless(diepunits_X, diepunits_Y) {
  2858. ctx_arc(canvas_2_windowScaling(diepunits_X), canvas_2_windowScaling(diepunits_Y), 5, 0, 2 * Math.PI, false, "lightblue");
  2859. }
  2860.  
  2861. function grid_rect(x, y, a, b, color) {
  2862. ctx.beginPath();
  2863. ctx.rect(canvas_2_windowScaling(x), canvas_2_windowScaling(y), canvas_2_windowScaling(a), canvas_2_windowScaling(b));
  2864. ctx.strokeStyle = color;
  2865. ctx.stroke();
  2866. }
  2867.  
  2868. function draw_upgrade_grid() {
  2869. let box = {width: 86, height: 86}; //in windowScaling
  2870. let l = boxes.length;
  2871. for (let i = 0; i < l; i++) {
  2872. let start_x = windowScaling_2_window(boxes[i].LUcornerX);
  2873. let start_y = windowScaling_2_window(boxes[i].LUcornerY);
  2874. let end_x = windowScaling_2_window(boxes[i].LUcornerX + box.width);
  2875. let end_y = windowScaling_2_window(boxes[i].LUcornerY + box.height);
  2876. let temp_color = "black";
  2877. if (coords.x > start_x && coords.y > start_y && coords.x < end_x && coords.y < end_y) {
  2878. temp_color = "red";
  2879. selected_box = i;
  2880. } else {
  2881. temp_color = "black";
  2882. selected_box = null;
  2883. }
  2884. grid_rect(boxes[i].LUcornerX, boxes[i].LUcornerY, 86, 86, temp_color);
  2885. }
  2886. for (let i = 0; i < l; i++) {
  2887. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY);
  2888. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width/2, boxes[i].LUcornerY);
  2889. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width, boxes[i].LUcornerY);
  2890. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width, boxes[i].LUcornerY + box.height/2);
  2891. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width, boxes[i].LUcornerY + box.height);
  2892. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY + box.height/2);
  2893. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY + box.height);
  2894. dot_in_diepunits_FOVless(boxes[i].LUcornerX + box.width, boxes[i].LUcornerY + box.height/2);
  2895. }
  2896. }
  2897.  
  2898. const gradients = ["#94b3d0", "#96b0c7", "#778daa", "#4c7299", "#52596c", "#19254e", "#2d445f", "#172631"];
  2899. const tank_group1 = ["Trapper", "Overtrapper", "Mega Trapper", "Tri-Trapper"]; //Traps only
  2900. const tank_group2 = ["Tank", "Twin", "Triple Shot", "Spread Shot", "Penta Shot", "Machine Gun", "Sprayer", "Triplet"]; //constant bullets [initial speed = 0.699]
  2901. const tank_group2round = ["Twin Flank", "Triple Twin", "Quad Tank", "OctoT ank", "Flank Guard"];
  2902. const tank_group3 = ["Gunner Trapper"]; //Traps AND constant bullets
  2903. const tank_group4 = ["Fighter", "Booster", "Tri-Angle"]; // fast tanks
  2904. const tank_group5 = ["Sniper", "Assassin", "Stalker", "Ranger"]; //sniper+ bullets
  2905. const tank_group6 = ["Destroyer", "Hybrid", "Annihilator"]; //slower bullets [intitial speed = 0.699]
  2906. //const tank_group7 = ["Overseer", "Overlord", "Manager", "Necromancer"]; //infinite bullets(drones) (UNFINISHED)
  2907. const tank_group8 = ["Factory"]; //drones with spreading abilities
  2908. const tank_group9 = ["Battleship"]; //special case
  2909. const tank_group10 = ["Streamliner"]; // special case
  2910. const tank_group11 = ["Gunner", "AutoGunner"] // (UNFINISHED)
  2911.  
  2912. //get bullet speed
  2913. function count_fours(string) {
  2914. let fours_count = 0;
  2915. let temp_array = [...string];
  2916. for (let i = 0; i < temp_array.length; i++) {
  2917. if (temp_array[i] === "4") {
  2918. fours_count++;
  2919. }
  2920. }
  2921. return fours_count;
  2922. }
  2923.  
  2924. function draw_cirle_radius_for_tank() {
  2925. let b_s;
  2926. if (diep_data.length > 0) {
  2927. player.raw_build = diep_data[0][1];
  2928. player.real_time_build = real_build(player.raw_build);
  2929. b_s = count_fours(player.real_time_build);
  2930. } else {
  2931. b_s = 0;
  2932. }
  2933.  
  2934. if (tank_group1.includes(player.tank)) {
  2935. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 485 + (52.5 * b_s), gradients[b_s]);
  2936. } else if (tank_group2.includes(player.tank)) {
  2937. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  2938. } else if (tank_group2round.includes(player.tank)) {
  2939. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  2940. } else if (tank_group3.includes(player.tank)) {
  2941. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  2942. small_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 485 + (52.5 * b_s), gradients[b_s]);
  2943. } else if (tank_group4.includes(player.tank)) {
  2944. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  2945. small_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1135 + (100 * b_s), gradients[b_s]);
  2946. } else if (tank_group5.includes(player.tank)) {
  2947. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 2680 + (350 * b_s), gradients[b_s]);
  2948. } else if (tank_group6.includes(player.tank)) {
  2949. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1443.21 + (146.79 * b_s), gradients[b_s]);
  2950. /*
  2951. }else if(tank_group7.includes(player.tank)){
  2952. circle_in_diepunits( canvas.width/2/scalingFactor , canvas.height/2/scalingFactor, 1607 + (145*b_s), gradients[b_s]);
  2953. circle_in_diepunits( coords.x*2/scalingFactor , coords.y*2/scalingFactor, 1607 + (145*i), gradients[b_s]);
  2954. */
  2955. } else if (tank_group8.includes(player.tank)) {
  2956. if (!auto_fire) {
  2957. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 200, gradients[0]);
  2958. } else {
  2959. circle_in_diepunits(coords.x * two / scalingFactor, coords.y * two / scalingFactor, 800, gradients[1]);
  2960. circle_in_diepunits(coords.x * two / scalingFactor, coords.y * two / scalingFactor, 900, gradients[2]);
  2961. }
  2962. } else if (tank_group9.includes(player.tank)) {
  2963. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1640 + (210 * b_s), gradients[b_s]);
  2964. } else if (tank_group10.includes(player.tank)) {
  2965. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1750 + (190 * b_s), gradients[b_s]);
  2966. } else {
  2967. return;
  2968. }
  2969.  
  2970. }
  2971.  
  2972. //let's calculate the angle
  2973. var vector_l = [null, null];
  2974. var angle_l = 0;
  2975.  
  2976. function calc_leader() {
  2977. if (script_list.minimap_leader_v1) {
  2978. let xc = canvas.width / 2;
  2979. let yc = canvas.height / 2;
  2980. vector_l[0] = window.l_arrow.xl - xc;
  2981. vector_l[1] = window.l_arrow.yl - yc;
  2982. angle_l = Math.atan2(vector_l[1], vector_l[0]) * (180 / Math.PI);
  2983. } else if (script_list.minimap_leader_v2) {
  2984. let xc = canvas.width / 2;
  2985. let yc = canvas.height / 2;
  2986. vector_l[0] = window.L_X - xc;
  2987. vector_l[1] = window.L_Y - yc;
  2988. angle_l = Math.atan2(vector_l[1], vector_l[0]) * (180 / Math.PI);
  2989. } else {
  2990. console.log("waiting for leader script to give us values");
  2991. }
  2992. }
  2993.  
  2994. // Minimap logic
  2995. var minimap_elements = [
  2996. {
  2997. name: "minimap",
  2998. x: 177.5,
  2999. y: 177.5,
  3000. width: 162.5,
  3001. height: 162.5,
  3002. color: "purple"
  3003. },
  3004. {
  3005. name: "2 Teams Blue Team",
  3006. x: 177.5,
  3007. y: 177.5,
  3008. width: 17.5,
  3009. height: 162.5,
  3010. color: "blue"
  3011. },
  3012. {
  3013. name: "2 Teams Blue Team zone",
  3014. x: 160.0,
  3015. y: 177.5,
  3016. width: 17.5,
  3017. height: 162.5,
  3018. color: "SlateBlue"
  3019. },
  3020. {
  3021. name: "2 Teams Red Team",
  3022. x: 32.5,
  3023. y: 177.5,
  3024. width: 17.5,
  3025. height: 162.5,
  3026. color: "red"
  3027. },
  3028. {
  3029. name: "2 Teams Red Team zone",
  3030. x: 50,
  3031. y: 177.5,
  3032. width: 17.5,
  3033. height: 162.5,
  3034. color: "orangeRed"
  3035. },
  3036. {
  3037. name: "4 Teams Blue Team",
  3038. x: 177.5,
  3039. y: 177.5,
  3040. width: 25,
  3041. height: 25,
  3042. color: "blue"
  3043. },
  3044. {
  3045. name: "4 Teams Blue zone",
  3046. x: 177.5,
  3047. y: 177.5,
  3048. width: 40,
  3049. height: 40,
  3050. color: "SlateBlue"
  3051. },
  3052. {
  3053. name: "4 Teams Purple Team",
  3054. x: 40,
  3055. y: 177.5,
  3056. width: 25,
  3057. height: 25,
  3058. color: "purple"
  3059. },
  3060. {
  3061. name: "4 Teams Purple zone",
  3062. x: 55,
  3063. y: 177.5,
  3064. width: 40,
  3065. height: 40,
  3066. color: "Violet"
  3067. },
  3068. {
  3069. name: "4 Teams Green Team",
  3070. x: 177.5,
  3071. y: 40,
  3072. width: 25,
  3073. height: 25,
  3074. color: "green"
  3075. },
  3076. {
  3077. name: "4 Teams Green zone",
  3078. x: 177.5,
  3079. y: 55,
  3080. width: 40,
  3081. height: 40,
  3082. color: "LimeGreen"
  3083. },
  3084. {
  3085. name: "4 Teams Red Team",
  3086. x: 40,
  3087. y: 40,
  3088. width: 25,
  3089. height: 25,
  3090. color: "orangeRed"
  3091. },
  3092. {
  3093. name: "4 Teams Red zone",
  3094. x: 55,
  3095. y: 55,
  3096. width: 40,
  3097. height: 40,
  3098. color: "red"
  3099. },
  3100. ];
  3101.  
  3102. var m_e_ctx_coords = [
  3103. {
  3104. name: "minimap",
  3105. startx: null,
  3106. stary: null,
  3107. endx: null,
  3108. endy: null
  3109. },
  3110. {
  3111. name: "2 Teams Blue Team",
  3112. startx: null,
  3113. stary: null,
  3114. endx: null,
  3115. endy: null
  3116. },
  3117. {
  3118. name: "2 Teams Blue Team Zone",
  3119. startx: null,
  3120. stary: null,
  3121. endx: null,
  3122. endy: null
  3123. },
  3124. {
  3125. name: "2 Teams Red Team",
  3126. startx: null,
  3127. stary: null,
  3128. endx: null,
  3129. endy: null
  3130. },
  3131. {
  3132. name: "2 Teams Red Team Zone",
  3133. startx: null,
  3134. stary: null,
  3135. endx: null,
  3136. endy: null
  3137. },
  3138. {
  3139. name: "4 Teams Blue Team",
  3140. startx: null,
  3141. stary: null,
  3142. endx: null,
  3143. endy: null
  3144. },
  3145. {
  3146. name: "4 Teams Blue zone",
  3147. startx: null,
  3148. stary: null,
  3149. endx: null,
  3150. endy: null
  3151. },
  3152. {
  3153. name: "4 Teams Purple Team",
  3154. startx: null,
  3155. stary: null,
  3156. endx: null,
  3157. endy: null
  3158. },
  3159. {
  3160. name: "4 Teams Purple zone",
  3161. startx: null,
  3162. stary: null,
  3163. endx: null,
  3164. endy: null
  3165. },
  3166. {
  3167. name: "4 Teams Green Team",
  3168. startx: null,
  3169. stary: null,
  3170. endx: null,
  3171. endy: null
  3172. },
  3173. {
  3174. name: "4 Teams Green zone",
  3175. startx: null,
  3176. stary: null,
  3177. endx: null,
  3178. endy: null
  3179. },
  3180. {
  3181. name: "4 Teams Red Team",
  3182. startx: null,
  3183. stary: null,
  3184. endx: null,
  3185. endy: null
  3186. },
  3187. {
  3188. name: "4 Teams Red zone",
  3189. startx: null,
  3190. stary: null,
  3191. endx: null,
  3192. endy: null
  3193. }
  3194. ]
  3195.  
  3196. function draw_minimap() {
  3197. //console.log('called draw_minimap function');
  3198. let l = minimap_elements.length;
  3199. switch (gamemode) {
  3200. case "2 Teams":
  3201. for (let i = 0; i < 5; i++) {
  3202. if (i === 2 || i === 4) {
  3203. if (toggleButtons.Functional['Toggle Base Zones']) {
  3204. updateAndDrawElement(i);
  3205. }
  3206. } else {
  3207. updateAndDrawElement(i);
  3208. }
  3209. }
  3210. break;
  3211. case "4 Teams":
  3212. updateAndDrawElement(0);
  3213. for (let i = 5; i < l; i++) {
  3214. if (i === 6 || i === 8 || i === 10 || i === 12) {
  3215. if (toggleButtons.Functional['Toggle Base Zones']) {
  3216. updateAndDrawElement(i);
  3217. }
  3218. } else {
  3219. updateAndDrawElement(i);
  3220. }
  3221. }
  3222. break;
  3223. }
  3224. if (script_list.minimap_leader_v1 || script_list.minimap_leader_v2) {
  3225. minimap_collision_check();
  3226. }
  3227. }
  3228.  
  3229. function updateAndDrawElement(index) {
  3230. // Update their real-time position
  3231. //console.log('updateAndDrawElement function called');
  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. //console.log('Debug Minimap is off, quitting...');
  3240. return;
  3241. }
  3242. //console.log('Drawing minimap...');
  3243. ctx.beginPath();
  3244. ctx.rect(m_e_ctx_coords[index].startx, m_e_ctx_coords[index].starty, minimap_elements[index].width * windowScaling(), minimap_elements[index].height * windowScaling());
  3245. ctx.lineWidth = "1";
  3246. ctx.strokeStyle = minimap_elements[index].color;
  3247. ctx.stroke();
  3248. }
  3249.  
  3250. function minimap_collision_check() {
  3251. //console.log('checking collision...');
  3252. if (script_list.minimap_leader_v1 || script_list.minimap_leader_v2) {
  3253. let x = script_list.minimap_leader_v1 ? window.m_arrow.xl : window.arrows[0][0];
  3254. let y = script_list.minimap_leader_v1 ? window.m_arrow.yl : window.arrows[0][1];
  3255. /*console.log(`
  3256. x: ${x}
  3257. y: ${y}
  3258. `);
  3259. */
  3260.  
  3261. if (m_e_ctx_coords[0].startx < x &&
  3262. m_e_ctx_coords[0].starty < y &&
  3263. m_e_ctx_coords[0].endx > x &&
  3264. m_e_ctx_coords[0].endy > y) {
  3265.  
  3266. if (gamemode === "2 Teams") {
  3267. if (checkWithinBase(1, x, y)) position_on_minimap = "blue base";
  3268. else if (checkWithinBase(2, x, y)) position_on_minimap = "blue drones";
  3269. else if (checkWithinBase(3, x, y)) position_on_minimap = "red base";
  3270. else if (checkWithinBase(4, x, y)) position_on_minimap = "red drones";
  3271. else position_on_minimap = "not in the base";
  3272. } else if (gamemode === "4 Teams") {
  3273. if (checkWithinBase(6, x, y)) {
  3274. if (checkWithinBase(5, x, y)) {
  3275. position_on_minimap = "blue base"
  3276. } else {
  3277. position_on_minimap = "blue drones";
  3278. }
  3279. } else if (checkWithinBase(8, x, y)) {
  3280. if (checkWithinBase(7, x, y)) {
  3281. position_on_minimap = "purple base"
  3282. } else {
  3283. position_on_minimap = "purple drones";
  3284. }
  3285. } else if (checkWithinBase(10, x, y)) {
  3286. if (checkWithinBase(9, x, y)) {
  3287. position_on_minimap = "green base"
  3288. } else {
  3289. position_on_minimap = "green drones";
  3290. }
  3291. } else if (checkWithinBase(12, x, y)) {
  3292. if (checkWithinBase(11, x, y)) {
  3293. position_on_minimap = "red base"
  3294. } else {
  3295. position_on_minimap = "red drones";
  3296. }
  3297. } else {
  3298. position_on_minimap = "not in the base";
  3299. }
  3300. } else {
  3301. position_on_minimap = "Warning! not on minimap";
  3302. }
  3303. }
  3304. }
  3305. }
  3306.  
  3307. function checkWithinBase(baseIndex, x, y) {
  3308. return m_e_ctx_coords[baseIndex].startx < x &&
  3309. m_e_ctx_coords[baseIndex].starty < y &&
  3310. m_e_ctx_coords[baseIndex].endx > x &&
  3311. m_e_ctx_coords[baseIndex].endy > y;
  3312. }
  3313.  
  3314. //notify player about entering base zones
  3315. let alerted = false;
  3316.  
  3317. let team_clrs = ["blue", "red", "purple", "green"];
  3318.  
  3319. function alert_about_drones() {
  3320. //console.log(position_on_minimap);
  3321. if (position_on_minimap.includes('drones') && !position_on_minimap.includes(team_clrs[player.team_index])) {
  3322. if (!alerted) {
  3323. new_notification("Warning drones!", rgbToNumber(...notification_rbgs.warning), 2500);
  3324. alerted = true;
  3325. }
  3326. } else {
  3327. alerted = false;
  3328. }
  3329. }
  3330.  
  3331. //let's try drawing a line to the leader
  3332.  
  3333. function apply_vector_on_minimap() {
  3334. if (script_list.minimap_leader_v2) {
  3335. let x = minimapArrow[0];
  3336. let y = minimapArrow[1];
  3337. let thetaRadians = angle_l * (Math.PI / 180);
  3338. let r = m_e_ctx_coords[0].endx - m_e_ctx_coords[0].startx;
  3339. let x2 = x + r * Math.cos(thetaRadians);
  3340. let y2 = y + r * Math.sin(thetaRadians);
  3341. ctx.beginPath();
  3342. ctx.moveTo(x, y);
  3343. ctx.lineTo(x2, y2);
  3344. ctx.stroke();
  3345. }
  3346. }
  3347.  
  3348. const circle_gradients = [
  3349. "#FF0000", // Red
  3350. "#FF4D00", // Orange Red
  3351. "#FF8000", // Orange
  3352. "#FFB300", // Dark Goldenrod
  3353. "#FFD700", // Gold
  3354. "#FFEA00", // Yellow
  3355. "#D6FF00", // Light Yellow Green
  3356. "#A3FF00", // Yellow Green
  3357. "#6CFF00", // Lime Green
  3358. "#00FF4C", // Medium Spring Green
  3359. "#00FF9D", // Turquoise
  3360. "#00D6FF", // Sky Blue
  3361. "#006CFF", // Blue
  3362. "#0000FF" // Dark Blue
  3363. ];
  3364.  
  3365. function draw_crx_events() {
  3366. //you need either leader arrow or moveTo/lineTo script from h3llside for this part
  3367. if (script_list.moveToLineTo_debug) {
  3368. let l = window.y_and_x.length;
  3369. for (let i = 0; i < l; i++) {
  3370. ctx_arc(window.y_and_x[i][0], window.y_and_x[i][1], 10, 0, 2 * Math.PI, false, circle_gradients[i]);
  3371. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", i, window.y_and_x[i][0], window.y_and_x[i][1]);
  3372. }
  3373. } else if (script_list.minimap_leader_v1) {
  3374. //ctx_arc(window.l_arrow.xm, window.l_arrow.ym, 15, 0, 2 * Math.PI, false, window.l_arrow.color);
  3375. //ctx_arc(window.m_arrow.xm, window.m_arrow.ym, 1, 0, 2 * Math.PI, false, "yellow");
  3376. ctx_arc(window.l_arrow.xl, window.l_arrow.yl, 5, 0, 2 * Math.PI, false, window.l_arrow.color);
  3377. ctx_arc(window.m_arrow.xl, window.m_arrow.yl, 1, 0, 2 * Math.PI, false, "yellow");
  3378. }
  3379. }
  3380.  
  3381. //tank aim lines
  3382. let TurretRatios = [
  3383. {
  3384. name: "Destroyer",
  3385. ratio: 95 / 71.4,
  3386. color: "red"
  3387. },
  3388. {
  3389. name: "Anni",
  3390. ratio: 95 / 96.6,
  3391. color: "darkred"
  3392. },
  3393. {
  3394. name: "Fighter",
  3395. ratio: 80 / 42,
  3396. color: "orange"
  3397. },
  3398. {
  3399. name: "Booster",
  3400. ratio: 70 / 42,
  3401. color: "green"
  3402. },
  3403. {
  3404. name: "Tank",
  3405. ratio: 95 / 42,
  3406. color: "yellow"
  3407. },
  3408. {
  3409. name: "Sniper",
  3410. ratio: 110 / 42,
  3411. color: "yellow"
  3412. },
  3413. {
  3414. name: "Ranger",
  3415. ratio: 120 / 42,
  3416. color: "orange"
  3417. },
  3418. {
  3419. name: "Hunter",
  3420. ratio: 95 / 56.7,
  3421. color: "orange"
  3422. },
  3423. {
  3424. name: "Predator",
  3425. ratio: 80 / 71.4,
  3426. color: "darkorange"
  3427. },
  3428. {
  3429. name: "Mega Trapper",
  3430. ratio: 60 / 54.6,
  3431. color: "red"
  3432. },
  3433. {
  3434. name: "Trapper",
  3435. ratio: 60 / 42,
  3436. color: "orange"
  3437. },
  3438. {
  3439. name: "Gunner Trapper",
  3440. ratio: 95 / 26.6,
  3441. color: "yellow"
  3442. },
  3443. {
  3444. name: "Predator",
  3445. ratio: 95 / 84.8,
  3446. color: "red"
  3447. },
  3448. {
  3449. name: "Gunner(small)",
  3450. ratio: 65 / 25.2,
  3451. color: "lightgreen"
  3452. },
  3453. {
  3454. name: "Gunner(big)",
  3455. ratio: 85 / 25.2,
  3456. color: "green"
  3457. },
  3458. {
  3459. name: "Spread1",
  3460. ratio: 89 / 29.4,
  3461. color: "orange"
  3462. },
  3463. {
  3464. name: "Spread2",
  3465. ratio: 83 / 29.4,
  3466. color: "orange"
  3467. },
  3468. {
  3469. name: "Spread3",
  3470. ratio: 71 / 29.4,
  3471. color: "orange"
  3472. },
  3473. {
  3474. name: "Spread4",
  3475. ratio: 65 / 29.4,
  3476. color: "orange"
  3477. },
  3478. //{name: "bullet", ratio: 1, color: "pink"},
  3479. ];
  3480.  
  3481. function drawTheThing(x, y, r, index) {
  3482. if (toggleButtons.Visual['Toggle Aim Lines']) {
  3483. if (TurretRatios[index].name != "bullet") {
  3484. ctx.strokeStyle = TurretRatios[index].color;
  3485. ctx.lineWidth = 5;
  3486.  
  3487. let extendedR = 300 * scalingFactor;
  3488.  
  3489. // Reverse the angle to switch the direction
  3490. const reversedAngle = -angle;
  3491.  
  3492. // Calculate the end point of the line
  3493. const endX = x + extendedR * Math.cos(reversedAngle);
  3494. const endY = y + extendedR * Math.sin(reversedAngle);
  3495.  
  3496. // Draw the line
  3497. ctx.beginPath();
  3498. ctx.moveTo(x, y);
  3499. ctx.lineTo(endX, endY);
  3500. ctx.stroke();
  3501.  
  3502. // Draw text at the end of the line
  3503. ctx.font = "20px Arial";
  3504. ctx.fillStyle = TurretRatios[index].color;
  3505. ctx.strokeStyle = "black";
  3506. ctx.strokeText(TurretRatios[index].name, endX, endY);
  3507. ctx.fillText(TurretRatios[index].name, endX, endY);
  3508. ctx.beginPath();
  3509. } else {
  3510. ctx.strokeStyle = TurretRatios[index].color;
  3511. ctx.lineWidth = 5;
  3512.  
  3513. // Draw text at the end of the line
  3514. ctx.font = "15px Arial";
  3515. ctx.fillStyle = TurretRatios[index].color;
  3516. ctx.strokeStyle = "black";
  3517. let tankRadiusesTrans = [];
  3518. for (let i = 1; i <= 45; i++) {
  3519. let value = Math.abs((48.589 * (1.01 ** (i - 1))) * Math.abs(scalingFactor).toFixed(4)).toFixed(3);
  3520. tankRadiusesTrans.push(value);
  3521. }
  3522.  
  3523. let r_abs = Math.abs(r).toFixed(3);
  3524. if (r_abs < tankRadiusesTrans[0]) {
  3525. ctx.beginPath();
  3526. ctx.strokeStyle = TurretRatios[index].color;
  3527. ctx.arc(x, y - r / 2, r * 2, 0, 2 * Math.PI);
  3528. ctx.stroke();
  3529. ctx.beginPath();
  3530. } else {
  3531.  
  3532. // Find the closest value in the array
  3533. let closestValue = tankRadiusesTrans.reduce((prev, curr) => {
  3534. return (Math.abs(curr - r_abs) < Math.abs(prev - r_abs) ? curr : prev);
  3535. });
  3536.  
  3537. // Find the index of the closest value
  3538. let closestIndex = tankRadiusesTrans.indexOf(closestValue);
  3539.  
  3540. if (closestIndex !== -1) {
  3541. let r_name = `Level ${closestIndex + 1}`;
  3542. ctx.strokeText(r_name, x, y + 50 * scalingFactor);
  3543. ctx.fillText(r_name, x, y + 50 * scalingFactor);
  3544. ctx.beginPath();
  3545. } else {
  3546.  
  3547. let r_name = `radius: ${Math.abs(r).toFixed(4)} 1: ${tankRadiusesTrans[0]} 2: ${tankRadiusesTrans[1]} 3: ${tankRadiusesTrans[2]}`;
  3548. ctx.strokeText(r_name, x, y);
  3549. ctx.fillText(r_name, x, y);
  3550. ctx.beginPath();
  3551. }
  3552. /*
  3553. ctx.strokeText(TurretRatios[index].name, x, y);
  3554. ctx.fillText(TurretRatios[index].name, x, y);
  3555. */
  3556. }
  3557. }
  3558. }
  3559. }
  3560.  
  3561. var angle, a, b, width;
  3562. let perm_cont = [];
  3563.  
  3564. CanvasRenderingContext2D.prototype.setTransform = new Proxy(CanvasRenderingContext2D.prototype.setTransform, {
  3565. apply(target, thisArgs, args) {
  3566. // Check if the ratio matches the specified conditions
  3567. let l = TurretRatios.length;
  3568. for (let i = 0; i < l; i++) {
  3569. if (Math.abs(args[0] / args[3]).toFixed(3) == (TurretRatios[i].ratio).toFixed(3)) {
  3570. if (TurretRatios[i].name === "bullet") {
  3571. if (args[0] != 1 && args[0] > 10 && args[0] < 100 && args[4] > 1 && args[5] > 1 && args[4] != args[5] &&
  3572. thisArgs.globalAlpha != 0.10000000149011612 && thisArgs.globalAlpha != 0.3499999940395355) {
  3573. if (!perm_cont.includes(thisArgs)) {
  3574. perm_cont.push(thisArgs);
  3575. //console.log(perm_cont);
  3576. }
  3577. angle = Math.atan2(args[2], args[3]) || 0;
  3578. width = Math.hypot(args[3], args[2]);
  3579. a = args[4] - Math.cos(angle + Math.PI / 2) * width / 2;
  3580. b = args[5] + Math.sin(angle + Math.PI / 2) * width / 2;
  3581. //console.log(b);
  3582. if (a > 0 && b > 0 && thisArgs.fillStyle != "#1B1B1B") { //OUTLINE COLOR
  3583. drawTheThing(a, b, Math.hypot(args[3], args[2]), i);
  3584. }
  3585. }
  3586. } else {
  3587. angle = Math.atan2(args[2], args[3]) || 0;
  3588. width = Math.hypot(args[3], args[2]);
  3589. a = args[4] - Math.cos(angle + Math.PI / 2) * width / 2;
  3590. b = args[5] + Math.sin(angle + Math.PI / 2) * width / 2;
  3591. drawTheThing(a, b, Math.hypot(args[3], args[2]), i);
  3592. }
  3593. }
  3594. }
  3595. return Reflect.apply(target, thisArgs, args);
  3596. }
  3597. });
  3598.  
  3599. const ms_fps_clrs = ["lime", "green", "yellow", "orange", "darkorange", "red", "darkred"];
  3600. const ms_filters = new Uint16Array([15, 26, 50, 90, 170, 380, 1000]);
  3601. const fps_filters = new Uint16Array([59, 55, 50, 35, 20, 10, 5]);
  3602.  
  3603. function pick_fps_color() {
  3604. let fps_num = parseFloat(fps);
  3605. let l = fps_filters.length;
  3606. for (let i = 0; i < l; i++) {
  3607. if (fps_num > fps_filters[i]) {
  3608. ctx_text(ms_fps_clrs[i], "black", 4, 1 + "em Ubuntu", fps + "fps", canvas.width / 2, canvas.height / 2);
  3609. return;
  3610. }
  3611. }
  3612. }
  3613.  
  3614. function pick_ms_color() {
  3615. let ms_num = parseFloat(ms);
  3616. for (let i = 0; i < ms_filters.length; i++) {
  3617. if (ms_num < ms_filters[i]) {
  3618. ctx_text(ms_fps_clrs[i], "black", 4, 1 + "em Ubuntu", ms + "ms", canvas.width / 2, canvas.height / 2 + 20);
  3619. return;
  3620. }
  3621. }
  3622. }
  3623.  
  3624. //gonna work on that later (it's not accurate enough)
  3625. const arena_sizes = {
  3626. startX: -3400,
  3627. startY: -3400,
  3628. endX: 3400,
  3629. endY: 3400
  3630. }
  3631.  
  3632. function world_2_minimap(x, y){
  3633. let minimap_width = minimapDim[0];
  3634. let minimap_height = minimapDim[1];
  3635. let center = {x:minimapPos[0]+minimap_width/2, y:minimapPos[1]+minimap_height/2};
  3636. let scaled_du = minimap_width/(arena_sizes.endX*2);
  3637. return {x:center.x+(x*scaled_du), y:center.y+(y*scaled_du)};
  3638. }
  3639.  
  3640. function world_your_pos(){
  3641. let minimap_width = (minimapPos[0]+minimapDim[0])-minimapPos[0];
  3642. let minimap_height = (minimapPos[1]+minimapDim[1])-minimapPos[1];
  3643. let center = {x:minimapPos[0]+minimap_width/2, y:minimapPos[1]+minimap_height/2};
  3644. let scaled_du = minimap_width/(arena_sizes.endX*2);
  3645. let offset = {x: (minimapArrow[0] - center.x)/scaled_du, y: (minimapArrow[1] - center.y)/scaled_du};
  3646. console.log(offset);
  3647. return offset;
  3648. }
  3649.  
  3650. function window_2_world(x, y){
  3651. let tank_pos = world_your_pos();
  3652. /*
  3653. let width = window.innerWidth*FOV;
  3654. let height = window.innerHeight*FOV;
  3655. */
  3656. let width = window.innerWidth;
  3657. let height = window.innerHeight;
  3658. let corners = {
  3659. lu: {
  3660. x: tank_pos.x-(width/2),
  3661. y: tank_pos.y-(height/2)
  3662. },
  3663. rb: {
  3664. x: tank_pos.x+(width/2),
  3665. y: tank_pos.y+(height/2)
  3666. }
  3667. }
  3668. let final_coords = {x: corners.lu.x+x, y: corners.lu.y+y};
  3669. return final_coords;
  3670. }
  3671.  
  3672. function world_2_window(x, y){
  3673. let tank_pos = world_your_pos();
  3674.  
  3675. let final_coords = {
  3676. x: (x-tank_pos.x)/FOV,
  3677. y: (y-tank_pos.y)/FOV
  3678. }
  3679. //ctx_arc(window_2_canvas(final_coords.x), window_2_canvas(final_coords.y), 10, 0, 2 * Math.PI, false, "yellow");
  3680. //console.log(final_coords);
  3681. return final_coords;
  3682. }
  3683.  
  3684. function draw_point(x, y){
  3685. let point = world_2_minimap(x, y);
  3686. ctx_arc(window_2_canvas(point.x), window_2_canvas(point.y), 1, 0, 2 * Math.PI, false, "yellow");
  3687. }
  3688.  
  3689. //keys visualiser
  3690. function transparent_rect_fill(x, y, a, b, scolor, fcolor, opacity){
  3691. ctx.beginPath();
  3692. ctx.rect(x, y, a, b);
  3693.  
  3694. // Set stroke opacity
  3695. ctx.globalAlpha = 1; // Reset to 1 for stroke, or set as needed
  3696. ctx.strokeStyle = scolor;
  3697. ctx.stroke();
  3698.  
  3699. // Set fill opacity
  3700. ctx.globalAlpha = opacity; // Set the opacity for the fill color
  3701. ctx.fillStyle = fcolor;
  3702. ctx.fill();
  3703.  
  3704. // Reset globalAlpha back to 1 for future operations
  3705. ctx.globalAlpha = 1;
  3706. }
  3707.  
  3708. let ctx_wasd = {
  3709. square_sizes: { //in windowScaling
  3710. a: 50,
  3711. b: 50
  3712. },
  3713. text_props: {
  3714. lineWidth: 3,
  3715. font: 1 + "em Ubuntu",
  3716. },
  3717. square_colors: {
  3718. stroke: "black",
  3719. unpressed: "yellow",
  3720. pressed: "orange"
  3721. },
  3722. text_colors: {
  3723. stroke: "black",
  3724. unpressed: "orange",
  3725. pressed: "red"
  3726. },
  3727. w: {
  3728. x: 300,
  3729. y: 200,
  3730. pressed: false,
  3731. text: 'W'
  3732. },
  3733. a: {
  3734. x: 350,
  3735. y: 150,
  3736. pressed: false,
  3737. text: 'A'
  3738. },
  3739. s: {
  3740. x: 300,
  3741. y: 150,
  3742. pressed: false,
  3743. text: 'S'
  3744. },
  3745. d: {
  3746. x: 250,
  3747. y: 150,
  3748. pressed: false,
  3749. text: 'D'
  3750. },
  3751. l_m: {
  3752. x: 350,
  3753. y: 75,
  3754. pressed: false,
  3755. text: 'LMC'
  3756. },
  3757. r_m: {
  3758. x: 250,
  3759. y: 75,
  3760. pressed: false,
  3761. text: 'RMC'
  3762. },
  3763. }
  3764.  
  3765. function visualise_keys(){
  3766. let keys = ['w', 'a', 's', 'd', 'l_m', 'r_m'];
  3767. let l = keys.length;
  3768. for(let i = 0; i < l; i++){
  3769. let args = {
  3770. x: canvas.width - windowScaling_2_canvas(ctx_wasd[keys[i]].x),
  3771. y: canvas.height - windowScaling_2_canvas(ctx_wasd[keys[i]].y),
  3772. a: windowScaling_2_canvas(ctx_wasd.square_sizes.a),
  3773. b: windowScaling_2_canvas(ctx_wasd.square_sizes.b),
  3774. s_c: ctx_wasd.square_colors.stroke,
  3775. f_c: ctx_wasd[keys[i]].pressed? ctx_wasd.square_colors.pressed : ctx_wasd.square_colors.unpressed,
  3776. t_s: ctx_wasd.text_colors.stroke,
  3777. t_f: ctx_wasd[keys[i]].pressed? ctx_wasd.text_colors.pressed : ctx_wasd.text_colors.unpressed,
  3778. t_lineWidth: ctx_wasd.text_props.lineWidth,
  3779. t_font: ctx_wasd.text_props.font,
  3780. text: ctx_wasd[keys[i]].text,
  3781. opacity: 0.25
  3782. }
  3783. transparent_rect_fill(
  3784. args.x,
  3785. args.y,
  3786. args.a,
  3787. args.b,
  3788. args.s_c,
  3789. args.f_c,
  3790. args.opacity
  3791. );
  3792. ctx_text(
  3793. args.t_f,
  3794. args.t_s,
  3795. args.t_lineWidth,
  3796. args.t_font,
  3797. args.text,
  3798. args.x+(args.a/2),
  3799. args.y+(args.b/2)
  3800. );
  3801. }
  3802. }
  3803.  
  3804. document.body.addEventListener("keydown", function(e) {
  3805. switch(e.code){
  3806. case "KeyW":
  3807. ctx_wasd.w.pressed = true;
  3808. break
  3809. case "KeyA":
  3810. ctx_wasd.a.pressed = true;
  3811. break
  3812. case "KeyS":
  3813. ctx_wasd.s.pressed = true;
  3814. break
  3815. case "KeyD":
  3816. ctx_wasd.d.pressed = true;
  3817. break
  3818. }
  3819. });
  3820.  
  3821. document.body.addEventListener("keyup", function(e) {
  3822. switch(e.code){
  3823. case "KeyW":
  3824. ctx_wasd.w.pressed = false;
  3825. break
  3826. case "KeyA":
  3827. ctx_wasd.a.pressed = false;
  3828. break
  3829. case "KeyS":
  3830. ctx_wasd.s.pressed = false;
  3831. break
  3832. case "KeyD":
  3833. ctx_wasd.d.pressed = false;
  3834. break
  3835. }
  3836. });
  3837.  
  3838. document.body.addEventListener("mousedown", function(e) {
  3839. switch(e.button){
  3840. case 0:
  3841. ctx_wasd.l_m.pressed = true;
  3842. break
  3843. case 2:
  3844. ctx_wasd.r_m.pressed = true;
  3845. break
  3846. }
  3847. });
  3848.  
  3849. document.body.addEventListener("mouseup", function(e) {
  3850. switch(e.button){
  3851. case 0:
  3852. ctx_wasd.l_m.pressed = false;
  3853. break
  3854. case 2:
  3855. ctx_wasd.r_m.pressed = false;
  3856. break
  3857. }
  3858. });
  3859.  
  3860. setTimeout(() => {
  3861. let gui = () => {
  3862. check_addon_scripts();
  3863. text_startingY = canvas_2_windowScaling(450);
  3864. textAdd = canvas_2_windowScaling(25);
  3865. if (state === "in game") {
  3866. //transparent_rect_fill(canvas_2_windowScaling(100), canvas_2_windowScaling(100), 250, 250, "black", "yellow", 0.25);
  3867. if(toggleButtons.Visual['Wasd & Mouse press visualiser']){
  3868. visualise_keys();
  3869. }
  3870. if(window.arrowv2_debug){
  3871. draw_arrow(minimapArrow[0], minimapArrow[1], "lime");
  3872. draw_viewport();
  3873. draw_arrow(leaderArrow[0], leaderArrow[1], "pink");
  3874. draw_arrow(minimapPos[0], minimapPos[1], "purple");
  3875. }
  3876. /*
  3877. let coordss = world_2_window(arena_sizes.startX + 1450, arena_sizes.startY + 1450);
  3878. ctx.beginPath();
  3879. ctx.moveTo(window.innerWidth/2, window.innerHeight/2);
  3880. ctx.lineTo(coordss.x, coordss.y);
  3881. ctx.stroke();
  3882. let mouse = window_2_world(coords.x, coords.y);
  3883. draw_point(mouse.x, mouse.y);
  3884. */
  3885. if (ms_active) {
  3886. pick_fps_color();
  3887. pick_ms_color();
  3888. }
  3889. draw_minimap();
  3890. if (toggleButtons.Functional['Toggle Base Zones']) {
  3891. alert_about_drones();
  3892. }
  3893. if (script_list.minimap_leader_v2) {
  3894. if (toggleButtons.Visual['Toggle Leader Angle']) {
  3895. calc_leader();
  3896. apply_vector_on_minimap();
  3897. }
  3898. }
  3899. if (toggleButtons.Debug['Toggle Arrow pos']) {
  3900. window.arrowv2_debug = true;
  3901. } else {
  3902. window.arrowv2_debug = false;
  3903. }
  3904. if (script_list.set_transform_debug) {
  3905. ctx_arc(window.crx_container[2], window.crx_container[3], 50, 0, 2 * Math.PI, false, "yellow");
  3906. }
  3907. if (toggleButtons.Debug['Toggle Text']) {
  3908. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "canvas Lvl:" + player.level, canvas.width / 20 + 10, text_startingY + (textAdd * 0));
  3909. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "canvas tank: " + player.tank, canvas.width / 20 + 10, text_startingY + (textAdd * 1));
  3910. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "radius: " + ripsaw_radius, canvas.width / 20 + 10, text_startingY + (textAdd * 2));
  3911. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "scaling Factor: " + scalingFactor, canvas.width / 20 + 10, text_startingY + (textAdd * 3));
  3912. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "diep Units: " + diepUnits, canvas.width / 20 + 10, text_startingY + (textAdd * 4));
  3913. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "Fov: " + FOV, canvas.width / 20 + 10, text_startingY + (textAdd * 5));
  3914. 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));
  3915. //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);
  3916.  
  3917. //points at mouse
  3918. ctx_arc(coords.x * two, coords.y * two, 5, 0, 2 * Math.PI, false, "purple");
  3919. /*
  3920. circle_in_diepunits(coords.x*2/scalingFactor, coords.y*2/scalingFactor, 35, "pink");
  3921. circle_in_diepunits(coords.x*2/scalingFactor, coords.y*2/scalingFactor, 55, "yellow");
  3922. circle_in_diepunits(coords.x*2/scalingFactor, coords.y*2/scalingFactor, 75, "purple");
  3923. circle_in_diepunits(coords.x*2/scalingFactor, coords.y*2/scalingFactor, 200, "blue");
  3924. */
  3925.  
  3926. //coords at mouse
  3927. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "realX: " + coords.x * two + "realY: " + coords.y * two, coords.x * two, coords.y * two);
  3928. }
  3929.  
  3930. if (player.level != null && player.tank != null) {
  3931. if (toggleButtons.Debug['Toggle Middle Circle']) {
  3932. ctx.beginPath();
  3933. ctx.moveTo(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY);
  3934. ctx.lineTo(coords.x * two, coords.y * two);
  3935. ctx.stroke();
  3936. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius, 0, 2 * Math.PI, false, "darkblue");
  3937. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius * 0.9, 0, 2 * Math.PI, false, "lightblue");
  3938. }
  3939. if (toggleButtons.Debug['Toggle Upgrades']) {
  3940. draw_upgrade_grid();
  3941. }
  3942. //draw_server_border(4000, 2250);
  3943. draw_crx_events();
  3944. if (toggleButtons.Visual['Toggle Bullet Distance']) {
  3945. draw_cirle_radius_for_tank();
  3946. }
  3947. };
  3948. }
  3949. window.requestAnimationFrame(gui);
  3950. }
  3951. gui();
  3952. setTimeout(() => {
  3953. gui();
  3954. }, 5000);
  3955. }, 1000);
  3956.  
  3957. // Alert players about missing scripts (for addons)
  3958. let notified = {};
  3959.  
  3960. function require(category, toggleButton, script) {
  3961. if (state === "in game") {
  3962. const notificationKey = `${category}-${toggleButton}-${script}`;
  3963. if (toggleButtons[category]?.[toggleButton] && !script_list[script] && !notified[notificationKey]) {
  3964. new_notification(`${toggleButton} requires ${script} to be active!`, rgbToNumber(...notification_rbgs.require), 7500);
  3965. notified[notificationKey] = true;
  3966. }
  3967. }
  3968. }
  3969.  
  3970. function check_addon_scripts() {
  3971. require('Addons', 'FOV changer', 'fov');
  3972. }
  3973.  
  3974. //cooldowns (unfinished)
  3975. let c_cd = "red";
  3976. let c_r = "green";
  3977. const cooldowns = [
  3978. {
  3979. Tank: "Destroyer",
  3980. cooldown0: 109,
  3981. cooldown1: 94,
  3982. cooldown2: 81,
  3983. cooldown3: 86
  3984. },
  3985. ]
  3986.  
  3987. //detect which slot was clicked
  3988. document.addEventListener('mousedown', checkPos)
  3989.  
  3990. function checkPos(e) {
  3991. console.log(boxes[selected_box]);
  3992. }
  3993.  
  3994.  
  3995. //warns you about annis, destroyers
  3996. /*
  3997. function drawTheThing(x,y,r) {
  3998. if(script_boolean){
  3999. let a = ctx.fillStyle;
  4000. ctx.fillStyle = "#FF000044";
  4001. ctx.beginPath();
  4002. ctx.arc(x,y,4*r,0,2*Math.PI);
  4003. ctx.fill();
  4004. ctx.fillStyle = "#FF000066";
  4005. ctx.beginPath();
  4006. ctx.arc(x,y,2*r,0,2*Math.PI);
  4007. ctx.fill();
  4008. ctx.beginPath();
  4009. }
  4010. }
  4011. var angle,a,b,width;
  4012. CanvasRenderingContext2D.prototype.setTransform = new Proxy(CanvasRenderingContext2D.prototype.setTransform, {
  4013. apply(target, thisArgs, args) {
  4014. //console.log(thisArgs)
  4015. 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)) {
  4016. angle = Math.atan2(args[2],args[3]) || 0;
  4017. width = Math.hypot(args[3], args[2]);
  4018. a = args[4]-Math.cos(angle+Math.PI/2)*width/2;
  4019. b = args[5]+Math.sin(angle+Math.PI/2)*width/2;
  4020. drawTheThing(a,b, Math.hypot(args[3],args[2]));
  4021. }
  4022. return Reflect.apply(target, thisArgs, args);
  4023. }
  4024. });
  4025. */
  4026.  
  4027. //physics for movement (UNFINISHED)
  4028. /*
  4029. //movement speed ingame stat
  4030. let m_s = [0, 1, 2, 3, 4, 5, 6, 7];
  4031.  
  4032. function accelarate(A_o){
  4033. //Accelaration
  4034. let sum = 0;
  4035. runForTicks((ticksPassed, currentTick) => {
  4036. console.log("sum is being calculated...");
  4037. sum += A_o * Math.pow(0.9, ticksPassed - 1);
  4038. offsetX = Math.floor(sum * scalingFactor);
  4039. console.log(offsetX);
  4040. }, 50);
  4041. //decelerate(sum);
  4042. }
  4043.  
  4044. function decelerate(sum){
  4045. //deceleration
  4046. let res = 0;
  4047. runForTicks((ticksPassed, currentTick) => {
  4048. console.log("res is being calculated...");
  4049. res = sum * Math.pow(0.9, ticksPassed);
  4050. offsetX = Math.floor(res * scalingFactor);
  4051. console.log(offsetX);
  4052. }, 50);
  4053. }
  4054. function calculate_speed(movement_speed_stat){
  4055. console.log("calculate_speed function called");
  4056. //use Accelaration for first 50 ticks, then deceleration until ticks hit 100, then stop moving
  4057.  
  4058. //calculating base value, we'll need this later
  4059. let a = (1.07**movement_speed_stat);
  4060. let b = (1.015**(player.level - 1));
  4061. let A_o = 2.55*(a/b);
  4062. accelarate(A_o);
  4063. }
  4064. */
  4065.  
  4066. //handle Key presses
  4067. let key_storage = [];
  4068. let keyHeld = {};
  4069.  
  4070. window.addEventListener('keydown', function(e) {
  4071. if (!keyHeld[e.key]) {
  4072. keyHeld[e.key] = true;
  4073. key_storage.push(e.key);
  4074. analyse_keys();
  4075. }
  4076. console.log(key_storage);
  4077. });
  4078.  
  4079. window.addEventListener('keyup', function(e) {
  4080. if (key_storage.includes(e.key)) {
  4081. key_storage.splice(key_storage.indexOf(e.key), 1);
  4082. }
  4083. keyHeld[e.key] = false;
  4084. console.log(key_storage);
  4085. analyse_keys();
  4086. });
  4087.  
  4088. function analyse_keys() {
  4089. if (key_storage.includes("j")) { //J
  4090. change_visibility();
  4091. //auto spin && auto fire
  4092. } else if (key_storage.includes("l")) {
  4093. ms_active = !ms_active;
  4094. } else if (key_storage.includes("e")) { //E
  4095. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  4096. f_s("fire");
  4097. } else {
  4098. auto_fire = false;
  4099. }
  4100. console.log(auto_fire);
  4101. }else if (key_storage.includes("c")) {
  4102. console.log(auto_spin);
  4103. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  4104. f_s("spin");
  4105. } else {
  4106. auto_spin = false;
  4107. }
  4108. console.log(auto_spin);
  4109. //stats
  4110. } else if (toggleButtons.Functional['Stats']) {
  4111. if (key_storage.includes("u")) {
  4112. if (key_storage.includes("r")) {
  4113. reset_stats();
  4114. }
  4115. if (!document.body.contains(upgrade_box)) {
  4116. document.body.appendChild(upgrade_box);
  4117. }
  4118. update_stats();
  4119. if (stats_limit >= 0) {
  4120. for (let i = 1; i < 9; i++) {
  4121. if (key_storage.includes(`${i}`) && stats[i] < 7) {
  4122. stats[i] += 1;
  4123. stats_limit -= 1;
  4124. }
  4125. }
  4126. }
  4127. } else {
  4128. if (document.body.contains(upgrade_box)) {
  4129. document.body.removeChild(upgrade_box);
  4130. }
  4131. use_stats_ingame();
  4132. }
  4133. }
  4134. }
  4135.  
  4136. //stats handler
  4137. var stats_instructions_showed = false;
  4138.  
  4139. function show_stats_instructions() {
  4140. if (toggleButtons.Functional['Stats']) {
  4141. input.execute("ren_stats false");
  4142. if (!stats_instructions_showed) {
  4143. if (state === "in game") {
  4144. use_stats_ingame();
  4145. new_notification("Usage: hold 'u' button and then press a number between 1 and 9", rgbToNumber(...notification_rbgs.normal), 5000);
  4146. new_notification("Explanation: this module lets you choose a tank build that will stay even after you die", rgbToNumber(...notification_rbgs.normal), 5100);
  4147. new_notification("unless you press r while pressing u", rgbToNumber(...notification_rbgs.normal), 5200);
  4148. stats_instructions_showed = true;
  4149. }
  4150. } else {
  4151. if (state === "in menu") {
  4152. stats_instructions_showed = false;
  4153. }
  4154. }
  4155. } else {
  4156. input.execute("ren_stats true");
  4157. }
  4158. }
  4159.  
  4160. setInterval(show_stats_instructions, 500);
  4161. let stats = ["don't use this", 0, 0, 0, 0, 0, 0, 0, 0];
  4162. let stats_limit = 32;
  4163.  
  4164. function update_stats() {
  4165. let l = stats.length;
  4166. for (let i = 1; i < l; i++) {
  4167. let stat_steps = stats[i];
  4168. for (let j = 1; j < stat_steps + 1; j++) {
  4169. let stat_row = document.querySelector(`#row${[i]} > #s_box${j}`);
  4170. stat_row.style.backgroundColor = `${upgrade_name_colors[i]}`;
  4171. }
  4172. }
  4173. }
  4174.  
  4175. function reset_stats() {
  4176. let l = stats.length;
  4177. for (let i = 1; i < l; i++) {
  4178. let stat_steps = stats[i];
  4179. for (let j = 1; j < stat_steps + 1; j++) {
  4180. let stat_row = document.querySelector(`#row${[i]} > #s_box${j}`);
  4181. stat_row.style.backgroundColor = "black";
  4182. }
  4183. }
  4184. stats = ["don't use this", 0, 0, 0, 0, 0, 0, 0, 0];
  4185. stats_limit = 32;
  4186. }
  4187.  
  4188. function use_stats_ingame() {
  4189. let final_decision = "";
  4190. for (let i = 5; i < 9; i++) {
  4191. for (let j = 0; j < stats[i]; j++) {
  4192. final_decision += `${i}`;
  4193. }
  4194. }
  4195. for (let i = 1; i < 5; i++) {
  4196. for (let j = 0; j < stats[i]; j++) {
  4197. final_decision += `${i}`;
  4198. }
  4199. }
  4200. input.execute(`game_stats_build ${final_decision}`);
  4201. }
  4202.  
  4203. const upgrade_names = [
  4204. "don't use this",
  4205. "Health Regen",
  4206. "Max Health",
  4207. "Body Damage",
  4208. "Bullet Speed",
  4209. "Bullet Penetration",
  4210. "Bullet Damage",
  4211. "Reload",
  4212. "Movement Speed",
  4213. ];
  4214.  
  4215. const upgrade_name_colors = [
  4216. "don't use this",
  4217. "DarkSalmon",
  4218. "pink",
  4219. "DarkViolet",
  4220. "DodgerBlue",
  4221. "yellow",
  4222. "red",
  4223. "lime",
  4224. "lightblue",
  4225. ];
  4226.  
  4227. const upgrade_box = document.createElement("div");
  4228. upgrade_box.style.width = "400px";
  4229. upgrade_box.style.height = "300px";
  4230. upgrade_box.style.backgroundColor = "lightGray";
  4231. upgrade_box.style.position = "fixed";
  4232. upgrade_box.style.display = "block";
  4233. upgrade_box.style.bottom = "10px";
  4234. upgrade_box.style.zIndex = 100;
  4235.  
  4236. for (let i = 1; i < 9; i++) {
  4237. create_upgrades(`row${i}`, i);
  4238. }
  4239.  
  4240. function create_upgrades(name, rownum) {
  4241. let black_box = document.createElement("div");
  4242. black_box.id = name;
  4243. black_box.style.width = "350px";
  4244. black_box.style.height = "20px";
  4245. black_box.style.position = "relative";
  4246. black_box.style.display = "block";
  4247. black_box.style.marginTop = "15px";
  4248. black_box.style.left = "25px";
  4249. for (let i = 1; i < 8; i++) {
  4250. let small_box = document.createElement("div");
  4251. small_box.id = `s_box${i}`;
  4252. small_box.style.width = "20px";
  4253. small_box.style.height = "20px";
  4254. small_box.style.backgroundColor = "black";
  4255. small_box.style.display = "inline-block";
  4256. small_box.style.border = "2px solid white";
  4257.  
  4258. black_box.appendChild(small_box);
  4259. }
  4260. let upgrade_btn = document.createElement("button");
  4261. upgrade_btn.id = upgrade_names[rownum];
  4262. upgrade_btn.style.color = "black";
  4263. upgrade_btn.innerHTML = "+";
  4264. upgrade_btn.style.width = "20px";
  4265. upgrade_btn.style.height = "20px";
  4266. upgrade_btn.style.backgroundColor = upgrade_name_colors[rownum];
  4267. upgrade_btn.style.display = "inline-block";
  4268. upgrade_btn.style.border = "2px solid black";
  4269. upgrade_btn.style.cursor = "pointer";
  4270. black_box.appendChild(upgrade_btn);
  4271.  
  4272. let text_el = document.createElement("h3");
  4273. text_el.innerText = `[${rownum}] ${upgrade_names[rownum]}`;
  4274. text_el.style.fontSize = "15px";
  4275. text_el.style.display = "inline-block";
  4276. black_box.appendChild(text_el);
  4277. upgrade_box.appendChild(black_box);
  4278. }
  4279. // Handle key presses for moving the center (UNFINISHED)
  4280.  
  4281. /*
  4282. function return_to_center(XorY, posOrNeg){
  4283. console.log("function called with: " + XorY + posOrNeg);
  4284. if(XorY === "x"){
  4285. if(posOrNeg === "pos"){
  4286. while(offsetX < 0){
  4287. offsetX += 0.5*scalingFactor;
  4288. }
  4289. }else if(posOrNeg === "neg"){
  4290. while(offsetX > 0){
  4291. offsetX -= 0.5*scalingFactor;
  4292. }
  4293. }else{
  4294. console.log("invalid posOrNeg at return_to_center();")
  4295. }
  4296. }else if(XorY === "y"){
  4297. if(posOrNeg === "pos"){
  4298. while(offsetY < 0){
  4299. offsetY += 0.5*scalingFactor;
  4300. }
  4301. }else if(posOrNeg === "neg"){
  4302. while(offsetY > 0){
  4303. offsetY -= 0.5*scalingFactor;
  4304. }
  4305. }else{
  4306. console.log("invalid posOrNeg at return_to_center();")
  4307. }
  4308. }else{
  4309. console.log("invalid XorY at return_to_center();");
  4310. }
  4311. }
  4312.  
  4313. document.onkeydown = function(e) {
  4314. switch (e.keyCode) {
  4315. case 87: // 'W' key
  4316. console.log("W");
  4317. if(offsetY >= -87.5*scalingFactor){
  4318. offsetY -= 12.5*scalingFactor;
  4319. }
  4320. break
  4321. case 83: // 'S' key
  4322. console.log("S");
  4323. if(offsetY <= 87.5*scalingFactor){
  4324. offsetY += 12.5*scalingFactor;
  4325. }
  4326. break;
  4327. case 68: // 'D' key
  4328. console.log("D");
  4329. if(offsetX <= 87.5*scalingFactor){
  4330. offsetX += 12.5*scalingFactor;
  4331. }
  4332. break
  4333. case 65: // 'A' key
  4334. console.log("A");
  4335. if(offsetX >= -87.5*scalingFactor){
  4336. offsetX -= 12.5*scalingFactor;
  4337. }
  4338. break
  4339. }
  4340. }
  4341.  
  4342. document.onkeyup = function(e) {
  4343. switch (e.keyCode) {
  4344. case 87: // 'W' key
  4345. console.log("W unpressed");
  4346. return_to_center("y", "pos");
  4347. break
  4348. case 83: // 'S' key
  4349. console.log("S unpressed");
  4350. return_to_center("y", "neg");
  4351. break;
  4352. case 68: // 'D' key
  4353. console.log("D unpressed");
  4354. return_to_center("x", "neg");
  4355. break
  4356. case 65:
  4357. console.log("A unpressed");
  4358. return_to_center("x", "pos");
  4359. }
  4360. }
  4361. */