diff --git a/Hunter.rbxl b/Hunter.rbxl index 0ce59bb..2c45f81 100644 Binary files a/Hunter.rbxl and b/Hunter.rbxl differ diff --git a/citadel.project.json b/citadel.project.json index 3651784..ccc7652 100644 --- a/citadel.project.json +++ b/citadel.project.json @@ -6,11 +6,13 @@ "$ignoreUnknownInstances": true, "CitadelAssaultConfig": { "$path": "scripts/CitadelAssaultConfig.luau" }, "Hunter": { "$path": "scripts/Hunter" }, + "MatchRules": { "$path": "scripts/MatchRules.luau" }, "SniperEffects": { "$path": "scripts/SniperEffects.luau" } }, "ServerScriptService": { "$ignoreUnknownInstances": true, "ArenaObjectives": { "$path": "scripts/ArenaObjectives.luau" }, + "ArenaObjectiveSites": { "$path": "scripts/ArenaObjectiveSites.luau" }, "ModeRuntime": { "$path": "scripts/ModeRuntime" }, "ArenaRounds": { "$path": "scripts/ArenaRounds.server.luau" }, "ArenaSpawns": { "$path": "scripts/ArenaSpawns.luau" }, diff --git a/scripts/ArenaClient/BriefingController.client.luau b/scripts/ArenaClient/BriefingController.client.luau index f6b2a6a..9929948 100644 --- a/scripts/ArenaClient/BriefingController.client.luau +++ b/scripts/ArenaClient/BriefingController.client.luau @@ -185,7 +185,7 @@ local function update() if typeof(limit) == "number" and limit > now then showBriefing(id, now, limit, false) end elseif stage == "RoleSwap" then local limit = match:GetAttribute("StageEndsAt") - if typeof(limit) == "number" then showBanner(Strings.round.swap, "", limit) end + if typeof(limit) == "number" then showBanner("⇄ " .. Strings.round.swap, if player:GetAttribute("ArenaTeam") == "Orange" then Strings.round.attack else Strings.round.defend, limit) end elseif stage == "Live" or stage == "FinalPush" then if final then showBanner(Strings.round.final, Strings.round.finalPush[id] or "", now + Config.finalBannerSeconds) diff --git a/scripts/ArenaClient/CitadelGuide.client.luau b/scripts/ArenaClient/CitadelGuide.client.luau new file mode 100644 index 0000000..1ffee86 --- /dev/null +++ b/scripts/ArenaClient/CitadelGuide.client.luau @@ -0,0 +1,168 @@ +--!strict +local Players = game:GetService("Players") +local rs = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local UI = require(rs:WaitForChild("HunterUI") :: ModuleScript) +local Sounds = require(rs:WaitForChild("SniperEffects") :: ModuleScript) +local Config = require(rs.CitadelAssaultConfig) +local Strings = require(rs.Hunter.Strings) +local Hints = require(rs.Hunter.Hints) +local Kinds = require(rs.Hunter.EventKinds) +local Stage = require(rs.Hunter.Stage) +local Provider = require(script.Parent.HintProviders.Siege) +local Router = require(script.Parent.EventRouter) +local player = Players.LocalPlayer +local pg = player:WaitForChild("PlayerGui") +local match = rs:WaitForChild("ArenaRound"):WaitForChild("Procedural") +local T = Strings.hint.Siege +local gui = Instance.new("ScreenGui") +gui.Name, gui.DisplayOrder, gui.ResetOnSpawn, gui.Enabled = "CitadelGuide", 25, false, false +gui.Parent = pg +local panel = UI.plate(gui, "Direction", UDim2.fromScale(.5, .77), UDim2.new(.88, 0, 0, 74), UI.Outline) +panel.AnchorPoint = Vector2.new(.5, .5) +Instance.new("UISizeConstraint", panel).MaxSize = Vector2.new(326, 74) +local contour = UI.contour(panel, UI.Gold) +local arrow = UI.label(panel, "Arrow", "▲", UDim2.fromOffset(10, 15), UDim2.fromOffset(34, 34), 24, UI.Gold) +local title = UI.label(panel, "Title", "", UDim2.fromOffset(53, 5), UDim2.new(1, -59, 0, 22), 17, UI.Ink) +local distance = UI.label(panel, "Distance", "", UDim2.fromOffset(53, 27), UDim2.new(1, -59, 0, 18), 15, UI.Ink) +local nextLine = UI.label(panel, "Next", "", UDim2.fromOffset(53, 47), UDim2.new(1, -59, 0, 19), 13, UI.Muted) +for _, line in {title, distance, nextLine} do line.TextXAlignment = Enum.TextXAlignment.Left end +local hints = Hints.new() +local pending: Hints.Hint? = nil +local count = 0 +local shownTutorial = false +local lastGeneration: unknown = nil +local previousZone: string? = nil +local previousStatus: string? = nil +local lastTick = 0 +local charge: Sound? = nil +local currentTarget: Vector3? = nil +local function stopCharge() + if charge then charge:Destroy(); charge = nil end +end + +local function eligible(): boolean + return player:GetAttribute("InArena") == true and match:GetAttribute("Ruleset") == "Siege" and match:GetAttribute("Phase") == "Round" +end + +local function push(key: string, message: string, priority: number, ttl: number?) + if not Config.HintsEnabled or not eligible() then return end + pending = {key = key, text = message, priority = priority, ttl = ttl or 4, cooldown = Config.HINT_COOLDOWN} +end + +local subscriptions = { + Router.on(Kinds.ZoneStarted, function(p) + if not eligible() then return end + if p.side ~= player:GetAttribute("ArenaTeam") then push("sg_def_new", T.defNew(p.index or 1), 90) end + end), + Router.on(Kinds.ZoneCaptured, function(p) + if not eligible() then return end + local i = p.index or 1 + local won = p.side == player:GetAttribute("ArenaTeam") + push(if won then "sg_captured" else "sg_def_lost", if won then T.captured(i) else T.defLost(i + 1, Config.MAX_OBJECTIVES), 90) + end), + Router.on(Kinds.AllObjectivesTaken, function(p) + if p.side == player:GetAttribute("ArenaTeam") then push("sg_all", T.all, 94) end + end), + Router.on(Kinds.RoleSwap, function(p) + if not eligible() then return end + Sounds.sound("SiegeEnter") + push("sg_new_role", if p.side == player:GetAttribute("ArenaTeam") then T.newAttack else T.newDefense, 96, 5) + end), +} +local function update() + local data = match:FindFirstChild("CitadelMatchState") + local character = player.Character + local root = character and character:FindFirstChild("HumanoidRootPart") + local human = character and character:FindFirstChildOfClass("Humanoid") + if not eligible() or not data or not root or not root:IsA("BasePart") or not human or human.Health <= 0 then + gui.Enabled = false + currentTarget = nil + pg:SetAttribute("SiegeHint", nil) + stopCharge() + previousZone, previousStatus, lastTick = nil, nil, 0 + if not eligible() then hints = Hints.new(); pending = nil end + return + end + local phase = data:GetAttribute("Phase") + local stage = match:GetAttribute("RoundStage") + if not Stage.combatAllowed(match) then + gui.Enabled = false + pg:SetAttribute("SiegeHint", nil) + stopCharge() + previousZone, previousStatus, lastTick = nil, nil, 0 + return + end + local generation = match:GetAttribute("MapGeneration") + if lastGeneration ~= generation then count += 1; lastGeneration = generation end + local status = data:GetAttribute("Status") :: string? + local zone = player:GetAttribute("CitadelZone") :: string? + local side = player:GetAttribute("ArenaTeam") + local attacking = side == data:GetAttribute("Attacker") + local point = data:GetAttribute("Point") + local index = (data:GetAttribute("Index") :: number?) or 1 + local fraction = (data:GetAttribute("Progress") :: number?) or 0 + local percent = math.floor((fraction + 1e-7) * 10) * 10 + local delta = if typeof(point) == "Vector3" then point - root.Position else Vector3.zero + if not shownTutorial and Config.HintsEnabled and typeof(point) == "Vector3" and not pending then + shownTutorial = true + push("sg_tutorial", T.tutorial, 95, 6) + end + local candidates = Provider.candidates({ + zone = zone, status = status, attacking = attacking, seconds = (data:GetAttribute("Seconds") :: number?) or 0, + first = phase == "Attack1", distance = delta.Magnitude, dy = delta.Y, progress = percent, experienced = count > 3, + }) + if pending then table.insert(candidates, pending); pending = nil end + local chosen = if Config.HintsEnabled then Hints.pick(hints, candidates, workspace:GetServerTimeNow()) else nil + pg:SetAttribute("SiegeHint", if chosen then chosen.text else nil) + + if zone == "Inside" and previousZone ~= zone then Sounds.sound("SiegeEnter") end + if zone == "Inside" and status == "Capturing" and attacking then + if not charge then charge = Sounds.sound("SiegeCharge") end + if charge then charge.PlaybackSpeed = .9 + .6 * fraction end + if percent > lastTick then Sounds.sound("SiegeTick") end + elseif charge then stopCharge() end + if status ~= previousStatus and status == "Contested" then Sounds.sound("SiegeBlocked") + elseif status ~= previousStatus and status == "Decaying" and attacking then Sounds.sound("SiegeDecay") end + previousZone, previousStatus, lastTick = zone, status, percent + + local results = pg:FindFirstChild("ArenaResults") + local main = pg:FindFirstChild("MainMenu") + local blocked = pg:GetAttribute("HunterVoting") == true or (results and results:GetAttribute("LiveScoreboardOpen") == true) + or (main and main:IsA("ScreenGui") and main.Enabled) + gui.Enabled = not blocked and stage ~= "RoleSwap" and typeof(point) == "Vector3" and zone ~= "Inside" and + (attacking or status == "Capturing" or status == "Contested") + currentTarget = if gui.Enabled and typeof(point) == "Vector3" then point else nil + if not gui.Enabled then return end + local tint = if not attacking then UI.Gold elseif side == "Orange" then UI.Orange else UI.Blue + contour:SetAttribute("Accent", tint) + arrow.TextColor3 = tint + title.Text = if attacking then T.point(index, tostring(data:GetAttribute("PointName") or "")) else T.defend + distance.Text = Strings.studs(delta.Magnitude) .. (if delta.Y > 8 then T.above elseif delta.Y < -8 then T.below else "") + local following = data:GetAttribute("NextPoint") + nextLine.Text = if typeof(following) == "Vector3" then T.next(index + 1, Strings.studs((following - root.Position).Magnitude)) else "" +end +local interval = 0 +local tick = RunService.Heartbeat:Connect(function(dt) + interval += dt + if interval < Config.CHECK_INTERVAL then return end + interval %= Config.CHECK_INTERVAL + update() +end) +local render = RunService.RenderStepped:Connect(function() + local camera = workspace.CurrentCamera + local target = currentTarget + if not camera or not target then return end + local root = player.Character and player.Character.PrimaryPart + if not root then return end + local delta = target - root.Position + local localDelta = camera.CFrame:VectorToObjectSpace(Vector3.new(delta.X, 0, delta.Z)) + arrow.Rotation = math.deg(math.atan2(localDelta.X, -localDelta.Z)) +end) +script.Destroying:Once(function() + stopCharge() + tick:Disconnect() + render:Disconnect() + for _, cancel in subscriptions do cancel() end + gui:Destroy() +end) diff --git a/scripts/ArenaClient/HintProviders/Siege.luau b/scripts/ArenaClient/HintProviders/Siege.luau new file mode 100644 index 0000000..f272d9e --- /dev/null +++ b/scripts/ArenaClient/HintProviders/Siege.luau @@ -0,0 +1,30 @@ +--!strict +local rs = game:GetService("ReplicatedStorage") +local Strings = require(rs.Hunter.Strings) +local Config = require(rs.CitadelAssaultConfig) +local Hints = require(rs.Hunter.Hints) +local text = Strings.hint.Siege +export type Snapshot = {zone: string?, status: string?, attacking: boolean, seconds: number, first: boolean, distance: number, dy: number, progress: number, experienced: boolean} +local Provider = {} + +function Provider.candidates(s: Snapshot): {Hints.Hint} + local candidates: {Hints.Hint} = {} + if not Config.HintsEnabled then return candidates end + local function add(key: string, message: string, priority: number) + table.insert(candidates, {key = key, text = message, priority = priority, ttl = .4, cooldown = Config.HINT_COOLDOWN}) + end + local copy = if s.experienced then text.short else text + if s.first and s.seconds > 0 and s.seconds <= Config.SWAP_WARNING then add("sg_swap", text.swap(s.seconds), 85) end + if s.zone == "Height" then add("sg_height", if s.attacking then text.height(s.dy) else copy.defHeight, 80) + elseif s.zone == "Blocked" then add("sg_blocked", if s.attacking then copy.blocked else copy.defBlocked, 80) + elseif s.attacking then + if s.status == "Contested" then add("sg_contested", copy.contested, 70) + elseif s.status == "Decaying" then add("sg_decay", copy.decay, 60) + elseif s.zone == "Inside" and s.status == "Capturing" then add("sg_capturing", text.capturing(s.progress), 40) + elseif s.zone == "Outside" then add("sg_far", text.far(s.distance), 40) end + elseif s.zone == "Inside" then add("sg_def_block", copy.defBlock, 60) + elseif s.status == "Capturing" then add("sg_def_far", copy.defFar, 70) end + return candidates +end + +return Provider diff --git a/scripts/ArenaObjectiveSites.luau b/scripts/ArenaObjectiveSites.luau index e5a0e9c..a7e64ff 100644 --- a/scripts/ArenaObjectiveSites.luau +++ b/scripts/ArenaObjectiveSites.luau @@ -59,8 +59,8 @@ local function fits(center: Vector3, geometry: RaycastParams, radius: number): b return workspace:Raycast(center + Vector3.yAxis * .25, Vector3.yAxis * 9, geometry) == nil end -function Sites.clearCircle(center: Vector3, geometry: RaycastParams, radius: number): Vector3 - if fits(center, geometry, radius) then return center end +function Sites.clearCircle(center: Vector3, geometry: RaycastParams, radius: number): (Vector3, boolean) + if fits(center, geometry, radius) then return center, true end for distance = 3, 48, 3 do for index = 0, 15 do local angle = index * math.pi / 8 @@ -68,11 +68,11 @@ function Sites.clearCircle(center: Vector3, geometry: RaycastParams, radius: num local floor = workspace:Raycast(at + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry) if floor and floor.Normal.Y >= .95 and math.abs(floor.Position.Y - center.Y) <= .35 and fits(floor.Position, geometry, radius) then - return floor.Position + return floor.Position, true end end end - return center + return center, false end function Sites.hotPath(id: string, map: Map, radius: number): {Site} diff --git a/scripts/ArenaRoundHud.client.luau b/scripts/ArenaRoundHud.client.luau index 20183d5..4b9a359 100644 --- a/scripts/ArenaRoundHud.client.luau +++ b/scripts/ArenaRoundHud.client.luau @@ -20,7 +20,11 @@ local objectiveCue = ReplicatedStorage:WaitForChild("ArenaObjectiveCue") :: Remo local objectiveCueConnection = objectiveCue.OnClientEvent:Connect(function(captured: boolean | string) Sounds.sound(if captured == "FlagDropped" then "FlagDropped" elseif captured == true then "HotPointCaptured" else "HotPointStart") end) -local RoundStrings = require(ReplicatedStorage:WaitForChild("Hunter"):WaitForChild("Strings") :: ModuleScript).round +local Hunter = ReplicatedStorage:WaitForChild("Hunter") +local HunterStrings = require(Hunter:WaitForChild("Strings") :: ModuleScript) +local RoundStrings = HunterStrings.round +local SiegeResults = require(Hunter:WaitForChild("SiegeResults") :: ModuleScript) +local SiegeConfig = require(ReplicatedStorage:WaitForChild("CitadelAssaultConfig") :: ModuleScript) local limit = state:GetAttribute("TeamLimit") :: number local modeIds = {Modes.Procedural} local function currentMode(): string @@ -157,7 +161,12 @@ siegeBar.BackgroundColor3 = Color3.fromRGB(34, 45, 65) siegeBar.BorderSizePixel = 0 siegeBar.Visible = false siegeBar.Parent = objective +local siegeSteps = UI.label(objective, "SiegeSteps", "", UDim2.fromOffset(16, 96), UDim2.new(1, -32, 0, 22), 15, UI.Gold) +siegeSteps.Visible = false +local siegeChip = UI.label(objective, "SiegeChip", "", UDim2.fromOffset(16, 119), UDim2.new(1, -32, 0, 21), 14, UI.Mint) +siegeChip.Visible = false local siegeSegments: {Frame} = {} +local siegeSegmentCount = 0 for i = 1, 10 do local segment = Instance.new("Frame") segment.Position = UDim2.fromScale((i - 1) / 10, 0) @@ -405,7 +414,7 @@ local function refreshObjective() local visible = player:GetAttribute("InArena") == true and match:GetAttribute("Phase") == "Round" local needsLayout = visible ~= objective.Visible objective.Visible = visible - siegeBar.Visible = false + siegeBar.Visible, siegeSteps.Visible, siegeChip.Visible = false, false, false if visible then local rule = Rules.get(match:GetAttribute("Ruleset")) local accent = if player:GetAttribute("ArenaTeam") == "Orange" then orange else blue @@ -420,21 +429,44 @@ local function refreshObjective() local attacker = siege:GetAttribute("Attacker") local seconds = (siege:GetAttribute("Seconds") :: number?) or 0 local zone = player:GetAttribute("CitadelZone") - local role = if attacker == player:GetAttribute("ArenaTeam") then "Вы атакуете" else "Вы защищаете" + local attacking = attacker == player:GetAttribute("ArenaTeam") + local role = if attacking then "▲ " .. RoundStrings.attack else "◆ " .. RoundStrings.defend local point = (siege:GetAttribute("PointName") :: string?) or "" - objectiveTitle.Text = if phase == "RoleSwap" then "СМЕНА РОЛЕЙ" else string.format("АТАКА %d/2 · %d:%02d", + local roleColor = if attacking then accent else UI.Gold + objectiveTitle.Text = if phase == "RoleSwap" then RoundStrings.swap else string.format("АТАКА %d/2 · %d:%02d", if phase == "Attack2" then 2 else 1, math.floor(seconds / 60), seconds % 60) - objectiveText.Text = role .. " · " .. point + objectiveText.Text = role .. (if point ~= "" then " · " .. point else "") + objectiveTitle.TextColor3 = roleColor + objectiveContour:SetAttribute("Accent", roleColor) + local hint = playerGui:GetAttribute("SiegeHint") + if typeof(hint) == "string" then text = hint end if phase ~= "RoleSwap" and siege:GetAttribute("Point") then - if zone == "Height" then text = "Найдите нужный этаж" - elseif zone == "Blocked" then text = "Нет прямой видимости центра" - elseif zone == "Inside" and role == "Вы защищаете" then text = "Вы блокируете захват. Оставайтесь в круге!" end - siegeBar.Visible = true + siegeBar.Visible, siegeSteps.Visible = true, true local progress = (siege:GetAttribute("Progress") :: number?) or 0 + local filled = math.floor((progress + 1e-7) * 10) + local index = (siege:GetAttribute("Index") :: number?) or 1 + local total = (siege:GetAttribute("Total") :: number?) or SiegeConfig.MAX_OBJECTIVES + local state = siege:GetAttribute("Status") + local attackColor = if attacker == "Orange" then orange else blue + local segmentColor = if state == "Contested" then SiegeConfig.CONTESTED_COLOR + elseif state == "Decaying" then attackColor:Lerp(muted, .45) else attackColor for i, segment in siegeSegments do - segment.Visible = progress + 1e-8 >= i / #siegeSegments - segment.BackgroundColor3 = if siege:GetAttribute("Status") == "Contested" then orange else blue + segment.Visible = i <= filled + segment.BackgroundColor3 = segmentColor + if i == filled and filled > siegeSegmentCount then + segment.BackgroundTransparency = .55 + TweenService:Create(segment, TweenInfo.new(.2), {BackgroundTransparency = 0}):Play() + end end + siegeSegmentCount = filled + local dots: {string} = {} + for i = 1, total do dots[i] = if i < index then "✓" elseif i == index then "◆" else "○" end + siegeSteps.Text = table.concat(dots, " ") .. string.format(" %d%%", filled * 10) + siegeSteps.TextColor3 = roleColor + local copy = HunterStrings.hint.Siege + siegeChip.Visible = zone == "Inside" or zone == "Height" or zone == "Blocked" + siegeChip.Text = if zone == "Inside" then copy.inside elseif zone == "Height" then copy.wrongFloor else copy.noSight + siegeChip.TextColor3 = if zone == "Inside" then UI.Mint else UI.Gold end end local tokens = (player:GetAttribute("ArenaTokens") :: number?) or 0 @@ -445,7 +477,7 @@ local function refreshObjective() objectiveStatus.Visible = text ~= "" objectiveStatus.Text = text objectiveStatus.TextColor3 = accent:Lerp(ink, .3) - local height = if siegeBar.Visible then 101 elseif objectiveStatus.Visible then 88 else 62 + local height = if siegeBar.Visible then 145 elseif objectiveStatus.Visible then 88 else 62 if height ~= objective.Size.Y.Offset then objective.Size = UDim2.fromOffset(widthOfCard, height) needsLayout = true @@ -598,6 +630,10 @@ end local blueResult = resultTeam("Blue", 23, "СИНИЕ", blue, blueDark) local orangeResult = resultTeam("Orange", 491, "ОРАНЖЕВЫЕ", orange, orangeDark) +local siegeRecap = UI.label(resultsPanel, "SiegeTimes", "", UDim2.fromOffset(30, 0), UDim2.fromOffset(900, 84), 16, ink) +siegeRecap.TextWrapped = true +siegeRecap.TextXAlignment = Enum.TextXAlignment.Left +siegeRecap.Visible = false local resultsExtra = UI.plate(resultsPanel, "ResultsExtra", UDim2.fromOffset(25, 0), UDim2.fromOffset(910, 98), UI.Gold) local mvpChip = UI.label(resultsExtra, "MVP", "", UDim2.fromOffset(15, 4), UDim2.fromOffset(865, 28), 21, UI.Gold) mvpChip.FontFace = UI.Display @@ -644,10 +680,11 @@ local function setSummaryTeams(bluePlayers: {ResultPlayer}, orangePlayers: {Resu populateResults(orangeResult, orangeTotal, orangePlayers) local rowSpace = 35 * math.max(3, #bluePlayers, #orangePlayers) local final = summaryView == "Final" - local height = 280 + rowSpace + (if final then 121 else 0) + local height = 280 + rowSpace + (if final then 121 else 0) + (if final and siegeRecap.Visible then 90 else 0) blueResult.card.Position = UDim2.fromOffset(23, if final then 112 else 97) orangeResult.card.Position = UDim2.fromOffset(491, if final then 112 else 97) resultsExtra.Position = UDim2.fromOffset(25, height - 164) + siegeRecap.Position = UDim2.fromOffset(30, height - 250) if resultsPanel.Size.Y.Offset == height then return end resultsPanel.Size = UDim2.fromOffset(960, height) blueResult.card.Size = UDim2.fromOffset(446, 117 + rowSpace) @@ -659,6 +696,7 @@ end local function startSummary(view: SummaryView, ruleId: unknown) summaryView = view + siegeRecap.Visible = false resultReason.Visible = view == "Final" resultsExtra.Visible = view == "Final" lobbyButton.Visible = view == "Live" and player:GetAttribute("InArena") == true @@ -838,6 +876,12 @@ results.OnClientEvent:Connect(function(result: RoundResult, participantSide: str if left <= 0 then return end if resultsShade.Visible then hideResults() end startSummary("Final", result.ruleset) + if result.ruleset == "Siege" and result.siegeTimes then + local lines = SiegeResults.rows(result.siegeTimes, SiegeConfig.MAX_OBJECTIVES) + table.insert(lines, SiegeResults.tiebreak) + siegeRecap.Text = table.concat(lines, "\n") + siegeRecap.Visible = true + end setSummaryTeams(result.blue, result.orange, result.blueScore, result.orangeScore) local winnerColor = if result.winner == "Blue" then blue elseif result.winner == "Orange" then orange else UI.Gold resultWinner.Text = if result.winner == "Blue" then "СИНИЕ ПОБЕДИЛИ" @@ -1017,9 +1061,11 @@ local function updateClock() clockMotion:Play() refreshControls() end +local siegeHintConnection = playerGui:GetAttributeChangedSignal("SiegeHint"):Connect(refreshObjective) local timerConnection = RunService.Heartbeat:Connect(updateClock) script.Destroying:Once(function() timerConnection:Disconnect() + siegeHintConnection:Disconnect() if finalClockPulse then finalClockPulse:Cancel() end votingChanged:Disconnect() scoreboardFocus:Disconnect() diff --git a/scripts/ArenaRounds.server.luau b/scripts/ArenaRounds.server.luau index 22b30be..cfd2dc1 100644 --- a/scripts/ArenaRounds.server.luau +++ b/scripts/ArenaRounds.server.luau @@ -18,6 +18,7 @@ local RoundPlayer = require(Runtime:WaitForChild("PlayerRoundState") :: ModuleSc local Stats = require(Runtime:WaitForChild("Stats") :: ModuleScript) local ArenaSpawns = require(script.Parent:WaitForChild("ArenaSpawns")) +local SiegeSpawn = require(script.Parent:WaitForChild("CitadelSpawnService") :: ModuleScript) local SkinCatalog = require(ReplicatedStorage:WaitForChild("RifleSkinCatalog") :: ModuleScript) local lobbySpawn = workspace:WaitForChild("HunterLobby"):WaitForChild("Arrival Spawn") :: SpawnLocation local rifleTemplate = ReplicatedStorage:WaitForChild("ArenaEquipment"):WaitForChild("SniperRifle") :: Tool @@ -235,6 +236,15 @@ local function enterArena(player: Player, character: Model, humanoid: Humanoid) local destination = destinationFor(player) player.RespawnLocation = destination ArenaSpawns.place(character, destination) + local siege = randomState:FindFirstChild("CitadelMatchState") + local side = player:GetAttribute("ArenaTeam") + local attacker = siege and siege:GetAttribute("Attacker") + local base = siege and typeof(side) == "string" and siege:GetAttribute(side .. "Base") + if siege and typeof(base) == "Vector3" and typeof(attacker) == "string" + and randomState:GetAttribute("RoundStage") ~= "RoleSwap" then + local at = SiegeSpawn.position(Modes.geometry(Modes.of(player)), attacker == side, base, joinOrder[player] or 1) + character:PivotTo(CFrame.new(at + Vector3.yAxis * 4)) + end if Stage.combatAllowed(randomState) then RoundPlayer.thaw(player) arm(player, character, humanoid) @@ -851,6 +861,11 @@ end local function runMatch(match: Match) while true do local now = workspace:GetServerTimeNow() + local siegeDeadline = match.state:GetAttribute("SiegeEndsAt") + if match.phase == "Round" and typeof(siegeDeadline) == "number" and siegeDeadline < match.endsAt then + match.endsAt = siegeDeadline + publish(match) + end local remaining = match.endsAt - now if match.phase == "Round" then local engine = match.engine diff --git a/scripts/CitadelAssaultConfig.luau b/scripts/CitadelAssaultConfig.luau index 0b233a8..6e43739 100644 --- a/scripts/CitadelAssaultConfig.luau +++ b/scripts/CitadelAssaultConfig.luau @@ -3,6 +3,14 @@ return table.freeze({ MATCH_DURATION = 300, ATTACK_DURATION = 150, CAPTURE_TIME = 4, + CAPTURE_RADIUS = 11, + EARLY_FINISH_WHEN_ALL_TAKEN = false, + SWAP_WARNING = 10, + LIGHT_HEIGHT = 46, + MATERIALIZE_SECONDS = .6, + CAPTURE_EFFECT_SECONDS = .55, + CONFETTI_COUNT = 24, + CONTESTED_COLOR = Color3.fromRGB(255, 81, 105), DECAY_MULTIPLIER = 0.5, HEIGHT_TOLERANCE = 7, POINTS_PER_OBJECTIVE = 1, diff --git a/scripts/HotPoint.luau b/scripts/HotPoint.luau index b4cb562..7c3cf40 100644 --- a/scripts/HotPoint.luau +++ b/scripts/HotPoint.luau @@ -29,7 +29,8 @@ local neutral = Color3.fromRGB(183, 132, 255) local contested = Color3.fromRGB(255, 211, 124) local teamColor: {[Side]: Color3} = {Blue = Color3.fromRGB(76, 228, 255), Orange = Color3.fromRGB(255, 81, 105)} -function HotPoint.attachRing(mark: Marker): (Color3) -> () +function HotPoint.attachRing(mark: Marker, radius: number?): (Color3) -> () + local r = radius or HotPoint.Radius local body = mark.body body.Transparency = .92 local beams: {Beam} = {} @@ -38,7 +39,7 @@ function HotPoint.attachRing(mark: Marker): (Color3) -> () local radial = Vector3.new(math.cos(angle), 0, math.sin(angle)) local tangent = Vector3.new(-radial.Z, 0, radial.X) local item = Instance.new("Attachment") - local world = CFrame.fromMatrix(mark.origin + radial * HotPoint.Radius + Vector3.yAxis * height, tangent, Vector3.yAxis) + local world = CFrame.fromMatrix(mark.origin + radial * r + Vector3.yAxis * height, tangent, Vector3.yAxis) item.CFrame = body.CFrame:ToObjectSpace(world) item.Parent = body return item @@ -48,7 +49,7 @@ function HotPoint.attachRing(mark: Marker): (Color3) -> () for index = 0, 3 do table.insert(corners, anchor(index * math.pi / 2, height)) end - local handle = 4 * (math.sqrt(2) - 1) / 3 * HotPoint.Radius + local handle = 4 * (math.sqrt(2) - 1) / 3 * r for index, start in corners do local beam = Instance.new("Beam") beam.Name = name diff --git a/scripts/Hunter/SiegeResults.luau b/scripts/Hunter/SiegeResults.luau new file mode 100644 index 0000000..f270311 --- /dev/null +++ b/scripts/Hunter/SiegeResults.luau @@ -0,0 +1,20 @@ +--!strict +local Results = {} + +function Results.clockPrecise(t: number): string + return string.format("%d:%05.2f", math.floor(t / 60), t % 60) +end + +function Results.rows(times: {[string]: any}, total: number): {string} + local rows = {} + for i = 1, total do + local b, o = times["BlueTime" .. i], times["OrangeTime" .. i] + rows[i] = string.format("Рубеж %d · Синие %s · Оранжевые %s", i, + if typeof(b) == "number" then Results.clockPrecise(b) else "—", + if typeof(o) == "number" then Results.clockPrecise(o) else "—") + end + return rows +end + +Results.tiebreak = "При равенстве рубежей побеждает команда, быстрее дошедшая до последнего взятого." +return table.freeze(Results) diff --git a/scripts/Hunter/Strings.luau b/scripts/Hunter/Strings.luau index 16c46d0..e1fc9f5 100644 --- a/scripts/Hunter/Strings.luau +++ b/scripts/Hunter/Strings.luau @@ -5,6 +5,41 @@ end local function clock(seconds: number): string return string.format("%d:%02d", math.floor(seconds / 60), math.floor(seconds % 60)) end +local function studs(distance: number): string + local n = math.floor(distance + .5) + local m10, m100 = n % 10, n % 100 + local unit = if m10 == 1 and m100 ~= 11 then "студ" + elseif m10 >= 2 and m10 <= 4 and (m100 < 12 or m100 > 14) then "студа" else "студов" + return string.format("%d %s", n, unit) +end +local siegeHints = { + far = function(n: number) return "Двигайтесь к кругу — " .. studs(n) end, + height = function(dy: number) return if dy > 0 then "Круг выше вас — найдите нужный этаж" else "Круг ниже вас — найдите нужный этаж" end, + capturing = function(percent: number) return string.format("Стойте в круге — захват %d%%", percent) end, + swap = function(seconds: number) return string.format("Смена ролей через %d с. Незавершённый захват сбросится.", seconds) end, + captured = function(index: number) return string.format("Рубеж %d взят! Следуйте к новой цели.", index) end, + defNew = function(index: number) return string.format("Не дайте взять рубеж %d!", index) end, + defLost = function(index: number, total: number) return if index <= total then string.format("Рубеж потерян! Защитите рубеж %d.", index) else "Соперники взяли последний рубеж." end, + all = "Все рубежи взяты! Держите позиции до конца атаки.", + tutorial = "Стойте в круге до заполнения полосы. Число атакующих не ускоряет захват. Защитник в круге останавливает его.", + newAttack = "Теперь вы атакуете. Возьмите первый рубеж.", + newDefense = "Теперь вы защищаете. Удерживайте первый рубеж.", + point = function(index: number, name: string) return string.format("РУБЕЖ %d · %s", index, name) end, + next = function(index: number, distance: string) return string.format("ДАЛЕЕ %d · %s", index, distance) end, + defend = "ЗАЩИТИТЕ РУБЕЖ", above = " · ВЫШЕ", below = " · НИЖЕ", + inside = "В ЗОНЕ", wrongFloor = "ДРУГОЙ ЭТАЖ", noSight = "НЕТ ВИДИМОСТИ", + blocked = "Нет прямой видимости центра — выйдите на открытое место.", + defHeight = "Вы на другом этаже и не блокируете захват.", + defBlocked = "Центр закрыт стеной. Смените позицию, чтобы блокировать захват.", + contested = "Зона оспаривается — устраните защитника.", + decay = "Захват откатывается — вернитесь в круг.", + defBlock = "Вы блокируете захват — оставайтесь в круге.", + defFar = "Враг на рубеже! Зайдите в круг, чтобы остановить захват.", + short = { + blocked = "Откройте обзор центра.", defHeight = "Смените этаж.", defBlocked = "Центр за стеной.", + contested = "Устраните защитника.", decay = "Вернитесь в круг.", defBlock = "Удерживайте круг.", defFar = "Остановите захват.", + }, +} local function flagCarrier(name: string): string return name .. " несёт флаг" end local round = table.freeze({ mode = "РЕЖИМ", fight = "В БОЙ!", final = "ФИНАЛЬНЫЙ РЫВОК", swap = "СМЕНА РОЛЕЙ", @@ -35,6 +70,8 @@ local round = table.freeze({ return table.freeze({ round = round, + studs = studs, + hint = table.freeze({Siege = siegeHints}), team = team, clock = clock, bases = table.freeze({Blue = "БАЗА СИНИХ", Orange = "БАЗА ОРАНЖЕВЫХ"}), hotPoint = "ГОРЯЧАЯ ТОЧКА", @@ -56,7 +93,7 @@ return table.freeze({ siegeSwap = "СМЕНА РОЛЕЙ", siegeComplete = "Все рубежи взяты!", siegeStatus = function(attacker: string, index: number, total: number, percent: number, phase: string) local reason = if phase == "Contested" then "Зона оспаривается!" elseif phase == "Decaying" then "Захват откатывается" - elseif phase == "Capturing" then "Захват идёт" else "Двигайтесь к синему кругу" + elseif phase == "Capturing" then "Захват идёт" else "Двигайтесь к кругу" return string.format("%s · Рубеж %d/%d · %d%% · %s", attacker, index, total, percent, reason) end, feed = table.freeze({ diff --git a/scripts/MatchRules.luau b/scripts/MatchRules.luau index fd9b951..469ae45 100644 --- a/scripts/MatchRules.luau +++ b/scripts/MatchRules.luau @@ -12,7 +12,7 @@ MatchRules.All = table.freeze({ {id = "Domination", title = "Три точки", detail = "Захватывайте и удерживайте зоны, чтобы получать очки.", score = "Очки контроля"}, {id = "CaptureFlag", title = "Захват флага", detail = "Заберите флаг с крыши цитадели и принесите его на свою базу.", score = "Флаги"}, {id = "TrophyHunt", title = "Охота за трофеями", detail = "Собирайте выпавшие жетоны и сдавайте их на своей базе.", score = "Сданные жетоны"}, - {id = "Siege", title = "Штурм цитадели", detail = "В атаке берите рубежи, в защите удерживайте их. Затем смена ролей.", score = "Захваченные рубежи"}, + {id = "Siege", title = "Штурм цитадели", detail = "Обе команды по очереди атакуют три рубежа. При равенстве решает время последнего захвата.", score = "Захваченные рубежи"}, {id = "OneLife", title = "Одна жизнь", detail = "Выиграйте 3 мини-раунда. В каждом у вас одна жизнь.", score = "Победы в мини-раундах"}, {id = "HuntLeader", title = "Охота на лидера", detail = "Устраняйте отмеченного лидера соперников. За него дают 3 очка.", score = "Очки за убийства"}, } :: {Rule}) diff --git a/scripts/ModeRuntime/Common.luau b/scripts/ModeRuntime/Common.luau index 1a0db8b..4f53b66 100644 --- a/scripts/ModeRuntime/Common.luau +++ b/scripts/ModeRuntime/Common.luau @@ -67,9 +67,10 @@ local function marker(parent: Instance, id: string, name: string, at: Vector3, t 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) +local function ring(parent: Instance, id: string, name: string, at: Vector3, tint: Color3, radius: number?): Marker + local r = radius or HotPoint.Radius + local mark = marker(parent, id, name, at, tint, r * 2) + local recolor = HotPoint.attachRing(mark, r) mark.recolor = recolor recolor(tint) return mark @@ -89,9 +90,12 @@ 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 makeZone(folder: Folder, geometry: RaycastParams, 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} +local function makeZone(folder: Folder, geometry: RaycastParams, site: Sites.Site, name: string, radius: number?, tint: Color3?): Zone + local r = radius or HotPoint.Radius + local center, fits = Sites.clearCircle(site.position, geometry, r) + if radius and not fits then warn("Нет свободного места для рубежа:", site.name) end + site = {name = site.name, position = center} + return {site = site, marker = ring(folder, name, site.name, center, tint or neutral, r), owner = nil, claiming = nil, progress = 0} end local function bases(folder: Folder, geometry: RaycastParams, map: Sites.Map) map.blue = Sites.clearCircle(map.blue, geometry, HotPoint.Radius) diff --git a/scripts/ModeRuntime/Modes/Siege.luau b/scripts/ModeRuntime/Modes/Siege.luau index 447563f..4f4295a 100644 --- a/scripts/ModeRuntime/Modes/Siege.luau +++ b/scripts/ModeRuntime/Modes/Siege.luau @@ -6,7 +6,7 @@ local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds) local Strings = require(game.ReplicatedStorage.Hunter.Strings) local CollectionService = game:GetService("CollectionService") local Zones = require(Runtime.Zones) -local HotPoint = require(Runtime.Parent.HotPoint) +local Effects = require(Runtime.SiegeEffects) local Sites = require(Runtime.Parent.ArenaObjectiveSites) local SiegeConfig = require(game.ReplicatedStorage.CitadelAssaultConfig) local Capture = require(Runtime.Parent.CitadelCaptureService) @@ -14,15 +14,20 @@ local Score = require(Runtime.Parent.CitadelScoreService) local SiegeSpawn = require(Runtime.Parent.CitadelSpawnService) type Fighter = Types.Fighter type Side = Types.Side -local SPEC: Zones.Spec = {radius = HotPoint.Radius, height = SiegeConfig.HEIGHT_TOLERANCE, sightHeight = SiegeConfig.SIGHT_HEIGHT} +local SPEC: Zones.Spec = {radius = SiegeConfig.CAPTURE_RADIUS, height = SiegeConfig.HEIGHT_TOLERANCE, sightHeight = SiegeConfig.SIGHT_HEIGHT} local function start(ctx: Types.ModeContext): Types.ModeInstance local map, world, geometry, folder, state = assert(ctx.map), ctx.world, ctx.geometry, ctx.folder, ctx.state local zones: {Common.Zone} = {} + local visuals: {Effects.Rig} = {} + local visibleIndex = 0 local data = Instance.new("Folder") data.Name = "CitadelMatchState" data.Parent = state ctx.janitor.give(data) + data:SetAttribute("Radius", SiegeConfig.CAPTURE_RADIUS) + data:SetAttribute("BlueBase", map.blue) + data:SetAttribute("OrangeBase", map.orange) 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 @@ -32,25 +37,33 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance end end for i, site in sites do - local zone = Common.makeZone(folder, geometry, site, "Checkpoint" .. i) + local zone = Common.makeZone(folder, geometry, site, "Checkpoint" .. i, SiegeConfig.CAPTURE_RADIUS, Common.gold) zone.marker.body:SetAttribute("Index", i) zone.marker.body.Parent = nil ctx.janitor.give(zone.marker.body) table.insert(zones, zone) + table.insert(visuals, Effects.new(zone.marker, folder, ctx.janitor)) end - zones[1].marker.body.Parent = folder + data:SetAttribute("Total", #zones) 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 swapAt = SiegeConfig.ATTACK_DURATION + local lastStatus: string? = nil + local marked: {[Player]: boolean} = {} local function runSiege(members: {Player}, fighters: {Fighter}, now: number, dt: number): boolean local half = SiegeConfig.ATTACK_DURATION local elapsed = now - ctx.liveAt - if elapsed >= half and not hadSiegeSwap then - ctx.setStage("RoleSwap", ctx.liveAt + half + SiegeConfig.SWAP_FREEZE) + if elapsed >= swapAt and not hadSiegeSwap then + ctx.setStage("RoleSwap", ctx.liveAt + swapAt + SiegeConfig.SWAP_FREEZE) hadSiegeSwap = true - for _, z in zones do z.marker.body.Parent = nil end + for i, z in zones do + visuals[i].hide() + z.marker.body.Parent = nil + end + visibleIndex, lastStatus = 0, nil siegeSide, siegeIndex, siegeProgress = Common.opposite(siegeSide), 1, 0 siegeCaptureStarted = false local arenaSites = map @@ -66,11 +79,11 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance 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 + local swap = elapsed >= swapAt and elapsed < swapAt + SiegeConfig.SWAP_FREEZE + local attackStart = if hadSiegeSwap then swapAt + 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)) + data:SetAttribute("Seconds", math.clamp(math.ceil((if hadSiegeSwap then half else swapAt) - (elapsed - attackStart)), 0, half)) if swap then data:SetAttribute("Progress", 0) data:SetAttribute("Status", "Idle") @@ -78,16 +91,33 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance return false end if state:GetAttribute("RoundStage") == "RoleSwap" then ctx.setStage("Live") end + if hadSiegeSwap and elapsed >= attackStart + half then return true end local attacker = Strings.team(siegeSide) local zone = zones[siegeIndex] data:SetAttribute("Index", siegeIndex) + for player in marked do + if not table.find(members, player) then + player:SetAttribute("CitadelZone", nil) + marked[player] = nil + end + end + for _, player in members do marked[player] = true end if not zone then data:SetAttribute("Point", nil) data:SetAttribute("NextPoint", nil) + data:SetAttribute("Status", "Complete") + for player in marked do player:SetAttribute("CitadelZone", nil) end ctx.status(Strings.siegeComplete) - return true + return false end - zone.marker.body.Parent = folder + local visual = visuals[siegeIndex] + if visibleIndex ~= siegeIndex then + visibleIndex, lastStatus = siegeIndex, nil + zone.marker.body.Parent = folder + visual.show() + ctx.events.fire(Kinds.ZoneStarted, {side = siegeSide, index = siegeIndex, text = zone.site.name, at = zone.site.position}) + end + local updated: {[Player]: boolean} = {} local attack, defense = false, false local attackers: {Player} = {} for _, fighter in fighters do @@ -101,8 +131,10 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance defense = true end end + updated[fighter.player] = true fighter.player:SetAttribute("CitadelZone", reason) end + for player in marked do if not updated[player] then player:SetAttribute("CitadelZone", nil) end 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 @@ -120,7 +152,15 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance 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 ctx.status(Strings.siegeStatus(attacker, siegeIndex, #zones, percent, phase)) - Common.paint(zone.marker, if phase == "Contested" then Common.orange else Common.blue) + local teamTint = Common.color(siegeSide) + local tint = if phase == "Idle" then Common.gold elseif phase == "Contested" then SiegeConfig.CONTESTED_COLOR + elseif phase == "Decaying" then teamTint:Lerp(Color3.fromRGB(150, 162, 182), .45) else teamTint + Common.paint(zone.marker, tint) + visual.update(tint, phase, progress, phase ~= lastStatus) + if phase == "Contested" and lastStatus ~= phase then + ctx.events.fire(Kinds.ZoneContested, {side = siegeSide, index = siegeIndex, at = zone.site.position}) + end + lastStatus = phase if phase ~= "Captured" or not Score.record(siegeTimes, siegeSide, siegeIndex, elapsed - attackStart) then return false end ctx.scoring.add(siegeSide, SiegeConfig.POINTS_PER_OBJECTIVE, Kinds.ZoneCaptured) for _, player in attackers do ctx.contribute(player, "captures", 1) end @@ -128,12 +168,16 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance ctx.cue(fighters, true, nil) siegeCaptureStarted = false data:SetAttribute(siegeSide .. "Time" .. siegeIndex, elapsed - attackStart) - zone.marker.body.Parent = nil + visual.capture(teamTint) siegeIndex += 1 siegeProgress = 0 if siegeIndex > #zones then ctx.events.fire(Kinds.AllObjectivesTaken, {side = siegeSide}) - return true + if SiegeConfig.EARLY_FINISH_WHEN_ALL_TAKEN then + if hadSiegeSwap then return true end + swapAt = elapsed + state:SetAttribute("SiegeEndsAt", ctx.liveAt + swapAt + SiegeConfig.SWAP_FREEZE + half) + end end return false end @@ -144,8 +188,11 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance state:SetAttribute("CitadelResultReason", reason) return winner, reason end, + death = function(p) p:SetAttribute("CitadelZone", nil) end, + leaving = function(p) marked[p] = nil; p:SetAttribute("CitadelZone", nil) end, destroy = function() - for _, p in ctx.members() do p:SetAttribute("CitadelZone", nil) end + state:SetAttribute("SiegeEndsAt", nil) + for p in marked do p:SetAttribute("CitadelZone", nil) end end, }) end diff --git a/scripts/ModeRuntime/SiegeEffects.luau b/scripts/ModeRuntime/SiegeEffects.luau new file mode 100644 index 0000000..624a029 --- /dev/null +++ b/scripts/ModeRuntime/SiegeEffects.luau @@ -0,0 +1,109 @@ +--!strict +local TweenService = game:GetService("TweenService") +local Runtime = script.Parent +local Common = require(Runtime.Common) +local Types = require(Runtime.Types) +local Config = require(game.ReplicatedStorage.CitadelAssaultConfig) +export type Rig = {show: () -> (), hide: () -> (), update: (Color3, string, number, boolean) -> (), capture: (Color3) -> ()} + +local function newPart(name: string, parent: Instance): Part + local p = Instance.new("Part") + p.Name, p.Shape, p.Material = name, Enum.PartType.Cylinder, Enum.Material.Neon + p.CanCollide, p.CanQuery, p.CanTouch, p.Anchored, p.CastShadow = false, false, false, true, false + p.Transparency = 1 + p.Parent = parent + return p +end + +local Effects = {} +function Effects.new(mark: Common.Marker, folder: Folder, janitor: Types.Janitor): Rig + local root = Instance.new("Folder") + root.Name = "SiegeLight" + root.Parent = folder + local column = newPart("Column", root) + local wave = newPart("Shockwave", root) + local anchor = Instance.new("Attachment") + anchor.Parent = wave + local sparks = Instance.new("ParticleEmitter") + sparks.Texture = "rbxasset://textures/particles/sparkles_main.dds" + sparks.Speed, sparks.Lifetime, sparks.Rate = NumberRange.new(12, 25), NumberRange.new(.45, 1.2), 0 + sparks.SpreadAngle = Vector2.new(145, 145) + sparks.LightEmission = 1 + sparks.Parent = anchor + local diameter = Config.CAPTURE_RADIUS * 2 + local rotation = CFrame.Angles(0, 0, math.pi / 2) + local floor = CFrame.new(mark.origin + Vector3.yAxis * .21) * rotation + wave.CFrame = floor + local width = 3.5 + local fullColumn = CFrame.new(mark.origin + Vector3.yAxis * (Config.LIGHT_HEIGHT / 2)) * rotation + local motion: Tween? = nil + local lightMotion: Tween? = nil + local effect: Tween? = nil + local run = 0 + local function cancel() + run += 1 + if motion then motion:Cancel() end + if lightMotion then lightMotion:Cancel() end + if effect then effect:Cancel() end + end + local function hide() + cancel() + column.Transparency, wave.Transparency = 1, 1 + sparks:Clear() + end + janitor.give(hide) + + return { + hide = hide, + show = function() + hide() + mark.body:SetAttribute("ObjectiveArrowHidden", nil) + mark.label.Visible = true + mark.body.Size = Vector3.new(.16, diameter * .15, diameter * .15) + mark.body.Transparency = .92 + Common.paint(mark, Common.gold) + column.Color = Common.gold + column.Size, column.CFrame = Vector3.new(.2, width, width), floor + column.Transparency = .85 + local t = TweenInfo.new(Config.MATERIALIZE_SECONDS, Enum.EasingStyle.Quart, Enum.EasingDirection.Out) + motion = TweenService:Create(mark.body, t, {Size = Vector3.new(.16, diameter, diameter)}) + lightMotion = TweenService:Create(column, t, {CFrame = fullColumn, Size = Vector3.new(Config.LIGHT_HEIGHT, width, width)}) + motion:Play() + lightMotion:Play() + end, + update = function(tint, phase, progress, changed) + column.Color = tint + column.Transparency = if phase == "Capturing" then 1 - (.55 + .45 * progress) * .25 + elseif phase == "Decaying" then .94 else .86 + if phase == "Contested" and changed then + wave.Color, wave.Transparency = tint, .68 + wave.Size = Vector3.new(.12, diameter, diameter) + if effect then effect:Cancel() end + effect = TweenService:Create(wave, TweenInfo.new(.25), {Transparency = 1}) + effect:Play() + end + end, + capture = function(tint) + cancel() + local token = run + Common.paint(mark, Color3.new(1, 1, 1)) + mark.body:SetAttribute("ObjectiveArrowHidden", true) + mark.label.Visible = false + wave.Size = Vector3.new(.11, diameter, diameter) + wave.Color, wave.Transparency = tint, .55 + sparks.Color = ColorSequence.new(tint) + sparks:Emit(Config.CONFETTI_COUNT) + local t = TweenInfo.new(Config.CAPTURE_EFFECT_SECONDS, Enum.EasingStyle.Quad, Enum.EasingDirection.Out) + motion = TweenService:Create(mark.body, t, {Size = Vector3.new(.16, .1, .1), Transparency = 1}) + lightMotion = TweenService:Create(column, t, {Size = Vector3.new(.2, width, width), CFrame = floor, Transparency = 1}) + effect = TweenService:Create(wave, t, {Size = Vector3.new(.11, diameter * 1.6, diameter * 1.6), Transparency = 1}) + motion:Play() + lightMotion:Play() + effect:Play() + task.delay(Config.CAPTURE_EFFECT_SECONDS, function() + if token == run and mark.body.Parent == folder then mark.body.Parent = nil end + end) + end, + } +end +return Effects diff --git a/scripts/SniperEffects.luau b/scripts/SniperEffects.luau index 58d7d28..c0a4885 100644 --- a/scripts/SniperEffects.luau +++ b/scripts/SniperEffects.luau @@ -40,6 +40,11 @@ local SOUNDS: { [string]: SoundDef } = { Elimination = { id = "rbxassetid://15675043410", volume = 0.78, speed = 1.18, near = 0, far = 0, group = "Kill", cut = 0.52 }, StreakAccent = { id = "rbxassetid://3120909354", volume = 0.5, speed = 1, near = 0, far = 0, group = "Kill" }, -- Level_up ReloadReady = { id = "rbxassetid://15675085146", volume = 0.24, speed = 1.15, near = 0, far = 0, group = "Reload", cut = 0.19 }, + SiegeEnter = { id = "rbxassetid://113416294133952", volume = .23, speed = 1.30, near = 0, far = 0, group = "HUD" }, + SiegeCharge = { id = "rbxassetid://2789428506", volume = .22, speed = 1, near = 0, far = 0, group = "HUD" }, + SiegeTick = { id = "rbxassetid://113416294133952", volume = .22, speed = 1.48, near = 0, far = 0, group = "HUD" }, + SiegeBlocked = { id = "rbxassetid://2789428506", volume = .25, speed = .70, near = 0, far = 0, group = "HUD" }, + SiegeDecay = { id = "rbxassetid://2789428506", volume = .20, speed = .58, near = 0, far = 0, group = "HUD" }, RoundStart = { id = "rbxassetid://4612374036", volume = .27, speed = 1.15, near = 0, far = 0, group = "HUD" }, Tick = { id = "rbxassetid://113416294133952", volume = .22, speed = 1.12, near = 0, far = 0, group = "HUD" }, RoundCountdown = { id = "rbxassetid://113416294133952", volume = 0.25, speed = 1, near = 0, far = 0, group = "HUD" }, -- timer tick diff --git a/scripts/Tests/Siege.spec.luau b/scripts/Tests/Siege.spec.luau new file mode 100644 index 0000000..b41764e --- /dev/null +++ b/scripts/Tests/Siege.spec.luau @@ -0,0 +1,18 @@ +--!strict +return function(capture: any, score: any, results: any) + assert(capture.advance(0, 4, true, false, 4, .5) == 1) + assert(capture.advance(1, 4, true, true, 4, .5) == .5) + assert(capture.advance(1, 8, true, true, 4, .5) == 0) + assert(capture.advance(0, 4, false, false, 4, .5) == 0) + for count = 1, 3 do + local a, b = {}, {} + for i = 1, count do a[i], b[i] = i * 12, i * 12 + .1 end + assert(score.winner({Blue = a, Orange = b}, .05) == "Blue") + assert(score.winner({Blue = b, Orange = a}, .05) == "Orange") + assert(score.winner({Blue = a, Orange = a}, .05) == "Draw") + end + assert(score.winner({Blue = {}, Orange = {}}, .05) == "Draw") + local ledger = {Blue = {}, Orange = {}} + assert(score.record(ledger, "Blue", 1, 8) and not score.record(ledger, "Blue", 1, 9)) + assert(results.rows({BlueTime1 = 72.4}, 1)[1] == "Рубеж 1 · Синие 1:12.40 · Оранжевые —") +end