diff options
author | Asheraf <acheraf1998@gmail.com> | 2019-10-29 14:25:10 +0100 |
---|---|---|
committer | Asheraf <acheraf1998@gmail.com> | 2019-10-30 12:11:14 +0100 |
commit | 5a02643ceb1d8b866d5b683e312397084894a673 (patch) | |
tree | 20c09feed89bc2ae502026ee941da1e00ba4af1d /src/map | |
parent | 857650c4f58d347455b0d075b49a53f69e6d0c51 (diff) | |
download | hercules-5a02643ceb1d8b866d5b683e312397084894a673.tar.gz hercules-5a02643ceb1d8b866d5b683e312397084894a673.tar.bz2 hercules-5a02643ceb1d8b866d5b683e312397084894a673.tar.xz hercules-5a02643ceb1d8b866d5b683e312397084894a673.zip |
Add support for overriding default view data in mob database
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/mob.c | 67 | ||||
-rw-r--r-- | src/map/mob.h | 1 |
2 files changed, 68 insertions, 0 deletions
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); |