Diep.io+ (minor changes)

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

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