Polish One Life mini-rounds and spectating
This commit is contained in:
1 parent
0c949fadf0
commit
ebe8db5359
12 files changed
+175
-17
No files matched your search
@@ -0,0 +1,10 @@
|
||||
--!strict
|
||||
local rs=game:GetService("ReplicatedStorage")
|
||||
local H=require(rs.Hunter.Hints)
|
||||
local S=require(rs.Hunter.Strings).lifeHints
|
||||
return {candidates=function(match: Instance, player: Player): {H.Hint}
|
||||
if match:GetAttribute("MiniRoundActive")==true and player:GetAttribute("ArenaWaiting")==true then
|
||||
return {{key="life_watch",text=S.wait,priority=60,ttl=.4}}
|
||||
end
|
||||
return {}
|
||||
end}
|
||||
@@ -62,6 +62,15 @@ local function event(kind: string, p: any)
|
||||
elseif p.side == player:GetAttribute("ArenaTeam") then S.flagHints.picked else S.flagHints.enemyPicked
|
||||
bannerUntil = workspace:GetServerTimeNow() + 2.7
|
||||
end
|
||||
if id == "OneLife" and (kind == Kinds.MiniRoundStarted or kind == Kinds.MiniRoundEnded) then
|
||||
contour:SetAttribute("Accent",tone)
|
||||
local copy=S.lifeHints
|
||||
local blue,orange=p.blue or 0,p.orange or 0
|
||||
title.Text=if kind == Kinds.MiniRoundStarted then string.format(copy.begin,p.index or 1,blue,orange)
|
||||
elseif not p.side then copy.draw else string.format(copy.win,S.team(p.side),math.max(blue,orange),math.min(blue,orange))
|
||||
bannerUntil=workspace:GetServerTimeNow()+2.8
|
||||
Sounds.sound(if kind==Kinds.MiniRoundStarted then "RoundStart" else "HotPointCaptured")
|
||||
end
|
||||
if id == "TrophyHunt" and p.userId == player.UserId then
|
||||
if kind == Kinds.TokensBanked then
|
||||
contour:SetAttribute("Accent", tone)
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
--!strict
|
||||
local Players=game:GetService("Players")
|
||||
local rs=game:GetService("ReplicatedStorage")
|
||||
local RunService=game:GetService("RunService")
|
||||
local UI=require(rs:WaitForChild("HunterUI") :: ModuleScript)
|
||||
local S=require(rs.Hunter.Strings).lifeHints
|
||||
local player=Players.LocalPlayer
|
||||
local pg=player:WaitForChild("PlayerGui")
|
||||
local match=rs:WaitForChild("ArenaRound"):WaitForChild("Procedural")
|
||||
local gui=Instance.new("ScreenGui")
|
||||
gui.Name,gui.DisplayOrder,gui.ResetOnSpawn,gui.Enabled="OneLifeSpectator",23,false,false
|
||||
gui.Parent=pg
|
||||
local panel=UI.plate(gui,"Spectator",UDim2.fromScale(.5,.84),UDim2.new(.85,0,0,56),UI.Blue)
|
||||
panel.AnchorPoint=Vector2.new(.5,.5)
|
||||
Instance.new("UISizeConstraint",panel).MaxSize=Vector2.new(360,56)
|
||||
local name=UI.label(panel,"Target","",UDim2.fromOffset(51,0),UDim2.new(1,-102,1,0),16,UI.Ink)
|
||||
name.TextTruncate=Enum.TextTruncate.AtEnd
|
||||
local targets: {Player}={}
|
||||
local selected: Player?=nil
|
||||
local control: Humanoid?=nil
|
||||
|
||||
local function assign()
|
||||
local camera=workspace.CurrentCamera
|
||||
local subject=selected and selected.Character and selected.Character:FindFirstChildOfClass("Humanoid")
|
||||
if not camera or not subject then return end
|
||||
control=subject
|
||||
camera.CameraSubject=subject
|
||||
name.Text=string.format(S.spectate, selected and selected.DisplayName or "")
|
||||
end
|
||||
|
||||
for index, sign in {-1,1} do
|
||||
local button=Instance.new("TextButton")
|
||||
button.Name=if sign<0 then "Previous" else "Next"
|
||||
button.AnchorPoint=Vector2.new(if sign<0 then 0 else 1,.5)
|
||||
button.Position=UDim2.new(index-1,if sign<0 then 7 else -7,.5,0)
|
||||
button.Size=UDim2.fromOffset(38,38)
|
||||
button.BackgroundColor3=UI.Panel
|
||||
button.TextColor3=UI.Ink
|
||||
button.TextSize=22
|
||||
button.Text=if sign<0 then "◀" else "▶"
|
||||
button.Parent=panel
|
||||
UI.bindButton(button, UI.Blue, true)
|
||||
button.Activated:Connect(function()
|
||||
if #targets<2 then return end
|
||||
local current=table.find(targets,selected :: Player) or 1
|
||||
selected=targets[(current+sign-1)%#targets+1]
|
||||
assign()
|
||||
end)
|
||||
end
|
||||
|
||||
local function reset()
|
||||
local camera=workspace.CurrentCamera
|
||||
local human=player.Character and player.Character:FindFirstChildOfClass("Humanoid")
|
||||
if camera and human and control and camera.CameraSubject==control then camera.CameraSubject=human end
|
||||
control,selected=nil,nil
|
||||
pg:SetAttribute("HunterSpectating",nil)
|
||||
gui.Enabled=false
|
||||
end
|
||||
|
||||
local elapsed=0
|
||||
local step=RunService.Heartbeat:Connect(function(dt)
|
||||
elapsed+=dt
|
||||
if elapsed<.15 then return end
|
||||
elapsed%=.15
|
||||
local active=player:GetAttribute("InArena")==true and player:GetAttribute("ArenaWaiting")==true
|
||||
and match:GetAttribute("Ruleset")=="OneLife" and match:GetAttribute("MiniRoundActive")==true
|
||||
if not active then if control or gui.Enabled then reset() end; return end
|
||||
local side=player:GetAttribute("ArenaTeam")
|
||||
table.clear(targets)
|
||||
for _, other in Players:GetPlayers() do
|
||||
local human=other.Character and other.Character:FindFirstChildOfClass("Humanoid")
|
||||
if other~=player and other:GetAttribute("ArenaTeam")==side and other:GetAttribute("InArena")==true
|
||||
and other:GetAttribute("ArenaWaiting")~=true and human and human.Health>0 then
|
||||
table.insert(targets,other)
|
||||
end
|
||||
end
|
||||
if #targets==0 then reset(); return end
|
||||
if not selected or not table.find(targets,selected) then selected=targets[1] end
|
||||
assign()
|
||||
local summary=pg:FindFirstChild("ArenaResults")
|
||||
local blocked=summary and summary:GetAttribute("LiveScoreboardOpen")==true
|
||||
gui.Enabled=not blocked
|
||||
pg:SetAttribute("HunterSpectating",if gui.Enabled then true else nil)
|
||||
end)
|
||||
script.Destroying:Once(function()
|
||||
step:Disconnect()
|
||||
reset()
|
||||
gui:Destroy()
|
||||
end)
|
||||
@@ -161,6 +161,8 @@ siegeBar.BackgroundColor3 = Color3.fromRGB(34, 45, 65)
|
||||
siegeBar.BorderSizePixel = 0
|
||||
siegeBar.Visible = false
|
||||
siegeBar.Parent = objective
|
||||
local lifeBoard = UI.label(objective,"OneLifeBoard","",UDim2.fromOffset(15,90),UDim2.new(1,-30,0,25),17,UI.Gold)
|
||||
lifeBoard.Visible=false
|
||||
local dominationChips = Instance.new("Frame")
|
||||
dominationChips.Name = "DominationChips"
|
||||
dominationChips.Position = UDim2.fromOffset(15, 88)
|
||||
@@ -458,6 +460,7 @@ local function refreshObjective()
|
||||
objective.Visible = visible
|
||||
siegeBar.Visible, siegeSteps.Visible, siegeChip.Visible = false, false, false
|
||||
dominationChips.Visible = false
|
||||
lifeBoard.Visible = false
|
||||
if visible then
|
||||
local rule = Rules.get(match:GetAttribute("Ruleset"))
|
||||
local accent = if player:GetAttribute("ArenaTeam") == "Orange" then orange else blue
|
||||
@@ -512,6 +515,16 @@ local function refreshObjective()
|
||||
siegeChip.TextColor3 = if zone == "Inside" then UI.Mint else UI.Gold
|
||||
end
|
||||
end
|
||||
if rule.id == "OneLife" then
|
||||
local function dots(points: number): string
|
||||
local n=math.clamp(math.floor(points),0,3)
|
||||
return string.rep("●",n)..string.rep("○",3-n)
|
||||
end
|
||||
lifeBoard.Visible=true
|
||||
lifeBoard.Text=string.format(HunterStrings.lifeHints.alive,(match:GetAttribute("MiniAliveBlue") :: number?) or 0,
|
||||
(match:GetAttribute("MiniAliveOrange") :: number?) or 0)
|
||||
.." "..dots((match:GetAttribute("BlueScore") :: number?) or 0).." / "..dots((match:GetAttribute("OrangeScore") :: number?) or 0)
|
||||
end
|
||||
if rule.id == "Domination" then
|
||||
dominationChips.Visible = true
|
||||
for key, slot in domSlots do
|
||||
@@ -540,7 +553,7 @@ local function refreshObjective()
|
||||
objectiveStatus.Visible = text ~= ""
|
||||
objectiveStatus.Text = text
|
||||
objectiveStatus.TextColor3 = accent:Lerp(ink, .3)
|
||||
local height = if siegeBar.Visible then 145 elseif dominationChips.Visible then 133 elseif objectiveStatus.Visible then 88 else 62
|
||||
local height = if siegeBar.Visible then 145 elseif dominationChips.Visible then 133 elseif lifeBoard.Visible then 120 elseif objectiveStatus.Visible then 88 else 62
|
||||
if height ~= objective.Size.Y.Offset then
|
||||
objective.Size = UDim2.fromOffset(widthOfCard, height)
|
||||
needsLayout = true
|
||||
@@ -1081,11 +1094,14 @@ local function updateClock()
|
||||
local arenaMode = currentMode()
|
||||
local inArena = player:GetAttribute("InArena") == true
|
||||
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 nextMini = match:GetAttribute("MiniRoundNextAt")
|
||||
local miniBeat = if typeof(nextMini)=="number" then math.ceil(nextMini-workspace:GetServerTimeNow()) else 0
|
||||
local beat = if stage=="Countdown" then introSeconds elseif miniBeat>0 and miniBeat<=3 then miniBeat else 0
|
||||
local counting = inArena and beat > 0
|
||||
local hadCountdown = countdown.Visible
|
||||
if counting then
|
||||
if not hadCountdown or introSeconds ~= lastIntroBeat then showCountdownBeat(introSeconds) end
|
||||
lastIntroBeat = introSeconds
|
||||
if not hadCountdown or beat ~= lastIntroBeat then showCountdownBeat(beat) end
|
||||
lastIntroBeat = beat
|
||||
elseif countdown.Visible then
|
||||
countdown.Visible = false
|
||||
clearCountdownBeat()
|
||||
@@ -1094,7 +1110,7 @@ local function updateClock()
|
||||
lastSecond, lastPhase, lastTeam, lastMode, lastInArena = seconds, phase, team, arenaMode, inArena
|
||||
lastStage = stage
|
||||
local rule = Rules.get(activeState():GetAttribute("Ruleset"))
|
||||
if inArena and (rule.id == "Siege" or rule.id == "Domination") then refreshObjective() end
|
||||
if inArena and (rule.id == "Siege" or rule.id == "Domination" or rule.id == "OneLife") then refreshObjective() end
|
||||
mode.Visible = true
|
||||
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 "ДО ГОЛОСОВАНИЯ")
|
||||
|
||||
@@ -111,7 +111,7 @@ RunService:BindToRenderStep(renderName, Enum.RenderPriority.Camera.Value + 2, fu
|
||||
local menuShown = menu ~= nil and menu.Enabled
|
||||
local resultsGui = playerGui:FindFirstChild("ArenaResults")
|
||||
local scoreboardShown = resultsGui ~= nil and resultsGui:GetAttribute("LiveScoreboardOpen") == true
|
||||
local votingShown = playerGui:GetAttribute("HunterVoting") == true
|
||||
local votingShown = playerGui:GetAttribute("HunterVoting") == true or playerGui:GetAttribute("HunterSpectating") == true
|
||||
local inArena = player:GetAttribute("InArena") == true
|
||||
UserInputService.MouseIconEnabled = not inArena or tunerShown or menuShown or scoreboardShown or votingShown
|
||||
if scoreboardShown or votingShown or (not inArena and not UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2)) then
|
||||
|
||||
@@ -6,11 +6,11 @@ export type ModeProfile = {
|
||||
goal: string, rules: {string}, scoreMultiplierInFinalPush: number,
|
||||
}
|
||||
local ROUND_SECONDS = 300
|
||||
local function profile(id: string, goal: string, rules: {string}, roundSeconds: number?): ModeProfile
|
||||
local function profile(id: string, goal: string, rules: {string}, roundSeconds: number?, finalPush: 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,
|
||||
finalPushSeconds = finalPush or 30, respawnDelay = 2, spawnProtection = 2,
|
||||
goal = goal, rules = table.freeze(rules), scoreMultiplierInFinalPush = 1,
|
||||
})
|
||||
end
|
||||
@@ -28,7 +28,7 @@ local profiles: {[string]: ModeProfile} = {
|
||||
Siege = profile("Siege", "В атаке берите рубежи, в защите удерживайте их.",
|
||||
{"Рубежи берутся по очереди", "Удерживайте круг 4 секунды", "В середине матча команды меняются ролями"}, Siege.MATCH_DURATION),
|
||||
OneLife = profile("OneLife", "Выиграйте три мини-раунда.",
|
||||
{"В мини-раунде одна жизнь", "Выигрывает команда с большим числом живых", "Мини-раунд длится до 45 секунд"}),
|
||||
{"В мини-раунде одна жизнь", "Выигрывает команда с большим числом живых", "Мини-раунд длится до 45 секунд"}, nil, 0),
|
||||
HuntLeader = profile("HuntLeader", "Устраните лидера соперников и защитите своего.",
|
||||
{"Обычное устранение — 1 очко", "Лидер соперников — 3 очка", "После гибели лидера назначается новый"}),
|
||||
}
|
||||
|
||||
@@ -67,6 +67,12 @@ local trophyHints = table.freeze({
|
||||
carry="У вас %d жетонов — сдайте их на базе!", near="Рядом жетоны — подберите их.",
|
||||
banked="СДАНО ЖЕТОНОВ ×%d", lost="Вы погибли — жетоны выпали.",
|
||||
})
|
||||
local lifeHints = table.freeze({
|
||||
wait = "Вы выбыли до следующего мини-раунда. Наблюдайте за союзниками.",
|
||||
spectate = "Наблюдаете: %s", begin = "ВПЕРЁД! · МИНИ-РАУНД %d · %d:%d",
|
||||
win = "%s выиграли мини-раунд (%d против %d)", draw = "МИНИ-РАУНД ВНИЧЬЮ",
|
||||
alive = "ЖИВЫ %d · %d",
|
||||
})
|
||||
local function flagCarrier(name: string): string return name .. " несёт флаг" end
|
||||
local round = table.freeze({
|
||||
mode = "РЕЖИМ", fight = "В БОЙ!", final = "ФИНАЛЬНЫЙ РЫВОК", swap = "СМЕНА РОЛЕЙ",
|
||||
@@ -102,6 +108,7 @@ return table.freeze({
|
||||
hotHints = hotHints,
|
||||
flagHints = flagHints,
|
||||
trophyHints = trophyHints,
|
||||
lifeHints = lifeHints,
|
||||
hint = table.freeze({Siege = siegeHints}),
|
||||
team = team, clock = clock,
|
||||
bases = table.freeze({Blue = "БАЗА СИНИХ", Orange = "БАЗА ОРАНЖЕВЫХ"}),
|
||||
|
||||
@@ -4,25 +4,30 @@ local Types = require(Runtime.Types)
|
||||
local Common = require(Runtime.Common)
|
||||
local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
|
||||
local Strings = require(game.ReplicatedStorage.Hunter.Strings)
|
||||
local Rules = require(Runtime.OneLifeRules)
|
||||
type Fighter = Types.Fighter
|
||||
|
||||
local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local lifeActive, miniNumber = false, 0
|
||||
local lifeEnds, nextMini = math.huge, ctx.liveAt + 2
|
||||
local lifeEnds, nextMini = math.huge, ctx.liveAt
|
||||
local state = ctx.state
|
||||
local function runOneLife(members: {Player}, fighters: {Fighter}, now: number): boolean
|
||||
if lifeActive then
|
||||
local b, o = 0, 0
|
||||
for _, f in fighters do if f.side == "Blue" then b += 1 else o += 1 end end
|
||||
state:SetAttribute("MiniAliveBlue", b)
|
||||
state:SetAttribute("MiniAliveOrange", o)
|
||||
if (b > 0 and o > 0) and now < lifeEnds then
|
||||
ctx.status(Strings.lifeActive(miniNumber, b, o, math.ceil(lifeEnds - now)))
|
||||
return false
|
||||
end
|
||||
local side: Types.Side? = if b == o then nil elseif b > o then "Blue" else "Orange"
|
||||
local side = Rules.winner(b,o)
|
||||
if side then ctx.scoring.add(side, 1, Kinds.MiniRoundEnded) end
|
||||
ctx.events.fire(Kinds.MiniRoundEnded, {side = side, index = miniNumber})
|
||||
if ctx.scoring.get("Blue") >= 3 or ctx.scoring.get("Orange") >= 3 then return true end
|
||||
state:SetAttribute("MiniRoundActive", false)
|
||||
ctx.events.fire(Kinds.MiniRoundEnded, {side = side, index = miniNumber, blue = b, orange = o})
|
||||
if Rules.finished(ctx.scoring.get("Blue"),ctx.scoring.get("Orange")) then return true end
|
||||
for _, p in members do ctx.bench(p) end
|
||||
lifeActive, nextMini = false, now + 4
|
||||
lifeActive, nextMini = false, now + Rules.INTERMISSION
|
||||
end
|
||||
if now >= nextMini then ctx.balanceWaiting() end
|
||||
local ready: {Player} = {}
|
||||
@@ -37,12 +42,16 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
if b and o and now >= nextMini then
|
||||
for _, p in ready do ctx.deploy(p) end
|
||||
miniNumber += 1
|
||||
lifeActive, lifeEnds = true, now + 45
|
||||
lifeActive, lifeEnds = true, now + Rules.DURATION
|
||||
state:SetAttribute("MiniRoundActive",true)
|
||||
state:SetAttribute("MiniRoundNextAt",nil)
|
||||
ctx.status(Strings.lifeStart(miniNumber))
|
||||
ctx.events.fire(Kinds.MiniRoundStarted, {index = miniNumber})
|
||||
ctx.events.fire(Kinds.MiniRoundStarted, {index = miniNumber, blue = ctx.scoring.get("Blue"), orange = ctx.scoring.get("Orange")})
|
||||
elseif not b or not o then
|
||||
state:SetAttribute("MiniRoundNextAt",nil)
|
||||
ctx.status(Strings.lifeWaiting)
|
||||
else
|
||||
state:SetAttribute("MiniRoundNextAt",nextMini)
|
||||
ctx.status(Strings.lifeNext(math.ceil(nextMini - now)))
|
||||
end
|
||||
return false
|
||||
@@ -50,6 +59,9 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
return Common.instance(ctx, {
|
||||
step = function(now, _, fighters) return runOneLife(ctx.members(), fighters, now) end,
|
||||
death = function(player) ctx.bench(player) end,
|
||||
destroy = function()
|
||||
for _, name in {"MiniRoundActive","MiniRoundNextAt","MiniAliveBlue","MiniAliveOrange"} do state:SetAttribute(name,nil) end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
--!strict
|
||||
local Rules = {WINS = 3, DURATION = 45, INTERMISSION = 4}
|
||||
function Rules.winner(blue: number, orange: number): ("Blue" | "Orange")?
|
||||
return if blue == orange then nil elseif blue > orange then "Blue" else "Orange"
|
||||
end
|
||||
function Rules.finished(blue: number, orange: number): boolean
|
||||
return math.max(blue, orange) >= Rules.WINS
|
||||
end
|
||||
return table.freeze(Rules)
|
||||
@@ -3,7 +3,7 @@ local Sites = require(script.Parent.Parent.ArenaObjectiveSites)
|
||||
export type Side = "Blue" | "Orange"
|
||||
export type Fighter = {player: Player, side: Side, root: BasePart}
|
||||
export type Audience = "All" | Side | {Player}
|
||||
export type EventPayload = {side: Side?, userId: number?, index: number?, value: number?, text: string?, at: Vector3?}
|
||||
export type EventPayload = {side: Side?, userId: number?, index: number?, value: number?, text: string?, at: Vector3?, blue: number?, orange: number?}
|
||||
export type Janitor = {give: ((() -> ()) | Instance | RBXScriptConnection) -> (), clean: () -> ()}
|
||||
export type Scoring = {add: (Side, number, string?, Player?) -> (), get: (Side) -> number}
|
||||
export type Events = {fire: (string, EventPayload?, Audience?) -> ()}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
--!strict
|
||||
return function(rules: any)
|
||||
assert(rules.winner(2,1)=="Blue" and rules.winner(1,2)=="Orange")
|
||||
assert(rules.winner(2,2)==nil and rules.winner(0,0)==nil)
|
||||
assert(rules.finished(3,1) and rules.finished(0,3) and not rules.finished(2,2))
|
||||
end
|
||||
Reference in new issue
Block a user