Polish Domination zone control and HUD
This commit is contained in:
1 parent
c0b099e604
commit
d3648c485b
9 files changed
+271
-13
No files matched your search
@@ -0,0 +1,26 @@
|
||||
--!strict
|
||||
local rs = game:GetService("ReplicatedStorage")
|
||||
local Hints = require(rs.Hunter.Hints)
|
||||
local S = require(rs.Hunter.Strings).domination
|
||||
local Provider = {}
|
||||
|
||||
function Provider.candidates(match: Instance, player: Player): {Hints.Hint}
|
||||
local side = player:GetAttribute("ArenaTeam")
|
||||
local zone = player:GetAttribute("DominationZone")
|
||||
local out: {Hints.Hint} = {}
|
||||
local function add(key: string, text: string, priority: number)
|
||||
table.insert(out, {key = key, text = text, priority = priority, ttl = .4})
|
||||
end
|
||||
if zone == "Height" then add("dp_height", S.height, 80)
|
||||
elseif zone == "Blocked" then add("dp_blocked", S.blocked, 80) end
|
||||
for _, key in {"A", "B", "C"} do
|
||||
if match:GetAttribute("ZoneContested_" .. key) == true then add("dp_contest_" .. key, S.contested(key), 60)
|
||||
elseif match:GetAttribute("ZoneOwner_" .. key) == nil then add("dp_free_" .. key, S.free(key), 40) end
|
||||
end
|
||||
if typeof(side) == "string" then
|
||||
local rate = match:GetAttribute("ScoreRate_" .. side)
|
||||
if typeof(rate) == "number" and rate > 0 then add("dp_rate", S.hold(rate), 20) end
|
||||
end
|
||||
return out
|
||||
end
|
||||
return Provider
|
||||
@@ -0,0 +1,106 @@
|
||||
--!strict
|
||||
local Players = game:GetService("Players")
|
||||
local rs = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local UI = require(rs:WaitForChild("HunterUI") :: ModuleScript)
|
||||
local Sounds = require(rs:WaitForChild("SniperEffects") :: ModuleScript)
|
||||
local S = require(rs.Hunter.Strings)
|
||||
local Hints = require(rs.Hunter.Hints)
|
||||
local Kinds = require(rs.Hunter.EventKinds)
|
||||
local Router = require(script.Parent.EventRouter)
|
||||
|
||||
local player = Players.LocalPlayer
|
||||
local pg = player:WaitForChild("PlayerGui")
|
||||
local match = rs:WaitForChild("ArenaRound"):WaitForChild("Procedural")
|
||||
local providers = script.Parent:WaitForChild("HintProviders")
|
||||
local gui = Instance.new("ScreenGui")
|
||||
gui.Name, gui.DisplayOrder, gui.ResetOnSpawn = "ModeFeedback", 24, false
|
||||
gui.Parent = pg
|
||||
local banner = UI.plate(gui, "EventBanner", UDim2.fromScale(.5, .34), UDim2.new(.8, 0, 0, 58), UI.Gold)
|
||||
banner.AnchorPoint = Vector2.new(.5,.5)
|
||||
Instance.new("UISizeConstraint", banner).MaxSize = Vector2.new(430,58)
|
||||
local contour = UI.contour(banner, UI.Gold)
|
||||
local title = UI.label(banner,"Title","",UDim2.fromScale(.02,0),UDim2.fromScale(.96,1),24,UI.Ink)
|
||||
title.FontFace = UI.Display
|
||||
banner.Visible = false
|
||||
|
||||
local wave = Instance.new("Part")
|
||||
wave.Name = "LocalObjectiveWave"
|
||||
wave.Shape, wave.Material = Enum.PartType.Cylinder, Enum.Material.Neon
|
||||
wave.Anchored, wave.CanCollide, wave.CanTouch, wave.CanQuery = true, false, false, false
|
||||
wave.Transparency = 1
|
||||
wave.Parent = workspace
|
||||
local effect: Tween? = nil
|
||||
local pending: Hints.Hint? = nil
|
||||
local activeMode: string? = nil
|
||||
local provider: any = nil
|
||||
local selection = Hints.new()
|
||||
local bannerUntil = 0
|
||||
|
||||
local function tint(side: string?): Color3
|
||||
return if side == "Blue" then UI.Blue elseif side == "Orange" then UI.Orange else UI.Gold
|
||||
end
|
||||
|
||||
local function showWave(at: Vector3, color: Color3)
|
||||
if effect then effect:Cancel() end
|
||||
wave.CFrame = CFrame.new(at + Vector3.yAxis*.3) * CFrame.Angles(0, 0, math.pi/2)
|
||||
wave.Size = Vector3.new(.1,12,12)
|
||||
wave.Color, wave.Transparency = color, .64
|
||||
effect = TweenService:Create(wave,TweenInfo.new(.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),
|
||||
{Size=Vector3.new(.1,42,42),Transparency=1})
|
||||
effect:Play()
|
||||
end
|
||||
|
||||
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 == "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}
|
||||
elseif kind == Kinds.FullControl then
|
||||
contour:SetAttribute("Accent",tone)
|
||||
title.Text = S.domination.control
|
||||
bannerUntil = workspace:GetServerTimeNow()+3
|
||||
Sounds.sound("RoundStart")
|
||||
elseif kind == Kinds.ZoneCaptured and typeof(p.at)=="Vector3" then
|
||||
showWave(p.at,tone)
|
||||
end
|
||||
end
|
||||
end
|
||||
local subscriptions: {() -> ()} = {}
|
||||
for _, kind in Kinds do table.insert(subscriptions,Router.on(kind,function(p) event(kind,p) end)) end
|
||||
local elapsed = 0
|
||||
local heartbeat = RunService.Heartbeat:Connect(function(dt)
|
||||
elapsed += dt
|
||||
if elapsed < .12 then return end
|
||||
elapsed %= .12
|
||||
local now = workspace:GetServerTimeNow()
|
||||
local mode = match:GetAttribute("Ruleset")
|
||||
local playing = player:GetAttribute("InArena") == true and match:GetAttribute("Phase")=="Round"
|
||||
if not playing or typeof(mode)~="string" or mode=="Siege" then
|
||||
activeMode, provider, pending, bannerUntil = nil,nil,nil,0
|
||||
pg:SetAttribute("ModeHint",nil)
|
||||
banner.Visible = false
|
||||
return
|
||||
end
|
||||
if mode ~= activeMode then
|
||||
activeMode, selection = mode,Hints.new()
|
||||
local source = providers:FindFirstChild(mode)
|
||||
provider = if source and source:IsA("ModuleScript") then require(source) else nil
|
||||
end
|
||||
local candidates = if provider then provider.candidates(match,player) else {}
|
||||
if pending then table.insert(candidates,pending);pending=nil end
|
||||
local hint = Hints.pick(selection,candidates,now)
|
||||
pg:SetAttribute("ModeHint",if hint then hint.text else nil)
|
||||
local results = pg:FindFirstChild("ArenaResults")
|
||||
banner.Visible = now<bannerUntil and pg:GetAttribute("HunterVoting")~=true and (not results or results:GetAttribute("LiveScoreboardOpen")~=true)
|
||||
end)
|
||||
script.Destroying:Once(function()
|
||||
heartbeat:Disconnect()
|
||||
for _, remove in subscriptions do remove() end
|
||||
if effect then effect:Cancel() end
|
||||
wave:Destroy()
|
||||
gui:Destroy()
|
||||
end)
|
||||
Reference in new issue
Block a user