* Removed status point calculations (duplicate) from pc_resetstate function. It is now handled by pc_need_status_point.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14824 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
Gepard 2011-05-15 15:09:52 +00:00
parent 5179a206ba
commit 5d8e2e76bb
4 changed files with 51 additions and 35 deletions

View File

@ -1,6 +1,7 @@
Date Added
2011/05/15
* Removed status point calculations (duplicate) from `pc_resetstate` function. It is now handled by `pc_need_status_point`. [Gepard]
* Merged pcdb_checkid update from renewal [14810/branches/renewal]. [Ai4rei]
2011/05/14
* Moved bitfield 'boss' inside 'spawn_data' and 'mob_data' into the respective state struct (from r13813, follow up to r14795). [Ai4rei]

View File

@ -2542,7 +2542,7 @@ int clif_updatestatus(struct map_session_data *sd,int type)
case SP_UDEX:
case SP_ULUK:
WFIFOW(fd,0)=0xbe;
WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR);
WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR,1);
len=5;
break;
@ -2824,17 +2824,17 @@ int clif_initialstatus(struct map_session_data *sd)
WBUFW(buf,0)=0xbd;
WBUFW(buf,2)=min(sd->status.status_point, SHRT_MAX);
WBUFB(buf,4)=min(sd->status.str, UCHAR_MAX);
WBUFB(buf,5)=pc_need_status_point(sd,SP_STR);
WBUFB(buf,5)=pc_need_status_point(sd,SP_STR,1);
WBUFB(buf,6)=min(sd->status.agi, UCHAR_MAX);
WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI);
WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI,1);
WBUFB(buf,8)=min(sd->status.vit, UCHAR_MAX);
WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT);
WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT,1);
WBUFB(buf,10)=min(sd->status.int_, UCHAR_MAX);
WBUFB(buf,11)=pc_need_status_point(sd,SP_INT);
WBUFB(buf,11)=pc_need_status_point(sd,SP_INT,1);
WBUFB(buf,12)=min(sd->status.dex, UCHAR_MAX);
WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX);
WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX,1);
WBUFB(buf,14)=min(sd->status.luk, UCHAR_MAX);
WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK);
WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK,1);
WBUFW(buf,16) = sd->battle_status.batk + sd->battle_status.rhw.atk + sd->battle_status.lhw.atk;
WBUFW(buf,18) = sd->battle_status.rhw.atk2 + sd->battle_status.lhw.atk2; //atk bonus
@ -12420,17 +12420,17 @@ void clif_check(int fd, struct map_session_data* pl_sd)
WFIFOHEAD(fd,packet_len(0x214));
WFIFOW(fd, 0) = 0x214;
WFIFOB(fd, 2) = min(pl_sd->status.str, UCHAR_MAX);
WFIFOB(fd, 3) = pc_need_status_point(pl_sd, SP_STR);
WFIFOB(fd, 3) = pc_need_status_point(pl_sd, SP_STR, 1);
WFIFOB(fd, 4) = min(pl_sd->status.agi, UCHAR_MAX);
WFIFOB(fd, 5) = pc_need_status_point(pl_sd, SP_AGI);
WFIFOB(fd, 5) = pc_need_status_point(pl_sd, SP_AGI, 1);
WFIFOB(fd, 6) = min(pl_sd->status.vit, UCHAR_MAX);
WFIFOB(fd, 7) = pc_need_status_point(pl_sd, SP_VIT);
WFIFOB(fd, 7) = pc_need_status_point(pl_sd, SP_VIT, 1);
WFIFOB(fd, 8) = min(pl_sd->status.int_, UCHAR_MAX);
WFIFOB(fd, 9) = pc_need_status_point(pl_sd, SP_INT);
WFIFOB(fd, 9) = pc_need_status_point(pl_sd, SP_INT, 1);
WFIFOB(fd,10) = min(pl_sd->status.dex, UCHAR_MAX);
WFIFOB(fd,11) = pc_need_status_point(pl_sd, SP_DEX);
WFIFOB(fd,11) = pc_need_status_point(pl_sd, SP_DEX, 1);
WFIFOB(fd,12) = min(pl_sd->status.luk, UCHAR_MAX);
WFIFOB(fd,13) = pc_need_status_point(pl_sd, SP_LUK);
WFIFOB(fd,13) = pc_need_status_point(pl_sd, SP_LUK, 1);
WFIFOW(fd,14) = pl_sd->battle_status.batk+pl_sd->battle_status.rhw.atk+pl_sd->battle_status.lhw.atk;
WFIFOW(fd,16) = pl_sd->battle_status.rhw.atk2+pl_sd->battle_status.lhw.atk2;
WFIFOW(fd,18) = pl_sd->battle_status.matk_max;

View File

@ -5134,10 +5134,26 @@ static int pc_setstat(struct map_session_data* sd, int type, int val)
return val;
}
/// Returns the number of stat points needed to raise the specified stat by 1.
int pc_need_status_point(struct map_session_data* sd, int type)
/// Returns the number of stat points needed to change the specified stat by val.
/// If val is negative, returns the number of stat points that would be needed to
/// raise the specified stat from (current value - val) to current value.
int pc_need_status_point(struct map_session_data* sd, int type, int val)
{
return ( 1 + (pc_getstat(sd,type) + 9) / 10 );
int low, high, sp = 0;
if ( val == 0 )
return 0;
low = pc_getstat(sd,type);
high = low + val;
if ( val < 0 )
swap(low, high);
for ( ; low < high; low++ )
sp += ( 1 + (low + 9) / 10 );
return sp;
}
/// Raises a stat by 1.
@ -5152,7 +5168,7 @@ int pc_statusup(struct map_session_data* sd, int type)
nullpo_ret(sd);
// check conditions
need = pc_need_status_point(sd,type);
need = pc_need_status_point(sd,type,1);
if( type < SP_STR || type > SP_LUK || need < 0 || need > sd->status.status_point )
{
clif_statusupack(sd,type,0,0);
@ -5174,7 +5190,7 @@ int pc_statusup(struct map_session_data* sd, int type)
status_calc_pc(sd,0);
// update increase cost indicator
if( need != pc_need_status_point(sd,type) )
if( need != pc_need_status_point(sd,type,1) )
clif_updatestatus(sd, SP_USTR + type-SP_STR);
// update statpoint count
@ -5205,7 +5221,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val)
return 1;
}
need = pc_need_status_point(sd,type);
need = pc_need_status_point(sd,type,1);
// set new value
max = pc_maxparameter(sd);
@ -5214,7 +5230,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val)
status_calc_pc(sd,0);
// update increase cost indicator
if( need != pc_need_status_point(sd,type) )
if( need != pc_need_status_point(sd,type,1) )
clif_updatestatus(sd, SP_USTR + type-SP_STR);
// update stat value
@ -5424,25 +5440,24 @@ int pc_resetstate(struct map_session_data* sd)
sd->status.status_point = statp[sd->status.base_level] + ( sd->class_&JOBL_UPPER ? 52 : 0 ); // extra 52+48=100 stat points
}
else
{ //Use new stat-calculating equation [Skotlex]
#define sumsp(a) (((a-1)/10 +2)*(5*((a-1)/10 +1) + (a-1)%10) -10)
{
int add=0;
add += sumsp(sd->status.str);
add += sumsp(sd->status.agi);
add += sumsp(sd->status.vit);
add += sumsp(sd->status.int_);
add += sumsp(sd->status.dex);
add += sumsp(sd->status.luk);
add += pc_need_status_point(sd, SP_STR, 1-pc_getstat(sd, SP_STR));
add += pc_need_status_point(sd, SP_AGI, 1-pc_getstat(sd, SP_AGI));
add += pc_need_status_point(sd, SP_VIT, 1-pc_getstat(sd, SP_VIT));
add += pc_need_status_point(sd, SP_INT, 1-pc_getstat(sd, SP_INT));
add += pc_need_status_point(sd, SP_DEX, 1-pc_getstat(sd, SP_DEX));
add += pc_need_status_point(sd, SP_LUK, 1-pc_getstat(sd, SP_LUK));
sd->status.status_point+=add;
}
sd->status.str=1;
sd->status.agi=1;
sd->status.vit=1;
sd->status.int_=1;
sd->status.dex=1;
sd->status.luk=1;
pc_setstat(sd, SP_STR, 1);
pc_setstat(sd, SP_AGI, 1);
pc_setstat(sd, SP_VIT, 1);
pc_setstat(sd, SP_INT, 1);
pc_setstat(sd, SP_DEX, 1);
pc_setstat(sd, SP_LUK, 1);
clif_updatestatus(sd,SP_STR);
clif_updatestatus(sd,SP_AGI);

View File

@ -649,7 +649,7 @@ unsigned int pc_nextbaseexp(struct map_session_data *);
unsigned int pc_thisbaseexp(struct map_session_data *);
unsigned int pc_nextjobexp(struct map_session_data *);
unsigned int pc_thisjobexp(struct map_session_data *);
int pc_need_status_point(struct map_session_data *,int);
int pc_need_status_point(struct map_session_data *,int,int);
int pc_statusup(struct map_session_data*,int);
int pc_statusup2(struct map_session_data*,int,int);
int pc_skillup(struct map_session_data*,int);