Polish Hunt Leader tracking and feedback

This commit is contained in:
Leshyi committed 2026-11-30 00:05:33 +05:00
1 parent ebe8db5359
commit 7a1c80c22a
8 files changed
+85 -8

No files matched your search

BIN
View File
Binary file not shown.
@@ -0,0 +1,35 @@
--!strict
local rs=game:GetService("ReplicatedStorage")
local H=require(rs.Hunter.Hints)
local S=require(rs.Hunter.Strings).leaderHints
local Provider={}
local function sides(player: Player): (string,string)
if player:GetAttribute("ArenaTeam")=="Orange" then return "Orange","Blue" end
return "Blue","Orange"
end
function Provider.candidates(match: Instance, player: Player): {H.Hint}
if player:GetAttribute("ArenaLeader")==true then return {{key="hl_self",text=S.self,priority=80,ttl=.4}} end
local own,enemy=sides(player)
local ally=match:GetAttribute("LeaderName_"..own)
local opponent=match:GetAttribute("LeaderName_"..enemy)
local root=player.Character and player.Character.PrimaryPart
local target=match:GetAttribute("LeaderPosition_"..enemy)
local nearby=root and typeof(target)=="Vector3" and (root.Position-target).Magnitude<95
if typeof(opponent)=="string" and (nearby or typeof(ally)~="string") then
return {{key="hl_enemy",text=string.format(S.enemy,opponent),priority=60,ttl=.4}}
end
if typeof(ally)=="string" then return {{key="hl_ally",text=string.format(S.ally,ally),priority=50,ttl=.4}} end
return {}
end
function Provider.target(match: Instance, player: Player): (Vector3?,string?,string?)
if player:GetAttribute("ArenaLeader")==true then return nil end
local own=sides(player)
local point=match:GetAttribute("LeaderPosition_"..own)
local name=match:GetAttribute("LeaderName_"..own)
return if typeof(point)=="Vector3" then point else nil, if typeof(name)=="string" then string.format(S.ally,name) else nil, own
end
function Provider.highlight(_match: Instance, viewer: Player, member: Player): boolean
return member:GetAttribute("InArena")==true and member:GetAttribute("ArenaLeader")==true
and member:GetAttribute("ArenaTeam")~=viewer:GetAttribute("ArenaTeam")
end
return Provider
@@ -62,6 +62,18 @@ local function event(kind: string, p: any)
elseif p.side == player:GetAttribute("ArenaTeam") then S.flagHints.picked else S.flagHints.enemyPicked elseif p.side == player:GetAttribute("ArenaTeam") then S.flagHints.picked else S.flagHints.enemyPicked
bannerUntil = workspace:GetServerTimeNow() + 2.7 bannerUntil = workspace:GetServerTimeNow() + 2.7
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
contour:SetAttribute("Accent",tone)
title.Text=if kind==Kinds.LeaderDown then S.leaderHints.down else string.format(S.leaderHints.new,p.text or "")
bannerUntil=now+2.5
end
if kind==Kinds.LeaderDown then
Sounds.sound("HotPointCaptured")
if typeof(p.at)=="Vector3" then showWave(p.at,tone) end
end
end
if id == "OneLife" and (kind == Kinds.MiniRoundStarted or kind == Kinds.MiniRoundEnded) then if id == "OneLife" and (kind == Kinds.MiniRoundStarted or kind == Kinds.MiniRoundEnded) then
contour:SetAttribute("Accent",tone) contour:SetAttribute("Accent",tone)
local copy=S.lifeHints local copy=S.lifeHints
+1 -1
View File
@@ -548,7 +548,7 @@ local function refreshObjective()
local tokens = (player:GetAttribute("ArenaTokens") :: number?) or 0 local tokens = (player:GetAttribute("ArenaTokens") :: number?) or 0
if player:GetAttribute("ArenaFlag") and typeof(modeHint) ~= "string" then text = "У вас флаг · Несите его на свою базу" if player:GetAttribute("ArenaFlag") and typeof(modeHint) ~= "string" then text = "У вас флаг · Несите его на свою базу"
elseif tokens > 0 and typeof(modeHint) ~= "string" then text = "Жетонов у вас: " .. tokens .. " · Вернитесь на базу" elseif tokens > 0 and typeof(modeHint) ~= "string" then text = "Жетонов у вас: " .. tokens .. " · Вернитесь на базу"
elseif player:GetAttribute("ArenaLeader") then text = "Вы лидер · За вас дают 3 очка" elseif player:GetAttribute("ArenaLeader") and typeof(modeHint) ~= "string" then text = "Вы лидер · За вас дают 3 очка"
elseif rule.id == "TrophyHunt" and typeof(modeHint) ~= "string" then text = "" end elseif rule.id == "TrophyHunt" and typeof(modeHint) ~= "string" then text = "" end
objectiveStatus.Visible = text ~= "" objectiveStatus.Visible = text ~= ""
objectiveStatus.Text = text objectiveStatus.Text = text
+5
View File
@@ -73,6 +73,10 @@ local lifeHints = table.freeze({
win = "%s выиграли мини-раунд (%d против %d)", draw = "МИНИ-РАУНД ВНИЧЬЮ", win = "%s выиграли мини-раунд (%d против %d)", draw = "МИНИ-РАУНД ВНИЧЬЮ",
alive = "ЖИВЫ %d · %d", alive = "ЖИВЫ %d · %d",
}) })
local leaderHints = table.freeze({
self="Вы лидер — за вас дают 3 очка.", ally="Прикройте лидера: %s", enemy="Лидер соперников: %s",
new="НОВЫЙ ЛИДЕР · %s", down="ЛИДЕР УСТРАНЁН +3",
})
local function flagCarrier(name: string): string return name .. " несёт флаг" end local function flagCarrier(name: string): string return name .. " несёт флаг" end
local round = table.freeze({ local round = table.freeze({
mode = "РЕЖИМ", fight = "В БОЙ!", final = "ФИНАЛЬНЫЙ РЫВОК", swap = "СМЕНА РОЛЕЙ", mode = "РЕЖИМ", fight = "В БОЙ!", final = "ФИНАЛЬНЫЙ РЫВОК", swap = "СМЕНА РОЛЕЙ",
@@ -109,6 +113,7 @@ return table.freeze({
flagHints = flagHints, flagHints = flagHints,
trophyHints = trophyHints, trophyHints = trophyHints,
lifeHints = lifeHints, lifeHints = lifeHints,
leaderHints = leaderHints,
hint = table.freeze({Siege = siegeHints}), hint = table.freeze({Siege = siegeHints}),
team = team, clock = clock, team = team, clock = clock,
bases = table.freeze({Blue = "БАЗА СИНИХ", Orange = "БАЗА ОРАНЖЕВЫХ"}), bases = table.freeze({Blue = "БАЗА СИНИХ", Orange = "БАЗА ОРАНЖЕВЫХ"}),
+9
View File
@@ -0,0 +1,9 @@
--!strict
local Rules = {}
function Rules.points(isLeader: boolean): number
return if isLeader then 3 else 1
end
function Rules.nextIndex(index: number, count: number, sameAsPrevious: boolean): number
return if count > 1 and sameAsPrevious then index%count+1 else index
end
return table.freeze(Rules)
+18 -7
View File
@@ -6,10 +6,12 @@ local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
local Strings = require(game.ReplicatedStorage.Hunter.Strings) local Strings = require(game.ReplicatedStorage.Hunter.Strings)
type Fighter = Types.Fighter type Fighter = Types.Fighter
type Side = Types.Side type Side = Types.Side
local Rules = require(Runtime.LeaderRules)
local rng = Random.new() local rng = Random.new()
local function start(ctx: Types.ModeContext): Types.ModeInstance local function start(ctx: Types.ModeContext): Types.ModeInstance
local leaders: {[Side]: Player} = {} local leaders: {[Side]: Player} = {}
local state = ctx.state
local previousLeader: {[Side]: Player} = {} local previousLeader: {[Side]: Player} = {}
local leaderLabels: {[Player]: BillboardGui} = {} local leaderLabels: {[Player]: BillboardGui} = {}
local function clearLeader(side: Side) local function clearLeader(side: Side)
@@ -17,6 +19,8 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
if not p then return end if not p then return end
previousLeader[side] = p previousLeader[side] = p
leaders[side] = nil leaders[side] = nil
state:SetAttribute("LeaderName_"..side,nil)
state:SetAttribute("LeaderPosition_"..side,nil)
p:SetAttribute("ArenaLeader", nil) p:SetAttribute("ArenaLeader", nil)
local badge = leaderLabels[p] local badge = leaderLabels[p]
if badge then badge:Destroy() end if badge then badge:Destroy() end
@@ -29,17 +33,22 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
for _, f in fighters do for _, f in fighters do
if f.side ~= side then continue end if f.side ~= side then continue end
table.insert(roster, f) table.insert(roster, f)
if f.player == leaders[side] then present = true end if f.player == leaders[side] then
present = true
state:SetAttribute("LeaderPosition_"..side,f.root.Position)
end
end end
if present then continue end if present then continue end
clearLeader(side) clearLeader(side)
if #roster == 0 then continue end if #roster == 0 then continue end
local pick = rng:NextInteger(1, #roster) local pick = rng:NextInteger(1, #roster)
if #roster > 1 and roster[pick].player == previousLeader[side] then pick = pick % #roster + 1 end pick = Rules.nextIndex(pick,#roster,roster[pick].player == previousLeader[side])
local p = roster[pick].player local p = roster[pick].player
local head = p.Character and p.Character:FindFirstChild("Head") local head = p.Character and p.Character:FindFirstChild("Head")
if not head or not head:IsA("BasePart") then continue end if not head or not head:IsA("BasePart") then continue end
leaders[side] = p leaders[side] = p
state:SetAttribute("LeaderName_"..side,p.DisplayName)
state:SetAttribute("LeaderPosition_"..side,roster[pick].root.Position)
p:SetAttribute("ArenaLeader", true) p:SetAttribute("ArenaLeader", true)
leaderLabels[p] = Common.label(head, Strings.leaderLabel, Common.gold, 2.7).Parent :: BillboardGui leaderLabels[p] = Common.label(head, Strings.leaderLabel, Common.gold, 2.7).Parent :: BillboardGui
ctx.events.fire(Kinds.LeaderAssigned, {side = side, userId = p.UserId, text = p.DisplayName}) ctx.events.fire(Kinds.LeaderAssigned, {side = side, userId = p.UserId, text = p.DisplayName})
@@ -49,21 +58,23 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
end end
return Common.instance(ctx, { return Common.instance(ctx, {
step = function(_, _, fighters) updateLeaders(fighters); return false end, step = function(_, _, fighters) updateLeaders(fighters); return false end,
kill = function(player, victim) kill = function(player, victim, at)
local side = Common.sideOf(player) local side = Common.sideOf(player)
if not side then return end if not side then return end
local target = Common.opposite(side) local target = Common.opposite(side)
local bonus = leaders[target] == victim local bonus = leaders[target] == victim
ctx.scoring.add(side, if bonus then 3 else 1, if bonus then Kinds.LeaderDown else "Elimination", player) ctx.scoring.add(side, Rules.points(bonus), if bonus then Kinds.LeaderDown else "Elimination", player)
if bonus then if bonus then
ctx.contribute(player, "leaderKills", 1) ctx.contribute(player, "leaderKills", 1)
clearLeader(target) clearLeader(target)
ctx.events.fire(Kinds.LeaderDown, {side = side, userId = player.UserId, text = victim.DisplayName}) ctx.events.fire(Kinds.LeaderDown, {side = side, userId = player.UserId, text = victim.DisplayName, at = at})
end end
end, end,
death = function(player)
for _, side in Common.sides do if leaders[side] == player then clearLeader(side) end end
end,
leaving = function(player) leaving = function(player)
local side = Common.sideOf(player) for _, side in Common.sides do if leaders[side] == player then clearLeader(side) end end
if side and leaders[side] == player then clearLeader(side) end
end, end,
destroy = function() for _, side in Common.sides do clearLeader(side) end end, destroy = function() for _, side in Common.sides do clearLeader(side) end end,
}) })
+5
View File
@@ -0,0 +1,5 @@
--!strict
return function(rules: any)
assert(rules.points(false)==1 and rules.points(true)==3)
assert(rules.nextIndex(1,1,true)==1 and rules.nextIndex(2,2,true)==1 and rules.nextIndex(2,3,false)==2)
end