summaryrefslogtreecommitdiff
path: root/hercules
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-05 13:05:14 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-05 13:05:14 +0300
commit4f2de562e813a398edac31cb5c888f39afa9577f (patch)
tree8d2669f23c9bdc04393a948e859b6a4d80f929ab /hercules
parente2d21a550df8849689379015f373715ed423ac4b (diff)
downloadtools-4f2de562e813a398edac31cb5c888f39afa9577f.tar.gz
tools-4f2de562e813a398edac31cb5c888f39afa9577f.tar.bz2
tools-4f2de562e813a398edac31cb5c888f39afa9577f.tar.xz
tools-4f2de562e813a398edac31cb5c888f39afa9577f.zip
hercules: add item names to constants while converting item_db.
Diffstat (limited to 'hercules')
-rw-r--r--hercules/code/server/itemdb.py117
-rwxr-xr-xhercules/convert_server.py2
2 files changed, 61 insertions, 58 deletions
diff --git a/hercules/code/server/itemdb.py b/hercules/code/server/itemdb.py
index b0a2bff..a47bb42 100644
--- a/hercules/code/server/itemdb.py
+++ b/hercules/code/server/itemdb.py
@@ -12,52 +12,55 @@ from code.stringutils import *
def convertItemDb():
srcFile = "oldserverdata/db/item_db.txt"
dstFile = "newserverdata/db/re/item_db.conf"
+ constsFile = "newserverdata/db/const.txt"
fieldsSplit = re.compile(",")
scriptsSplit = re.compile("{")
with open(srcFile, "r") as r:
with open(dstFile, "w") as w:
- tpl = readFile("templates/item_db.tpl")
- w.write(tpl)
- for line in r:
- if len(line) < 2 or line[0] == "#" or line[0:2] == "//":
- continue
- rows = fieldsSplit.split(line)
- if len(rows) < 5 or rows[0] == "0":
- continue
+ with open(constsFile, "a") as c:
+ c.write("// items\n");
+ tpl = readFile("templates/item_db.tpl")
+ w.write(tpl)
+ for line in r:
+ if len(line) < 2 or line[0] == "#" or line[0:2] == "//":
+ continue
+ rows = fieldsSplit.split(line)
+ if len(rows) < 5 or rows[0] == "0":
+ continue
- sz = len(rows)
- if sz > 19:
- sz = 19
- for f in xrange(0, sz):
- rows[f] = rows[f].strip()
- w.write("{\n")
-
- writeIntField(w, "Id", rows[0])
- writeStrField(w, "AegisName", rows[1])
- writeStrField(w, "Name", rows[2])
- writeIntField(w, "Type", rows[4])
- writeIntField(w, "Buy", rows[5])
- writeIntField(w, "Sell", rows[6])
- writeIntField(w, "Weight", rows[7])
- writeIntField(w, "Atk", rows[8])
- writeIntField(w, "Matk", "0")
- writeIntField(w, "Def", rows[9])
- writeIntField(w, "Range", rows[10])
- writeIntField(w, "Slots", "0")
- writeIntField(w, "Job", "0xFFFFFFFF")
- writeIntField(w, "Upper", "0x3F")
- writeIntField(w, "Gender", rows[13])
- writeIntField(w, "Loc", rows[14])
- writeIntField(w, "WeaponLv", rows[15])
- writeIntField(w, "EquipLv", rows[16])
- writeIntField(w, "Refine", "false")
- writeIntField(w, "View", rows[17])
- writeIntField(w, "BindOnEquip", "false")
- writeIntField(w, "BuyingStore", "false")
- writeIntField(w, "Delay", "0")
- trade = int(rows[3])
- if trade != 0:
- writeStartBlock(w, "Trade")
+ sz = len(rows)
+ if sz > 19:
+ sz = 19
+ for f in xrange(0, sz):
+ rows[f] = rows[f].strip()
+ w.write("{\n")
+ c.write("{0}\t{1}\n".format(rows[1], rows[0]))
+ writeIntField(w, "Id", rows[0])
+ writeStrField(w, "AegisName", rows[1])
+ writeStrField(w, "Name", rows[2])
+ writeIntField(w, "Type", rows[4])
+ writeIntField(w, "Buy", rows[5])
+ writeIntField(w, "Sell", rows[6])
+ writeIntField(w, "Weight", rows[7])
+ writeIntField(w, "Atk", rows[8])
+ writeIntField(w, "Matk", "0")
+ writeIntField(w, "Def", rows[9])
+ writeIntField(w, "Range", rows[10])
+ writeIntField(w, "Slots", "0")
+ writeIntField(w, "Job", "0xFFFFFFFF")
+ writeIntField(w, "Upper", "0x3F")
+ writeIntField(w, "Gender", rows[13])
+ writeIntField(w, "Loc", rows[14])
+ writeIntField(w, "WeaponLv", rows[15])
+ writeIntField(w, "EquipLv", rows[16])
+ writeIntField(w, "Refine", "false")
+ writeIntField(w, "View", rows[17])
+ writeIntField(w, "BindOnEquip", "false")
+ writeIntField(w, "BuyingStore", "false")
+ writeIntField(w, "Delay", "0")
+ trade = int(rows[3])
+ if trade != 0:
+ writeStartBlock(w, "Trade")
if trade & 1 == 1:
writeSubField(w, "nodrop", "true")
if trade & 2 == 2:
@@ -67,21 +70,21 @@ def convertItemDb():
if trade & 512 == 512:
writeSubField(w, "noselltonpc", "true")
writeEndBlock(w)
- writeIntField(w, "Sprite", "0")
+ writeIntField(w, "Sprite", "0")
- scripts = ""
- for f in xrange(sz, len(rows)):
- scripts = scripts + ", " + rows[f]
- rows = scriptsSplit.split(scripts)
- cnt = len(rows)
- if cnt > 1:
- text = rows[1].strip()
- if len(text) > 1:
- text = text[:-2]
- if text != "":
- writeStartScript(w, "Script")
- w.write(" {0}\n".format(text))
- writeEndScript(w)
+ scripts = ""
+ for f in xrange(sz, len(rows)):
+ scripts = scripts + ", " + rows[f]
+ rows = scriptsSplit.split(scripts)
+ cnt = len(rows)
+ if cnt > 1:
+ text = rows[1].strip()
+ if len(text) > 1:
+ text = text[:-2]
+ if text != "":
+ writeStartScript(w, "Script")
+ w.write(" {0}\n".format(text))
+ writeEndScript(w)
- w.write("},\n")
- w.write(")\n")
+ w.write("},\n")
+ w.write(")\n")
diff --git a/hercules/convert_server.py b/hercules/convert_server.py
index 9eaba1a..703870b 100755
--- a/hercules/convert_server.py
+++ b/hercules/convert_server.py
@@ -16,7 +16,7 @@ cleanServerData()
createMainScript()
convertNpcs()
convertMobDb()
-convertItemDb()
convertConsts()
+convertItemDb()
convertMobSkillDb()
convertQuestsDb()