summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-08 02:18:01 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-08 02:18:01 +0000
commit72fb7ef9f269c5ae8545cb813d7409c3b06526c3 (patch)
tree073440f219389e6b58c902f7919961ee538d779e
parentbc8350f550226c4d7d848ea9737f46c4a5d61575 (diff)
downloadhercules-72fb7ef9f269c5ae8545cb813d7409c3b06526c3.tar.gz
hercules-72fb7ef9f269c5ae8545cb813d7409c3b06526c3.tar.bz2
hercules-72fb7ef9f269c5ae8545cb813d7409c3b06526c3.tar.xz
hercules-72fb7ef9f269c5ae8545cb813d7409c3b06526c3.zip
- 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://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8179 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt7
-rw-r--r--src/map/pc.c41
2 files changed, 36 insertions, 12 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 9150d891c..65bba6939 100644
--- a/Changelog-Trunk.txt
+++ b/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
diff --git a/src/map/pc.c b/src/map/pc.c
index 8614d5956..eaa157075 100644
--- a/src/map/pc.c
+++ b/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;
}
/*==========================================
* カ?ド?入