билборды
This commit is contained in:
1 parent
0972c05e3d
commit
15c64d9eb2
9 files changed
+1759
-83
No files matched your search
+877
-53
File diff suppressed because it is too large.
Load diff
@@ -30,13 +30,17 @@ local function feed(kind, info)
|
||||
remote:FireAllClients("Feed", kind, info)
|
||||
end
|
||||
|
||||
pcall(function()
|
||||
MessagingService:SubscribeAsync(FEED_TOPIC, function(msg)
|
||||
local d = msg.Data
|
||||
if type(d) == "table" and d.jobId ~= game.JobId then
|
||||
d.remote = true -- улов на другом сервере
|
||||
feed("catch", d)
|
||||
end
|
||||
-- подписка — в фоне: SubscribeAsync ждёт ответа сервиса (в неопубликованном плейсе — долго),
|
||||
-- а скрипт должен сразу дойти до загрузки игроков, телепортов и остального
|
||||
task.spawn(function()
|
||||
pcall(function()
|
||||
MessagingService:SubscribeAsync(FEED_TOPIC, function(msg)
|
||||
local d = msg.Data
|
||||
if type(d) == "table" and d.jobId ~= game.JobId then
|
||||
d.remote = true -- улов на другом сервере
|
||||
feed("catch", d)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -320,6 +324,9 @@ local function updateStats(player)
|
||||
player:SetAttribute("BoostLeft", math.max(0, data.boostUntil - os.time()))
|
||||
player:SetAttribute("TotalCaught", data.totalCaught)
|
||||
player:SetAttribute("CoinsEarned", data.coinsEarned)
|
||||
-- когда откроется следующая ежедневная награда (0 — уже доступна); по ней сундук в лобби прыгает только для тех,
|
||||
-- кому есть что забрать
|
||||
player:SetAttribute("DailyNextAt", data.daily.last >= today() and (data.daily.last + 1) * 86400 or 0)
|
||||
player:SetAttribute("RobuxSpent", data.robuxSpent)
|
||||
-- шаг обучения (линия-подсказка); у старых игроков без поля, уже ловивших рыбу, обучение пройдено
|
||||
player:SetAttribute("Tutorial", data.tutorial or (data.totalCaught > 0 and Config.TutorialDone or 0))
|
||||
|
||||
@@ -1939,6 +1939,7 @@ local function spawnNpc(spot, parent)
|
||||
return nil
|
||||
end
|
||||
rig.Name = name
|
||||
rig:SetAttribute("Npc", true) -- по нему клиент находит NPC (взгляд на игрока, приветствие), сервер — включает idle
|
||||
local hum = rig:FindFirstChildOfClass("Humanoid")
|
||||
hum.DisplayName = name
|
||||
hum.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
|
||||
@@ -1985,6 +1986,12 @@ local function spawnNpc(spot, parent)
|
||||
elderPart(V(1.0, 0.75, 0.35), CFrame.new(0, -0.55, -0.5), colors.hat)
|
||||
elderPart(V(0.32, 0.3, 0.08), CFrame.new(0.22, 0.12, -0.6), Color3.fromRGB(20, 20, 22))
|
||||
elderPart(V(1.24, 0.08, 1.24), CFrame.new(0, 0.18, 0) * CFrame.Angles(0, 0, math.rad(-12)), Color3.fromRGB(20, 20, 22))
|
||||
elseif spot:GetAttribute("Look") == "Scarf" then
|
||||
-- платок (цвет HatColor): макушка и узелок сзади
|
||||
local s = hatPart(V(1.3, 0.5, 1.3), CFrame.new(0, 0.42, 0.05), Enum.PartType.Block)
|
||||
s.Material = Enum.Material.SmoothPlastic
|
||||
local k = hatPart(V(0.4, 0.4, 0.3), CFrame.new(0, 0.05, 0.62), Enum.PartType.Block)
|
||||
k.Material = Enum.Material.SmoothPlastic
|
||||
else
|
||||
hatPart(V(0.15, 2.0, 2.0), CFrame.new(0, 0.55, 0) * CFrame.Angles(0, 0, math.rad(90)), Enum.PartType.Cylinder)
|
||||
hatPart(V(0.6, 1.35, 1.35), CFrame.new(0, 0.85, 0) * CFrame.Angles(0, 0, math.rad(90)), Enum.PartType.Cylinder)
|
||||
@@ -1996,6 +2003,7 @@ local function spawnNpc(spot, parent)
|
||||
end
|
||||
return rig
|
||||
end
|
||||
Builder.spawnNpc = spawnNpc -- жители лобби (LobbyLife.server.lua) создаются так же
|
||||
|
||||
-- NPC встают на свои детали-места, доски «кто водится» получают актуальный список рыб
|
||||
function Builder.prepareRuntime(root)
|
||||
@@ -2013,6 +2021,23 @@ function Builder.prepareRuntime(root)
|
||||
spot.Transparency = 1
|
||||
spawnNpc(spot, root)
|
||||
end
|
||||
-- порталы лобби двигают в Studio за модель (PortalModel_WorldN); невидимый якорь с подсказкой и подписью
|
||||
-- (Portal_WorldN) и маркер стрелки обучения (GuidePortal, перед порталом в мир 1) встают к модели
|
||||
for _, model in ipairs(root:GetChildren()) do
|
||||
local id = model.Name:match("^PortalModel_(World%d)$")
|
||||
local anchor = id and root:FindFirstChild("Portal_" .. id)
|
||||
if model:IsA("Model") and anchor then
|
||||
local cf, size = model:GetBoundingBox()
|
||||
anchor.CFrame = CFrame.new(cf.Position.X, cf.Position.Y - size.Y / 2 + 10, cf.Position.Z) * (anchor.CFrame - anchor.Position)
|
||||
local marker = id == "World1" and root:FindFirstChild("GuidePortal", true)
|
||||
if marker then
|
||||
local flat = V(cf.Position.X, 0, cf.Position.Z)
|
||||
local outward = flat.Magnitude > 0.1 and flat.Unit or V(0, 0, 1)
|
||||
local p = flat + outward * 5.7
|
||||
marker.CFrame = CFrame.new(p.X, marker.Position.Y, p.Z) * (marker.CFrame - marker.Position)
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, board in ipairs(boards) do
|
||||
writeBestiary(board)
|
||||
end
|
||||
|
||||
+39
-7
@@ -1352,13 +1352,17 @@ local function feed(kind, info)
|
||||
remote:FireAllClients("Feed", kind, info)
|
||||
end
|
||||
|
||||
pcall(function()
|
||||
MessagingService:SubscribeAsync(FEED_TOPIC, function(msg)
|
||||
local d = msg.Data
|
||||
if type(d) == "table" and d.jobId ~= game.JobId then
|
||||
d.remote = true -- улов на другом сервере
|
||||
feed("catch", d)
|
||||
end
|
||||
-- подписка — в фоне: SubscribeAsync ждёт ответа сервиса (в неопубликованном плейсе — долго),
|
||||
-- а скрипт должен сразу дойти до загрузки игроков, телепортов и остального
|
||||
task.spawn(function()
|
||||
pcall(function()
|
||||
MessagingService:SubscribeAsync(FEED_TOPIC, function(msg)
|
||||
local d = msg.Data
|
||||
if type(d) == "table" and d.jobId ~= game.JobId then
|
||||
d.remote = true -- улов на другом сервере
|
||||
feed("catch", d)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -1642,6 +1646,9 @@ local function updateStats(player)
|
||||
player:SetAttribute("BoostLeft", math.max(0, data.boostUntil - os.time()))
|
||||
player:SetAttribute("TotalCaught", data.totalCaught)
|
||||
player:SetAttribute("CoinsEarned", data.coinsEarned)
|
||||
-- когда откроется следующая ежедневная награда (0 — уже доступна); по ней сундук в лобби прыгает только для тех,
|
||||
-- кому есть что забрать
|
||||
player:SetAttribute("DailyNextAt", data.daily.last >= today() and (data.daily.last + 1) * 86400 or 0)
|
||||
player:SetAttribute("RobuxSpent", data.robuxSpent)
|
||||
-- шаг обучения (линия-подсказка); у старых игроков без поля, уже ловивших рыбу, обучение пройдено
|
||||
player:SetAttribute("Tutorial", data.tutorial or (data.totalCaught > 0 and Config.TutorialDone or 0))
|
||||
@@ -6148,6 +6155,7 @@ local function spawnNpc(spot, parent)
|
||||
return nil
|
||||
end
|
||||
rig.Name = name
|
||||
rig:SetAttribute("Npc", true) -- по нему клиент находит NPC (взгляд на игрока, приветствие), сервер — включает idle
|
||||
local hum = rig:FindFirstChildOfClass("Humanoid")
|
||||
hum.DisplayName = name
|
||||
hum.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
|
||||
@@ -6194,6 +6202,12 @@ local function spawnNpc(spot, parent)
|
||||
elderPart(V(1.0, 0.75, 0.35), CFrame.new(0, -0.55, -0.5), colors.hat)
|
||||
elderPart(V(0.32, 0.3, 0.08), CFrame.new(0.22, 0.12, -0.6), Color3.fromRGB(20, 20, 22))
|
||||
elderPart(V(1.24, 0.08, 1.24), CFrame.new(0, 0.18, 0) * CFrame.Angles(0, 0, math.rad(-12)), Color3.fromRGB(20, 20, 22))
|
||||
elseif spot:GetAttribute("Look") == "Scarf" then
|
||||
-- платок (цвет HatColor): макушка и узелок сзади
|
||||
local s = hatPart(V(1.3, 0.5, 1.3), CFrame.new(0, 0.42, 0.05), Enum.PartType.Block)
|
||||
s.Material = Enum.Material.SmoothPlastic
|
||||
local k = hatPart(V(0.4, 0.4, 0.3), CFrame.new(0, 0.05, 0.62), Enum.PartType.Block)
|
||||
k.Material = Enum.Material.SmoothPlastic
|
||||
else
|
||||
hatPart(V(0.15, 2.0, 2.0), CFrame.new(0, 0.55, 0) * CFrame.Angles(0, 0, math.rad(90)), Enum.PartType.Cylinder)
|
||||
hatPart(V(0.6, 1.35, 1.35), CFrame.new(0, 0.85, 0) * CFrame.Angles(0, 0, math.rad(90)), Enum.PartType.Cylinder)
|
||||
@@ -6205,6 +6219,7 @@ local function spawnNpc(spot, parent)
|
||||
end
|
||||
return rig
|
||||
end
|
||||
Builder.spawnNpc = spawnNpc -- жители лобби (LobbyLife.server.lua) создаются так же
|
||||
|
||||
-- NPC встают на свои детали-места, доски «кто водится» получают актуальный список рыб
|
||||
function Builder.prepareRuntime(root)
|
||||
@@ -6222,6 +6237,23 @@ function Builder.prepareRuntime(root)
|
||||
spot.Transparency = 1
|
||||
spawnNpc(spot, root)
|
||||
end
|
||||
-- порталы лобби двигают в Studio за модель (PortalModel_WorldN); невидимый якорь с подсказкой и подписью
|
||||
-- (Portal_WorldN) и маркер стрелки обучения (GuidePortal, перед порталом в мир 1) встают к модели
|
||||
for _, model in ipairs(root:GetChildren()) do
|
||||
local id = model.Name:match("^PortalModel_(World%d)$")
|
||||
local anchor = id and root:FindFirstChild("Portal_" .. id)
|
||||
if model:IsA("Model") and anchor then
|
||||
local cf, size = model:GetBoundingBox()
|
||||
anchor.CFrame = CFrame.new(cf.Position.X, cf.Position.Y - size.Y / 2 + 10, cf.Position.Z) * (anchor.CFrame - anchor.Position)
|
||||
local marker = id == "World1" and root:FindFirstChild("GuidePortal", true)
|
||||
if marker then
|
||||
local flat = V(cf.Position.X, 0, cf.Position.Z)
|
||||
local outward = flat.Magnitude > 0.1 and flat.Unit or V(0, 0, 1)
|
||||
local p = flat + outward * 5.7
|
||||
marker.CFrame = CFrame.new(p.X, marker.Position.Y, p.Z) * (marker.CFrame - marker.Position)
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, board in ipairs(boards) do
|
||||
writeBestiary(board)
|
||||
end
|
||||
|
||||
@@ -29,13 +29,17 @@ local function feed(kind, info)
|
||||
remote:FireAllClients("Feed", kind, info)
|
||||
end
|
||||
|
||||
pcall(function()
|
||||
MessagingService:SubscribeAsync(FEED_TOPIC, function(msg)
|
||||
local d = msg.Data
|
||||
if type(d) == "table" and d.jobId ~= game.JobId then
|
||||
d.remote = true -- улов на другом сервере
|
||||
feed("catch", d)
|
||||
end
|
||||
-- подписка — в фоне: SubscribeAsync ждёт ответа сервиса (в неопубликованном плейсе — долго),
|
||||
-- а скрипт должен сразу дойти до загрузки игроков, телепортов и остального
|
||||
task.spawn(function()
|
||||
pcall(function()
|
||||
MessagingService:SubscribeAsync(FEED_TOPIC, function(msg)
|
||||
local d = msg.Data
|
||||
if type(d) == "table" and d.jobId ~= game.JobId then
|
||||
d.remote = true -- улов на другом сервере
|
||||
feed("catch", d)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -319,6 +323,9 @@ local function updateStats(player)
|
||||
player:SetAttribute("BoostLeft", math.max(0, data.boostUntil - os.time()))
|
||||
player:SetAttribute("TotalCaught", data.totalCaught)
|
||||
player:SetAttribute("CoinsEarned", data.coinsEarned)
|
||||
-- когда откроется следующая ежедневная награда (0 — уже доступна); по ней сундук в лобби прыгает только для тех,
|
||||
-- кому есть что забрать
|
||||
player:SetAttribute("DailyNextAt", data.daily.last >= today() and (data.daily.last + 1) * 86400 or 0)
|
||||
player:SetAttribute("RobuxSpent", data.robuxSpent)
|
||||
-- шаг обучения (линия-подсказка); у старых игроков без поля, уже ловивших рыбу, обучение пройдено
|
||||
player:SetAttribute("Tutorial", data.tutorial or (data.totalCaught > 0 and Config.TutorialDone or 0))
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
-- LobbyLife (Script) -> ServerScriptService
|
||||
-- Живое лобби (общее для всех игроков): у всех NPC играет idle-анимация, по площади гуляют жители —
|
||||
-- рыбак с удочкой на плече и бабушка с корзинкой. Маршруты считает PathfindingService, поэтому
|
||||
-- жители обходят лавки, фонтан и порталы. Остальное оживление — на клиенте (LobbyLife.client.lua).
|
||||
|
||||
local PathfindingService = game:GetService("PathfindingService")
|
||||
local ServerScriptService = game:GetService("ServerScriptService")
|
||||
|
||||
local WorldBuilder = require(ServerScriptService:WaitForChild("WorldBuilder"))
|
||||
|
||||
local ANIM = {
|
||||
idle = "rbxassetid://507766666", -- стандартные R15-анимации Roblox
|
||||
walk = "rbxassetid://507777826",
|
||||
}
|
||||
local FLOOR = 1
|
||||
-- куда ходят жители (x, z на площади лобби); между точками путь ищет PathfindingService
|
||||
local POINTS = {
|
||||
{ 28, 8 }, { -28, -8 }, { 0, 32 }, { 0, -32 }, { 30, 25 }, { -30, 25 }, { 30, -24 }, { -30, -24 },
|
||||
{ 45, 12 }, { -45, -12 }, { 12, 45 }, { -22, 40 }, { 22, -42 }, { -42, 20 },
|
||||
}
|
||||
local WALKERS = {
|
||||
{ name = "Рыбак Фёдор", skin = Color3.fromRGB(226, 176, 140), shirt = Color3.fromRGB(70, 110, 150), pants = Color3.fromRGB(60, 62, 70),
|
||||
hat = Color3.fromRGB(110, 120, 70), look = nil, prop = "rod", speed = 7 },
|
||||
{ name = "Бабушка Нюра", skin = Color3.fromRGB(240, 200, 170), shirt = Color3.fromRGB(170, 70, 90), pants = Color3.fromRGB(90, 60, 80),
|
||||
hat = Color3.fromRGB(235, 220, 120), look = "Scarf", prop = "basket", speed = 5 },
|
||||
}
|
||||
|
||||
local rng = Random.new()
|
||||
|
||||
---------------------------------------------------------------- куда жителям нельзя
|
||||
-- Поиск пути Roblox забирается на низкие препятствия (чаша фонтана, скамейки, основания порталов)
|
||||
-- и ведёт жителей поверху. Поэтому вокруг всего, что стоит на площади на уровне роста, ставим невидимые
|
||||
-- «стены»: CanCollide = true, но в своей группе столкновений, которая ни с чем не сталкивается —
|
||||
-- поиск пути видит в них препятствие, а игроки, жители и лучи (CanQuery = false) проходят насквозь.
|
||||
local LOBBY_R = 76 -- зоны — только на площади лобби
|
||||
local noWalk = {} -- { center, half } по мировым осям — чтобы выкинуть точки маршрута, попавшие внутрь
|
||||
|
||||
local function inside(pos)
|
||||
for _, z in ipairs(noWalk) do
|
||||
if math.abs(pos.X - z.center.X) <= z.half.X and math.abs(pos.Z - z.center.Z) <= z.half.Z then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- габариты повёрнутой коробки по мировым осям (половины): у лежащих цилиндров и повёрнутых лавок
|
||||
-- локальные оси не совпадают с мировыми, поэтому зону строим по проекции на пол
|
||||
local function worldHalf(cf, size)
|
||||
local r, u, b = cf.RightVector, cf.UpVector, cf.LookVector
|
||||
local h = size / 2
|
||||
return Vector3.new(
|
||||
math.abs(r.X) * h.X + math.abs(u.X) * h.Y + math.abs(b.X) * h.Z,
|
||||
math.abs(r.Y) * h.X + math.abs(u.Y) * h.Y + math.abs(b.Y) * h.Z,
|
||||
math.abs(r.Z) * h.X + math.abs(u.Z) * h.Y + math.abs(b.Z) * h.Z)
|
||||
end
|
||||
|
||||
local function buildNoWalk(map)
|
||||
local PhysicsService = game:GetService("PhysicsService")
|
||||
pcall(function()
|
||||
PhysicsService:RegisterCollisionGroup("NpcNoWalk")
|
||||
end)
|
||||
for _, g in ipairs(PhysicsService:GetRegisteredCollisionGroups()) do
|
||||
PhysicsService:CollisionGroupSetCollidable("NpcNoWalk", g.name, false)
|
||||
end
|
||||
local folder = Instance.new("Folder")
|
||||
folder.Name = "NpcNoWalk"
|
||||
local function block(cf, size)
|
||||
local c, e = cf.Position, worldHalf(cf, size)
|
||||
-- только то, что стоит на полу на уровне роста и на самой площади
|
||||
if c.Y - e.Y > FLOOR + 6 or c.Y + e.Y < FLOOR + 0.6 or Vector3.new(c.X, 0, c.Z).Magnitude > LOBBY_R then
|
||||
return
|
||||
end
|
||||
local size2 = Vector3.new(e.X * 2 + 1.5, 10, e.Z * 2 + 1.5) -- небольшой запас: жители не трутся о края
|
||||
local p = Instance.new("Part")
|
||||
p.Name = "NoWalk"
|
||||
p.Anchored, p.CanCollide, p.CanQuery, p.CanTouch = true, true, false, false
|
||||
p.CollisionGroup = "NpcNoWalk" -- ни с чем не сталкивается, но поиск пути её видит
|
||||
p.Transparency = 1
|
||||
p.Size = size2
|
||||
p.CFrame = CFrame.new(c.X, FLOOR + 5, c.Z)
|
||||
p.Parent = folder
|
||||
table.insert(noWalk, { center = p.Position, half = size2 / 2 })
|
||||
end
|
||||
local skip = {
|
||||
LobbyCliffs = true, LobbyCliffDecor = true, LobbyCliffFoot = true, LobbyForest = true, LobbyTrees = true,
|
||||
LobbyRockPlants = true, LobbyHillForest = true, LobbyHaze = true, FishingZones = true, World1Map = true,
|
||||
}
|
||||
local function consider(inst)
|
||||
if inst:IsA("Model") then
|
||||
if inst:FindFirstChildOfClass("Humanoid") or inst:GetAttribute("Npc") then
|
||||
return
|
||||
end
|
||||
local cf, size = inst:GetBoundingBox()
|
||||
block(cf, size)
|
||||
elseif inst:IsA("BasePart") and inst.Transparency < 0.95 then
|
||||
block(inst.CFrame, inst.Size)
|
||||
end
|
||||
end
|
||||
for _, c in ipairs(map:GetChildren()) do
|
||||
if not skip[c.Name] and not c:IsA("Folder") then
|
||||
consider(c)
|
||||
end
|
||||
end
|
||||
-- модели, поставленные на площадь руками (фонтан, декор из Toolbox)
|
||||
for _, c in ipairs(workspace:GetChildren()) do
|
||||
if c ~= map and (c:IsA("Model") or c:IsA("BasePart")) and not c:IsA("Terrain") then
|
||||
consider(c)
|
||||
end
|
||||
end
|
||||
folder.Parent = workspace
|
||||
end
|
||||
|
||||
local function loadAnim(hum, id)
|
||||
local animator = hum:FindFirstChildOfClass("Animator")
|
||||
if not animator then
|
||||
animator = Instance.new("Animator")
|
||||
animator.Parent = hum
|
||||
end
|
||||
local a = Instance.new("Animation")
|
||||
a.AnimationId = id
|
||||
return animator:LoadAnimation(a)
|
||||
end
|
||||
|
||||
local function startIdle(rig)
|
||||
local hum = rig:FindFirstChildOfClass("Humanoid")
|
||||
if hum and not rig:GetAttribute("IdleOn") then
|
||||
rig:SetAttribute("IdleOn", true)
|
||||
local ok, track = pcall(loadAnim, hum, ANIM.idle)
|
||||
if ok then
|
||||
track.Looped = true
|
||||
track:Play(0.3, 1, rng:NextNumber(0.85, 1.1))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- реквизит в руках / за спиной: приваривается к части тела
|
||||
local function prop(rig, kind)
|
||||
local function piece(partName, size, color, offset, shape)
|
||||
local body = rig:FindFirstChild(partName)
|
||||
if not body then
|
||||
return
|
||||
end
|
||||
local p = Instance.new("Part")
|
||||
p.Shape = shape or Enum.PartType.Block
|
||||
p.Size = size
|
||||
p.Color = color
|
||||
p.Material = Enum.Material.SmoothPlastic
|
||||
p.CanCollide, p.CanQuery, p.CanTouch, p.Massless = false, false, false, true
|
||||
p.CFrame = body.CFrame * offset
|
||||
local w = Instance.new("WeldConstraint")
|
||||
w.Part0, w.Part1 = body, p
|
||||
w.Parent = p
|
||||
p.Parent = rig
|
||||
end
|
||||
if kind == "rod" then
|
||||
-- удочка на плече: длинное удилище наискосок за спиной и катушка
|
||||
piece("UpperTorso", Vector3.new(0.18, 7, 0.18), Color3.fromRGB(120, 80, 45),
|
||||
CFrame.new(0.4, 1.2, 0.65) * CFrame.Angles(math.rad(-25), 0, math.rad(-30)), Enum.PartType.Block)
|
||||
piece("UpperTorso", Vector3.new(0.5, 0.5, 0.35), Color3.fromRGB(60, 60, 66), CFrame.new(0.9, 0.2, 0.75))
|
||||
elseif kind == "basket" then
|
||||
-- корзинка в руке: короб и ручка
|
||||
piece("RightHand", Vector3.new(1.1, 0.7, 0.8), Color3.fromRGB(170, 120, 60), CFrame.new(0, -0.7, 0))
|
||||
piece("RightHand", Vector3.new(0.12, 0.6, 0.6), Color3.fromRGB(140, 95, 45), CFrame.new(0, -0.15, 0))
|
||||
piece("RightHand", Vector3.new(0.9, 0.18, 0.6), Color3.fromRGB(240, 120, 90), CFrame.new(0, -0.28, 0)) -- яблоки сверху
|
||||
end
|
||||
end
|
||||
|
||||
local function walker(def, map)
|
||||
if #POINTS < 2 then
|
||||
warn("LobbyLife: свободных точек маршрута меньше двух, жители не гуляют")
|
||||
return
|
||||
end
|
||||
local start = POINTS[rng:NextInteger(1, #POINTS)]
|
||||
local spot = Instance.new("Part")
|
||||
spot.CFrame = CFrame.new(start[1], FLOOR + 3, start[2])
|
||||
spot:SetAttribute("NpcName", def.name)
|
||||
spot:SetAttribute("SkinColor", def.skin)
|
||||
spot:SetAttribute("ShirtColor", def.shirt)
|
||||
spot:SetAttribute("PantsColor", def.pants)
|
||||
spot:SetAttribute("HatColor", def.hat)
|
||||
if def.look then
|
||||
spot:SetAttribute("Look", def.look)
|
||||
end
|
||||
local rig = WorldBuilder.spawnNpc(spot, map)
|
||||
spot:Destroy()
|
||||
if not rig then
|
||||
return
|
||||
end
|
||||
rig:SetAttribute("Walker", true)
|
||||
prop(rig, def.prop)
|
||||
local hum = rig:FindFirstChildOfClass("Humanoid")
|
||||
local root = rig:FindFirstChild("HumanoidRootPart")
|
||||
hum.WalkSpeed = def.speed
|
||||
hum.NameDisplayDistance = 35
|
||||
root.Anchored = false
|
||||
pcall(function() root:SetNetworkOwner(nil) end) -- двигает сервер, у всех одинаково
|
||||
startIdle(rig)
|
||||
local walk = loadAnim(hum, ANIM.walk)
|
||||
walk.Looped = true
|
||||
|
||||
task.spawn(function()
|
||||
while rig.Parent do
|
||||
local p = POINTS[rng:NextInteger(1, #POINTS)]
|
||||
local target = Vector3.new(p[1], FLOOR + 2, p[2])
|
||||
if (target - root.Position).Magnitude > 8 then
|
||||
local path = PathfindingService:CreatePath({ AgentRadius = 2, AgentHeight = 5, AgentCanJump = false })
|
||||
local ok = pcall(function()
|
||||
path:ComputeAsync(root.Position, target)
|
||||
end)
|
||||
if ok and path.Status == Enum.PathStatus.Success then
|
||||
walk:Play(0.25, 1, def.speed / 8)
|
||||
for _, wp in ipairs(path:GetWaypoints()) do
|
||||
if not rig.Parent then
|
||||
return
|
||||
end
|
||||
hum:MoveTo(wp.Position)
|
||||
local reached = hum.MoveToFinished:Wait()
|
||||
if not reached then
|
||||
break -- застрял: выберем другую точку
|
||||
end
|
||||
end
|
||||
walk:Stop(0.3)
|
||||
end
|
||||
end
|
||||
task.wait(rng:NextNumber(3, 8)) -- постоял, посмотрел по сторонам
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local map = workspace:WaitForChild("FishingMap")
|
||||
task.wait(2) -- MapBuilder расставляет NPC
|
||||
for _, d in ipairs(map:GetDescendants()) do
|
||||
if d:IsA("Model") and d:GetAttribute("Npc") then
|
||||
startIdle(d)
|
||||
end
|
||||
end
|
||||
map.DescendantAdded:Connect(function(d)
|
||||
if d:IsA("Model") then
|
||||
task.defer(function()
|
||||
if d:GetAttribute("Npc") then
|
||||
startIdle(d)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
buildNoWalk(map)
|
||||
-- точки маршрута, оказавшиеся внутри препятствий (например, на месте передвинутой лавки), не используем
|
||||
for i = #POINTS, 1, -1 do
|
||||
if inside(Vector3.new(POINTS[i][1], FLOOR, POINTS[i][2])) then
|
||||
table.remove(POINTS, i)
|
||||
end
|
||||
end
|
||||
for _, def in ipairs(WALKERS) do
|
||||
walker(def, map)
|
||||
end
|
||||
@@ -1938,6 +1938,7 @@ local function spawnNpc(spot, parent)
|
||||
return nil
|
||||
end
|
||||
rig.Name = name
|
||||
rig:SetAttribute("Npc", true) -- по нему клиент находит NPC (взгляд на игрока, приветствие), сервер — включает idle
|
||||
local hum = rig:FindFirstChildOfClass("Humanoid")
|
||||
hum.DisplayName = name
|
||||
hum.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
|
||||
@@ -1984,6 +1985,12 @@ local function spawnNpc(spot, parent)
|
||||
elderPart(V(1.0, 0.75, 0.35), CFrame.new(0, -0.55, -0.5), colors.hat)
|
||||
elderPart(V(0.32, 0.3, 0.08), CFrame.new(0.22, 0.12, -0.6), Color3.fromRGB(20, 20, 22))
|
||||
elderPart(V(1.24, 0.08, 1.24), CFrame.new(0, 0.18, 0) * CFrame.Angles(0, 0, math.rad(-12)), Color3.fromRGB(20, 20, 22))
|
||||
elseif spot:GetAttribute("Look") == "Scarf" then
|
||||
-- платок (цвет HatColor): макушка и узелок сзади
|
||||
local s = hatPart(V(1.3, 0.5, 1.3), CFrame.new(0, 0.42, 0.05), Enum.PartType.Block)
|
||||
s.Material = Enum.Material.SmoothPlastic
|
||||
local k = hatPart(V(0.4, 0.4, 0.3), CFrame.new(0, 0.05, 0.62), Enum.PartType.Block)
|
||||
k.Material = Enum.Material.SmoothPlastic
|
||||
else
|
||||
hatPart(V(0.15, 2.0, 2.0), CFrame.new(0, 0.55, 0) * CFrame.Angles(0, 0, math.rad(90)), Enum.PartType.Cylinder)
|
||||
hatPart(V(0.6, 1.35, 1.35), CFrame.new(0, 0.85, 0) * CFrame.Angles(0, 0, math.rad(90)), Enum.PartType.Cylinder)
|
||||
@@ -1995,6 +2002,7 @@ local function spawnNpc(spot, parent)
|
||||
end
|
||||
return rig
|
||||
end
|
||||
Builder.spawnNpc = spawnNpc -- жители лобби (LobbyLife.server.lua) создаются так же
|
||||
|
||||
-- NPC встают на свои детали-места, доски «кто водится» получают актуальный список рыб
|
||||
function Builder.prepareRuntime(root)
|
||||
@@ -2012,6 +2020,23 @@ function Builder.prepareRuntime(root)
|
||||
spot.Transparency = 1
|
||||
spawnNpc(spot, root)
|
||||
end
|
||||
-- порталы лобби двигают в Studio за модель (PortalModel_WorldN); невидимый якорь с подсказкой и подписью
|
||||
-- (Portal_WorldN) и маркер стрелки обучения (GuidePortal, перед порталом в мир 1) встают к модели
|
||||
for _, model in ipairs(root:GetChildren()) do
|
||||
local id = model.Name:match("^PortalModel_(World%d)$")
|
||||
local anchor = id and root:FindFirstChild("Portal_" .. id)
|
||||
if model:IsA("Model") and anchor then
|
||||
local cf, size = model:GetBoundingBox()
|
||||
anchor.CFrame = CFrame.new(cf.Position.X, cf.Position.Y - size.Y / 2 + 10, cf.Position.Z) * (anchor.CFrame - anchor.Position)
|
||||
local marker = id == "World1" and root:FindFirstChild("GuidePortal", true)
|
||||
if marker then
|
||||
local flat = V(cf.Position.X, 0, cf.Position.Z)
|
||||
local outward = flat.Magnitude > 0.1 and flat.Unit or V(0, 0, 1)
|
||||
local p = flat + outward * 5.7
|
||||
marker.CFrame = CFrame.new(p.X, marker.Position.Y, p.Z) * (marker.CFrame - marker.Position)
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, board in ipairs(boards) do
|
||||
writeBestiary(board)
|
||||
end
|
||||
|
||||
@@ -154,10 +154,18 @@ local function apply(h, lidDeg, coin)
|
||||
end
|
||||
end
|
||||
|
||||
local start = os.clock()
|
||||
-- прыгает только для тех, кому есть что забрать: DailyNextAt (ставит сервер) — когда откроется следующая
|
||||
-- награда, 0 — уже доступна. Забрал — сундук доигрывает текущий прыжок и замирает до следующего дня.
|
||||
local player = game:GetService("Players").LocalPlayer
|
||||
local function rewardReady()
|
||||
local nextAt = player:GetAttribute("DailyNextAt")
|
||||
return nextAt ~= nil and workspace:GetServerTimeNow() >= nextAt
|
||||
end
|
||||
|
||||
local scanAt = -math.huge
|
||||
local lastT = 0
|
||||
RunService.RenderStepped:Connect(function()
|
||||
local cycleT = nil -- время внутри текущего цикла; nil — сундук стоит
|
||||
local resting = false
|
||||
RunService.RenderStepped:Connect(function(dt)
|
||||
if not chest or not chest.Parent then
|
||||
chest = nil
|
||||
if os.clock() - scanAt > 3 then
|
||||
@@ -170,16 +178,29 @@ RunService.RenderStepped:Connect(function()
|
||||
if cam and (cam.CFrame.Position - rest.pivot.Position).Magnitude > VIEW_DIST then
|
||||
return
|
||||
end
|
||||
local t = (os.clock() - start) % PERIOD
|
||||
-- события цикла: начало прыжка (t перескочил через 0) и удар о землю
|
||||
if t < lastT then
|
||||
if not cycleT then
|
||||
if not rewardReady() then
|
||||
if not resting then
|
||||
resting = true
|
||||
apply(0, 0, 0) -- стоит закрытый, как в редакторе
|
||||
end
|
||||
return
|
||||
end
|
||||
cycleT, resting = 0, false
|
||||
play(fx.hop)
|
||||
end
|
||||
if lastT < T_IMPACT and t >= T_IMPACT then
|
||||
local prev = cycleT
|
||||
cycleT += dt
|
||||
-- удар о землю
|
||||
if prev < T_IMPACT and cycleT >= T_IMPACT then
|
||||
play(fx.land)
|
||||
task.delay(0.08, play, fx.coins) -- монеты звенят чуть позже удара, когда подпрыгивают
|
||||
fx.dust:Emit(26)
|
||||
end
|
||||
lastT = t
|
||||
apply(pose(t))
|
||||
if cycleT >= PERIOD then
|
||||
cycleT = nil -- цикл закончен; следующий начнётся, только если награда всё ещё доступна
|
||||
apply(0, 0, 0)
|
||||
return
|
||||
end
|
||||
apply(pose(cycleT))
|
||||
end)
|
||||
@@ -0,0 +1,479 @@
|
||||
-- LobbyLife (LocalScript) -> StarterPlayer > StarterPlayerScripts
|
||||
-- Живое лобби у этого игрока (всё — на клиенте, сервер не нагружается):
|
||||
-- NPC поворачивают голову к игроку и машут, когда он подходит;
|
||||
-- кот ходит за игроком по площади, а один — ложится у фонтана;
|
||||
-- чайки над скалами, бабочки у цветов, ночью — светлячки у фонарей и клумб;
|
||||
-- деревья, трава, цветы и кусты колышутся от ветра (только рядом с камерой), с деревьев падают листья.
|
||||
-- Общие для всех вещи (idle NPC, гуляющие жители) — в LobbyLife.server.lua.
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local RunService = game:GetService("RunService")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Config = require(ReplicatedStorage:WaitForChild("FishConfig"))
|
||||
|
||||
local player = Players.LocalPlayer
|
||||
local V = Vector3.new
|
||||
local rng = Random.new()
|
||||
local LOBBY = V(0, 1, 0) -- центр лобби, пол на высоте 1
|
||||
local LOBBY_VIEW = 170 -- дальше камеры от центра лобби — ничего не анимируем
|
||||
local WAVE_ANIM = "rbxassetid://507770239"
|
||||
local LEAF_TEXTURE = "rbxassetid://138319345672122"
|
||||
|
||||
local map = workspace:WaitForChild("FishingMap")
|
||||
local fx = Instance.new("Folder")
|
||||
fx.Name = "LobbyLifeFX"
|
||||
fx.Parent = workspace
|
||||
|
||||
local function part(props)
|
||||
local p = Instance.new(props.Class or "Part")
|
||||
p.Anchored = true
|
||||
p.CanCollide, p.CanQuery, p.CanTouch, p.CastShadow = false, false, false, false
|
||||
p.Material = Enum.Material.SmoothPlastic
|
||||
p.TopSurface, p.BottomSurface = Enum.SurfaceType.Smooth, Enum.SurfaceType.Smooth
|
||||
for k, v in pairs(props) do
|
||||
if k ~= "Class" then
|
||||
p[k] = v
|
||||
end
|
||||
end
|
||||
p.Parent = props.Parent or fx
|
||||
return p
|
||||
end
|
||||
|
||||
local function camPos()
|
||||
local cam = workspace.CurrentCamera
|
||||
return cam and cam.CFrame.Position or LOBBY
|
||||
end
|
||||
local function myRoot()
|
||||
return player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- NPC: взгляд и приветствие
|
||||
|
||||
local npcs = {}
|
||||
local function scanNpcs()
|
||||
for _, d in ipairs(map:GetDescendants()) do
|
||||
if d:IsA("Model") and d:GetAttribute("Npc") and not npcs[d] then
|
||||
local head = d:FindFirstChild("Head")
|
||||
local neck = head and head:FindFirstChild("Neck")
|
||||
local torso = d:FindFirstChild("UpperTorso")
|
||||
if neck and neck:IsA("Motor6D") and torso then
|
||||
npcs[d] = { neck = neck, c0 = neck.C0, torso = torso, head = head, yaw = 0, pitch = 0, waveAt = -math.huge }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function wave(rig, info)
|
||||
local hum = rig:FindFirstChildOfClass("Humanoid")
|
||||
local animator = hum and hum:FindFirstChildOfClass("Animator")
|
||||
if not animator then
|
||||
return
|
||||
end
|
||||
if not info.waveTrack then
|
||||
local a = Instance.new("Animation")
|
||||
a.AnimationId = WAVE_ANIM
|
||||
local ok, track = pcall(function() return animator:LoadAnimation(a) end)
|
||||
info.waveTrack = ok and track or false
|
||||
end
|
||||
if info.waveTrack then
|
||||
info.waveTrack.Priority = Enum.AnimationPriority.Action
|
||||
info.waveTrack:Play(0.2)
|
||||
end
|
||||
end
|
||||
|
||||
local function updateNpcs(dt)
|
||||
local root = myRoot()
|
||||
local myHead = player.Character and player.Character:FindFirstChild("Head")
|
||||
local now = os.clock()
|
||||
for rig, n in pairs(npcs) do
|
||||
if not rig.Parent then
|
||||
npcs[rig] = nil
|
||||
else
|
||||
local wantYaw, wantPitch = 0, 0
|
||||
local dist = root and (root.Position - n.head.Position).Magnitude or math.huge
|
||||
if myHead and dist < 24 then
|
||||
-- куда смотреть: в системе координат торса, лицо — по -Z
|
||||
local rel = n.torso.CFrame:PointToObjectSpace(myHead.Position)
|
||||
local headRel = n.torso.CFrame:PointToObjectSpace(n.head.Position)
|
||||
local d = rel - headRel
|
||||
wantYaw = math.clamp(math.atan2(-d.X, -d.Z), math.rad(-70), math.rad(70))
|
||||
wantPitch = math.clamp(math.atan2(d.Y, math.sqrt(d.X * d.X + d.Z * d.Z)), math.rad(-20), math.rad(30))
|
||||
-- голову к игроку, только если он перед NPC, а не за спиной
|
||||
if math.abs(math.atan2(-d.X, -d.Z)) > math.rad(110) then
|
||||
wantYaw, wantPitch = 0, 0
|
||||
end
|
||||
-- подошёл близко — помахать (не чаще раза в 25 секунд)
|
||||
if dist < 11 and now - n.waveAt > 25 then
|
||||
n.waveAt = now
|
||||
wave(rig, n)
|
||||
end
|
||||
end
|
||||
local k = math.min(1, dt * 4)
|
||||
n.yaw += (wantYaw - n.yaw) * k
|
||||
n.pitch += (wantPitch - n.pitch) * k
|
||||
n.neck.C0 = n.c0 * CFrame.Angles(0, n.yaw, 0) * CFrame.Angles(n.pitch, 0, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- кот
|
||||
|
||||
local cat = {}
|
||||
do
|
||||
local GINGER, WHITE, PINK = Color3.fromRGB(232, 150, 70), Color3.fromRGB(245, 238, 228), Color3.fromRGB(240, 150, 160)
|
||||
cat.body = part({ Size = V(1.3, 1.0, 2.3), Color = GINGER })
|
||||
cat.belly = part({ Size = V(1.0, 0.3, 1.9), Color = WHITE })
|
||||
cat.head = part({ Size = V(1.15, 1.0, 1.0), Color = GINGER })
|
||||
cat.muzzle = part({ Size = V(0.6, 0.35, 0.25), Color = WHITE })
|
||||
cat.nose = part({ Size = V(0.18, 0.12, 0.08), Color = PINK })
|
||||
cat.eyes = {
|
||||
part({ Size = V(0.16, 0.2, 0.05), Color = Color3.fromRGB(40, 40, 30) }),
|
||||
part({ Size = V(0.16, 0.2, 0.05), Color = Color3.fromRGB(40, 40, 30) }),
|
||||
}
|
||||
cat.ears = {
|
||||
part({ Class = "WedgePart", Size = V(0.3, 0.45, 0.35), Color = GINGER }),
|
||||
part({ Class = "WedgePart", Size = V(0.3, 0.45, 0.35), Color = GINGER }),
|
||||
}
|
||||
cat.legs = {}
|
||||
for i = 1, 4 do
|
||||
cat.legs[i] = part({ Size = V(0.32, 0.7, 0.32), Color = (i <= 2) and WHITE or GINGER })
|
||||
end
|
||||
cat.tail = {}
|
||||
for i = 1, 5 do
|
||||
cat.tail[i] = part({ Size = V(0.24, 0.24, 0.42), Color = (i == 5) and WHITE or GINGER })
|
||||
end
|
||||
cat.pos = LOBBY + V(10, 0, 12)
|
||||
cat.dir = V(0, 0, -1)
|
||||
cat.speed = 0
|
||||
cat.lying = 0 -- 0 стоит … 1 лежит
|
||||
cat.walk = 0 -- фаза шага
|
||||
cat.home = LOBBY + V(-9, 0, 13) -- лежанка у фонтана
|
||||
end
|
||||
|
||||
local function catTarget(root)
|
||||
if root and (root.Position - LOBBY).Magnitude < 70 and (root.Position - cat.pos).Magnitude < 40 then
|
||||
-- за игроком: держится чуть сбоку и позади
|
||||
local look = root.CFrame.LookVector
|
||||
local side = root.CFrame.RightVector
|
||||
return V(root.Position.X, LOBBY.Y, root.Position.Z) - look * 3 + side * 2.2, 3.5, true
|
||||
end
|
||||
return cat.home, 0.5, false
|
||||
end
|
||||
|
||||
local function updateCat(dt, t)
|
||||
local root = myRoot()
|
||||
local target, stopDist, following = catTarget(root)
|
||||
local flat = V(target.X - cat.pos.X, 0, target.Z - cat.pos.Z)
|
||||
local dist = flat.Magnitude
|
||||
local want = 0
|
||||
if dist > stopDist then
|
||||
want = math.clamp(dist * 1.2, 4, following and 15 or 6) -- догоняет бегом, домой идёт шагом
|
||||
end
|
||||
cat.speed += (want - cat.speed) * math.min(1, dt * 5)
|
||||
if dist > 0.05 and cat.speed > 0.2 then
|
||||
cat.dir = cat.dir:Lerp(flat.Unit, math.min(1, dt * 6)).Unit
|
||||
local step = math.min(dist, cat.speed * dt)
|
||||
cat.pos += cat.dir * step
|
||||
end
|
||||
-- не заходим в чашу фонтана и на прилавки
|
||||
local r = V(cat.pos.X, 0, cat.pos.Z).Magnitude
|
||||
if r < 14 then
|
||||
cat.pos = LOBBY + V(cat.pos.X, 0, cat.pos.Z).Unit * 14
|
||||
elseif r > 54 then
|
||||
cat.pos = LOBBY + V(cat.pos.X, 0, cat.pos.Z).Unit * 54
|
||||
end
|
||||
local resting = not following and dist <= 0.6 and cat.speed < 0.5
|
||||
cat.lying += ((resting and 1 or 0) - cat.lying) * math.min(1, dt * 2)
|
||||
cat.walk += cat.speed * dt * 2.2
|
||||
|
||||
local L = cat.lying
|
||||
local base = CFrame.lookAt(cat.pos, cat.pos + cat.dir) -- -Z — нос
|
||||
local bob = math.abs(math.sin(cat.walk)) * 0.08 * math.min(1, cat.speed / 4)
|
||||
local bodyY = 1.05 - 0.55 * L + bob
|
||||
local body = base * CFrame.new(0, bodyY, 0)
|
||||
cat.body.CFrame = body
|
||||
cat.belly.CFrame = body * CFrame.new(0, -0.4, 0)
|
||||
local headTurn = L > 0.5 and math.sin(t * 0.4) * 0.3 or 0
|
||||
local head = body * CFrame.new(0, 0.55 - 0.25 * L, -1.35) * CFrame.Angles(0, headTurn, 0)
|
||||
cat.head.CFrame = head
|
||||
cat.muzzle.CFrame = head * CFrame.new(0, -0.18, -0.55)
|
||||
cat.nose.CFrame = head * CFrame.new(0, -0.02, -0.66)
|
||||
cat.eyes[1].CFrame = head * CFrame.new(-0.25, 0.12, -0.51)
|
||||
cat.eyes[2].CFrame = head * CFrame.new(0.25, 0.12, -0.51)
|
||||
cat.ears[1].CFrame = head * CFrame.new(-0.35, 0.68, 0.05) * CFrame.Angles(0, math.pi, 0)
|
||||
cat.ears[2].CFrame = head * CFrame.new(0.35, 0.68, 0.05) * CFrame.Angles(0, math.pi, 0)
|
||||
-- лапы: шагают попеременно, лёжа прячутся под корпус
|
||||
local swing = math.sin(cat.walk) * 0.6 * math.min(1, cat.speed / 3)
|
||||
local legPos = { { -0.42, -0.85 }, { 0.42, -0.85 }, { -0.42, 0.85 }, { 0.42, 0.85 } }
|
||||
for i, lp in ipairs(legPos) do
|
||||
local s = ((i == 1 or i == 4) and swing or -swing)
|
||||
cat.legs[i].CFrame = body * CFrame.new(lp[1], -0.5 - 0.15 * (1 - L) + 0.25 * L, lp[2]) * CFrame.Angles(s, 0, 0)
|
||||
* CFrame.new(0, -0.25 * (1 - L), 0)
|
||||
end
|
||||
-- хвост: цепочка сегментов, кончик покачивается
|
||||
local tcf = body * CFrame.new(0, 0.3, 1.15) * CFrame.Angles(math.rad(35 - 25 * L), 0, 0)
|
||||
for i, seg in ipairs(cat.tail) do
|
||||
local sway = math.sin(t * 2.2 - i * 0.6) * (0.18 + 0.05 * i)
|
||||
tcf = tcf * CFrame.Angles(math.rad(10), sway, 0) * CFrame.new(0, 0, 0.38)
|
||||
seg.CFrame = tcf
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- чайки
|
||||
|
||||
local gulls = {}
|
||||
for i = 1, 4 do
|
||||
local g = {
|
||||
body = part({ Size = V(0.7, 0.6, 1.9), Color = Color3.fromRGB(245, 245, 248) }),
|
||||
head = part({ Size = V(0.5, 0.5, 0.55), Color = Color3.fromRGB(250, 250, 252) }),
|
||||
beak = part({ Size = V(0.15, 0.15, 0.45), Color = Color3.fromRGB(245, 180, 60) }),
|
||||
wings = { part({ Size = V(2.4, 0.1, 0.9), Color = Color3.fromRGB(205, 210, 220) }), part({ Size = V(2.4, 0.1, 0.9), Color = Color3.fromRGB(205, 210, 220) }) },
|
||||
tips = { part({ Size = V(0.8, 0.1, 0.7), Color = Color3.fromRGB(60, 62, 70) }), part({ Size = V(0.8, 0.1, 0.7), Color = Color3.fromRGB(60, 62, 70) }) },
|
||||
r = rng:NextNumber(70, 115), h = rng:NextNumber(52, 78), w = rng:NextNumber(0.1, 0.17) * (i % 2 == 0 and 1 or -1),
|
||||
a = rng:NextNumber(0, math.pi * 2), flap = rng:NextNumber(0, 10),
|
||||
}
|
||||
gulls[i] = g
|
||||
end
|
||||
|
||||
local function updateGulls(dt, t)
|
||||
for _, g in ipairs(gulls) do
|
||||
g.a += g.w * dt
|
||||
local r = g.r + math.sin(t * 0.13 + g.a) * 12
|
||||
local pos = V(math.cos(g.a) * r, g.h + math.sin(t * 0.4 + g.r) * 4, math.sin(g.a) * r)
|
||||
local ahead = V(math.cos(g.a + 0.05 * math.sign(g.w)) * r, pos.Y, math.sin(g.a + 0.05 * math.sign(g.w)) * r)
|
||||
local bank = -math.sign(g.w) * math.rad(18)
|
||||
local cf = CFrame.lookAt(pos, ahead) * CFrame.Angles(0, 0, bank)
|
||||
-- машет крыльями урывками, потом планирует
|
||||
local flapping = math.sin(t * 0.5 + g.flap) > 0.2
|
||||
local wing = flapping and math.sin(t * 9 + g.flap) * math.rad(35) or math.rad(4)
|
||||
g.body.CFrame = cf
|
||||
g.head.CFrame = cf * CFrame.new(0, 0.25, -1.05)
|
||||
g.beak.CFrame = cf * CFrame.new(0, 0.2, -1.5)
|
||||
for s = 1, 2 do
|
||||
local side = (s == 1) and -1 or 1
|
||||
local hinge = cf * CFrame.new(side * 0.35, 0.15, -0.1) * CFrame.Angles(0, 0, side * wing)
|
||||
g.wings[s].CFrame = hinge * CFrame.new(side * 1.2, 0, 0)
|
||||
g.tips[s].CFrame = hinge * CFrame.new(side * 2.4, 0, 0.05) * CFrame.Angles(0, 0, side * wing * 0.5) * CFrame.new(side * 0.35, 0, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- бабочки и светлячки
|
||||
|
||||
local butterflies = {}
|
||||
local fireflyEmitters = {}
|
||||
local function setupFlowersFX()
|
||||
local anchors = {}
|
||||
local foot = map:FindFirstChild("LobbyCliffFoot")
|
||||
local flowers = foot and foot:FindFirstChild("Flowers")
|
||||
if flowers then
|
||||
for _, f in ipairs(flowers:GetChildren()) do
|
||||
table.insert(anchors, f:GetPivot().Position)
|
||||
end
|
||||
end
|
||||
if #anchors == 0 then
|
||||
for i = 1, 12 do
|
||||
local a = i / 12 * math.pi * 2
|
||||
table.insert(anchors, LOBBY + V(math.cos(a) * 70, 0, math.sin(a) * 70))
|
||||
end
|
||||
end
|
||||
local COLORS = { Color3.fromRGB(255, 200, 80), Color3.fromRGB(255, 255, 255), Color3.fromRGB(150, 200, 255), Color3.fromRGB(255, 150, 200), Color3.fromRGB(255, 160, 70) }
|
||||
for i = 1, 16 do
|
||||
local anchor = anchors[rng:NextInteger(1, #anchors)]
|
||||
local c = COLORS[rng:NextInteger(1, #COLORS)]
|
||||
table.insert(butterflies, {
|
||||
anchor = V(anchor.X, LOBBY.Y, anchor.Z), seed = rng:NextNumber(0, 100),
|
||||
body = part({ Size = V(0.08, 0.08, 0.4), Color = Color3.fromRGB(50, 40, 35) }),
|
||||
wings = { part({ Size = V(0.45, 0.04, 0.4), Color = c }), part({ Size = V(0.45, 0.04, 0.4), Color = c }) },
|
||||
})
|
||||
end
|
||||
-- светлячки: у фонарей лобби и у клумб, светятся только ночью
|
||||
local spots = {}
|
||||
for _, d in ipairs(map:GetDescendants()) do
|
||||
if d:IsA("PointLight") and d.Parent:IsA("BasePart") then
|
||||
local p = d.Parent.Position
|
||||
if (V(p.X, 0, p.Z)).Magnitude < 80 and p.Y < 20 then
|
||||
table.insert(spots, p - V(0, 3, 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
for i = 1, math.min(10, #anchors) do
|
||||
table.insert(spots, anchors[rng:NextInteger(1, #anchors)] + V(0, 1.5, 0))
|
||||
end
|
||||
for _, p in ipairs(spots) do
|
||||
local box = part({ Size = V(6, 3, 6), Transparency = 1, CFrame = CFrame.new(p) })
|
||||
local pe = Instance.new("ParticleEmitter")
|
||||
pe.Texture = "rbxasset://textures/particles/sparkles_main.dds"
|
||||
pe.Color = ColorSequence.new(Color3.fromRGB(220, 255, 120))
|
||||
pe.LightEmission = 1
|
||||
pe.Size = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(0.2, 0.22), NumberSequenceKeypoint.new(0.8, 0.22), NumberSequenceKeypoint.new(1, 0) })
|
||||
pe.Lifetime = NumberRange.new(3, 5)
|
||||
pe.Rate = 1.5
|
||||
pe.Speed = NumberRange.new(0.3, 0.8)
|
||||
pe.SpreadAngle = Vector2.new(180, 180)
|
||||
pe.Acceleration = V(0, 0.15, 0)
|
||||
pe.Shape = Enum.ParticleEmitterShape.Box
|
||||
pe.Enabled = false
|
||||
pe.Parent = box
|
||||
table.insert(fireflyEmitters, pe)
|
||||
end
|
||||
end
|
||||
|
||||
local function updateButterflies(dt, t)
|
||||
for _, b in ipairs(butterflies) do
|
||||
local s = b.seed
|
||||
local off = V(math.sin(t * 0.37 + s) * 2.6 + math.sin(t * 0.9 + s * 2) * 0.8, 1.6 + math.sin(t * 0.7 + s) * 0.9 + 0.5,
|
||||
math.cos(t * 0.31 + s) * 2.6 + math.cos(t * 1.1 + s) * 0.8)
|
||||
local pos = b.anchor + off
|
||||
local vel = V(math.cos(t * 0.37 + s) * 0.37 * 2.6, 0, -math.sin(t * 0.31 + s) * 0.31 * 2.6)
|
||||
local cf = CFrame.lookAt(pos, pos + (vel.Magnitude > 0.01 and vel or V(0, 0, -1)))
|
||||
local flap = math.sin(t * 17 + s) * math.rad(60) + math.rad(15)
|
||||
b.body.CFrame = cf
|
||||
b.wings[1].CFrame = cf * CFrame.Angles(0, 0, flap) * CFrame.new(-0.24, 0, 0)
|
||||
b.wings[2].CFrame = cf * CFrame.Angles(0, 0, -flap) * CFrame.new(0.24, 0, 0)
|
||||
end
|
||||
end
|
||||
|
||||
local nightCheckAt = 0
|
||||
local function updateFireflies(t)
|
||||
if t - nightCheckAt < 1 then
|
||||
return
|
||||
end
|
||||
nightCheckAt = t
|
||||
local night = false
|
||||
if Config.DayNight and Config.DayNight.enabled and Config.Nightness and Config.ClockAt then
|
||||
local clock = Config.ClockAt(workspace:GetServerTimeNow(), workspace:GetAttribute("DayStart"))
|
||||
night = Config.Nightness(clock) > 0.4
|
||||
end
|
||||
for _, pe in ipairs(fireflyEmitters) do
|
||||
pe.Enabled = night
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- ветер: деревья, трава, цветы, кусты
|
||||
|
||||
local swayers = {}
|
||||
local function addSway(model, amp, freq, range)
|
||||
local parts, rel = {}, {}
|
||||
local cf, size = model:GetBoundingBox()
|
||||
local base = CFrame.new(cf.Position.X, cf.Position.Y - size.Y / 2, cf.Position.Z)
|
||||
for _, p in ipairs(model:GetDescendants()) do
|
||||
if p:IsA("BasePart") then
|
||||
table.insert(parts, p)
|
||||
table.insert(rel, base:ToObjectSpace(p.CFrame))
|
||||
end
|
||||
end
|
||||
if #parts > 0 then
|
||||
table.insert(swayers, {
|
||||
parts = parts, rel = rel, base = base, amp = math.rad(amp) * rng:NextNumber(0.8, 1.2),
|
||||
freq = freq * rng:NextNumber(0.85, 1.15), phase = rng:NextNumber(0, math.pi * 2), range = range,
|
||||
height = size.Y,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local leafTrees = {}
|
||||
local function setupSway()
|
||||
local function each(folder, amp, freq, range, leaves)
|
||||
if not folder then
|
||||
return
|
||||
end
|
||||
for _, m in ipairs(folder:GetChildren()) do
|
||||
if m:IsA("Model") then
|
||||
addSway(m, amp, freq, range)
|
||||
if leaves then
|
||||
table.insert(leafTrees, m)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- амплитуда (градусы) и частота (качаний в секунду): деревья — чуть заметно и медленно, трава — живее
|
||||
each(map:FindFirstChild("LobbyTrees"), 0.6, 0.32, 130, true)
|
||||
each(map:FindFirstChild("LobbyForest"), 0.6, 0.32, 130, true)
|
||||
local foot = map:FindFirstChild("LobbyCliffFoot")
|
||||
if foot then
|
||||
each(foot:FindFirstChild("Grass"), 2.8, 0.8, 50)
|
||||
each(foot:FindFirstChild("Flowers"), 3.2, 0.85, 50)
|
||||
each(foot:FindFirstChild("Bushes"), 1, 0.5, 60)
|
||||
end
|
||||
-- падающие листья: у ближайших к площади деревьев, из объёма кроны
|
||||
table.sort(leafTrees, function(a, b)
|
||||
return V(a:GetPivot().Position.X, 0, a:GetPivot().Position.Z).Magnitude < V(b:GetPivot().Position.X, 0, b:GetPivot().Position.Z).Magnitude
|
||||
end)
|
||||
for i = 1, math.min(24, #leafTrees) do
|
||||
local cf, size = leafTrees[i]:GetBoundingBox()
|
||||
local crown = part({ Size = V(size.X * 0.8, size.Y * 0.35, size.Z * 0.8), Transparency = 1, CFrame = cf * CFrame.new(0, size.Y * 0.2, 0) })
|
||||
local pe = Instance.new("ParticleEmitter")
|
||||
pe.Texture = LEAF_TEXTURE
|
||||
pe.Color = ColorSequence.new(Color3.fromRGB(255, 255, 255), Color3.fromRGB(255, 235, 170))
|
||||
pe.Size = NumberSequence.new(0.45)
|
||||
pe.Lifetime = NumberRange.new(6, 9)
|
||||
pe.Rate = 0.15
|
||||
pe.Speed = NumberRange.new(0.2, 0.6)
|
||||
pe.Acceleration = V(0.6, -1.1, 0.2)
|
||||
pe.Drag = 0.6
|
||||
pe.Rotation = NumberRange.new(0, 360)
|
||||
pe.RotSpeed = NumberRange.new(-140, 140)
|
||||
pe.Orientation = Enum.ParticleOrientation.VelocityPerpendicular
|
||||
pe.Shape = Enum.ParticleEmitterShape.Box
|
||||
pe.Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 1), NumberSequenceKeypoint.new(0.08, 0), NumberSequenceKeypoint.new(0.85, 0), NumberSequenceKeypoint.new(1, 1) })
|
||||
pe.LightInfluence = 1
|
||||
pe.Parent = crown
|
||||
end
|
||||
end
|
||||
|
||||
local swayAcc = 0
|
||||
local bulkParts, bulkCFrames = {}, {}
|
||||
local function updateSway(dt, t)
|
||||
swayAcc += dt
|
||||
if swayAcc < 1 / 30 then
|
||||
return
|
||||
end
|
||||
swayAcc = 0
|
||||
local cam = camPos()
|
||||
-- порывы: ветер то стихает, то усиливается
|
||||
local gust = 0.75 + 0.2 * math.sin(t * 0.23) + 0.08 * math.sin(t * 0.71)
|
||||
table.clear(bulkParts)
|
||||
table.clear(bulkCFrames)
|
||||
for _, s in ipairs(swayers) do
|
||||
if (s.base.Position - cam).Magnitude < s.range then
|
||||
local a = s.amp * gust
|
||||
local ax = a * math.sin(t * s.freq * math.pi * 2 + s.phase)
|
||||
local az = a * 0.6 * math.sin(t * s.freq * math.pi * 1.3 + s.phase * 1.7) + a * 0.2 -- лёгкий наклон по ветру
|
||||
local pose = s.base * CFrame.Angles(ax, 0, az)
|
||||
for i, p in ipairs(s.parts) do
|
||||
table.insert(bulkParts, p)
|
||||
table.insert(bulkCFrames, pose * s.rel[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
if #bulkParts > 0 then
|
||||
workspace:BulkMoveTo(bulkParts, bulkCFrames, Enum.BulkMoveMode.FireCFrameChanged)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- запуск
|
||||
|
||||
task.wait(3) -- карта и NPC успевают появиться
|
||||
scanNpcs()
|
||||
setupFlowersFX()
|
||||
setupSway()
|
||||
local scanAt = os.clock()
|
||||
local t0 = os.clock()
|
||||
RunService.RenderStepped:Connect(function(dt)
|
||||
local t = os.clock() - t0
|
||||
if os.clock() - scanAt > 5 then
|
||||
scanAt = os.clock()
|
||||
scanNpcs()
|
||||
end
|
||||
updateNpcs(dt)
|
||||
if (camPos() - LOBBY).Magnitude > LOBBY_VIEW then
|
||||
return -- игрок в другом мире: лобби не анимируем
|
||||
end
|
||||
updateCat(dt, t)
|
||||
updateGulls(dt, t)
|
||||
updateButterflies(dt, t)
|
||||
updateFireflies(t)
|
||||
updateSway(dt, t)
|
||||
end)
|
||||
Reference in new issue
Block a user