diff --git a/Hunter.rbxl b/Hunter.rbxl index 04e9580..7b21bc4 100644 Binary files a/Hunter.rbxl and b/Hunter.rbxl differ diff --git a/citadel.project.json b/citadel.project.json index 1c7788e..dfe4f73 100644 --- a/citadel.project.json +++ b/citadel.project.json @@ -28,6 +28,7 @@ "$ignoreUnknownInstances": true, "ArenaRoundHud": { "$path": "scripts/ArenaRoundHud.client.luau" }, "HealthBar": { "$path": "scripts/HealthBar.client.luau" }, + "ObjectiveArrows": { "$path": "scripts/ObjectiveArrows.client.luau" }, "OwnMovementAudio": { "$path": "scripts/OwnMovementAudio.client.luau" }, "ArenaClient": { "$path": "scripts/ArenaClient" } } diff --git a/docs/modes.md b/docs/modes.md new file mode 100644 index 0000000..a733c77 --- /dev/null +++ b/docs/modes.md @@ -0,0 +1,45 @@ +# Режимы Hunter + +Синие играют против оранжевых на процедурной арене. Общий профиль задаёт 5 секунд на брифинг, 3 на отсчёт, 300 на матч и 30 на финальный рывок. Обычное возрождение и защита после него занимают по 2 секунды. Индивидуальные настройки приведены ниже. Сервер рассчитывает счёт и состояние целей, клиент показывает события и воспроизводит сигналы. + +| Режим и профиль | Цель и правила | События и подсказки | Статистика | +| --- | --- | --- | --- | +| Командный бой · `TeamDeathmatch` | Больше устранений за матч. Устранение даёт очко, при равном счёте объявляется ничья. | Лента серий и подсказка о задаче в брифинге. | Командный счёт, убийства и смерти. | +| Горячая точка · `HotPoint` | Захватить текущую зону. Одному нужно 10 секунд, с союзником захват в 1,5 раза быстрее. Соперник оспаривает захват. После захвата цель перемещается. | Начало и оспаривание захвата, схлопывание кольца с дымом, уведомления о захвате и смене точки, указатель направления. | Очки команды и вклад в захват. | +| Три точки · `Domination` | Взять точку за 3 секунды без противника. Каждая удерживаемая точка даёт очко в секунду. | Захват, оспаривание, потеря и полный контроль. Подсказка сообщает состояние зоны. | Командные очки и вклад в контроль. | +| Захват флага · `CaptureFlag` | Забрать флаг с крыши и донести до своей базы. После смерти носителя флаг падает, через 20 секунд возвращается. Доставка даёт очко и возвращает флаг на крышу. | Подбор, падение, возврат и доставка. Маркер носителя и аура свободного флага. | Командный счёт и доставки флага. | +| Охота за жетонами · `TrophyHunt` | Собирать жетоны после устранений и сдавать на своей базе. Жетоны выпадают при гибели носителя. Сданный жетон даёт очко. | Подбор, выпадение, потеря и сдача. На панели виден запас, жетоны на земле мерцают перед исчезновением. | Командный счёт и число сданных жетонов. | +| Штурм · `Siege` | Атакующие удерживают круг 4 секунды и берут рубежи по очереди. Затем команды меняются ролями. Длительность задаёт `CitadelAssaultConfig.MATCH_DURATION`. | Захват рубежа, взятие всех рубежей, смена ролей. Указатель рубежа и подсказки о положении в зоне. | Число рубежей и времена захвата каждой стороны. | +| Одна жизнь · `OneLife` | Выиграть три мини-раунда. В каждом одна жизнь и до 45 секунд. Преимущество получает команда с большим числом живых. Финальный рывок отключён. | Начало и конец мини-раунда, подсказка об одной жизни. | Счёт мини-раундов, обычная статистика боя. | +| Охота на лидера · `HuntLeader` | Защитить своего лидера и устранить вражеского. Обычное устранение даёт одно очко, лидер даёт три. После смерти назначается новый лидер. | Назначение и гибель лидера, маркер цели. | Командные очки и устранения лидеров. | + +## Как добавить новый режим + +1. Добавить модуль в `scripts/ModeRuntime/Modes` с уникальным `id` и методами из `Types.Mode`. Использовать контекст режима для счёта и очистки. +2. Зарегистрировать режим в `MatchRules.All`. +3. Добавить профиль в `Hunter/ModeProfiles`. Указать цель, три правила и отклонения от общего тайминга. +4. Добавить тексты в `Hunter/Strings` и профиль режима. +5. Подключить провайдер подсказок через `Hunter/Hints` и проверить длину строки. +6. Описать события в `Hunter/EventKinds` и обработать их в `ArenaClient/ModeFeedback`. Для важных переходов использовать два канала из трёх. +7. Покрыть чистую логику тестами и прогнать полный матч, выход и вход, итоги и голосование в Studio. + +## QA этапа 4 + +✓ означает пройденную проверку, ☐ означает отсутствие прогона, — обозначает неприменимый сценарий. + +| Сценарий | TDM | HotPoint | Domination | CTF | Trophy | Siege | OneLife | Leader | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | +| Матч 2×2 до итогов и голосования | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | +| Выход среди раунда | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | +| Вход среди раунда | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | +| Смерть во время выполнения цели | — | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | +| Команда опустела | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | +| Брифинг блокирует стрельбу и движение | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | +| Начало и конец финального рывка | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | — | ☐ | +| Читаемость HUD и FPS в мобильном эмуляторе | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | +| Десять полных раундов и проверка соединений и Tween | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | ☐ | +| Десять серверных циклов запуска, первого шага и очистки без игроков | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | + +В одиночной сессии Play проверены модульные тесты бюджетов и подсказок. После 100 повторов кольца, столба и частиц число эмиттеров осталось 20. При 30 запросах одного звукового эффекта осталось 6 активных экземпляров. Проверка очистки на сервере подтверждает удаление папки целей и записи активного матча. + +Для завершения приёмки нужны четыре игрока, мобильный эмулятор с измерением FPS и полный прогон раундов. В исходниках остаются старые видимые строки, которые ещё предстоит перенести в `Strings` и профили. diff --git a/scripts/ArenaClient/ArenaVfx.luau b/scripts/ArenaClient/ArenaVfx.luau new file mode 100644 index 0000000..f8d6869 --- /dev/null +++ b/scripts/ArenaClient/ArenaVfx.luau @@ -0,0 +1,112 @@ +--!strict +local Players = game:GetService("Players") +local RS = game:GetService("ReplicatedStorage") +local TweenService = game:GetService("TweenService") +local Input = game:GetService("UserInputService") +local Config = require(RS.Hunter.EffectsConfig) +local Budget = require(RS.Hunter.EffectsBudget) +local profile = Budget.profile(Input.TouchEnabled, Input.KeyboardEnabled) +local localPlayer = Players.LocalPlayer +local root = Instance.new("Folder") +root.Name = "HunterClientVfx" +root.Parent = workspace +type Slot = {part: Part, tween: Tween?, effect: ParticleEmitter?} +local rotation = CFrame.Angles(0, 0, math.pi / 2) + +local function pool(name: string, size: number, particles: boolean): () -> Slot + local slots: {Slot} = {} + local cursor = 0 + for i = 1, size do + local part = Instance.new("Part") + part.Name = name + part.Anchored, part.CanCollide, part.CanQuery, part.CanTouch = true, false, false, false + part.CastShadow = false + part.Shape, part.Material, part.Transparency = Enum.PartType.Cylinder, Enum.Material.Neon, 1 + part.Size = Vector3.one + part.Parent = root + local emitter: ParticleEmitter? = nil + if particles then + emitter = Instance.new("ParticleEmitter") + emitter.Texture = "rbxasset://textures/particles/sparkles_main.dds" + emitter.Rate = 0 + emitter.Lifetime = NumberRange.new(.3, .65) + emitter.Speed = NumberRange.new(9, 24) + emitter.SpreadAngle = Vector2.new(145, 145) + emitter.Size = NumberSequence.new(.42, 0) + emitter.LightEmission, emitter.LightInfluence = 1, 0 + emitter.Parent = part + end + slots[i] = {part = part, effect = emitter, tween = nil} + end + return function() + cursor = cursor % size + 1 + local slot = slots[cursor] + if slot.tween then slot.tween:Cancel(); slot.tween = nil end + if slot.effect then slot.effect:Clear() end + slot.part.Transparency = 1 + return slot + end +end + +local rings = pool("Ring", profile.worldSlots, false) +local columns = pool("Column", profile.worldSlots, false) +local bursts = pool("Burst", math.min(profile.burstSlots, profile.maxEmitters), true) +local gui = Instance.new("ScreenGui") +gui.Name = "ArenaScreenVfx" +gui.DisplayOrder = 7 +gui.ResetOnSpawn = false +gui.Parent = localPlayer:WaitForChild("PlayerGui") +local flash = Instance.new("Frame") +flash.BorderSizePixel = 0 +flash.Size = UDim2.fromScale(1, 1) +flash.BackgroundTransparency = 1 +flash.Parent = gui +local flashTween: Tween? = nil + +local ArenaVfx = {} +local function animate(slot: Slot, seconds: number, props: {[string]: any}) + local tween = TweenService:Create(slot.part, TweenInfo.new(math.clamp(seconds, .05, .6), Enum.EasingStyle.Quad, Enum.EasingDirection.Out), props) + slot.tween = tween + tween:Play() +end + +function ArenaVfx.ring(at: Vector3, radius: number, color: Color3, seconds: number, inward: boolean?) + local slot = rings() + slot.part.CFrame = CFrame.new(at + Vector3.yAxis * .24) * rotation + local diameter = radius * 2 + local start = if inward then diameter else diameter * .55 + local finish = if inward then .1 else diameter * 1.6 + slot.part.Size = Vector3.new(.1, start, start) + slot.part.Color, slot.part.Transparency = color, .7 + animate(slot, seconds, {Size = Vector3.new(.1, finish, finish), Transparency = 1}) +end + +function ArenaVfx.burst(at: Vector3, color: Color3, count: number, smoke: boolean?) + local amount = Budget.particles(count, profile.scale) + if amount == 0 then return end + local slot = bursts() + slot.part.CFrame = CFrame.new(at + Vector3.yAxis) + local emitter = assert(slot.effect) + emitter.Texture = if smoke then "rbxasset://textures/particles/smoke_main.dds" else "rbxasset://textures/particles/sparkles_main.dds" + emitter.Size = if smoke then NumberSequence.new(2, 8) else NumberSequence.new(.42, 0) + emitter.Transparency = if smoke then NumberSequence.new(.35, 1) else NumberSequence.new(.06, 1) + emitter.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) + emitter:Emit(amount) +end + +function ArenaVfx.column(at: Vector3, color: Color3) + local slot = columns() + slot.part.CFrame = CFrame.new(at + Vector3.yAxis) * rotation + slot.part.Size = Vector3.new(1, 3, 3) + slot.part.Color, slot.part.Transparency = color, .72 + animate(slot, Config.FeedbackSeconds, {CFrame = CFrame.new(at + Vector3.yAxis * 22) * rotation, + Size = Vector3.new(44, 4, 4), Transparency = 1}) +end + +function ArenaVfx.flash(color: Color3) + if flashTween then flashTween:Cancel() end + flash.BackgroundColor3, flash.BackgroundTransparency = color, .93 + flashTween = TweenService:Create(flash, TweenInfo.new(.32), {BackgroundTransparency = 1}) + flashTween:Play() +end +return ArenaVfx diff --git a/scripts/ArenaClient/BriefingController.client.luau b/scripts/ArenaClient/BriefingController.client.luau index 9929948..1ec16f5 100644 --- a/scripts/ArenaClient/BriefingController.client.luau +++ b/scripts/ArenaClient/BriefingController.client.luau @@ -189,6 +189,7 @@ local function update() elseif stage == "Live" or stage == "FinalPush" then if final then showBanner(Strings.round.final, Strings.round.finalPush[id] or "", now + Config.finalBannerSeconds) + Sounds.sound("FinalPush") elseif oldStage == "Countdown" and wasInArena then showBanner(Strings.round.fight, "", now + Config.startBannerSeconds) Sounds.sound("RoundStart") diff --git a/scripts/ArenaClient/CitadelGuide.client.luau b/scripts/ArenaClient/CitadelGuide.client.luau index 1ffee86..3eb3861 100644 --- a/scripts/ArenaClient/CitadelGuide.client.luau +++ b/scripts/ArenaClient/CitadelGuide.client.luau @@ -4,6 +4,8 @@ local rs = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local UI = require(rs:WaitForChild("HunterUI") :: ModuleScript) local Sounds = require(rs:WaitForChild("SniperEffects") :: ModuleScript) +local Input = game:GetService("UserInputService") +local mobile = Input.TouchEnabled and not Input.KeyboardEnabled local Config = require(rs.CitadelAssaultConfig) local Strings = require(rs.Hunter.Strings) local Hints = require(rs.Hunter.Hints) @@ -114,7 +116,7 @@ local function update() }) if pending then table.insert(candidates, pending); pending = nil end local chosen = if Config.HintsEnabled then Hints.pick(hints, candidates, workspace:GetServerTimeNow()) else nil - pg:SetAttribute("SiegeHint", if chosen then chosen.text else nil) + pg:SetAttribute("SiegeHint", if chosen then (if mobile then Hints.compact(chosen.text) else chosen.text) else nil) if zone == "Inside" and previousZone ~= zone then Sounds.sound("SiegeEnter") end if zone == "Inside" and status == "Capturing" and attacking then diff --git a/scripts/ArenaClient/ModeFeedback.client.luau b/scripts/ArenaClient/ModeFeedback.client.luau index a109e82..14e4ff6 100644 --- a/scripts/ArenaClient/ModeFeedback.client.luau +++ b/scripts/ArenaClient/ModeFeedback.client.luau @@ -9,6 +9,10 @@ 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") @@ -25,13 +29,6 @@ local title = UI.label(banner,"Title","",UDim2.fromScale(.02,0),UDim2.fromScale( 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 @@ -43,19 +40,53 @@ local function tint(side: string?): Color3 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() + 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 @@ -76,7 +107,7 @@ local function event(kind: string, p: any) bannerUntil=now+2.5 end if kind==Kinds.LeaderDown then - Sounds.sound("HotPointCaptured") + Sounds.sound("LeaderDown") if typeof(p.at)=="Vector3" then showWave(p.at,tone) end end end @@ -87,7 +118,7 @@ local function event(kind: string, p: any) 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 "RoundStart" else "HotPointCaptured") + 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 @@ -121,6 +152,24 @@ local heartbeat = RunService.Heartbeat:Connect(function(dt) 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) @@ -135,14 +184,14 @@ local heartbeat = RunService.Heartbeat:Connect(function(dt) 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) + 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 boolean, kill: (Player, Player, Vector3, number) -> (), hit: ((Player, number, boolean) -> ())?, @@ -41,6 +43,7 @@ function Objectives.start(config: Types.Config): Match end local instance = result :: Types.ModeInstance local lastStep = ctx.liveAt + local profileLabel = "Mode." .. mode.id .. ".step" local destroyed = false local match: Match match = { @@ -48,7 +51,14 @@ function Objectives.start(config: Types.Config): Match if destroyed then return false end local elapsed = math.max(0, now - lastStep) lastStep = now - return instance.step(now, math.min(elapsed, .5), Context.collect(ctx.members()), elapsed) + debug.profilebegin(profileLabel) + Diagnostics.begin() + local fighters = Context.collect(ctx.members()) + local ok, ended = pcall(instance.step, now, math.min(elapsed, .5), fighters, elapsed) + Diagnostics.finish(ctx.state, #fighters, now) + debug.profileend() + if not ok then error(ended, 0) end + return ended end, kill = instance.kill, hit = instance.hit, death = instance.death, leaving = instance.leaving, winner = function() @@ -65,6 +75,7 @@ function Objectives.start(config: Types.Config): Match ctx.folder:Destroy() ctx.status("") ctx.state:SetAttribute("RoundStage", nil) + for _, attr in {"DebugRays", "DebugFighters", "DebugEvents"} do ctx.state:SetAttribute(attr, nil) end if not ok then warn(issue) end end, } diff --git a/scripts/ArenaRoundHud.client.luau b/scripts/ArenaRoundHud.client.luau index 27a628f..da88542 100644 --- a/scripts/ArenaRoundHud.client.luau +++ b/scripts/ArenaRoundHud.client.luau @@ -332,7 +332,7 @@ local function showCountdownBeat(seconds: number) digitMotion:Play() echoMotion:Play() echoFade:Play() - countdownSound = Sounds.sound("RoundCountdown") + countdownSound = Sounds.sound("Countdown") end local teamStats = UI.plate(hudLayout, "TeamKillStats", UDim2.fromOffset(15, 74), UDim2.fromOffset(widthOfCard, 55), UI.Outline) @@ -952,6 +952,7 @@ results.OnClientEvent:Connect(function(result: RoundResult, participantSide: str if left <= 0 then return end if resultsShade.Visible then hideResults() end startSummary("Final", result.ruleset) + Sounds.sound("Results") if result.ruleset == "Siege" and result.siegeTimes then local lines = SiegeResults.rows(result.siegeTimes, SiegeConfig.MAX_OBJECTIVES) table.insert(lines, SiegeResults.tiebreak) diff --git a/scripts/HotPoint.luau b/scripts/HotPoint.luau index 4904999..f37b80b 100644 --- a/scripts/HotPoint.luau +++ b/scripts/HotPoint.luau @@ -1,5 +1,5 @@ --!strict -local TweenService = game:GetService("TweenService") +local Diagnostics = require(script.Parent.ModeRuntime.ZoneDiagnostics) local Credit = require(script.Parent.ModeRuntime.HotPointCredit) local Sites = require(script.Parent:WaitForChild("ArenaObjectiveSites") :: ModuleScript) @@ -26,7 +26,7 @@ local TEAM_SPEED = 1.5 local HIT_WINDOW = 1.2 local HIT_DECAY = .8 -local neutral = Color3.fromRGB(183, 132, 255) +local neutral = Color3.fromRGB(255, 220, 96) local contested = Color3.fromRGB(255, 211, 124) local teamColor: {[Side]: Color3} = {Blue = Color3.fromRGB(76, 228, 255), Orange = Color3.fromRGB(255, 81, 105)} @@ -35,7 +35,6 @@ function HotPoint.attachRing(mark: Marker, radius: number?): (Color3) -> () local body = mark.body body.Transparency = .92 local beams: {Beam} = {} - local sparks: {ParticleEmitter} = {} local function anchor(angle: number, height: number): Attachment local radial = Vector3.new(math.cos(angle), 0, math.sin(angle)) local tangent = Vector3.new(-radial.Z, 0, radial.X) @@ -81,22 +80,6 @@ function HotPoint.attachRing(mark: Marker, radius: number?): (Color3) -> () veil.Parent = body table.insert(beams, veil) end - local emitter = Instance.new("ParticleEmitter") - emitter.Name = "RisingSparks" - emitter.Texture = "rbxasset://textures/particles/sparkles_main.dds" - emitter.EmissionDirection = Enum.NormalId.Top - emitter.Rate, emitter.Speed = 12, NumberRange.new(16.5, 27) - emitter.Lifetime, emitter.SpreadAngle = NumberRange.new(.6, 1.08), Vector2.new(8, 8) - emitter.Rotation, emitter.RotSpeed = NumberRange.new(-180, 180), NumberRange.new(-95, 95) - emitter.LightEmission, emitter.LightInfluence, emitter.Brightness = 1, 0, 2 - emitter.Size = NumberSequence.new({ - NumberSequenceKeypoint.new(0, .16), NumberSequenceKeypoint.new(.25, .55), NumberSequenceKeypoint.new(1, .08), - }) - emitter.Transparency = NumberSequence.new({ - NumberSequenceKeypoint.new(0, 1), NumberSequenceKeypoint.new(.22, .12), NumberSequenceKeypoint.new(1, 1), - }) - emitter.Parent = source - table.insert(sparks, emitter) end return function(tint: Color3) body.Color, mark.label.TextColor3 = tint, tint @@ -107,50 +90,12 @@ function HotPoint.attachRing(mark: Marker, radius: number?): (Color3) -> () ColorSequenceKeypoint.new(1, tint), }) for _, beam in beams do beam.Color = spectrum end - for _, emitter in sparks do emitter.Color = spectrum end end end -local function collapse(mark: Marker) - local body = mark.body - local motion = TweenInfo.new(COLLAPSE_SECONDS, Enum.EasingStyle.Quad, Enum.EasingDirection.In) - local center = body.CFrame:PointToObjectSpace(mark.origin + Vector3.yAxis * .29) - body:SetAttribute("ObjectiveArrowHidden", true) - mark.label.Visible = false - TweenService:Create(body, motion, {Size = Vector3.new(body.Size.X, .1, .1), Transparency = 1}):Play() - for _, item in body:GetDescendants() do - if item:IsA("Attachment") then - TweenService:Create(item, motion, {Position = center}):Play() - elseif item:IsA("Beam") then - TweenService:Create(item, motion, {Width0 = 0, Width1 = 0, CurveSize0 = 0, CurveSize1 = 0}):Play() - elseif item:IsA("ParticleEmitter") then - item.Enabled = false - elseif item:IsA("PointLight") then - TweenService:Create(item, motion, {Brightness = 0, Range = 0}):Play() - end - end - - local source = Instance.new("Attachment") - source.CFrame = body.CFrame:ToObjectSpace(CFrame.new(mark.origin + Vector3.yAxis * .65)) - source.Parent = body - local smoke = Instance.new("ParticleEmitter") - smoke.Name = "CaptureSmoke" - smoke.Texture = "rbxasset://textures/particles/smoke_main.dds" - smoke.Rate = 0 - smoke.Lifetime = NumberRange.new(.8, 1.45) - smoke.Speed = NumberRange.new(7, 16) - smoke.SpreadAngle = Vector2.new(68, 68) - smoke.Rotation = NumberRange.new(-180, 180) - smoke.Acceleration = Vector3.yAxis * 6 - smoke.Color = ColorSequence.new(body.Color:Lerp(Color3.fromRGB(215, 222, 236), .65)) - smoke.Size = NumberSequence.new({ - NumberSequenceKeypoint.new(0, 2), NumberSequenceKeypoint.new(.5, 6), NumberSequenceKeypoint.new(1, 10), - }) - smoke.Transparency = NumberSequence.new({ - NumberSequenceKeypoint.new(0, .28), NumberSequenceKeypoint.new(.42, .46), NumberSequenceKeypoint.new(1, 1), - }) - smoke.Parent = source - smoke:Emit(32) +local function closeMarker(mark: Marker) + mark.body:SetAttribute("ObjectiveArrowHidden", true) + mark.body.Parent = nil end function HotPoint.start(config: Config): Capture @@ -185,11 +130,11 @@ function HotPoint.start(config: Config): Capture if delta.Y < -.5 or delta.Y > 60 or delta.X * delta.X + delta.Z * delta.Z > HotPoint.Radius ^ 2 then return false end if delta.Y > 8 then -- A jump over the point still counts when the first floor below is the capture floor. - local floor = workspace:Raycast(fighter.root.Position, -Vector3.yAxis * (delta.Y + .8), config.geometry) + local floor = Diagnostics.raycast(fighter.root.Position, -Vector3.yAxis * (delta.Y + .8), config.geometry) return floor ~= nil and math.abs(floor.Position.Y - origin.Y) < .65 end local to = origin + Vector3.yAxis * 2.7 - fighter.root.Position - return workspace:Raycast(fighter.root.Position, to, config.geometry) == nil + return Diagnostics.raycast(fighter.root.Position, to, config.geometry) == nil end local function step(fighters: {Fighter}, now: number, dt: number) @@ -264,7 +209,7 @@ function HotPoint.start(config: Config): Capture state:SetAttribute("HotPointPosition", nil) state:SetAttribute("HotPointMovesAt", movesAt) paintRing(teamColor[side]) - if mark then collapse(mark) end + if mark then closeMarker(mark) end else local phase = if isContested then "Contested" elseif underFire then "UnderFire" else "Capturing" publish(side, math.floor(100 * credit / CAPTURE_SECONDS), phase) diff --git a/scripts/Hunter/EffectsBudget.luau b/scripts/Hunter/EffectsBudget.luau new file mode 100644 index 0000000..62c9307 --- /dev/null +++ b/scripts/Hunter/EffectsBudget.luau @@ -0,0 +1,10 @@ +--!strict +local Config = require(script.Parent.EffectsConfig) +local Budget = {} +function Budget.profile(touch: boolean, keyboard: boolean) + return if touch and not keyboard then Config.Mobile else Config.Desktop +end +function Budget.particles(requested: number, scale: number): number + return if requested <= 0 then 0 else math.max(1, math.floor(requested * scale)) +end +return table.freeze(Budget) diff --git a/scripts/Hunter/EffectsConfig.luau b/scripts/Hunter/EffectsConfig.luau new file mode 100644 index 0000000..c98aac0 --- /dev/null +++ b/scripts/Hunter/EffectsConfig.luau @@ -0,0 +1,29 @@ +--!strict +local tick = "rbxassetid://113416294133952" +local ready = "rbxassetid://2789428506" +local success = "rbxassetid://4612374036" +export type Cue = {id: string, volume: number, speed: number} +local function cue(id: string, volume: number, speed: number): Cue + return table.freeze({id = id, volume = volume, speed = speed}) +end +return table.freeze({ + Debug = false, SoundLimit = 6, HintLimit = 60, + Danger = Color3.fromRGB(255, 81, 105), + FeedbackSeconds = .55, BannerMotionSeconds = .22, + Desktop = table.freeze({scale = 1, maxEmitters = 200, burstSlots = 10, worldSlots = 8}), + Mobile = table.freeze({scale = .4, maxEmitters = 80, burstSlots = 4, worldSlots = 4}), + Cues = table.freeze({ + RoundStart = cue(success,.27,1.15), Countdown = cue(tick,.25,1), Tick = cue(tick,.22,1.12), + FinalPush = cue(ready,.25,.9), ZoneEnter = cue(tick,.23,1.30), ZoneCharge = cue(ready,.22,1), + ZoneBlocked = cue(ready,.25,.70), ZoneDecay = cue(ready,.20,.58), ZoneCaptured = cue(success,.28,1), + AllTaken = cue(success,.27,1.18), FlagPicked = cue(ready,.25,1), FlagDropped = cue(ready,.23,.72), + FlagScored = cue(success,.28,1.06), TokenPick = cue(tick,.22,1.21), TokensBanked = cue(success,.27,1.2), + LeaderDown = cue(success,.28,.94), RoleSwap = cue(ready,.25,1.18), + MiniRoundStart = cue(success,.26,1.24), Results = cue(success,.25,.92), + }), + Aliases = table.freeze({ + RoundCountdown = "Countdown", SiegeEnter = "ZoneEnter", SiegeCharge = "ZoneCharge", + SiegeTick = "Tick", SiegeBlocked = "ZoneBlocked", SiegeDecay = "ZoneDecay", + HotPointStart = "ZoneCharge", HotPointCaptured = "ZoneCaptured", HotPointMove = "Countdown", + }), +}) diff --git a/scripts/Hunter/EventKinds.luau b/scripts/Hunter/EventKinds.luau index d53c52b..8bd51f9 100644 --- a/scripts/Hunter/EventKinds.luau +++ b/scripts/Hunter/EventKinds.luau @@ -2,7 +2,7 @@ return table.freeze({ ZoneStarted = "ZoneStarted", ZoneCaptured = "ZoneCaptured", ZoneContested = "ZoneContested", ZoneLost = "ZoneLost", FullControl = "FullControl", AllObjectivesTaken = "AllObjectivesTaken", FlagPicked = "FlagPicked", FlagDropped = "FlagDropped", - FlagReturned = "FlagReturned", FlagScored = "FlagScored", TokenDropped = "TokenDropped", TokensBanked = "TokensBanked", TokensLost = "TokensLost", + FlagReturned = "FlagReturned", FlagScored = "FlagScored", TokenPicked = "TokenPicked", TokenDropped = "TokenDropped", TokensBanked = "TokensBanked", TokensLost = "TokensLost", LeaderAssigned = "LeaderAssigned", LeaderDown = "LeaderDown", MiniRoundStarted = "MiniRoundStarted", MiniRoundEnded = "MiniRoundEnded", RoleSwap = "RoleSwap", Streak = "Streak", }) diff --git a/scripts/Hunter/Hints.luau b/scripts/Hunter/Hints.luau index 19ab1b7..5da410f 100644 --- a/scripts/Hunter/Hints.luau +++ b/scripts/Hunter/Hints.luau @@ -1,6 +1,7 @@ --!strict export type Hint = {key: string, text: string, priority: number, cooldown: number?, ttl: number?} export type State = {shownAt: {[string]: number}, current: Hint?, currentUntil: number} +local Config = require(script.Parent.EffectsConfig) local Hints = {DEFAULT_COOLDOWN = 3, DEFAULT_TTL = 3} function Hints.new(): State return {shownAt = {}, current = nil, currentUntil = 0} end function Hints.pick(state: State, candidates: {Hint}, now: number): Hint? @@ -21,4 +22,10 @@ function Hints.pick(state: State, candidates: {Hint}, now: number): Hint? end return current end +function Hints.compact(text: string): string + local line = text:gsub("[\r\n]+", " ") + local cut = utf8.offset(line, Config.HintLimit) + if cut and utf8.offset(line, Config.HintLimit + 1) then return line:sub(1, cut - 1) .. "…" end + return line +end return Hints diff --git a/scripts/ModeRuntime/Common.luau b/scripts/ModeRuntime/Common.luau index 4f53b66..d02c6cf 100644 --- a/scripts/ModeRuntime/Common.luau +++ b/scripts/ModeRuntime/Common.luau @@ -1,4 +1,5 @@ --!strict +local Diagnostics = require(script.Parent.ZoneDiagnostics) local Types = require(script.Parent.Types) local HotPoint = require(script.Parent.Parent.HotPoint) local Sites = require(script.Parent.Parent.ArenaObjectiveSites) @@ -11,7 +12,7 @@ local sides: {Side} = {"Blue", "Orange"} local blue = Color3.fromRGB(67, 216, 255) local orange = Color3.fromRGB(255, 150, 68) local gold = Color3.fromRGB(255, 220, 96) -local neutral = Color3.fromRGB(188, 150, 255) +local neutral = Color3.fromRGB(255, 220, 96) local function opposite(side: Side): Side return if side == "Blue" then "Orange" else "Blue" end @@ -88,7 +89,7 @@ local function paint(mark: Marker, tint: Color3) if aura then aura.Color = tint end end local function visibleAt(fighter: Fighter, at: Vector3, geometry: RaycastParams): boolean - return workspace:Raycast(fighter.root.Position, at - fighter.root.Position, geometry) == nil + return Diagnostics.raycast(fighter.root.Position, at - fighter.root.Position, geometry) == nil end local function makeZone(folder: Folder, geometry: RaycastParams, site: Sites.Site, name: string, radius: number?, tint: Color3?): Zone local r = radius or HotPoint.Radius diff --git a/scripts/ModeRuntime/Events.luau b/scripts/ModeRuntime/Events.luau index bb37a61..d44257f 100644 --- a/scripts/ModeRuntime/Events.luau +++ b/scripts/ModeRuntime/Events.luau @@ -7,9 +7,11 @@ local remote = if existing and existing:IsA("RemoteEvent") then existing else In remote.Name = "ArenaObjectiveEvent" remote.Parent = ReplicatedStorage local Events = {} +local Diagnostics = require(script.Parent.ZoneDiagnostics) function Events.new(members: () -> {Player}): Types.Events return {fire = function(kind, payload, audience) + Diagnostics.event() local packet = table.clone(payload or {}) :: {[string]: any} packet.t = workspace:GetServerTimeNow() for _, player in members() do diff --git a/scripts/ModeRuntime/Modes/CaptureFlag.luau b/scripts/ModeRuntime/Modes/CaptureFlag.luau index d2f869a..8f1a02a 100644 --- a/scripts/ModeRuntime/Modes/CaptureFlag.luau +++ b/scripts/ModeRuntime/Modes/CaptureFlag.luau @@ -4,12 +4,13 @@ local Types = require(Runtime.Types) local Common = require(Runtime.Common) local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds) local Strings = require(game.ReplicatedStorage.Hunter.Strings) +local Diagnostics = require(Runtime.ZoneDiagnostics) local Context = require(Runtime.Context) local Rules = require(Runtime.FlagRules) local HotPoint = require(Runtime.Parent.HotPoint) type Fighter = Types.Fighter type Flag = { - marker: Common.Marker, stars: ParticleEmitter, mist: ParticleEmitter, light: PointLight, banner: BasePart, + marker: Common.Marker, light: PointLight, banner: BasePart, carrier: Player?, tether: WeldConstraint?, droppedUntil: number, } local function makeFlag(parent: Instance, roof: Vector3): Flag @@ -35,33 +36,7 @@ local function makeFlag(parent: Instance, roof: Vector3): Flag local banner = attach("Banner", Vector3.new(2.65, 1.48, .15), Vector3.new(1.35, 1.45, 0), Common.gold) attach("CrownLight", Vector3.new(.33, .33, .33), Vector3.yAxis * 2.34, Common.neutral).Shape = Enum.PartType.Ball - local aura = Instance.new("Attachment") - aura.Name = "FlagAura" - aura.Position = -Vector3.yAxis * 1.75 - aura.Parent = body - local stars = Instance.new("ParticleEmitter") - stars.Name = "Stars" - stars.Texture = "rbxasset://textures/particles/sparkles_main.dds" - stars.Color = ColorSequence.new(Common.neutral, Common.gold) - stars.LightEmission, stars.LightInfluence = 1, 0 - stars.Rate, stars.Speed, stars.Lifetime = 24, NumberRange.new(3, 6), NumberRange.new(.7, 1.4) - stars.SpreadAngle = Vector2.new(65, 65) - stars.Rotation, stars.RotSpeed = NumberRange.new(-180, 180), NumberRange.new(-90, 90) - stars.Size = NumberSequence.new({NumberSequenceKeypoint.new(0, .22), NumberSequenceKeypoint.new(.4, .52), NumberSequenceKeypoint.new(1, 0)}) - stars.Parent = aura - - local mist = Instance.new("ParticleEmitter") - mist.Name = "ColoredMist" - mist.Texture = "rbxasset://textures/particles/smoke_main.dds" - mist.Color = ColorSequence.new(Common.neutral, Common.gold) - mist.LightEmission, mist.LightInfluence = .55, 0 - mist.Rate, mist.Speed, mist.Lifetime = 9, NumberRange.new(1, 4), NumberRange.new(.7, 1.2) - mist.SpreadAngle = Vector2.new(110, 110) - mist.Size = NumberSequence.new(1.4, 4) - mist.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0, .72), NumberSequenceKeypoint.new(.45, .79), NumberSequenceKeypoint.new(1, 1)}) - mist.Parent = aura - - return {marker = mark, stars = stars, mist = mist, light = light, banner = banner, + return {marker = mark, light = light, banner = banner, carrier = nil, tether = nil, droppedUntil = 0} end @@ -88,8 +63,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance mark.body.CFrame = CFrame.new(at + Vector3.yAxis * 2.4) mark.label.Text = if droppedUntil > 0 then Strings.flagDropLabel else Strings.flagRoofLabel mark.label.TextColor3, object.banner.Color = Common.gold, Common.gold - object.stars.Enabled, object.mist.Enabled, object.light.Enabled = true, true, true - object.stars:Emit(16) + object.light.Enabled = true end local function pickUpFlag(object: Flag, fighter: Fighter) @@ -108,14 +82,12 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance local tint = Common.color(fighter.side) object.marker.label.Text = Strings.flagCarrierLabel(fighter.player.DisplayName) object.marker.label.TextColor3, object.banner.Color = tint, tint - object.stars.Enabled, object.mist.Enabled, object.light.Enabled = false, false, false - object.stars:Clear() - object.mist:Clear() + object.light.Enabled = false end local function dropCarried(player: Player, at: Vector3?, now: number, fighters: {Fighter}?) if flag.carrier == player then if at then - local floor = workspace:Raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry) + local floor = Diagnostics.raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry) if floor then putFlag(flag, floor.Position, now + Rules.RETURN_SECONDS) for _, fighter in (fighters or Context.collect(ctx.members())) do ctx.legacy(fighter.player, "FlagDropped") end @@ -140,7 +112,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance if Common.boundsAt(fighter.root.Position, base, HotPoint.Radius, 7) then ctx.scoring.add(fighter.side, 1, Kinds.FlagScored, fighter.player) ctx.contribute(fighter.player, "deliveries", 1) - ctx.events.fire(Kinds.FlagScored, {side = fighter.side, userId = fighter.player.UserId}) + ctx.events.fire(Kinds.FlagScored, {side = fighter.side, userId = fighter.player.UserId, at = base}) ctx.cue(fighters, true, nil) putFlag(flag, flag.marker.origin, 0) ctx.events.fire(Kinds.FlagReturned, {at = flag.marker.origin}) diff --git a/scripts/ModeRuntime/Modes/HotPoint.luau b/scripts/ModeRuntime/Modes/HotPoint.luau index 8c9b980..9055fda 100644 --- a/scripts/ModeRuntime/Modes/HotPoint.luau +++ b/scripts/ModeRuntime/Modes/HotPoint.luau @@ -19,7 +19,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance end, score = function(side, points) ctx.scoring.add(side, points, Kinds.ZoneCaptured) - ctx.events.fire(Kinds.ZoneCaptured, {side = side, text = Strings.hotPoint, value = nowAt - ctx.liveAt}) + ctx.events.fire(Kinds.ZoneCaptured, {side = side, text = Strings.hotPoint, value = nowAt - ctx.liveAt, at = ctx.state:GetAttribute("HotPointPosition") :: Vector3?}) end, status = ctx.status, contribute = ctx.contribute, }) @@ -29,7 +29,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance capture.step(fighters, now, elapsed or dt) local contested = ctx.state:GetAttribute("HotPointPhase") == "Contested" if contested and not wasContested then - ctx.events.fire(Kinds.ZoneContested, {text = Strings.hotPoint}) + ctx.events.fire(Kinds.ZoneContested, {text = Strings.hotPoint, at = ctx.state:GetAttribute("HotPointPosition") :: Vector3?}) end wasContested = contested return false diff --git a/scripts/ModeRuntime/Modes/Siege.luau b/scripts/ModeRuntime/Modes/Siege.luau index 4f4295a..f95dc95 100644 --- a/scripts/ModeRuntime/Modes/Siege.luau +++ b/scripts/ModeRuntime/Modes/Siege.luau @@ -42,7 +42,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance zone.marker.body.Parent = nil ctx.janitor.give(zone.marker.body) table.insert(zones, zone) - table.insert(visuals, Effects.new(zone.marker, folder, ctx.janitor)) + table.insert(visuals, Effects.new(zone.marker)) end data:SetAttribute("Total", #zones) local siegeTimes: Score.Ledger = {Blue = {}, Orange = {}} @@ -156,7 +156,6 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance local tint = if phase == "Idle" then Common.gold elseif phase == "Contested" then SiegeConfig.CONTESTED_COLOR elseif phase == "Decaying" then teamTint:Lerp(Color3.fromRGB(150, 162, 182), .45) else teamTint Common.paint(zone.marker, tint) - visual.update(tint, phase, progress, phase ~= lastStatus) if phase == "Contested" and lastStatus ~= phase then ctx.events.fire(Kinds.ZoneContested, {side = siegeSide, index = siegeIndex, at = zone.site.position}) end @@ -164,11 +163,11 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance if phase ~= "Captured" or not Score.record(siegeTimes, siegeSide, siegeIndex, elapsed - attackStart) then return false end ctx.scoring.add(siegeSide, SiegeConfig.POINTS_PER_OBJECTIVE, Kinds.ZoneCaptured) for _, player in attackers do ctx.contribute(player, "captures", 1) end - ctx.events.fire(Kinds.ZoneCaptured, {side = siegeSide, index = siegeIndex, text = zone.site.name, value = elapsed - attackStart}) + ctx.events.fire(Kinds.ZoneCaptured, {side = siegeSide, index = siegeIndex, text = zone.site.name, value = elapsed - attackStart, at = zone.site.position}) ctx.cue(fighters, true, nil) siegeCaptureStarted = false data:SetAttribute(siegeSide .. "Time" .. siegeIndex, elapsed - attackStart) - visual.capture(teamTint) + visual.capture() siegeIndex += 1 siegeProgress = 0 if siegeIndex > #zones then diff --git a/scripts/ModeRuntime/Modes/TrophyHunt.luau b/scripts/ModeRuntime/Modes/TrophyHunt.luau index 6ef53c3..e19386c 100644 --- a/scripts/ModeRuntime/Modes/TrophyHunt.luau +++ b/scripts/ModeRuntime/Modes/TrophyHunt.luau @@ -7,8 +7,8 @@ local Strings = require(game.ReplicatedStorage.Hunter.Strings) type Fighter = Types.Fighter local HotPoint = require(Runtime.Parent.HotPoint) local Rules = require(Runtime.TrophyRules) -local TweenService = game:GetService("TweenService") -type Drop = {marker: Common.Marker, amount: number, expires: number, fade: Tween?} +local Diagnostics = require(Runtime.ZoneDiagnostics) +type Drop = {marker: Common.Marker, amount: number, expires: number} local function start(ctx: Types.ModeContext): Types.ModeInstance local map, geometry, folder = assert(ctx.map), ctx.geometry, ctx.folder @@ -16,7 +16,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance local tokens: {Drop} = {} local carried: {[Player]: number} = {} local function floorAt(at: Vector3): Vector3 - local hit = workspace:Raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry) + local hit = Diagnostics.raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry) return if hit then hit.Position else map.ground.position end local function tokenDrop(at: Vector3, amount: number, now: number) @@ -26,38 +26,34 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance if Rules.canMerge(existing.marker.origin, floor) then existing.amount += amount existing.expires = now + Rules.LIFETIME - if existing.fade then existing.fade:Cancel(); existing.fade = nil end - existing.marker.body.Transparency = .04 + existing.marker.body:SetAttribute("TokenExpiresAt", existing.expires) existing.marker.label.Text = Strings.tokens(existing.amount) return end end if #tokens >= Rules.MAX_DROPS then local old = table.remove(tokens, 1) - if old.fade then old.fade:Cancel() end old.marker.body:Destroy() end - table.insert(tokens, {marker = Common.marker(folder, "Tokens", Strings.tokens(amount), floor, Common.gold, 1.55, true), amount = amount, expires = now + Rules.LIFETIME}) + local mark = Common.marker(folder, "Tokens", Strings.tokens(amount), floor, Common.gold, 1.55, true) + mark.body:SetAttribute("TokenExpiresAt", now + Rules.LIFETIME) + mark.body:SetAttribute("TokenFlashSeconds", Rules.FLASH_SECONDS) + table.insert(tokens, {marker = mark, amount = amount, expires = now + Rules.LIFETIME}) end local function runTrophies(fighters: {Fighter}, now: number) for i = #tokens, 1, -1 do local token = tokens[i] local collector: Fighter? = nil if now < token.expires then - if token.expires - now <= Rules.FLASH_SECONDS and not token.fade then - token.fade = TweenService:Create(token.marker.body,TweenInfo.new(.38,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,-1,true),{Transparency=.76}) - token.fade:Play() - end for _, f in fighters do if Common.boundsAt(f.root.Position, token.marker.origin, 5, 6) and Common.visibleAt(f, token.marker.body.Position, geometry) then collector = f; break end end if not collector then continue end local p = collector.player - if not carried[p] then ctx.cue(fighters, false, collector.side) end + if not carried[p] then ctx.events.fire(Kinds.TokenPicked, {userId = p.UserId}, {p}) end carried[p] = (carried[p] or 0) + token.amount p:SetAttribute("ArenaTokens", carried[p]) end - if token.fade then token.fade:Cancel() end token.marker.body:Destroy() table.remove(tokens, i) end @@ -66,7 +62,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance if amount and Common.boundsAt(f.root.Position, if f.side == "Blue" then map.blue else map.orange, HotPoint.Radius, 7) then ctx.scoring.add(f.side, amount, Kinds.TokensBanked, f.player) ctx.contribute(f.player, "tokensBanked", amount) - ctx.events.fire(Kinds.TokensBanked, {side = f.side, userId = f.player.UserId, value = amount}) + ctx.events.fire(Kinds.TokensBanked, {side = f.side, userId = f.player.UserId, value = amount, at = if f.side == "Blue" then map.blue else map.orange}) ctx.cue(fighters, true, nil) carried[f.player] = nil f.player:SetAttribute("ArenaTokens", nil) @@ -92,7 +88,6 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance death = drop, leaving = drop, destroy = function() for p in carried do p:SetAttribute("ArenaTokens", nil) end - for _, token in tokens do if token.fade then token.fade:Cancel() end end end, }) end diff --git a/scripts/ModeRuntime/SiegeEffects.luau b/scripts/ModeRuntime/SiegeEffects.luau index 624a029..e647b97 100644 --- a/scripts/ModeRuntime/SiegeEffects.luau +++ b/scripts/ModeRuntime/SiegeEffects.luau @@ -1,109 +1,19 @@ --!strict -local TweenService = game:GetService("TweenService") -local Runtime = script.Parent -local Common = require(Runtime.Common) -local Types = require(Runtime.Types) -local Config = require(game.ReplicatedStorage.CitadelAssaultConfig) -export type Rig = {show: () -> (), hide: () -> (), update: (Color3, string, number, boolean) -> (), capture: (Color3) -> ()} - -local function newPart(name: string, parent: Instance): Part - local p = Instance.new("Part") - p.Name, p.Shape, p.Material = name, Enum.PartType.Cylinder, Enum.Material.Neon - p.CanCollide, p.CanQuery, p.CanTouch, p.Anchored, p.CastShadow = false, false, false, true, false - p.Transparency = 1 - p.Parent = parent - return p -end - +local Common = require(script.Parent.Common) +export type Rig = {show: () -> (), hide: () -> (), capture: () -> ()} local Effects = {} -function Effects.new(mark: Common.Marker, folder: Folder, janitor: Types.Janitor): Rig - local root = Instance.new("Folder") - root.Name = "SiegeLight" - root.Parent = folder - local column = newPart("Column", root) - local wave = newPart("Shockwave", root) - local anchor = Instance.new("Attachment") - anchor.Parent = wave - local sparks = Instance.new("ParticleEmitter") - sparks.Texture = "rbxasset://textures/particles/sparkles_main.dds" - sparks.Speed, sparks.Lifetime, sparks.Rate = NumberRange.new(12, 25), NumberRange.new(.45, 1.2), 0 - sparks.SpreadAngle = Vector2.new(145, 145) - sparks.LightEmission = 1 - sparks.Parent = anchor - local diameter = Config.CAPTURE_RADIUS * 2 - local rotation = CFrame.Angles(0, 0, math.pi / 2) - local floor = CFrame.new(mark.origin + Vector3.yAxis * .21) * rotation - wave.CFrame = floor - local width = 3.5 - local fullColumn = CFrame.new(mark.origin + Vector3.yAxis * (Config.LIGHT_HEIGHT / 2)) * rotation - local motion: Tween? = nil - local lightMotion: Tween? = nil - local effect: Tween? = nil - local run = 0 - local function cancel() - run += 1 - if motion then motion:Cancel() end - if lightMotion then lightMotion:Cancel() end - if effect then effect:Cancel() end - end +function Effects.new(mark: Common.Marker): Rig local function hide() - cancel() - column.Transparency, wave.Transparency = 1, 1 - sparks:Clear() + mark.body:SetAttribute("ObjectiveArrowHidden", true) + mark.body.Parent = nil end - janitor.give(hide) - return { hide = hide, show = function() - hide() mark.body:SetAttribute("ObjectiveArrowHidden", nil) - mark.label.Visible = true - mark.body.Size = Vector3.new(.16, diameter * .15, diameter * .15) - mark.body.Transparency = .92 Common.paint(mark, Common.gold) - column.Color = Common.gold - column.Size, column.CFrame = Vector3.new(.2, width, width), floor - column.Transparency = .85 - local t = TweenInfo.new(Config.MATERIALIZE_SECONDS, Enum.EasingStyle.Quart, Enum.EasingDirection.Out) - motion = TweenService:Create(mark.body, t, {Size = Vector3.new(.16, diameter, diameter)}) - lightMotion = TweenService:Create(column, t, {CFrame = fullColumn, Size = Vector3.new(Config.LIGHT_HEIGHT, width, width)}) - motion:Play() - lightMotion:Play() - end, - update = function(tint, phase, progress, changed) - column.Color = tint - column.Transparency = if phase == "Capturing" then 1 - (.55 + .45 * progress) * .25 - elseif phase == "Decaying" then .94 else .86 - if phase == "Contested" and changed then - wave.Color, wave.Transparency = tint, .68 - wave.Size = Vector3.new(.12, diameter, diameter) - if effect then effect:Cancel() end - effect = TweenService:Create(wave, TweenInfo.new(.25), {Transparency = 1}) - effect:Play() - end - end, - capture = function(tint) - cancel() - local token = run - Common.paint(mark, Color3.new(1, 1, 1)) - mark.body:SetAttribute("ObjectiveArrowHidden", true) - mark.label.Visible = false - wave.Size = Vector3.new(.11, diameter, diameter) - wave.Color, wave.Transparency = tint, .55 - sparks.Color = ColorSequence.new(tint) - sparks:Emit(Config.CONFETTI_COUNT) - local t = TweenInfo.new(Config.CAPTURE_EFFECT_SECONDS, Enum.EasingStyle.Quad, Enum.EasingDirection.Out) - motion = TweenService:Create(mark.body, t, {Size = Vector3.new(.16, .1, .1), Transparency = 1}) - lightMotion = TweenService:Create(column, t, {Size = Vector3.new(.2, width, width), CFrame = floor, Transparency = 1}) - effect = TweenService:Create(wave, t, {Size = Vector3.new(.11, diameter * 1.6, diameter * 1.6), Transparency = 1}) - motion:Play() - lightMotion:Play() - effect:Play() - task.delay(Config.CAPTURE_EFFECT_SECONDS, function() - if token == run and mark.body.Parent == folder then mark.body.Parent = nil end - end) end, + capture = hide, } end return Effects diff --git a/scripts/ModeRuntime/ZoneDiagnostics.luau b/scripts/ModeRuntime/ZoneDiagnostics.luau new file mode 100644 index 0000000..53864a5 --- /dev/null +++ b/scripts/ModeRuntime/ZoneDiagnostics.luau @@ -0,0 +1,33 @@ +--!strict +local Config = require(game.ReplicatedStorage.Hunter.EffectsConfig) +local Diagnostics = {} +local stepping = false +local rays = 0 +local events = 0 +local window = 0 + +function Diagnostics.begin() + stepping = Config.Debug + rays = 0 +end + +function Diagnostics.raycast(origin: Vector3, direction: Vector3, geometry: RaycastParams): RaycastResult? + if stepping then rays += 1 end + return workspace:Raycast(origin, direction, geometry) +end + +function Diagnostics.event() + if Config.Debug then events += 1 end +end + +function Diagnostics.finish(state: Instance, fighters: number, now: number) + stepping = false + if not Config.Debug then return end + state:SetAttribute("DebugRays", rays) + state:SetAttribute("DebugFighters", fighters) + if now - window >= 1 then + state:SetAttribute("DebugEvents", events) + window, events = now, 0 + end +end +return Diagnostics diff --git a/scripts/ModeRuntime/Zones.luau b/scripts/ModeRuntime/Zones.luau index af4ef2c..f19ae42 100644 --- a/scripts/ModeRuntime/Zones.luau +++ b/scripts/ModeRuntime/Zones.luau @@ -1,4 +1,5 @@ --!strict +local Diagnostics = require(script.Parent.ZoneDiagnostics) export type Spec = {radius: number, height: number, sightHeight: number, exclusiveHeight: boolean?} export type Reason = "Outside" | "Height" | "Blocked" | "Inside" local Zones = {} @@ -14,6 +15,6 @@ function Zones.classify(position: Vector3, center: Vector3, spec: Spec, geometry local candidate = Zones.reason(position - center, spec, false) if candidate ~= "Inside" then return candidate end local target = center + Vector3.yAxis * spec.sightHeight - return if workspace:Raycast(position, target - position, geometry) then "Blocked" else "Inside" + return if Diagnostics.raycast(position, target - position, geometry) then "Blocked" else "Inside" end return Zones diff --git a/scripts/ObjectiveArrows.client.luau b/scripts/ObjectiveArrows.client.luau index 9eb2248..2ee2bf8 100644 --- a/scripts/ObjectiveArrows.client.luau +++ b/scripts/ObjectiveArrows.client.luau @@ -4,12 +4,15 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local Input = game:GetService("UserInputService") +local mobile = Input.TouchEnabled and not Input.KeyboardEnabled local player = Players.LocalPlayer local playerGui = player:WaitForChild("PlayerGui") local arena = Modes.geometry(Modes.Procedural) type Arrow = {gui: Frame, chevrons: {Model}, faces: {BasePart}, edges: {BasePart}, glow: {BasePart}, color: Color3?, phase: number} local arrows: {[BasePart]: Arrow} = {} -local SIZE = 156 +local flatArrows: {[BasePart]: {TextLabel}} = {} +local SIZE = if mobile then 125 else 156 local HEIGHT = 105 local MAX_DISTANCE = 710 local ANIMATION_RATE = 2 * math.pi / 4.5 @@ -31,6 +34,26 @@ local function build(marker: BasePart) gui.BackgroundTransparency = 1 gui.Visible = false + if mobile then + local glyphs: {TextLabel} = {} + for index, size in {16, 25, 33} do + local glyph = Instance.new("TextLabel") + glyph.BackgroundTransparency = 1 + glyph.AnchorPoint = Vector2.new(.5, .5) + glyph.Size = UDim2.fromOffset(90, 38) + glyph.Font = Enum.Font.GothamBlack + glyph.Text = "⌄" + glyph.TextSize = size + glyph.TextStrokeTransparency = .15 + glyph.Parent = gui + glyphs[index] = glyph + end + flatArrows[marker] = glyphs + arrows[marker] = {gui = gui, chevrons = {}, faces = {}, edges = {}, glow = {}, color = nil, phase = marker.Position.X * .03} + gui.Parent = overlay + return + end + local viewport = Instance.new("ViewportFrame") viewport.Name = "ArrowViewport" viewport.BackgroundTransparency = 1 @@ -87,6 +110,7 @@ local function remove(instance: Instance) local arrow = arrows[instance] if not arrow then return end arrows[instance] = nil + flatArrows[instance] = nil arrow.gui:Destroy() end @@ -115,6 +139,13 @@ RunService:BindToRenderStep(renderName, Enum.RenderPriority.Camera.Value + 3, fu arrow.gui.Position = UDim2.fromOffset(projected.X, y) local spacing = 1.15 + math.sin(phase - .9) * .16 + local flat = flatArrows[marker] + if flat then + for i, glyph in flat do + glyph.Position = UDim2.new(.5, 0, .5, (i - 2) * 18 * spacing) + glyph.TextColor3 = marker.Color:Lerp(Color3.new(1,1,1), .25) + end + end for index, chevron in arrow.chevrons do chevron:PivotTo(CFrame.new(0, (2 - index) * spacing, 0)) end diff --git a/scripts/SniperEffects.luau b/scripts/SniperEffects.luau index c0a4885..2626dc5 100644 --- a/scripts/SniperEffects.luau +++ b/scripts/SniperEffects.luau @@ -18,6 +18,8 @@ local RunService = game:GetService("RunService") local SoundService = game:GetService("SoundService") local SniperEffects = {} +local AudioConfig = require(game:GetService("ReplicatedStorage"):WaitForChild("Hunter"):WaitForChild("EffectsConfig") :: ModuleScript) +local activeCues: {Sound} = {} -- Free Creator Store sounds. volume, plus how far the sound carries when it is in the world. -- group: which volume setting scales it (attribute Vol of the SniperViewmodel config @@ -40,25 +42,20 @@ local SOUNDS: { [string]: SoundDef } = { Elimination = { id = "rbxassetid://15675043410", volume = 0.78, speed = 1.18, near = 0, far = 0, group = "Kill", cut = 0.52 }, StreakAccent = { id = "rbxassetid://3120909354", volume = 0.5, speed = 1, near = 0, far = 0, group = "Kill" }, -- Level_up ReloadReady = { id = "rbxassetid://15675085146", volume = 0.24, speed = 1.15, near = 0, far = 0, group = "Reload", cut = 0.19 }, - SiegeEnter = { id = "rbxassetid://113416294133952", volume = .23, speed = 1.30, near = 0, far = 0, group = "HUD" }, - SiegeCharge = { id = "rbxassetid://2789428506", volume = .22, speed = 1, near = 0, far = 0, group = "HUD" }, - SiegeTick = { id = "rbxassetid://113416294133952", volume = .22, speed = 1.48, near = 0, far = 0, group = "HUD" }, - SiegeBlocked = { id = "rbxassetid://2789428506", volume = .25, speed = .70, near = 0, far = 0, group = "HUD" }, - SiegeDecay = { id = "rbxassetid://2789428506", volume = .20, speed = .58, near = 0, far = 0, group = "HUD" }, - RoundStart = { id = "rbxassetid://4612374036", volume = .27, speed = 1.15, near = 0, far = 0, group = "HUD" }, - Tick = { id = "rbxassetid://113416294133952", volume = .22, speed = 1.12, near = 0, far = 0, group = "HUD" }, - RoundCountdown = { id = "rbxassetid://113416294133952", volume = 0.25, speed = 1, near = 0, far = 0, group = "HUD" }, -- timer tick ButtonHover = { id = "rbxassetid://84648433095796", volume = 0.22, speed = 1, near = 0, far = 0, group = "HUD" }, ButtonPress = { id = "rbxassetid://121882355123711", volume = 0.27, speed = 1, near = 0, far = 0, group = "HUD" }, - FlagDropped = { id = "rbxassetid://2789428506", volume = 0.23, speed = .72, near = 0, far = 0, group = "HUD" }, - HotPointMove = { id = "rbxassetid://113416294133952", volume = 0.23, speed = 1.18, near = 0, far = 0, group = "HUD" }, - HotPointStart = { id = "rbxassetid://2789428506", volume = 0.25, speed = 1, near = 0, far = 0, group = "HUD" }, -- Unlock_phoenix - HotPointCaptured = { id = "rbxassetid://4612374036", volume = 0.28, speed = 1, near = 0, far = 0, group = "HUD" }, -- bling_big_diamond_pickup MoneyCollect1 = { id = "rbxassetid://84894146013271", volume = 0.15, speed = 1, near = 0, far = 0, group = "Pickup", cut = 0.16 }, CupidKnife = { id = "rbxassetid://120151468640015", volume = 0.32, speed = 1, near = 0, far = 0, group = "Pickup" }, -- a player / bot destroyed: the body breaks apart like blocks (heard by everyone, from the body) Break = { id = "rbxassetid://130215756597524", volume = 1, speed = 1, near = 25, far = 300, group = "Kill" }, -- blockbreak sfx } +local arenaCues: {[string]: boolean} = {} +local function addCue(name: string, cue: AudioConfig.Cue) + SOUNDS[name] = {id = cue.id, volume = cue.volume, speed = cue.speed, near = 0, far = 0, group = "HUD"} + arenaCues[name] = true +end +for name, cue in AudioConfig.Cues do addCue(name, cue) end +for name, target in AudioConfig.Aliases do addCue(name, AudioConfig.Cues[target]) end SniperEffects.SOUNDS = SOUNDS -- the settings live as attributes on the local player's SniperViewmodel script @@ -92,7 +89,10 @@ SniperEffects.BOLT_CUES = { task.spawn(function() -- Sound instances, not bare ids: a bare id string is preloaded as an image and fails local preload = {} + local seen: {[string]: boolean} = {} for _, def in SOUNDS do + if def.id == "" or seen[def.id] then continue end + seen[def.id] = true local s = Instance.new("Sound") s.SoundId = def.id table.insert(preload, s) @@ -105,13 +105,28 @@ end) function SniperEffects.sound(name: string, at: Instance?, pitch: number?): Sound? local def = SOUNDS[name] - if not def then + if not def or def.id == "" then return nil end local volume = def.volume * math.max(setting("VolMaster", 1), 0) * math.max(setting("Vol" .. def.group, 1), 0) if volume <= 0 then return nil end + local limited = arenaCues[name] + if limited then + for i = #activeCues, 1, -1 do + if not activeCues[i].Parent then table.remove(activeCues, i) end + end + if #activeCues >= AudioConfig.SoundLimit then + -- Убираем самый тихий сигнал. Если новый ещё тише, оставляем текущий микс. + local quietest = 1 + for i = 2, #activeCues do + if activeCues[i].Volume < activeCues[quietest].Volume then quietest = i end + end + if activeCues[quietest].Volume > volume then return nil end + table.remove(activeCues, quietest):Destroy() + end + end local s = Instance.new("Sound") s.Name = "Sniper" .. name s.SoundId = def.id @@ -123,6 +138,7 @@ function SniperEffects.sound(name: string, at: Instance?, pitch: number?): Sound s.RollOffMaxDistance = def.far end s.Parent = at or SoundService + if limited then table.insert(activeCues, s) end s:Play() if def.cut then local fade = def.cut diff --git a/scripts/Tests/EffectsBudget.spec.luau b/scripts/Tests/EffectsBudget.spec.luau new file mode 100644 index 0000000..58a492f --- /dev/null +++ b/scripts/Tests/EffectsBudget.spec.luau @@ -0,0 +1,9 @@ +--!strict +return function(budget: any, config: any, hints: any) + assert(budget.profile(true, false) == config.Mobile) + assert(budget.profile(true, true) == config.Desktop) + assert(budget.particles(20, .4) == 8 and budget.particles(0, .4) == 0) + assert(config.Mobile.burstSlots <= config.Mobile.maxEmitters and config.Desktop.burstSlots <= config.Desktop.maxEmitters) + assert(utf8.len(hints.compact(string.rep("я", 100))) == config.HintLimit) + assert(hints.compact("Одна\nстрока") == "Одна строка") +end