summaryrefslogtreecommitdiff
path: root/src/map/pc.c
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/map/pc.c
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/map/pc.c')
-rw-r--r--src/map/pc.c27
1 files changed, 17 insertions, 10 deletions
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;
}