Yingyang005

Bladers Rebirth V2

Jan 20th, 2025 (edited)
884
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.99 KB | None | 0 0
  1. -- Services
  2. local Players = game:GetService("Players")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4. local RunService = game:GetService("RunService")
  5. local VirtualUser = game:GetService("VirtualUser")
  6.  
  7. -- Packages
  8. local Rayfield = loadstring(game:HttpGet("https://raw.githubusercontent.com/SiriusSoftwareLtd/Rayfield/main/source.lua"))()
  9. local Maid = loadstring(game:HttpGet("https://raw.githubusercontent.com/Quenty/NevermoreEngine/refs/heads/main/src/maid/src/Shared/Maid.lua"))()
  10. local Signal = loadstring(game:HttpGet("https://raw.githubusercontent.com/Sleitnick/RbxUtil/refs/heads/main/modules/signal/init.luau"))()
  11.  
  12. -- Constants
  13. local GENERAL_POLL_DELAY = 0.1
  14.  
  15. -- Controllers
  16. local AutofarmController = {}
  17. local MiscController = {}
  18. local UIController = {}
  19.  
  20. -- Classes
  21. local BaseFarmStrategy = {}
  22. local RockFarmStrategy = {}
  23.  
  24. local BaseNPCBattleStrategy = {}
  25. local TrainerFarmStrategy = {}
  26. local BossFarmStrategy = {}
  27.  
  28. -- Variables
  29. local Client = Players.LocalPlayer
  30.  
  31. local EventsFolder = ReplicatedStorage.Events
  32. local BeybladesFolder = workspace.Beyblades
  33. local TrainingFolder = workspace.Training
  34. local NPCsFolder = workspace.NPCs
  35. local RemotesFolder = ReplicatedStorage.Events
  36.  
  37. local RNG = Random.new()
  38.  
  39. -- Class Definitions
  40. do
  41. BaseFarmStrategy.__index = BaseFarmStrategy
  42.  
  43. function BaseFarmStrategy.new()
  44. local self = setmetatable({}, BaseFarmStrategy)
  45. self._LastAttack = 9999999
  46. self._Maid = Maid.new()
  47. return self
  48. end
  49.  
  50. function BaseFarmStrategy:Start()
  51. -- Override in child classes
  52. end
  53.  
  54. function BaseFarmStrategy:Update()
  55. -- Override in child classes
  56. end
  57.  
  58. function BaseFarmStrategy:Destroy()
  59. self._Maid:DoCleaning()
  60. self._Maid = nil
  61. end
  62. end
  63.  
  64. do
  65. setmetatable(RockFarmStrategy, BaseFarmStrategy)
  66. RockFarmStrategy.__index = RockFarmStrategy
  67.  
  68. function RockFarmStrategy.new()
  69. local self = setmetatable(BaseFarmStrategy.new(), RockFarmStrategy)
  70. self._CurrentTarget = nil
  71.  
  72. self._Maid:GiveTask(function()
  73. self._CurrentTarget = nil
  74. AutofarmController:UnlaunchBeyblade()
  75. end)
  76.  
  77. return self
  78. end
  79.  
  80. function RockFarmStrategy:ScanForTarget()
  81. local TargetRockName: string = UIController:GetSelectedRockName()
  82. for _, Rock: Model in TrainingFolder:GetChildren() do
  83. if Rock.PrimaryPart and Rock.PrimaryPart.Position.Y > 1000 then continue end
  84. if Rock.Name ~= TargetRockName then continue end
  85. if Rock:GetAttribute("Health") <= 0 then continue end
  86. self._CurrentTarget = Rock
  87. break
  88. end
  89. end
  90.  
  91. function RockFarmStrategy:Update()
  92. local ClientBeyblade: Model = AutofarmController:GetClientBeyblade()
  93. if not ClientBeyblade or not self._CurrentTarget then return end
  94.  
  95. -- Attack logic
  96. if os.clock() - self._LastAttack >= GENERAL_POLL_DELAY then
  97. self._LastAttack = os.clock()
  98. AutofarmController:Attack(self._CurrentTarget)
  99. AutofarmController:FireSkills(self._CurrentTarget)
  100. end
  101.  
  102. -- Teleport logic
  103. ClientBeyblade.HumanoidRootPart.CFrame = self._CurrentTarget.PrimaryPart.CFrame * CFrame.new(0, 1, 0)
  104. end
  105.  
  106. function RockFarmStrategy:Start()
  107. -- Initial Beyblade launch
  108. AutofarmController:LaunchBeyblade()
  109.  
  110. -- Initial scan for valid target
  111. self:ScanForTarget()
  112.  
  113. -- Handle beyblade tracking
  114. self._Maid:GiveTask(BeybladesFolder.ChildRemoved:Connect(function(Beyblade: Model)
  115. if Beyblade.Name == Client.Name then
  116. task.wait(self.GENERAL_POLL_DELAY)
  117. AutofarmController:LaunchBeyblade()
  118. end
  119. end))
  120.  
  121. -- Handle rock tracking
  122. self._Maid:GiveTask(TrainingFolder.ChildAdded:Connect(function(Rock: Model)
  123. task.wait()
  124. local TargetRockName = UIController:GetSelectedRockName()
  125. if Rock.Name ~= TargetRockName then return end
  126.  
  127. if Rock.PrimaryPart and Rock.PrimaryPart.Position.Y < 1000 then
  128. if not self._CurrentTarget then
  129. self._CurrentTarget = Rock
  130. end
  131. end
  132. end))
  133.  
  134. self._Maid:GiveTask(TrainingFolder.ChildRemoved:Connect(function(Rock: Model)
  135. if Rock == self._CurrentTarget then
  136. self._CurrentTarget = nil
  137. self:ScanForTarget()
  138. end
  139. end))
  140.  
  141. self._Maid:GiveTask(UIController.OnRockTargetTypeChanged:Connect(function()
  142. -- Scan for a new target after changing the type of rock we want to target
  143. self:ScanForTarget()
  144. end))
  145. end
  146. end
  147.  
  148. do
  149. setmetatable(BaseNPCBattleStrategy, BaseFarmStrategy)
  150. BaseNPCBattleStrategy.__index = BaseNPCBattleStrategy
  151.  
  152. type DialogueChoice = {
  153. Id: number,
  154. Text: string,
  155. Type: string?,
  156. }
  157.  
  158. function BaseNPCBattleStrategy.new()
  159. local self = setmetatable(BaseFarmStrategy.new(), BaseNPCBattleStrategy)
  160. self._CurrentNPC = nil
  161. self._NPCBeyblade = nil
  162.  
  163. self._Maid:GiveTask(function()
  164. self._CurrentNPC = nil
  165. self._NPCBeyblade = nil
  166. end)
  167.  
  168. return self
  169. end
  170.  
  171. function BaseNPCBattleStrategy:HandleDialogue(Responses: { DialogueChoice }, NPC: Model)
  172. if not Responses or not NPC then return end
  173.  
  174. local FirstResponseId, FirstReplyId
  175.  
  176. for _, Choice in ipairs(Responses) do
  177. if Choice.Type == "Response" and not FirstResponseId then
  178. FirstResponseId = Choice.Id
  179. elseif Choice.Type == "Reply" and not FirstReplyId then
  180. FirstReplyId = Choice.Id
  181. end
  182. end
  183.  
  184. local DelayTime = FirstReplyId and 2 or 0.5
  185. local ChoiceId = FirstReplyId or FirstResponseId
  186.  
  187. task.wait(DelayTime)
  188. AutofarmController:FireServer("DialogueChoice", ChoiceId)
  189. end
  190.  
  191. function BaseNPCBattleStrategy:Update()
  192. local ClientBeyblade: Model = AutofarmController:GetClientBeyblade()
  193.  
  194. if not ClientBeyblade or not self._NPCBeyblade then return end
  195.  
  196. -- Attack logic
  197. if os.clock() - self._LastAttack >= GENERAL_POLL_DELAY then
  198. self._LastAttack = os.clock()
  199. AutofarmController:Attack(self._NPCBeyblade)
  200. AutofarmController:FireSkills(self._NPCBeyblade)
  201. end
  202.  
  203. -- Teleport logic
  204. ClientBeyblade.HumanoidRootPart.CFrame = self._NPCBeyblade.HumanoidRootPart.CFrame * CFrame.new(0, 1, 0)
  205. end
  206.  
  207. function BaseNPCBattleStrategy:Start()
  208. self._Maid:GiveTask(task.spawn(function()
  209. while true do
  210. task.wait(0.5)
  211. if self._CurrentNPC then
  212. local CooldownEndTime = self._CurrentNPC:GetAttribute("CooldownEnd")
  213. if CooldownEndTime and os.time() < CooldownEndTime then
  214. self:BeginFarming()
  215. end
  216. else
  217. self:BeginFarming()
  218. end
  219. end
  220. end))
  221.  
  222. self._Maid:GiveTask(EventsFolder.UpdateDialogue.OnClientEvent:Connect(function(DialogueResponses, NPC)
  223. self:HandleDialogue(DialogueResponses, NPC)
  224. end))
  225.  
  226. self._Maid:GiveTask(BeybladesFolder.ChildAdded:Connect(function(Beyblade)
  227. task.wait(0.5)
  228. if Beyblade:GetAttribute("TargetPlayer") == Client.Name then
  229. self._NPCBeyblade = Beyblade
  230. end
  231. end))
  232.  
  233. self._Maid:GiveTask(BeybladesFolder.ChildRemoved:Connect(function(Beyblade)
  234. if Beyblade == self._NPCBeyblade then
  235. self._NPCBeyblade = nil
  236. task.wait(0.5)
  237. self:BeginFarming()
  238. end
  239. end))
  240.  
  241. self:BeginFarming()
  242. end
  243.  
  244. function BaseNPCBattleStrategy:BeginFarming()
  245. AutofarmController:UnlaunchBeyblade()
  246.  
  247. self._CurrentNPC = self:FindAvailableNPC()
  248. self._NPCBeyblade = nil
  249.  
  250. if not self._CurrentNPC then return end
  251.  
  252. local Character = Client.Character
  253. if not Character then return end
  254.  
  255. task.wait(1.5)
  256. Character.HumanoidRootPart.CFrame = self._CurrentNPC.HumanoidRootPart.CFrame
  257. task.wait(0.5)
  258. fireproximityprompt(self._CurrentNPC.HumanoidRootPart.Dialogue)
  259. end
  260.  
  261. function BaseNPCBattleStrategy:FindAvailableNPC()
  262. end
  263. end
  264.  
  265. do
  266. setmetatable(TrainerFarmStrategy, BaseNPCBattleStrategy)
  267. TrainerFarmStrategy.__index = TrainerFarmStrategy
  268.  
  269. function TrainerFarmStrategy.new()
  270. return setmetatable(BaseNPCBattleStrategy.new(), TrainerFarmStrategy)
  271. end
  272.  
  273. function TrainerFarmStrategy:FindAvailableNPC()
  274. for _, NPC in NPCsFolder:GetChildren() do
  275. if not string.find(NPC.Name, "Trainer") then continue end
  276.  
  277. local CooldownEndTime = NPC:GetAttribute("CooldownEnd")
  278. if CooldownEndTime and os.time() < CooldownEndTime then continue end
  279.  
  280. local NPCLevel = NPC:GetAttribute("Level")
  281. if NPCLevel < UIController:GetMinimumTrainerLevel() then continue end
  282. if NPCLevel > UIController:GetMaximumTrainerLevel() then continue end
  283.  
  284. return NPC
  285. end
  286.  
  287. return nil
  288. end
  289. end
  290.  
  291. do
  292. setmetatable(BossFarmStrategy, BaseNPCBattleStrategy)
  293. BossFarmStrategy.__index = BossFarmStrategy
  294.  
  295. function BossFarmStrategy.new()
  296. return setmetatable(BaseNPCBattleStrategy.new(), BossFarmStrategy)
  297. end
  298.  
  299. function BossFarmStrategy:FindAvailableNPC()
  300. for _, NPC in NPCsFolder:GetChildren() do
  301. if not string.find(NPC.Name, "Boss") then continue end
  302. if not table.find(UIController:GetTargetBossNames(), NPC:GetAttribute("Name")) then
  303. continue
  304. end
  305.  
  306. local CooldownEndTime = NPC:GetAttribute("CooldownEnd")
  307. if CooldownEndTime and os.time() < CooldownEndTime then continue end
  308.  
  309. return NPC
  310. end
  311.  
  312. return nil
  313. end
  314. end
  315.  
  316. -- Controller Definitions
  317. do
  318. local FarmStrategyClasses = {
  319. RockFarm = RockFarmStrategy,
  320. TrainerFarm = TrainerFarmStrategy,
  321. BossFarm = BossFarmStrategy
  322. }
  323.  
  324. local StatsModule = require(ReplicatedStorage.Modules.Stats)
  325.  
  326. function AutofarmController:FireServer(RemoteName, ...)
  327. RemotesFolder[RemoteName]:FireServer(...)
  328. end
  329.  
  330. function AutofarmController:Attack(Target: Model)
  331. local AttackRemote = RemotesFolder:FindFirstChild("Attack")
  332. if not AttackRemote then return end
  333.  
  334. local ClientBeyblade = self:GetClientBeyblade()
  335. if not ClientBeyblade then return end
  336.  
  337. local TargetPosition = Target.PrimaryPart.Position
  338. local RandomValue = RNG:NextNumber(0.85, 0.9)
  339.  
  340. AttackRemote:FireServer("Attack", ClientBeyblade, Target, RandomValue, TargetPosition)
  341. end
  342.  
  343. function AutofarmController:FireSkills(Target: Model)
  344. local EquippedBeyblade = nil
  345. for _, Item in StatsModule.Inventory.Items do
  346. if Item.Name == "Beyblade" and Item.Equipped then
  347. EquippedBeyblade = Item
  348. break
  349. end
  350. end
  351.  
  352. if not EquippedBeyblade then return end
  353.  
  354. local TargetPrimaryPart = Target.PrimaryPart
  355. local TargetPosition = TargetPrimaryPart.Position
  356.  
  357. -- Better method of firing skills without having to
  358. -- fire for every possible keybind regardless if it's equipped/unequipped
  359. for SkillIndex, _ in pairs(EquippedBeyblade.Skills) do
  360. -- RunSkill, returns debounce data which we could utilise
  361. -- FinishSkill, for 2nd arg I could've put any instance, since
  362. -- it doesn't affect the skill's performance
  363. RemotesFolder.SetPoint:FireServer(TargetPosition)
  364. task.spawn(function()
  365. -- May yield, so process in a thread
  366. RemotesFolder.RunSkill:InvokeServer("Skill" .. SkillIndex)
  367. end)
  368. RemotesFolder.FinishSkill:FireServer(TargetPosition, TargetPrimaryPart)
  369. end
  370. end
  371.  
  372. function AutofarmController:GetClientBeyblade() : Model
  373. return BeybladesFolder:FindFirstChild(Client.Name)
  374. end
  375.  
  376. function AutofarmController:LaunchBeyblade()
  377. local ClientBeyblade: Model = self:GetClientBeyblade()
  378. if not ClientBeyblade then
  379. repeat
  380. AutofarmController:FireServer("Launch")
  381. task.wait(GENERAL_POLL_DELAY)
  382. until self:GetClientBeyblade()
  383. end
  384. end
  385.  
  386. function AutofarmController:UnlaunchBeyblade()
  387. local Character = Client.Character
  388. if Character and Character:GetAttribute("Launching") then
  389. Character:GetAttributeChangedSignal("Launching"):Wait()
  390. end
  391. local ClientBeyblade: Model = self:GetClientBeyblade()
  392. if ClientBeyblade then
  393. repeat
  394. AutofarmController:FireServer("Launch")
  395. task.wait(GENERAL_POLL_DELAY)
  396. until not self:GetClientBeyblade()
  397. end
  398. end
  399.  
  400. function AutofarmController:SwitchStrategy(NewStrategyType: string?)
  401. if self.CurrentFarmStrategy then
  402. self.CurrentFarmStrategy:Destroy()
  403. self.CurrentFarmStrategy = nil
  404. end
  405.  
  406. if NewStrategyType and FarmStrategyClasses[NewStrategyType] then
  407. -- Create a new instance of the strategy class
  408. self.CurrentFarmStrategy = FarmStrategyClasses[NewStrategyType].new()
  409.  
  410. if UIController:IsBeybladeAutofarmToggled() then
  411. self.CurrentFarmStrategy:Start()
  412. end
  413. end
  414. end
  415.  
  416. function AutofarmController:Init()
  417. self.CurrentFarmStrategy = nil
  418. end
  419.  
  420. function AutofarmController:Start()
  421. local CharacterMaid = Maid.new()
  422.  
  423. local function OnCharacterAdded(Character)
  424. CharacterMaid:DoCleaning()
  425.  
  426. Character:WaitForChild("HumanoidRootPart")
  427. Character:WaitForChild("Humanoid")
  428.  
  429. -- Handle Beyblade autofarm updates
  430. CharacterMaid:GiveTask(RunService.Heartbeat:Connect(function()
  431. if not UIController:IsBeybladeAutofarmToggled() then return end
  432. if self.CurrentFarmStrategy then
  433. self.CurrentFarmStrategy:Update()
  434. end
  435. end))
  436.  
  437. -- Handle priority changes
  438. CharacterMaid:GiveTask(UIController.OnHighestPriorityFarmChanged:Connect(function(NewHighestFarmType: string?)
  439. self:SwitchStrategy(NewHighestFarmType)
  440. end))
  441.  
  442. CharacterMaid:GiveTask(UIController.OnBeybladeAutofarmToggled:Connect(function(IsEnabled: boolean)
  443. local CurrentStrategy = self.CurrentFarmStrategy
  444.  
  445. if CurrentStrategy then
  446. if IsEnabled then
  447. CurrentStrategy:Start()
  448. else
  449. self:SwitchStrategy(nil)
  450. end
  451. elseif IsEnabled then
  452. self:SwitchStrategy(UIController:GetHighestPriorityFarm())
  453. end
  454. end))
  455.  
  456. -- Cleanup
  457. CharacterMaid:GiveTask(function()
  458. self:SwitchStrategy(nil) -- Clean up current strategy
  459. end)
  460. end
  461.  
  462. Client.CharacterAdded:Connect(OnCharacterAdded)
  463. if Client.Character then
  464. task.spawn(OnCharacterAdded, Client.Character)
  465. end
  466. end
  467. end
  468.  
  469. do
  470. local CONFIG_FOLDER_NAME: string = "TEST-CONFIG1"
  471.  
  472. UIController.OnBeybladeAutofarmToggled = Signal.new()
  473.  
  474. UIController.OnTrainerFarmToggled = Signal.new()
  475. UIController.OnBossFarmToggled = Signal.new()
  476. UIController.OnRockFarmToggled = Signal.new()
  477.  
  478. UIController.OnHighestPriorityFarmChanged = Signal.new()
  479. UIController.OnRockTargetTypeChanged = Signal.new()
  480.  
  481. UIController.OnTrainerLevelChanged = Signal.new()
  482.  
  483. UIController.OnStaffAutoKickChanged = Signal.new()
  484.  
  485. -- State management
  486. UIController.State = {
  487. IsAutofarmEnabled = false,
  488. ActiveFarms = {
  489. RockFarm = {
  490. Enabled = false,
  491. Priority = 5,
  492. SelectedRock = "Rock"
  493. },
  494.  
  495. TrainerFarm = {
  496. Enabled = false,
  497. Priority = 5,
  498. MinimumLevel = 5,
  499. MaximumLevel = 5
  500. },
  501.  
  502. BossFarm = {
  503. Enabled = false,
  504. Priority = 5
  505. }
  506. }
  507. }
  508.  
  509. -- Helpers
  510. function UIController:_CheckAndFirePriorityChange()
  511. local NewHighestPriorityFarm = self:GetHighestPriorityFarm()
  512.  
  513. -- Store the last highest priority farm if we haven't yet
  514. if not self._LastHighestPriorityFarm then
  515. self._LastHighestPriorityFarm = NewHighestPriorityFarm
  516. self.OnHighestPriorityFarmChanged:Fire(NewHighestPriorityFarm, nil)
  517. return
  518. end
  519.  
  520. -- If the highest priority farm has changed, fire the signal
  521. if self._LastHighestPriorityFarm ~= NewHighestPriorityFarm then
  522. self.OnHighestPriorityFarmChanged:Fire(NewHighestPriorityFarm, self._LastHighestPriorityFarm)
  523. self._LastHighestPriorityFarm = NewHighestPriorityFarm
  524. end
  525. end
  526.  
  527. -- State getters
  528. function UIController:IsBeybladeAutofarmToggled(): boolean
  529. return self.State.IsAutofarmEnabled
  530. end
  531.  
  532. function UIController:GetSelectedRockName(): string
  533. return self.State.ActiveFarms.RockFarm.SelectedRock
  534. end
  535.  
  536. function UIController:GetMaximumTrainerLevel()
  537. return self.State.ActiveFarms.TrainerFarm.MaximumLevel
  538. end
  539.  
  540. function UIController:GetMinimumTrainerLevel()
  541. return self.State.ActiveFarms.TrainerFarm.MinimumLevel
  542. end
  543.  
  544. function UIController:GetTargetBossNames()
  545. return Rayfield.Flags.SelectedBossToFarm.CurrentOption
  546. end
  547.  
  548. function UIController:GetHighestPriorityFarm(): nil | string
  549. local HighestPriority: number = -1
  550. local SelectedFarm: (nil | string) = nil
  551.  
  552. for FarmType: string, FarmData in self.State.ActiveFarms do
  553. if FarmData.Enabled and FarmData.Priority > HighestPriority then
  554. HighestPriority = FarmData.Priority
  555. SelectedFarm = FarmType
  556. end
  557. end
  558.  
  559. return SelectedFarm
  560. end
  561.  
  562. function UIController:CanStaffAutoKick()
  563. return Rayfield.Flags.CanStaffAutoKick.CurrentValue
  564. end
  565.  
  566. -- State setters
  567. function UIController:SetAutofarmEnabled(IsEnabled: boolean)
  568. self.State.IsAutofarmEnabled = IsEnabled
  569. self.OnBeybladeAutofarmToggled:Fire(IsEnabled)
  570. end
  571.  
  572. function UIController:SetSelectedRock(RockName: string)
  573. self.State.ActiveFarms.RockFarm.SelectedRock = RockName
  574. self.OnRockTargetTypeChanged:Fire()
  575. end
  576.  
  577. function UIController:SetFarmState(FarmType: string, IsEnabled: boolean, Priority: number?)
  578. if IsEnabled ~= nil then
  579. self.State.ActiveFarms[FarmType].Enabled = IsEnabled
  580. end
  581.  
  582. if Priority then
  583. self.State.ActiveFarms[FarmType].Priority = Priority
  584. end
  585.  
  586. -- Check if this change affected the highest priority farm
  587. self:_CheckAndFirePriorityChange()
  588. end
  589.  
  590. function UIController:Start()
  591. end
  592.  
  593. function UIController:Init()
  594. local Window = Rayfield:CreateWindow({
  595. Name = "YINHUB V3|Blader's Rebirth",
  596. LoadingTitle = "Loading User Interface",
  597. LoadingSubtitle = "Script Credits: LYME",
  598.  
  599. ConfigurationSaving = {
  600. Enabled = true,
  601. FolderName = CONFIG_FOLDER_NAME
  602. },
  603.  
  604. KeySystem = false
  605. })
  606.  
  607. UIController:_CreateFarmTab(Window)
  608. UIController:_CreateMiscTab(Window)
  609. Rayfield:LoadConfiguration()
  610. end
  611.  
  612. function UIController:_CreateMiscTab(Window)
  613. local Tab = Window:CreateTab("Misc", 4483362458)
  614.  
  615. -- Staff Management Section
  616. Tab:CreateSection("Staff Manangement")
  617. Tab:CreateToggle({
  618. Name = "Staff Auto-Kick",
  619. CurrentValue = false,
  620. Flag = "CanStaffAutoKick",
  621. Callback = function(State)
  622. self.OnStaffAutoKickChanged:Fire(State)
  623. end,
  624. })
  625. end
  626.  
  627. function UIController:_CreateFarmTab(Window)
  628. local Tab = Window:CreateTab("Farming", 4483362458)
  629.  
  630. -- Main Autofarm Toggle Section
  631. Tab:CreateSection("Main Controls")
  632.  
  633. Tab:CreateToggle({
  634. Name = "Enable Beyblade Autofarm",
  635. CurrentValue = self.State.IsAutofarmEnabled,
  636. Flag = "MainAutofarmToggle",
  637. Callback = function(State)
  638. self:SetAutofarmEnabled(State)
  639. end,
  640. })
  641.  
  642. -- Rock Farm Section
  643. Tab:CreateSection("Auto Rock Farm")
  644.  
  645. local RockList = {
  646. "Rock", "Large Rock", "Cobblestone", "Metal", "Large Metal Rock",
  647. "Blood Rock", "Bluesteel Rock", "Large Bluesteel Rock",
  648. "Sandstone", "Sandcastle", "Cactus", "Glacier", "Ice Crystal",
  649. "Water Rock", "Giant Water Rock", "Ghost Tear", "Darkstone",
  650. "Molten Rock", "Large Darkstone", "Portable Crystal", "Boulder"
  651. }
  652.  
  653. -- Add anything extra we missed out
  654. for _, Rock in TrainingFolder:GetChildren() do
  655. if not table.find(RockList, Rock.Name) then continue end
  656. table.insert(RockList, Rock.Name)
  657. end
  658.  
  659. Tab:CreateDropdown({
  660. Name = "Select Rock to Farm",
  661. Options = RockList,
  662. CurrentOption = {self.State.ActiveFarms.RockFarm.SelectedRock},
  663. Flag = "SelectedRockToFarm",
  664. Callback = function(Option)
  665. self:SetSelectedRock(Option[1])
  666. end
  667. })
  668.  
  669. --[[
  670. Tab:CreateSlider({
  671. Name = "Priority",
  672. Range = {0, 10},
  673. Increment = 1,
  674. Suffix = "Priority",
  675. CurrentValue = self.State.ActiveFarms.RockFarm.Priority,
  676. Flag = "RockFarmPriority",
  677. Callback = function(Value)
  678. -- Update priority change
  679. self:SetFarmState("RockFarm", nil, Value)
  680. end,
  681. })
  682. --]]
  683.  
  684. Tab:CreateToggle({
  685. Name = "Rock Autofarm",
  686. CurrentValue = self.State.ActiveFarms.RockFarm.Enabled,
  687. Flag = "RockAutofarmToggle",
  688. Callback = function(State)
  689. self:SetFarmState("RockFarm", State)
  690. UIController.OnRockFarmToggled:Fire(State)
  691. end,
  692. })
  693.  
  694. -- Trainer NPC Autofarm Section
  695. Tab:CreateSection("Auto Trainer Farm")
  696.  
  697. -- Get the highest level trainer in the game
  698. local MaxTrainerLevel = -math.huge
  699. for _, NPC in NPCsFolder:GetChildren() do
  700. if not string.find(NPC.Name, "Trainer") then continue end
  701. local NPCLevel = NPC:GetAttribute("Level")
  702. if NPCLevel < MaxTrainerLevel then continue end
  703. MaxTrainerLevel = NPCLevel
  704. end
  705.  
  706. Tab:CreateSlider({
  707. Name = "Minimum Trainer Level",
  708. Range = {5, MaxTrainerLevel},
  709. Increment = 5,
  710. CurrentValue = self.State.ActiveFarms.TrainerFarm.MinimumLevel,
  711. Flag = "MinimumTrainerLevel",
  712. Callback = function(Value)
  713. self.State.ActiveFarms.TrainerFarm.MinimumLevel = tonumber(Value)
  714. self.OnTrainerLevelChanged:Fire()
  715. end,
  716. })
  717.  
  718. Tab:CreateSlider({
  719. Name = "Maximum Trainer Level",
  720. Range = {5, MaxTrainerLevel},
  721. Increment = 5,
  722. CurrentValue = self.State.ActiveFarms.TrainerFarm.MaximumLevel,
  723. Flag = "MaximumTrainerLevel",
  724. Callback = function(Value)
  725. self.State.ActiveFarms.TrainerFarm.MaximumLevel = tonumber(Value)
  726. self.OnTrainerLevelChanged:Fire()
  727. end,
  728. })
  729.  
  730. --[[
  731. Tab:CreateSlider({
  732. Name = "Priority",
  733. Range = {0, 10},
  734. Increment = 1,
  735. Suffix = "Priority",
  736. CurrentValue = self.State.ActiveFarms.TrainerFarm.Priority,
  737. Flag = "TrainerFarmPriority",
  738. Callback = function(Value)
  739. -- Update priority change
  740. self:SetFarmState("TrainerFarm", nil, Value)
  741. end,
  742. })
  743. --]]
  744.  
  745. Tab:CreateToggle({
  746. Name = "Trainer Autofarm",
  747. CurrentValue = false,
  748. Flag = "TrainerAutofarmToggle",
  749. Callback = function(State)
  750. self:SetFarmState("TrainerFarm", State)
  751. self.OnTrainerFarmToggled:Fire(State)
  752. end,
  753. })
  754.  
  755. -- Boss NPC Autofarm Section
  756. Tab:CreateSection("Auto Boss Farm")
  757.  
  758. local BossList = {}
  759. for _, NPC in ipairs(NPCsFolder:GetChildren()) do
  760. if not string.find(NPC.Name, "Boss") then continue end
  761. table.insert(BossList, NPC:GetAttribute("Name"))
  762. end
  763.  
  764. Tab:CreateDropdown({
  765. Name = "Select Bosses to Farm",
  766. Options = BossList,
  767. CurrentOption = {BossList[1]},
  768. Flag = "SelectedBossToFarm",
  769. MultipleOptions = true,
  770. Callback = function() end
  771. })
  772.  
  773. --[[
  774. Tab:CreateSlider({
  775. Name = "Priority",
  776. Range = {0, 10},
  777. Increment = 1,
  778. Suffix = "Priority",
  779. CurrentValue = self.State.ActiveFarms.BossFarm.Priority,
  780. Flag = "BossFarmPriority",
  781. Callback = function(Value)
  782. -- Update priority change
  783. self:SetFarmState("BossFarm", nil, Value)
  784. end,
  785. })
  786. --]]
  787.  
  788. Tab:CreateToggle({
  789. Name = "Boss Autofarm",
  790. CurrentValue = false,
  791. Flag = "BossAutofarmToggle",
  792. Callback = function(State)
  793. self:SetFarmState("BossFarm", State)
  794. self.OnBossFarmToggled:Fire(State)
  795. end,
  796. })
  797. end
  798.  
  799. function UIController:Notify(MessageData)
  800. Rayfield:Notify({
  801. Title = MessageData.Title,
  802. Content = MessageData.Content,
  803. Duration = MessageData.Duration,
  804. Image = 4483362458,
  805. })
  806. end
  807. end
  808.  
  809. do
  810. local GAME_GROUP_ID = 33103002
  811. local MINIMUM_GROUP_FLAG_RANK = 95 -- Minimum: Contributor rank
  812.  
  813. function MiscController:OnPlayerAdded(Player)
  814. if Player:GetRankInGroup(GAME_GROUP_ID) < MINIMUM_GROUP_FLAG_RANK then return end
  815.  
  816. local StaffName = Player.Name
  817. local StaffRole = Player:GetRoleInGroup(GAME_GROUP_ID)
  818.  
  819. local MessageContent = "Staff Name: " .. StaffName .. ", Staff Role/Rank: " .. StaffRole
  820. UIController:Notify({
  821. Title = "[WARNING] Staff In Game!",
  822. Content = MessageContent
  823. })
  824.  
  825. if UIController:CanStaffAutoKick() then
  826. Client:Kick("Kicked from game due to staff being in the same server! " .. MessageContent)
  827. end
  828. end
  829.  
  830. function MiscController:Init()
  831. UIController.OnStaffAutoKickChanged:Connect(function(IsEnabled)
  832. if not IsEnabled then return end
  833. for _, Player in Players:GetPlayers() do
  834. task.spawn(function()
  835. self:OnPlayerAdded(Player)
  836. end)
  837. end
  838. end)
  839.  
  840. Players.PlayerAdded:Connect(function(Player)
  841. self:OnPlayerAdded(Player)
  842. end)
  843.  
  844. for _, Player in Players:GetPlayers() do
  845. task.spawn(function()
  846. self:OnPlayerAdded(Player)
  847. end)
  848. end
  849. end
  850.  
  851. function MiscController:Start()
  852. end
  853. end
  854.  
  855. local function LoadControllers()
  856. -- Functions check
  857. for _, FunctionName in pairs({
  858. "getfenv",
  859. "getgc",
  860. "islclosure",
  861. "fireproximityprompt",
  862. "getupvalues"
  863. }) do
  864. assert(loadstring("return " .. FunctionName)(), "Function: " .. FunctionName .. " couldn't be found!")
  865. end
  866.  
  867. -- Grab network functions
  868. local NetworkModule = ReplicatedStorage.Modules.Network
  869. local NetworkFireMethod = nil
  870.  
  871. for _, Function in getgc() do
  872. if type(Function) == "function" and islclosure(Function) then
  873. if getfenv(Function).script == NetworkModule and getinfo(Function).name == "fire" then
  874. NetworkFireMethod = Function
  875. break
  876. end
  877. end
  878. end
  879.  
  880. -- Reverse Remote name randomisations
  881. for _, Upvalue in getupvalues(NetworkFireMethod) do
  882. if type(Upvalue) == "table" and Upvalue["Attack"] then
  883. for RemoteName, RemoteObject in Upvalue do
  884. RemoteObject.Name = RemoteName
  885. end
  886. break
  887. end
  888. end
  889.  
  890. -- Anti-idle/afk
  891. Client.Idled:Connect(function()
  892. VirtualUser:ClickButton2(Vector2.new())
  893. end)
  894.  
  895. -- Initialize controllers
  896. UIController:Init()
  897. AutofarmController:Init()
  898. MiscController:Init()
  899.  
  900. UIController:Start()
  901. AutofarmController:Start()
  902. MiscController:Start()
  903. end
  904.  
  905. LoadControllers()
Advertisement
Add Comment
Please, Sign In to add comment