Diep.io+ (added Auto ui scale & modified menu)

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

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