From e083ec710171239abfc2014c88f54363feaf3e0d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 3 Sep 2014 18:16:01 +0300 Subject: hercules: add conversion from item_db to items.xml. --- hercules/itemstoxml.py | 1 + hercules/maptool.py | 93 +++++++++++++++++++++++++++ hercules/templates/item.tpl | 11 ++++ hercules/templates/items.xml | 150 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 255 insertions(+) create mode 120000 hercules/itemstoxml.py create mode 100644 hercules/templates/item.tpl create mode 100644 hercules/templates/items.xml diff --git a/hercules/itemstoxml.py b/hercules/itemstoxml.py new file mode 120000 index 0000000..df2b3e6 --- /dev/null +++ b/hercules/itemstoxml.py @@ -0,0 +1 @@ +maptool.py \ No newline at end of file diff --git a/hercules/maptool.py b/hercules/maptool.py index ef7fec3..ac0ceef 100755 --- a/hercules/maptool.py +++ b/hercules/maptool.py @@ -28,6 +28,8 @@ def detectCommand(): return "mapstotmx" elif sys.argv[0][-15:] == "/queststoxml.py": return "queststoxml" + elif sys.argv[0][-14:] == "/itemstoxml.py": + return "itemstoxml" return "help" def makeDir(path): @@ -82,10 +84,21 @@ def saveFile(fileName, data): w.write(data) def stripQuotes(data): + if len(data) == 0: + return data if data[-1] == "\"": data = data[:-1] if data[0] == "\"": data = data[1:] + if data[-1] == "'": + data = data[:-1] + if data[0] == "'": + data = data[1:] + return data + +def stripQuotes2(data): + for idx in xrange(0, len(data)): + data[idx] = stripQuotes(data[idx]) return data def printHelp(): @@ -187,12 +200,92 @@ def covertQuests(): data = data + tpl.format(questId, name, text + ": " + str(questId)) saveFile(destDir + "quests.xml", quests.format(data)) +def convertItems(): + destDir = "clientdata/" + templatesDir = "templates/" + itemsDbFile = "serverdata/sql-files/item_db_re.sql" + fieldsSplit = re.compile(",") + bracketsSplit = re.compile("[(]|[)]") + makeDir(destDir) + tpl = readFile(templatesDir + "item.tpl") + items = readFile(templatesDir + "items.xml") + data = "" + with open(itemsDbFile, "r") as f: + for line in f: + if len(line) < 10 or line[0:2] == "//" or line[0:12] != "REPLACE INTO": + continue + rows = bracketsSplit.split(line) + if len(rows) < 2: + continue + rows = fieldsSplit.split(rows[1]) + if len(rows) < 31: + continue + rows = stripQuotes2(rows) + itemId = rows[0] + name = rows[1] + name2 = rows[2] + itemType = rows[3] + priceBuy = rows[4] + priceSell = rows[5] + weight = rows[6] + atk = rows[7] + matk = rows[8] + defence = rows[9] + attackRange = rows[10] + slots = rows[11] + equipJobs = rows[12] + equipUpper = rows[12] + equipGender = rows[14] + equipLocations = rows[15] + weaponLevel = rows[16] + equipLevelMin = rows[17] + equipLevelMax = rows[18] + refinable = rows[19] + view = rows[20] + bindOnEquip = rows[21] + buyInStore = rows[22] + delay = rows[23] + tradeFlag = rows[24] + tradeGroup = rows[25] + nouseFlag = rows[26] + nouseGroup = rows[27] + stackAmount = rows[28] + stackFlag = rows[29] + sprite = rows[30] + + name = name.replace("\\'", "'") + image = "" + + if equipLocations == "512": + image = "equipment/chest/sailorshirt.png" + elif equipLocations == "64": + image = "equipment/feet/boots.png|S:#3c3c3c,40332d,4d4d4d,5e4a3d,686868,705740,919191,a1825d,b6b6b6,b59767,dfdfdf,dbbf88" + elif equipLocations == "4": + image = "equipment/hands/armbands.png" + elif equipLocations == "1": + image = "equipment/legs/shorts.png|S:#4d4d4d,514d47,686868,706662,919191,99917b,b6b6b6,c0b698,dfdfdf,e4dfca" + elif equipLocations == "256": + image = "equipment/head/bandana.png" + elif equipLocations == "2": + image = "equipment/weapons/knife.png" + elif equipLocations == "0": + image = "usable/bread.png" + else: + image = "generic/box-fish.png" + + data = data + tpl.format(itemId, name, weight, + atk, matk, defence, attackRange, delay, image) + saveFile(destDir + "items.xml", items.format(data)) + def readMapCache(path, cmd): if cmd == "help": printHelp() if cmd == "queststoxml": covertQuests() return + elif cmd == "itemstoxml": + convertItems() + return with open(path, "rb") as f: size = readInt32(f) diff --git a/hercules/templates/item.tpl b/hercules/templates/item.tpl new file mode 100644 index 0000000..f3c329e --- /dev/null +++ b/hercules/templates/item.tpl @@ -0,0 +1,11 @@ + + diff --git a/hercules/templates/items.xml b/hercules/templates/items.xml new file mode 100644 index 0000000..6bd8412 --- /dev/null +++ b/hercules/templates/items.xml @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + hairstyles/hairstyle01.xml + + + hairstyles/hairstyle02.xml + + + hairstyles/hairstyle03.xml + + + hairstyles/hairstyle04.xml + + + hairstyles/hairstyle05.xml + + + hairstyles/hairstyle06.xml + + + hairstyles/hairstyle07.xml + + + hairstyles/hairstyle08.xml + + + hairstyles/hairstyle09.xml + + + hairstyles/hairstyle10.xml + + + hairstyles/hairstyle11.xml + + + hairstyles/hairstyle12.xml + + + hairstyles/hairstyle13.xml + + + hairstyles/hairstyle14.xml + + + hairstyles/hairstyle15.xml + + + hairstyles/hairstyle16.xml + + + hairstyles/hairstyle17.xml + + + hairstyles/hairstyle18.xml + + + hairstyles/hairstyle19.xml + + + hairstyles/hairstyle20.xml + + + hairstyles/hairstyle21.xml + + + hairstyles/hairstyle22.xml + + + hairstyles/hairstyle23.xml + + + hairstyles/hairstyle24.xml + + + hairstyles/hairstyle25.xml + + + hairstyles/hairstyle26.xml + + + hairstyles/hairstyle27.xml + + + hairstyles/hairstyle28.xml + + + + + races/human-male.xml + races/human-female.xml + weapons/barehands/hit1.ogg + weapons/barehands/miss1.ogg + + + races/ukar-male.xml + races/ukar-female.xml + weapons/barehands/hit1.ogg + weapons/barehands/miss1.ogg + + + races/demon-male.xml + races/demon-female.xml + weapons/barehands/hit1.ogg + weapons/barehands/miss1.ogg + + + races/elven-male.xml + races/elven-female.xml + weapons/barehands/hit1.ogg + weapons/barehands/miss1.ogg + + + races/orc-male.xml + races/orc-female.xml + weapons/barehands/hit1.ogg + weapons/barehands/miss1.ogg + + + races/raijin-male.xml + races/raijin-female.xml + weapons/barehands/hit1.ogg + weapons/barehands/miss1.ogg + + + races/tritan-male.xml + races/tritan-female.xml + weapons/barehands/hit1.ogg + weapons/barehands/miss1.ogg + + + +{0} + -- cgit v1.2.3-70-g09d2