Package: dbcpy
AboutThis repository contains code for a python3 library that is capable of editing variousDBCfiles.
The library was only tested with 3.3.5a DBCs and aTrinityCoreserver.
If this library dose not fit your use case, please consider usingpywowlib. Although
pywowlib's README states that reading/writing DBCs is not possible,the features seem to be already implemented.InstalationpipinstalldbcpyRecordsdbcpy dose NOT useWoWDBDefsto parse the DBCs.
DBC representations must be added manually, for a list of supported DBCs seerecordsAdding recordsAdding a record is easy. Just pick a copy-paste the definition fromhereinto a python dictionary and define a new dataclass. Seethisfor a
reference implementation.ExamplesModifying an existing items' display_ids (will take ~1 second)#!/usr/bin/env python3fromdbcpy.dbc_fileimportDBCFilefromdbcpy.records.item_recordimportItemRecorddefchange_display_ids(item_record):# entry: new_display_idnew_display_ids={1501:37388,15534:27083,}try:item_record.display_id=new_display_ids[item_record.entry]returnitem_recordexceptKeyError:returnitem_recordif__name__=='__main__':withopen('Item.dbc','r+b')asf:dbc_file=DBCFile.from_file(f,ItemRecord)some_item=dbc_file.records.find(873)some_item.entry=56807some_item.display_id=20300withopen('Item.dbc.new','w+b')asff:dbc_file.write_to_file(change_display_ids,ff)withopen('Item.dbc.new','r+b')asf:dbc_file=DBCFile.from_file(f,ItemRecord)print(dbc_file.records.find(1501).display_id)print(dbc_file.records.find(15534).display_id)Adding a Spell.dbc entry (will take >1 second):#!/usr/bin/env python3fromdbcpy.dbc_fileimportDBCFilefromdbcpy.records.spell_recordimportSpellRecordif__name__=='__main__':withopen('Spell.dbc','r+b')asf:dbc_file=DBCFile.from_file(f,SpellRecord)some_spell=dbc_file.records.find(116)some_spell.name.en_us='New spell name'some_spell.entry=80865dbc_file.records.append(some_spell)withopen('Spell.dbc','r+b')asf:dbc_file=DBCFile.from_file(f,SpellRecord)the_spell=dbc_file.records.find(80865)print(the_spell.name.en_us)Modyfing an existing spells' names (will take ~30 seconds)#!/usr/bin/env python3fromdbcpy.dbc_fileimportDBCFilefromdbcpy.records.spell_recordimportSpellRecorddefrename_spell(spell_record):new_names={8716:'i love',37263:'long',37290:'discussions',}try:spell_record.name.en_us=new_names[spell_record.entry]returnspell_recordexceptKeyError:returnspell_recordif__name__=='__main__':withopen('Spell.dbc','r+b')asf:dbc_file=DBCFile.from_file(f,SpellRecord)withopen('Spell.dbc.new','w+b')asff:dbc_file.write_to_file(rename_spell,ff)withopen('Spell.dbc.new','r+b')asf:dbc_file=DBCFile.from_file(f,SpellRecord)print(dbc_file.records.find(8716).name.en_us)print(dbc_file.records.find(37263).name.en_us)print(dbc_file.records.find(37290).name.en_us)Why dose modifying an existing record takes so long?Well, not always. In order to modify an existing record, we must rewrite the whole DBC file, because of the string block.
The SpellRecord is especiallylargeand theRecordReader.read_recordmethod is not suited for readinglargerecords like that. It handles smaller records (like ItemRecord) well enough (~1 second).
The simplest fix would be to implement a SpellRecord specific RecordReader.How to contribute?Ensure that your commits have meaningful commentsIf your contribution is small (e.g it fixes a minor bug) increment revision (the last digit of version) insetup.pyProvide test-casesLegal NoteWorld of Warcraft is a registered trademark of Blizzard Entertainment and/or other respective owners.
This software is not created by Blizzard Entertainment or its affiliates, and is for purely educational and research purposes.
This software is not intended for the use and production of cheating (hacking) software or modifications that can disrupt World of Warcraft's gameplay.
It is your sole responsibility to follow copyright law, game's ToS and EULA.
The creators hold no responsibility for the consequences of use of this software.The code is licensed underLGPL 3.0.