diff --git a/Hunter.rbxl b/Hunter.rbxl index 2c45f81..88c7dac 100644 Binary files a/Hunter.rbxl and b/Hunter.rbxl differ diff --git a/scripts/ArenaClient/HintProviders/Domination.luau b/scripts/ArenaClient/HintProviders/Domination.luau new file mode 100644 index 0000000..e3f1310 --- /dev/null +++ b/scripts/ArenaClient/HintProviders/Domination.luau @@ -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 diff --git a/scripts/ArenaClient/ModeFeedback.client.luau b/scripts/ArenaClient/ModeFeedback.client.luau new file mode 100644 index 0000000..492a8a1 --- /dev/null +++ b/scripts/ArenaClient/ModeFeedback.client.luau @@ -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= i / 10 then 0 else .8 + end + end + rateLabel.Text = string.format("СИНИЕ +%d/с ОРАНЖЕВЫЕ +%d/с", + (match:GetAttribute("ScoreRate_Blue") :: number?) or 0, (match:GetAttribute("ScoreRate_Orange") :: number?) or 0) + end + local modeHint = playerGui:GetAttribute("ModeHint") + if rule.id ~= "Siege" and typeof(modeHint) == "string" then text = modeHint end local tokens = (player:GetAttribute("ArenaTokens") :: number?) or 0 if player:GetAttribute("ArenaFlag") then text = "У вас флаг · Несите его на свою базу" elseif tokens > 0 then text = "Жетонов у вас: " .. tokens .. " · Вернитесь на базу" @@ -477,7 +528,7 @@ local function refreshObjective() objectiveStatus.Visible = text ~= "" objectiveStatus.Text = text objectiveStatus.TextColor3 = accent:Lerp(ink, .3) - local height = if siegeBar.Visible then 145 elseif objectiveStatus.Visible then 88 else 62 + local height = if siegeBar.Visible then 145 elseif dominationChips.Visible then 133 elseif objectiveStatus.Visible then 88 else 62 if height ~= objective.Size.Y.Offset then objective.Size = UDim2.fromOffset(widthOfCard, height) needsLayout = true @@ -1031,7 +1082,7 @@ local function updateClock() lastSecond, lastPhase, lastTeam, lastMode, lastInArena = seconds, phase, team, arenaMode, inArena lastStage = stage local rule = Rules.get(activeState():GetAttribute("Ruleset")) - if rule.id == "Siege" and inArena then refreshObjective() end + if inArena and (rule.id == "Siege" or rule.id == "Domination") then refreshObjective() end mode.Visible = true mode.Text = if intro then RoundStrings.untilStart elseif stage == "RoleSwap" then RoundStrings.swap elseif phase == "Vote" then "ГОЛОСОВАНИЕ" elseif phase == "Reveal" then "ДО НАЧАЛА РАУНДА" elseif phase == "Break" then (if activeState():GetAttribute("AllowModeChange") == false then "ДО НАЧАЛА РАУНДА" else "ДО ГОЛОСОВАНИЯ") @@ -1061,11 +1112,20 @@ local function updateClock() clockMotion:Play() refreshControls() end +local domConnections: {RBXScriptConnection} = {} +for _, key in {"A", "B", "C"} do + for _, attr in {"ZoneProgress_", "ZoneOwner_", "ZoneClaim_"} do + table.insert(domConnections, activeState():GetAttributeChangedSignal(attr .. key):Connect(refreshObjective)) + end +end +local modeHintConnection = playerGui:GetAttributeChangedSignal("ModeHint"):Connect(refreshObjective) local siegeHintConnection = playerGui:GetAttributeChangedSignal("SiegeHint"):Connect(refreshObjective) local timerConnection = RunService.Heartbeat:Connect(updateClock) script.Destroying:Once(function() timerConnection:Disconnect() siegeHintConnection:Disconnect() + modeHintConnection:Disconnect() + for _, connection in domConnections do connection:Disconnect() end if finalClockPulse then finalClockPulse:Cancel() end votingChanged:Disconnect() scoreboardFocus:Disconnect() diff --git a/scripts/Hunter/EventKinds.luau b/scripts/Hunter/EventKinds.luau index 9de6f5d..5bcc04c 100644 --- a/scripts/Hunter/EventKinds.luau +++ b/scripts/Hunter/EventKinds.luau @@ -1,7 +1,7 @@ --!strict return table.freeze({ ZoneStarted = "ZoneStarted", ZoneCaptured = "ZoneCaptured", ZoneContested = "ZoneContested", ZoneLost = "ZoneLost", - AllObjectivesTaken = "AllObjectivesTaken", FlagPicked = "FlagPicked", FlagDropped = "FlagDropped", + FullControl = "FullControl", AllObjectivesTaken = "AllObjectivesTaken", FlagPicked = "FlagPicked", FlagDropped = "FlagDropped", FlagReturned = "FlagReturned", FlagScored = "FlagScored", TokenDropped = "TokenDropped", TokensBanked = "TokensBanked", LeaderAssigned = "LeaderAssigned", LeaderDown = "LeaderDown", MiniRoundStarted = "MiniRoundStarted", MiniRoundEnded = "MiniRoundEnded", RoleSwap = "RoleSwap", Streak = "Streak", diff --git a/scripts/Hunter/Strings.luau b/scripts/Hunter/Strings.luau index e1fc9f5..82d5923 100644 --- a/scripts/Hunter/Strings.luau +++ b/scripts/Hunter/Strings.luau @@ -40,6 +40,14 @@ local siegeHints = { contested = "Устраните защитника.", decay = "Вернитесь в круг.", defBlock = "Удерживайте круг.", defFar = "Остановите захват.", }, } +local domination = table.freeze({ + height = "Точка на другом этаже.", blocked = "Из этой позиции не видно центр точки.", + contested = function(id: string) return "Точка " .. id .. " оспаривается — захват стоит." end, + free = function(id: string) return "Точка " .. id .. " свободна — займите её." end, + lost = function(id: string) return "Точка " .. id .. " потеряна — отбейте её!" end, + hold = function(n: number) return string.format("Держите точки — +%d очков в секунду.", n) end, + control = "ПОЛНЫЙ КОНТРОЛЬ", +}) local function flagCarrier(name: string): string return name .. " несёт флаг" end local round = table.freeze({ mode = "РЕЖИМ", fight = "В БОЙ!", final = "ФИНАЛЬНЫЙ РЫВОК", swap = "СМЕНА РОЛЕЙ", @@ -71,6 +79,7 @@ local round = table.freeze({ return table.freeze({ round = round, studs = studs, + domination = domination, hint = table.freeze({Siege = siegeHints}), team = team, clock = clock, bases = table.freeze({Blue = "БАЗА СИНИХ", Orange = "БАЗА ОРАНЖЕВЫХ"}), diff --git a/scripts/ModeRuntime/DominationRules.luau b/scripts/ModeRuntime/DominationRules.luau new file mode 100644 index 0000000..437d943 --- /dev/null +++ b/scripts/ModeRuntime/DominationRules.luau @@ -0,0 +1,10 @@ +--!strict +local Rules = {CAPTURE_SECONDS = 3} +function Rules.claimSide(blue: boolean, orange: boolean): ("Blue" | "Orange")? + return if blue == orange then nil elseif blue then "Blue" else "Orange" +end +function Rules.tick(now: number, nextAt: number): (boolean, number) + if now < nextAt then return false, nextAt end + return true, now + 1 +end +return table.freeze(Rules) diff --git a/scripts/ModeRuntime/Modes/Domination.luau b/scripts/ModeRuntime/Modes/Domination.luau index e9b9976..34383c5 100644 --- a/scripts/ModeRuntime/Modes/Domination.luau +++ b/scripts/ModeRuntime/Modes/Domination.luau @@ -8,22 +8,30 @@ local Zones = require(Runtime.Zones) local HotPoint = require(Runtime.Parent.HotPoint) type Fighter = Types.Fighter type Side = Types.Side -local SPEC: Zones.Spec = {radius = HotPoint.Radius, height = 8, sightHeight = 2.7, exclusiveHeight = true} +local Run = require(Runtime.DominationRules) +local RADIUS = HotPoint.Radius -- Общий радиус зон до отдельного баланса режима. +local SPEC: Zones.Spec = {radius = RADIUS, height = 8, sightHeight = 2.7, exclusiveHeight = true} local function start(ctx: Types.ModeContext): Types.ModeInstance local map = assert(ctx.map) local zones: {Common.Zone} = {} + local contested: {[number]: boolean} = {} + local affected: {[Player]: boolean} = {} + local state = ctx.state + local full: Side? = nil for i, site in {map.west, map.gallery, map.east} do local key = string.char(64 + i) local zone = Common.makeZone(ctx.folder, ctx.geometry, site, key) zone.marker.label.Text = key .. " · " .. site.name table.insert(zones, zone) end - local function presence(fighters: {Fighter}, zone: Common.Zone, geometry: RaycastParams, dt: number): (boolean, boolean, {Fighter}) + local function presence(fighters: {Fighter}, zone: Common.Zone, geometry: RaycastParams, dt: number, reasons: {[Player]: string}): (boolean, boolean, {Fighter}) local blue, orange = false, false local inside: {Fighter} = {} for _, fighter in fighters do - if Zones.classify(fighter.root.Position, zone.site.position, SPEC, geometry) == "Inside" then + local reason = Zones.classify(fighter.root.Position, zone.site.position, SPEC, geometry) + if reason ~= "Outside" and reasons[fighter.player] ~= "Inside" then reasons[fighter.player] = reason end + if reason == "Inside" then table.insert(inside, fighter) ctx.contribute(fighter.player, "holdSeconds", dt) if fighter.side == "Blue" then blue = true else orange = true end @@ -34,23 +42,27 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance local geometry = ctx.geometry local nextScore = ctx.liveAt + 1 return Common.instance(ctx, {step = function(now, dt, fighters) - local scoreNow = now >= nextScore - if scoreNow then nextScore = now + 1 end + local scoreNow, nextAt = Run.tick(now, nextScore) + nextScore = nextAt + local reasons: {[Player]: string} = {} local ownedBlue, ownedOrange = 0, 0 for index, zone in zones do - local b, o, inside = presence(fighters, zone, geometry, dt) - local side: Side? = if b == o then nil elseif b then "Blue" else "Orange" + local b, o, inside = presence(fighters, zone, geometry, dt, reasons) + local key = string.char(64 + index) + if b and o and not contested[index] then ctx.events.fire(Kinds.ZoneContested, {index = index, text = key}) end + contested[index] = b and o + local side = Run.claimSide(b, o) if side and side ~= zone.owner then if zone.claiming ~= side then zone.claiming, zone.progress = side, 0 ctx.cue(fighters, false, side) end zone.progress += dt - if zone.progress >= 3 then + if zone.progress >= Run.CAPTURE_SECONDS then local previous = zone.owner zone.owner, zone.progress = side, 0 for _, fighter in inside do ctx.contribute(fighter.player, "captures", 1) end - local payload = {side = side, index = index, text = zone.marker.label.Text, value = now - ctx.liveAt} + local payload = {side = side, index = index, text = zone.marker.label.Text, value = now - ctx.liveAt, at = zone.site.position} ctx.events.fire(Kinds.ZoneCaptured, payload) if previous then ctx.events.fire(Kinds.ZoneLost, {side = previous, index = index, text = payload.text}) end ctx.cue(fighters, true, nil) @@ -58,15 +70,41 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance else zone.claiming, zone.progress = nil, 0 end - Common.paint(zone.marker, Common.color(zone.owner)) + local shade = Common.color(zone.owner) + Common.paint(zone.marker, if contested[index] then shade:Lerp(Color3.fromRGB(80, 88, 103), .55) else shade) + state:SetAttribute("ZoneOwner_" .. key, zone.owner) + state:SetAttribute("ZoneClaim_" .. key, zone.claiming) + state:SetAttribute("ZoneProgress_" .. key, math.clamp(zone.progress / Run.CAPTURE_SECONDS, 0, 1)) + state:SetAttribute("ZoneContested_" .. key, contested[index]) if zone.owner == "Blue" then ownedBlue += 1 elseif zone.owner == "Orange" then ownedOrange += 1 end end + for player in affected do + if not reasons[player] then player:SetAttribute("DominationZone", nil); affected[player] = nil end + end + for player, reason in reasons do + affected[player] = true + player:SetAttribute("DominationZone", reason) + end + state:SetAttribute("ScoreRate_Blue", ownedBlue) + state:SetAttribute("ScoreRate_Orange", ownedOrange) + local owner: Side? = if ownedBlue == #zones then "Blue" elseif ownedOrange == #zones then "Orange" else nil + if owner ~= full then + full = owner + if owner then ctx.events.fire(Kinds.FullControl, {side = owner}) end + end if scoreNow then if ownedBlue > 0 then ctx.scoring.add("Blue", ownedBlue) end if ownedOrange > 0 then ctx.scoring.add("Orange", ownedOrange) end end ctx.status(Strings.dominationStatus(ownedBlue, ownedOrange)) return false + end, destroy = function() + for player in affected do player:SetAttribute("DominationZone", nil) end + for _, id in {"A", "B", "C"} do + for _, name in {"ZoneOwner_", "ZoneClaim_", "ZoneProgress_", "ZoneContested_"} do state:SetAttribute(name .. id, nil) end + end + state:SetAttribute("ScoreRate_Blue", nil) + state:SetAttribute("ScoreRate_Orange", nil) end}) end diff --git a/scripts/Tests/Domination.spec.luau b/scripts/Tests/Domination.spec.luau new file mode 100644 index 0000000..dae083c --- /dev/null +++ b/scripts/Tests/Domination.spec.luau @@ -0,0 +1,9 @@ +--!strict +return function(rules: any) + assert(rules.claimSide(true, true) == nil) + assert(rules.claimSide(true, false) == "Blue") + assert(rules.claimSide(false, true) == "Orange") + local due, nextAt = rules.tick(4.2, 1) + assert(due and nextAt == 5.2) + assert(not rules.tick(4.9, nextAt)) +end