Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TweenService = game:GetService("TweenService")
- local Debris = game:GetService("Debris")
- local boss = script.Parent
- local humanoid = boss:WaitForChild("Humanoid")
- local rootPart = boss:WaitForChild("HumanoidRootPart")
- local dataFolder = workspace:WaitForChild("Data")
- local playerValue = dataFolder:WaitForChild("Player")
- --------------------------------------------------
- -- НАСТРОЙКИ БОССА
- --------------------------------------------------
- local ACTIVATION_DISTANCE = 45
- -- Во сколько раз увеличивается капитан
- local BOSS_SCALE = 3
- -- Радиус обычной атаки
- local ATTACK_DISTANCE = 14
- -- Урон
- local DAMAGE = 35
- -- Время между атаками
- local ATTACK_COOLDOWN = 1.7
- -- Задержка до момента попадания
- local HIT_DELAY = 0.45
- -- Радиус мощной ударной волны
- local SHOCKWAVE_RADIUS = 20
- --------------------------------------------------
- -- СОСТОЯНИЕ
- --------------------------------------------------
- local awakened = false
- local attacking = false
- --------------------------------------------------
- -- СЕРВЕРНОЕ ВЛАДЕНИЕ ФИЗИКОЙ
- --------------------------------------------------
- pcall(function()
- rootPart:SetNetworkOwner(nil)
- end)
- --------------------------------------------------
- -- HUMANOID
- --------------------------------------------------
- humanoid.AutoRotate = false
- --------------------------------------------------
- -- ANIMATOR
- --------------------------------------------------
- local animator = humanoid:FindFirstChildOfClass("Animator")
- if not animator then
- animator = Instance.new("Animator")
- animator.Parent = humanoid
- end
- --------------------------------------------------
- -- ПОИСК АНИМАЦИИ АТАКИ
- --------------------------------------------------
- local animateScript = boss:FindFirstChild("Animate")
- local attackAnimation = nil
- if animateScript then
- local toolSlash = animateScript:FindFirstChild("toolslash")
- if toolSlash then
- for _, object in ipairs(toolSlash:GetDescendants()) do
- if object:IsA("Animation") then
- attackAnimation = object
- break
- end
- end
- end
- -- Запасной поиск
- if not attackAnimation then
- for _, object in ipairs(animateScript:GetDescendants()) do
- if object:IsA("Animation") then
- local objectName = object.Name:lower()
- if string.find(objectName, "slash")
- or string.find(objectName, "attack") then
- attackAnimation = object
- break
- end
- end
- end
- end
- end
- local attackTrack = nil
- if attackAnimation then
- attackTrack = animator:LoadAnimation(attackAnimation)
- attackTrack.Priority = Enum.AnimationPriority.Action
- attackTrack.Looped = false
- print("Captain: анимация атаки найдена")
- else
- warn("Captain: анимация атаки не найдена")
- end
- --------------------------------------------------
- -- ФУНКЦИЯ ПОВОРОТА К ИГРОКУ
- --------------------------------------------------
- local function lookAtPlayer()
- local player = playerValue.Value
- if not player then
- return nil
- end
- local character = player.Character
- if not character then
- return nil
- end
- local targetRoot = character:FindFirstChild("HumanoidRootPart")
- if not targetRoot then
- return nil
- end
- local lookPosition = Vector3.new(
- targetRoot.Position.X,
- rootPart.Position.Y,
- targetRoot.Position.Z
- )
- local targetCFrame = CFrame.lookAt(
- rootPart.Position,
- lookPosition
- )
- -- Поворачиваем постепенно
- local tween = TweenService:Create(
- rootPart,
- TweenInfo.new(
- 0.25,
- Enum.EasingStyle.Quad,
- Enum.EasingDirection.Out
- ),
- {
- CFrame = targetCFrame
- }
- )
- tween:Play()
- return targetRoot
- end
- --------------------------------------------------
- -- ЭФФЕКТ КОЛЬЦА
- --------------------------------------------------
- local function createRing(position, startSize, endSize, duration)
- local ring = Instance.new("Part")
- ring.Name = "BossShockwave"
- ring.Shape = Enum.PartType.Cylinder
- ring.Material = Enum.Material.Neon
- ring.Size = Vector3.new(
- 0.3,
- startSize,
- startSize
- )
- ring.Transparency = 0.15
- ring.Anchored = true
- ring.CanCollide = false
- ring.CanTouch = false
- ring.CanQuery = false
- ring.CFrame =
- CFrame.new(position)
- * CFrame.Angles(0, 0, math.rad(90))
- ring.Parent = workspace
- local tween = TweenService:Create(
- ring,
- TweenInfo.new(
- duration,
- Enum.EasingStyle.Quad,
- Enum.EasingDirection.Out
- ),
- {
- Size = Vector3.new(
- 0.3,
- endSize,
- endSize
- ),
- Transparency = 1
- }
- )
- tween:Play()
- Debris:AddItem(ring, duration + 0.2)
- end
- --------------------------------------------------
- -- ЭФФЕКТ ВСПЫШКИ
- --------------------------------------------------
- local function createExplosion(position, size)
- local explosionPart = Instance.new("Part")
- explosionPart.Name = "CaptainExplosion"
- explosionPart.Shape = Enum.PartType.Ball
- explosionPart.Material = Enum.Material.Neon
- explosionPart.Size = Vector3.new(
- 1,
- 1,
- 1
- )
- explosionPart.Transparency = 0.15
- explosionPart.Anchored = true
- explosionPart.CanCollide = false
- explosionPart.CanTouch = false
- explosionPart.CanQuery = false
- explosionPart.CFrame = CFrame.new(position)
- explosionPart.Parent = workspace
- local tween = TweenService:Create(
- explosionPart,
- TweenInfo.new(
- 0.5,
- Enum.EasingStyle.Quad,
- Enum.EasingDirection.Out
- ),
- {
- Size = Vector3.new(
- size,
- size,
- size
- ),
- Transparency = 1
- }
- )
- tween:Play()
- Debris:AddItem(explosionPart, 0.7)
- end
- --------------------------------------------------
- -- ЭФФЕКТ ПРОБУЖДЕНИЯ
- --------------------------------------------------
- local function awakeningEffects()
- -- Highlight
- local highlight = Instance.new("Highlight")
- highlight.Name = "CaptainHighlight"
- highlight.Adornee = boss
- highlight.FillTransparency = 0.45
- highlight.OutlineTransparency = 0
- highlight.Parent = boss
- -- Начальное состояние
- highlight.FillColor = Color3.fromRGB(255, 0, 0)
- highlight.OutlineColor = Color3.fromRGB(255, 170, 0)
- -- Свет
- local light = Instance.new("PointLight")
- light.Name = "CaptainAura"
- light.Color = Color3.fromRGB(255, 50, 0)
- light.Brightness = 0
- light.Range = 8
- light.Parent = rootPart
- -- Постепенно включаем свет
- local lightTween = TweenService:Create(
- light,
- TweenInfo.new(
- 0.7,
- Enum.EasingStyle.Quad,
- Enum.EasingDirection.Out
- ),
- {
- Brightness = 12,
- Range = 25
- }
- )
- lightTween:Play()
- --------------------------------------------------
- -- КОЛЬЦА
- --------------------------------------------------
- createRing(
- rootPart.Position - Vector3.new(0, 3, 0),
- 2,
- 18,
- 0.7
- )
- task.wait(0.15)
- createRing(
- rootPart.Position - Vector3.new(0, 3, 0),
- 3,
- 28,
- 0.8
- )
- task.wait(0.15)
- createRing(
- rootPart.Position - Vector3.new(0, 3, 0),
- 4,
- 40,
- 1
- )
- --------------------------------------------------
- -- ВСПЫШКА
- --------------------------------------------------
- createExplosion(
- rootPart.Position,
- 18
- )
- --------------------------------------------------
- -- МАЛЕНЬКАЯ ПАУЗА
- --------------------------------------------------
- task.wait(0.3)
- --------------------------------------------------
- -- УВЕЛИЧЕНИЕ
- --------------------------------------------------
- boss:ScaleTo(BOSS_SCALE)
- --------------------------------------------------
- -- ЕЩЁ ОДНА ВСПЫШКА
- --------------------------------------------------
- createExplosion(
- rootPart.Position,
- 28
- )
- createRing(
- rootPart.Position - Vector3.new(0, 5, 0),
- 5,
- 50,
- 1
- )
- --------------------------------------------------
- -- УСИЛИВАЕМ СВЕЧЕНИЕ
- --------------------------------------------------
- light.Brightness = 20
- light.Range = 35
- end
- --------------------------------------------------
- -- ПРОБУЖДЕНИЕ БОССА
- --------------------------------------------------
- local function awaken()
- if awakened then
- return
- end
- awakened = true
- print("КАПИТАН ПИРАТОВ ПРОСНУЛСЯ!")
- -- Поворачиваемся перед трансформацией
- lookAtPlayer()
- task.wait(0.4)
- awakeningEffects()
- task.wait(1)
- end
- --------------------------------------------------
- -- УДАРНАЯ ВОЛНА
- --------------------------------------------------
- local function createAttackWave()
- local position =
- rootPart.Position
- + rootPart.CFrame.LookVector * 5
- -- Центральная вспышка
- createExplosion(
- position,
- 12
- )
- -- Большое кольцо
- createRing(
- rootPart.Position - Vector3.new(0, 5, 0),
- 3,
- SHOCKWAVE_RADIUS * 2,
- 0.45
- )
- end
- --------------------------------------------------
- -- НАНЕСЕНИЕ УРОНА
- --------------------------------------------------
- local function dealDamage()
- local player = playerValue.Value
- if not player then
- return
- end
- local character = player.Character
- if not character then
- return
- end
- local targetHumanoid =
- character:FindFirstChildOfClass("Humanoid")
- local targetRoot =
- character:FindFirstChild("HumanoidRootPart")
- if not targetHumanoid or not targetRoot then
- return
- end
- if targetHumanoid.Health <= 0 then
- return
- end
- local distance =
- (targetRoot.Position - rootPart.Position).Magnitude
- if distance <= SHOCKWAVE_RADIUS then
- targetHumanoid:TakeDamage(DAMAGE)
- print(
- "Капитан нанёс",
- DAMAGE,
- "урона"
- )
- end
- end
- --------------------------------------------------
- -- АТАКА
- --------------------------------------------------
- local function attack()
- if attacking then
- return
- end
- attacking = true
- --------------------------------------------------
- -- ПОВОРОТ
- --------------------------------------------------
- lookAtPlayer()
- task.wait(0.25)
- --------------------------------------------------
- -- АНИМАЦИЯ
- --------------------------------------------------
- if attackTrack then
- attackTrack:Play(
- 0.05,
- 1,
- 1.15
- )
- end
- --------------------------------------------------
- -- ЭФФЕКТ ЗАРЯДА
- --------------------------------------------------
- createExplosion(
- rootPart.Position,
- 10
- )
- --------------------------------------------------
- -- ЖДЁМ МОМЕНТ УДАРА
- --------------------------------------------------
- task.wait(HIT_DELAY)
- --------------------------------------------------
- -- УДАР
- --------------------------------------------------
- createAttackWave()
- dealDamage()
- --------------------------------------------------
- -- ЖДЁМ ОКОНЧАНИЕ
- --------------------------------------------------
- if attackTrack then
- local length = attackTrack.Length
- if length > 0 then
- task.wait(
- math.max(
- length - HIT_DELAY,
- 0
- )
- )
- else
- task.wait(0.5)
- end
- else
- task.wait(0.5)
- end
- attacking = false
- end
- --------------------------------------------------
- -- ОСНОВНОЙ ЦИКЛ
- --------------------------------------------------
- while boss.Parent do
- if humanoid.Health <= 0 then
- break
- end
- local player = playerValue.Value
- if not player then
- task.wait(0.3)
- continue
- end
- local character = player.Character
- if not character then
- task.wait(0.3)
- continue
- end
- local targetHumanoid =
- character:FindFirstChildOfClass("Humanoid")
- local targetRoot =
- character:FindFirstChild("HumanoidRootPart")
- if not targetHumanoid or not targetRoot then
- task.wait(0.3)
- continue
- end
- if targetHumanoid.Health <= 0 then
- task.wait(0.3)
- continue
- end
- local distance =
- (targetRoot.Position - rootPart.Position).Magnitude
- --------------------------------------------------
- -- ИГРОК ПОДОШЁЛ
- --------------------------------------------------
- if not awakened then
- if distance <= ACTIVATION_DISTANCE then
- awaken()
- end
- task.wait(0.15)
- continue
- end
- --------------------------------------------------
- -- БОСС ПРОБУЖДЁН
- --------------------------------------------------
- lookAtPlayer()
- --------------------------------------------------
- -- АТАКА
- --------------------------------------------------
- if distance <= ATTACK_DISTANCE then
- attack()
- task.wait(ATTACK_COOLDOWN)
- else
- -- Игрок отошёл.
- -- Капитан продолжает смотреть на него,
- -- но не преследует.
- task.wait(0.2)
- end
- end
Advertisement