summaryrefslogtreecommitdiff
path: root/hercules/code/servertoclient/npcs.py
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-04-10 00:45:07 -0300
committerJesusaves <cpntb1@ymail.com>2021-04-10 00:45:07 -0300
commitc6095ad062eaa0f5576cfab1c4fe436b90c2fbfe (patch)
tree742dd839971d2aab1f08fd0291af66e6439646ab /hercules/code/servertoclient/npcs.py
downloadtools-c6095ad062eaa0f5576cfab1c4fe436b90c2fbfe.tar.gz
tools-c6095ad062eaa0f5576cfab1c4fe436b90c2fbfe.tar.bz2
tools-c6095ad062eaa0f5576cfab1c4fe436b90c2fbfe.tar.xz
tools-c6095ad062eaa0f5576cfab1c4fe436b90c2fbfe.zip
Add initial tools
Diffstat (limited to 'hercules/code/servertoclient/npcs.py')
-rw-r--r--hercules/code/servertoclient/npcs.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/hercules/code/servertoclient/npcs.py b/hercules/code/servertoclient/npcs.py
new file mode 100644
index 0000000..5e49ffd
--- /dev/null
+++ b/hercules/code/servertoclient/npcs.py
@@ -0,0 +1,29 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2015 Evol Online
+# Author: Andrei Karas (4144)
+
+from code.fileutils import makeDir, readFile, saveFile
+
+
+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/"
+ makeDir(destDir)
+ tpl = readFile(templatesDir + "npc.tpl")
+ npcs = readFile(templatesDir + "npcs.xml")
+ data = ""
+
+ for key in getNpcIds(idtofile):
+ npcSprite = "<sprite>sprites/{0}.xml</sprite>".format(idtofile[key])
+ data = data + tpl.format(
+ id = key,
+ sprite = npcSprite)
+ saveFile(destDir + "npcs.xml", npcs.format(data))