Polish Capture the Flag navigation and feedback

This commit is contained in:
Leshyi committed 2026-11-29 23:58:57 +05:00
1 parent 522344e34b
commit 9fb926537c
8 files changed
+203 -5

No files matched your search

@@ -0,0 +1,36 @@
--!strict
local rs = game:GetService("ReplicatedStorage")
local S = require(rs.Hunter.Strings).flagHints
local H = require(rs.Hunter.Hints)
local Provider = {}
function Provider.candidates(match: Instance, player: Player): {H.Hint}
local side = match:GetAttribute("FlagCarrierSide")
local at = match:GetAttribute("FlagReturnAt")
local own = player:GetAttribute("ArenaTeam")
local key, text, priority = "flag_roof", S.roof, 30
if player:GetAttribute("ArenaFlag") == true then key,text,priority = "flag_deliver",S.deliver,90
elseif typeof(side) == "string" and side ~= own then key,text,priority = "flag_enemy",S.enemy,80
elseif side == own and typeof(side) == "string" then key,text,priority = "flag_escort",S.escort,60
elseif typeof(at) == "number" then
key,text,priority = "flag_drop",string.format(S.dropped,math.max(0,math.ceil(at-workspace:GetServerTimeNow()))),70
end
return {{key=key,text=text,priority=priority,ttl=.4}}
end
function Provider.target(match: Instance, player: Player): (Vector3?, string?, string?)
local own = player:GetAttribute("ArenaTeam")
if player:GetAttribute("ArenaFlag") == true and typeof(own) == "string" then
local base = match:GetAttribute("FlagBase_" .. own)
return if typeof(base) == "Vector3" then base else nil, S.base, own
end
local point = match:GetAttribute("FlagPosition")
local carrierSide = match:GetAttribute("FlagCarrierSide")
local name = if carrierSide == own and typeof(carrierSide) == "string" then S.escortTitle else S.title
return if typeof(point) == "Vector3" then point else nil, name, if typeof(carrierSide) == "string" then carrierSide else nil
end
function Provider.highlight(_match: Instance, _viewer: Player, member: Player): boolean
return member:GetAttribute("ArenaFlag") == true
end
return Provider
@@ -56,6 +56,12 @@ local function event(kind: string, p: any)
if player:GetAttribute("InArena") ~= true or match:GetAttribute("Phase") ~= "Round" then return end
local id = match:GetAttribute("Ruleset")
local tone = tint(p.side)
if id == "CaptureFlag" and (kind == Kinds.FlagPicked or kind == Kinds.FlagScored) then
contour:SetAttribute("Accent", tone)
title.Text = if kind == Kinds.FlagScored then S.flagHints.scored
elseif p.side == player:GetAttribute("ArenaTeam") then S.flagHints.picked else S.flagHints.enemyPicked
bannerUntil = workspace:GetServerTimeNow() + 2.7
end
if id == "Domination" then
if kind == Kinds.ZoneLost and p.side == player:GetAttribute("ArenaTeam") then
pending = {key="dp_lost",priority=70,text=S.domination.lost(string.sub(p.text or "A",1,1)),ttl=4}
+107
View File
@@ -0,0 +1,107 @@
--!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)
local Stage = require(rs.Hunter.Stage)
local player = Players.LocalPlayer
local pg = player:WaitForChild("PlayerGui")
local match = rs:WaitForChild("ArenaRound"):WaitForChild("Procedural")
local providers = script.Parent.HintProviders
local gui = Instance.new("ScreenGui")
gui.Name, gui.DisplayOrder, gui.ResetOnSpawn, gui.Enabled = "ModeGuide", 25, false, false
gui.Parent = pg
local panel = UI.plate(gui,"Direction",UDim2.fromScale(.5,.73),UDim2.new(.85,0,0,60),UI.Outline)
panel.AnchorPoint = Vector2.new(.5,.5)
Instance.new("UISizeConstraint",panel).MaxSize = Vector2.new(326,60)
local contour = UI.contour(panel,UI.Gold)
local arrow = UI.label(panel,"Arrow","▲",UDim2.fromOffset(11,10),UDim2.fromOffset(40,38),26,UI.Gold)
local title = UI.label(panel,"Title","",UDim2.fromOffset(54,6),UDim2.new(1,-65,0,22),18,UI.Ink)
local detail = UI.label(panel,"Distance","",UDim2.fromOffset(54,30),UDim2.new(1,-65,0,22),15,UI.Muted)
title.TextXAlignment, detail.TextXAlignment = Enum.TextXAlignment.Left, Enum.TextXAlignment.Left
local markers = Instance.new("Folder")
markers.Name = "ModeTargets"
markers.Parent = workspace
local highlights: {[Player]: Highlight} = {}
local provider: any = nil
local currentMode: string? = nil
local current: Vector3? = nil
local function color(side: unknown): Color3
return if side=="Blue" then UI.Blue elseif side=="Orange" then UI.Orange else UI.Gold
end
local function refresh()
local id = match:GetAttribute("Ruleset")
local active = player:GetAttribute("InArena")==true and match:GetAttribute("Phase")=="Round" and Stage.combatAllowed(match)
if id~=currentMode then
currentMode = if typeof(id)=="string" then id else nil
local module = if typeof(id)=="string" then providers:FindFirstChild(id) else nil
provider = if module and module:IsA("ModuleScript") then require(module) else nil
end
local ready: {[Player]: boolean} = {}
if active and provider and provider.highlight then
for _, member in Players:GetPlayers() do
local character = member.Character
if member~=player and character and provider.highlight(match,player,member) then
ready[member]=true
local entry=highlights[member]
if not entry then
entry=Instance.new("Highlight")
entry.Name = "ModeTarget"
entry.DepthMode=Enum.HighlightDepthMode.AlwaysOnTop
entry.FillTransparency=.77
entry.OutlineTransparency=.16
entry.Parent=markers
highlights[member]=entry
end
entry.Adornee=character
local tone=color(member:GetAttribute("ArenaTeam"))
entry.FillColor,entry.OutlineColor=tone,tone
end
end
end
for member,entry in highlights do
if not ready[member] then entry:Destroy(); highlights[member]=nil end
end
local root=player.Character and player.Character.PrimaryPart
local menu=pg:FindFirstChild("MainMenu")
local results=pg:FindFirstChild("ArenaResults")
local blocked=pg:GetAttribute("HunterVoting")==true or (menu and menu:IsA("ScreenGui") and menu.Enabled)
or (results and results:GetAttribute("LiveScoreboardOpen")==true)
gui.Enabled=active and not blocked
panel.Visible=false
current=nil
if not gui.Enabled or not root or not provider or not provider.target then return end
local point,label,side=provider.target(match,player)
if not point or not label then return end
local delta=point-root.Position
current=point
panel.Visible=true
title.Text=label
local copy=S.hint.Siege
detail.Text=S.studs(delta.Magnitude)..(if delta.Y>8 then copy.above elseif delta.Y < -8 then copy.below else "")
local tint=color(side)
arrow.TextColor3=tint
contour:SetAttribute("Accent",tint)
end
local elapsed=0
local step=RunService.Heartbeat:Connect(function(dt)
elapsed+=dt
if elapsed < .14 then return end
elapsed%=.14
refresh()
end)
local render=RunService.RenderStepped:Connect(function()
local camera=workspace.CurrentCamera
local root=player.Character and player.Character.PrimaryPart
if not camera or not root or not current then return end
local d=current-root.Position
local v=camera.CFrame:VectorToObjectSpace(Vector3.new(d.X,0,d.Z))
arrow.Rotation=math.deg(math.atan2(v.X,-v.Z))
end)
script.Destroying:Once(function()
step:Disconnect()
render:Disconnect()
markers:Destroy()
gui:Destroy()
end)