From 6f7680b47bcffaf6613f72b462f545e11d40957d Mon Sep 17 00:00:00 2001 From: Kei Date: Thu, 9 Sep 2021 12:42:46 +0800 Subject: [PATCH] Rework the drop rate, bonus drop rate and the drop rate cap. * PK Enabled, increased drop rate of each item by 25% * Drop rate bonuses now stack with each other and capped to max of 90% * Moved drop_rate0item on the end so it can override the existing drop_rate cap. --- src/map/mob.c | 59 +++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/map/mob.c b/src/map/mob.c index 137416ae77a..6bef7c19309 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2723,61 +2723,64 @@ static int mob_dead(struct mob_data *md, struct block_list *src, int type) if ( !(it = itemdb->exists(md->db->dropitem[i].nameid)) ) continue; drop_rate = md->db->dropitem[i].p; - if (drop_rate <= 0) { - if (battle_config.drop_rate0item) - continue; - drop_rate = 1; - } // change drops depending on monsters size [Valaris] - if (battle_config.mob_size_influence) - { + if (battle_config.mob_size_influence) { if (md->special_state.size == SZ_MEDIUM && drop_rate >= 2) drop_rate /= 2; else if( md->special_state.size == SZ_BIG) drop_rate *= 2; } - if (src) { + if (src != NULL) { //Drops affected by luk as a fixed increase [Valaris] if (battle_config.drops_by_luk) - drop_rate += status_get_luk(src)*battle_config.drops_by_luk/100; + drop_rate += status_get_luk(src) * battle_config.drops_by_luk / 100; + //Drops affected by luk as a % increase [Skotlex] 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 && - md->level - sd->status.base_level >= 20) - drop_rate = (int)(drop_rate*1.25); // pk_mode increase drops if 20 level difference [Valaris] + drop_rate += (int)(0.5 + drop_rate * status_get_luk(src) * battle_config.drops_by_luk2 / 10000.); - // Increase drop rate if user has SC_CASH_RECEIVEITEM - if (sd) { - temp = 0; + if (sd != NULL) { + int drop_rate_bonus = 100; - if (src) - temp += sd->dropaddrace[md->status.race] + (is_boss(src) ? sd->dropaddrace[RC_BOSS] : sd->dropaddrace[RC_NONBOSS]); + // When PK Mode is enabled, increase item drop rate bonus of each items by 25% when there is a 20 level difference between the player and the monster.[KeiKun] + if (battle_config.pk_mode && (md->level - sd->status.base_level >= 20)) + drop_rate_bonus += 25; // flat 25% bonus - if (sd->sc.data[SC_CASH_RECEIVEITEM]) // now rig the drop rate to never be over 90% unless it is originally >90%. - temp += sd->sc.data[SC_CASH_RECEIVEITEM]->val1; + drop_rate_bonus += sd->dropaddrace[md->status.race] + (is_boss(src) ? sd->dropaddrace[RC_BOSS] : sd->dropaddrace[RC_NONBOSS]); // bonus2 bDropAddRace[KeiKun] - if (sd->sc.data[SC_OVERLAPEXPUP]) - temp += sd->sc.data[SC_OVERLAPEXPUP]->val2; + if (sd->sc.data[SC_CASH_RECEIVEITEM] != NULL) // Increase drop rate if user has SC_CASH_RECEIVEITEM + drop_rate_bonus += sd->sc.data[SC_CASH_RECEIVEITEM]->val1; - drop_rate = max(drop_rate, cap_value((int)(0.5 + drop_rate * temp / 100.), 0, 9000)); + if (sd->sc.data[SC_OVERLAPEXPUP] != NULL) + drop_rate_bonus += sd->sc.data[SC_OVERLAPEXPUP]->val2; + + drop_rate = (int)(0.5 + drop_rate * drop_rate_bonus / 100.); + + // Limit drop rate, default: 90% + drop_rate = max(drop_rate, 90000); + } } + #ifdef RENEWAL_DROP - if( drop_modifier != 100 ) { + if (drop_modifier != 100) { drop_rate = drop_rate * drop_modifier / 100; - if( drop_rate < 1 ) + if (drop_rate < 1) drop_rate = 1; } #endif - if( sd && sd->status.mod_drop != 100 ) { + if (sd != NULL && sd->status.mod_drop != 100) { drop_rate = drop_rate * sd->status.mod_drop / 100; - if( drop_rate < 1 ) + if (drop_rate < 1) drop_rate = 1; } + if (battle_config.drop_rate0item) + drop_rate = max(drop_rate, 0); + else + drop_rate = max(drop_rate, 1); + // attempt to drop the item if (rnd() % 10000 >= drop_rate) continue;