From 1e53de04f67dfcf310c2352dd00dcf5a52351e9c Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 9 Feb 2006 17:26:55 +0000 Subject: [PATCH] - Added setting max_exp_gain_rate which caps how much exp you can get from a single kill. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5239 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ conf-tmpl/battle/exp.conf | 6 ++++++ src/map/battle.c | 2 ++ src/map/battle.h | 1 + src/map/pc.c | 23 ++++++++++++++++++++--- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index cf377d528d..5bbfadf0df 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -6,6 +6,8 @@ GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALAR 2006/02/09 + * Added setting max_exp_gain_rate which caps how much exp you can get from + a single kill. See battle/exp.txt for details. [Skotlex] * pc_readdb will now cap experience required per level to UINT_MAX, it will warn if the exp table has exp values above said limit. [Skotlex] * Changed the default of skill_delay_attack_enable to no. [Skotlex] diff --git a/conf-tmpl/battle/exp.conf b/conf-tmpl/battle/exp.conf index 494081d081..b9d5708aa0 100644 --- a/conf-tmpl/battle/exp.conf +++ b/conf-tmpl/battle/exp.conf @@ -38,6 +38,12 @@ job_exp_rate: 100 // Turn this on to allow a player to level up more than once from a kill. (Note 1) multi_level_up: no +// Setting this can cap the max experience one can get per kill specified as a +// % of the current exp bar. (Every 10 = 1.0%) +// For example, set it to 500 and no matter how much exp the mob gives, +// it can never give you above half of your current exp bar. +max_exp_gain_rate: 0 + //Method of calculating earned experience when defeating a monster: //0 - jAthena's (uses damage given / total damage as damage ratio) //1 - eAthena's (uses damage given / max_hp as damage ratio) diff --git a/src/map/battle.c b/src/map/battle.c index 354dc0d88a..09b8d7439a 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3752,6 +3752,7 @@ static const struct battle_data_short { { "manner_system", &battle_config.manner_system }, // [Komurka] { "pet_equip_required", &battle_config.pet_equip_required }, // [Valaris] { "multi_level_up", &battle_config.multi_level_up }, // [Valaris] + { "max_exp_gain_rate", &battle_config.max_exp_gain_rate }, // [Skotlex] { "backstab_bow_penalty", &battle_config.backstab_bow_penalty }, { "night_at_start", &battle_config.night_at_start }, // added by [Yor] { "show_mob_hp", &battle_config.show_mob_hp }, // [Valaris] @@ -4139,6 +4140,7 @@ void battle_set_defaults() { battle_config.manner_system = 1; // [Valaris] battle_config.pet_equip_required = 0; // [Valaris] battle_config.multi_level_up = 0; // [Valaris] + battle_config.max_exp_gain_rate = 0; // [Skotlex] battle_config.backstab_bow_penalty = 0; // Akaru battle_config.night_at_start = 0; // added by [Yor] battle_config.day_duration = 2*60*60*1000; // added by [Yor] (2 hours) diff --git a/src/map/battle.h b/src/map/battle.h index 353ba7bc1c..5511f6bee8 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -301,6 +301,7 @@ extern struct Battle_Config { unsigned short equip_skill_break_rate; //Offensive skills break rate unsigned short pet_equip_required; unsigned short multi_level_up; + unsigned short max_exp_gain_rate; //Max amount of exp bar % you can get in one go. unsigned short pk_mode; unsigned short manner_system; unsigned short show_mob_hp; // end additions [Valaris] diff --git a/src/map/pc.c b/src/map/pc.c index 66a14f9db0..2d55bb46c0 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4711,13 +4711,30 @@ int pc_gainexp(struct map_session_data *sd,unsigned int base_exp,unsigned int jo base_exp-=guild_payexp(sd,base_exp); } - if(sd->state.showexp){ - nextb = pc_nextbaseexp(sd); - nextj = pc_nextjobexp(sd); + nextb = pc_nextbaseexp(sd); + nextj = pc_nextjobexp(sd); + + + if(sd->state.showexp || battle_config.max_exp_gain_rate){ if (nextb > 0) nextbp = (float) base_exp / (float) nextb; if (nextj > 0) nextjp = (float) job_exp / (float) nextj; + + if(battle_config.max_exp_gain_rate) { + if (nextbp > battle_config.max_exp_gain_rate/1000.) { + //Note that this value should never be greater than the original + //base_exp, therefore no overflow checks are needed. [Skotlex] + base_exp = (unsigned int)(battle_config.max_exp_gain_rate/1000.*nextb); + if (sd->state.showexp) + nextbp = (float) base_exp / (float) nextb; + } + if (nextjp > battle_config.max_exp_gain_rate/1000.) { + job_exp = (unsigned int)(battle_config.max_exp_gain_rate/1000.*nextj); + if (sd->state.showexp) + nextjp = (float) job_exp / (float) nextj; + } + } } //Overflow checks... think we'll ever really need'em? [Skotlex]