summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDastgir <dastgirp@gmail.com>2020-01-25 18:51:59 +0530
committerDastgir <dastgirp@gmail.com>2020-01-27 16:53:57 +0530
commit9c8cf4d8420f4002b857e1a7f5f797a6ec747929 (patch)
tree113ba80b3d6e9b7a5203e274e3e82e16222c2b1a /tools
parentc03722679a01e5f181c2138565e95a6b0981a124 (diff)
downloadhercules-9c8cf4d8420f4002b857e1a7f5f797a6ec747929.tar.gz
hercules-9c8cf4d8420f4002b857e1a7f5f797a6ec747929.tar.bz2
hercules-9c8cf4d8420f4002b857e1a7f5f797a6ec747929.tar.xz
hercules-9c8cf4d8420f4002b857e1a7f5f797a6ec747929.zip
Updated mobdbconverter to support constants
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mobdbconverter.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/tools/mobdbconverter.py b/tools/mobdbconverter.py
index 2073d083c..8a220b08d 100755
--- a/tools/mobdbconverter.py
+++ b/tools/mobdbconverter.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# -*- coding: utf8 -*-
#
# This file is part of Hercules.
@@ -141,6 +141,24 @@ def isHaveData(fields, start, cnt):
return True
return False
+def convertToSize(size):
+ sizes = ["Size_Small", "Size_Medium", "Size_Large"]
+ if (size >= len(sizes)):
+ return size
+ return f'"{sizes[size]}"'
+
+def convertToRace(race):
+ races = ["RC_Formless", "RC_Undead", "RC_Brute", "RC_Plant", "RC_Insect", "RC_Fish", "RC_Demon", "RC_DemiHuman", "RC_Angel", "RC_Dragon"]
+ if (race >= len(races)):
+ return race
+ return f'"{races[race]}"'
+
+def convertToElement(element):
+ elements = ["Ele_Neutral", "Ele_Water", "Ele_Earth", "Ele_Fire", "Ele_Wind", "Ele_Poison", "Ele_Holy", "Ele_Dark", "Ele_Ghost", "Ele_Undead"]
+ if (element >= len(elements)):
+ return element
+ return f'"{elements[element]}"'
+
def convertFile(inFile, itemDb):
if inFile != "" and not os.path.exists(inFile):
return
@@ -186,9 +204,9 @@ def convertFile(inFile, itemDb):
endGroup()
printField("ViewRange", fields[20])
printField("ChaseRange", fields[21])
- printField("Size", fields[22])
- printField("Race", fields[23])
- print("\tElement: ({0}, {1})".format(int(fields[24]) % 10, int(int(fields[24]) / 20)));
+ printField("Size", convertToSize(int(fields[22])))
+ printField("Race", convertToRace(int(fields[23])))
+ print("\tElement: ({0}, {1})".format(convertToElement(int(fields[24]) % 10), int(int(fields[24]) / 20)));
mode = int(fields[25], 0)
if mode != 0:
startGroup("Mode")
@@ -277,13 +295,13 @@ def readItemDB(inFile, itemDb):
return itemDb
if len(sys.argv) != 4 and len(sys.argv) != 3:
- printHelp();
+ printHelp()
exit(1)
startPath = sys.argv[2]
if len(sys.argv) == 4:
sourceFile = sys.argv[3]
else:
- sourceFile = "";
+ sourceFile = ""
itemDb = dict()
if sys.argv[1] == "re":
@@ -293,7 +311,7 @@ elif sys.argv[1] == "pre-re":
itemDb = readItemDB(startPath + "/db/pre-re/item_db.conf", itemDb)
itemDb = readItemDB(startPath + "/db/item_db2.conf", itemDb)
else:
- printHelp();
+ printHelp()
exit(1)
convertFile(sourceFile, itemDb)