diff options
-rw-r--r-- | hercules/code/fileutils.py | 7 | ||||
-rw-r--r-- | hercules/code/servertoclient/monsters.py | 4 | ||||
-rw-r--r-- | hercules/code/servertoclient/sprites.py | 41 | ||||
-rwxr-xr-x | hercules/convert_server_to_client.py | 2 |
4 files changed, 43 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) diff --git a/hercules/convert_server_to_client.py b/hercules/convert_server_to_client.py index d2fb2c7..fc2dec2 100755 --- a/hercules/convert_server_to_client.py +++ b/hercules/convert_server_to_client.py @@ -12,9 +12,11 @@ from code.servertoclient.monsters import * from code.servertoclient.pets import * from code.servertoclient.quests import * from code.servertoclient.skills import * +from code.servertoclient.sprites import * # non free data idtofile = convertLuas() +convertSpritesNonFree(idtofile) convertHomunculuses() convertItems() |