BurningTimesAi/공유/기획/FirstRising/맵/tools/boss_blockers.py

35 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
# 보스전 자리(반지름 r) 안에 발자국이 걸리는 막는 소품을 뽑는다 — 빌더가 남긴 소품 기록(_props.json)과 맵 정의를 읽는다.
# python boss_blockers.py <맵 이름> [여유 m]
import io, json, math, os, sys, glob
root = r"C:\BurningTimes\FirstRising"
name = sys.argv[1]
pad = float(sys.argv[2]) if len(sys.argv) > 2 else 0.0
d = json.loads(io.open(os.path.join(root, "Assets/BurningTimes/Maps/%s/%s.map.json" % (name, name)), encoding="utf-8-sig").read())
boss = d["boss"]
cands = glob.glob(os.path.join(root, "Logs", "*%s*props*.json" % name.lower())) + glob.glob(os.path.join(root, "Assets/BurningTimes/Maps", name, "*props*.json"))
print("기록 파일", cands)
rec = json.loads(io.open(cands[0], encoding="utf-8-sig").read())
items = rec.get("props") or rec.get("items") or rec
print("항목", len(items), "예", items[0])
bx, bz, br = boss["x"], boss["z"], boss["r"]
hits = []
for it in items:
how = it.get("how", "")
if not how.startswith("block"):
continue
if how == "block-trunk":
hx = hz = max(0.28, min(0.7, min(it["sx"], it["sz"]) * 0.12))
else:
hx, hz = max(it["sx"] * 0.34, 0.25), max(it["sz"] * 0.34, 0.25)
# 원과 사각형 사이의 가장 가까운 거리
dx = max(abs(it["x"] - bx) - hx, 0.0)
dz = max(abs(it["z"] - bz) - hz, 0.0)
dist = math.hypot(dx, dz)
if dist < br + pad:
hits.append((dist, it))
hits.sort(key=lambda h: h[0])
print("보스 자리 (%.1f, %.1f) r %.1f · 여유 %.1f — 걸리는 막는 소품 %d" % (bx, bz, br, pad, len(hits)))
for dist, it in hits:
print(" %-42s %-11s (%.1f, %.1f) 크기 %.1f × %.1f × %.1f · 발자국까지 %.1f m · 중심 거리 %.1f" % (it["name"], it["how"], it["x"], it["z"], it["sx"], it["sy"], it["sz"], dist, math.hypot(it["x"] - bx, it["z"] - bz)))