diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-29 14:53:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-29 14:53:25 +0300 |
commit | 3e422ea7eb8e83638971bdff4f584db2750ee0a4 (patch) | |
tree | 6f8273bbfaad60cccc3b52c628f839dd6bd59149 /hercules/code/server/tmw | |
parent | c69198c97f9b8b2f0cee5b4b3274b38da164cf7d (diff) | |
download | tools-3e422ea7eb8e83638971bdff4f584db2750ee0a4.tar.gz tools-3e422ea7eb8e83638971bdff4f584db2750ee0a4.tar.bz2 tools-3e422ea7eb8e83638971bdff4f584db2750ee0a4.tar.xz tools-3e422ea7eb8e83638971bdff4f584db2750ee0a4.zip |
hercules: add support for convert mob_db from tmw.
Diffstat (limited to 'hercules/code/server/tmw')
-rw-r--r-- | hercules/code/server/tmw/main.py | 4 | ||||
-rw-r--r-- | hercules/code/server/tmw/mobdb.py | 98 |
2 files changed, 100 insertions, 2 deletions
diff --git a/hercules/code/server/tmw/main.py b/hercules/code/server/tmw/main.py index 9512a97..ed15533 100644 --- a/hercules/code/server/tmw/main.py +++ b/hercules/code/server/tmw/main.py @@ -6,7 +6,7 @@ from code.server.consts import * from code.server.tmw.itemdb import * -from code.server.mobdb import * +from code.server.tmw.mobdb import * from code.server.mobskilldb import * from code.server.tmw.npcs import * from code.server.utils import * @@ -18,7 +18,7 @@ def serverTmwMain(): createMainScript() items = convertItemDb() convertNpcs(items) - #convertMobDb() + convertMobDb() #quests = convertQuestsDb() #convertConsts(quests) #convertMobSkillDb() diff --git a/hercules/code/server/tmw/mobdb.py b/hercules/code/server/tmw/mobdb.py new file mode 100644 index 0000000..5545d3b --- /dev/null +++ b/hercules/code/server/tmw/mobdb.py @@ -0,0 +1,98 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2014 Evol Online +# Author: Andrei Karas (4144) + +import re + +from code.fileutils import * +from code.stringutils import * + +def getMobDbFile(srcDir): + files = os.listdir(srcDir) + for srcFile in files: + if srcFile.find("mob_db.txt") >= 0: + yield srcFile + +def convertMobDb(): + srcDir = "oldserverdata/db/" + dstFile = "newserverdata/db/re/mob_db.txt" + fieldsSplit = re.compile(",") + with open(dstFile, "w") as w: + for srcFile in getMobDbFile(srcDir): + with open(srcDir + srcFile, "r") as r: + for line in r: + if len(line) < 2: + w.write(line) + continue + rows = fieldsSplit.split(line) + for f in xrange(0, len(rows)): + rows[f] = rows[f].strip() + w.write("{0:<5} {1:<15} {2:<16} {3:<16} {4:<5} {5:<5} {6:<5} " + "{7:<5} {8:<5} {9:<7} {10:<5} {11:<5} {12:<5} {13:<5} " + "{14:<5} {15:<5} {16:<5} {17:<5} {18:<5} {19:<5} {20:<7}" + " {21:<7} {22:<6} {23:<5} {24:<8} {25:<8} {26:<6} " + "{27:<8} {28:<9} {29:<8} {30:<5} {31:<7} {32:<8} {33:<7}" + " {34:<8} {35:<7} {36:<8} {37:<8} {38:<9} {39:<8} " + "{40:<9} {41:<8} {42:<9} {43:<8} {44:<9} {45:<8} {46:<9}" + " {47:<8} {48:<9} {49:<8} {50:<9} {51:<8} {52:<9} " + "{53:<8} {54:<9} {55:<8} {56:<8} \n".format( + rows[0] + ",", + rows[1] + ",", + rows[2] + ",", + rows[2] + ",", + rows[3] + ",", + rows[4] + ",", + rows[5] + ",", + rows[6] + ",", + rows[7] + ",", + rows[8] + ",", + rows[9] + ",", + rows[10] + ",", + rows[11] + ",", + rows[12] + ",", + rows[13] + ",", + rows[14] + ",", + rows[15] + ",", + rows[16] + ",", + rows[17] + ",", + rows[18] + ",", + rows[19] + ",", + rows[20] + ",", + rows[21] + ",", + rows[22] + ",", + rows[23] + ",", + rows[24] + ",", + rows[25] + ",", + rows[26] + ",", + rows[27] + ",", + rows[28] + ",", + rows[45] + ",", + rows[47] + ",", + rows[48] + ",", + rows[49] + ",", + rows[50] + ",", + rows[51] + ",", + rows[52] + ",", + rows[29] + ",", + rows[30] + ",", + rows[31] + ",", + rows[32] + ",", + rows[33] + ",", + rows[34] + ",", + rows[35] + ",", + rows[36] + ",", + rows[37] + ",", + rows[38] + ",", + rows[39] + ",", + rows[40] + ",", + rows[41] + ",", + rows[42] + ",", + rows[43] + ",", + rows[44] + ",", + "0,", + "0,", + "0,", + "0" + )) + |