Lobby 3d
This commit is contained in:
1 parent
fd5e92d0f5
commit
9f898c04dd
415 files changed
+6241617
-633464
No files matched your search
@@ -0,0 +1,282 @@
|
||||
-- Двухэтажное здание Гильдии рыбаков вместо двора гильдии и двух домиков на севере лобби.
|
||||
-- Собирается tools/build-guild-hall2.js (модель assets/props/lobby_guild_hall.bbmodel + этот код), запускать в Edit.
|
||||
-- Повторный запуск пересобирает только FishingMap.GuildHall; старое лежит в ServerStorage.Backup (не удаляется).
|
||||
|
||||
local map = workspace:FindFirstChild("FishingMap")
|
||||
assert(map, "Нет Workspace.FishingMap")
|
||||
local V = Vector3.new
|
||||
local SCALE = 1.25 -- модель в Blockbench рассчитана на дверь 5.5 стада; ×1.25 — свободно проходит персонаж
|
||||
local CENTER = V(0, 0, -58) -- середина севера лобби, между портальной площадью и скалами
|
||||
local TITLE_FONT = Font.new("rbxasset://fonts/families/Merriweather.json", Enum.FontWeight.Heavy)
|
||||
local GOLD_TEXT = Color3.fromRGB(255, 214, 120)
|
||||
|
||||
---------------------------------------------------------------- 1) старое — в ServerStorage.Backup
|
||||
|
||||
local backup = game.ServerStorage:FindFirstChild("Backup") or Instance.new("Folder")
|
||||
backup.Name = "Backup"
|
||||
backup.Parent = game.ServerStorage
|
||||
local oldElder -- место Ворона из старого двора (с атрибутами внешности) — переедет в зал
|
||||
local function stash(obj, name)
|
||||
if obj and obj.Parent ~= backup then
|
||||
obj.Name = name or obj.Name
|
||||
obj.Parent = backup
|
||||
end
|
||||
end
|
||||
local oldHall = map:FindFirstChild("GuildHall")
|
||||
if oldHall and not oldHall:GetAttribute("GuildHall2") then
|
||||
for _, d in ipairs(oldHall:GetDescendants()) do
|
||||
if d:IsA("BasePart") and d:GetAttribute("GuildElder") then
|
||||
oldElder = d
|
||||
end
|
||||
end
|
||||
stash(oldHall, "GuildYard_old")
|
||||
elseif oldHall then
|
||||
oldHall:Destroy() -- пересборка нового здания
|
||||
end
|
||||
oldElder = oldElder or (backup:FindFirstChild("GuildYard_old") and (function()
|
||||
for _, d in ipairs(backup.GuildYard_old:GetDescendants()) do
|
||||
if d:IsA("BasePart") and d:GetAttribute("GuildElder") then
|
||||
return d
|
||||
end
|
||||
end
|
||||
end)())
|
||||
assert(oldElder, "Не найдено место Старейшины Ворона (GuildElder) в старом дворе")
|
||||
stash(workspace:FindFirstChild("GuildHouse"), "GuildHouse_old")
|
||||
-- левый домик — безымянная Workspace.Model того же размера слева от прохода
|
||||
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
|
||||
stash(c, "LeftHouse_old")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- 2) здание
|
||||
|
||||
local hall = Instance.new("Folder")
|
||||
hall.Name = "GuildHall"
|
||||
hall:SetAttribute("GuildHall2", true)
|
||||
hall.Parent = map
|
||||
local model = BUILD.hall(hall)
|
||||
model.Name = "GuildHallBuilding"
|
||||
model:ScaleTo(SCALE)
|
||||
|
||||
-- всё мелкое, что стоит на месте здания (камни и кусты из набора домиков), тоже в архив
|
||||
local HALF = V(21, 0, 19) -- полуразмер участка с запасом
|
||||
for _, c in ipairs(workspace:GetChildren()) do
|
||||
if (c:IsA("Model") or c:IsA("BasePart")) and c ~= workspace.Terrain then
|
||||
local p = c:IsA("Model") and c:GetBoundingBox().Position or c.Position
|
||||
if math.abs(p.X - CENTER.X) < HALF.X and math.abs(p.Z - CENTER.Z) < HALF.Z and p.Y < 30 then
|
||||
stash(c, c.Name .. "_old")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- высота земли посередине участка
|
||||
local params = RaycastParams.new()
|
||||
params.FilterType = Enum.RaycastFilterType.Exclude
|
||||
params.FilterDescendantsInstances = { hall }
|
||||
local hit = workspace:Raycast(CENTER + V(0, 60, 0), V(0, -120, 0), params)
|
||||
local groundY = hit and hit.Position.Y or 1.02
|
||||
-- фасад модели смотрит в −Z; разворот на 180°, чтобы фасад смотрел на площадь (+Z)
|
||||
model:PivotTo(CFrame.new(CENTER.X, groundY, CENTER.Z) * CFrame.Angles(0, math.pi, 0))
|
||||
|
||||
---------------------------------------------------------------- 3) материалы, коллизии, тени
|
||||
|
||||
local NO_COLLIDE_GROUPS = {
|
||||
Door = true, Banners = true, WallNets = true, Sign = true, Crest = true, Lantern_L = true, Lantern_R = true,
|
||||
Chandelier = true, FireGlow = true, ElderSpot = true, Balcony = false,
|
||||
}
|
||||
local NO_COLLIDE_NAMES = { Rug = true, RugBorder = true, RugCenter = true, Flower = true, FlowerLeaves = true, Shutter = true, ShutterStrap = true }
|
||||
local parts, collide, glow = 0, 0, 0
|
||||
for _, p in ipairs(model:GetDescendants()) do
|
||||
if p:IsA("BasePart") then
|
||||
parts += 1
|
||||
p.Anchored = true
|
||||
local group = p.Parent and p.Parent.Name or ""
|
||||
local s = { p.Size.X, p.Size.Y, p.Size.Z }
|
||||
table.sort(s)
|
||||
-- «палки» и мелочь (средний размер < 1 стада) — без столкновений и лучей; совсем мелкое — без теней
|
||||
local solid = s[2] >= 1 and not NO_COLLIDE_GROUPS[group] and not NO_COLLIDE_NAMES[p.Name]
|
||||
if p.Name:find("Window_Glow") then
|
||||
solid = true -- стекло: в окно не пролезть
|
||||
end
|
||||
p.CanCollide = solid
|
||||
p.CanQuery = solid
|
||||
p.CanTouch = false
|
||||
p.CastShadow = s[3] >= 2.5
|
||||
if solid then
|
||||
collide += 1
|
||||
end
|
||||
if p.Name:find("_Glow") then
|
||||
p.Material = Enum.Material.Neon
|
||||
p.CastShadow = false
|
||||
glow += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
local base = model.PrimaryPart
|
||||
if base then
|
||||
base.CanCollide, base.CanQuery, base.Transparency = false, false, 1
|
||||
end
|
||||
|
||||
local function find(groupName, partName)
|
||||
local g = model:FindFirstChild(groupName, true)
|
||||
if not g then
|
||||
return nil
|
||||
end
|
||||
if not partName then
|
||||
return g
|
||||
end
|
||||
for _, d in ipairs(g:GetDescendants()) do
|
||||
if d:IsA("BasePart") and d.Name == partName then
|
||||
return d
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function light(part, range, brightness, color, shadows)
|
||||
if not part then
|
||||
return
|
||||
end
|
||||
local l = Instance.new("PointLight")
|
||||
l.Range, l.Brightness, l.Color, l.Shadows = range, brightness, color, shadows or false
|
||||
l.Parent = part
|
||||
return l
|
||||
end
|
||||
|
||||
-- свет в зале: люстра (под колесом), камин, свеча на кафедре — горят и днём (AlwaysLit: Ambience их не гасит);
|
||||
-- фонари у двери гаснут днём, как остальные фонари лобби
|
||||
local function alwaysLit(part)
|
||||
if part then
|
||||
part:SetAttribute("AlwaysLit", true)
|
||||
end
|
||||
return part
|
||||
end
|
||||
for _, g in ipairs({ "Chandelier", "Fireplace", "FireGlow", "Interior" }) do
|
||||
for _, d in ipairs((find(g) or Instance.new("Folder")):GetDescendants()) do
|
||||
if d:IsA("BasePart") and d.Name:find("_Glow") then
|
||||
alwaysLit(d)
|
||||
end
|
||||
end
|
||||
end
|
||||
local chand = alwaysLit(find("Chandelier", "ChCandle_Glow"))
|
||||
light(chand, 28, 0.9, Color3.fromRGB(255, 222, 180), true)
|
||||
light(alwaysLit(find("FireGlow", "Fire_Glow")), 16, 1.2, Color3.fromRGB(255, 160, 90))
|
||||
light(alwaysLit(find("Interior", "Candle_Glow")), 10, 0.6, Color3.fromRGB(255, 214, 170))
|
||||
-- рассеянный свет под потолком зала (невидимые детали): днём снаружи ярко, без него зал кажется пещерой
|
||||
for _, x in ipairs({ -7, 7 }) do
|
||||
local f = Instance.new("Part")
|
||||
f.Name = "HallFill"
|
||||
f.Size = V(0.4, 0.4, 0.4)
|
||||
f.Transparency, f.Anchored, f.CanCollide, f.CanQuery, f.CanTouch, f.CastShadow = 1, true, false, false, false, false
|
||||
f.CFrame = model:GetPivot() * CFrame.new(x * SCALE, 7.6 * SCALE, 1.5 * SCALE)
|
||||
f.Parent = model
|
||||
light(f, 20, 0.45, Color3.fromRGB(255, 240, 220))
|
||||
end
|
||||
light(find("Lantern_L", "LanternL_Glow"), 14, 1, Color3.fromRGB(255, 205, 150))
|
||||
for _, d in ipairs((find("Lantern_R") or model):GetDescendants()) do
|
||||
if d:IsA("BasePart") and d.Name:find("_Glow") then
|
||||
light(d, 14, 1, Color3.fromRGB(255, 205, 150))
|
||||
end
|
||||
end
|
||||
-- огонь в камине
|
||||
local fire = find("FireGlow", "FireCore_Glow")
|
||||
if fire then
|
||||
local f = Instance.new("Fire")
|
||||
f.Size, f.Heat = 3, 4
|
||||
f.Color, f.SecondaryColor = Color3.fromRGB(255, 150, 60), Color3.fromRGB(200, 60, 20)
|
||||
f.Parent = fire
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- 4) вывеска, доска заказов, Ворон
|
||||
|
||||
local function surfaceGui(part, face)
|
||||
local sg = Instance.new("SurfaceGui")
|
||||
sg.Face = face
|
||||
sg.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
|
||||
sg.PixelsPerStud = 50
|
||||
sg.LightInfluence = 0
|
||||
sg.Parent = part
|
||||
return sg
|
||||
end
|
||||
local function label(parent, props)
|
||||
local t = Instance.new("TextLabel")
|
||||
t.BackgroundTransparency = 1
|
||||
t.FontFace = TITLE_FONT
|
||||
t.TextScaled = true
|
||||
t.TextColor3 = GOLD_TEXT
|
||||
t.TextStrokeTransparency = 0.35
|
||||
t.TextStrokeColor3 = Color3.fromRGB(40, 28, 20)
|
||||
for k, v in pairs(props) do
|
||||
t[k] = v
|
||||
end
|
||||
t.Parent = parent
|
||||
return t
|
||||
end
|
||||
|
||||
-- вывеска над дверью (лицевая грань модели — Front, после разворота она смотрит на площадь)
|
||||
local signFace = find("Sign", "Sign_Face")
|
||||
assert(signFace, "Нет Sign_Face в модели")
|
||||
local sg = surfaceGui(signFace, Enum.NormalId.Front)
|
||||
label(sg, { Size = UDim2.fromScale(0.94, 0.86), Position = UDim2.fromScale(0.03, 0.07), Text = "⚓ ГИЛЬДИЯ РЫБАКОВ" })
|
||||
local bb = Instance.new("BillboardGui")
|
||||
bb.Size = UDim2.fromOffset(320, 56)
|
||||
bb.StudsOffsetWorldSpace = V(0, 12, 0)
|
||||
bb.MaxDistance = 160
|
||||
bb.LightInfluence = 0
|
||||
bb.Parent = signFace
|
||||
label(bb, { Size = UDim2.fromScale(1, 1), Text = "⚔ Гильдия рыбаков", TextStrokeTransparency = 0.15 })
|
||||
|
||||
-- доска заказов у входа: грань — поверхность с заголовком и приколотыми заказами
|
||||
local board = find("OrderBoard", "OrderBoard_Face")
|
||||
assert(board, "Нет OrderBoard_Face в модели")
|
||||
board.CanCollide, board.CanQuery = true, true
|
||||
board:SetAttribute("OrderBoard", true)
|
||||
local bsg = surfaceGui(board, Enum.NormalId.Front)
|
||||
label(bsg, { Size = UDim2.fromScale(0.9, 0.2), Position = UDim2.fromScale(0.05, 0.03), Text = "📜 ДОСКА ЗАКАЗОВ" })
|
||||
local rng = Random.new(7)
|
||||
for i = 1, 6 do
|
||||
local note = Instance.new("Frame")
|
||||
note.Size = UDim2.fromScale(0.26, 0.3)
|
||||
note.Position = UDim2.fromScale(0.06 + ((i - 1) % 3) * 0.31, 0.27 + math.floor((i - 1) / 3) * 0.36)
|
||||
note.Rotation = rng:NextNumber(-7, 7)
|
||||
note.BackgroundColor3 = Color3.fromRGB(236, 220, 180):Lerp(Color3.fromRGB(200, 170, 120), rng:NextNumber(0, 0.4))
|
||||
note.BorderSizePixel = 0
|
||||
note.Parent = bsg
|
||||
local pin = Instance.new("Frame")
|
||||
pin.Size = UDim2.fromScale(0.16, 0.12)
|
||||
pin.Position = UDim2.fromScale(0.42, -0.04)
|
||||
pin.BackgroundColor3 = (i % 2 == 0) and Color3.fromRGB(150, 40, 35) or Color3.fromRGB(214, 160, 70)
|
||||
pin.BorderSizePixel = 0
|
||||
pin.Parent = note
|
||||
Instance.new("UICorner", pin).CornerRadius = UDim.new(1, 0)
|
||||
for l = 1, 3 do
|
||||
local line = Instance.new("Frame")
|
||||
line.Size = UDim2.fromScale(0.7, 0.05)
|
||||
line.Position = UDim2.fromScale(0.15, 0.25 + l * 0.17)
|
||||
line.BackgroundColor3 = Color3.fromRGB(110, 80, 50)
|
||||
line.BorderSizePixel = 0
|
||||
line.Parent = note
|
||||
end
|
||||
end
|
||||
local pp = Instance.new("ProximityPrompt")
|
||||
pp.ActionText, pp.ObjectText = "Заказы гильдии", "Доска заказов"
|
||||
pp.HoldDuration, pp.MaxActivationDistance, pp.RequiresLineOfSight = 0, 12, false
|
||||
pp:SetAttribute("Action", "Orders")
|
||||
pp.Parent = board
|
||||
|
||||
-- Старейшина Ворон — за кафедрой в глубине зала, лицом к двери
|
||||
local spot = find("ElderSpot", "ElderSpot")
|
||||
assert(spot, "Нет ElderSpot в модели")
|
||||
local elder = oldElder:Clone()
|
||||
local top = spot.Position + V(0, spot.Size.Y / 2, 0)
|
||||
local look = -spot.CFrame.LookVector -- фасад модели смотрел в −Z, после разворота «вперёд» — к двери
|
||||
look = V(look.X, 0, look.Z).Unit
|
||||
-- старое место стояло центром на 3 стада выше пола (ноги на +0.5)
|
||||
elder.CFrame = CFrame.lookAt(top + V(0, 2.9, 0), top + V(0, 2.9, 0) + (-look))
|
||||
elder.Parent = hall
|
||||
spot.Transparency = 1
|
||||
|
||||
return ("Гильдия: деталей %d, с коллизией %d, светящихся %d; земля Y=%.2f; Ворон в %s"):format(parts, collide, glow, groundY, tostring(elder.Position))
|
||||
Reference in new issue
Block a user