From 134940f76d714341cc5f79408c0636cfd1177daf Mon Sep 17 00:00:00 2001 From: listik Date: Tue, 3 Nov 2026 23:03:51 +0300 Subject: [PATCH] 12 --- .../6_World1Builder_ServerScriptService.rbxmx | 39 ++- .../7_WorldBuilder_ServerScriptService.rbxmx | 240 ++++++++++++++- install/INSTALL.lua | 279 ++++++++++++++++-- src/ServerScriptService/World1Builder.lua | 39 ++- src/ServerScriptService/WorldBuilder.lua | 70 +++-- 5 files changed, 574 insertions(+), 93 deletions(-) diff --git a/install/6_World1Builder_ServerScriptService.rbxmx b/install/6_World1Builder_ServerScriptService.rbxmx index bb93a0d..0c1c6cc 100644 --- a/install/6_World1Builder_ServerScriptService.rbxmx +++ b/install/6_World1Builder_ServerScriptService.rbxmx @@ -132,7 +132,8 @@ end ---------------------------------------------------------------- детали -- parent — куда положить папку World1Map (Workspace при сборке в Studio, FishingMap при запуске игры) -function Builder.build(parent) +-- makePortal — WorldBuilder.portalModel: ставит модель портала из шаблона (без него строится старое кольцо) +function Builder.build(parent, makePortal) buildTerrain() local rng = Random.new(7) @@ -541,20 +542,30 @@ function Builder.build(parent) portalModel.Name = "PortalToLobby" portalModel.Parent = map local center = baseCF * CFrame.new(0, 10, 0) - P({ Size = V(17, 1, 9), CFrame = baseCF * CFrame.new(0, 0.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(95, 100, 115), Parent = portalModel }) - P({ Size = V(14, 1, 7), CFrame = baseCF * CFrame.new(0, 1.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(110, 115, 130), Parent = portalModel }) - local R, n = 7, 20 - for i = 0, n - 1 do - local a = (i + 0.5) / n * math.pi * 2 - P({ Size = V(2 * math.pi * R / n + 0.4, 1.7, 1.7), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(80, 85, 100), Parent = portalModel }) - if i % 2 == 0 then - P({ Size = V(0.6, 0.6, 1.9), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R + 0.95, 0), Material = Enum.Material.Neon, Color = color, Parent = portalModel }) + local fancy = makePortal and makePortal(baseCF, color, "PortalModel_Lobby", portalModel) + local disc + if fancy then + -- модель из шаблона; невидимый якорь держит подсказку, подпись и искры + disc = P({ + Name = "Portal_Lobby", Size = V(1, 1, 1), CFrame = center * CFrame.Angles(0, math.rad(90), 0), + Transparency = 1, CanCollide = false, CanQuery = false, CanTouch = false, Parent = portalModel, + }) + else + P({ Size = V(17, 1, 9), CFrame = baseCF * CFrame.new(0, 0.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(95, 100, 115), Parent = portalModel }) + P({ Size = V(14, 1, 7), CFrame = baseCF * CFrame.new(0, 1.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(110, 115, 130), Parent = portalModel }) + local R, n = 7, 20 + for i = 0, n - 1 do + local a = (i + 0.5) / n * math.pi * 2 + P({ Size = V(2 * math.pi * R / n + 0.4, 1.7, 1.7), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(80, 85, 100), Parent = portalModel }) + if i % 2 == 0 then + P({ Size = V(0.6, 0.6, 1.9), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R + 0.95, 0), Material = Enum.Material.Neon, Color = color, Parent = portalModel }) + end end + disc = P({ + Name = "Portal_Lobby", Shape = Enum.PartType.Cylinder, Size = V(0.3, 2 * R - 1, 2 * R - 1), CFrame = center * CFrame.Angles(0, math.rad(90), 0), + Material = Enum.Material.Neon, Color = color, Transparency = 0.3, CanCollide = false, Parent = portalModel, + }) end - local disc = P({ - Name = "Portal_Lobby", Shape = Enum.PartType.Cylinder, Size = V(0.3, 2 * R - 1, 2 * R - 1), CFrame = center * CFrame.Angles(0, math.rad(90), 0), - Material = Enum.Material.Neon, Color = color, Transparency = 0.3, CanCollide = false, Parent = portalModel, - }) local pe = Instance.new("ParticleEmitter") pe.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) pe.LightEmission = 1 @@ -567,7 +578,7 @@ function Builder.build(parent) pe.Parent = disc local bb = Instance.new("BillboardGui") bb.Size = UDim2.fromOffset(250, 64) - bb.StudsOffset = V(0, 10, 0) + bb.StudsOffset = V(0, fancy and 7 or 10, 0) bb.MaxDistance = 160 bb.LightInfluence = 0 bb.Parent = disc diff --git a/install/7_WorldBuilder_ServerScriptService.rbxmx b/install/7_WorldBuilder_ServerScriptService.rbxmx index 79bea75..c06f6ee 100644 --- a/install/7_WorldBuilder_ServerScriptService.rbxmx +++ b/install/7_WorldBuilder_ServerScriptService.rbxmx @@ -16,6 +16,7 @@ -- ProximityPrompt с атрибутом Action (Shop, Sell, Portal, Daily, Talk, ...). local Workspace = game:GetService("Workspace") +local ServerStorage = game:GetService("ServerStorage") local Lighting = game:GetService("Lighting") local Players = game:GetService("Players") local RunService = game:GetService("RunService") @@ -174,6 +175,160 @@ local function marker(name, cf) return P({ Name = name, Size = V(4, 1, 4), CFrame = cf, Transparency = 1, CanCollide = false, CanQuery = false, CanTouch = false }) end +local function lobbyCliffs() + local template = ServerStorage:FindFirstChild("FishingCliffTemplate") + if not template or not template:IsA("Model") then + warn("FishingCliffTemplate отсутствует; используем низкую изгородь лобби") + for deg = 0, 359, 7 do + local a = math.rad(deg) + local p = V(math.cos(a) * 82, FLOOR + 2, math.sin(a) * 82) + P({ Size = V(10.5, 4, 3), CFrame = CFrame.lookAt(p, V(0, p.Y, 0)), Material = Enum.Material.Grass, Color = Color3.fromRGB(60, 130, 55) }) + end + return + end + + local ring = Instance.new("Folder") + ring.Name = "LobbyCliffs" + ring.Parent = map + local count = 24 + local tiers = { + { name = "LobbyCliff", radius = 88, scale = 1.4, baseY = FLOOR }, + { name = "LobbyCliffUpper", radius = 104, scale = 2.2, baseY = FLOOR + 10 }, + } + for _, tier in ipairs(tiers) do + for i = 1, count do + local angle = (i - 1) * 2 * math.pi / count + local radial = V(math.cos(angle), 0, math.sin(angle)) + local center = V(radial.X * tier.radius, tier.baseY, radial.Z * tier.radius) + local model = template:Clone() + model.Name = string.format("%s_%02d", tier.name, i) + model:ScaleTo(tier.scale) + local facing = CFrame.lookAt(center, center + radial) + local rotation = facing - facing.Position + model:PivotTo(CFrame.new(center) * rotation) + local boxCF, boxSize = model:GetBoundingBox() + local targetBoxCenter = V(center.X, tier.baseY + boxSize.Y / 2, center.Z) + model:PivotTo(model:GetPivot() + (targetBoxCenter - boxCF.Position)) + model.Parent = ring + end + end +end + +local function rockTopPosition(cliffs, radial, desiredRadius, radiusOffsets) + local params = RaycastParams.new() + params.FilterType = Enum.RaycastFilterType.Include + params.FilterDescendantsInstances = { cliffs } + for _, offset in ipairs(radiusOffsets) do + local radius = desiredRadius + offset + local origin = V(radial.X * radius, 128, radial.Z * radius) + local hit = Workspace:Raycast(origin, V(0, -180, 0), params) + if hit then + return hit.Position + end + end + return V(radial.X * desiredRadius, FLOOR, radial.Z * desiredRadius) +end + +local function placeModelOnRock(model, position, yaw) + local rotation = CFrame.Angles(0, yaw, 0) + model:PivotTo(CFrame.new(position) * rotation) + local boxCF, boxSize = model:GetBoundingBox() + local targetBoxCenter = V(position.X, position.Y + boxSize.Y / 2, position.Z) + model:PivotTo(model:GetPivot() + (targetBoxCenter - boxCF.Position)) +end + +local function lobbyTrees() + local templates = ServerStorage:FindFirstChild("LobbyTreeTemplates") + local cliffs = map:FindFirstChild("LobbyCliffs") + if not templates or not cliffs then + warn("LobbyTreeTemplates или LobbyCliffs отсутствует; деревья лобби пропущены") + return + end + local treeTypes = { "LargeCanopy", "Pine", "RoundCanopy" } + local treeScale = { LargeCanopy = 1, Pine = 1.25, RoundCanopy = 1.2 } + local folder = Instance.new("Folder") + folder.Name = "LobbyTrees" + folder.Parent = map + for layer = 1, 2 do + local baseRadius = layer == 1 and 84 or 96 + local radiusOffsets = { 0, -2, 2, -4, 4, -6, 6 } + for i = 1, 18 do + local degrees = (i - 1) * 20 + 10 + (layer == 2 and 10 or 0) + local angle = math.rad(degrees) + local radial = V(math.cos(angle), 0, math.sin(angle)) + local position = rockTopPosition(cliffs, radial, baseRadius, radiusOffsets) + local kind = treeTypes[(i + layer - 2) % #treeTypes + 1] + local template = templates:FindFirstChild(kind) + if template and template:IsA("Model") then + local model = template:Clone() + model.Name = string.format("LobbyTree_L%d_%02d_%s", layer, i, kind) + model:ScaleTo(treeScale[kind]) + placeModelOnRock(model, position, math.rad((i * 47 + layer * 23) % 360)) + for _, part in ipairs(model:GetDescendants()) do + if part:IsA("BasePart") then part.Anchored = true end + end + model.Parent = folder + end + end + end +end + +local function lobbyRockPlants() + local templates = ServerStorage:FindFirstChild("LobbyRockPlantTemplates") + local cliffs = map:FindFirstChild("LobbyCliffs") + if not templates or not cliffs then + warn("LobbyRockPlantTemplates или LobbyCliffs отсутствует; растительность скал пропущена") + return + end + local folder = Instance.new("Folder") + folder.Name = "LobbyRockPlants" + folder.Parent = map + local clusterAngles = { + { layer = 1, degrees = 45 }, { layer = 1, degrees = 135 }, + { layer = 1, degrees = 225 }, { layer = 1, degrees = 315 }, + { layer = 2, degrees = 0 }, { layer = 2, degrees = 90 }, + { layer = 2, degrees = 180 }, { layer = 2, degrees = 270 }, + } + local tuftKinds = { "GrassTuft", "BladeGrass", "GrassTuft", "FlowerPatch", "GrassTuft", "WideGrass" } + local tuftScales = { GrassTuft = 1.15, BladeGrass = 1.45, FlowerPatch = 1.1, WideGrass = 0.55 } + local offsets = { { 0, 0 }, { -2.2, 0 }, { 2.2, 0 }, { 0, -2.2 }, { 0, 2.2 }, { 1.6, 1.6 } } + local rayParams = RaycastParams.new() + rayParams.FilterType = Enum.RaycastFilterType.Include + rayParams.FilterDescendantsInstances = { cliffs } + for clusterIndex, cluster in ipairs(clusterAngles) do + local baseRadius = cluster.layer == 1 and 84 or 96 + local baseAngle = math.rad(cluster.degrees) + local radial = V(math.cos(baseAngle), 0, math.sin(baseAngle)) + local tangent = V(-radial.Z, 0, radial.X) + local basePos = rockTopPosition(cliffs, radial, baseRadius, { 0, -2, 2, -4, 4, -6, 6 }) + local bush = Instance.new("Model") + bush.Name = string.format("GrassBush_%02d_L%d", clusterIndex, cluster.layer) + for i, offset in ipairs(offsets) do + local xz = basePos + radial * offset[1] + tangent * offset[2] + local plantPos + for _, correction in ipairs({ 0, -2, 2, -4, 4 }) do + local candidate = xz + radial * correction + local hit = Workspace:Raycast(V(candidate.X, 128, candidate.Z), V(0, -180, 0), rayParams) + if hit then plantPos = hit.Position; break end + end + if plantPos then + local kind = tuftKinds[i] + local template = templates:FindFirstChild(kind) + if template and template:IsA("Model") then + local plant = template:Clone() + plant.Name = kind .. "_" .. i + plant:ScaleTo(tuftScales[kind]) + placeModelOnRock(plant, plantPos, math.rad((clusterIndex * 37 + i * 53) % 360)) + for _, part in ipairs(plant:GetDescendants()) do + if part:IsA("BasePart") then part.Anchored = true end + end + plant.Parent = bush + end + end + end + bush.Parent = folder + end +end -- высота земли: читаем воксели столбца (лучи по только что залитому террейну ненадёжны, особенно в редакторе) local function groundY(x, z) local region = Region3.new(V(x - 1, -128, z - 1), V(x + 1, 160, z + 1)):ExpandToGrid(4) @@ -360,7 +515,77 @@ local function stall(cf, opt) return counter end +-- Модель портала из ServerStorage.FishingPortalTemplate, перекрашенная в цвет мира и +-- поставленная основанием на baseCF. Без шаблона возвращает nil (тогда строится старое кольцо). +function Builder.portalModel(baseCF, color, name, parent) + local template = ServerStorage:FindFirstChild("FishingPortalTemplate") + if not (template and template:IsA("Model")) then + return nil + end + local model = template:Clone() + model.Name = name + for _, part in ipairs(model:GetDescendants()) do + if part:IsA("BasePart") then + local c = part.Color + local isGreen = c.G > c.R * 1.15 and c.G > c.B * 1.10 and c.G > 0.25 + if part.Material == Enum.Material.Neon then + part.Color = color + elseif isGreen then + part.Color = color:Lerp(Color3.fromRGB(55, 65, 75), 0.30) + part.Material = Enum.Material.SmoothPlastic + end + elseif part:IsA("ParticleEmitter") then + part.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) + end + end + + local pivot = template:GetPivot() + local boxCFrame, boxSize = template:GetBoundingBox() + local boxBottom = pivot:PointToObjectSpace(Vector3.new( + boxCFrame.Position.X, + boxCFrame.Position.Y - boxSize.Y / 2, + boxCFrame.Position.Z + )).Y + model:PivotTo(baseCF * CFrame.new(0, -boxBottom, 0)) + model.Parent = parent + return model +end + local function portal(baseCF, title, color, worldId, locked) + -- Все порталы, и в лобби, и возвратные в мирах, используют модель автора из ServerStorage. + do + local model = Builder.portalModel(baseCF, color, "PortalModel_" .. worldId, map) + if model then + -- Этот невидимый якорь сохраняет ProximityPrompt и подпись мира. + local disc = P({ + Name = "Portal_" .. worldId, + Size = V(1, 1, 1), + CFrame = baseCF * CFrame.new(0, 10, 0), + Transparency = 1, + CanCollide = false, + CanQuery = false, + CanTouch = false, + }) + local pe = Instance.new("ParticleEmitter") + pe.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) + pe.LightEmission = 1 + pe.Rate = 25 + pe.Lifetime = NumberRange.new(1, 1.8) + pe.Speed = NumberRange.new(0.5, 2) + pe.SpreadAngle = Vector2.new(180, 180) + pe.Size = NumberSequence.new(0.5, 0) + pe.Transparency = NumberSequence.new(0.2, 1) + pe.Parent = disc + billboard(disc, title, color:Lerp(Color3.new(1, 1, 1), 0.4), 7, 200) + if locked then + billboard(disc, "🔒", Color3.new(1, 1, 1), 0, 120) + end + local pp = prompt(disc, locked and "Посмотреть" or "Перейти", title, "Portal", 14) + pp:SetAttribute("World", worldId) + return disc + end + end + local center = baseCF * CFrame.new(0, 10, 0) P({ Size = V(17, 1, 9), CFrame = baseCF * CFrame.new(0, 0.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(95, 100, 115) }) P({ Size = V(14, 1, 7), CFrame = baseCF * CFrame.new(0, 1.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(110, 115, 130) }) @@ -541,15 +766,10 @@ function Builder.build() banner(V(math.cos(a) * 74, FLOOR, math.sin(a) * 74), b[2], b[3], b[4]) end - -- живая изгородь по краю (с проходами) - for deg = 0, 359, 7 do - local skip = (deg > 80 and deg < 100) or (deg > 255 and deg < 285) or deg < 8 or deg > 352 or (deg > 172 and deg < 188) - if not skip then - local a = math.rad(deg) - local p = V(math.cos(a) * 82, FLOOR + 2, math.sin(a) * 82) - P({ Size = V(10.5, 4, 3), CFrame = CFrame.lookAt(p, V(0, p.Y, 0)), Material = Enum.Material.Grass, Color = Color3.fromRGB(60, 130, 55) }) - end - end + -- высокий скальный контур закрывает горизонт и удерживает игроков в лобби + lobbyCliffs() + lobbyTrees() + lobbyRockPlants() -- магазин (запад) и скупка (восток) stall(CFrame.lookAt(V(-62, FLOOR, 0), V(0, FLOOR, 0)), { @@ -723,7 +943,7 @@ function Builder.build() ---------------------------------------------------------------- МИР 1: ТИХОЕ ОЗЕРО do -- отдельно собранное раньше «Тихое озеро» (Workspace.World1Map) переносим в карту, иначе строим заново - local w1map = world1Prebuilt or World1Builder.build(map) + local w1map = world1Prebuilt or World1Builder.build(map, Builder.portalModel) w1map.Parent = map -- NPC встают на маркеры — их можно двигать в Studio local seller = w1map:FindFirstChild("World1NpcSeller", true) diff --git a/install/INSTALL.lua b/install/INSTALL.lua index a95ebcc..683b5d9 100644 --- a/install/INSTALL.lua +++ b/install/INSTALL.lua @@ -2743,7 +2743,8 @@ end ---------------------------------------------------------------- детали -- parent — куда положить папку World1Map (Workspace при сборке в Studio, FishingMap при запуске игры) -function Builder.build(parent) +-- makePortal — WorldBuilder.portalModel: ставит модель портала из шаблона (без него строится старое кольцо) +function Builder.build(parent, makePortal) buildTerrain() local rng = Random.new(7) @@ -3152,20 +3153,30 @@ function Builder.build(parent) portalModel.Name = "PortalToLobby" portalModel.Parent = map local center = baseCF * CFrame.new(0, 10, 0) - P({ Size = V(17, 1, 9), CFrame = baseCF * CFrame.new(0, 0.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(95, 100, 115), Parent = portalModel }) - P({ Size = V(14, 1, 7), CFrame = baseCF * CFrame.new(0, 1.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(110, 115, 130), Parent = portalModel }) - local R, n = 7, 20 - for i = 0, n - 1 do - local a = (i + 0.5) / n * math.pi * 2 - P({ Size = V(2 * math.pi * R / n + 0.4, 1.7, 1.7), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(80, 85, 100), Parent = portalModel }) - if i % 2 == 0 then - P({ Size = V(0.6, 0.6, 1.9), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R + 0.95, 0), Material = Enum.Material.Neon, Color = color, Parent = portalModel }) + local fancy = makePortal and makePortal(baseCF, color, "PortalModel_Lobby", portalModel) + local disc + if fancy then + -- модель из шаблона; невидимый якорь держит подсказку, подпись и искры + disc = P({ + Name = "Portal_Lobby", Size = V(1, 1, 1), CFrame = center * CFrame.Angles(0, math.rad(90), 0), + Transparency = 1, CanCollide = false, CanQuery = false, CanTouch = false, Parent = portalModel, + }) + else + P({ Size = V(17, 1, 9), CFrame = baseCF * CFrame.new(0, 0.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(95, 100, 115), Parent = portalModel }) + P({ Size = V(14, 1, 7), CFrame = baseCF * CFrame.new(0, 1.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(110, 115, 130), Parent = portalModel }) + local R, n = 7, 20 + for i = 0, n - 1 do + local a = (i + 0.5) / n * math.pi * 2 + P({ Size = V(2 * math.pi * R / n + 0.4, 1.7, 1.7), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(80, 85, 100), Parent = portalModel }) + if i % 2 == 0 then + P({ Size = V(0.6, 0.6, 1.9), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R + 0.95, 0), Material = Enum.Material.Neon, Color = color, Parent = portalModel }) + end end + disc = P({ + Name = "Portal_Lobby", Shape = Enum.PartType.Cylinder, Size = V(0.3, 2 * R - 1, 2 * R - 1), CFrame = center * CFrame.Angles(0, math.rad(90), 0), + Material = Enum.Material.Neon, Color = color, Transparency = 0.3, CanCollide = false, Parent = portalModel, + }) end - local disc = P({ - Name = "Portal_Lobby", Shape = Enum.PartType.Cylinder, Size = V(0.3, 2 * R - 1, 2 * R - 1), CFrame = center * CFrame.Angles(0, math.rad(90), 0), - Material = Enum.Material.Neon, Color = color, Transparency = 0.3, CanCollide = false, Parent = portalModel, - }) local pe = Instance.new("ParticleEmitter") pe.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) pe.LightEmission = 1 @@ -3178,7 +3189,7 @@ function Builder.build(parent) pe.Parent = disc local bb = Instance.new("BillboardGui") bb.Size = UDim2.fromOffset(250, 64) - bb.StudsOffset = V(0, 10, 0) + bb.StudsOffset = V(0, fancy and 7 or 10, 0) bb.MaxDistance = 160 bb.LightInfluence = 0 bb.Parent = disc @@ -3626,6 +3637,7 @@ make('ModuleScript', 'WorldBuilder', game.ServerScriptService, [=====[-- WorldBu -- ProximityPrompt с атрибутом Action (Shop, Sell, Portal, Daily, Talk, ...). local Workspace = game:GetService("Workspace") +local ServerStorage = game:GetService("ServerStorage") local Lighting = game:GetService("Lighting") local Players = game:GetService("Players") local RunService = game:GetService("RunService") @@ -3784,6 +3796,160 @@ local function marker(name, cf) return P({ Name = name, Size = V(4, 1, 4), CFrame = cf, Transparency = 1, CanCollide = false, CanQuery = false, CanTouch = false }) end +local function lobbyCliffs() + local template = ServerStorage:FindFirstChild("FishingCliffTemplate") + if not template or not template:IsA("Model") then + warn("FishingCliffTemplate отсутствует; используем низкую изгородь лобби") + for deg = 0, 359, 7 do + local a = math.rad(deg) + local p = V(math.cos(a) * 82, FLOOR + 2, math.sin(a) * 82) + P({ Size = V(10.5, 4, 3), CFrame = CFrame.lookAt(p, V(0, p.Y, 0)), Material = Enum.Material.Grass, Color = Color3.fromRGB(60, 130, 55) }) + end + return + end + + local ring = Instance.new("Folder") + ring.Name = "LobbyCliffs" + ring.Parent = map + local count = 24 + local tiers = { + { name = "LobbyCliff", radius = 88, scale = 1.4, baseY = FLOOR }, + { name = "LobbyCliffUpper", radius = 104, scale = 2.2, baseY = FLOOR + 10 }, + } + for _, tier in ipairs(tiers) do + for i = 1, count do + local angle = (i - 1) * 2 * math.pi / count + local radial = V(math.cos(angle), 0, math.sin(angle)) + local center = V(radial.X * tier.radius, tier.baseY, radial.Z * tier.radius) + local model = template:Clone() + model.Name = string.format("%s_%02d", tier.name, i) + model:ScaleTo(tier.scale) + local facing = CFrame.lookAt(center, center + radial) + local rotation = facing - facing.Position + model:PivotTo(CFrame.new(center) * rotation) + local boxCF, boxSize = model:GetBoundingBox() + local targetBoxCenter = V(center.X, tier.baseY + boxSize.Y / 2, center.Z) + model:PivotTo(model:GetPivot() + (targetBoxCenter - boxCF.Position)) + model.Parent = ring + end + end +end + +local function rockTopPosition(cliffs, radial, desiredRadius, radiusOffsets) + local params = RaycastParams.new() + params.FilterType = Enum.RaycastFilterType.Include + params.FilterDescendantsInstances = { cliffs } + for _, offset in ipairs(radiusOffsets) do + local radius = desiredRadius + offset + local origin = V(radial.X * radius, 128, radial.Z * radius) + local hit = Workspace:Raycast(origin, V(0, -180, 0), params) + if hit then + return hit.Position + end + end + return V(radial.X * desiredRadius, FLOOR, radial.Z * desiredRadius) +end + +local function placeModelOnRock(model, position, yaw) + local rotation = CFrame.Angles(0, yaw, 0) + model:PivotTo(CFrame.new(position) * rotation) + local boxCF, boxSize = model:GetBoundingBox() + local targetBoxCenter = V(position.X, position.Y + boxSize.Y / 2, position.Z) + model:PivotTo(model:GetPivot() + (targetBoxCenter - boxCF.Position)) +end + +local function lobbyTrees() + local templates = ServerStorage:FindFirstChild("LobbyTreeTemplates") + local cliffs = map:FindFirstChild("LobbyCliffs") + if not templates or not cliffs then + warn("LobbyTreeTemplates или LobbyCliffs отсутствует; деревья лобби пропущены") + return + end + local treeTypes = { "LargeCanopy", "Pine", "RoundCanopy" } + local treeScale = { LargeCanopy = 1, Pine = 1.25, RoundCanopy = 1.2 } + local folder = Instance.new("Folder") + folder.Name = "LobbyTrees" + folder.Parent = map + for layer = 1, 2 do + local baseRadius = layer == 1 and 84 or 96 + local radiusOffsets = { 0, -2, 2, -4, 4, -6, 6 } + for i = 1, 18 do + local degrees = (i - 1) * 20 + 10 + (layer == 2 and 10 or 0) + local angle = math.rad(degrees) + local radial = V(math.cos(angle), 0, math.sin(angle)) + local position = rockTopPosition(cliffs, radial, baseRadius, radiusOffsets) + local kind = treeTypes[(i + layer - 2) % #treeTypes + 1] + local template = templates:FindFirstChild(kind) + if template and template:IsA("Model") then + local model = template:Clone() + model.Name = string.format("LobbyTree_L%d_%02d_%s", layer, i, kind) + model:ScaleTo(treeScale[kind]) + placeModelOnRock(model, position, math.rad((i * 47 + layer * 23) % 360)) + for _, part in ipairs(model:GetDescendants()) do + if part:IsA("BasePart") then part.Anchored = true end + end + model.Parent = folder + end + end + end +end + +local function lobbyRockPlants() + local templates = ServerStorage:FindFirstChild("LobbyRockPlantTemplates") + local cliffs = map:FindFirstChild("LobbyCliffs") + if not templates or not cliffs then + warn("LobbyRockPlantTemplates или LobbyCliffs отсутствует; растительность скал пропущена") + return + end + local folder = Instance.new("Folder") + folder.Name = "LobbyRockPlants" + folder.Parent = map + local clusterAngles = { + { layer = 1, degrees = 45 }, { layer = 1, degrees = 135 }, + { layer = 1, degrees = 225 }, { layer = 1, degrees = 315 }, + { layer = 2, degrees = 0 }, { layer = 2, degrees = 90 }, + { layer = 2, degrees = 180 }, { layer = 2, degrees = 270 }, + } + local tuftKinds = { "GrassTuft", "BladeGrass", "GrassTuft", "FlowerPatch", "GrassTuft", "WideGrass" } + local tuftScales = { GrassTuft = 1.15, BladeGrass = 1.45, FlowerPatch = 1.1, WideGrass = 0.55 } + local offsets = { { 0, 0 }, { -2.2, 0 }, { 2.2, 0 }, { 0, -2.2 }, { 0, 2.2 }, { 1.6, 1.6 } } + local rayParams = RaycastParams.new() + rayParams.FilterType = Enum.RaycastFilterType.Include + rayParams.FilterDescendantsInstances = { cliffs } + for clusterIndex, cluster in ipairs(clusterAngles) do + local baseRadius = cluster.layer == 1 and 84 or 96 + local baseAngle = math.rad(cluster.degrees) + local radial = V(math.cos(baseAngle), 0, math.sin(baseAngle)) + local tangent = V(-radial.Z, 0, radial.X) + local basePos = rockTopPosition(cliffs, radial, baseRadius, { 0, -2, 2, -4, 4, -6, 6 }) + local bush = Instance.new("Model") + bush.Name = string.format("GrassBush_%02d_L%d", clusterIndex, cluster.layer) + for i, offset in ipairs(offsets) do + local xz = basePos + radial * offset[1] + tangent * offset[2] + local plantPos + for _, correction in ipairs({ 0, -2, 2, -4, 4 }) do + local candidate = xz + radial * correction + local hit = Workspace:Raycast(V(candidate.X, 128, candidate.Z), V(0, -180, 0), rayParams) + if hit then plantPos = hit.Position; break end + end + if plantPos then + local kind = tuftKinds[i] + local template = templates:FindFirstChild(kind) + if template and template:IsA("Model") then + local plant = template:Clone() + plant.Name = kind .. "_" .. i + plant:ScaleTo(tuftScales[kind]) + placeModelOnRock(plant, plantPos, math.rad((clusterIndex * 37 + i * 53) % 360)) + for _, part in ipairs(plant:GetDescendants()) do + if part:IsA("BasePart") then part.Anchored = true end + end + plant.Parent = bush + end + end + end + bush.Parent = folder + end +end -- высота земли: читаем воксели столбца (лучи по только что залитому террейну ненадёжны, особенно в редакторе) local function groundY(x, z) local region = Region3.new(V(x - 1, -128, z - 1), V(x + 1, 160, z + 1)):ExpandToGrid(4) @@ -3970,7 +4136,77 @@ local function stall(cf, opt) return counter end +-- Модель портала из ServerStorage.FishingPortalTemplate, перекрашенная в цвет мира и +-- поставленная основанием на baseCF. Без шаблона возвращает nil (тогда строится старое кольцо). +function Builder.portalModel(baseCF, color, name, parent) + local template = ServerStorage:FindFirstChild("FishingPortalTemplate") + if not (template and template:IsA("Model")) then + return nil + end + local model = template:Clone() + model.Name = name + for _, part in ipairs(model:GetDescendants()) do + if part:IsA("BasePart") then + local c = part.Color + local isGreen = c.G > c.R * 1.15 and c.G > c.B * 1.10 and c.G > 0.25 + if part.Material == Enum.Material.Neon then + part.Color = color + elseif isGreen then + part.Color = color:Lerp(Color3.fromRGB(55, 65, 75), 0.30) + part.Material = Enum.Material.SmoothPlastic + end + elseif part:IsA("ParticleEmitter") then + part.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) + end + end + + local pivot = template:GetPivot() + local boxCFrame, boxSize = template:GetBoundingBox() + local boxBottom = pivot:PointToObjectSpace(Vector3.new( + boxCFrame.Position.X, + boxCFrame.Position.Y - boxSize.Y / 2, + boxCFrame.Position.Z + )).Y + model:PivotTo(baseCF * CFrame.new(0, -boxBottom, 0)) + model.Parent = parent + return model +end + local function portal(baseCF, title, color, worldId, locked) + -- Все порталы, и в лобби, и возвратные в мирах, используют модель автора из ServerStorage. + do + local model = Builder.portalModel(baseCF, color, "PortalModel_" .. worldId, map) + if model then + -- Этот невидимый якорь сохраняет ProximityPrompt и подпись мира. + local disc = P({ + Name = "Portal_" .. worldId, + Size = V(1, 1, 1), + CFrame = baseCF * CFrame.new(0, 10, 0), + Transparency = 1, + CanCollide = false, + CanQuery = false, + CanTouch = false, + }) + local pe = Instance.new("ParticleEmitter") + pe.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) + pe.LightEmission = 1 + pe.Rate = 25 + pe.Lifetime = NumberRange.new(1, 1.8) + pe.Speed = NumberRange.new(0.5, 2) + pe.SpreadAngle = Vector2.new(180, 180) + pe.Size = NumberSequence.new(0.5, 0) + pe.Transparency = NumberSequence.new(0.2, 1) + pe.Parent = disc + billboard(disc, title, color:Lerp(Color3.new(1, 1, 1), 0.4), 7, 200) + if locked then + billboard(disc, "🔒", Color3.new(1, 1, 1), 0, 120) + end + local pp = prompt(disc, locked and "Посмотреть" or "Перейти", title, "Portal", 14) + pp:SetAttribute("World", worldId) + return disc + end + end + local center = baseCF * CFrame.new(0, 10, 0) P({ Size = V(17, 1, 9), CFrame = baseCF * CFrame.new(0, 0.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(95, 100, 115) }) P({ Size = V(14, 1, 7), CFrame = baseCF * CFrame.new(0, 1.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(110, 115, 130) }) @@ -4151,15 +4387,10 @@ function Builder.build() banner(V(math.cos(a) * 74, FLOOR, math.sin(a) * 74), b[2], b[3], b[4]) end - -- живая изгородь по краю (с проходами) - for deg = 0, 359, 7 do - local skip = (deg > 80 and deg < 100) or (deg > 255 and deg < 285) or deg < 8 or deg > 352 or (deg > 172 and deg < 188) - if not skip then - local a = math.rad(deg) - local p = V(math.cos(a) * 82, FLOOR + 2, math.sin(a) * 82) - P({ Size = V(10.5, 4, 3), CFrame = CFrame.lookAt(p, V(0, p.Y, 0)), Material = Enum.Material.Grass, Color = Color3.fromRGB(60, 130, 55) }) - end - end + -- высокий скальный контур закрывает горизонт и удерживает игроков в лобби + lobbyCliffs() + lobbyTrees() + lobbyRockPlants() -- магазин (запад) и скупка (восток) stall(CFrame.lookAt(V(-62, FLOOR, 0), V(0, FLOOR, 0)), { @@ -4333,7 +4564,7 @@ function Builder.build() ---------------------------------------------------------------- МИР 1: ТИХОЕ ОЗЕРО do -- отдельно собранное раньше «Тихое озеро» (Workspace.World1Map) переносим в карту, иначе строим заново - local w1map = world1Prebuilt or World1Builder.build(map) + local w1map = world1Prebuilt or World1Builder.build(map, Builder.portalModel) w1map.Parent = map -- NPC встают на маркеры — их можно двигать в Studio local seller = w1map:FindFirstChild("World1NpcSeller", true) diff --git a/src/ServerScriptService/World1Builder.lua b/src/ServerScriptService/World1Builder.lua index 81a711c..0625b98 100644 --- a/src/ServerScriptService/World1Builder.lua +++ b/src/ServerScriptService/World1Builder.lua @@ -131,7 +131,8 @@ end ---------------------------------------------------------------- детали -- parent — куда положить папку World1Map (Workspace при сборке в Studio, FishingMap при запуске игры) -function Builder.build(parent) +-- makePortal — WorldBuilder.portalModel: ставит модель портала из шаблона (без него строится старое кольцо) +function Builder.build(parent, makePortal) buildTerrain() local rng = Random.new(7) @@ -540,20 +541,30 @@ function Builder.build(parent) portalModel.Name = "PortalToLobby" portalModel.Parent = map local center = baseCF * CFrame.new(0, 10, 0) - P({ Size = V(17, 1, 9), CFrame = baseCF * CFrame.new(0, 0.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(95, 100, 115), Parent = portalModel }) - P({ Size = V(14, 1, 7), CFrame = baseCF * CFrame.new(0, 1.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(110, 115, 130), Parent = portalModel }) - local R, n = 7, 20 - for i = 0, n - 1 do - local a = (i + 0.5) / n * math.pi * 2 - P({ Size = V(2 * math.pi * R / n + 0.4, 1.7, 1.7), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(80, 85, 100), Parent = portalModel }) - if i % 2 == 0 then - P({ Size = V(0.6, 0.6, 1.9), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R + 0.95, 0), Material = Enum.Material.Neon, Color = color, Parent = portalModel }) + local fancy = makePortal and makePortal(baseCF, color, "PortalModel_Lobby", portalModel) + local disc + if fancy then + -- модель из шаблона; невидимый якорь держит подсказку, подпись и искры + disc = P({ + Name = "Portal_Lobby", Size = V(1, 1, 1), CFrame = center * CFrame.Angles(0, math.rad(90), 0), + Transparency = 1, CanCollide = false, CanQuery = false, CanTouch = false, Parent = portalModel, + }) + else + P({ Size = V(17, 1, 9), CFrame = baseCF * CFrame.new(0, 0.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(95, 100, 115), Parent = portalModel }) + P({ Size = V(14, 1, 7), CFrame = baseCF * CFrame.new(0, 1.5, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(110, 115, 130), Parent = portalModel }) + local R, n = 7, 20 + for i = 0, n - 1 do + local a = (i + 0.5) / n * math.pi * 2 + P({ Size = V(2 * math.pi * R / n + 0.4, 1.7, 1.7), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R, 0), Material = Enum.Material.Slate, Color = Color3.fromRGB(80, 85, 100), Parent = portalModel }) + if i % 2 == 0 then + P({ Size = V(0.6, 0.6, 1.9), CFrame = center * CFrame.Angles(0, 0, a) * CFrame.new(0, R + 0.95, 0), Material = Enum.Material.Neon, Color = color, Parent = portalModel }) + end end + disc = P({ + Name = "Portal_Lobby", Shape = Enum.PartType.Cylinder, Size = V(0.3, 2 * R - 1, 2 * R - 1), CFrame = center * CFrame.Angles(0, math.rad(90), 0), + Material = Enum.Material.Neon, Color = color, Transparency = 0.3, CanCollide = false, Parent = portalModel, + }) end - local disc = P({ - Name = "Portal_Lobby", Shape = Enum.PartType.Cylinder, Size = V(0.3, 2 * R - 1, 2 * R - 1), CFrame = center * CFrame.Angles(0, math.rad(90), 0), - Material = Enum.Material.Neon, Color = color, Transparency = 0.3, CanCollide = false, Parent = portalModel, - }) local pe = Instance.new("ParticleEmitter") pe.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) pe.LightEmission = 1 @@ -566,7 +577,7 @@ function Builder.build(parent) pe.Parent = disc local bb = Instance.new("BillboardGui") bb.Size = UDim2.fromOffset(250, 64) - bb.StudsOffset = V(0, 10, 0) + bb.StudsOffset = V(0, fancy and 7 or 10, 0) bb.MaxDistance = 160 bb.LightInfluence = 0 bb.Parent = disc diff --git a/src/ServerScriptService/WorldBuilder.lua b/src/ServerScriptService/WorldBuilder.lua index b8f9feb..988500c 100644 --- a/src/ServerScriptService/WorldBuilder.lua +++ b/src/ServerScriptService/WorldBuilder.lua @@ -514,39 +514,47 @@ local function stall(cf, opt) return counter end -local function portal(baseCF, title, color, worldId, locked) - -- Центральные порталы используют модель, добавленную автором в ServerStorage. - -- Возвратные порталы в мирах (worldId == "Lobby") сохраняют прежний вид. - if worldId ~= "Lobby" then - local template = ServerStorage:FindFirstChild("FishingPortalTemplate") - if template and template:IsA("Model") then - local model = template:Clone() - model.Name = "PortalModel_" .. worldId - for _, part in ipairs(model:GetDescendants()) do - if part:IsA("BasePart") then - local c = part.Color - local isGreen = c.G > c.R * 1.15 and c.G > c.B * 1.10 and c.G > 0.25 - if part.Material == Enum.Material.Neon then - part.Color = color - elseif isGreen then - part.Color = color:Lerp(Color3.fromRGB(55, 65, 75), 0.30) - part.Material = Enum.Material.SmoothPlastic - end - elseif part:IsA("ParticleEmitter") then - part.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) - end +-- Модель портала из ServerStorage.FishingPortalTemplate, перекрашенная в цвет мира и +-- поставленная основанием на baseCF. Без шаблона возвращает nil (тогда строится старое кольцо). +function Builder.portalModel(baseCF, color, name, parent) + local template = ServerStorage:FindFirstChild("FishingPortalTemplate") + if not (template and template:IsA("Model")) then + return nil + end + local model = template:Clone() + model.Name = name + for _, part in ipairs(model:GetDescendants()) do + if part:IsA("BasePart") then + local c = part.Color + local isGreen = c.G > c.R * 1.15 and c.G > c.B * 1.10 and c.G > 0.25 + if part.Material == Enum.Material.Neon then + part.Color = color + elseif isGreen then + part.Color = color:Lerp(Color3.fromRGB(55, 65, 75), 0.30) + part.Material = Enum.Material.SmoothPlastic end + elseif part:IsA("ParticleEmitter") then + part.Color = ColorSequence.new(color, Color3.new(1, 1, 1)) + end + end - local pivot = template:GetPivot() - local boxCFrame, boxSize = template:GetBoundingBox() - local boxBottom = pivot:PointToObjectSpace(Vector3.new( - boxCFrame.Position.X, - boxCFrame.Position.Y - boxSize.Y / 2, - boxCFrame.Position.Z - )).Y - model:PivotTo(baseCF * CFrame.new(0, -boxBottom, 0)) - model.Parent = map + local pivot = template:GetPivot() + local boxCFrame, boxSize = template:GetBoundingBox() + local boxBottom = pivot:PointToObjectSpace(Vector3.new( + boxCFrame.Position.X, + boxCFrame.Position.Y - boxSize.Y / 2, + boxCFrame.Position.Z + )).Y + model:PivotTo(baseCF * CFrame.new(0, -boxBottom, 0)) + model.Parent = parent + return model +end +local function portal(baseCF, title, color, worldId, locked) + -- Все порталы, и в лобби, и возвратные в мирах, используют модель автора из ServerStorage. + do + local model = Builder.portalModel(baseCF, color, "PortalModel_" .. worldId, map) + if model then -- Этот невидимый якорь сохраняет ProximityPrompt и подпись мира. local disc = P({ Name = "Portal_" .. worldId, @@ -934,7 +942,7 @@ function Builder.build() ---------------------------------------------------------------- МИР 1: ТИХОЕ ОЗЕРО do -- отдельно собранное раньше «Тихое озеро» (Workspace.World1Map) переносим в карту, иначе строим заново - local w1map = world1Prebuilt or World1Builder.build(map) + local w1map = world1Prebuilt or World1Builder.build(map, Builder.portalModel) w1map.Parent = map -- NPC встают на маркеры — их можно двигать в Studio local seller = w1map:FindFirstChild("World1NpcSeller", true)