summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/mob_avail.txt43
-rw-r--r--src/map/mob.c45
-rw-r--r--src/map/mob.h2
-rw-r--r--tools/mobavailconverter.py94
4 files changed, 102 insertions, 82 deletions
diff --git a/db/mob_avail.txt b/db/mob_avail.txt
deleted file mode 100644
index 2df4ddedc..000000000
--- a/db/mob_avail.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-// Mob Availability and Alias Database
-//
-// Structure of Database:
-// MobID,SpriteID{,Equipment}
-//
-// 01. MobID Mob ID to change.
-// 02. SpriteID Mob ID which will be sent to the client instead of MobID.
-// If 0, the mob becomes unavailable for use.
-// 03. Equipment Item ID of pet equipment (must be available for pet counterpart, or this will cause problems).
-//
-// To disguise a mob as a player:
-// MobID,SpriteID,Sex,Hair_Style,Hair_Color,Weapon,Shield,Head_Top,Head_Middle,Head_Bottom,Option,Dye_Color
-//
-// SpriteID is a job class value.
-// Weapon and Shield uses Item ID, while Head uses View ID.
-
-//1002,1039 // Poring - Baphomet
-//1970,1002,10013 // Displays a Poring with a backpack
-
-// Easter Event Monsters
-//1920,1047,0
-//1921,1093,0
-
-// eA Dev Team
-// Valaris
-//1900,4013,1,1,1,1254,0,67,12,54,16,1
-// Valaris Worshiper
-//1901,6,1,1,1,1219,2101,67,12,54,0,1
-// MC Cameri
-//1902,14,1,6,6,1101,2105,0,0,0,32,3
-// Poki#3
-//1903,4012,1,21,0,1720,0,102,184,57,16,0
-// Sentry
-//1904,1286,0
-
-// iRO Halloween Event 2008
-//3000,1015,0
-//3001,1036,0
-//3002,1298,0
-
-// iRO Halloween Event 2009
-//3014,1179,0
-//3015,1272,0
diff --git a/src/map/mob.c b/src/map/mob.c
index 54c83964f..48cbbf6f2 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -5080,46 +5080,15 @@ static void mob_name_constants(void)
#endif // ENABLE_CASE_CHECK
}
-/*==========================================
- * MOB display graphic change data reading
- *------------------------------------------*/
-static bool mob_readdb_mobavail(char *str[], int columns, int current)
+static void mob_mobavail_removal_notice(void)
{
- int class_, view_class;
-
- nullpo_retr(false, str);
- class_=atoi(str[0]);
-
- if(mob->db(class_) == mob->dummy) {
- // invalid class (probably undefined in db)
- ShowWarning("mob_readdb_mobavail: Unknown mob id %d.\n", class_);
- return false;
- }
-
- view_class = atoi(str[1]);
+ char filepath[256];
- memset(&mob->db_data[class_]->vd, 0, sizeof(struct view_data));
- mob->db_data[class_]->vd.class = view_class;
+ safesnprintf(filepath, sizeof(filepath), "%s/mob_avail.txt", map->db_path);
- //Player sprites
- if (pc->db_checkid(view_class) && columns == 12) {
- mob->db_data[class_]->vd.sex=atoi(str[2]);
- mob->db_data[class_]->vd.hair_style=atoi(str[3]);
- mob->db_data[class_]->vd.hair_color=atoi(str[4]);
- mob->db_data[class_]->vd.weapon=atoi(str[5]);
- mob->db_data[class_]->vd.shield=atoi(str[6]);
- mob->db_data[class_]->vd.head_top=atoi(str[7]);
- mob->db_data[class_]->vd.head_mid=atoi(str[8]);
- mob->db_data[class_]->vd.head_bottom=atoi(str[9]);
- mob->db_data[class_]->option=atoi(str[10])&~(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE);
- mob->db_data[class_]->vd.cloth_color=atoi(str[11]); // Monster player dye option - Valaris
+ if (exists(filepath)) {
+ ShowError("mob_mobavail_removal_notice: the usage of mob_avail.txt is no longer supported, move your data using tools/mobavailconverter.py and delete the database file to suspend this message.\n");
}
- else if(columns==3)
- mob->db_data[class_]->vd.head_bottom=atoi(str[2]); // mob equipment [Valaris]
- else if( columns != 2 )
- return false;
-
- return true;
}
/*==========================================
@@ -5637,7 +5606,7 @@ static void mob_load(bool minimal)
mob->readchatdb();
mob->readdb();
mob->readskilldb();
- sv->readdb(map->db_path, "mob_avail.txt", ',', 2, 12, -1, mob->readdb_mobavail);
+ mob->mobavail_removal_notice();
mob->read_randommonster();
sv->readdb(map->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, mob->readdb_race2);
}
@@ -5961,7 +5930,7 @@ void mob_defaults(void)
mob->read_db_stats_sub = mob_read_db_stats_sub;
mob->read_db_viewdata_sub = mob_read_db_viewdata_sub;
mob->name_constants = mob_name_constants;
- mob->readdb_mobavail = mob_readdb_mobavail;
+ mob->mobavail_removal_notice = mob_mobavail_removal_notice;
mob->read_randommonster = mob_read_randommonster;
mob->parse_row_chatdb = mob_parse_row_chatdb;
mob->readchatdb = mob_readchatdb;
diff --git a/src/map/mob.h b/src/map/mob.h
index 5830bf888..6a4744ca5 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -592,7 +592,7 @@ struct mob_interface {
void (*read_db_stats_sub) (struct mob_db *entry, struct config_setting_t *t);
void (*read_db_viewdata_sub) (struct mob_db *entry, struct config_setting_t *t);
void (*name_constants) (void);
- bool (*readdb_mobavail) (char *str[], int columns, int current);
+ void (*mobavail_removal_notice) (void);
int (*read_randommonster) (void);
bool (*parse_row_chatdb) (char **str, const char *source, int line, int *last_msg_id);
void (*readchatdb) (void);
diff --git a/tools/mobavailconverter.py b/tools/mobavailconverter.py
new file mode 100644
index 000000000..44a3cd2eb
--- /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 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)