123
This commit is contained in:
1 parent
1a0e54a933
commit
296988b199
71 files changed
+575263
-93130
No files matched your search
@@ -86,25 +86,41 @@ local function buildNoWalk(map)
|
||||
LobbyCliffs = true, LobbyCliffDecor = true, LobbyCliffFoot = true, LobbyForest = true, LobbyTrees = true,
|
||||
LobbyRockPlants = true, LobbyHillForest = true, LobbyHaze = true, FishingZones = true, World1Map = true,
|
||||
}
|
||||
-- небольшая модель (скамейка, клумба, фонарь, бочка) — одна зона по её габаритам;
|
||||
-- большая (фонтан, гирлянда между столбами, здание) — по отдельным деталям, иначе под запрет
|
||||
-- попала бы вся площадь между её краями. Папки обходим вглубь: декор лобби лежит в папках
|
||||
local SMALL = 10 -- стадов по большей стороне
|
||||
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
|
||||
if math.max(size.X, size.Z) <= SMALL then
|
||||
block(cf, size)
|
||||
else
|
||||
for _, c in ipairs(inst:GetChildren()) do
|
||||
consider(c)
|
||||
end
|
||||
end
|
||||
elseif inst:IsA("Folder") then
|
||||
if not skip[inst.Name] and inst.Name ~= "NpcNoWalk" then
|
||||
for _, c in ipairs(inst:GetChildren()) do
|
||||
consider(c)
|
||||
end
|
||||
end
|
||||
elseif inst:IsA("BasePart") and (inst.Transparency < 0.95 or inst:IsA("Seat")) and (inst.CanCollide or inst:IsA("Seat")) 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
|
||||
if not skip[c.Name] 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
|
||||
if c ~= map and (c:IsA("Model") or c:IsA("BasePart") or c:IsA("Folder")) and not c:IsA("Terrain") then
|
||||
consider(c)
|
||||
end
|
||||
end
|
||||
@@ -195,6 +211,7 @@ local function walker(def, map)
|
||||
hum.NameDisplayDistance = 35
|
||||
root.Anchored = false
|
||||
pcall(function() root:SetNetworkOwner(nil) end) -- двигает сервер, у всех одинаково
|
||||
hum:SetStateEnabled(Enum.HumanoidStateType.Seated, false) -- жители не садятся на скамейки сами
|
||||
startIdle(rig)
|
||||
local walk = loadAnim(hum, ANIM.walk)
|
||||
walk.Looped = true
|
||||
@@ -210,6 +227,7 @@ local function walker(def, map)
|
||||
end)
|
||||
if ok and path.Status == Enum.PathStatus.Success then
|
||||
walk:Play(0.25, 1, def.speed / 8)
|
||||
local lastGood = root.Position
|
||||
for _, wp in ipairs(path:GetWaypoints()) do
|
||||
if not rig.Parent then
|
||||
return
|
||||
@@ -217,8 +235,14 @@ local function walker(def, map)
|
||||
hum:MoveTo(wp.Position)
|
||||
local reached = hum.MoveToFinished:Wait()
|
||||
if not reached then
|
||||
break -- застрял: выберем другую точку
|
||||
-- застрял (упёрся в игрока или край): вернуть на последнюю пройденную точку
|
||||
-- и выбрать другую цель — житель не остаётся внутри скамейки или клумбы
|
||||
if inside(root.Position) then
|
||||
root.CFrame = CFrame.new(lastGood) * (root.CFrame - root.Position)
|
||||
end
|
||||
break
|
||||
end
|
||||
lastGood = wp.Position + Vector3.new(0, 2, 0)
|
||||
end
|
||||
walk:Stop(0.3)
|
||||
end
|
||||
@@ -254,3 +278,56 @@ end
|
||||
for _, def in ipairs(WALKERS) do
|
||||
walker(def, map)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- сиденья: только по кнопке «Сесть»
|
||||
-- Roblox сажает всякого, кто коснулся Seat. Во всей игре (лобби и миры) сиденья выключены (Disabled),
|
||||
-- на каждом — подсказка «Сесть» (E). По нажатию сиденье на миг включается и сажает игрока;
|
||||
-- встать — прыжком, после этого сиденье снова выключено. NPC так сесть не могут.
|
||||
|
||||
local function setupSeat(seat)
|
||||
if seat:GetAttribute("SitPrompt") then
|
||||
return
|
||||
end
|
||||
seat:SetAttribute("SitPrompt", true)
|
||||
seat.Disabled = true
|
||||
local pp = Instance.new("ProximityPrompt")
|
||||
pp.Name = "SitPrompt"
|
||||
pp.ActionText = "Сесть"
|
||||
pp.ObjectText = ""
|
||||
pp.KeyboardKeyCode = Enum.KeyCode.E
|
||||
pp.HoldDuration = 0
|
||||
pp.MaxActivationDistance = 6
|
||||
pp.RequiresLineOfSight = false
|
||||
pp.Style = Enum.ProximityPromptStyle.Default
|
||||
pp.Parent = seat
|
||||
pp.Triggered:Connect(function(player)
|
||||
local hum = player.Character and player.Character:FindFirstChildOfClass("Humanoid")
|
||||
if not hum or hum.Health <= 0 or seat.Occupant or hum.SeatPart then
|
||||
return
|
||||
end
|
||||
seat.Disabled = false
|
||||
seat:Sit(hum)
|
||||
task.delay(0.3, function()
|
||||
if not seat.Occupant then
|
||||
seat.Disabled = true -- не получилось сесть — не оставлять сиденье включённым
|
||||
end
|
||||
end)
|
||||
end)
|
||||
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
|
||||
pp.Enabled = seat.Occupant == nil
|
||||
if not seat.Occupant then
|
||||
seat.Disabled = true
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
for _, d in ipairs(workspace:GetDescendants()) do
|
||||
if d:IsA("Seat") then
|
||||
setupSeat(d)
|
||||
end
|
||||
end
|
||||
workspace.DescendantAdded:Connect(function(d)
|
||||
if d:IsA("Seat") then
|
||||
setupSeat(d)
|
||||
end
|
||||
end)
|
||||
Reference in new issue
Block a user