Diep.io+ (added stats + stats GUI)

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

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