1
This commit is contained in:
1 parent
1a6f73ace2
commit
ce2ccfccdb
6 files changed
+93
-29
No files matched your search
@@ -11,7 +11,7 @@ local CollectionService = game:GetService("CollectionService")
|
||||
|
||||
type Side = "Blue" | "Orange"
|
||||
type Fighter = HotPoint.Fighter
|
||||
type Marker = HotPoint.Marker
|
||||
type Marker = HotPoint.Marker & {recolor: ((Color3) -> ())?}
|
||||
type Zone = {site: Sites.Site, marker: Marker, owner: Side?, claiming: Side?, progress: number}
|
||||
type Flag = {side: Side, marker: Marker, carrier: Player?, droppedUntil: number}
|
||||
type Drop = {marker: Marker, amount: number, expires: number}
|
||||
@@ -26,6 +26,9 @@ export type Match = {
|
||||
|
||||
local active: {[string]: Match} = {}
|
||||
local Objectives = {}
|
||||
local objectiveCue = Instance.new("RemoteEvent")
|
||||
objectiveCue.Name = "ArenaObjectiveCue"
|
||||
objectiveCue.Parent = ReplicatedStorage
|
||||
local sides: {Side} = {"Blue", "Orange"}
|
||||
local blue = Color3.fromRGB(67, 216, 255)
|
||||
local orange = Color3.fromRGB(255, 150, 68)
|
||||
@@ -87,8 +90,20 @@ 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)
|
||||
mark.recolor = recolor
|
||||
recolor(tint)
|
||||
return mark
|
||||
end
|
||||
|
||||
local function paint(mark: Marker, tint: Color3)
|
||||
if mark.body.Color == tint then return end
|
||||
if mark.recolor then
|
||||
mark.recolor(tint)
|
||||
return
|
||||
end
|
||||
mark.body.Color = tint
|
||||
mark.label.TextColor3 = tint
|
||||
local aura = mark.body:FindFirstChildOfClass("PointLight")
|
||||
@@ -103,7 +118,7 @@ local function presence(fighters: {Fighter}, zone: Zone, geometry: RaycastParams
|
||||
local b, o = false, false
|
||||
-- Separate vertically stacked objectives by avatar foot height.
|
||||
for _, fighter in fighters do
|
||||
if boundsAt(fighter.root.Position, zone.site.position, 11, 8)
|
||||
if boundsAt(fighter.root.Position, zone.site.position, HotPoint.Radius, 8)
|
||||
and visibleAt(fighter, zone.site.position + Vector3.yAxis * 2.7, geometry) then
|
||||
if fighter.side == "Blue" then b = true else o = true end
|
||||
end
|
||||
@@ -148,8 +163,14 @@ function Objectives.start(config: Config): Match
|
||||
end
|
||||
return found
|
||||
end
|
||||
local function cue(fighters: {Fighter}, captured: boolean, side: Side?)
|
||||
for _, fighter in fighters do
|
||||
if captured or fighter.side == side then objectiveCue:FireClient(fighter.player, captured) end
|
||||
end
|
||||
end
|
||||
local function makeZone(site: Sites.Site, name: string): Zone
|
||||
return {site = site, marker = marker(folder, name, site.name, site.position, neutral, 22), owner = nil, claiming = nil, progress = 0}
|
||||
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}
|
||||
end
|
||||
local zones: {Zone} = {}
|
||||
local hotPoint = if hotPath then HotPoint.start({
|
||||
@@ -168,6 +189,7 @@ function Objectives.start(config: Config): Match
|
||||
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 siegeState: Folder? = nil
|
||||
local lifeActive, miniNumber = false, 0
|
||||
@@ -184,10 +206,12 @@ function Objectives.start(config: Config): Match
|
||||
table.insert(zones, zone)
|
||||
end
|
||||
elseif rule == "CaptureFlag" or rule == "TrophyHunt" then
|
||||
map.blue = Sites.clearCircle(map.blue, geometry, HotPoint.Radius)
|
||||
map.orange = Sites.clearCircle(map.orange, geometry, HotPoint.Radius)
|
||||
for _, side in sides do
|
||||
local at = if side == "Blue" then map.blue else map.orange
|
||||
local name = if side == "Blue" then "БАЗА СИНИХ" else "БАЗА ОРАНЖЕВЫХ"
|
||||
marker(folder, side .. "Base", name, at, color(side), 15)
|
||||
ring(folder, side .. "Base", name, at, color(side))
|
||||
if rule == "CaptureFlag" then
|
||||
local flag = marker(folder, side .. "Flag", "ФЛАГ", at, color(side), 2.6, true)
|
||||
flag.body.Transparency = 1
|
||||
@@ -328,6 +352,7 @@ function Objectives.start(config: Config): Match
|
||||
flag.carrier = f.player
|
||||
flag.droppedUntil = 0
|
||||
f.player:SetAttribute("ArenaFlag", side)
|
||||
cue(fighters, false, f.side)
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -335,8 +360,9 @@ function Objectives.start(config: Config): Match
|
||||
for _, fighter in fighters do
|
||||
local own, enemy = flags[fighter.side], flags[opposite(fighter.side)]
|
||||
if enemy.carrier == fighter.player and not own.carrier and own.droppedUntil == 0
|
||||
and boundsAt(fighter.root.Position, own.marker.origin, 7, 7) then
|
||||
and boundsAt(fighter.root.Position, own.marker.origin, HotPoint.Radius, 7) then
|
||||
add(fighter.side, 1)
|
||||
cue(fighters, true, nil)
|
||||
sendHome(enemy)
|
||||
end
|
||||
end
|
||||
@@ -356,6 +382,7 @@ function Objectives.start(config: Config): Match
|
||||
end
|
||||
if not collector then continue end
|
||||
local p = collector.player
|
||||
if not carried[p] then cue(fighters, false, collector.side) end
|
||||
carried[p] = (carried[p] or 0) + token.amount
|
||||
p:SetAttribute("ArenaTokens", carried[p])
|
||||
end
|
||||
@@ -364,8 +391,9 @@ function Objectives.start(config: Config): Match
|
||||
end
|
||||
for _, f in fighters do
|
||||
local amount = carried[f.player]
|
||||
if amount and boundsAt(f.root.Position, if f.side == "Blue" then map.blue else map.orange, 8, 7) then
|
||||
if amount and boundsAt(f.root.Position, if f.side == "Blue" then map.blue else map.orange, HotPoint.Radius, 7) then
|
||||
add(f.side, amount)
|
||||
cue(fighters, true, nil)
|
||||
carried[f.player] = nil
|
||||
f.player:SetAttribute("ArenaTokens", nil)
|
||||
end
|
||||
@@ -380,6 +408,7 @@ function Objectives.start(config: Config): Match
|
||||
hadSiegeSwap = true
|
||||
for _, z in zones do z.marker.body.Parent = nil end
|
||||
siegeSide, siegeIndex, siegeProgress = opposite(siegeSide), 1, 0
|
||||
siegeCaptureStarted = false
|
||||
local arenaSites = assert(map)
|
||||
local ordinals = {Blue = 0, Orange = 0}
|
||||
for _, p in members do
|
||||
@@ -417,7 +446,7 @@ function Objectives.start(config: Config): Match
|
||||
for _, fighter in fighters do
|
||||
local delta = fighter.root.Position - zone.site.position
|
||||
local reason = "Outside"
|
||||
if delta.X * delta.X + delta.Z * delta.Z <= SiegeConfig.CAPTURE_RADIUS ^ 2 then
|
||||
if delta.X * delta.X + delta.Z * delta.Z <= HotPoint.Radius ^ 2 then
|
||||
if math.abs(delta.Y) > SiegeConfig.HEIGHT_TOLERANCE then reason = "Height"
|
||||
elseif not visibleAt(fighter, zone.site.position + Vector3.yAxis * SiegeConfig.SIGHT_HEIGHT, geometry) then reason = "Blocked"
|
||||
else
|
||||
@@ -429,6 +458,12 @@ function Objectives.start(config: Config): Match
|
||||
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
|
||||
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)
|
||||
@@ -443,6 +478,8 @@ function Objectives.start(config: Config): Match
|
||||
paint(zone.marker, if phase == "Contested" then orange else blue)
|
||||
if phase ~= "Captured" or not Score.record(siegeTimes, siegeSide, siegeIndex, elapsed - attackStart) then return false end
|
||||
add(siegeSide, SiegeConfig.POINTS_PER_OBJECTIVE)
|
||||
cue(fighters, true, nil)
|
||||
siegeCaptureStarted = false
|
||||
data:SetAttribute(siegeSide .. "Time" .. siegeIndex, elapsed - attackStart)
|
||||
zone.marker.body.Parent = nil
|
||||
siegeIndex += 1
|
||||
@@ -505,9 +542,15 @@ function Objectives.start(config: Config): Match
|
||||
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 end
|
||||
if zone.claiming ~= side then
|
||||
zone.claiming, zone.progress = side, 0
|
||||
cue(fighters, false, side)
|
||||
end
|
||||
zone.progress += dt
|
||||
if zone.progress >= 3 then zone.owner, zone.progress = side, 0 end
|
||||
if zone.progress >= 3 then
|
||||
zone.owner, zone.progress = side, 0
|
||||
cue(fighters, true, nil)
|
||||
end
|
||||
else
|
||||
zone.claiming, zone.progress = nil, 0
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user