* Extracted calculations of the number of status points PC gets when leveling up to a function.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14825 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
Gepard 2011-05-15 17:04:46 +00:00
parent 5d8e2e76bb
commit 336680302f
4 changed files with 22 additions and 13 deletions

View File

@ -1,6 +1,7 @@
Date Added
2011/05/15
* Extracted calculations of the number of status points PC gets when leveling up to a function. [Gepard]
* 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

View File

@ -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)

View File

@ -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;
}

View File

@ -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);