From 29379c3ea5ffdd134d3a7581055cd6802199b9c0 Mon Sep 17 00:00:00 2001 From: Cydh Ramdh Date: Tue, 19 Jul 2016 16:43:05 +0700 Subject: [PATCH 1/2] Added script bonuses in order to support official `AddReceiveItem_Equip n` * `bonus2 bDropAddRace,r,x;` : Adds x% to player's drop rate when killing a monster with race r. * `bonus2 bDropAddClass,c,x;` : Adds x% to player's drop rate when killing a monster with race c. Signed-off-by: Cydh Ramdh --- doc/item_bonus.txt | 3 +++ src/map/map.h | 2 +- src/map/mob.c | 21 ++++++++++++++++++--- src/map/pc.c | 10 ++++++++++ src/map/pc.h | 2 ++ src/map/script_constants.h | 2 ++ src/map/status.c | 2 ++ 7 files changed, 38 insertions(+), 4 deletions(-) diff --git a/doc/item_bonus.txt b/doc/item_bonus.txt index 5929422819..dd7aa3f016 100644 --- a/doc/item_bonus.txt +++ b/doc/item_bonus.txt @@ -411,6 +411,9 @@ bonus bBreakArmorRate,n; Adds a n/100% chance to break enemy's armor while att Monster drops ------------- +bonus2 bDropAddRace,r,x; Adds x% to player's drop rate when killing a monster with race r. +bonus2 bDropAddClass,c,x; Adds x% to player's drop rate when killing a monster with race c. + bonus3 bAddMonsterIdDropItem,iid,mid,n; Adds a n/100% chance of dropping item iid when killing monster mid bonus2 bAddMonsterDropItem,iid,n; Adds a n/100% chance for item iid to be dropped when killing a monster diff --git a/src/map/map.h b/src/map/map.h index 65ee5349f7..fbf7bd22af 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -468,7 +468,7 @@ enum _sp { SP_ADD_CLASS_DROP_ITEMGROUP, SP_ADDMAXWEIGHT, SP_ADD_ITEMGROUP_HEAL_RATE, // 2071-2073 SP_HP_VANISH_RACE_RATE, SP_SP_VANISH_RACE_RATE, SP_ABSORB_DMG_MAXHP, SP_SUB_SKILL, SP_SUBDEF_ELE, // 2074-2078 SP_STATE_NORECOVER_RACE, SP_CRITICAL_RANGEATK, SP_MAGIC_ADDRACE2, SP_IGNORE_MDEF_RACE2_RATE, // 2079-2082 - SP_WEAPON_ATK_RATE, SP_WEAPON_MATK_RATE, // 2083-2084 + SP_WEAPON_ATK_RATE, SP_WEAPON_MATK_RATE, SP_DROP_ADDRACE, SP_DROP_ADDCLASS, // 2083-2086 }; enum _look { diff --git a/src/map/mob.c b/src/map/mob.c index 201a3e9193..c628b3a55b 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2527,14 +2527,29 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) (int)(md->level - sd->status.base_level) >= 20) drop_rate = (int)(drop_rate*1.25); // pk_mode increase drops if 20 level difference [Valaris] - // Increase drop rate if user has SC_ITEMBOOST - if (sd && sd->sc.data[SC_ITEMBOOST]) // now rig the drop rate to never be over 90% unless it is originally >90%. - drop_rate = max(drop_rate,cap_value((int)(0.5+drop_rate*(sd->sc.data[SC_ITEMBOOST]->val1)/100.),0,9000)); + if (sd) { + int drop_rate_ = 0; + + if (src) { + drop_rate_ += sd->dropaddclass[md->status.class_] + sd->dropaddclass[CLASS_ALL]; + drop_rate_ += sd->dropaddrace[md->status.race] + sd->dropaddrace[RC_ALL]; + } + + // Increase drop rate if user has SC_ITEMBOOST + if (&sd->sc && sd->sc.data[SC_ITEMBOOST]) + drop_rate_ += sd->sc.data[SC_ITEMBOOST]->val1; + + drop_rate_ = (int)(0.5 + drop_rate * drop_rate_ / 100.); + // Now rig the drop rate to never be over 90% unless it is originally >90%. + drop_rate = i32max(drop_rate, cap_value(drop_rate_, 0, 9000)); + } +#ifdef VIP_ENABLE // Increase item drop rate for VIP. if (battle_config.vip_drop_increase && (sd && pc_isvip(sd))) { drop_rate += (int)(0.5 + (drop_rate * battle_config.vip_drop_increase) / 100); drop_rate = min(drop_rate,10000); //cap it to 100% } +#endif #ifdef RENEWAL_DROP if( drop_modifier != 100 ) { drop_rate = apply_rate(drop_rate, drop_modifier); diff --git a/src/map/pc.c b/src/map/pc.c index daa2458b87..afaee32ca8 100755 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3696,6 +3696,16 @@ void pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if (sd->state.lr_flag != 2) sd->ignore_mdef_by_race2[type2] += val; break; + case SP_DROP_ADDRACE: // bonus2 bDropAddRace,r,x; + PC_BONUS_CHK_RACE(type2, SP_DROP_ADDRACE); + if (sd->state.lr_flag != 2) + sd->dropaddrace[type2] += val; + break; + case SP_DROP_ADDCLASS: // bonus2 bDropAddClass,c,x; + PC_BONUS_CHK_CLASS(type2, SP_DROP_ADDCLASS); + if (sd->state.lr_flag != 2) + sd->dropaddclass[type2] += val; + break; default: if (running_npc_stat_calc_event) { ShowWarning("pc_bonus2: unknown bonus type %d %d %d in OnPCStatCalcEvent!\n", type, type2, val); diff --git a/src/map/pc.h b/src/map/pc.h index e155b466cf..587e7e1b1b 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -368,6 +368,8 @@ struct map_session_data { short sp_gain_race[RC_MAX]; int magic_addrace2[RC2_MAX]; int ignore_mdef_by_race2[RC2_MAX]; + int dropaddrace[RC_MAX]; + int dropaddclass[CLASS_MAX]; // zeroed arrays end here. // zeroed structures start here diff --git a/src/map/script_constants.h b/src/map/script_constants.h index c6cc13da08..c1d79ea8a3 100644 --- a/src/map/script_constants.h +++ b/src/map/script_constants.h @@ -660,6 +660,8 @@ script_set_constant("bCriticalLong",SP_CRITICAL_RANGEATK,false); script_set_constant("bMagicAddRace2", SP_MAGIC_ADDRACE2, false); script_set_constant("bIgnoreMdefRace2Rate", SP_IGNORE_MDEF_RACE2_RATE, false); + script_set_constant("bDropAddRace", SP_DROP_ADDRACE, false); + script_set_constant("bDropAddClass", SP_DROP_ADDCLASS, false); /* equip positions */ export_constant(EQI_HEAD_TOP); diff --git a/src/map/status.c b/src/map/status.c index 86d2bf41ec..74a9c8052d 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -3123,6 +3123,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) + sizeof(sd->ignore_mdef_by_class) + sizeof(sd->ignore_def_by_race) + sizeof(sd->sp_gain_race) + + sizeof(sd->dropaddrace) + + sizeof(sd->dropaddclass) ); memset (&sd->right_weapon.overrefine, 0, sizeof(sd->right_weapon) - sizeof(sd->right_weapon.atkmods)); From e7882351d87187f7e97c82361e9b6ec414a2dfaf Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Sat, 23 Jul 2016 18:43:09 +0200 Subject: [PATCH 2/2] Cleaned up player specific drop rate calculations Removed the src check for the new bonuses. --- src/map/mob.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/map/mob.c b/src/map/mob.c index c628b3a55b..a8324294e3 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2523,33 +2523,36 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if (battle_config.drops_by_luk2) drop_rate += (int)(0.5+drop_rate*status_get_luk(src)*battle_config.drops_by_luk2/10000.); } - if (sd && battle_config.pk_mode && - (int)(md->level - sd->status.base_level) >= 20) - drop_rate = (int)(drop_rate*1.25); // pk_mode increase drops if 20 level difference [Valaris] - if (sd) { - int drop_rate_ = 0; + // Player specific drop rate adjustments + if( sd ){ + int drop_rate_bonus = 0; - if (src) { - drop_rate_ += sd->dropaddclass[md->status.class_] + sd->dropaddclass[CLASS_ALL]; - drop_rate_ += sd->dropaddrace[md->status.race] + sd->dropaddrace[RC_ALL]; - } + // pk_mode increase drops if 20 level difference [Valaris] + if( battle_config.pk_mode && (int)(md->level - sd->status.base_level) >= 20 ) + drop_rate = (int)(drop_rate*1.25); + + // Add class and race specific bonuses + drop_rate_bonus += sd->dropaddclass[md->status.class_] + sd->dropaddclass[CLASS_ALL]; + drop_rate_bonus += sd->dropaddrace[md->status.race] + sd->dropaddrace[RC_ALL]; // Increase drop rate if user has SC_ITEMBOOST if (&sd->sc && sd->sc.data[SC_ITEMBOOST]) - drop_rate_ += sd->sc.data[SC_ITEMBOOST]->val1; + drop_rate_bonus += sd->sc.data[SC_ITEMBOOST]->val1; - drop_rate_ = (int)(0.5 + drop_rate * drop_rate_ / 100.); + drop_rate_bonus = (int)(0.5 + drop_rate * drop_rate_bonus / 100.); // Now rig the drop rate to never be over 90% unless it is originally >90%. - drop_rate = i32max(drop_rate, cap_value(drop_rate_, 0, 9000)); - } + drop_rate = i32max(drop_rate, cap_value(drop_rate_bonus, 0, 9000)); + #ifdef VIP_ENABLE - // Increase item drop rate for VIP. - if (battle_config.vip_drop_increase && (sd && pc_isvip(sd))) { - drop_rate += (int)(0.5 + (drop_rate * battle_config.vip_drop_increase) / 100); - drop_rate = min(drop_rate,10000); //cap it to 100% - } + // Increase item drop rate for VIP. + if (battle_config.vip_drop_increase && pc_isvip(sd)) { + drop_rate += (int)(0.5 + (drop_rate * battle_config.vip_drop_increase) / 100); + drop_rate = min(drop_rate,10000); //cap it to 100% + } #endif + } + #ifdef RENEWAL_DROP if( drop_modifier != 100 ) { drop_rate = apply_rate(drop_rate, drop_modifier);