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
@@ -67,9 +67,10 @@ local function marker(parent: Instance, id: string, name: string, at: Vector3, t
|
||||
return {body = part, label = label(part, name, tint, if tall then 2.1 else 4, id ~= "Tokens"), origin = at}
|
||||
end
|
||||
|
||||
local function ring(parent: Instance, id: string, name: string, at: Vector3, tint: Color3): Marker
|
||||
local mark = marker(parent, id, name, at, tint, HotPoint.Radius * 2)
|
||||
local recolor = HotPoint.attachRing(mark)
|
||||
local function ring(parent: Instance, id: string, name: string, at: Vector3, tint: Color3, radius: number?): Marker
|
||||
local r = radius or HotPoint.Radius
|
||||
local mark = marker(parent, id, name, at, tint, r * 2)
|
||||
local recolor = HotPoint.attachRing(mark, r)
|
||||
mark.recolor = recolor
|
||||
recolor(tint)
|
||||
return mark
|
||||
@@ -89,9 +90,12 @@ end
|
||||
local function visibleAt(fighter: Fighter, at: Vector3, geometry: RaycastParams): boolean
|
||||
return workspace:Raycast(fighter.root.Position, at - fighter.root.Position, geometry) == nil
|
||||
end
|
||||
local function makeZone(folder: Folder, geometry: RaycastParams, site: Sites.Site, name: string): Zone
|
||||
site = {name = site.name, position = Sites.clearCircle(site.position, geometry, HotPoint.Radius)}
|
||||
return {site = site, marker = ring(folder, name, site.name, site.position, neutral), owner = nil, claiming = nil, progress = 0}
|
||||
local function makeZone(folder: Folder, geometry: RaycastParams, site: Sites.Site, name: string, radius: number?, tint: Color3?): Zone
|
||||
local r = radius or HotPoint.Radius
|
||||
local center, fits = Sites.clearCircle(site.position, geometry, r)
|
||||
if radius and not fits then warn("Нет свободного места для рубежа:", site.name) end
|
||||
site = {name = site.name, position = center}
|
||||
return {site = site, marker = ring(folder, name, site.name, center, tint or neutral, r), owner = nil, claiming = nil, progress = 0}
|
||||
end
|
||||
local function bases(folder: Folder, geometry: RaycastParams, map: Sites.Map)
|
||||
map.blue = Sites.clearCircle(map.blue, geometry, HotPoint.Radius)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
--!strict
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local Runtime = script.Parent
|
||||
local Common = require(Runtime.Common)
|
||||
local Types = require(Runtime.Types)
|
||||
local Config = require(game.ReplicatedStorage.CitadelAssaultConfig)
|
||||
export type Rig = {show: () -> (), hide: () -> (), update: (Color3, string, number, boolean) -> (), capture: (Color3) -> ()}
|
||||
|
||||
local function newPart(name: string, parent: Instance): Part
|
||||
local p = Instance.new("Part")
|
||||
p.Name, p.Shape, p.Material = name, Enum.PartType.Cylinder, Enum.Material.Neon
|
||||
p.CanCollide, p.CanQuery, p.CanTouch, p.Anchored, p.CastShadow = false, false, false, true, false
|
||||
p.Transparency = 1
|
||||
p.Parent = parent
|
||||
return p
|
||||
end
|
||||
|
||||
local Effects = {}
|
||||
function Effects.new(mark: Common.Marker, folder: Folder, janitor: Types.Janitor): Rig
|
||||
local root = Instance.new("Folder")
|
||||
root.Name = "SiegeLight"
|
||||
root.Parent = folder
|
||||
local column = newPart("Column", root)
|
||||
local wave = newPart("Shockwave", root)
|
||||
local anchor = Instance.new("Attachment")
|
||||
anchor.Parent = wave
|
||||
local sparks = Instance.new("ParticleEmitter")
|
||||
sparks.Texture = "rbxasset://textures/particles/sparkles_main.dds"
|
||||
sparks.Speed, sparks.Lifetime, sparks.Rate = NumberRange.new(12, 25), NumberRange.new(.45, 1.2), 0
|
||||
sparks.SpreadAngle = Vector2.new(145, 145)
|
||||
sparks.LightEmission = 1
|
||||
sparks.Parent = anchor
|
||||
local diameter = Config.CAPTURE_RADIUS * 2
|
||||
local rotation = CFrame.Angles(0, 0, math.pi / 2)
|
||||
local floor = CFrame.new(mark.origin + Vector3.yAxis * .21) * rotation
|
||||
wave.CFrame = floor
|
||||
local width = 3.5
|
||||
local fullColumn = CFrame.new(mark.origin + Vector3.yAxis * (Config.LIGHT_HEIGHT / 2)) * rotation
|
||||
local motion: Tween? = nil
|
||||
local lightMotion: Tween? = nil
|
||||
local effect: Tween? = nil
|
||||
local run = 0
|
||||
local function cancel()
|
||||
run += 1
|
||||
if motion then motion:Cancel() end
|
||||
if lightMotion then lightMotion:Cancel() end
|
||||
if effect then effect:Cancel() end
|
||||
end
|
||||
local function hide()
|
||||
cancel()
|
||||
column.Transparency, wave.Transparency = 1, 1
|
||||
sparks:Clear()
|
||||
end
|
||||
janitor.give(hide)
|
||||
|
||||
return {
|
||||
hide = hide,
|
||||
show = function()
|
||||
hide()
|
||||
mark.body:SetAttribute("ObjectiveArrowHidden", nil)
|
||||
mark.label.Visible = true
|
||||
mark.body.Size = Vector3.new(.16, diameter * .15, diameter * .15)
|
||||
mark.body.Transparency = .92
|
||||
Common.paint(mark, Common.gold)
|
||||
column.Color = Common.gold
|
||||
column.Size, column.CFrame = Vector3.new(.2, width, width), floor
|
||||
column.Transparency = .85
|
||||
local t = TweenInfo.new(Config.MATERIALIZE_SECONDS, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
|
||||
motion = TweenService:Create(mark.body, t, {Size = Vector3.new(.16, diameter, diameter)})
|
||||
lightMotion = TweenService:Create(column, t, {CFrame = fullColumn, Size = Vector3.new(Config.LIGHT_HEIGHT, width, width)})
|
||||
motion:Play()
|
||||
lightMotion:Play()
|
||||
end,
|
||||
update = function(tint, phase, progress, changed)
|
||||
column.Color = tint
|
||||
column.Transparency = if phase == "Capturing" then 1 - (.55 + .45 * progress) * .25
|
||||
elseif phase == "Decaying" then .94 else .86
|
||||
if phase == "Contested" and changed then
|
||||
wave.Color, wave.Transparency = tint, .68
|
||||
wave.Size = Vector3.new(.12, diameter, diameter)
|
||||
if effect then effect:Cancel() end
|
||||
effect = TweenService:Create(wave, TweenInfo.new(.25), {Transparency = 1})
|
||||
effect:Play()
|
||||
end
|
||||
end,
|
||||
capture = function(tint)
|
||||
cancel()
|
||||
local token = run
|
||||
Common.paint(mark, Color3.new(1, 1, 1))
|
||||
mark.body:SetAttribute("ObjectiveArrowHidden", true)
|
||||
mark.label.Visible = false
|
||||
wave.Size = Vector3.new(.11, diameter, diameter)
|
||||
wave.Color, wave.Transparency = tint, .55
|
||||
sparks.Color = ColorSequence.new(tint)
|
||||
sparks:Emit(Config.CONFETTI_COUNT)
|
||||
local t = TweenInfo.new(Config.CAPTURE_EFFECT_SECONDS, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
|
||||
motion = TweenService:Create(mark.body, t, {Size = Vector3.new(.16, .1, .1), Transparency = 1})
|
||||
lightMotion = TweenService:Create(column, t, {Size = Vector3.new(.2, width, width), CFrame = floor, Transparency = 1})
|
||||
effect = TweenService:Create(wave, t, {Size = Vector3.new(.11, diameter * 1.6, diameter * 1.6), Transparency = 1})
|
||||
motion:Play()
|
||||
lightMotion:Play()
|
||||
effect:Play()
|
||||
task.delay(Config.CAPTURE_EFFECT_SECONDS, function()
|
||||
if token == run and mark.body.Parent == folder then mark.body.Parent = nil end
|
||||
end)
|
||||
end,
|
||||
}
|
||||
end
|
||||
return Effects
|
||||
Reference in new issue
Block a user