summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c26
-rw-r--r--src/map/pc.c57
-rw-r--r--src/map/pc.h2
3 files changed, 50 insertions, 35 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index eeb9f7532..81ab49799 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -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;
diff --git a/src/map/pc.c b/src/map/pc.c
index 4371b1276..359769833 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -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);
diff --git a/src/map/pc.h b/src/map/pc.h
index 1d0a59391..e37e02e59 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -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);