Advertisement
NoTextForSpeech

tds autochain

Nov 23rd, 2024
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.60 KB | None | 0 0
  1. --[[
  2. The Biggest Technical Update!
  3. This update took a long time due to I had to finish my final examination and also lost motivation.
  4. Changelog:
  5. +Added:
  6. ++ New Remade SelectedTower() function and Status System.
  7. + Tweak a bit of CheckDistant() function.
  8. + Supported low level commander, so instead of skipping it, now it will loop active ability in 10s and skip it when the ability doesn't active it in 10s.
  9. + Added getgenv().KeepTracking, keep tracking getgenv().troops and updated it when a commander removed or added, even after the gui already deleted.
  10. + Added Delete Gui button.
  11. + Added Executed Check, prevents script from errors, can be disabled using Delete Gui button.
  12. + Added getgenv().DebugModes, print all information about a function is working.
  13. *Changed, Fixed:
  14. * Changed Chain() function, now it will stop at the next commander when disabled, instead of running through a loop then stopped
  15. * Changed getgenv().troops, so it can work with new remade SelectedTower().
  16. * Change TowerAdded(), made it selected faster.
  17. * Fixed error in TowerRemoved() function.
  18. ==============================Credits==============================
  19. This Script Is Open-source, Feel Free To Change Anything.
  20. Credit: Sigmanic (Sigmanic#6607 --Main Account, Thomas Andrew#8787 --Second Account)
  21. ]]--
  22. if game.PlaceId ~= 5591597781 then return end
  23. --getgenv().PreferDouble = true --Remove the first "--" if you want to use double chain.
  24. getgenv().KeepTracking = true --Recommended turn this on.
  25. getgenv().DebugModes = true
  26.  
  27. if getgenv().AlrExecAC then
  28. game.StarterGui:SetCore("SendNotification", {
  29. Title = "Auto Chain",
  30. Text = "Script Already Executed.";
  31. Duration = 6;
  32. })
  33. return
  34. end
  35. getgenv().AlrExecAC = true
  36. if not getgenv().troops then
  37. getgenv().troops = { --Contain number and tower instance
  38. [1] = {1},
  39. [2] = {2},
  40. [3] = {3},
  41. [4] = {4},
  42. [5] = {5},
  43. [6] = {6}
  44. }
  45. end
  46. function prints(...)
  47. if DebugModes then
  48. return print(...)
  49. else
  50. return
  51. end
  52. end
  53. if KeepTracking and typeof(getgenv().TowerAdded) == "RBXScriptConnection" and typeof(getgenv().TowerRemoved) == "RBXScriptConnection" then
  54. prints("deleted TowerAdded,TowerRemoved")
  55. getgenv().TowerAdded:Disconnect()
  56. getgenv().TowerRemoved:Disconnect()
  57. end
  58.  
  59. local CancelLoop = false
  60. local StatusTable = {}
  61. getgenv().TowerAdded = nil
  62. getgenv().TowerRemoved = nil
  63. local library = loadstring(game:HttpGet("https://raw.githubusercontent.com/Sigmanic/ROBLOX/main/ModificationWallyUi", true))()
  64. local w = library:CreateWindow('Auto Chain')
  65. w:Toggle('Active Auto Chain', {flag = "autochain"},function(value) StatusTable["autochain"] = value end)
  66. StatusTable[1] = w:Section('Commander 1: None')
  67. StatusTable[2] = w:Section('Commander 2: None')
  68. StatusTable[3] = w:Section('Commander 3: None')
  69. w:Button("Delete Gui",function()
  70. w["object"].Parent.Parent:Destroy()
  71. CancelLoop = true
  72. if not KeepTracking then
  73. getgenv().TowerAdded:Disconnect()
  74. getgenv().TowerRemoved:Disconnect()
  75. end
  76. StatusTable = nil
  77. getgenv().AlrExecAC = false
  78. end)
  79. local function Status(Index,Text)
  80. if not StatusTable then
  81. return
  82. elseif StatusTable[Index] == nil then
  83. return prints(Index,"Doesn't existed")
  84. else
  85. if type(Text) == "string" then
  86. StatusTable[Index].Text = tostring(Text)
  87. return
  88. else
  89. return StatusTable[Index]
  90. end
  91. end
  92. end
  93. for i,v in next,troops do
  94. local Values = v[2]
  95. if Values and Status(i) then
  96. prints("Status",i,v[2])
  97. Status(i,"Commander "..i..": Selected")
  98. end
  99. end
  100. function SelectedTower(Tower,Value)
  101. if Value == true then --Select Tower
  102. for i=1,#troops do
  103. if Tower == troops[i][2] then
  104. prints("SelectedTower()",Tower,"Already Existed")
  105. return
  106. end
  107. end
  108. for i,v in ipairs(troops) do
  109. if not v[2] and Status(i) then
  110. prints("SelectedTower()",Tower,i)
  111. table.insert(troops[i],2,Tower)
  112. Status(i,"Commander "..i..": Selected")
  113. return
  114. end
  115. end
  116. elseif Value == false then --Remove Tower
  117. for i,v in next,troops do
  118. local Values = v[2]
  119. if Values == Tower then
  120. table.remove(troops[i],2)
  121. Status(i,"Commander "..i..": None")
  122. end
  123. end
  124. end
  125. end
  126. for i,v in pairs(game:GetService("Workspace").Towers:GetChildren()) do
  127. if v:FindFirstChild("Owner").Value and v:FindFirstChild("Owner").Value == game:GetService("Players").LocalPlayer.UserId and v.TowerReplicator:GetAttribute("Type") == "Commander" then
  128. prints(v,"Added1")
  129. --SelectedTower(v,true)
  130. task.spawn(SelectedTower,v,true)
  131. end
  132. end
  133. getgenv().TowerAdded = game:GetService("Workspace").Towers.ChildAdded:Connect(function(v)
  134. wait(.25)
  135. if not v:FindFirstChild("TowerReplicator") then
  136. repeat wait() until v:FindFirstChild("TowerReplicator")
  137. end
  138. if v:FindFirstChild("Owner").Value and v:FindFirstChild("Owner").Value == game:GetService("Players").LocalPlayer.UserId and v.TowerReplicator:GetAttribute("Type") == "Commander" then
  139. prints("TowerAdded",v,"Added")
  140. --SelectedTower(v,true)
  141. task.spawn(SelectedTower,v,true)
  142. end
  143. end)
  144. getgenv().TowerRemoved = game:GetService("Workspace").Towers.ChildRemoved:Connect(function(v)
  145. if v:FindFirstChild("Owner").Value and v:FindFirstChild("Owner").Value == game:GetService("Players").LocalPlayer.UserId and v.TowerReplicator:GetAttribute("Type") == "Commander" then
  146. prints("TowerRemoved",v,"Removed")
  147. --SelectedTower(v,false)
  148. task.spawn(SelectedTower,v,false)
  149. end
  150. task.wait()
  151. end)
  152. local function Chain(Tower,Type)
  153. if CancelLoop then
  154. prints("CancelLoop 1",CancelLoop)
  155. return
  156. end
  157. local Info = Tower[1]
  158. if not Status(Type) then
  159. Status(Info,"Commander "..Info..": Prepare")
  160. repeat task.wait() until Status(Type)
  161. end
  162. local Tower = Tower[2]
  163. if Tower then
  164. if Tower.TowerReplicator:GetAttribute("Upgrade") >= 2 then
  165. if not Tower.TowerReplicator.Stuns:GetAttribute("1") or Tower.TowerReplicator.Stuns:GetAttribute("1") == false and Tower.TowerReplicator:GetAttribute("Upgrade") >= 2 then
  166. game:GetService("ReplicatedStorage").RemoteFunction:InvokeServer("Troops","Abilities","Activate",{["Troop"] = Tower ,["Name"] = "Call Of Arms"})
  167. Status(Info,"Commander "..Info..": Actived")
  168. task.wait(10.01)
  169. Status(Info,"Commander "..Info..": Waiting")
  170. else
  171. Status(Info,"Commander "..Info..": Stunning")
  172. repeat wait()
  173. until not Tower.TowerReplicator.Stuns:GetAttribute("1") or Tower.TowerReplicator.Stuns:GetAttribute("1") == false
  174. game:GetService("ReplicatedStorage").RemoteFunction:InvokeServer("Troops","Abilities","Activate",{["Troop"] = Tower ,["Name"] = "Call Of Arms"})
  175. Status(Info,"Commander "..Info..": Actived")
  176. task.wait(10.01)
  177. Status(Info,"Commander "..Info..": Waiting")
  178. end
  179. elseif Tower.TowerReplicator:GetAttribute("Upgrade") < 2 then
  180. local OldTime = os.clock()
  181. local Times,Exec = 0,0
  182. repeat
  183. task.spawn(function()
  184. if Tower:FindFirstChild("AnimationController") then
  185. Status(Info,"Commander "..Info..": Low Level")
  186. else
  187. Status(Info,"Commander "..Info..": Skipping")
  188. end
  189. game:GetService("ReplicatedStorage").RemoteFunction:InvokeServer("Troops","Abilities","Activate",{["Troop"] = Tower ,["Name"] = "Call Of Arms"})
  190. Exec = Exec + 1
  191. end)
  192. Times = Times + 2.5
  193. --prints(Times)
  194. task.wait(.242)
  195. until (Tower:FindFirstChild("AnimationController") and tostring(Tower:FindFirstChild("AnimationController"):GetPlayingAnimationTracks()[4]) == "Stance") or Times >= 99
  196. --local TimeNeed = math.floor((os.clock() - OldTime)*100+0.5)/100
  197. local TimeLost = os.clock() - OldTime
  198. --prints(," Time:",os.clock() - OldTime)
  199. if Tower:FindFirstChild("AnimationController") and tostring(Tower:FindFirstChild("AnimationController"):GetPlayingAnimationTracks()[4]) == "Stance" then
  200. Status(Info,"Commander "..Info..": Actived")
  201. task.wait(10-0.24)
  202. end
  203. if (os.clock() - OldTime) < 9.999 then
  204. prints("Time Lower:",os.clock() - OldTime)
  205. task.wait(0.025)
  206. end
  207. local TimeTotal = os.clock() - OldTime
  208. Status(Info,"Commander "..Info..": Waiting")
  209. prints("Total Time:",TimeTotal,"Execute:",Exec)
  210. prints("Time Waiting",TimeTotal-TimeLost,"Time Lost",TimeLost)
  211. end
  212. else
  213. Status(Info,"Commander "..Info..": Skipping")
  214. task.wait(10.01)
  215. Status(Info,"Commander "..Info..": Waiting")
  216. end
  217. if not Status(Type) and (Info == 3 or Info == 6) then
  218. local Info = Info - 2
  219. Status(Info,"Commander "..Info..": Prepare")
  220. end
  221. end
  222. task.spawn(function()
  223. while task.wait() do
  224. if w.flags.autochain and not CancelLoop then
  225. Chain(troops[1],"autochain")
  226. Chain(troops[2],"autochain")
  227. Chain(troops[3],"autochain")
  228. elseif CancelLoop then
  229. CancelLoop = false
  230. break
  231. end
  232. end
  233. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement