Skip to content

Commit

Permalink
Add server-wide drop rates modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
specing committed Apr 10, 2024
1 parent 0fb2ce0 commit dc9c104
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/map/atcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,13 +1724,32 @@ ATCE atcommand_jexprate(Session *s, dumb_ptr<map_session_data>,
return ATCE::OKAY;
}

static
ATCE atcommand_droprate(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
int rate;

if (!extract(message, &rate) || !rate)
{
clif_displaymessage(s,
"Please, enter a rate adjustement (usage: @droprate <percent>)."_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<map_session_data>,
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;
}
Expand Down Expand Up @@ -5644,9 +5663,12 @@ Map<XString, AtCommandInfo> atcommand_info =
{"jexprate"_s, {"<percent>"_s,
60, atcommand_jexprate,
"Set job exp rate"_s}},
{"droprate"_s, {"<percent>"_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}},
Expand Down
3 changes: 3 additions & 0 deletions src/map/mob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,9 @@ int mob_damage(dumb_ptr<block_list> src, dumb_ptr<mob_data> 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;

Expand Down
1 change: 1 addition & 0 deletions tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ def build_config():
battle_conf.opt('item_third_get_time', milliseconds, '1_s')
battle_conf.opt('base_exp_rate', percent, '100')
battle_conf.opt('job_exp_rate', percent, '100')
battle_conf.opt('drop_rate', percent, '100')
battle_conf.opt('death_penalty_type', i32, '0', min='0', max='2')
battle_conf.opt('death_penalty_base', per10kd, '0')
battle_conf.opt('death_penalty_job', per10kd, '0')
Expand Down

0 comments on commit dc9c104

Please sign in to comment.