Fixed drop rate bonuses (#3986)
Fixes #2613 Co-authored-by: aleos <aleos89@users.noreply.github.com> Co-authored-by: Lemongrass3110 <lemongrass@kstp.at> Co-authored-by: Atemo <Atemo@users.noreply.github.com>
This commit is contained in:
parent
21cb9e87a2
commit
72aafdadea
@ -185,3 +185,7 @@ mer_idle_no_share: no
|
||||
// NOTE: This allows you to configure different settings for mercenary, separated from normal idle timer and 'idletime_option'.
|
||||
// It will only apply to mercenary-only kills and it will not affect normal autoloot and party share options.
|
||||
idletime_mer_option: 0x1F
|
||||
|
||||
// If drop rate was below this amount and bonus is applied to it, the bonus can't make it exceed this amount.
|
||||
drop_rate_cap: 9000
|
||||
drop_rate_cap_vip: 9000
|
||||
|
@ -4904,7 +4904,7 @@ Body:
|
||||
NoMail: true
|
||||
NoAuction: true
|
||||
Script: |
|
||||
sc_start SC_ITEMBOOST,1800000,200;
|
||||
sc_start SC_ITEMBOOST,1800000,100;
|
||||
- Id: 12211
|
||||
AegisName: Kafra_Card
|
||||
Name: Kafra Card
|
||||
@ -5562,7 +5562,7 @@ Body:
|
||||
NoMail: true
|
||||
NoAuction: true
|
||||
Script: |
|
||||
sc_start SC_ITEMBOOST,1800000,200;
|
||||
sc_start SC_ITEMBOOST,1800000,100;
|
||||
- Id: 12265
|
||||
AegisName: Comp_Insurance
|
||||
Name: Life Insurrance
|
||||
@ -7557,7 +7557,7 @@ Body:
|
||||
Buy: 2
|
||||
Weight: 10
|
||||
Script: |
|
||||
sc_start SC_ITEMBOOST,900000,300;
|
||||
sc_start SC_ITEMBOOST,900000,200;
|
||||
- Id: 12413
|
||||
AegisName: PCBang_Coupon_Box2
|
||||
Name: PCBang Coupon Box2
|
||||
|
@ -6029,7 +6029,7 @@ Body:
|
||||
NoMail: true
|
||||
NoAuction: true
|
||||
Script: |
|
||||
sc_start SC_ITEMBOOST,1800000,200;
|
||||
sc_start SC_ITEMBOOST,1800000,100;
|
||||
- Id: 12211
|
||||
AegisName: Kafra_Card
|
||||
Name: Kafra Card
|
||||
@ -8696,7 +8696,7 @@ Body:
|
||||
Buy: 2
|
||||
Weight: 10
|
||||
Script: |
|
||||
sc_start SC_ITEMBOOST,900000,300;
|
||||
sc_start SC_ITEMBOOST,900000,200;
|
||||
- Id: 12413
|
||||
AegisName: PCBang_Coupon_Box2
|
||||
Name: PC Cafe Coupon Box
|
||||
@ -45103,7 +45103,7 @@ Body:
|
||||
NoAuction: true
|
||||
Script: |
|
||||
sc_start SC_EXPBOOST,8640000,50;
|
||||
sc_start SC_ITEMBOOST,8640000,200;
|
||||
sc_start SC_ITEMBOOST,8640000,100;
|
||||
- Id: 22617
|
||||
AegisName: Clear_Box_S
|
||||
Name: Clear Box S
|
||||
|
@ -7473,25 +7473,19 @@ ACMD_FUNC(mobinfo)
|
||||
clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
|
||||
strcpy(atcmd_output, " ");
|
||||
unsigned int j = 0;
|
||||
int drop_modifier = 100;
|
||||
#ifdef RENEWAL_DROP
|
||||
int penalty = pc_level_penalty_mod( sd, PENALTY_DROP, mob );
|
||||
if( battle_config.atcommand_mobinfo_type ){
|
||||
drop_modifier = pc_level_penalty_mod( sd, PENALTY_DROP, mob );
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
|
||||
int droprate;
|
||||
if (mob->dropitem[i].nameid == 0 || mob->dropitem[i].rate < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
|
||||
continue;
|
||||
droprate = mob->dropitem[i].rate;
|
||||
|
||||
#ifdef RENEWAL_DROP
|
||||
if( battle_config.atcommand_mobinfo_type ) {
|
||||
droprate = droprate * penalty / 100;
|
||||
if (droprate <= 0 && !battle_config.drop_rate0item)
|
||||
droprate = 1;
|
||||
}
|
||||
#endif
|
||||
if (pc_isvip(sd)) // Display drop rate increase for VIP
|
||||
droprate += (droprate * battle_config.vip_drop_increase) / 100;
|
||||
int droprate = mob_getdroprate( &sd->bl, mob, mob->dropitem[i].rate, drop_modifier );
|
||||
|
||||
if (item_data->slots)
|
||||
sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->ename.c_str(), item_data->slots, (float)droprate / 100);
|
||||
else
|
||||
|
@ -8886,6 +8886,8 @@ static const struct _battle_data {
|
||||
{ "mob_max_skilllvl", &battle_config.mob_max_skilllvl, MAX_MOBSKILL_LEVEL, 1, MAX_MOBSKILL_LEVEL, },
|
||||
{ "retaliate_to_master", &battle_config.retaliate_to_master, 1, 0, 1, },
|
||||
{ "rare_drop_announce", &battle_config.rare_drop_announce, 0, 0, 10000, },
|
||||
{ "drop_rate_cap", &battle_config.drop_rate_cap, 9000, 0, 10000, },
|
||||
{ "drop_rate_cap_vip", &battle_config.drop_rate_cap_vip, 9000, 0, 10000, },
|
||||
{ "duel_allow_pvp", &battle_config.duel_allow_pvp, 0, 0, 1, },
|
||||
{ "duel_allow_gvg", &battle_config.duel_allow_gvg, 0, 0, 1, },
|
||||
{ "duel_allow_teleport", &battle_config.duel_allow_teleport, 0, 0, 1, },
|
||||
|
@ -440,6 +440,8 @@ struct Battle_Config
|
||||
int character_size; // if riders have size=2, and baby class riders size=1 [Lupus]
|
||||
int mob_max_skilllvl; // Max possible skill level [Lupus]
|
||||
int rare_drop_announce; // chance <= to show rare drops global announces
|
||||
int drop_rate_cap; // Drop rate can't be raised above this amount by drop bonus items
|
||||
int drop_rate_cap_vip;
|
||||
|
||||
int retaliate_to_master; //Whether when a mob is attacked by another mob, it will retaliate versus the mob or the mob's master. [Skotlex]
|
||||
|
||||
|
142
src/map/mob.cpp
142
src/map/mob.cpp
@ -2471,6 +2471,83 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Get modified drop rate
|
||||
* @param src: Source object
|
||||
* @param mob: Monster data
|
||||
* @param base_rate: Base drop rate
|
||||
* @param drop_modifier: RENEWAL_DROP level modifier
|
||||
* @return Modified drop rate
|
||||
*/
|
||||
int mob_getdroprate(struct block_list *src, std::shared_ptr<s_mob_db> mob, int base_rate, int drop_modifier)
|
||||
{
|
||||
int drop_rate = base_rate;
|
||||
|
||||
if (battle_config.mob_size_influence) { // Change drops depending on monsters size [Valaris]
|
||||
if (mob->status.size == SZ_MEDIUM && drop_rate >= 2)
|
||||
drop_rate /= 2; // SZ_MEDIUM actually is small size modification... this is not a bug!
|
||||
else if (mob->status.size == SZ_BIG)
|
||||
drop_rate *= 2;
|
||||
}
|
||||
|
||||
if (src) {
|
||||
if (battle_config.drops_by_luk) // Drops affected by luk as a fixed increase [Valaris]
|
||||
drop_rate += status_get_luk(src) * battle_config.drops_by_luk / 100;
|
||||
if (battle_config.drops_by_luk2) // Drops affected by luk as a % increase [Skotlex]
|
||||
drop_rate += (int)(0.5 + drop_rate * status_get_luk(src) * battle_config.drops_by_luk2 / 10000.);
|
||||
|
||||
if (src->type == BL_PC) { // Player specific drop rate adjustments
|
||||
struct map_session_data *sd = (struct map_session_data*)src;
|
||||
int drop_rate_bonus = 100;
|
||||
|
||||
// In PK mode players get an additional drop chance bonus of 25% if there is a 20 level difference
|
||||
if( battle_config.pk_mode && (int)(mob->lv - sd->status.base_level) >= 20 ){
|
||||
drop_rate_bonus += 25;
|
||||
}
|
||||
|
||||
// Add class and race specific bonuses
|
||||
drop_rate_bonus += sd->indexed_bonus.dropaddclass[mob->status.class_] + sd->indexed_bonus.dropaddclass[CLASS_ALL];
|
||||
drop_rate_bonus += sd->indexed_bonus.dropaddrace[mob->status.race] + sd->indexed_bonus.dropaddrace[RC_ALL];
|
||||
|
||||
if (sd->sc.data[SC_ITEMBOOST])
|
||||
drop_rate_bonus += sd->sc.data[SC_ITEMBOOST]->val1;
|
||||
|
||||
int cap;
|
||||
|
||||
if (pc_isvip(sd)) { // Increase item drop rate for VIP.
|
||||
// Unsure how the VIP and other bonuses should stack, this is additive.
|
||||
drop_rate_bonus += battle_config.vip_drop_increase;
|
||||
cap = battle_config.drop_rate_cap_vip;
|
||||
} else
|
||||
cap = battle_config.drop_rate_cap;
|
||||
|
||||
drop_rate = (int)( 0.5 + drop_rate * drop_rate_bonus / 100. );
|
||||
|
||||
// Now limit the drop rate to never be exceed the cap (default: 90%), unless it is originally above it already.
|
||||
if( drop_rate > cap && base_rate < cap ){
|
||||
drop_rate = cap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RENEWAL_DROP
|
||||
drop_rate = apply_rate( drop_rate, drop_modifier );
|
||||
#endif
|
||||
|
||||
// Cap it to 100%
|
||||
drop_rate = min( drop_rate, 10000 );
|
||||
|
||||
// If the monster's drop rate can become 0
|
||||
if( battle_config.drop_rate0item ){
|
||||
drop_rate = max( drop_rate, 0 );
|
||||
}else{
|
||||
// If not - cap to 0.01% drop rate - as on official servers
|
||||
drop_rate = max( drop_rate, 1 );
|
||||
}
|
||||
|
||||
return drop_rate;
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Signals death of mob.
|
||||
* type&1 -> no drops, type&2 -> no exp
|
||||
@ -2732,9 +2809,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
|
||||
struct item_drop_list *dlist = ers_alloc(item_drop_list_ers, struct item_drop_list);
|
||||
struct item_drop *ditem;
|
||||
struct item_data* it = NULL;
|
||||
int drop_rate;
|
||||
int drop_rate, drop_modifier = 100;
|
||||
|
||||
#ifdef RENEWAL_DROP
|
||||
int drop_modifier = pc_level_penalty_mod( mvp_sd != nullptr ? mvp_sd : second_sd != nullptr ? second_sd : third_sd, PENALTY_DROP, nullptr, md );
|
||||
drop_modifier = pc_level_penalty_mod( mvp_sd != nullptr ? mvp_sd : second_sd != nullptr ? second_sd : third_sd, PENALTY_DROP, nullptr, md );
|
||||
#endif
|
||||
dlist->m = md->bl.m;
|
||||
dlist->x = md->bl.x;
|
||||
@ -2749,63 +2827,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
|
||||
continue;
|
||||
if ( !(it = itemdb_exists(md->db->dropitem[i].nameid)) )
|
||||
continue;
|
||||
drop_rate = md->db->dropitem[i].rate;
|
||||
if (drop_rate <= 0) {
|
||||
if (battle_config.drop_rate0item)
|
||||
continue;
|
||||
drop_rate = 1;
|
||||
}
|
||||
|
||||
drop_rate = mob_getdroprate(src, md->db, md->db->dropitem[i].rate, drop_modifier);
|
||||
|
||||
// change drops depending on monsters size [Valaris]
|
||||
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) {
|
||||
//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;
|
||||
//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.);
|
||||
}
|
||||
|
||||
// Player specific drop rate adjustments
|
||||
if( sd ){
|
||||
int drop_rate_bonus = 0;
|
||||
|
||||
// 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->indexed_bonus.dropaddclass[md->status.class_] + sd->indexed_bonus.dropaddclass[CLASS_ALL];
|
||||
drop_rate_bonus += sd->indexed_bonus.dropaddrace[md->status.race] + sd->indexed_bonus.dropaddrace[RC_ALL];
|
||||
|
||||
// Increase drop rate if user has SC_ITEMBOOST
|
||||
if (sd->sc.data[SC_ITEMBOOST])
|
||||
drop_rate_bonus += sd->sc.data[SC_ITEMBOOST]->val1;
|
||||
|
||||
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_bonus, 0, 9000));
|
||||
|
||||
if (pc_isvip(sd)) { // Increase item drop rate for VIP.
|
||||
drop_rate += (int)(0.5 + drop_rate * battle_config.vip_drop_increase / 100.);
|
||||
drop_rate = min(drop_rate,10000); //cap it to 100%
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RENEWAL_DROP
|
||||
if( drop_modifier != 100 ) {
|
||||
drop_rate = apply_rate(drop_rate, drop_modifier);
|
||||
if( drop_rate < 1 )
|
||||
drop_rate = 1;
|
||||
}
|
||||
#endif
|
||||
// attempt to drop the item
|
||||
if (rnd() % 10000 >= drop_rate)
|
||||
continue;
|
||||
@ -2818,7 +2842,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
|
||||
ditem = mob_setdropitem(&md->db->dropitem[i], 1, md->mob_id);
|
||||
|
||||
//A Rare Drop Global Announce by Lupus
|
||||
if( mvp_sd && drop_rate <= battle_config.rare_drop_announce ) {
|
||||
if( mvp_sd && md->db->dropitem[i].rate <= battle_config.rare_drop_announce ) {
|
||||
char message[128];
|
||||
sprintf (message, msg_txt(NULL,541), mvp_sd->status.name, md->name, it->ename.c_str(), (float)drop_rate/100);
|
||||
//MSG: "'%s' won %s's %s (chance: %0.02f%%)"
|
||||
|
@ -504,6 +504,8 @@ void mob_add_spawn(uint16 mob_id, const struct spawn_info& new_spawn);
|
||||
const std::vector<spawn_info> mob_get_spawns(uint16 mob_id);
|
||||
bool mob_has_spawn(uint16 mob_id);
|
||||
|
||||
int mob_getdroprate(struct block_list *src, std::shared_ptr<s_mob_db> mob, int base_rate, int drop_modifier);
|
||||
|
||||
// MvP Tomb System
|
||||
int mvptomb_setdelayspawn(struct npc_data *nd);
|
||||
TIMER_FUNC(mvptomb_delayspawn);
|
||||
|
Loading…
x
Reference in New Issue
Block a user