diff options
Diffstat (limited to 'hercules')
-rw-r--r-- | hercules/code/configutils.py | 30 | ||||
-rw-r--r-- | hercules/code/server/tmw/itemdb.py | 5 | ||||
-rw-r--r-- | hercules/code/server/tmw/main.py | 2 | ||||
-rw-r--r-- | hercules/code/server/tmw/mobdb.py | 155 |
4 files changed, 117 insertions, 75 deletions
diff --git a/hercules/code/configutils.py b/hercules/code/configutils.py index a20f3a0..6d9ddb2 100644 --- a/hercules/code/configutils.py +++ b/hercules/code/configutils.py @@ -8,20 +8,44 @@ def writeIntField(w, name, value): value = "0" w.write(" {0}: {1}\n".format(name, value)) +def writeIntField2(w, name, value): + if value == "": + value = "0" + w.write(" {0}: {1}\n".format(name, value)) + def writeStrField(w, name, value): w.write(" {0}: \"{1}\"\n".format(name, value)) +def writeCondField2(w, cond, name): + if cond != 0: + w.write(" {0}: true\n".format(name)) + def writeSubField(w, name, value): - w.write(" {0}: {1}\n".format(name, value)); + w.write(" {0}: {1}\n".format(name, value)) + +def writeFieldArr(w, name, value, value2): + w.write(" {0}: [{1}, {2}]\n".format(name, value, value2)) + +def writeFieldList(w, name, value, value2): + w.write(" {0}: ({1}, {2})\n".format(name, value, value2)) def writeStartBlock(w, text): - w.write(" {0}: {{\n".format(text)); + w.write(" {0}: {{\n".format(text)) def writeEndBlock(w): - w.write(" }\n"); + w.write(" }\n") def writeStartScript(w, name): w.write(" {0}: <\"\n".format(name)) def writeEndScript(w): w.write(" \">\n") + +def isHaveData(fields, start, cnt): + for f in range(0, cnt): + value = fields[start + f * 2] + chance = fields[start + f * 2] + if value == "" or value == "0" or chance == "" or chance == "0": + continue + return True + return False diff --git a/hercules/code/server/tmw/itemdb.py b/hercules/code/server/tmw/itemdb.py index ecd69ca..6e3145c 100644 --- a/hercules/code/server/tmw/itemdb.py +++ b/hercules/code/server/tmw/itemdb.py @@ -170,8 +170,9 @@ def convertItemDb(isNew): for f in xrange(0, sz): rows[f] = rows[f].strip() - items[rows[1]] = {'id':rows[0],'buy':rows[4]} - items[rows[0]] = {'id':rows[0],'buy':rows[4]} + items[rows[1]] = {'id':rows[0],'buy':rows[4],'name':rows[1]} + items[rows[0]] = {'id':rows[0],'buy':rows[4],'name':rows[1]} + items[int(rows[0])] = {'id':rows[0],'buy':rows[4],'name':rows[1]} # set all values then write w.write("{\n") c.write("{0}\t{1}\n".format(rows[1], rows[0])) diff --git a/hercules/code/server/tmw/main.py b/hercules/code/server/tmw/main.py index 330c860..2831877 100644 --- a/hercules/code/server/tmw/main.py +++ b/hercules/code/server/tmw/main.py @@ -31,7 +31,7 @@ def serverTmwMain(isNew): items = convertItemDb(isNew) npcIds = Set() convertNpcs(items, npcIds) - convertMobDb() + convertMobDb(items) quests = dict() convertConsts(quests, npcIds) convertMobSkillDb() diff --git a/hercules/code/server/tmw/mobdb.py b/hercules/code/server/tmw/mobdb.py index 67b0f21..3b3da62 100644 --- a/hercules/code/server/tmw/mobdb.py +++ b/hercules/code/server/tmw/mobdb.py @@ -5,6 +5,7 @@ import re, math +from code.configutils import * from code.fileutils import * from code.stringutils import * @@ -14,11 +15,13 @@ def getMobDbFile(srcDir): if srcFile.find("mob_db") >= 0: yield srcFile -def convertMobDb(): +def convertMobDb(items): srcDir = "oldserverdata/world/map/db/" - dstFile = "newserverdata/db/re/mob_db.txt" + dstFile = "newserverdata/db/re/mob_db.conf" fieldsSplit = re.compile(",") + tpl = readFile("templates/mob_db.tpl") with open(dstFile, "w") as w: + w.write(tpl) for srcFile in getMobDbFile(srcDir): with open(srcDir + srcFile, "r") as r: for line in r: @@ -65,71 +68,85 @@ def convertMobDb(): else: calc_exp = rows[6] - w.write("{0:<5} {1:<23} {2:<23} {3:<23} {4:<5} {5:<6} {6:<3} " - "{7:<7} {8:<6} {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] + ",", - str(calc_exp) + ",", - 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] + ",", - "10,", - 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" - )) + w.write("{\n") + writeIntField(w, "Id", rows[0]) + writeStrField(w, "SpriteName", rows[1]) + writeStrField(w, "Name", rows[2]) + writeIntField(w, "Lv", rows[3]) + writeIntField(w, "Hp", rows[4]) + writeIntField(w, "Sp", rows[5]) + writeIntField(w, "Exp", calc_exp) + writeIntField(w, "JExp", rows[7]) + writeIntField(w, "AttackRange", rows[8]) + writeFieldArr(w, "Attack", rows[9], rows[10]) + writeIntField(w, "Def", rows[11]) + writeIntField(w, "Mdef", rows[12]) + writeStartBlock(w, "Stats") + writeIntField2(w, "Str", rows[13]) + writeIntField2(w, "Agi", rows[14]) + writeIntField2(w, "Vit", rows[15]) + writeIntField2(w, "Int", rows[16]) + writeIntField2(w, "Dex", rows[17]) + writeIntField2(w, "Luk", rows[18]) + writeEndBlock(w) + writeIntField(w, "ViewRange", rows[19]) + writeIntField(w, "ChaseRange", 10) + writeIntField(w, "Size", rows[21]) + writeIntField(w, "Race", rows[22]) + writeFieldList(w, "Element", int(rows[23]) % 10, int(rows[23]) / 20) + mode = int(rows[24], 0) + if mode != 0: + writeStartBlock(w, "Mode") + writeCondField2(w, mode & 0x0001, "CanMove") + writeCondField2(w, mode & 0x0002, "Looter") + writeCondField2(w, mode & 0x0004, "Aggressive") + writeCondField2(w, mode & 0x0008, "Assist") + writeCondField2(w, mode & 0x0010, "CastSensorIdle") + writeCondField2(w, mode & 0x0020, "Boss") + writeCondField2(w, mode & 0x0040, "Plant") + writeCondField2(w, mode & 0x0080, "CanAttack") + writeCondField2(w, mode & 0x0100, "Detector") + writeCondField2(w, mode & 0x0200, "CastSensorChase") + writeCondField2(w, mode & 0x0400, "ChangeChase") + writeCondField2(w, mode & 0x0800, "Angry") + writeCondField2(w, mode & 0x1000, "ChangeTargetMelee") + writeCondField2(w, mode & 0x2000, "ChangeTargetChase") + writeCondField2(w, mode & 0x4000, "TargetWeak") + writeCondField2(w, mode & 0x8000, "LiveWithoutMaster") + writeEndBlock(w) + writeIntField(w, "MoveSpeed", rows[25]) + writeIntField(w, "AttackDelay", rows[26]) + writeIntField(w, "AttackMotion", rows[27]) + writeIntField(w, "DamageMotion", rows[28]) + writeIntField(w, "MvpExp", rows[45]) + if isHaveData(rows, 47, 3): + writeStartBlock(w, "MvpDrops") + for f in range(0, 3): + value = rows[47 + f * 2] + chance = rows[47 + f * 2] + if value == "" or value == "0" or chance == "" or chance == "0": + continue + value = int(value) + if value not in items: + w.write("// Error: mvp drop with id {0} not found in item db\n".format(value)) + print("Error: mvp drop with id {0} not found in item db".format(value)) + else: + writeSubField(w, items[value]["name"], chance) + writeEndBlock(w) + if isHaveData(rows, 29, 10): + writeStartBlock(w, "Drops") + for f in range(0, 10): + value = rows[29 + f * 2] + chance = rows[30 + f * 2] + if value == "" or value == "0" or chance == "" or chance == "0": + continue + value = int(value) + if value not in items: + w.write("// Error: drop with id {0} not found in item db\n".format(value)) + print("Error: drop with id {0} not found in item db".format(value)) + else: + writeSubField(w, items[value]["name"], chance) + writeEndBlock(w) + w.write("},\n") + w.write(")\n") |