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)
|
||||
Reference in new issue
Block a user