summaryrefslogtreecommitdiff
path: root/hercules/code
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-09-20 16:38:51 +0300
committerAndrei Karas <akaras@inbox.ru>2015-09-20 16:38:51 +0300
commit06887bd17dd04cb6314cc215424b041dda7dca87 (patch)
tree1f6ad19c17aac7d1d099836e237092bfa6857272 /hercules/code
parent4964b079cb3864f5e5a7c530b0eb0c5957363baa (diff)
downloadevol-tools-06887bd17dd04cb6314cc215424b041dda7dca87.tar.gz
evol-tools-06887bd17dd04cb6314cc215424b041dda7dca87.tar.bz2
evol-tools-06887bd17dd04cb6314cc215424b041dda7dca87.tar.xz
evol-tools-06887bd17dd04cb6314cc215424b041dda7dca87.zip
hercules: add support for convert all non free sprites.
Diffstat (limited to 'hercules/code')
-rw-r--r--hercules/code/fileutils.py7
-rw-r--r--hercules/code/servertoclient/monsters.py4
-rw-r--r--hercules/code/servertoclient/sprites.py41
3 files changed, 41 insertions, 11 deletions
diff --git a/hercules/code/fileutils.py b/hercules/code/fileutils.py
index 44ec591..2cf106b 100644
--- a/hercules/code/fileutils.py
+++ b/hercules/code/fileutils.py
@@ -73,3 +73,10 @@ def makeDir(path):
def removeAllFiles(path):
if os.path.exists(path):
shutil.rmtree(path)
+
+def findFileIn(names, dirs):
+ for name in names:
+ for path in dirs:
+ if os.path.exists(path + name):
+ return path
+ return None
diff --git a/hercules/code/servertoclient/monsters.py b/hercules/code/servertoclient/monsters.py
index 782b449..10f20ec 100644
--- a/hercules/code/servertoclient/monsters.py
+++ b/hercules/code/servertoclient/monsters.py
@@ -35,8 +35,8 @@ def convertMonsters(isNonFree = False, idtofile = None):
continue
monsterId = rows[0]
if isNonFree == True and monsterId in idtofile:
- convertSprite("rodata/data/sprite/ёуЅєЕН/", idtofile[monsterId])
- monsterSprite = "<sprite>monsters/{0}.xml</sprite>".format(idtofile[monsterId])
+ #convertSprite("rodata/data/sprite/ёуЅєЕН/", idtofile[monsterId])
+ monsterSprite = "<sprite>sprites/{0}.xml</sprite>".format(idtofile[monsterId])
else:
monsterSprite = """<sprite>monsters/blub.xml</sprite>
<sprite>accessories/blub-tentacle.xml|#3e4164,3a3968,544a82,64437a,7d6db4,a26392,8f99c4,d294ab,b3cdcd,e7b8b8,d9ecd1,f0e8c5</sprite>""";
diff --git a/hercules/code/servertoclient/sprites.py b/hercules/code/servertoclient/sprites.py
index 7e03b58..9243f19 100644
--- a/hercules/code/servertoclient/sprites.py
+++ b/hercules/code/servertoclient/sprites.py
@@ -145,8 +145,7 @@ def decodeSprite(spr):
-def saveSpriteImage(act, spr, spriteName):
- monstersDir = "clientdata/graphics/sprites/monsters/"
+def saveSpriteImage(act, spr, spriteDir, spriteName):
# for imageN in range(0, spr.rgbaSpritesCount):
# image = spr.images[imageN + spr.indexedSpritesCount]
# print "{0} x {1}".format(image.width, image.height)
@@ -240,8 +239,8 @@ def saveSpriteImage(act, spr, spriteName):
spr.frameToIdx = frameToIdx
spr.tilesetWidth = tilesetWidth
spr.tilesetHeight = tilesetHeight
- makeDir(monstersDir)
- tileset.save(monstersDir + spriteName + ".png")
+ makeDir(spriteDir)
+ tileset.save(spriteDir + spriteName + ".png")
def extractSpriteAnimData(act, spr, actIndex, direction):
# delay = anim.delay
@@ -291,10 +290,9 @@ def extractSpriteDataAll(act, spr, actIndex, name):
data = data + extractSpriteAnimData(act, spr, actIndex + 6, "rightdown")
return data
-def saveSpriteXml(act, spr, spriteName):
- monstersDir = "clientdata/graphics/sprites/monsters/"
+def saveSpriteXml(act, spr, spriteDir, spriteName):
templatesDir = "templates/"
- dstFile = monstersDir + spriteName + ".xml"
+ dstFile = spriteDir + spriteName + ".xml"
tpl = readFile(templatesDir + "sprite.xml")
# 0, 8, 16, 24, 32, 40, 48
# 0 - walk or attack or ?
@@ -439,8 +437,33 @@ def convertSprite(spritePath, spriteName):
act = readAct(actFile)
spr = readSpr(sprFile)
decodeSprite(spr)
- saveSpriteImage(act, spr, spriteName)
- saveSpriteXml(act, spr, spriteName)
+ saveSpriteImage(act, spr, "clientdata/graphics/sprites/sprites/", spriteName)
+ saveSpriteXml(act, spr, "clientdata/graphics/sprites/sprites/", spriteName)
# if actFile.find("wolf") > 0:
# exit(0)
# exit(0)
+
+def findSpritePath(spriteName):
+ testName = spriteName + ".act"
+ testName2 = spriteName.upper() + ".act"
+ path = findFileIn((testName, testName2),
+ ("rodata/data/sprite/ёуЅєЕН/",
+ "rodata/data/sprite/npc/",
+ "rodata/data/sprite/homun/"))
+ return path
+
+def convertSpritesNonFree(idtofile):
+ processed = []
+ for spriteid in idtofile:
+ spriteName = idtofile[spriteid]
+ if spriteName in processed:
+ print "skipping " + spriteName
+ continue
+
+ path = findSpritePath(spriteName)
+ if path is None:
+ print "not found " + spriteName
+ continue
+ print spriteName
+ convertSprite(path, spriteName)
+ processed.append(spriteName)