summaryrefslogtreecommitdiff
path: root/hercules
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-21 18:07:31 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-21 18:07:31 +0300
commit29c95b266b64690c636bef31360a17e0f95ba909 (patch)
tree520d314055147c9f41d052fbbc171b3936f058bf /hercules
parent7113c2d2c52c670067704a8f4e9d8b45da14fc52 (diff)
downloadtools-29c95b266b64690c636bef31360a17e0f95ba909.tar.gz
tools-29c95b266b64690c636bef31360a17e0f95ba909.tar.bz2
tools-29c95b266b64690c636bef31360a17e0f95ba909.tar.xz
tools-29c95b266b64690c636bef31360a17e0f95ba909.zip
hercules: add mercenaries.xml generation.
Diffstat (limited to 'hercules')
-rwxr-xr-xhercules/maptool.py26
l---------hercules/mercenariestoxml.py1
-rw-r--r--hercules/templates/mercenaries.xml6
-rw-r--r--hercules/templates/mercenary.tpl3
4 files changed, 36 insertions, 0 deletions
diff --git a/hercules/maptool.py b/hercules/maptool.py
index 6d9d51a..fa3ecc8 100755
--- a/hercules/maptool.py
+++ b/hercules/maptool.py
@@ -33,6 +33,8 @@ def detectCommand():
return "itemstoxml"
elif sys.argv[0][-17:] == "/monsterstoxml.py":
return "monsterstoxml"
+ elif sys.argv[0][-20:] == "/mercenariestoxml.py":
+ return "mercenariestoxml"
return "help"
def makeDir(path):
@@ -371,6 +373,27 @@ def convertMonsters():
saveFile(destDir + "monsters.xml", monsters.format(data))
+def convertMercenaries():
+ destDir = "clientdata/"
+ templatesDir = "templates/"
+ mercenariesDbFile = "serverdata/db/mercenary_db.txt"
+ fieldsSplit = re.compile(",")
+ makeDir(destDir)
+ tpl = readFile(templatesDir + "mercenary.tpl")
+ mercenaries = readFile(templatesDir + "mercenaries.xml")
+ data = ""
+ mercenarySprite = "<sprite>monsters/croc.xml</sprite>";
+ with open(mercenariesDbFile, "r") as f:
+ for line in f:
+ if line == "" or line[0:2] == "//":
+ continue
+ rows = fieldsSplit.split(line)
+ if len(rows) < 9:
+ continue
+ mercenaryId = rows[0]
+ data = data + tpl.format(mercenaryId, mercenarySprite)
+ saveFile(destDir + "mercenaries.xml", mercenaries.format(data))
+
def readMapCache(path, cmd):
if cmd == "help":
@@ -384,6 +407,9 @@ def readMapCache(path, cmd):
elif cmd == "monsterstoxml":
convertMonsters();
return
+ elif cmd == "mercenariestoxml":
+ convertMercenaries();
+ return
with open(path, "rb") as f:
size = readInt32(f)
diff --git a/hercules/mercenariestoxml.py b/hercules/mercenariestoxml.py
new file mode 120000
index 0000000..df2b3e6
--- /dev/null
+++ b/hercules/mercenariestoxml.py
@@ -0,0 +1 @@
+maptool.py \ No newline at end of file
diff --git a/hercules/templates/mercenaries.xml b/hercules/templates/mercenaries.xml
new file mode 100644
index 0000000..cfc801c
--- /dev/null
+++ b/hercules/templates/mercenaries.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Authors: 4144
+Copyright (C) 2014 Evol Online -->
+<mercenaries>
+{0}
+</mercenaries>
diff --git a/hercules/templates/mercenary.tpl b/hercules/templates/mercenary.tpl
new file mode 100644
index 0000000..e17f281
--- /dev/null
+++ b/hercules/templates/mercenary.tpl
@@ -0,0 +1,3 @@
+ <mercenary id="{0}">
+ {1}
+ </mercenary>