Files
Fishing/tools/build-guild-hall.lua

273 lines
14 KiB
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Дом гильдии рыбаков в лобби + лавки наживки. Запускать в Studio в режиме редактирования
-- (Command Bar или Studio MCP), потом сохранить плейс (Ctrl+S). Повторный запуск пересобирает только
-- то, что строит этот скрипт (папки FishingMap.GuildHall и FishingMap.BaitShops), остальная карта не трогается.
--
-- Гильдия занимает правый из двух домиков на севере лобби (Workspace.GuildHouse — тот же дом из набора,
-- что и левый). Перед его фасадом: вывеска «⚓ ГИЛЬДИЯ РЫБАКОВ», знамёна, фонари, стойка и место
-- Старейшины Ворона (NpcSpot с атрибутами, GuildElder, Look=Elder, Action=Guild) и доска заказов
-- (атрибут OrderBoard + подсказка Action=Orders).
local map = workspace:FindFirstChild("FishingMap")
assert(map, "Нет Workspace.FishingMap")
local V = Vector3.new
local FLOOR = 1.02 -- верх дорожки лобби
-- правый домик: при первом запуске это безымянная Workspace.Model справа от прохода
local house = workspace:FindFirstChild("GuildHouse")
if not house then
for _, c in ipairs(workspace:GetChildren()) do
if c:IsA("Model") and c.Name == "Model" then
local cf, size = c:GetBoundingBox()
if cf.X > 10 and cf.X < 40 and cf.Z < -40 and cf.Z > -70 and size.X > 30 then
house = c
end
end
end
assert(house, "Не найден правый домик лобби")
house.Name = "GuildHouse"
end
-- фасад, смотрящий на площадь (+Z): ищем лучом
local houseCF = house:GetBoundingBox()
local X0 = houseCF.X - 1.7 -- середина стены (без крыльца)
local probe = RaycastParams.new()
probe.FilterType = Enum.RaycastFilterType.Include
probe.FilterDescendantsInstances = { house }
local facadeHit = workspace:Raycast(V(X0, FLOOR + 6, -20), V(0, 0, -40), probe)
assert(facadeHit, "Не найден фасад домика гильдии")
local FZ = facadeHit.Position.Z -- плоскость фасада
local WOOD = Color3.fromRGB(110, 72, 44)
local DARK = Color3.fromRGB(66, 42, 26)
local GOLD = Color3.fromRGB(214, 160, 70)
local CRIMSON = Color3.fromRGB(150, 40, 35)
local PARCH = Color3.fromRGB(236, 220, 180)
local TITLE_FONT = Font.new("rbxasset://fonts/families/Merriweather.json", Enum.FontWeight.Heavy)
for _, name in ipairs({ "GuildHall", "BaitShops" }) do
local old = map:FindFirstChild(name)
if old then
old:Destroy()
end
end
local hall = Instance.new("Folder")
hall.Name = "GuildHall"
hall.Parent = map
local rng = Random.new(42)
local function shade(c, k)
k = 1 + rng:NextNumber(-k, k)
return Color3.new(math.clamp(c.R * k, 0, 1), math.clamp(c.G * k, 0, 1), math.clamp(c.B * k, 0, 1))
end
local function P(props, parent)
local p = Instance.new(props.ClassName or "Part")
props.ClassName = nil
p.Anchored = true
p.TopSurface, p.BottomSurface = Enum.SurfaceType.Smooth, Enum.SurfaceType.Smooth
p.Material = Enum.Material.SmoothPlastic
for k, v in pairs(props) do
p[k] = v
end
p.Parent = parent or hall
return p
end
local function surfaceText(part, face, text, color, size)
local sg = Instance.new("SurfaceGui")
sg.Face = face
sg.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
sg.PixelsPerStud = 40
sg.LightInfluence = 0
sg.Parent = part
local t = Instance.new("TextLabel")
t.Size = UDim2.fromScale(1, 1)
t.BackgroundTransparency = 1
t.FontFace = TITLE_FONT
t.TextScaled = true
t.TextColor3 = color
t.TextStrokeTransparency = 0.35
t.TextStrokeColor3 = Color3.fromRGB(40, 28, 20)
t.Text = text
t.Parent = sg
local pad = Instance.new("UIPadding")
pad.PaddingLeft, pad.PaddingRight = UDim.new(0.05, 0), UDim.new(0.05, 0)
pad.PaddingTop, pad.PaddingBottom = UDim.new(size or 0.1, 0), UDim.new(size or 0.1, 0)
pad.Parent = t
return t
end
local function billboard(target, text, color, offsetY, width)
local bb = Instance.new("BillboardGui")
bb.Size = UDim2.fromOffset(width or 300, 56)
bb.StudsOffset = V(0, offsetY, 0)
bb.MaxDistance = 160
bb.LightInfluence = 0
bb.Parent = target
local t = Instance.new("TextLabel")
t.Size = UDim2.fromScale(1, 1)
t.BackgroundTransparency = 1
t.FontFace = TITLE_FONT
t.TextScaled = true
t.TextColor3 = color
t.TextStrokeTransparency = 0.15
t.Text = text
t.Parent = bb
return bb
end
local function prompt(target, actionText, objectText, action, dist)
local pp = Instance.new("ProximityPrompt")
pp.ActionText = actionText
pp.ObjectText = objectText
pp.HoldDuration = 0
pp.MaxActivationDistance = dist or 12
pp.RequiresLineOfSight = false
pp:SetAttribute("Action", action)
pp.Parent = target
return pp
end
local function lantern(pos, parent)
P({ Name = "LanternCap", Size = V(1.1, 0.3, 1.1), CFrame = CFrame.new(pos + V(0, 0.75, 0)), Color = DARK }, parent)
local l = P({ Name = "GuildLantern", Size = V(0.8, 1.1, 0.8), CFrame = CFrame.new(pos), Material = Enum.Material.Neon, Color = Color3.fromRGB(255, 205, 130) }, parent)
local light = Instance.new("PointLight")
light.Range = 16
light.Brightness = 1.2
light.Color = Color3.fromRGB(255, 205, 150)
light.Parent = l
end
-- большой куст из набора домика стоит там, где стойка: сдвигаем его левее (один раз)
local bush = house:FindFirstChild("Object.5989")
if bush and bush.Position.X > houseCF.X - 9 then
bush.CFrame = bush.CFrame - V(4, 0, 0)
end
---------------------------------------------------------------- знамёна по углам фасада
for _, x in ipairs({ X0 - 9.2, X0 + 9.2 }) do
P({ Name = "BannerRod", Size = V(3.2, 0.25, 0.25), CFrame = CFrame.new(x, FLOOR + 13.4, FZ + 0.5), Color = GOLD })
local banner = P({ Name = "GuildBanner", Size = V(2.6, 6.8, 0.2), CFrame = CFrame.new(x, FLOOR + 9.9, FZ + 0.5), Color = CRIMSON, Material = Enum.Material.Fabric, CanCollide = false })
P({ Name = "BannerTrim", Size = V(2.6, 0.3, 0.22), CFrame = CFrame.new(x, FLOOR + 6.6, FZ + 0.51), Color = GOLD, CanCollide = false })
surfaceText(banner, Enum.NormalId.Back, "⚓", Color3.fromRGB(255, 214, 120), 0.25)
end
---------------------------------------------------------------- стойка Старейшины перед фасадом
local DZ = FZ + 5.6 -- стойка
local EZ = FZ + 2.8 -- Старейшина за стойкой
P({ Name = "GuildDesk", Size = V(9, 3.4, 1.8), CFrame = CFrame.new(X0, FLOOR + 1.7, DZ), Color = DARK })
P({ Name = "DeskTop", Size = V(9.6, 0.3, 2.4), CFrame = CFrame.new(X0, FLOOR + 3.55, DZ), Color = WOOD })
P({ Name = "DeskTrim", Size = V(9.1, 0.35, 1.9), CFrame = CFrame.new(X0, FLOOR + 0.6, DZ), Color = GOLD })
local front = P({ Name = "DeskFront", Size = V(6, 1.6, 0.15), CFrame = CFrame.new(X0, FLOOR + 2, DZ + 0.95), Color = CRIMSON, Material = Enum.Material.Fabric })
surfaceText(front, Enum.NormalId.Back, "⚓ F·E·D·C·B·A·S", Color3.fromRGB(255, 214, 120), 0.18)
P({ Name = "GuildBook", Size = V(1.6, 0.25, 1.1), CFrame = CFrame.new(X0 - 1.6, FLOOR + 3.85, DZ) * CFrame.Angles(0, math.rad(12), 0), Color = Color3.fromRGB(110, 30, 30) })
P({ Name = "BookPages", Size = V(1.5, 0.27, 1.0), CFrame = CFrame.new(X0 - 1.6, FLOOR + 3.87, DZ) * CFrame.Angles(0, math.rad(12), 0), Color = PARCH })
P({ Name = "SealBox", Size = V(1.2, 0.7, 0.9), CFrame = CFrame.new(X0 + 2.2, FLOOR + 4.05, DZ), Color = GOLD })
P({ Name = "Inkwell", Size = V(0.45, 0.5, 0.45), CFrame = CFrame.new(X0 + 0.4, FLOOR + 3.95, DZ - 0.3), Color = Color3.fromRGB(30, 30, 35) })
P({ Name = "Quill", Size = V(0.1, 1.3, 0.1), CFrame = CFrame.new(X0 + 0.5, FLOOR + 4.4, DZ - 0.3) * CFrame.Angles(0, 0, math.rad(-20)), Color = Color3.fromRGB(240, 240, 235), CanCollide = false })
-- ворота над стойкой с вывеской: её видно с площади, а не из-под свеса крыши
local GATE_H = 11
for _, x in ipairs({ X0 - 5.2, X0 + 5.2 }) do
P({ Name = "GatePost", Size = V(0.8, GATE_H, 0.8), CFrame = CFrame.new(x, FLOOR + GATE_H / 2, DZ - 0.3), Color = DARK })
P({ Name = "GateFoot", Size = V(1.4, 0.8, 1.4), CFrame = CFrame.new(x, FLOOR + 0.4, DZ - 0.3), Color = Color3.fromRGB(120, 112, 104), Material = Enum.Material.Slate })
end
P({ Name = "GateBeam", Size = V(12, 0.9, 1.2), CFrame = CFrame.new(X0, FLOOR + GATE_H - 0.2, DZ - 0.3), Color = DARK })
P({ Name = "SignFrame", Size = V(12.6, 3.9, 0.3), CFrame = CFrame.new(X0, FLOOR + GATE_H + 2, DZ - 0.45), Color = GOLD })
local sign = P({ Name = "GuildSign", Size = V(12, 3.3, 0.5), CFrame = CFrame.new(X0, FLOOR + GATE_H + 2, DZ - 0.2), Color = Color3.fromRGB(70, 45, 30) })
surfaceText(sign, Enum.NormalId.Back, "⚓ ГИЛЬДИЯ РЫБАКОВ", Color3.fromRGB(255, 214, 120), 0.14)
billboard(sign, "⚔ Гильдия рыбаков", Color3.fromRGB(255, 214, 120), 3.6, 320)
for _, x in ipairs({ X0 - 3.6, X0 + 3.6 }) do
P({ Name = "Chain", Size = V(0.15, 1.2, 0.15), CFrame = CFrame.new(x, FLOOR + GATE_H - 1.2, DZ - 0.3), Color = Color3.fromRGB(70, 70, 75), Material = Enum.Material.Metal })
lantern(V(x, FLOOR + GATE_H - 2.3, DZ - 0.3), hall)
end
-- ковровая дорожка от площади к стойке
P({ Name = "GuildRug", Size = V(4, 0.1, 9), CFrame = CFrame.new(X0, FLOOR + 0.05, DZ + 5.6), Color = shade(CRIMSON, 0.03), Material = Enum.Material.Fabric, CanCollide = false })
for _, x in ipairs({ X0 - 2.05, X0 + 2.05 }) do
P({ Name = "RugTrim", Size = V(0.15, 0.11, 9), CFrame = CFrame.new(x, FLOOR + 0.05, DZ + 5.6), Color = GOLD, CanCollide = false })
end
---------------------------------------------------------------- доска заказов (справа от стойки, лицом к площади)
local BX, BZ = X0 + 9.2, FZ + 4.4
local boardCF = CFrame.new(BX, FLOOR, BZ) * CFrame.Angles(0, math.rad(-18), 0) -- чуть повёрнута к центру площади
local function at(x, y, z)
return boardCF * CFrame.new(x, y, z)
end
for _, x in ipairs({ -3.4, 3.4 }) do
P({ Name = "BoardLeg", Size = V(0.5, 8.6, 0.5), CFrame = at(x, 4.3, -0.1), Color = DARK })
end
local board = P({ Name = "OrderBoard", Size = V(6.4, 4.6, 0.4), CFrame = at(0, 5, 0), Color = Color3.fromRGB(112, 80, 52) })
board:SetAttribute("OrderBoard", true)
P({ Name = "BoardFrame", Size = V(6.9, 5.1, 0.35), CFrame = at(0, 5, -0.1), Color = DARK })
P({ Name = "BoardRoof", Size = V(7.6, 0.3, 1.8), CFrame = at(0, 8.9, 0.2) * CFrame.Angles(math.rad(14), 0, 0), Color = Color3.fromRGB(110, 34, 30) })
local header = P({ Name = "BoardHeader", Size = V(6.4, 1.1, 0.3), CFrame = at(0, 8, 0.15), Color = Color3.fromRGB(70, 45, 30) })
surfaceText(header, Enum.NormalId.Back, "📜 ДОСКА ЗАКАЗОВ", Color3.fromRGB(255, 214, 120), 0.12)
-- пергаменты-заказы, приколотые к доске
for i, spot in ipairs({ { 6.2, -2.1 }, { 6.0, 0.1 }, { 6.3, 2.2 }, { 4.0, -1.2 }, { 3.8, 1.1 }, { 3.9, 2.6 } }) do
local note = P({
Name = "OrderNote", Size = V(1.35, 1.7, 0.06), Color = shade(PARCH, 0.05), CanCollide = false,
CFrame = at(spot[2], spot[1] - 0.6, 0.23) * CFrame.Angles(0, 0, math.rad(rng:NextNumber(-8, 8))),
})
P({ Name = "Pin", Size = V(0.2, 0.2, 0.12), CFrame = note.CFrame * CFrame.new(0, 0.65, 0.05), Color = (i % 2 == 0) and CRIMSON or GOLD, CanCollide = false })
end
prompt(board, "Заказы гильдии", "Доска заказов", "Orders", 12)
-- бочка у доски
P({ Name = "Barrel", ClassName = "Part", Shape = Enum.PartType.Cylinder, Size = V(3, 2.4, 2.4), CFrame = at(4.7, 1.5, 0.4) * CFrame.Angles(0, 0, math.rad(90)), Color = shade(WOOD, 0.08) })
P({ Name = "BarrelBand", ClassName = "Part", Shape = Enum.PartType.Cylinder, Size = V(0.3, 2.55, 2.55), CFrame = at(4.7, 1.5, 0.4) * CFrame.Angles(0, 0, math.rad(90)), Color = DARK })
---------------------------------------------------------------- Старейшина Ворон
local elder = P({ Name = "NpcSpot", Size = V(2, 5, 1), CFrame = CFrame.new(X0, FLOOR + 3, EZ) * CFrame.Angles(0, math.pi, 0),
Color = Color3.fromRGB(60, 50, 70), Transparency = 0.5, CanCollide = false, CanQuery = false, CanTouch = false })
elder:SetAttribute("NpcName", "Старейшина Ворон")
elder:SetAttribute("SkinColor", Color3.fromRGB(222, 176, 140))
elder:SetAttribute("ShirtColor", Color3.fromRGB(58, 46, 70))
elder:SetAttribute("PantsColor", Color3.fromRGB(48, 40, 34))
elder:SetAttribute("HatColor", Color3.fromRGB(150, 150, 152))
elder:SetAttribute("NpcAction", "Guild")
elder:SetAttribute("NpcActionText", "Гильдия")
elder:SetAttribute("Look", "Elder")
elder:SetAttribute("GuildElder", true)
---------------------------------------------------------------- лавки наживки: у магазина в лобби и у деда на причале Мира 1
local shops = Instance.new("Folder")
shops.Name = "BaitShops"
shops.Parent = map
local function baitCrate(pos, objectText)
local crate = P({ Name = "BaitCrate", Size = V(2.6, 2.2, 2.2), CFrame = CFrame.new(pos + V(0, 1.1, 0)), Color = shade(WOOD, 0.06) }, shops)
P({ Name = "CrateBand", Size = V(2.7, 0.3, 2.3), CFrame = CFrame.new(pos + V(0, 1.6, 0)), Color = DARK }, shops)
P({ Name = "Worms", Size = V(2.3, 0.2, 1.9), CFrame = CFrame.new(pos + V(0, 2.25, 0)), Color = Color3.fromRGB(96, 66, 46), Material = Enum.Material.Ground }, shops)
for i = 1, 4 do
P({ Name = "Worm", ClassName = "Part", Shape = Enum.PartType.Cylinder, Size = V(0.9, 0.25, 0.25), CanCollide = false,
CFrame = CFrame.new(pos + V(rng:NextNumber(-0.8, 0.8), 2.4, rng:NextNumber(-0.6, 0.6))) * CFrame.Angles(0, rng:NextNumber(0, 6.28), 0),
Color = Color3.fromRGB(210, 120, 120) }, shops)
end
billboard(crate, "🐛 Наживка", Color3.fromRGB(255, 214, 120), 3.2, 180)
prompt(crate, "Наживка", objectText, "Bait", 11)
return crate
end
local function groundAt(x, z)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = { shops, hall }
local hit = workspace:Raycast(V(x, 80, z), V(0, -160, 0), params)
return hit and hit.Position.Y or FLOOR
end
baitCrate(V(-49.5, groundAt(-49.5, 15), 15), "Лавка Михалыча")
-- у Деда Петровича на причале «Тихого озера»
local grandpa = map:FindFirstChild("World1NpcGrandpa", true)
if grandpa then
local p = grandpa.Position + grandpa.CFrame.RightVector * 3.2
baitCrate(V(p.X, groundAt(p.X, p.Z), p.Z), "Дед Петрович")
end
return ("Двор гильдии: %d деталей, лавок наживки: %d"):format(#hall:GetDescendants(), #shops:GetChildren())