summaryrefslogtreecommitdiff
path: root/hercules
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-03 18:16:01 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-03 18:16:01 +0300
commite083ec710171239abfc2014c88f54363feaf3e0d (patch)
treeeb1951ae2c481152f1e89dfc07c80981881604e2 /hercules
parent8c0b57568736abfe5c1d4410ffa64e845881fe71 (diff)
downloadevol-tools-e083ec710171239abfc2014c88f54363feaf3e0d.tar.gz
evol-tools-e083ec710171239abfc2014c88f54363feaf3e0d.tar.bz2
evol-tools-e083ec710171239abfc2014c88f54363feaf3e0d.tar.xz
evol-tools-e083ec710171239abfc2014c88f54363feaf3e0d.zip
hercules: add conversion from item_db to items.xml.
Diffstat (limited to 'hercules')
l---------hercules/itemstoxml.py1
-rwxr-xr-xhercules/maptool.py93
-rw-r--r--hercules/templates/item.tpl11
-rw-r--r--hercules/templates/items.xml150
4 files changed, 255 insertions, 0 deletions
diff --git a/hercules/itemstoxml.py b/hercules/itemstoxml.py
new file mode 120000
index 0000000..df2b3e6
--- /dev/null
+++ b/hercules/itemstoxml.py
@@ -0,0 +1 @@
+maptool.py \ No newline at end of file
diff --git a/hercules/maptool.py b/hercules/maptool.py
index ef7fec3..ac0ceef 100755
--- a/hercules/maptool.py
+++ b/hercules/maptool.py
@@ -28,6 +28,8 @@ def detectCommand():
return "mapstotmx"
elif sys.argv[0][-15:] == "/queststoxml.py":
return "queststoxml"
+ elif sys.argv[0][-14:] == "/itemstoxml.py":
+ return "itemstoxml"
return "help"
def makeDir(path):
@@ -82,10 +84,21 @@ def saveFile(fileName, data):
w.write(data)
def stripQuotes(data):
+ if len(data) == 0:
+ return data
if data[-1] == "\"":
data = data[:-1]
if data[0] == "\"":
data = data[1:]
+ if data[-1] == "'":
+ data = data[:-1]
+ if data[0] == "'":
+ data = data[1:]
+ return data
+
+def stripQuotes2(data):
+ for idx in xrange(0, len(data)):
+ data[idx] = stripQuotes(data[idx])
return data
def printHelp():
@@ -187,12 +200,92 @@ def covertQuests():
data = data + tpl.format(questId, name, text + ": " + str(questId))
saveFile(destDir + "quests.xml", quests.format(data))
+def convertItems():
+ destDir = "clientdata/"
+ templatesDir = "templates/"
+ itemsDbFile = "serverdata/sql-files/item_db_re.sql"
+ fieldsSplit = re.compile(",")
+ bracketsSplit = re.compile("[(]|[)]")
+ makeDir(destDir)
+ tpl = readFile(templatesDir + "item.tpl")
+ items = readFile(templatesDir + "items.xml")
+ data = ""
+ with open(itemsDbFile, "r") as f:
+ for line in f:
+ if len(line) < 10 or line[0:2] == "//" or line[0:12] != "REPLACE INTO":
+ continue
+ rows = bracketsSplit.split(line)
+ if len(rows) < 2:
+ continue
+ rows = fieldsSplit.split(rows[1])
+ if len(rows) < 31:
+ continue
+ rows = stripQuotes2(rows)
+ itemId = rows[0]
+ name = rows[1]
+ name2 = rows[2]
+ itemType = rows[3]
+ priceBuy = rows[4]
+ priceSell = rows[5]
+ weight = rows[6]
+ atk = rows[7]
+ matk = rows[8]
+ defence = rows[9]
+ attackRange = rows[10]
+ slots = rows[11]
+ equipJobs = rows[12]
+ equipUpper = rows[12]
+ equipGender = rows[14]
+ equipLocations = rows[15]
+ weaponLevel = rows[16]
+ equipLevelMin = rows[17]
+ equipLevelMax = rows[18]
+ refinable = rows[19]
+ view = rows[20]
+ bindOnEquip = rows[21]
+ buyInStore = rows[22]
+ delay = rows[23]
+ tradeFlag = rows[24]
+ tradeGroup = rows[25]
+ nouseFlag = rows[26]
+ nouseGroup = rows[27]
+ stackAmount = rows[28]
+ stackFlag = rows[29]
+ sprite = rows[30]
+
+ name = name.replace("\\'", "'")
+ image = ""
+
+ if equipLocations == "512":
+ image = "equipment/chest/sailorshirt.png"
+ elif equipLocations == "64":
+ image = "equipment/feet/boots.png|S:#3c3c3c,40332d,4d4d4d,5e4a3d,686868,705740,919191,a1825d,b6b6b6,b59767,dfdfdf,dbbf88"
+ elif equipLocations == "4":
+ image = "equipment/hands/armbands.png"
+ elif equipLocations == "1":
+ image = "equipment/legs/shorts.png|S:#4d4d4d,514d47,686868,706662,919191,99917b,b6b6b6,c0b698,dfdfdf,e4dfca"
+ elif equipLocations == "256":
+ image = "equipment/head/bandana.png"
+ elif equipLocations == "2":
+ image = "equipment/weapons/knife.png"
+ elif equipLocations == "0":
+ image = "usable/bread.png"
+ else:
+ image = "generic/box-fish.png"
+
+ data = data + tpl.format(itemId, name, weight,
+ atk, matk, defence, attackRange, delay, image)
+ saveFile(destDir + "items.xml", items.format(data))
+
def readMapCache(path, cmd):
if cmd == "help":
printHelp()
if cmd == "queststoxml":
covertQuests()
return
+ elif cmd == "itemstoxml":
+ convertItems()
+ return
with open(path, "rb") as f:
size = readInt32(f)
diff --git a/hercules/templates/item.tpl b/hercules/templates/item.tpl
new file mode 100644
index 0000000..f3c329e
--- /dev/null
+++ b/hercules/templates/item.tpl
@@ -0,0 +1,11 @@
+ <item id="{0}"
+ name="{1}"
+ weight="{2}"
+ attack="{3}"
+ mattack="{4}"
+ defense="{5}"
+ range="{6}"
+ speed="{7}"
+ image="{8}"
+ />
+ </item>
diff --git a/hercules/templates/items.xml b/hercules/templates/items.xml
new file mode 100644
index 0000000..6bd8412
--- /dev/null
+++ b/hercules/templates/items.xml
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/xsl" href="items.xsl"?>
+<!-- Authors: 4144, Piman, Reid
+Copyright (C) 2010-2013 Evol Online -->
+
+<items>
+ <version revision="$Revision$"/>
+
+ <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
+ <its:translateRule selector="//item/@name" translate="yes"/>
+ <its:translateRule selector="//item/@description" translate="yes"/>
+ <its:translateRule selector="//item/@useButton" translate="yes"/>
+ <its:translateRule selector="//item/@useButton2" translate="yes"/>
+ <its:translateRule selector="//item/@effect" translate="yes"/>
+ <its:translateRule selector="//*" translate="no"/>
+ </its:rules>
+
+ <!-- Hairstyles -->
+ <item id="-1" type="hairsprite" name="Bald">
+ <sprite>hairstyles/hairstyle01.xml</sprite>
+ </item>
+ <item id="-2" type="hairsprite" name="Bowl Cut" colors="hairS">
+ <sprite>hairstyles/hairstyle02.xml</sprite>
+ </item>
+ <item id="-3" type="hairsprite" name="Combed Back" colors="hairS">
+ <sprite>hairstyles/hairstyle03.xml</sprite>
+ </item>
+ <item id="-4" type="hairsprite" name="Emo" colors="hairS">
+ <sprite>hairstyles/hairstyle04.xml</sprite>
+ </item>
+ <item id="-5" type="hairsprite" name="Mohawk" colors="hairS">
+ <sprite>hairstyles/hairstyle05.xml</sprite>
+ </item>
+ <item id="-6" type="hairsprite" name="Pompadour" colors="hairS">
+ <sprite>hairstyles/hairstyle06.xml</sprite>
+ </item>
+ <item id="-7" type="hairsprite" name="Center Parting" colors="hairS">
+ <sprite>hairstyles/hairstyle07.xml</sprite>
+ </item>
+ <item id="-8" type="hairsprite" name="Long and Slick" colors="hair">
+ <sprite>hairstyles/hairstyle08.xml</sprite>
+ </item>
+ <item id="-9" type="hairsprite" name="Short and Curly" colors="hair">
+ <sprite>hairstyles/hairstyle09.xml</sprite>
+ </item>
+ <item id="-10" type="hairsprite" name="Pigtails" colors="hair">
+ <sprite>hairstyles/hairstyle10.xml</sprite>
+ </item>
+ <item id="-11" type="hairsprite" name="Long and Curly" colors="hair">
+ <sprite>hairstyles/hairstyle11.xml</sprite>
+ </item>
+ <item id="-12" type="hairsprite" name="Parted" colors="hair">
+ <sprite>hairstyles/hairstyle12.xml</sprite>
+ </item>
+ <item id="-13" type="hairsprite" name="Perky Ponytail" colors="hairS">
+ <sprite>hairstyles/hairstyle13.xml</sprite>
+ </item>
+ <item id="-14" type="hairsprite" name="Wave" colors="hairS">
+ <sprite>hairstyles/hairstyle14.xml</sprite>
+ </item>
+ <item id="-15" type="hairsprite" name="Mane" colors="hairS">
+ <sprite>hairstyles/hairstyle15.xml</sprite>
+ </item>
+ <item id="-16" type="hairsprite" name="Bun" colors="hairS">
+ <sprite>hairstyles/hairstyle16.xml</sprite>
+ </item>
+ <item id="-17" type="hairsprite" name="Wavy" colors="hairS">
+ <sprite>hairstyles/hairstyle17.xml</sprite>
+ </item>
+ <item id="-18" type="hairsprite" name="Bunches" colors="hairS">
+ <sprite>hairstyles/hairstyle18.xml</sprite>
+ </item>
+ <item id="-19" type="hairsprite" name="Long Ponytail" colors="hairS">
+ <sprite>hairstyles/hairstyle19.xml</sprite>
+ </item>
+ <item id="-20" type="hairsprite" name="Infinitely Long" colors="hair">
+ <sprite>hairstyles/hairstyle20.xml</sprite>
+ </item>
+ <item id="-21" type="hairsprite" name="Choppy" colors="hair">
+ <sprite>hairstyles/hairstyle21.xml</sprite>
+ </item>
+ <item id="-22" type="hairsprite" name="Wild" colors="hair">
+ <sprite>hairstyles/hairstyle22.xml</sprite>
+ </item>
+ <item id="-23" type="hairsprite" name="Punk" colors="hairS">
+ <sprite>hairstyles/hairstyle23.xml</sprite>
+ </item>
+ <item id="-24" type="hairsprite" name="Imperial" colors="hairS">
+ <sprite>hairstyles/hairstyle24.xml</sprite>
+ </item>
+ <item id="-25" type="hairsprite" name="Side Strand" colors="hairS">
+ <sprite>hairstyles/hairstyle25.xml</sprite>
+ </item>
+ <item id="-26" type="hairsprite" name="Messy" colors="hairS">
+ <sprite>hairstyles/hairstyle26.xml</sprite>
+ </item>
+ <item id="-27" type="hairsprite" name="Flat Ponytail" colors="hairS">
+ <sprite>hairstyles/hairstyle27.xml</sprite>
+ </item>
+ <item id="-28" type="hairsprite" name="Tapered Nape" colors="hairS">
+ <sprite>hairstyles/hairstyle28.xml</sprite>
+ </item>
+
+ <!-- Races -->
+ <item id="-100" type="racesprite" name="Human">
+ <sprite gender="unisex">races/human-male.xml</sprite>
+ <sprite gender="female">races/human-female.xml</sprite>
+ <sound event="hit">weapons/barehands/hit1.ogg</sound>
+ <sound event="miss">weapons/barehands/miss1.ogg</sound>
+ </item>
+ <item id="-101" type="racesprite" name="Ukar">
+ <sprite gender="unisex">races/ukar-male.xml</sprite>
+ <sprite gender="female">races/ukar-female.xml</sprite>
+ <sound event="hit">weapons/barehands/hit1.ogg</sound>
+ <sound event="miss">weapons/barehands/miss1.ogg</sound>
+ </item>
+ <item id="-102" type="racesprite" name="Demon">
+ <sprite gender="unisex">races/demon-male.xml</sprite>
+ <sprite gender="female">races/demon-female.xml</sprite>
+ <sound event="hit">weapons/barehands/hit1.ogg</sound>
+ <sound event="miss">weapons/barehands/miss1.ogg</sound>
+ </item>
+ <item id="-103" type="racesprite" name="Elven">
+ <sprite gender="unisex">races/elven-male.xml</sprite>
+ <sprite gender="female">races/elven-female.xml</sprite>
+ <sound event="hit">weapons/barehands/hit1.ogg</sound>
+ <sound event="miss">weapons/barehands/miss1.ogg</sound>
+ </item>
+ <item id="-104" type="racesprite" name="Orc">
+ <sprite gender="unisex">races/orc-male.xml</sprite>
+ <sprite gender="female">races/orc-female.xml</sprite>
+ <sound event="hit">weapons/barehands/hit1.ogg</sound>
+ <sound event="miss">weapons/barehands/miss1.ogg</sound>
+ </item>
+ <item id="-105" type="racesprite" name="Raijin">
+ <sprite gender="unisex">races/raijin-male.xml</sprite>
+ <sprite gender="female">races/raijin-female.xml</sprite>
+ <sound event="hit">weapons/barehands/hit1.ogg</sound>
+ <sound event="miss">weapons/barehands/miss1.ogg</sound>
+ </item>
+ <item id="-106" type="racesprite" name="Tritan">
+ <sprite gender="unisex">races/tritan-male.xml</sprite>
+ <sprite gender="female">races/tritan-female.xml</sprite>
+ <sound event="hit">weapons/barehands/hit1.ogg</sound>
+ <sound event="miss">weapons/barehands/miss1.ogg</sound>
+ </item>
+
+ <!-- Items -->
+{0}
+</items>