Follow ups & fix

* Follow up df2f850c, correcting `class_idx` usage that should be compared with `enum e_job` in `pc_calc_basesp` and also in `pc_calc_basehp`
* Follow up 308c4779, fixed typo fix
* Makes `instance_id()` doesn't show debug message when it return 0 for instance id

Signed-off-by: Cydh Ramdh <cydh@pservero.com>
This commit is contained in:
Cydh Ramdh 2015-04-15 20:03:06 +07:00
parent 308c4779c8
commit 177ea6c779
3 changed files with 27 additions and 17 deletions

View File

@ -2304,7 +2304,7 @@ Also useful when passing arrays to functions or accessing another npc's arrays:
This function will return the specified stat of the invoking character, or, if a This function will return the specified stat of the invoking character, or, if a
character name is specified, of that player. The stat can either be a number or character name is specified, of that player. The stat can either be a number or
paramater name, defined in 'db/const.txt'. parameter name, defined in 'db/const.txt'.
Some example parameters: Some example parameters:

View File

@ -10470,35 +10470,44 @@ static bool pc_readdb_levelpenalty(char* fields[], int columns, int current)
/** [Cydh] /** [Cydh]
* Calculates base hp of player. Reference: http://irowiki.org/wiki/Max_HP * Calculates base hp of player. Reference: http://irowiki.org/wiki/Max_HP
* @param level Base level of player * @param level Base level of player
* @param idx Index of class * @param class_ Job ID @see enum e_job
* @return base_hp * @return base_hp
*/ */
static unsigned int pc_calc_basehp(uint16 level, uint16 class_idx) { static unsigned int pc_calc_basehp(uint16 level, uint16 class_) {
double base_hp; double base_hp;
uint16 i; uint16 i, idx = pc_class2idx(class_);
base_hp = 35 + level * (job_info[class_idx].hp_multiplicator/100.); base_hp = 35 + level * (job_info[idx].hp_multiplicator/100.);
#ifndef RENEWAL #ifndef RENEWAL
if(level >= 10 && (class_idx == JOB_NINJA || class_idx == JOB_GUNSLINGER)) base_hp += 90; if(level >= 10 && (class_ == JOB_NINJA || class_ == JOB_GUNSLINGER)) base_hp += 90;
#endif #endif
for (i = 2; i <= level; i++) for (i = 2; i <= level; i++)
base_hp += floor(((job_info[class_idx].hp_factor/100.) * i) + 0.5); //Don't have round() base_hp += floor(((job_info[idx].hp_factor/100.) * i) + 0.5); //Don't have round()
return (unsigned int)base_hp; return (unsigned int)base_hp;
} }
/** [Playter] /** [Playtester]
* Calculates base sp of player. * Calculates base sp of player.
* @param level Base level of player * @param level Base level of player
* @param idx Index of class * @param class_ Job ID @see enum e_job
* @return base_sp * @return base_sp
*/ */
static unsigned int pc_calc_basesp(uint16 level, uint16 class_idx) { static unsigned int pc_calc_basesp(uint16 level, uint16 class_) {
double base_sp; double base_sp;
uint16 idx = pc_class2idx(class_);
base_sp = 10 + floor(level * (job_info[class_idx].sp_factor / 100.)); base_sp = 10 + floor(level * (job_info[idx].sp_factor / 100.));
#ifndef RENEWAL #ifndef RENEWAL
if(level >= 10 && class_idx == JOB_NINJA) base_sp -= 20; switch (class_) {
if(level >= 10 && class_idx == JOB_GUNSLINGER) base_sp -= 17; case JOB_NINJA:
if (level >= 10)
base_sp -= 20;
break;
case JOB_GUNSLINGER:
if (level >= 10)
base_sp -= 17;
break;
}
#endif #endif
return (unsigned int)base_sp; return (unsigned int)base_sp;
} }
@ -10856,7 +10865,8 @@ void pc_readdb(void) {
for (i = 0; i < JOB_MAX; i++) { for (i = 0; i < JOB_MAX; i++) {
int idx; int idx;
uint16 j; uint16 j;
if (!pcdb_checkid(i)) continue; if (!pcdb_checkid(i))
continue;
if (i == JOB_WEDDING || i == JOB_XMAS || i == JOB_SUMMER || i == JOB_HANBOK || i == JOB_OKTOBERFEST) if (i == JOB_WEDDING || i == JOB_XMAS || i == JOB_SUMMER || i == JOB_HANBOK || i == JOB_OKTOBERFEST)
continue; //Classes that do not need exp tables. continue; //Classes that do not need exp tables.
idx = pc_class2idx(i); idx = pc_class2idx(i);
@ -10868,9 +10878,9 @@ void pc_readdb(void) {
//Init and checking the empty value of Base HP/SP [Cydh] //Init and checking the empty value of Base HP/SP [Cydh]
for (j = 0; j < (job_info[idx].max_level[0] ? job_info[idx].max_level[0] : MAX_LEVEL); j++) { for (j = 0; j < (job_info[idx].max_level[0] ? job_info[idx].max_level[0] : MAX_LEVEL); j++) {
if (job_info[idx].base_hp[j] == 0) if (job_info[idx].base_hp[j] == 0)
job_info[idx].base_hp[j] = pc_calc_basehp(j+1,idx); job_info[idx].base_hp[j] = pc_calc_basehp(j+1,i);
if (job_info[idx].base_sp[j] == 0) if (job_info[idx].base_sp[j] == 0)
job_info[idx].base_sp[j] = pc_calc_basesp(j+1,idx); job_info[idx].base_sp[j] = pc_calc_basesp(j+1,i);
} }
} }
} }

View File

@ -18301,7 +18301,7 @@ BUILDIN_FUNC(instance_id)
if(!instance_id) { if(!instance_id) {
//ShowError("script:instance_id: No instance attached to NPC or player"); //ShowError("script:instance_id: No instance attached to NPC or player");
script_pushint(st, 0); script_pushint(st, 0);
return 1; return SCRIPT_CMD_SUCCESS;
} }
script_pushint(st, instance_id); script_pushint(st, instance_id);
return SCRIPT_CMD_SUCCESS; return SCRIPT_CMD_SUCCESS;