Sfoglia il codice sorgente

- Cleaned up the apparent mess that is pc_skill. Hopefully it SHOULD fix as described on the docs now, this should also fix adopting not correctly giving the family-related skills. The flag value of skill should be: 0 to set the skill (if skill level is 0, this removes a learned skill), 1 grants the skill as an item bonus which is temporary, and 2 will add a skill bonus like 1, except the skill level adds up to whatever level already known of that skill.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8179 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 anni fa
parent
commit
367750c38c
2 ha cambiato i file con 36 aggiunte e 12 eliminazioni
  1. 7 0
      Changelog-Trunk.txt
  2. 29 12
      src/map/pc.c

+ 7 - 0
Changelog-Trunk.txt

@@ -4,6 +4,13 @@ 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/08/07
+	* Cleaned up the apparent mess that is pc_skill. Hopefully it SHOULD work as
+	  described on the docs now, this should also fix adopting not correctly
+	  giving the family-related skills. The flag value of skill should be: 0 to
+	  set the skill (if skill level is 0, this removes a learned skill), 1 grants
+	  the skill as an item bonus which is temporary, and 2 will add a skill bonus
+	  like 1, except the skill level adds up to whatever level already known of
+	  that skill. [Skotlex]
 	* Fixed EQP_WEAPON related code messing up with both weapon AND shield.
 	  [Skotlex]
 	* Cleaned up the Asura code so that when the skill fails your

+ 29 - 12
src/map/pc.c

@@ -2348,7 +2348,11 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4
 }
 
 /*==========================================
- * スクリプトによるスキル所得
+ *	Grants a player a given skill. Flag values are:
+ *	0 - Grant skill unconditionally and forever (only this one invokes status_calc_pc,
+ *	    as the other two are assumed to be invoked from within it)
+ *	1 - Grant an item skill (temporary)
+ *	2 - Like 1, except the level granted can stack with previously learned level.
  *------------------------------------------
  */
 int pc_skill(struct map_session_data *sd,int id,int level,int flag)
@@ -2360,30 +2364,43 @@ int pc_skill(struct map_session_data *sd,int id,int level,int flag)
 			ShowError("pc_skill: Skill level %d too high. Max lv supported is MAX_SKILL_LEVEL (%d)\n", level, MAX_SKILL_LEVEL);
 		return 0;
 	}
-	if(!flag && (sd->status.skill[id].id == id || level == 0)){	// クエスト所得ならここで?件を確認して送信する
+	switch (flag) {
+	case 0: //Set skill data overwriting whatever was there before.
+		sd->status.skill[id].id=id;
 		sd->status.skill[id].lv=level;
+		sd->status.skill[id].flag=0;
+		if (!level) //Remove skill.
+			sd->status.skill[id].id = 0;
 		if (!skill_get_inf(id)) //Only recalculate for passive skills.
 			status_calc_pc(sd,0);
 		clif_skillinfoblock(sd);
-	}
-	else if(flag==2 && (sd->status.skill[id].id == id || level == 0)){	// クエスト所得ならここで?件を確認して送信する
+	break;
+	case 2: //Add skill bonus on top of what you had.
+		if (sd->status.skill[id].id==id) {
+			if (!sd->status.skill[id].flag)
+				sd->status.skill[id].flag=sd->status.skill[id].lv+2; //Store previous level.
+		} else {
+			sd->status.skill[id].id=id;
+			sd->status.skill[id].flag=1; //Set that this is a bonus skill.
+		}
 		sd->status.skill[id].lv+=level;
-		if (!skill_get_inf(id)) //Only recalculate for passive skills.
-			status_calc_pc(sd,0);
-		clif_skillinfoblock(sd);
-	}
-	else if(sd->status.skill[id].lv < level){	// ?えられるがlvが小さいなら
+	break;
+	case 1: //Item bonus skill.
+		if(sd->status.skill[id].lv >= level)
+			return 0;
 		if(sd->status.skill[id].id==id) {
 			if (!sd->status.skill[id].flag) //Non-granted skill, store it's level.
 				sd->status.skill[id].flag=sd->status.skill[id].lv+2;
 		} else {
 			sd->status.skill[id].id=id;
-			sd->status.skill[id].flag=1;	// cardスキルとする
+			sd->status.skill[id].flag=1;
 		}
 		sd->status.skill[id].lv=level;
+	break;
+	default: //Unknown flag?
+		return 0;
 	}
-
-	return 0;
+	return 1;
 }
 /*==========================================
  * カ?ド?入