summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorGepard <Gepard@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-05-15 17:39:46 +0000
committerGepard <Gepard@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-05-15 17:39:46 +0000
commit7e5da9f35dec37d88a490207b54dd41853db93f9 (patch)
treef799c020cbc64757e8f749ef9df8b71debfda3d8 /src/map
parent6af2f57a569cb3c8949ea84029e169daecf24548 (diff)
downloadhercules-7e5da9f35dec37d88a490207b54dd41853db93f9.tar.gz
hercules-7e5da9f35dec37d88a490207b54dd41853db93f9.tar.bz2
hercules-7e5da9f35dec37d88a490207b54dd41853db93f9.tar.xz
hercules-7e5da9f35dec37d88a490207b54dd41853db93f9.zip
* Merged changes from trunk [14824:14825/trunk].
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14826 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c6
-rw-r--r--src/map/clif.c26
-rw-r--r--src/map/pc.c108
-rw-r--r--src/map/pc.h3
4 files changed, 80 insertions, 63 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 7d66d1694..664430b18 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1836,8 +1836,8 @@ ACMD_FUNC(baselevelup)
} // End Addition
if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
level = pc_maxbaselv(sd) - sd->status.base_level;
- for (i = 1; i <= level; i++)
- status_point += (sd->status.base_level + i + 14) / 5;
+ for (i = 0; i < level; i++)
+ status_point += pc_gets_status_point(sd->status.base_level + i);
sd->status.status_point += status_point;
sd->status.base_level += (unsigned int)level;
@@ -1853,7 +1853,7 @@ ACMD_FUNC(baselevelup)
if ((unsigned int)level >= sd->status.base_level)
level = sd->status.base_level-1;
for (i = 0; i > -level; i--)
- status_point += (sd->status.base_level + i + 14) / 5;
+ status_point += pc_gets_status_point(sd->status.base_level + i - 1);
if (sd->status.status_point < status_point)
pc_resetstate(sd);
if (sd->status.status_point < status_point)
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 13e6fae57..6d4002599 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -5038,18 +5038,8 @@ int pc_checkbaselevelup(struct map_session_data *sd)
if(!battle_config.multi_level_up && sd->status.base_exp > next-1)
sd->status.base_exp = next-1;
+ next = pc_gets_status_point(sd->status.base_level);
sd->status.base_level ++;
-
- //Give status points
- if (battle_config.use_statpoint_table) //Use values from "db/statpoint.txt"
- next = statp[sd->status.base_level] - statp[sd->status.base_level-1];
- else //Default increase
- {
- if (sd->status.base_level <= 100)
- next = (sd->status.base_level+14) / 5;
- else
- next = (sd->status.base_level+129) / 10;
- }
sd->status.status_point += next;
} while ((next=pc_nextbaseexp(sd)) > 0 && sd->status.base_exp >= next);
@@ -5367,18 +5357,45 @@ 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)
+// Calculates the number of status points PC gets when leveling up (from level to level+1)
+int pc_gets_status_point(int level)
+{
+ if (battle_config.use_statpoint_table) //Use values from "db/statpoint.txt"
+ return (statp[level+1] - statp[level]);
+ else //Default increase
+ {
+ if (level < 100)
+ return ((level+15) / 5);
+ else
+ return ((level+130) / 10);
+ }
+}
+
+/// 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)
{
- int stat = pc_getstat(sd, type);
+ int low, high, sp = 0;
- if( stat >= pc_maxparameter(sd) )
+ if ( val == 0 )
+ return 0;
+
+ low = pc_getstat(sd,type);
+ if ( low >= pc_maxparameter(sd) && val > 0 )
return 0; // Official servers show '0' when max is reached
+ high = low + val;
- if( stat < 100 )
- return ( 1 + (stat + 9) / 10 );
- else
- return ( 16 + 4*((stat - 100) / 5) );
+ if ( val < 0 )
+ swap(low, high);
+
+ for ( ; low < high; low++ )
+ if( low < 100 )
+ sp += ( 1 + (low + 9) / 10 );
+ else
+ sp += ( 16 + 4*((low - 100) / 5) );
+
+ return sp;
}
/// Raises a stat by 1.
@@ -5393,7 +5410,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);
@@ -5415,7 +5432,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
@@ -5446,7 +5463,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);
@@ -5455,7 +5472,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
@@ -5665,25 +5682,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);
@@ -6298,8 +6314,8 @@ int pc_setparam(struct map_session_data *sd,int type,int val)
val = pc_maxbaselv(sd);
if ((unsigned int)val > sd->status.base_level) {
int stat=0;
- for (i = 1; i <= (int)((unsigned int)val - sd->status.base_level); i++)
- stat += (sd->status.base_level + i + 14) / 5 ;
+ for (i = 0; i < (int)((unsigned int)val - sd->status.base_level); i++)
+ stat += pc_gets_status_point(sd->status.base_level + i);
sd->status.status_point += stat;
}
sd->status.base_level = (unsigned int)val;
@@ -8308,7 +8324,7 @@ int pc_readdb(void)
sprintf(line, "%s/statpoint.txt", db_path);
fp=fopen(line,"r");
if(fp == NULL){
- ShowStatus("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line);
+ ShowWarning("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line);
//return 1;
} else {
while(fgets(line, sizeof(line), fp))
@@ -8327,13 +8343,13 @@ int pc_readdb(void)
ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","statpoint.txt");
}
// generate the remaining parts of the db if necessary
+ k = battle_config.use_statpoint_table; //save setting
+ battle_config.use_statpoint_table = 0; //temporarily disable to force pc_gets_status_point use default values
statp[0] = 45; // seed value
- for (; i <= MAX_LEVEL; i++) {
- if(i <= 100)
- statp[i] = statp[i-1] + (i+14)/5;
- else
- statp[i] = statp[i-1] + (i+129)/10;
- }
+ for (; i <= MAX_LEVEL; i++)
+ statp[i] = statp[i-1] + pc_gets_status_point(i-1);
+ battle_config.use_statpoint_table = k; //restore setting
+
return 0;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index 029630eec..271b3f6b0 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -651,7 +651,8 @@ 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_gets_status_point(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);