Add round stages, respawn protection and match highlights
This commit is contained in:
1 parent
b87a3770a1
commit
d1c42a36b8
28 files changed
+752
-44
No files matched your search
BIN
Binary file not shown.
@@ -5,13 +5,17 @@
|
||||
"ReplicatedStorage": {
|
||||
"$ignoreUnknownInstances": true,
|
||||
"CitadelAssaultConfig": { "$path": "scripts/CitadelAssaultConfig.luau" },
|
||||
"Hunter": { "$path": "scripts/Hunter" }
|
||||
"Hunter": { "$path": "scripts/Hunter" },
|
||||
"SniperEffects": { "$path": "scripts/SniperEffects.luau" }
|
||||
},
|
||||
"ServerScriptService": {
|
||||
"$ignoreUnknownInstances": true,
|
||||
"ArenaObjectives": { "$path": "scripts/ArenaObjectives.luau" },
|
||||
"ModeRuntime": { "$path": "scripts/ModeRuntime" },
|
||||
"ArenaRounds": { "$path": "scripts/ArenaRounds.server.luau" },
|
||||
"ArenaSpawns": { "$path": "scripts/ArenaSpawns.luau" },
|
||||
"SniperShots": { "$path": "scripts/SniperShots.server.luau" },
|
||||
"HotPoint": { "$path": "scripts/HotPoint.luau" },
|
||||
"CitadelCaptureService": { "$path": "scripts/CitadelCaptureService.luau" },
|
||||
"CitadelScoreService": { "$path": "scripts/CitadelScoreService.luau" },
|
||||
"CitadelSpawnService": { "$path": "scripts/CitadelSpawnService.luau" }
|
||||
@@ -21,6 +25,7 @@
|
||||
"StarterPlayerScripts": {
|
||||
"$ignoreUnknownInstances": true,
|
||||
"ArenaRoundHud": { "$path": "scripts/ArenaRoundHud.client.luau" },
|
||||
"HealthBar": { "$path": "scripts/HealthBar.client.luau" },
|
||||
"ArenaClient": { "$path": "scripts/ArenaClient" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
--!strict
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local Input = game:GetService("UserInputService")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript)
|
||||
local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript)
|
||||
local Sounds = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript)
|
||||
local Siege = require(ReplicatedStorage:WaitForChild("CitadelAssaultConfig") :: ModuleScript)
|
||||
local Hunter = ReplicatedStorage:WaitForChild("Hunter")
|
||||
local Profiles = require(Hunter:WaitForChild("ModeProfiles") :: ModuleScript)
|
||||
local Config = require(Hunter:WaitForChild("RoundConfig") :: ModuleScript)
|
||||
local Strings = require(Hunter:WaitForChild("Strings") :: ModuleScript)
|
||||
local match = ReplicatedStorage:WaitForChild("ArenaRound"):WaitForChild("Procedural")
|
||||
local player = Players.LocalPlayer
|
||||
local playerGui = player:WaitForChild("PlayerGui")
|
||||
|
||||
local gui = Instance.new("ScreenGui")
|
||||
gui.Name = "RoundPresentation"
|
||||
gui.ResetOnSpawn = false
|
||||
gui.IgnoreGuiInset = true
|
||||
gui.DisplayOrder = 24
|
||||
gui.Parent = playerGui
|
||||
|
||||
local vignette = Instance.new("CanvasGroup")
|
||||
vignette.Name = "FinalPushVignette"
|
||||
vignette.Size = UDim2.fromScale(1, 1)
|
||||
vignette.BackgroundTransparency = 1
|
||||
vignette.Visible = false
|
||||
vignette.Parent = gui
|
||||
local edges = {
|
||||
{0, 0, 1, .2, 90}, {0, .8, 1, .2, 270},
|
||||
{0, 0, .14, 1, 0}, {.86, 0, .14, 1, 180},
|
||||
}
|
||||
for _, side in edges do
|
||||
local edge = Instance.new("Frame")
|
||||
edge.Position = UDim2.fromScale(side[1], side[2])
|
||||
edge.Size = UDim2.fromScale(side[3], side[4])
|
||||
edge.BorderSizePixel = 0
|
||||
edge.BackgroundColor3 = Color3.fromRGB(255, 60, 70)
|
||||
edge.Parent = vignette
|
||||
local gradient = Instance.new("UIGradient", edge)
|
||||
gradient.Rotation = side[5]
|
||||
gradient.Transparency = NumberSequence.new(.38, 1)
|
||||
end
|
||||
|
||||
local swapShade = Instance.new("Frame")
|
||||
swapShade.Name = "RoleSwapShade"
|
||||
swapShade.Size = UDim2.fromScale(1, 1)
|
||||
swapShade.BackgroundColor3 = UI.Panel
|
||||
swapShade.BackgroundTransparency = 1
|
||||
swapShade.Visible = false
|
||||
swapShade.Parent = gui
|
||||
|
||||
local card = Instance.new("CanvasGroup")
|
||||
card.Name = "Briefing"
|
||||
card.AnchorPoint = Vector2.new(.5, .5)
|
||||
card.Position = UDim2.fromScale(.5, .5)
|
||||
card.Size = UDim2.new(.85, 0, 0, 260)
|
||||
card.BackgroundTransparency = 1
|
||||
card.Visible = false
|
||||
card.Parent = gui
|
||||
local max = Instance.new("UISizeConstraint", card)
|
||||
max.MaxSize = Vector2.new(520, 260)
|
||||
local plate = UI.plate(card, "Plate", UDim2.new(), UDim2.fromScale(1, 1), UI.Blue)
|
||||
local contour = UI.contour(plate, UI.Blue)
|
||||
UI.label(plate, "Mode", Strings.round.mode, UDim2.fromOffset(12, 12), UDim2.new(1, -24, 0, 19), 14, UI.Muted)
|
||||
local title = UI.label(plate, "Title", "", UDim2.fromOffset(12, 31), UDim2.new(1, -24, 0, 40), 34, UI.Blue)
|
||||
title.FontFace = UI.Display
|
||||
local goal = UI.label(plate, "Goal", "", UDim2.fromOffset(18, 70), UDim2.new(1, -36, 0, 35), 18, UI.Ink)
|
||||
goal.TextWrapped = true
|
||||
local rules: {TextLabel} = {}
|
||||
for i = 1, 3 do
|
||||
local line = UI.label(plate, "Rule" .. i, "", UDim2.fromOffset(25, 108 + (i - 1) * 23), UDim2.new(1, -50, 0, 23), 15, UI.Ink)
|
||||
line.TextXAlignment = Enum.TextXAlignment.Left
|
||||
table.insert(rules, line)
|
||||
end
|
||||
local role = UI.label(plate, "Role", "", UDim2.fromOffset(18, 182), UDim2.new(1, -36, 0, 24), 17, UI.Gold)
|
||||
local tutorial = UI.label(plate, "Tutorial", "", UDim2.fromOffset(18, 207), UDim2.new(1, -36, 0, 31), 14, UI.Muted)
|
||||
tutorial.TextWrapped = true
|
||||
local track = UI.element("ProgressBar", plate, UDim2.fromScale(.07, .94), UDim2.new(.86, 0, 0, 4))
|
||||
local fill = track:WaitForChild("Fill") :: Frame
|
||||
|
||||
local banner = UI.plate(gui, "RoundBanner", UDim2.fromScale(.5, .28), UDim2.new(.82, 0, 0, 78), UI.Gold)
|
||||
banner.AnchorPoint = Vector2.new(.5, .5)
|
||||
Instance.new("UISizeConstraint", banner).MaxSize = Vector2.new(500, 78)
|
||||
local bannerTitle = UI.label(banner, "Title", "", UDim2.fromOffset(0, 6), UDim2.new(1, 0, 0, 36), 27, UI.Gold)
|
||||
bannerTitle.FontFace = UI.Display
|
||||
local bannerDetail = UI.label(banner, "Detail", "", UDim2.fromOffset(12, 43), UDim2.new(1, -24, 0, 25), 16, UI.Ink)
|
||||
local respawn = UI.label(gui, "Respawn", "", UDim2.fromScale(.5, .63), UDim2.new(.85, 0, 0, 42), 27, UI.Ink)
|
||||
respawn.AnchorPoint = Vector2.new(.5, .5)
|
||||
respawn.FontFace = UI.Display
|
||||
UI.edge(respawn, UI.Panel, 0)
|
||||
banner.Visible, respawn.Visible = false, false
|
||||
|
||||
local seen: {[string]: boolean} = {}
|
||||
local oldStage: string? = nil
|
||||
local wasInArena = false
|
||||
local briefUntil, bannerUntil = 0, 0
|
||||
local lastTick = -1
|
||||
local barTween: Tween? = nil
|
||||
local slide: Tween? = nil
|
||||
local fade: Tween? = nil
|
||||
local pulse: Tween? = nil
|
||||
local swapTween: Tween? = nil
|
||||
local shakeUntil = 0
|
||||
|
||||
local function showBriefing(id: string, now: number, untilAt: number, short: boolean)
|
||||
local profile = Profiles[id]
|
||||
if not profile then return end
|
||||
local side = player:GetAttribute("ArenaTeam")
|
||||
local tone = if side == "Orange" then UI.Orange else UI.Blue
|
||||
title.TextColor3 = tone
|
||||
title.Text = Rules.get(id).title
|
||||
goal.Text = profile.goal
|
||||
contour:SetAttribute("Accent", tone)
|
||||
UI.tintPlate(plate, tone)
|
||||
for i, line in rules do
|
||||
line.Visible = not short
|
||||
line.Text = "✓ " .. profile.rules[i]
|
||||
end
|
||||
local attacker = match:FindFirstChild("CitadelMatchState")
|
||||
local attackerSide = attacker and attacker:GetAttribute("Attacker") or Siege.FIRST_ATTACKER
|
||||
role.Position = UDim2.fromOffset(18, if short then 122 else 182)
|
||||
role.Text = if id == "Siege" then (if side == attackerSide then Strings.round.attack else Strings.round.defend) else Strings.team(side)
|
||||
tutorial.Visible = not short and not seen[id]
|
||||
tutorial.Text = Strings.round.tutorial[id] or ""
|
||||
if not short then seen[id] = true end
|
||||
card.Size = UDim2.new(.85, 0, 0, if short then 168 else 260)
|
||||
briefUntil = untilAt
|
||||
card.Position, card.GroupTransparency, card.Visible = UDim2.fromScale(.5, .54), 1, true
|
||||
if barTween then barTween:Cancel() end
|
||||
if slide then slide:Cancel() end
|
||||
if fade then fade:Cancel() end
|
||||
local entrance = TweenInfo.new(.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
|
||||
slide = TweenService:Create(card, entrance, {Position = UDim2.fromScale(.5, .5)})
|
||||
fade = TweenService:Create(card, entrance, {GroupTransparency = 0})
|
||||
local duration = math.max(.05, if short then Config.lateBriefingSeconds else profile.briefingSeconds)
|
||||
fill.Size = UDim2.fromScale(math.clamp((untilAt - now) / duration, 0, 1), 1)
|
||||
barTween = TweenService:Create(fill, TweenInfo.new(math.max(.05, untilAt - now), Enum.EasingStyle.Linear), {Size = UDim2.fromScale(0, 1)})
|
||||
slide:Play()
|
||||
fade:Play()
|
||||
barTween:Play()
|
||||
end
|
||||
|
||||
local function showBanner(heading: string, detail: string, untilAt: number)
|
||||
bannerTitle.Text, bannerDetail.Text = heading, detail
|
||||
bannerUntil = untilAt
|
||||
banner.Visible = true
|
||||
end
|
||||
|
||||
local function update()
|
||||
local now = workspace:GetServerTimeNow()
|
||||
local inArena = player:GetAttribute("InArena") == true
|
||||
local stage = match:GetAttribute("RoundStage") :: string?
|
||||
local id = Rules.get(match:GetAttribute("Ruleset")).id
|
||||
local final = inArena and stage == "FinalPush"
|
||||
local swapping = inArena and stage == "RoleSwap"
|
||||
if swapping ~= swapShade.Visible then
|
||||
swapShade.Visible = swapping
|
||||
if swapTween then swapTween:Cancel(); swapTween = nil end
|
||||
if swapping then
|
||||
swapShade.BackgroundTransparency = 1
|
||||
swapTween = TweenService:Create(swapShade, TweenInfo.new(.22), {BackgroundTransparency = .28})
|
||||
swapTween:Play()
|
||||
end
|
||||
end
|
||||
if final ~= vignette.Visible then
|
||||
vignette.Visible = final
|
||||
if pulse then pulse:Cancel(); pulse = nil end
|
||||
if final then
|
||||
vignette.GroupTransparency = .46
|
||||
pulse = TweenService:Create(vignette, TweenInfo.new(.9, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
|
||||
{GroupTransparency = .75})
|
||||
pulse:Play()
|
||||
end
|
||||
end
|
||||
if inArena and (stage ~= oldStage or not wasInArena) then
|
||||
card.Visible = false
|
||||
banner.Visible = false
|
||||
lastTick = -1
|
||||
if stage == "Briefing" then
|
||||
local limit = match:GetAttribute("StageEndsAt")
|
||||
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
|
||||
elseif stage == "Live" or stage == "FinalPush" then
|
||||
if final then
|
||||
showBanner(Strings.round.final, Strings.round.finalPush[id] or "", now + Config.finalBannerSeconds)
|
||||
elseif oldStage == "Countdown" and wasInArena then
|
||||
showBanner(Strings.round.fight, "", now + Config.startBannerSeconds)
|
||||
Sounds.sound("RoundStart")
|
||||
if Config.CameraShake and not Input.TouchEnabled then shakeUntil = os.clock() + .22 end
|
||||
elseif not wasInArena then
|
||||
showBriefing(id, now, now + Config.lateBriefingSeconds, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
card.Visible = card.Visible and inArena and now < briefUntil
|
||||
banner.Visible = banner.Visible and inArena and now < bannerUntil
|
||||
local shieldAt = player:GetAttribute("RoundRespawnAt")
|
||||
local left = if typeof(shieldAt) == "number" then math.ceil(shieldAt - now) else 0
|
||||
respawn.Visible = inArena and left > 0
|
||||
if respawn.Visible then respawn.Text = string.format(Strings.round.respawn, left) end
|
||||
if final then
|
||||
local endsAt = match:GetAttribute("EndsAt")
|
||||
local seconds = if typeof(endsAt) == "number" then math.ceil(endsAt - now) else 0
|
||||
if seconds > 0 and seconds <= Config.finalTickSeconds and seconds ~= lastTick then
|
||||
lastTick = seconds
|
||||
Sounds.sound("Tick")
|
||||
end
|
||||
end
|
||||
oldStage, wasInArena = stage, inArena
|
||||
end
|
||||
|
||||
local connection = RunService.Heartbeat:Connect(update)
|
||||
local shakeName = "HunterRoundStartShake"
|
||||
if Config.CameraShake and not Input.TouchEnabled then
|
||||
RunService:BindToRenderStep(shakeName, Enum.RenderPriority.Camera.Value + 1, function()
|
||||
local camera = workspace.CurrentCamera
|
||||
local left = shakeUntil - os.clock()
|
||||
if camera and left > 0 then camera.CFrame *= CFrame.Angles(math.sin(left * 85) * left * .027, 0, 0) end
|
||||
end)
|
||||
end
|
||||
script.Destroying:Once(function()
|
||||
connection:Disconnect()
|
||||
if Config.CameraShake and not Input.TouchEnabled then RunService:UnbindFromRenderStep(shakeName) end
|
||||
for _, tween in {barTween, slide, fade, pulse, swapTween} do if tween then tween:Cancel() end end
|
||||
gui:Destroy()
|
||||
end)
|
||||
@@ -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)
|
||||
|
||||
+157
-14
@@ -7,13 +7,21 @@ local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScri
|
||||
local Hosting = require(ReplicatedStorage:WaitForChild("HostedArena") :: ModuleScript)
|
||||
local Objectives = require(script.Parent:WaitForChild("ArenaObjectives") :: ModuleScript)
|
||||
local SiegeConfig = require(ReplicatedStorage:WaitForChild("CitadelAssaultConfig") :: ModuleScript)
|
||||
local Hunter = ReplicatedStorage:WaitForChild("Hunter")
|
||||
local Profiles = require(Hunter:WaitForChild("ModeProfiles") :: ModuleScript)
|
||||
local Timeline = require(Hunter:WaitForChild("Timeline") :: ModuleScript)
|
||||
local Stage = require(Hunter:WaitForChild("Stage") :: ModuleScript)
|
||||
local RoundConfig = require(Hunter:WaitForChild("RoundConfig") :: ModuleScript)
|
||||
local Strings = require(Hunter:WaitForChild("Strings") :: ModuleScript)
|
||||
local Runtime = script.Parent:WaitForChild("ModeRuntime")
|
||||
local RoundPlayer = require(Runtime:WaitForChild("PlayerRoundState") :: ModuleScript)
|
||||
local Stats = require(Runtime:WaitForChild("Stats") :: ModuleScript)
|
||||
|
||||
local ArenaSpawns = require(script.Parent:WaitForChild("ArenaSpawns"))
|
||||
local SkinCatalog = require(ReplicatedStorage:WaitForChild("RifleSkinCatalog") :: ModuleScript)
|
||||
local lobbySpawn = workspace:WaitForChild("HunterLobby"):WaitForChild("Arrival Spawn") :: SpawnLocation
|
||||
local rifleTemplate = ReplicatedStorage:WaitForChild("ArenaEquipment"):WaitForChild("SniperRifle") :: Tool
|
||||
|
||||
local ROUND_SECONDS = 300
|
||||
local BREAK_SECONDS = 15
|
||||
local VOTE_SECONDS = 15
|
||||
local TEAM_REVEAL_SECONDS = 1.05
|
||||
@@ -55,7 +63,7 @@ randomState.Parent = state
|
||||
|
||||
type Side = Hosting.Side
|
||||
type Match = {id: string, state: Folder, blue: Team, orange: Team, phase: string, endsAt: number, order: number,
|
||||
rule: string, allowModeChange: boolean, engine: Objectives.Match?, eligible: {[Player]: Side}, ballots: {[Player]: string}}
|
||||
rule: string, startedAt: number?, liveAt: number?, allowModeChange: boolean, engine: Objectives.Match?, eligible: {[Player]: Side}, ballots: {[Player]: string}}
|
||||
type PendingJoin = {match: Match, side: Side, endsAt: number}
|
||||
local pendingJoins: {[Player]: PendingJoin} = {}
|
||||
local matches: {[string]: Match} = {
|
||||
@@ -161,6 +169,7 @@ local function guardInventory(player: Player, container: Instance)
|
||||
local function disarmed(): boolean
|
||||
return player:GetAttribute("InArena") ~= true or player:GetAttribute("ArenaWaiting") == true
|
||||
or player:GetAttribute("ArenaIntermission") == true
|
||||
or not Stage.combatAllowed(randomState)
|
||||
end
|
||||
container.ChildAdded:Connect(function(child)
|
||||
if child:IsA("Tool") and disarmed() then child:Destroy() end
|
||||
@@ -176,10 +185,14 @@ end
|
||||
local function recordDeath(player: Player, character: Model)
|
||||
if not roster[player] or placedCharacter[player] ~= character or lastCountedDeath[player] == character then return end
|
||||
lastCountedDeath[player] = character
|
||||
Stats.add(player, "deaths", 1)
|
||||
player:SetAttribute("RoundDeaths", ((player:GetAttribute("RoundDeaths") :: number?) or 0) + 1)
|
||||
end
|
||||
|
||||
local function moveToLobby(player: Player)
|
||||
RoundPlayer.thaw(player)
|
||||
RoundPlayer.clearShield(player)
|
||||
player:SetAttribute("RoundRespawnAt", nil)
|
||||
placedCharacter[player] = nil
|
||||
player:SetAttribute("InArena", false)
|
||||
player.RespawnLocation = lobbySpawn
|
||||
@@ -198,6 +211,7 @@ local function sendToLobby(player: Player)
|
||||
roster[player] = nil
|
||||
joinOrder[player] = nil
|
||||
lastCountedDeath[player] = nil
|
||||
Stats.remove(player)
|
||||
moveToLobby(player)
|
||||
player:SetAttribute("ArenaWaiting", nil)
|
||||
player:SetAttribute("ArenaIntermission", nil)
|
||||
@@ -221,7 +235,15 @@ local function enterArena(player: Player, character: Model, humanoid: Humanoid)
|
||||
local destination = destinationFor(player)
|
||||
player.RespawnLocation = destination
|
||||
ArenaSpawns.place(character, destination)
|
||||
if Stage.combatAllowed(randomState) then
|
||||
RoundPlayer.thaw(player)
|
||||
arm(player, character, humanoid)
|
||||
else
|
||||
clearTools(character)
|
||||
clearTools(player:FindFirstChildOfClass("Backpack"))
|
||||
RoundPlayer.clearShield(player)
|
||||
RoundPlayer.freeze(player, character, humanoid)
|
||||
end
|
||||
end
|
||||
|
||||
local function deploy(player: Player)
|
||||
@@ -239,6 +261,7 @@ local function deploy(player: Player)
|
||||
end
|
||||
|
||||
local function stageOnArena(player: Player)
|
||||
RoundPlayer.clearShield(player)
|
||||
placedCharacter[player] = nil
|
||||
player:SetAttribute("InArena", true)
|
||||
local destination = destinationFor(player)
|
||||
@@ -258,6 +281,7 @@ local function bench(player: Player)
|
||||
if character and humanoid and humanoid.Health > 0 then
|
||||
humanoid.Health = humanoid.MaxHealth
|
||||
ArenaSpawns.place(character, destination)
|
||||
if not Stage.combatAllowed(randomState) then RoundPlayer.freeze(player, character, humanoid) end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -265,6 +289,17 @@ local function enterRound(player: Player, match: Match)
|
||||
if match.rule == "OneLife" then bench(player) else deploy(player) end
|
||||
end
|
||||
|
||||
local function spawnCharacter(player: Player, previous: Model?)
|
||||
-- Загружаем персонажа только пока действителен конкретный запрос на возрождение.
|
||||
for attempt = 1, 2 do
|
||||
if player.Parent ~= Players or player.Character ~= previous then return end
|
||||
local ok, issue = pcall(player.LoadCharacterAsync, player)
|
||||
if ok then return end
|
||||
warn("Не удалось возродить игрока:", issue)
|
||||
if attempt == 1 then task.wait(1) end
|
||||
end
|
||||
end
|
||||
|
||||
local function onCharacter(player: Player, character: Model)
|
||||
local root = character:WaitForChild("HumanoidRootPart", 10)
|
||||
local humanoid = character:WaitForChild("Humanoid", 10)
|
||||
@@ -278,26 +313,42 @@ local function onCharacter(player: Player, character: Model)
|
||||
humanoid.HealthChanged:Connect(replicateHealth)
|
||||
replicateHealth()
|
||||
humanoid.Died:Once(function()
|
||||
if player.Character ~= character then return end
|
||||
RoundPlayer.thaw(player)
|
||||
RoundPlayer.clearShield(player)
|
||||
local match = matches[Modes.of(player)]
|
||||
local engine = match.engine
|
||||
local wasFighting = roster[player] ~= nil and placedCharacter[player] == character
|
||||
recordDeath(player, character)
|
||||
if player.Character == character then resetStreak(player) end
|
||||
if wasFighting and engine and match.phase == "Round" then
|
||||
local position = if root:IsA("BasePart") then root.Position else nil
|
||||
local fightingStage = match.phase == "Round" and Stage.combatAllowed(match.state)
|
||||
local wasFighting = roster[player] ~= nil and placedCharacter[player] == character and fightingStage
|
||||
local roundRespawn = roster[player] ~= nil and match.phase == "Round" and match.rule ~= "OneLife"
|
||||
local now = workspace:GetServerTimeNow()
|
||||
local delay = if roundRespawn then Profiles[match.rule].respawnDelay else Players.RespawnTime
|
||||
if roundRespawn then player:SetAttribute("RoundRespawnAt", now + delay) end
|
||||
task.delay(delay, spawnCharacter, player, character)
|
||||
if fightingStage then recordDeath(player, character) end
|
||||
resetStreak(player)
|
||||
if wasFighting and engine then
|
||||
local position = if root:IsA("BasePart") then root.Position else nil
|
||||
task.defer(function()
|
||||
if match.engine == engine and roster[player] and placedCharacter[player] == character then engine.death(player, position, now) end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
local respawning = player:GetAttribute("RoundRespawnAt") ~= nil
|
||||
player:SetAttribute("RoundRespawnAt", nil)
|
||||
if roster[player] and player:GetAttribute("InArena") == true then
|
||||
if player:GetAttribute("ArenaIntermission") == true or player:GetAttribute("ArenaWaiting") == true then
|
||||
local destination = player.RespawnLocation or destinationFor(player)
|
||||
player.RespawnLocation = destination
|
||||
ArenaSpawns.place(character, destination)
|
||||
if player:GetAttribute("ArenaIntermission") ~= true and not Stage.combatAllowed(randomState) then
|
||||
RoundPlayer.freeze(player, character, humanoid)
|
||||
end
|
||||
else
|
||||
enterArena(player, character, humanoid)
|
||||
if respawning and Stage.combatAllowed(randomState) then
|
||||
RoundPlayer.shield(player, character, Profiles[matches[Modes.of(player)].rule].spawnProtection)
|
||||
end
|
||||
end
|
||||
else
|
||||
ArenaSpawns.place(character, lobbySpawn)
|
||||
@@ -319,9 +370,12 @@ local function onPlayer(player: Player)
|
||||
if player.Character then
|
||||
guardInventory(player, player.Character)
|
||||
task.spawn(onCharacter, player, player.Character)
|
||||
else
|
||||
task.defer(spawnCharacter, player, nil)
|
||||
end
|
||||
end
|
||||
|
||||
Players.CharacterAutoLoads = false
|
||||
Players.PlayerAdded:Connect(onPlayer)
|
||||
for _, player in Players:GetPlayers() do onPlayer(player) end
|
||||
|
||||
@@ -349,6 +403,9 @@ local function broadcastVotes(match: Match)
|
||||
end
|
||||
|
||||
Players.PlayerRemoving:Connect(function(player)
|
||||
RoundPlayer.thaw(player)
|
||||
RoundPlayer.clearShield(player)
|
||||
Stats.remove(player)
|
||||
local wasPlaying = roster[player] ~= nil
|
||||
local match = matches[Modes.of(player)]
|
||||
local engine = match.engine
|
||||
@@ -529,8 +586,13 @@ cycleSkin.OnServerEvent:Connect(function(player: Player)
|
||||
end)
|
||||
|
||||
local function publish(match: Match)
|
||||
local duration = if match.phase == "Round" then ROUND_SECONDS elseif match.phase == "Vote" then VOTE_SECONDS
|
||||
local duration = if match.phase == "Round" then match.endsAt - (match.startedAt or match.endsAt) elseif match.phase == "Vote" then VOTE_SECONDS
|
||||
elseif match.phase == "Reveal" then Rules.VoteRevealSeconds else BREAK_SECONDS
|
||||
if match.phase ~= "Round" then
|
||||
match.state:SetAttribute("RoundStage", nil)
|
||||
match.state:SetAttribute("StageEndsAt", nil)
|
||||
match.state:SetAttribute("LiveAt", nil)
|
||||
end
|
||||
match.state:SetAttribute("PhaseDuration", duration)
|
||||
match.state:SetAttribute("EndsAt", match.endsAt)
|
||||
match.state:SetAttribute("Phase", match.phase)
|
||||
@@ -592,8 +654,12 @@ local function startRound(match: Match)
|
||||
match.state:SetAttribute("MapGeneration", arena:GetAttribute("Generation"))
|
||||
match.state:SetAttribute("MapLayout", arena:GetAttribute("LayoutVariant"))
|
||||
local now = workspace:GetServerTimeNow()
|
||||
local profile = Profiles[match.rule]
|
||||
local roundDuration = profile.roundSeconds + (if match.rule == "Siege" then SiegeConfig.SWAP_FREEZE else 0)
|
||||
local liveAt = Timeline.liveAt(now, profile.briefingSeconds, profile.countdownSeconds)
|
||||
Stats.reset()
|
||||
local ok, engine = pcall(Objectives.start, {
|
||||
arena = match.id, rule = match.rule, state = match.state, now = now, duration = ROUND_SECONDS,
|
||||
arena = match.id, rule = match.rule, state = match.state, now = liveAt, duration = roundDuration,
|
||||
bench = bench, deploy = deploy,
|
||||
balanceWaiting = function() balanceWaiting(match) end,
|
||||
members = function(): {Player}
|
||||
@@ -609,8 +675,11 @@ local function startRound(match: Match)
|
||||
return
|
||||
end
|
||||
match.engine = engine
|
||||
local roundDuration = if match.rule == "Siege" then SiegeConfig.MATCH_DURATION + SiegeConfig.SWAP_FREEZE else ROUND_SECONDS
|
||||
match.phase, match.endsAt = "Round", now + roundDuration
|
||||
match.startedAt, match.liveAt = now, liveAt
|
||||
match.phase, match.endsAt = "Round", liveAt + roundDuration
|
||||
match.state:SetAttribute("LiveAt", liveAt)
|
||||
match.state:SetAttribute("StageEndsAt", now + profile.briefingSeconds)
|
||||
match.state:SetAttribute("RoundStage", "Briefing")
|
||||
match.state:SetAttribute("Ruleset", match.rule)
|
||||
match.state:SetAttribute("BlueKills", 0)
|
||||
match.state:SetAttribute("OrangeKills", 0)
|
||||
@@ -629,7 +698,7 @@ local function finishRound(match: Match)
|
||||
if team ~= match.blue and team ~= match.orange then continue end
|
||||
local character = player.Character
|
||||
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
|
||||
if character and humanoid and humanoid.Health <= 0 then recordDeath(player, character) end
|
||||
if character and humanoid and humanoid.Health <= 0 and Stage.combatAllowed(match.state) then recordDeath(player, character) end
|
||||
table.insert(participants, {player = player, side = if team == match.blue then "Blue" else "Orange"})
|
||||
table.insert(if team == match.blue then bluePlayers else orangePlayers, {
|
||||
userId = player.UserId,
|
||||
@@ -655,11 +724,41 @@ local function finishRound(match: Match)
|
||||
local winner = if engine then engine.winner() else "Draw"
|
||||
local siegeState = match.state:FindFirstChild("CitadelMatchState")
|
||||
local siegeTimes = if siegeState then siegeState:GetAttributes() else nil
|
||||
local rows: {Stats.Row} = {}
|
||||
local contributions: {[string]: {[string]: number}} = {}
|
||||
local names: {[number]: string} = {}
|
||||
for _, entry in participants do
|
||||
local player = entry.player
|
||||
if winner == entry.side then Stats.add(player, "wins", 1) end
|
||||
local record = Stats.get(player)
|
||||
contributions[tostring(player.UserId)] = record
|
||||
names[player.UserId] = player.DisplayName
|
||||
table.insert(rows, {userId = player.UserId, stats = record})
|
||||
end
|
||||
local mvp = Stats.mvp(rows, RoundConfig.mvpWeights)
|
||||
local lines = {}
|
||||
for _, key in Strings.round.highlightOrder do
|
||||
local best: Stats.Row? = nil
|
||||
for _, row in rows do
|
||||
local value = row.stats[key] or 0
|
||||
local bestValue = if best then best.stats[key] or 0 else 0
|
||||
if value > 0 and (not best or value > bestValue or (value == bestValue and row.userId < best.userId)) then
|
||||
best = row
|
||||
end
|
||||
end
|
||||
if best then
|
||||
table.insert(lines, {title = Strings.round.stats[key], name = names[best.userId], value = best.stats[key]})
|
||||
if #lines == 3 then break end
|
||||
end
|
||||
end
|
||||
local snapshot = {
|
||||
mode = match.id,
|
||||
ruleset = match.rule,
|
||||
allowModeChange = match.allowModeChange,
|
||||
winner = winner,
|
||||
reason = match.state:GetAttribute("ResultReason") or (if winner == "Draw" then Strings.round.drawReason else Strings.round.scoreReason),
|
||||
highlights = {mvpUserId = mvp, mvpName = if mvp then names[mvp] else nil, lines = lines},
|
||||
contributions = contributions,
|
||||
siegeReason = if siegeState then match.state:GetAttribute("CitadelResultReason") else nil,
|
||||
siegeTimes = siegeTimes,
|
||||
endsAt = match.endsAt,
|
||||
@@ -673,6 +772,9 @@ local function finishRound(match: Match)
|
||||
for _, entry in participants do
|
||||
local player = entry.player
|
||||
match.eligible[player] = entry.side
|
||||
RoundPlayer.thaw(player)
|
||||
RoundPlayer.clearShield(player)
|
||||
player:SetAttribute("RoundRespawnAt", nil)
|
||||
player:SetAttribute("ArenaIntermission", true)
|
||||
local wasInArena = player:GetAttribute("InArena") == true
|
||||
player:SetAttribute("ArenaWaiting", nil)
|
||||
@@ -720,6 +822,32 @@ local function finishVote(match: Match, now: number)
|
||||
startRound(match)
|
||||
end
|
||||
|
||||
local function advanceStage(match: Match, now: number): number
|
||||
local profile = Profiles[match.rule]
|
||||
local stage, boundary = Timeline.stage(match.startedAt or now, match.endsAt, profile.briefingSeconds,
|
||||
profile.countdownSeconds, profile.finalPushSeconds, now)
|
||||
local previous = match.state:GetAttribute("RoundStage")
|
||||
if previous == "RoleSwap" then
|
||||
return (match.state:GetAttribute("StageEndsAt") :: number?) or boundary
|
||||
end
|
||||
if previous ~= stage then
|
||||
match.state:SetAttribute("StageEndsAt", boundary)
|
||||
match.state:SetAttribute("RoundStage", stage)
|
||||
if stage == "Live" or stage == "FinalPush" then
|
||||
for player, team in roster do
|
||||
if team ~= match.blue and team ~= match.orange then continue end
|
||||
RoundPlayer.thaw(player)
|
||||
local character = player.Character
|
||||
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
|
||||
if character and humanoid and humanoid.Health > 0 and player:GetAttribute("ArenaWaiting") ~= true then
|
||||
arm(player, character, humanoid)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return boundary
|
||||
end
|
||||
|
||||
local function runMatch(match: Match)
|
||||
while true do
|
||||
local now = workspace:GetServerTimeNow()
|
||||
@@ -737,8 +865,23 @@ local function runMatch(match: Match)
|
||||
match.rule = choices[modeRandom:NextInteger(1, #choices)]
|
||||
end
|
||||
startRound(match)
|
||||
elseif remaining <= 0 or (engine and engine.step(now)) then finishRound(match)
|
||||
else task.wait(math.min(remaining, if match.rule == "Siege" then SiegeConfig.CHECK_INTERVAL else .2)) end
|
||||
elseif remaining <= 0 then
|
||||
finishRound(match)
|
||||
else
|
||||
local boundary = advanceStage(match, now)
|
||||
local wasSwap = match.state:GetAttribute("RoundStage") == "RoleSwap"
|
||||
if now >= (match.liveAt or now) and engine and engine.step(now) then
|
||||
finishRound(match)
|
||||
else
|
||||
if wasSwap and match.state:GetAttribute("RoundStage") == "Live" then
|
||||
-- Режим завершил паузу и разрешил боевой этап.
|
||||
match.state:SetAttribute("RoundStage", nil)
|
||||
boundary = advanceStage(match, now)
|
||||
end
|
||||
local interval = if match.rule == "Siege" then SiegeConfig.CHECK_INTERVAL else .2
|
||||
task.wait(math.min(remaining, interval, math.max(.01, boundary - now)))
|
||||
end
|
||||
end
|
||||
elseif remaining > 0 then
|
||||
task.wait(remaining)
|
||||
elseif match.phase == "Break" and match.allowModeChange then
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript)
|
||||
local RoundConfig = require(ReplicatedStorage:WaitForChild("Hunter"):WaitForChild("RoundConfig") :: ModuleScript)
|
||||
local random = Random.new()
|
||||
local ArenaSpawns = {}
|
||||
|
||||
@@ -20,24 +21,35 @@ function ArenaSpawns.choose(player: Player): SpawnLocation
|
||||
assert(#choices > 0, arena.Name .. " has no enabled spawns for this team")
|
||||
local best = choices[random:NextInteger(1, #choices)]
|
||||
local bestDistance = -1
|
||||
local bestSafe: SpawnLocation? = nil
|
||||
local bestSafeScore = -1
|
||||
for _, marker in choices do
|
||||
local nearest = 1000
|
||||
local enemyDistance = math.huge
|
||||
for _, other in Players:GetPlayers() do
|
||||
local character = other.Character
|
||||
local root = character and character:FindFirstChild("HumanoidRootPart")
|
||||
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
|
||||
if other ~= player and other:GetAttribute("InArena") == true and Modes.same(player, other)
|
||||
and root and root:IsA("BasePart") and humanoid and humanoid.Health > 0 then
|
||||
nearest = math.min(nearest, (root.Position - marker.Position).Magnitude)
|
||||
local distance = (root.Position - marker.Position).Magnitude
|
||||
nearest = math.min(nearest, distance)
|
||||
local otherSide = other:GetAttribute("ArenaTeam")
|
||||
if otherSide ~= nil and otherSide ~= side and other:GetAttribute("ArenaWaiting") ~= true then
|
||||
enemyDistance = math.min(enemyDistance, distance)
|
||||
end
|
||||
end
|
||||
end
|
||||
local score = nearest + random:NextNumber(0, 24)
|
||||
if enemyDistance >= RoundConfig.safeSpawnDistance and score > bestSafeScore then
|
||||
bestSafe, bestSafeScore = marker, score
|
||||
end
|
||||
if score > bestDistance then
|
||||
bestDistance = score
|
||||
best = marker
|
||||
end
|
||||
end
|
||||
return best
|
||||
return bestSafe or best
|
||||
end
|
||||
|
||||
function ArenaSpawns.place(character: Model, marker: SpawnLocation)
|
||||
|
||||
@@ -44,6 +44,14 @@ gui:GetPropertyChangedSignal("AbsoluteSize"):Connect(fit)
|
||||
fit()
|
||||
local shield = UI.element("Shield", plate, UDim2.fromOffset(14, 13), nil)
|
||||
Instance.new("UIScale", shield).Scale = 1.13
|
||||
local protection = UI.element("Shield", plate, UDim2.new(1, -30, 0, -24), nil)
|
||||
protection.Name = "SpawnProtection"
|
||||
local function refreshProtection()
|
||||
local deadline = player:GetAttribute("SpawnShield")
|
||||
protection.Visible = typeof(deadline) == "number" and deadline > workspace:GetServerTimeNow()
|
||||
end
|
||||
player:GetAttributeChangedSignal("SpawnShield"):Connect(refreshProtection)
|
||||
refreshProtection()
|
||||
local text = UI.label(plate, "Value", "100", UDim2.fromOffset(46, 0), UDim2.fromOffset(55, 49), 24, UI.Ink)
|
||||
text.FontFace = UI.Display
|
||||
text.TextXAlignment = Enum.TextXAlignment.Left
|
||||
|
||||
@@ -8,6 +8,7 @@ export type Marker = {body: Part, label: TextLabel, origin: Vector3}
|
||||
type Config = {
|
||||
state: Instance, geometry: RaycastParams, sites: {Sites.Site}, startedAt: number,
|
||||
marker: (Sites.Site) -> Marker, score: (Side, number) -> (), status: (string) -> (),
|
||||
contribute: ((Player, string, number) -> ())?,
|
||||
}
|
||||
type Capture = {
|
||||
step: ({Fighter}, number, number) -> (), hit: (Player, number, boolean) -> (),
|
||||
@@ -221,6 +222,7 @@ function HotPoint.start(config: Config): Capture
|
||||
for _, fighter in fighters do
|
||||
if not isInside(fighter, site.position) then continue end
|
||||
table.insert(inside, fighter)
|
||||
if config.contribute then config.contribute(fighter.player, "holdSeconds", dt) end
|
||||
if fighter.side == "Blue" then blue += 1 else orange += 1 end
|
||||
end
|
||||
local remaining = math.ceil(movesAt - now)
|
||||
@@ -254,6 +256,9 @@ function HotPoint.start(config: Config): Capture
|
||||
capturedSide, capturedAt = side, now
|
||||
movesAt = now + COLLAPSE_SECONDS + CAPTURE_NOTICE_SECONDS + NEXT_POINT_WARNING_SECONDS
|
||||
config.score(side, 1)
|
||||
if config.contribute then
|
||||
for player in capturers do config.contribute(player, "captures", 1) end
|
||||
end
|
||||
clearCapture()
|
||||
publish(nil, 0, nil)
|
||||
config.status("")
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
--!strict
|
||||
local Siege = require(script.Parent.Parent:WaitForChild("CitadelAssaultConfig") :: ModuleScript)
|
||||
export type ModeProfile = {
|
||||
id: string, roundSeconds: number, briefingSeconds: number, countdownSeconds: number,
|
||||
finalPushSeconds: number, respawnDelay: number, spawnProtection: number,
|
||||
goal: string, rules: {string}, scoreMultiplierInFinalPush: number,
|
||||
}
|
||||
local ROUND_SECONDS = 300
|
||||
local function profile(id: string, goal: string, rules: {string}, roundSeconds: number?): ModeProfile
|
||||
assert(#rules == 3, id .. ": нужно ровно три правила")
|
||||
return table.freeze({
|
||||
id = id, roundSeconds = roundSeconds or ROUND_SECONDS, briefingSeconds = 5, countdownSeconds = 3,
|
||||
finalPushSeconds = 30, respawnDelay = 2, spawnProtection = 2,
|
||||
goal = goal, rules = table.freeze(rules), scoreMultiplierInFinalPush = 1,
|
||||
})
|
||||
end
|
||||
local profiles: {[string]: ModeProfile} = {
|
||||
TeamDeathmatch = profile("TeamDeathmatch", "Устраните больше соперников, чем они вас.",
|
||||
{"Каждое устранение — 1 очко", "После гибели вы возрождаетесь", "При равном счёте — ничья"}),
|
||||
HotPoint = profile("HotPoint", "Захватите активную зону раньше соперников.",
|
||||
{"Оставайтесь в круге 10 секунд", "С союзником захват в 1,5 раза быстрее", "Соперник оспаривает захват"}),
|
||||
Domination = profile("Domination", "Удерживайте больше точек, чем соперники.",
|
||||
{"Точка берётся за 3 секунды без соперников", "Каждая ваша точка — 1 очко в секунду", "Соперники в круге прерывают захват"}),
|
||||
CaptureFlag = profile("CaptureFlag", "Принесите флаг с крыши на свою базу.",
|
||||
{"Флаг может взять любой игрок", "Упавший флаг лежит 20 секунд", "Доставка — 1 очко"}),
|
||||
TrophyHunt = profile("TrophyHunt", "Соберите жетоны и сдайте их на базе.",
|
||||
{"Жетон выпадает после устранения", "При гибели ваши жетоны выпадают", "Каждый сданный жетон — 1 очко"}),
|
||||
Siege = profile("Siege", "В атаке берите рубежи, в защите удерживайте их.",
|
||||
{"Рубежи берутся по очереди", "Удерживайте круг 4 секунды", "В середине матча команды меняются ролями"}, Siege.MATCH_DURATION),
|
||||
OneLife = profile("OneLife", "Выиграйте три мини-раунда.",
|
||||
{"В мини-раунде одна жизнь", "Выигрывает команда с большим числом живых", "Мини-раунд длится до 45 секунд"}),
|
||||
HuntLeader = profile("HuntLeader", "Устраните лидера соперников и защитите своего.",
|
||||
{"Обычное устранение — 1 очко", "Лидер соперников — 3 очка", "После гибели лидера назначается новый"}),
|
||||
}
|
||||
return table.freeze(profiles)
|
||||
@@ -0,0 +1,10 @@
|
||||
--!strict
|
||||
return table.freeze({
|
||||
safeSpawnDistance = 32,
|
||||
CameraShake = false,
|
||||
lateBriefingSeconds = 2,
|
||||
startBannerSeconds = 1.15,
|
||||
finalBannerSeconds = 3,
|
||||
finalTickSeconds = 10,
|
||||
mvpWeights = table.freeze({kills = 1, captures = 3, holdSeconds = .1, deliveries = 4, tokensBanked = 1, leaderKills = 3, deaths = -.25}),
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
--!strict
|
||||
local Stage = {}
|
||||
|
||||
function Stage.combatAllowed(state: Instance): boolean
|
||||
local stage = state:GetAttribute("RoundStage")
|
||||
return stage == nil or stage == "Live" or stage == "FinalPush"
|
||||
end
|
||||
|
||||
return table.freeze(Stage)
|
||||
@@ -6,7 +6,35 @@ local function clock(seconds: number): string
|
||||
return string.format("%d:%02d", math.floor(seconds / 60), math.floor(seconds % 60))
|
||||
end
|
||||
local function flagCarrier(name: string): string return name .. " несёт флаг" end
|
||||
local round = table.freeze({
|
||||
mode = "РЕЖИМ", fight = "В БОЙ!", final = "ФИНАЛЬНЫЙ РЫВОК", swap = "СМЕНА РОЛЕЙ",
|
||||
attack = "Вы атакуете", defend = "Вы защищаете", respawn = "ВОЗРОЖДЕНИЕ · %d",
|
||||
untilStart = "ДО НАЧАЛА БОЯ", scoreReason = "Победа по командному счёту", drawReason = "Команды набрали поровну очков",
|
||||
mvp = "MVP · %s", contribution = "ВАШ ВКЛАД · %s",
|
||||
highlightOrder = {"captures", "deliveries", "tokensBanked", "leaderKills", "holdSeconds", "kills"},
|
||||
stats = {kills = "Устранения", deaths = "Смерти", captures = "Захваты", holdSeconds = "В зоне, с",
|
||||
carries = "Подборы флага", deliveries = "Доставки", tokensBanked = "Сдано жетонов", leaderKills = "Устранено лидеров", wins = "Победы"},
|
||||
contributionKeys = {
|
||||
TeamDeathmatch = {"kills", "deaths"}, HotPoint = {"captures", "holdSeconds"}, Domination = {"captures", "holdSeconds"},
|
||||
CaptureFlag = {"carries", "deliveries"}, TrophyHunt = {"tokensBanked", "kills"}, Siege = {"captures", "holdSeconds"},
|
||||
OneLife = {"kills", "deaths"}, HuntLeader = {"leaderKills", "kills"},
|
||||
},
|
||||
tutorial = {
|
||||
TeamDeathmatch = "Держитесь рядом с союзниками.", HotPoint = "Шевроны укажут путь к активной зоне.",
|
||||
Domination = "Цвет круга показывает, кто держит точку.", CaptureFlag = "Сопровождайте своего носителя.",
|
||||
TrophyHunt = "Сдавайте жетоны, пока их не потеряли.", Siege = "Сверяйте этаж и видимость центра.",
|
||||
OneLife = "Выходите на бой вместе с командой.", HuntLeader = "Ищите метку над лидером соперников.",
|
||||
},
|
||||
finalPush = {
|
||||
TeamDeathmatch = "Последний шанс изменить счёт!", HotPoint = "Боритесь за последний захват!",
|
||||
Domination = "Каждая секунда на счету!", CaptureFlag = "Последний рывок к своей базе!",
|
||||
TrophyHunt = "Сдайте собранные жетоны!", Siege = "Время решающего штурма!",
|
||||
OneLife = "Сохраните бойцов до конца!", HuntLeader = "Защитите своего лидера!",
|
||||
},
|
||||
})
|
||||
|
||||
return table.freeze({
|
||||
round = round,
|
||||
team = team, clock = clock,
|
||||
bases = table.freeze({Blue = "БАЗА СИНИХ", Orange = "БАЗА ОРАНЖЕВЫХ"}),
|
||||
hotPoint = "ГОРЯЧАЯ ТОЧКА",
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--!strict
|
||||
export type Stage = "Briefing" | "Countdown" | "Live" | "FinalPush" | "Ended"
|
||||
local Timeline = {}
|
||||
function Timeline.liveAt(startedAt: number, briefing: number, countdown: number): number
|
||||
return startedAt + briefing + countdown
|
||||
end
|
||||
function Timeline.stage(startedAt: number, endsAt: number, briefing: number, countdown: number,
|
||||
finalPush: number, now: number): (Stage, number)
|
||||
local liveAt = Timeline.liveAt(startedAt, briefing, countdown)
|
||||
if now < startedAt + briefing then return "Briefing", startedAt + briefing end
|
||||
if now < liveAt then return "Countdown", liveAt end
|
||||
if now >= endsAt then return "Ended", endsAt end
|
||||
if now >= endsAt - finalPush then return "FinalPush", endsAt end
|
||||
return "Live", math.max(liveAt, endsAt - finalPush)
|
||||
end
|
||||
return table.freeze(Timeline)
|
||||
@@ -7,6 +7,8 @@ local Common = require(script.Parent.Common)
|
||||
local Scoring = require(script.Parent.Scoring)
|
||||
local Events = require(script.Parent.Events)
|
||||
local Janitor = require(script.Parent.Janitor)
|
||||
local Stats = require(script.Parent.Stats)
|
||||
local Profiles = require(ReplicatedStorage.Hunter.ModeProfiles)
|
||||
local Context = {}
|
||||
|
||||
function Context.collect(members: {Player}): {Types.Fighter}
|
||||
@@ -33,24 +35,22 @@ function Context.create(config: Types.Config, mode: Types.Mode, legacy: RemoteEv
|
||||
folder.Name = "MatchObjectives"
|
||||
folder.Parent = world
|
||||
local janitor = Janitor.new()
|
||||
local contributions: {[number]: {[string]: number}} = {}
|
||||
state:SetAttribute("ObjectiveStatus", "")
|
||||
state:SetAttribute("ResultReason", nil)
|
||||
return {
|
||||
arena = config.arena, rule = config.rule, state = state, liveAt = config.now, duration = config.duration,
|
||||
world = world, geometry = geometry, map = map, folder = folder, janitor = janitor,
|
||||
members = config.members, bench = config.bench, deploy = config.deploy, balanceWaiting = config.balanceWaiting,
|
||||
scoring = Scoring.new(state, function(_, points, reason, player)
|
||||
if not reason or not player then return end
|
||||
local stats = contributions[player.UserId] or {}
|
||||
stats[reason] = (stats[reason] or 0) + points
|
||||
contributions[player.UserId] = stats
|
||||
end),
|
||||
scoring = Scoring.new(state, nil, Profiles[config.rule].scoreMultiplierInFinalPush),
|
||||
contribute = Stats.add,
|
||||
events = Events.new(config.members),
|
||||
status = function(value)
|
||||
if state:GetAttribute("ObjectiveStatus") ~= value then state:SetAttribute("ObjectiveStatus", value) end
|
||||
end,
|
||||
setStage = function(stage) state:SetAttribute("RoundStage", stage) end,
|
||||
setStage = function(stage, stageEndsAt)
|
||||
if stageEndsAt then state:SetAttribute("StageEndsAt", stageEndsAt) end
|
||||
state:SetAttribute("RoundStage", stage)
|
||||
end,
|
||||
cue = function(fighters, captured, side)
|
||||
for _, fighter in fighters do
|
||||
if captured or fighter.side == side then legacy:FireClient(fighter.player, captured) end
|
||||
|
||||
@@ -120,6 +120,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local base = if fighter.side == "Blue" then map.blue else map.orange
|
||||
if Common.boundsAt(fighter.root.Position, base, HotPoint.Radius, 7) then
|
||||
ctx.scoring.add(fighter.side, 1, Kinds.FlagScored, fighter.player)
|
||||
ctx.contribute(fighter.player, "deliveries", 1)
|
||||
ctx.events.fire(Kinds.FlagScored, {side = fighter.side, userId = fighter.player.UserId})
|
||||
ctx.cue(fighters, true, nil)
|
||||
putFlag(flag, flag.marker.origin, 0)
|
||||
@@ -140,6 +141,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
for _, fighter in fighters do
|
||||
if Common.boundsAt(fighter.root.Position, at, 5.5, 6.5) and Common.visibleAt(fighter, at, geometry) then
|
||||
pickUpFlag(flag, fighter)
|
||||
ctx.contribute(fighter.player, "carries", 1)
|
||||
ctx.events.fire(Kinds.FlagPicked, {side = fighter.side, userId = fighter.player.UserId, text = fighter.player.DisplayName})
|
||||
ctx.cue(fighters, false, fighter.side)
|
||||
ctx.status(Strings.flagCarrier(fighter.player.DisplayName))
|
||||
|
||||
@@ -19,14 +19,17 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
zone.marker.label.Text = key .. " · " .. site.name
|
||||
table.insert(zones, zone)
|
||||
end
|
||||
local function presence(fighters: {Fighter}, zone: Common.Zone, geometry: RaycastParams): (boolean, boolean)
|
||||
local function presence(fighters: {Fighter}, zone: Common.Zone, geometry: RaycastParams, dt: number): (boolean, boolean, {Fighter})
|
||||
local blue, orange = false, false
|
||||
local inside: {Fighter} = {}
|
||||
for _, fighter in fighters do
|
||||
if Zones.classify(fighter.root.Position, zone.site.position, SPEC, geometry) == "Inside" then
|
||||
table.insert(inside, fighter)
|
||||
ctx.contribute(fighter.player, "holdSeconds", dt)
|
||||
if fighter.side == "Blue" then blue = true else orange = true end
|
||||
end
|
||||
end
|
||||
return blue, orange
|
||||
return blue, orange, inside
|
||||
end
|
||||
local geometry = ctx.geometry
|
||||
local nextScore = ctx.liveAt + 1
|
||||
@@ -35,7 +38,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
if scoreNow then nextScore = now + 1 end
|
||||
local ownedBlue, ownedOrange = 0, 0
|
||||
for index, zone in zones do
|
||||
local b, o = presence(fighters, zone, geometry)
|
||||
local b, o, inside = presence(fighters, zone, geometry, dt)
|
||||
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
|
||||
@@ -46,6 +49,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
if zone.progress >= 3 then
|
||||
local previous = zone.owner
|
||||
zone.owner, zone.progress = side, 0
|
||||
for _, fighter in inside do ctx.contribute(fighter.player, "captures", 1) end
|
||||
local payload = {side = side, index = index, text = zone.marker.label.Text, value = now - ctx.liveAt}
|
||||
ctx.events.fire(Kinds.ZoneCaptured, payload)
|
||||
if previous then ctx.events.fire(Kinds.ZoneLost, {side = previous, index = index, text = payload.text}) end
|
||||
|
||||
@@ -19,7 +19,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
ctx.scoring.add(side, points, Kinds.ZoneCaptured)
|
||||
ctx.events.fire(Kinds.ZoneCaptured, {side = side, text = Strings.hotPoint})
|
||||
end,
|
||||
status = ctx.status,
|
||||
status = ctx.status, contribute = ctx.contribute,
|
||||
})
|
||||
return Common.instance(ctx, {
|
||||
step = function(now, dt, fighters, elapsed) capture.step(fighters, now, elapsed or dt); return false end,
|
||||
|
||||
@@ -56,6 +56,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local bonus = leaders[target] == victim
|
||||
ctx.scoring.add(side, if bonus then 3 else 1, if bonus then Kinds.LeaderDown else "Elimination", player)
|
||||
if bonus then
|
||||
ctx.contribute(player, "leaderKills", 1)
|
||||
clearLeader(target)
|
||||
ctx.events.fire(Kinds.LeaderDown, {side = side, userId = player.UserId, text = victim.DisplayName})
|
||||
end
|
||||
|
||||
@@ -48,6 +48,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
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)
|
||||
hadSiegeSwap = true
|
||||
for _, z in zones do z.marker.body.Parent = nil end
|
||||
siegeSide, siegeIndex, siegeProgress = Common.opposite(siegeSide), 1, 0
|
||||
@@ -76,6 +77,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
ctx.status(Strings.siegeSwap)
|
||||
return false
|
||||
end
|
||||
if state:GetAttribute("RoundStage") == "RoleSwap" then ctx.setStage("Live") end
|
||||
local attacker = Strings.team(siegeSide)
|
||||
local zone = zones[siegeIndex]
|
||||
data:SetAttribute("Index", siegeIndex)
|
||||
@@ -87,10 +89,17 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
end
|
||||
zone.marker.body.Parent = folder
|
||||
local attack, defense = false, false
|
||||
local attackers: {Player} = {}
|
||||
for _, fighter in fighters do
|
||||
local reason = Zones.classify(fighter.root.Position, zone.site.position, SPEC, geometry)
|
||||
if reason == "Inside" then
|
||||
if fighter.side == siegeSide then attack = true else defense = true end
|
||||
ctx.contribute(fighter.player, "holdSeconds", dt)
|
||||
if fighter.side == siegeSide then
|
||||
attack = true
|
||||
table.insert(attackers, fighter.player)
|
||||
else
|
||||
defense = true
|
||||
end
|
||||
end
|
||||
fighter.player:SetAttribute("CitadelZone", reason)
|
||||
end
|
||||
@@ -114,6 +123,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
Common.paint(zone.marker, if phase == "Contested" then Common.orange else Common.blue)
|
||||
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
|
||||
ctx.events.fire(Kinds.ZoneCaptured, {side = siegeSide, index = siegeIndex, text = zone.site.name, value = elapsed - attackStart})
|
||||
ctx.cue(fighters, true, nil)
|
||||
siegeCaptureStarted = false
|
||||
|
||||
@@ -55,6 +55,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local amount = carried[f.player]
|
||||
if amount and Common.boundsAt(f.root.Position, if f.side == "Blue" then map.blue else map.orange, HotPoint.Radius, 7) then
|
||||
ctx.scoring.add(f.side, amount, Kinds.TokensBanked, f.player)
|
||||
ctx.contribute(f.player, "tokensBanked", amount)
|
||||
ctx.events.fire(Kinds.TokensBanked, {side = f.side, userId = f.player.UserId, value = amount})
|
||||
ctx.cue(fighters, true, nil)
|
||||
carried[f.player] = nil
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
--!strict
|
||||
local RoundState = {}
|
||||
type Movement = {humanoid: Humanoid, root: BasePart, walk: number, jumpHeight: number, jumpPower: number, wasAnchored: boolean}
|
||||
local frozen: {[Player]: Movement} = {}
|
||||
|
||||
function RoundState.thaw(player: Player)
|
||||
local old = frozen[player]
|
||||
if not old then return end
|
||||
frozen[player] = nil
|
||||
old.root.Anchored = old.wasAnchored
|
||||
if old.humanoid.WalkSpeed == 0 then old.humanoid.WalkSpeed = old.walk end
|
||||
if old.humanoid.JumpHeight == 0 then old.humanoid.JumpHeight = old.jumpHeight end
|
||||
if old.humanoid.JumpPower == 0 then old.humanoid.JumpPower = old.jumpPower end
|
||||
end
|
||||
|
||||
function RoundState.freeze(player: Player, character: Model, humanoid: Humanoid)
|
||||
local root = character:FindFirstChild("HumanoidRootPart")
|
||||
if not root or not root:IsA("BasePart") then return end
|
||||
if frozen[player] and frozen[player].root == root then return end
|
||||
RoundState.thaw(player)
|
||||
frozen[player] = {humanoid = humanoid, root = root, walk = humanoid.WalkSpeed,
|
||||
jumpHeight = humanoid.JumpHeight, jumpPower = humanoid.JumpPower, wasAnchored = root.Anchored}
|
||||
root.AssemblyLinearVelocity = Vector3.zero
|
||||
root.AssemblyAngularVelocity = Vector3.zero
|
||||
root.Anchored = true
|
||||
humanoid.WalkSpeed = 0
|
||||
humanoid.JumpHeight = 0
|
||||
humanoid.JumpPower = 0
|
||||
end
|
||||
|
||||
function RoundState.clearShield(player: Player)
|
||||
player:SetAttribute("SpawnShield", nil)
|
||||
local character = player.Character
|
||||
local old = character and character:FindFirstChild("RoundSpawnShield")
|
||||
if old then old:Destroy() end
|
||||
end
|
||||
|
||||
function RoundState.shield(player: Player, character: Model, seconds: number)
|
||||
RoundState.clearShield(player)
|
||||
if seconds <= 0 then return end
|
||||
local untilAt = workspace:GetServerTimeNow() + seconds
|
||||
local field = Instance.new("ForceField")
|
||||
field.Name = "RoundSpawnShield"
|
||||
field.Visible = false
|
||||
field.Parent = character
|
||||
player:SetAttribute("SpawnShield", untilAt)
|
||||
task.delay(seconds, function()
|
||||
field:Destroy()
|
||||
if player:GetAttribute("SpawnShield") == untilAt then player:SetAttribute("SpawnShield", nil) end
|
||||
end)
|
||||
end
|
||||
|
||||
return RoundState
|
||||
@@ -1,12 +1,13 @@
|
||||
--!strict
|
||||
local Types = require(script.Parent.Types)
|
||||
local Scoring = {}
|
||||
function Scoring.new(state: Instance, onAdd: ((Types.Side, number, string?, Player?) -> ())?): Types.Scoring
|
||||
function Scoring.new(state: Instance, onAdd: ((Types.Side, number, string?, Player?) -> ())?, finalMultiplier: number?): Types.Scoring
|
||||
local score: {[Types.Side]: number} = {Blue = 0, Orange = 0}
|
||||
state:SetAttribute("BlueScore", 0)
|
||||
state:SetAttribute("OrangeScore", 0)
|
||||
return {
|
||||
add = function(side, points, reason, credit)
|
||||
if state:GetAttribute("RoundStage") == "FinalPush" then points *= finalMultiplier or 1 end
|
||||
score[side] += points
|
||||
state:SetAttribute(side .. "Score", score[side])
|
||||
if onAdd then onAdd(side, points, reason, credit) end
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
--!strict
|
||||
export type Row = {userId: number, stats: {[string]: number}}
|
||||
local Stats = {}
|
||||
local byPlayer: {[Player]: {[string]: number}} = {}
|
||||
|
||||
function Stats.reset()
|
||||
table.clear(byPlayer)
|
||||
end
|
||||
|
||||
function Stats.add(player: Player, key: string, amount: number)
|
||||
local record = byPlayer[player]
|
||||
if not record then
|
||||
record = {}
|
||||
byPlayer[player] = record
|
||||
end
|
||||
record[key] = (record[key] or 0) + amount
|
||||
end
|
||||
|
||||
function Stats.get(player: Player): {[string]: number}
|
||||
return table.clone(byPlayer[player] or {})
|
||||
end
|
||||
|
||||
function Stats.remove(player: Player)
|
||||
byPlayer[player] = nil
|
||||
end
|
||||
|
||||
function Stats.mvp(rows: {Row}, weights: {[string]: number}): number?
|
||||
local best: number? = nil
|
||||
local bestScore = -math.huge
|
||||
for _, row in rows do
|
||||
local score = 0
|
||||
for key, weight in weights do score += (row.stats[key] or 0) * weight end
|
||||
if score > bestScore or (score == bestScore and best ~= nil and row.userId < best) then
|
||||
best, bestScore = row.userId, score
|
||||
end
|
||||
end
|
||||
return best
|
||||
end
|
||||
|
||||
return Stats
|
||||
@@ -13,7 +13,8 @@ export type ModeContext = {
|
||||
arena: string, rule: string, state: Instance, liveAt: number, duration: number, world: Model,
|
||||
geometry: RaycastParams, folder: Folder, map: Sites.Map?,
|
||||
members: () -> {Player}, bench: (Player) -> (), deploy: (Player) -> (), balanceWaiting: () -> (),
|
||||
scoring: Scoring, events: Events, status: (string) -> (), setStage: (string) -> (), janitor: Janitor,
|
||||
scoring: Scoring, events: Events, status: (string) -> (), setStage: (string, number?) -> (), janitor: Janitor,
|
||||
contribute: (Player, string, number) -> (),
|
||||
cue: ({Fighter}, boolean, Side?) -> (), legacy: (Player, string) -> (),
|
||||
}
|
||||
export type ModeInstance = {
|
||||
|
||||
@@ -40,7 +40,9 @@ 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 },
|
||||
RoundCountdown = { id = "rbxassetid://113416294133952", volume = 0.48, speed = 1, near = 0, far = 0, group = "HUD" }, -- timer tick
|
||||
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
|
||||
ButtonHover = { id = "rbxassetid://84648433095796", volume = 0.22, speed = 1, near = 0, far = 0, group = "HUD" },
|
||||
ButtonPress = { id = "rbxassetid://121882355123711", volume = 0.27, speed = 1, near = 0, far = 0, group = "HUD" },
|
||||
FlagDropped = { id = "rbxassetid://2789428506", volume = 0.23, speed = .72, near = 0, far = 0, group = "HUD" },
|
||||
|
||||
@@ -45,6 +45,11 @@ local SAMPLE_STEP = 1 / 30
|
||||
local round = ReplicatedStorage:WaitForChild("ArenaRound")
|
||||
local ArenaModes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript)
|
||||
local Objectives = require(script.Parent:WaitForChild("ArenaObjectives") :: ModuleScript)
|
||||
local Hunter = ReplicatedStorage:WaitForChild("Hunter")
|
||||
local Stage = require(Hunter:WaitForChild("Stage") :: ModuleScript)
|
||||
local Runtime = script.Parent:WaitForChild("ModeRuntime")
|
||||
local Stats = require(Runtime:WaitForChild("Stats") :: ModuleScript)
|
||||
local RoundPlayer = require(Runtime:WaitForChild("PlayerRoundState") :: ModuleScript)
|
||||
local TrophyDrops = require(script.Parent:WaitForChild("TrophyDrops"))
|
||||
local PowerDrops = require(script.Parent:WaitForChild("PowerUpDrops"))
|
||||
local PowerEffects = require(script.Parent:WaitForChild("PowerUpEffects"))
|
||||
@@ -67,6 +72,7 @@ local function recordArenaKill(player: Player, victim: Player, origin: Vector3,
|
||||
if side ~= "Blue" and side ~= "Orange" then return nil end
|
||||
local scoreAttribute = side .. "Kills"
|
||||
local state = ArenaModes.state(round, mode)
|
||||
Stats.add(player, "kills", 1)
|
||||
player:SetAttribute("RoundKills", ((player:GetAttribute("RoundKills") :: number?) or 0) + 1)
|
||||
state:SetAttribute(scoreAttribute, ((state:GetAttribute(scoreAttribute) :: number?) or 0) + 1)
|
||||
local match = Objectives.current(mode)
|
||||
@@ -125,6 +131,8 @@ local function applyHit(
|
||||
player: Player, character: Model, shooter: Humanoid, model: Model, humanoid: Humanoid,
|
||||
victim: Player?, hit: ShotHistory.Hit, origin: Vector3, params: RaycastParams, mode: string
|
||||
)
|
||||
local now = workspace:GetServerTimeNow()
|
||||
if not Stage.combatAllowed(ArenaModes.state(round, mode)) then return end
|
||||
local eye = headOf(character)
|
||||
if player.Character ~= character or not inMode(player, mode) or shooter.Health <= 0
|
||||
or not model.Parent or humanoid.Health <= 0 or not hit.part:IsDescendantOf(model)
|
||||
@@ -139,6 +147,11 @@ local function applyHit(
|
||||
return
|
||||
end
|
||||
|
||||
local shield = victim and victim:GetAttribute("SpawnShield")
|
||||
if typeof(shield) == "number" and shield > now then
|
||||
broadcast(mode, remote, character, hit.position)
|
||||
return
|
||||
end
|
||||
local before = humanoid.Health
|
||||
PowerEffects.damage(model, humanoid, math.floor(damageFor(hit.zone) + .5), workspace:GetServerTimeNow())
|
||||
local damage = before - humanoid.Health
|
||||
@@ -173,7 +186,8 @@ remote.OnServerEvent:Connect(function(player: Player, direction: unknown, camera
|
||||
or timestamp ~= timestamp or math.abs(timestamp) == math.huge then return end
|
||||
local received = workspace:GetServerTimeNow()
|
||||
local mode = ArenaModes.of(player)
|
||||
if player:GetAttribute("InArena") ~= true or not ArenaModes.open(round, mode, received) then return end
|
||||
if player:GetAttribute("InArena") ~= true or not ArenaModes.open(round, mode, received)
|
||||
or not Stage.combatAllowed(ArenaModes.state(round, mode)) then return end
|
||||
local oneWay = math.clamp(player:GetNetworkPing() * .5, 0, .20)
|
||||
local ageLimit = math.clamp(oneWay + .10, .12, .30)
|
||||
if timestamp > received + .035 or timestamp < received - ageLimit then return end
|
||||
@@ -198,6 +212,7 @@ remote.OnServerEvent:Connect(function(player: Player, direction: unknown, camera
|
||||
world.FilterDescendantsInstances = excluded
|
||||
world.RespectCanCollide = true
|
||||
if obstruction(eye, cameraOrigin, world) then return end
|
||||
if player:GetAttribute("SpawnShield") ~= nil then RoundPlayer.clearShield(player) end
|
||||
|
||||
local origin, dir = cameraOrigin, direction.Unit
|
||||
local worldHit = workspace:Raycast(origin, dir * RANGE, world)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
--!strict
|
||||
return function(stats: any)
|
||||
assert(stats.mvp({}, {kills = 1}) == nil)
|
||||
local rows = {{userId = 9, stats = {kills = 2}}, {userId = 3, stats = {captures = 1}}, {userId = 2, stats = {kills = 2}}}
|
||||
assert(stats.mvp(rows, {kills = 1, captures = 3}) == 3)
|
||||
assert(stats.mvp(rows, {kills = 1}) == 2)
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
--!strict
|
||||
return function(timeline: any)
|
||||
local expected = {{0,"Briefing",5},{5,"Countdown",8},{8,"Live",78},{77.99,"Live",78},{78,"FinalPush",108},{108,"Ended",108}}
|
||||
for _, row in expected do
|
||||
local stage, boundary = timeline.stage(0,108,5,3,30,row[1])
|
||||
assert(stage == row[2] and boundary == row[3])
|
||||
end
|
||||
assert(timeline.stage(0,12,5,3,30,7) == "Countdown")
|
||||
assert(timeline.stage(0,12,5,3,30,8) == "FinalPush")
|
||||
end
|
||||
Reference in new issue
Block a user