diff --git a/Hunter.rbxl b/Hunter.rbxl index 0561a04..990086c 100644 Binary files a/Hunter.rbxl and b/Hunter.rbxl differ diff --git a/scripts/ArenaClient/HintProviders/TeamDeathmatch.luau b/scripts/ArenaClient/HintProviders/TeamDeathmatch.luau new file mode 100644 index 0000000..7e30b0a --- /dev/null +++ b/scripts/ArenaClient/HintProviders/TeamDeathmatch.luau @@ -0,0 +1,14 @@ +--!strict +local rs=game:GetService("ReplicatedStorage") +local H=require(rs.Hunter.Hints) +local Rules=require(rs.Hunter.TeamDeathmatchRules) +local S=require(rs.Hunter.Strings).teamDeathmatch +return {candidates=function(match: Instance, player: Player): {H.Hint} + if match:GetAttribute("RoundStage")~="FinalPush" then return {} end + local own=player:GetAttribute("ArenaTeam") + if own~="Blue" and own~="Orange" then return {} end + local rival=if own=="Blue" then "Orange" else "Blue" + local n=Rules.chaseGap((match:GetAttribute(own.."Score") :: number?) or 0,(match:GetAttribute(rival.."Score") :: number?) or 0) + if n then return {{key="tdm_gap",text=string.format(S.chase,n),priority=60,ttl=.4}} end + return {} +end} diff --git a/scripts/ArenaClient/ModeFeedback.client.luau b/scripts/ArenaClient/ModeFeedback.client.luau index 4ea5aeb..a109e82 100644 --- a/scripts/ArenaClient/ModeFeedback.client.luau +++ b/scripts/ArenaClient/ModeFeedback.client.luau @@ -62,6 +62,12 @@ 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 == "TeamDeathmatch" and kind == Kinds.Streak then + contour:SetAttribute("Accent",tone) + title.Text=string.format(S.teamDeathmatch.streak,p.text or "",p.value or 0) + bannerUntil=workspace:GetServerTimeNow()+2.7 + if p.userId~=player.UserId then Sounds.sound("RoundStart") end + end if id == "HuntLeader" and (kind == Kinds.LeaderAssigned or kind == Kinds.LeaderDown) then local now=workspace:GetServerTimeNow() if kind == Kinds.LeaderDown or now>=bannerUntil then diff --git a/scripts/Hunter/Strings.luau b/scripts/Hunter/Strings.luau index c0bcaa6..1d16c06 100644 --- a/scripts/Hunter/Strings.luau +++ b/scripts/Hunter/Strings.luau @@ -77,6 +77,10 @@ local leaderHints = table.freeze({ self="Вы лидер — за вас дают 3 очка.", ally="Прикройте лидера: %s", enemy="Лидер соперников: %s", new="НОВЫЙ ЛИДЕР · %s", down="ЛИДЕР УСТРАНЁН +3", }) +local teamDeathmatch = table.freeze({ + chase="Отставание %d — время рисковать!", + streak="%s · СЕРИЯ %d", +}) local function flagCarrier(name: string): string return name .. " несёт флаг" end local round = table.freeze({ mode = "РЕЖИМ", fight = "В БОЙ!", final = "ФИНАЛЬНЫЙ РЫВОК", swap = "СМЕНА РОЛЕЙ", @@ -114,6 +118,7 @@ return table.freeze({ trophyHints = trophyHints, lifeHints = lifeHints, leaderHints = leaderHints, + teamDeathmatch = teamDeathmatch, hint = table.freeze({Siege = siegeHints}), team = team, clock = clock, bases = table.freeze({Blue = "БАЗА СИНИХ", Orange = "БАЗА ОРАНЖЕВЫХ"}), @@ -150,5 +155,6 @@ return table.freeze({ TokensBanked = function(p: any) return string.format("%s сдали жетоны ×%d", team(p.side), p.value or 0) end, LeaderDown = function(p: any) return team(p.side) .. " устранили лидера (+3)" end, RoleSwap = function(_: any) return "Команды меняются ролями" end, + Streak = function(p: any) return string.format(teamDeathmatch.streak,p.text or "Игрок",p.value or 0) end, }), }) diff --git a/scripts/Hunter/TeamDeathmatchRules.luau b/scripts/Hunter/TeamDeathmatchRules.luau new file mode 100644 index 0000000..bf77d4d --- /dev/null +++ b/scripts/Hunter/TeamDeathmatchRules.luau @@ -0,0 +1,12 @@ +--!strict +local Rules={} +local STREAK={[3]=true,[5]=true,[7]=true} +local CHASE_GAP=5 +function Rules.announce(kills: number): boolean + return STREAK[kills]==true +end +function Rules.chaseGap(own: number, rival: number): number? + local gap=rival-own + return if gap>=CHASE_GAP then gap else nil +end +return table.freeze(Rules) diff --git a/scripts/ModeRuntime/Modes/TeamDeathmatch.luau b/scripts/ModeRuntime/Modes/TeamDeathmatch.luau index 4b283e4..d251220 100644 --- a/scripts/ModeRuntime/Modes/TeamDeathmatch.luau +++ b/scripts/ModeRuntime/Modes/TeamDeathmatch.luau @@ -1,11 +1,19 @@ --!strict local Types = require(script.Parent.Parent.Types) local Common = require(script.Parent.Parent.Common) +local Hunter=game.ReplicatedStorage.Hunter +local Rules=require(Hunter.TeamDeathmatchRules) +local Kinds=require(Hunter.EventKinds) local function start(ctx: Types.ModeContext): Types.ModeInstance return Common.instance(ctx, {kill = function(player: Player) local side = Common.sideOf(player) - if side then ctx.scoring.add(side, 1, "Elimination", player) end + if not side then return end + ctx.scoring.add(side, 1, "Elimination", player) + local streak=player:GetAttribute("StreakKills") + if typeof(streak)=="number" and Rules.announce(streak) then + ctx.events.fire(Kinds.Streak,{side=side,userId=player.UserId,text=player.DisplayName,value=streak}) + end end}) end diff --git a/scripts/SniperShots.server.luau b/scripts/SniperShots.server.luau index 838d324..7f05fbe 100644 --- a/scripts/SniperShots.server.luau +++ b/scripts/SniperShots.server.luau @@ -75,13 +75,13 @@ local function recordArenaKill(player: Player, victim: Player, origin: Vector3, Stats.add(player, "kills", 1) player:SetAttribute("RoundKills", ((player:GetAttribute("RoundKills") :: number?) or 0) + 1) state:SetAttribute(scoreAttribute, ((state:GetAttribute(scoreAttribute) :: number?) or 0) + 1) + local streak = ((player:GetAttribute("StreakKills") :: number?) or 0) + 1 + player:SetAttribute("StreakUntil", now + (round:GetAttribute("StreakWindow") :: number)) + player:SetAttribute("StreakKills", streak) local match = Objectives.current(mode) if match then match.kill(player, victim, origin, now) end TrophyDrops.spawn(player, origin) PowerDrops.spawn(origin, nil, mode) - local streak = ((player:GetAttribute("StreakKills") :: number?) or 0) + 1 - player:SetAttribute("StreakUntil", now + (round:GetAttribute("StreakWindow") :: number)) - player:SetAttribute("StreakKills", streak) return streak end diff --git a/scripts/Tests/TeamDeathmatchRules.spec.luau b/scripts/Tests/TeamDeathmatchRules.spec.luau new file mode 100644 index 0000000..ca18a8c --- /dev/null +++ b/scripts/Tests/TeamDeathmatchRules.spec.luau @@ -0,0 +1,6 @@ +--!strict +return function(rules: any) + for i=0,9 do assert(rules.announce(i)==(i==3 or i==5 or i==7)) end + assert(rules.chaseGap(10,14)==nil and rules.chaseGap(10,15)==5) + assert(rules.chaseGap(0,17)==17 and rules.chaseGap(8,1)==nil) +end