From 0fe8bd35a065099373d0bde449c352c5b13a54f7 Mon Sep 17 00:00:00 2001 From: heyshawtyy <108924601+heyshawtyy@users.noreply.github.com> Date: Fri, 13 Nov 2026 14:32:46 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=BC=D0=B0=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=9E=D1=81=D1=82=D1=80=D0=BE=D0=B2=D0=B5=202:=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=B4=20=D0=B8=D0=B7=20Studio=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D1=81=D1=91=D0=BD=20=D0=B2=20src=20=D0=B8=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B5=D0=B4=D0=B8=D0=BD=D1=91=D0=BD=20=D1=81=20GameServer/Fish?= =?UTF-8?q?ingClient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Fishing.rbxlx | 39 +- src/ReplicatedStorage/HouseConfig.lua | 54 + src/ReplicatedStorage/HouseCosmetics.lua | 127 ++ src/ServerScriptService/GameServer.server.lua | 24 + src/ServerScriptService/Houses.lua | 1052 +++++++++++++++++ .../FishingClient.client.lua | 15 +- .../HouseClient.client.lua | 689 +++++++++++ tools/dump-place-scripts.js | 36 + 8 files changed, 2032 insertions(+), 4 deletions(-) create mode 100644 src/ReplicatedStorage/HouseConfig.lua create mode 100644 src/ReplicatedStorage/HouseCosmetics.lua create mode 100644 src/ServerScriptService/Houses.lua create mode 100644 src/StarterPlayer/StarterPlayerScripts/HouseClient.client.lua create mode 100644 tools/dump-place-scripts.js diff --git a/Fishing.rbxlx b/Fishing.rbxlx index 3d9e029..76f0a89 100644 --- a/Fishing.rbxlx +++ b/Fishing.rbxlx @@ -7713577,7 +7713577,7 @@ local function teleportLoading(targetId, delay) loadingGui:SetAttribute("Ready", false) loadingGui:SetAttribute("StartAt", now) loadingGui:SetAttribute("MinUntil", now + Config.Loading.teleport) - loadingGui:SetAttribute("Title", placeTitle(target)) + loadingGui:SetAttribute("Title", targetId == "Home" and "🏠 Мой дом" or placeTitle(target)) loadingGui:SetAttribute("Visible", true) end task.spawn(function() @@ -7713587,7 +7713587,18 @@ local function teleportLoading(targetId, delay) repeat task.wait() w = currentWorld() - until (w and w.id or "Lobby") == targetId or os.clock() > deadline or token ~= teleportToken + local arrived + if targetId == "Home" then + -- остров «Мой дом» не мир из Config: ждём, пока персонаж окажется рядом с его спавном + local island = workspace:FindFirstChild("Island2") + local spawnPart = island and island:FindFirstChild("HomeSpawn") + local char = Players.LocalPlayer.Character + local hrp = char and char:FindFirstChild("HumanoidRootPart") + arrived = spawnPart ~= nil and hrp ~= nil and (hrp.Position - spawnPart.Position).Magnitude < 300 + else + arrived = (w and w.id or "Lobby") == targetId + end + until arrived or os.clock() > deadline or token ~= teleportToken if token ~= teleportToken then return end @@ -7730092,6 +7730103,7 @@ local Potions = require(script.Parent:WaitForChild("Potions")) local Market = require(script.Parent:WaitForChild("Market")) local Telemetry = require(script.Parent:WaitForChild("Telemetry")) local PlayerStore = require(script.Parent:WaitForChild("PlayerStore")) +local Houses = require(script.Parent:WaitForChild("Houses")) -- дома игроков на острове «Мой дом» local E = Config.Economy local remote = ReplicatedStorage:FindFirstChild("GameEvent") or Instance.new("RemoteEvent") @@ -7730188,6 +7730200,7 @@ local function defaultData() settings = { music = Config.DefaultVolume.music, sfx = Config.DefaultVolume.sfx }, -- гильдия: жемчуг, печати, отдых (ранг, заказы, наживку, ловушки дополняет Guild.defaults) pearls = 0, seals = 0, rest = 0, + houseLevel = 0, -- уровень дома на острове «Мой дом» (0 — пустой участок) } end @@ -7730469,6 +7730482,7 @@ local function updateStats(player) player:SetAttribute("Tutorial", data.tutorial or (data.totalCaught > 0 and Config.TutorialDone or 0)) player:SetAttribute("Mastery", masteryCount(data)) player:SetAttribute("Passes", table.concat(ps, ",")) + player:SetAttribute("HouseLevel", data.houseLevel or 0) Guild.attrs(player, data) local ls = player:FindFirstChild("leaderstats") @@ -7730509,6 +7730523,8 @@ Guild.init({ addCoins = addCoins, spendCoins = spendCoins, tierOf = tierOf, }) +Houses.init({ profiles = profiles, notify = notify, updateStats = updateStats, spendCoins = spendCoins, addCoins = addCoins, remote = remote }) + -- зелье-награда: в сумку зелий (пить — когда игрок сам решит) local function givePotion(player, data, def) if def and Potions.add(data, def.id, 1) then @@ -7731674,6 +7731690,8 @@ local function teleportTo(player, worldId) local markerName if worldId == "Lobby" then markerName = "LobbySpawn" + elseif worldId == "Home" then + markerName = "HomeSpawn" -- остров «Мой дом» (Workspace.Island2) else local world = Config.Find(Config.Worlds, worldId) if not world then @@ -7731696,6 +7731714,10 @@ local function teleportTo(player, worldId) end local map = workspace:FindFirstChild("FishingMap") local m = map and map:FindFirstChild(markerName, true) -- маркеры могут лежать в папках уровня (World1Map) + if not m and worldId == "Home" then + local island = workspace:FindFirstChild("Island2") + m = island and island:FindFirstChild(markerName, true) + end if m and not teleporting[player] then -- клиент затемняет экран, переносим уже в темноте: свет новой локации ставится до того, как её видно teleporting[player] = true @@ -7731746,6 +7731768,10 @@ ProximityPromptService.PromptTriggered:Connect(function(prompt, player) sellItems(player, nil) elseif action == "Portal" then teleportTo(player, prompt:GetAttribute("World")) + elseif action == "House" then + Houses.onPrompt(player, prompt) + elseif action == "HouseComputer" then + Houses.onComputer(player, prompt) elseif action == "Talk" then talk(player) elseif action == "Daily" then @@ -7731827,6 +7731853,14 @@ local function onRemote(player, action, a, b) potionCooldown[player] = t + 0.4 drinkPotion(player, a, b) end + elseif action == "HouseUpgrade" then + Houses.upgrade(player) + elseif action == "HouseSpin" then + Houses.spin(player, a, b) + elseif action == "HouseEquip" then + Houses.equip(player, a, b) + elseif action == "HouseReveal" then + Houses.reveal(player) elseif Market.onAction(player, action, a, b) then return else @@ -7732049,6 +7732083,7 @@ local function onPlayerAdded(player) loadPasses(player, data) ensureChain(data) Guild.defaults(data) + Houses.defaults(data) -- экономика v2: перенос старого сохранения (уровень, доля опыта, зелье, id рыбы); повторно не выполняется if Progression.migrate(data, { now = os.time(), userId = player.UserId, name = player.DisplayName }) then Telemetry.event(player, "EconomyMigrated", 1, { tostring(data.migration and data.migration.from), tostring(data.level) }) diff --git a/src/ReplicatedStorage/HouseConfig.lua b/src/ReplicatedStorage/HouseConfig.lua new file mode 100644 index 0000000..6b2c2c8 --- /dev/null +++ b/src/ReplicatedStorage/HouseConfig.lua @@ -0,0 +1,54 @@ +-- HouseConfig (ModuleScript) -> ReplicatedStorage +-- Дома игроков на острове «Мой дом» (Workspace.Island2): уровни, цены, участки. +-- Общий для сервера (Houses) и клиента (HouseClient). + +local H = {} + +H.MaxLevel = 10 +H.BaseCost = 5000 -- цена 1-го уровня +H.Mult = 10 -- каждый следующий уровень дороже предыдущего в 10 раз + +H.Names = { + "Хижина", + "Домик", + "Дом с крыльцом", + "Каменный дом", + "Двухэтажный дом", + "Дом с флигелем", + "Особняк", + "Особняк с башней", + "Усадьба", + "Дворец", +} + +-- цена покупки уровня level (1..MaxLevel): 5 000, 50 000, 500 000 … +function H.cost(level) + return H.BaseCost * H.Mult ^ (level - 1) +end + +function H.name(level) + return level > 0 and H.Names[level] or "Пустой участок" +end + +-- остров и участки: по одному в каждом из 6 секторов между реками +H.Center = Vector3.new(4000, 20, 0) -- центр острова, Y — верх пола +H.IslandRadius = 285 +H.Plots = 6 +H.PlotRadius = 205 -- расстояние от центра острова до центра участка +-- сторона участка 128: при острове радиусом 285 до русла реки ~15 стадов, до края ~8 +H.PlotSize = 128 + +-- участок i (1..6): центр на уровне пола, «лицом» (-Z) к центру острова +function H.plotCFrame(i) + local a = math.rad(30 + 60 * (i - 1)) + local pos = H.Center + Vector3.new(math.cos(a) * H.PlotRadius, 0, math.sin(a) * H.PlotRadius) + return CFrame.lookAt(pos, Vector3.new(H.Center.X, pos.Y, H.Center.Z)) +end + +-- игрок на острове (по горизонтали, с запасом) +function H.onIsland(pos, margin) + local d = Vector3.new(pos.X - H.Center.X, 0, pos.Z - H.Center.Z).Magnitude + return d <= H.IslandRadius + (margin or 30) and pos.Y > H.Center.Y - 60 +end + +return H diff --git a/src/ReplicatedStorage/HouseCosmetics.lua b/src/ReplicatedStorage/HouseCosmetics.lua new file mode 100644 index 0000000..f5af1e3 --- /dev/null +++ b/src/ReplicatedStorage/HouseCosmetics.lua @@ -0,0 +1,127 @@ +-- HouseCosmetics (ModuleScript) -> ReplicatedStorage +-- Улучшения дома, которые крутятся на компьютере в доме (остров «Мой дом»). +-- Иерархия: категория (кусты, двери, окна, крыша, пол) -> предметы с редкостью и шансом. +-- Шансы в категории в сумме дают 100. Внешний вид предмета — поля color / material / …, +-- их читает Houses.buildHouse. Ничего не надето — стандартный вид дома его уровня. + +local M = {} + +local RGB = Color3.fromRGB +local Mat = Enum.Material + +M.Rarities = { + Common = { name = "Обычный", color = RGB(200, 200, 200), rank = 1 }, + Uncommon = { name = "Необычный", color = RGB(110, 220, 110), rank = 2 }, + Rare = { name = "Редкий", color = RGB(80, 160, 255), rank = 3 }, + Epic = { name = "Эпический", color = RGB(180, 90, 255), rank = 4 }, + Legendary = { name = "Легендарный", color = RGB(255, 170, 40), rank = 5 }, + Mythic = { name = "Мифический", color = RGB(255, 90, 180), rank = 6 }, +} + +-- доля цены крутки, которая возвращается за повторный предмет +M.DuplicateRefund = 0.2 +-- сколько круток можно сделать одной кнопкой +M.SpinCounts = { 1, 3, 10 } + +M.Categories = { + { + id = "bush", name = "Кусты", icon = "🌳", cost = 1000, + items = { + { id = "green", name = "Зелёный куст", rarity = "Common", chance = 45, color = RGB(70, 150, 70), material = Mat.Grass, shape = "Ball", size = 4 }, + { id = "cube", name = "Стриженый куб", rarity = "Uncommon", chance = 30, color = RGB(56, 128, 60), material = Mat.Grass, shape = "Block", size = 3.6 }, + { id = "sakura", name = "Сакура", rarity = "Rare", chance = 15, color = RGB(255, 170, 205), material = Mat.Grass, shape = "Ball", size = 4.4, flowers = RGB(255, 255, 255) }, + { id = "maple", name = "Осенний клён", rarity = "Epic", chance = 7, color = RGB(230, 120, 40), material = Mat.Grass, shape = "Ball", size = 4.6, flowers = RGB(255, 210, 60) }, + { id = "frost", name = "Ледяной куст", rarity = "Legendary", chance = 2.5, color = RGB(150, 220, 255), material = Mat.Ice, shape = "Ball", size = 4.4, flowers = RGB(220, 245, 255), glow = true }, + { id = "golden", name = "Золотой куст", rarity = "Mythic", chance = 0.5, color = RGB(255, 205, 70), material = Mat.Foil, shape = "Ball", size = 4.8, flowers = RGB(255, 240, 160), glow = true }, + }, + }, + { + id = "door", name = "Двери", icon = "🚪", cost = 2500, + items = { + { id = "oak", name = "Дубовая дверь", rarity = "Common", chance = 45, color = RGB(110, 66, 38), material = Mat.WoodPlanks }, + { id = "red", name = "Красная дверь", rarity = "Uncommon", chance = 30, color = RGB(170, 40, 40), material = Mat.SmoothPlastic }, + { id = "iron", name = "Железная дверь", rarity = "Rare", chance = 15, color = RGB(96, 100, 110), material = Mat.DiamondPlate }, + { id = "emerald", name = "Изумрудная дверь", rarity = "Epic", chance = 7, color = RGB(40, 170, 90), material = Mat.Glass, frame = RGB(120, 255, 170) }, + { id = "crystal", name = "Хрустальная дверь", rarity = "Legendary", chance = 2.5, color = RGB(170, 230, 255), material = Mat.Glass, transparency = 0.3, frame = RGB(200, 245, 255) }, + { id = "golden", name = "Золотая дверь", rarity = "Mythic", chance = 0.5, color = RGB(255, 200, 60), material = Mat.Foil, frame = RGB(255, 230, 140) }, + }, + }, + { + id = "window", name = "Окна", icon = "🖼", cost = 2500, + items = { + { id = "clear", name = "Прозрачное стекло", rarity = "Common", chance = 45, color = RGB(170, 215, 240), material = Mat.Glass, transparency = 0.65 }, + { id = "tinted", name = "Тонировка", rarity = "Uncommon", chance = 30, color = RGB(50, 66, 84), material = Mat.Glass, transparency = 0.4 }, + { id = "stained", name = "Витраж", rarity = "Rare", chance = 15, color = RGB(220, 90, 160), material = Mat.Glass, transparency = 0.45, frame = RGB(60, 40, 90) }, + { id = "warm", name = "Тёплый свет", rarity = "Epic", chance = 7, color = RGB(255, 214, 140), material = Mat.Neon, transparency = 0.5 }, + { id = "aurora", name = "Северное сияние", rarity = "Legendary", chance = 2.5, color = RGB(90, 255, 190), material = Mat.Neon, transparency = 0.5, frame = RGB(40, 90, 120) }, + { id = "rainbow", name = "Радужные окна", rarity = "Mythic", chance = 0.5, color = RGB(255, 120, 200), material = Mat.Neon, transparency = 0.45, rainbow = true, frame = RGB(255, 230, 140) }, + }, + }, + { + id = "roof", name = "Крыша", icon = "🏠", cost = 10000, + items = { + { id = "straw", name = "Солома", rarity = "Common", chance = 45, color = RGB(196, 164, 92), material = Mat.Fabric }, + { id = "tile", name = "Красная черепица", rarity = "Uncommon", chance = 30, color = RGB(170, 70, 52), material = Mat.Slate }, + { id = "slate", name = "Синий сланец", rarity = "Rare", chance = 15, color = RGB(58, 78, 120), material = Mat.Slate }, + { id = "copper", name = "Медная крыша", rarity = "Epic", chance = 7, color = RGB(70, 160, 130), material = Mat.Metal }, + { id = "lava", name = "Лавовая крыша", rarity = "Legendary", chance = 2.5, color = RGB(255, 110, 40), material = Mat.CrackedLava }, + { id = "golden", name = "Золотая крыша", rarity = "Mythic", chance = 0.5, color = RGB(255, 205, 70), material = Mat.Foil }, + }, + }, + { + id = "floor", name = "Пол", icon = "🟫", cost = 5000, + items = { + { id = "planks", name = "Доски", rarity = "Common", chance = 45, color = RGB(150, 104, 62), material = Mat.WoodPlanks }, + { id = "stone", name = "Каменная плитка", rarity = "Uncommon", chance = 30, color = RGB(130, 128, 124), material = Mat.Cobblestone }, + { id = "carpet", name = "Красный ковёр", rarity = "Rare", chance = 15, color = RGB(160, 40, 50), material = Mat.Fabric }, + { id = "marble", name = "Мрамор", rarity = "Epic", chance = 7, color = RGB(235, 232, 225), material = Mat.Marble }, + { id = "ice", name = "Ледяной пол", rarity = "Legendary", chance = 2.5, color = RGB(170, 220, 255), material = Mat.Ice }, + { id = "golden", name = "Золотой пол", rarity = "Mythic", chance = 0.5, color = RGB(255, 205, 70), material = Mat.Foil }, + }, + }, +} + +M.ById = {} +for _, cat in ipairs(M.Categories) do + M.ById[cat.id] = cat + cat.byId = {} + for _, it in ipairs(cat.items) do + cat.byId[it.id] = it + end +end + +function M.category(catId) + return M.ById[catId] +end + +function M.item(catId, itemId) + local cat = M.ById[catId] + return cat and itemId and cat.byId[itemId] or nil +end + +-- случайный предмет по шансам (rng — Random) +function M.roll(catId, rng) + local cat = M.ById[catId] + local total = 0 + for _, it in ipairs(cat.items) do + total += it.chance + end + local r = rng:NextNumber() * total + for _, it in ipairs(cat.items) do + r -= it.chance + if r <= 0 then + return it + end + end + return cat.items[#cat.items] +end + +-- число для подписи: 45 -> "45%", 2.5 -> "2.5%" +function M.chanceText(chance) + if chance == math.floor(chance) then + return ("%d%%"):format(chance) + end + return ("%s%%"):format(tostring(chance)) +end + +return M diff --git a/src/ServerScriptService/GameServer.server.lua b/src/ServerScriptService/GameServer.server.lua index 89b6dc0..1e177e3 100644 --- a/src/ServerScriptService/GameServer.server.lua +++ b/src/ServerScriptService/GameServer.server.lua @@ -19,6 +19,7 @@ local Potions = require(script.Parent:WaitForChild("Potions")) local Market = require(script.Parent:WaitForChild("Market")) local Telemetry = require(script.Parent:WaitForChild("Telemetry")) local PlayerStore = require(script.Parent:WaitForChild("PlayerStore")) +local Houses = require(script.Parent:WaitForChild("Houses")) -- дома игроков на острове «Мой дом» local E = Config.Economy local remote = ReplicatedStorage:FindFirstChild("GameEvent") or Instance.new("RemoteEvent") @@ -115,6 +116,7 @@ local function defaultData() settings = { music = Config.DefaultVolume.music, sfx = Config.DefaultVolume.sfx }, -- гильдия: жемчуг, печати, отдых (ранг, заказы, наживку, ловушки дополняет Guild.defaults) pearls = 0, seals = 0, rest = 0, + houseLevel = 0, -- уровень дома на острове «Мой дом» (0 — пустой участок) } end @@ -396,6 +398,7 @@ local function updateStats(player) player:SetAttribute("Tutorial", data.tutorial or (data.totalCaught > 0 and Config.TutorialDone or 0)) player:SetAttribute("Mastery", masteryCount(data)) player:SetAttribute("Passes", table.concat(ps, ",")) + player:SetAttribute("HouseLevel", data.houseLevel or 0) Guild.attrs(player, data) local ls = player:FindFirstChild("leaderstats") @@ -436,6 +439,8 @@ Guild.init({ addCoins = addCoins, spendCoins = spendCoins, tierOf = tierOf, }) +Houses.init({ profiles = profiles, notify = notify, updateStats = updateStats, spendCoins = spendCoins, addCoins = addCoins, remote = remote }) + -- зелье-награда: в сумку зелий (пить — когда игрок сам решит) local function givePotion(player, data, def) if def and Potions.add(data, def.id, 1) then @@ -1601,6 +1606,8 @@ local function teleportTo(player, worldId) local markerName if worldId == "Lobby" then markerName = "LobbySpawn" + elseif worldId == "Home" then + markerName = "HomeSpawn" -- остров «Мой дом» (Workspace.Island2) else local world = Config.Find(Config.Worlds, worldId) if not world then @@ -1623,6 +1630,10 @@ local function teleportTo(player, worldId) end local map = workspace:FindFirstChild("FishingMap") local m = map and map:FindFirstChild(markerName, true) -- маркеры могут лежать в папках уровня (World1Map) + if not m and worldId == "Home" then + local island = workspace:FindFirstChild("Island2") + m = island and island:FindFirstChild(markerName, true) + end if m and not teleporting[player] then -- клиент затемняет экран, переносим уже в темноте: свет новой локации ставится до того, как её видно teleporting[player] = true @@ -1673,6 +1684,10 @@ ProximityPromptService.PromptTriggered:Connect(function(prompt, player) sellItems(player, nil) elseif action == "Portal" then teleportTo(player, prompt:GetAttribute("World")) + elseif action == "House" then + Houses.onPrompt(player, prompt) + elseif action == "HouseComputer" then + Houses.onComputer(player, prompt) elseif action == "Talk" then talk(player) elseif action == "Daily" then @@ -1754,6 +1769,14 @@ local function onRemote(player, action, a, b) potionCooldown[player] = t + 0.4 drinkPotion(player, a, b) end + elseif action == "HouseUpgrade" then + Houses.upgrade(player) + elseif action == "HouseSpin" then + Houses.spin(player, a, b) + elseif action == "HouseEquip" then + Houses.equip(player, a, b) + elseif action == "HouseReveal" then + Houses.reveal(player) elseif Market.onAction(player, action, a, b) then return else @@ -1976,6 +1999,7 @@ local function onPlayerAdded(player) loadPasses(player, data) ensureChain(data) Guild.defaults(data) + Houses.defaults(data) -- экономика v2: перенос старого сохранения (уровень, доля опыта, зелье, id рыбы); повторно не выполняется if Progression.migrate(data, { now = os.time(), userId = player.UserId, name = player.DisplayName }) then Telemetry.event(player, "EconomyMigrated", 1, { tostring(data.migration and data.migration.from), tostring(data.level) }) diff --git a/src/ServerScriptService/Houses.lua b/src/ServerScriptService/Houses.lua new file mode 100644 index 0000000..517cfb0 --- /dev/null +++ b/src/ServerScriptService/Houses.lua @@ -0,0 +1,1052 @@ +-- Houses (ModuleScript) -> ServerScriptService +-- Остров «Мой дом»: каждому игроку на острове — свой участок (их 6) и дом его уровня (0..10). +-- В дом можно зайти: проёмы двери и окон в стенах, до 3 этажей с лестницами, на первом этаже — +-- компьютер, на котором крутятся улучшения дома (кусты, двери, окна, крыша, пол — +-- ReplicatedStorage.HouseCosmetics). +-- Данные в профиле: data.houseLevel, data.houseCos = { owned = { [категория] = { [id] = true } }, equip = { [категория] = id } }. +-- Участок выдаётся, когда игрок попадает на остров, и освобождается, когда он уходит. +-- Панели (улучшение дома и компьютер) — HouseClient. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") + +local HC = require(ReplicatedStorage:WaitForChild("HouseConfig")) +local COS = require(ReplicatedStorage:WaitForChild("HouseCosmetics")) + +local Houses = {} + +local deps = nil -- profiles, notify, updateStats, spendCoins, addCoins, remote (из GameServer) +local owners = {} -- [номер участка] = player +local plotOf = {} -- [player] = номер участка +local warnedFull = {} -- [player] = true: уже сказали, что свободных участков нет +local spinCooldown = {} -- [player] = os.clock(), до которого нельзя крутить +local pendingRebuild = {} -- [участок] = true: дом перестроится после анимации крутки +local rng = Random.new() + +local GOLD = Color3.fromRGB(255, 220, 80) +local RED = Color3.fromRGB(255, 120, 120) +local GREEN = Color3.fromRGB(120, 255, 140) + +-- дом меняет вид, когда ленты у игрока остановились (клиент присылает "HouseReveal"); +-- если клиент молчит — через столько секунд +Houses.SPIN_REVEAL = 10 + +---------------------------------------------------------------- помощники постройки + +local function part(parent, base, size, lcf, color, material, props) + local p = Instance.new(props and props.class or "Part") + p.Anchored = true + p.TopSurface = Enum.SurfaceType.Smooth + p.BottomSurface = Enum.SurfaceType.Smooth + p.Size = size + p.CFrame = base * lcf + p.Color = color + p.Material = material or Enum.Material.SmoothPlastic + if props then + for k, v in pairs(props) do + if k ~= "class" then + p[k] = v + end + end + end + p.Parent = parent + return p +end + +local function island() + return workspace:FindFirstChild("Island2") +end + +local function folder(parent, name) + local f = parent:FindFirstChild(name) + if not f then + f = Instance.new("Folder") + f.Name = name + f.Parent = parent + end + return f +end + +local function surfaceText(p, text, color, ppStud) + local sg = Instance.new("SurfaceGui") + sg.Face = Enum.NormalId.Front + sg.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud + sg.PixelsPerStud = ppStud or 40 + sg.Parent = p + local t = Instance.new("TextLabel") + t.Name = "Text" + t.Size = UDim2.fromScale(1, 1) + t.BackgroundTransparency = 1 + t.TextScaled = true + t.Font = Enum.Font.Merriweather + t.TextColor3 = color or Color3.fromRGB(255, 236, 190) + t.TextStrokeTransparency = 0.4 + t.Text = text + t.Parent = sg + return t +end + +---------------------------------------------------------------- участки (статичные: плита + табличка) + +local SLAB_H = 0.6 + +-- создаёт недостающие участки в Island2.Plots (можно вызвать и в Studio до запуска) +function Houses.ensurePlots() + local isl = island() + if not isl then + return nil + end + local plots = folder(isl, "Plots") + for i = 1, HC.Plots do + -- участок другого размера или не на своём месте (поменяли HouseConfig) — пересоздаём + local ex = plots:FindFirstChild("Plot_" .. i) + local slab = ex and ex:FindFirstChild("Slab") + if ex and (not slab or math.abs(slab.Size.X - HC.PlotSize) > 0.01 + or (slab.Position * Vector3.new(1, 0, 1) - HC.plotCFrame(i).Position * Vector3.new(1, 0, 1)).Magnitude > 0.5) then + ex:Destroy() + end + if not plots:FindFirstChild("Plot_" .. i) then + local m = Instance.new("Model") + m.Name = "Plot_" .. i + local cf = HC.plotCFrame(i) + local S = HC.PlotSize + part(m, cf, Vector3.new(S, SLAB_H, S), CFrame.new(0, SLAB_H / 2, 0), Color3.fromRGB(196, 186, 168), Enum.Material.Cobblestone, { Name = "Slab" }) + part(m, cf, Vector3.new(S + 1, SLAB_H - 0.1, S + 1), CFrame.new(0, (SLAB_H - 0.1) / 2, 0), Color3.fromRGB(120, 84, 56), Enum.Material.WoodPlanks, { Name = "Border", CanCollide = false }) + local signCF = CFrame.new(10, 0, -S / 2 + 1.5) + part(m, cf, Vector3.new(0.6, 5, 0.6), signCF * CFrame.new(0, SLAB_H + 2.5, 0), Color3.fromRGB(90, 60, 38), Enum.Material.Wood, { Name = "SignPost" }) + local board = part(m, cf, Vector3.new(4.2, 2.4, 0.3), signCF * CFrame.new(0, SLAB_H + 4.4, -0.35), Color3.fromRGB(150, 104, 62), Enum.Material.WoodPlanks, { Name = "Sign" }) + surfaceText(board, "Участок " .. i) + local pp = Instance.new("ProximityPrompt") + pp.ActionText = "Дом" + pp.ObjectText = "Участок " .. i + pp.HoldDuration = 0 + pp.MaxActivationDistance = 12 + pp.RequiresLineOfSight = false + pp:SetAttribute("Action", "House") + pp:SetAttribute("Plot", i) + pp.Parent = board + local anchor = part(m, cf, Vector3.new(1, 1, 1), CFrame.new(0, 34, 0), Color3.new(1, 1, 1), nil, + { Name = "LabelAnchor", Transparency = 1, CanCollide = false, CanQuery = false, CanTouch = false }) + local bb = Instance.new("BillboardGui") + bb.Name = "OwnerLabel" + bb.Size = UDim2.fromOffset(320, 70) + bb.MaxDistance = 260 + bb.Parent = anchor + local l1 = Instance.new("TextLabel") + l1.Name = "Owner" + l1.Size = UDim2.fromScale(1, 0.58) + l1.BackgroundTransparency = 1 + l1.TextScaled = true + l1.Font = Enum.Font.Merriweather + l1.TextColor3 = Color3.fromRGB(160, 255, 170) + l1.TextStrokeTransparency = 0.3 + l1.Text = "Свободный участок" + l1.Parent = bb + local l2 = l1:Clone() + l2.Name = "Level" + l2.Size = UDim2.fromScale(1, 0.4) + l2.Position = UDim2.fromScale(0, 0.6) + l2.TextColor3 = Color3.fromRGB(236, 220, 180) + l2.Text = "" + l2.Parent = bb + m.Parent = plots + end + end + return plots +end + +local function plotModel(i) + local isl = island() + local plots = isl and isl:FindFirstChild("Plots") + return plots and plots:FindFirstChild("Plot_" .. i) +end + +local function setLabels(i) + local m = plotModel(i) + if not m then + return + end + local owner = owners[i] + local data = owner and deps and deps.profiles[owner] + local lvl = data and data.houseLevel or 0 + local bb = m:FindFirstChild("LabelAnchor") and m.LabelAnchor:FindFirstChild("OwnerLabel") + if bb then + bb.Owner.Text = owner and ("🏠 Дом " .. owner.DisplayName) or "Свободный участок" + bb.Level.Text = owner and (("Ур. %d · %s"):format(lvl, HC.name(lvl))) or "" + -- подпись поднимается над высокими домами + bb.StudsOffsetWorldSpace = Vector3.new(0, lvl >= 8 and 28 or (lvl >= 5 and 14 or (lvl >= 1 and 0 or -18)), 0) + end + local sign = m:FindFirstChild("Sign") + if sign then + local sg = sign:FindFirstChildOfClass("SurfaceGui") + if sg then + sg.Text.Text = owner and owner.DisplayName or ("Участок " .. i) + end + local pp = sign:FindFirstChildOfClass("ProximityPrompt") + if pp then + pp.ObjectText = owner and ("Дом " .. owner.DisplayName) or ("Участок " .. i) + pp.ActionText = owner and "Улучшить дом" or "Дом" + end + end +end + +---------------------------------------------------------------- дом по уровню +-- Локальные координаты участка: Y = 0 — верх плиты, -Z — фасад (смотрит на центр острова). +-- Каждый уровень добавляет дому размер, этажи или детали; надетая косметика меняет кусты, дверь, окна, +-- крышу и пол. + +local WIDTH = { 20, 22, 24, 26, 28, 28, 30, 32, 34, 36 } +local DEPTH = { 16, 18, 18, 20, 24, 24, 24, 26, 26, 26 } +local FLOORS = { 1, 1, 1, 1, 2, 2, 2, 3, 3, 3 } +local FLOOR_H = 12 -- высота этажа +local WALL = 1 -- толщина стен +local DOOR_H = 8 +local WIN_W, WIN_H, WIN_Y = 3.2, 3.6, 3.6 -- окно: ширина, высота, низ над полом этажа +local STAIR_W, STAIR_RISE, STAIR_RUN = 4, 1, 1.3 +local PLAT_H = 1.2 -- каменный постамент под домом +local FRONT_YARD = 16 -- от переднего края участка до фасада +local LAWN_LEVEL = 3 -- лужайка за домом открывается с этого уровня +Houses.LAWN_LEVEL = LAWN_LEVEL + +local function doorWOf(L) + return L >= 7 and 5 or 4.4 +end + +-- центр дома по Z: дом у передней части участка, сзади — место под лужайку +local function houseZ(d) + return -HC.PlotSize / 2 + FRONT_YARD + d / 2 +end + +-- лужайка за домом (fromZ — задний край постамента); до LAWN_LEVEL — закрытая земля с табличкой +local function lawn(m, base, level, fromZ) + local S = HC.PlotSize + local z0, z1 = fromZ + 4, S / 2 - 3 + local x0, x1 = -S / 2 + 3, S / 2 - 3 + local cz, dz, dx = (z0 + z1) / 2, z1 - z0, x1 - x0 + if level < LAWN_LEVEL then + part(m, base, Vector3.new(dx, 0.1, dz), CFrame.new(0, 0.05, cz), Color3.fromRGB(150, 120, 90), Enum.Material.Ground, { Name = "LawnLocked", CanCollide = false }) + part(m, base, Vector3.new(0.6, 4, 0.6), CFrame.new(0, 2, z0 + 3), Color3.fromRGB(90, 60, 38), Enum.Material.Wood, { Name = "LawnSignPost" }) + local board = part(m, base, Vector3.new(7, 2.6, 0.3), CFrame.new(0, 4.3, z0 + 2.8), Color3.fromRGB(150, 104, 62), Enum.Material.WoodPlanks, { Name = "LawnSign" }) + surfaceText(board, "🔒 Лужайка — с " .. LAWN_LEVEL .. " ур. дома") + return + end + local GRASS = Color3.fromRGB(86, 168, 72) + part(m, base, Vector3.new(dx, 0.3, dz), CFrame.new(0, 0.15, cz), GRASS, Enum.Material.Grass, { Name = "Lawn" }) + -- полосы покоса + local n = math.floor(dx / 8) + for k = 0, n - 1, 2 do + part(m, base, Vector3.new(8, 0.05, dz), CFrame.new(x0 + 4 + k * 8, 0.32, cz), Color3.fromRGB(104, 186, 86), Enum.Material.Grass, { Name = "LawnStripe", CanCollide = false }) + end + -- живая изгородь по трём сторонам + local HEDGE = Color3.fromRGB(48, 110, 52) + part(m, base, Vector3.new(dx, 2.2, 1.6), CFrame.new(0, 1.1, z1 - 0.8), HEDGE, Enum.Material.Grass, { Name = "Hedge" }) + for _, s in ipairs({ -1, 1 }) do + part(m, base, Vector3.new(1.6, 2.2, dz), CFrame.new(s * (dx / 2 - 0.8), 1.1, cz), HEDGE, Enum.Material.Grass, { Name = "Hedge" }) + -- деревья в задних углах + local tx, tz = s * (dx / 2 - 8), z1 - 8 + part(m, base, Vector3.new(1.4, 7, 1.4), CFrame.new(tx, 3.5, tz), Color3.fromRGB(110, 76, 46), Enum.Material.Wood, { Name = "TreeTrunk" }) + part(m, base, Vector3.new(9, 9, 9), CFrame.new(tx, 9.5, tz), Color3.fromRGB(60, 140, 62), Enum.Material.Grass, { Name = "TreeCrown", Shape = Enum.PartType.Ball }) + -- клумбы вдоль боков + local fx = s * (dx / 2 - 4) + part(m, base, Vector3.new(3, 0.6, dz * 0.45), CFrame.new(fx, 0.45, cz - dz * 0.1), Color3.fromRGB(110, 78, 50), Enum.Material.Ground, { Name = "FlowerBed" }) + for q = 0, math.floor(dz * 0.45 / 2.5) - 1 do + local col = ({ Color3.fromRGB(235, 80, 90), Color3.fromRGB(250, 210, 70), Color3.fromRGB(190, 110, 230), Color3.fromRGB(255, 255, 255) })[q % 4 + 1] + part(m, base, Vector3.new(0.8, 0.8, 0.8), CFrame.new(fx + ((q % 2 == 0) and -0.6 or 0.6), 1.05, cz - dz * 0.1 - dz * 0.225 + 1.2 + q * 2.5), col, Enum.Material.SmoothPlastic, + { Name = "Flower", Shape = Enum.PartType.Ball, CanCollide = false }) + end + end + -- скамейка посередине + local bz = cz + dz * 0.15 + part(m, base, Vector3.new(6, 0.4, 1.8), CFrame.new(0, 1.6, bz), Color3.fromRGB(150, 104, 62), Enum.Material.WoodPlanks, { Name = "BenchSeat" }) + part(m, base, Vector3.new(6, 1.6, 0.3), CFrame.new(0, 2.6, bz + 0.85), Color3.fromRGB(150, 104, 62), Enum.Material.WoodPlanks, { Name = "BenchBack" }) + for _, s in ipairs({ -1, 1 }) do + part(m, base, Vector3.new(0.4, 1.4, 1.6), CFrame.new(s * 2.6, 0.9, bz), Color3.fromRGB(60, 60, 64), Enum.Material.Metal, { Name = "BenchLeg" }) + end +end + +local function gableRoof(parent, base, cx, cz, w, d, y, h, color, material) + -- два клина: высокая сторона — к коньку (центру по X), скат — наружу + local half = w / 2 + 1 + for _, s in ipairs({ -1, 1 }) do + part(parent, base, Vector3.new(d + 2, h, half), CFrame.new(cx + s * half / 2, y + h / 2, cz) * CFrame.Angles(0, s < 0 and math.rad(90) or math.rad(-90), 0), + color, material, { class = "WedgePart", Name = "Roof" }) + end +end + +-- стена с проёмами. wcf — середина низа стены (локальная X — вдоль стены, Y — вверх, -Z — наружу); +-- openings — { x = центр, y = низ, w, h } в тех же локальных координатах. Стена режется на полосы по X, +-- в каждой полосе ставятся куски между проёмами. +local function wallWithOpenings(parent, base, wcf, length, height, openings, color, material, name) + local xs = { -length / 2, length / 2 } + for _, o in ipairs(openings) do + table.insert(xs, math.clamp(o.x - o.w / 2, -length / 2, length / 2)) + table.insert(xs, math.clamp(o.x + o.w / 2, -length / 2, length / 2)) + end + table.sort(xs) + for k = 1, #xs - 1 do + local a, b = xs[k], xs[k + 1] + if b - a > 0.01 then + local mid = (a + b) / 2 + local holes = {} + for _, o in ipairs(openings) do + if mid > o.x - o.w / 2 and mid < o.x + o.w / 2 then + table.insert(holes, o) + end + end + table.sort(holes, function(p, q) + return p.y < q.y + end) + local y = 0 + for _, o in ipairs(holes) do + if o.y - y > 0.01 then + part(parent, base, Vector3.new(b - a, o.y - y, WALL), wcf * CFrame.new(mid, (y + o.y) / 2, 0), color, material, { Name = name }) + end + y = math.max(y, o.y + o.h) + end + if height - y > 0.01 then + part(parent, base, Vector3.new(b - a, height - y, WALL), wcf * CFrame.new(mid, (y + height) / 2, 0), color, material, { Name = name }) + end + end + end +end + +-- перекрытие с проёмом под лестницу (rect и hole — {x0, x1, z0, z1}) +local function slabWithHole(parent, base, y, th, rect, hole, color, material, name) + local function piece(x0, x1, z0, z1) + if x1 - x0 > 0.01 and z1 - z0 > 0.01 then + part(parent, base, Vector3.new(x1 - x0, th, z1 - z0), CFrame.new((x0 + x1) / 2, y, (z0 + z1) / 2), color, material, { Name = name }) + end + end + if not hole then + piece(rect[1], rect[2], rect[3], rect[4]) + return + end + piece(rect[1], hole[1], rect[3], rect[4]) + piece(hole[2], rect[2], rect[3], rect[4]) + piece(hole[1], hole[2], rect[3], hole[3]) + piece(hole[1], hole[2], hole[4], rect[4]) +end + +-- стекло и рама в проёме: lcf — центр проёма на оси стены (-Z — наружу); style — предмет «Окна» +local windowIndex = 0 +local function windowAt(parent, base, lcf, w, h, style, depth) + windowIndex += 1 + depth = depth or WALL + local frameC = style.frame or Color3.fromRGB(92, 62, 40) + for _, side in ipairs({ -1, 1 }) do + local z = side * (depth / 2 + 0.06) + for _, sy in ipairs({ -1, 1 }) do + part(parent, base, Vector3.new(w + 0.7, 0.35, 0.15), lcf * CFrame.new(0, sy * (h / 2 + 0.12), z), frameC, Enum.Material.Wood, { Name = "WindowFrame", CanCollide = false }) + part(parent, base, Vector3.new(0.35, h, 0.15), lcf * CFrame.new(sy * (w / 2 + 0.12), 0, z), frameC, Enum.Material.Wood, { Name = "WindowFrame", CanCollide = false }) + end + end + local color = style.color + if style.rainbow then + color = Color3.fromHSV((windowIndex * 0.13) % 1, 0.65, 1) + end + part(parent, base, Vector3.new(w, h, 0.15), lcf, color, style.material, { Name = "Window", Transparency = style.transparency or 0, CastShadow = false }) + part(parent, base, Vector3.new(0.15, h, 0.2), lcf * CFrame.new(0, 0, -0.1), frameC, Enum.Material.Wood, { Name = "WindowBar", CanCollide = false }) + part(parent, base, Vector3.new(w, 0.15, 0.2), lcf * CFrame.new(0, 0, -0.1), frameC, Enum.Material.Wood, { Name = "WindowBar", CanCollide = false }) +end + +-- куст по предмету «Кусты» +local function bush(parent, base, pos, style) + local s = style.size + local shape = style.shape == "Block" and Enum.PartType.Block or Enum.PartType.Ball + local b = part(parent, base, Vector3.new(s, s, s), CFrame.new(pos + Vector3.new(0, s * 0.42, 0)), style.color, style.material, { Name = "Bush", Shape = shape }) + if style.flowers then + local c = pos + Vector3.new(0, s * 0.42, 0) + for k = 0, 6 do + local dir + if k == 6 then + dir = Vector3.new(0, 1, 0) + else + local a = k / 6 * math.pi * 2 + dir = Vector3.new(math.cos(a), 0.55 + (k % 2) * 0.35, math.sin(a)).Unit + end + part(parent, base, Vector3.new(0.7, 0.7, 0.7), CFrame.new(c + dir * (s * 0.5)), + style.flowers, style.glow and Enum.Material.Neon or Enum.Material.SmoothPlastic, { Name = "Blossom", Shape = Enum.PartType.Ball, CanCollide = false }) + end + end + if style.glow then + local pl = Instance.new("PointLight") + pl.Color = style.flowers or style.color + pl.Range = 8 + pl.Brightness = 0.8 + pl.Parent = b + end + return b +end + +-- надетая косметика игрока: { bush = item, door = item, … } (нет — стандарт) +local function equippedItems(data) + local out = {} + local cos = data and data.houseCos + if cos and cos.equip then + for catId, itemId in pairs(cos.equip) do + out[catId] = COS.item(catId, itemId) + end + end + return out +end + +-- компьютерный стол у задней стены (zb — внутренняя грань стены, y0 — пол) +local function computer(parent, base, x, zb, y0, plotIndex) + local desk = Color3.fromRGB(110, 74, 46) + local dark = Color3.fromRGB(36, 38, 44) + part(parent, base, Vector3.new(5, 0.3, 2.4), CFrame.new(x, y0 + 3, zb - 1.3), desk, Enum.Material.WoodPlanks, { Name = "Desk" }) + for _, sx in ipairs({ -1, 1 }) do + for _, sz in ipairs({ -1, 1 }) do + part(parent, base, Vector3.new(0.3, 2.85, 0.3), CFrame.new(x + sx * 2.2, y0 + 1.42, zb - 1.3 + sz * 0.95), desk, Enum.Material.Wood, { Name = "DeskLeg" }) + end + end + part(parent, base, Vector3.new(3.2, 2, 0.25), CFrame.new(x, y0 + 4.6, zb - 0.6), dark, Enum.Material.SmoothPlastic, { Name = "Monitor" }) + local screen = part(parent, base, Vector3.new(2.9, 1.7, 0.05), CFrame.new(x, y0 + 4.6, zb - 0.75), Color3.fromRGB(70, 200, 120), Enum.Material.Neon, { Name = "ComputerScreen", CanCollide = false }) + surfaceText(screen, "🏠 HOME", Color3.fromRGB(20, 40, 30), 50) + part(parent, base, Vector3.new(0.3, 1.2, 0.3), CFrame.new(x, y0 + 3.6, zb - 0.6), dark, Enum.Material.SmoothPlastic, { Name = "MonitorStand" }) + part(parent, base, Vector3.new(2.2, 0.12, 0.7), CFrame.new(x, y0 + 3.2, zb - 1.7), dark, Enum.Material.SmoothPlastic, { Name = "Keyboard" }) + part(parent, base, Vector3.new(1.2, 2.4, 1.6), CFrame.new(x + 3.4, y0 + 1.2, zb - 1.2), dark, Enum.Material.SmoothPlastic, { Name = "PcCase" }) + part(parent, base, Vector3.new(0.1, 0.3, 0.3), CFrame.new(x + 2.79, y0 + 2, zb - 1.9), Color3.fromRGB(70, 200, 120), Enum.Material.Neon, { Name = "PcLight", CanCollide = false }) + part(parent, base, Vector3.new(2, 0.3, 2), CFrame.new(x, y0 + 1.8, zb - 3.5), Color3.fromRGB(150, 40, 45), Enum.Material.Fabric, { Name = "ChairSeat" }) + part(parent, base, Vector3.new(2, 2.2, 0.3), CFrame.new(x, y0 + 3, zb - 4.4), Color3.fromRGB(150, 40, 45), Enum.Material.Fabric, { Name = "ChairBack" }) + part(parent, base, Vector3.new(0.4, 1.7, 0.4), CFrame.new(x, y0 + 0.85, zb - 3.5), dark, Enum.Material.Metal, { Name = "ChairLeg" }) + local pp = Instance.new("ProximityPrompt") + pp.ActionText = "Крутить улучшения" + pp.ObjectText = "💻 Компьютер" + pp.HoldDuration = 0 + pp.MaxActivationDistance = 9 + pp.RequiresLineOfSight = false + pp:SetAttribute("Action", "HouseComputer") + pp:SetAttribute("Plot", plotIndex or 0) + pp.Parent = screen +end + +function Houses.buildHouse(level, base, ownerName, plotIndex, equip) + equip = equip or {} + windowIndex = 0 + local m = Instance.new("Model") + m.Name = "House" + if level <= 0 then + -- пустой участок: разметка фундамента и колышки + local w, d = WIDTH[1], DEPTH[1] + local zc = houseZ(d) + for _, c in ipairs({ { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 } }) do + part(m, base, Vector3.new(0.5, 2, 0.5), CFrame.new(c[1] * w / 2, 1, zc + c[2] * d / 2), Color3.fromRGB(150, 110, 70), Enum.Material.Wood, { Name = "Stake" }) + end + part(m, base, Vector3.new(w, 0.15, d), CFrame.new(0, 0.08, zc), Color3.fromRGB(110, 84, 60), Enum.Material.Ground, { Name = "Outline", CanCollide = false }) + lawn(m, base, 0, zc + d / 2 + 3) + return m + end + + local L = math.clamp(level, 1, HC.MaxLevel) + local w, d = WIDTH[L], DEPTH[L] + local floors = FLOORS[L] + local bodyH = floors * FLOOR_H + local gold = L >= 10 + + -- палитра по эпохам: дерево (1–3), камень (4–6), светлый штукатур (7–10) + local wallColor, wallMat, roofColor, roofMat, trim + if L <= 3 then + wallColor, wallMat = Color3.fromRGB(168, 118, 74), Enum.Material.WoodPlanks + roofColor, roofMat = Color3.fromRGB(196, 164, 92), Enum.Material.Fabric + trim = Color3.fromRGB(96, 64, 40) + elseif L <= 6 then + wallColor, wallMat = Color3.fromRGB(176, 166, 150), Enum.Material.Brick + roofColor, roofMat = Color3.fromRGB(170, 70, 52), Enum.Material.Slate + trim = Color3.fromRGB(110, 76, 50) + else + wallColor, wallMat = Color3.fromRGB(238, 232, 220), Enum.Material.SmoothPlastic + roofColor, roofMat = Color3.fromRGB(58, 78, 120), Enum.Material.Slate + trim = gold and Color3.fromRGB(230, 184, 70) or Color3.fromRGB(120, 92, 64) + end + local trimMat = gold and Enum.Material.Metal or Enum.Material.Wood + + -- косметика (если надета) или стандарт + if equip.roof then + roofColor, roofMat = equip.roof.color, equip.roof.material + end + local windowStyle = equip.window or (L >= 7 and COS.item("window", "warm")) or COS.item("window", "clear") + local doorStyle = equip.door or COS.item("door", "oak") + local floorStyle = equip.floor or COS.item("floor", "planks") + local bushStyle = equip.bush or COS.item("bush", "green") + + local z0 = houseZ(d) -- дом у передней части участка, сзади лужайка + local front = z0 - d / 2 -- наружная грань фасада + local back = z0 + d / 2 + local inX0, inX1 = -w / 2 + WALL, w / 2 - WALL -- комната изнутри + local inZ0, inZ1 = front + WALL, back - WALL + + -- каменный постамент под всем домом (с крыльцом, флигелем и башней), переди — ступени + local base0 = base -- уровень земли участка: лужайка, сад, фонтан + local pxL = -w / 2 - (L >= 8 and 9 or 4) + local pxR = w / 2 + (L >= 6 and 13 or 4) + local pzF, pzB = front - 7.5, back + 3 + local pcx, pcz = (pxL + pxR) / 2, (pzF + pzB) / 2 + part(m, base0, Vector3.new(pxR - pxL, PLAT_H, pzB - pzF), CFrame.new(pcx, PLAT_H / 2, pcz), Color3.fromRGB(156, 150, 142), Enum.Material.Cobblestone, { Name = "Platform" }) + part(m, base0, Vector3.new(pxR - pxL + 1, 0.5, pzB - pzF + 1), CFrame.new(pcx, 0.25, pcz), Color3.fromRGB(100, 96, 92), Enum.Material.Slate, { Name = "PlatformTrim" }) + part(m, base0, Vector3.new(pxR - pxL + 0.4, 0.25, pzB - pzF + 0.4), CFrame.new(pcx, PLAT_H - 0.1, pcz), Color3.fromRGB(190, 184, 176), Enum.Material.Slate, { Name = "PlatformCap", CanCollide = false }) + for k, h in ipairs({ PLAT_H * 2 / 3, PLAT_H / 3 }) do + part(m, base0, Vector3.new(doorWOf(L) + 8 + k * 2, h, 1.2), CFrame.new(0, h / 2, pzF - 0.6 - (k - 1) * 1.2), Color3.fromRGB(140, 134, 128), Enum.Material.Slate, { Name = "PlatformStep" }) + end + lawn(m, base0, L, pzB) + base = base0 * CFrame.new(0, PLAT_H, 0) -- дальше дом стоит на постаменте + + -- фундамент (с 4-го — каменный цоколь) + local plinth = L >= 4 and 1.2 or 0.6 + part(m, base, Vector3.new(w + 1, plinth, d + 1), CFrame.new(0, plinth / 2, z0), L >= 4 and Color3.fromRGB(120, 116, 112) or Color3.fromRGB(110, 80, 52), + L >= 4 and Enum.Material.Cobblestone or Enum.Material.Wood, { Name = "Foundation" }) + local function floorY(f) -- уровень пола этажа f + return plinth + (f - 1) * FLOOR_H + end + + -- лестницы: пролёт f ведёт с этажа f на f+1, нечётные — у левой стены, чётные — у правой + local steps = math.floor(FLOOR_H / STAIR_RISE) - 1 + local run = steps * STAIR_RUN + local stairZ0 = inZ0 + 1.5 -- марш начинается у входа, чтобы наверху оставалась широкая площадка + local flights = {} + for f = 1, floors - 1 do + local side = (f % 2 == 1) and -1 or 1 + local x0 = side < 0 and inX0 or (inX1 - STAIR_W) + flights[f] = { side = side, x0 = x0, x1 = x0 + STAIR_W, z0 = stairZ0, z1 = stairZ0 + run } + end + + -- стены с проёмами: дверь и окна на каждом этаже + local doorW = doorWOf(L) + local perSide = w >= 30 and 3 or 2 + local frontOpen, leftOpen, rightOpen, backOpen = {}, {}, {}, {} + table.insert(frontOpen, { x = 0, y = 0, w = doorW, h = DOOR_H, door = true }) + local span = w / 2 - doorW / 2 - 1.5 + for f = 1, floors do + local y = (f - 1) * FLOOR_H + WIN_Y + for _, s in ipairs({ -1, 1 }) do + for k = 1, perSide do + local x = s * (doorW / 2 + 1 + (k - 0.5) * (span / perSide)) + table.insert(frontOpen, { x = x, y = y, w = WIN_W, h = WIN_H, floor = f }) + end + end + if f >= 2 then + table.insert(frontOpen, { x = 0, y = y, w = WIN_W, h = WIN_H, floor = f }) + end + -- боковые окна — кроме стороны, вдоль которой на этом этаже идёт лестница + local fl = flights[f] + for _, zc in ipairs({ z0 - d / 4, z0 + d / 4 }) do + if not (fl and fl.side < 0) then + table.insert(leftOpen, { x = -(zc - z0), y = y, w = WIN_W, h = WIN_H, z = zc }) + end + if not (fl and fl.side > 0) then + table.insert(rightOpen, { x = zc - z0, y = y, w = WIN_W, h = WIN_H, z = zc }) + end + end + if f >= 2 then + table.insert(backOpen, { x = 0, y = y, w = WIN_W, h = WIN_H }) + end + end + local frontCF = CFrame.new(0, plinth, front + WALL / 2) + local backCF = CFrame.new(0, plinth, back - WALL / 2) * CFrame.Angles(0, math.pi, 0) + local leftCF = CFrame.new(-w / 2 + WALL / 2, plinth, z0) * CFrame.Angles(0, math.rad(90), 0) + local rightCF = CFrame.new(w / 2 - WALL / 2, plinth, z0) * CFrame.Angles(0, math.rad(-90), 0) + wallWithOpenings(m, base, frontCF, w, bodyH, frontOpen, wallColor, wallMat, "WallFront") + wallWithOpenings(m, base, backCF, w - 0.01, bodyH, backOpen, wallColor, wallMat, "WallBack") + wallWithOpenings(m, base, leftCF, d - 2 * WALL, bodyH, leftOpen, wallColor, wallMat, "WallSide") + wallWithOpenings(m, base, rightCF, d - 2 * WALL, bodyH, rightOpen, wallColor, wallMat, "WallSide") + for _, list in ipairs({ { frontCF, frontOpen }, { backCF, backOpen }, { leftCF, leftOpen }, { rightCF, rightOpen } }) do + for _, o in ipairs(list[2]) do + if not o.door then + windowAt(m, base, list[1] * CFrame.new(o.x, o.y + o.h / 2, 0), o.w, o.h, windowStyle) + end + end + end + + -- полы и перекрытия (косметика «Пол»), проёмы над лестницами, лампы + local room = { inX0, inX1, inZ0, inZ1 } + part(m, base, Vector3.new(inX1 - inX0, 0.2, inZ1 - inZ0), CFrame.new(0, plinth + 0.1, z0), floorStyle.color, floorStyle.material, { Name = "Floor" }) + for f = 1, floors do + local top = floorY(f + 1) + if f < floors then + local fl = flights[f] + slabWithHole(m, base, top - 0.3, 0.6, room, { fl.x0, fl.x1, fl.z0, fl.z1 }, floorStyle.color, floorStyle.material, "Floor") + else + slabWithHole(m, base, top - 0.3, 0.6, room, nil, Color3.fromRGB(226, 214, 192), Enum.Material.WoodPlanks, "Ceiling") + end + local lamp = part(m, base, Vector3.new(1.6, 0.4, 1.6), CFrame.new(0, top - 0.8, z0 + 1), Color3.fromRGB(255, 230, 170), Enum.Material.Neon, { Name = "CeilingLamp", CanCollide = false }) + local pl = Instance.new("PointLight") + pl.Color = Color3.fromRGB(255, 225, 170) + pl.Range = math.max(w, d) + pl.Brightness = 1.4 + pl.Parent = lamp + end + -- пролёты лестниц и перила вокруг проёма наверху + local stairC = Color3.fromRGB(130, 90, 58) + for f, fl in pairs(flights) do + local yb = floorY(f) + (f == 1 and 0.2 or 0) + local cx = (fl.x0 + fl.x1) / 2 + for k = 1, steps do + local h = k * STAIR_RISE + part(m, base, Vector3.new(STAIR_W, h, STAIR_RUN), CFrame.new(cx, yb + h / 2, fl.z0 + (k - 0.5) * STAIR_RUN), stairC, Enum.Material.WoodPlanks, { Name = "Stair" }) + end + local yt = floorY(f + 1) + local innerX = fl.side < 0 and fl.x1 or fl.x0 + part(m, base, Vector3.new(0.3, 3, run), CFrame.new(innerX - fl.side * 0.15, yt + 1.5, (fl.z0 + fl.z1) / 2), trim, trimMat, { Name = "Railing" }) + part(m, base, Vector3.new(STAIR_W, 3, 0.3), CFrame.new(cx, yt + 1.5, fl.z0 + 0.15), trim, trimMat, { Name = "Railing" }) + -- поручень вдоль ступеней + local a = Vector3.new(innerX - fl.side * 0.15, yb + 3.5, fl.z0) + local b = Vector3.new(innerX - fl.side * 0.15, yb + 3.5 + steps * STAIR_RISE, fl.z1) + part(m, base, Vector3.new(0.25, 0.25, (b - a).Magnitude), CFrame.lookAt((a + b) / 2, b), trim, trimMat, { Name = "Handrail", CanCollide = false }) + end + -- компьютер у задней стены первого этажа + computer(m, base, 0, inZ1, plinth + 0.2, plotIndex) + + local top = plinth + bodyH + local yMid = plinth + bodyH / 2 + for _, c in ipairs({ { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 } }) do + part(m, base, Vector3.new(0.8, bodyH, 0.8), CFrame.new(c[1] * (w / 2), yMid, z0 + c[2] * (d / 2)), trim, trimMat, { Name = "Corner" }) + end + -- междуэтажный пояс — только полоски снаружи стен (не перекрывает лестничный проём) + for f = 2, floors do + local y = floorY(f) + for _, s in ipairs({ -1, 1 }) do + part(m, base, Vector3.new(w + 0.6, 0.6, 0.3), CFrame.new(0, y, (s < 0 and front or back) + s * 0.15), trim, trimMat, { Name = "Belt", CanCollide = false }) + part(m, base, Vector3.new(0.3, 0.6, d + 0.6), CFrame.new(s * (w / 2 + 0.15), y, z0), trim, trimMat, { Name = "Belt", CanCollide = false }) + end + end + part(m, base, Vector3.new(w + 0.6, 0.5, d + 0.6), CFrame.new(0, top - 0.25, z0), trim, trimMat, { Name = "Eave" }) + + -- дверь (косметика «Двери»): распахнута внутрь, стоит поперёк фасада у левого косяка + local doorFrame = doorStyle.frame or trim + for _, s in ipairs({ -1, 1 }) do + part(m, base, Vector3.new(0.4, DOOR_H, WALL + 0.3), CFrame.new(s * (doorW / 2 + 0.2), plinth + DOOR_H / 2, front + WALL / 2), doorFrame, trimMat, { Name = "DoorFrame" }) + end + part(m, base, Vector3.new(doorW + 0.8, 0.4, WALL + 0.3), CFrame.new(0, plinth + DOOR_H + 0.2, front + WALL / 2), doorFrame, trimMat, { Name = "DoorFrame" }) + local doorLeaf = doorW - 0.2 + part(m, base, Vector3.new(0.3, DOOR_H - 0.2, doorLeaf), CFrame.new(-doorW / 2 + 0.2, plinth + (DOOR_H - 0.2) / 2, inZ0 + doorLeaf / 2), + doorStyle.color, doorStyle.material, { Name = "Door", CanCollide = false, Transparency = doorStyle.transparency or 0 }) + part(m, base, Vector3.new(0.3, 0.3, 0.3), CFrame.new(-doorW / 2 + 0.45, plinth + 3.6, inZ0 + doorLeaf - 0.6), Color3.fromRGB(230, 190, 90), Enum.Material.Metal, { Name = "Knob", CanCollide = false }) + + -- цветочные ящики под окнами первого этажа (с 4-го) + if L >= 4 then + for _, o in ipairs(frontOpen) do + if o.floor == 1 then + local y = plinth + o.y - 0.4 + part(m, base, Vector3.new(o.w + 0.4, 0.6, 0.8), CFrame.new(o.x, y, front - 0.5), Color3.fromRGB(120, 76, 44), Enum.Material.WoodPlanks, { Name = "FlowerBox", CanCollide = false }) + for q = -1, 1 do + part(m, base, Vector3.new(0.6, 0.6, 0.6), CFrame.new(o.x + q * 1, y + 0.5, front - 0.5), ({ Color3.fromRGB(235, 80, 90), Color3.fromRGB(250, 210, 70), Color3.fromRGB(190, 110, 230) })[q + 2], + Enum.Material.SmoothPlastic, { Name = "Flower", Shape = Enum.PartType.Ball, CanCollide = false }) + end + end + end + end + + -- крыша (косметика «Крыша») + local roofH = math.max(5, w * 0.32) + gableRoof(m, base, 0, z0, w, d, top, roofH, roofColor, roofMat) + part(m, base, Vector3.new(0.6, 0.6, d + 2.2), CFrame.new(0, top + roofH, z0), trim, trimMat, { Name = "Ridge" }) + + -- 2+: дымоход + if L >= 2 then + local cx = w / 4 + part(m, base, Vector3.new(2.4, roofH + 3, 2.4), CFrame.new(cx, top + (roofH + 3) / 2, z0 + d / 4), Color3.fromRGB(140, 80, 64), Enum.Material.Brick, { Name = "Chimney" }) + part(m, base, Vector3.new(3, 0.4, 3), CFrame.new(cx, top + roofH + 3.2, z0 + d / 4), Color3.fromRGB(90, 86, 84), Enum.Material.Slate, { Name = "ChimneyCap" }) + end + + -- крыльцо: ступенька, с 3-го — настил с навесом + if L >= 3 then + local pw = doorW + 7 + part(m, base, Vector3.new(pw, plinth, 5), CFrame.new(0, plinth / 2, front - 2.5), Color3.fromRGB(130, 92, 60), Enum.Material.WoodPlanks, { Name = "Porch" }) + part(m, base, Vector3.new(doorW + 1, plinth / 2, 1.2), CFrame.new(0, plinth / 4, front - 5.6), Color3.fromRGB(120, 116, 112), Enum.Material.Slate, { Name = "Step" }) + for _, s in ipairs({ -1, 1 }) do + part(m, base, Vector3.new(0.7, DOOR_H + 0.8, 0.7), CFrame.new(s * (pw / 2 - 0.5), plinth + (DOOR_H + 0.8) / 2, front - 4.6), trim, trimMat, { Name = "PorchPost" }) + end + part(m, base, Vector3.new(pw + 1, 0.5, 5.6), CFrame.new(0, plinth + DOOR_H + 1, front - 2.6), roofColor, roofMat, { Name = "PorchRoof" }) + else + part(m, base, Vector3.new(doorW + 1, plinth / 2, 1.4), CFrame.new(0, plinth / 4, front - 0.7), Color3.fromRGB(120, 116, 112), Enum.Material.Slate, { Name = "Step" }) + end + + -- кусты у фасада (косметика «Кусты») + for _, s in ipairs({ -1, 1 }) do + bush(m, base, Vector3.new(s * (w / 2 - 1.5), 0, front - 3), bushStyle) + end + + -- 6+: флигель справа + if L >= 6 then + local ww, wd, wh = 9, d - 6, FLOOR_H + local wx = w / 2 + ww / 2 + part(m, base, Vector3.new(ww, plinth, wd + 1), CFrame.new(wx, plinth / 2, z0 + 1), Color3.fromRGB(120, 116, 112), Enum.Material.Cobblestone, { Name = "WingFoundation" }) + part(m, base, Vector3.new(ww, wh, wd), CFrame.new(wx, plinth + wh / 2, z0 + 1), wallColor, wallMat, { Name = "Wing" }) + windowAt(m, base, CFrame.new(wx, plinth + WIN_Y + WIN_H / 2, z0 + 1 - wd / 2), WIN_W, WIN_H, windowStyle, 0.4) + gableRoof(m, base, wx, z0 + 1, ww, wd, plinth + wh, 3.6, roofColor, roofMat) + end + + -- 7+: балкон над крыльцом и фонари у двери + if L >= 7 then + local by = floorY(2) + part(m, base, Vector3.new(doorW + 7, 0.5, 3), CFrame.new(0, by + 0.25, front - 1.5), trim, trimMat, { Name = "Balcony" }) + part(m, base, Vector3.new(doorW + 7, 1.4, 0.3), CFrame.new(0, by + 1.2, front - 2.9), trim, trimMat, { Name = "BalconyRail" }) + for _, s in ipairs({ -1, 1 }) do + local l = part(m, base, Vector3.new(0.7, 1, 0.7), CFrame.new(s * (doorW / 2 + 1.2), plinth + 6.5, front - 0.5), Color3.fromRGB(255, 214, 120), Enum.Material.Neon, { Name = "Lamp", CanCollide = false }) + local lp = Instance.new("PointLight") + lp.Color = Color3.fromRGB(255, 200, 120) + lp.Range = 14 + lp.Brightness = 1.2 + lp.Parent = l + end + end + + -- 8+: башня слева сзади (снаружи, чтобы не занимать комнаты) + local towerTop = nil + if L >= 8 then + local r = 8 + local tx, tz = -w / 2 - r / 2 + 0.6, back - r / 2 + local th = bodyH + roofH + 4 + part(m, base, Vector3.new(th, r, r), CFrame.new(tx, plinth + th / 2, tz) * CFrame.Angles(0, 0, math.rad(90)), wallColor, wallMat, { Name = "Tower", Shape = Enum.PartType.Cylinder }) + local y = plinth + th + for k, rr in ipairs({ 9, 7, 5, 3, 1.4 }) do + part(m, base, Vector3.new(1.6, rr, rr), CFrame.new(tx, y + 0.8 + (k - 1) * 1.6, tz) * CFrame.Angles(0, 0, math.rad(90)), roofColor, roofMat, { Name = "TowerRoof", Shape = Enum.PartType.Cylinder }) + end + towerTop = Vector3.new(tx, y + 8, tz) + windowAt(m, base, CFrame.new(tx, plinth + th - 5, tz - r / 2), 2, 3, windowStyle, 0.4) + end + + -- 9+: сад — изгородь по краю участка, кусты, дорожка к двери + if L >= 9 then + local S = HC.PlotSize / 2 - 1 + local fenceC = gold and Color3.fromRGB(240, 236, 228) or Color3.fromRGB(150, 104, 62) + local function fence(a, b) + local len = (b - a).Magnitude + local mid = (a + b) / 2 + part(m, base0, Vector3.new(0.4, 0.5, len), CFrame.lookAt(mid + Vector3.new(0, 2, 0), b + Vector3.new(0, 2, 0)), fenceC, Enum.Material.Wood, { Name = "Fence" }) + part(m, base0, Vector3.new(0.4, 0.5, len), CFrame.lookAt(mid + Vector3.new(0, 1, 0), b + Vector3.new(0, 1, 0)), fenceC, Enum.Material.Wood, { Name = "Fence" }) + local n = math.floor(len / 4) + for i = 0, n do + part(m, base0, Vector3.new(0.7, 2.8, 0.7), CFrame.new(a:Lerp(b, i / n) + Vector3.new(0, 1.4, 0)), fenceC, Enum.Material.Wood, { Name = "FencePost" }) + end + end + local gate = 4 + fence(Vector3.new(-S, 0, -S), Vector3.new(-gate, 0, -S)) + fence(Vector3.new(gate, 0, -S), Vector3.new(S, 0, -S)) + fence(Vector3.new(S, 0, -S), Vector3.new(S, 0, S)) + fence(Vector3.new(S, 0, S), Vector3.new(-S, 0, S)) + fence(Vector3.new(-S, 0, S), Vector3.new(-S, 0, -S)) + local pathEnd = pzF - 3 + for i = 0, 4 do + part(m, base0, Vector3.new(3.2, 0.2, 2.2), CFrame.new((i % 2 == 0) and 0.4 or -0.4, 0.1, -S + 2 + i * ((pathEnd + S - 2) / 4)), Color3.fromRGB(160, 156, 150), Enum.Material.Slate, { Name = "PathStone", CanCollide = false }) + end + for _, p in ipairs({ Vector3.new(-S + 4, 0, -S + 5), Vector3.new(-S + 10, 0, -S + 3.5), Vector3.new(S - 4, 0, -S + 5), Vector3.new(S - 10, 0, -S + 3.5) }) do + bush(m, base0, p, bushStyle) + end + end + + -- 10: дворец — фонтан, флаги, золотые шпили + if gold then + -- фонтан — на лужайке за домом + local fz = pzB + 16 + local fx = 0 + part(m, base0, Vector3.new(1.4, 10, 10), CFrame.new(fx, 1, fz) * CFrame.Angles(0, 0, math.rad(90)), Color3.fromRGB(200, 196, 190), Enum.Material.Marble, { Name = "Fountain", Shape = Enum.PartType.Cylinder }) + part(m, base0, Vector3.new(0.3, 9, 9), CFrame.new(fx, 1.6, fz) * CFrame.Angles(0, 0, math.rad(90)), Color3.fromRGB(70, 160, 230), Enum.Material.Glass, { Name = "FountainWater", Shape = Enum.PartType.Cylinder, Transparency = 0.2, CanCollide = false }) + part(m, base0, Vector3.new(4, 1.4, 1.4), CFrame.new(fx, 3.4, fz) * CFrame.Angles(0, 0, math.rad(90)), Color3.fromRGB(230, 184, 70), Enum.Material.Metal, { Name = "FountainPillar", Shape = Enum.PartType.Cylinder }) + local function flag(pos, color) + part(m, base, Vector3.new(0.3, 6, 0.3), CFrame.new(pos + Vector3.new(0, 3, 0)), Color3.fromRGB(230, 184, 70), Enum.Material.Metal, { Name = "FlagPole" }) + part(m, base, Vector3.new(0.1, 2, 3), CFrame.new(pos + Vector3.new(0, 4.8, 1.6)), color, Enum.Material.Fabric, { Name = "Flag", CanCollide = false }) + end + flag(Vector3.new(0, top + roofH, z0), Color3.fromRGB(80, 200, 110)) + if towerTop then + flag(towerTop, Color3.fromRGB(220, 60, 60)) + end + for _, s in ipairs({ -1, 1 }) do + part(m, base, Vector3.new(1, 1, 1), CFrame.new(s * (w / 2), top + 1, front), Color3.fromRGB(255, 214, 120), Enum.Material.Neon, { Name = "GoldFinial", Shape = Enum.PartType.Ball, CanCollide = false }) + end + end + + -- табличка с именем хозяина над дверью + if ownerName then + local plate = part(m, base, Vector3.new(9, 1.3, 0.2), CFrame.new(0, plinth + (L >= 3 and DOOR_H + 2.1 or DOOR_H + 1.2), front - 0.12), trim, trimMat, { Name = "NamePlate", CanCollide = false }) + surfaceText(plate, ownerName) + end + return m +end + +---------------------------------------------------------------- владение участками + +local function houseFolder(i) + local isl = island() + return isl and folder(folder(isl, "Houses"), "Plot_" .. i) +end + +local function rebuild(i) + pendingRebuild[i] = nil + local f = houseFolder(i) + if not f then + return + end + f:ClearAllChildren() + local owner = owners[i] + if owner then + local data = deps.profiles[owner] + local house = Houses.buildHouse(data and data.houseLevel or 0, HC.plotCFrame(i) * CFrame.new(0, SLAB_H, 0), owner.DisplayName, i, equippedItems(data)) + house.Name = "House_" .. owner.Name + house.Parent = f + end + setLabels(i) +end + +local function release(player) + local i = plotOf[player] + if i then + plotOf[player] = nil + owners[i] = nil + player:SetAttribute("HousePlot", nil) + rebuild(i) + end +end + +local function assign(player) + for i = 1, HC.Plots do + if not owners[i] then + owners[i] = player + plotOf[player] = i + player:SetAttribute("HousePlot", i) + rebuild(i) + local data = deps.profiles[player] + local lvl = data and data.houseLevel or 0 + deps.notify(player, lvl > 0 and ("🏠 Твой дом — участок " .. i .. ". Заходи: внутри компьютер с улучшениями!") + or ("🏠 Твой участок — №" .. i .. ". Построй дом у таблички!"), GREEN) + return true + end + end + return false +end + +---------------------------------------------------------------- косметика: состояние для клиента + +local function cosState(data) + local owned, equip = {}, {} + for catId, set in pairs(data.houseCos.owned) do + local list = {} + for id in pairs(set) do + table.insert(list, id) + end + owned[catId] = list + end + for catId, id in pairs(data.houseCos.equip) do + equip[catId] = id + end + return { owned = owned, equip = equip } +end + +local function sendCos(player, open) + local data = deps.profiles[player] + if data then + deps.remote:FireClient(player, open and "OpenHouseComputer" or "HouseCos", cosState(data)) + end +end +Houses.sendCos = sendCos + +---------------------------------------------------------------- API для GameServer + +function Houses.init(d) + deps = d + Houses.ensurePlots() + for i = 1, HC.Plots do + rebuild(i) + end + Players.PlayerRemoving:Connect(function(p) + release(p) + warnedFull[p] = nil + spinCooldown[p] = nil + end) + -- кто на острове — получает участок, кто ушёл — освобождает + task.spawn(function() + while true do + task.wait(1) + for _, p in ipairs(Players:GetPlayers()) do + local hrp = p.Character and p.Character:FindFirstChild("HumanoidRootPart") + local here = hrp ~= nil and HC.onIsland(hrp.Position, plotOf[p] and 120 or 30) + if here and not plotOf[p] and deps.profiles[p] then + if not assign(p) and not warnedFull[p] then + warnedFull[p] = true + deps.notify(p, "🏠 Все участки на острове заняты. Загляни позже!", RED) + end + elseif not here and plotOf[p] and hrp then + release(p) + end + if not here then + warnedFull[p] = nil + end + end + end + end) +end + +-- старые сохранения — без полей; чистим предметы, которых больше нет в HouseCosmetics +function Houses.defaults(data) + local lv = tonumber(data.houseLevel) or 0 + data.houseLevel = math.clamp(math.floor(lv), 0, HC.MaxLevel) + if type(data.houseCos) ~= "table" then + data.houseCos = {} + end + local cos = data.houseCos + cos.owned = type(cos.owned) == "table" and cos.owned or {} + cos.equip = type(cos.equip) == "table" and cos.equip or {} + for _, cat in ipairs(COS.Categories) do + local set = type(cos.owned[cat.id]) == "table" and cos.owned[cat.id] or {} + for id in pairs(set) do + if not cat.byId[id] then + set[id] = nil + end + end + cos.owned[cat.id] = set + if cos.equip[cat.id] and not set[cos.equip[cat.id]] then + cos.equip[cat.id] = nil + end + end +end + +-- табличка участка: свой — открыть панель, чужой — подсказка +function Houses.onPrompt(player, prompt) + local i = prompt:GetAttribute("Plot") + local owner = i and owners[i] + if owner == player then + deps.remote:FireClient(player, "OpenHouse") + elseif owner then + local data = deps.profiles[owner] + local lvl = data and data.houseLevel or 0 + deps.notify(player, ("🏠 Дом %s — ур. %d (%s)"):format(owner.DisplayName, lvl, HC.name(lvl)), Color3.fromRGB(236, 220, 180)) + else + deps.notify(player, "🏠 Свободный участок", Color3.fromRGB(236, 220, 180)) + end +end + +-- компьютер в доме: крутить может только хозяин +function Houses.onComputer(player, prompt) + local i = prompt:GetAttribute("Plot") + local owner = i and owners[i] + if owner == player then + sendCos(player, true) + else + deps.notify(player, "💻 Это чужой компьютер — улучшения крутятся в своём доме", RED) + end +end + +-- покупка следующего уровня +function Houses.upgrade(player) + local data = deps.profiles[player] + if not data then + return + end + local i = plotOf[player] + if not i then + deps.notify(player, "🏠 Улучшать дом можно только на острове «Мой дом»", RED) + return + end + local nextLv = (data.houseLevel or 0) + 1 + if nextLv > HC.MaxLevel then + deps.notify(player, "🏠 У тебя уже максимальный уровень дома!", GOLD) + return + end + local cost = HC.cost(nextLv) + if not deps.spendCoins(player, data, cost, "House", "HouseLevel" .. nextLv) then + deps.notify(player, "Не хватает серебра", RED) + return + end + data.houseLevel = nextLv + deps.updateStats(player) + rebuild(i) + deps.notify(player, ("🏠 Дом улучшен: ур. %d — %s!"):format(nextLv, HC.name(nextLv)), GOLD) +end + +-- крутка категории catId, count раз (1 или 10). Результат сразу в профиле; клиент показывает +-- анимацию, а дом перестраивается после неё (SPIN_REVEAL секунд). +function Houses.spin(player, catId, count) + local data = deps.profiles[player] + local cat = type(catId) == "string" and COS.category(catId) + count = tonumber(count) + if not data or not cat or not count or not table.find(COS.SpinCounts, count) then + return + end + local now = os.clock() + if (spinCooldown[player] or 0) > now then + return + end + spinCooldown[player] = now + 1 + local i = plotOf[player] + if not i or (data.houseLevel or 0) < 1 then + deps.notify(player, "💻 Крутить улучшения можно за компьютером в своём доме", RED) + return + end + local cost = cat.cost * count + if not deps.spendCoins(player, data, cost, "HouseSpin", cat.id .. "x" .. count) then + deps.notify(player, "Не хватает серебра", RED) + return + end + local owned = data.houseCos.owned[cat.id] + local results, newOnes, refund = {}, 0, 0 + local best = nil + for _ = 1, count do + local it = COS.roll(cat.id, rng) + local isNew = not owned[it.id] + if isNew then + owned[it.id] = true + newOnes += 1 + if not best or COS.Rarities[it.rarity].rank > COS.Rarities[best.rarity].rank then + best = it + end + else + refund += cat.cost * COS.DuplicateRefund + end + table.insert(results, { id = it.id, new = isNew }) + end + if refund > 0 then + deps.addCoins(player, data, refund, "HouseSpinRefund") + end + -- новая вещь редче надетой (или ничего не надето) — на дом, когда анимация закончится + local cur = COS.item(cat.id, data.houseCos.equip[cat.id]) + if best and (not cur or COS.Rarities[best.rarity].rank > COS.Rarities[cur.rarity].rank) then + data.houseCos.equip[cat.id] = best.id + if not pendingRebuild[i] then + pendingRebuild[i] = true + task.delay(Houses.SPIN_REVEAL, function() + if pendingRebuild[i] then + rebuild(i) + end + end) + end + end + deps.updateStats(player) + -- клиент сам покажет итог после анимации и потом обновит строки по новому состоянию + deps.remote:FireClient(player, "HouseSpinResult", cat.id, results, math.floor(refund), cosState(data)) + -- лента на экране компьютера в доме — видна всем, кто рядом (останавливается на самом редком) + local show = results[1].id + for _, r in ipairs(results) do + if COS.Rarities[cat.byId[r.id].rarity].rank > COS.Rarities[cat.byId[show].rarity].rank then + show = r.id + end + end + deps.remote:FireAllClients("HouseScreenSpin", i, cat.id, show) +end + +-- у игрока закончилась анимация крутки — показать новый вид дома +function Houses.reveal(player) + local i = plotOf[player] + if i and pendingRebuild[i] then + rebuild(i) + end +end + +-- надеть предмет (itemId = nil — вернуть стандарт) +function Houses.equip(player, catId, itemId) + local data = deps.profiles[player] + local cat = type(catId) == "string" and COS.category(catId) + if not data or not cat then + return + end + if itemId ~= nil and (type(itemId) ~= "string" or not data.houseCos.owned[cat.id][itemId]) then + return + end + data.houseCos.equip[cat.id] = itemId + local i = plotOf[player] + if i then + rebuild(i) + end + sendCos(player, false) +end + +return Houses diff --git a/src/StarterPlayer/StarterPlayerScripts/FishingClient.client.lua b/src/StarterPlayer/StarterPlayerScripts/FishingClient.client.lua index f373173..eaf67cd 100644 --- a/src/StarterPlayer/StarterPlayerScripts/FishingClient.client.lua +++ b/src/StarterPlayer/StarterPlayerScripts/FishingClient.client.lua @@ -2552,7 +2552,7 @@ local function teleportLoading(targetId, delay) loadingGui:SetAttribute("Ready", false) loadingGui:SetAttribute("StartAt", now) loadingGui:SetAttribute("MinUntil", now + Config.Loading.teleport) - loadingGui:SetAttribute("Title", placeTitle(target)) + loadingGui:SetAttribute("Title", targetId == "Home" and "🏠 Мой дом" or placeTitle(target)) loadingGui:SetAttribute("Visible", true) end task.spawn(function() @@ -2562,7 +2562,18 @@ local function teleportLoading(targetId, delay) repeat task.wait() w = currentWorld() - until (w and w.id or "Lobby") == targetId or os.clock() > deadline or token ~= teleportToken + local arrived + if targetId == "Home" then + -- остров «Мой дом» не мир из Config: ждём, пока персонаж окажется рядом с его спавном + local island = workspace:FindFirstChild("Island2") + local spawnPart = island and island:FindFirstChild("HomeSpawn") + local char = Players.LocalPlayer.Character + local hrp = char and char:FindFirstChild("HumanoidRootPart") + arrived = spawnPart ~= nil and hrp ~= nil and (hrp.Position - spawnPart.Position).Magnitude < 300 + else + arrived = (w and w.id or "Lobby") == targetId + end + until arrived or os.clock() > deadline or token ~= teleportToken if token ~= teleportToken then return end diff --git a/src/StarterPlayer/StarterPlayerScripts/HouseClient.client.lua b/src/StarterPlayer/StarterPlayerScripts/HouseClient.client.lua new file mode 100644 index 0000000..4ef2901 --- /dev/null +++ b/src/StarterPlayer/StarterPlayerScripts/HouseClient.client.lua @@ -0,0 +1,689 @@ +-- HouseClient (LocalScript) -> StarterPlayer > StarterPlayerScripts +-- Остров «Мой дом», клиент: +-- • окно «Мой дом» (уровень дома, улучшение) — у таблички участка ("OpenHouse"); +-- • окно «Компьютер» — категории HouseCosmetics строками с шансами, кнопки крутки ("OpenHouseComputer"); +-- • открытие как в кейсах: на весь экран, по ленте на каждую крутку, линия со стрелками по центру, +-- «Катиться быстрее» и автоматическое вращение ("HouseSpinResult"); +-- • та же лента на экране компьютера в доме — видна всем игрокам ("HouseScreenSpin"). +-- Стиль окон — Theme.kit из FishingClient. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local TweenService = game:GetService("TweenService") +local RunService = game:GetService("RunService") +local Lighting = game:GetService("Lighting") + +local player = Players.LocalPlayer +local HC = require(ReplicatedStorage:WaitForChild("HouseConfig")) +local COS = require(ReplicatedStorage:WaitForChild("HouseCosmetics")) +local Theme = require(script.Parent:WaitForChild("UiTheme")) +local remote = ReplicatedStorage:WaitForChild("GameEvent") +local okAudio, Audio = pcall(function() + return require(script.Parent:WaitForChild("Audio", 5)) +end) + +while not Theme.kit do + task.wait(0.1) +end +local K = Theme.kit +local C = Theme.C +local new, text, btn, corner, stroke, gradient = K.new, K.text, K.btn, K.corner, K.stroke, K.gradient +local fmt = K.fmt +local TITLE = K.TITLE +local CENTER = Enum.TextXAlignment.Center +local RIGHT = Enum.TextXAlignment.Right +local WHITE = Color3.new(1, 1, 1) +local GREEN = Color3.fromRGB(70, 140, 70) + +local function sound(name) + if okAudio and Audio then + pcall(Audio.play, name) + end +end + +-- своя кнопка «закрыть» в правом верхнем углу (рисованная печать окна не всегда загружается) +local function closeButton(parent, onClick, z) + local b = btn({ Name = "CloseX", Size = UDim2.fromOffset(42, 42), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 10), BackgroundColor3 = C.crimson, + Text = "✕", TextSize = 24, TextColor3 = C.goldBright, ZIndex = z or 60, Parent = parent }, onClick) + if Theme.unskin then + Theme.unskin(b) + end + local c = b:FindFirstChildOfClass("UICorner") + if c then + c.CornerRadius = UDim.new(1, 0) + end + Theme.pressFx(b) + return b +end + +local function card(list, order, height, strokeColor) + return new("Frame", { Size = UDim2.new(1, -4, 0, height), BackgroundColor3 = WHITE, LayoutOrder = order, Parent = list }, + { corner(8), stroke(strokeColor or C.goldDark, 2, 0), gradient(C.woodLight, C.wood, 90) }) +end + +local function clearList(list) + for _, c in ipairs(list:GetChildren()) do + if c:IsA("GuiObject") then + c:Destroy() + end + end +end + +-- образец предмета: цветной квадрат или шар (кусты), у радужных — градиент +local function swatch(parent, cat, it, props) + local r = COS.Rarities[it.rarity] + local sw = new("Frame", props) + sw.BackgroundColor3 = it.color + corner(cat.id == "bush" and it.shape == "Ball" and 999 or 6).Parent = sw + stroke(r.color, 2, 0).Parent = sw + if it.rainbow then + new("UIGradient", { Color = ColorSequence.new({ + ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 90, 90)), ColorSequenceKeypoint.new(0.33, Color3.fromRGB(255, 230, 90)), + ColorSequenceKeypoint.new(0.66, Color3.fromRGB(90, 220, 255)), ColorSequenceKeypoint.new(1, Color3.fromRGB(220, 110, 255)), + }), Parent = sw }) + end + sw.Parent = props.Parent + return sw +end + +---------------------------------------------------------------- окно «Мой дом»: уровень и улучшение + +local win = K.makeWindow("🏠 Мой дом", GREEN, { { id = "house", label = "🏠 Дом" } }) +local list = K.scrollArea(win.pages.house) +closeButton(win.frame, function() + win.close() +end) + +local function render() + clearList(list) + local lvl = player:GetAttribute("HouseLevel") or 0 + local coins = player:GetAttribute("Coins") or 0 + local plot = player:GetAttribute("HousePlot") + + local head = card(list, 1, 96, C.gold) + text({ Size = UDim2.new(1, -24, 0, 30), Position = UDim2.fromOffset(12, 8), Font = TITLE, TextSize = 24, TextColor3 = C.goldBright, + Text = ("Ур. %d · %s"):format(lvl, HC.name(lvl)), Parent = head }) + text({ Size = UDim2.new(1, -24, 0, 20), Position = UDim2.fromOffset(12, 38), TextSize = 15, TextColor3 = C.muted, + Text = plot and ("Участок №" .. plot .. " на острове") or "Участок выдаётся на острове «Мой дом»", Parent = head }) + text({ Size = UDim2.new(0, 220, 0, 20), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 38), TextSize = 15, TextXAlignment = RIGHT, + TextColor3 = C.silver, Text = ("%s %s"):format(fmt(coins), Theme.SILVER), Parent = head }) + local bar = new("Frame", { Size = UDim2.new(1, -24, 0, 14), Position = UDim2.fromOffset(12, 68), BackgroundColor3 = C.dark, Parent = head }, + { corner(7), stroke(C.goldDark, 1.5, 0) }) + new("Frame", { Size = UDim2.fromScale(lvl / HC.MaxLevel, 1), BackgroundColor3 = Color3.fromRGB(110, 200, 110), BorderSizePixel = 0, Parent = bar }, { corner(7) }) + text({ Size = UDim2.fromScale(1, 1), TextSize = 12, TextXAlignment = CENTER, Font = TITLE, Text = lvl .. " / " .. HC.MaxLevel, + TextStrokeTransparency = 0.4, TextStrokeColor3 = C.ink, Parent = bar }) + + if lvl < HC.MaxLevel then + local nextLv = lvl + 1 + local cost = HC.cost(nextLv) + local can = coins >= cost and plot ~= nil + local up = card(list, 2, 74, Color3.fromRGB(110, 200, 110)) + text({ Size = UDim2.new(1, -230, 0, 26), Position = UDim2.fromOffset(12, 10), Font = TITLE, TextSize = 20, TextColor3 = C.text, + Text = ("Следующий: ур. %d · %s"):format(nextLv, HC.name(nextLv)), Parent = up }) + text({ Size = UDim2.new(1, -230, 0, 22), Position = UDim2.fromOffset(12, 40), TextSize = 16, TextColor3 = can and C.silver or Color3.fromRGB(255, 138, 122), + Text = ("Цена: %s %s"):format(fmt(cost), Theme.SILVER), Parent = up }) + local b = btn({ Size = UDim2.fromOffset(200, 48), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -12, 0.5, 0), + BackgroundColor3 = can and GREEN or C.grey, Text = can and "Улучшить" or (plot and "Мало серебра" or "Нет участка"), TextSize = 20, Parent = up }, function() + remote:FireServer("HouseUpgrade") + end) + b.AutoButtonColor = can + Theme.pressFx(b) + else + local done = card(list, 2, 52, C.goldBright) + text({ Size = UDim2.fromScale(1, 1), Font = TITLE, TextSize = 20, TextXAlignment = CENTER, TextColor3 = C.goldBright, + Text = "👑 Максимальный уровень дома!", Parent = done }) + end + + for i = 1, HC.MaxLevel do + local owned = i <= lvl + local isNext = i == lvl + 1 + local row = card(list, 10 + i, 40, owned and Color3.fromRGB(110, 200, 110) or (isNext and C.gold or C.goldDark)) + if not owned and not isNext then + row.BackgroundTransparency = 0.35 + end + text({ Size = UDim2.new(0, 46, 1, 0), Position = UDim2.fromOffset(10, 0), Font = TITLE, TextSize = 18, + TextColor3 = owned and Color3.fromRGB(160, 240, 160) or C.goldBright, Text = owned and "✔" or tostring(i), Parent = row }) + text({ Size = UDim2.new(1, -260, 1, 0), Position = UDim2.fromOffset(50, 0), TextSize = 17, TextColor3 = owned and C.text or C.muted, + Text = ("Ур. %d · %s"):format(i, HC.name(i)), Parent = row }) + text({ Size = UDim2.new(0, 220, 1, 0), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 0), TextSize = 16, TextXAlignment = RIGHT, + TextColor3 = owned and Color3.fromRGB(160, 240, 160) or C.silver, Text = owned and "куплено" or (fmt(HC.cost(i)) .. " " .. Theme.SILVER), Parent = row }) + end +end +win.render = render + +---------------------------------------------------------------- окно «Компьютер»: категории строками с шансами +-- Нажать на полученный предмет — надеть (ещё раз — вернуть стандарт). + +local cos = { owned = {}, equip = {} } -- последнее состояние от сервера +local lastSpin = {} -- [категория] = { [id] = сколько выпало в последней крутке } +local spinning = false -- идёт открытие: строки не перерисовываем, повторно не крутим + +local pcWin = K.makeWindow("💻 Компьютер", Color3.fromRGB(70, 200, 120), { { id = "spin", label = "🎲 Улучшения" } }) +local pcList = K.scrollArea(pcWin.pages.spin) +closeButton(pcWin.frame, function() + pcWin.close() +end) + +local function ownedSet(catId) + local set = {} + for _, id in ipairs(cos.owned[catId] or {}) do + set[id] = true + end + return set +end + +local function requestSpin(catId, n) + if spinning then + return + end + local cat = COS.category(catId) + if (player:GetAttribute("Coins") or 0) < cat.cost * n then + K.notify("Не хватает серебра", Color3.fromRGB(255, 120, 120)) + return + end + spinning = true -- снимется, когда закроется открытие (или сервер не ответит) + remote:FireServer("HouseSpin", catId, n) + task.delay(3, function() + if spinning and not (player.PlayerGui:FindFirstChild("HouseSpinGui") and player.PlayerGui.HouseSpinGui.Enabled) then + spinning = false + end + end) +end + +local function renderPc() + clearList(pcList) + local coins = player:GetAttribute("Coins") or 0 + text({ Size = UDim2.new(1, -4, 0, 24), LayoutOrder = 0, TextSize = 15, TextColor3 = C.muted, Parent = pcList, + Text = ("Твоё серебро: %s %s · повтор возвращает %d%% цены · нажми на свой предмет, чтобы надеть"):format(fmt(coins), Theme.SILVER, COS.DuplicateRefund * 100) }) + for ci, cat in ipairs(COS.Categories) do + local owned = ownedSet(cat.id) + local equipped = cos.equip[cat.id] + local row = new("Frame", { Size = UDim2.new(1, -4, 0, 196), BackgroundColor3 = WHITE, LayoutOrder = ci, Parent = pcList }, + { corner(8), stroke(C.goldDark, 2, 0), gradient(C.woodLight, C.wood, 90) }) + local have = 0 + for _ in pairs(owned) do + have += 1 + end + local btnW = 118 + local btnsW = #COS.SpinCounts * (btnW + 8) + text({ Size = UDim2.new(1, -(btnsW + 24), 0, 30), Position = UDim2.fromOffset(12, 8), Font = TITLE, TextSize = 21, TextColor3 = C.goldBright, + Text = ("%s %s"):format(cat.icon, cat.name), Parent = row }) + text({ Size = UDim2.new(1, -(btnsW + 24), 0, 18), Position = UDim2.fromOffset(12, 36), TextSize = 14, TextColor3 = C.muted, TextTruncate = Enum.TextTruncate.AtEnd, + Text = ("Собрано %d / %d · надето: %s"):format(have, #cat.items, equipped and cat.byId[equipped] and cat.byId[equipped].name or "стандарт"), Parent = row }) + for bi, n in ipairs(COS.SpinCounts) do + local cost = cat.cost * n + local can = coins >= cost + local b = btn({ Size = UDim2.fromOffset(btnW, 44), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12 - (#COS.SpinCounts - bi) * (btnW + 8), 0, 8), + BackgroundColor3 = can and GREEN or C.grey, TextSize = 14, TextWrapped = true, + Text = ("Открыть %d\n%s %s"):format(n, fmt(cost), Theme.SILVER), Parent = row }, function() + requestSpin(cat.id, n) + end) + b.AutoButtonColor = can + Theme.pressFx(b) + end + local tiles = new("Frame", { Size = UDim2.new(1, -24, 0, 126), Position = UDim2.fromOffset(12, 60), BackgroundTransparency = 1, Parent = row }, { + new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder }), + }) + local n = #cat.items + for ii, it in ipairs(cat.items) do + local r = COS.Rarities[it.rarity] + local has = owned[it.id] == true + local on = equipped == it.id + local tile = new("TextButton", { Size = UDim2.new(1 / n, -6 + 6 / n, 1, 0), BackgroundColor3 = C.dark, BackgroundTransparency = has and 0.1 or 0.45, + AutoButtonColor = has, Text = "", LayoutOrder = ii, Parent = tiles }, { corner(8), stroke(on and C.goldBright or r.color, on and 3.5 or 2, has and 0 or 0.35) }) + local sw = swatch(tile, cat, it, { Size = UDim2.fromOffset(46, 46), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 8), + BackgroundTransparency = has and 0 or 0.4, Parent = tile }) + if not has then + text({ Size = UDim2.fromScale(1, 1), TextXAlignment = CENTER, TextSize = 22, Font = TITLE, Text = "?", TextColor3 = WHITE, TextStrokeTransparency = 0.3, TextStrokeColor3 = C.ink, Parent = sw }) + end + text({ Size = UDim2.new(1, -8, 0, 30), Position = UDim2.fromOffset(4, 56), TextSize = 12, TextWrapped = true, TextXAlignment = CENTER, + TextColor3 = has and C.text or C.muted, Text = it.name, Parent = tile }) + text({ Size = UDim2.new(1, -8, 0, 22), Position = UDim2.fromOffset(4, 86), Font = TITLE, TextSize = 18, TextXAlignment = CENTER, + TextColor3 = r.color, TextStrokeColor3 = C.ink, TextStrokeTransparency = 0.3, Text = COS.chanceText(it.chance), Parent = tile }) + text({ Size = UDim2.new(1, -8, 0, 14), Position = UDim2.fromOffset(4, 108), TextSize = 11, TextXAlignment = CENTER, + TextColor3 = on and C.goldBright or (has and Color3.fromRGB(160, 240, 160) or C.muted), + Text = on and "Надето" or (has and "есть" or r.name), Parent = tile }) + local got = lastSpin[cat.id] and lastSpin[cat.id][it.id] + if got then + text({ Size = UDim2.fromOffset(40, 18), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -4, 0, 4), BackgroundTransparency = 0, BackgroundColor3 = Color3.fromRGB(70, 160, 70), + TextSize = 12, Font = TITLE, TextXAlignment = CENTER, Text = "+" .. got, Parent = tile }) + end + if has then + tile.MouseButton1Click:Connect(function() + remote:FireServer("HouseEquip", cat.id, (not on) and it.id or nil) + end) + end + end + end +end +pcWin.render = function() + if not spinning then + renderPc() + end +end + +---------------------------------------------------------------- плитка ленты (как в кейсах): тёмная карточка, цветная полоса редкости снизу + +local function reelTile(parent, cat, it, w, h, x, y, z, small) + local r = COS.Rarities[it.rarity] + -- привязка по центру: UIScale увеличивает выпавший лот симметрично, линия остаётся по его центру + local t = new("Frame", { Name = "Tile", Size = UDim2.fromOffset(w, h), AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromOffset(x + w / 2, y + h / 2), + BackgroundColor3 = WHITE, BorderSizePixel = 0, ZIndex = z, Parent = parent }) + local g = new("UIGradient", { Color = ColorSequence.new(Color3.fromRGB(44, 44, 52), Color3.fromRGB(16, 16, 20)), Rotation = 90, Parent = t }) + local st = new("UIStroke", { Color = Color3.fromRGB(70, 70, 82), Thickness = small and 1 or 1.5, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = t }) + new("Frame", { Name = "RarityBar", Size = UDim2.new(1, 0, 0, small and 3 or 4), AnchorPoint = Vector2.new(0, 1), Position = UDim2.fromScale(0, 1), BackgroundColor3 = r.color, + BorderSizePixel = 0, ZIndex = z + 2, Parent = t }) + local s = math.floor(h * 0.48) + swatch(t, cat, it, { Size = UDim2.fromOffset(s, s), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, math.floor(h * 0.1)), ZIndex = z + 1, Parent = t }) + new("TextLabel", { Size = UDim2.new(1, -8, 0, math.floor(h * 0.2)), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -(small and 4 or 6)), BackgroundTransparency = 1, + Font = K.BODY, TextScaled = true, TextColor3 = Color3.fromRGB(225, 225, 230), Text = it.name, ZIndex = z + 1, Parent = t }) + return t, g, st +end + +-- выпавшая плитка: светлая «подсветка», рамка редкости, увеличение +local function highlight(tile, g, st, it) + local r = COS.Rarities[it.rarity] + g.Color = ColorSequence.new({ + ColorSequenceKeypoint.new(0, Color3.fromRGB(150, 185, 215)), + ColorSequenceKeypoint.new(0.45, Color3.fromRGB(60, 86, 112)), + ColorSequenceKeypoint.new(1, Color3.fromRGB(18, 22, 30)), + }) + st.Color = Color3.fromRGB(235, 235, 240) + st.Thickness = 2.5 + tile.RarityBar.BackgroundColor3 = r.color + tile.ZIndex += 5 + for _, d in ipairs(tile:GetDescendants()) do + if d:IsA("GuiObject") then + d.ZIndex += 5 + end + end + local sc = new("UIScale", { Parent = tile }) + TweenService:Create(sc, TweenInfo.new(0.3, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1.14 }):Play() +end + +---------------------------------------------------------------- открытие на весь экран + +local settings = { fast = false, auto = false } +local spinGui = new("ScreenGui", { Name = "HouseSpinGui", IgnoreGuiInset = true, ResetOnSpawn = false, DisplayOrder = 60, Enabled = false, + ZIndexBehavior = Enum.ZIndexBehavior.Sibling, Parent = player:WaitForChild("PlayerGui") }) +local blur = Lighting:FindFirstChild("HouseSpinBlur") or new("BlurEffect", { Name = "HouseSpinBlur", Size = 0, Enabled = false, Parent = Lighting }) +local shade = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.fromRGB(6, 6, 8), BackgroundTransparency = 0.25, Active = true, Parent = spinGui }) +new("UIGradient", { Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0.25), NumberSequenceKeypoint.new(0.5, 0.05), NumberSequenceKeypoint.new(1, 0.25) }), Parent = shade }) +local spinTitle = text({ Size = UDim2.new(1, 0, 0, 44), Position = UDim2.new(0, 0, 0, 92), Font = TITLE, TextSize = 32, TextXAlignment = CENTER, TextColor3 = WHITE, + TextStrokeTransparency = 0.4, TextStrokeColor3 = Color3.new(0, 0, 0), Text = "", ZIndex = 5, Parent = spinGui }) + +-- верхние кнопки: автовращение (жёлтая), «Катиться быстрее» (зелёная), закрыть +local function flatButton(props, color) + local b = new("TextButton", props) + b.BackgroundColor3 = color + b.AutoButtonColor = true + b.Font = Enum.Font.FredokaOne + if Theme.FACES and Theme.FACES[TITLE] then + b.FontFace = Theme.FACES[TITLE] + end + b.TextColor3 = WHITE + b.TextStrokeTransparency = 0.2 + b.TextStrokeColor3 = Color3.fromRGB(20, 20, 20) + corner(6).Parent = b + new("UIStroke", { Color = Color3.fromRGB(255, 255, 255), Transparency = 0.6, Thickness = 2, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = b }) + new("UIGradient", { Color = ColorSequence.new(Color3.fromRGB(255, 255, 255), Color3.fromRGB(200, 200, 200)), Rotation = 90, Parent = b }) + b.MouseButton1Click:Connect(function() + sound("click") + end) + return b +end +local autoBtn = flatButton({ Size = UDim2.fromOffset(250, 52), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.33, 0, 0, 24), TextSize = 18, TextWrapped = true, ZIndex = 6, Parent = spinGui }, + Color3.fromRGB(245, 190, 30)) +local fastBtn = flatButton({ Size = UDim2.fromOffset(240, 58), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -86, 0, 22), TextSize = 22, ZIndex = 6, Parent = spinGui }, + Color3.fromRGB(60, 190, 70)) +local function paintToggles() + autoBtn.Text = "Автоматическое вращение: " .. (settings.auto and "включено" or "выключено") + autoBtn.BackgroundColor3 = settings.auto and Color3.fromRGB(255, 150, 30) or Color3.fromRGB(245, 190, 30) + fastBtn.Text = settings.fast and "Быстро: включено" or "Катиться быстрее" + fastBtn.BackgroundColor3 = settings.fast and Color3.fromRGB(40, 150, 60) or Color3.fromRGB(60, 190, 70) +end +paintToggles() +autoBtn.MouseButton1Click:Connect(function() + settings.auto = not settings.auto + paintToggles() +end) +fastBtn.MouseButton1Click:Connect(function() + settings.fast = not settings.fast + paintToggles() +end) + +-- область лент, линия по центру и стрелки +local reelArea = new("Frame", { Size = UDim2.new(1, -120, 0.62, 0), AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.52), BackgroundTransparency = 1, Parent = spinGui }) +local rowsHolder = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundTransparency = 1, Parent = reelArea }) +local centerLine = new("Frame", { Size = UDim2.new(0, 3, 1, 0), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.fromScale(0.5, 0), BackgroundColor3 = Color3.fromRGB(12, 12, 12), + BorderSizePixel = 0, ZIndex = 30, Parent = reelArea }) +local arrowTop = text({ Size = UDim2.fromOffset(70, 60), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 0, 0), Font = Enum.Font.GothamBold, TextSize = 64, + TextXAlignment = CENTER, TextColor3 = WHITE, TextStrokeTransparency = 0, TextStrokeColor3 = Color3.fromRGB(20, 20, 20), Text = "▼", ZIndex = 31, Parent = reelArea }) +local arrowBottom = text({ Size = UDim2.fromOffset(70, 60), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 1, 0), Font = Enum.Font.GothamBold, TextSize = 64, + TextXAlignment = CENTER, TextColor3 = WHITE, TextStrokeTransparency = 0, TextStrokeColor3 = Color3.fromRGB(20, 20, 20), Text = "▲", ZIndex = 31, Parent = reelArea }) + +local resultText = text({ Size = UDim2.new(1, -40, 0, 34), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -86), Font = TITLE, TextSize = 26, TextXAlignment = CENTER, + TextColor3 = WHITE, TextStrokeTransparency = 0.4, TextStrokeColor3 = Color3.new(0, 0, 0), Text = "", ZIndex = 5, Parent = spinGui }) +local bottomBar = new("Frame", { Size = UDim2.new(1, 0, 0, 56), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -22), BackgroundTransparency = 1, ZIndex = 5, Parent = spinGui }, { + new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, HorizontalAlignment = Enum.HorizontalAlignment.Center, Padding = UDim.new(0, 14), SortOrder = Enum.SortOrder.LayoutOrder }), +}) +local skipBtn = flatButton({ Size = UDim2.fromOffset(200, 52), TextSize = 22, Text = "Пропустить", LayoutOrder = 1, ZIndex = 6, Parent = bottomBar }, Color3.fromRGB(90, 90, 100)) +local takeBtn = flatButton({ Size = UDim2.fromOffset(200, 52), TextSize = 22, Text = "Забрать", LayoutOrder = 2, ZIndex = 6, Parent = bottomBar }, Color3.fromRGB(60, 190, 70)) +local againBtn = flatButton({ Size = UDim2.fromOffset(220, 52), TextSize = 22, Text = "Ещё", LayoutOrder = 3, ZIndex = 6, Parent = bottomBar }, Color3.fromRGB(70, 110, 200)) + +local current = nil -- текущее открытие: { catId, results, refund, state, rows, finished, token } +local spinToken = 0 + +local function setBlur(on) + blur.Enabled = true + TweenService:Create(blur, TweenInfo.new(0.25), { Size = on and 18 or 0 }):Play() + if not on then + task.delay(0.3, function() + if not spinGui.Enabled then + blur.Enabled = false + end + end) + end +end + +local function closeSpin() + spinToken += 1 + spinGui.Enabled = false + setBlur(false) + spinning = false + if current then + cos = current.state or cos + lastSpin = {} + local counts = {} + for _, x in ipairs(current.results) do + counts[x.id] = (counts[x.id] or 0) + 1 + end + lastSpin[current.catId] = counts + if not current.revealed then + remote:FireServer("HouseReveal") + end + current = nil + end + pcWin.refresh() +end +closeButton(spinGui, function() + if current and not current.finished then + current.skip() + end + closeSpin() +end, 40) + +-- все ленты остановились: итог, кнопки, автовращение +local function onAllStopped(cur) + cur.finished = true + cur.revealed = true + remote:FireServer("HouseReveal") + local cat = COS.category(cur.catId) + local newCount = 0 + for _, x in ipairs(cur.results) do + if x.new then + newCount += 1 + end + end + if #cur.results == 1 then + local it = cat.byId[cur.results[1].id] + local r = COS.Rarities[it.rarity] + resultText.Text = ("%s · %s%s"):format(it.name, r.name, cur.results[1].new and " · НОВИНКА!" or (" · повтор, +" .. fmt(cur.refund) .. " " .. Theme.SILVER)) + resultText.TextColor3 = r.color + else + resultText.Text = ("Новых: %d · за повторы +%s %s"):format(newCount, fmt(cur.refund), Theme.SILVER) + resultText.TextColor3 = newCount > 0 and C.goldBright or WHITE + end + sound("open") + skipBtn.Visible = false + takeBtn.Visible = true + againBtn.Visible = true + againBtn.Text = ("Ещё %d · %s %s"):format(#cur.results, fmt(cat.cost * #cur.results), Theme.SILVER) + -- автовращение: через мгновение ещё раз, пока хватает серебра + if settings.auto then + local token = spinToken + task.delay(settings.fast and 0.8 or 1.5, function() + if token ~= spinToken or not settings.auto or not current or not current.finished then + return + end + if (player:GetAttribute("Coins") or 0) < cat.cost * #cur.results then + settings.auto = false + paintToggles() + resultText.Text = "Автовращение остановлено: не хватает серебра" + return + end + local catId, n = cur.catId, #cur.results + closeSpin() + requestSpin(catId, n) + end) + end +end + +takeBtn.MouseButton1Click:Connect(closeSpin) +againBtn.MouseButton1Click:Connect(function() + if current then + local catId, n = current.catId, #current.results + closeSpin() + requestSpin(catId, n) + end +end) +skipBtn.MouseButton1Click:Connect(function() + if current and not current.finished then + current.skip() + end +end) + +local reelRng = Random.new() + +local function playSpin(catId, results, refund, state) + local cat = COS.category(catId) + if not cat or #results == 0 then + cos = state or cos + spinning = false + return + end + spinning = true + spinToken += 1 + local token = spinToken + for _, c in ipairs(rowsHolder:GetChildren()) do + c:Destroy() + end + local cur = { catId = catId, results = results, refund = refund, state = state, finished = false, revealed = false } + current = cur + spinTitle.Text = ("%s %s%s"):format(cat.icon, cat.name, #results > 1 and (" ×" .. #results) or "") + resultText.Text = "" + skipBtn.Visible = true + takeBtn.Visible = false + againBtn.Visible = false + spinGui.Enabled = true + setBlur(true) + sound("open") + RunService.Heartbeat:Wait() + + -- размеры: строки делят высоту области, плитки — полтора высоты строки. + -- Размер области считаем от экрана: AbsoluteSize только что включённого ScreenGui ещё не пересчитан. + local vpSize = workspace.CurrentCamera.ViewportSize + local area = Vector2.new(vpSize.X - 120, vpSize.Y * 0.62) + local rows = #results + local gap = rows > 3 and 8 or 40 + local rowH = math.min(170, (area.Y - gap * (rows - 1)) / rows) + local tileH = math.floor(rowH * 0.84) + local tileW = math.floor(tileH * 1.5) + local step = tileW + math.max(4, math.floor(tileW * 0.04)) + local total = rows * rowH + (rows - 1) * gap + local y0 = (area.Y - total) / 2 + centerLine.Size = UDim2.new(0, 3, 0, total + 20) + centerLine.Position = UDim2.new(0.5, 0, 0, y0 - 10) + arrowTop.Position = UDim2.new(0.5, 0, 0, y0 - 6) + arrowBottom.Position = UDim2.new(0.5, 0, 0, y0 + total + 6) + arrowTop.TextSize = math.clamp(rowH * 0.5, 34, 64) + arrowBottom.TextSize = arrowTop.TextSize + + local N, TI = 54, 47 + local baseTime = settings.fast and 1.5 or 4.6 + local stagger = settings.fast and 0.06 or 0.22 + local reels = {} + local stopped = 0 + for k, res in ipairs(results) do + local row = new("Frame", { Size = UDim2.new(1, 0, 0, rowH), Position = UDim2.fromOffset(0, y0 + (k - 1) * (rowH + gap)), BackgroundTransparency = 1, + ClipsDescendants = true, Parent = rowsHolder }) + local strip = new("Frame", { Size = UDim2.fromOffset(step * N, rowH), BackgroundTransparency = 1, Parent = row }) + local win1 = cat.byId[res.id] + local tiles = {} + for j = 1, N do + local it = (j == TI) and win1 or COS.roll(catId, reelRng) + local t, g, st = reelTile(strip, cat, it, tileW, tileH, (j - 1) * step, (rowH - tileH) / 2, 2, rows > 3) + tiles[j] = { t = t, g = g, st = st, it = it } + end + -- позиция ленты отсчитывается от центра строки (Scale 0.5) — выпавшая плитка всегда под линией + local finalX = -((TI - 1) * step + tileW / 2) -- линия ровно по центру выпавшего лота + strip.Position = UDim2.new(0.5, -tileW * 2, 0, 0) + local tw = TweenService:Create(strip, TweenInfo.new(baseTime + (k - 1) * stagger, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), { Position = UDim2.new(0.5, finalX, 0, 0) }) + local reel = { strip = strip, tween = tw, finalX = finalX, tiles = tiles, done = false } + reels[k] = reel + local function stop() + if reel.done or token ~= spinToken then + return + end + reel.done = true + tw:Cancel() + strip.Position = UDim2.new(0.5, finalX, 0, 0) + local w = tiles[TI] + highlight(w.t, w.g, w.st, w.it) + stopped += 1 + if stopped == #results then + onAllStopped(cur) + end + end + reel.stop = stop + tw.Completed:Connect(stop) + tw:Play() + end + -- щелчок, когда под линией проходит новая плитка (по первой ленте) + local lastIdx = -1 + local conn + conn = RunService.RenderStepped:Connect(function() + if token ~= spinToken or reels[1].done then + conn:Disconnect() + return + end + local idx = math.floor(-reels[1].strip.Position.X.Offset / step) + if idx ~= lastIdx then + lastIdx = idx + sound("click") + end + end) + cur.skip = function() + for _, r in ipairs(reels) do + r.stop() + end + end +end + +---------------------------------------------------------------- лента на экране компьютера в доме (видна всем) + +local SCREEN_PPS = 110 -- пикселей на стад: экран 2.9 × 1.7 → ~320 × 187 + +local function screenSpin(plot, catId, targetId) + local cat = COS.category(catId) + local isl = workspace:FindFirstChild("Island2") + local f = cat and isl and isl:FindFirstChild("Houses") and isl.Houses:FindFirstChild("Plot_" .. tostring(plot)) + local screen = f and f:FindFirstChild("ComputerScreen", true) + if not screen or not cat.byId[targetId] then + return + end + local old = screen:FindFirstChild("ReelGui") + if old then + old:Destroy() + end + local home = nil + for _, g in ipairs(screen:GetChildren()) do + if g:IsA("SurfaceGui") and g.Name ~= "ReelGui" then + home = g + g.Enabled = false + end + end + local sg = new("SurfaceGui", { Name = "ReelGui", Face = Enum.NormalId.Front, SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud, PixelsPerStud = SCREEN_PPS, + LightInfluence = 0, ZIndexBehavior = Enum.ZIndexBehavior.Sibling, Parent = screen }) + local W, H = screen.Size.X * SCREEN_PPS, screen.Size.Y * SCREEN_PPS + local bg = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.fromRGB(14, 14, 18), BorderSizePixel = 0, Parent = sg }) + new("TextLabel", { Size = UDim2.new(1, 0, 0, H * 0.16), Position = UDim2.fromOffset(0, H * 0.02), BackgroundTransparency = 1, Font = Enum.Font.GothamBold, TextScaled = true, + TextColor3 = WHITE, Text = cat.icon .. " " .. cat.name, Parent = bg }) + local rowH = H * 0.62 + local row = new("Frame", { Size = UDim2.new(1, 0, 0, rowH), Position = UDim2.fromOffset(0, H * 0.2), BackgroundTransparency = 1, ClipsDescendants = true, Parent = bg }) + local tileH = math.floor(rowH * 0.86) + local tileW = math.floor(tileH * 1.3) + local step = tileW + 4 + local N, TI = 34, 28 + local strip = new("Frame", { Size = UDim2.fromOffset(step * N, rowH), BackgroundTransparency = 1, Parent = row }) + local winTile + for j = 1, N do + local it = (j == TI) and cat.byId[targetId] or COS.roll(catId, reelRng) + local t, g, st = reelTile(strip, cat, it, tileW, tileH, (j - 1) * step, (rowH - tileH) / 2, 2, true) + if j == TI then + winTile = { t = t, g = g, st = st, it = it } + end + end + new("Frame", { Size = UDim2.new(0, 2, 0, rowH + 10), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, H * 0.2 - 5), BackgroundColor3 = WHITE, BorderSizePixel = 0, ZIndex = 20, Parent = bg }) + local label = new("TextLabel", { Size = UDim2.new(1, -10, 0, H * 0.14), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -2), BackgroundTransparency = 1, + Font = Enum.Font.GothamBold, TextScaled = true, TextColor3 = Color3.fromRGB(200, 200, 210), Text = "Крутим…", Parent = bg }) + local finalX = -((TI - 1) * step + tileW / 2) + strip.Position = UDim2.new(0.5, -tileW * 2, 0, 0) + local tw = TweenService:Create(strip, TweenInfo.new(4, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), { Position = UDim2.new(0.5, finalX, 0, 0) }) + tw.Completed:Connect(function() + if not sg.Parent then + return + end + highlight(winTile.t, winTile.g, winTile.st, winTile.it) + local r = COS.Rarities[winTile.it.rarity] + label.Text = winTile.it.name + label.TextColor3 = r.color + task.delay(4, function() + if sg.Parent then + sg:Destroy() + if home and home.Parent then + home.Enabled = true + end + end + end) + end) + tw:Play() +end + +---------------------------------------------------------------- события от сервера + +pcWin.frame:GetPropertyChangedSignal("Visible"):Connect(function() + if not pcWin.frame.Visible and spinGui.Enabled and current and current.finished then + closeSpin() + end +end) + +remote.OnClientEvent:Connect(function(action, a, b, c, d) + if action == "OpenHouse" then + win.open("house") + task.defer(function() + list.CanvasPosition = Vector2.zero + end) + elseif action == "OpenHouseComputer" then + cos = a + lastSpin = {} + pcWin.open("spin") + task.defer(function() + pcList.CanvasPosition = Vector2.zero + end) + elseif action == "HouseCos" then + cos = a + pcWin.refresh() + elseif action == "HouseSpinResult" then + playSpin(a, b, c or 0, d) + elseif action == "HouseScreenSpin" then + screenSpin(a, b, c) + end +end) + +for _, attr in ipairs({ "HouseLevel", "Coins", "HousePlot" }) do + player:GetAttributeChangedSignal(attr):Connect(function() + win.refresh() + pcWin.refresh() + end) +end diff --git a/tools/dump-place-scripts.js b/tools/dump-place-scripts.js new file mode 100644 index 0000000..0611013 --- /dev/null +++ b/tools/dump-place-scripts.js @@ -0,0 +1,36 @@ +// Dumps every script in a .rbxlx (with its full instance path) into a folder, +// so place scripts can be compared with src/. +// usage: node tools/dump-place-scripts.js place.rbxlx outDir +'use strict'; +const fs = require('fs'); +const path = require('path'); + +const [,, inP, outDir] = process.argv; +const text = fs.readFileSync(inP, 'latin1'); +const NAME_RE = /([^<]*)<\/string>/; +const TOKEN_RE = /|<\/Item>/g; +const stack = []; +const seen = new Map(); +let m; +fs.mkdirSync(outDir, { recursive: true }); +while ((m = TOKEN_RE.exec(text))) { + if (m[0] === '') { stack.pop(); continue; } + const cls = m[1]; + const ps = text.indexOf('', m.index); + const pe = text.indexOf('', ps); + const props = text.slice(ps, pe); + const nm = NAME_RE.exec(props.replace(//g, '')); + const name = nm ? Buffer.from(nm[1], 'latin1').toString('utf8') : '(' + cls + ')'; + stack.push(name); + if (cls === 'Script' || cls === 'LocalScript' || cls === 'ModuleScript') { + const sm = /<\/ProtectedString>/.exec(props) + || /([\s\S]*?)<\/ProtectedString>/.exec(props); + const src = sm ? Buffer.from(sm[1], 'latin1').toString('utf8') : ''; + let rel = stack.join('__').replace(/[\\/:*?"<>|]/g, '_') + '.' + cls + '.lua'; + const n = (seen.get(rel) || 0) + 1; seen.set(rel, n); + if (n > 1) rel = rel.replace(/\.lua$/, '.dup' + n + '.lua'); + fs.writeFileSync(path.join(outDir, rel), src); + } + TOKEN_RE.lastIndex = pe; +} +console.log('dumped', [...seen.values()].reduce((a, b) => a + b, 0), 'scripts to', outDir);