Parcourir la source

- 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
skotlex il y a 19 ans
Parent
commit
1e53de04f6
5 fichiers modifiés avec 31 ajouts et 3 suppressions
  1. 2 0
      Changelog-Trunk.txt
  2. 6 0
      conf-tmpl/battle/exp.conf
  3. 2 0
      src/map/battle.c
  4. 1 0
      src/map/battle.h
  5. 20 3
      src/map/pc.c

+ 2 - 0
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]

+ 6 - 0
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)

+ 2 - 0
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)

+ 1 - 0
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]

+ 20 - 3
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]