Diep.io+ (GUI update + Tank lines)

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

  1. // ==UserScript==
  2. // @name Diep.io+ (GUI update + Tank lines)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.0.0.1
  5. // @description autorespawn(auto ad watcher with 2min timer), leader arrow + minimap arrow, FOV & diepUnits & windowScaling() calculator, Factory controls overlay, bullet distance (FOR EVERY BULLET SPEED BUILD) of 75% tanks, copy party link, leave game, no privacy settings button, no apes.io advertisment, net_predict_movement false
  6. // @author r!PsAw
  7. // @match https://diep.io/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=diep.io
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. //!!!WARNING!!! Ui scale has to be at 0.9x for this script to work//
  14. let ingamescreen = document.getElementById("in-game-screen");
  15.  
  16. //GUI
  17. const container = document.createElement('div');
  18. container.style.position = 'fixed';
  19. container.style.top = '10px';
  20. container.style.left = '75px';
  21. container.style.padding = '15px';
  22. container.style.backgroundImage = 'linear-gradient(#ffffff, #79c7ff)';
  23. container.style.color = 'white';
  24. container.style.borderRadius = '10px';
  25. container.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
  26. container.style.minWidth = '200px';
  27. container.style.zIndex = '10';
  28.  
  29. const title = document.createElement('h1');
  30. title.textContent = 'Diep.io+ (hide with J)';
  31. title.style.margin = '0 0 5px 0';
  32. title.style.fontSize = '24px';
  33. title.style.textAlign = 'center';
  34. title.style.color = '#fb2a7b';
  35. title.style.zIndex = '11';
  36. container.appendChild(title);
  37.  
  38. const subtitle = document.createElement('h3');
  39. subtitle.textContent = 'made by r!PsAw';
  40. subtitle.style.margin = '0 0 15px 0';
  41. subtitle.style.fontSize = '14px';
  42. subtitle.style.textAlign = 'center';
  43. subtitle.style.color = '#6fa8dc';
  44. subtitle.style.zIndex = '11';
  45. container.appendChild(subtitle);
  46.  
  47. const categories = ['Debug', 'Visual', 'Functional'];
  48. const categoryButtons = {};
  49. const categoryContainer = document.createElement('div');
  50. categoryContainer.style.display = 'flex';
  51. categoryContainer.style.justifyContent = 'space-between';
  52. categoryContainer.style.marginBottom = '15px';
  53. categoryContainer.style.zIndex = '12';
  54.  
  55. categories.forEach(category => {
  56. const button = document.createElement('button');
  57. button.textContent = category;
  58. button.style.flex = '1';
  59. button.style.padding = '8px';
  60. button.style.margin = '0 5px';
  61. button.style.cursor = 'pointer';
  62. button.style.border = 'none';
  63. button.style.borderRadius = '5px';
  64. button.style.backgroundColor = '#0000ff';
  65. button.style.color = 'white';
  66. button.style.transition = 'background-color 0.3s';
  67. button.style.zIndex = '13';
  68.  
  69. button.addEventListener('mouseover', () => {
  70. button.style.backgroundColor = '#0000ff';
  71. });
  72. button.addEventListener('mouseout', () => {
  73. button.style.backgroundColor = '#fb2a7b';
  74. });
  75.  
  76. categoryContainer.appendChild(button);
  77. categoryButtons[category] = button;
  78. });
  79.  
  80. container.appendChild(categoryContainer);
  81.  
  82. const contentArea = document.createElement('div');
  83. contentArea.style.marginTop = '15px';
  84. contentArea.style.zIndex = '12';
  85. container.appendChild(contentArea);
  86.  
  87. const toggleButtons = {
  88. Debug: {
  89. 'Toggle Text': false,
  90. 'Toggle Middle Circle': false,
  91. 'Toggle Upgrades': false
  92. },
  93. Visual: {
  94. 'Toggle Aim Lines': false,
  95. 'Toggle Bullet Distance': false,
  96. 'Toggle Minimap': false,
  97. 'Toggle Leader Angle': false
  98. },
  99. Functional: {
  100. 'Auto Respawn': false,
  101. 'Toggle Leave Button': false
  102. }
  103. };
  104.  
  105. function createToggleButton(text, initialState) {
  106. const button = document.createElement('button');
  107. button.textContent = text;
  108. button.style.display = 'block';
  109. button.style.width = '100%';
  110. button.style.marginBottom = '10px';
  111. button.style.padding = '8px';
  112. button.style.cursor = 'pointer';
  113. button.style.border = 'none';
  114. button.style.borderRadius = '5px';
  115. button.style.transition = 'background-color 0.3s';
  116. button.style.zIndex = '13'; // Increase z-index for each toggle button
  117. updateButtonColor(button, initialState);
  118.  
  119. button.addEventListener('click', () => {
  120. toggleButtons[currentCategory][text] = !toggleButtons[currentCategory][text];
  121. updateButtonColor(button, toggleButtons[currentCategory][text]);
  122. });
  123.  
  124. return button;
  125. }
  126.  
  127. function updateButtonColor(button, state) {
  128. if (state) {
  129. button.style.backgroundColor = '#63a5d4';
  130. button.style.color = 'white';
  131. } else {
  132. button.style.backgroundColor = '#a11a4e';
  133. button.style.color = 'white';
  134. }
  135. }
  136.  
  137. let currentCategory = '';
  138. function showCategory(category) {
  139. contentArea.innerHTML = '';
  140. currentCategory = category;
  141.  
  142. Object.keys(categoryButtons).forEach(cat => {
  143. if (cat === category) {
  144. categoryButtons[cat].style.backgroundColor = '#0000ff';
  145. } else {
  146. categoryButtons[cat].style.backgroundColor = '#fb2a7b';
  147. }
  148. });
  149.  
  150. if (category === 'Functional') {
  151. const copyLinkButton = document.createElement('button');
  152. copyLinkButton.textContent = 'Copy Party Link';
  153. copyLinkButton.style.display = 'block';
  154. copyLinkButton.style.width = '100%';
  155. copyLinkButton.style.marginBottom = '10px';
  156. copyLinkButton.style.padding = '8px';
  157. copyLinkButton.style.cursor = 'pointer';
  158. copyLinkButton.style.border = 'none';
  159. copyLinkButton.style.borderRadius = '5px';
  160. copyLinkButton.style.backgroundColor = '#2196F3';
  161. copyLinkButton.style.color = 'white';
  162. copyLinkButton.style.transition = 'background-color 0.3s';
  163. copyLinkButton.style.zIndex = '13';
  164.  
  165. copyLinkButton.addEventListener('mouseover', () => {
  166. copyLinkButton.style.backgroundColor = '#1E88E5';
  167. });
  168. copyLinkButton.addEventListener('mouseout', () => {
  169. copyLinkButton.style.backgroundColor = '#2196F3';
  170. });
  171.  
  172. copyLinkButton.addEventListener('click', () => {
  173. document.getElementById("copy-party-link").click();
  174. });
  175. contentArea.appendChild(copyLinkButton);
  176. }
  177.  
  178. Object.keys(toggleButtons[category]).forEach(text => {
  179. const button = createToggleButton(text, toggleButtons[category][text]);
  180. contentArea.appendChild(button);
  181. });
  182. }
  183.  
  184. Object.keys(categoryButtons).forEach(category => {
  185. categoryButtons[category].addEventListener('click', () => showCategory(category));
  186. });
  187.  
  188. document.body.appendChild(container);
  189. //visibility of gui
  190. let visibility_gui = true;
  191. function change_visibility(){
  192. visibility_gui = !visibility_gui;
  193. if(visibility_gui){
  194. container.style.display = 'block';
  195. } else {
  196. container.style.display = 'none';
  197. }
  198. }
  199.  
  200. //ui scale
  201.  
  202. let ui_scale = document.querySelector("#settings-modal > div > div:nth-child(1) > div > div:nth-child(1) > label > span")
  203. function ui_scale_check(){
  204. if(ui_scale.innerHTML != "-" && ui_scale.innerHTML != null && ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
  205. if(ui_scale.innerHTML != "0.9x"){
  206. input.inGameNotification("please change your ui_scale to 0.9x in Menu -> Settings");
  207. console.log(ui_scale.innerHTML);
  208. }else{
  209. console.log("no alert");
  210. }
  211. clearInterval(interval_for_ui_scale);
  212. }
  213. }
  214. let interval_for_ui_scale = setInterval(ui_scale_check, 0);
  215.  
  216. //check scripts
  217. let script_list = {
  218. minimap_leader_v1: null,
  219. minimap_leader_v2: null,
  220. fov: null,
  221. set_transform_debug: null,
  222. moveToLineTo_debug: null,
  223. gamemode_detect : null
  224. };
  225.  
  226. function check_ripsaw_scripts() {
  227. if (ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")) {
  228. script_list.minimap_leader_v1 = !!window.m_arrow;
  229. script_list.minimap_leader_v2 = !!window.M_X;
  230. script_list.fov = !!window.HEAPF32;
  231. script_list.set_transform_debug = !!window.crx_container;
  232. script_list.moveToLineTo_debug = !!window.y_and_x;
  233. script_list.gamemode_detect = !!window.gm;
  234. }
  235. }
  236. setInterval(check_ripsaw_scripts, 500);
  237.  
  238. //detect gamemode
  239. let gamemode;
  240. function check_gamemode (){
  241. if(script_list.gamemode_detect){
  242. gamemode = window.gm;
  243. }else{
  244. let gamemode_sel_btn = document.querySelector("#gamemode-selector > div > div.selected");
  245. switch(gamemode_sel_btn.getAttribute("value")){
  246. case "ffa":
  247. gamemode = "ffa";
  248. break
  249. case "teams":
  250. gamemode = "2tdm";
  251. break
  252. case "4teams":
  253. gamemode = "4tdm";
  254. break
  255. case "maze":
  256. gamemode = "maze";
  257. break
  258. case "event":
  259. gamemode = "mothership";
  260. break
  261. case "sandbox":
  262. gamemode = "sandbox";
  263. break
  264. }
  265. }
  266. }
  267.  
  268. setInterval(check_gamemode, 100);
  269.  
  270. //detect if dead or alive
  271. let state = "idk yet";
  272. function check_state(){
  273. switch(input.doesHaveTank()){
  274. case 0:
  275. state = "in menu";
  276. break
  277. case 1:
  278. state = "in game";
  279. break
  280. }
  281. }
  282.  
  283. setInterval(check_state, 100);
  284. //config
  285. var two = canvas.width/window.innerWidth;
  286. var debugboolean = false;
  287. var script_boolean = true;
  288.  
  289. // Mouse coordinates
  290. var uwuX = '0'; var uwuY = '0';
  291. document.addEventListener('mousemove', function(e) {
  292. uwuX = e.clientX;
  293. uwuY = e.clientY;
  294. });
  295.  
  296. //net_predict_movement false
  297. (function() {
  298. function applySettings() {
  299. input.execute("net_predict_movement false");
  300. }
  301.  
  302. function waitForGame() {
  303. if (window.input && input.execute) {
  304. applySettings();
  305. } else {
  306. setTimeout(waitForGame, 100);
  307. }
  308. }
  309. waitForGame();
  310. })();
  311.  
  312. //annoying html elements
  313. let ads_removed = false;
  314. function instant_remove() {
  315. let privacy_btn = document.getElementById("cmpPersistentLink");
  316. let apes_btn = document.getElementById("apes-io-promo");
  317. let discord_ad = document.querySelector("#apes-io-promo > img");
  318. let annoying = document.querySelector("#last-updated");
  319. if (privacy_btn) {
  320. privacy_btn.remove();
  321. }
  322.  
  323. if(annoying) {
  324. annoying.remove();
  325. }
  326.  
  327. if (apes_btn) {
  328. apes_btn.remove();
  329. }
  330.  
  331. if (discord_ad) {
  332. discord_ad.remove();
  333. }
  334.  
  335. if (!privacy_btn && !apes_btn && !discord_ad && !annoying) {
  336. console.log("removed buttons, quitting...");
  337. clearInterval(interval);
  338. }
  339. };
  340.  
  341. let interval = setInterval(instant_remove, 100);
  342.  
  343. //timer for bonus reward
  344. const gameOverScreen = document.getElementById('game-over-screen');
  345. const ad_btn = document.getElementById("game-over-video-ad");
  346. var ad_btn_free = true;
  347.  
  348. const timerDisplay = document.createElement('h1');
  349. timerDisplay.textContent = "Time left to collect next bonus levels: 02:00";
  350. gameOverScreen.appendChild(timerDisplay);
  351.  
  352. let timer;
  353. let totalTime = 120; // 2 minutes in seconds
  354.  
  355. function startTimer() {
  356. clearInterval(timer);
  357. timer = setInterval(function() {
  358. if (totalTime <= 0) {
  359. clearInterval(timer);
  360. timerDisplay.textContent = "00:00";
  361. } else {
  362. totalTime--;
  363. let minutes = Math.floor(totalTime / 60);
  364. let seconds = totalTime % 60;
  365. timerDisplay.textContent =
  366. `Time left to collect next bonus levels: ${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
  367. }
  368. }, 1000);
  369. }
  370.  
  371. function resetTimer() {
  372. if(totalTime === 0){
  373. clearInterval(timer);
  374. totalTime = 120; // Reset to 2 minutes
  375. timerDisplay.textContent = "02:00";
  376. }
  377. }
  378.  
  379. ad_btn.addEventListener('click', check_ad_state);
  380.  
  381. function check_ad_state(){
  382. if(totalTime === 0){
  383. resetTimer();
  384. }else if(totalTime === 120){
  385. ad_btn_free = true;
  386. startTimer();
  387. }else{
  388. ad_btn_free = false;
  389. }
  390. }
  391.  
  392. //autorespawn old method
  393.  
  394. /*
  395. let autorespawn = false;
  396.  
  397. function respawn(){
  398. if(toggleButtons.Functional['Auto Respawn']){
  399. if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
  400. return;
  401. }else{
  402. if(totalTime === 120 || totalTime === 0){
  403. ad_btn.click();
  404. }else{
  405. let spawnbtn = document.getElementById("spawn-button");
  406. spawnbtn.click();
  407. }
  408. }
  409. }
  410. }
  411.  
  412. setInterval(respawn, 1000);
  413. */
  414.  
  415. //autorespawn new method (no bonus level)
  416. function respawn(){
  417. if(toggleButtons.Functional['Auto Respawn']){
  418. if(state === "in menu"){
  419. let spawnbtn = document.getElementById("spawn-button");
  420. spawnbtn.click();
  421. }
  422. }
  423. }
  424.  
  425. setInterval(respawn, 1000);
  426. //toggle leave game
  427. let ingame_quit_btn = document.getElementById("quick-exit-game");
  428.  
  429. function check_class(){
  430. if(toggleButtons.Functional['Toggle Leave Button']){
  431. ingame_quit_btn.classList.remove("hidden");
  432. ingame_quit_btn.classList.add("shown");
  433. }else{
  434. ingame_quit_btn.classList.remove("shown");
  435. ingame_quit_btn.classList.add("hidden");
  436. }
  437. }
  438.  
  439. setInterval(check_class, 300);
  440.  
  441. //find the current Level (credits to abc)
  442. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  443. apply(fillRect, ctx, [text, x, y, ...blah]) {
  444. if (text.startsWith('Lvl ')) {
  445. currentLevel = text.split(' ')[1];
  446. if(text.split(' ')[3] != undefined){
  447. tanky = text.split(' ')[2] + text.split(' ')[3];
  448. }else{
  449. tanky = text.split(' ')[2]
  450. }
  451. }
  452. fillRect.call(ctx, text, x, y, ...blah);
  453. }
  454. });
  455.  
  456. //Detect AutoFire/AutoSpin
  457. let auto_fire = false;
  458. let auto_spin = false;
  459.  
  460. function f_s(f_or_s){
  461. switch (f_or_s){
  462. case "fire":
  463. auto_fire = !auto_fire;
  464. break
  465. case "spin":
  466. auto_spin = !auto_spin;
  467. break
  468. }
  469. }
  470. //Diep Units & fov calculator
  471. //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.
  472.  
  473. /*
  474. =============================================================================
  475. Skid & Noob friendly calculation explained:
  476.  
  477. Read this in order to understand, how the position calculation works.
  478.  
  479. 1. Canvas/window coords
  480. When you load diep.io in a browser window, it also loads a canvas where the game is drawn.
  481. 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.
  482. Diep.io uses canvas mainly. Your window and the canvas use different coordinate systems, even tho they appear the same at first:
  483.  
  484. start->x
  485. |
  486. \/
  487. y
  488.  
  489. if x is for example 3 and y is 5, you find the point of your mouse.
  490.  
  491. start->x...
  492. |_________|
  493. \/________|
  494. y_________|
  495. ._________|
  496. ._________|
  497. ._________|
  498. ._________|
  499. ._________HERE
  500.  
  501. the right upper corner of your window is the x limit, called window.innerWidth
  502. the left bottom corner of your window is the y limit, called window.innerHeight
  503.  
  504. canvas is the same, but multiplied by 2. So for x, it's canvas.height = window.innerHeight * 2
  505. same goes for y, canvas.width = window.innerWidth * 2
  506.  
  507. This can work the other way around too. canvas.height/2 = window.innerHeight
  508. and canvas.width/2 = window.innerWidth
  509.  
  510. NOTE: when you use input.mouse(x, y) you're using the canvas coordinate system.
  511.  
  512. 2. DiepUnits
  513. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  514. if you're curious about what l and Fv means, like I was I can tell you now.
  515.  
  516. L stands for your Tank level, that you currently have.
  517. Fv is the fieldFactor. You can find them here for each tank: https://github.com/ABCxFF/diepindepth/blob/main/extras/tankdefs.json
  518. (The formula from the picture as code: const FOV = (level, fieldFactor) => (.55*fieldFactor)/Math.pow(1.01, (level-1)/2); )
  519.  
  520. Additions:
  521. DiepUnits are used, to draw all entities in game in the right size. For example when you go Ranger, they appear smaller
  522. because your entire ingame map shrinks down, so you see more without changing the size of the canvas or the window.
  523. So if a square is 55 diepunits big and it gets visually smaller, it's still 55 diepunits big.
  524.  
  525. Coordinate system: x*scalingFactor, y*scalingFactor
  526.  
  527. IMPORTANT!!! Note that your Tank is getting additional DiepUnits with every level it grows.
  528. This formula descritbes it's growth
  529. 53 * (1.01 ** (currentLevel - 1));
  530.  
  531. 3. WindowScaling
  532. Read this first: https://github.com/ABCxFF/diepindepth/blob/main/canvas/scaling.md
  533. (you can use the function given in there, if you don't want to make your own)
  534.  
  535. it's used for all ui elements, like scoreboard, minimap or stats upgrades.
  536. NOTE: It's not used for html Elements, only canvas. So the starting menu or gameover screen aren't part of it.
  537.  
  538. Coordinate system: x*windowScaling(), y*windowScaling()
  539.  
  540. 4. Converting coordinate systems into each other
  541. canvas -> window = a/2 -> b
  542. window -> canvas = a*2 -> b
  543. windowScaling -> window = ( a*windowScaling() )/2 -> b
  544. windowScaling -> canvas = a*windowScaling() - > b
  545. diepUnits -> canvas = a/scalingFactor -> b
  546. diepUnits -> window = ( a/scalingFactor )/2 -> b
  547. window -> diepUnits = ( a*scalingFactor )*2 -> b
  548. canvas -> diepUnits = a*scalingFactor -> b
  549. window -> windowScaling() = ( a*windowScaling() )*2 -> b
  550. canvas -> windowScaling() = a*windowScaling() - > b
  551. diepUnits -> windowScaling() = ( a/scalingFactor ) * fieldFactor -> b
  552. windowScaling()-> diepUnits = ( a/fieldFactor ) * scalingFactor -> b
  553.  
  554. =============================================================================
  555.  
  556. My todo list or fix:
  557.  
  558. - simulate diep.io moving and knockback physics
  559.  
  560. - simulate diep.io bullets
  561.  
  562. - figure out how to simulate mouse click events
  563.  
  564. - Finish bullet speed hybrid tanks
  565.  
  566. - Figure out physics for sniper, Ranger etc.
  567.  
  568. =============================================================================
  569.  
  570. Useful info:
  571.  
  572. -shape sizes:
  573.  
  574. tank lvl 1 size = 53 diep units
  575.  
  576. grid square side length = 50 diep units
  577. square, triangle = 55 diep units
  578. pentagon = 75 diep units
  579. small crasher = 35 diep units
  580. big crasher = 55 diep units
  581. alpha pentagon = 200 diep units
  582.  
  583. =============================================================================
  584. */
  585. var currentLevel = 0;
  586. var lastLevel = 0;
  587. var tanky = "";
  588. let ripsaw_radius;
  589. let fieldFactor = 1.0;
  590. let found = false;
  591. let loltank ;let lolztank;
  592. let diepUnits = 53 * (1.01 ** (currentLevel - 1));
  593. let FOV = (0.55 * fieldFactor) / Math.pow(1.01, (currentLevel - 1) / 2);
  594. let scalingFactor = FOV * windowScaling();
  595. const fieldFactors = [
  596. {tank: "Sniper", factor: 0.899},
  597. {tank: "Overseer", factor: 0.899},
  598. {tank: "Overlord", factor: 0.899},
  599. {tank: "Assassin", factor: 0.8},
  600. {tank: "Necromancer", factor: 0.899},
  601. {tank: "Hunter", factor: 0.85},
  602. {tank: "Stalker", factor: 0.8},
  603. {tank: "Ranger", factor: 0.699},
  604. {tank: "Manager", factor: 0.899},
  605. {tank: "Predator", factor: 0.85},
  606. {tank: "Trapper", factor: 0.899},
  607. {tank: "GunnerTrapper", factor: 0.899},
  608. {tank: "Overtrapper", factor: 0.899},
  609. {tank: "MegaTrapper", factor: 0.899},
  610. {tank: "Tri-Trapper", factor: 0.899},
  611. {tank: "Smasher", factor: 0.899},
  612. {tank: "Landmine", factor: 0.899},
  613. {tank: "Streamliner", factor: 0.85},
  614. {tank: "AutoTrapper", factor: 0.899},
  615. {tank: "Battleship", factor: 0.899},
  616. {tank: "AutoSmasher", factor: 0.899},
  617. {tank: "Spike", factor: 0.899},
  618. {tank: "Factory", factor: 0.899},
  619. {tank: "Skimmer", factor: 0.899},
  620. {tank: "Glider", factor: 0.899},
  621. {tank: "Rocketeer", factor: 0.899},
  622. ]
  623.  
  624. function windowScaling() {
  625. const a = canvas.height / 1080;
  626. const b = canvas.width / 1920;
  627. return b < a ? a : b;
  628. }
  629.  
  630. function calculateFOV(Fv, l) {
  631. const numerator = 0.55 * Fv;
  632. const denominator = Math.pow(1.01, (l - 1) / 2);
  633. if(typeof window.HEAPF32 !== 'undefined' && typeof window.fov !== 'undefined' && window.fov.length > 0){
  634. //use this part, if you have a fov script that can share it's fov value with you
  635. FOV = HEAPF32[fov[0]];
  636. }else{
  637. //use this part if you have no fov script
  638. FOV = numerator / denominator;
  639. }
  640. return FOV;
  641. }
  642.  
  643. function apply_values(FF){
  644. calculateFOV(FF, currentLevel);
  645. scalingFactor = FOV * windowScaling();
  646. ripsaw_radius = diepUnits * scalingFactor;
  647. diepUnits = 53 * (1.01 ** (currentLevel - 1));
  648. }
  649.  
  650. function apply_changes(value){
  651. if(found){
  652. fieldFactor = fieldFactors[value].factor;
  653. loltank = tanky;
  654. lastLevel = currentLevel;
  655. apply_values(fieldFactor);
  656. }else{
  657. if(value === null){
  658. fieldFactor = 1.0;
  659. loltank = "default";
  660. lolztank = tanky;
  661. lastLevel = currentLevel;
  662. apply_values(fieldFactor);
  663. }
  664. }
  665. }
  666.  
  667. function bruteforce_tanks(){
  668. for (let i = 0; i < fieldFactors.length; i++){
  669. if(tanky.includes(fieldFactors[i].tank)){
  670. found = true;
  671. console.log("FOUND TANK " + fieldFactors[i].tank);
  672. apply_changes(i);
  673. break;
  674. }else{
  675. found = false;
  676. if(i < fieldFactors.length - 1){
  677. console.log(`checking tank ${i}`);
  678. }else{
  679. console.log("No Tank was found, resetting to default")
  680. apply_changes(null);
  681. }
  682. }
  683. }
  684. }
  685.  
  686. window.addEventListener("resize", bruteforce_tanks);
  687.  
  688. function check_lvl_change() {
  689. if(lastLevel === currentLevel){
  690. //console.log("level wasn't changed");
  691. }else{
  692. console.log("changed level, bruteforcing");
  693. bruteforce_tanks();
  694. }
  695. }
  696.  
  697. function check_change(){
  698. //console.log("lastLevel: " + lastLevel + " currentLevel: " + currentLevel);
  699. check_lvl_change();
  700. if(loltank != tanky){
  701. if(loltank === "default"){
  702. if(lolztank != tanky){
  703. bruteforce_tanks();
  704. }else{
  705. return;
  706. }
  707. }else{
  708. bruteforce_tanks();
  709. }
  710. }
  711. }
  712.  
  713. setInterval(check_change, 250);
  714.  
  715. //canvas gui
  716. let offsetX = 0;
  717. let offsetY = 0;
  718. //for canvas text height and space between it
  719. let text_startingY = 450*windowScaling();let textAdd = 25*windowScaling();
  720. let selected_box = null;
  721. const boxes = [
  722. {color: "lightblue", LUcornerX: 47, LUcornerY: 67},
  723. {color: "green", LUcornerX: 47+90+13, LUcornerY: 67},
  724. {color: "red", LUcornerX: 47, LUcornerY: 67+90+9},
  725. {color: "yellow", LUcornerX: 47+90+13, LUcornerY: 67+90+9},
  726. {color: "blue", LUcornerX: 47, LUcornerY: 67+((90+9)*2)},
  727. {color: "rainbow", LUcornerX: 47+90+13, LUcornerY: 67+((90+9)*2)}
  728. ]
  729.  
  730. const ctx = canvas.getContext('2d');
  731. function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY){
  732. ctx.fillStyle = fcolor;
  733. ctx.lineWidth = lineWidth;
  734. ctx.font = font;
  735. ctx.strokeStyle = scolor;
  736. ctx.strokeText(`${text}`, textX, textY)
  737. ctx.fillText(`${text}`, textX, textY)
  738. }
  739.  
  740. function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c){
  741. ctx.beginPath();
  742. ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
  743. ctx.fillStyle = c;
  744. ctx.fill();
  745. }
  746.  
  747. function ctx_rect(x, y, a, b, c){
  748. ctx.beginPath();
  749. ctx.strokeStyle = c;
  750. ctx.strokeRect(x, y, a, b);
  751. }
  752.  
  753. //use this for game entities
  754. function dot_in_diepunits(diepunits_X, diepunits_Y){
  755. ctx_arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, 5, 0, 2 * Math.PI, false, "lightblue");
  756. }
  757.  
  758. function circle_in_diepunits(diepunits_X, diepunits_Y, diepunits_R, c){
  759. ctx.beginPath();
  760. ctx.arc(diepunits_X * scalingFactor, diepunits_Y * scalingFactor, diepunits_R*scalingFactor, 0, 2 * Math.PI, false);
  761. ctx.strokeStyle = c;
  762. ctx.stroke();
  763. }
  764.  
  765. //use this for ui elements like upgrades or scoreboard
  766. function dot_in_diepunits_FOVless(diepunits_X, diepunits_Y){
  767. ctx_arc(diepunits_X * windowScaling(), diepunits_Y * windowScaling(), 5, 0, 2 * Math.PI, false, "lightblue");
  768. }
  769.  
  770. function square_for_grid(x, y, a, b, color){
  771. ctx.beginPath();
  772. ctx.rect(x*windowScaling(), y*windowScaling(), a*windowScaling(), b*windowScaling());
  773. ctx.strokeStyle = color;
  774. ctx.stroke();
  775. }
  776.  
  777. function draw_upgrade_grid(){
  778. for(let i = 0; i < boxes.length; i++){
  779. let start_x = (boxes[i].LUcornerX*windowScaling())/two;
  780. let start_y = (boxes[i].LUcornerY*windowScaling())/two;
  781. let end_x = ((boxes[i].LUcornerX+43*2)*windowScaling())/two;
  782. let end_y = ((boxes[i].LUcornerY+43*2)*windowScaling())/two;
  783. let temp_color = "black";
  784. if(uwuX > start_x && uwuY > start_y && uwuX < end_x && uwuY < end_y){
  785. temp_color = "red";
  786. selected_box = i;
  787. }else{
  788. temp_color = "black";
  789. selected_box = null;
  790. }
  791. square_for_grid(boxes[i].LUcornerX, boxes[i].LUcornerY, 86, 86, temp_color);
  792. }
  793. for(let i = 0; i < boxes.length; i++){
  794. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY);
  795. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43, boxes[i].LUcornerY);
  796. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43*2, boxes[i].LUcornerY);
  797. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43*2, boxes[i].LUcornerY+43);
  798. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43*2, boxes[i].LUcornerY+43*2);
  799. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY+43);
  800. dot_in_diepunits_FOVless(boxes[i].LUcornerX, boxes[i].LUcornerY+43*2);
  801. dot_in_diepunits_FOVless(boxes[i].LUcornerX+43, boxes[i].LUcornerY+43);
  802. }
  803. }
  804.  
  805. const gradients = ["#94b3d0", "#96b0c7", "#778daa", "#4c7299", "#52596c", "#19254e", "#2d445f", "#172631"];
  806. const tank_group1 = ["Trapper", "Overtrapper", "MegaTrapper", "Tri-Trapper"]; //Traps only
  807. const tank_group2 = ["Tank", "Twin", "TripleShot", "SpreadShot", "PentaShot", "TwinFlank", "TripleTwin", "QuadTank", "OctoTank", "MachineGun", "Sprayer", "Triplet", "FlankGuard"]; //constant bullets [initial speed = 0.699]
  808. //const tank_group3 = ["GunnerTrapper", "AutoTrapper"]; //Traps AND constant bullets (UNFINISHED)
  809. //const tank_group4 = []; //mix of bullets (UNFINISHED)
  810. //const tank_group5 = ["Sniper", "Assassin", "Stalker", "Ranger"]; //sniper+ bullets (UNFINISHED)
  811. const tank_group6 = ["Destroyer", "Hybrid", "Annihilator"]; //slower bullets [intitial speed = 0.699]
  812. //const tank_group7 = ["Overseer", "Overlord", "Manager", "Necromancer"]; //infinite bullets(drones) (UNFINISHED)
  813. const tank_group8 = ["Factory"]; //drones with spreading abilities
  814. const tank_group9 = ["Battleship"]; //special case
  815.  
  816. function draw_cirle_radius_for_tank(){
  817. if(tank_group1.includes(tanky)){
  818. for(let i = 0; i < gradients.length; i++){
  819. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 485 + (52.5*i), gradients[i]);
  820. }
  821. }else if(tank_group2.includes(tanky)){
  822. for(let i = 0; i < gradients.length; i++){
  823. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 1850 + (210*i), gradients[i]);
  824. }
  825. /*
  826. }else if(tank_group5.includes(tanky)){
  827. for(let i = 0; i < gradients.length; i++){
  828. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 2703 + (420*i), gradients[i]);
  829. }*/
  830. }else if(tank_group6.includes(tanky)){
  831. for(let i = 0; i < gradients.length; i++){
  832. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 1443.21 + (146.79*i), gradients[i]);
  833. }
  834. /*
  835. }else if(tank_group7.includes(tanky)){
  836. for(let i = 0; i < gradients.length; i++){
  837. circle_in_diepunits( canvas.width/2/scalingFactor , canvas.height/2/scalingFactor, 1607 + (145*i), gradients[i]);
  838. circle_in_diepunits( uwuX*2/scalingFactor , uwuY*2/scalingFactor, 1607 + (145*i), gradients[i]);
  839. }*/
  840. }else if(tank_group8.includes(tanky)){
  841. circle_in_diepunits(uwuX*two/scalingFactor, uwuY*two/scalingFactor, 200, gradients[0]);
  842. circle_in_diepunits(uwuX*two/scalingFactor, uwuY*two/scalingFactor, 800, gradients[1]);
  843. circle_in_diepunits(uwuX*two/scalingFactor, uwuY*two/scalingFactor, 900, gradients[2]);
  844. }else if(tank_group9.includes(tanky)){
  845. for(let i = 0; i < gradients.length; i++){
  846. circle_in_diepunits(canvas.width/2/scalingFactor, canvas.height/2/scalingFactor, 1640 + (210*i), gradients[i]);
  847. }
  848. }else{
  849. return;
  850. }
  851.  
  852. }
  853.  
  854. //let's calculate the angle
  855. var vector_l = [null, null];
  856. var angle_l = 0;
  857. function calc_leader(){
  858. if(script_list.minimap_leader_v1){
  859. let xc = canvas.width/2;
  860. let yc = canvas.height/2;
  861. vector_l[0] = window.l_arrow.xl - xc;
  862. vector_l[1] = window.l_arrow.yl - yc;
  863. angle_l = Math.atan2(vector_l[1], vector_l[0]) * (180 / Math.PI);
  864. }else if(script_list.minimap_leader_v2){
  865. let xc = canvas.width/2;
  866. let yc = canvas.height/2;
  867. vector_l[0] = window.L_X - xc;
  868. vector_l[1] = window.L_Y - yc;
  869. angle_l = Math.atan2(vector_l[1], vector_l[0]) * (180 / Math.PI);
  870. }else{
  871. console.log("waiting for leader script to give us values");
  872. }
  873. }
  874.  
  875. //setInterval(calc_l, 0);
  876.  
  877. // Minimap logic
  878. var minimap_elements = [
  879. {name: "minimap", x: 177.5, y: 177.5, width: 162.5, height: 162.5, color: "purple"},
  880. {name: "2tdm Blue Team", x: 177.5, y: 177.5, width: 17.5, height: 162.5, color: "blue"},
  881. {name: "2tdm Red Team", x: 32.5, y: 177.5, width: 17.5, height: 162.5, color: "red"},
  882. {name: "4tdm Blue Team", x: 177.5, y: 177.5, width: 25, height: 25, color: "blue"},
  883. {name: "4tdm Purple Team", x: 40, y: 177.5, width: 25, height: 25, color: "purple"},
  884. {name: "4tdm Green Team", x: 177.5, y: 40, width: 25, height: 25, color: "green"},
  885. {name: "4tdm Red Team", x: 40, y: 40, width: 25, height: 25, color: "red"},
  886. ];
  887.  
  888. var m_e_ctx_coords = [
  889. {name: "minimap", startx: null, stary: null, endx: null, endy: null},
  890. {name: "2tdm Blue Team", startx: null, stary: null, endx: null, endy: null},
  891. {name: "2tdm Red Team", startx: null, stary: null, endx: null, endy: null},
  892. {name: "4tdm Blue Team", startx: null, stary: null, endx: null, endy: null},
  893. {name: "4tdm Purple Team", startx: null, stary: null, endx: null, endy: null},
  894. {name: "4tdm Green Team", startx: null, stary: null, endx: null, endy: null},
  895. {name: "4tdm Red Team", startx: null, stary: null, endx: null, endy: null}
  896. ]
  897.  
  898. function draw_minimap(){
  899. switch(gamemode){
  900. case "2tdm":
  901. for(let i = 0; i < 3; i++){
  902. updateAndDrawElement(i);
  903. }
  904. break;
  905. case "4tdm":
  906. updateAndDrawElement(0);
  907. for(let i = 3; i < minimap_elements.length; i++){ // Draw all 4tdm elements
  908. updateAndDrawElement(i);
  909. }
  910. break;
  911. }
  912. if(script_list.minimap_leader_v1 || script_list.minimap_leader_v2){
  913. minimap_collision_check();
  914. }
  915. }
  916.  
  917. function updateAndDrawElement(index) {
  918. // Update their real-time position
  919. m_e_ctx_coords[index].startx = canvas.width - (minimap_elements[index].x * windowScaling());
  920. m_e_ctx_coords[index].starty = canvas.height - (minimap_elements[index].y * windowScaling());
  921. m_e_ctx_coords[index].endx = m_e_ctx_coords[index].startx + minimap_elements[index].width * windowScaling();
  922. m_e_ctx_coords[index].endy = m_e_ctx_coords[index].starty + minimap_elements[index].height * windowScaling();
  923.  
  924. // Draw the element
  925. ctx.beginPath();
  926. ctx.rect(m_e_ctx_coords[index].startx, m_e_ctx_coords[index].starty, minimap_elements[index].width * windowScaling(), minimap_elements[index].height * windowScaling());
  927. ctx.lineWidth = "1";
  928. ctx.strokeStyle = minimap_elements[index].color;
  929. ctx.stroke();
  930. }
  931.  
  932. let position_on_minimap;
  933. function minimap_collision_check() {
  934. if (script_list.minimap_leader_v1 || script_list.minimap_leader_v2) {
  935. let x = script_list.minimap_leader_v1 ? window.m_arrow.xl : window.M_X;
  936. let y = script_list.minimap_leader_v1 ? window.m_arrow.yl : window.M_Y;
  937.  
  938. if (m_e_ctx_coords[0].startx < x &&
  939. m_e_ctx_coords[0].starty < y &&
  940. m_e_ctx_coords[0].endx > x &&
  941. m_e_ctx_coords[0].endy > y) {
  942.  
  943. if (gamemode === "2tdm") {
  944. if (checkWithinBase(1, x, y)) position_on_minimap = "blue base";
  945. else if (checkWithinBase(2, x, y)) position_on_minimap = "red base";
  946. else position_on_minimap = "not in the base";
  947. } else if (gamemode === "4tdm") {
  948. if (checkWithinBase(3, x, y)) position_on_minimap = "blue base";
  949. else if (checkWithinBase(4, x, y)) position_on_minimap = "purple base";
  950. else if (checkWithinBase(5, x, y)) position_on_minimap = "green base";
  951. else if (checkWithinBase(6, x, y)) position_on_minimap = "red base";
  952. else position_on_minimap = "not in the base";
  953. }
  954. } else {
  955. position_on_minimap = "Warning! not on minimap";
  956. }
  957. }
  958. }
  959.  
  960. function checkWithinBase(baseIndex, x, y) {
  961. return m_e_ctx_coords[baseIndex].startx < x &&
  962. m_e_ctx_coords[baseIndex].starty < y &&
  963. m_e_ctx_coords[baseIndex].endx > x &&
  964. m_e_ctx_coords[baseIndex].endy > y;
  965. }
  966.  
  967. //let's try drawing a line to the leader
  968.  
  969. function apply_vector_on_minimap(){
  970. if(script_list.minimap_leader_v1){
  971. let x = window.m_arrow.xl;
  972. let y = window.m_arrow.yl;
  973. let thetaRadians = angle_l * (Math.PI / 180);
  974. let r = m_e_ctx_coords[0].endx-m_e_ctx_coords[0].startx;
  975. let x2 = x + r * Math.cos(thetaRadians);
  976. let y2 = y + r * Math.sin(thetaRadians);
  977. ctx.beginPath();
  978. ctx.moveTo(x, y);
  979. ctx.lineTo(x2, y2);
  980. ctx.stroke();
  981. }else if(script_list.minimap_leader_v2){
  982. let x = window.M_X;
  983. let y = window.M_Y;
  984. let thetaRadians = angle_l * (Math.PI / 180);
  985. let r = m_e_ctx_coords[0].endx-m_e_ctx_coords[0].startx;
  986. let x2 = x + r * Math.cos(thetaRadians);
  987. let y2 = y + r * Math.sin(thetaRadians);
  988. ctx.beginPath();
  989. ctx.moveTo(x, y);
  990. ctx.lineTo(x2, y2);
  991. ctx.stroke();
  992. }
  993. }
  994.  
  995.  
  996. //drawing the limit of the server (needs rework)
  997. function draw_server_border(a, b){
  998. ctx.beginPath();
  999. ctx.rect(canvas.width/2 - (a/2*scalingFactor), canvas.height/2 - (b/2*scalingFactor), a*scalingFactor, b*scalingFactor);
  1000. ctx.strokeStyle = "red";
  1001. ctx.stroke();
  1002. }
  1003.  
  1004. const circle_gradients = [
  1005. "#FF0000",// Red
  1006. "#FF4D00",// Orange Red
  1007. "#FF8000",// Orange
  1008. "#FFB300",// Dark Goldenrod
  1009. "#FFD700",// Gold
  1010. "#FFEA00",// Yellow
  1011. "#D6FF00",// Light Yellow Green
  1012. "#A3FF00",// Yellow Green
  1013. "#6CFF00",// Lime Green
  1014. "#00FF4C",// Medium Spring Green
  1015. "#00FF9D",// Turquoise
  1016. "#00D6FF",// Sky Blue
  1017. "#006CFF",// Blue
  1018. "#0000FF"// Dark Blue
  1019. ];
  1020.  
  1021. function draw_crx_events(){
  1022. //you need either leader arrow or moveTo/lineTo script from h3llside for this part
  1023. if(script_list.moveToLineTo_debug){
  1024. for(let i = 0; i < window.y_and_x.length; i++){
  1025. ctx_arc(window.y_and_x[i][0], window.y_and_x[i][1], 10, 0, 2 * Math.PI, false, circle_gradients[i]);
  1026. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", i, window.y_and_x[i][0], window.y_and_x[i][1]);
  1027. }
  1028. }else if(script_list.minimap_leader_v1){
  1029. //ctx_arc(window.l_arrow.xm, window.l_arrow.ym, 15, 0, 2 * Math.PI, false, window.l_arrow.color);
  1030. //ctx_arc(window.m_arrow.xm, window.m_arrow.ym, 1, 0, 2 * Math.PI, false, "yellow");
  1031. ctx_arc(window.l_arrow.xl, window.l_arrow.yl, 5, 0, 2 * Math.PI, false, window.l_arrow.color);
  1032. ctx_arc(window.m_arrow.xl, window.m_arrow.yl, 1, 0, 2 * Math.PI, false, "yellow");
  1033. }
  1034. }
  1035.  
  1036. //tank aim lines
  1037. let TurretRatios = [
  1038. {name: "Destroyer", ratio: 95/71.4, color: "red"},
  1039. {name: "Anni", ratio: 95/96.6, color: "darkred"},
  1040. {name: "Fighter", ratio: 80/42, color: "orange"},
  1041. {name: "Booster", ratio: 70/42, color: "green"},
  1042. {name: "Tank", ratio: 95/42, color: "yellow"},
  1043. {name: "Sniper", ratio: 110/42, color: "yellow"},
  1044. {name: "Ranger", ratio: 120/42, color: "orange"},
  1045. {name: "Hunter", ratio: 95/56.7, color: "orange"},
  1046. {name: "Predator", ratio: 80/71.4, color: "darkorange"},
  1047. {name: "Mega Trapper", ratio: 60/54.6, color: "red"},
  1048. {name: "Trapper", ratio: 60/42, color: "orange"},
  1049. {name: "Gunner Trapper", ratio: 95/26.6, color: "yellow"},
  1050. {name: "Predator", ratio: 95/84.8, color: "red"},
  1051. {name: "Gunner(small)", ratio: 65/25.2, color: "lightgreen"},
  1052. {name: "Gunner(big)", ratio: 85/25.2, color: "green"},
  1053. {name: "Spread1", ratio: 89/29.4, color: "orange"},
  1054. {name: "Spread2", ratio: 83/29.4, color: "orange"},
  1055. {name: "Spread3", ratio: 71/29.4, color: "orange"},
  1056. {name: "Spread4", ratio: 65/29.4, color: "orange"},
  1057. ];
  1058.  
  1059. function drawTheThing(x, y, r, index) {
  1060. if(toggleButtons.Visual['Toggle Aim Lines']){
  1061. ctx.strokeStyle = TurretRatios[index].color;
  1062. ctx.lineWidth = 5;
  1063.  
  1064. let extendedR = 300 * scalingFactor;
  1065.  
  1066. // Reverse the angle to switch the direction
  1067. const reversedAngle = -angle;
  1068.  
  1069. // Calculate the end point of the line
  1070. const endX = x + extendedR * Math.cos(reversedAngle);
  1071. const endY = y + extendedR * Math.sin(reversedAngle);
  1072.  
  1073. // Draw the line
  1074. ctx.beginPath();
  1075. ctx.moveTo(x, y);
  1076. ctx.lineTo(endX, endY);
  1077. ctx.stroke();
  1078.  
  1079. // Draw text at the end of the line
  1080. ctx.font = "20px Arial";
  1081. ctx.fillStyle = TurretRatios[index].color;
  1082. ctx.strokeStyle = "black";
  1083. ctx.strokeText(TurretRatios[index].name, endX, endY);
  1084. ctx.fillText(TurretRatios[index].name, endX, endY);
  1085.  
  1086. ctx.beginPath();
  1087. }
  1088. }
  1089.  
  1090. var angle, a, b, width;
  1091. let perm_cont = [];
  1092.  
  1093. CanvasRenderingContext2D.prototype.setTransform = new Proxy(CanvasRenderingContext2D.prototype.setTransform, {
  1094. apply(target, thisArgs, args) {
  1095. // Check if the ratio matches the specified conditions
  1096. for(let i = 0; i < TurretRatios.length; i++){
  1097. if (Math.abs(args[0] / args[3]).toFixed(3) == (TurretRatios[i].ratio).toFixed(3)) {
  1098. if(TurretRatios[i].name === "bullet"){
  1099. if(args[0] === 1&& args[1] === 0 && args[2] === 0 && args[3] === 1 && args[4] != 0 && args[5] != 0){
  1100. if(!perm_cont.includes(thisArgs)){
  1101. perm_cont.push(thisArgs);
  1102. console.log(perm_cont);
  1103. }
  1104. angle = Math.atan2(args[2], args[3]) || 0;
  1105. width = Math.hypot(args[3], args[2]);
  1106. a = args[4] - Math.cos(angle + Math.PI / 2) * width / 2;
  1107. b = args[5] + Math.sin(angle + Math.PI / 2) * width / 2;
  1108. console.log(b);
  1109. if(canvas.height/2 > b){
  1110. drawTheThing(a, b, Math.hypot(args[3], args[2]), i);
  1111. }
  1112. }
  1113. }else{
  1114. angle = Math.atan2(args[2], args[3]) || 0;
  1115. width = Math.hypot(args[3], args[2]);
  1116. a = args[4] - Math.cos(angle + Math.PI / 2) * width / 2;
  1117. b = args[5] + Math.sin(angle + Math.PI / 2) * width / 2;
  1118. drawTheThing(a, b, Math.hypot(args[3], args[2]), i);
  1119. }
  1120. }
  1121. }
  1122. return Reflect.apply(target, thisArgs, args);
  1123. }
  1124. });
  1125.  
  1126. setTimeout(() => {
  1127. let gui = () => {
  1128. if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
  1129. if(toggleButtons.Visual['Toggle Minimap']){
  1130. draw_minimap();
  1131. }
  1132. if(script_list.minimap_leader_v1 || script_list.minimap_leader_v2){
  1133. if(toggleButtons.Visual['Toggle Leader Angle']){
  1134. calc_leader();
  1135. apply_vector_on_minimap();
  1136. if(!toggleButtons.Visual['Toggle Minimap']){
  1137. input.inGameNotification("please enable Minimap as well");
  1138. }
  1139. }
  1140. }
  1141. if(script_list.set_transform_debug){
  1142. ctx_arc(window.crx_container[2], window.crx_container[3], 50, 0, 2 * Math.PI, false, "yellow");
  1143. }
  1144. if(toggleButtons.Debug['Toggle Text']){
  1145. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "canvas Lvl:" + currentLevel, canvas.width/20 + 10, text_startingY + (textAdd*0));
  1146. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "canvas tank: " + tanky, canvas.width/20 + 10, text_startingY + (textAdd*1));
  1147. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "radius: " + ripsaw_radius, canvas.width/20 + 10, text_startingY + (textAdd*2));
  1148. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "field Factor: " + fieldFactor, canvas.width/20 + 10, text_startingY + (textAdd*3));
  1149. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "diep Units: " + diepUnits, canvas.width/20 + 10, text_startingY + (textAdd*4));
  1150. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "Fov: " + FOV, canvas.width/20 + 10, text_startingY + (textAdd*5));
  1151. ctx_text("white", "DarkRed", 3, 1 + "em Ubuntu", "current Tick: " + currentTick, canvas.width/20 + 10, text_startingY + (textAdd*6));
  1152. 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));
  1153. //ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "realX: " + uwuX + "realY: " + uwuY + "newX: " + uwuX*windowScaling() + "newY: " + uwuY*windowScaling(), uwuX*2, uwuY*2);
  1154.  
  1155. //points at mouse
  1156. ctx_arc(uwuX*two, uwuY*two, 5, 0, 2 * Math.PI, false, "purple");
  1157. /*
  1158. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 35, "pink");
  1159. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 55, "yellow");
  1160. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 75, "purple");
  1161. circle_in_diepunits(uwuX*2/scalingFactor, uwuY*2/scalingFactor, 200, "blue");
  1162. */
  1163.  
  1164. //coords at mouse
  1165. ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "realX: " + uwuX*two + "realY: " + uwuY*two, uwuX*two, uwuY*two);
  1166. }
  1167.  
  1168. if(currentLevel != null && tanky != null){
  1169. if(toggleButtons.Debug['Toggle Middle Circle']){
  1170. ctx.beginPath();
  1171. ctx.moveTo(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY);
  1172. ctx.lineTo(uwuX*two, uwuY*two);
  1173. ctx.stroke();
  1174. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius, 0, 2 * Math.PI, false, "darkblue");
  1175. ctx_arc(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY, ripsaw_radius*0.9, 0, 2 * Math.PI, false, "lightblue");
  1176. }
  1177. if(toggleButtons.Debug['Toggle Upgrades']){
  1178. draw_upgrade_grid();
  1179. }
  1180. //draw_server_border(4000, 2250);
  1181. draw_crx_events();
  1182. if(toggleButtons.Visual['Toggle Bullet Distance']){
  1183. draw_cirle_radius_for_tank();
  1184. }
  1185. };
  1186. }
  1187. window.requestAnimationFrame(gui);
  1188. }
  1189. gui();
  1190. setTimeout(() => {
  1191. gui();
  1192. },5000);
  1193. }, 1000);
  1194.  
  1195. //game ticks finder
  1196. let clearRect_count = 0;
  1197. let fps;
  1198. CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
  1199. apply(fillRect, ctx, [text, x, y, ...blah]) {
  1200. if (text.endsWith('FPS')) {
  1201. fps = text.split(' ')[0];
  1202. }
  1203. fillRect.call(ctx, text, x, y, ...blah);
  1204. }
  1205. });
  1206.  
  1207. // Tick tracking
  1208. let currentTick = 0;
  1209. const tickQueue = [];
  1210. const everyTickFunctions = [];
  1211.  
  1212. function runEveryTick(callback) {
  1213. everyTickFunctions.push(callback);
  1214. }
  1215.  
  1216. CanvasRenderingContext2D.prototype.clearRect = new Proxy(CanvasRenderingContext2D.prototype.clearRect, {
  1217. apply(target, thisArg, argumentsList) {
  1218. clearRect_count += 1;
  1219. currentTick = Math.floor(clearRect_count / 6);
  1220. processTickQueue();
  1221. everyTickFunctions.forEach(func => func(currentTick));
  1222. return target.apply(thisArg, argumentsList);
  1223. }
  1224. });
  1225.  
  1226. function scheduleAfterTicks(callback, ticksToWait) {
  1227. const executionTick = currentTick + ticksToWait;
  1228. tickQueue.push({ callback, executionTick });
  1229. }
  1230.  
  1231. function processTickQueue() {
  1232. while (tickQueue.length > 0 && tickQueue[0].executionTick <= currentTick) {
  1233. const item = tickQueue.shift();
  1234. item.callback();
  1235. }
  1236. }
  1237.  
  1238. // Function to run code for a specified number of ticks
  1239. function runForTicks(callback, totalTicks) {
  1240. const startingTick = currentTick;
  1241. let ticksPassed = 0;
  1242.  
  1243. function tickHandler() {
  1244. if (ticksPassed < totalTicks) {
  1245. callback(ticksPassed, currentTick);
  1246. ticksPassed++;
  1247. scheduleAfterTicks(tickHandler, 1);
  1248. }
  1249. }
  1250.  
  1251. tickHandler(); // Start the process
  1252. }
  1253.  
  1254. // Example usage:
  1255. function test() {
  1256. console.log("Starting test at tick:", currentTick);
  1257.  
  1258. scheduleAfterTicks(() => {
  1259. console.log("150 ticks have passed, current tick:", currentTick);
  1260. // Add your code here
  1261. }, 150);
  1262. }
  1263.  
  1264. function testLoop() {
  1265. console.log("Starting testLoop at tick:", currentTick);
  1266. runForTicks((ticksPassed, currentTick) => {
  1267. console.log(`Tick passed: ${ticksPassed}, Current tick: ${currentTick}`);
  1268. // Add any other code you want to run each tick
  1269. }, 50);
  1270. }
  1271.  
  1272. //cooldowns (unfinished)
  1273. let c_cd = "red";
  1274. let c_r = "green";
  1275. const cooldowns = [
  1276. {Tank: "Destroyer", cooldown0: 109, cooldown1: 94, cooldown2: 81, cooldown3: 86},
  1277. ]
  1278.  
  1279. //detect which slot was clicked
  1280. document.addEventListener('mousedown', checkPos)
  1281. function checkPos(e){
  1282. console.log(currentTick);
  1283. console.log(boxes[selected_box]);
  1284. }
  1285.  
  1286.  
  1287. //warns you about annis, destroyers
  1288. /*
  1289. function drawTheThing(x,y,r) {
  1290. if(script_boolean){
  1291. let a = ctx.fillStyle;
  1292. ctx.fillStyle = "#FF000044";
  1293. ctx.beginPath();
  1294. ctx.arc(x,y,4*r,0,2*Math.PI);
  1295. ctx.fill();
  1296. ctx.fillStyle = "#FF000066";
  1297. ctx.beginPath();
  1298. ctx.arc(x,y,2*r,0,2*Math.PI);
  1299. ctx.fill();
  1300. ctx.beginPath();
  1301. }
  1302. }
  1303. var angle,a,b,width;
  1304. CanvasRenderingContext2D.prototype.setTransform = new Proxy(CanvasRenderingContext2D.prototype.setTransform, {
  1305. apply(target, thisArgs, args) {
  1306. //console.log(thisArgs)
  1307. 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)) {
  1308. angle = Math.atan2(args[2],args[3]) || 0;
  1309. width = Math.hypot(args[3], args[2]);
  1310. a = args[4]-Math.cos(angle+Math.PI/2)*width/2;
  1311. b = args[5]+Math.sin(angle+Math.PI/2)*width/2;
  1312. drawTheThing(a,b, Math.hypot(args[3],args[2]));
  1313. }
  1314. return Reflect.apply(target, thisArgs, args);
  1315. }
  1316. });
  1317. */
  1318.  
  1319. //physics for movement (UNFINISHED)
  1320. /*
  1321. //movement speed ingame stat
  1322. let m_s = [0, 1, 2, 3, 4, 5, 6, 7];
  1323.  
  1324. function accelarate(A_o){
  1325. //Accelaration
  1326. let sum = 0;
  1327. runForTicks((ticksPassed, currentTick) => {
  1328. console.log("sum is being calculated...");
  1329. sum += A_o * Math.pow(0.9, ticksPassed - 1);
  1330. offsetX = Math.floor(sum * scalingFactor);
  1331. console.log(offsetX);
  1332. }, 50);
  1333. //decelerate(sum);
  1334. }
  1335.  
  1336. function decelerate(sum){
  1337. //deceleration
  1338. let res = 0;
  1339. runForTicks((ticksPassed, currentTick) => {
  1340. console.log("res is being calculated...");
  1341. res = sum * Math.pow(0.9, ticksPassed);
  1342. offsetX = Math.floor(res * scalingFactor);
  1343. console.log(offsetX);
  1344. }, 50);
  1345. }
  1346. function calculate_speed(movement_speed_stat){
  1347. console.log("calculate_speed function called");
  1348. //use Accelaration for first 50 ticks, then deceleration until ticks hit 100, then stop moving
  1349.  
  1350. //calculating base value, we'll need this later
  1351. let a = (1.07**movement_speed_stat);
  1352. let b = (1.015**(currentLevel - 1));
  1353. let A_o = 2.55*(a/b);
  1354. accelarate(A_o);
  1355. }
  1356. */
  1357.  
  1358. //handle Key presses
  1359. let key_storage = [];
  1360.  
  1361. document.onkeydown = function(e) {
  1362. if(!key_storage.includes(e.key)){
  1363. key_storage.push(e.key);
  1364. }
  1365. console.log(key_storage);
  1366. analyse_keys();
  1367. }
  1368.  
  1369. document.onkeyup = function(e) {
  1370. if(key_storage.includes(e.key)){
  1371. key_storage.splice(key_storage.indexOf(e.key), 1);
  1372. }
  1373. console.log(key_storage);
  1374. analyse_keys();
  1375. }
  1376.  
  1377. function analyse_keys(){
  1378. if(key_storage.includes("j")){ //J
  1379. change_visibility();
  1380. }else if(key_storage.includes("e")){ //E
  1381. if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
  1382. f_s("fire");
  1383. }else{
  1384. auto_fire = false;
  1385. }
  1386. console.log(auto_fire);
  1387. }else if(key_storage.includes("c")){
  1388. console.log(auto_spin);
  1389. if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
  1390. f_s("spin");
  1391. }else{
  1392. auto_spin = false;
  1393. }
  1394. console.log(auto_spin);
  1395. }
  1396. }
  1397. // Handle key presses for moving the center (UNFINISHED)
  1398.  
  1399. /*
  1400. function return_to_center(XorY, posOrNeg){
  1401. console.log("function called with: " + XorY + posOrNeg);
  1402. if(XorY === "x"){
  1403. if(posOrNeg === "pos"){
  1404. while(offsetX < 0){
  1405. offsetX += 0.5*scalingFactor;
  1406. }
  1407. }else if(posOrNeg === "neg"){
  1408. while(offsetX > 0){
  1409. offsetX -= 0.5*scalingFactor;
  1410. }
  1411. }else{
  1412. console.log("invalid posOrNeg at return_to_center();")
  1413. }
  1414. }else if(XorY === "y"){
  1415. if(posOrNeg === "pos"){
  1416. while(offsetY < 0){
  1417. offsetY += 0.5*scalingFactor;
  1418. }
  1419. }else if(posOrNeg === "neg"){
  1420. while(offsetY > 0){
  1421. offsetY -= 0.5*scalingFactor;
  1422. }
  1423. }else{
  1424. console.log("invalid posOrNeg at return_to_center();")
  1425. }
  1426. }else{
  1427. console.log("invalid XorY at return_to_center();");
  1428. }
  1429. }
  1430.  
  1431. document.onkeydown = function(e) {
  1432. switch (e.keyCode) {
  1433. case 87: // 'W' key
  1434. console.log("W");
  1435. if(offsetY >= -87.5*scalingFactor){
  1436. offsetY -= 12.5*scalingFactor;
  1437. }
  1438. break
  1439. case 83: // 'S' key
  1440. console.log("S");
  1441. if(offsetY <= 87.5*scalingFactor){
  1442. offsetY += 12.5*scalingFactor;
  1443. }
  1444. break;
  1445. case 68: // 'D' key
  1446. console.log("D");
  1447. if(offsetX <= 87.5*scalingFactor){
  1448. offsetX += 12.5*scalingFactor;
  1449. }
  1450. break
  1451. case 65: // 'A' key
  1452. console.log("A");
  1453. if(offsetX >= -87.5*scalingFactor){
  1454. offsetX -= 12.5*scalingFactor;
  1455. }
  1456. break
  1457. }
  1458. }
  1459.  
  1460. document.onkeyup = function(e) {
  1461. switch (e.keyCode) {
  1462. case 87: // 'W' key
  1463. console.log("W unpressed");
  1464. return_to_center("y", "pos");
  1465. break
  1466. case 83: // 'S' key
  1467. console.log("S unpressed");
  1468. return_to_center("y", "neg");
  1469. break;
  1470. case 68: // 'D' key
  1471. console.log("D unpressed");
  1472. return_to_center("x", "neg");
  1473. break
  1474. case 65:
  1475. console.log("A unpressed");
  1476. return_to_center("x", "pos");
  1477. }
  1478. }
  1479. */