96 lines
4.4 KiB
Luau
96 lines
4.4 KiB
Luau
--!strict
|
|
local Text = require(game:GetService("ReplicatedStorage"):WaitForChild("Hunter"):WaitForChild("Strings") :: ModuleScript).interface.HotPointGuide
|
|
|
|
local Players = game:GetService("Players")
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local RunService = game:GetService("RunService")
|
|
local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript)
|
|
local Sounds = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript)
|
|
local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript)
|
|
|
|
local player = Players.LocalPlayer
|
|
local playerGui = player:WaitForChild("PlayerGui")
|
|
local match = Modes.state(ReplicatedStorage:WaitForChild("ArenaRound"), Modes.Procedural)
|
|
local WARNING_SECONDS = 5
|
|
local GUIDE_SECONDS = 7
|
|
|
|
local gui = Instance.new("ScreenGui")
|
|
gui.Name = "HotPointGuide"
|
|
gui.ResetOnSpawn = false
|
|
gui.DisplayOrder = 25
|
|
gui.Enabled = false
|
|
gui.Parent = playerGui
|
|
|
|
local panel = UI.plate(gui, "Direction", UDim2.fromScale(.5, .68), UDim2.new(.85, 0, 0, 60), UI.Outline)
|
|
panel.AnchorPoint = Vector2.new(.5, .5)
|
|
local sizeLimit = Instance.new("UISizeConstraint")
|
|
sizeLimit.MaxSize = Vector2.new(326, 60)
|
|
sizeLimit.Parent = panel
|
|
local contour = UI.contour(panel, UI.Blue)
|
|
local arrow = UI.label(panel, "Arrow", "▲", UDim2.fromOffset(12, 8), UDim2.fromOffset(44, 44), 29, UI.Blue)
|
|
local title = UI.label(panel, "Title", Text.kGoryacheyTochke, UDim2.fromOffset(63, 7), UDim2.new(1, -72, 0, 23), 18, UI.Ink)
|
|
title.TextXAlignment = Enum.TextXAlignment.Left
|
|
local detail = UI.label(panel, "Detail", "", UDim2.fromOffset(63, 31), UDim2.new(1, -72, 0, 20), 15, UI.Muted)
|
|
detail.TextXAlignment = Enum.TextXAlignment.Left
|
|
|
|
local guideUntil = 0
|
|
local lastPoint: Vector3? = nil
|
|
local lastCharacter: Model? = nil
|
|
local heardDeadline: number? = nil
|
|
|
|
local function update()
|
|
local character = player.Character
|
|
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
|
|
local root = character and character:FindFirstChild("HumanoidRootPart")
|
|
local camera = workspace.CurrentCamera
|
|
local point = match:GetAttribute("HotPointPosition")
|
|
local nextPoint = match:GetAttribute("HotPointNextPosition")
|
|
local deadline = match:GetAttribute("HotPointMovesAt")
|
|
if player:GetAttribute("InArena") ~= true or match:GetAttribute("Ruleset") ~= "HotPoint"
|
|
or match:GetAttribute("Phase") ~= "Round"
|
|
or not root or not root:IsA("BasePart") or not humanoid or humanoid.Health <= 0 or not camera then
|
|
gui.Enabled = false
|
|
lastPoint, lastCharacter, heardDeadline = nil, nil, nil
|
|
return
|
|
end
|
|
|
|
local now = workspace:GetServerTimeNow()
|
|
local activePoint = if typeof(point) == "Vector3" then point else nil
|
|
if activePoint ~= lastPoint or character ~= lastCharacter then
|
|
guideUntil = now + GUIDE_SECONDS
|
|
lastPoint, lastCharacter = activePoint, character
|
|
end
|
|
local remaining = if typeof(deadline) == "number" then deadline - now else math.huge
|
|
local moving = remaining > 0 and remaining <= WARNING_SECONDS and typeof(nextPoint) == "Vector3"
|
|
local target = if moving and typeof(nextPoint) == "Vector3" then nextPoint else activePoint
|
|
if not target then gui.Enabled = false; return end
|
|
local delta = target - root.Position
|
|
local flat = Vector3.new(delta.X, 0, delta.Z)
|
|
local summary = playerGui:FindFirstChild("ArenaResults")
|
|
local menu = playerGui:FindFirstChild("MainMenu")
|
|
local menusOpen = (summary and summary:GetAttribute("LiveScoreboardOpen") == true)
|
|
or (menu and menu:IsA("ScreenGui") and menu.Enabled)
|
|
local show = not menusOpen and (moving or (now < guideUntil and (flat.Magnitude > 18 or math.abs(delta.Y) > 8)))
|
|
gui.Enabled = show
|
|
if not show then return end
|
|
|
|
if moving and heardDeadline ~= deadline then
|
|
heardDeadline = deadline :: number
|
|
Sounds.sound("HotPointMove")
|
|
end
|
|
local tint = if moving then UI.Gold else UI.Blue
|
|
contour:SetAttribute("Accent", tint)
|
|
arrow.TextColor3 = tint
|
|
local localDirection = camera.CFrame:VectorToObjectSpace(flat)
|
|
arrow.Rotation = math.deg(math.atan2(localDirection.X, -localDirection.Z))
|
|
title.Text = if moving then (Text.novayaTochkaDS):format(math.ceil(remaining)) else Text.kGoryacheyTochke
|
|
local floor = if delta.Y > 8 then Text.vyshe elseif delta.Y < -8 then Text.nizhe else ""
|
|
detail.Text = (Text.dStudovS):format(math.floor(delta.Magnitude + .5), floor)
|
|
end
|
|
|
|
local connection = RunService.RenderStepped:Connect(update)
|
|
script.Destroying:Once(function()
|
|
connection:Disconnect()
|
|
gui:Destroy()
|
|
end)
|