Diep.io Auto-leveler Bot Enhanced

Press Q to toggle auto-leveling; must be in the base once for team detection.

  1. // ==UserScript==
  2. // @name Diep.io Auto-leveler Bot Enhanced
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-11-02
  5. // @description Press Q to toggle auto-leveling; must be in the base once for team detection.
  6. // @match https://diep.io/*
  7. // @grant none
  8. // @run-at document-start
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. let isBotActive = false;
  15. let teamDetected = false;
  16. let team = null;
  17. let maxLevel = 45; // Diep.io max level (you can adjust this if needed)
  18. let upgradeOrder = ["health", "bulletSpeed", "reload", "movementSpeed"]; // Example upgrade order
  19.  
  20. // Toggle the bot with the "Q" key
  21. document.addEventListener('keydown', (event) => {
  22. if (event.key === 'Q' || event.key === 'q') {
  23. isBotActive = !isBotActive;
  24. console.log(`Auto-leveler is now ${isBotActive ? 'ON' : 'OFF'}`);
  25. if (isBotActive && !teamDetected) {
  26. detectTeam();
  27. }
  28. }
  29. });
  30.  
  31. // Detect the player's team by identifying game-related variables or attributes
  32. function detectTeam() {
  33. try {
  34. // This is a generalized approach. You may need to update it with specific variables used in Diep.io.
  35. if (window.game && window.game.team) { // Replace this with Diep.io's actual team variable
  36. team = window.game.team;
  37. teamDetected = true;
  38. console.log(`Team detected: ${team}`);
  39. } else {
  40. console.log("Unable to detect team. Make sure you are in the base at least once.");
  41. }
  42. } catch (error) {
  43. console.error("Team detection error:", error);
  44. }
  45. }
  46.  
  47. // Main function that performs leveling up
  48. function autoLevel() {
  49. if (!isBotActive || !teamDetected) return;
  50.  
  51. try {
  52. // Check player level and experience points (assumes Diep.io has a player object with level tracking)
  53. if (window.player && window.player.level < maxLevel) {
  54. // Replace `window.player` with Diep.io's actual player object or variable path
  55. for (let stat of upgradeOrder) {
  56. upgradeStat(stat); // Attempt to upgrade each stat in the order specified
  57. }
  58. console.log(`Auto-leveling... Current level: ${window.player.level}`);
  59. }
  60. } catch (error) {
  61. console.error("Auto-leveling error:", error);
  62. }
  63. }
  64.  
  65. // Upgrade a specified stat, simulating a user clicking the upgrade button or triggering a level-up function
  66. function upgradeStat(statName) {
  67. try {
  68. // Example action to upgrade stat, replace with Diep.io's actual upgrade mechanism
  69. if (window.upgrade && typeof window.upgrade[statName] === "function") {
  70. window.upgrade[statName](); // Attempt to upgrade the specified stat
  71. console.log(`Upgraded ${statName}`);
  72. } else {
  73. console.log(`Upgrade function for ${statName} not found`);
  74. }
  75. } catch (error) {
  76. console.error(`Error upgrading ${statName}:`, error);
  77. }
  78. }
  79.  
  80. // Interval to check for leveling
  81. setInterval(() => {
  82. autoLevel();
  83. }, 1000); // Adjust interval as needed for optimal performance
  84.  
  85. })();