Files
Hunter/scripts/studio/BuildArenaRunes.luau
T
2026-11-29 15:49:17 +03:00

295 lines
13 KiB
Luau

--!strict
-- Studio authoring script. Run in Edit to add or refresh the imported arena's runes.
local arena = workspace:WaitForChild("HunterMonolithImport") :: Model
local center = arena:GetPivot().Position
local geometry = RaycastParams.new()
geometry.FilterType = Enum.RaycastFilterType.Include
geometry.FilterDescendantsInstances = {arena}
geometry.RespectCanCollide = true
local set = Instance.new("Folder")
set.Name = "ArenaRunes"
local cobalt = Color3.fromRGB(100, 217, 255)
local violet = Color3.fromRGB(184, 123, 255)
local ice = Color3.fromRGB(216, 239, 255)
local dark = Color3.fromRGB(22, 21, 43)
local gold = Color3.fromRGB(255, 192, 115)
local count = {Guide = 0, Boost = 0, Jump = 0}
local function walkable(x: number, z: number, ceiling: number): Vector3
local hit = workspace:Raycast(Vector3.new(center.X + x, ceiling, center.Z + z), Vector3.new(0, -110, 0), geometry)
assert(hit and hit.Normal.Y > .97, string.format("No flat surface at (%d,%d)", x, z))
return hit.Position
end
local function flatFootprint(position: Vector3, right: Vector3, forward: Vector3, x: number, z: number)
for _, offset in {right * x + forward * z, right * x - forward * z, -right * x + forward * z, -right * x - forward * z} do
local test = position + offset
local floor = workspace:Raycast(test + Vector3.yAxis, -Vector3.yAxis * 2, geometry)
assert(floor and floor.Normal.Y > .96 and math.abs(floor.Position.Y - position.Y) < .20,
"Rune footprint needs flat floor: " .. tostring(test))
end
end
local function part(parent: Instance, name: string, size: Vector3, pose: CFrame, color: Color3, neon: boolean): Part
local p = Instance.new("Part")
p.Name, p.Size, p.CFrame, p.Color = name, size, pose, color
p.Material = if neon then Enum.Material.Neon else Enum.Material.SmoothPlastic
p.Anchored, p.CanCollide, p.CanTouch, p.CanQuery, p.CastShadow = true, false, false, false, false
p.Parent = parent
return p
end
local function rune(name: string, kind: "Guide" | "Boost" | "Jump", at: CFrame, tint: Color3): (Model, BasePart)
local m = Instance.new("Model")
m.Name = name
m.ModelStreamingMode = Enum.ModelStreamingMode.Atomic
m:SetAttribute("Kind", kind)
m:SetAttribute("Tint", tint)
count[kind] += 1
m:SetAttribute("Phase", count[kind] * 1.17)
local p = part(m, "Origin", Vector3.new(2, 2, 2), at, tint, false)
p.Transparency = 1
m.PrimaryPart = p
m.Parent = set
return m, p
end
local function group(parent: Model, name: string, at: CFrame, motion: string, sequence: number): Model
local m = Instance.new("Model")
m.Name = name
m.WorldPivot = at
m:SetAttribute("Motion", motion)
m:SetAttribute("Sequence", sequence)
m.Parent = parent
return m
end
local function bar(parent: Model, name: string, at: CFrame, a: Vector3, b: Vector3, width: number, height: number, color: Color3)
local from = at:PointToWorldSpace(a)
local to = at:PointToWorldSpace(b)
local mid = (from + to) / 2
part(parent, name, Vector3.new(width, height, (from - to).Magnitude + .09), CFrame.lookAt(mid, to), color, true)
end
local function floorArrow(parent: Model, at: CFrame, width: number, length: number, tint: Color3, index: number)
local arrow = group(parent, "Chevron" .. index, at, "Chase", index)
local tip = Vector3.new(0, 0, -length * .45)
for _, side in {-1, 1} do
bar(arrow, "Wing", at, Vector3.new(width * .5 * side, 0, length * .45), tip, .32, .13, tint)
end
return arrow
end
local function light(origin: BasePart, tint: Color3, range: number, ambientRate: number)
local lamp = Instance.new("PointLight")
lamp.Name = "RuneLight"
lamp.Color = tint
lamp.Brightness = .6
lamp.Range = range
lamp.Parent = origin
local emitter = Instance.new("ParticleEmitter")
emitter.Name = "RuneSparks"
emitter.Texture = "rbxasset://textures/particles/sparkles_main.dds"
emitter.Color = ColorSequence.new(ice, tint)
emitter.LightEmission = .86
emitter.EmissionDirection = Enum.NormalId.Top
emitter.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, .58), NumberSequenceKeypoint.new(.22, .23), NumberSequenceKeypoint.new(1, 1),
})
emitter.Size = NumberSequence.new(.33, .07)
emitter.Lifetime = NumberRange.new(.52, .92)
emitter.Speed = NumberRange.new(1.7, 3.5)
emitter.SpreadAngle = Vector2.new(38, 38)
emitter.RotSpeed = NumberRange.new(-50, 50)
emitter.Rate = ambientRate
local attachment = Instance.new("Attachment")
attachment.Name = "SparkSource"
attachment.Position = Vector3.new(0, .29, 0)
attachment.Parent = origin
emitter.Parent = attachment
end
local function ring(parent: Model, at: CFrame, radius: number, tint: Color3, pieces: number, motion: string)
local model = group(parent, motion, at, motion, 0)
for i = 0, pieces - 1 do
local angle = math.pi * 2 * i / pieces
local endAngle = angle + math.pi * 2 / pieces * .83
local a = Vector3.new(math.cos(angle) * radius, 0, math.sin(angle) * radius)
local b = Vector3.new(math.cos(endAngle) * radius, 0, math.sin(endAngle) * radius)
bar(model, "Arc", at, a, b, if radius > 4 then .25 else .14, .09, if i % 4 == 0 then ice else tint)
end
return model
end
local function disc(parent: Model, name: string, at: CFrame, radius: number, thickness: number, tint: Color3, neon: boolean)
local p = part(parent, name, Vector3.new(thickness, radius * 2, radius * 2), at * CFrame.Angles(0, 0, math.pi / 2), tint, neon)
p.Shape = Enum.PartType.Cylinder
end
local guideSpecs = {
{"North cross", 0,-54,0,-18,20},{"South cross",0,54,0,18,20},
{"East passage",120,0,85,0,22},{"West passage",-120,0,-85,0,22},
{"North gallery approach",24,-149,24,-166,22},{"South gallery approach",-24,149,-24,166,22},
{"East gallery approach",150,24,166,24,22},{"West gallery approach",-150,-24,-166,-24,22},
{"North ramp",-99,-118,-99,-86,20},{"South ramp",99,118,99,86,20},
{"South court bypass",-138,163,-155,177,22},{"North court bypass",138,-163,155,-177,22},
{"East upper link",92,-12,79,-12,47},{"West upper link",-92,12,-79,12,47},
}
for _, spec in guideSpecs do
local name, x, z, tx, tz, ceiling = table.unpack(spec :: {any})
local position = walkable(x, z, ceiling)
local tint = if name:find("gallery") or name:find("upper") then violet else cobalt
if name:find("ramp") then tint = gold end
local m, origin = rune("Guide · " .. name, "Guide", CFrame.lookAt(position, Vector3.new(center.X + tx, position.Y, center.Z + tz)), tint)
flatFootprint(position, origin.CFrame.RightVector, origin.CFrame.LookVector, 2.5, 4.1)
for i = 1, 3 do
floorArrow(m, origin.CFrame * CFrame.new(0, .16, (2 - i) * 2.65), 4.55, 1.45, tint, i)
end
end
local boostColors = {
Color3.fromRGB(255, 55, 168),
Color3.fromRGB(255, 78, 149),
Color3.fromRGB(255, 129, 123),
Color3.fromRGB(255, 183, 108),
Color3.fromRGB(255, 231, 112),
}
local function triangularInlay(parent: Model, a: Vector3, b: Vector3, c: Vector3, tint: Color3)
-- Split along the altitude to the longest edge. Two wedges give the inlay a clean outline.
if (c - b).Magnitude > (b - a).Magnitude and (c - b).Magnitude >= (c - a).Magnitude then
a, b, c = b, c, a
elseif (c - a).Magnitude > (b - a).Magnitude then
a, b, c = c, a, b
end
local edge = (b - a).Unit
local corner = a + edge * (c - a):Dot(edge)
local rise = c - corner
for _, endPoint in {a, b} do
local run = endPoint - corner
if run.Magnitude < .01 then continue end
local y, z = rise.Unit, -run.Unit
local wedge = Instance.new("WedgePart")
wedge.Name = "LightInlay"
wedge.Size = Vector3.new(.08, rise.Magnitude, run.Magnitude)
wedge.CFrame = CFrame.fromMatrix(corner + (rise + run) / 2, y:Cross(z), y, z)
wedge.Color, wedge.Material, wedge.Transparency = tint, Enum.Material.Neon, .23
wedge.Anchored, wedge.CanCollide, wedge.CanTouch, wedge.CanQuery, wedge.CastShadow = true, false, false, false, false
wedge.Parent = parent
end
end
local function boostChevron(parent: Model, at: CFrame, halfWidth: number, spacing: number, tint: Color3, index: number)
local arrow = group(parent, "Chevron" .. index, at, "BoostChase", index)
local tip = at.Position + at.LookVector * (spacing * .36)
local thickness = -at.LookVector * (spacing * .36)
for _, side in {-1, 1} do
local wing = at.Position + at.RightVector * (side * halfWidth)
triangularInlay(arrow, tip, tip + thickness, wing, tint)
triangularInlay(arrow, wing, tip + thickness, wing + thickness, tint)
end
end
local function isMainRamp(name: string): boolean
return name:match("^A%d+_") ~= nil and (name:find("_ramp_") ~= nil or name:find("_ascent_to_") ~= nil
or name:find("^A%d+_Gallery_.+_access_") ~= nil or name:find("_inward_access_") ~= nil
or name:find("_terrace_access_") ~= nil)
end
local rampGeometry = RaycastParams.new()
rampGeometry.FilterType = Enum.RaycastFilterType.Include
rampGeometry.RespectCanCollide = true
local ramps: {BasePart} = {}
for _, child in arena:GetDescendants() do
if child:IsA("BasePart") and child.CanCollide and isMainRamp(child.Name) then table.insert(ramps, child) end
end
table.sort(ramps, function(a, b) return a.Name < b.Name end)
assert(#ramps > 0, "No playable arena ramps found")
for _, ramp in ramps do
rampGeometry.FilterDescendantsInstances = {ramp}
local top = ramp.Position.Y + ramp.Size.Y / 2 + 4
local function surfaceAt(point: Vector3): RaycastResult
local hit = workspace:Raycast(Vector3.new(point.X, top, point.Z), -Vector3.yAxis * (ramp.Size.Y + 8), rampGeometry)
assert(hit and hit.Normal.Y > .6 and hit.Normal.Y < .985, "Expected a ramp slope: " .. ramp.Name)
return hit
end
local mid = surfaceAt(ramp.Position)
local normal = mid.Normal
local downhill = Vector3.new(normal.X, 0, normal.Z).Unit
local alongX = math.abs(downhill.X) > .5
local length = if alongX then ramp.Size.X else ramp.Size.Z
local width = if alongX then ramp.Size.Z else ramp.Size.X
local lower = surfaceAt(mid.Position + downhill * (length * .20))
local forward = -downhill * normal.Y + Vector3.yAxis * math.sqrt(1 - normal.Y ^ 2)
local at = CFrame.lookAt(lower.Position, lower.Position + forward, normal)
local halfWidth = width * .41
local halfLength = math.min(14, length / normal.Y * .24)
for _, x in {-halfWidth, 0, halfWidth} do
for _, z in {-halfLength, 0, halfLength} do
local point = at:PointToWorldSpace(Vector3.new(x, 0, z))
local hit = workspace:Raycast(point + Vector3.yAxis * 5, -Vector3.yAxis * 6, geometry)
assert(hit and hit.Instance == ramp and (hit.Position - point).Magnitude < .10,
"Booster does not fit the ramp surface: " .. ramp.Name)
end
end
local m, origin = rune("Boost · " .. ramp.Name, "Boost", at, boostColors[3])
m:SetAttribute("HalfWidth", halfWidth)
m:SetAttribute("HalfLength", halfLength)
local spacing = halfLength * 2 / #boostColors
for i, tint in boostColors do
local pose = at * CFrame.new(0, .15, (3 - i) * spacing)
boostChevron(m, pose, halfWidth * (1 - (i - 1) * .022), spacing, tint, i)
end
light(origin, boostColors[2], 13, 0)
end
local jumpSpecs = {
{"North Gallery",24,-166,0,-1},{"South Gallery",-24,166,0,1},
{"East Gallery",166,24,1,0},{"West Gallery",-166,-24,-1,0},
{"East Citadel",79,-12,-1,0},{"West Citadel",-79,12,1,0},
}
for _, spec in jumpSpecs do
local name, x, z, dx, dz = table.unpack(spec :: {any})
local position = walkable(x, z, 110)
local m, origin = rune("Jump · " .. name, "Jump", CFrame.lookAt(position, position + Vector3.new(dx, 0, dz)), violet)
local at = origin.CFrame
flatFootprint(position, at.RightVector, at.LookVector, 4, 4)
disc(m, "RuneSlab", at * CFrame.new(0, .16, 0), 5.2, .24, dark, false)
ring(m, at * CFrame.new(0, .31, 0), 4.88, violet, 14, "OuterRing")
ring(m, at * CFrame.new(0, .32, 0), 3.35, violet, 8, "InnerRing")
for i = 0, 7 do
local angle = i * math.pi / 4
part(m, "EdgeCrystal", Vector3.new(.39, .16, .39), at * CFrame.new(math.cos(angle) * 4.15, .38, math.sin(angle) * 4.15)
* CFrame.Angles(0, angle + math.pi / 4, 0), if i % 2 == 0 then ice else violet, true)
end
for i = 1, 2 do
local pose = at * CFrame.new(0, .75 + i * .72, -.12)
local glyph = group(m, "LiftGlyph" .. i, pose, "Lift", i)
for _, side in {-1, 1} do
bar(glyph, "RisingStroke", pose, Vector3.new(.97 * side, -.33, 0), Vector3.new(0, .34, 0), .19, .15, if i == 1 then violet else ice)
end
end
light(origin, violet, 16, 3)
end
local existing = arena:FindFirstChild(set.Name)
if existing then
for _, model in existing:GetChildren() do
local kind = model:GetAttribute("Kind")
if kind == "Boost" or kind == "Landing" then
model:Destroy()
elseif kind == "Jump" then
local destination = model:FindFirstChild("Destination")
if destination then destination:Destroy() end
end
end
for _, model in set:GetChildren() do
if model:GetAttribute("Kind") == "Boost" or not existing:FindFirstChild(model.Name) then model.Parent = existing end
end
set:Destroy()
else
set.Parent = arena
end
return count