From dc9c104ad231e6ba9f695072d36d586e2e3d3d4c Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Wed, 10 Apr 2024 16:43:21 +0200 Subject: Add server-wide drop rates modifier --- src/map/atcommand.cpp | 28 +++++++++++++++++++++++++--- src/map/mob.cpp | 3 +++ 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 6901437..20743dd 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -1724,13 +1724,32 @@ ATCE atcommand_jexprate(Session *s, dumb_ptr, return ATCE::OKAY; } +static +ATCE atcommand_droprate(Session *s, dumb_ptr, + ZString message) +{ + int rate; + + if (!extract(message, &rate) || !rate) + { + clif_displaymessage(s, + "Please, enter a rate adjustement (usage: @droprate )."_s); + return ATCE::USAGE; + } + battle_config.drop_rate = rate; + AString output = STRPRINTF("Drops rate now at %d percent"_fmt, rate); + clif_displaymessage(s, output); + return ATCE::OKAY; +} + static ATCE atcommand_rates(Session *s, dumb_ptr, ZString message) { AString output = STRPRINTF( - "Experience rates: Base %d%% / Job %d%%. Drop rate: 100%%"_fmt, - battle_config.base_exp_rate, battle_config.job_exp_rate); + "Experience rates: Base %d%% / Job %d%%. Drop rate: %d%%"_fmt, + battle_config.base_exp_rate, battle_config.job_exp_rate, + battle_config.drop_rate); clif_displaymessage(s, output); return ATCE::OKAY; } @@ -5644,9 +5663,12 @@ Map atcommand_info = {"jexprate"_s, {""_s, 60, atcommand_jexprate, "Set job exp rate"_s}}, + {"droprate"_s, {""_s, + 60, atcommand_droprate, + "Set drop rate"_s}}, {"rates"_s, {""_s, 0, atcommand_rates, - "Show base and job exp rates"_s}}, + "Show base and job exp and drop rates"_s}}, {"pvpon"_s, {""_s, 60, atcommand_pvpon, "Disable PvP on your map"_s}}, diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 4fd9d6d..f2f6815 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -2736,6 +2736,9 @@ int mob_damage(dumb_ptr src, dumb_ptr md, int damage, if (sd && md && battle_config.pk_mode == 1 && (get_mob_db(md->mob_class).lv - sd->status.base_level >= 20)) drop_rate.num *= 1.25; // pk_mode increase drops if 20 level difference [Valaris] + + // server-wide drop rate scaling + drop_rate.num = (drop_rate.num * battle_config.drop_rate) / 100; if (!random_::chance(drop_rate)) continue; -- cgit v1.2.3-70-g09d2