Files
roblox-project/bunsik-tycoon/tools/npc_verify_avatars.luau
EJClaw d0ae06e198 feat(bunsik): 손님 외형 다양화 — 로블록스 공식 머리·모자·옷·얼굴 조합(사람 75%), 공식 동물 번들 11종(펭귄·곰·북극곰·고양이·강아지·판다·여우·쥐 등, 25%)
- NpcLooks: 확인된 아이템 표(assets/npc_assets.md), 서버 시작 때 외형 템플릿을 만들어 두고 복제
- 화면 UI 통합 테스트를 새 화면에 맞게 다시 씀(서버 로직은 tests/cloud/server.luau)
- GUI 미리보기를 장면 6개씩 나눠 뽑기(5분 제한·4MB 출력 제한)
- 서버 통합 테스트 1416개, 화면 통합 테스트 379개 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 02:06:09 +09:00

510 lines
13 KiB
Lua

-- 손님 외형(사람·동물) 최종 확인. 로블록스 서버에서 HumanoidDescription으로 실제 모델을 만들어 봅니다.
-- python3 tools/cloud.py run tools/npc_verify_avatars.luau --out assets/npc_animals.rbxm
-- 확인 항목: 생성 성공, 장신구·옷 개수, 크기·HipHeight, 동물 머리 모자가 사람 머리를 덮는 정도,
-- R15 관절 15개 이름, 걷기·대기·앉기 애니메이션 로드(Length>0).
-- 주의: Luau Execution은 시뮬레이션을 돌리지 않아(RunService:IsRunning()=false) 관절이 실제로 움직이는지는 못 봅니다.
-- 마지막에 동물 프리셋 모델을 .rbxm(BinaryOutput)으로 내보내고, 다시 읽어 개수를 확인합니다.
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local SerializationService = game:GetService("SerializationService")
local RunService = game:GetService("RunService")
local function rgb(r, g, b)
return Color3.fromRGB(r, g, b)
end
-- ===== 데이터(npc_assets.md 와 같음) =====
local HAIR = {
63690008,
451221329,
376526888,
376524487,
376548738,
376527350,
451220849,
62234425,
2956239660,
3814476174,
24910539,
7193442167,
9244095135,
6993754725,
7193448258,
9243987340,
7193450455,
7193452166,
9244148336,
430063008,
727320877,
}
local HATS = {
1028606,
607702162,
321570512,
10911990,
67291394,
3756496643,
100932329,
150337770,
118280079,
215724779,
116778296,
833771553,
3756447657,
439943629,
1536057124,
}
local SHIRTS = {
144076358,
607785314,
398633584,
144076436,
398634295,
3670737444,
382538059,
398635081,
382537702,
382537085,
382538295,
4047884939,
4047884046,
4047886060,
}
local PANTS = { 144076760, 398634487, 398633812, 398635338, 382537806, 382538503, 382537569, 382537950 }
local FACE_HEADS = {
10725626210,
10725826963,
11308945948,
15938951781,
10687288296,
10638267973,
10723855306,
13692975981,
11163789916,
12954264879,
13682064263,
130433936882245,
11159990982,
11180212350,
16042049101,
}
local SKIN = { rgb(255, 220, 190), rgb(240, 200, 160), rgb(205, 160, 120), rgb(150, 105, 75) }
type Animal = {
name: string,
body: { number }?, -- Torso, LeftArm, RightArm, LeftLeg, RightLeg
head: number?, -- Head(다이내믹 헤드)
hat: string?, -- HatAccessory(동물 머리 모양 모자)
ears: string?,
tail: string?,
colors: { Color3 }, -- Head, Torso, LeftArm, RightArm, LeftLeg, RightLeg
shirt: number?,
pants: number?,
hideHead: boolean?, -- 모자가 머리를 통째로 덮으면 사람 얼굴이 비치지 않게 Head 투명
lowerHat: boolean?, -- 머리 "위에" 얹히는 모자(아랫면이 머리 꼭대기 근처)를 목까지 내림
}
local W, G = rgb(245, 245, 245), rgb(163, 162, 165)
local ANIMALS: { Animal } = {
{
name = "Penguin",
body = { 46358991, 46359095, 46359040, 46359181, 46359241 },
hat = "15967866",
colors = { W, W, W, W, W, W },
hideHead = true,
},
{
name = "Bear",
body = { 27132957, 27133013, 27132990, 27133040, 27133055 },
hat = "28998435",
lowerHat = true,
colors = {
rgb(160, 110, 80),
rgb(160, 110, 80),
rgb(110, 75, 55),
rgb(110, 75, 55),
rgb(110, 75, 55),
rgb(110, 75, 55),
},
hideHead = true,
},
{
name = "PolarBear",
body = { 137715759, 137715036, 137715073, 137715120, 137715151 },
hat = "137714793",
colors = {
rgb(248, 248, 248),
rgb(248, 248, 248),
rgb(248, 248, 248),
rgb(248, 248, 248),
rgb(248, 248, 248),
rgb(248, 248, 248),
},
hideHead = true,
},
{
name = "Cat",
body = { 146176562, 146176342, 146176447, 146176406, 146176511 },
hat = "146176716",
colors = { G, G, G, G, G, G },
hideHead = true,
},
{
name = "Dog",
body = { 1796148633, 1796137813, 1796141971, 1796143895, 1796146180 },
hat = "1796135151",
colors = { G, G, G, G, G, G },
hideHead = true,
},
{
name = "Panda",
body = { 27132957, 27133013, 27132990, 27133040, 27133055 },
hat = "27369187",
colors = {
rgb(242, 242, 242),
rgb(242, 242, 242),
rgb(30, 30, 30),
rgb(30, 30, 30),
rgb(30, 30, 30),
rgb(30, 30, 30),
},
hideHead = true,
},
{
name = "Fox",
hat = "61773267",
lowerHat = true,
tail = "187846604",
colors = {
rgb(235, 120, 40),
rgb(235, 120, 40),
rgb(235, 120, 40),
rgb(235, 120, 40),
rgb(250, 240, 230),
rgb(250, 240, 230),
},
shirt = 382537702,
pants = 382537806,
hideHead = true,
},
{
name = "Mouse",
hat = "439943629",
colors = {
rgb(170, 185, 215),
rgb(170, 185, 215),
rgb(170, 185, 215),
rgb(170, 185, 215),
rgb(170, 185, 215),
rgb(170, 185, 215),
},
shirt = 398635081,
pants = 144076760,
hideHead = true,
},
{
name = "Bunny",
head = 119665103921086,
ears = "1080949",
tail = "738679517",
colors = { W, W, W, W, W, W },
shirt = 4047886060,
pants = 382537950,
},
{
name = "Kitty",
head = 82082995456115,
ears = "1374269",
tail = "187846604",
colors = {
rgb(250, 200, 140),
rgb(250, 200, 140),
rgb(250, 200, 140),
rgb(250, 200, 140),
rgb(250, 200, 140),
rgb(250, 200, 140),
},
shirt = 382537085,
pants = 398634487,
},
{
name = "Puppy",
head = 138526270057654,
ears = "11142487",
colors = {
rgb(220, 180, 130),
rgb(220, 180, 130),
rgb(220, 180, 130),
rgb(220, 180, 130),
rgb(220, 180, 130),
rgb(220, 180, 130),
},
shirt = 144076436,
pants = 382538503,
},
}
-- ===== 만드는 함수(게임 코드에 그대로 옮길 수 있는 모양) =====
local function setColors(d: HumanoidDescription, c: { Color3 })
d.HeadColor, d.TorsoColor, d.LeftArmColor, d.RightArmColor, d.LeftLegColor, d.RightLegColor =
c[1], c[2], c[3], c[4], c[5], c[6]
end
local function humanDesc(rng: Random): HumanoidDescription
local d = Instance.new("HumanoidDescription")
d.HairAccessory = tostring(HAIR[rng:NextInteger(1, #HAIR)])
if rng:NextNumber() < 0.35 then
d.HatAccessory = tostring(HATS[rng:NextInteger(1, #HATS)])
end
d.Shirt = SHIRTS[rng:NextInteger(1, #SHIRTS)]
d.Pants = PANTS[rng:NextInteger(1, #PANTS)]
d.Head = FACE_HEADS[rng:NextInteger(1, #FACE_HEADS)]
local s = SKIN[rng:NextInteger(1, #SKIN)]
setColors(d, { s, s, s, s, s, s })
local h = 0.85 + rng:NextNumber() * 0.15 -- 어린이~어른 키 섞기
d.HeightScale, d.WidthScale, d.DepthScale, d.HeadScale = h, 0.9, 0.9, 1
return d
end
local function animalDesc(a: Animal): HumanoidDescription
local d = Instance.new("HumanoidDescription")
if a.body then
d.Torso, d.LeftArm, d.RightArm, d.LeftLeg, d.RightLeg = a.body[1], a.body[2], a.body[3], a.body[4], a.body[5]
end
if a.head then
d.Head = a.head
end
d.HatAccessory = a.hat or a.ears or ""
d.WaistAccessory = a.tail or ""
d.Shirt = a.shirt or 0
d.Pants = a.pants or 0
setColors(d, a.colors)
return d
end
-- 모델을 Workspace에 넣고 한 프레임 지난 뒤(장신구 용접이 자리 잡은 뒤) 호출합니다.
local function finishAnimal(m: Model, a: Animal)
local head = m:FindFirstChild("Head") :: BasePart
local hum = m:FindFirstChildOfClass("Humanoid") :: Humanoid
if a.lowerHat then
for _, acc in m:GetChildren() do
if acc:IsA("Accessory") and acc.AccessoryType == Enum.AccessoryType.Hat then
local h = acc:FindFirstChild("Handle") :: BasePart
local drop = (h.Position.Y - h.Size.Y / 2) - (head.Position.Y - head.Size.Y / 2)
local att = h:FindFirstChild("HatAttachment") :: Attachment?
if drop > 0.1 and att then
-- 손잡이 쪽 Attachment를 올리고 다시 붙이면 모자가 그만큼 내려갑니다.
-- (붙이는 관절은 Handle.AccessoryRigidConstraint. Attachment만 옮기면 물리가 돌 때까지 반영이 안 됨)
att.Position += Vector3.new(0, drop, 0)
acc.Parent = nil
hum:AddAccessory(acc)
end
end
end
end
if a.hideHead then
head.Transparency = 1
for _, x in head:GetChildren() do
if x:IsA("Decal") then
x.Transparency = 1
end
end
end
end
-- ===== 확인 =====
local R15_JOINTS = {
"Root",
"Waist",
"Neck",
"LeftShoulder",
"LeftElbow",
"LeftWrist",
"RightShoulder",
"RightElbow",
"RightWrist",
"LeftHip",
"LeftKnee",
"LeftAnkle",
"RightHip",
"RightKnee",
"RightAnkle",
}
local ANIM = { walk = "rbxassetid://507777826", idle = "rbxassetid://507766388", sit = "rbxassetid://2506281703" }
local function hatFit(m: Model): { number }?
-- {모자 아랫면 - 머리 아랫면, 모자 윗면 - 머리 윗면} (스터드). 아랫면 차이가 0 근처면 머리를 다 덮음
local head = m:FindFirstChild("Head") :: BasePart
for _, acc in m:GetChildren() do
if acc:IsA("Accessory") and acc.AccessoryType == Enum.AccessoryType.Hat then
local h = acc:FindFirstChild("Handle") :: BasePart
if h then
local hb, ht = h.Position.Y - h.Size.Y / 2, h.Position.Y + h.Size.Y / 2
local b, t = head.Position.Y - head.Size.Y / 2, head.Position.Y + head.Size.Y / 2
return { math.round((hb - b) * 100) / 100, math.round((ht - t) * 100) / 100 }
end
end
end
return nil
end
local built: { Model } = {}
local summary = { ok = 0, fail = 0 }
local function check(label: string, d: HumanoidDescription, after: ((Model) -> ())?, keep: boolean?)
local t0 = os.clock()
local ok, model = pcall(Players.CreateHumanoidModelFromDescription, Players, d, Enum.HumanoidRigType.R15)
if not ok then
summary.fail += 1
print(HttpService:JSONEncode({ n = label, ok = false, err = tostring(model) }))
return
end
local m = model :: Model
m.Name = label
local anim = m:FindFirstChild("Animate", true)
if anim then
anim:Destroy() -- 플레이어용 LocalScript(서버 NPC에선 안 돌아감)
end
m:PivotTo(CFrame.new(#built * 8, 20, 0))
m.Parent = workspace;
(m:FindFirstChild("HumanoidRootPart") :: BasePart).Anchored = true
RunService.Heartbeat:Wait()
if after then
after(m)
RunService.Heartbeat:Wait()
end
local hum = m:FindFirstChildOfClass("Humanoid") :: Humanoid
local acc, parts, scripts, sa = {}, 0, 0, 0
for _, x in m:GetDescendants() do
if x:IsA("Accessory") then
table.insert(acc, x.Name)
elseif x:IsA("BasePart") then
parts += 1
elseif x:IsA("LuaSourceContainer") then
scripts += 1
elseif x:IsA("SurfaceAppearance") then
sa += 1
end
end
local missing = {}
for _, j in R15_JOINTS do
if not m:FindFirstChild(j, true) then
table.insert(missing, j)
end
end
local animator = hum:FindFirstChildOfClass("Animator") or Instance.new("Animator", hum)
local lens = {}
for k, id in ANIM do
local a = Instance.new("Animation")
a.AnimationId = id
local tr = animator:LoadAnimation(a)
local w0 = os.clock()
while tr.Length == 0 and os.clock() - w0 < 3 do
task.wait(0.05)
end
lens[k] = math.round(tr.Length * 100) / 100
tr:Destroy()
end
local _, size = m:GetBoundingBox()
summary.ok += 1
print(HttpService:JSONEncode({
n = label,
ok = true,
acc = acc,
shirt = m:FindFirstChildOfClass("Shirt") ~= nil,
pants = m:FindFirstChildOfClass("Pants") ~= nil,
parts = parts,
scripts = scripts,
surfaceAppearance = sa,
missingJoints = missing,
anim = lens,
size = string.format("%.1fx%.1fx%.1f", size.X, size.Y, size.Z),
hip = math.round(hum.HipHeight * 100) / 100,
rootY = (m:FindFirstChild("HumanoidRootPart") :: BasePart).Size.Y,
hatFit = hatFit(m),
sec = math.round((os.clock() - t0) * 100) / 100,
}))
if keep then
table.insert(built, m)
else
m:Destroy()
end
end
-- 1) 아이템마다 한 번씩(모두 실제로 붙는지): 사람 기본 몸에 하나씩 넣어 봄
local itemFails = {}
local function itemCheck(kind: string, id: number, apply: (HumanoidDescription) -> ())
local d = Instance.new("HumanoidDescription")
apply(d)
local ok, m = pcall(Players.CreateHumanoidModelFromDescription, Players, d, Enum.HumanoidRigType.R15)
if not ok then
table.insert(itemFails, kind .. " " .. id .. " " .. tostring(m))
return
end
local good
if kind == "hair" or kind == "hat" then
good = m:FindFirstChildOfClass("Accessory") ~= nil
elseif kind == "shirt" then
good = m:FindFirstChildOfClass("Shirt") ~= nil
elseif kind == "pants" then
good = m:FindFirstChildOfClass("Pants") ~= nil
else
local head = m:FindFirstChild("Head") :: MeshPart
good = head:IsA("MeshPart") and head.MeshId ~= "" and not string.find(head.MeshId, "123480233606534")
end
if not good then
table.insert(itemFails, kind .. " " .. id .. " not applied")
end
m:Destroy()
end
for _, id in HAIR do
itemCheck("hair", id, function(d)
d.HairAccessory = tostring(id)
end)
end
for _, id in HATS do
itemCheck("hat", id, function(d)
d.HatAccessory = tostring(id)
end)
end
for _, id in SHIRTS do
itemCheck("shirt", id, function(d)
d.Shirt = id
end)
end
for _, id in PANTS do
itemCheck("pants", id, function(d)
d.Pants = id
end)
end
for _, id in FACE_HEADS do
itemCheck("faceHead", id, function(d)
d.Head = id
end)
end
print(HttpService:JSONEncode({
items = #HAIR + #HATS + #SHIRTS + #PANTS + #FACE_HEADS,
itemFails = itemFails,
}))
-- 2) 사람 무작위 조합 6개
local rng = Random.new(7)
for i = 1, 6 do
check("Human" .. i, humanDesc(rng), nil, i == 1)
end
-- 3) 동물 프리셋
for _, a in ANIMALS do
check(a.name, animalDesc(a), function(m)
finishAnimal(m, a)
end, true)
end
-- 4) .rbxm 으로 내보내고 다시 읽어 보기
for _, m in built do
m.Parent = nil
(m:FindFirstChild("HumanoidRootPart") :: BasePart).Anchored = false
end
local buf = SerializationService:SerializeInstancesAsync(built)
local back = SerializationService:DeserializeInstancesAsync(buf)
print(HttpService:JSONEncode({ rbxmBytes = buffer.len(buf), models = #built, roundTrip = #back }))
return { BinaryOutput = buf, ReturnValues = { summary.ok, summary.fail, #itemFails } }