diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/pc.c | 190 | ||||
-rw-r--r-- | src/map/status.c | 33 | ||||
-rw-r--r-- | src/map/status.h | 17 |
3 files changed, 81 insertions, 159 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; } /*========================================== diff --git a/src/map/status.c b/src/map/status.c index 4b1144d49..7e6585085 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -5959,28 +5959,19 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val switch(type) { //OPT1 - case SC_STONE: - case SC_FREEZE: - case SC_STUN: - case SC_SLEEP: - if(type == SC_STONE) - sc->opt1 = OPT1_STONEWAIT; - else - sc->opt1 = OPT1_STONE + (type - SC_STONE); - break; + case SC_STONE: sc->opt1 = OPT1_STONEWAIT; break; + case SC_FREEZE: sc->opt1 = OPT1_FREEZE; break; + case SC_STUN: sc->opt1 = OPT1_STUN; break; + case SC_SLEEP: sc->opt1 = OPT1_SLEEP; break; //OPT2 - case SC_POISON: - case SC_CURSE: - case SC_SILENCE: - case SC_BLIND: - sc->opt2 |= 1<<(type-SC_POISON); - break; - case SC_DPOISON: - sc->opt2 |= OPT2_DPOISON; - break; - case SC_SIGNUMCRUCIS: - sc->opt2 |= OPT2_SIGNUMCRUCIS; - break; + case SC_POISON: sc->opt2 |= OPT2_POISON; break; + case SC_CURSE: sc->opt2 |= OPT2_CURSE; break; + case SC_SILENCE: sc->opt2 |= OPT2_SILENCE; break; + case SC_SIGNUMCRUCIS: sc->opt2 |= OPT2_SIGNUMCRUCIS; break; + case SC_BLIND: sc->opt2 |= OPT2_BLIND; break; + case SC_ANGELUS: sc->opt2 |= OPT2_ANGELUS; break; + case SC_BLEEDING: sc->opt2 |= OPT2_BLEEDING; break; + case SC_DPOISON: sc->opt2 |= OPT2_DPOISON; break; //OPT3 case SC_TWOHANDQUICKEN: case SC_SPEARQUICKEN: diff --git a/src/map/status.h b/src/map/status.h index b036dbd09..c34c45d10 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -496,15 +496,14 @@ enum { }; //opt2: Stackable status changes. -#define OPT2_POISON 0x001 -#define OPT2_CURSE 0x002 -#define OPT2_SILENCE 0x004 -#define OPT2_SIGNUMCRUCIS 0x008 -#define OPT2_BLIND 0x010 -//0x020 - nothing -//0x040 - nothing -#define OPT2_DPOISON 0x080 -//0x100 +#define OPT2_POISON 0x0001 +#define OPT2_CURSE 0x0002 +#define OPT2_SILENCE 0x0004 +#define OPT2_SIGNUMCRUCIS 0x0008 +#define OPT2_BLIND 0x0010 +#define OPT2_ANGELUS 0x0020 +#define OPT2_BLEEDING 0x0040 +#define OPT2_DPOISON 0x0080 #define OPTION_SIGHT 0x00000001 #define OPTION_HIDE 0x00000002 |