diff options
Diffstat (limited to 'hercules')
-rwxr-xr-x | hercules/maptool.py | 41 | ||||
l--------- | hercules/queststoxml.py | 1 | ||||
-rw-r--r-- | hercules/templates/quest.tpl | 5 | ||||
-rw-r--r-- | hercules/templates/quests.xml | 6 |
4 files changed, 53 insertions, 0 deletions
diff --git a/hercules/maptool.py b/hercules/maptool.py index 51ff750..ef7fec3 100755 --- a/hercules/maptool.py +++ b/hercules/maptool.py @@ -26,6 +26,8 @@ def detectCommand(): return "extractmaps" elif sys.argv[0][-13:] == "/mapstotmx.py": return "mapstotmx" + elif sys.argv[0][-15:] == "/queststoxml.py": + return "queststoxml" return "help" def makeDir(path): @@ -79,6 +81,13 @@ def saveFile(fileName, data): with open(fileName, "w") as w: w.write(data) +def stripQuotes(data): + if data[-1] == "\"": + data = data[:-1] + if data[0] == "\"": + data = data[1:] + return data + def printHelp(): print "Unknown options selected." print "" @@ -150,9 +159,41 @@ def covertToTmx(f, mapsCount): collision = collision + "\n" saveFile(mapsDir + name + ".tmx", tmx.format(sx, sy, ground, collision, fringe)) +def covertQuests(): + destDir = "clientdata/" + templatesDir = "templates/" + questsDbFile = "serverdata/db/quest_db.txt" + fieldsSplit = re.compile(",") + makeDir(destDir) + tpl = readFile(templatesDir + "quest.tpl") + quests = readFile(templatesDir + "quests.xml") + data = "" + with open(questsDbFile, "r") as f: + for line in f: + if line == "" or line[0:2] == "//": + continue + rows = fieldsSplit.split(line) + if len(rows) < 9: + continue + questId = rows[0] + text = rows[8] + if text[-1] == "\n": + text = text[:-1] + text = stripQuotes(text) + name = text + if len(name) > 20: + name = name[:19] + + data = data + tpl.format(questId, name, text + ": " + str(questId)) + saveFile(destDir + "quests.xml", quests.format(data)) + def readMapCache(path, cmd): if cmd == "help": printHelp() + if cmd == "queststoxml": + covertQuests() + return + with open(path, "rb") as f: size = readInt32(f) if os.path.getsize(path) != size: diff --git a/hercules/queststoxml.py b/hercules/queststoxml.py new file mode 120000 index 0000000..df2b3e6 --- /dev/null +++ b/hercules/queststoxml.py @@ -0,0 +1 @@ +maptool.py
\ No newline at end of file diff --git a/hercules/templates/quest.tpl b/hercules/templates/quest.tpl new file mode 100644 index 0000000..25615f9 --- /dev/null +++ b/hercules/templates/quest.tpl @@ -0,0 +1,5 @@ + <var id="{0}"> + <quest name="{1}" group="hercules" incomplete="1" complete="2"> + <name>{2}</name> + </quest> + </var> diff --git a/hercules/templates/quests.xml b/hercules/templates/quests.xml new file mode 100644 index 0000000..c2828f9 --- /dev/null +++ b/hercules/templates/quests.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Authors: 4144 +Copyright (C) 2014 Evol Online --> +<quests> +{0} +</quests> |