Diep.io+ (added FOV to addons)

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

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