feeeew

ALS AutoAbility

Oct 10th, 2025
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.48 KB | None | 0 0
  1. repeat task.wait() until game:IsLoaded()
  2.  
  3. -- ========================================
  4. -- CONFIGURATION - Edit settings below
  5. -- ========================================
  6.  
  7. -- Enable/disable the script
  8. getgenv().AutoAbilitiesEnabled = true
  9.  
  10. -- Game speed multiplier (affects cooldown calculations)
  11. -- Set to 3 if playing on 3x speed, 1 for normal speed, etc.
  12. local GAME_SPEED = 3
  13.  
  14. -- Tower ability configurations
  15. -- Format: [TowerName] = { ability1, ability2, ... }
  16. --
  17. -- Available options for each ability:
  18. -- - name: Ability name (required) - cooldown and requiredLevel auto-detected from TowerInfo
  19. -- - onlyOnBoss: Only use when boss exists (true/false)
  20. -- - onSpecificWaves: Only use on specific waves (e.g., {25, 50} or single wave 50)
  21. -- - minWave: Only use on or after this wave number
  22. -- - maxWave: Only use on or before this wave number
  23. -- - requireBossInRange: Wait for boss to be in tower's range (true/false)
  24. -- - rangeDelay: How long (seconds) boss must be in range before using ability
  25. -- - delayAfterBossSpawn: Wait X seconds after boss spawns before using ability
  26.  
  27. local TOWER_ABILITIES = {
  28.     ["AiHoshinoEvo"] = {
  29.         {name = "Concert"}
  30.     },
  31.     ["Bulma"] = {
  32.         {name = "Summon Wish Dragon"},
  33.         {name = "Wish: Power"}
  34.     },
  35.     ["AsuraEvo"] = {
  36.         {name = "Lines of Sanzu", onlyOnBoss = true, onSpecificWaves = 50}
  37.     },
  38.     ["NarutoBaryon"] = {
  39.         {name = "Spiralling Shuriken"},
  40.         {name = "Lava Release: Spiralling Shuriken", onlyOnBoss = true, onSpecificWaves = 50}
  41.     },
  42.     ["LelouchEvo"] = {
  43.         {name = "All of you, Die!", onlyOnBoss = true, onSpecificWaves = 50, requireBossInRange = true},
  44.         {name = "Submission", onlyOnBoss = true, onSpecificWaves = 50, requireBossInRange = true}
  45.     },
  46.     ["LightEvo"] = {
  47.         {name = "Write Names", onlyOnBoss = true, onSpecificWaves = 50, delayAfterBossSpawn = 1}
  48.     }
  49. }
  50.  
  51. -- ========================================
  52. -- SCRIPT CODE - Do not edit below unless you know what you're doing
  53. -- ========================================
  54.  
  55. local RS = game:GetService("ReplicatedStorage")
  56. local Towers = workspace.Towers
  57.  
  58. local bossSpawnTime = nil
  59. local lightAbilityUsed = false
  60. local bossInRangeTracker = {}
  61. local abilityCooldowns = {}
  62. local towerInfoCache = {}
  63. local generalBossSpawnTime = nil
  64.  
  65.  
  66.  
  67. local function getTowerInfo(towerName)
  68.     if towerInfoCache[towerName] then
  69.         return towerInfoCache[towerName]
  70.     end
  71.    
  72.     local success, towerData = pcall(function()
  73.         local towerInfoPath = RS:WaitForChild("Modules"):WaitForChild("TowerInfo")
  74.         local towerModule = towerInfoPath:FindFirstChild(towerName)
  75.         if towerModule and towerModule:IsA("ModuleScript") then
  76.             return require(towerModule)
  77.         end
  78.         return nil
  79.     end)
  80.    
  81.     if success and towerData then
  82.         towerInfoCache[towerName] = towerData
  83.         return towerData
  84.     end
  85.     return nil
  86. end
  87.  
  88. local function getAbilityData(towerName, abilityName)
  89.     local towerInfo = getTowerInfo(towerName)
  90.     if not towerInfo then
  91.         return nil
  92.     end
  93.    
  94.     for level = 0, 50 do
  95.         if towerInfo[level] then
  96.             if towerInfo[level].Ability then
  97.                 local abilityData = towerInfo[level].Ability
  98.                 if abilityData.Name == abilityName and not abilityData.AttributeRequired then
  99.                     return {
  100.                         cooldown = abilityData.Cd,
  101.                         requiredLevel = level,
  102.                         isGlobal = abilityData.IsCdGlobal
  103.                     }
  104.                 end
  105.             end
  106.            
  107.             if towerInfo[level].Abilities then
  108.                 for _, abilityData in pairs(towerInfo[level].Abilities) do
  109.                     if abilityData.Name == abilityName and not abilityData.AttributeRequired then
  110.                         return {
  111.                             cooldown = abilityData.Cd,
  112.                             requiredLevel = level,
  113.                             isGlobal = abilityData.IsCdGlobal
  114.                         }
  115.                     end
  116.                 end
  117.             end
  118.         end
  119.     end
  120.     return nil
  121. end
  122.  
  123. local function getTower(name)
  124.     return Towers:FindFirstChild(name)
  125. end
  126.  
  127. local function getUpgradeLevel(tower)
  128.     if not tower then return 0 end
  129.     local upgradeVal = tower:FindFirstChild("Upgrade")
  130.     if upgradeVal and upgradeVal:IsA("ValueBase") then
  131.         return upgradeVal.Value or 0
  132.     end
  133.     return 0
  134. end
  135.  
  136. local function getCurrentWave()
  137.     local ok, result = pcall(function()
  138.         local player = game:GetService("Players").LocalPlayer
  139.         local gui = player.PlayerGui:FindFirstChild("Top")
  140.         if not gui then return 0 end
  141.         local frame = gui:FindFirstChild("Frame")
  142.         if not frame then return 0 end
  143.         frame = frame:FindFirstChild("Frame")
  144.         if not frame then return 0 end
  145.         frame = frame:FindFirstChild("Frame")
  146.         if not frame then return 0 end
  147.         frame = frame:FindFirstChild("Frame")
  148.         if not frame then return 0 end
  149.         local button = frame:FindFirstChild("TextButton")
  150.         if not button then return 0 end
  151.         local children = button:GetChildren()
  152.         if #children < 3 then return 0 end
  153.         local text = children[3].Text
  154.         return tonumber(text) or 0
  155.     end)
  156.     return ok and result or 0
  157. end
  158.  
  159. local function getTowerInfoName(tower)
  160.     if not tower then return nil end
  161.    
  162.     local candidates = {
  163.         tower:GetAttribute("TowerType"),
  164.         tower:GetAttribute("Type"),
  165.         tower:GetAttribute("TowerName"),
  166.         tower:GetAttribute("BaseTower"),
  167.         tower:FindFirstChild("TowerType") and tower.TowerType:IsA("ValueBase") and tower.TowerType.Value,
  168.         tower:FindFirstChild("Type") and tower.Type:IsA("ValueBase") and tower.Type.Value,
  169.         tower:FindFirstChild("TowerName") and tower.TowerName:IsA("ValueBase") and tower.TowerName.Value,
  170.         tower.Name
  171.     }
  172.    
  173.     for _, candidate in ipairs(candidates) do
  174.         if candidate and type(candidate) == "string" and candidate ~= "" then
  175.             return candidate
  176.         end
  177.     end
  178.    
  179.     return tower.Name
  180. end
  181.  
  182. local function getTower(name)
  183.     return Towers:FindFirstChild(name)
  184. end
  185.  
  186. local function getUpgradeLevel(tower)
  187.     if not tower then return 0 end
  188.     local upgradeVal = tower:FindFirstChild("Upgrade")
  189.     if upgradeVal and upgradeVal:IsA("ValueBase") then
  190.         return upgradeVal.Value or 0
  191.     end
  192.     return 0
  193. end
  194.  
  195. local function useAbility(tower, abilityName)
  196.     if tower then
  197.         pcall(function()
  198.             local Event = RS.Remotes.Ability
  199.             Event:InvokeServer(tower, abilityName)
  200.         end)
  201.     end
  202. end
  203.  
  204. local function isOnCooldown(towerName, abilityName)
  205.     local abilityData = getAbilityData(towerName, abilityName)
  206.     if not abilityData or not abilityData.cooldown then return false end
  207.    
  208.     local key = towerName .. "_" .. abilityName
  209.     local lastUsed = abilityCooldowns[key]
  210.    
  211.     if not lastUsed then return false end
  212.    
  213.     local adjustedCooldown = abilityData.cooldown / GAME_SPEED
  214.     local elapsed = tick() - lastUsed
  215.     return elapsed < adjustedCooldown
  216. end
  217.  
  218. local function setAbilityUsed(towerName, abilityName)
  219.     local key = towerName .. "_" .. abilityName
  220.     abilityCooldowns[key] = tick()
  221. end
  222.  
  223. local function hasAbilityBeenUnlocked(towerName, abilityName, towerLevel)
  224.     local abilityData = getAbilityData(towerName, abilityName)
  225.     if not abilityData then
  226.         return false
  227.     end
  228.    
  229.     local unlocked = towerLevel >= abilityData.requiredLevel
  230.     if not unlocked then
  231.     end
  232.     return unlocked
  233. end
  234.  
  235. local function isWave50()
  236.     local ok, result = pcall(function()
  237.         local player = game:GetService("Players").LocalPlayer
  238.         local gui = player.PlayerGui:FindFirstChild("Top")
  239.         if not gui then return false end
  240.         local frame = gui:FindFirstChild("Frame")
  241.         if not frame then return false end
  242.         frame = frame:FindFirstChild("Frame")
  243.         if not frame then return false end
  244.         frame = frame:FindFirstChild("Frame")
  245.         if not frame then return false end
  246.         frame = frame:FindFirstChild("Frame")
  247.         if not frame then return false end
  248.         local button = frame:FindFirstChild("TextButton")
  249.         if not button then return false end
  250.         local children = button:GetChildren()
  251.         if #children < 3 then return false end
  252.         local text = children[3].Text
  253.         return text == tostring(BOSS_WAVE) or text == BOSS_WAVE
  254.     end)
  255.     return ok and result
  256. end
  257.  
  258. local function bossExists()
  259.     local ok, result = pcall(function()
  260.         local enemies = workspace:FindFirstChild("Enemies")
  261.         if not enemies then return false end
  262.         return enemies:FindFirstChild("Boss") ~= nil
  263.     end)
  264.     return ok and result
  265. end
  266.  
  267. local function bossReadyForAbilities()
  268.     if bossExists() then
  269.         if not generalBossSpawnTime then
  270.             generalBossSpawnTime = tick()
  271.         end
  272.         local elapsed = tick() - generalBossSpawnTime
  273.         return elapsed >= 1
  274.     else
  275.         generalBossSpawnTime = nil
  276.         return false
  277.     end
  278. end
  279.  
  280. local function checkBossSpawnTime()
  281.     if bossExists() then
  282.         if not bossSpawnTime then
  283.             bossSpawnTime = tick()
  284.             lightAbilityUsed = false
  285.         end
  286.         local elapsed = tick() - bossSpawnTime
  287.         if elapsed >= 16 and not lightAbilityUsed then
  288.             return true
  289.         end
  290.         return false
  291.     else
  292.         bossSpawnTime = nil
  293.         lightAbilityUsed = false
  294.         return false
  295.     end
  296. end
  297.  
  298. local function getBossPosition()
  299.     local ok, result = pcall(function()
  300.         local enemies = workspace:FindFirstChild("Enemies")
  301.         if not enemies then return nil end
  302.         local boss = enemies:FindFirstChild("Boss")
  303.         if not boss then return nil end
  304.         local hrp = boss:FindFirstChild("HumanoidRootPart")
  305.         if hrp then
  306.             return hrp.Position
  307.         end
  308.         return nil
  309.     end)
  310.     return ok and result or nil
  311. end
  312.  
  313. local function getTowerPosition(tower)
  314.     if not tower then return nil end
  315.     local ok, result = pcall(function()
  316.         local hrp = tower:FindFirstChild("HumanoidRootPart")
  317.         if hrp then
  318.             return hrp.Position
  319.         end
  320.         return nil
  321.     end)
  322.     return ok and result or nil
  323. end
  324.  
  325. local function getTowerRange(tower)
  326.     if not tower then return 0 end
  327.     local ok, result = pcall(function()
  328.         local stats = tower:FindFirstChild("Stats")
  329.         if not stats then return 0 end
  330.         local range = stats:FindFirstChild("Range")
  331.         if not range then return 0 end
  332.         return range.Value or 0
  333.     end)
  334.     return ok and result or 0
  335. end
  336.  
  337. local function isBossInRange(tower)
  338.     local bossPos = getBossPosition()
  339.     local towerPos = getTowerPosition(tower)
  340.    
  341.     if not bossPos or not towerPos then
  342.         return false
  343.     end
  344.    
  345.     local range = getTowerRange(tower)
  346.     if range <= 0 then return false end
  347.    
  348.     local distance = (bossPos - towerPos).Magnitude
  349.     return distance <= range
  350. end
  351.  
  352. local function checkBossInRangeForDuration(tower, requiredDuration)
  353.     if not tower then return false end
  354.    
  355.     local towerName = tower.Name
  356.     local currentTime = tick()
  357.    
  358.     if isBossInRange(tower) then
  359.         if requiredDuration == 0 then
  360.             return true
  361.         end
  362.        
  363.         if not bossInRangeTracker[towerName] then
  364.             bossInRangeTracker[towerName] = currentTime
  365.             return false
  366.         else
  367.             local timeInRange = currentTime - bossInRangeTracker[towerName]
  368.             if timeInRange >= requiredDuration then
  369.                 return true
  370.             end
  371.         end
  372.     else
  373.         bossInRangeTracker[towerName] = nil
  374.     end
  375.    
  376.     return false
  377. end
  378.  
  379.  
  380. while getgenv().AutoAbilitiesEnabled do
  381.     wait(0.5)
  382.    
  383.     local currentWave = getCurrentWave()
  384.     local hasBoss = bossExists()
  385.    
  386.     for towerName, abilities in pairs(TOWER_ABILITIES) do
  387.         local tower = getTower(towerName)
  388.        
  389.         if tower then
  390.             local towerInfoName = getTowerInfoName(tower)
  391.             local towerLevel = getUpgradeLevel(tower)
  392.            
  393.             for _, abilityConfig in ipairs(abilities) do
  394.                 local shouldUse = true
  395.                 local failReason = nil
  396.                
  397.                 if not hasAbilityBeenUnlocked(towerInfoName, abilityConfig.name, towerLevel) then
  398.                     shouldUse = false
  399.                     failReason = "Not unlocked (Level " .. towerLevel .. ")"
  400.                 end
  401.                
  402.                 if isOnCooldown(towerInfoName, abilityConfig.name) then
  403.                     shouldUse = false
  404.                     failReason = "On cooldown"
  405.                 end
  406.                
  407.                 if abilityConfig.onlyOnBoss and not hasBoss then
  408.                     shouldUse = false
  409.                     failReason = "Boss required but not present"
  410.                 end
  411.                
  412.                 if abilityConfig.onlyOnBoss and hasBoss and shouldUse then
  413.                     if not bossReadyForAbilities() then
  414.                         shouldUse = false
  415.                         failReason = "Waiting 1s after boss spawn"
  416.                     end
  417.                 end
  418.                
  419.                 if abilityConfig.onSpecificWaves and shouldUse then
  420.                     local onCorrectWave = false
  421.                     if type(abilityConfig.onSpecificWaves) == "table" then
  422.                         for _, wave in ipairs(abilityConfig.onSpecificWaves) do
  423.                             if currentWave == wave then
  424.                                 onCorrectWave = true
  425.                                 break
  426.                             end
  427.                         end
  428.                     else
  429.                         onCorrectWave = (currentWave == abilityConfig.onSpecificWaves)
  430.                     end
  431.                     if not onCorrectWave then
  432.                         shouldUse = false
  433.                         failReason = "Wrong wave (Current: " .. currentWave .. ")"
  434.                     end
  435.                 end
  436.                
  437.                 if abilityConfig.minWave and currentWave < abilityConfig.minWave then
  438.                     shouldUse = false
  439.                 end
  440.                
  441.                 if abilityConfig.maxWave and currentWave > abilityConfig.maxWave then
  442.                     shouldUse = false
  443.                 end
  444.                
  445.                 if abilityConfig.requireBossInRange and shouldUse then
  446.                     local rangeDelay = abilityConfig.rangeDelay or 0
  447.                     if not checkBossInRangeForDuration(tower, rangeDelay) then
  448.                         shouldUse = false
  449.  
  450.                     end
  451.                 end
  452.                
  453.                 if shouldUse then
  454.                     if abilityConfig.delayAfterBossSpawn then
  455.                         if checkBossSpawnTime() then
  456.                             useAbility(tower, abilityConfig.name)
  457.                             lightAbilityUsed = true
  458.                             setAbilityUsed(towerInfoName, abilityConfig.name)
  459.                         end
  460.                     else
  461.                         useAbility(tower, abilityConfig.name)
  462.                         setAbilityUsed(towerInfoName, abilityConfig.name)
  463.                     end
  464.                 end
  465.             end
  466.         end
  467.     end
  468. end
  469.  
Advertisement
Add Comment
Please, Sign In to add comment