diff --git a/Hunter.rbxl b/Hunter.rbxl index 977b60d..26ff68a 100644 Binary files a/Hunter.rbxl and b/Hunter.rbxl differ diff --git a/scripts/ArenaClient/HintProviders/TrophyHunt.luau b/scripts/ArenaClient/HintProviders/TrophyHunt.luau new file mode 100644 index 0000000..7c4cfae --- /dev/null +++ b/scripts/ArenaClient/HintProviders/TrophyHunt.luau @@ -0,0 +1,22 @@ +--!strict +local rs=game:GetService("ReplicatedStorage") +local S=require(rs.Hunter.Strings).trophyHints +local H=require(rs.Hunter.Hints) +local Provider={} +function Provider.candidates(_match: Instance, player: Player): {H.Hint} + local count=player:GetAttribute("ArenaTokens") + if typeof(count)=="number" and count>=3 then + return {{key="th_bank",text=string.format(S.carry,count),priority=70,ttl=.4}} + end + local root=player.Character and player.Character.PrimaryPart + local world=workspace:FindFirstChild("ProceduralArena") + local folder=world and world:FindFirstChild("MatchObjectives") + if not root or not folder then return {} end + for _,token in folder:GetChildren() do + if token.Name=="Tokens" and token:IsA("BasePart") and (root.Position-token.Position).Magnitude<18 then + return {{key="th_near",text=S.near,priority=30,ttl=.4}} + end + end + return {} +end +return Provider diff --git a/scripts/ArenaClient/ModeFeedback.client.luau b/scripts/ArenaClient/ModeFeedback.client.luau index a3a3dd5..4840ded 100644 --- a/scripts/ArenaClient/ModeFeedback.client.luau +++ b/scripts/ArenaClient/ModeFeedback.client.luau @@ -62,6 +62,15 @@ local function event(kind: string, p: any) elseif p.side == player:GetAttribute("ArenaTeam") then S.flagHints.picked else S.flagHints.enemyPicked bannerUntil = workspace:GetServerTimeNow() + 2.7 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} diff --git a/scripts/ArenaClient/TrophyCounter.client.luau b/scripts/ArenaClient/TrophyCounter.client.luau new file mode 100644 index 0000000..a94079b --- /dev/null +++ b/scripts/ArenaClient/TrophyCounter.client.luau @@ -0,0 +1,80 @@ +--!strict +local rs=game:GetService("ReplicatedStorage") +local Players=game:GetService("Players") +local RunService=game:GetService("RunService") +local TweenService=game:GetService("TweenService") +local UI=require(rs:WaitForChild("HunterUI") :: ModuleScript) +local Kinds=require(rs.Hunter.EventKinds) +local Router=require(script.Parent.EventRouter) +local player=Players.LocalPlayer +local match=rs:WaitForChild("ArenaRound"):WaitForChild("Procedural") +local gui=Instance.new("ScreenGui") +gui.Name,gui.DisplayOrder,gui.ResetOnSpawn="TrophyCounter",23,false +gui.Parent=player:WaitForChild("PlayerGui") +local plate=UI.plate(gui,"Coins",UDim2.new(1,-16,1,-80),UDim2.fromOffset(106,48),UI.Gold) +plate.AnchorPoint=Vector2.new(1,1) +local art=UI.element("GoldCoin",plate,UDim2.fromOffset(6,4),UDim2.fromOffset(40,40)) :: Frame +local rig=UI.bindCoin(art) +local label=UI.label(plate,"Count","×0",UDim2.fromOffset(47,0),UDim2.fromOffset(52,48),24,UI.Gold) +label.FontFace=UI.Display +local scale=Instance.new("UIScale",plate) +local bounce: Tween?=nil +local last=0 +local function update() + local count=player:GetAttribute("ArenaTokens") + local n=if typeof(count)=="number" then count else 0 + gui.Enabled=player:GetAttribute("InArena")==true and match:GetAttribute("Ruleset")=="TrophyHunt" and match:GetAttribute("Phase")=="Round" + label.Text="×"..n + if gui.Enabled and n>last then + if bounce then bounce:Cancel() end + scale.Scale=1.18 + bounce=TweenService:Create(scale,TweenInfo.new(.32,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Scale=1}) + bounce:Play() + end + last=n +end +local connections={player:GetAttributeChangedSignal("ArenaTokens"):Connect(update),player:GetAttributeChangedSignal("InArena"):Connect(update), + match:GetAttributeChangedSignal("Ruleset"):Connect(update),match:GetAttributeChangedSignal("Phase"):Connect(update)} +local draw=RunService.RenderStepped:Connect(function() + if not gui.Enabled then return end + local t=os.clock() + UI.spinCoin(rig,t*2,math.max(0,math.cos(t*2))*.55,t%1) +end) + +local pool: {Part}={} +local motions: {[Part]: Tween}={} +for i=1,6 do + local coin=Instance.new("Part") + coin.Name="TrophySpark" + coin.Shape,coin.Material,coin.Color=Enum.PartType.Cylinder,Enum.Material.Neon,UI.Gold + coin.Size=Vector3.new(.12,.62,.62) + coin.Anchored,coin.CanCollide,coin.CanQuery,coin.CanTouch=true,false,false,false + coin.Transparency=1 + coin.Parent=workspace + table.insert(pool,coin) +end +local off=Router.on(Kinds.TokenDropped,function(payload) + if not gui.Enabled or typeof(payload.at)~="Vector3" then return end + for i,coin in pool do + if motions[coin] then motions[coin]:Cancel() end + local a=i*math.pi/3 + local from=payload.at+Vector3.yAxis*.7 + coin.CFrame=CFrame.new(from)*CFrame.Angles(a,0,0) + coin.Transparency=.1 + local tween=TweenService:Create(coin,TweenInfo.new(.55,Enum.EasingStyle.Quad,Enum.EasingDirection.Out), + {CFrame=CFrame.new(from+Vector3.new(math.cos(a)*4,2.4,math.sin(a)*4))*CFrame.Angles(a,1.7,1),Transparency=1}) + motions[coin]=tween + tween:Play() + end +end) +update() +script.Destroying:Once(function() + draw:Disconnect() + for _, cn in connections do cn:Disconnect() end + off() + for _, coin in pool do + if motions[coin] then motions[coin]:Cancel() end + coin:Destroy() + end + gui:Destroy() +end) diff --git a/scripts/ArenaRoundHud.client.luau b/scripts/ArenaRoundHud.client.luau index 901db45..bf0ad04 100644 --- a/scripts/ArenaRoundHud.client.luau +++ b/scripts/ArenaRoundHud.client.luau @@ -533,10 +533,10 @@ local function refreshObjective() 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 .. " · Вернитесь на базу" + if player:GetAttribute("ArenaFlag") and typeof(modeHint) ~= "string" then text = "У вас флаг · Несите его на свою базу" + elseif tokens > 0 and typeof(modeHint) ~= "string" then text = "Жетонов у вас: " .. tokens .. " · Вернитесь на базу" elseif player:GetAttribute("ArenaLeader") then text = "Вы лидер · За вас дают 3 очка" - elseif rule.id == "TrophyHunt" then text = "" end + elseif rule.id == "TrophyHunt" and typeof(modeHint) ~= "string" then text = "" end objectiveStatus.Visible = text ~= "" objectiveStatus.Text = text objectiveStatus.TextColor3 = accent:Lerp(ink, .3) diff --git a/scripts/Hunter/EventKinds.luau b/scripts/Hunter/EventKinds.luau index 5bcc04c..d53c52b 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", + FlagReturned = "FlagReturned", FlagScored = "FlagScored", TokenDropped = "TokenDropped", TokensBanked = "TokensBanked", TokensLost = "TokensLost", 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 288e1a6..01984da 100644 --- a/scripts/Hunter/Strings.luau +++ b/scripts/Hunter/Strings.luau @@ -63,6 +63,10 @@ local flagHints = table.freeze({ base="НА СВОЮ БАЗУ",title="ФЛАГ",escortTitle="СОПРОВОДИТЕ НОСИТЕЛЯ", picked="ФЛАГ ВЗЯТ!", enemyPicked="СОПЕРНИКИ ВЗЯЛИ ФЛАГ!", scored="ФЛАГ ДОСТАВЛЕН! +1", }) +local trophyHints = table.freeze({ + carry="У вас %d жетонов — сдайте их на базе!", near="Рядом жетоны — подберите их.", + banked="СДАНО ЖЕТОНОВ ×%d", lost="Вы погибли — жетоны выпали.", +}) local function flagCarrier(name: string): string return name .. " несёт флаг" end local round = table.freeze({ mode = "РЕЖИМ", fight = "В БОЙ!", final = "ФИНАЛЬНЫЙ РЫВОК", swap = "СМЕНА РОЛЕЙ", @@ -97,6 +101,7 @@ return table.freeze({ domination = domination, hotHints = hotHints, flagHints = flagHints, + trophyHints = trophyHints, hint = table.freeze({Siege = siegeHints}), team = team, clock = clock, bases = table.freeze({Blue = "БАЗА СИНИХ", Orange = "БАЗА ОРАНЖЕВЫХ"}), diff --git a/scripts/ModeRuntime/Modes/TrophyHunt.luau b/scripts/ModeRuntime/Modes/TrophyHunt.luau index 0c6d282..6ef53c3 100644 --- a/scripts/ModeRuntime/Modes/TrophyHunt.luau +++ b/scripts/ModeRuntime/Modes/TrophyHunt.luau @@ -6,7 +6,9 @@ local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds) local Strings = require(game.ReplicatedStorage.Hunter.Strings) type Fighter = Types.Fighter local HotPoint = require(Runtime.Parent.HotPoint) -type Drop = {marker: Common.Marker, amount: number, expires: number} +local Rules = require(Runtime.TrophyRules) +local TweenService = game:GetService("TweenService") +type Drop = {marker: Common.Marker, amount: number, expires: number, fade: Tween?} local function start(ctx: Types.ModeContext): Types.ModeInstance local map, geometry, folder = assert(ctx.map), ctx.geometry, ctx.folder @@ -21,24 +23,31 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance local floor = floorAt(at) ctx.events.fire(Kinds.TokenDropped, {at = floor, value = amount}) for _, existing in tokens do - if Common.boundsAt(existing.marker.origin, floor, 3.5, 3) then + if Rules.canMerge(existing.marker.origin, floor) then existing.amount += amount - existing.expires = now + 42 + existing.expires = now + Rules.LIFETIME + if existing.fade then existing.fade:Cancel(); existing.fade = nil end + existing.marker.body.Transparency = .04 existing.marker.label.Text = Strings.tokens(existing.amount) return end end - if #tokens >= 60 then + 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 + 42}) + table.insert(tokens, {marker = Common.marker(folder, "Tokens", Strings.tokens(amount), floor, Common.gold, 1.55, true), 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 @@ -48,6 +57,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance 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 @@ -69,7 +79,10 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance if not amount then return end carried[player] = nil player:SetAttribute("ArenaTokens", nil) - if at then tokenDrop(at, amount, now) end + if at then + tokenDrop(at, amount, now) + ctx.events.fire(Kinds.TokensLost, {userId=player.UserId,value=amount}) + end end return Common.instance(ctx, { step = function(now, _, fighters) runTrophies(fighters, now); return false end, @@ -77,7 +90,10 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance if Common.sideOf(player) then tokenDrop(at, 1, now) end end, death = drop, leaving = drop, - destroy = function() for p in carried do p:SetAttribute("ArenaTokens", nil) end end, + 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/TrophyRules.luau b/scripts/ModeRuntime/TrophyRules.luau new file mode 100644 index 0000000..7146727 --- /dev/null +++ b/scripts/ModeRuntime/TrophyRules.luau @@ -0,0 +1,7 @@ +--!strict +local Rules = {LIFETIME = 42, FLASH_SECONDS = 8, MAX_DROPS = 60} +function Rules.canMerge(a: Vector3, b: Vector3): boolean + local d = a - b + return math.abs(d.Y) < 3 and d.X*d.X+d.Z*d.Z <= 3.5^2 +end +return table.freeze(Rules) diff --git a/scripts/Tests/TrophyRules.spec.luau b/scripts/Tests/TrophyRules.spec.luau new file mode 100644 index 0000000..26ff17a --- /dev/null +++ b/scripts/Tests/TrophyRules.spec.luau @@ -0,0 +1,6 @@ +--!strict +return function(rules: any) + assert(rules.canMerge(Vector3.zero,Vector3.new(3.5,2.99,0))) + assert(not rules.canMerge(Vector3.zero,Vector3.new(3.51,0,0))) + assert(not rules.canMerge(Vector3.zero,Vector3.new(0,3,0))) +end