فهرست منبع

- Added function pc_check_skilltree for checking if you unlocked new tree-skills when raising non-passive skills.
- Some cleaning of pc_calc_skilltree
- Fixed flee/hit calculation in status_calc_bl to account for bonuses from the base status.
- Some cleaning of status_calc_pet to use the cap_value define.


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

skotlex 19 سال پیش
والد
کامیت
2268d4b763
3فایلهای تغییر یافته به همراه72 افزوده شده و 37 حذف شده
  1. 4 0
      Changelog-Trunk.txt
  2. 61 11
      src/map/pc.c
  3. 7 26
      src/map/status.c

+ 4 - 0
Changelog-Trunk.txt

@@ -4,6 +4,10 @@ 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.
 
 2006/05/30
+	* Added function pc_check_skilltree for checking if you unlocked new
+	  tree-skills when raising non-passive skills. [Skotlex]
+	* Fixed flee/hit calculation in status_calc_bl to account for bonuses from
+	  the base status. [Skotlex]
 	* [Fixed]:
 	  - Compatibility problems in login.c [Lance]
 	* Fixed pets ignoring can-act delays for skill usage. [Skotlex]

+ 61 - 11
src/map/pc.c

@@ -923,6 +923,8 @@ int pc_calc_skilltree(struct map_session_data *sd)
 		flag=0;
 		for(i=0;i < MAX_SKILL_TREE && (id=skill_tree[c][i].id)>0;i++){
 			int j,f=1;
+			if(sd->status.skill[id].id)
+				continue; //Skill already known.
 			if(!battle_config.skillfree) {
 				for(j=0;j<5;j++) {
 					if( skill_tree[c][i].need[j].id &&
@@ -937,20 +939,18 @@ int pc_calc_skilltree(struct map_session_data *sd)
 				else if (pc_checkskill(sd, NV_BASIC) < 9 && id != NV_BASIC && !(skill_get_inf2(id)&INF2_QUEST_SKILL))
 					f=0; // Do not unlock normal skills when Basic Skills is not maxed out (can happen because of skill reset)
 			}
-			if(sd->status.skill[id].id==0 ){
-				if(skill_get_inf2(id)&INF2_SPIRIT_SKILL)
-				{	//Spirit skills cannot be learned, they will only show up on your tree when you get buffed.
-					if (sd->sc.count && sd->sc.data[SC_SPIRIT].timer != -1)
-					{	//Enable Spirit Skills. [Skotlex]
-						sd->status.skill[id].id=id;
-						sd->status.skill[id].lv=1;
-						sd->status.skill[id].flag=1; //So it is not saved, and tagged as a "bonus" skill.
-						flag=1;
-					}
-				} else if (f){
+			if(skill_get_inf2(id)&INF2_SPIRIT_SKILL)
+			{	//Spirit skills cannot be learned, they will only show up on your tree when you get buffed.
+				if (sd->sc.count && sd->sc.data[SC_SPIRIT].timer != -1)
+				{	//Enable Spirit Skills. [Skotlex]
 					sd->status.skill[id].id=id;
+					sd->status.skill[id].lv=1;
+					sd->status.skill[id].flag=1; //So it is not saved, and tagged as a "bonus" skill.
 					flag=1;
 				}
+			} else if (f){
+				sd->status.skill[id].id=id;
+				flag=1;
 			}
 		}
 	} while(flag);
@@ -971,6 +971,54 @@ int pc_calc_skilltree(struct map_session_data *sd)
 	return 0;
 }
 
+//Checks if you can learn a new skill after having leveled up a skill.
+static void pc_check_skilltree(struct map_session_data *sd, int skill) {
+	int i,id=0,flag;
+	int c=0;
+
+	if(battle_config.skillfree)
+		return; //Function serves no purpose if this is set
+	
+	i = pc_calc_skilltree_normalize_job(sd);
+	c = pc_mapid2jobid(i, sd->status.sex);
+	if (c == -1) { //Unable to normalize job??
+		if (battle_config.error_log)
+			ShowError("pc_check_skilltree: Unable to normalize job %d for character %s (%d:%d)\n", i, sd->status.name, sd->status.account_id, sd->status.char_id);
+		return;
+	}
+	
+	do {
+		flag=0;
+		for(i=0;i < MAX_SKILL_TREE && (id=skill_tree[c][i].id)>0;i++){
+			int j,f=1;
+
+			if(sd->status.skill[id].id) //Already learned
+				continue;
+			
+			for(j=0;j<5;j++) {
+				if( skill_tree[c][i].need[j].id &&
+					pc_checkskill(sd,skill_tree[c][i].need[j].id) <
+					skill_tree[c][i].need[j].lv) {
+					f=0;
+					break;
+				}
+			}
+			if (!f)
+				continue;
+			if (sd->status.job_level < skill_tree[c][i].joblv)
+				continue;
+			else if (pc_checkskill(sd, NV_BASIC) < 9 && id != NV_BASIC && !(skill_get_inf2(id)&INF2_QUEST_SKILL))
+				continue; // Do not unlock normal skills when Basic Skills is not maxed out (can happen because of skill reset)
+			
+			if(skill_get_inf2(id)&INF2_SPIRIT_SKILL)
+				//Spirit skills cannot be learned
+				continue;
+			sd->status.skill[id].id=id;
+			flag=1;
+		}
+	} while(flag);
+}
+
 // Make sure all the skills are in the correct condition
 // before persisting to the backend.. [MouseJstr]
 int pc_clean_skilltree(struct map_session_data *sd) {
@@ -4158,6 +4206,8 @@ int pc_skillup(struct map_session_data *sd,int skill_num)
 		sd->status.skill_point--;
 		if (!skill_get_inf(skill_num)) //Only recalculate for passive skills.
 			status_calc_pc(sd,0);
+		else
+			pc_check_skilltree(sd, skill_num);
 		clif_skillup(sd,skill_num);
 		clif_updatestatus(sd,SP_SKILLPOINT);
 		clif_skillinfoblock(sd);

+ 7 - 26
src/map/status.c

@@ -1211,24 +1211,11 @@ int status_calc_pet(struct pet_data *pd, int first)
 				status->rhw.atk2 = battle_config.pet_max_atk2;
 
 			status->str = cap_value(status->str,1,battle_config.pet_max_stats);
-			if(status->str > battle_config.pet_max_stats)
-				status->str = battle_config.pet_max_stats;
-			else if (status->str < 1) status->str = 1;
-			if(status->agi > battle_config.pet_max_stats)
-				status->agi = battle_config.pet_max_stats;
-			else if (status->agi < 1) status->agi = 1;
-			if(status->vit > battle_config.pet_max_stats)
-				status->vit = battle_config.pet_max_stats;
-			else if (status->vit < 1) status->vit = 1;
-			if(status->int_ > battle_config.pet_max_stats)
-				status->int_ = battle_config.pet_max_stats;
-			else if (status->int_ < 1) status->int_ = 1;
-			if(status->dex > battle_config.pet_max_stats)
-				status->dex = battle_config.pet_max_stats;
-			else if (status->dex < 1) status->dex = 1;
-			if(status->luk > battle_config.pet_max_stats)
-				status->luk = battle_config.pet_max_stats;
-			else if (status->luk < 1) status->luk = 1;
+			status->agi = cap_value(status->agi,1,battle_config.pet_max_stats);
+			status->vit = cap_value(status->vit,1,battle_config.pet_max_stats);
+			status->int_= cap_value(status->int_,1,battle_config.pet_max_stats);
+			status->dex = cap_value(status->dex,1,battle_config.pet_max_stats);
+			status->luk = cap_value(status->luk,1,battle_config.pet_max_stats);
 
 			status->batk = status_base_atk(&pd->bl, &pd->status);
 			status_calc_misc(&pd->status, lv);
@@ -2511,18 +2498,12 @@ void status_calc_bl(struct block_list *bl, unsigned long flag)
 	}
 
 	if(flag&SCB_HIT) {
-		status->hit = status_get_lv(bl) + status->dex;
-		temp = b_status->dex - status->dex;
-		if (temp)
-			status->hit += temp;
+		status->hit = b_status->hit - b_status->dex + status->dex;
 		status->hit = status_calc_hit(bl, sc, status->hit);
 	}
 
 	if(flag&SCB_FLEE) {
-		status->flee = status_get_lv(bl) + status->agi;
-		temp = b_status->agi - status->agi;
-		if (temp)
-			status->flee += temp;
+		status->flee = b_status->flee - b_status->agi + status->agi;
 		status->flee = status_calc_flee(bl, sc, status->flee);
 	}