summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGepard <Gepard@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-05-15 17:04:46 +0000
committerGepard <Gepard@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-05-15 17:04:46 +0000
commitebc2e786b5003fc7e3624419db895e26ed4d41dd (patch)
treeb172f750660ab9f379dee7144eee7fd070bf4b36 /src
parent6c492d546fde8fd7180695891a1f1eb576758075 (diff)
downloadhercules-ebc2e786b5003fc7e3624419db895e26ed4d41dd.tar.gz
hercules-ebc2e786b5003fc7e3624419db895e26ed4d41dd.tar.bz2
hercules-ebc2e786b5003fc7e3624419db895e26ed4d41dd.tar.xz
hercules-ebc2e786b5003fc7e3624419db895e26ed4d41dd.zip
* Extracted calculations of the number of status points PC gets when leveling up to a function.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14825 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.c6
-rw-r--r--src/map/pc.c27
-rw-r--r--src/map/pc.h1
3 files changed, 21 insertions, 13 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 459a6a734..e58f07880 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1751,8 +1751,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;
@@ -1768,7 +1768,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/pc.c b/src/map/pc.c
index 359769833..976d1e488 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4857,13 +4857,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 ++;
-
- if (battle_config.use_statpoint_table)
- next = statp[sd->status.base_level] - statp[sd->status.base_level-1];
- else //Estimated way.
- next = (sd->status.base_level+14) / 5 ;
-
sd->status.status_point += next;
} while ((next=pc_nextbaseexp(sd)) > 0 && sd->status.base_exp >= next);
@@ -5134,6 +5129,15 @@ static int pc_setstat(struct map_session_data* sd, int type, int val)
return val;
}
+// 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
+ return ((level+15) / 5);
+}
+
/// 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.
@@ -6072,8 +6076,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;
@@ -8074,7 +8078,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))
@@ -8093,9 +8097,12 @@ 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++)
- statp[i] = statp[i-1] + (i-1+15)/5;
+ 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 e37e02e59..ca4f671a4 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -649,6 +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_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);