Advertisement
ChaosityYT

Swordburst 2 Autofarm

Aug 5th, 2019
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.00 KB | None | 0 0
  1. local Rawr = {}
  2. local Api = {}
  3. local Log = {}
  4.  
  5. local function Service(name)
  6. return game:GetService(name)
  7. end
  8.  
  9. local function SecondsToClock(seconds)
  10. -- https://gist.github.com/jesseadams/791673
  11. local seconds = tonumber(seconds)
  12. if seconds <= 0 then
  13. return "00:00:00";
  14. else
  15. local hours = string.format("%02.f", math.floor(seconds/3600));
  16. local mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)));
  17. local secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60));
  18. return hours..":"..mins..":"..secs
  19. end
  20. end
  21.  
  22. function Log:Init()
  23. local Profile = game:GetService("ReplicatedStorage").Profiles[Api.GetPlayer().Name]
  24. local Vel = Profile.Stats.Vel
  25. local LastVel = Vel.Value
  26. Log.Earned = {
  27. Vel = 0,
  28. Items = {},
  29. }
  30. Profile.Inventory.ChildAdded:Connect(function(item)
  31. table.insert(Log.Earned.Items, item.Name)
  32. if(Api.GetSetting("auto_dismantle") == true)then
  33. Api.Dismantle(item.Name)
  34. end
  35. end)
  36. Vel.Changed:Connect(function()
  37. local earn = Vel.Value - LastVel
  38. LastVel = Vel.Value
  39. Log.Earned.Vel = Log.Earned.Vel + earn
  40. end)
  41. end
  42.  
  43. function Log.Save()
  44. Log.Earned.RunTime = SecondsToClock(tick()-Api.Start)
  45. Synapse:WriteFile(tick() .. "_log.dat", game:GetService("HttpService"):JSONEncode(Log.Earned))
  46. end
  47.  
  48. function Rawr:Check(...) --secret sauce
  49. local player = Api.GetPlayer()
  50. local character = Api.GetCharacter()
  51. local args = {...}
  52.  
  53. if(character and character.PrimaryPart and args[1]:lower()=="cframe")then
  54. --player.Character = Api.FakeCharacter
  55. player.Character.RobloxLocked = true
  56. wait(Api.GetSetting("rawr_bypass_speed"))
  57. character:SetPrimaryPartCFrame(args[2])
  58. wait(Api.GetSetting("rawr_bypass_speed"))
  59. --player.Character = character
  60. player.Character.RobloxLocked = false
  61. end
  62. end
  63.  
  64. function Api.GetPlayer()
  65. return game:GetService("Players").LocalPlayer
  66. end
  67.  
  68. function Api.Dismantle(name)
  69. game.ReplicatedStorage.Event:FireServer("Equipment", {
  70. "Dismantle",
  71. game:GetService("ReplicatedStorage").Profiles[Api.GetPlayer().Name].Inventory[name]
  72. })
  73. end
  74.  
  75. function Api.Replicate(object)
  76. local Model = Instance.new("Model")
  77. Model.Name = object.Name
  78. for index, child in pairs(object:GetChildren()) do
  79. local c = child:Clone()
  80. c.Parent = Model
  81. end
  82. if(object.PrimaryPart)then
  83. Model.PrimaryPart = Model[object.PrimaryPart.Name]
  84. end
  85. return Model
  86. end
  87.  
  88. function Api.GetCharacter()
  89. return Api.Character or Api.GetPlayer().Character
  90. end
  91.  
  92. function Api.GetEntity(model)
  93. return model:FindFirstChild("Entity")
  94. end
  95.  
  96. function Api.Settings(...)
  97. Api.Settings = {}
  98. for name, value in pairs(...) do
  99. Api.Settings[name] = value
  100. end
  101. end
  102.  
  103. function Api.GetSetting(name)
  104. return Api.Settings[name]
  105. end
  106.  
  107. function Api.IsValid(model)
  108. if(model.PrimaryPart and model:FindFirstChild("Entity") and model.Entity:FindFirstChild("Health") and model.Parent~=nil and model:FindFirstChild("Nameplate"))then
  109. return true
  110. end
  111. end
  112.  
  113. function Api.GetPlayerDistances(model)
  114. local localPlayer = Api.GetPlayer()
  115. local distances = {}
  116. for index, player in pairs(Service("Players"):GetChildren()) do
  117. if(player~=localPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") and model:FindFirstChild("HumanoidRootPart"))then
  118. distances[player.Name] = (model.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude
  119. end
  120. end
  121. return distances
  122. end
  123.  
  124. function Api.CheckNear(monster)
  125. if(Api.GetSetting("avoid_players_nearby")["Enabled"] == true)then
  126. local max_distance = Api.GetSetting("avoid_players_nearby")["Distance"]
  127. local distances = Api.GetPlayerDistances(monster)
  128. for player, distance in pairs(distances)do
  129. if(distance <= max_distance)then
  130. return false
  131. end
  132. end
  133. end
  134. return true
  135. end
  136.  
  137. function Api.CheckBlacklist(monster)
  138. for index, blacklist in pairs(Api.Blacklist) do
  139. if(monster == blacklist)then
  140. return false
  141. end
  142. end
  143. return true
  144. end
  145.  
  146. function Api.GetMonsters()
  147. local targets = {}
  148. for index, monster in pairs(Service("Workspace").Mobs:GetChildren()) do
  149. local entity = monster:FindFirstChildOfClass("Folder")
  150. local filterApplied = false
  151. local distanceCheck = Api.CheckNear(monster)
  152. if(monster.PrimaryPart and Api.IsValid(monster) and distanceCheck and Api.CheckBlacklist(monster))then
  153. if(Api.GetSetting("monster_filter")["Enabled"] == true)then
  154. if(entity.Health.Value >= Api.GetSetting("monster_filter")["max_monster_health"] and entity.Exp.Value >= Api.GetSetting("monster_filter")["min_exp_earned"])then
  155. table.insert(targets, monster)
  156. end
  157. filterApplied = true
  158. elseif(Api.GetSetting("target_specific_enemy").Enabled == true)then
  159. if(Api.GetSetting("target_specific_enemy").Names[monster.Nameplate.SurfaceGui.TextLabel.Text] == true)then
  160. table.insert(targets, monster)
  161. end
  162. filterApplied = true
  163. end
  164. if(filterApplied == false)then
  165. table.insert(targets, monster)
  166. end
  167. end
  168. end
  169. return targets
  170. end
  171.  
  172. function Api:Connect()
  173. local player = Api.GetPlayer()
  174. local character = Api.GetCharacter()
  175. local setupCharacter = function(character)
  176. Api.FakeCharacter = Api.Replicate(character)
  177. end
  178.  
  179. setupCharacter(character)
  180. player.CharacterAdded:Connect(setupCharacter)
  181. end
  182.  
  183. function Api:SetKeys()
  184. game:GetService("UserInputService").InputBegan:connect(function(Key)
  185. if(Key.KeyCode == Api.GetSetting("stop_key"))then
  186. Api.Enabled = false
  187. elseif(Key.KeyCode == Api.GetSetting("pause_key"))then
  188. Api.Paused = true
  189. elseif(Key.KeyCode == Api.GetSetting("unpause_key"))then
  190. Api.Paused = false
  191. end
  192. end)
  193. end
  194.  
  195. function Api:Init()
  196. Api.Blacklist = {}
  197. Api.Start = tick()
  198. Api.Paused = false
  199. Api.CanClick = false
  200. Api.Enabled = true
  201. wait(Api.GetSetting("StartDelay"))
  202. spawn(function()
  203. while wait(Api.GetSetting("click_break_speed")) and Api.Enabled do
  204. if(Api.Paused == false and Api.CanClick == true)then
  205. if(mouse1click)then
  206. mouse1click()
  207. end
  208. else
  209. wait()
  210. end
  211. end
  212. end)
  213. while wait() and Api.Enabled do
  214. if(Api.Paused == false)then
  215. for index, monster in pairs(Api.GetMonsters()) do
  216. local distanceCheck = Api.CheckNear(monster)
  217. if(distanceCheck and Api.IsValid(monster) and Api.Enabled)then -- recheck
  218. Rawr:Check("CFrame", monster:GetPrimaryPartCFrame() * CFrame.new(0, 0, 3)) -- bypass
  219. wait(Api.GetSetting("swap_monster_speed"))
  220. local entity = Api.GetEntity(monster)
  221. local base = entity.Health.Value
  222. entity.Health.Changed:Connect(function()
  223. if(entity.Health.Value == base)then
  224. dontBreak = false
  225. end
  226. end)
  227. dontBreak = true
  228. local timer = 0
  229. while dontBreak and Api.Enabled do
  230. if(Api.Paused == false)then
  231. local thisTime = wait()
  232. wait(thisTime)
  233. timer = timer + thisTime
  234. if(timer >= Api.GetSetting("timeout")["time"])then
  235. warn('Timeout exceeded!')
  236. if(Api.GetSetting("timeout")["blacklist_monster_after_timeout"] == true)then
  237. table.insert(Api.Blacklist, monster)
  238. end
  239. break
  240. end
  241. if(Api.IsValid(monster) and entity.Health.Value > 0)then
  242. local character = Api.GetCharacter()
  243. if(character)then
  244. Api.CanClick = true
  245. character:SetPrimaryPartCFrame(monster:GetPrimaryPartCFrame() * CFrame.new(0, 0, 3))
  246. else
  247. character = Api.GetCharacter()
  248. if(character)then
  249. Rawr:Check("CFrame", monster:GetPrimaryPartCFrame() * CFrame.new(0, 0, 3)) -- bypass
  250. wait(Api.GetSetting("swap_monster_speed"))
  251. end
  252. end
  253. else
  254. Api.CanClick = false
  255. break
  256. end
  257. else
  258. wait()
  259. end
  260. end
  261. wait(Api.GetSetting("swap_monster_speed"))
  262. end
  263. end
  264. end
  265. end
  266. Log.Save()
  267. end
  268.  
  269. Api.Settings({
  270. ["start_delay"] = 2,
  271. ["stop_key"] = Enum.KeyCode.Escape,
  272. ["pause_key"] = Enum.KeyCode.LeftControl,
  273. ["unpause_key"] = Enum.KeyCode.RightControl,
  274. ["rawr_bypass_speed"] = 0.5, -- 0.65
  275. ["swap_monster_speed"] = 0.5, -- 0.7,
  276. ["click_break_speed"] = 0.1,
  277. ["auto_dismantle"] = true,
  278. ["timeout"] = {
  279. ["time"] = 15,
  280. ["blacklist_monster_after_timeout"] = true
  281. },
  282. ["monster_filter"] = {
  283. ["Enabled"] = false,
  284. ["max_monster_health"] = 0,
  285. ["min_exp_earned"] = 0,
  286. },
  287. ["avoid_players_nearby"] = {
  288. ["Enabled"] = true,
  289. ["Distance"] = 200
  290. },
  291. ["target_specific_enemy"] = {
  292. ["Enabled"] = false,
  293. ["Names"] = {
  294. ["Giant Ruins Hornet"] = true,
  295. ["Petal Knight"] = true,
  296. ["Giant Praying Mantis"] = true,
  297. ["Gargoyle Reaper"] = true,
  298. ["Mortis the Flaming Sear"] = true,
  299. }
  300. }
  301. })
  302.  
  303. Api:SetKeys()
  304. Api:Connect()
  305. Log:Init()
  306. Api:Init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement