浏览代码

Bug fixes
* Fixed wrong bonus for Max HP (bugreport:8679)
* HP/SP respawn (restart_hp_rate and restart_sp_rate) should be work now (bugreport:8642)
* Fixed MVP drop that failed to make random order (bugreport:8665)

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>

Cydh Ramdh 11 年之前
父节点
当前提交
0766c73229
共有 4 个文件被更改,包括 49 次插入47 次删除
  1. 1 1
      src/map/atcommand.c
  2. 19 13
      src/map/mob.c
  3. 9 6
      src/map/skill.c
  4. 20 27
      src/map/status.c

+ 1 - 1
src/map/atcommand.c

@@ -7468,7 +7468,7 @@ ACMD_FUNC(iteminfo)
 		item_data = item_array[i];
 		sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
 			item_data->name,item_data->jname,item_data->slot,item_data->nameid,
-			(item_data->type != IT_AMMO) ? itemdb_typename(item_data->type) : itemdb_typename_ammo(item_data->look),
+			(item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
 			(item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
 		);
 		clif_displaymessage(fd, atcmd_output);

+ 19 - 13
src/map/mob.c

@@ -2395,7 +2395,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 #endif
 			// attempt to drop the item
 			if (rnd() % 10000 >= drop_rate)
-					continue;
+				continue;
 
 			if( mvp_sd && it->type == IT_PETEGG ) {
 				pet_create_egg(mvp_sd, md->db->dropitem[i].nameid);
@@ -2510,30 +2510,36 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 			int mdrop_id[MAX_MVP_DROP];
 			int mdrop_p[MAX_MVP_DROP];
 
-			memset(&mdrop_id,0,MAX_MVP_DROP*sizeof(int));
+			memset(mdrop_id,0,MAX_MVP_DROP*sizeof(int));
+			memset(mdrop_p,0,MAX_MVP_DROP*sizeof(int));
 
+			//Make random order
 			for(i = 0; i < MAX_MVP_DROP; i++) {
 				while( 1 ) {
-					int va = rnd()%MAX_MVP_DROP;
-					if( !mdrop_id[va] || !md->db->mvpitem[i].nameid ) {
-						mdrop_id[va] = md->db->mvpitem[i].nameid;
-						mdrop_p[va]  = md->db->mvpitem[i].p;
+					uint8 va = rnd()%MAX_MVP_DROP;
+					if (mdrop_id[va] == 0) {
+						if (md->db->mvpitem[i].nameid > 0) {
+							mdrop_id[va] = md->db->mvpitem[i].nameid;
+							mdrop_p[va] = md->db->mvpitem[i].p;
+						}
+						else
+							mdrop_id[va] = -1;
 						break;
 					}
 				}
 			}
 
 			for(i = 0; i < MAX_MVP_DROP; i++) {
-				if(mdrop_id[i] <= 0)
-					continue;
-				if(!itemdb_exists(mdrop_id[i]))
+				if(mdrop_id[i] <= 0 || !itemdb_exists(mdrop_id[i]))
 					continue;
 
 				temp = mdrop_p[i];
-				if(temp <= 0 && !battle_config.drop_rate0item)
-					temp = 1;
-				if(temp <= rnd()%10000+1) //if ==0, then it doesn't drop
-					continue;
+				if (temp != 10000) {
+					if(temp <= 0 && !battle_config.drop_rate0item)
+						temp = 1;
+					if(rnd()%10000 >= temp) //if ==0, then it doesn't drop
+						continue;
+				}
 
 				memset(&item,0,sizeof(item));
 				item.nameid=mdrop_id[i];

+ 9 - 6
src/map/skill.c

@@ -336,8 +336,16 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
 	return range;
 }
 
+/** Calculates heal value of skill's effect
+* @param src
+* @param target
+* @param skill_id
+* @param skill_lv
+* @param heal
+* @return modified heal value
+*/
 int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, bool heal) {
-	int skill, hp;
+	int skill, hp = 0;
 	struct map_session_data *sd = BL_CAST(BL_PC, src);
 	struct map_session_data *tsd = BL_CAST(BL_PC, target);
 	struct status_change *sc, *tsc;
@@ -11697,11 +11705,6 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
 			val2 += pc_checkskill(sd,DC_DANCINGLESSON);
 		}
 		break;
-	case BA_APPLEIDUN:
-		val1 = 5+2*skill_lv+status->vit/10; // MaxHP percent increase
-		if(sd)
-			val1 += pc_checkskill(sd,BA_MUSICALLESSON);
-		break;
 	case DC_SERVICEFORYOU:
 			//val1: MaxSP percent increase
 			val1 = 15+skill_lv+(status->int_/10); //Bonus rate by Dancer's INT 

+ 20 - 27
src/map/status.c

@@ -104,7 +104,7 @@ static unsigned short status_calc_ematk(struct block_list *,struct status_change
 #endif
 static int status_get_hpbonus(struct block_list *bl, enum e_status_bonus type);
 static int status_get_spbonus(struct block_list *bl, enum e_status_bonus type);
-static unsigned int status_calc_maxhpsp_pc(struct map_session_data *sd, uint8 flag);
+static unsigned int status_calc_maxhpsp_pc(struct map_session_data* sd, unsigned int stat, bool isHP);
 
 /**
  * Returns the status change associated with a skill.
@@ -2660,13 +2660,13 @@ static int status_get_spbonus(struct block_list *bl, enum e_status_bonus type) {
 
 /**
 * Get final MaxHP or MaxSP for player. References: http://irowiki.org/wiki/Max_HP and http://irowiki.org/wiki/Max_SP
-* The calculation needs base_level, battle_status (vit or int), additive modifier, and multiplicative modifier
-* @param sd: Player
-* @param flag: 0=Calculates MaxHP, 1=Calculates MaxSP
-* @return max_hp: value
+* The calculation needs base_level, base_status/battle_status (vit or int), additive modifier, and multiplicative modifier
+* @param sd Player
+* @param stat Vit/Int of player as param modifier
+* @param isHP true - calculates Max HP, false - calculated Max SP
+* @return max The max value of HP or SP
 **/
-static unsigned int status_calc_maxhpsp_pc(struct map_session_data* sd, uint8 flag)
-{
+static unsigned int status_calc_maxhpsp_pc(struct map_session_data* sd, unsigned int stat, bool isHP) {
 	double max = 0;
 	uint16 idx, level, job_id;
 
@@ -2676,13 +2676,13 @@ static unsigned int status_calc_maxhpsp_pc(struct map_session_data* sd, uint8 fl
 	idx = pc_class2idx(job_id);
 	level = max(sd->status.base_level,1);
 
-	if (flag == 0) { //Calculates MaxHP
-		max = job_info[idx].base_hp[level-1] * (1 + (max(sd->battle_status.vit,1) * 0.01)) * ((sd->class_&JOBL_UPPER)?1.25:1);
+	if (isHP) { //Calculates MaxHP
+		max = job_info[idx].base_hp[level-1] * (1 + (max(stat,1) * 0.01)) * ((sd->class_&JOBL_UPPER)?1.25:1);
 		max += status_get_hpbonus(&sd->bl,STATUS_BONUS_FIX);
 		max = max * (1 + status_get_hpbonus(&sd->bl,STATUS_BONUS_RATE) * 0.01);
 	}
-	else if (flag == 1) { //Calculates MaxSP
-		max = job_info[idx].base_sp[level-1] * (1 + (max(sd->battle_status.int_,1) * 0.01));
+	else { //Calculates MaxSP
+		max = job_info[idx].base_sp[level-1] * (1 + (max(stat,1) * 0.01));
 		max += status_get_spbonus(&sd->bl,STATUS_BONUS_FIX);
 		max = max * (1 + status_get_spbonus(&sd->bl,STATUS_BONUS_RATE) * 0.01);
 		max = (max * ((sd->class_&JOBL_UPPER)?1.25:1)) + 0.5; //Don't have round()
@@ -3176,7 +3176,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
 #endif
 
 // ----- HP MAX CALCULATION -----
-	sd->status.max_hp = status_calc_maxhpsp_pc(sd,0);
+	status->max_hp = sd->status.max_hp = status_calc_maxhpsp_pc(sd,status->vit,true);
 	
 	if(battle_config.hp_rate != 100)
 		status->max_hp = (int64)status->max_hp * battle_config.hp_rate/100;
@@ -3187,7 +3187,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
 		status->max_hp = 1;
 
 // ----- SP MAX CALCULATION -----
-	sd->status.max_sp = status_calc_maxhpsp_pc(sd,1);
+	status->max_sp = sd->status.max_sp = status_calc_maxhpsp_pc(sd,status->int_,false);
 
 	if(battle_config.sp_rate != 100)
 		status->max_sp = (int64)status->max_sp * battle_config.sp_rate/100;
@@ -3217,7 +3217,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
 		if( !status->sp ) // The minimum for the respawn setting is SP:1
 			status->sp = 1;
 	}
-
+	
 // ----- MISC CALCULATION -----
 	status_calc_misc(&sd->bl, status, sd->status.base_level);
 
@@ -3925,8 +3925,6 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str
 		} else
 			regen->flag&=~sce->val4; // Remove regen as specified by val4
 	}
-	if (sc->data[SC_APPLEIDUN])
-		regen->rate.hp += sc->data[SC_APPLEIDUN]->val3;
 	if (sc->data[SC_EPICLESIS]) {
 		regen->rate.hp += sc->data[SC_EPICLESIS]->val3;
 		regen->rate.sp += sc->data[SC_EPICLESIS]->val4;
@@ -4283,7 +4281,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
 
 	if(flag&SCB_MAXHP) {
 		if( bl->type&BL_PC ) {
-			status->max_hp = status_calc_maxhpsp_pc(sd,0);
+			status->max_hp = status_calc_maxhpsp_pc(sd,status->vit,true);
 			
 			if( status->max_hp > (unsigned int)battle_config.max_hp )
 				status->max_hp = (unsigned int)battle_config.max_hp;
@@ -4298,7 +4296,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
 
 	if(flag&SCB_MAXSP) {
 		if( bl->type&BL_PC ) {
-			status->max_sp = status_calc_maxhpsp_pc(sd,1);
+			status->max_sp = status_calc_maxhpsp_pc(sd,status->int_,false);
 			
 			if( status->max_sp > (unsigned int)battle_config.max_sp )
 				status->max_sp = (unsigned int)battle_config.max_sp;
@@ -9534,15 +9532,10 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
 				val1 = 1002; // Default poring
 			break;
 		case SC_APPLEIDUN:
-			{
-				uint8 i;
-				val2 = 5 + (2 * (val1-1)); //HP Rate
-				val3 = 30 + (5 * val1); //HP Recovery rate
-				if (sd && (i = pc_checkskill(sd,BA_MUSICALLESSON)) > 0) {
-					val2 += i;
-					val3 += (5 * i);
-				}
-			} break;
+			val2 = (5 + 2 * val1) + (status_get_vit(src) / 10); //HP Rate: (5 + 2 * skill_lv) + (vit/10) + (BA_MUSICALLESSON level)
+			if (sd)
+				val2 += pc_checkskill(sd,BA_MUSICALLESSON);
+			break;
 		case SC_EPICLESIS:
 			val2 = 5 * val1; //HP rate bonus
 			switch (val1) { //! FIXME, looks so weird!