Загрузка данных
local workspace = game.Workspace
-- Классические цвета Roblox 2008
local COLORS = {
baseplate = Color3.fromRGB(99, 95, 98),
wall = Color3.fromRGB(163, 162, 165),
wall_red = Color3.fromRGB(196, 40, 28),
wall_blue = Color3.fromRGB(13, 105, 172),
wall_green = Color3.fromRGB(75, 151, 75),
wall_brown = Color3.fromRGB(124, 92, 70),
ceiling = Color3.fromRGB(27, 42, 53),
floor = Color3.fromRGB(150, 150, 150),
crate = Color3.fromRGB(196, 40, 28),
pipe = Color3.fromRGB(99, 95, 98)
}
function createPart(name, size, pos, color, parent, material)
material = material or Enum.Material.Plastic
local part = Instance.new("Part")
part.Name = name
part.Size = size
part.Position = pos
part.Color = color
part.Material = material
part.Anchored = true
part.TopSurface = Enum.SurfaceType.Studs
part.BottomSurface = Enum.SurfaceType.Inlet
part.Parent = parent
return part
end
function createWall(parent, pos, size, color)
local wall = createPart("Wall", size, pos, color or COLORS.wall, parent)
wall.TopSurface = Enum.SurfaceType.Smooth
wall.BottomSurface = Enum.SurfaceType.Smooth
wall.LeftSurface = Enum.SurfaceType.Studs
wall.RightSurface = Enum.SurfaceType.Studs
return wall
end
function generateRoom(parent, centerPos, width, depth, wallHeight, color)
local halfW = width / 2
local halfD = depth / 2
local halfH = wallHeight / 2
-- Стены
createWall(parent, centerPos + Vector3.new(0, halfH, -halfD - 0.5), Vector3.new(width, wallHeight, 1), color)
createWall(parent, centerPos + Vector3.new(0, halfH, halfD + 0.5), Vector3.new(width, wallHeight, 1), color)
createWall(parent, centerPos + Vector3.new(-halfW - 0.5, halfH, 0), Vector3.new(1, wallHeight, depth), color)
createWall(parent, centerPos + Vector3.new(halfW + 0.5, halfH, 0), Vector3.new(1, wallHeight, depth), color)
-- Пол внутри
local floor = createPart("RoomFloor", Vector3.new(width - 2, 1, depth - 2), centerPos, COLORS.floor, parent)
floor.TopSurface = Enum.SurfaceType.Studs
end
function generateCorridor(parent, startPos, endPos, width, wallHeight, color)
local direction = (endPos - startPos)
local length = direction.Magnitude
local midPoint = (startPos + endPos) / 2
local unitDir = direction.Unit
local floor = createPart("CorridorFloor", Vector3.new(width, 1, length), midPoint, COLORS.floor, parent)
floor.TopSurface = Enum.SurfaceType.Studs
local perp = Vector3.new(-unitDir.Z, 0, unitDir.X) * (width / 2 + 0.5)
createWall(parent, midPoint + perp + Vector3.new(0, wallHeight/2, 0), Vector3.new(1, wallHeight, length), color)
createWall(parent, midPoint - perp + Vector3.new(0, wallHeight/2, 0), Vector3.new(1, wallHeight, length), color)
end
function generateDecor(parent, roomCenter)
-- Ящики
for i = 1, math.random(2, 4) do
local cratePos = roomCenter + Vector3.new(math.random(-15, 15), 2, math.random(-15, 15))
local crate = createPart("Crate", Vector3.new(4, 4, 4), cratePos, COLORS.crate, parent)
crate.TopSurface = Enum.SurfaceType.Smooth
end
-- Трубы
for i = 1, math.random(1, 3) do
local pipePos = roomCenter + Vector3.new(math.random(-18, 18), math.random(5, 15), math.random(-18, 18))
local pipe = createPart("Pipe", Vector3.new(1, math.random(8, 15), 1), pipePos, COLORS.pipe, parent, Enum.Material.Concrete)
pipe.TopSurface = Enum.SurfaceType.Smooth
end
end
function createPointsForRoom(roomNum, roomPos)
local pointsFolder = workspace.NPCs:FindFirstChild("Room" .. roomNum .. "_Points")
if not pointsFolder then
pointsFolder = Instance.new("Folder")
pointsFolder.Name = "Room" .. roomNum .. "_Points"
pointsFolder.Parent = workspace.NPCs
end
for p = 1, 3 do
local point = Instance.new("Part")
point.Name = "Point" .. p
point.Size = Vector3.new(1, 1, 1)
point.Position = roomPos + Vector3.new(math.random(-15, 15), 0.5, math.random(-15, 15))
point.Transparency = 1
point.CanCollide = false
point.Anchored = true
point.Parent = pointsFolder
end
end
function generateMap()
local map = workspace:FindFirstChild("Map")
if not map then
map = Instance.new("Folder")
map.Name = "Map"
map.Parent = workspace
end
for _, child in pairs(map:GetChildren()) do
child:Destroy()
end
-- Поле и потолок
createPart("Baseplate", Vector3.new(512, 1, 512), Vector3.new(0, 0, 0), COLORS.baseplate, map)
createPart("Ceiling", Vector3.new(512, 1, 512), Vector3.new(0, 25, 0), COLORS.ceiling, map)
-- 6 комнат в ряд
local roomColors = {COLORS.wall_red, COLORS.wall_blue, COLORS.wall_green, COLORS.wall_brown, COLORS.wall}
local rooms = {}
local roomSpacing = 60
local startX = -150
for i = 1, 6 do
local roomPos = Vector3.new(startX + (i-1) * roomSpacing, 0, 0)
local color = roomColors[math.random(1, #roomColors)]
generateRoom(map, roomPos, 40, 40, 20, color)
generateDecor(map, roomPos)
createPointsForRoom(i, roomPos)
table.insert(rooms, roomPos)
end
-- Коридоры между комнатами
for i = 1, #rooms - 1 do
local startPos = rooms[i] + Vector3.new(20, 0, 0)
local endPos = rooms[i + 1] + Vector3.new(-20, 0, 0)
generateCorridor(map, startPos, endPos, 10, 20, COLORS.wall)
end
-- Боковые коридоры
for i = 1, 3 do
local roomIdx = math.random(1, #rooms)
local roomPos = rooms[roomIdx]
local sideDir = math.random(1, 2) == 1 and 1 or -1
local startPos = roomPos + Vector3.new(0, 0, 20 * sideDir)
local endPos = startPos + Vector3.new(0, 0, 40 * sideDir)
generateCorridor(map, startPos, endPos, 8, 20, COLORS.wall_brown)
generateRoom(map, endPos + Vector3.new(0, 0, 20 * sideDir), 25, 25, 20, COLORS.wall_blue)
createPointsForRoom(6 + i, endPos + Vector3.new(0, 0, 20 * sideDir))
end
-- Спавны
local spawnsFolder = workspace:FindFirstChild("Spawns")
if not spawnsFolder then
spawnsFolder = Instance.new("Folder")
spawnsFolder.Name = "Spawns"
spawnsFolder.Parent = workspace
end
for _, child in pairs(spawnsFolder:GetChildren()) do
child:Destroy()
end
local spawnColors = {
Color3.fromRGB(75, 151, 75),
Color3.fromRGB(196, 40, 28),
Color3.fromRGB(13, 105, 172),
Color3.fromRGB(245, 205, 48)
}
for i = 1, 4 do
local spawn = Instance.new("SpawnLocation")
spawn.Name = "Spawn" .. i
spawn.Size = Vector3.new(6, 1, 6)
spawn.Position = Vector3.new(-180 + (i-1) * 40, 1, -50)
spawn.Color = spawnColors[i]
spawn.Material = Enum.Material.Plastic
spawn.TopSurface = Enum.SurfaceType.Studs
spawn.BottomSurface = Enum.SurfaceType.Inlet
spawn.Parent = spawnsFolder
end
print("КАРТА СГЕНЕРИРОВАНА! Комнат: " .. #rooms .. "+3 боковых")
end
generateMap()