summaryrefslogtreecommitdiff
path: root/hercules
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-02 12:37:49 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-02 12:38:12 +0300
commit58d6b3709c95a0ea1b3f97c99a29f7b529e647dc (patch)
treeefc1f414a1aa0e0593b5d57b2993c1b13c09eb79 /hercules
parent73238e37ab83c0171ffe4f5b7b0a014950c15562 (diff)
downloadevol-tools-58d6b3709c95a0ea1b3f97c99a29f7b529e647dc.tar.gz
evol-tools-58d6b3709c95a0ea1b3f97c99a29f7b529e647dc.tar.bz2
evol-tools-58d6b3709c95a0ea1b3f97c99a29f7b529e647dc.tar.xz
evol-tools-58d6b3709c95a0ea1b3f97c99a29f7b529e647dc.zip
hercules: add item_db coversion.
Diffstat (limited to 'hercules')
-rw-r--r--hercules/code/server/itemdb.py109
-rwxr-xr-xhercules/convert_server.py8
-rw-r--r--hercules/templates/item_db.tpl60
3 files changed, 174 insertions, 3 deletions
diff --git a/hercules/code/server/itemdb.py b/hercules/code/server/itemdb.py
new file mode 100644
index 0000000..e91682d
--- /dev/null
+++ b/hercules/code/server/itemdb.py
@@ -0,0 +1,109 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import re
+
+from code.fileutils import *
+from code.stringutils import *
+
+def writeIntField(w, name, value):
+ if value == "":
+ value = "0"
+ w.write(" {0}: {1}\n".format(name, value))
+
+def writeStrField(w, name, value):
+ w.write(" {0}: \"{1}\"\n".format(name, value))
+
+def writeSubField(w, name, value):
+ w.write(" {0}: {1}\n".format(name, value));
+
+def writeStartBlock(w, text):
+ w.write(" {0}: {{\n".format(text));
+
+def writeEndBlock(w):
+ w.write(" }\n");
+
+def writeStartScript(w, name):
+ w.write(" {0}: <\"\n".format(name))
+
+def writeEndScript(w):
+ w.write(" \">\n")
+
+def convertItemDb():
+ srcFile = "oldserverdata/db/item_db.txt"
+ dstFile = "newserverdata/db/re/item_db.conf"
+ 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
+
+ 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")
+ if trade & 1 == 1:
+ writeSubField(w, "nodrop", "true")
+ if trade & 2 == 2:
+ writeSubField(w, "notrade", "true")
+ if trade & 8 == 8:
+ writeSubField(w, "nostorage", "true")
+ if trade & 512 == 512:
+ writeSubField(w, "noselltonpc", "true")
+ writeEndBlock(w)
+ 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)
+
+ w.write("},\n")
+ w.write(")\n")
diff --git a/hercules/convert_server.py b/hercules/convert_server.py
index 7ad1fe5..9968218 100755
--- a/hercules/convert_server.py
+++ b/hercules/convert_server.py
@@ -4,11 +4,13 @@
# Copyright (C) 2014 Evol Online
# Author: Andrei Karas (4144)
-from code.server.npcs import *
+from code.server.itemdb import *
from code.server.mobdb import *
+from code.server.npcs import *
from code.server.utils import *
cleanServerData()
createMainScript()
-convertNpcs();
-convertMobDb();
+convertNpcs()
+convertMobDb()
+convertItemDb()
diff --git a/hercules/templates/item_db.tpl b/hercules/templates/item_db.tpl
new file mode 100644
index 0000000..574a430
--- /dev/null
+++ b/hercules/templates/item_db.tpl
@@ -0,0 +1,60 @@
+item_db: (
+// Items Database
+//
+/******************************************************************************
+ ************* Entry structure ************************************************
+ ******************************************************************************
+{
+ // =================== Mandatory fields ===============================
+ Id: ID (int)
+ AegisName: "Aegis_Name" (string)
+ Name: "Item Name" (string)
+ // =================== Optional fields ================================
+ Type: Item Type (int, defaults to 3 = etc item)
+ Buy: Buy Price (int, defaults to Sell * 2)
+ Sell: Sell Price (int, defaults to Buy / 2)
+ Weight: Item Weight (int, defaults to 0)
+ Atk: Attack (int, defaults to 0)
+ Matk: Magical Attack (int, defaults to 0, ignored in pre-re)
+ Def: Defense (int, defaults to 0)
+ Range: Attack Range (int, defaults to 0)
+ Slots: Slots (int, defaults to 0)
+ Job: Job mask (int, defaults to all jobs = 0xFFFFFFFF)
+ Upper: Upper mask (int, defaults to any = 0x3f)
+ Gender: Gender (int, defaults to both = 2)
+ Loc: Equip location (int, required value for equipment)
+ WeaponLv: Weapon Level (int, defaults to 0)
+ EquipLv: Equip required level (int, defaults to 0)
+ EquipLv: [min, max] (alternative syntax with min / max level)
+ Refine: Refineable (boolean, defaults to true)
+ View: View ID (int, defaults to 0)
+ BindOnEquip: true/false (boolean, defaults to false)
+ BuyingStore: true/false (boolean, defaults to false)
+ Delay: Delay to use item (int, defaults to 0)
+ Trade: { (defaults to no restrictions)
+ override: GroupID (int, defaults to 100)
+ nodrop: true/false (boolean, defaults to false)
+ notrade: true/false (boolean, defaults to false)
+ partneroverride: true/false (boolean, defaults to false)
+ noselltonpc: true/false (boolean, defaults to false)
+ nocart: true/false (boolean, defaults to false)
+ nostorage: true/false (boolean, defaults to false)
+ nogstorage: true/false (boolean, defaults to false)
+ nomail: true/false (boolean, defaults to false)
+ noauction: true/false (boolean, defaults to false)
+ }
+ Nouse: { (defaults to no restrictions)
+ override: GroupID (int, defaults to 100)
+ sitting: true/false (boolean, defaults to false)
+ }
+ Stack: [amount, type] (int, defaults to 0)
+ Sprite: SpriteID (int, defaults to 0)
+ Script: <"
+ Script
+ (it can be multi-line)
+ ">
+ OnEquipScript: <" OnEquip Script (can also be multi-line) ">
+ OnUnequipScript: <" OnUnequip Script (can also be multi-line) ">
+},
+******************************************************************************/
+