Diep.io+ (bullet distances now only shows for your bullet speed)

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

目前為 2024-11-14 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Diep.io+ (bullet distances now only shows for your bullet speed)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.1.0.0
  5. // @description autorespawn(auto ad watcher with 2min timer), leader arrow + minimap arrow, FOV & diepUnits & windowScaling() calculator, Factory controls overlay, bullet distance (FOR EVERY BULLET SPEED BUILD) of 75% tanks, copy party link, leave game, no privacy settings button, no apes.io advertisment, net_predict_movement false
  6. // @author r!PsAw
  7. // @match https://diep.io/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=diep.io
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. //!!!WARNING!!! Ui scale has to be at 0.9x for this script to work//
  14.  
  15. let pt = '';
  16. let player = {
  17. name: "",
  18. last_level: 0,
  19. level: 0,
  20. tank: "",
  21. raw_build: "",
  22. real_time_build: "",
  23. };
  24.  
  25. //create ingame Notifications
  26. function rgbToNumber(r, g, b) {
  27. return (r << 16) | (g << 8) | b;
  28. }
  29. const notification_rbgs = {
  30. require: [255,165,0], //orange
  31. warning: [255,0,0], //red
  32. normal: [0,0,128] //blue
  33. }
  34. function new_notification(text, color, duration){
  35. input.inGameNotification(text, color, duration);
  36. }
  37.  
  38. //auto ui scale = 0.9x
  39. var ui_scale = parseFloat(localStorage.getItem("d:ui_scale"));
  40.  
  41. function correct_ui_scale(){
  42. ui_scale = parseFloat(localStorage.getItem("d:ui_scale"));
  43. new_notification(`invalid UI scale detected! ${ui_scale}`, rgbToNumber(...notification_rbgs.warning), 10000);
  44. localStorage.setItem("d:ui_scale", 0.9);
  45. new_notification("Automatically changed to 0.9 for Diep.io+ :)", rgbToNumber(...notification_rbgs.normal), 10000);
  46. ui_scale = parseFloat(localStorage.getItem("d:ui_scale"));
  47. }
  48.  
  49. function update_scale_option(selector, label, min, max) {
  50. let element = document.querySelector(selector);
  51. let label_element = element.closest("div").querySelector("span");
  52. label_element.innerHTML = `[DIEP.IO+] ${label}`;
  53. label_element.style.background = "black";
  54. label_element.style.color = "purple";
  55. element.min = min;
  56. element.max = max;
  57. }
  58.  
  59. function new_ranges_for_scales() {
  60. update_scale_option("#subsetting-option-ui_scale", "UI Scale", '0.01', '1000');
  61. update_scale_option("#subsetting-option-border_radius", "UI Border Radius", '0.01', '1000');
  62. update_scale_option("#subsetting-option-border_intensity", "UI Border Intensity", '0.01', '1000');
  63. }
  64.  
  65. new_ranges_for_scales();
  66.  
  67.  
  68. function ui_scale_check() {
  69. if (homescreen.classList.contains("screen") && homescreen.classList.contains("active")) {
  70. if (ui_scale != 0.9) {
  71. //new_notification("please change your ui_scale to 0.9x in Menu -> Settings", rgbToNumber(...notification_rbgs.warning), 10000);
  72. correct_ui_scale();
  73. } else {
  74. console.log("no alert");
  75. }
  76. clearInterval(interval_for_ui_scale);
  77. }
  78. }
  79. let interval_for_ui_scale = setInterval(ui_scale_check, 100);
  80.  
  81. //string generator
  82. function newString(length) {
  83. let final_result = "";
  84. let chars =
  85. "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=/.,".split(
  86. ""
  87. );
  88. for (let i = 0; i < length; i++) {
  89. final_result += chars[Math.floor(Math.random() * chars.length)];
  90. }
  91. return final_result;
  92. }
  93.  
  94. //encryption
  95. function convert_numeric(number, from, to) {
  96. return parseInt(number, from).toString(to);
  97. }
  98.  
  99. let ls_cnfgs = new Map();
  100. let _names = ["banned", "nickname", "gui", "player_token", "console", "addons", "last_gm"];
  101. _names.forEach((name, index) => {
  102. ls_cnfgs.set(name, index + 3);
  103. });
  104.  
  105. let els_args = new Uint8Array([3, 10, 16]);
  106.  
  107. function els(type){
  108. return convert_numeric(Math.pow(ls_cnfgs.get(type), els_args[0]), els_args[1], els_args[2]);
  109. }
  110. //
  111. function aYsGH(){
  112. let ytS = "d:nas_logged_in";
  113. localStorage.getItem(ytS) === null? localStorage.setItem(ytS, true): localStorage.getItem(`[Diep.io+] ${els('nickname')}`) === null? HdSoyr_() : null;
  114. IjHGfoas();
  115. ASgddisfPAW();
  116. }
  117.  
  118. const originalRemoveItem = localStorage.removeItem;
  119.  
  120. localStorage.removeItem = function(key) {
  121. if (key.includes("[Diep.io+]")) {
  122. crash();
  123. }
  124. originalRemoveItem.call(this, key);
  125. };
  126.  
  127. function IjHGfoas(){
  128. let str = localStorage.getItem(`[Diep.io+] ${els('nickname')}`);
  129. const keywords = /Mi300|o2|NX|Ponyo|rbest|c8|Sprunk/i;
  130.  
  131. if (keywords.test(str)) {
  132. crash(str);
  133. }
  134. }
  135.  
  136. function ASgddisfPAW(){
  137. let SfsaAG = localStorage.getItem(`[Diep.io+] ${els('player_token')}`);
  138. SfsaAG === null? localStorage.setItem(`[Diep.io+] ${els('player_token')}`, newString(25)) : pt = SfsaAG;
  139. pt = localStorage.getItem(`[Diep.io+] ${els('player_token')}`);
  140. }
  141.  
  142. aYsGH();
  143. //
  144. let homescreen = document.getElementById("home-screen");
  145. let ingamescreen = document.getElementById("in-game-screen");
  146. let gameOverScreen = document.getElementById('game-over-screen');
  147. let gameOverScreenContainer = document.querySelector("#game-over-screen > div > div.game-details > div:nth-child(1)");
  148. function u_ln(){
  149. if(input.doesHaveTank()){
  150. player.name = window.localStorage["d:last_spawn_name"];
  151. localStorage.setItem(`[Diep.io+] ${els('nickname')}`, player.name);
  152. }
  153. }
  154. setInterval(u_ln, 500);
  155. let new_FOVs = [
  156. {
  157. name: "Tank",
  158. fieldFactor: 1,
  159. FOV: null
  160. },
  161. {
  162. name: "Sniper",
  163. fieldFactor: 0.899,
  164. FOV: null
  165. },
  166. {
  167. name: "Predator",
  168. fieldFactor: 0.85,
  169. FOV: null
  170. },
  171. {
  172. name: "Assassin",
  173. fieldFactor: 0.8,
  174. FOV: null
  175. },
  176. {
  177. name: "Ranger",
  178. fieldFactor: 0.699,
  179. FOV: null
  180. },
  181. {
  182. name: "Background",
  183. FOV: 0.3499999940395355
  184. }
  185. ]
  186.  
  187. //GUI
  188. const container = document.createElement('div');
  189. container.style.position = 'fixed';
  190. container.style.top = '10px';
  191. container.style.left = '75px';
  192. container.style.padding = '15px';
  193. container.style.backgroundImage = 'linear-gradient(#ffffff, #79c7ff)';
  194. container.style.color = 'white';
  195. container.style.borderRadius = '10px';
  196. container.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
  197. container.style.minWidth = '200px';
  198. container.style.zIndex = '10';
  199.  
  200. container.addEventListener('mouseover', () => {
  201. input.execute('ren_upgrades false');
  202. });
  203.  
  204. container.addEventListener('mouseout', () => {
  205. input.execute('ren_upgrades true');
  206. });
  207.  
  208. const title = document.createElement('h1');
  209. title.textContent = 'Diep.io+ (hide with J)';
  210. title.style.margin = '0 0 5px 0';
  211. title.style.fontSize = '24px';
  212. title.style.textAlign = 'center';
  213. title.style.color = '#fb2a7b';
  214. title.style.zIndex = '11';
  215. container.appendChild(title);
  216.  
  217. const subtitle = document.createElement('h3');
  218. subtitle.textContent = 'made by r!PsAw';
  219. subtitle.style.margin = '0 0 15px 0';
  220. subtitle.style.fontSize = '14px';
  221. subtitle.style.textAlign = 'center';
  222. subtitle.style.color = '#6fa8dc';
  223. subtitle.style.zIndex = '11';
  224. container.appendChild(subtitle);
  225.  
  226. const categories = ['Debug', 'Visual', 'Functional', 'Addons'];
  227. const categoryButtons = {};
  228. const categoryContainer = document.createElement('div');
  229. categoryContainer.style.display = 'flex';
  230. categoryContainer.style.justifyContent = 'space-between';
  231. categoryContainer.style.marginBottom = '15px';
  232. categoryContainer.style.zIndex = '12';
  233.  
  234. categories.forEach(category => {
  235. const button = document.createElement('button');
  236. button.textContent = category;
  237. button.style.flex = '1';
  238. button.style.padding = '8px';
  239. button.style.margin = '0 5px';
  240. button.style.cursor = 'pointer';
  241. button.style.border = 'none';
  242. button.style.borderRadius = '5px';
  243. button.style.backgroundColor = '#fb2a7b';
  244. button.style.color = 'white';
  245. button.style.transition = 'background-color 0.3s';
  246. button.style.zIndex = '13';
  247.  
  248. button.addEventListener('mouseover', () => {
  249. button.style.backgroundColor = '#0000ff';
  250. });
  251. button.addEventListener('mouseout', () => {
  252. button.style.backgroundColor = '#fb2a7b';
  253. });
  254.  
  255. categoryContainer.appendChild(button);
  256. categoryButtons[category] = button;
  257. });
  258.  
  259. container.appendChild(categoryContainer);
  260.  
  261. const contentArea = document.createElement('div');
  262. contentArea.style.marginTop = '15px';
  263. contentArea.style.zIndex = '12';
  264. container.appendChild(contentArea);
  265.  
  266. let FOVindex = 0;
  267. let toggleButtons = {
  268. Debug: {
  269. 'Toggle Text': false,
  270. 'Toggle Middle Circle': false,
  271. 'Toggle Upgrades': false,
  272. 'Toggle Arrow pos': false
  273. },
  274. Visual: {
  275. 'Toggle Aim Lines': false,
  276. 'Toggle Bullet Distance': false,
  277. 'Toggle Minimap': true,
  278. 'Highlight Leader Score': false
  279. },
  280. Functional: {
  281. 'Auto Respawn': false,
  282. 'Auto Bonus Level': false,
  283. 'Toggle Leave Button': false,
  284. 'Toggle Level Seeker': false,
  285. 'Stats': false
  286. },
  287. Addons: {
  288. 'Change Leader Arrow Color': '#000000',
  289. 'Toggle Leader Angle': false,
  290. 'Toggle Base Zones': false,
  291. 'Alts On Minimap (soon!)': false,
  292. 'FOV changer': false,
  293. 'selected': FOVindex
  294. }
  295. };
  296.  
  297. function saveSettings() {
  298. localStorage.setItem(`[Diep.io+] ${els('gui')}`, JSON.stringify({
  299. toggleButtons: toggleButtons,
  300. FOVindex: FOVindex
  301. }));
  302. }
  303.  
  304. function loadSettings() {
  305. try {
  306. const savedData = localStorage.getItem(`[Diep.io+] ${els('gui')}`);
  307. if (savedData) {
  308. const parsed = JSON.parse(savedData);
  309. if (parsed.toggleButtons) {
  310. // Merge saved settings with default settings to handle new options
  311. categories.forEach(category => {
  312. toggleButtons[category] = {
  313. ...toggleButtons[category], // Keep default values
  314. ...parsed.toggleButtons[category] // Override with saved values
  315. };
  316. });
  317. }
  318. if (typeof parsed.FOVindex === 'number') {
  319. FOVindex = parsed.FOVindex;
  320. }
  321. }
  322. } catch (error) {
  323. console.error('Error loading settings:', error);
  324. }
  325. }
  326.  
  327. function createToggleButton(text, initialState) {
  328. const button = document.createElement('button');
  329. if (text.startsWith('selected')) {
  330. button.textContent = `selected ${new_FOVs[FOVindex].name}`;
  331. } else {
  332. button.textContent = text;
  333. }
  334. button.style.display = 'block';
  335. button.style.width = '100%';
  336. button.style.marginBottom = '10px';
  337. button.style.padding = '8px';
  338. button.style.cursor = 'pointer';
  339. button.style.border = 'none';
  340. button.style.borderRadius = '5px';
  341. button.style.transition = 'background-color 0.3s';
  342. button.style.zIndex = '13';
  343. if (text.startsWith('selected')) {
  344. button.style.backgroundColor = '#7a143b';
  345. button.style.color = 'white';
  346. button.addEventListener('click', () => {
  347. let l = new_FOVs.length;
  348. if (FOVindex < l - 1) {
  349. FOVindex += 1;
  350. } else {
  351. FOVindex = 0;
  352. }
  353. button.textContent = `selected ${new_FOVs[FOVindex].name}`;
  354. saveSettings();
  355. });
  356. } else if (text === 'Change Leader Arrow Color') {
  357. updateButtonColor(button, initialState);
  358. button.addEventListener('click', () => {
  359. const colorPicker = document.createElement('input');
  360. colorPicker.type = 'color';
  361. colorPicker.value = toggleButtons[currentCategory][text];
  362. colorPicker.style.display = 'none';
  363. document.body.appendChild(colorPicker);
  364.  
  365. colorPicker.addEventListener('change', (event) => {
  366. const newColor = event.target.value;
  367. toggleButtons[currentCategory][text] = newColor;
  368. updateButtonColor(button, newColor);
  369. document.body.removeChild(colorPicker);
  370. saveSettings();
  371. });
  372.  
  373. colorPicker.click();
  374. });
  375. } else {
  376. updateButtonColor(button, initialState);
  377. button.addEventListener('click', () => {
  378. toggleButtons[currentCategory][text] = !toggleButtons[currentCategory][text];
  379. updateButtonColor(button, toggleButtons[currentCategory][text]);
  380. saveSettings();
  381. });
  382. }
  383.  
  384. return button;
  385. }
  386.  
  387. loadSettings();
  388.  
  389. function updateButtonColor(button, state) {
  390. if (typeof state === 'string') {
  391. // For color picker button
  392. button.style.backgroundColor = state;
  393. window.choose_color = state;
  394. button.style.color = 'white';
  395. } else {
  396. // For toggle buttons
  397. if (state) {
  398. button.style.backgroundColor = '#63a5d4';
  399. button.style.color = 'white';
  400. } else {
  401. button.style.backgroundColor = '#a11a4e';
  402. button.style.color = 'white';
  403. }
  404. }
  405. }
  406.  
  407. let currentCategory = '';
  408. let modes = ["in-game", "awaiting-spawn", "game-over"];
  409. let selected_index = 0;
  410. let button2_state = false;
  411. let intervalId = null;
  412.  
  413. function showCategory(category) {
  414. contentArea.innerHTML = '';
  415. currentCategory = category;
  416.  
  417. Object.keys(categoryButtons).forEach(cat => {
  418. if (cat === category) {
  419. categoryButtons[cat].style.backgroundColor = '#0000ff';
  420. } else {
  421. categoryButtons[cat].style.backgroundColor = '#fb2a7b';
  422. }
  423. });
  424.  
  425. if (category === 'Functional') {
  426. const copyLinkButton = document.createElement('button');
  427. copyLinkButton.textContent = 'Copy Party Link';
  428. copyLinkButton.style.display = 'block';
  429. copyLinkButton.style.width = '100%';
  430. copyLinkButton.style.marginBottom = '10px';
  431. copyLinkButton.style.padding = '8px';
  432. copyLinkButton.style.cursor = 'pointer';
  433. copyLinkButton.style.border = 'none';
  434. copyLinkButton.style.borderRadius = '5px';
  435. copyLinkButton.style.backgroundColor = '#2196F3';
  436. copyLinkButton.style.color = 'white';
  437. copyLinkButton.style.transition = 'background-color 0.3s';
  438. copyLinkButton.style.zIndex = '13';
  439.  
  440. copyLinkButton.addEventListener('mouseover', () => {
  441. copyLinkButton.style.backgroundColor = '#1E88E5';
  442. });
  443. copyLinkButton.addEventListener('mouseout', () => {
  444. copyLinkButton.style.backgroundColor = '#2196F3';
  445. });
  446.  
  447. copyLinkButton.addEventListener('click', () => {
  448. document.getElementById("copy-party-link").click();
  449. });
  450.  
  451. const copyInfoButton = document.createElement('button');
  452. copyInfoButton.textContent = 'Copy Info';
  453. copyInfoButton.style.display = 'block';
  454. copyInfoButton.style.width = '100%';
  455. copyInfoButton.style.marginBottom = '10px';
  456. copyInfoButton.style.padding = '8px';
  457. copyInfoButton.style.cursor = 'pointer';
  458. copyInfoButton.style.border = 'none';
  459. copyInfoButton.style.borderRadius = '5px';
  460. copyInfoButton.style.backgroundColor = '#2196F3';
  461. copyInfoButton.style.color = 'white';
  462. copyInfoButton.style.transition = 'background-color 0.3s';
  463. copyInfoButton.style.zIndex = '13';
  464.  
  465. copyInfoButton.addEventListener('mouseover', () => {
  466. copyInfoButton.style.backgroundColor = '#1E88E5';
  467. });
  468. copyInfoButton.addEventListener('mouseout', () => {
  469. copyInfoButton.style.backgroundColor = '#2196F3';
  470. });
  471.  
  472. copyInfoButton.addEventListener('click', () => {
  473. get_info();
  474. });
  475.  
  476. contentArea.appendChild(copyLinkButton);
  477. contentArea.appendChild(copyInfoButton);
  478.  
  479. const newButtonsContainer = document.createElement('div');
  480. newButtonsContainer.style.display = 'flex';
  481. newButtonsContainer.style.justifyContent = 'space-between';
  482. newButtonsContainer.style.marginBottom = '10px';
  483.  
  484. const button1 = document.createElement('button');
  485. button1.textContent = modes[selected_index];
  486. button1.style.flex = '1';
  487. button1.style.marginRight = '5px';
  488. button1.style.padding = '8px';
  489. button1.style.cursor = 'pointer';
  490. button1.style.border = 'none';
  491. button1.style.borderRadius = '5px';
  492. button1.style.backgroundColor = '#2196F3';
  493. button1.style.color = 'white';
  494. button1.style.transition = 'background-color 0.3s';
  495.  
  496. button1.addEventListener('mouseover', () => {
  497. button1.style.backgroundColor = '#1E88E5';
  498. });
  499. button1.addEventListener('mouseout', () => {
  500. button1.style.backgroundColor = '#2196F3';
  501. });
  502. button1.addEventListener('click', () => {
  503. selected_index = (selected_index + 1) % modes.length;
  504. button1.textContent = modes[selected_index];
  505. });
  506.  
  507. // Button 2: Toggle loop
  508. const button2 = document.createElement('button');
  509. button2.textContent = 'Start Loop';
  510. button2.style.flex = '1';
  511. button2.style.marginLeft = '5px';
  512. button2.style.padding = '8px';
  513. button2.style.cursor = 'pointer';
  514. button2.style.border = 'none';
  515. button2.style.borderRadius = '5px';
  516. button2.style.backgroundColor = '#f44336';
  517. button2.style.color = 'white';
  518. button2.style.transition = 'background-color 0.3s';
  519.  
  520. button2.addEventListener('click', () => {
  521. button2_state = !button2_state;
  522. if (button2_state) {
  523. button2.textContent = 'Stop Loop';
  524. button2.style.backgroundColor = '#4CAF50';
  525. intervalId = setInterval(() => {
  526. window.__common__.screen_state = modes[selected_index];
  527. }, 100); // Adjust the interval as needed
  528. } else {
  529. button2.textContent = 'Start Loop';
  530. button2.style.backgroundColor = '#f44336';
  531. if (intervalId !== null) {
  532. clearInterval(intervalId);
  533. intervalId = null;
  534. }
  535. }
  536. });
  537.  
  538. newButtonsContainer.appendChild(button1);
  539. newButtonsContainer.appendChild(button2);
  540. contentArea.appendChild(newButtonsContainer);
  541. }
  542.  
  543. Object.keys(toggleButtons[category]).forEach(text => {
  544. const button = createToggleButton(text, toggleButtons[category][text]);
  545. contentArea.appendChild(button);
  546. });
  547. }
  548.  
  549. Object.keys(categoryButtons).forEach(category => {
  550. categoryButtons[category].addEventListener('click', () => showCategory(category));
  551. });
  552.  
  553. document.body.appendChild(container);
  554.  
  555. //you can't use my script >:(
  556. function waitForInput(callback, checkInterval = 100, timeout = 10000) {
  557. const startTime = Date.now();
  558.  
  559. function checkInput() {
  560. if (typeof input !== 'undefined' && input && input.try_spawn) {
  561. callback();
  562. } else if (Date.now() - startTime < timeout) {
  563. setTimeout(checkInput, checkInterval);
  564. }
  565. }
  566.  
  567. checkInput();
  568. }
  569.  
  570. function crash(name) {
  571. let nn = typeof name === "undefined" ? window.localStorage.getItem("d:last_spawn_name") : name;
  572. alert(`${nn} is blacklisted from using Diep.io+, crashing...`);
  573. localStorage.setItem(`[Diep.io+] ${els('banned')}`, true);
  574. localStorage.setItem(`[Diep.io+] ${els('nickname')}`, nn);
  575. while (true) {
  576. }
  577. }
  578.  
  579. function HdSoyr_(){
  580. crash();
  581. }
  582.  
  583.  
  584. waitForInput(function () {
  585. localStorage.getItem(`[Diep.io+] ${els('banned')}`) === 'true'? crash():null;;
  586. const originalTrySpawn = input.try_spawn;
  587.  
  588. input.try_spawn = function (str) {
  589. const keywords = /Mi300|o2|NX|Ponyo|rbest|c8|Sprunk/i;
  590.  
  591. if (keywords.test(str)) {
  592. crash(str);
  593. }
  594.  
  595. return originalTrySpawn.call(this, str);
  596. }
  597. });
  598.  
  599. //visibility of gui
  600. let visibility_gui = true;
  601.  
  602. function change_visibility() {
  603. visibility_gui = !visibility_gui;
  604. if (visibility_gui) {
  605. container.style.display = 'block';
  606. } else {
  607. container.style.display = 'none';
  608. }
  609. }
  610.  
  611. //check scripts
  612. let script_list = {
  613. minimap_leader_v1: null,
  614. minimap_leader_v2: null,
  615. fov: null,
  616. set_transform_debug: null,
  617. moveToLineTo_debug: null,
  618. gamemode_detect: null,
  619. multibox: null,
  620. death_screen_faker: null
  621. };
  622.  
  623. function check_ripsaw_scripts() {
  624. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  625. script_list.minimap_leader_v1 = !!window.m_arrow;
  626. script_list.minimap_leader_v2 = !!window.M_X;
  627. script_list.fov = !!window.HEAPF32;
  628. script_list.set_transform_debug = !!window.crx_container;
  629. script_list.moveToLineTo_debug = !!window.y_and_x;
  630. script_list.gamemode_detect = !!window.gm;
  631. script_list.multibox = !!window.mbox;
  632. script_list.death_screen_faker = !!window.faker;
  633. }
  634. localStorage.setItem(`[Diep.io+] ${els('addons')}`, JSON.stringify(script_list));
  635. }
  636. setInterval(check_ripsaw_scripts, 500);
  637.  
  638. //detect gamemode
  639. let gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  640. let last_gamemode = localStorage.getItem(`[Diep.io+] ${els("last_gm")}`);
  641. localStorage.setItem(`[Diep.io+] ${els("last_gm")}`, gamemode);
  642.  
  643. function check_gamemode() {
  644. if (script_list.gamemode_detect) {
  645. gamemode = window.gm;
  646. } else {
  647. gamemode = document.querySelector("#gamemode-selector > div > div.selected > div.dropdown-label").innerHTML;
  648. save_gm();
  649. }
  650. }
  651.  
  652. setInterval(check_gamemode, 250);
  653.  
  654. function save_gm(){
  655. let saved_gm = localStorage.getItem(`[Diep.io+] ${els("last_gm")}`);
  656. if(saved_gm != null && saved_gm != gamemode){
  657. last_gamemode = saved_gm;
  658. }
  659. saved_gm === null? localStorage.setItem(`[Diep.io+] ${els("last_gm")}`, gamemode):null;
  660. }
  661.  
  662. //check region
  663. let region;
  664.  
  665. function check_region() {
  666. region = document.querySelector("#region-selector > div > div.selected > div.dropdown-label").innerHTML;
  667. }
  668.  
  669. setInterval(check_region, 100);
  670.  
  671. //detect if dead or alive
  672. let state = "idk yet";
  673.  
  674. function check_state() {
  675. switch (input.doesHaveTank()) {
  676. case 0:
  677. state = "in menu";
  678. break
  679. case 1:
  680. state = "in game";
  681. break
  682. }
  683. }
  684.  
  685. setInterval(check_state, 100);
  686. //
  687. const build_stat_levels = [
  688. 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
  689. ];
  690.  
  691. function real_build(string) {
  692. let processed = build_stat_levels.indexOf(player.level);
  693. let temp_array = [...string];
  694. temp_array = temp_array.slice(0, processed);
  695. let final_string = temp_array.join("");
  696. return final_string;
  697. }
  698.  
  699. //diep console data capture
  700. const originalConsoleLog = console.log;
  701. const capturedLogs = [];
  702. const diep_data = [];
  703.  
  704. function read_diep_data(){
  705. // Override console.log to prevent logging to the console
  706. console.log = function(...args) {
  707. capturedLogs.push(args.join(' '));
  708. };
  709.  
  710. // Call the function that logs output
  711. input.print_convar_help();
  712.  
  713. // Restore the original console.log function
  714. console.log = originalConsoleLog;
  715. if(diep_data.length === 0){
  716. save_diep_data();
  717. }else{
  718. update_diep_data();
  719. }
  720. capturedLogs.length = 0;
  721. console.log(diep_data);
  722. }
  723.  
  724. setInterval(read_diep_data, 1000);
  725.  
  726. function save_diep_data(){
  727. let l = capturedLogs.length;
  728. for(let i = 0; i<l; i++){
  729. let sett_nam = capturedLogs[i].split(' = ')[0];
  730. let sett_val = capturedLogs[i].split(' ')[2];
  731. diep_data.push([sett_nam, sett_val]);
  732. }
  733. player.raw_build = diep_data[0][1];
  734. player.real_time_build = real_build(player.raw_build);
  735. }
  736.  
  737. function update_diep_data() {
  738. let l = capturedLogs.length;
  739. for (let i = 0; i < l; i++) {
  740. if (!Array.isArray(diep_data[i])) {
  741. diep_data[i] = [];
  742. }
  743.  
  744. const splitLog = capturedLogs[i].split(' ');
  745.  
  746. if (splitLog.length > 2) {
  747. diep_data[i][1] = splitLog[2];
  748. } else {
  749. console.error(`Captured log at index ${i} is not in the expected format:`, capturedLogs[i]);
  750. }
  751. }
  752. localStorage.setItem(`[Diep.io+] ${els('console')}`, JSON.stringify(diep_data));
  753. }
  754.  
  755.  
  756. //personal best
  757. let your_final_score = 0;
  758. const personal_best = document.createElement('div');
  759. const gameDetail = document.createElement('div');
  760. const label = document.createElement('div');
  761. //applying class
  762. gameDetail.classList.add("game-detail");
  763. label.classList.add("label");
  764. personal_best.classList.add("value");
  765. //text context
  766. label.textContent = "Best:";
  767. //adding to html
  768. gameOverScreenContainer.appendChild(gameDetail);
  769. gameDetail.appendChild(label);
  770. gameDetail.appendChild(personal_best);
  771.  
  772. function load_ls() {
  773. return localStorage.getItem(gamemode);
  774. }
  775.  
  776. function save_ls() {
  777. localStorage.setItem(gamemode, your_final_score);
  778. }
  779.  
  780. function check_final_score() {
  781. if (window.__common__.screen_state === "game-over" && !script_list.death_screen_faker) {
  782. your_final_score = window.__common__.death_score;
  783. let saved_score = parseFloat(load_ls());
  784. personal_best.textContent = saved_score;
  785. if (saved_score < your_final_score) {
  786. personal_best.textContent = your_final_score;
  787. save_ls();
  788. }
  789. }
  790. }
  791.  
  792. setInterval(check_final_score, 100);
  793.  
  794. //config
  795. var two = canvas.width / window.innerWidth;
  796. var script_boolean = true;
  797.  
  798. // Mouse coordinates
  799. var uwuX = '0';
  800. var uwuY = '0';
  801. document.addEventListener('mousemove', function(e) {
  802. uwuX = e.clientX;
  803. uwuY = e.clientY;
  804. });
  805.  
  806. //net_predict_movement false
  807. (function() {
  808. function applySettings() {
  809. input.execute("net_predict_movement false");
  810. }
  811.  
  812. function waitForGame() {
  813. if (window.input && input.execute) {
  814. applySettings();
  815. } else {
  816. setTimeout(waitForGame, 100);
  817. }
  818. }
  819. waitForGame();
  820. })();
  821.  
  822. //annoying html elements
  823. let ads_removed = false;
  824.  
  825. function instant_remove() {
  826. let privacy_btn = document.getElementById("cmpPersistentLink");
  827. let apes_btn = document.getElementById("apes-io-promo");
  828. let discord_ad = document.querySelector("#apes-io-promo > img");
  829. let annoying = document.querySelector("#last-updated");
  830. if (privacy_btn) {
  831. privacy_btn.remove();
  832. }
  833.  
  834. if (annoying) {
  835. annoying.remove();
  836. }
  837.  
  838. if (apes_btn) {
  839. apes_btn.remove();
  840. }
  841.  
  842. if (discord_ad) {
  843. discord_ad.remove();
  844. }
  845.  
  846. if (!privacy_btn && !apes_btn && !discord_ad && !annoying) {
  847. console.log("removed buttons, quitting...");
  848. clearInterval(interval);
  849. }
  850. };
  851.  
  852. let interval = setInterval(instant_remove, 100);
  853.  
  854. //timer for bonus reward
  855. const ad_btn = document.getElementById("game-over-video-ad");
  856. var ad_btn_free = true;
  857.  
  858. const timerDisplay = document.createElement('h1');
  859. timerDisplay.textContent = "Time left to collect next bonus levels: 02:00";
  860. gameOverScreen.appendChild(timerDisplay);
  861.  
  862. let timer;
  863. let totalTime = 120; // 2 minutes in seconds
  864.  
  865. function startTimer() {
  866. clearInterval(timer);
  867. timer = setInterval(function() {
  868. if (totalTime <= 0) {
  869. clearInterval(timer);
  870. timerDisplay.textContent = "00:00";
  871. } else {
  872. totalTime--;
  873. let minutes = Math.floor(totalTime / 60);
  874. let seconds = totalTime % 60;
  875. timerDisplay.textContent =
  876. `Time left to collect next bonus levels: ${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
  877. }
  878. }, 1000);
  879. }
  880.  
  881. function resetTimer() {
  882. if (totalTime === 0) {
  883. clearInterval(timer);
  884. totalTime = 120; // Reset to 2 minutes
  885. timerDisplay.textContent = "02:00";
  886. }
  887. }
  888.  
  889. ad_btn.addEventListener('click', check_ad_state);
  890.  
  891. function check_ad_state() {
  892. if (totalTime === 0) {
  893. resetTimer();
  894. } else if (totalTime === 120) {
  895. ad_btn_free = true;
  896. startTimer();
  897. } else {
  898. ad_btn_free = false;
  899. }
  900. }
  901.  
  902. //autorespawn
  903.  
  904. let autorespawn = false;
  905.  
  906. function respawn() {
  907. if (toggleButtons.Functional['Auto Respawn']) {
  908. if (state === "in game") {
  909. return;
  910. } else {
  911. if ((totalTime === 120 || totalTime === 0) && toggleButtons.Functional['Auto Bonus Level']) {
  912. ad_btn.click();
  913. } else {
  914. let spawnbtn = document.getElementById("spawn-button");
  915. spawnbtn.click();
  916. }
  917. }
  918. }
  919. }
  920.  
  921. setInterval(respawn, 1000);
  922.  
  923. //toggle leave game
  924. let ingame_quit_btn = document.getElementById("quick-exit-game");
  925.  
  926. function check_class() {
  927. if (toggleButtons.Functional['Toggle Leave Button']) {
  928. ingame_quit_btn.classList.remove("hidden");
  929. ingame_quit_btn.classList.add("shown");
  930. } else {
  931. ingame_quit_btn.classList.remove("shown");
  932. ingame_quit_btn.classList.add("hidden");
  933. }
  934. }
  935.  
  936. setInterval(check_class, 300);
  937.  
  938. //score logic
  939. let your_nameFont;
  940. let scoreBoardFont;
  941. let highest_score;
  942. let highest_score_addon;
  943. let highest_score_string;
  944. let is_highest_score_alive;
  945. let scores = {
  946. millions: 0,
  947. thousands: 0,
  948. lessThan1k: 0
  949. };
  950.  
  951. function get_highest_score() {
  952. if (scores.millions > 0) {
  953. highest_score = scores.millions;
  954. highest_score_addon = "m";
  955. } else if (scores.thousands > 0) {
  956. highest_score = scores.thousands;
  957. highest_score_addon = "k";
  958. } else if (scores.lessThan1k > 0) {
  959. highest_score = scores.lessThan1k;
  960. }
  961. }
  962. //getting text information (credits to abc)
  963. let fps;
  964. let ms;
  965. let ms_active = false;
  966. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  967. apply(fillRect, ctx, [text, x, y, ...blah]) {
  968. if (text.endsWith('FPS')) {
  969. fps = text.split(' ')[0];
  970. }
  971. if(text.includes(' ms ')){
  972. ms = text.split(' ')[0];
  973. ms_active = true;
  974. }
  975. fillRect.call(ctx, text, x, y, ...blah);
  976. }
  977. });
  978.  
  979. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  980. apply(fillRect, ctx, [text, x, y, ...blah]) {
  981. const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string)
  982. if (text.startsWith('Lvl ')) {
  983. player.level = parseFloat(text.split(' ')[1]);
  984. if (text.split(' ')[3] != undefined) {
  985. player.tank = text.split(' ')[2] + text.split(' ')[3];
  986. } else {
  987. player.tank = text.split(' ')[2]
  988. }
  989. } else if (text === player.name) {
  990. your_nameFont = ctx.font;
  991. } else if (text === " - ") {
  992. scoreBoardFont = ctx.font
  993. } else if (isNumeric(text) && ctx.font === scoreBoardFont) {
  994. scores.lessThan1k = parseFloat(text);
  995. } else if (text.includes('.') && text.includes('k') && ctx.font === scoreBoardFont) {
  996. if (parseFloat(text.split('k')[0]) > scores.thousands) {
  997. scores.thousands = parseFloat(text.split('k')[0]);
  998. }
  999. } else if (text.includes('.') && text.includes('m') && ctx.font === scoreBoardFont) {
  1000. if (parseFloat(text.split('m')[0]) > scores.millions) {
  1001. scores.millions = parseFloat(text.split('m')[0]);
  1002. }
  1003. }
  1004.  
  1005. get_highest_score();
  1006. if (highest_score != null) {
  1007. if (highest_score_addon != null) {
  1008. highest_score_string = `${highest_score}${highest_score_addon}`;
  1009. } else {
  1010. highest_score_string = `${highest_score}`;
  1011. }
  1012. if (text === highest_score_string && toggleButtons.Visual['Highlight Leader Score']) {
  1013. ctx.fillStyle = "orange";
  1014. }
  1015. }
  1016. fillRect.call(ctx, text, x, y, ...blah);
  1017. }
  1018. });
  1019.  
  1020. //getting Info
  1021. let position_on_minimap;
  1022.  
  1023. function get_info() {
  1024. if (!toggleButtons.Visual['Toggle Minimap']) {
  1025. new_notification("Enabled Minimap for it to work properly. To turn it off, go to Visual -> Minimap", rgbToNumber(...notification_rbgs.normal), 5000);
  1026. new_notification("please click again", rgbToNumber(...notification_rbgs.normal), 5000);
  1027. toggleButtons.Visual['Toggle Minimap'] = true;
  1028. }
  1029. let link = "https://diep.io/?p=" + window.__common__.party_link;
  1030. let team = document.querySelector("#copy-party-link").classList[1];
  1031. console.log(`link: ${link}
  1032. team: ${team}
  1033. position_on_minimap: ${position_on_minimap}
  1034. gamemode: ${gamemode}
  1035. Leader: ${highest_score}${highest_score_addon}`);
  1036. switch (team){
  1037. case "red":
  1038. team = '🔴';
  1039. break
  1040. case "blue":
  1041. team = '🔵';
  1042. break
  1043. case "green":
  1044. team = '🟢';
  1045. break
  1046. case "purple":
  1047. team = '🟣';
  1048. break
  1049. }
  1050. if (region != null && gamemode != null && highest_score != null) {
  1051. navigator.clipboard.writeText(`🌐Region: ${region}
  1052. 🎮Mode: ${gamemode}
  1053. 👑Leader: ${highest_score}${highest_score_addon}
  1054. ${team}Link: ${link}`);
  1055. }
  1056. }
  1057. //display level
  1058. const pointsNeeded = new Uint16Array([
  1059. 0, 4, 13, 28, 50, 78, 113, 157, 211, 275,
  1060. 350, 437, 538, 655, 787, 938, 1109, 1301,
  1061. 1516, 1757, 2026, 2325, 2658, 3026, 3433,
  1062. 3883, 4379, 4925, 5525, 6184, 6907, 7698,
  1063. 8537, 9426, 10368, 11367, 12426, 13549,
  1064. 14739, 16000, 17337, 18754, 20256, 21849,
  1065. 23536
  1066. ]);
  1067.  
  1068. const crx = CanvasRenderingContext2D.prototype;
  1069. crx.fillText = new Proxy(crx.fillText, {
  1070. apply: function(f, _this, args) {
  1071. if (scoreBoardFont != null && toggleButtons.Functional['Toggle Level Seeker']) {
  1072. const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string);
  1073. if (_this.font != scoreBoardFont) {
  1074. if (isNumeric(args[0])) {
  1075. for (let i = 0; i < 16; i++) {
  1076. if (parseFloat(args[0]) < pointsNeeded[i]) {
  1077. args[0] = `L: ${i}`;
  1078. }
  1079. }
  1080. } else if (args[0].includes('.')) {
  1081. if (args[0].includes('k')) {
  1082. for (let i = 16; i < 45; i++) {
  1083. if (parseFloat(args[0].split('k')[0]) * 1000 < pointsNeeded[i]) {
  1084. args[0] = `L: ${i}`;
  1085. }
  1086. }
  1087. if (parseFloat(args[0].split('k')[0]) * 1000 > pointsNeeded[44]){
  1088. args[0] = `L: 45`;
  1089. }
  1090. } else if (args[0].includes('m')) {
  1091. args[0] = `L: 45`;
  1092. }
  1093. }
  1094. }
  1095. }
  1096. f.apply(_this, args);
  1097. }
  1098. });
  1099. crx.strokeText = new Proxy(crx.strokeText, {
  1100. apply: function(f, _this, args) {
  1101. if (scoreBoardFont != null && toggleButtons.Functional['Toggle Level Seeker']) {
  1102. const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string);
  1103. if (_this.font != scoreBoardFont) {
  1104. if (isNumeric(args[0])) {
  1105. for (let i = 0; i < 16; i++) {
  1106. if (parseFloat(args[0]) < pointsNeeded[i]) {
  1107. args[0] = `L: ${i}`;
  1108. }
  1109. }
  1110. } else if (args[0].includes('.')) {
  1111. if (args[0].includes('k')) {
  1112. for (let i = 16; i < 45; i++) {
  1113. if (parseFloat(args[0].split('k')[0]) * 1000 < pointsNeeded[i]) {
  1114. args[0] = `L: ${i}`;
  1115. }
  1116. }
  1117. if (parseFloat(args[0].split('k')[0]) * 1000 > pointsNeeded[44]){
  1118. args[0] = `L: 45`;
  1119. }
  1120. } else if (args[0].includes('m')) {
  1121. args[0] = `L: 45`;
  1122. }
  1123. }
  1124. }
  1125. }
  1126. f.apply(_this, args);
  1127. }
  1128. });
  1129.  
  1130. //Detect AutoFire/AutoSpin
  1131. let auto_fire = false;
  1132. let auto_spin = false;
  1133.  
  1134. function f_s(f_or_s) {
  1135. switch (f_or_s) {
  1136. case "fire":
  1137. auto_fire = !auto_fire;
  1138. break
  1139. case "spin":
  1140. auto_spin = !auto_spin;
  1141. break
  1142. }
  1143. }
  1144. //Diep Units & fov calculator
  1145. //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.
  1146.  
  1147. /*
  1148. =============================================================================
  1149. Skid & Noob friendly calculation explained:
  1150.  
  1151. Read this in order to understand, how the position calculation works.
  1152.  
  1153. 1. Canvas/window coords
  1154. When you load diep.io in a browser window, it also loads a canvas where the game is drawn.
  1155. 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.
  1156. Diep.io uses canvas mainly. Your window and the canvas use different coordinate systems, even tho they appear the same at first:
  1157.  
  1158. start->x
  1159. |
  1160. \/
  1161. y
  1162.  
  1163. if x is for example 3 and y is 5, you find the point of your mouse.
  1164.  
  1165. start->x...
  1166. |_________|
  1167. \/________|
  1168. y_________|
  1169. ._________|
  1170. ._________|
  1171. ._________|
  1172. ._________|
  1173. ._________HERE
  1174.  
  1175. the right upper corner of your window is the x limit, called window.innerWidth
  1176. the left bottom corner of your window is the y limit, called window.innerHeight
  1177.  
  1178. canvas is the same, but multiplied by 2. So for x, it's canvas.height = window.innerHeight * 2
  1179. same goes for y, canvas.width = window.innerWidth * 2
  1180.  
  1181. This can work the other way around too. canvas.height/2 = window.innerHeight
  1182. and canvas.width/2 = window.innerWidth
  1183.  
  1184. NOTE: when you use input.mouse(x, y) you're using the canvas coordinate system.
  1185.  
  1186. 2. DiepUnits
  1187. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  1188. if you're curious about what l and Fv means, like I was I can tell you now.
  1189.  
  1190. L stands for your Tank level, that you currently have.
  1191. Fv is the fieldFactor. You can find them here for each tank: https://github.com/ABCxFF/diepindepth/blob/main/extras/tankdefs.json
  1192. (The formula from the picture as code: const FOV = (level, fieldFactor) => (.55*fieldFactor)/Math.pow(1.01, (level-1)/2); )
  1193.  
  1194. Additions:
  1195. DiepUnits are used, to draw all entities in game in the right size. For example when you go Ranger, they appear smaller
  1196. because your entire ingame map shrinks down, so you see more without changing the size of the canvas or the window.
  1197. So if a square is 55 diepunits big and it gets visually smaller, it's still 55 diepunits big.
  1198.  
  1199. Coordinate system: x*scalingFactor, y*scalingFactor
  1200.  
  1201. IMPORTANT!!! Note that your Tank is getting additional DiepUnits with every level it grows.
  1202. This formula descritbes it's growth
  1203. 53 * (1.01 ** (currentLevel - 1));
  1204.  
  1205. 3. WindowScaling
  1206. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  1207. (you can use the function given in there, if you don't want to make your own)
  1208.  
  1209. it's used for all ui elements, like scoreboard, minimap or stats upgrades.
  1210. NOTE: It's not used for html Elements, only canvas. So the starting menu or gameover screen aren't part of it.
  1211.  
  1212. Coordinate system: x*windowScaling(), y*windowScaling()
  1213.  
  1214. 4. Converting coordinate systems into each other
  1215. canvas -> window = a/(canvas.width/window.innerWidth) -> b
  1216. window -> canvas = a*(canvas.width/window.innerWidth) -> b
  1217. windowScaling -> window = ( a*windowScaling() )/(canvas.width/window.innerWidth) -> b
  1218. windowScaling -> canvas = a*windowScaling() - > b
  1219. diepUnits -> canvas = a/scalingFactor -> b
  1220. diepUnits -> window = ( a/scalingFactor )/(canvas.width/window.innerWidth) -> b
  1221. window -> diepUnits = ( a*scalingFactor )*(canvas.width/window.innerWidth) -> b
  1222. canvas -> diepUnits = a*scalingFactor -> b
  1223. window -> windowScaling() = ( a*windowScaling() )*(canvas.width/window.innerWidth) -> b
  1224. canvas -> windowScaling() = a*windowScaling() - > b
  1225. diepUnits -> windowScaling() = ( a/scalingFactor ) * fieldFactor -> b
  1226. windowScaling()-> diepUnits = ( a/fieldFactor ) * scalingFactor -> b
  1227.  
  1228. =============================================================================
  1229.  
  1230. My todo list or fix:
  1231.  
  1232. - simulate diep.io moving and knockback physics
  1233.  
  1234. - simulate diep.io bullets
  1235.  
  1236. - figure out how to simulate mouse click events
  1237.  
  1238. - Finish bullet speed hybrid tanks
  1239.  
  1240. - Figure out physics for sniper, Ranger etc.
  1241.  
  1242. =============================================================================
  1243.  
  1244. Known Bugs:
  1245.  
  1246. - when enabling Level Seeker and pressing L, the ms gets replaced as well
  1247.  
  1248. =============================================================================
  1249.  
  1250. Useful info:
  1251.  
  1252. -shape sizes:
  1253.  
  1254. tank lvl 1 size = 53 diep units
  1255.  
  1256. grid square side length = 50 diep units
  1257. square, triangle = 55 diep units
  1258. pentagon = 75 diep units
  1259. small crasher = 35 diep units
  1260. big crasher = 55 diep units
  1261. alpha pentagon = 200 diep units
  1262.  
  1263. =============================================================================
  1264. */
  1265. let ripsaw_radius;
  1266. let fieldFactor = 1.0;
  1267. let found = false;
  1268. let loltank;
  1269. let lolztank;
  1270. let diepUnits = 53 * (1.01 ** (player.level - 1));
  1271. let FOV = (0.55 * fieldFactor) / Math.pow(1.01, (player.level - 1) / 2);
  1272. let legit_FOV;
  1273. let change_FOV_request = false;
  1274. let scalingFactor = FOV * windowScaling();
  1275. const fieldFactors = [
  1276. {
  1277. tank: "Sniper",
  1278. factor: 0.899
  1279. },
  1280. {
  1281. tank: "Overseer",
  1282. factor: 0.899
  1283. },
  1284. {
  1285. tank: "Overlord",
  1286. factor: 0.899
  1287. },
  1288. {
  1289. tank: "Assassin",
  1290. factor: 0.8
  1291. },
  1292. {
  1293. tank: "Necromancer",
  1294. factor: 0.899
  1295. },
  1296. {
  1297. tank: "Hunter",
  1298. factor: 0.85
  1299. },
  1300. {
  1301. tank: "Stalker",
  1302. factor: 0.8
  1303. },
  1304. {
  1305. tank: "Ranger",
  1306. factor: 0.699
  1307. },
  1308. {
  1309. tank: "Manager",
  1310. factor: 0.899
  1311. },
  1312. {
  1313. tank: "Predator",
  1314. factor: 0.85
  1315. },
  1316. {
  1317. tank: "Trapper",
  1318. factor: 0.899
  1319. },
  1320. {
  1321. tank: "GunnerTrapper",
  1322. factor: 0.899
  1323. },
  1324. {
  1325. tank: "Overtrapper",
  1326. factor: 0.899
  1327. },
  1328. {
  1329. tank: "MegaTrapper",
  1330. factor: 0.899
  1331. },
  1332. {
  1333. tank: "Tri-Trapper",
  1334. factor: 0.899
  1335. },
  1336. {
  1337. tank: "Smasher",
  1338. factor: 0.899
  1339. },
  1340. {
  1341. tank: "Landmine",
  1342. factor: 0.899
  1343. },
  1344. {
  1345. tank: "Streamliner",
  1346. factor: 0.85
  1347. },
  1348. {
  1349. tank: "AutoTrapper",
  1350. factor: 0.899
  1351. },
  1352. {
  1353. tank: "Battleship",
  1354. factor: 0.899
  1355. },
  1356. {
  1357. tank: "AutoSmasher",
  1358. factor: 0.899
  1359. },
  1360. {
  1361. tank: "Spike",
  1362. factor: 0.899
  1363. },
  1364. {
  1365. tank: "Factory",
  1366. factor: 0.899
  1367. },
  1368. {
  1369. tank: "Skimmer",
  1370. factor: 0.899
  1371. },
  1372. {
  1373. tank: "Glider",
  1374. factor: 0.899
  1375. },
  1376. {
  1377. tank: "Rocketeer",
  1378. factor: 0.899
  1379. },
  1380. ]
  1381.  
  1382. function windowScaling() {
  1383. const a = canvas.height / 1080;
  1384. const b = canvas.width / 1920;
  1385. return b < a ? a : b;
  1386. }
  1387.  
  1388. function check_FOV_requests() {
  1389. if (script_list.fov) {
  1390. if (toggleButtons.Addons['FOV changer']) {
  1391. change_FOV_request = true;
  1392. change_FOV(FOVindex);
  1393. } else {
  1394. change_FOV_request = false;
  1395. change_FOV();
  1396. }
  1397. }
  1398. }
  1399.  
  1400. setInterval(check_FOV_requests, 500);
  1401.  
  1402. function calculateFOV(Fv, l) {
  1403. const numerator = 0.55 * Fv;
  1404. const denominator = Math.pow(1.01, (l - 1) / 2);
  1405. legit_FOV = numerator / denominator;
  1406. window.legit_FOV = legit_FOV;
  1407. let l1 = new_FOVs.length;
  1408. for (let i = 0; i < l1; i++) {
  1409. if (new_FOVs[i].name != 'Background') {
  1410. new_FOVs[i].FOV = ((0.55 * new_FOVs[i].fieldFactor) / (Math.pow(1.01, (l - 1) / 2)));
  1411. } else {
  1412. new_FOVs[i].FOV = 0.3499999940395355;
  1413. }
  1414. }
  1415. if (typeof window.HEAPF32 !== 'undefined' && typeof window.fov !== 'undefined' && window.fov.length > 0 && !window.legit_request) {
  1416. //use this part, if you have a fov script that can share it's fov value with you
  1417. FOV = HEAPF32[fov[0]];
  1418. } else {
  1419. //use this part if you have no fov script
  1420. FOV = legit_FOV;
  1421. }
  1422. return FOV;
  1423. }
  1424.  
  1425. function change_FOV(index) {
  1426. for (const fov of window.fov) {
  1427. if (change_FOV_request && !window.legit_request) {
  1428. if (index === 0) {
  1429. window.HEAPF32[fov] = new_FOVs[index].FOV;
  1430. }
  1431. window.HEAPF32[fov] = new_FOVs[index].FOV;
  1432. } else {
  1433. window.HEAPF32[fov] = legit_FOV;
  1434. }
  1435. }
  1436. }
  1437.  
  1438. function apply_values(FF) {
  1439. calculateFOV(FF, player.level);
  1440. scalingFactor = FOV * windowScaling();
  1441. ripsaw_radius = diepUnits * scalingFactor;
  1442. diepUnits = 53 * (1.01 ** (player.level - 1));
  1443. }
  1444.  
  1445. function apply_changes(value) {
  1446. if (found) {
  1447. fieldFactor = fieldFactors[value].factor;
  1448. loltank = player.tank;
  1449. player.last_level = player.level;
  1450. apply_values(fieldFactor);
  1451. } else {
  1452. if (value === null) {
  1453. fieldFactor = 1.0;
  1454. loltank = "default";
  1455. lolztank = player.tank;
  1456. player.last_level = player.level;
  1457. apply_values(fieldFactor);
  1458. }
  1459. }
  1460. }
  1461.  
  1462. function bruteforce_tanks() {
  1463. let l = fieldFactors.length;
  1464. for (let i = 0; i < l; i++) {
  1465. if (player.tank.includes(fieldFactors[i].tank)) {
  1466. found = true;
  1467. console.log("FOUND TANK " + fieldFactors[i].tank);
  1468. apply_changes(i);
  1469. break;
  1470. } else {
  1471. found = false;
  1472. if (i < l - 1) {
  1473. console.log(`checking tank ${i}`);
  1474. } else {
  1475. console.log("Tank set to default or not found")
  1476. apply_changes(null);
  1477. }
  1478. }
  1479. }
  1480. }
  1481.  
  1482. window.addEventListener("resize", bruteforce_tanks);
  1483.  
  1484. function check_lvl_change() {
  1485. if (player.last_level != player.level) {
  1486. console.log("changed level, bruteforcing");
  1487. bruteforce_tanks();
  1488. }
  1489. }
  1490.  
  1491. function check_change() {
  1492. check_lvl_change();
  1493. if (loltank != player.tank) {
  1494. if (loltank === "default") {
  1495. if (lolztank != player.tank) {
  1496. bruteforce_tanks();
  1497. } else {
  1498. return;
  1499. }
  1500. } else {
  1501. bruteforce_tanks();
  1502. }
  1503. }
  1504. }
  1505.  
  1506. setInterval(check_change, 250);
  1507.  
  1508. //canvas gui
  1509. let offsetX = 0;
  1510. let offsetY = 0;
  1511. //for canvas text height and space between it
  1512. let text_startingY = 450 * windowScaling();
  1513. let textAdd = 25 * windowScaling();
  1514. let selected_box = null;
  1515. const boxes = [
  1516. {
  1517. color: "lightblue",
  1518. LUcornerX: 47,
  1519. LUcornerY: 67
  1520. },
  1521. {
  1522. color: "green",
  1523. LUcornerX: 47 + 90 + 13,
  1524. LUcornerY: 67
  1525. },
  1526. {
  1527. color: "red",
  1528. LUcornerX: 47,
  1529. LUcornerY: 67 + 90 + 9
  1530. },
  1531. {
  1532. color: "yellow",
  1533. LUcornerX: 47 + 90 + 13,
  1534. LUcornerY: 67 + 90 + 9
  1535. },
  1536. {
  1537. color: "blue",
  1538. LUcornerX: 47,
  1539. LUcornerY: 67 + ((90 + 9) * 2)
  1540. },
  1541. {
  1542. color: "rainbow",
  1543. LUcornerX: 47 + 90 + 13,
  1544. LUcornerY: 67 + ((90 + 9) * 2)
  1545. }
  1546. ]
  1547.  
  1548. const ctx = canvas.getContext('2d');
  1549.  
  1550. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY) {
  1551. ctx.fillStyle = fcolor;
  1552. ctx.lineWidth = lineWidth;
  1553. ctx.font = font;
  1554. ctx.strokeStyle = scolor;
  1555. ctx.strokeText(`${text}`, textX, textY)
  1556. ctx.fillText(`${text}`, textX, textY)
  1557. }
  1558.  
  1559. function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c) {
  1560. ctx.beginPath();
  1561. ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
  1562. ctx.fillStyle = c;
  1563. ctx.fill();
  1564. }
  1565.  
  1566. function ctx_rect(x, y, a, b, c) {
  1567. ctx.beginPath();
  1568. ctx.strokeStyle = c;
  1569. ctx.strokeRect(x, y, a, b);
  1570. }
  1571.  
  1572. //use this for game entities
  1573. function dot_in_diepunits(diepunits_X, diepunits_Y) {
  1574. ctx_arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, 5, 0, 2 * Math.PI, false, "lightblue");
  1575. }
  1576.  
  1577. function circle_in_diepunits(diepunits_X, diepunits_Y, diepunits_R, c) {
  1578. ctx.beginPath();
  1579. ctx.arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, diepunits_R * scalingFactor, 0, 2 * Math.PI, false);
  1580. ctx.strokeStyle = c;
  1581. ctx.stroke();
  1582. }
  1583.  
  1584. function big_half_circle(diepunits_X, diepunits_Y, diepunits_R, c){
  1585. let centerY = diepunits_Y*scalingFactor;
  1586. let centerX = diepunits_X*scalingFactor;
  1587. let angle = Math.atan2(uwuY - centerY, uwuX - centerX);
  1588. ctx.beginPath();
  1589. ctx.arc(centerX, centerY, diepunits_R * scalingFactor, angle - Math.PI / 2, angle + Math.PI / 2, false);
  1590. ctx.strokeStyle = c;
  1591. ctx.stroke();
  1592. }
  1593.  
  1594. function small_half_circle(diepunits_X, diepunits_Y, diepunits_R, c){
  1595. let centerY = diepunits_Y*scalingFactor;
  1596. let centerX = diepunits_X*scalingFactor;
  1597. let angle = Math.atan2(uwuY - centerY, uwuX - centerX);
  1598. ctx.beginPath();
  1599. ctx.arc(centerX, centerY, diepunits_R * scalingFactor, angle + Math.PI / 2, angle - Math.PI / 2, false);
  1600. ctx.strokeStyle = c;
  1601. ctx.stroke();
  1602. }
  1603.  
  1604. //use this for ui elements like upgrades or scoreboard
  1605. function dot_in_diepunits_FOVless(diepunits_X, diepunits_Y) {
  1606. ctx_arc(diepunits_X * windowScaling(), diepunits_Y * windowScaling(), 5, 0, 2 * Math.PI, false, "lightblue");
  1607. }
  1608.  
  1609. function square_for_grid(x, y, a, b, color) {
  1610. ctx.beginPath();
  1611. ctx.rect(x * windowScaling(), y * windowScaling(), a * windowScaling(), b * windowScaling());
  1612. ctx.strokeStyle = color;
  1613. ctx.stroke();
  1614. }
  1615.  
  1616. function draw_upgrade_grid() {
  1617. let l = boxes.length;
  1618. for (let i = 0; i < l; i++) {
  1619. let start_x = (boxes[i].LUcornerX * windowScaling()) / two;
  1620. let start_y = (boxes[i].LUcornerY * windowScaling()) / two;
  1621. let end_x = ((boxes[i].LUcornerX + 43 * 2) * windowScaling()) / two;
  1622. let end_y = ((boxes[i].LUcornerY + 43 * 2) * windowScaling()) / two;
  1623. let temp_color = "black";
  1624. if (uwuX > start_x && uwuY > start_y && uwuX < end_x && uwuY < end_y) {
  1625. temp_color = "red";
  1626. selected_box = i;
  1627. } else {
  1628. temp_color = "black";
  1629. selected_box = null;
  1630. }
  1631. square_for_grid(boxes[i].LUcornerX, boxes[i].LUcornerY, 86, 86, temp_color);
  1632. }
  1633. for (let i = 0; i < l; i++) {
  1634. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY);
  1635. dot_in_diepunits_FOVless(boxes[i].LUcornerX + 43, boxes[i].LUcornerY);
  1636. dot_in_diepunits_FOVless(boxes[i].LUcornerX + 43 * 2, boxes[i].LUcornerY);
  1637. dot_in_diepunits_FOVless(boxes[i].LUcornerX + 43 * 2, boxes[i].LUcornerY + 43);
  1638. dot_in_diepunits_FOVless(boxes[i].LUcornerX + 43 * 2, boxes[i].LUcornerY + 43 * 2);
  1639. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY + 43);
  1640. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY + 43 * 2);
  1641. dot_in_diepunits_FOVless(boxes[i].LUcornerX + 43, boxes[i].LUcornerY + 43);
  1642. }
  1643. }
  1644.  
  1645. const gradients = ["#94b3d0", "#96b0c7", "#778daa", "#4c7299", "#52596c", "#19254e", "#2d445f", "#172631"];
  1646. const tank_group1 = ["Trapper", "Overtrapper", "MegaTrapper", "Tri-Trapper"]; //Traps only
  1647. const tank_group2 = ["Tank", "Twin", "TripleShot", "SpreadShot", "PentaShot", "MachineGun", "Sprayer", "Triplet"]; //constant bullets [initial speed = 0.699]
  1648. const tank_group2round = ["TwinFlank", "TripleTwin", "QuadTank", "OctoTank", "FlankGuard"];
  1649. const tank_group3 = ["GunnerTrapper"]; //Traps AND constant bullets
  1650. const tank_group4 = ["Fighter", "Booster", "Tri-Angle"]; // fast tanks
  1651. const tank_group5 = ["Sniper", "Assassin", "Stalker", "Ranger"]; //sniper+ bullets
  1652. const tank_group6 = ["Destroyer", "Hybrid", "Annihilator"]; //slower bullets [intitial speed = 0.699]
  1653. //const tank_group7 = ["Overseer", "Overlord", "Manager", "Necromancer"]; //infinite bullets(drones) (UNFINISHED)
  1654. const tank_group8 = ["Factory"]; //drones with spreading abilities
  1655. const tank_group9 = ["Battleship"]; //special case
  1656. const tank_group10 = ["Streamliner"]; // special case
  1657. const tank_group11 = ["Gunner", "AutoGunner"] // (UNFINISHED)
  1658.  
  1659. //get bullet speed
  1660. function count_fours(string){
  1661. let fours_count = 0;
  1662. let temp_array = [...string];
  1663. for(let i = 0; i < temp_array.length; i++){
  1664. if(temp_array[i] === "4"){
  1665. fours_count++;
  1666. }
  1667. }
  1668. return fours_count;
  1669. }
  1670.  
  1671. function draw_cirle_radius_for_tank() {
  1672. let b_s;
  1673. if(diep_data.length > 0){
  1674. player.raw_build = diep_data[0][1];
  1675. player.real_time_build = real_build(player.raw_build);
  1676. b_s = count_fours(player.real_time_build);
  1677. }else{
  1678. b_s = 0;
  1679. }
  1680.  
  1681. if (tank_group1.includes(player.tank)) {
  1682. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 485 + (52.5 * b_s), gradients[b_s]);
  1683. } else if (tank_group2.includes(player.tank)) {
  1684. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  1685. } else if (tank_group2round.includes(player.tank)) {
  1686. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  1687. } else if(tank_group3.includes(player.tank)){
  1688. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  1689. small_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 485 + (52.5 * b_s), gradients[b_s]);
  1690. } else if(tank_group4.includes(player.tank)){
  1691. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1850 + (210 * b_s), gradients[b_s]);
  1692. small_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1135 + (100 * b_s), gradients[b_s]);
  1693. }else if(tank_group5.includes(player.tank)){
  1694. big_half_circle(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 2680 + (350*b_s), gradients[b_s]);
  1695. } else if (tank_group6.includes(player.tank)) {
  1696. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1443.21 + (146.79 * b_s), gradients[b_s]);
  1697. /*
  1698. }else if(tank_group7.includes(player.tank)){
  1699. circle_in_diepunits( canvas.width/2/scalingFactor , canvas.height/2/scalingFactor, 1607 + (145*b_s), gradients[b_s]);
  1700. circle_in_diepunits( uwuX*2/scalingFactor , uwuY*2/scalingFactor, 1607 + (145*i), gradients[b_s]);
  1701. */
  1702. } else if (tank_group8.includes(player.tank)) {
  1703. if (!auto_fire) {
  1704. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 200, gradients[0]);
  1705. } else {
  1706. circle_in_diepunits(uwuX * two / scalingFactor, uwuY * two / scalingFactor, 800, gradients[1]);
  1707. circle_in_diepunits(uwuX * two / scalingFactor, uwuY * two / scalingFactor, 900, gradients[2]);
  1708. }
  1709. } else if (tank_group9.includes(player.tank)) {
  1710. circle_in_diepunits(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1640 + (210 * b_s), gradients[b_s]);
  1711. }else if (tank_group10.includes(player.tank)) {
  1712. big_half_circle(canvas.width / 2 / scalingFactor, canvas.height / 2 / scalingFactor, 1750 + (190 * b_s), gradients[b_s]);
  1713. } else {
  1714. return;
  1715. }
  1716.  
  1717. }
  1718.  
  1719. //let's calculate the angle
  1720. var vector_l = [null, null];
  1721. var angle_l = 0;
  1722.  
  1723. function calc_leader() {
  1724. if (script_list.minimap_leader_v1) {
  1725. let xc = canvas.width / 2;
  1726. let yc = canvas.height / 2;
  1727. vector_l[0] = window.l_arrow.xl - xc;
  1728. vector_l[1] = window.l_arrow.yl - yc;
  1729. angle_l = Math.atan2(vector_l[1], vector_l[0]) * (180 / Math.PI);
  1730. } else if (script_list.minimap_leader_v2) {
  1731. let xc = canvas.width / 2;
  1732. let yc = canvas.height / 2;
  1733. vector_l[0] = window.L_X - xc;
  1734. vector_l[1] = window.L_Y - yc;
  1735. angle_l = Math.atan2(vector_l[1], vector_l[0]) * (180 / Math.PI);
  1736. } else {
  1737. console.log("waiting for leader script to give us values");
  1738. }
  1739. }
  1740.  
  1741. // Minimap logic
  1742. var minimap_elements = [
  1743. {
  1744. name: "minimap",
  1745. x: 177.5,
  1746. y: 177.5,
  1747. width: 162.5,
  1748. height: 162.5,
  1749. color: "purple"
  1750. },
  1751. {
  1752. name: "2 Teams Blue Team",
  1753. x: 177.5,
  1754. y: 177.5,
  1755. width: 17.5,
  1756. height: 162.5,
  1757. color: "blue"
  1758. },
  1759. {
  1760. name: "2 Teams Blue Team zone",
  1761. x: 160.0,
  1762. y: 177.5,
  1763. width: 17.5,
  1764. height: 162.5,
  1765. color: "SlateBlue"
  1766. },
  1767. {
  1768. name: "2 Teams Red Team",
  1769. x: 32.5,
  1770. y: 177.5,
  1771. width: 17.5,
  1772. height: 162.5,
  1773. color: "red"
  1774. },
  1775. {
  1776. name: "2 Teams Red Team zone",
  1777. x: 50,
  1778. y: 177.5,
  1779. width: 17.5,
  1780. height: 162.5,
  1781. color: "orangeRed"
  1782. },
  1783. {
  1784. name: "4 Teams Blue Team",
  1785. x: 177.5,
  1786. y: 177.5,
  1787. width: 25,
  1788. height: 25,
  1789. color: "blue"
  1790. },
  1791. {
  1792. name: "4 Teams Blue zone",
  1793. x: 177.5,
  1794. y: 177.5,
  1795. width: 40,
  1796. height: 40,
  1797. color: "SlateBlue"
  1798. },
  1799. {
  1800. name: "4 Teams Purple Team",
  1801. x: 40,
  1802. y: 177.5,
  1803. width: 25,
  1804. height: 25,
  1805. color: "purple"
  1806. },
  1807. {
  1808. name: "4 Teams Purple zone",
  1809. x: 55,
  1810. y: 177.5,
  1811. width: 40,
  1812. height: 40,
  1813. color: "Violet"
  1814. },
  1815. {
  1816. name: "4 Teams Green Team",
  1817. x: 177.5,
  1818. y: 40,
  1819. width: 25,
  1820. height: 25,
  1821. color: "green"
  1822. },
  1823. {
  1824. name: "4 Teams Green zone",
  1825. x: 177.5,
  1826. y: 55,
  1827. width: 40,
  1828. height: 40,
  1829. color: "LimeGreen"
  1830. },
  1831. {
  1832. name: "4 Teams Red Team",
  1833. x: 40,
  1834. y: 40,
  1835. width: 25,
  1836. height: 25,
  1837. color: "orangeRed"
  1838. },
  1839. {
  1840. name: "4 Teams Red zone",
  1841. x: 55,
  1842. y: 55,
  1843. width: 40,
  1844. height: 40,
  1845. color: "red"
  1846. },
  1847. ];
  1848.  
  1849. var m_e_ctx_coords = [
  1850. {
  1851. name: "minimap",
  1852. startx: null,
  1853. stary: null,
  1854. endx: null,
  1855. endy: null
  1856. },
  1857. {
  1858. name: "2 Teams Blue Team",
  1859. startx: null,
  1860. stary: null,
  1861. endx: null,
  1862. endy: null
  1863. },
  1864. {
  1865. name: "2 Teams Blue Team Zone",
  1866. startx: null,
  1867. stary: null,
  1868. endx: null,
  1869. endy: null
  1870. },
  1871. {
  1872. name: "2 Teams Red Team",
  1873. startx: null,
  1874. stary: null,
  1875. endx: null,
  1876. endy: null
  1877. },
  1878. {
  1879. name: "2 Teams Red Team Zone",
  1880. startx: null,
  1881. stary: null,
  1882. endx: null,
  1883. endy: null
  1884. },
  1885. {
  1886. name: "4 Teams Blue Team",
  1887. startx: null,
  1888. stary: null,
  1889. endx: null,
  1890. endy: null
  1891. },
  1892. {
  1893. name: "4 Teams Blue zone",
  1894. startx: null,
  1895. stary: null,
  1896. endx: null,
  1897. endy: null
  1898. },
  1899. {
  1900. name: "4 Teams Purple Team",
  1901. startx: null,
  1902. stary: null,
  1903. endx: null,
  1904. endy: null
  1905. },
  1906. {
  1907. name: "4 Teams Purple zone",
  1908. startx: null,
  1909. stary: null,
  1910. endx: null,
  1911. endy: null
  1912. },
  1913. {
  1914. name: "4 Teams Green Team",
  1915. startx: null,
  1916. stary: null,
  1917. endx: null,
  1918. endy: null
  1919. },
  1920. {
  1921. name: "4 Teams Green zone",
  1922. startx: null,
  1923. stary: null,
  1924. endx: null,
  1925. endy: null
  1926. },
  1927. {
  1928. name: "4 Teams Red Team",
  1929. startx: null,
  1930. stary: null,
  1931. endx: null,
  1932. endy: null
  1933. },
  1934. {
  1935. name: "4 Teams Red zone",
  1936. startx: null,
  1937. stary: null,
  1938. endx: null,
  1939. endy: null
  1940. }
  1941. ]
  1942.  
  1943. function draw_minimap() {
  1944. let l = minimap_elements.length;
  1945. switch (gamemode) {
  1946. case "2 Teams":
  1947. for (let i = 0; i < 5; i++) {
  1948. if (i === 2 || i === 4) {
  1949. if (toggleButtons.Addons['Toggle Base Zones']) {
  1950. updateAndDrawElement(i);
  1951. }
  1952. } else {
  1953. updateAndDrawElement(i);
  1954. }
  1955. }
  1956. break;
  1957. case "4 Teams":
  1958. updateAndDrawElement(0);
  1959. for (let i = 5; i < l; i++) {
  1960. if (i === 6 || i === 8 || i === 10 || i === 12) {
  1961. if (toggleButtons.Addons['Toggle Base Zones']) {
  1962. updateAndDrawElement(i);
  1963. }
  1964. } else {
  1965. updateAndDrawElement(i);
  1966. }
  1967. }
  1968. break;
  1969. }
  1970. if (script_list.minimap_leader_v1 || script_list.minimap_leader_v2) {
  1971. minimap_collision_check();
  1972. }
  1973. }
  1974.  
  1975. function updateAndDrawElement(index) {
  1976. // Update their real-time position
  1977. m_e_ctx_coords[index].startx = canvas.width - (minimap_elements[index].x * windowScaling());
  1978. m_e_ctx_coords[index].starty = canvas.height - (minimap_elements[index].y * windowScaling());
  1979. m_e_ctx_coords[index].endx = m_e_ctx_coords[index].startx + minimap_elements[index].width * windowScaling();
  1980. m_e_ctx_coords[index].endy = m_e_ctx_coords[index].starty + minimap_elements[index].height * windowScaling();
  1981.  
  1982. // Draw the element
  1983. ctx.beginPath();
  1984. ctx.rect(m_e_ctx_coords[index].startx, m_e_ctx_coords[index].starty, minimap_elements[index].width * windowScaling(), minimap_elements[index].height * windowScaling());
  1985. ctx.lineWidth = "1";
  1986. ctx.strokeStyle = minimap_elements[index].color;
  1987. ctx.stroke();
  1988. }
  1989.  
  1990. function minimap_collision_check() {
  1991. if (script_list.minimap_leader_v1 || script_list.minimap_leader_v2) {
  1992. let x = script_list.minimap_leader_v1 ? window.m_arrow.xl : window.M_X;
  1993. let y = script_list.minimap_leader_v1 ? window.m_arrow.yl : window.M_Y;
  1994.  
  1995. if (m_e_ctx_coords[0].startx < x &&
  1996. m_e_ctx_coords[0].starty < y &&
  1997. m_e_ctx_coords[0].endx > x &&
  1998. m_e_ctx_coords[0].endy > y) {
  1999.  
  2000. if (gamemode === "2 Teams") {
  2001. if (checkWithinBase(1, x, y)) position_on_minimap = "blue base";
  2002. else if (checkWithinBase(2, x, y)) position_on_minimap = "blue drones";
  2003. else if (checkWithinBase(3, x, y)) position_on_minimap = "red base";
  2004. else if (checkWithinBase(4, x, y)) position_on_minimap = "red drones";
  2005. else position_on_minimap = "not in the base";
  2006. } else if (gamemode === "4 Teams") {
  2007. if (checkWithinBase(6, x, y)) {
  2008. if (checkWithinBase(5, x, y)) {
  2009. position_on_minimap = "blue base"
  2010. } else {
  2011. position_on_minimap = "blue drones";
  2012. }
  2013. } else if (checkWithinBase(8, x, y)) {
  2014. if (checkWithinBase(7, x, y)) {
  2015. position_on_minimap = "purple base"
  2016. } else {
  2017. position_on_minimap = "purple drones";
  2018. }
  2019. } else if (checkWithinBase(10, x, y)) {
  2020. if (checkWithinBase(9, x, y)) {
  2021. position_on_minimap = "green base"
  2022. } else {
  2023. position_on_minimap = "green drones";
  2024. }
  2025. } else if (checkWithinBase(12, x, y)) {
  2026. if (checkWithinBase(11, x, y)) {
  2027. position_on_minimap = "red base"
  2028. } else {
  2029. position_on_minimap = "red drones";
  2030. }
  2031. } else {
  2032. position_on_minimap = "not in the base";
  2033. }
  2034. } else {
  2035. position_on_minimap = "Warning! not on minimap";
  2036. }
  2037. }
  2038. }
  2039. }
  2040.  
  2041. function checkWithinBase(baseIndex, x, y) {
  2042. return m_e_ctx_coords[baseIndex].startx < x &&
  2043. m_e_ctx_coords[baseIndex].starty < y &&
  2044. m_e_ctx_coords[baseIndex].endx > x &&
  2045. m_e_ctx_coords[baseIndex].endy > y;
  2046. }
  2047.  
  2048. //notify player about entering base zones
  2049. let alerted = false;
  2050.  
  2051. function alert_about_drones() {
  2052. if (position_on_minimap.includes('drones')) {
  2053. if (!alerted) {
  2054. new_notification("Warning drones!", rgbToNumber(...notification_rbgs.warning), 2500);
  2055. alerted = true;
  2056. }
  2057. } else {
  2058. alerted = false;
  2059. }
  2060. }
  2061.  
  2062. //let's try drawing a line to the leader
  2063.  
  2064. function apply_vector_on_minimap() {
  2065. if (script_list.minimap_leader_v1) {
  2066. let x = window.m_arrow.xl;
  2067. let y = window.m_arrow.yl;
  2068. let thetaRadians = angle_l * (Math.PI / 180);
  2069. let r = m_e_ctx_coords[0].endx - m_e_ctx_coords[0].startx;
  2070. let x2 = x + r * Math.cos(thetaRadians);
  2071. let y2 = y + r * Math.sin(thetaRadians);
  2072. ctx.beginPath();
  2073. ctx.moveTo(x, y);
  2074. ctx.lineTo(x2, y2);
  2075. ctx.stroke();
  2076. } else if (script_list.minimap_leader_v2) {
  2077. let x = window.M_X;
  2078. let y = window.M_Y;
  2079. let thetaRadians = angle_l * (Math.PI / 180);
  2080. let r = m_e_ctx_coords[0].endx - m_e_ctx_coords[0].startx;
  2081. let x2 = x + r * Math.cos(thetaRadians);
  2082. let y2 = y + r * Math.sin(thetaRadians);
  2083. ctx.beginPath();
  2084. ctx.moveTo(x, y);
  2085. ctx.lineTo(x2, y2);
  2086. ctx.stroke();
  2087. }
  2088. }
  2089.  
  2090.  
  2091. //drawing the limit of the server (needs rework)
  2092. function draw_server_border(a, b) {
  2093. ctx.beginPath();
  2094. ctx.rect(canvas.width / 2 - (a / 2 * scalingFactor), canvas.height / 2 - (b / 2 * scalingFactor), a * scalingFactor, b * scalingFactor);
  2095. ctx.strokeStyle = "red";
  2096. ctx.stroke();
  2097. }
  2098.  
  2099. const circle_gradients = [
  2100. "#FF0000", // Red
  2101. "#FF4D00", // Orange Red
  2102. "#FF8000", // Orange
  2103. "#FFB300", // Dark Goldenrod
  2104. "#FFD700", // Gold
  2105. "#FFEA00", // Yellow
  2106. "#D6FF00", // Light Yellow Green
  2107. "#A3FF00", // Yellow Green
  2108. "#6CFF00", // Lime Green
  2109. "#00FF4C", // Medium Spring Green
  2110. "#00FF9D", // Turquoise
  2111. "#00D6FF", // Sky Blue
  2112. "#006CFF", // Blue
  2113. "#0000FF" // Dark Blue
  2114. ];
  2115.  
  2116. function draw_crx_events() {
  2117. //you need either leader arrow or moveTo/lineTo script from h3llside for this part
  2118. if (script_list.moveToLineTo_debug) {
  2119. let l = window.y_and_x.length;
  2120. for (let i = 0; i < l; i++) {
  2121. ctx_arc(window.y_and_x[i][0], window.y_and_x[i][1], 10, 0, 2 * Math.PI, false, circle_gradients[i]);
  2122. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", i, window.y_and_x[i][0], window.y_and_x[i][1]);
  2123. }
  2124. } else if (script_list.minimap_leader_v1) {
  2125. //ctx_arc(window.l_arrow.xm, window.l_arrow.ym, 15, 0, 2 * Math.PI, false, window.l_arrow.color);
  2126. //ctx_arc(window.m_arrow.xm, window.m_arrow.ym, 1, 0, 2 * Math.PI, false, "yellow");
  2127. ctx_arc(window.l_arrow.xl, window.l_arrow.yl, 5, 0, 2 * Math.PI, false, window.l_arrow.color);
  2128. ctx_arc(window.m_arrow.xl, window.m_arrow.yl, 1, 0, 2 * Math.PI, false, "yellow");
  2129. }
  2130. }
  2131.  
  2132. //tank aim lines
  2133. let TurretRatios = [
  2134. {
  2135. name: "Destroyer",
  2136. ratio: 95 / 71.4,
  2137. color: "red"
  2138. },
  2139. {
  2140. name: "Anni",
  2141. ratio: 95 / 96.6,
  2142. color: "darkred"
  2143. },
  2144. {
  2145. name: "Fighter",
  2146. ratio: 80 / 42,
  2147. color: "orange"
  2148. },
  2149. {
  2150. name: "Booster",
  2151. ratio: 70 / 42,
  2152. color: "green"
  2153. },
  2154. {
  2155. name: "Tank",
  2156. ratio: 95 / 42,
  2157. color: "yellow"
  2158. },
  2159. {
  2160. name: "Sniper",
  2161. ratio: 110 / 42,
  2162. color: "yellow"
  2163. },
  2164. {
  2165. name: "Ranger",
  2166. ratio: 120 / 42,
  2167. color: "orange"
  2168. },
  2169. {
  2170. name: "Hunter",
  2171. ratio: 95 / 56.7,
  2172. color: "orange"
  2173. },
  2174. {
  2175. name: "Predator",
  2176. ratio: 80 / 71.4,
  2177. color: "darkorange"
  2178. },
  2179. {
  2180. name: "Mega Trapper",
  2181. ratio: 60 / 54.6,
  2182. color: "red"
  2183. },
  2184. {
  2185. name: "Trapper",
  2186. ratio: 60 / 42,
  2187. color: "orange"
  2188. },
  2189. {
  2190. name: "Gunner Trapper",
  2191. ratio: 95 / 26.6,
  2192. color: "yellow"
  2193. },
  2194. {
  2195. name: "Predator",
  2196. ratio: 95 / 84.8,
  2197. color: "red"
  2198. },
  2199. {
  2200. name: "Gunner(small)",
  2201. ratio: 65 / 25.2,
  2202. color: "lightgreen"
  2203. },
  2204. {
  2205. name: "Gunner(big)",
  2206. ratio: 85 / 25.2,
  2207. color: "green"
  2208. },
  2209. {
  2210. name: "Spread1",
  2211. ratio: 89 / 29.4,
  2212. color: "orange"
  2213. },
  2214. {
  2215. name: "Spread2",
  2216. ratio: 83 / 29.4,
  2217. color: "orange"
  2218. },
  2219. {
  2220. name: "Spread3",
  2221. ratio: 71 / 29.4,
  2222. color: "orange"
  2223. },
  2224. {
  2225. name: "Spread4",
  2226. ratio: 65 / 29.4,
  2227. color: "orange"
  2228. },
  2229. //{name: "bullet", ratio: 1, color: "pink"},
  2230. ];
  2231.  
  2232. function drawTheThing(x, y, r, index) {
  2233. if (toggleButtons.Visual['Toggle Aim Lines']) {
  2234. if (TurretRatios[index].name != "bullet") {
  2235. ctx.strokeStyle = TurretRatios[index].color;
  2236. ctx.lineWidth = 5;
  2237.  
  2238. let extendedR = 300 * scalingFactor;
  2239.  
  2240. // Reverse the angle to switch the direction
  2241. const reversedAngle = -angle;
  2242.  
  2243. // Calculate the end point of the line
  2244. const endX = x + extendedR * Math.cos(reversedAngle);
  2245. const endY = y + extendedR * Math.sin(reversedAngle);
  2246.  
  2247. // Draw the line
  2248. ctx.beginPath();
  2249. ctx.moveTo(x, y);
  2250. ctx.lineTo(endX, endY);
  2251. ctx.stroke();
  2252.  
  2253. // Draw text at the end of the line
  2254. ctx.font = "20px Arial";
  2255. ctx.fillStyle = TurretRatios[index].color;
  2256. ctx.strokeStyle = "black";
  2257. ctx.strokeText(TurretRatios[index].name, endX, endY);
  2258. ctx.fillText(TurretRatios[index].name, endX, endY);
  2259. ctx.beginPath();
  2260. } else {
  2261. ctx.strokeStyle = TurretRatios[index].color;
  2262. ctx.lineWidth = 5;
  2263.  
  2264. // Draw text at the end of the line
  2265. ctx.font = "15px Arial";
  2266. ctx.fillStyle = TurretRatios[index].color;
  2267. ctx.strokeStyle = "black";
  2268. let tankRadiusesTrans = [];
  2269. for (let i = 1; i <= 45; i++) {
  2270. let value = Math.abs((48.589 * (1.01 ** (i - 1))) * Math.abs(scalingFactor).toFixed(4)).toFixed(3);
  2271. tankRadiusesTrans.push(value);
  2272. }
  2273.  
  2274. let r_abs = Math.abs(r).toFixed(3);
  2275. if (r_abs < tankRadiusesTrans[0]) {
  2276. ctx.beginPath();
  2277. ctx.strokeStyle = TurretRatios[index].color;
  2278. ctx.arc(x, y - r / 2, r * 2, 0, 2 * Math.PI);
  2279. ctx.stroke();
  2280. ctx.beginPath();
  2281. } else {
  2282.  
  2283. // Find the closest value in the array
  2284. let closestValue = tankRadiusesTrans.reduce((prev, curr) => {
  2285. return (Math.abs(curr - r_abs) < Math.abs(prev - r_abs) ? curr : prev);
  2286. });
  2287.  
  2288. // Find the index of the closest value
  2289. let closestIndex = tankRadiusesTrans.indexOf(closestValue);
  2290.  
  2291. if (closestIndex !== -1) {
  2292. let r_name = `Level ${closestIndex + 1}`;
  2293. ctx.strokeText(r_name, x, y + 50 * scalingFactor);
  2294. ctx.fillText(r_name, x, y + 50 * scalingFactor);
  2295. ctx.beginPath();
  2296. } else {
  2297.  
  2298. let r_name = `radius: ${Math.abs(r).toFixed(4)} 1: ${tankRadiusesTrans[0]} 2: ${tankRadiusesTrans[1]} 3: ${tankRadiusesTrans[2]}`;
  2299. ctx.strokeText(r_name, x, y);
  2300. ctx.fillText(r_name, x, y);
  2301. ctx.beginPath();
  2302. }
  2303. /*
  2304. ctx.strokeText(TurretRatios[index].name, x, y);
  2305. ctx.fillText(TurretRatios[index].name, x, y);
  2306. */
  2307. }
  2308. }
  2309. }
  2310. }
  2311.  
  2312. var angle, a, b, width;
  2313. let perm_cont = [];
  2314.  
  2315. CanvasRenderingContext2D.prototype.setTransform = new Proxy(CanvasRenderingContext2D.prototype.setTransform, {
  2316. apply(target, thisArgs, args) {
  2317. // Check if the ratio matches the specified conditions
  2318. let l = TurretRatios.length;
  2319. for (let i = 0; i < l; i++) {
  2320. if (Math.abs(args[0] / args[3]).toFixed(3) == (TurretRatios[i].ratio).toFixed(3)) {
  2321. if (TurretRatios[i].name === "bullet") {
  2322. if (args[0] != 1 && args[0] > 10 && args[0] < 100 && args[4] > 1 && args[5] > 1 && args[4] != args[5] &&
  2323. thisArgs.globalAlpha != 0.10000000149011612 && thisArgs.globalAlpha != 0.3499999940395355) {
  2324. if (!perm_cont.includes(thisArgs)) {
  2325. perm_cont.push(thisArgs);
  2326. //console.log(perm_cont);
  2327. }
  2328. angle = Math.atan2(args[2], args[3]) || 0;
  2329. width = Math.hypot(args[3], args[2]);
  2330. a = args[4] - Math.cos(angle + Math.PI / 2) * width / 2;
  2331. b = args[5] + Math.sin(angle + Math.PI / 2) * width / 2;
  2332. //console.log(b);
  2333. if (a > 0 && b > 0 && thisArgs.fillStyle != "#1B1B1B") { //OUTLINE COLOR
  2334. drawTheThing(a, b, Math.hypot(args[3], args[2]), i);
  2335. }
  2336. }
  2337. } else {
  2338. angle = Math.atan2(args[2], args[3]) || 0;
  2339. width = Math.hypot(args[3], args[2]);
  2340. a = args[4] - Math.cos(angle + Math.PI / 2) * width / 2;
  2341. b = args[5] + Math.sin(angle + Math.PI / 2) * width / 2;
  2342. drawTheThing(a, b, Math.hypot(args[3], args[2]), i);
  2343. }
  2344. }
  2345. }
  2346. return Reflect.apply(target, thisArgs, args);
  2347. }
  2348. });
  2349.  
  2350. const ms_fps_clrs = ["lime", "green", "yellow", "orange", "darkorange", "red", "darkred"];
  2351. const ms_filters = new Uint16Array([15, 26, 50, 90, 170, 380, 1000]);
  2352. const fps_filters = new Uint16Array([59, 55, 50, 35, 20, 10, 5]);
  2353.  
  2354. function pick_fps_color(){
  2355. let fps_num = parseFloat(fps);
  2356. let l = fps_filters.length;
  2357. for(let i = 0; i<l; i++){
  2358. if(fps_num > fps_filters[i]){
  2359. ctx_text(ms_fps_clrs[i], "black", 4, 1 + "em Ubuntu", fps+"fps", canvas.width/2, canvas.height/2);
  2360. return;
  2361. }
  2362. }
  2363. }
  2364.  
  2365. function pick_ms_color(){
  2366. let ms_num = parseFloat(ms);
  2367. for(let i = 0; i<ms_filters.length; i++){
  2368. if(ms_num < ms_filters[i]){
  2369. ctx_text(ms_fps_clrs[i], "black", 4, 1 + "em Ubuntu", ms+"ms", canvas.width/2, canvas.height/2 + 20);
  2370. return;
  2371. }
  2372. }
  2373. }
  2374.  
  2375. setTimeout(() => {
  2376. let gui = () => {
  2377. check_addon_scripts();
  2378. if (state === "in game") {
  2379. if(ms_active){
  2380. pick_fps_color();
  2381. pick_ms_color();
  2382. }
  2383. if (toggleButtons.Visual['Toggle Minimap']) {
  2384. draw_minimap();
  2385. }
  2386. if (toggleButtons.Addons['Toggle Base Zones']) {
  2387. toggleButtons.Visual['Toggle Minimap'] = true;
  2388. alert_about_drones();
  2389. }
  2390. if (script_list.minimap_leader_v2) {
  2391. if (toggleButtons.Addons['Toggle Leader Angle']) {
  2392. if (!script_list.minimap_leader_v2) {
  2393. new_notification("missing Leader & Minimap Arrow(Mi300)", rgbToNumber(...notification_rbgs.require), 5000);
  2394. }
  2395. if (!toggleButtons.Visual['Toggle Minimap']) {
  2396. new_notification("Enabled Minimap for it to work properly. To turn it off, go to Visual -> Minimap", rgbToNumber(...notification_rbgs.normal), 5000);
  2397. toggleButtons.Visual['Toggle Minimap'] = true;
  2398. } else {
  2399. calc_leader();
  2400. apply_vector_on_minimap();
  2401. }
  2402. }
  2403. }
  2404. if (toggleButtons.Debug['Toggle Arrow pos']) {
  2405. window.arrowv2_debug = true;
  2406. } else {
  2407. window.arrowv2_debug = false;
  2408. }
  2409. if (script_list.set_transform_debug) {
  2410. ctx_arc(window.crx_container[2], window.crx_container[3], 50, 0, 2 * Math.PI, false, "yellow");
  2411. }
  2412. if (toggleButtons.Debug['Toggle Text']) {
  2413. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "canvas Lvl:" + player.level, canvas.width / 20 + 10, text_startingY + (textAdd * 0));
  2414. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "canvas tank: " + player.tank, canvas.width / 20 + 10, text_startingY + (textAdd * 1));
  2415. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "radius: " + ripsaw_radius, canvas.width / 20 + 10, text_startingY + (textAdd * 2));
  2416. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "scaling Factor: " + scalingFactor, canvas.width / 20 + 10, text_startingY + (textAdd * 3));
  2417. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "diep Units: " + diepUnits, canvas.width / 20 + 10, text_startingY + (textAdd * 4));
  2418. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "Fov: " + FOV, canvas.width / 20 + 10, text_startingY + (textAdd * 5));
  2419. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "current Tick: " + currentTick, canvas.width / 20 + 10, text_startingY + (textAdd * 6));
  2420. 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));
  2421. //ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "realX: " + uwuX + "realY: " + uwuY + "newX: " + uwuX*windowScaling() + "newY: " + uwuY*windowScaling(), uwuX*2, uwuY*2);
  2422.  
  2423. //points at mouse
  2424. ctx_arc(uwuX * two, uwuY * two, 5, 0, 2 * Math.PI, false, "purple");
  2425. /*
  2426. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 35, "pink");
  2427. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 55, "yellow");
  2428. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 75, "purple");
  2429. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 200, "blue");
  2430. */
  2431.  
  2432. //coords at mouse
  2433. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "realX: " + uwuX * two + "realY: " + uwuY * two, uwuX * two, uwuY * two);
  2434. }
  2435.  
  2436. if (player.level != null && player.tank != null) {
  2437. if (toggleButtons.Debug['Toggle Middle Circle']) {
  2438. ctx.beginPath();
  2439. ctx.moveTo(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY);
  2440. ctx.lineTo(uwuX * two, uwuY * two);
  2441. ctx.stroke();
  2442. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius, 0, 2 * Math.PI, false, "darkblue");
  2443. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius * 0.9, 0, 2 * Math.PI, false, "lightblue");
  2444. }
  2445. if (toggleButtons.Debug['Toggle Upgrades']) {
  2446. draw_upgrade_grid();
  2447. }
  2448. //draw_server_border(4000, 2250);
  2449. draw_crx_events();
  2450. if (toggleButtons.Visual['Toggle Bullet Distance']) {
  2451. draw_cirle_radius_for_tank();
  2452. }
  2453. };
  2454. }
  2455. window.requestAnimationFrame(gui);
  2456. }
  2457. gui();
  2458. setTimeout(() => {
  2459. gui();
  2460. }, 5000);
  2461. }, 1000);
  2462.  
  2463. // Alert players about missing scripts (for addons)
  2464. let notified = {};
  2465.  
  2466. function require(category, toggleButton, script) {
  2467. if (state === "in game") {
  2468. const notificationKey = `${category}-${toggleButton}-${script}`;
  2469. if (toggleButtons[category]?.[toggleButton] && !script_list[script] && !notified[notificationKey]) {
  2470. new_notification(`${toggleButton} requires ${script} to be active!`, rgbToNumber(...notification_rbgs.require), 7500);
  2471. notified[notificationKey] = true;
  2472. }
  2473. }
  2474. }
  2475.  
  2476. function check_addon_scripts() {
  2477. require('Addons', 'Change Leader Arrow Color', 'minimap_leader_v2');
  2478. require('Addons', 'Toggle Leader Angle', 'minimap_leader_v2');
  2479. require('Addons', 'Toggle Base Zones', 'minimap_leader_v2');
  2480. require('Addons', 'FOV changer', 'fov');
  2481. }
  2482.  
  2483.  
  2484. //game ticks finder
  2485. let clearRect_count = 0;
  2486.  
  2487. // Tick tracking
  2488. let currentTick = 0;
  2489. const tickQueue = [];
  2490. const everyTickFunctions = [];
  2491.  
  2492. function runEveryTick(callback) {
  2493. everyTickFunctions.push(callback);
  2494. }
  2495.  
  2496. CanvasRenderingContext2D.prototype.clearRect = new Proxy(CanvasRenderingContext2D.prototype.clearRect, {
  2497. apply(target, thisArg, argumentsList) {
  2498. clearRect_count += 1;
  2499. currentTick = Math.floor(clearRect_count / 6);
  2500. processTickQueue();
  2501. everyTickFunctions.forEach(func => func(currentTick));
  2502. return target.apply(thisArg, argumentsList);
  2503. }
  2504. });
  2505.  
  2506. function scheduleAfterTicks(callback, ticksToWait) {
  2507. const executionTick = currentTick + ticksToWait;
  2508. tickQueue.push({
  2509. callback,
  2510. executionTick
  2511. });
  2512. }
  2513.  
  2514. function processTickQueue() {
  2515. let l = tickQueue.length;
  2516. while (l > 0 && tickQueue[0].executionTick <= currentTick) {
  2517. const item = tickQueue.shift();
  2518. item.callback();
  2519. }
  2520. }
  2521.  
  2522. // Function to run code for a specified number of ticks
  2523. function runForTicks(callback, totalTicks) {
  2524. const startingTick = currentTick;
  2525. let ticksPassed = 0;
  2526.  
  2527. function tickHandler() {
  2528. if (ticksPassed < totalTicks) {
  2529. callback(ticksPassed, currentTick);
  2530. ticksPassed++;
  2531. scheduleAfterTicks(tickHandler, 1);
  2532. }
  2533. }
  2534.  
  2535. tickHandler(); // Start the process
  2536. }
  2537.  
  2538. // Example usage:
  2539. function test() {
  2540. console.log("Starting test at tick:", currentTick);
  2541.  
  2542. scheduleAfterTicks(() => {
  2543. console.log("150 ticks have passed, current tick:", currentTick);
  2544. // Add your code here
  2545. }, 150);
  2546. }
  2547.  
  2548. function testLoop() {
  2549. console.log("Starting testLoop at tick:", currentTick);
  2550. runForTicks((ticksPassed, currentTick) => {
  2551. console.log(`Tick passed: ${ticksPassed}, Current tick: ${currentTick}`);
  2552. // Add any other code you want to run each tick
  2553. }, 50);
  2554. }
  2555.  
  2556. //cooldowns (unfinished)
  2557. let c_cd = "red";
  2558. let c_r = "green";
  2559. const cooldowns = [
  2560. {
  2561. Tank: "Destroyer",
  2562. cooldown0: 109,
  2563. cooldown1: 94,
  2564. cooldown2: 81,
  2565. cooldown3: 86
  2566. },
  2567. ]
  2568.  
  2569. //detect which slot was clicked
  2570. document.addEventListener('mousedown', checkPos)
  2571.  
  2572. function checkPos(e) {
  2573. console.log(currentTick);
  2574. console.log(boxes[selected_box]);
  2575. }
  2576.  
  2577.  
  2578. //warns you about annis, destroyers
  2579. /*
  2580. function drawTheThing(x,y,r) {
  2581. if(script_boolean){
  2582. let a = ctx.fillStyle;
  2583. ctx.fillStyle = "#FF000044";
  2584. ctx.beginPath();
  2585. ctx.arc(x,y,4*r,0,2*Math.PI);
  2586. ctx.fill();
  2587. ctx.fillStyle = "#FF000066";
  2588. ctx.beginPath();
  2589. ctx.arc(x,y,2*r,0,2*Math.PI);
  2590. ctx.fill();
  2591. ctx.beginPath();
  2592. }
  2593. }
  2594. var angle,a,b,width;
  2595. CanvasRenderingContext2D.prototype.setTransform = new Proxy(CanvasRenderingContext2D.prototype.setTransform, {
  2596. apply(target, thisArgs, args) {
  2597. //console.log(thisArgs)
  2598. 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)) {
  2599. angle = Math.atan2(args[2],args[3]) || 0;
  2600. width = Math.hypot(args[3], args[2]);
  2601. a = args[4]-Math.cos(angle+Math.PI/2)*width/2;
  2602. b = args[5]+Math.sin(angle+Math.PI/2)*width/2;
  2603. drawTheThing(a,b, Math.hypot(args[3],args[2]));
  2604. }
  2605. return Reflect.apply(target, thisArgs, args);
  2606. }
  2607. });
  2608. */
  2609.  
  2610. //physics for movement (UNFINISHED)
  2611. /*
  2612. //movement speed ingame stat
  2613. let m_s = [0, 1, 2, 3, 4, 5, 6, 7];
  2614.  
  2615. function accelarate(A_o){
  2616. //Accelaration
  2617. let sum = 0;
  2618. runForTicks((ticksPassed, currentTick) => {
  2619. console.log("sum is being calculated...");
  2620. sum += A_o * Math.pow(0.9, ticksPassed - 1);
  2621. offsetX = Math.floor(sum * scalingFactor);
  2622. console.log(offsetX);
  2623. }, 50);
  2624. //decelerate(sum);
  2625. }
  2626.  
  2627. function decelerate(sum){
  2628. //deceleration
  2629. let res = 0;
  2630. runForTicks((ticksPassed, currentTick) => {
  2631. console.log("res is being calculated...");
  2632. res = sum * Math.pow(0.9, ticksPassed);
  2633. offsetX = Math.floor(res * scalingFactor);
  2634. console.log(offsetX);
  2635. }, 50);
  2636. }
  2637. function calculate_speed(movement_speed_stat){
  2638. console.log("calculate_speed function called");
  2639. //use Accelaration for first 50 ticks, then deceleration until ticks hit 100, then stop moving
  2640.  
  2641. //calculating base value, we'll need this later
  2642. let a = (1.07**movement_speed_stat);
  2643. let b = (1.015**(player.level - 1));
  2644. let A_o = 2.55*(a/b);
  2645. accelarate(A_o);
  2646. }
  2647. */
  2648.  
  2649. //handle Key presses
  2650. let key_storage = [];
  2651. let keyHeld = {};
  2652.  
  2653. document.onkeydown = function (e) {
  2654. if (!keyHeld[e.key]) {
  2655. keyHeld[e.key] = true;
  2656. key_storage.push(e.key);
  2657. analyse_keys();
  2658. }
  2659. console.log(key_storage);
  2660. };
  2661.  
  2662. document.onkeyup = function (e) {
  2663. if (key_storage.includes(e.key)) {
  2664. key_storage.splice(key_storage.indexOf(e.key), 1);
  2665. }
  2666. keyHeld[e.key] = false;
  2667. console.log(key_storage);
  2668. analyse_keys();
  2669. };
  2670.  
  2671. function analyse_keys() {
  2672. if (key_storage.includes("j")) { //J
  2673. change_visibility();
  2674. //auto spin && auto fire
  2675. } else if (key_storage.includes("l")){
  2676. ms_active = !ms_active;
  2677. } else if (key_storage.includes("e")) { //E
  2678. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  2679. f_s("fire");
  2680. } else {
  2681. auto_fire = false;
  2682. }
  2683. console.log(auto_fire);
  2684. } else if (key_storage.includes("c")) {
  2685. console.log(auto_spin);
  2686. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  2687. f_s("spin");
  2688. } else {
  2689. auto_spin = false;
  2690. }
  2691. console.log(auto_spin);
  2692. //stats
  2693. } else if (toggleButtons.Functional['Stats']) {
  2694. if (key_storage.includes("u")) {
  2695. if (key_storage.includes("r")) {
  2696. reset_stats();
  2697. }
  2698. if (!document.body.contains(upgrade_box)) {
  2699. document.body.appendChild(upgrade_box);
  2700. }
  2701. update_stats();
  2702. if (stats_limit >= 0) {
  2703. for (let i = 1; i < 9; i++) {
  2704. if (key_storage.includes(`${i}`) && stats[i] < 7) {
  2705. stats[i] += 1;
  2706. stats_limit -= 1;
  2707. }
  2708. }
  2709. }
  2710. } else {
  2711. if (document.body.contains(upgrade_box)) {
  2712. document.body.removeChild(upgrade_box);
  2713. }
  2714. use_stats_ingame();
  2715. }
  2716. }
  2717. }
  2718.  
  2719. //stats handler
  2720. var stats_instructions_showed = false;
  2721. function show_stats_instructions(){
  2722. if(toggleButtons.Functional['Stats']){
  2723. input.execute("ren_stats false");
  2724. if(!stats_instructions_showed){
  2725. if(state === "in game"){
  2726. use_stats_ingame();
  2727. new_notification("Usage: hold 'u' button and then press a number between 1 and 9", rgbToNumber(...notification_rbgs.normal), 5000);
  2728. new_notification("Explanation: this module lets you choose a tank build that will stay even after you die", rgbToNumber(...notification_rbgs.normal), 5100);
  2729. new_notification("unless you press r while pressing u", rgbToNumber(...notification_rbgs.normal), 5200);
  2730. stats_instructions_showed = true;
  2731. }
  2732. }else{
  2733. if(state === "in menu"){
  2734. stats_instructions_showed = false;
  2735. }
  2736. }
  2737. }else{
  2738. input.execute("ren_stats true");
  2739. }
  2740. }
  2741.  
  2742. setInterval(show_stats_instructions, 500);
  2743. let stats = ["don't use this", 0, 0, 0, 0, 0, 0, 0, 0];
  2744. let stats_limit = 32;
  2745.  
  2746. function update_stats() {
  2747. let l = stats.length;
  2748. for (let i = 1; i < l; i++) {
  2749. let stat_steps = stats[i];
  2750. for (let j = 1; j < stat_steps + 1; j++) {
  2751. let stat_row = document.querySelector(`#row${[i]} > #s_box${j}`);
  2752. stat_row.style.backgroundColor = `${upgrade_name_colors[i]}`;
  2753. }
  2754. }
  2755. }
  2756.  
  2757. function reset_stats() {
  2758. let l = stats.length;
  2759. for (let i = 1; i < l; i++) {
  2760. let stat_steps = stats[i];
  2761. for (let j = 1; j < stat_steps + 1; j++) {
  2762. let stat_row = document.querySelector(`#row${[i]} > #s_box${j}`);
  2763. stat_row.style.backgroundColor = "black";
  2764. }
  2765. }
  2766. stats = ["don't use this", 0, 0, 0, 0, 0, 0, 0, 0];
  2767. stats_limit = 32;
  2768. }
  2769.  
  2770. function use_stats_ingame() {
  2771. let final_decision = "";
  2772. for (let i = 5; i < 9; i++) {
  2773. for (let j = 0; j < stats[i]; j++) {
  2774. final_decision += `${i}`;
  2775. }
  2776. }
  2777. for (let i = 1; i < 5; i++) {
  2778. for (let j = 0; j < stats[i]; j++) {
  2779. final_decision += `${i}`;
  2780. }
  2781. }
  2782. input.execute(`game_stats_build ${final_decision}`);
  2783. }
  2784.  
  2785. const upgrade_names = [
  2786. "don't use this",
  2787. "Health Regen",
  2788. "Max Health",
  2789. "Body Damage",
  2790. "Bullet Speed",
  2791. "Bullet Penetration",
  2792. "Bullet Damage",
  2793. "Reload",
  2794. "Movement Speed",
  2795. ];
  2796.  
  2797. const upgrade_name_colors = [
  2798. "don't use this",
  2799. "DarkSalmon",
  2800. "pink",
  2801. "DarkViolet",
  2802. "DodgerBlue",
  2803. "yellow",
  2804. "red",
  2805. "lime",
  2806. "lightblue",
  2807. ];
  2808.  
  2809. const upgrade_box = document.createElement("div");
  2810. upgrade_box.style.width = "400px";
  2811. upgrade_box.style.height = "300px";
  2812. upgrade_box.style.backgroundColor = "lightGray";
  2813. upgrade_box.style.position = "fixed";
  2814. upgrade_box.style.display = "block";
  2815. upgrade_box.style.bottom = "10px";
  2816. upgrade_box.style.zIndex = 100;
  2817.  
  2818. for (let i = 1; i < 9; i++) {
  2819. create_upgrades(`row${i}`, i);
  2820. }
  2821.  
  2822. function create_upgrades(name, rownum) {
  2823. let black_box = document.createElement("div");
  2824. black_box.id = name;
  2825. black_box.style.width = "350px";
  2826. black_box.style.height = "20px";
  2827. black_box.style.position = "relative";
  2828. black_box.style.display = "block";
  2829. black_box.style.marginTop = "15px";
  2830. black_box.style.left = "25px";
  2831. for (let i = 1; i < 8; i++) {
  2832. let small_box = document.createElement("div");
  2833. small_box.id = `s_box${i}`;
  2834. small_box.style.width = "20px";
  2835. small_box.style.height = "20px";
  2836. small_box.style.backgroundColor = "black";
  2837. small_box.style.display = "inline-block";
  2838. small_box.style.border = "2px solid white";
  2839.  
  2840. black_box.appendChild(small_box);
  2841. }
  2842. let upgrade_btn = document.createElement("button");
  2843. upgrade_btn.id = upgrade_names[rownum];
  2844. upgrade_btn.style.color = "black";
  2845. upgrade_btn.innerHTML = "+";
  2846. upgrade_btn.style.width = "20px";
  2847. upgrade_btn.style.height = "20px";
  2848. upgrade_btn.style.backgroundColor = upgrade_name_colors[rownum];
  2849. upgrade_btn.style.display = "inline-block";
  2850. upgrade_btn.style.border = "2px solid black";
  2851. upgrade_btn.style.cursor = "pointer";
  2852. black_box.appendChild(upgrade_btn);
  2853.  
  2854. let text_el = document.createElement("h3");
  2855. text_el.innerText = `[${rownum}] ${upgrade_names[rownum]}`;
  2856. text_el.style.fontSize = "15px";
  2857. text_el.style.display = "inline-block";
  2858. black_box.appendChild(text_el);
  2859. upgrade_box.appendChild(black_box);
  2860. }
  2861. // Handle key presses for moving the center (UNFINISHED)
  2862.  
  2863. /*
  2864. function return_to_center(XorY, posOrNeg){
  2865. console.log("function called with: " + XorY + posOrNeg);
  2866. if(XorY === "x"){
  2867. if(posOrNeg === "pos"){
  2868. while(offsetX < 0){
  2869. offsetX += 0.5*scalingFactor;
  2870. }
  2871. }else if(posOrNeg === "neg"){
  2872. while(offsetX > 0){
  2873. offsetX -= 0.5*scalingFactor;
  2874. }
  2875. }else{
  2876. console.log("invalid posOrNeg at return_to_center();")
  2877. }
  2878. }else if(XorY === "y"){
  2879. if(posOrNeg === "pos"){
  2880. while(offsetY < 0){
  2881. offsetY += 0.5*scalingFactor;
  2882. }
  2883. }else if(posOrNeg === "neg"){
  2884. while(offsetY > 0){
  2885. offsetY -= 0.5*scalingFactor;
  2886. }
  2887. }else{
  2888. console.log("invalid posOrNeg at return_to_center();")
  2889. }
  2890. }else{
  2891. console.log("invalid XorY at return_to_center();");
  2892. }
  2893. }
  2894.  
  2895. document.onkeydown = function(e) {
  2896. switch (e.keyCode) {
  2897. case 87: // 'W' key
  2898. console.log("W");
  2899. if(offsetY >= -87.5*scalingFactor){
  2900. offsetY -= 12.5*scalingFactor;
  2901. }
  2902. break
  2903. case 83: // 'S' key
  2904. console.log("S");
  2905. if(offsetY <= 87.5*scalingFactor){
  2906. offsetY += 12.5*scalingFactor;
  2907. }
  2908. break;
  2909. case 68: // 'D' key
  2910. console.log("D");
  2911. if(offsetX <= 87.5*scalingFactor){
  2912. offsetX += 12.5*scalingFactor;
  2913. }
  2914. break
  2915. case 65: // 'A' key
  2916. console.log("A");
  2917. if(offsetX >= -87.5*scalingFactor){
  2918. offsetX -= 12.5*scalingFactor;
  2919. }
  2920. break
  2921. }
  2922. }
  2923.  
  2924. document.onkeyup = function(e) {
  2925. switch (e.keyCode) {
  2926. case 87: // 'W' key
  2927. console.log("W unpressed");
  2928. return_to_center("y", "pos");
  2929. break
  2930. case 83: // 'S' key
  2931. console.log("S unpressed");
  2932. return_to_center("y", "neg");
  2933. break;
  2934. case 68: // 'D' key
  2935. console.log("D unpressed");
  2936. return_to_center("x", "neg");
  2937. break
  2938. case 65:
  2939. console.log("A unpressed");
  2940. return_to_center("x", "pos");
  2941. }
  2942. }
  2943. */