Polish Domination zone control and HUD
This commit is contained in:
1 parent
c0b099e604
commit
d3648c485b
9 files changed
+271
-13
No files matched your search
BIN
Binary file not shown.
@@ -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
|
||||
@@ -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<bannerUntil and pg:GetAttribute("HunterVoting")~=true and (not results or results:GetAttribute("LiveScoreboardOpen")~=true)
|
||||
end)
|
||||
script.Destroying:Once(function()
|
||||
heartbeat:Disconnect()
|
||||
for _, remove in subscriptions do remove() end
|
||||
if effect then effect:Cancel() end
|
||||
wave:Destroy()
|
||||
gui:Destroy()
|
||||
end)
|
||||
@@ -161,6 +161,36 @@ siegeBar.BackgroundColor3 = Color3.fromRGB(34, 45, 65)
|
||||
siegeBar.BorderSizePixel = 0
|
||||
siegeBar.Visible = false
|
||||
siegeBar.Parent = objective
|
||||
local dominationChips = Instance.new("Frame")
|
||||
dominationChips.Name = "DominationChips"
|
||||
dominationChips.Position = UDim2.fromOffset(15, 88)
|
||||
dominationChips.Size = UDim2.new(1, -30, 0, 40)
|
||||
dominationChips.BackgroundTransparency = 1
|
||||
dominationChips.Visible = false
|
||||
dominationChips.Parent = objective
|
||||
local domSlots: {[string]: {chip: GuiObject, text: TextLabel, ticks: {Frame}}} = {}
|
||||
for i, key in {"A", "B", "C"} do
|
||||
local chip = UI.element("ScoreChip", dominationChips, UDim2.new((i - 1) / 3, 0, 0, 0), UDim2.new(1 / 3, -6, 0, 25))
|
||||
local templateValue = chip:FindFirstChild("Value")
|
||||
if templateValue and templateValue:IsA("TextLabel") then templateValue.Visible = false end
|
||||
local text = UI.label(chip, "Zone", key, UDim2.new(), UDim2.fromScale(1, 1), 17, ink)
|
||||
local ticks: {Frame} = {}
|
||||
for segment = 1, 10 do
|
||||
local angle = (segment - 1) * math.pi / 5 - math.pi / 2
|
||||
local dot = Instance.new("Frame")
|
||||
dot.Name = "CaptureProgress"
|
||||
dot.AnchorPoint = Vector2.new(.5, .5)
|
||||
dot.Position = UDim2.new(.5, math.cos(angle) * 12, .5, math.sin(angle) * 10)
|
||||
dot.Size = UDim2.fromOffset(3, 3)
|
||||
dot.BorderSizePixel = 0
|
||||
dot.Visible = false
|
||||
dot.Parent = chip
|
||||
Instance.new("UICorner", dot).CornerRadius = UDim.new(1, 0)
|
||||
table.insert(ticks, dot)
|
||||
end
|
||||
domSlots[key] = {chip = chip, text = text, ticks = ticks}
|
||||
end
|
||||
local rateLabel = UI.label(dominationChips, "ScoreRate", "", UDim2.fromOffset(0, 26), UDim2.new(1, 0, 0, 17), 13, muted)
|
||||
local siegeSteps = UI.label(objective, "SiegeSteps", "", UDim2.fromOffset(16, 96), UDim2.new(1, -32, 0, 22), 15, UI.Gold)
|
||||
siegeSteps.Visible = false
|
||||
local siegeChip = UI.label(objective, "SiegeChip", "", UDim2.fromOffset(16, 119), UDim2.new(1, -32, 0, 21), 14, UI.Mint)
|
||||
@@ -415,6 +445,7 @@ local function refreshObjective()
|
||||
local needsLayout = visible ~= objective.Visible
|
||||
objective.Visible = visible
|
||||
siegeBar.Visible, siegeSteps.Visible, siegeChip.Visible = false, false, false
|
||||
dominationChips.Visible = false
|
||||
if visible then
|
||||
local rule = Rules.get(match:GetAttribute("Ruleset"))
|
||||
local accent = if player:GetAttribute("ArenaTeam") == "Orange" then orange else blue
|
||||
@@ -469,6 +500,26 @@ local function refreshObjective()
|
||||
siegeChip.TextColor3 = if zone == "Inside" then UI.Mint else UI.Gold
|
||||
end
|
||||
end
|
||||
if rule.id == "Domination" then
|
||||
dominationChips.Visible = true
|
||||
for key, slot in domSlots do
|
||||
local owner = match:GetAttribute("ZoneOwner_" .. key)
|
||||
local claimant = match:GetAttribute("ZoneClaim_" .. key)
|
||||
local progress = (match:GetAttribute("ZoneProgress_" .. key) :: number?) or 0
|
||||
local ownerTint = if owner == "Blue" then blue elseif owner == "Orange" then orange else muted
|
||||
slot.text.TextColor3 = ownerTint
|
||||
slot.chip.BackgroundColor3 = panelColor:Lerp(ownerTint, .28)
|
||||
for i, tick in slot.ticks do
|
||||
tick.Visible = typeof(claimant) == "string"
|
||||
tick.BackgroundColor3 = if claimant == "Blue" then blue else orange
|
||||
tick.BackgroundTransparency = if progress + 1e-7 >= 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()
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 = "БАЗА ОРАНЖЕВЫХ"}),
|
||||
|
||||
@@ -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)
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user