--!strict local ReplicatedStorage = game:GetService("ReplicatedStorage") local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) local Sites = require(script.Parent:WaitForChild("ArenaObjectiveSites") :: ModuleScript) local HotPoint = require(script.Parent:WaitForChild("HotPoint") :: ModuleScript) local SiegeConfig = require(ReplicatedStorage:WaitForChild("CitadelAssaultConfig") :: ModuleScript) local Capture = require(script.Parent:WaitForChild("CitadelCaptureService") :: ModuleScript) local Score = require(script.Parent:WaitForChild("CitadelScoreService") :: ModuleScript) local SiegeSpawn = require(script.Parent:WaitForChild("CitadelSpawnService") :: ModuleScript) local CollectionService = game:GetService("CollectionService") type Side = "Blue" | "Orange" type Fighter = HotPoint.Fighter type Marker = HotPoint.Marker & {recolor: ((Color3) -> ())?} type Zone = {site: Sites.Site, marker: Marker, owner: Side?, claiming: Side?, progress: number} type Flag = { marker: Marker, stars: ParticleEmitter, mist: ParticleEmitter, light: PointLight, banner: BasePart, carrier: Player?, tether: WeldConstraint?, droppedUntil: number, } type Drop = {marker: Marker, amount: number, expires: number} type Config = {arena: string, rule: string, state: Instance, now: number, duration: number, members: () -> {Player}, bench: (Player) -> (), deploy: (Player) -> (), balanceWaiting: () -> ()} export type Match = { step: (number) -> boolean, kill: (Player, Player, Vector3, number) -> (), hit: ((Player, number, boolean) -> ())?, death: (Player, Vector3?, number) -> (), leaving: (Player, Vector3?, number) -> (), winner: () -> string, destroy: () -> (), } local active: {[string]: Match} = {} local Objectives = {} local objectiveCue = Instance.new("RemoteEvent") objectiveCue.Name = "ArenaObjectiveCue" objectiveCue.Parent = ReplicatedStorage local sides: {Side} = {"Blue", "Orange"} local blue = Color3.fromRGB(67, 216, 255) local orange = Color3.fromRGB(255, 150, 68) local gold = Color3.fromRGB(255, 220, 96) local neutral = Color3.fromRGB(188, 150, 255) local rng = Random.new() local function opposite(side: Side): Side return if side == "Blue" then "Orange" else "Blue" end local function color(side: Side?): Color3 return if side == "Blue" then blue elseif side == "Orange" then orange else neutral end local function sideOf(player: Player): Side? local side = player:GetAttribute("ArenaTeam") return if side == "Blue" then "Blue" elseif side == "Orange" then "Orange" else nil end local function boundsAt(position: Vector3, target: Vector3, radius: number, height: number): boolean local delta = position - target return math.abs(delta.Y) < height and delta.X * delta.X + delta.Z * delta.Z <= radius * radius end local function label(adornee: BasePart, name: string, tint: Color3, offset: number, waypoint: boolean?): TextLabel local gui = Instance.new("BillboardGui") gui.Name = "ObjectiveLabel" gui.Size = UDim2.fromOffset(220, 26) gui.StudsOffsetWorldSpace = Vector3.yAxis * offset gui.MaxDistance = if waypoint then 710 else 170 gui.AlwaysOnTop = waypoint == true gui.LightInfluence = 0 gui.Parent = adornee local text = Instance.new("TextLabel") text.Size = UDim2.fromScale(1, 1) text.BackgroundTransparency = 1 text.Font = Enum.Font.GothamBlack text.TextSize = 15 text.Text, text.TextColor3 = name, tint text.TextStrokeColor3, text.TextStrokeTransparency = Color3.fromRGB(9, 13, 25), .14 text.Parent = gui return text end local function marker(parent: Instance, id: string, name: string, at: Vector3, tint: Color3, diameter: number, tall: boolean?): Marker local part = Instance.new("Part") part.Name = id if not tall then part:SetAttribute("ObjectiveArrow", true) end part.Shape = if tall then Enum.PartType.Ball else Enum.PartType.Cylinder part.Size = if tall then Vector3.new(diameter, diameter, diameter) else Vector3.new(.16, diameter, diameter) part.CFrame = CFrame.new(at + Vector3.yAxis * (if tall then 2.4 else .12)) * CFrame.Angles(0, 0, math.pi / 2) part.Anchored, part.CanCollide, part.CanQuery, part.CanTouch, part.CastShadow = true, false, false, false, false part.Material, part.Color = Enum.Material.Neon, tint part.Transparency = if tall then .04 else .76 local aura = Instance.new("PointLight") aura.Range, aura.Brightness, aura.Color = if tall then 13 else 9, .7, tint aura.Parent = part part.Parent = parent return {body = part, label = label(part, name, tint, if tall then 2.1 else 4, id ~= "Tokens"), origin = at} end local function ring(parent: Instance, id: string, name: string, at: Vector3, tint: Color3): Marker local mark = marker(parent, id, name, at, tint, HotPoint.Radius * 2) local recolor = HotPoint.attachRing(mark) mark.recolor = recolor recolor(tint) return mark end local function paint(mark: Marker, tint: Color3) if mark.body.Color == tint then return end if mark.recolor then mark.recolor(tint) return end mark.body.Color = tint mark.label.TextColor3 = tint local aura = mark.body:FindFirstChildOfClass("PointLight") if aura then aura.Color = tint end end local function makeFlag(parent: Instance, roof: Vector3): Flag local mark = marker(parent, "CitadelFlag", "ФЛАГ · КРЫША", roof, gold, 2.6, true) local body = mark.body body.Transparency = 1 body.CFrame = CFrame.new(body.Position) local light = assert(body:FindFirstChildOfClass("PointLight")) light.Range, light.Brightness = 21, 1.6 local function attach(name: string, size: Vector3, offset: Vector3, tint: Color3): Part local part = Instance.new("Part") part.Name, part.Size, part.Color = name, size, tint part.CFrame = body.CFrame + offset part.Material = Enum.Material.Neon part.Massless, part.CanCollide, part.CanTouch, part.CanQuery = true, false, false, false part.Parent = body local weld = Instance.new("WeldConstraint") weld.Part0, weld.Part1, weld.Parent = body, part, part return part end attach("Pole", Vector3.new(.17, 4.5, .17), Vector3.zero, Color3.fromRGB(235, 235, 255)) local banner = attach("Banner", Vector3.new(2.65, 1.48, .15), Vector3.new(1.35, 1.45, 0), gold) attach("CrownLight", Vector3.new(.33, .33, .33), Vector3.yAxis * 2.34, neutral).Shape = Enum.PartType.Ball local aura = Instance.new("Attachment") aura.Name = "FlagAura" aura.Position = -Vector3.yAxis * 1.75 aura.Parent = body local stars = Instance.new("ParticleEmitter") stars.Name = "Stars" stars.Texture = "rbxasset://textures/particles/sparkles_main.dds" stars.Color = ColorSequence.new(neutral, gold) stars.LightEmission, stars.LightInfluence = 1, 0 stars.Rate, stars.Speed, stars.Lifetime = 24, NumberRange.new(3, 6), NumberRange.new(.7, 1.4) stars.SpreadAngle = Vector2.new(65, 65) stars.Rotation, stars.RotSpeed = NumberRange.new(-180, 180), NumberRange.new(-90, 90) stars.Size = NumberSequence.new({NumberSequenceKeypoint.new(0, .22), NumberSequenceKeypoint.new(.4, .52), NumberSequenceKeypoint.new(1, 0)}) stars.Parent = aura local mist = Instance.new("ParticleEmitter") mist.Name = "ColoredMist" mist.Texture = "rbxasset://textures/particles/smoke_main.dds" mist.Color = ColorSequence.new(neutral, gold) mist.LightEmission, mist.LightInfluence = .55, 0 mist.Rate, mist.Speed, mist.Lifetime = 9, NumberRange.new(1, 4), NumberRange.new(.7, 1.2) mist.SpreadAngle = Vector2.new(110, 110) mist.Size = NumberSequence.new(1.4, 4) mist.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0, .72), NumberSequenceKeypoint.new(.45, .79), NumberSequenceKeypoint.new(1, 1)}) mist.Parent = aura return {marker = mark, stars = stars, mist = mist, light = light, banner = banner, carrier = nil, tether = nil, droppedUntil = 0} end local function visibleAt(fighter: Fighter, at: Vector3, geometry: RaycastParams): boolean return workspace:Raycast(fighter.root.Position, at - fighter.root.Position, geometry) == nil end local function presence(fighters: {Fighter}, zone: Zone, geometry: RaycastParams): (boolean, boolean) local b, o = false, false -- Separate vertically stacked objectives by avatar foot height. for _, fighter in fighters do if boundsAt(fighter.root.Position, zone.site.position, HotPoint.Radius, 8) and visibleAt(fighter, zone.site.position + Vector3.yAxis * 2.7, geometry) then if fighter.side == "Blue" then b = true else o = true end end end return b, o end function Objectives.current(arena: string): Match? return active[arena] end function Objectives.start(config: Config): Match local rule, state, arena = config.rule, config.state, config.arena local world = Modes.geometry(arena) local geometry = Modes.collision(arena) local map = if rule == "TeamDeathmatch" or rule == "HuntLeader" then nil else Sites.resolve(arena) local hotPath = if rule == "HotPoint" and map then Sites.hotPath(arena, map, HotPoint.Radius) else nil local folder = Instance.new("Folder") folder.Name = "MatchObjectives" folder.Parent = world local blueScore, orangeScore = 0, 0 local function add(side: Side, points: number) if side == "Blue" then blueScore += points else orangeScore += points end state:SetAttribute(side .. "Score", if side == "Blue" then blueScore else orangeScore) end local function status(text: string) if state:GetAttribute("ObjectiveStatus") ~= text then state:SetAttribute("ObjectiveStatus", text) end end state:SetAttribute("BlueScore", 0) state:SetAttribute("OrangeScore", 0) state:SetAttribute("ObjectiveStatus", "") local function collect(members: {Player}): {Fighter} local found: {Fighter} = {} for _, p in members do local side = sideOf(p) local c = p.Character local h = c and c:FindFirstChildOfClass("Humanoid") local r = c and c:FindFirstChild("HumanoidRootPart") if side and h and h.Health > 0 and r and r:IsA("BasePart") and p:GetAttribute("InArena") == true then table.insert(found, {player = p, side = side, root = r}) end end return found end local function cue(fighters: {Fighter}, captured: boolean, side: Side?) for _, fighter in fighters do if captured or fighter.side == side then objectiveCue:FireClient(fighter.player, captured) end end end local function makeZone(site: Sites.Site, name: string): Zone site = {name = site.name, position = Sites.clearCircle(site.position, geometry, HotPoint.Radius)} return {site = site, marker = ring(folder, name, site.name, site.position, neutral), owner = nil, claiming = nil, progress = 0} end local zones: {Zone} = {} local hotPoint = if hotPath then HotPoint.start({ state = state, geometry = geometry, sites = hotPath, startedAt = config.now, marker = function(site: Sites.Site): Marker return marker(folder, "HotPoint", "ГОРЯЧАЯ ТОЧКА", site.position, neutral, HotPoint.Radius * 2) end, score = add, status = status, }) else nil local flag = if rule == "CaptureFlag" and map then makeFlag(folder, map.roof.position) else nil local tokens: {Drop} = {} local carried: {[Player]: number} = {} local leaders: {[Side]: Player} = {} local previousLeader: {[Side]: Player} = {} local leaderLabels: {[Player]: BillboardGui} = {} local siegeTimes: Score.Ledger = {Blue = {}, Orange = {}} local siegeSide: Side = if SiegeConfig.FIRST_ATTACKER == "Orange" then "Orange" else "Blue" local siegeIndex, siegeProgress = 1, 0 local siegeCaptureStarted = false local hadSiegeSwap = false local siegeState: Folder? = nil local lifeActive, miniNumber = false, 0 local lifeEnds, nextMini = math.huge, config.now + 2 local lastStep, nextScore = config.now, config.now + 1 local match: Match if map then if rule == "Domination" then for i, site in {map.west, map.gallery, map.east} do local key = string.char(64 + i) local zone = makeZone(site, key) zone.marker.label.Text = key .. " · " .. site.name table.insert(zones, zone) end elseif rule == "CaptureFlag" or rule == "TrophyHunt" then map.blue = Sites.clearCircle(map.blue, geometry, HotPoint.Radius) map.orange = Sites.clearCircle(map.orange, geometry, HotPoint.Radius) for _, side in sides do local at = if side == "Blue" then map.blue else map.orange local name = if side == "Blue" then "БАЗА СИНИХ" else "БАЗА ОРАНЖЕВЫХ" ring(folder, side .. "Base", name, at, color(side)) end elseif rule == "Siege" then local data = Instance.new("Folder") data.Name = "CitadelMatchState" data.Parent = state siegeState = data local sites: {Sites.Site} = {map.ground, map.gallery, map.roof} for _, point in CollectionService:GetTagged("CitadelPoint") do if not point:IsA("BasePart") or not point:IsDescendantOf(world) then continue end local index = point:GetAttribute("Index") if typeof(index) == "number" and index % 1 == 0 and sites[index] then sites[index] = {name = sites[index].name, position = point.Position} end end for i, site in sites do local zone = makeZone(site, "Checkpoint" .. i) zone.marker.body:SetAttribute("Index", i) zone.marker.body.Parent = nil table.insert(zones, zone) end zones[1].marker.body.Parent = folder end end local function putFlag(object: Flag, at: Vector3, droppedUntil: number) if object.carrier then object.carrier:SetAttribute("ArenaFlag", nil) end if object.tether then object.tether:Destroy() end object.carrier, object.tether, object.droppedUntil = nil, nil, droppedUntil local mark = object.marker mark.body.Anchored = true mark.body.CFrame = CFrame.new(at + Vector3.yAxis * 2.4) mark.label.Text = if droppedUntil > 0 then "ФЛАГ УПАЛ" else "ФЛАГ · КРЫША" mark.label.TextColor3, object.banner.Color = gold, gold object.stars.Enabled, object.mist.Enabled, object.light.Enabled = true, true, true object.stars:Emit(16) end local function pickUpFlag(object: Flag, fighter: Fighter) local body = object.marker.body body.CFrame = fighter.root.CFrame * CFrame.new(0, 3.15, .65) body.Massless = true local tether = Instance.new("WeldConstraint") tether.Part0, tether.Part1 = body, fighter.root tether.Parent = body body.Anchored = false object.carrier, object.tether, object.droppedUntil = fighter.player, tether, 0 fighter.player:SetAttribute("ArenaFlag", true) local tint = color(fighter.side) object.marker.label.Text = fighter.player.DisplayName .. " · НЕСЁТ ФЛАГ" object.marker.label.TextColor3, object.banner.Color = tint, tint object.stars.Enabled, object.mist.Enabled, object.light.Enabled = false, false, false object.stars:Clear() object.mist:Clear() end local function floorAt(at: Vector3): Vector3 local hit = workspace:Raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry) return if hit then hit.Position else (if map then map.ground.position else at) end local function tokenDrop(at: Vector3, amount: number, now: number) local floor = floorAt(at) for _, existing in tokens do if boundsAt(existing.marker.origin, floor, 3.5, 3) then existing.amount += amount existing.expires = now + 42 existing.marker.label.Text = "ЖЕТОНЫ ×" .. existing.amount return end end if #tokens >= 60 then local old = table.remove(tokens, 1) old.marker.body:Destroy() end table.insert(tokens, {marker = marker(folder, "Tokens", "ЖЕТОНЫ ×" .. amount, floor, gold, 1.55, true), amount = amount, expires = now + 42}) end local function dropCarried(player: Player, at: Vector3?, now: number) if flag and flag.carrier == player then if at then local floor = workspace:Raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry) local landing = if floor then floor.Position else at putFlag(flag, landing, now + 20) for _, fighter in collect(config.members()) do objectiveCue:FireClient(fighter.player, "FlagDropped") end else putFlag(flag, flag.marker.origin, 0) end end local amount = carried[player] if amount then carried[player] = nil player:SetAttribute("ArenaTokens", nil) if at then tokenDrop(at, amount, now) end end end local function clearLeader(side: Side) local p = leaders[side] if not p then return end previousLeader[side] = p leaders[side] = nil p:SetAttribute("ArenaLeader", nil) local badge = leaderLabels[p] if badge then badge:Destroy() end leaderLabels[p] = nil end local function updateLeaders(fighters: {Fighter}) for _, side in sides do local roster: {Fighter} = {} local present = false for _, f in fighters do if f.side ~= side then continue end table.insert(roster, f) if f.player == leaders[side] then present = true end end if present then continue end clearLeader(side) if #roster == 0 then continue end local pick = rng:NextInteger(1, #roster) if #roster > 1 and roster[pick].player == previousLeader[side] then pick = pick % #roster + 1 end local p = roster[pick].player local head = p.Character and p.Character:FindFirstChild("Head") if not head or not head:IsA("BasePart") then continue end leaders[side] = p p:SetAttribute("ArenaLeader", true) leaderLabels[p] = label(head, "ЛИДЕР", gold, 2.7).Parent :: BillboardGui end local a, b = leaders.Blue, leaders.Orange status("Лидеры · " .. (if a then a.DisplayName else "—") .. " / " .. (if b then b.DisplayName else "—")) end local function runFlag(fighters: {Fighter}, now: number) if not flag or not map then return end if flag.carrier then for _, fighter in fighters do if fighter.player ~= flag.carrier then continue end local base = if fighter.side == "Blue" then map.blue else map.orange if boundsAt(fighter.root.Position, base, HotPoint.Radius, 7) then add(fighter.side, 1) cue(fighters, true, nil) putFlag(flag, flag.marker.origin, 0) status("Флаг вернулся на крышу цитадели") end return end local carrier = flag.carrier local root = carrier.Character and carrier.Character.PrimaryPart dropCarried(carrier, root and root.Position, now) return elseif flag.droppedUntil > 0 and now >= flag.droppedUntil then putFlag(flag, flag.marker.origin, 0) end local at = flag.marker.body.Position for _, fighter in fighters do if boundsAt(fighter.root.Position, at, 5.5, 6.5) and visibleAt(fighter, at, geometry) then pickUpFlag(flag, fighter) cue(fighters, false, fighter.side) status(fighter.player.DisplayName .. " несёт флаг") return end end status(if flag.droppedUntil > 0 then "Флаг на земле · Подберите его" else "Флаг на крыше цитадели") end local function runTrophies(fighters: {Fighter}, now: number) if not map then return end for i = #tokens, 1, -1 do local token = tokens[i] local collector: Fighter? = nil if now < token.expires then for _, f in fighters do if boundsAt(f.root.Position, token.marker.origin, 5, 6) and visibleAt(f, token.marker.body.Position, geometry) then collector = f; break end end if not collector then continue end local p = collector.player if not carried[p] then cue(fighters, false, collector.side) end carried[p] = (carried[p] or 0) + token.amount p:SetAttribute("ArenaTokens", carried[p]) end token.marker.body:Destroy() table.remove(tokens, i) end for _, f in fighters do local amount = carried[f.player] if amount and boundsAt(f.root.Position, if f.side == "Blue" then map.blue else map.orange, HotPoint.Radius, 7) then add(f.side, amount) cue(fighters, true, nil) carried[f.player] = nil f.player:SetAttribute("ArenaTokens", nil) end end status("Сдавайте собранные жетоны на своей базе") end local function runSiege(members: {Player}, fighters: {Fighter}, now: number, dt: number): boolean local data = assert(siegeState) local half = SiegeConfig.ATTACK_DURATION local elapsed = now - config.now if elapsed >= half and not hadSiegeSwap then hadSiegeSwap = true for _, z in zones do z.marker.body.Parent = nil end siegeSide, siegeIndex, siegeProgress = opposite(siegeSide), 1, 0 siegeCaptureStarted = false local arenaSites = assert(map) local ordinals = {Blue = 0, Orange = 0} for _, p in members do config.deploy(p) local side, character = sideOf(p), p.Character if not side or not character or not character.PrimaryPart then continue end local attack = side == siegeSide ordinals[side] += 1 local at = SiegeSpawn.position(world, attack, if attack then arenaSites.blue else arenaSites.orange, ordinals[side]) character:PivotTo(CFrame.new(at + Vector3.yAxis * 4)) end end local swap = elapsed >= half and elapsed < half + SiegeConfig.SWAP_FREEZE local attackStart = if hadSiegeSwap then half + SiegeConfig.SWAP_FREEZE else 0 data:SetAttribute("Phase", if swap then "RoleSwap" elseif hadSiegeSwap then "Attack2" else "Attack1") data:SetAttribute("Attacker", siegeSide) data:SetAttribute("Seconds", math.clamp(math.ceil(half - (elapsed - attackStart)), 0, half)) if swap then data:SetAttribute("Progress", 0) data:SetAttribute("Status", "Idle") status("СМЕНА РОЛЕЙ") return false end local attacker = if siegeSide == "Blue" then "Синие" else "Оранжевые" local zone = zones[siegeIndex] data:SetAttribute("Index", siegeIndex) if not zone then data:SetAttribute("Point", nil) data:SetAttribute("NextPoint", nil) status("Все рубежи взяты!") return true end zone.marker.body.Parent = folder local attack, defense = false, false for _, fighter in fighters do local delta = fighter.root.Position - zone.site.position local reason = "Outside" if delta.X * delta.X + delta.Z * delta.Z <= HotPoint.Radius ^ 2 then if math.abs(delta.Y) > SiegeConfig.HEIGHT_TOLERANCE then reason = "Height" elseif not visibleAt(fighter, zone.site.position + Vector3.yAxis * SiegeConfig.SIGHT_HEIGHT, geometry) then reason = "Blocked" else reason = "Inside" if fighter.side == siegeSide then attack = true else defense = true end end end fighter.player:SetAttribute("CitadelZone", reason) end local progress, phase = Capture.advance(siegeProgress, math.min(dt, math.max(0, elapsed - attackStart)), attack, defense, SiegeConfig.CAPTURE_TIME, SiegeConfig.DECAY_MULTIPLIER) if phase == "Capturing" and not siegeCaptureStarted then cue(fighters, false, siegeSide) siegeCaptureStarted = true elseif progress == 0 and phase ~= "Capturing" then siegeCaptureStarted = false end siegeProgress = progress data:SetAttribute("Progress", progress) data:SetAttribute("Status", phase) data:SetAttribute("Point", zone.site.position) data:SetAttribute("PointName", zone.site.name) local nextZone = zones[siegeIndex + 1] data:SetAttribute("NextPoint", if nextZone then nextZone.site.position else nil) local percent = math.floor(progress / SiegeConfig.HUD_PROGRESS_STEP + 1e-8) * SiegeConfig.HUD_PROGRESS_STEP * 100 local reason = if phase == "Contested" then "Зона оспаривается!" elseif phase == "Decaying" then "Захват откатывается" elseif phase == "Capturing" then "Захват идёт" else "Двигайтесь к синему кругу" status(string.format("%s · Рубеж %d/%d · %d%% · %s", attacker, siegeIndex, #zones, percent, reason)) paint(zone.marker, if phase == "Contested" then orange else blue) if phase ~= "Captured" or not Score.record(siegeTimes, siegeSide, siegeIndex, elapsed - attackStart) then return false end add(siegeSide, SiegeConfig.POINTS_PER_OBJECTIVE) cue(fighters, true, nil) siegeCaptureStarted = false data:SetAttribute(siegeSide .. "Time" .. siegeIndex, elapsed - attackStart) zone.marker.body.Parent = nil siegeIndex += 1 siegeProgress = 0 return siegeIndex > #zones end local function runOneLife(members: {Player}, fighters: {Fighter}, now: number): boolean if lifeActive then local b, o = 0, 0 for _, f in fighters do if f.side == "Blue" then b += 1 else o += 1 end end if (b > 0 and o > 0) and now < lifeEnds then status(string.format("Мини-раунд %d · Живы %d / %d · %d с", miniNumber, b, o, math.ceil(lifeEnds - now))) return false end if b ~= o then add(if b > o then "Blue" else "Orange", 1) end if blueScore >= 3 or orangeScore >= 3 then return true end for _, p in members do config.bench(p) end lifeActive, nextMini = false, now + 4 end if now >= nextMini then config.balanceWaiting() end local ready: {Player} = {} local b, o = false, false for _, p in members do local c = p.Character local h = c and c:FindFirstChildOfClass("Humanoid") if not c or not c.PrimaryPart or not h or h.Health <= 0 then continue end table.insert(ready, p) if sideOf(p) == "Blue" then b = true else o = true end end if b and o and now >= nextMini then for _, p in ready do config.deploy(p) end miniNumber += 1 lifeActive, lifeEnds = true, now + 45 status("Мини-раунд " .. miniNumber) elseif not b or not o then status("Ожидаем игроков с обеих сторон") else status("Следующий мини-раунд через " .. math.ceil(nextMini - now) .. " с") end return false end local function step(now: number): boolean if rule == "TeamDeathmatch" then return false end local elapsed = math.max(0, now - lastStep) local dt = math.min(elapsed, .5) lastStep = now local members = config.members() local fighters = collect(members) if rule == "OneLife" then return runOneLife(members, fighters, now) end if rule == "HuntLeader" then updateLeaders(fighters); return false end if rule == "CaptureFlag" then runFlag(fighters, now); return false end if rule == "TrophyHunt" then runTrophies(fighters, now); return false end if rule == "Siege" then return runSiege(members, fighters, now, dt) end if hotPoint then hotPoint.step(fighters, now, elapsed); return false end local scoreNow = now >= nextScore if scoreNow then nextScore = now + 1 end local ownedBlue, ownedOrange = 0, 0 for _, zone in zones do local b, o = presence(fighters, zone, geometry) local side: Side? = if b == o then nil elseif b then "Blue" else "Orange" if side and side ~= zone.owner then if zone.claiming ~= side then zone.claiming, zone.progress = side, 0 cue(fighters, false, side) end zone.progress += dt if zone.progress >= 3 then zone.owner, zone.progress = side, 0 cue(fighters, true, nil) end else zone.claiming, zone.progress = nil, 0 end paint(zone.marker, color(zone.owner)) if zone.owner == "Blue" then ownedBlue += 1 elseif zone.owner == "Orange" then ownedOrange += 1 end end if scoreNow then if ownedBlue > 0 then add("Blue", ownedBlue) end if ownedOrange > 0 then add("Orange", ownedOrange) end end status(string.format("Точки под контролем · %d / %d", ownedBlue, ownedOrange)) return false end match = { step = step, hit = if hotPoint then hotPoint.hit else nil, kill = function(player, victim, at, now) local side = sideOf(player) if not side then return end if rule == "TeamDeathmatch" then add(side, 1) elseif rule == "HuntLeader" then local target = opposite(side) local bonus = leaders[target] == victim add(side, if bonus then 3 else 1) if bonus then clearLeader(target) end elseif rule == "TrophyHunt" then tokenDrop(at, 1, now) end end, death = function(player, at, now) if hotPoint then hotPoint.death(player) end dropCarried(player, at, now) if rule == "OneLife" then config.bench(player) end end, leaving = function(player, at, now) if hotPoint then hotPoint.death(player) end dropCarried(player, at, now) local side = sideOf(player) if side and leaders[side] == player then clearLeader(side) end end, winner = function() if rule == "Siege" then local winner, reason = Score.winner(siegeTimes, SiegeConfig.TIE_EPSILON) state:SetAttribute("CitadelResultReason", reason) return winner end if blueScore ~= orangeScore then return if blueScore > orangeScore then "Blue" else "Orange" end return "Draw" end, destroy = function() if siegeState then siegeState:Destroy() for _, p in config.members() do p:SetAttribute("CitadelZone", nil) end end if active[arena] == match then active[arena] = nil end if hotPoint then hotPoint.destroy() end for _, side in sides do clearLeader(side) end for p in carried do p:SetAttribute("ArenaTokens", nil) end if flag and flag.carrier then flag.carrier:SetAttribute("ArenaFlag", nil) end for _, z in zones do z.marker.body:Destroy() end folder:Destroy() status("") end, } active[arena] = match return match end return Objectives