summaryrefslogtreecommitdiff
path: root/tools/mobavailconverter.py
diff options
context:
space:
mode:
authorKenpachi2k13 <3476227+Kenpachi2k13@users.noreply.github.com>2020-05-03 09:14:56 +0200
committerGitHub <noreply@github.com>2020-05-03 09:14:56 +0200
commitcd593de68b02d77766fcb3b7b2a869096ceb7183 (patch)
tree2245738ce70d50031b927fed560815458658c7c2 /tools/mobavailconverter.py
parentf70a887b188dbd88c45c9992cd18a33b6886005f (diff)
parentf40cc839413cc82aed445d39cc3aa204dce87780 (diff)
downloadhercules-cd593de68b02d77766fcb3b7b2a869096ceb7183.tar.gz
hercules-cd593de68b02d77766fcb3b7b2a869096ceb7183.tar.bz2
hercules-cd593de68b02d77766fcb3b7b2a869096ceb7183.tar.xz
hercules-cd593de68b02d77766fcb3b7b2a869096ceb7183.zip
Merge branch 'master' into cell_noskill
Diffstat (limited to 'tools/mobavailconverter.py')
-rw-r--r--tools/mobavailconverter.py94
1 files changed, 94 insertions, 0 deletions
diff --git a/tools/mobavailconverter.py b/tools/mobavailconverter.py
new file mode 100644
index 000000000..377557710
--- /dev/null
+++ b/tools/mobavailconverter.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+#
+# This file is part of Hercules.
+# http://herc.ws - http://github.com/HerculesWS/Hercules
+#
+# Copyright (C) 2019-2020 Hercules Dev Team
+# Copyright (C) 2019 Asheraf
+#
+# Hercules is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import re
+import csv
+
+f = open('../db/re/mob_db.conf')
+mob_db = f.read()
+
+with open('../db/mob_avail.txt') as dbfile:
+ mob_avail = csv.reader(dbfile, delimiter=',')
+
+ for mob in mob_avail:
+ if len(mob) == 0 or mob[0].startswith('//'):
+ continue
+
+ mob = [re.sub(r'//.*', '', i).strip() for i in mob]
+
+ mob_id = int(mob[0])
+ sprite_id = int(mob[1])
+ weapon = 0
+ shield = 0
+ head_top = 0
+ head_mid = 0
+ head_bottom = 0
+ hair_style = 0
+ hair_color = 0
+ cloth_color = 0
+ gender = 0
+ option = 0
+ if len(mob) == 3:
+ head_bottom = int(mob[2])
+ elif len(mob) == 12:
+ gender = int(mob[2])
+ hair_style = int(mob[3])
+ hair_color = int(mob[4])
+ weapon = int(mob[5])
+ shield = int(mob[6])
+ head_top = int(mob[7])
+ head_mid = int(mob[8])
+ head_bottom = int(mob[9])
+ option = int(mob[10])
+ cloth_color = int(mob[11])
+
+ s = ''
+ s += '\tViewData: {\n'
+ s += '\t\tSpriteId: {}\n'.format(sprite_id)
+ if weapon != 0:
+ s += '\t\tWeaponId: {}\n'.format(weapon)
+ if shield != 0:
+ s += '\t\tShieldId: {}\n'.format(shield)
+ if head_top != 0:
+ s += '\t\tHeadTopId: {}\n'.format(head_top)
+ if head_mid != 0:
+ s += '\t\tHeadMidId: {}\n'.format(head_mid)
+ if head_bottom != 0:
+ s += '\t\tHeadLowId: {}\n'.format(head_bottom)
+ if hair_style != 0:
+ s += '\t\tHairStyleId: {}\n'.format(hair_style)
+ if hair_color != 0:
+ s += '\t\tHairColorId: {}\n'.format(hair_color)
+ if cloth_color != 0:
+ s += '\t\tBodyColorId: {}\n'.format(cloth_color)
+ if gender != 0:
+ s += '\t\tGender: SEX_MALE\n'
+ if option != 0:
+ s += '\t\tOptions: {}\n'.format(option)
+ s += '\t}'
+
+ mob_db = re.sub(
+ r'(\tId: ' + str(mob_id) + r'\n([\S\s]*?)(?=},))},',
+ r'\1' + str(s) + r'\n},',
+ mob_db)
+ print(mob_db)