Загрузка данных


-- ПОСТРОЙКА КАРТЫ ПРЯМО В РЕДАКТОРЕ (не в Play Mode!)
-- Вставь в Command Bar и нажми Enter

local C = {
    wall = Color3.fromRGB(163, 162, 165),
    corridor = Color3.fromRGB(120, 120, 120),
    side = Color3.fromRGB(80, 80, 80),
    floor = Color3.fromRGB(150, 150, 150),
    ceiling = Color3.fromRGB(27, 42, 53),
    spawnGreen = Color3.fromRGB(75, 151, 75),
    spawnRed = Color3.fromRGB(196, 40, 28),
    spawnBlue = Color3.fromRGB(13, 105, 172),
    spawnYellow = Color3.fromRGB(245, 205, 48)
}

function part(name, size, pos, color, parent)
    local p = Instance.new("Part")
    p.Name = name
    p.Size = size
    p.CFrame = CFrame.new(pos)
    p.Color = color
    p.Material = Enum.Material.Plastic
    p.Anchored = true
    p.TopSurface = Enum.SurfaceType.Studs
    p.BottomSurface = Enum.SurfaceType.Inlet
    p.Parent = parent
    return p
end

function wall(name, size, pos, color, parent)
    local w = part(name, size, pos, color, parent)
    w.TopSurface = Enum.SurfaceType.Smooth
    w.BottomSurface = Enum.SurfaceType.Smooth
    w.LeftSurface = Enum.SurfaceType.Studs
    w.RightSurface = Enum.SurfaceType.Studs
    return w
end

-- Папки
local map = workspace:FindFirstChild("Map") or Instance.new("Folder")
map.Name = "Map"
map.Parent = workspace

local npcs = workspace:FindFirstChild("NPCs") or Instance.new("Folder")
npcs.Name = "NPCs"
npcs.Parent = workspace

local spawns = workspace:FindFirstChild("Spawns") or Instance.new("Folder")
spawns.Name = "Spawns"
spawns.Parent = workspace

-- ПОТОЛОК (если нет)
if not map:FindFirstChild("Ceiling") then
    part("Ceiling", Vector3.new(512, 1, 512), Vector3.new(0, 20, 0), C.ceiling, map)
end

-- КОРИДОРЫ
local corridors = {{-120}, {-60}, {0}, {60}, {120}}
for _, data in pairs(corridors) do
    local x = data[1]
    local name = "Corridor_" .. x
    if map:FindFirstChild(name) then continue end
    
    local f = Instance.new("Folder")
    f.Name = name
    f.Parent = map
    
    part("Floor", Vector3.new(20, 1, 10), Vector3.new(x, 0, 0), C.corridor, f)
    wall("WallNorth", Vector3.new(20, 20, 1), Vector3.new(x, 10, -5.5), C.wall, f)
    wall("WallSouth", Vector3.new(20, 20, 1), Vector3.new(x, 10, 5.5), C.wall, f)
end

-- ДВЕРНЫЕ ПРОЁМЫ (в твои комнаты)
local rooms = {
    {name = "Room1", x = -130.5, color = Color3.fromRGB(196, 40, 28)},
    {name = "Room2", x = -110.5, color = Color3.fromRGB(13, 105, 172), x2 = -69.5},
    {name = "Room3", x = -50.5, color = Color3.fromRGB(75, 151, 75), x2 = -9.5},
    {name = "Room4", x = 9.5, color = Color3.fromRGB(124, 92, 70), x2 = 50.5},
    {name = "Room5", x = 69.5, color = Color3.fromRGB(163, 162, 165), x2 = 110.5},
    {name = "Room6", x = 129.5, color = Color3.fromRGB(245, 205, 48)}
}

for _, r in pairs(rooms) do
    local room = workspace:FindFirstChild(r.name)
    if not room then continue end
    
    -- Левая дверь
    if r.x then
        local doorName = "DoorLeft"
        if r.x > 0 and r.name ~= "Room1" then doorName = "DoorRight" end
        if r.name == "Room1" then doorName = "DoorRight" end
        
        if not room:FindFirstChild(doorName) then
            local df = Instance.new("Folder")
            df.Name = doorName
            df.Parent = room
            
            wall("Top", Vector3.new(1, 8, 40), Vector3.new(r.x, 16, 0), r.color, df)
            wall("SideLeft", Vector3.new(1, 12, 16), Vector3.new(r.x, 6, -12), r.color, df)
            wall("SideRight", Vector3.new(1, 12, 16), Vector3.new(r.x, 6, 12), r.color, df)
        end
    end
    
    -- Правая дверь (если есть)
    if r.x2 then
        local doorName = "DoorRight"
        if not room:FindFirstChild(doorName) then
            local df = Instance.new("Folder")
            df.Name = doorName
            df.Parent = room
            
            wall("Top", Vector3.new(1, 8, 40), Vector3.new(r.x2, 16, 0), r.color, df)
            wall("SideLeft", Vector3.new(1, 12, 16), Vector3.new(r.x2, 6, -12), r.color, df)
            wall("SideRight", Vector3.new(1, 12, 16), Vector3.new(r.x2, 6, 12), r.color, df)
        end
    end
end

-- Room6 сплошная правая стена
local room6 = workspace:FindFirstChild("Room6")
if room6 and not room6:FindFirstChild("WallRightSolid") then
    wall("WallRightSolid", Vector3.new(1, 20, 40), Vector3.new(170.5, 10, 0), C.spawnYellow, room6)
end

-- БОКОВЫЕ КОМНАТЫ
local sideRooms = {
    {name = "SideA", x = -150, z = -50, cx = -150, cz = -28.75},
    {name = "SideB", x = 30, z = 50, cx = 30, cz = 28.75},
    {name = "SideC", x = -90, z = -50, cx = -90, cz = -28.75}
}

for _, s in pairs(sideRooms) do
    if map:FindFirstChild(s.name) then continue end
    
    local f = Instance.new("Folder")
    f.Name = s.name
    f.Parent = map
    
    -- Комната
    wall("Back", Vector3.new(25, 20, 1), Vector3.new(s.x, 10, s.z - 12.5), C.side, f)
    wall("Front", Vector3.new(25, 20, 1), Vector3.new(s.x, 10, s.z + 12.5), C.side, f)
    wall("Left", Vector3.new(1, 20, 25), Vector3.new(s.x - 12.5, 10, s.z), C.side, f)
    wall("Right", Vector3.new(1, 20, 25), Vector3.new(s.x + 12.5, 10, s.z), C.side, f)
    part("Floor", Vector3.new(23, 1, 23), Vector3.new(s.x, 0, s.z), C.floor, f)
    
    -- Коридор к ней
    local cf = Instance.new("Folder")
    cf.Name = "CorridorTo" .. s.name
    cf.Parent = map
    
    local cz = (s.z > 0) and s.z - 12.5 or s.z + 12.5
    part("Floor", Vector3.new(8, 1, 20), Vector3.new(s.x, 0, s.cz), C.corridor, cf)
    wall("Wall1", Vector3.new(1, 20, 20), Vector3.new(s.x - 4.5, 10, s.cz), C.side, cf)
    wall("Wall2", Vector3.new(1, 20, 20), Vector3.new(s.x + 4.5, 10, s.cz), C.side, cf)
end

-- СПАВНЫ
local spawnData = {
    {"SpawnGreen", Vector3.new(-180, 1, 80), C.spawnGreen},
    {"SpawnRed", Vector3.new(-160, 1, 80), C.spawnRed},
    {"SpawnBlue", Vector3.new(-180, 1, 100), C.spawnBlue},
    {"SpawnYellow", Vector3.new(-160, 1, 100), C.spawnYellow}
}

for _, s in pairs(spawnData) do
    if spawns:FindFirstChild(s[1]) then continue end
    local sp = Instance.new("SpawnLocation")
    sp.Name = s[1]
    sp.Size = Vector3.new(6, 1, 6)
    sp.CFrame = CFrame.new(s[2])
    sp.Color = s[3]
    sp.Material = Enum.Material.Plastic
    sp.TopSurface = Enum.SurfaceType.Studs
    sp.BottomSurface = Enum.SurfaceType.Inlet
    sp.Parent = spawns
end

-- NPC ТОЧКИ
local npcData = {
    {"Room1", -150, 0}, {"Room2", -90, 0}, {"Room3", -30, 0},
    {"Room4", 30, 0}, {"Room5", 90, 0}, {"Room6", 150, 0},
    {"SideA", -150, -50}, {"SideB", 30, 50}, {"SideC", -90, -50}
}

for _, n in pairs(npcData) do
    local fname = n[1] .. "_Points"
    if npcs:FindFirstChild(fname) then continue end
    
    local f = Instance.new("Folder")
    f.Name = fname
    f.Parent = npcs
    
    for i = 1, 3 do
        local p = Instance.new("Part")
        p.Name = "Point" .. i
        p.Size = Vector3.new(1, 1, 1)
        p.CFrame = CFrame.new(n[2] + math.random(-12, 12), 0.5, n[3] + math.random(-12, 12))
        p.Transparency = 1
        p.CanCollide = false
        p.Anchored = true
        p.Parent = f
    end
end

print("=== ГОТОВО! Сохрани проект (Ctrl+S) ===")