diff options
author | Haru <haru@dotalux.com> | 2019-07-28 20:25:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-28 20:25:19 +0200 |
commit | c179d9184301e83e75a425fc09818be98b443f65 (patch) | |
tree | 2d27640ae8e572eac3f763dd4375ed233e157977 /src/map | |
parent | 015f3ef6f763fb11360b4b644d19034e4fcb0357 (diff) | |
parent | b372b02e9cc21ceeb42a428177d992998aed2eec (diff) | |
download | hercules-c179d9184301e83e75a425fc09818be98b443f65.tar.gz hercules-c179d9184301e83e75a425fc09818be98b443f65.tar.bz2 hercules-c179d9184301e83e75a425fc09818be98b443f65.tar.xz hercules-c179d9184301e83e75a425fc09818be98b443f65.zip |
Merge pull request #2510 from Emistry/mobdb_dmg_taken_rate
Update mob_db - DamageTakenRate field
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/battle.c | 12 | ||||
-rw-r--r-- | src/map/mob.c | 7 | ||||
-rw-r--r-- | src/map/mob.h | 2 | ||||
-rw-r--r-- | src/map/script.c | 9 | ||||
-rw-r--r-- | src/map/script.h | 1 | ||||
-rw-r--r-- | src/map/skill.c | 12 |
6 files changed, 43 insertions, 0 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 7fa1567e7..3cb7c9a93 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6321,6 +6321,18 @@ static enum damage_lv battle_weapon_attack(struct block_list *src, struct block_ if (sd && sd->state.arrow_atk) //Consume arrow. battle->consume_ammo(sd, 0, 0); + if (target->type == BL_MOB) { + struct mob_data *md = BL_CAST(BL_MOB, target); + if (md != NULL) { + if (md->db->dmg_taken_rate != 100) { + if (wd.damage > 0) + wd.damage = apply_percentrate64(wd.damage, md->db->dmg_taken_rate, 100); + if (wd.damage2 > 0) + wd.damage2 = apply_percentrate64(wd.damage2, md->db->dmg_taken_rate, 100); + } + } + } + damage = wd.damage + wd.damage2; if( damage > 0 && src != target ) { if( sc && sc->data[SC_DUPLELIGHT] && (wd.flag&BF_SHORT) && rnd()%100 <= 10+2*sc->data[SC_DUPLELIGHT]->val1 ){ diff --git a/src/map/mob.c b/src/map/mob.c index 939d062af..283bec25a 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4604,6 +4604,7 @@ static int mob_read_db_sub(struct config_setting_t *mobt, int n, const char *sou * AttackMotion: attack motion * DamageMotion: damage motion * MvpExp: mvp experience + * DamageTakenRate: damage taken rate * MvpDrops: { * AegisName: chance * ... @@ -4837,6 +4838,12 @@ static int mob_read_db_sub(struct config_setting_t *mobt, int n, const char *sou } } + if (mob->lookup_const(mobt, "DamageTakenRate", &i32) && i32 >= 0) { + md.dmg_taken_rate = cap_value(i32, 1, INT_MAX); + } else if (!inherit) { + md.dmg_taken_rate = 100; + } + mob->read_db_additional_fields(&md, mobt, n, source); return mob->db_validate_entry(&md, n, source); diff --git a/src/map/mob.h b/src/map/mob.h index 0a7489c47..a48c4cc74 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -206,6 +206,7 @@ struct mob_db { unsigned int option; int summonper[MAX_RANDOMMONSTER]; int maxskill; + int dmg_taken_rate; struct mob_skill skill[MAX_MOBSKILL]; struct spawn_info spawn[10]; struct hplugin_data_store *hdata; ///< HPM Plugin Data Store @@ -244,6 +245,7 @@ struct mob_data { unsigned int dmg; unsigned int flag : 2; //0: Normal. 1: Homunc exp. 2: Pet exp } dmglog[DAMAGELOG_SIZE]; + int dmg_taken_rate; struct spawn_data *spawn; //Spawn data. int spawn_timer; //Required for Convex Mirror struct item *lootitem; diff --git a/src/map/script.c b/src/map/script.c index 20b4c238a..f515d4403 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -18584,6 +18584,7 @@ static BUILDIN(getmonsterinfo) case 20: script_pushint(st,monster->status.def_ele); break; case 21: script_pushint(st,monster->status.mode); break; case 22: script_pushint(st,monster->mexp); break; + case 23: script_pushint(st, monster->dmg_taken_rate); break; default: script_pushint(st,-1); //wrong Index } return true; @@ -19141,6 +19142,9 @@ static BUILDIN(setunitdata) script_pushint(st, 1); return true; } + case UDT_DAMAGE_TAKEN_RATE: + setunitdata_check_bounds(4, 1, INT_MAX); + break; default: break; } @@ -19315,6 +19319,9 @@ static BUILDIN(setunitdata) case UDT_DMOTION: md->status.dmotion = (unsigned short) val; break; + case UDT_DAMAGE_TAKEN_RATE: + md->dmg_taken_rate = (int) val; + break; default: ShowWarning("buildin_setunitdata: Invalid data type '%s' for mob unit.\n", udtype); script_pushint(st, 0); @@ -20162,6 +20169,7 @@ static BUILDIN(getunitdata) case UDT_AMOTION: script_pushint(st, md->status.amotion); break; case UDT_ADELAY: script_pushint(st, md->status.adelay); break; case UDT_DMOTION: script_pushint(st, md->status.dmotion); break; + case UDT_DAMAGE_TAKEN_RATE: script_pushint(st, md->dmg_taken_rate); break; default: ShowWarning("buildin_getunitdata: Invalid data type '%s' for Mob unit.\n", udtype); script_pushint(st, -1); @@ -26894,6 +26902,7 @@ static void script_hardcoded_constants(void) script->set_constant("UDT_ROBE", UDT_ROBE, false, false); script->set_constant("UDT_BODY2", UDT_BODY2, false, false); script->set_constant("UDT_GROUP", UDT_GROUP, false, false); + script->set_constant("UDT_DAMAGE_TAKEN_RATE", UDT_DAMAGE_TAKEN_RATE, false, false); script->constdb_comment("getguildonline types"); script->set_constant("GUILD_ONLINE_ALL", GUILD_ONLINE_ALL, false, false); diff --git a/src/map/script.h b/src/map/script.h index 62950ba8d..84a8e3b6e 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -434,6 +434,7 @@ enum script_unit_data_types { UDT_ROBE, UDT_BODY2, UDT_GROUP, + UDT_DAMAGE_TAKEN_RATE, UDT_MAX }; diff --git a/src/map/skill.c b/src/map/skill.c index a259829ef..af61c887c 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2906,6 +2906,18 @@ static int skill_attack(int attack_type, struct block_list *src, struct block_li } } + if (bl->type == BL_MOB) { + struct mob_data *md = BL_CAST(BL_MOB, bl); + if (md != NULL) { + if (md->db->dmg_taken_rate != 100) { + if (dmg.damage > 0) + dmg.damage = apply_percentrate64(dmg.damage, md->db->dmg_taken_rate, 100); + if (dmg.damage2 > 0) + dmg.damage2 = apply_percentrate64(dmg.damage2, md->db->dmg_taken_rate, 100); + } + } + } + damage = dmg.damage + dmg.damage2; if( (skill_id == AL_INCAGI || skill_id == AL_BLESSING || |