--!strict local ReplicatedStorage = game:GetService("ReplicatedStorage") local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) local Sites = {} export type Site = {name: string, position: Vector3} export type Map = {blue: Vector3, orange: Vector3, ground: Site, gallery: Site, roof: Site, west: Site, east: Site} local level = 32.51785 function Sites.resolve(id: string): Map local origin = Modes.geometry(id):GetPivot().Position local geometry = Modes.collision(id) local function sample(point: Vector3): Vector3? local floor = workspace:Raycast(point + Vector3.yAxis * 2, -Vector3.yAxis * 5, geometry) if not floor or floor.Normal.Y < .95 or math.abs(floor.Position.Y - point.Y) > 1.6 then return nil end if workspace:Raycast(floor.Position + Vector3.yAxis * .15, Vector3.yAxis * 6, geometry) then return nil end return floor.Position end local function find(name: string, candidates: {Vector3}): Site for _, candidate in candidates do local at = origin + candidate local center = sample(at) if center and sample(at + Vector3.xAxis * 4) and sample(at - Vector3.xAxis * 4) and sample(at + Vector3.zAxis * 4) and sample(at - Vector3.zAxis * 4) then return {name = name, position = center} end end error("No walkable match objective: " .. id .. " / " .. name) end local base = Vector3.new(0, 0, 205) local gallery = {Vector3.new(0, level, 44), Vector3.new(0, level, -44)} local roof = {Vector3.yAxis * level * 2, Vector3.new(0, level * 2, 12)} return { blue = find("База синих", {-base}).position, orange = find("База оранжевых", {base}).position, ground = find("Нижний проход", {Vector3.zero, Vector3.new(0, 0, 6)}), gallery = find("Средняя галерея", gallery), roof = find("Крыша цитадели", roof), west = find("Западный фланг", {Vector3.new(-162.6, 0, 0), Vector3.new(-145, 0, 0), Vector3.new(-120, 0, 0)}), east = find("Восточный фланг", {Vector3.new(162.6, 0, 0), Vector3.new(145, 0, 0), Vector3.new(120, 0, 0)}), } end local function fits(center: Vector3, geometry: RaycastParams, radius: number): boolean for index = 0, 15 do local angle = index * math.pi / 8 local offset = Vector3.new(math.cos(angle), 0, math.sin(angle)) * (radius + .4) for _, distance in {0.5, 1} do local at = center + offset * distance local floor = workspace:Raycast(at + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry) if not floor or floor.Normal.Y < .95 or math.abs(floor.Position.Y - center.Y) > .35 then return false end if workspace:Raycast(at + Vector3.yAxis * .25, Vector3.yAxis * 9, geometry) then return false end end for _, height in {1, 4, 8} do if workspace:Raycast(center + Vector3.yAxis * height, offset, geometry) then return false end end end return workspace:Raycast(center + Vector3.yAxis * .25, Vector3.yAxis * 9, geometry) == nil end function Sites.clearCircle(center: Vector3, geometry: RaycastParams, radius: number): Vector3 if fits(center, geometry, radius) then return center end for distance = 3, 48, 3 do for index = 0, 15 do local angle = index * math.pi / 8 local at = center + Vector3.new(math.cos(angle), 0, math.sin(angle)) * distance local floor = workspace:Raycast(at + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry) if floor and floor.Normal.Y >= .95 and math.abs(floor.Position.Y - center.Y) <= .35 and fits(floor.Position, geometry, radius) then return floor.Position end end end return center end function Sites.hotPath(id: string, map: Map, radius: number): {Site} local origin = Modes.geometry(id):GetPivot().Position local geometry = Modes.collision(id) local path: {Site} = {} local function insert(site: Site, alternatives: {Vector3}) local candidates = {site.position} for _, offset in alternatives do table.insert(candidates, origin + offset) end for _, candidate in candidates do local floor = workspace:Raycast(candidate + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry) if floor and floor.Normal.Y >= .95 and math.abs(floor.Position.Y - candidate.Y) <= .35 and fits(floor.Position, geometry, radius) then table.insert(path, {name = site.name, position = floor.Position}) return end end error("No room for Hot Point: " .. site.name) end insert(map.ground, {Vector3.new(18, 0, 0), Vector3.new(-18, 0, 0)}) insert(map.west, {Vector3.new(-151, 0, 0), Vector3.new(-176, 0, 0), Vector3.new(-189, 0, 0)}) insert(map.roof, {Vector3.new(0, 2 * level, 24), Vector3.new(0, 2 * level, -24)}) insert(map.east, {Vector3.new(151, 0, 0), Vector3.new(176, 0, 0), Vector3.new(189, 0, 0)}) local galleries = {Vector3.new(0, level, 0)} for _, x in {36, -36, 45, -45, 18, -18} do for _, z in {0, 27, -27, 34, -34} do table.insert(galleries, Vector3.new(x, level, z)) end end insert(map.gallery, galleries) return path end return Sites