Refactor arena modes and add objective event feed
This commit is contained in:
1 parent
df6ab8efe1
commit
b87a3770a1
26 files changed
+1221
-654
No files matched your search
@@ -0,0 +1,158 @@
|
||||
--!strict
|
||||
local Runtime = script.Parent.Parent
|
||||
local Types = require(Runtime.Types)
|
||||
local Common = require(Runtime.Common)
|
||||
local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
|
||||
local Strings = require(game.ReplicatedStorage.Hunter.Strings)
|
||||
local Context = require(Runtime.Context)
|
||||
local HotPoint = require(Runtime.Parent.HotPoint)
|
||||
type Fighter = Types.Fighter
|
||||
type Flag = {
|
||||
marker: Common.Marker, stars: ParticleEmitter, mist: ParticleEmitter, light: PointLight, banner: BasePart,
|
||||
carrier: Player?, tether: WeldConstraint?, droppedUntil: number,
|
||||
}
|
||||
local function makeFlag(parent: Instance, roof: Vector3): Flag
|
||||
local mark = Common.marker(parent, "CitadelFlag", Strings.flagRoofLabel, roof, Common.gold, 2.6, true)
|
||||
local body = mark.body
|
||||
body.Transparency = 1
|
||||
body.CFrame = CFrame.new(body.Position)
|
||||
local light = assert(body:FindFirstChildOfClass("PointLight"))
|
||||
light.Range, light.Brightness = 21, 1.6
|
||||
|
||||
local function attach(name: string, size: Vector3, offset: Vector3, tint: Color3): Part
|
||||
local part = Instance.new("Part")
|
||||
part.Name, part.Size, part.Color = name, size, tint
|
||||
part.CFrame = body.CFrame + offset
|
||||
part.Material = Enum.Material.Neon
|
||||
part.Massless, part.CanCollide, part.CanTouch, part.CanQuery = true, false, false, false
|
||||
part.Parent = body
|
||||
local weld = Instance.new("WeldConstraint")
|
||||
weld.Part0, weld.Part1, weld.Parent = body, part, part
|
||||
return part
|
||||
end
|
||||
attach("Pole", Vector3.new(.17, 4.5, .17), Vector3.zero, Color3.fromRGB(235, 235, 255))
|
||||
local banner = attach("Banner", Vector3.new(2.65, 1.48, .15), Vector3.new(1.35, 1.45, 0), Common.gold)
|
||||
attach("CrownLight", Vector3.new(.33, .33, .33), Vector3.yAxis * 2.34, Common.neutral).Shape = Enum.PartType.Ball
|
||||
|
||||
local aura = Instance.new("Attachment")
|
||||
aura.Name = "FlagAura"
|
||||
aura.Position = -Vector3.yAxis * 1.75
|
||||
aura.Parent = body
|
||||
local stars = Instance.new("ParticleEmitter")
|
||||
stars.Name = "Stars"
|
||||
stars.Texture = "rbxasset://textures/particles/sparkles_main.dds"
|
||||
stars.Color = ColorSequence.new(Common.neutral, Common.gold)
|
||||
stars.LightEmission, stars.LightInfluence = 1, 0
|
||||
stars.Rate, stars.Speed, stars.Lifetime = 24, NumberRange.new(3, 6), NumberRange.new(.7, 1.4)
|
||||
stars.SpreadAngle = Vector2.new(65, 65)
|
||||
stars.Rotation, stars.RotSpeed = NumberRange.new(-180, 180), NumberRange.new(-90, 90)
|
||||
stars.Size = NumberSequence.new({NumberSequenceKeypoint.new(0, .22), NumberSequenceKeypoint.new(.4, .52), NumberSequenceKeypoint.new(1, 0)})
|
||||
stars.Parent = aura
|
||||
|
||||
local mist = Instance.new("ParticleEmitter")
|
||||
mist.Name = "ColoredMist"
|
||||
mist.Texture = "rbxasset://textures/particles/smoke_main.dds"
|
||||
mist.Color = ColorSequence.new(Common.neutral, Common.gold)
|
||||
mist.LightEmission, mist.LightInfluence = .55, 0
|
||||
mist.Rate, mist.Speed, mist.Lifetime = 9, NumberRange.new(1, 4), NumberRange.new(.7, 1.2)
|
||||
mist.SpreadAngle = Vector2.new(110, 110)
|
||||
mist.Size = NumberSequence.new(1.4, 4)
|
||||
mist.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0, .72), NumberSequenceKeypoint.new(.45, .79), NumberSequenceKeypoint.new(1, 1)})
|
||||
mist.Parent = aura
|
||||
|
||||
return {marker = mark, stars = stars, mist = mist, light = light, banner = banner,
|
||||
carrier = nil, tether = nil, droppedUntil = 0}
|
||||
end
|
||||
|
||||
local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local map, geometry = assert(ctx.map), ctx.geometry
|
||||
local flag = makeFlag(ctx.folder, map.roof.position)
|
||||
Common.bases(ctx.folder, geometry, map)
|
||||
|
||||
local function putFlag(object: Flag, at: Vector3, droppedUntil: number)
|
||||
if object.carrier then object.carrier:SetAttribute("ArenaFlag", nil) end
|
||||
if object.tether then object.tether:Destroy() end
|
||||
object.carrier, object.tether, object.droppedUntil = nil, nil, droppedUntil
|
||||
local mark = object.marker
|
||||
mark.body.Anchored = true
|
||||
mark.body.CFrame = CFrame.new(at + Vector3.yAxis * 2.4)
|
||||
mark.label.Text = if droppedUntil > 0 then Strings.flagDropLabel else Strings.flagRoofLabel
|
||||
mark.label.TextColor3, object.banner.Color = Common.gold, Common.gold
|
||||
object.stars.Enabled, object.mist.Enabled, object.light.Enabled = true, true, true
|
||||
object.stars:Emit(16)
|
||||
end
|
||||
|
||||
local function pickUpFlag(object: Flag, fighter: Fighter)
|
||||
local body = object.marker.body
|
||||
body.CFrame = fighter.root.CFrame * CFrame.new(0, 3.15, .65)
|
||||
body.Massless = true
|
||||
local tether = Instance.new("WeldConstraint")
|
||||
tether.Part0, tether.Part1 = body, fighter.root
|
||||
tether.Parent = body
|
||||
body.Anchored = false
|
||||
object.carrier, object.tether, object.droppedUntil = fighter.player, tether, 0
|
||||
fighter.player:SetAttribute("ArenaFlag", true)
|
||||
local tint = Common.color(fighter.side)
|
||||
object.marker.label.Text = Strings.flagCarrierLabel(fighter.player.DisplayName)
|
||||
object.marker.label.TextColor3, object.banner.Color = tint, tint
|
||||
object.stars.Enabled, object.mist.Enabled, object.light.Enabled = false, false, false
|
||||
object.stars:Clear()
|
||||
object.mist:Clear()
|
||||
end
|
||||
local function dropCarried(player: Player, at: Vector3?, now: number, fighters: {Fighter}?)
|
||||
if flag.carrier == player then
|
||||
if at then
|
||||
local floor = workspace:Raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry)
|
||||
local landing = if floor then floor.Position else at
|
||||
putFlag(flag, landing, now + 20)
|
||||
for _, fighter in (fighters or Context.collect(ctx.members())) do ctx.legacy(fighter.player, "FlagDropped") end
|
||||
ctx.events.fire(Kinds.FlagDropped, {at = landing})
|
||||
else
|
||||
putFlag(flag, flag.marker.origin, 0)
|
||||
ctx.events.fire(Kinds.FlagReturned, {at = flag.marker.origin})
|
||||
end
|
||||
end
|
||||
end
|
||||
local function runFlag(fighters: {Fighter}, now: number)
|
||||
if flag.carrier then
|
||||
for _, fighter in fighters do
|
||||
if fighter.player ~= flag.carrier then continue end
|
||||
local base = if fighter.side == "Blue" then map.blue else map.orange
|
||||
if Common.boundsAt(fighter.root.Position, base, HotPoint.Radius, 7) then
|
||||
ctx.scoring.add(fighter.side, 1, Kinds.FlagScored, fighter.player)
|
||||
ctx.events.fire(Kinds.FlagScored, {side = fighter.side, userId = fighter.player.UserId})
|
||||
ctx.cue(fighters, true, nil)
|
||||
putFlag(flag, flag.marker.origin, 0)
|
||||
ctx.events.fire(Kinds.FlagReturned, {at = flag.marker.origin})
|
||||
ctx.status(Strings.flagReturned)
|
||||
end
|
||||
return
|
||||
end
|
||||
local carrier = flag.carrier
|
||||
local root = carrier.Character and carrier.Character.PrimaryPart
|
||||
dropCarried(carrier, root and root.Position, now, fighters)
|
||||
return
|
||||
elseif flag.droppedUntil > 0 and now >= flag.droppedUntil then
|
||||
putFlag(flag, flag.marker.origin, 0)
|
||||
ctx.events.fire(Kinds.FlagReturned, {at = flag.marker.origin})
|
||||
end
|
||||
local at = flag.marker.body.Position
|
||||
for _, fighter in fighters do
|
||||
if Common.boundsAt(fighter.root.Position, at, 5.5, 6.5) and Common.visibleAt(fighter, at, geometry) then
|
||||
pickUpFlag(flag, fighter)
|
||||
ctx.events.fire(Kinds.FlagPicked, {side = fighter.side, userId = fighter.player.UserId, text = fighter.player.DisplayName})
|
||||
ctx.cue(fighters, false, fighter.side)
|
||||
ctx.status(Strings.flagCarrier(fighter.player.DisplayName))
|
||||
return
|
||||
end
|
||||
end
|
||||
ctx.status(if flag.droppedUntil > 0 then Strings.flagOnGround else Strings.flagOnRoof)
|
||||
end
|
||||
return Common.instance(ctx, {
|
||||
step = function(now, _, fighters) runFlag(fighters, now); return false end,
|
||||
death = dropCarried, leaving = dropCarried,
|
||||
destroy = function() if flag.carrier then flag.carrier:SetAttribute("ArenaFlag", nil) end end,
|
||||
})
|
||||
end
|
||||
|
||||
return {id = "CaptureFlag", usesMap = true, start = start}
|
||||
@@ -0,0 +1,69 @@
|
||||
--!strict
|
||||
local Runtime = script.Parent.Parent
|
||||
local Types = require(Runtime.Types)
|
||||
local Common = require(Runtime.Common)
|
||||
local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
|
||||
local Strings = require(game.ReplicatedStorage.Hunter.Strings)
|
||||
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 function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local map = assert(ctx.map)
|
||||
local zones: {Common.Zone} = {}
|
||||
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): (boolean, boolean)
|
||||
local blue, orange = false, false
|
||||
for _, fighter in fighters do
|
||||
if Zones.classify(fighter.root.Position, zone.site.position, SPEC, geometry) == "Inside" then
|
||||
if fighter.side == "Blue" then blue = true else orange = true end
|
||||
end
|
||||
end
|
||||
return blue, orange
|
||||
end
|
||||
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 ownedBlue, ownedOrange = 0, 0
|
||||
for index, zone in zones do
|
||||
local b, o = presence(fighters, zone, geometry)
|
||||
local side: Side? = if b == o then nil elseif b then "Blue" else "Orange"
|
||||
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
|
||||
local previous = zone.owner
|
||||
zone.owner, zone.progress = side, 0
|
||||
local payload = {side = side, index = index, text = zone.marker.label.Text, value = now - ctx.liveAt}
|
||||
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)
|
||||
end
|
||||
else
|
||||
zone.claiming, zone.progress = nil, 0
|
||||
end
|
||||
Common.paint(zone.marker, Common.color(zone.owner))
|
||||
if zone.owner == "Blue" then ownedBlue += 1 elseif zone.owner == "Orange" then ownedOrange += 1 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})
|
||||
end
|
||||
|
||||
return {id = "Domination", usesMap = true, start = start}
|
||||
@@ -0,0 +1,30 @@
|
||||
--!strict
|
||||
local Runtime = script.Parent.Parent
|
||||
local Types = require(Runtime.Types)
|
||||
local Common = require(Runtime.Common)
|
||||
local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
|
||||
local Strings = require(game.ReplicatedStorage.Hunter.Strings)
|
||||
local HotPoint = require(Runtime.Parent.HotPoint)
|
||||
local Sites = require(Runtime.Parent.ArenaObjectiveSites)
|
||||
|
||||
local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local path = Sites.hotPath(ctx.arena, assert(ctx.map), HotPoint.Radius)
|
||||
local capture = HotPoint.start({
|
||||
state = ctx.state, geometry = ctx.geometry, sites = path, startedAt = ctx.liveAt,
|
||||
marker = function(site)
|
||||
ctx.events.fire(Kinds.ZoneStarted, {text = site.name, at = site.position})
|
||||
return Common.marker(ctx.folder, "HotPoint", Strings.hotPoint, site.position, Common.neutral, HotPoint.Radius * 2)
|
||||
end,
|
||||
score = function(side, points)
|
||||
ctx.scoring.add(side, points, Kinds.ZoneCaptured)
|
||||
ctx.events.fire(Kinds.ZoneCaptured, {side = side, text = Strings.hotPoint})
|
||||
end,
|
||||
status = ctx.status,
|
||||
})
|
||||
return Common.instance(ctx, {
|
||||
step = function(now, dt, fighters, elapsed) capture.step(fighters, now, elapsed or dt); return false end,
|
||||
hit = capture.hit, death = capture.death, leaving = capture.death, destroy = capture.destroy,
|
||||
})
|
||||
end
|
||||
|
||||
return {id = "HotPoint", usesMap = true, start = start}
|
||||
@@ -0,0 +1,71 @@
|
||||
--!strict
|
||||
local Runtime = script.Parent.Parent
|
||||
local Types = require(Runtime.Types)
|
||||
local Common = require(Runtime.Common)
|
||||
local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
|
||||
local Strings = require(game.ReplicatedStorage.Hunter.Strings)
|
||||
type Fighter = Types.Fighter
|
||||
type Side = Types.Side
|
||||
local rng = Random.new()
|
||||
|
||||
local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local leaders: {[Side]: Player} = {}
|
||||
local previousLeader: {[Side]: Player} = {}
|
||||
local leaderLabels: {[Player]: BillboardGui} = {}
|
||||
local function clearLeader(side: Side)
|
||||
local p = leaders[side]
|
||||
if not p then return end
|
||||
previousLeader[side] = p
|
||||
leaders[side] = nil
|
||||
p:SetAttribute("ArenaLeader", nil)
|
||||
local badge = leaderLabels[p]
|
||||
if badge then badge:Destroy() end
|
||||
leaderLabels[p] = nil
|
||||
end
|
||||
local function updateLeaders(fighters: {Fighter})
|
||||
for _, side in Common.sides do
|
||||
local roster: {Fighter} = {}
|
||||
local present = false
|
||||
for _, f in fighters do
|
||||
if f.side ~= side then continue end
|
||||
table.insert(roster, f)
|
||||
if f.player == leaders[side] then present = true end
|
||||
end
|
||||
if present then continue end
|
||||
clearLeader(side)
|
||||
if #roster == 0 then continue end
|
||||
local pick = rng:NextInteger(1, #roster)
|
||||
if #roster > 1 and roster[pick].player == previousLeader[side] then pick = pick % #roster + 1 end
|
||||
local p = roster[pick].player
|
||||
local head = p.Character and p.Character:FindFirstChild("Head")
|
||||
if not head or not head:IsA("BasePart") then continue end
|
||||
leaders[side] = p
|
||||
p:SetAttribute("ArenaLeader", true)
|
||||
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})
|
||||
end
|
||||
local a, b = leaders.Blue, leaders.Orange
|
||||
ctx.status(Strings.leaders(if a then a.DisplayName else nil, if b then b.DisplayName else nil))
|
||||
end
|
||||
return Common.instance(ctx, {
|
||||
step = function(_, _, fighters) updateLeaders(fighters); return false end,
|
||||
kill = function(player, victim)
|
||||
local side = Common.sideOf(player)
|
||||
if not side then return end
|
||||
local target = Common.opposite(side)
|
||||
local bonus = leaders[target] == victim
|
||||
ctx.scoring.add(side, if bonus then 3 else 1, if bonus then Kinds.LeaderDown else "Elimination", player)
|
||||
if bonus then
|
||||
clearLeader(target)
|
||||
ctx.events.fire(Kinds.LeaderDown, {side = side, userId = player.UserId, text = victim.DisplayName})
|
||||
end
|
||||
end,
|
||||
leaving = function(player)
|
||||
local side = Common.sideOf(player)
|
||||
if side and leaders[side] == player then clearLeader(side) end
|
||||
end,
|
||||
destroy = function() for _, side in Common.sides do clearLeader(side) end end,
|
||||
})
|
||||
end
|
||||
|
||||
return {id = "HuntLeader", usesMap = false, start = start}
|
||||
@@ -0,0 +1,56 @@
|
||||
--!strict
|
||||
local Runtime = script.Parent.Parent
|
||||
local Types = require(Runtime.Types)
|
||||
local Common = require(Runtime.Common)
|
||||
local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
|
||||
local Strings = require(game.ReplicatedStorage.Hunter.Strings)
|
||||
type Fighter = Types.Fighter
|
||||
|
||||
local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local lifeActive, miniNumber = false, 0
|
||||
local lifeEnds, nextMini = math.huge, ctx.liveAt + 2
|
||||
local function runOneLife(members: {Player}, fighters: {Fighter}, now: number): boolean
|
||||
if lifeActive then
|
||||
local b, o = 0, 0
|
||||
for _, f in fighters do if f.side == "Blue" then b += 1 else o += 1 end end
|
||||
if (b > 0 and o > 0) and now < lifeEnds then
|
||||
ctx.status(Strings.lifeActive(miniNumber, b, o, math.ceil(lifeEnds - now)))
|
||||
return false
|
||||
end
|
||||
local side: Types.Side? = if b == o then nil elseif b > o then "Blue" else "Orange"
|
||||
if side then ctx.scoring.add(side, 1, Kinds.MiniRoundEnded) end
|
||||
ctx.events.fire(Kinds.MiniRoundEnded, {side = side, index = miniNumber})
|
||||
if ctx.scoring.get("Blue") >= 3 or ctx.scoring.get("Orange") >= 3 then return true end
|
||||
for _, p in members do ctx.bench(p) end
|
||||
lifeActive, nextMini = false, now + 4
|
||||
end
|
||||
if now >= nextMini then ctx.balanceWaiting() end
|
||||
local ready: {Player} = {}
|
||||
local b, o = false, false
|
||||
for _, p in members do
|
||||
local c = p.Character
|
||||
local h = c and c:FindFirstChildOfClass("Humanoid")
|
||||
if not c or not c.PrimaryPart or not h or h.Health <= 0 then continue end
|
||||
table.insert(ready, p)
|
||||
if Common.sideOf(p) == "Blue" then b = true else o = true end
|
||||
end
|
||||
if b and o and now >= nextMini then
|
||||
for _, p in ready do ctx.deploy(p) end
|
||||
miniNumber += 1
|
||||
lifeActive, lifeEnds = true, now + 45
|
||||
ctx.status(Strings.lifeStart(miniNumber))
|
||||
ctx.events.fire(Kinds.MiniRoundStarted, {index = miniNumber})
|
||||
elseif not b or not o then
|
||||
ctx.status(Strings.lifeWaiting)
|
||||
else
|
||||
ctx.status(Strings.lifeNext(math.ceil(nextMini - now)))
|
||||
end
|
||||
return false
|
||||
end
|
||||
return Common.instance(ctx, {
|
||||
step = function(now, _, fighters) return runOneLife(ctx.members(), fighters, now) end,
|
||||
death = function(player) ctx.bench(player) end,
|
||||
})
|
||||
end
|
||||
|
||||
return {id = "OneLife", usesMap = true, start = start}
|
||||
@@ -0,0 +1,143 @@
|
||||
--!strict
|
||||
local Runtime = script.Parent.Parent
|
||||
local Types = require(Runtime.Types)
|
||||
local Common = require(Runtime.Common)
|
||||
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 Sites = require(Runtime.Parent.ArenaObjectiveSites)
|
||||
local SiegeConfig = require(game.ReplicatedStorage.CitadelAssaultConfig)
|
||||
local Capture = require(Runtime.Parent.CitadelCaptureService)
|
||||
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 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 data = Instance.new("Folder")
|
||||
data.Name = "CitadelMatchState"
|
||||
data.Parent = state
|
||||
ctx.janitor.give(data)
|
||||
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
|
||||
local index = point:GetAttribute("Index")
|
||||
if typeof(index) == "number" and index % 1 == 0 and sites[index] then
|
||||
sites[index] = {name = sites[index].name, position = point.Position}
|
||||
end
|
||||
end
|
||||
for i, site in sites do
|
||||
local zone = Common.makeZone(folder, geometry, site, "Checkpoint" .. i)
|
||||
zone.marker.body:SetAttribute("Index", i)
|
||||
zone.marker.body.Parent = nil
|
||||
ctx.janitor.give(zone.marker.body)
|
||||
table.insert(zones, zone)
|
||||
end
|
||||
zones[1].marker.body.Parent = folder
|
||||
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 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
|
||||
hadSiegeSwap = true
|
||||
for _, z in zones do z.marker.body.Parent = nil end
|
||||
siegeSide, siegeIndex, siegeProgress = Common.opposite(siegeSide), 1, 0
|
||||
siegeCaptureStarted = false
|
||||
local arenaSites = map
|
||||
ctx.events.fire(Kinds.RoleSwap, {side = siegeSide})
|
||||
local ordinals = {Blue = 0, Orange = 0}
|
||||
for _, p in members do
|
||||
ctx.deploy(p)
|
||||
local side, character = Common.sideOf(p), p.Character
|
||||
if not side or not character or not character.PrimaryPart then continue end
|
||||
local attack = side == siegeSide
|
||||
ordinals[side] += 1
|
||||
local at = SiegeSpawn.position(world, attack, if attack then arenaSites.blue else arenaSites.orange, ordinals[side])
|
||||
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
|
||||
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))
|
||||
if swap then
|
||||
data:SetAttribute("Progress", 0)
|
||||
data:SetAttribute("Status", "Idle")
|
||||
ctx.status(Strings.siegeSwap)
|
||||
return false
|
||||
end
|
||||
local attacker = Strings.team(siegeSide)
|
||||
local zone = zones[siegeIndex]
|
||||
data:SetAttribute("Index", siegeIndex)
|
||||
if not zone then
|
||||
data:SetAttribute("Point", nil)
|
||||
data:SetAttribute("NextPoint", nil)
|
||||
ctx.status(Strings.siegeComplete)
|
||||
return true
|
||||
end
|
||||
zone.marker.body.Parent = folder
|
||||
local attack, defense = false, false
|
||||
for _, fighter in fighters do
|
||||
local reason = Zones.classify(fighter.root.Position, zone.site.position, SPEC, geometry)
|
||||
if reason == "Inside" then
|
||||
if fighter.side == siegeSide then attack = true else defense = true end
|
||||
end
|
||||
fighter.player:SetAttribute("CitadelZone", reason)
|
||||
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
|
||||
ctx.cue(fighters, false, siegeSide)
|
||||
siegeCaptureStarted = true
|
||||
elseif progress == 0 and phase ~= "Capturing" then
|
||||
siegeCaptureStarted = false
|
||||
end
|
||||
siegeProgress = progress
|
||||
data:SetAttribute("Progress", progress)
|
||||
data:SetAttribute("Status", phase)
|
||||
data:SetAttribute("Point", zone.site.position)
|
||||
data:SetAttribute("PointName", zone.site.name)
|
||||
local nextZone = zones[siegeIndex + 1]
|
||||
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)
|
||||
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)
|
||||
ctx.events.fire(Kinds.ZoneCaptured, {side = siegeSide, index = siegeIndex, text = zone.site.name, value = elapsed - attackStart})
|
||||
ctx.cue(fighters, true, nil)
|
||||
siegeCaptureStarted = false
|
||||
data:SetAttribute(siegeSide .. "Time" .. siegeIndex, elapsed - attackStart)
|
||||
zone.marker.body.Parent = nil
|
||||
siegeIndex += 1
|
||||
siegeProgress = 0
|
||||
if siegeIndex > #zones then
|
||||
ctx.events.fire(Kinds.AllObjectivesTaken, {side = siegeSide})
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
return Common.instance(ctx, {
|
||||
step = function(now, dt, fighters) return runSiege(ctx.members(), fighters, now, dt) end,
|
||||
winner = function()
|
||||
local winner, reason = Score.winner(siegeTimes, SiegeConfig.TIE_EPSILON)
|
||||
state:SetAttribute("CitadelResultReason", reason)
|
||||
return winner, reason
|
||||
end,
|
||||
destroy = function()
|
||||
for _, p in ctx.members() do p:SetAttribute("CitadelZone", nil) end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return {id = "Siege", usesMap = true, start = start}
|
||||
@@ -0,0 +1,12 @@
|
||||
--!strict
|
||||
local Types = require(script.Parent.Parent.Types)
|
||||
local Common = require(script.Parent.Parent.Common)
|
||||
|
||||
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
|
||||
end})
|
||||
end
|
||||
|
||||
return {id = "TeamDeathmatch", usesMap = false, start = start}
|
||||
@@ -0,0 +1,83 @@
|
||||
--!strict
|
||||
local Runtime = script.Parent.Parent
|
||||
local Types = require(Runtime.Types)
|
||||
local Common = require(Runtime.Common)
|
||||
local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
|
||||
local Strings = require(game.ReplicatedStorage.Hunter.Strings)
|
||||
type Fighter = Types.Fighter
|
||||
local HotPoint = require(Runtime.Parent.HotPoint)
|
||||
type Drop = {marker: Common.Marker, amount: number, expires: number}
|
||||
|
||||
local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local map, geometry, folder = assert(ctx.map), ctx.geometry, ctx.folder
|
||||
Common.bases(folder, geometry, map)
|
||||
local tokens: {Drop} = {}
|
||||
local carried: {[Player]: number} = {}
|
||||
local function floorAt(at: Vector3): Vector3
|
||||
local hit = workspace:Raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry)
|
||||
return if hit then hit.Position else map.ground.position
|
||||
end
|
||||
local function tokenDrop(at: Vector3, amount: number, now: number)
|
||||
local floor = floorAt(at)
|
||||
ctx.events.fire(Kinds.TokenDropped, {at = floor, value = amount})
|
||||
for _, existing in tokens do
|
||||
if Common.boundsAt(existing.marker.origin, floor, 3.5, 3) then
|
||||
existing.amount += amount
|
||||
existing.expires = now + 42
|
||||
existing.marker.label.Text = Strings.tokens(existing.amount)
|
||||
return
|
||||
end
|
||||
end
|
||||
if #tokens >= 60 then
|
||||
local old = table.remove(tokens, 1)
|
||||
old.marker.body:Destroy()
|
||||
end
|
||||
table.insert(tokens, {marker = Common.marker(folder, "Tokens", Strings.tokens(amount), floor, Common.gold, 1.55, true), amount = amount, expires = now + 42})
|
||||
end
|
||||
local function runTrophies(fighters: {Fighter}, now: number)
|
||||
for i = #tokens, 1, -1 do
|
||||
local token = tokens[i]
|
||||
local collector: Fighter? = nil
|
||||
if now < token.expires then
|
||||
for _, f in fighters do
|
||||
if Common.boundsAt(f.root.Position, token.marker.origin, 5, 6) and Common.visibleAt(f, token.marker.body.Position, geometry) then collector = f; break end
|
||||
end
|
||||
if not collector then continue end
|
||||
local p = collector.player
|
||||
if not carried[p] then ctx.cue(fighters, false, collector.side) end
|
||||
carried[p] = (carried[p] or 0) + token.amount
|
||||
p:SetAttribute("ArenaTokens", carried[p])
|
||||
end
|
||||
token.marker.body:Destroy()
|
||||
table.remove(tokens, i)
|
||||
end
|
||||
for _, f in fighters do
|
||||
local amount = carried[f.player]
|
||||
if amount and Common.boundsAt(f.root.Position, if f.side == "Blue" then map.blue else map.orange, HotPoint.Radius, 7) then
|
||||
ctx.scoring.add(f.side, amount, Kinds.TokensBanked, f.player)
|
||||
ctx.events.fire(Kinds.TokensBanked, {side = f.side, userId = f.player.UserId, value = amount})
|
||||
ctx.cue(fighters, true, nil)
|
||||
carried[f.player] = nil
|
||||
f.player:SetAttribute("ArenaTokens", nil)
|
||||
end
|
||||
end
|
||||
ctx.status(Strings.trophyStatus)
|
||||
end
|
||||
local function drop(player: Player, at: Vector3?, now: number)
|
||||
local amount = carried[player]
|
||||
if not amount then return end
|
||||
carried[player] = nil
|
||||
player:SetAttribute("ArenaTokens", nil)
|
||||
if at then tokenDrop(at, amount, now) end
|
||||
end
|
||||
return Common.instance(ctx, {
|
||||
step = function(now, _, fighters) runTrophies(fighters, now); return false end,
|
||||
kill = function(player, _, at, now)
|
||||
if Common.sideOf(player) then tokenDrop(at, 1, now) end
|
||||
end,
|
||||
death = drop, leaving = drop,
|
||||
destroy = function() for p in carried do p:SetAttribute("ArenaTokens", nil) end end,
|
||||
})
|
||||
end
|
||||
|
||||
return {id = "TrophyHunt", usesMap = true, start = start}
|
||||
Reference in new issue
Block a user