From 8c01ae9657385e7f4914799a609c6435aaf90247 Mon Sep 17 00:00:00 2001 From: Leshyi Date: Mon, 2 Nov 2026 17:21:45 +0300 Subject: [PATCH] 123 --- Zombi/src/client/Battle.client.luau | 215 +++++++++++++++++++++ Zombi/src/client/Gun.client.luau | 4 +- Zombi/src/client/ZombieFX.client.luau | 76 ++++++++ Zombi/src/server/Buggy.luau | 12 +- Zombi/src/server/Drops.luau | 166 ++++++++++++++++ Zombi/src/server/Lobby.luau | 2 + Zombi/src/server/Main.server.luau | 2 + Zombi/src/server/Weapons.luau | 14 +- Zombi/src/server/Zombies.luau | 265 +++++++++++++++++++++----- Zombi/src/shared/BuggyStats.luau | 16 ++ Zombi/src/shared/Config.luau | 43 +++++ 11 files changed, 756 insertions(+), 59 deletions(-) create mode 100644 Zombi/src/client/Battle.client.luau create mode 100644 Zombi/src/server/Drops.luau diff --git a/Zombi/src/client/Battle.client.luau b/Zombi/src/client/Battle.client.luau new file mode 100644 index 0000000..2108b70 --- /dev/null +++ b/Zombi/src/client/Battle.client.luau @@ -0,0 +1,215 @@ +-- Бой на карте команды: волна и сколько зомби осталось, полоса здоровья босса, крупные объявления +-- («ВОЛНА 2», «БОСС-ЗОМБИ!», «ВОЛНА ПРОЙДЕНА»), список подобранных бустов и надпись при подборе. +-- Состояние волны сервер держит в атрибутах папки Zombies<номер карты>, события шлёт через WaveEvent. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local TweenService = game:GetService("TweenService") + +local Config = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Config")) +local BuggyStats = require(ReplicatedStorage.Shared:WaitForChild("BuggyStats")) +local Remotes = ReplicatedStorage:WaitForChild("Remotes") + +local player = Players.LocalPlayer + +local BG = Color3.fromRGB(30, 22, 16) +local TEXT = Color3.fromRGB(245, 235, 220) +local MUTED = Color3.fromRGB(190, 170, 150) +local ORANGE = Color3.fromRGB(230, 130, 40) +local BOSS_RED = Color3.fromRGB(220, 45, 35) + +local gui = Instance.new("ScreenGui") +gui.Name = "BattleHUD" +gui.ResetOnSpawn = false +gui.IgnoreGuiInset = true +gui.DisplayOrder = 40 +gui.Parent = player:WaitForChild("PlayerGui") + +local function frame(props): Frame + local f = Instance.new("Frame") + f.BorderSizePixel = 0 + for k, v in props do + f[k] = v + end + f.Parent = props.Parent or gui + return f +end + +local function text(parent: Instance, props): TextLabel + local l = Instance.new("TextLabel") + l.BackgroundTransparency = 1 + l.Font = Enum.Font.GothamBlack + l.TextColor3 = TEXT + l.TextStrokeTransparency = 0.5 + for k, v in props do + l[k] = v + end + l.Parent = parent + return l +end + +-- ===== Волна (под полосой HP) ===== + +local waveBar = frame({ AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 54), Size = UDim2.fromOffset(340, 26), BackgroundColor3 = BG, BackgroundTransparency = 0.15, Visible = false }) +Instance.new("UICorner", waveBar).CornerRadius = UDim.new(0, 8) +local waveLabel = text(waveBar, { Size = UDim2.fromScale(1, 1), TextSize = 15 }) + +-- ===== Босс ===== + +local bossBar = frame({ AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 88), Size = UDim2.fromOffset(460, 40), BackgroundColor3 = BG, BackgroundTransparency = 0.1, Visible = false }) +Instance.new("UICorner", bossBar).CornerRadius = UDim.new(0, 10) +local bossStroke = Instance.new("UIStroke", bossBar) +bossStroke.Color = BOSS_RED +bossStroke.Thickness = 2 +local bossTrack = frame({ Parent = bossBar, Position = UDim2.fromOffset(12, 22), Size = UDim2.new(1, -24, 0, 10), BackgroundColor3 = Color3.fromRGB(60, 25, 20) }) +Instance.new("UICorner", bossTrack).CornerRadius = UDim.new(1, 0) +local bossFill = frame({ Parent = bossTrack, Size = UDim2.fromScale(1, 1), BackgroundColor3 = BOSS_RED }) +Instance.new("UICorner", bossFill).CornerRadius = UDim.new(1, 0) +local bossLabel = text(bossBar, { Position = UDim2.fromOffset(12, 2), Size = UDim2.new(1, -24, 0, 20), TextSize = 14, TextColor3 = Color3.fromRGB(255, 120, 100), TextXAlignment = Enum.TextXAlignment.Left }) + +-- ===== Бусты (слева, под осколками) ===== + +local boostList = frame({ Position = UDim2.fromOffset(16, 196), Size = UDim2.fromOffset(240, 0), AutomaticSize = Enum.AutomaticSize.Y, BackgroundTransparency = 1 }) +local boostLayout = Instance.new("UIListLayout", boostList) +boostLayout.Padding = UDim.new(0, 6) +boostLayout.SortOrder = Enum.SortOrder.LayoutOrder + +local boostRows = {} +for i, boost in Config.Boosts.List do + local row = frame({ Parent = boostList, LayoutOrder = i, Size = UDim2.fromOffset(240, 30), BackgroundColor3 = BG, BackgroundTransparency = 0.15, Visible = false }) + Instance.new("UICorner", row).CornerRadius = UDim.new(0, 8) + local stroke = Instance.new("UIStroke", row) + stroke.Color = boost.color + stroke.Thickness = 2 + text(row, { Position = UDim2.fromOffset(6, 0), Size = UDim2.fromOffset(26, 30), TextSize = 18, Text = boost.icon, TextStrokeTransparency = 1 }) + local label = text(row, { Position = UDim2.fromOffset(36, 0), Size = UDim2.new(1, -42, 1, 0), TextSize = 13, TextXAlignment = Enum.TextXAlignment.Left, TextColor3 = boost.color }) + boostRows[boost.id] = { row = row, label = label, boost = boost } +end + +-- Как буст описать в списке: «Урон +30%», у брони — «Броня −24% урона». +local function boostText(boost, stacks: number): string + local percent = math.floor(boost.step * stacks * 100 + 0.5) + if boost.id == "armor" then + return ("%s −%d%% урона"):format(boost.name, percent) + end + return ("%s +%d%%"):format(boost.name, percent) .. (if stacks >= boost.max then " MAX" else "") +end + +local function refreshBoosts() + for id, entry in boostRows do + local stacks = BuggyStats.BoostStacks(player, id) + entry.row.Visible = stacks > 0 + entry.label.Text = boostText(entry.boost, stacks) + end +end +for _, boost in Config.Boosts.List do + player:GetAttributeChangedSignal("Boost_" .. boost.id):Connect(refreshBoosts) +end +refreshBoosts() + +-- ===== Крупные надписи ===== + +local function announce(message: string, color: Color3, size: number, life: number, shake: boolean) + local label = text(gui, { + AnchorPoint = Vector2.new(0.5, 0.5), + Position = UDim2.fromScale(0.5, 0.36), + Size = UDim2.fromOffset(1000, size * 1.3), + TextSize = size, + TextColor3 = color, + TextStrokeColor3 = Color3.fromRGB(25, 10, 5), + TextStrokeTransparency = 0, + Text = message, + }) + local scale = Instance.new("UIScale", label) + scale.Scale = 0.4 + TweenService:Create(scale, TweenInfo.new(0.3, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 }):Play() + if shake then + task.spawn(function() + for i = 1, 10 do + label.Rotation = (if i % 2 == 0 then 1 else -1) * (10 - i) * 0.7 + task.wait(0.04) + end + label.Rotation = 0 + end) + end + task.delay(life, function() + TweenService:Create(label, TweenInfo.new(0.5), { TextTransparency = 1, TextStrokeTransparency = 1 }):Play() + task.wait(0.55) + label:Destroy() + end) +end + +Remotes:WaitForChild("WaveEvent").OnClientEvent:Connect(function(kind: string, wave: number) + if kind == "wave" then + announce("ВОЛНА " .. wave, ORANGE, 90, 1.6, false) + elseif kind == "boss" then + announce("БОСС-ЗОМБИ!", BOSS_RED, 110, 2, true) + elseif kind == "cleared" then + announce(("ВОЛНА %d ПРОЙДЕНА"):format(wave), Color3.fromRGB(110, 220, 100), 70, 1.8, false) + end +end) + +-- Подобрал буст — крупная надпись его цветом под прицелом. +Remotes:WaitForChild("BoostPicked").OnClientEvent:Connect(function(_, id: string, userId: number, _stacks: number, maxed: boolean) + local boost = Config.BoostById[id] + if userId ~= player.UserId or not boost then + return + end + local label = text(gui, { + AnchorPoint = Vector2.new(0.5, 0.5), + Position = UDim2.fromScale(0.5, 0.62), + Size = UDim2.fromOffset(700, 44), + TextSize = 34, + TextColor3 = boost.color, + TextStrokeColor3 = Color3.fromRGB(25, 10, 5), + TextStrokeTransparency = 0, + Text = if maxed + then boost.icon .. " " .. string.upper(boost.name) .. " — УЖЕ МАКСИМУМ" + elseif id == "armor" then ("%s БРОНЯ −%d%% УРОНА"):format(boost.icon, math.floor(boost.step * 100 + 0.5)) + else ("%s +%d%% %s"):format(boost.icon, math.floor(boost.step * 100 + 0.5), string.upper(boost.name)), + }) + local scale = Instance.new("UIScale", label) + scale.Scale = 1.6 + TweenService:Create(scale, TweenInfo.new(0.25, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 }):Play() + TweenService:Create(label, TweenInfo.new(1.4, Enum.EasingStyle.Quad), { Position = UDim2.fromScale(0.5, 0.56) }):Play() + task.delay(1, function() + TweenService:Create(label, TweenInfo.new(0.5), { TextTransparency = 1, TextStrokeTransparency = 1 }):Play() + task.wait(0.55) + label:Destroy() + end) +end) + +-- ===== Состояние волны каждый кадр ===== + +RunService.RenderStepped:Connect(function() + local arena = player:GetAttribute("Arena") or 0 + local folder = arena > 0 and workspace:FindFirstChild("Zombies" .. arena) + boostList.Visible = arena > 0 + if not folder then + waveBar.Visible = false + bossBar.Visible = false + return + end + local wave = folder:GetAttribute("Wave") or 1 + local phase = folder:GetAttribute("Phase") + waveBar.Visible = true + if phase == "boss" then + waveLabel.Text = ("ВОЛНА %d · БОСС"):format(wave) + waveLabel.TextColor3 = Color3.fromRGB(255, 120, 100) + elseif phase == "break" then + waveLabel.Text = ("ВОЛНА %d ПРОЙДЕНА · передышка"):format(wave) + waveLabel.TextColor3 = Color3.fromRGB(130, 220, 110) + else + waveLabel.Text = ("ВОЛНА %d · зомби осталось: %d"):format(wave, folder:GetAttribute("Remaining") or 0) + waveLabel.TextColor3 = TEXT + end + + local bossMax = folder:GetAttribute("BossMax") or 0 + bossBar.Visible = bossMax > 0 + if bossMax > 0 then + local health = folder:GetAttribute("BossHealth") or 0 + bossFill.Size = UDim2.fromScale(math.clamp(health / bossMax, 0, 1), 1) + bossLabel.Text = ("💀 БОСС-ЗОМБИ · %d / %d"):format(math.ceil(health), math.floor(bossMax)) + end +end) diff --git a/Zombi/src/client/Gun.client.luau b/Zombi/src/client/Gun.client.luau index ef3269e..660c6fa 100644 --- a/Zombi/src/client/Gun.client.luau +++ b/Zombi/src/client/Gun.client.luau @@ -11,6 +11,7 @@ local UserInputService = game:GetService("UserInputService") local Config = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Config")) local GunMath = require(ReplicatedStorage.Shared:WaitForChild("GunMath")) +local BuggyStats = require(ReplicatedStorage.Shared:WaitForChild("BuggyStats")) local Remotes = ReplicatedStorage:WaitForChild("Remotes") local G = Config.Gun @@ -314,7 +315,8 @@ RunService.RenderStepped:Connect(function(dt) heatFill.BackgroundColor3 = overheated and RED or TRACER_COLOR:Lerp(RED, heat) heatLabel.Text = overheated and "ПЕРЕГРЕВ!" or string.upper(item.name) .. " · ЛКМ" - if firing and not overheated and not model:GetAttribute("Locked") and now - lastShot >= 1 / spec.fireRate then + local fireRate = spec.fireRate * BuggyStats.BoostMultiplier(player, "firerate") -- буст из дропа + if firing and not overheated and not model:GetAttribute("Locked") and now - lastShot >= 1 / fireRate then lastShot = now heat += spec.heatPerShot if heat >= 1 then diff --git a/Zombi/src/client/ZombieFX.client.luau b/Zombi/src/client/ZombieFX.client.luau index 319a5d3..420b598 100644 --- a/Zombi/src/client/ZombieFX.client.luau +++ b/Zombi/src/client/ZombieFX.client.luau @@ -115,6 +115,82 @@ local function impact(position: Vector3, big: boolean) Debris:AddItem(holder, 1) end +-- ===== Бусты на земле ===== +-- Кристалл крутится и покачивается (только у себя — сервер его не двигает). + +local RunService = game:GetService("RunService") +local Config = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Config")) + +local spinning = {} -- [Model] = { crystal, shell, base: CFrame, phase } + +local function watchDrop(model: Instance) + if not model:IsA("Model") or not model:GetAttribute("Drop") then + return + end + local crystal = model:WaitForChild("Crystal", 5) :: BasePart? + local shell = model:WaitForChild("Shell", 5) :: BasePart? + if crystal and shell then + spinning[model] = { crystal = crystal, shell = shell, center = shell.Position, phase = rng:NextNumber(0, 6) } + end +end +workspace.DescendantAdded:Connect(function(d) + if d.Name == "Drop" then + task.spawn(watchDrop, d) + end +end) + +RunService.RenderStepped:Connect(function() + local t = os.clock() + for model, d in spinning do + if not model.Parent then + spinning[model] = nil + continue + end + local center = d.center + Vector3.new(0, math.sin(t * 2 + d.phase) * 0.45, 0) + d.crystal.CFrame = CFrame.new(center) * CFrame.Angles(0, t * 2 + d.phase, 0) * CFrame.Angles(math.rad(45), 0, math.rad(45)) + d.shell.CFrame = CFrame.new(center) + d.shell.Size = Vector3.one * (3.2 + math.sin(t * 4 + d.phase) * 0.25) + end +end) + +-- Подбор: вспышка цвета буста и расходящееся кольцо — видно всем рядом. +Remotes:WaitForChild("BoostPicked").OnClientEvent:Connect(function(position: Vector3, id: string) + local boost = Config.BoostById[id] + if not boost or (workspace.CurrentCamera.CFrame.Position - position).Magnitude > MAX_DISTANCE then + return + end + local holder = anchor(position) + burst(holder, { + Color = ColorSequence.new(boost.color, Color3.new(1, 1, 1)), + LightEmission = 1, + Size = NumberSequence.new(0.6, 0), + Lifetime = NumberRange.new(0.4, 0.8), + Speed = NumberRange.new(10, 22), + Drag = 3, + }, 30) + local light = Instance.new("PointLight") + light.Color = boost.color + light.Range = 20 + light.Brightness = 5 + light.Parent = holder + TweenService:Create(light, TweenInfo.new(0.5), { Brightness = 0 }):Play() + local ring = Instance.new("Part") + ring.Anchored = true + ring.CanCollide = false + ring.CanQuery = false + ring.CanTouch = false + ring.Shape = Enum.PartType.Cylinder + ring.Material = Enum.Material.Neon + ring.Color = boost.color + ring.Transparency = 0.2 + ring.Size = Vector3.new(0.15, 2, 2) + ring.CFrame = CFrame.new(position - Vector3.new(0, 2, 0)) * CFrame.Angles(0, 0, math.pi / 2) + ring.Parent = workspace + TweenService:Create(ring, TweenInfo.new(0.5, Enum.EasingStyle.Quad), { Size = Vector3.new(0.15, 16, 16), Transparency = 1 }):Play() + Debris:AddItem(ring, 0.6) + Debris:AddItem(holder, 1) +end) + HitRemote.OnClientEvent:Connect(function(position: Vector3, amount: number, killed: boolean) local camera = workspace.CurrentCamera if (camera.CFrame.Position - position).Magnitude > MAX_DISTANCE then diff --git a/Zombi/src/server/Buggy.luau b/Zombi/src/server/Buggy.luau index 90472c8..f8f6a83 100644 --- a/Zombi/src/server/Buggy.luau +++ b/Zombi/src/server/Buggy.luau @@ -413,8 +413,8 @@ function Buggy.Build(groundCFrame: CFrame, options): Model servo.ServoMaxTorque = 100000 servo.AngularSpeed = B.SteerSpeed servo.LimitsEnabled = true - servo.LowerAngle = -B.SteerAngle - 5 - servo.UpperAngle = B.SteerAngle + 5 + servo.LowerAngle = -50 -- с запасом под буст «Манёвренность» + servo.UpperAngle = 50 servo.Parent = knuckle table.insert(servos, servo) axleParent = knuckle @@ -654,8 +654,8 @@ function Buggy.Start() local steer = if data.locked then 0 else data.seat.SteerFloat local velocity = data.chassis.AssemblyLinearVelocity local forwardSpeed = velocity:Dot(data.chassis.CFrame.LookVector) -- вперёд — плюс - -- Тяжёлые детали (броня, гусеницы) снижают максимальную скорость. - local maxSpeed = B.MaxSpeed * data.speedFactor + -- Тяжёлые детали (броня, гусеницы) снижают максимальную скорость, буст «Скорость» из дропа — повышает. + local maxSpeed = B.MaxSpeed * data.speedFactor * BuggyStats.BoostMultiplier(data.owner, "speed") -- Целевая скорость колёс (studs/с) и усилие мотора. local speed, torque @@ -682,7 +682,9 @@ function Buggy.Start() -- Чем быстрее едем, тем меньше угол руля — чтобы на скорости машину не срывало в занос. local speedFactor = math.clamp(math.abs(forwardSpeed) / maxSpeed, 0, 1) - local angle = B.SteerAngle * (1 - (1 - B.HighSpeedSteer) * speedFactor) + -- Буст «Манёвренность» из дропа: руль поворачивается сильнее (не больше 45°). + local handling = BuggyStats.BoostMultiplier(data.owner, "handling") + local angle = math.min(B.SteerAngle * handling, 45) * (1 - (1 - B.HighSpeedSteer) * speedFactor) -- Положительный угол поворачивает колёса влево, а SteerFloat > 0 — это D (вправо). for _, servo in data.servos do servo.TargetAngle = -steer * angle * B.SteerSign diff --git a/Zombi/src/server/Drops.luau b/Zombi/src/server/Drops.luau new file mode 100644 index 0000000..ee0450d --- /dev/null +++ b/Zombi/src/server/Drops.luau @@ -0,0 +1,166 @@ +-- Бусты-дроп на картах команд: светящийся кристалл цвета буста, столб света вверх (видно издалека), +-- кольцо на земле. Подбирается касанием — багги или персонажем. Буст действует до конца боя +-- (атрибут Boost_ у игрока, складывается до max), как именно — см. BuggyStats.BoostMultiplier. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") + +local Config = require(ReplicatedStorage.Shared.Config) + +local BC = Config.Boosts +local Drops = {} + +local BEAM_HEIGHT = 140 +local CHECK_INTERVAL = 0.1 + +local rng = Random.new() +local drops = {} -- [Model] = { arena, boost, expires, position } +local PickedRemote: RemoteEvent + +local function part(parent: Instance, props): BasePart + local p = Instance.new("Part") + p.Anchored = true + p.CanCollide = false + p.CanQuery = false + p.CanTouch = false + p.CastShadow = false + for k, v in props do + p[k] = v + end + p.Parent = parent + return p +end + +-- Положить буст (boostId — какой, иначе случайный) на землю под position. +function Drops.Spawn(parent: Instance, position: Vector3, arenaIndex: number, boostId: string?) + local boost = boostId and Config.BoostById[boostId] or BC.List[rng:NextInteger(1, #BC.List)] + local params = RaycastParams.new() + params.FilterType = Enum.RaycastFilterType.Include + params.FilterDescendantsInstances = { workspace.Terrain } + local hit = workspace:Raycast(position + Vector3.new(0, 6, 0), Vector3.new(0, -80, 0), params) + local ground = if hit then hit.Position else position + local center = ground + Vector3.new(0, 2.4, 0) + + local model = Instance.new("Model") + model.Name = "Drop" + model:SetAttribute("Drop", boost.id) -- клиент крутит и покачивает кристалл (ZombieFX) + + -- Кристалл-ромб в светящейся оболочке + local crystal = part(model, { + Name = "Crystal", + Size = Vector3.new(1.5, 1.5, 1.5), + CFrame = CFrame.new(center) * CFrame.Angles(math.rad(45), 0, math.rad(45)), + Color = boost.color, + Material = Enum.Material.Neon, + }) + model.PrimaryPart = crystal + part(model, { Name = "Shell", Shape = Enum.PartType.Ball, Size = Vector3.new(3.2, 3.2, 3.2), CFrame = CFrame.new(center), Color = boost.color, Material = Enum.Material.Neon, Transparency = 0.8 }) + local light = Instance.new("PointLight") + light.Color = boost.color + light.Range = 16 + light.Brightness = 3 + light.Shadows = false + light.Parent = crystal + + -- Значок буста над кристаллом + local board = Instance.new("BillboardGui") + board.Size = UDim2.fromScale(3, 3) + board.StudsOffsetWorldSpace = Vector3.new(0, 2.6, 0) + board.LightInfluence = 0 + board.MaxDistance = 220 + board.Parent = crystal + local icon = Instance.new("TextLabel") + icon.Size = UDim2.fromScale(1, 1) + icon.BackgroundTransparency = 1 + icon.TextScaled = true + icon.Font = Enum.Font.GothamBlack + icon.Text = boost.icon + icon.Parent = board + + -- Кольцо на земле и столб света вверх + part(model, { Name = "Ring", Shape = Enum.PartType.Cylinder, Size = Vector3.new(0.12, 6, 6), CFrame = CFrame.new(ground + Vector3.new(0, 0.1, 0)) * CFrame.Angles(0, 0, math.pi / 2), Color = boost.color, Material = Enum.Material.Neon, Transparency = 0.45 }) + local anchor = part(model, { Name = "BeamBase", Size = Vector3.new(0.2, 0.2, 0.2), CFrame = CFrame.new(ground), Transparency = 1 }) + local bottom = Instance.new("Attachment") + bottom.Parent = anchor + local top = Instance.new("Attachment") + top.Position = Vector3.new(0, BEAM_HEIGHT, 0) + top.Parent = anchor + local beam = Instance.new("Beam") + beam.Attachment0 = bottom + beam.Attachment1 = top + beam.Color = ColorSequence.new(boost.color) + beam.LightEmission = 1 + beam.LightInfluence = 0 + beam.Width0 = 2.4 + beam.Width1 = 1 + beam.FaceCamera = true + beam.Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0.05), NumberSequenceKeypoint.new(0.6, 0.5), NumberSequenceKeypoint.new(1, 1) }) + beam.Parent = anchor + + model.Parent = parent + drops[model] = { arena = arenaIndex, boost = boost, expires = os.clock() + BC.Lifetime, position = center } +end + +-- Сбросить все бусты игрока (бой для него закончился). +function Drops.Reset(player: Player) + for _, boost in BC.List do + player:SetAttribute("Boost_" .. boost.id, nil) + end +end + +local function pick(player: Player, model: Model, d) + drops[model] = nil + model:Destroy() + local id = d.boost.id + local stacks = player:GetAttribute("Boost_" .. id) or 0 + local maxed = stacks >= d.boost.max + if not maxed then + stacks += 1 + player:SetAttribute("Boost_" .. id, stacks) + end + -- Всем — вспышка на месте подбора, подобравшему — надпись с бустом (ZombieFX) + PickedRemote:FireAllClients(d.position, id, player.UserId, stacks, maxed) +end + +-- Кто из игроков этой карты касается буста: персонаж или его багги (у машины радиус больше — она крупнее). +local function check() + local now = os.clock() + for model, d in drops do + if not model.Parent or now > d.expires then + drops[model] = nil + if model.Parent then + model:Destroy() + end + continue + end + for _, player in Players:GetPlayers() do + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + local root = character and character:FindFirstChild("HumanoidRootPart") :: BasePart? + if player:GetAttribute("Arena") ~= d.arena or not humanoid or not root or humanoid.Health <= 0 then + continue + end + local seat = humanoid.SeatPart + local position = if seat then seat.AssemblyRootPart.Position else root.Position + local radius = BC.PickupRadius + (if seat then 4 else 0) + if (position - d.position).Magnitude <= radius then + pick(player, model, d) + break + end + end + end +end + +function Drops.Init(remotes: Folder) + PickedRemote = Instance.new("RemoteEvent") + PickedRemote.Name = "BoostPicked" + PickedRemote.Parent = remotes + task.spawn(function() + while true do + task.wait(CHECK_INTERVAL) + check() + end + end) +end + +return Drops diff --git a/Zombi/src/server/Lobby.luau b/Zombi/src/server/Lobby.luau index ea9f4ca..2a0220c 100644 --- a/Zombi/src/server/Lobby.luau +++ b/Zombi/src/server/Lobby.luau @@ -12,6 +12,7 @@ local Config = require(ReplicatedStorage.Shared.Config) local Garage = require(script.Parent.Garage) local Hangar = require(script.Parent.Hangar) local Buggy = require(script.Parent.Buggy) +local Drops = require(script.Parent.Drops) local World = require(script.Parent.World) local Zombies = require(script.Parent.Zombies) @@ -250,6 +251,7 @@ end local function leaveArena(player: Player, toHangar: boolean) local circle = circles[player:GetAttribute("Arena") or 0] player:SetAttribute("Arena", 0) + Drops.Reset(player) -- бусты действуют только до конца боя Garage.RemoveBuggy(player) if toHangar then task.spawn(Garage.Teleport, player, Hangar.SpawnPoint, "Ангар") diff --git a/Zombi/src/server/Main.server.luau b/Zombi/src/server/Main.server.luau index 4929f0f..e6b2189 100644 --- a/Zombi/src/server/Main.server.luau +++ b/Zombi/src/server/Main.server.luau @@ -21,6 +21,7 @@ local Cases = require(script.Parent.Cases) local Shards = require(script.Parent.Shards) local Loading = require(script.Parent.Loading) local Zombies = require(script.Parent.Zombies) +local Drops = require(script.Parent.Drops) local remotes = Instance.new("Folder") remotes.Name = "Remotes" @@ -30,6 +31,7 @@ FlipBuggy.Parent = remotes Loading.Init(remotes) Shards.Init() Zombies.Init(remotes) +Drops.Init(remotes) Weapons.Init(remotes) Garage.Init(remotes) Lobby.Init(remotes) diff --git a/Zombi/src/server/Weapons.luau b/Zombi/src/server/Weapons.luau index 2e1d50e..4b182e3 100644 --- a/Zombi/src/server/Weapons.luau +++ b/Zombi/src/server/Weapons.luau @@ -6,6 +6,7 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") local Config = require(ReplicatedStorage.Shared.Config) +local BuggyStats = require(ReplicatedStorage.Shared.BuggyStats) local GunMath = require(ReplicatedStorage.Shared.GunMath) local Buggy = require(script.Parent.Buggy) local World = require(script.Parent.World) @@ -87,7 +88,7 @@ end -- Взрыв снаряда пушки или ракеты: урон спадает от центра к краю, бочки рядом детонируют. -- Стрелка не задевает. Багги в радиусе подбрасывает, водителю достаётся половина (если не прикрыт бронёй целиком). -local function blast(position: Vector3, spec, shooter: Player) +local function blast(position: Vector3, spec, shooter: Player, damage: number) local explosion = Instance.new("Explosion") explosion.Position = position explosion.BlastRadius = spec.blastRadius @@ -112,7 +113,7 @@ local function blast(position: Vector3, spec, shooter: Player) if humanoid and not damaged[humanoid] and humanoid.Parent ~= shooter.Character then damaged[humanoid] = true humanoid:SetAttribute("LastHitBy", shooter.UserId) - humanoid:TakeDamage(spec.damage * falloff) + humanoid:TakeDamage(damage * falloff) end end) explosion.Parent = workspace @@ -171,7 +172,10 @@ function Weapons.Init(remotes: Folder) if gun.overheated and gun.heat <= G.CoolResume then gun.overheated = false end - if gun.overheated or now - gun.lastShot < 0.8 / spec.fireRate then + -- Бусты из дропа: скорострельность и урон + local fireRate = spec.fireRate * BuggyStats.BoostMultiplier(player, "firerate") + local damage = spec.damage * BuggyStats.BoostMultiplier(player, "damage") + if gun.overheated or now - gun.lastShot < 0.8 / fireRate then return end gun.lastShot = now @@ -198,12 +202,12 @@ function Weapons.Init(remotes: Folder) if spec.kind == "bullet" then if result then - hit(result.Instance, player, spec.damage) + hit(result.Instance, player, damage) end else -- Снаряд летит до точки попадания (клиенты рисуют полёт), там взрыв. Промах — взрыв в конце дальности. local travel = (hitPosition - origin).Magnitude / spec.speed - task.delay(travel, blast, hitPosition, spec, player) + task.delay(travel, blast, hitPosition, spec, player, damage) end Tracer:FireAllClients(model, origin, hitPosition, player.UserId) end) diff --git a/Zombi/src/server/Zombies.luau b/Zombi/src/server/Zombies.luau index 87dad93..ff17b69 100644 --- a/Zombi/src/server/Zombies.luau +++ b/Zombi/src/server/Zombies.luau @@ -1,10 +1,13 @@ --- Зомби на картах команд. Когда команда загрузилась (Lobby → Zombies.Start), вокруг появляется стая и ждёт; --- на «НАЧАЛИ!» (Zombies.Attack) бросается в атаку. Новые приходят из-за пределов видимости вокруг игроков, --- бегут к ближайшему и бьют вблизи. +-- Зомби на картах команд, волнами. Когда команда загрузилась (Lobby → Zombies.Start), вокруг появляются +-- зомби первой волны и ждут; на «НАЧАЛИ!» (Zombies.Attack) бросаются в атаку. В волне конечное число зомби +-- (Config.Waves), одновременно на карте — не больше Config.Zombies Base/PerPlayer/Max: новые подходят +-- из-за пределов видимости. Волна выбита — появляется Босс-Зомби; убит босс — передышка и следующая волна. +-- Из убитых зомби иногда, из босса всегда выпадают бусты (Drops). Убившему — осколки. -- Урон им наносят пули и взрывы (Weapons) и таран багги (здесь): физически багги сквозь зомби не наезжает, --- удар считаем сами — зомби отлетает, машина чуть теряет скорость (меньше с тараном, бронёй, гусеницами). Каждое попадание сервер сообщает клиентам --- (ZombieHit) — они рисуют вылетающие цифры урона и искры. Убившему — осколки. --- Команда покинула карту (Lobby → Zombies.Stop) — зомби убираются. +-- удар считаем сами — зомби отлетает, машина чуть теряет скорость (меньше с тараном, бронёй, гусеницами). +-- Каждое попадание сервер сообщает клиентам (ZombieHit) — они рисуют вылетающие цифры урона и искры. +-- Состояние волны — в атрибутах папки Zombies<номер> (Wave, Phase, Remaining, BossHealth, BossMax), события — WaveEvent. +-- Команда покинула карту (Lobby → Zombies.Stop) — всё убирается. local Debris = game:GetService("Debris") local Players = game:GetService("Players") @@ -12,11 +15,15 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local Config = require(ReplicatedStorage.Shared.Config) +local BuggyStats = require(ReplicatedStorage.Shared.BuggyStats) local Buggy = require(script.Parent.Buggy) +local Drops = require(script.Parent.Drops) local Shards = require(script.Parent.Shards) local World = require(script.Parent.World) local Z = Config.Zombies +local WV = Config.Waves +local BS = Config.Boss local Zombies = {} local WALK_ANIMATION = "rbxassetid://180426354" -- стандартная анимация ходьбы R6 от Roblox @@ -26,10 +33,12 @@ local FRONT_BONUS = { spikes = 1.4, ram = 1.3, bucket = 1.2, bayonets = 1.8 } local rng = Random.new() local template: Model? = nil --- [номер карты] = { index, folder, zombies = { [Model] = data }, started } +-- [номер карты] = { index, folder, zombies = { [Model] = data }, attacking, pending, +-- wave, phase ("wave" | "boss" | "break"), toSpawn — сколько ещё зомби волны не вышло, boss — модель босса } local arenas = {} local HitRemote: RemoteEvent local ImpactRemote: RemoteEvent -- водителю: сбить скорость после удара о зомби +local WaveRemote: RemoteEvent -- игрокам карты: «волна N», «босс», «волна пройдена» (Round.client) -- ===== Модель ===== @@ -67,7 +76,7 @@ local function makeTemplate(): Model? Instance.new("Animator", humanoid) end - -- Светящиеся красные глаза + -- Светящиеся глаза local head = model:FindFirstChild("Head") :: BasePart? if head then for _, x in { -0.2, 0.2 } do @@ -99,12 +108,14 @@ local function makeTemplate(): Model? -- Ядовитое зелёное свечение: мягкий свет от тела и редкая дымка вокруг. if torso then local light = Instance.new("PointLight") + light.Name = "Glow" light.Color = Z.Glow light.Range = 9 light.Brightness = 1.2 light.Shadows = false light.Parent = torso local aura = Instance.new("ParticleEmitter") + aura.Name = "Aura" aura.Color = ColorSequence.new(Z.Glow) aura.LightEmission = 1 aura.Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 1), NumberSequenceKeypoint.new(0.3, 0.75), NumberSequenceKeypoint.new(1, 1) }) @@ -122,6 +133,34 @@ local function makeTemplate(): Model? return model end +-- Босс: тот же зомби, но огромный, темнее, с красным свечением. +local function makeBoss(health: number): Model + local model = (template :: Model):Clone() + model.Name = "Boss" + model:SetAttribute("Boss", true) + for _, d in model:GetDescendants() do + if d:IsA("BasePart") and d.Name ~= "HumanoidRootPart" then + if d.Name == "Eye" then + d.Color = BS.Glow + elseif d.Name == "Head" or d.Name:find("Arm") then + d.Color = BS.Color + end + elseif d.Name == "Glow" and d:IsA("PointLight") then + d.Color = BS.Glow + d.Range = 14 + d.Brightness = 2 + elseif d.Name == "Aura" and d:IsA("ParticleEmitter") then + d.Color = ColorSequence.new(BS.Glow) + d.Rate = 14 + end + end + model:ScaleTo(BS.Scale) + local humanoid = model:FindFirstChildOfClass("Humanoid") :: Humanoid + humanoid.MaxHealth = health + humanoid.Health = health + return model +end + -- ===== Игроки на карте ===== local function playersIn(index: number) @@ -138,7 +177,7 @@ local function playersIn(index: number) end -- Точка появления: на земле, на расстоянии от случайного игрока, внутри карты. -local function spawnPoint(index: number, targets): Vector3? +local function spawnPoint(index: number, targets, lift: number): Vector3? if #targets == 0 then return nil end @@ -152,21 +191,72 @@ local function spawnPoint(index: number, targets): Vector3? if math.abs(x - map.origin.X) < limit and math.abs(z - map.origin.Z) < limit then local ground = World.GroundHeight(x, z) if ground then - return Vector3.new(x, ground + 3.5 * Z.Scale, z) + return Vector3.new(x, ground + lift, z) end end end return nil end +-- ===== Волны ===== + +local function publish(arena) + local folder = arena.folder + local alive = 0 + for _, data in arena.zombies do + if data.humanoid.Health > 0 and not data.boss then + alive += 1 + end + end + folder:SetAttribute("Wave", arena.wave) + folder:SetAttribute("Phase", arena.phase) + folder:SetAttribute("Remaining", arena.toSpawn + arena.pending + alive) + local boss = arena.boss and arena.zombies[arena.boss] + folder:SetAttribute("BossHealth", if boss then math.max(0, boss.humanoid.Health) else 0) + folder:SetAttribute("BossMax", if boss then boss.humanoid.MaxHealth else 0) +end + +local function announce(arena, kind: string, value: number?) + for _, target in playersIn(arena.index) do + WaveRemote:FireClient(target.player, kind, value) + end +end + +local function startWave(arena, n: number, loud: boolean) + arena.wave = n + arena.phase = "wave" + arena.toSpawn = WV.FirstSize + WV.PerPlayer * math.max(1, #playersIn(arena.index)) + (n - 1) * WV.Growth + arena.boss = nil + if loud then + announce(arena, "wave", n) + end + publish(arena) +end + -- ===== Урон и смерть ===== +local spawnZombie: (any, any, boolean?) -> () + local function onDeath(arena, model: Model, data) + if arena.zombies[model] ~= data then + return + end arena.zombies[model] = nil local killerId = data.humanoid:GetAttribute("LastHitBy") local killer = killerId and Players:GetPlayerByUserId(killerId) - if killer and Z.ShardsPerKill > 0 then - task.spawn(Shards.Add, killer.UserId, Z.ShardsPerKill) + local reward = if data.boss then BS.Shards else Z.ShardsPerKill + if killer and reward > 0 then + task.spawn(Shards.Add, killer.UserId, reward) + end + -- Бусты: из обычного зомби — иногда, из босса — несколько, разлетаются вокруг. + local position = data.root.Position + if data.boss then + for i = 1, BS.Drops do + local a = i / BS.Drops * math.pi * 2 + Drops.Spawn(arena.folder, position + Vector3.new(math.cos(a), 0, math.sin(a)) * 7, arena.index) + end + elseif rng:NextNumber() < Config.Boosts.DropChance then + Drops.Spawn(arena.folder, position, arena.index) end -- Тело разлетается и через пару секунд исчезает. for _, part in model:GetChildren() do @@ -175,18 +265,33 @@ local function onDeath(arena, model: Model, data) end end Debris:AddItem(model, 3) + + if data.boss then + -- Босс убит — передышка и следующая волна, больше прежней. + arena.boss = nil + arena.phase = "break" + announce(arena, "cleared", arena.wave) + publish(arena) + task.delay(WV.Break, function() + if arenas[arena.index] == arena then + startWave(arena, arena.wave + 1, true) + end + end) + else + publish(arena) + end end -- Багги и зомби физически друг сквозь друга (группы столкновений в Buggy) — иначе зомби попадает под колесо, -- как на трамплин, и машину переворачивает. Удар считаем сами: зомби внутри габаритов багги. -local function insideBuggy(chassis: BasePart, position: Vector3): boolean +local function insideBuggy(chassis: BasePart, position: Vector3, reach: number): boolean local p = chassis.CFrame:PointToObjectSpace(position) - return math.abs(p.X) < 4.8 and p.Z > -8.5 and p.Z < 6.5 and p.Y > -4 and p.Y < 5 + return math.abs(p.X) < 4.8 + reach and p.Z > -8.5 - reach and p.Z < 6.5 + reach and p.Y > -4 and p.Y < 5 + reach * 2 end --- Багги на скорости сбивает зомби: урон от скорости, детали спереди добавляют, зомби отлетает, --- машина теряет немного скорости (сколько — зависит от деталей, BuggyStats.RamSlow). --- Медленно наехал — зомби просто отталкивает в сторону. +-- Багги на скорости сбивает зомби: урон от скорости, детали спереди и буст «Таран» добавляют, зомби отлетает, +-- машина теряет немного скорости (сколько — зависит от деталей и буста). Босса не отбросить, а машина +-- теряет втрое больше. Медленно наехал — обычного зомби просто отталкивает в сторону. local function ram(data, buggyModel: Model, buggy) local now = os.clock() if now - data.lastRam < 0.4 then @@ -196,19 +301,25 @@ local function ram(data, buggyModel: Model, buggy) local chassis = buggy.chassis local speed = (chassis.AssemblyLinearVelocity - data.root.AssemblyLinearVelocity).Magnitude if speed < Z.RamSpeed then - local side = chassis.CFrame.RightVector * (if chassis.CFrame:PointToObjectSpace(data.root.Position).X >= 0 then 1 else -1) - data.root.AssemblyLinearVelocity = side * 14 + Vector3.new(0, 6, 0) + if not data.boss then + local side = chassis.CFrame.RightVector * (if chassis.CFrame:PointToObjectSpace(data.root.Position).X >= 0 then 1 else -1) + data.root.AssemblyLinearVelocity = side * 14 + Vector3.new(0, 6, 0) + end return end local driver = Buggy.Driver(buggyModel) + local ramBoost = BuggyStats.BoostMultiplier(driver, "ram") if driver then data.humanoid:SetAttribute("LastHitBy", driver.UserId) -- Машину считает водитель — замедление применяет его клиент (Driving.client) - ImpactRemote:FireClient(driver, buggy.ramSlow) + local slow = buggy.ramSlow / ramBoost * (if data.boss then 3 else 1) + ImpactRemote:FireClient(driver, math.min(slow, 0.9)) end - local bonus = FRONT_BONUS[buggyModel:GetAttribute("Front") or ""] or 1 + local bonus = (FRONT_BONUS[buggyModel:GetAttribute("Front") or ""] or 1) * ramBoost data.humanoid:TakeDamage((10 + (speed - Z.RamSpeed) * Z.RamDamage) * bonus) - data.root.AssemblyLinearVelocity = chassis.AssemblyLinearVelocity * 1.1 + Vector3.new(0, 25, 0) + if not data.boss then + data.root.AssemblyLinearVelocity = chassis.AssemblyLinearVelocity * 1.1 + Vector3.new(0, 25, 0) + end end -- Каждый кадр: какие зомби оказались внутри какой-нибудь багги. @@ -220,7 +331,8 @@ local function checkRams() end local position = data.root.Position for buggyModel, buggy in Buggy.All() do - if buggy.chassis.Parent and (buggy.chassis.Position - position).Magnitude < 12 and insideBuggy(buggy.chassis, position) then + if buggy.chassis.Parent and (buggy.chassis.Position - position).Magnitude < 12 + data.reach * 2 + and insideBuggy(buggy.chassis, position, data.reach) then ram(data, buggyModel, buggy) break end @@ -229,22 +341,40 @@ local function checkRams() end end -local function spawnZombie(arena, targets) - local at = spawnPoint(arena.index, targets) - if not at or not template then +function spawnZombie(arena, targets, boss: boolean?) + if not template then return end - local model = template:Clone() + local health = BS.Health * (1 + BS.HealthGrowth * (arena.wave - 1)) + local scale = if boss then BS.Scale else Z.Scale + local at = spawnPoint(arena.index, targets, 3.5 * scale) + if not at then + return + end + local model = if boss then makeBoss(health) else template:Clone() model:PivotTo(CFrame.new(at) * CFrame.Angles(0, rng:NextNumber(0, math.pi * 2), 0)) local humanoid = model:FindFirstChildOfClass("Humanoid") :: Humanoid local root = model:FindFirstChild("HumanoidRootPart") :: BasePart - humanoid.WalkSpeed = rng:NextNumber(Z.WalkSpeed[1], Z.WalkSpeed[2]) + humanoid.WalkSpeed = if boss then BS.WalkSpeed else rng:NextNumber(Z.WalkSpeed[1], Z.WalkSpeed[2]) model.Parent = arena.folder pcall(function() root:SetNetworkOwner(nil) -- ИИ на сервере: физику зомби считает он же end) - local data = { humanoid = humanoid, root = root, speed = humanoid.WalkSpeed, lastAttack = 0, lastRam = 0, health = humanoid.Health, walk = nil } + local data = { + humanoid = humanoid, + root = root, + boss = boss == true, + speed = humanoid.WalkSpeed, + attackRange = if boss then BS.AttackRange else Z.AttackRange, + attackDamage = if boss then BS.AttackDamage else Z.AttackDamage, + attackCooldown = if boss then BS.AttackCooldown else Z.AttackCooldown, + reach = (scale - Z.Scale) * 1.5, -- большой босс достаёт до машины раньше + lastAttack = 0, + lastRam = 0, + health = humanoid.Health, + walk = nil, + } local animator = humanoid:FindFirstChildOfClass("Animator") if animator then local animation = Instance.new("Animation") @@ -258,24 +388,43 @@ local function spawnZombie(arena, targets) end end arena.zombies[model] = data + if boss then + arena.boss = model + end -- Каждое снижение здоровья — клиентам: цифры урона и искры над зомби. - humanoid.HealthChanged:Connect(function(health) - local lost = data.health - health - data.health = health + humanoid.HealthChanged:Connect(function(newHealth) + local lost = data.health - newHealth + data.health = newHealth if lost >= 0.5 then local head = model:FindFirstChild("Head") :: BasePart? local position = if head then head.Position else root.Position - HitRemote:FireAllClients(position, math.floor(lost + 0.5), health <= 0) + HitRemote:FireAllClients(position, math.floor(lost + 0.5), newHealth <= 0) + end + if data.boss then + publish(arena) end end) humanoid.Died:Connect(function() onDeath(arena, model, data) end) + publish(arena) end -- ===== ИИ ===== +-- Зомби пропал не от рук игроков (провалился, отстал) — в волну он возвращается, босс появляется заново. +local function lose(arena, model: Model, data) + arena.zombies[model] = nil + model:Destroy() + if data.boss then + arena.boss = nil + spawnZombie(arena, playersIn(arena.index), true) + else + arena.toSpawn += 1 + end +end + local function think(arena) local targets = playersIn(arena.index) local now = os.clock() @@ -284,11 +433,8 @@ local function think(arena) if data.humanoid.Health <= 0 then continue end - alive += 1 - -- Провалился или отстал далеко от всех — убираем, на его место придёт новый поближе. if data.root.Position.Y < -40 then - arena.zombies[model] = nil - model:Destroy() + lose(arena, model, data) continue end local nearest, distance = nil, math.huge @@ -299,12 +445,14 @@ local function think(arena) end end if nearest and distance > 450 then - arena.zombies[model] = nil - model:Destroy() + lose(arena, model, data) continue end + if not data.boss then + alive += 1 + end if nearest and not arena.attacking then - -- Раунд ещё не начался: стоят и смотрят на ближайшего игрока. + -- Раунд ещё не начался: стоят. data.humanoid:MoveTo(data.root.Position) if data.walk and data.walk.IsPlaying then data.walk:Stop() @@ -319,19 +467,26 @@ local function think(arena) end data.walk:AdjustSpeed(data.humanoid.WalkSpeed / 14) end - if distance <= Z.AttackRange and now - data.lastAttack >= Z.AttackCooldown then + if distance <= data.attackRange and now - data.lastAttack >= data.attackCooldown then data.lastAttack = now - nearest.humanoid:TakeDamage(Z.AttackDamage) + -- Буст «Броня» уменьшает урон по игроку + local armor = Config.BoostById.armor + local reduce = math.min(0.8, armor.step * BuggyStats.BoostStacks(nearest.player, "armor")) + nearest.humanoid:TakeDamage(data.attackDamage * (1 - reduce)) end elseif data.walk and data.walk.IsPlaying then data.walk:Stop() end end - -- Пополняем стаю до нужного размера (не больше двух за раз — чтобы не появлялись толпой). - if arena.started and #targets > 0 then - local wanted = math.min(Z.Max, Z.Base + Z.PerPlayer * #targets) - for _ = 1, math.min(2, wanted - alive - arena.pending) do + if #targets == 0 then + return + end + if arena.phase == "wave" then + -- Подводим зомби волны, пока на карте не наберётся нужная толпа (не больше двух за раз). + local cap = math.min(Z.Max, Z.Base + Z.PerPlayer * #targets) + for _ = 1, math.min(2, cap - alive - arena.pending, arena.toSpawn) do + arena.toSpawn -= 1 arena.pending += 1 task.delay(if alive == 0 then 0 else Z.RespawnDelay * rng:NextNumber(0.3, 1), function() arena.pending -= 1 @@ -340,18 +495,29 @@ local function think(arena) end end) end + -- Волна выбита — выходит босс. + if arena.toSpawn <= 0 and arena.pending == 0 and alive == 0 and arena.attacking then + arena.phase = "boss" + announce(arena, "boss", arena.wave) + spawnZombie(arena, targets, true) + end + elseif arena.phase == "boss" and not arena.boss then + spawnZombie(arena, targets, true) -- не нашлось места с первого раза — пробуем снова end + publish(arena) end -- ===== Карты ===== --- Стая появляется вокруг команды и ждёт (Lobby запускает это на отсчёте перед раундом). +-- Команда загрузилась: появляются зомби первой волны и ждут (Lobby запускает это на отсчёте перед раундом). function Zombies.Start(index: number) Zombies.Stop(index) local folder = Instance.new("Folder") folder.Name = "Zombies" .. index folder.Parent = workspace - arenas[index] = { index = index, folder = folder, zombies = {}, started = true, attacking = false, pending = 0 } + local arena = { index = index, folder = folder, zombies = {}, attacking = false, pending = 0, wave = 1, phase = "wave", toSpawn = 0 } + arenas[index] = arena + startWave(arena, 1, false) -- первую волну объявляет «НАЧАЛИ!» end -- Раунд начался — в атаку. @@ -377,6 +543,9 @@ function Zombies.Init(remotes: Folder) ImpactRemote = Instance.new("RemoteEvent") ImpactRemote.Name = "BuggyImpact" ImpactRemote.Parent = remotes + WaveRemote = Instance.new("RemoteEvent") + WaveRemote.Name = "WaveEvent" + WaveRemote.Parent = remotes task.spawn(function() template = makeTemplate() end) diff --git a/Zombi/src/shared/BuggyStats.luau b/Zombi/src/shared/BuggyStats.luau index b701ee7..ca79571 100644 --- a/Zombi/src/shared/BuggyStats.luau +++ b/Zombi/src/shared/BuggyStats.luau @@ -48,4 +48,20 @@ function BuggyStats.Compute(setup) return result end +-- ===== Бусты из дропа (действуют до конца боя) ===== + +-- Сколько раз игрок подобрал буст id (атрибут Boost_, его ведёт сервер). +function BuggyStats.BoostStacks(player: Player, id: string): number + return player:GetAttribute("Boost_" .. id) or 0 +end + +-- Множитель от буста: 1 + step × количество (скорострельность, урон, таран, скорость, манёвренность). +function BuggyStats.BoostMultiplier(player: Player?, id: string): number + local boost = Config.BoostById[id] + if not player or not boost then + return 1 + end + return 1 + boost.step * BuggyStats.BoostStacks(player, id) +end + return BuggyStats diff --git a/Zombi/src/shared/Config.luau b/Zombi/src/shared/Config.luau index 1b8b5d1..8fd499d 100644 --- a/Zombi/src/shared/Config.luau +++ b/Zombi/src/shared/Config.luau @@ -172,6 +172,49 @@ Config.Zombies = { Glow = Color3.fromRGB(110, 255, 80), -- свечение: свет от тела, дымка, глаза } +-- Волны: в каждой конечное число зомби (одновременно на карте — не больше Config.Zombies Base/PerPlayer/Max). +-- Волна выбита — появляется Босс-Зомби, после него передышка и следующая волна, больше прежней. +Config.Waves = { + FirstSize = 15, -- зомби в первой волне + PerPlayer = 6, -- и ещё столько на каждого игрока команды + Growth = 8, -- каждая следующая волна больше на столько + Break = 8, -- секунд передышки после босса +} + +Config.Boss = { + Scale = 3, -- во сколько раз выше обычного персонажа + Health = 1200, + HealthGrowth = 0.35, -- с каждой волной здоровья больше на эту долю + WalkSpeed = 13, + AttackRange = 13, + AttackDamage = 25, + AttackCooldown = 1.6, + Shards = 30, -- награда убившему + Drops = 4, -- сколько бустов гарантированно выпадает + Color = Color3.fromRGB(80, 105, 65), + Glow = Color3.fromRGB(255, 60, 40), +} + +-- Бусты: выпадают из зомби (с шансом DropChance) и босса, подбираются касанием багги или персонажа. +-- Действуют до конца боя и складываются до max: каждый подобранный добавляет step. +Config.Boosts = { + DropChance = 0.2, + Lifetime = 45, -- через сколько секунд неподобранный буст исчезает + PickupRadius = 7, + List = { + { id = "firerate", name = "Скорострельность", icon = "⚡", color = Color3.fromRGB(255, 170, 40), step = 0.15, max = 5 }, + { id = "damage", name = "Урон", icon = "💥", color = Color3.fromRGB(235, 60, 50), step = 0.15, max = 5 }, + { id = "ram", name = "Таран", icon = "🐏", color = Color3.fromRGB(240, 225, 60), step = 0.3, max = 3 }, + { id = "armor", name = "Броня", icon = "🛡️", color = Color3.fromRGB(175, 105, 230), step = 0.12, max = 4 }, + { id = "speed", name = "Скорость", icon = "💨", color = Color3.fromRGB(70, 150, 240), step = 0.1, max = 3 }, + { id = "handling", name = "Манёвренность", icon = "🌀", color = Color3.fromRGB(90, 215, 120), step = 0.15, max = 3 }, + }, +} +Config.BoostById = {} +for _, boost in Config.Boosts.List do + Config.BoostById[boost.id] = boost +end + -- Осколки — внутриигровая валюта: открывают закрытые детали и покраски. -- Выпадают на колесе фортуны и из кейсов (kind = "shards", amount = N). Config.Shards = {