Files
Fishing/tools/widen-lobby.lua
2026-11-06 12:34:01 +05:00

231 lines
10 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 / MCP),
-- потом Ctrl+S. Откат: tools/widen-lobby-undo.lua (у каждой сдвинутой детали в атрибутах лежит прежнее место).
--
-- 1) Край площади уходит на D studs наружу: скалы (с лёгким увеличением, чтобы между ними не было щелей),
-- деревья и кусты на скалах (заново сажаются на скалы), камни/трава/цветы у подножия, лес у края,
-- невидимая стена (шире, без щелей), камни и деревья, поставленные в Workspace руками. Диск мостовой — больше.
-- Холмы-террейн начинаются с радиуса 120 и остаются как есть.
-- 2) Лавки встают полукругом на радиусе R, фасадом к центру, через равные углы:
-- запад — удочки Михалыча, наживка, Сокровищница Златы; юг (за точкой появления) — свободно;
-- Премиум Барона, Скупка Зины, восток — доска «Топ по заработку». Между лавками — фонари, бочки, ящики, клумбы.
-- Порталы, фонтан, двор гильдии, доски «Топ рыболовов» и «Топ донатеров», табличка, сундук и точка появления не двигаются.
local D = 16 -- насколько отодвигаем край
local R = 80 -- радиус торгового ряда (центр лавки)
local FLOOR = 1
local TAG = "LobbyWide"
local map = workspace.FishingMap
local report = {}
local function flat(p)
return Vector3.new(p.X, 0, p.Z)
end
local function pivotOf(o)
if o:IsA("Model") then
return o:GetPivot()
elseif o:IsA("BasePart") then
return o.CFrame
end
end
local function setPivot(o, cf)
if o:IsA("Model") then
o:PivotTo(cf)
else
o.CFrame = cf
end
end
local function remember(o)
if o:GetAttribute(TAG .. "Orig") == nil then
o:SetAttribute(TAG .. "Orig", pivotOf(o))
if o:IsA("Model") then
o:SetAttribute(TAG .. "Scale", o:GetScale())
elseif o:IsA("BasePart") then
o:SetAttribute(TAG .. "Size", o.Size)
end
end
end
---------------------------------------------------------------- 1. край площади
if not map:GetAttribute(TAG) then
local count = 0
-- сдвиг радиально; grow — увеличить модель (низ остаётся на месте)
local function pushOut(o, grow)
local cf = pivotOf(o)
if not cf then
return
end
local r = flat(cf.Position).Magnitude
if r < 1 then
return
end
remember(o)
local dir = flat(cf.Position) / r
if grow and o:IsA("Model") then
local bcf, bsz = o:GetBoundingBox()
local bottom = bcf.Position.Y - bsz.Y / 2
o:ScaleTo(o:GetScale() * grow)
local bcf2, bsz2 = o:GetBoundingBox()
o:PivotTo(o:GetPivot() + Vector3.new(0, bottom - (bcf2.Position.Y - bsz2.Y / 2), 0))
cf = o:GetPivot()
end
setPivot(o, cf + dir * D)
count += 1
end
-- скалы: оба кольца, с увеличением по длине окружности
local cliffs = map:FindFirstChild("LobbyCliffs")
for _, m in ipairs(cliffs and cliffs:GetChildren() or {}) do
local r = flat(pivotOf(m).Position).Magnitude
pushOut(m, (r + D) / r)
end
-- всё у края: только модели/детали дальше minR от центра (на площади ничего не трогаем);
-- подножие скал (камни, кусты, трава, цветы) лежит кольцом 70–89 — уводим целиком, чтобы не осталось под лавками
local function pushFolder(folder, minR)
for _, c in ipairs(folder:GetChildren()) do
if c:IsA("Folder") then
pushFolder(c, minR)
elseif (c:IsA("Model") or c:IsA("BasePart")) and flat(pivotOf(c).Position).Magnitude >= minR then
pushOut(c)
end
end
end
for _, name in ipairs({ "LobbyCliffDecor", "LobbyCliffFoot", "LobbyForest", "LobbyTrees", "LobbyRockPlants" }) do
local f = map:FindFirstChild(name)
if f then
pushFolder(f, name == "LobbyCliffFoot" and 66 or 74)
end
end
-- деревья и кусты на скалах и лес: скалы стали выше, лес ушёл на склоны — сажаем заново на то, что под ними
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Include
rayParams.FilterDescendantsInstances = { cliffs, workspace.Terrain }
for _, name in ipairs({ "LobbyTrees", "LobbyRockPlants", "LobbyForest" }) do
local f = map:FindFirstChild(name)
for _, m in ipairs(f and f:GetDescendants() or {}) do
if m:IsA("Model") and m.Parent and (m.Parent == f or m.Parent.Parent == f) and m:FindFirstChildWhichIsA("BasePart", true) and not m:FindFirstChildOfClass("Model") then
local bcf, bsz = m:GetBoundingBox()
local hit = workspace:Raycast(Vector3.new(bcf.Position.X, 200, bcf.Position.Z), Vector3.new(0, -260, 0), rayParams)
if hit then
m:PivotTo(m:GetPivot() + Vector3.new(0, hit.Position.Y - (bcf.Position.Y - bsz.Y / 2), 0))
end
end
end
end
-- невидимая стена и высокие детали края прямо в FishingMap: дальше и шире
for _, c in ipairs(map:GetChildren()) do
if c:IsA("BasePart") and c.Size.Y >= 20 then
local r = flat(c.Position).Magnitude
if r >= 80 and r <= 100 then
remember(c)
c.Size = Vector3.new(c.Size.X * (r + D) / r + 0.5, c.Size.Y, c.Size.Z)
pushOut(c)
end
end
end
-- камни, деревья и валуны, поставленные в Workspace руками у края лобби
for _, c in ipairs(workspace:GetChildren()) do
if c ~= map and (c:IsA("Model") or c:IsA("BasePart")) and not c:IsA("Terrain") then
local cf = pivotOf(c)
local r = cf and flat(cf.Position).Magnitude or 0
if r >= 74 and r <= 130 then
pushOut(c)
end
end
end
-- диск мостовой
for _, c in ipairs(map:GetChildren()) do
if c:IsA("BasePart") and flat(c.Position).Magnitude < 1 and math.abs(c.Size.Y - 170) < 1 and math.abs(c.Size.Z - 170) < 1 then
remember(c)
c.Size = Vector3.new(c.Size.X, 170 + D * 2, 170 + D * 2)
table.insert(report, "диск мостовой: радиус " .. (85 + D))
end
end
map:SetAttribute(TAG, D)
table.insert(report, ("край отодвинут на %d studs, объектов сдвинуто: %d"):format(D, count))
end
---------------------------------------------------------------- 2. торговый ряд
local function slot(deg)
local a = math.rad(deg)
local p = Vector3.new(math.cos(a) * R, FLOOR, math.sin(a) * R)
return CFrame.lookAt(p, Vector3.new(0, FLOOR, 0))
end
-- старая лавка из WorldBuilder.stall: всё в её габаритах прямо в FishingMap
local function inStall(cf, p)
local l = cf:PointToObjectSpace(p)
return math.abs(l.X) <= 15.5 and l.Y >= -0.5 and l.Y <= 21 and l.Z >= -14.5 and l.Z <= 9.5
end
local function spotOf(npc)
for _, c in ipairs(map:GetChildren()) do
if c:IsA("BasePart") and c:GetAttribute("NpcName") == npc then
return c
end
end
end
-- кадр старой лавки по месту NPC (NPC стоял в (0, 4, 1.5) от неё)
local function stallFrame(spot)
local away = flat(spot.Position).Unit
local base = Vector3.new(spot.Position.X, FLOOR, spot.Position.Z) - away * 1.5
return CFrame.lookAt(base, base - away)
end
local function looseStall(npc)
local spot = spotOf(npc)
local cf = stallFrame(spot)
local items = {}
for _, c in ipairs(map:GetChildren()) do
if (c:IsA("BasePart") or c:IsA("Model")) and not c:GetAttribute("Leaderboard") and not c.Name:find("^LobbyShop_")
and not c.Name:find("^Portal") and not (c:GetAttribute("NpcName") and c ~= spot) then
if inStall(cf, pivotOf(c).Position) then
table.insert(items, c)
end
end
end
return cf, items
end
local function modelShop(name, npc)
local m = map:FindFirstChild(name)
assert(m, "нет " .. name)
local items = { m }
if npc then
table.insert(items, spotOf(npc))
end
local p = m:GetPivot()
return CFrame.lookAt(Vector3.new(p.X, FLOOR, p.Z), Vector3.new(p.X, FLOOR, p.Z) + flat(p.LookVector)), items
end
if not map:GetAttribute(TAG .. "Market") then
-- {угол, кадр сейчас, что двигать, подпись}; 90° (юг, за точкой появления) оставлен свободным
local plan = {}
local cf, items
cf, items = looseStall("Продавец Михалыч")
table.insert(plan, { 180, cf, items, "Удочки (Михалыч)" })
cf, items = modelShop("LobbyShop_Bait")
table.insert(plan, { 148, cf, items, "Наживка" })
cf, items = looseStall("Купчиха Злата")
table.insert(plan, { 116, cf, items, "Сокровищница (Злата)" })
cf, items = modelShop("LobbyShop_Premium", "Барон Злотов")
table.insert(plan, { 64, cf, items, "Премиум (Барон)" })
cf, items = modelShop("LobbyShop_FishBuyer", "Скупщица Зина")
table.insert(plan, { 32, cf, items, "Скупка (Зина)" })
local earn = map:FindFirstChild("Leaderboard_Earn")
if earn then
table.insert(plan, { 0, CFrame.lookAt(flat(earn:GetPivot().Position) + Vector3.new(0, FLOOR, 0), flat(earn:GetPivot().Position) + Vector3.new(0, FLOOR, 0) + flat(earn:GetPivot().LookVector)), { earn }, "Топ по заработку" })
end
for _, s in ipairs(plan) do
local to = slot(s[1])
for _, o in ipairs(s[3]) do
remember(o)
setPivot(o, to * s[2]:ToObjectSpace(pivotOf(o)))
end
table.insert(report, ("%s → %d°, деталей %d"):format(s[4], s[1], #s[3]))
end
-- украшения между лавками ставит tools/lobby-decor.lua
map:SetAttribute(TAG .. "Market", true)
end
return table.concat(report, "\n")