Броня в семи местах и три зоны урона
- В реестр заведены 46 предметов одежды ремейка: слот, слой, какие части тела закрывает и сколько снимает из каждого вида вреда. Данные выгружены в items.csv (extract-items.py), в коде у каждого предмета armor(...). - Семь мест: голова, лицо, грудь (2 слоя), ноги (2 слоя), руки, стопы, полный костюм. Пояс не делали - в ремейке его нет, есть только быстрая панель. - Inventory сервера: семь мест по два слоя, вещи надеваются и снимаются. - Damage: зона урона по точке попадания (голова верхние 0.4, ноги нижние 0.4), множители голова 2, тело 1, ноги 0.75; одежда снимает вред только там, где закрывает. - Пакет Attack (цель, точка попадания, рука) и клиентский патч, который его шлёт. У игрока появилась жизнь. - В items.csv добавлены колонки armor_slot, armor_layer, armor_zones. Тесты: протокол 24 + 10, сервер 85. Форк собирается чисто, 3279 классов.
This commit is contained in:
+48
-4
@@ -28,6 +28,15 @@ LANG = ROOT / "assets" / "rustex" / "legacy" / "minecraft" / "rustex_lang" / "en
|
||||
OUT_CSV = ROOT / "rsx-protocol" / "src" / "main" / "resources" / "items" / "items.csv"
|
||||
OUT_TEXTS = ROOT / "rsx-protocol" / "src" / "main" / "resources" / "items" / "item-texts.json"
|
||||
|
||||
# The slots of clothing, as the remake names them, and our seven places:
|
||||
# the head, the face, the chest, the legs, the hands, the feet and the whole
|
||||
# body. The chest and the legs have two layers.
|
||||
SLOT_NAMES = {
|
||||
"helmet": "1", "hat": "2", "plate": "3", "jacket": "3",
|
||||
"pants": "4", "kilt": "4", "gloves": "5", "boots": "6", "suit": "7",
|
||||
}
|
||||
LAYER_NAMES = {"plate": "0", "jacket": "1", "pants": "0", "kilt": "1"}
|
||||
|
||||
# The columns of the table, in the order they are written.
|
||||
COLUMNS = [
|
||||
"rid", "name", "category", "material", "nid",
|
||||
@@ -242,6 +251,30 @@ def parse_lang(text: str):
|
||||
return out
|
||||
|
||||
|
||||
def read_armor(records):
|
||||
"""The clothing of every item: the slot, the layer and what it covers."""
|
||||
out = {}
|
||||
for rec in records:
|
||||
m = re.search(r'rid:"([^"]+)"', rec)
|
||||
s = re.search(r'armorslot\.([a-z_]+):1b', rec)
|
||||
if not (m and s):
|
||||
continue
|
||||
slot = SLOT_NAMES.get(s.group(1))
|
||||
if slot is None:
|
||||
continue
|
||||
layer = LAYER_NAMES.get(s.group(1), "0")
|
||||
zones = 0
|
||||
if "dorend.head:1b" in rec:
|
||||
zones |= 1
|
||||
if ("dorend.body:1b" in rec or "dorend.left_arm:1b" in rec
|
||||
or "dorend.right_arm:1b" in rec):
|
||||
zones |= 2
|
||||
if "dorend.left_leg:1b" in rec or "dorend.right_leg:1b" in rec:
|
||||
zones |= 4
|
||||
out[m.group(1)] = (slot, layer, str(zones))
|
||||
return out
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if not STACKS.is_file():
|
||||
print("нет stacks.json:", STACKS)
|
||||
@@ -268,10 +301,21 @@ def main() -> int:
|
||||
# What the table has to tell us about the weapons.
|
||||
guns = [i for i in items if i.get("gun")]
|
||||
print("огнестрела в таблице:", len(guns))
|
||||
for gun in guns:
|
||||
print(" %-22s id=%-3s магазин=%-3s модель=%s"
|
||||
% (gun["rid"], gun.get("weapon_id", "?"), gun.get("ammo", "?"),
|
||||
gun.get("model", "-")))
|
||||
|
||||
# and the clothing: the slot it goes in, the layer and what it covers
|
||||
armor = read_armor(STACKS.read_text(encoding="utf-8", errors="replace").split("\n"))
|
||||
for item in items:
|
||||
slot, layer, zones = armor.get(item["rid"], ("", "", ""))
|
||||
item["armor_slot"] = slot
|
||||
item["armor_layer"] = layer
|
||||
item["armor_zones"] = zones
|
||||
columns = COLUMNS + ["armor_layer", "armor_zones"]
|
||||
with OUT_CSV.open("w", encoding="utf-8", newline="") as handle:
|
||||
writer = csv.DictWriter(handle, fieldnames=columns, extrasaction="ignore")
|
||||
writer.writeheader()
|
||||
for item in items:
|
||||
writer.writerow({key: item.get(key, "") for key in columns})
|
||||
print("с одеждой:", sum(1 for i in items if i.get("armor_slot")))
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user