198 lines
8.7 KiB
Luau
198 lines
8.7 KiB
Luau
--!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 Vfx = require(script.Parent.ArenaVfx)
|
|
local Config = require(rs.Hunter.EffectsConfig)
|
|
local Input = game:GetService("UserInputService")
|
|
local mobile = Input.TouchEnabled and not Input.KeyboardEnabled
|
|
|
|
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 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)
|
|
Vfx.ring(at, 18, color, Config.FeedbackSeconds)
|
|
end
|
|
|
|
local lastFlagAura = 0
|
|
local roleColumnAt = 0
|
|
local bannerScale = Instance.new("UIScale", banner)
|
|
local bannerTween: Tween? = nil
|
|
local function adjustScale() bannerScale.Scale = UI.combatScale(gui) end
|
|
local resize = gui:GetPropertyChangedSignal("AbsoluteSize"):Connect(adjustScale)
|
|
adjustScale()
|
|
banner:GetPropertyChangedSignal("Visible"):Connect(function()
|
|
if bannerTween then bannerTween:Cancel() end
|
|
if not banner.Visible then return end
|
|
banner.Position = UDim2.fromScale(.5, .365)
|
|
bannerTween = TweenService:Create(banner, TweenInfo.new(Config.BannerMotionSeconds, Enum.EasingStyle.Quart), {Position = UDim2.fromScale(.5, .34)})
|
|
bannerTween: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)
|
|
local at = p.at
|
|
if typeof(at) == "Vector3" then
|
|
if kind == Kinds.ZoneCaptured and id == "HotPoint" then
|
|
Vfx.ring(at, 18, tone, Config.FeedbackSeconds, true)
|
|
Vfx.burst(at, tone, 30, true)
|
|
elseif kind == Kinds.ZoneCaptured and id == "Siege" then
|
|
Vfx.ring(at, 11, tone, Config.FeedbackSeconds)
|
|
Vfx.burst(at, tone, 24)
|
|
Vfx.flash(UI.Ink)
|
|
elseif kind == Kinds.ZoneStarted and id == "Siege" then
|
|
Vfx.column(at, UI.Gold)
|
|
elseif kind == Kinds.ZoneContested then
|
|
Vfx.ring(at, if id == "Siege" then 11 else 18, Config.Danger, .35)
|
|
elseif kind == Kinds.FlagDropped or kind == Kinds.FlagReturned or kind == Kinds.FlagScored or kind == Kinds.TokensBanked then
|
|
Vfx.burst(at, tone, 16)
|
|
elseif kind == Kinds.TokenDropped then
|
|
Vfx.burst(at, UI.Gold, 12)
|
|
end
|
|
end
|
|
if kind == Kinds.AllObjectivesTaken then Sounds.sound("AllTaken") end
|
|
if kind == Kinds.RoleSwap then Sounds.sound("RoleSwap") end
|
|
if kind == Kinds.FlagPicked then Sounds.sound("FlagPicked") end
|
|
if kind == Kinds.TokenPicked then Sounds.sound("TokenPick") end
|
|
if kind == Kinds.FlagScored then Sounds.sound("FlagScored") end
|
|
if kind == Kinds.TokensBanked and p.userId == player.UserId then Sounds.sound("TokensBanked") end
|
|
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 == "TeamDeathmatch" and kind == Kinds.Streak then
|
|
contour:SetAttribute("Accent",tone)
|
|
title.Text=string.format(S.teamDeathmatch.streak,p.text or "",p.value or 0)
|
|
bannerUntil=workspace:GetServerTimeNow()+2.7
|
|
if p.userId~=player.UserId then Sounds.sound("RoundStart") end
|
|
end
|
|
if id == "HuntLeader" and (kind == Kinds.LeaderAssigned or kind == Kinds.LeaderDown) then
|
|
local now=workspace:GetServerTimeNow()
|
|
if kind == Kinds.LeaderDown or now>=bannerUntil then
|
|
contour:SetAttribute("Accent",tone)
|
|
title.Text=if kind==Kinds.LeaderDown then S.leaderHints.down else string.format(S.leaderHints.new,p.text or "")
|
|
bannerUntil=now+2.5
|
|
end
|
|
if kind==Kinds.LeaderDown then
|
|
Sounds.sound("LeaderDown")
|
|
if typeof(p.at)=="Vector3" then showWave(p.at,tone) end
|
|
end
|
|
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 "MiniRoundStart" else "ZoneCaptured")
|
|
end
|
|
if id == "TrophyHunt" and p.userId == player.UserId then
|
|
if kind == Kinds.TokensBanked then
|
|
contour:SetAttribute("Accent", tone)
|
|
title.Text = string.format(S.trophyHints.banked, p.value or 0)
|
|
bannerUntil = workspace:GetServerTimeNow() + 2.7
|
|
elseif kind == Kinds.TokensLost then
|
|
pending = {key="th_lost",priority=60,text=S.trophyHints.lost,ttl=4}
|
|
end
|
|
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}
|
|
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 playing and mode == "CaptureFlag" and now - lastFlagAura >= .8 and match:GetAttribute("FlagCarrierSide") == nil then
|
|
local at = match:GetAttribute("FlagPosition")
|
|
if typeof(at) == "Vector3" then
|
|
Vfx.burst(at, UI.Gold, 14)
|
|
lastFlagAura = now
|
|
end
|
|
end
|
|
if playing and mode == "Siege" and now - roleColumnAt >= .75 then
|
|
local data = match:FindFirstChild("CitadelMatchState")
|
|
local at = data and data:GetAttribute("Point")
|
|
if data and typeof(at) == "Vector3" and data:GetAttribute("Phase") ~= "RoleSwap" then
|
|
local status = data:GetAttribute("Status")
|
|
local hue = if status == "Contested" then Config.Danger elseif status == "Idle" then UI.Gold
|
|
elseif status == "Decaying" then UI.Muted else tint(data:GetAttribute("Attacker"))
|
|
Vfx.column(at, hue)
|
|
roleColumnAt = now
|
|
end
|
|
end
|
|
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 (if mobile then Hints.compact(hint.text) else 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
|
|
resize:Disconnect()
|
|
if bannerTween then bannerTween:Cancel() end
|
|
gui:Destroy()
|
|
end)
|