Add round stages, respawn protection and match highlights

This commit is contained in:
Leshyi committed 2026-11-29 23:29:29 +05:00
1 parent b87a3770a1
commit d1c42a36b8
28 files changed
+753 -45

No files matched your search

+68 -10
View File
@@ -20,6 +20,7 @@ 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 limit = state:GetAttribute("TeamLimit") :: number
local modeIds = {Modes.Procedural}
local function currentMode(): string
@@ -455,7 +456,9 @@ end
type ResultPlayer = {userId: number, displayName: string, kills: number, deaths: number}
type RoundResult = {mode: string, ruleset: string, winner: string, endsAt: number, duration: number, blueScore: number, orangeScore: number,
blue: {ResultPlayer}, orange: {ResultPlayer}, allowModeChange: boolean?, siegeReason: string?}
blue: {ResultPlayer}, orange: {ResultPlayer}, allowModeChange: boolean?, siegeReason: string?, reason: string?,
highlights: {mvpUserId: number?, mvpName: string?, lines: {{title: string, name: string, value: number}}}?,
contributions: {[string]: {[string]: number}}?}
type ResultRow = {body: Frame, avatar: ImageLabel, name: TextLabel, kills: TextLabel, deaths: TextLabel}
type ResultTeam = {card: Frame, score: TextLabel, empty: TextLabel, accent: Color3, rows: {ResultRow}}
type SummaryView = "Live" | "Final"
@@ -485,6 +488,8 @@ resultTitle.FontFace = UI.Display
resultTitle.TextXAlignment = Enum.TextXAlignment.Left
local resultWinner = UI.label(resultsPanel, "Winner", "", UDim2.fromOffset(27, 60), UDim2.fromOffset(510, 25), 17, UI.Gold)
resultWinner.TextXAlignment = Enum.TextXAlignment.Left
local resultReason = UI.label(resultsPanel, "Reason", "", UDim2.fromOffset(27, 83), UDim2.fromOffset(900, 22), 15, muted)
resultReason.TextXAlignment = Enum.TextXAlignment.Left
local resultMode = UI.label(resultsPanel, "Mode", "", UDim2.fromOffset(566, 30), UDim2.fromOffset(368, 31), 15, muted)
resultMode.TextXAlignment = Enum.TextXAlignment.Right
@@ -593,6 +598,16 @@ end
local blueResult = resultTeam("Blue", 23, "СИНИЕ", blue, blueDark)
local orangeResult = resultTeam("Orange", 491, "ОРАНЖЕВЫЕ", orange, orangeDark)
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
mvpChip.TextXAlignment = Enum.TextXAlignment.Left
local contribution = UI.label(resultsExtra, "Contribution", "", UDim2.fromOffset(15, 32), UDim2.fromOffset(865, 25), 16, ink)
contribution.TextXAlignment = Enum.TextXAlignment.Left
local highlights = UI.label(resultsExtra, "Highlights", "", UDim2.fromOffset(15, 60), UDim2.fromOffset(865, 31), 15, muted)
highlights.TextWrapped = true
highlights.TextXAlignment = Enum.TextXAlignment.Left
resultsExtra.Visible = false
local nextRound = UI.label(resultsPanel, "NextRound", "", UDim2.fromOffset(25, 573), UDim2.fromOffset(910, 31), 16, ink)
local resultTrack = UI.element("ProgressBar", resultsPanel, UDim2.fromOffset(25, 609), UDim2.fromOffset(910, 3))
local resultFill = resultTrack:WaitForChild("Fill") :: Frame
@@ -628,7 +643,11 @@ local function setSummaryTeams(bluePlayers: {ResultPlayer}, orangePlayers: {Resu
populateResults(blueResult, blueTotal, bluePlayers)
populateResults(orangeResult, orangeTotal, orangePlayers)
local rowSpace = 35 * math.max(3, #bluePlayers, #orangePlayers)
local height = 280 + rowSpace
local final = summaryView == "Final"
local height = 280 + rowSpace + (if final then 121 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)
if resultsPanel.Size.Y.Offset == height then return end
resultsPanel.Size = UDim2.fromOffset(960, height)
blueResult.card.Size = UDim2.fromOffset(446, 117 + rowSpace)
@@ -640,6 +659,8 @@ end
local function startSummary(view: SummaryView, ruleId: unknown)
summaryView = view
resultReason.Visible = view == "Final"
resultsExtra.Visible = view == "Final"
lobbyButton.Visible = view == "Live" and player:GetAttribute("InArena") == true
resultsGui:SetAttribute("LiveScoreboardOpen", view == "Live")
resultTitle.Text = if view == "Live" then "СТАТИСТИКА МАТЧА" else "ИТОГИ РАУНДА"
@@ -821,7 +842,22 @@ results.OnClientEvent:Connect(function(result: RoundResult, participantSide: str
local winnerColor = if result.winner == "Blue" then blue elseif result.winner == "Orange" then orange else UI.Gold
resultWinner.Text = if result.winner == "Blue" then "СИНИЕ ПОБЕДИЛИ"
elseif result.winner == "Orange" then "ОРАНЖЕВЫЕ ПОБЕДИЛИ" else "НИЧЬЯ"
if result.siegeReason then resultWinner.Text = result.siegeReason end
resultReason.Text = result.reason or result.siegeReason or ""
local personal = result.contributions and result.contributions[tostring(player.UserId)] or {}
local entries: {string} = {}
local keys = RoundStrings.contributionKeys[result.ruleset] or RoundStrings.contributionKeys.TeamDeathmatch
for _, key in keys do
table.insert(entries, RoundStrings.stats[key] .. " " .. tostring(math.floor(personal[key] or 0)))
end
contribution.Text = string.format(RoundStrings.contribution, table.concat(entries, " · "))
local recap = result.highlights
mvpChip.Visible = recap ~= nil and recap.mvpName ~= nil
mvpChip.Text = if recap and recap.mvpName then string.format(RoundStrings.mvp, recap.mvpName) else ""
table.clear(entries)
if recap then
for _, line in recap.lines do table.insert(entries, string.format("%s · %s (%d)", line.title, line.name, math.floor(line.value))) end
end
highlights.Text = table.concat(entries, " / ")
if result.ruleset == "Siege" and (participantSide == "Blue" or participantSide == "Orange") then
if result.winner == "Draw" then
showOutcome("НИЧЬЯ", ink)
@@ -906,6 +942,10 @@ ContextActionService:BindActionAtPriority(scoreboardAction, function(_, inputSta
end, false, Enum.ContextActionPriority.High.Value, Enum.KeyCode.Tab)
local lastSecond = -1
local lastStage: string? = nil
local priorClockStage: string? = nil
local finalClockPulse: Tween? = nil
local lastIntroBeat = -1
local lastPhase = ""
local lastTeam: string? = nil
local lastMode = ""
@@ -923,32 +963,49 @@ local function updateClock()
end
end
local seconds = remaining()
local phase = activeState():GetAttribute("Phase") :: string
local match = activeState()
local phase = match:GetAttribute("Phase") :: string
local stage = match:GetAttribute("RoundStage") :: string?
local untilLive = match:GetAttribute("LiveAt")
local intro = stage == "Briefing" or stage == "Countdown"
local introSeconds = if intro and typeof(untilLive) == "number" then math.max(0, math.ceil(untilLive - workspace:GetServerTimeNow())) else 0
if intro then seconds = introSeconds end
local team = player:GetAttribute("ArenaTeam") :: string?
local arenaMode = currentMode()
local inArena = player:GetAttribute("InArena") == true
if seconds == lastSecond and phase == lastPhase and team == lastTeam and arenaMode == lastMode and inArena == lastInArena then return end
local finishing = inArena and phase == "Round" and seconds > 0 and seconds <= 5
if seconds == lastSecond and phase == lastPhase and stage == lastStage and team == lastTeam and arenaMode == lastMode and inArena == lastInArena then return end
local counting = inArena and stage == "Countdown" and introSeconds > 0
local hadCountdown = countdown.Visible
if finishing then
if not countdown.Visible or seconds ~= lastSecond or arenaMode ~= lastMode then showCountdownBeat(seconds) end
if counting then
if not hadCountdown or introSeconds ~= lastIntroBeat then showCountdownBeat(introSeconds) end
lastIntroBeat = introSeconds
elseif countdown.Visible then
countdown.Visible = false
clearCountdownBeat()
end
if captureHud.Visible and hadCountdown ~= countdown.Visible then fitHud() end
lastSecond, lastPhase, lastTeam, lastMode, lastInArena = seconds, phase, team, arenaMode, inArena
lastStage = stage
local rule = Rules.get(activeState():GetAttribute("Ruleset"))
if rule.id == "Siege" and inArena then refreshObjective() end
mode.Visible = true
mode.Text = if phase == "Vote" then "ГОЛОСОВАНИЕ" elseif phase == "Reveal" then "ДО НАЧАЛА РАУНДА"
mode.Text = if intro then RoundStrings.untilStart elseif stage == "RoleSwap" then RoundStrings.swap elseif phase == "Vote" then "ГОЛОСОВАНИЕ" elseif phase == "Reveal" then "ДО НАЧАЛА РАУНДА"
elseif phase == "Break" then (if activeState():GetAttribute("AllowModeChange") == false then "ДО НАЧАЛА РАУНДА" else "ДО ГОЛОСОВАНИЯ")
elseif phase == "Round" then (if inArena then "ДО КОНЦА РАУНДА" else rule.title)
else "ПОДГОТОВКА АРЕНЫ"
clock.Position = UDim2.fromOffset(0, 14)
clock.TextSize = 32
clock.Text = string.format("%02d:%02d", seconds // 60, seconds % 60)
clock.TextColor3 = if seconds <= 15 and phase == "Round" then Color3.fromRGB(255, 218, 148) else ink
if stage ~= priorClockStage then
priorClockStage = stage
if finalClockPulse then finalClockPulse:Cancel(); finalClockPulse = nil end
clock.TextColor3 = if stage == "FinalPush" then Color3.fromRGB(255, 106, 107) else ink
if stage == "FinalPush" then
finalClockPulse = TweenService:Create(clock, TweenInfo.new(.72, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
{TextColor3 = Color3.fromRGB(255, 193, 175)})
finalClockPulse:Play()
end
end
mode.TextColor3 = if team == "Blue" then blue elseif team == "Orange" then orange else muted
roundFill.BackgroundColor3 = if seconds <= 15 and phase == "Round" then orange else mode.TextColor3:Lerp(blue, .32)
if clockMotion then clockMotion:Cancel() end
@@ -963,6 +1020,7 @@ end
local timerConnection = RunService.Heartbeat:Connect(updateClock)
script.Destroying:Once(function()
timerConnection:Disconnect()
if finalClockPulse then finalClockPulse:Cancel() end
votingChanged:Disconnect()
scoreboardFocus:Disconnect()
ContextActionService:UnbindAction(scoreboardAction)