Files
WoW-Hybrid-gateway/ops/item_random_property_enchants.py

42 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Source ItemRandomProperties -> its SpellItemEnchantment ids (PROP_ENCHANTMENT_SLOT_0..2).
70334 has no ItemRandomProperties table and item_random_property_profile (native ItemBonus lists) is empty, so a
random-property item ("of the Eagle") is presented like the bag path does it: the base item plus the property's
enchantments in enchant slots 3..5. Mail attachments need the ids because Turtle's SMSG_MAIL_LIST_RESULT sends only
the property id, not the item's enchant fields.
usage: item_random_property_enchants.py <server dbc dir> <out.hpp>
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from turtle_data import DBC # noqa: E402
def main(dbc_dir, out):
d = DBC(Path(dbc_dir) / 'ItemRandomProperties.dbc', 16) # ID, InternalName, Enchantment[5], Name_lang[9]
rows = sorted((r[0], r[2], r[3], r[4]) for r in d.rows if r[0] and any(r[2:5]))
assert all(not r[5] and not r[6] for r in d.rows), 'ItemRandomProperties uses more than 3 enchantments'
body = ','.join('{%d,{%d,%d,%d}}' % r for r in rows)
Path(out).write_text(f'''// Generated by ops/item_random_property_enchants.py from the server ItemRandomProperties.dbc; do not edit.
#pragma once
#include <algorithm>
#include <array>
#include <cstdint>
#include <iterator>
namespace gateway::item_random_property_enchants {{
struct Row {{uint32_t property; std::array<uint32_t,3> enchants;}};
inline constexpr Row Rows[]={{{body}}};
inline const Row* find(uint32_t property){{
auto p=std::lower_bound(std::begin(Rows),std::end(Rows),property,[](const Row& r,uint32_t v){{return r.property<v;}});
return p!=std::end(Rows) && p->property==property?p:nullptr;
}}
}}
''')
print('properties', len(rows))
if __name__ == '__main__':
main(*sys.argv[1:3])