Polish Citadel Assault objectives and results
This commit is contained in:
1 parent
d1c42a36b8
commit
c0b099e604
18 files changed
+555
-45
No files matched your search
@@ -6,7 +6,7 @@ local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
|
||||
local Strings = require(game.ReplicatedStorage.Hunter.Strings)
|
||||
local CollectionService = game:GetService("CollectionService")
|
||||
local Zones = require(Runtime.Zones)
|
||||
local HotPoint = require(Runtime.Parent.HotPoint)
|
||||
local Effects = require(Runtime.SiegeEffects)
|
||||
local Sites = require(Runtime.Parent.ArenaObjectiveSites)
|
||||
local SiegeConfig = require(game.ReplicatedStorage.CitadelAssaultConfig)
|
||||
local Capture = require(Runtime.Parent.CitadelCaptureService)
|
||||
@@ -14,15 +14,20 @@ local Score = require(Runtime.Parent.CitadelScoreService)
|
||||
local SiegeSpawn = require(Runtime.Parent.CitadelSpawnService)
|
||||
type Fighter = Types.Fighter
|
||||
type Side = Types.Side
|
||||
local SPEC: Zones.Spec = {radius = HotPoint.Radius, height = SiegeConfig.HEIGHT_TOLERANCE, sightHeight = SiegeConfig.SIGHT_HEIGHT}
|
||||
local SPEC: Zones.Spec = {radius = SiegeConfig.CAPTURE_RADIUS, height = SiegeConfig.HEIGHT_TOLERANCE, sightHeight = SiegeConfig.SIGHT_HEIGHT}
|
||||
|
||||
local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local map, world, geometry, folder, state = assert(ctx.map), ctx.world, ctx.geometry, ctx.folder, ctx.state
|
||||
local zones: {Common.Zone} = {}
|
||||
local visuals: {Effects.Rig} = {}
|
||||
local visibleIndex = 0
|
||||
local data = Instance.new("Folder")
|
||||
data.Name = "CitadelMatchState"
|
||||
data.Parent = state
|
||||
ctx.janitor.give(data)
|
||||
data:SetAttribute("Radius", SiegeConfig.CAPTURE_RADIUS)
|
||||
data:SetAttribute("BlueBase", map.blue)
|
||||
data:SetAttribute("OrangeBase", map.orange)
|
||||
local sites: {Sites.Site} = {map.ground, map.gallery, map.roof}
|
||||
for _, point in CollectionService:GetTagged("CitadelPoint") do
|
||||
if not point:IsA("BasePart") or not point:IsDescendantOf(world) then continue end
|
||||
@@ -32,25 +37,33 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
end
|
||||
end
|
||||
for i, site in sites do
|
||||
local zone = Common.makeZone(folder, geometry, site, "Checkpoint" .. i)
|
||||
local zone = Common.makeZone(folder, geometry, site, "Checkpoint" .. i, SiegeConfig.CAPTURE_RADIUS, Common.gold)
|
||||
zone.marker.body:SetAttribute("Index", i)
|
||||
zone.marker.body.Parent = nil
|
||||
ctx.janitor.give(zone.marker.body)
|
||||
table.insert(zones, zone)
|
||||
table.insert(visuals, Effects.new(zone.marker, folder, ctx.janitor))
|
||||
end
|
||||
zones[1].marker.body.Parent = folder
|
||||
data:SetAttribute("Total", #zones)
|
||||
local siegeTimes: Score.Ledger = {Blue = {}, Orange = {}}
|
||||
local siegeSide: Side = if SiegeConfig.FIRST_ATTACKER == "Orange" then "Orange" else "Blue"
|
||||
local siegeIndex, siegeProgress = 1, 0
|
||||
local siegeCaptureStarted = false
|
||||
local hadSiegeSwap = false
|
||||
local swapAt = SiegeConfig.ATTACK_DURATION
|
||||
local lastStatus: string? = nil
|
||||
local marked: {[Player]: boolean} = {}
|
||||
local function runSiege(members: {Player}, fighters: {Fighter}, now: number, dt: number): boolean
|
||||
local half = SiegeConfig.ATTACK_DURATION
|
||||
local elapsed = now - ctx.liveAt
|
||||
if elapsed >= half and not hadSiegeSwap then
|
||||
ctx.setStage("RoleSwap", ctx.liveAt + half + SiegeConfig.SWAP_FREEZE)
|
||||
if elapsed >= swapAt and not hadSiegeSwap then
|
||||
ctx.setStage("RoleSwap", ctx.liveAt + swapAt + SiegeConfig.SWAP_FREEZE)
|
||||
hadSiegeSwap = true
|
||||
for _, z in zones do z.marker.body.Parent = nil end
|
||||
for i, z in zones do
|
||||
visuals[i].hide()
|
||||
z.marker.body.Parent = nil
|
||||
end
|
||||
visibleIndex, lastStatus = 0, nil
|
||||
siegeSide, siegeIndex, siegeProgress = Common.opposite(siegeSide), 1, 0
|
||||
siegeCaptureStarted = false
|
||||
local arenaSites = map
|
||||
@@ -66,11 +79,11 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
character:PivotTo(CFrame.new(at + Vector3.yAxis * 4))
|
||||
end
|
||||
end
|
||||
local swap = elapsed >= half and elapsed < half + SiegeConfig.SWAP_FREEZE
|
||||
local attackStart = if hadSiegeSwap then half + SiegeConfig.SWAP_FREEZE else 0
|
||||
local swap = elapsed >= swapAt and elapsed < swapAt + SiegeConfig.SWAP_FREEZE
|
||||
local attackStart = if hadSiegeSwap then swapAt + SiegeConfig.SWAP_FREEZE else 0
|
||||
data:SetAttribute("Phase", if swap then "RoleSwap" elseif hadSiegeSwap then "Attack2" else "Attack1")
|
||||
data:SetAttribute("Attacker", siegeSide)
|
||||
data:SetAttribute("Seconds", math.clamp(math.ceil(half - (elapsed - attackStart)), 0, half))
|
||||
data:SetAttribute("Seconds", math.clamp(math.ceil((if hadSiegeSwap then half else swapAt) - (elapsed - attackStart)), 0, half))
|
||||
if swap then
|
||||
data:SetAttribute("Progress", 0)
|
||||
data:SetAttribute("Status", "Idle")
|
||||
@@ -78,16 +91,33 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
return false
|
||||
end
|
||||
if state:GetAttribute("RoundStage") == "RoleSwap" then ctx.setStage("Live") end
|
||||
if hadSiegeSwap and elapsed >= attackStart + half then return true end
|
||||
local attacker = Strings.team(siegeSide)
|
||||
local zone = zones[siegeIndex]
|
||||
data:SetAttribute("Index", siegeIndex)
|
||||
for player in marked do
|
||||
if not table.find(members, player) then
|
||||
player:SetAttribute("CitadelZone", nil)
|
||||
marked[player] = nil
|
||||
end
|
||||
end
|
||||
for _, player in members do marked[player] = true end
|
||||
if not zone then
|
||||
data:SetAttribute("Point", nil)
|
||||
data:SetAttribute("NextPoint", nil)
|
||||
data:SetAttribute("Status", "Complete")
|
||||
for player in marked do player:SetAttribute("CitadelZone", nil) end
|
||||
ctx.status(Strings.siegeComplete)
|
||||
return true
|
||||
return false
|
||||
end
|
||||
zone.marker.body.Parent = folder
|
||||
local visual = visuals[siegeIndex]
|
||||
if visibleIndex ~= siegeIndex then
|
||||
visibleIndex, lastStatus = siegeIndex, nil
|
||||
zone.marker.body.Parent = folder
|
||||
visual.show()
|
||||
ctx.events.fire(Kinds.ZoneStarted, {side = siegeSide, index = siegeIndex, text = zone.site.name, at = zone.site.position})
|
||||
end
|
||||
local updated: {[Player]: boolean} = {}
|
||||
local attack, defense = false, false
|
||||
local attackers: {Player} = {}
|
||||
for _, fighter in fighters do
|
||||
@@ -101,8 +131,10 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
defense = true
|
||||
end
|
||||
end
|
||||
updated[fighter.player] = true
|
||||
fighter.player:SetAttribute("CitadelZone", reason)
|
||||
end
|
||||
for player in marked do if not updated[player] then player:SetAttribute("CitadelZone", nil) end end
|
||||
local progress, phase = Capture.advance(siegeProgress, math.min(dt, math.max(0, elapsed - attackStart)), attack, defense,
|
||||
SiegeConfig.CAPTURE_TIME, SiegeConfig.DECAY_MULTIPLIER)
|
||||
if phase == "Capturing" and not siegeCaptureStarted then
|
||||
@@ -120,7 +152,15 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
data:SetAttribute("NextPoint", if nextZone then nextZone.site.position else nil)
|
||||
local percent = math.floor(progress / SiegeConfig.HUD_PROGRESS_STEP + 1e-8) * SiegeConfig.HUD_PROGRESS_STEP * 100
|
||||
ctx.status(Strings.siegeStatus(attacker, siegeIndex, #zones, percent, phase))
|
||||
Common.paint(zone.marker, if phase == "Contested" then Common.orange else Common.blue)
|
||||
local teamTint = Common.color(siegeSide)
|
||||
local tint = if phase == "Idle" then Common.gold elseif phase == "Contested" then SiegeConfig.CONTESTED_COLOR
|
||||
elseif phase == "Decaying" then teamTint:Lerp(Color3.fromRGB(150, 162, 182), .45) else teamTint
|
||||
Common.paint(zone.marker, tint)
|
||||
visual.update(tint, phase, progress, phase ~= lastStatus)
|
||||
if phase == "Contested" and lastStatus ~= phase then
|
||||
ctx.events.fire(Kinds.ZoneContested, {side = siegeSide, index = siegeIndex, at = zone.site.position})
|
||||
end
|
||||
lastStatus = phase
|
||||
if phase ~= "Captured" or not Score.record(siegeTimes, siegeSide, siegeIndex, elapsed - attackStart) then return false end
|
||||
ctx.scoring.add(siegeSide, SiegeConfig.POINTS_PER_OBJECTIVE, Kinds.ZoneCaptured)
|
||||
for _, player in attackers do ctx.contribute(player, "captures", 1) end
|
||||
@@ -128,12 +168,16 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
ctx.cue(fighters, true, nil)
|
||||
siegeCaptureStarted = false
|
||||
data:SetAttribute(siegeSide .. "Time" .. siegeIndex, elapsed - attackStart)
|
||||
zone.marker.body.Parent = nil
|
||||
visual.capture(teamTint)
|
||||
siegeIndex += 1
|
||||
siegeProgress = 0
|
||||
if siegeIndex > #zones then
|
||||
ctx.events.fire(Kinds.AllObjectivesTaken, {side = siegeSide})
|
||||
return true
|
||||
if SiegeConfig.EARLY_FINISH_WHEN_ALL_TAKEN then
|
||||
if hadSiegeSwap then return true end
|
||||
swapAt = elapsed
|
||||
state:SetAttribute("SiegeEndsAt", ctx.liveAt + swapAt + SiegeConfig.SWAP_FREEZE + half)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -144,8 +188,11 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
state:SetAttribute("CitadelResultReason", reason)
|
||||
return winner, reason
|
||||
end,
|
||||
death = function(p) p:SetAttribute("CitadelZone", nil) end,
|
||||
leaving = function(p) marked[p] = nil; p:SetAttribute("CitadelZone", nil) end,
|
||||
destroy = function()
|
||||
for _, p in ctx.members() do p:SetAttribute("CitadelZone", nil) end
|
||||
state:SetAttribute("SiegeEndsAt", nil)
|
||||
for p in marked do p:SetAttribute("CitadelZone", nil) end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user