Browse Source

- Added pc_calcexp to calculate individual exp bonuses acquired from exp's source (race bonus cards, SG Exp skills, pk-mode higher level exp)
- pc_gain_exp now also receives the source of the exp, when said source exists, bonuses are applicated as needed.
- Added status_kill when capturing a mob, should take care of the mob not respawning after caputed.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@7037 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 19 years ago
parent
commit
d7a3b4d7e4
11 changed files with 76 additions and 36 deletions
  1. 6 0
      Changelog-Trunk.txt
  2. 4 20
      src/map/mob.c
  3. 2 2
      src/map/npc.c
  4. 3 3
      src/map/party.c
  5. 1 1
      src/map/party.h
  6. 54 4
      src/map/pc.c
  7. 1 1
      src/map/pc.h
  8. 1 0
      src/map/pet.c
  9. 1 1
      src/map/script.c
  10. 3 3
      src/map/skill.c
  11. 0 1
      src/map/status.c

+ 6 - 0
Changelog-Trunk.txt

@@ -4,6 +4,12 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
 2006/06/07
 2006/06/07
+	* Added pc_calcexp to calculate individual exp bonuses acquired from exp's
+	  source (race bonus cards, SG Exp skills, pk-mode higher level exp) [Skotlex]
+	* pc_gain_exp now also receives the source of the exp, when said source
+	  exists, bonuses are applicated as needed. [Skotlex]
+	* Added status_kill when capturing a mob, should take care of the mob not
+	  respawning after caputed. [Skotlex]
 	* Fixed item info not displaying the found item id [Skotlex]
 	* Fixed item info not displaying the found item id [Skotlex]
 	* Fixed item info not displaying the weight value properly. [Skotlex]
 	* Fixed item info not displaying the weight value properly. [Skotlex]
 	* Adjusted status resistances and durations taking as base Viccious's info
 	* Adjusted status resistances and durations taking as base Viccious's info

+ 4 - 20
src/map/mob.c

@@ -1785,22 +1785,6 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 		if (md->sc.data[SC_RICHMANKIM].timer != -1)
 		if (md->sc.data[SC_RICHMANKIM].timer != -1)
 			bonus += md->sc.data[SC_RICHMANKIM].val2;
 			bonus += md->sc.data[SC_RICHMANKIM].val2;
 
 
-		if (tmpsd[i]->expaddrace[status->race])
-			bonus += tmpsd[i]->expaddrace[status->race];	
-		bonus += tmpsd[i]->expaddrace[status->mode&MD_BOSS?RC_BOSS:RC_NONBOSS];
-	
-		if (battle_config.pk_mode &&
-			(int)(md->db->lv - tmpsd[i]->status.base_level) >= 20) //Needed due to unsigned checks
-			bonus += 15; // pk_mode additional exp if monster >20 levels [Valaris]	
-		
-		//SG additional exp from Blessings [Komurka] - probably can be optimalized ^^;;
-		if(md->class_ == tmpsd[i]->hate_mob[2] && (battle_config.allow_skill_without_day || is_day_of_star() || tmpsd[i]->sc.data[SC_MIRACLE].timer!=-1))
-			bonus += 20*pc_checkskill(tmpsd[i],SG_STAR_BLESS);
-		else if(md->class_ == tmpsd[i]->hate_mob[1] && (battle_config.allow_skill_without_day || is_day_of_moon()))
-			bonus += 10*pc_checkskill(tmpsd[i],SG_MOON_BLESS);
-		else if(md->class_ == tmpsd[i]->hate_mob[0] && (battle_config.allow_skill_without_day || is_day_of_sun()))
-			bonus += 10*pc_checkskill(tmpsd[i],SG_SUN_BLESS);
-
 		if(battle_config.mobs_level_up && md->level > md->db->lv) // [Valaris]
 		if(battle_config.mobs_level_up && md->level > md->db->lv) // [Valaris]
 			bonus += (md->level-md->db->lv)*battle_config.mobs_level_up_exp_rate;
 			bonus += (md->level-md->db->lv)*battle_config.mobs_level_up_exp_rate;
 
 
@@ -1885,14 +1869,14 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 		}
 		}
 		if(flag) {
 		if(flag) {
 			if(base_exp || job_exp)
 			if(base_exp || job_exp)
-				pc_gainexp(tmpsd[i],base_exp,job_exp);
+				pc_gainexp(tmpsd[i], &md->bl, base_exp,job_exp);
 			if(zeny) // zeny from mobs [Valaris]
 			if(zeny) // zeny from mobs [Valaris]
-				pc_getzeny(tmpsd[i],zeny);
+				pc_getzeny(tmpsd[i], zeny);
 		}
 		}
 	}
 	}
 	
 	
 	for(i=0;i<pnum;i++) //Party share.
 	for(i=0;i<pnum;i++) //Party share.
-		party_exp_share(pt[i].p,md->bl.m,pt[i].base_exp,pt[i].job_exp,pt[i].zeny);
+		party_exp_share(pt[i].p, &md->bl, pt[i].base_exp,pt[i].job_exp,pt[i].zeny);
 	} //End EXP giving.
 	} //End EXP giving.
 	
 	
 	if (!(type&1) &&
 	if (!(type&1) &&
@@ -2043,7 +2027,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 
 
 		clif_mvp_effect(mvp_sd);
 		clif_mvp_effect(mvp_sd);
 		clif_mvp_exp(mvp_sd,mexp);
 		clif_mvp_exp(mvp_sd,mexp);
-		pc_gainexp(mvp_sd,mexp,0);
+		pc_gainexp(mvp_sd, &md->bl, mexp,0);
 		log_mvp[1] = mexp;
 		log_mvp[1] = mexp;
 		if(!map[md->bl.m].flag.nomvploot)
 		if(!map[md->bl.m].flag.nomvploot)
 		for(j=0;j<3;j++){
 		for(j=0;j<3;j++){

+ 2 - 2
src/map/npc.c

@@ -1213,7 +1213,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list)
 			z = z * (double)skill * (double)battle_config.shop_exp/10000.;
 			z = z * (double)skill * (double)battle_config.shop_exp/10000.;
 			if (z < 1)
 			if (z < 1)
 				z = 1;
 				z = 1;
-			pc_gainexp(sd,0,(int)z);
+			pc_gainexp(sd,NULL,0,(int)z);
 		}
 		}
 	}
 	}
 
 
@@ -1288,7 +1288,7 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list)
 			z = z * (double)skill * (double)battle_config.shop_exp/10000.;
 			z = z * (double)skill * (double)battle_config.shop_exp/10000.;
 			if (z < 1)
 			if (z < 1)
 				z = 1;
 				z = 1;
-			pc_gainexp(sd,0,(int)z);
+			pc_gainexp(sd,NULL,0,(int)z);
 		}
 		}
 	}
 	}
 		
 		

+ 3 - 3
src/map/party.c

@@ -659,7 +659,7 @@ int party_send_xy_clear(struct party *p)
 }
 }
 
 
 // exp share and added zeny share [Valaris]
 // exp share and added zeny share [Valaris]
-int party_exp_share(struct party *p,int map,unsigned int base_exp,unsigned int job_exp,int zeny)
+int party_exp_share(struct party *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny)
 {
 {
 	struct map_session_data* sd[MAX_PARTY];
 	struct map_session_data* sd[MAX_PARTY];
 	int i;
 	int i;
@@ -668,7 +668,7 @@ int party_exp_share(struct party *p,int map,unsigned int base_exp,unsigned int j
 	nullpo_retr(0, p);
 	nullpo_retr(0, p);
 
 
 	for (i = c = 0; i < MAX_PARTY; i++)
 	for (i = c = 0; i < MAX_PARTY; i++)
-		if ((sd[c] = p->member[i].sd)!=NULL && sd[c]->bl.m == map && !pc_isdead(sd[c])) {
+		if ((sd[c] = p->member[i].sd)!=NULL && sd[c]->bl.m == src->m && !pc_isdead(sd[c])) {
 			if (battle_config.idle_no_share && (sd[c]->chatID || sd[c]->vender_id || (sd[c]->idletime < (last_tick - battle_config.idle_no_share))))
 			if (battle_config.idle_no_share && (sd[c]->chatID || sd[c]->vender_id || (sd[c]->idletime < (last_tick - battle_config.idle_no_share))))
 				continue;
 				continue;
 			c++;
 			c++;
@@ -694,7 +694,7 @@ int party_exp_share(struct party *p,int map,unsigned int base_exp,unsigned int j
 
 
 	for (i = 0; i < c; i++)
 	for (i = 0; i < c; i++)
 	{
 	{
-		pc_gainexp(sd[i], base_exp, job_exp);
+		pc_gainexp(sd[i], src, base_exp, job_exp);
 		if (battle_config.zeny_from_mobs) // zeny from mobs [Valaris]
 		if (battle_config.zeny_from_mobs) // zeny from mobs [Valaris]
 			pc_getzeny(sd[i],bonus*zeny/(c*100));
 			pc_getzeny(sd[i],bonus*zeny/(c*100));
 	}
 	}

+ 1 - 1
src/map/party.h

@@ -39,7 +39,7 @@ int party_recv_message(int party_id,int account_id,char *mes,int len);
 int party_check_conflict(struct map_session_data *sd);
 int party_check_conflict(struct map_session_data *sd);
 int party_skill_check(struct map_session_data *sd, int party_id, int skillid, int skilllv);
 int party_skill_check(struct map_session_data *sd, int party_id, int skillid, int skilllv);
 int party_send_xy_clear(struct party *p);
 int party_send_xy_clear(struct party *p);
-int party_exp_share(struct party *p,int map,unsigned int base_exp,unsigned int job_exp,int zeny);
+int party_exp_share(struct party *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny);
 int party_share_loot(struct party *p, TBL_PC *sd, struct item *item_data);
 int party_share_loot(struct party *p, TBL_PC *sd, struct item *item_data);
 int party_send_dot_remove(struct map_session_data *sd);
 int party_send_dot_remove(struct map_session_data *sd);
 int party_sub_count(struct block_list *bl, va_list ap);
 int party_sub_count(struct block_list *bl, va_list ap);

+ 54 - 4
src/map/pc.c

@@ -36,6 +36,7 @@
 #include "vending.h"
 #include "vending.h"
 #include "atcommand.h"
 #include "atcommand.h"
 #include "log.h"
 #include "log.h"
+#include "date.h"
 
 
 #ifndef TXT_ONLY // mail system [Valaris]
 #ifndef TXT_ONLY // mail system [Valaris]
 #include "mail.h"
 #include "mail.h"
@@ -3927,11 +3928,60 @@ int pc_checkjoblevelup(struct map_session_data *sd)
 	return 1;
 	return 1;
 }
 }
 
 
+/*==========================================
+ * Alters experienced based on self bonuses that do not get even shared to the party.
+ *------------------------------------------
+ */
+static void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsigned int *job_exp, struct block_list *src)
+{
+	int bonus = 0;
+	struct status_data *status = status_get_status_data(src);
+	unsigned int temp;
+
+	if (sd->expaddrace[status->race])
+		bonus += sd->expaddrace[status->race];	
+	bonus += sd->expaddrace[status->mode&MD_BOSS?RC_BOSS:RC_NONBOSS];
+	
+	//SG additional exp from Blessings [Komurka] - probably can be optimalized ^^;;
+	temp = status_get_class(src);
+	if(temp == sd->hate_mob[2] &&
+		(battle_config.allow_skill_without_day || is_day_of_star() || sd->sc.data[SC_MIRACLE].timer!=-1))
+		bonus += 20*pc_checkskill(sd,SG_STAR_BLESS);
+	else
+	if(temp == sd->hate_mob[1] &&
+		(battle_config.allow_skill_without_day || is_day_of_moon()))
+		bonus += 10*pc_checkskill(sd,SG_MOON_BLESS);
+	else
+	if(temp == sd->hate_mob[0] &&
+		(battle_config.allow_skill_without_day || is_day_of_sun()))
+		bonus += 10*pc_checkskill(sd,SG_SUN_BLESS);
+
+	if (battle_config.pk_mode && 
+		(int)(status_get_lv(src) - sd->status.base_level) >= 20)
+		bonus += 15; // pk_mode additional exp if monster >20 levels [Valaris]	
+
+	if (!bonus)
+	  	return;
+	
+	temp = *base_exp*bonus/100;
+	if (*base_exp > UINT_MAX - temp)
+		*base_exp = UINT_MAX;
+	else
+		*base_exp += temp;
+
+	temp = *job_exp*bonus/100;
+	if (*job_exp > UINT_MAX - temp)
+		*job_exp = UINT_MAX;
+	else
+		*job_exp += temp;
+
+	return;
+}
 /*==========================================
 /*==========================================
  * ??’lŽæ“¾
  * ??’lŽæ“¾
  *------------------------------------------
  *------------------------------------------
  */
  */
-int pc_gainexp(struct map_session_data *sd,unsigned int base_exp,unsigned int job_exp)
+int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int base_exp,unsigned int job_exp)
 {
 {
 	char output[256];
 	char output[256];
 	float nextbp=0, nextjp=0;
 	float nextbp=0, nextjp=0;
@@ -3944,13 +3994,13 @@ int pc_gainexp(struct map_session_data *sd,unsigned int base_exp,unsigned int jo
 	if(!battle_config.pvp_exp && map[sd->bl.m].flag.pvp)  // [MouseJstr]
 	if(!battle_config.pvp_exp && map[sd->bl.m].flag.pvp)  // [MouseJstr]
 		return 0; // no exp on pvp maps
 		return 0; // no exp on pvp maps
 
 
-	if(sd->status.guild_id>0){	// ƒMƒ‹ƒh‚É�ã”[
+	if(sd->status.guild_id>0)
 		base_exp-=guild_payexp(sd,base_exp);
 		base_exp-=guild_payexp(sd,base_exp);
-	}
+
+	if(src) pc_calcexp(sd, &base_exp, &job_exp, src);
 
 
 	nextb = pc_nextbaseexp(sd);
 	nextb = pc_nextbaseexp(sd);
 	nextj = pc_nextjobexp(sd);
 	nextj = pc_nextjobexp(sd);
-	
 		
 		
 	if(sd->state.showexp || battle_config.max_exp_gain_rate){
 	if(sd->state.showexp || battle_config.max_exp_gain_rate){
 		if (nextb > 0)
 		if (nextb > 0)

+ 1 - 1
src/map/pc.h

@@ -135,7 +135,7 @@ unsigned int pc_maxbaselv(struct map_session_data *sd);
 unsigned int pc_maxjoblv(struct map_session_data *sd);
 unsigned int pc_maxjoblv(struct map_session_data *sd);
 int pc_checkbaselevelup(struct map_session_data *sd);
 int pc_checkbaselevelup(struct map_session_data *sd);
 int pc_checkjoblevelup(struct map_session_data *sd);
 int pc_checkjoblevelup(struct map_session_data *sd);
-int pc_gainexp(struct map_session_data*,unsigned int,unsigned int);
+int pc_gainexp(struct map_session_data*,struct block_list*,unsigned int,unsigned int);
 unsigned int pc_nextbaseexp(struct map_session_data *);
 unsigned int pc_nextbaseexp(struct map_session_data *);
 unsigned int pc_nextjobexp(struct map_session_data *);
 unsigned int pc_nextjobexp(struct map_session_data *);
 int pc_need_status_point(struct map_session_data *,int);
 int pc_need_status_point(struct map_session_data *,int);

+ 1 - 0
src/map/pet.c

@@ -596,6 +596,7 @@ int pet_catch_process2(struct map_session_data *sd,int target_id)
 
 
 	if(rand()%10000 < pet_catch_rate) {
 	if(rand()%10000 < pet_catch_rate) {
 		unit_remove_map(&md->bl,0);
 		unit_remove_map(&md->bl,0);
+		status_kill(&md->bl);
 		clif_pet_rulet(sd,1);
 		clif_pet_rulet(sd,1);
 //		if(battle_config.etc_log)
 //		if(battle_config.etc_log)
 //			printf("rulet success %d\n",target_id);
 //			printf("rulet success %d\n",target_id);

+ 1 - 1
src/map/script.c

@@ -5625,7 +5625,7 @@ int buildin_getexp(struct script_state *st)
 	if(base<0 || job<0)
 	if(base<0 || job<0)
 		return 0;
 		return 0;
 	if(sd)
 	if(sd)
-		pc_gainexp(sd,base,job);
+		pc_gainexp(sd,NULL,base,job);
 
 
 	return 0;
 	return 0;
 }
 }

+ 3 - 3
src/map/skill.c

@@ -3178,7 +3178,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
 				heal_get_jobexp = heal_get_jobexp * battle_config.heal_exp / 100;
 				heal_get_jobexp = heal_get_jobexp * battle_config.heal_exp / 100;
 				if (heal_get_jobexp <= 0)
 				if (heal_get_jobexp <= 0)
 					heal_get_jobexp = 1;
 					heal_get_jobexp = 1;
-				pc_gainexp (sd, 0, heal_get_jobexp);
+				pc_gainexp (sd, bl, 0, heal_get_jobexp);
 			}
 			}
 		}
 		}
 		break;
 		break;
@@ -3250,7 +3250,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
 						if (jexp < 1) jexp = 1;
 						if (jexp < 1) jexp = 1;
 					}
 					}
 					if(exp > 0 || jexp > 0)
 					if(exp > 0 || jexp > 0)
-						pc_gainexp (sd, exp, jexp);
+						pc_gainexp (sd, bl, exp, jexp);
 				}
 				}
 			}
 			}
 		}
 		}
@@ -3368,7 +3368,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
 		break;
 		break;
 	case SA_LEVELUP:
 	case SA_LEVELUP:
 		clif_skill_nodamage(src,bl,skillid,skilllv,1);
 		clif_skill_nodamage(src,bl,skillid,skilllv,1);
-		if (sd && pc_nextbaseexp(sd)) pc_gainexp(sd, pc_nextbaseexp(sd) * 10 / 100, 0);
+		if (sd && pc_nextbaseexp(sd)) pc_gainexp(sd, NULL, pc_nextbaseexp(sd) * 10 / 100, 0);
 		break;
 		break;
 	case SA_INSTANTDEATH:
 	case SA_INSTANTDEATH:
 		clif_skill_nodamage(src,bl,skillid,skilllv,1);
 		clif_skill_nodamage(src,bl,skillid,skilllv,1);

+ 0 - 1
src/map/status.c

@@ -644,7 +644,6 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
 		map_delblock(target);
 		map_delblock(target);
 		unit_free(target);
 		unit_free(target);
 	}
 	}
-
 		
 		
 	return hp+sp;
 	return hp+sp;
 }
 }