diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-02-10 22:43:22 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-02-10 22:43:22 +0000 |
commit | 1142aaf9e81d4532aa3f49fbc4a69a8a53976999 (patch) | |
tree | f8d4028132874f7bb957a1aa98dbd76b1f5f8901 /src/map/pc.c | |
parent | 9f3e6d6b0350a2f8f7e1f47c85919801e25d3401 (diff) | |
download | hercules-1142aaf9e81d4532aa3f49fbc4a69a8a53976999.tar.gz hercules-1142aaf9e81d4532aa3f49fbc4a69a8a53976999.tar.bz2 hercules-1142aaf9e81d4532aa3f49fbc4a69a8a53976999.tar.xz hercules-1142aaf9e81d4532aa3f49fbc4a69a8a53976999.zip |
Added two missing opt2 values, for Angelus and Bleeding status.
Cleaned up pc_statusup and pc_statusup2.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12190 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 190 |
1 files changed, 61 insertions, 129 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 082a61aa3..a5699312d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4325,25 +4325,30 @@ unsigned int pc_thisjobexp(struct map_session_data *sd) return exp_table[pc_class2idx(sd->status.class_)][1][sd->status.job_level-2]; } +static int pc_getstat(struct map_session_data* sd, int type) +{ + nullpo_retr(-1, sd); + switch( type ) { + case SP_STR: return sd->status.str; + case SP_AGI: return sd->status.agi; + case SP_VIT: return sd->status.vit; + case SP_INT: return sd->status.int_; + case SP_DEX: return sd->status.dex; + case SP_LUK: return sd->status.luk; + default: + return -1; + } +} + /*========================================== * 必要ステ?タスポイント計算 *------------------------------------------*/ int pc_need_status_point(struct map_session_data *sd,int type) { - int val; - nullpo_retr(-1, sd); - - if(type<SP_STR || type>SP_LUK) + if( type < SP_STR || type > SP_LUK ) return -1; - val = - type==SP_STR ? sd->status.str : - type==SP_AGI ? sd->status.agi : - type==SP_VIT ? sd->status.vit : - type==SP_INT ? sd->status.int_: - type==SP_DEX ? sd->status.dex : sd->status.luk; - - return (val+9)/10+1; + return ( 1 + (pc_getstat(sd,type) + 9) / 10 ); } /*========================================== @@ -4355,57 +4360,31 @@ int pc_statusup(struct map_session_data *sd,int type) nullpo_retr(0, sd); - max = pc_maxparameter(sd); + // check conditions + need = pc_need_status_point(sd,type); + if( type < SP_STR || type > SP_LUK || need < 0 || need > sd->status.status_point ) + { + clif_statusupack(sd,type,0,0); + return 1; + } - need=pc_need_status_point(sd,type); - if(type<SP_STR || type>SP_LUK || need<0 || need>sd->status.status_point){ + // check limits + max = pc_maxparameter(sd); + if( pc_getstat(sd,type) >= max ) + { clif_statusupack(sd,type,0,0); return 1; } + switch(type){ - case SP_STR: - if(sd->status.str >= max) { - clif_statusupack(sd,type,0,0); - return 1; - } - val= ++sd->status.str; - break; - case SP_AGI: - if(sd->status.agi >= max) { - clif_statusupack(sd,type,0,0); - return 1; - } - val= ++sd->status.agi; - break; - case SP_VIT: - if(sd->status.vit >= max) { - clif_statusupack(sd,type,0,0); - return 1; - } - val= ++sd->status.vit; - break; - case SP_INT: - if(sd->status.int_ >= max) { - clif_statusupack(sd,type,0,0); - return 1; - } - val= ++sd->status.int_; - break; - case SP_DEX: - if(sd->status.dex >= max) { - clif_statusupack(sd,type,0,0); - return 1; - } - val= ++sd->status.dex; - break; - case SP_LUK: - if(sd->status.luk >= max) { - clif_statusupack(sd,type,0,0); - return 1; - } - val= ++sd->status.luk; - break; + case SP_STR: val= ++sd->status.str; break; + case SP_AGI: val= ++sd->status.agi; break; + case SP_VIT: val= ++sd->status.vit; break; + case SP_INT: val= ++sd->status.int_; break; + case SP_DEX: val= ++sd->status.dex; break; + case SP_LUK: val= ++sd->status.luk; break; } + sd->status.status_point-=need; if(need!=pc_need_status_point(sd,type)){ clif_updatestatus(sd,type-SP_STR+SP_USTR); @@ -4428,66 +4407,18 @@ int pc_statusup2(struct map_session_data *sd,int type,int val) max = pc_maxparameter(sd); - if(type<SP_STR || type>SP_LUK){ + switch(type){ + case SP_STR: sd->status.str = cap_value(sd->status.str + val, 1, max); break; + case SP_AGI: sd->status.agi = cap_value(sd->status.agi + val, 1, max); break; + case SP_VIT: sd->status.vit = cap_value(sd->status.vit + val, 1, max); break; + case SP_INT: sd->status.int_= cap_value(sd->status.int_+ val, 1, max); break; + case SP_DEX: sd->status.dex = cap_value(sd->status.dex + val, 1, max); break; + case SP_LUK: sd->status.luk = cap_value(sd->status.luk + val, 1, max); break; + default: clif_statusupack(sd,type,0,0); return 1; } - switch(type){ - case SP_STR: - if(sd->status.str + val >= max) - val = max; - else if(sd->status.str + val < 1) - val = 1; - else - val += sd->status.str; - sd->status.str = val; - break; - case SP_AGI: - if(sd->status.agi + val >= max) - val = max; - else if(sd->status.agi + val < 1) - val = 1; - else - val += sd->status.agi; - sd->status.agi = val; - break; - case SP_VIT: - if(sd->status.vit + val >= max) - val = max; - else if(sd->status.vit + val < 1) - val = 1; - else - val += sd->status.vit; - sd->status.vit = val; - break; - case SP_INT: - if(sd->status.int_ + val >= max) - val = max; - else if(sd->status.int_ + val < 1) - val = 1; - else - val += sd->status.int_; - sd->status.int_ = val; - break; - case SP_DEX: - if(sd->status.dex + val >= max) - val = max; - else if(sd->status.dex + val < 1) - val = 1; - else - val += sd->status.dex; - sd->status.dex = val; - break; - case SP_LUK: - if(sd->status.luk + val >= max) - val = max; - else if(sd->status.luk + val < 1) - val = 1; - else - val = sd->status.luk + val; - sd->status.luk = val; - break; - } + status_calc_pc(sd,0); clif_statusupack(sd,type,1,val); @@ -6228,15 +6159,13 @@ static int pc_eventtimer(int tid,unsigned int tick,int id,int data) int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) { int i; - char* evname; nullpo_retr(0, sd); ARR_FIND( 0, MAX_EVENTTIMER, i, sd->eventtimer[i] == -1 ); if( i == MAX_EVENTTIMER ) return 0; - evname = aStrdup(name); - sd->eventtimer[i] = add_timer(gettick()+tick, pc_eventtimer,sd->bl.id,(int)evname); + sd->eventtimer[i] = add_timer(gettick()+tick, pc_eventtimer, sd->bl.id, (int)aStrdup(name)); sd->eventcount++; return 1; @@ -6248,25 +6177,28 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) int pc_deleventtimer(struct map_session_data *sd,const char *name) { int i; + char* p; nullpo_retr(0, sd); if (sd->eventcount <= 0) return 0; - for(i=0;i<MAX_EVENTTIMER;i++) - if( sd->eventtimer[i]!=-1 ) { - char *p = (char *)(get_timer(sd->eventtimer[i])->data); - if(p && strcmp(p, name)==0) { - delete_timer(sd->eventtimer[i],pc_eventtimer); - sd->eventtimer[i]=-1; - sd->eventcount--; - aFree(p); - return 1; - } - } + // find the named event timer + ARR_FIND( 0, MAX_EVENTTIMER, i, + sd->eventtimer[i] != -1 && + (p = (char *)(get_timer(sd->eventtimer[i])->data)) != NULL && + strcmp(p, name) == 0 + ); + if( i == MAX_EVENTTIMER ) + return 0; // not found - return 0; + delete_timer(sd->eventtimer[i],pc_eventtimer); + sd->eventtimer[i]=-1; + sd->eventcount--; + aFree(p); + + return 1; } /*========================================== |