Files
Hunter/scripts/HotPointGuide.client.luau
T
2026-11-29 19:27:36 +05:00

92 lines
4.1 KiB
Luau

--!strict
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, .78), 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", "К ГОРЯЧЕЙ ТОЧКЕ", 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 typeof(point) ~= "Vector3"
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()
if point ~= lastPoint or character ~= lastCharacter then
guideUntil = now + GUIDE_SECONDS
lastPoint, lastCharacter = point, 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 point
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 ("СМЕНА ТОЧКИ · %d С"):format(math.ceil(remaining)) else "К ГОРЯЧЕЙ ТОЧКЕ"
local floor = if delta.Y > 8 then " · ВЫШЕ" elseif delta.Y < -8 then " · НИЖЕ" else ""
detail.Text = ("%d СТУДОВ%s"):format(math.floor(delta.Magnitude + .5), floor)
end
local connection = RunService.RenderStepped:Connect(update)
script.Destroying:Once(function()
connection:Disconnect()
gui:Destroy()
end)