From 551261e4aa47d9e4baa9396e20f503b9fc75680a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 20 Sep 2015 17:45:30 +0300 Subject: hercules: add support for convert ro npcs. --- hercules/code/servertoclient/npcs.py | 34 +++++++++++++++++++++++++++++++++ hercules/code/servertoclient/sprites.py | 2 +- hercules/convert_server_to_client.py | 2 ++ hercules/templates/npc.tpl | 3 +++ hercules/templates/npcs.xml | 11 +++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 hercules/code/servertoclient/npcs.py create mode 100644 hercules/templates/npc.tpl create mode 100644 hercules/templates/npcs.xml diff --git a/hercules/code/servertoclient/npcs.py b/hercules/code/servertoclient/npcs.py new file mode 100644 index 0000000..1c0d76f --- /dev/null +++ b/hercules/code/servertoclient/npcs.py @@ -0,0 +1,34 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2015 Evol Online +# Author: Andrei Karas (4144) + +import re +from sets import Set + +from code.fileutils import * +from code.stringutils import * + +from code.servertoclient.sprites import * + +def getNpcIds(idtofile): + for key1 in idtofile: + key = int(key1) + if 45 <= key <= 125 or 400 < key < 1000 or 10001 <= key < 10100: + yield key1 + +def convertNpcsNonFree(idtofile): + destDir = "clientdata/" + templatesDir = "templates/" + monstersDbFile = "serverdata/sql-files/mob_db_re.sql" + fieldsSplit = re.compile(",") + bracketsSplit = re.compile("[(]|[)]") + makeDir(destDir) + tpl = readFile(templatesDir + "npc.tpl") + npcs = readFile(templatesDir + "npcs.xml") + data = "" + + for key in getNpcIds(idtofile): + npcSprite = "sprites/{0}.xml".format(idtofile[key]) + data = data + tpl.format(key, idtofile[key], npcSprite) + saveFile(destDir + "npcs.xml", npcs.format(data)) diff --git a/hercules/code/servertoclient/sprites.py b/hercules/code/servertoclient/sprites.py index 9243f19..035540e 100644 --- a/hercules/code/servertoclient/sprites.py +++ b/hercules/code/servertoclient/sprites.py @@ -307,7 +307,7 @@ def saveSpriteXml(act, spr, spriteDir, spriteName): deadData = extractSpriteDataAll(act, spr, 32, "dead") data = tpl.format( - src = "graphics/sprites/monsters/" + spriteName + ".png", + src = "graphics/sprites/sprites/" + spriteName + ".png", width = spr.maxwidth, height = spr.maxheight, stand = standData, diff --git a/hercules/convert_server_to_client.py b/hercules/convert_server_to_client.py index fc2dec2..03f7457 100755 --- a/hercules/convert_server_to_client.py +++ b/hercules/convert_server_to_client.py @@ -9,6 +9,7 @@ from code.servertoclient.items import * from code.servertoclient.luas import * from code.servertoclient.mercenaries import * from code.servertoclient.monsters import * +from code.servertoclient.npcs import * from code.servertoclient.pets import * from code.servertoclient.quests import * from code.servertoclient.skills import * @@ -17,6 +18,7 @@ from code.servertoclient.sprites import * # non free data idtofile = convertLuas() convertSpritesNonFree(idtofile) +convertNpcsNonFree(idtofile) convertHomunculuses() convertItems() diff --git a/hercules/templates/npc.tpl b/hercules/templates/npc.tpl new file mode 100644 index 0000000..9c345eb --- /dev/null +++ b/hercules/templates/npc.tpl @@ -0,0 +1,3 @@ + + {2} + diff --git a/hercules/templates/npcs.xml b/hercules/templates/npcs.xml new file mode 100644 index 0000000..72a0a4f --- /dev/null +++ b/hercules/templates/npcs.xml @@ -0,0 +1,11 @@ + + + + + + + + + +{0} + -- cgit v1.2.3-60-g2f50