Advertisement
Jelasion

Dq af

Feb 23rd, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 29.90 KB | None | 0 0
  1. repeat wait() until game:IsLoaded()
  2. local remotes = game:GetService("ReplicatedStorage"):WaitForChild("remotes")
  3. local LocalPlayer = game:GetService("Players").LocalPlayer
  4.  
  5. if game.PlaceId == 2414851778 then
  6.     repeat
  7.         remotes.loadPlayerCharacter:FireServer()
  8.         wait()
  9.     until LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("Humanoid") and LocalPlayer.Character:FindFirstChild("HumanoidRootPart") and LocalPlayer.Character:FindFirstChild("playerNameplate")
  10.  
  11.     remotes.createLobby:InvokeServer("Aquatic Temple", shared.Difficulty, 0, false, true, false)
  12.     remotes.startDungeon:FireServer()
  13.  
  14.     return;
  15. end;
  16.  
  17. if game.PlaceId ~= 6216785535 then return end
  18.  
  19. local HitboxManager = {}
  20. local DodgingManager = {}
  21. local EnemyManager = {}
  22. local Utilities = {}
  23.  
  24. game:GetService("LogService").MessageOut:Connect(function(Message)
  25.     if string.find(Message, "Server Kick Message:") then
  26.         game:GetService("TeleportService"):Teleport(2414851778)
  27.     end
  28. end)
  29.  
  30. local Player = game:GetService("Players").LocalPlayer
  31.  
  32. repeat wait() until Player.Character and Player.Character:FindFirstChild("HumanoidRootPart")
  33. remotes.changeStartValue:FireServer()
  34. wait(5)
  35.  
  36. local enemyProjectiles = game:GetService("ReplicatedStorage").enemyProjectiles
  37.  
  38. Player.Character.Humanoid.WalkSpeed = shared.Walkspeed
  39. Player.Character.Humanoid.AutoRotate = false
  40. local Heartbeat = game:GetService("RunService").Heartbeat
  41. local TweenService = game:GetService("TweenService")
  42.  
  43.  
  44. local projectiles = game:GetService("ReplicatedStorage").projectiles
  45.  
  46. local BackDistance = 50
  47. local AttackRange = 55
  48.  
  49. local floor = math.floor
  50. local max = math.max
  51.  
  52. local SpreadLine = {}
  53. local Laser = {}
  54.  
  55. HitboxManager.AllAttacks = {}
  56.  
  57. for i,v in next, workspace.borders:GetChildren() do
  58.     table.insert(HitboxManager.AllAttacks, v)
  59. end
  60.  
  61. local huge = math.huge
  62. local min = math.min
  63. local abs = math.abs
  64. local ceil = math.ceil
  65.  
  66. local GayThingy = false
  67.  
  68. DodgingManager.CheckSize = 4.8
  69.  
  70. do  
  71.     HitboxManager.Parts = {}
  72.     HitboxManager.RawParts = {}
  73.  
  74.     DodgingManager.Ignore = {"secondbossslamhitbox"}    
  75.  
  76.     local PathfindingService = game:GetService("PathfindingService")
  77.  
  78.     function EnemyManager:GetNearestEnemy()
  79.         local Nearest = nil
  80.         local Distance = huge
  81.         local CurrentPosition = Player.Character.HumanoidRootPart.Position
  82.  
  83.         for Index, Child in next, workspace.dungeon:GetChildren() do
  84.             if Child:FindFirstChild("enemyFolder") and Child.enemyFolder:FindFirstChildOfClass("Model") then
  85.                 for SecondIndex, Descendant in next, Child.enemyFolder:GetChildren() do
  86.                     if Descendant:IsA("Model") and Descendant:FindFirstChild("HumanoidRootPart") and Descendant:FindFirstChild("Humanoid") then
  87.                         local Magnitude = (CurrentPosition - Descendant.HumanoidRootPart.Position).Magnitude
  88.  
  89.                         if Magnitude < Distance then
  90.                             Distance = Magnitude
  91.                             Nearest = Descendant
  92.                         end
  93.                     end
  94.                 end
  95.             end
  96.         end
  97.  
  98.         if game.PlaceId == 6216785535 and Nearest and Nearest:FindFirstChild("HumanoidRootPart") and Nearest.HumanoidRootPart.Position.X >= -1330 and (Nearest.HumanoidRootPart.Position.Y >= -20 and Nearest.HumanoidRootPart.Position.Y < 0) then
  99.             local NewNearest
  100.             local NewDistance = huge
  101.            
  102.             for Index, Child in next, workspace.dungeon.room3.enemyFolder:GetChildren() do
  103.                 if Child:IsA("Model") and Child:FindFirstChild("HumanoidRootPart") and Child:FindFirstChild("Humanoid") and Child.HumanoidRootPart.Position.X < -1330 and Child.HumanoidRootPart.Position.Y < 0 then
  104.                     local Magnitude = (CurrentPosition - Child.HumanoidRootPart.Position).Magnitude
  105.    
  106.                     if Magnitude < NewDistance then
  107.                         NewDistance = Magnitude
  108.                         NewNearest = Child
  109.                     end
  110.                 end
  111.             end
  112.    
  113.             if NewNearest then
  114.                 return NewNearest
  115.             end
  116.         end
  117.  
  118.         if game.PlaceId == 6216785535 and Nearest and Nearest:FindFirstChild("HumanoidRootPart") and Nearest.HumanoidRootPart.Position.Y >= 90 then
  119.             local NewNearest
  120.             local NewDistance = huge
  121.            
  122.             for Index, Child in next, workspace.dungeon.room5.enemyFolder:GetChildren() do
  123.                 if Child:IsA("Model") and Child:FindFirstChild("HumanoidRootPart") and Child:FindFirstChild("Humanoid") and Child.HumanoidRootPart.Position.Y < 90 then
  124.                     local Magnitude = (CurrentPosition - Child.HumanoidRootPart.Position).Magnitude
  125.    
  126.                     if Magnitude < NewDistance then
  127.                         NewDistance = Magnitude
  128.                         NewNearest = Child
  129.                     end
  130.                 end
  131.             end
  132.    
  133.             if NewNearest then
  134.                 return NewNearest
  135.             end
  136.         end
  137.  
  138.         if game.PlaceId == 3041739550 and workspace:FindFirstChild("initialHunterBossEntry") then
  139.             local Clone = workspace.initialHunterBossEntry:Clone()
  140.             Clone.hitBox.CFrame = CFrame.new(Clone.hitBox.CFrame.X + 5, Clone.PrimaryPart.CFrame.Y, Clone.hitBox.CFrame.Z)
  141.             Clone.hitBox.Name = "HumanoidRootPart"
  142.  
  143.             return Clone
  144.         end
  145.  
  146.         return Nearest
  147.     end
  148.  
  149.     function HitboxManager:IsInstakillAttack(Part)
  150.         if Part.Name == "secondBossSlamHitbox" then
  151.             local hitBox = Part:WaitForChild("hitBox")
  152.  
  153.             if hitBox.Size.Z == 10 and hitBox.Size.Y == 150 and hitBox.Size.X % 10 == 0 and hitBox.Size.X >= 10 and hitBox.Size.X <= 150 then
  154.                 local Closest = EnemyManager:GetNearestEnemy()
  155.        
  156.                 if Closest and Closest.Name ~= "Sea King" then
  157.                     return true
  158.                 end
  159.             end
  160.         end
  161.  
  162.         return false
  163.     end
  164.  
  165.     function HitboxManager:IdentifyAttack(Part, Check)
  166.         local Name = Part.Name:lower()
  167.  
  168.         if Part.Parent and Part.Parent.Name == "firstBossLaserPrecast" then
  169.             wait()
  170.             if Part.Parent and table.find(Laser, Part.Parent) then
  171.                 return true
  172.             end
  173.         end
  174.  
  175.         if Part.Parent and HitboxManager:IsInstakillAttack(Part.Parent) then
  176.             return false
  177.         end
  178.  
  179.         if Part.Parent and Part.Parent.Name == "silkBlast" then
  180.             return true
  181.         end
  182.        
  183.         if not table.find(DodgingManager.Ignore, Name) then
  184.             if Part.Parent and Part.Parent.Name:lower() == "thirdbossspreadline" then
  185.                 if Part.Parent:FindFirstChild("precast") then
  186.                     if SpreadLine[Part.Parent] and SpreadLine[Part.Parent] < 2 then
  187.                         return true
  188.                     else
  189.                         if Part.Parent.precast.Transparency < 1 then
  190.                             if not SpreadLine[Part.Parent] then
  191.                                 SpreadLine[Part.Parent] = 0
  192.  
  193.                                 Part.Parent.precast:GetPropertyChangedSignal("Transparency"):connect(function()
  194.                                     if Part.Parent.precast.Transparency == 1 or Part.Parent.precast.Transparency == 0 then
  195.                                         SpreadLine[Part.Parent] = SpreadLine[Part.Parent] + 1
  196.                                     end
  197.                                 end)
  198.                             end
  199.  
  200.                             return true
  201.                         end
  202.                     end
  203.                 end
  204.             else
  205.                 if (Name:find("hitbox") or (Name:find("precast") and not Check)) and Part.Parent then
  206.                     if projectiles:FindFirstChild(Part.Parent.Name) then
  207.                         return false  
  208.                     end
  209.                     if Part.Parent:FindFirstChild("precast") then
  210.                         return Part.Parent.precast.Transparency < 1
  211.                     else
  212.                         return true
  213.                     end
  214.                 end
  215.             end
  216.         end
  217.        
  218.         return false
  219.     end
  220.  
  221.     function HitboxManager:Cast(Start, End)
  222.         local part = workspace:FindPartOnRayWithWhitelist(Ray.new(Start, End - Start), {workspace.borders, workspace.Terrain})
  223.  
  224.         return part
  225.     end
  226.  
  227.     function HitboxManager:IsSafe(Part, Path, Blacklist)
  228.         if GayThingy then
  229.             return true
  230.         end
  231.  
  232.         if not Player.Character or not Player.Character:FindFirstChild("HumanoidRootPart") then return end
  233.        
  234.         if typeof(Part) == "Instance" then
  235.             if HitboxManager:Cast(Player.Character.HumanoidRootPart.Position, Part.Position) and not Path then
  236.                 return false
  237.             end
  238.    
  239.             for Index, Attack in next, HitboxManager.AllAttacks do
  240.                 if HitboxManager:isInsideBrick(Part.Position, Attack) then
  241.                     return false
  242.                 end
  243.             end
  244.         else
  245.             if HitboxManager:Cast(Player.Character.HumanoidRootPart.Position, Part) and not Path then
  246.                 return false
  247.             end
  248.    
  249.             for Index, Attack in next, HitboxManager.AllAttacks do
  250.                 if HitboxManager:isInsideBrick(Part, Attack) and Attack.Parent and Attack.Parent.Name ~= "borders" and (not Blacklist or not table.find(Blacklist, Attack)) then
  251.                     return false
  252.                 end
  253.             end
  254.         end
  255.         return true
  256.     end
  257.  
  258.     function HitboxManager:isInsideBrick(position, brick)
  259.         local pos = brick.CFrame:PointToObjectSpace(position)
  260.         local Size = brick.Size + Vector3.new(DodgingManager.CheckSize, 0, DodgingManager.CheckSize)
  261.         return abs(pos.X) <= Size.X / 2 and abs(pos.Z) <= Size.Z / 2
  262.     end
  263.  
  264.     function DodgingManager:GetOptimalPosition(TouchingParts)
  265.         for Index, Data in next, HitboxManager.Parts do
  266.             if HitboxManager:IsSafe(Data.Part) then
  267.                 return Data.Part.Position
  268.             end
  269.         end
  270.     end
  271.  
  272.     function Utilities:GetLookCFrame(LookAt)
  273.         return CFrame.new(Player.Character.HumanoidRootPart.Position, LookAt) -- deprecated construtor go brrr
  274.     end
  275.  
  276.     function EnemyManager:LookAtNearestEnemy()
  277.         local Nearest = EnemyManager:GetNearestEnemy()
  278.         if Nearest and Nearest:FindFirstChild("HumanoidRootPart") then
  279.             local NearestPos = Nearest.HumanoidRootPart.Position
  280.             local LookCFrame = Utilities:GetLookCFrame(Vector3.new(NearestPos.X, Player.Character.HumanoidRootPart.Position.Y, NearestPos.Z))
  281.  
  282.             if LookCFrame then
  283.                 Player.Character.HumanoidRootPart.CFrame = LookCFrame
  284.             end
  285.         end
  286.     end
  287.  
  288.     function DodgingManager:MoveToPosition(Position, Dodge)
  289.         if not Player.Character or not Player.Character:FindFirstChild("Humanoid") or not Player.Character:FindFirstChild("HumanoidRootPart") then return end
  290.         if not HitboxManager:IsSafe(Position, false) then return end
  291.  
  292.         if Dodge then
  293.             local origin, destination = Player.Character.HumanoidRootPart.Position, Position
  294.  
  295.             local Touching = {}
  296.  
  297.             for i,v in next, HitboxManager.AllAttacks do
  298.                 if HitboxManager:isInsideBrick(origin, v) then
  299.                     table.insert(Touching, v)
  300.                 end
  301.             end
  302.  
  303.             local Waypoints = {}
  304.             local Magnitude = (origin - destination).magnitude
  305.  
  306.             for i = 1, Magnitude do
  307.                 table.insert(Waypoints, origin + (destination - origin) * (i / Magnitude))
  308.             end
  309.  
  310.             for i,v in next, Waypoints do
  311.                 if HitboxManager:IsSafe(Player.Character.HumanoidRootPart.Position) then
  312.                     break
  313.                 end
  314.  
  315.                 if HitboxManager:IsSafe(v, nil, Touching) or not HitboxManager:IsSafe(Player.Character.HumanoidRootPart.Position) then
  316.                     if (Player.Character.HumanoidRootPart.Position - Waypoints[#Waypoints]).Magnitude <= 7 then
  317.                         local FurthestSafe = Waypoints[#Waypoints]
  318.                        
  319.                         local Nearest = EnemyManager:GetNearestEnemy()
  320.  
  321.                         if Nearest and Nearest:FindFirstChild("HumanoidRootPart") then
  322.                             local comp = {Nearest.HumanoidRootPart.CFrame:GetComponents()}
  323.  
  324.                             comp[1] = FurthestSafe.X
  325.                             comp[2] = FurthestSafe.Y
  326.                             comp[3] = FurthestSafe.Z
  327.  
  328.                             Player.Character.HumanoidRootPart.CFrame = CFrame.new(unpack(comp))
  329.                         else
  330.                             Player.Character.HumanoidRootPart.CFrame = CFrame.new(FurthestSafe)
  331.                         end
  332.  
  333.                         break
  334.                     else
  335.                         if HitboxManager:IsSafe(Player.Character.HumanoidRootPart.Position) then
  336.                             break
  337.                         else
  338.                             Player.Character.Humanoid:MoveTo(v)
  339.                             Player.Character.Humanoid.MoveToFinished:wait()
  340.                         end
  341.                     end
  342.                 end
  343.             end
  344.         else
  345.             if HitboxManager:IsSafe(Position) or GayThingy then
  346.                 Player.Character.Humanoid:MoveTo(Position);
  347.                 Player.Character.Humanoid.MoveToFinished:wait()
  348.             end
  349.         end
  350.     end
  351.  
  352.     DodgingManager.IsPathfinding = false
  353.  
  354.     function DodgingManager:Pathfind(Position, DoCheck)
  355.         if not Player.Character or not Player.Character:FindFirstChild("Humanoid") or not Player.Character:FindFirstChild("HumanoidRootPart") then return end
  356.  
  357.         local Path = PathfindingService:CreatePath({
  358.             AgentCanJump = false,
  359.             AgentRadius = 3,
  360.             AgentHeight = 5
  361.         })
  362.        
  363.         Path:ComputeAsync(Player.Character.HumanoidRootPart.Position, Position)
  364.         local Waypoints = Path:GetWaypoints()
  365.  
  366.         Path.Blocked:Connect(function()
  367.             if Player.Character:FindFirstChildOfClass('Humanoid') then
  368.                 Player.Character.Humanoid.Jump = true
  369.             end;
  370.             return DodgingManager:Pathfind(Position, DoCheck);
  371.         end)
  372.  
  373.         if(Path.Status ~= Enum.PathStatus.Success) then
  374.             if Player.Character:FindFirstChildOfClass('Humanoid') then
  375.                 Player.Character.Humanoid.Jump = true
  376.             end;
  377.             return DodgingManager:Pathfind(Position, DoCheck);
  378.         end;
  379.  
  380.         for Index, Waypoint in next, Waypoints do
  381.             if Player.Character and Player.Character:FindFirstChild("HumanoidRootPart") then
  382.  
  383.                 if Waypoint.Action == Enum.PathWaypointAction.Jump and Player.Character:FindFirstChildWhichIsA("Humanoid") then
  384.                     Player.Character.Humanoid.Jump = true
  385.                 else
  386.                     local Magnitude = (Player.Character.HumanoidRootPart.Position - Position).Magnitude
  387.                
  388.                     local Nearest = EnemyManager:GetNearestEnemy()
  389.    
  390.                     if Player.Character and Player.Character:FindFirstChild("Humanoid") and Player.Character:FindFirstChild("HumanoidRootPart") then
  391.                         if HitboxManager:IsSafe(Waypoint.Position, true) or DoCheck == false then
  392.                             if not HitboxManager:isInsideBrick(Waypoint.Position, workspace.playerSpawn) or workspace.dungeon.room1:FindFirstChild("barrier") then
  393.                                 DodgingManager:MoveToPosition(Waypoint.Position)
  394.                             else
  395.                                 break
  396.                             end
  397.                         else
  398.                             break
  399.                         end
  400.                     else
  401.                         break
  402.                     end
  403.                 end
  404.             else
  405.                 break
  406.             end
  407.         end
  408.     end
  409.  
  410.     DodgingManager.IsGoingToBackVector = false
  411.  
  412.     function EnemyManager:MoveToNearestEnemy()
  413.         if not Player.Character or not Player.Character:FindFirstChild("HumanoidRootPart") or not Player.Character:FindFirstChild("Head") then return end
  414.  
  415.         local Nearest = EnemyManager:GetNearestEnemy()
  416.  
  417.         if Nearest and Nearest:FindFirstChild("HumanoidRootPart") then
  418.             DodgingManager:Pathfind(Nearest.HumanoidRootPart.Position, true)
  419.         end
  420.     end
  421.  
  422.     function EnemyManager:CastSpells()
  423.         for Index, Spell in next, Player.Backpack:GetChildren() do
  424.             if Spell:FindFirstChild("cooldown") and Spell.cooldown.Value <= 0 then
  425.                 local Event = Spell:FindFirstChildOfClass("RemoteEvent")
  426.                 if Event then
  427.                     Event:FireServer()
  428.                 end
  429.             end
  430.         end
  431.     end
  432.  
  433.     function DodgingManager:GetBackVector()
  434.         local Closest = EnemyManager:GetNearestEnemy()
  435.         if Closest and Closest:FindFirstChild("HumanoidRootPart") then
  436.             local CurrentPosition = Player.Character.HumanoidRootPart.Position
  437.             local Forward = Closest.HumanoidRootPart.CFrame
  438.    
  439.             local Furthest = nil
  440.             local Distance = 0
  441.  
  442.             for Index = 0, BackDistance do
  443.                 local Vector = Forward:ToWorldSpace(CFrame.new(0, 0, -Index)).Position
  444.  
  445.                 local Relative = Vector - CurrentPosition
  446.  
  447.                 if HitboxManager:IsSafe(Vector) then
  448.                     if Index > Distance then
  449.                         Furthest = Vector
  450.                         Distance = Index
  451.                     end
  452.                 else
  453.                     break
  454.                 end
  455.             end
  456.  
  457.             if GayThingy then
  458.                 Furthest = Furthest - Vector3.new(0, 0, 20)
  459.             end
  460.  
  461.             return Furthest
  462.         end
  463.     end
  464. end
  465.  
  466. Player.CharacterAdded:connect(function(Character)
  467.     local Humanoid = Character:WaitForChild("Humanoid")
  468.     Humanoid.WalkSpeed = shared.Walkspeed
  469.     Humanoid.AutoRotate = false
  470.     DodgingManager.IsPathfinding = false
  471.     StopLoop = false
  472. end)
  473.  
  474. local CurrentPosition = Player.Character.HumanoidRootPart.Position
  475.  
  476. workspace.Terrain:Clear()
  477.  
  478. for i = -22, 22, 2 do
  479.     for k = -22, 22, 2 do
  480.         local Part = Instance.new("Part")
  481.         Part.Transparency = 1
  482.         Part.CanCollide = false
  483.         Part.Position = CurrentPosition + Vector3.new(i, 0, k)
  484.         Part.Size = Vector3.new(4.8, 10, 4.8)
  485.         Part.Anchored = true
  486.         Part.Parent = workspace
  487.  
  488.         table.insert(HitboxManager.Parts, {Part = Part, X = i, Z = k})
  489.         table.insert(HitboxManager.RawParts, Part)
  490.     end
  491. end
  492.  
  493. table.insert(HitboxManager.RawParts, Player.Character)
  494.  
  495. table.sort(HitboxManager.Parts, function(a, b)
  496.     return (CurrentPosition - a.Part.Position).magnitude < (CurrentPosition - b.Part.Position).magnitude
  497. end)
  498.  
  499. local SilkBlastSafeSpots = {Vector3.new(-132.435944, 237.592529, -894.529907), Vector3.new(-114.921638, 235.781372, -834.34137), Vector3.new(-92.5981598, 235.066513, -896.379761)}
  500. local StopLoop = false
  501.  
  502. local OldBackDistance = BackDistance
  503. local OldAttackRange = AttackRange
  504.  
  505. local IsDoingSlam = false
  506. local IsDoingSafeSpot = false
  507. local AnimationPlayed = false
  508.  
  509. workspace.ChildAdded:Connect(function(child)
  510.     local Closest = EnemyManager:GetNearestEnemy()
  511.        
  512.     if Closest and Closest.Name == "Ancient Temple Protector" then
  513.         if HitboxManager:IsInstakillAttack(child) then
  514.             local hitBox = child:WaitForChild("hitBox")
  515.  
  516.             local hitBox = child:WaitForChild("hitBox")
  517.  
  518.             if abs(Player.Character.HumanoidRootPart.Position.X - hitBox.Position.X) <= 12 and not IsDoingSlam then
  519.                 IsDoingSlam = true
  520.                 DodgingManager.IsGoingToBackVector = true
  521.                 Player.Character.HumanoidRootPart.CFrame = hitBox.CFrame * CFrame.new(0, 0, 7)
  522.                 wait(1)
  523.                 DodgingManager.IsGoingToBackVector = false
  524.                 IsDoingSlam = false
  525.             end
  526.         end
  527.     end
  528.  
  529.     if child.Name == "firstBossLaserPrecast" then
  530.         table.insert(Laser, child)
  531.         wait(1.5)
  532.         table.remove(Laser, table.find(Laser, child))
  533.     end
  534.  
  535.     if child.Name == "silkBlast" then
  536.         StopLoop = true
  537.  
  538.         local Closest
  539.         local Distance = huge
  540.  
  541.         for Index, Position in next, SilkBlastSafeSpots do
  542.             local Magnitude = (Player.Character.HumanoidRootPart.Position - Position).Magnitude
  543.  
  544.             if Magnitude < Distance then
  545.                 Distance = Magnitude
  546.                 Closest = Position
  547.             end
  548.         end
  549.  
  550.         DodgingManager:Pathfind(Closest, false)
  551.  
  552.         StopLoop = false
  553.     end
  554.  
  555.     if child.Name == "firstBossMoveOrb" then
  556.         local originalPos = child.Position
  557.  
  558.         local con
  559.         con = child:GetPropertyChangedSignal("Position"):Connect(function()
  560.             con:Disconnect()
  561.             local partHitBox = Instance.new("Part")
  562.             partHitBox.Anchored = true
  563.             partHitBox.CanCollide = false
  564.             partHitBox.Transparency = 1
  565.             partHitBox.CFrame = CFrame.lookAt(originalPos, child.Position)
  566.             partHitBox.Size = Vector3.new(20, 5, 800)
  567.             partHitBox.Name = "hitBox"
  568.             partHitBox.Parent = workspace
  569.            
  570.             repeat
  571.                 wait()
  572.             until child == nil or not child:IsDescendantOf(workspace)
  573.             partHitBox:Destroy()
  574.         end)
  575.     end
  576.  
  577.     if child.Name == "finalBossOrbShot" then
  578.         local originalPos = child.Position
  579.  
  580.         local con
  581.         con = child:GetPropertyChangedSignal("Position"):Connect(function()
  582.             con:Disconnect()
  583.             local partHitBox = Instance.new("Part")
  584.             partHitBox.Anchored = true
  585.             partHitBox.CanCollide = false
  586.             partHitBox.Transparency = 1
  587.             partHitBox.CFrame = CFrame.lookAt(originalPos, child.Position)
  588.             partHitBox.Size = Vector3.new(child.Size.X + 5, 5, 800)
  589.             partHitBox.Name = "hitBox"
  590.             partHitBox.Parent = workspace
  591.  
  592.             spawn(function()
  593.                 wait(0.8)
  594.                 GayThingy = true
  595.                 wait(2)
  596.                 GayThingy = false
  597.             end)
  598.            
  599.             repeat
  600.                 wait()
  601.             until child == nil or not child:IsDescendantOf(workspace)
  602.             partHitBox:Destroy()
  603.         end)
  604.     end
  605.  
  606.     if child.Name == "firstBossFollowOrb" then
  607.         local originalPos = child.Position
  608.  
  609.         child:GetPropertyChangedSignal("Position"):Connect(function()
  610.             local partHitBox = Instance.new("Part")
  611.             partHitBox.Anchored = true
  612.             partHitBox.CanCollide = false
  613.             partHitBox.Transparency = 1
  614.             partHitBox.CFrame = CFrame.lookAt(originalPos, child.Position)
  615.             partHitBox.Size = Vector3.new(child.Size.X + 5, 5, 800)
  616.             partHitBox.Name = "hitBox"
  617.             partHitBox.Parent = workspace
  618.            
  619.             repeat
  620.                 wait()
  621.             until child == nil or not child:IsDescendantOf(workspace)
  622.             partHitBox:Destroy()
  623.         end)
  624.     end
  625. end)
  626.  
  627. local IsDoingFinalBossOrb = false
  628.  
  629. workspace.DescendantAdded:connect(function(Descendant)
  630.     if Descendant:IsA("Part") and HitboxManager:IdentifyAttack(Descendant) then
  631.         table.insert(HitboxManager.AllAttacks, Descendant)
  632.         repeat wait() until not Descendant or not HitboxManager:IdentifyAttack(Descendant)
  633.         table.remove(HitboxManager.AllAttacks, table.find(HitboxManager.AllAttacks, Descendant))
  634.     end
  635. end)
  636.  
  637. if game.PlaceId == 2606294912 or game.PlaceId == 2743806150 then
  638.     if game.PlaceId == 2606294912 then
  639.         for Index, Object in next, workspace.dungeon:GetDescendants() do
  640.             if Object.Name:lower():find("wall") or (Object:IsA("Part") and Object.Material == Enum.Material.Concrete and Object.BrickColor == BrickColor.new("Light red")) or Object.Name == "barrier" then
  641.                 Object:Destroy()
  642.             end
  643.         end
  644.     end
  645.  
  646.     setsimulationradius(math.huge, math.huge)
  647.  
  648.     for Index, Child in next, workspace.dungeon:GetChildren() do
  649.         if Child:FindFirstChild("enemyFolder") and Child.enemyFolder:FindFirstChildOfClass("Model") then
  650.             for SecondIndex, Descendant in next, Child.enemyFolder:GetChildren() do
  651.                 if Descendant:IsA("Model") and Descendant:FindFirstChild("HumanoidRootPart") and Descendant:FindFirstChild("Humanoid") and Descendant:FindFirstChild("enemyStyle") then
  652.                     Descendant.Humanoid.Health = -0
  653.                 end
  654.             end
  655.         end
  656.     end
  657.    
  658.     workspace.dungeon.DescendantAdded:connect(function(Descendant)
  659.         if Descendant:IsA("Humanoid") and Descendant.Parent.Name ~= "Ice Elemental" then
  660.             Descendant.Parent:WaitForChild("enemyStyle")
  661.  
  662.             Descendant.Health = -0
  663.         end
  664.     end)
  665. end
  666.  
  667. for i,v in next, workspace:GetDescendants() do
  668.     if v.ClassName == "Part" or v.ClassName == "SpawnLocation" or v.ClassName == "WedgePart" or v.ClassName == "Terrain" or v.ClassName == "MeshPart" then
  669.         v.Material = "Plastic"
  670.     elseif v.ClassName == "Decal" or v.ClassName == "Texture" then
  671.         v:Destroy()
  672.     end
  673. end
  674.  
  675. local connection;
  676. connection = game:GetService("RunService").Heartbeat:Connect(function()
  677.     setsimulationradius(math.huge, math.huge)
  678.  
  679.     if(_G.stop) then
  680.         connection:Disconnect();
  681.         connection = nil;
  682.  
  683.         _G.stop = nil;
  684.     end;
  685.  
  686.     if not StopLoop and Player.Character and Player.Character:FindFirstChild("HumanoidRootPart") then
  687.         CurrentPosition = Player.Character.HumanoidRootPart.CFrame
  688.  
  689.         local Nearest = EnemyManager:GetNearestEnemy()
  690.  
  691.         if Nearest and Nearest:FindFirstChild("Humanoid") and (game.PlaceId == 2606294912 or game.PlaceId == 2743806150) then
  692.             if Nearest.Name ~= "Ice Elemental" then
  693.                 Nearest.Humanoid.Health = -0
  694.             end
  695.         end
  696.  
  697.         for Index, Data in next, HitboxManager.Parts do
  698.             Data.Part.CFrame = CurrentPosition * CFrame.new(Data.X, 0, Data.Z)
  699.         end
  700.  
  701.         if not HitboxManager:IsSafe(CurrentPosition.Position) and not GayThingy then
  702.             local SafePosition = DodgingManager:GetOptimalPosition()
  703.             if SafePosition then
  704.                 if (CurrentPosition.Position - SafePosition).Magnitude > 7 then
  705.                     DodgingManager.IsPathfinding = true
  706.                     DodgingManager:MoveToPosition(SafePosition, true)
  707.                     DodgingManager.IsPathfinding = false
  708.                 else
  709.                     if Nearest and Nearest:FindFirstChild("HumanoidRootPart") then
  710.                         local comp = {Nearest.HumanoidRootPart.CFrame:GetComponents()}
  711.  
  712.                         comp[1] = SafePosition.X
  713.                         comp[2] = SafePosition.Y
  714.                         comp[3] = SafePosition.Z
  715.  
  716.                         Player.Character.HumanoidRootPart.CFrame = CFrame.new(unpack(comp))
  717.                     else
  718.                         Player.Character.HumanoidRootPart.CFrame = CFrame.new(SafePosition)
  719.                     end
  720.                 end;
  721.             end
  722.         else
  723.             if Nearest and Nearest:FindFirstChild("HumanoidRootPart") then
  724.                 local Magnitude = (Player.Character.HumanoidRootPart.Position - Nearest.HumanoidRootPart.Position).Magnitude
  725.                
  726.                 if floor(Magnitude) <= AttackRange or not HitboxManager:IsSafe(Player.Character.HumanoidRootPart.Position) then
  727.                     EnemyManager:LookAtNearestEnemy()
  728.                 end
  729.  
  730.                 if floor(Magnitude) <= AttackRange then
  731.                     spawn(function()
  732.                         wait(0.01)
  733.                         EnemyManager:CastSpells()
  734.                     end)
  735.                 end
  736.  
  737.                 if Nearest.Name == "Ancient Temple Protector" then
  738.                     BackDistance = 60
  739.                     AttackRange = 65
  740.                 elseif Nearest.Name == "Sea King" then
  741.                     if GayThingy then
  742.                         BackDistance = 80
  743.                     else
  744.                         BackDistance = 50
  745.                     end
  746.  
  747.                     AttackRange = 55
  748.                 else
  749.                     BackDistance = OldBackDistance
  750.                     AttackRange = OldAttackRange
  751.                 end
  752.  
  753.                 if IsDoingSlam or Nearest.Name == "Sea King" or GayThingy then
  754.                     local BackVector = DodgingManager:GetBackVector()
  755.                     if BackVector then
  756.                         DodgingManager.IsGoingToBackVector = true
  757.                         DodgingManager:MoveToPosition(BackVector)
  758.                         DodgingManager.IsGoingToBackVector = false
  759.                     end
  760.                 else
  761.                     if floor(Magnitude) > BackDistance and not DodgingManager.IsPathfinding then
  762.                         DodgingManager.IsPathfinding = true
  763.                         EnemyManager:MoveToNearestEnemy()
  764.                         DodgingManager.IsPathfinding = false
  765.                     elseif floor(Magnitude) < BackDistance and not DodgingManager.IsGoingToBackVector then
  766.                         local BackVector = DodgingManager:GetBackVector()
  767.                         if BackVector then
  768.                             DodgingManager.IsGoingToBackVector = true
  769.                             DodgingManager:MoveToPosition(BackVector)
  770.                             DodgingManager.IsGoingToBackVector = false
  771.                         end
  772.                     end
  773.                 end
  774.             end
  775.         end
  776.     end
  777. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement