summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsheraf <acheraf1998@gmail.com>2019-10-29 14:25:10 +0100
committerAsheraf <acheraf1998@gmail.com>2019-10-30 12:11:14 +0100
commit5a02643ceb1d8b866d5b683e312397084894a673 (patch)
tree20c09feed89bc2ae502026ee941da1e00ba4af1d
parent857650c4f58d347455b0d075b49a53f69e6d0c51 (diff)
downloadhercules-5a02643ceb1d8b866d5b683e312397084894a673.tar.gz
hercules-5a02643ceb1d8b866d5b683e312397084894a673.tar.bz2
hercules-5a02643ceb1d8b866d5b683e312397084894a673.tar.xz
hercules-5a02643ceb1d8b866d5b683e312397084894a673.zip
Add support for overriding default view data in mob database
-rw-r--r--db/pre-re/mob_db.conf15
-rw-r--r--db/re/mob_db.conf15
-rw-r--r--doc/mob_db.txt23
-rw-r--r--src/map/mob.c67
-rw-r--r--src/map/mob.h1
5 files changed, 121 insertions, 0 deletions
diff --git a/db/pre-re/mob_db.conf b/db/pre-re/mob_db.conf
index 565167e95..70edd12e9 100644
--- a/db/pre-re/mob_db.conf
+++ b/db/pre-re/mob_db.conf
@@ -94,6 +94,21 @@ mob_db: (
// ...
}
DamageTakenRate: damage taken rate (int, defaults to 100)
+ ViewData: {
+ SpriteId: sprite id (int, defaults to Id)
+ WeaponId: weapon id (int, defaults to 0)
+ ShieldId: shield id (int, defaults to 0)
+ RobeId: garment id (int, defaults to 0)
+ HeadTopId: top headgear id (int, defaults to 0)
+ HeadMidId: middle headgear id (int, defaults to 0)
+ HeadLowId: lower headgear id (int, defaults to 0)
+ HairStyleId: hair style id (int, defaults to 0)
+ BodyStyleId: clothes id (int, defaults to 0)
+ HairColorId: hair color id (int, defaults to 0)
+ BodyColorId: clothes color id (int, defaults to 0)
+ Gender: gender (string, defaults to "SEX_FEMALE")
+ Options: options (int, defaults to 0)
+ }
},
**************************************************************************/
diff --git a/db/re/mob_db.conf b/db/re/mob_db.conf
index 95645abe6..89bcffb3e 100644
--- a/db/re/mob_db.conf
+++ b/db/re/mob_db.conf
@@ -94,6 +94,21 @@ mob_db: (
// ...
}
DamageTakenRate: damage taken rate (int, defaults to 100)
+ ViewData: {
+ SpriteId: sprite id (int, defaults to Id)
+ WeaponId: weapon id (int, defaults to 0)
+ ShieldId: shield id (int, defaults to 0)
+ RobeId: garment id (int, defaults to 0)
+ HeadTopId: top headgear id (int, defaults to 0)
+ HeadMidId: middle headgear id (int, defaults to 0)
+ HeadLowId: lower headgear id (int, defaults to 0)
+ HairStyleId: hair style id (int, defaults to 0)
+ BodyStyleId: clothes id (int, defaults to 0)
+ HairColorId: hair color id (int, defaults to 0)
+ BodyColorId: clothes color id (int, defaults to 0)
+ Gender: gender (string, defaults to "SEX_FEMALE")
+ Options: options (int, defaults to 0)
+ }
},
**************************************************************************/
diff --git a/doc/mob_db.txt b/doc/mob_db.txt
index d62181048..53d345255 100644
--- a/doc/mob_db.txt
+++ b/doc/mob_db.txt
@@ -73,6 +73,22 @@ mob_db: (
AegisName: (chance, "Option Drop Group")
// ...
}
+ DamageTakenRate: damage taken rate (int, defaults to 100)
+ ViewData: {
+ SpriteId: sprite id (int, defaults to Id)
+ WeaponId: weapon id (int, defaults to 0)
+ ShieldId: shield id (int, defaults to 0)
+ RobeId: garment id (int, defaults to 0)
+ HeadTopId: top headgear id (int, defaults to 0)
+ HeadMidId: middle headgear id (int, defaults to 0)
+ HeadLowId: lower headgear id (int, defaults to 0)
+ HairStyleId: hair style id (int, defaults to 0)
+ BodyStyleId: clothes id (int, defaults to 0)
+ HairColorId: hair color id (int, defaults to 0)
+ BodyColorId: clothes color id (int, defaults to 0)
+ Gender: gender (string, defaults to "SEX_FEMALE")
+ Options: options (int, defaults to 0)
+ }
},
...
)
@@ -255,3 +271,10 @@ Drops: Sets monster drops list.
}
When not specified, becomes false (no drops).
+
+DamageTakenRate:
+ Limit the total damage received by the monster to the given rate
+
+ViewData:
+ Overrides the default view data sent to the client with the given values for:
+ Sprite, Weapon, Shield, Robe, HeadTop, HeadMid, HeadLow, HairStyle, BodyStyle, HairColor, BodyColor, Gender, Options
diff --git a/src/map/mob.c b/src/map/mob.c
index 2ea189c23..54c83964f 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -4171,6 +4171,50 @@ static void mob_read_db_stats_sub(struct mob_db *entry, struct config_setting_t
}
/**
+ * Processes the view data for a mob_db entry.
+ *
+ * @param[in,out] entry The destination mob_db entry, already initialized
+ * (mob_id, status.mode are expected to be already set).
+ * @param[in] t The libconfig entry.
+ */
+static void mob_read_db_viewdata_sub(struct mob_db *entry, struct config_setting_t *t)
+{
+ nullpo_retv(entry);
+ nullpo_retv(t);
+
+ struct config_setting_t *it;
+ int i32;
+
+ if ((it = libconfig->setting_get_member(t, "SpriteId")) != NULL)
+ entry->vd.class = libconfig->setting_get_int(it);
+ if ((it = libconfig->setting_get_member(t, "WeaponId")) != NULL)
+ entry->vd.weapon = libconfig->setting_get_int(it);
+ if ((it = libconfig->setting_get_member(t, "ShieldId")) != NULL)
+ entry->vd.shield = libconfig->setting_get_int(it);
+ if ((it = libconfig->setting_get_member(t, "RobeId")) != NULL)
+ entry->vd.robe = libconfig->setting_get_int(it);
+ if ((it = libconfig->setting_get_member(t, "HeadTopId")) != NULL)
+ entry->vd.head_top = libconfig->setting_get_int(it);
+ if ((it = libconfig->setting_get_member(t, "HeadMidId")) != NULL)
+ entry->vd.head_mid = libconfig->setting_get_int(it);
+ if ((it = libconfig->setting_get_member(t, "HeadLowId")) != NULL)
+ entry->vd.head_bottom = libconfig->setting_get_int(it);
+ if ((it = libconfig->setting_get_member(t, "HairStyleId")) != NULL)
+ entry->vd.hair_style = libconfig->setting_get_int(it);
+ if ((it = libconfig->setting_get_member(t, "BodyStyleId")) != NULL)
+ entry->vd.body_style = libconfig->setting_get_int(it);
+ if ((it = libconfig->setting_get_member(t, "HairColorId")) != NULL)
+ entry->vd.hair_color = libconfig->setting_get_uint16(it);
+ if ((it = libconfig->setting_get_member(t, "BodyColorId")) != NULL)
+ entry->vd.cloth_color = libconfig->setting_get_uint16(it);
+ if (mob->lookup_const(t, "Gender", &i32) && i32 >= 0) {
+ entry->vd.sex = (char)i32;
+ }
+ if ((it = libconfig->setting_get_member(t, "Options")) != NULL)
+ entry->option = libconfig->setting_get_int(it) &~ (OPTION_HIDE | OPTION_CLOAK | OPTION_INVISIBLE);
+}
+
+/**
* Processes the mode for a mob_db entry.
*
* @param[in] entry The destination mob_db entry, already initialized.
@@ -4650,6 +4694,22 @@ static int mob_read_db_sub(struct config_setting_t *mobt, int n, const char *sou
* AegisName: (chance, "Option Drop Group")
* ...
* }
+ * DamageTakenRate: damage taken rate
+ * ViewData: {
+ * SpriteId: sprite id
+ * WeaponId: weapon id
+ * ShieldId: shield id
+ * RobeId: garment id
+ * HeadTopId: top headgear id
+ * HeadMidId: middle headgear id
+ * HeadLowId: lower headgear id
+ * HairStyleId: hair style id
+ * BodyStyleId: clothes id
+ * HairColorId: hair color id
+ * BodyColorId: clothes color id
+ * Gender: gender
+ * Options: options
+ * }
*/
if (!libconfig->setting_lookup_int(mobt, "Id", &i32)) {
@@ -4879,6 +4939,12 @@ static int mob_read_db_sub(struct config_setting_t *mobt, int n, const char *sou
md.dmg_taken_rate = 100;
}
+ if ((t = libconfig->setting_get_member(mobt, "ViewData"))) {
+ if (config_setting_is_group(t)) {
+ mob->read_db_viewdata_sub(&md, t);
+ }
+ }
+
mob->read_db_additional_fields(&md, mobt, n, source);
return mob->db_validate_entry(&md, n, source);
@@ -5893,6 +5959,7 @@ void mob_defaults(void)
mob->read_db_mode_sub = mob_read_db_mode_sub;
mob->read_db_drops_option = mob_read_db_drops_option;
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->read_randommonster = mob_read_randommonster;
diff --git a/src/map/mob.h b/src/map/mob.h
index 9b0f6ffe0..5830bf888 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -590,6 +590,7 @@ struct mob_interface {
uint32 (*read_db_mode_sub) (struct mob_db *entry, struct config_setting_t *t);
struct optdrop_group *(*read_db_drops_option) (struct mob_db *entry, const char *item_name, struct config_setting_t *drop, int *drop_rate);
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);
int (*read_randommonster) (void);