From 177ea6c779579dff146d5e21f6dcffe17fe3ae9f Mon Sep 17 00:00:00 2001 From: Cydh Ramdh Date: Wed, 15 Apr 2015 20:03:06 +0700 Subject: [PATCH] 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 --- doc/script_commands.txt | 2 +- src/map/pc.c | 40 +++++++++++++++++++++++++--------------- src/map/script.c | 2 +- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 7b9ed7f54c..fb3cc12478 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -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 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: diff --git a/src/map/pc.c b/src/map/pc.c index 72f0d65e75..2ea38d2b6f 100755 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -10470,35 +10470,44 @@ static bool pc_readdb_levelpenalty(char* fields[], int columns, int current) /** [Cydh] * Calculates base hp of player. Reference: http://irowiki.org/wiki/Max_HP * @param level Base level of player -* @param idx Index of class +* @param class_ Job ID @see enum e_job * @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; - 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 - 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 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; } -/** [Playter] +/** [Playtester] * Calculates base sp of player. * @param level Base level of player -* @param idx Index of class +* @param class_ Job ID @see enum e_job * @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; + 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 - if(level >= 10 && class_idx == JOB_NINJA) base_sp -= 20; - if(level >= 10 && class_idx == JOB_GUNSLINGER) base_sp -= 17; + switch (class_) { + case JOB_NINJA: + if (level >= 10) + base_sp -= 20; + break; + case JOB_GUNSLINGER: + if (level >= 10) + base_sp -= 17; + break; + } #endif return (unsigned int)base_sp; } @@ -10856,7 +10865,8 @@ void pc_readdb(void) { for (i = 0; i < JOB_MAX; i++) { int idx; 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) continue; //Classes that do not need exp tables. idx = pc_class2idx(i); @@ -10868,9 +10878,9 @@ void pc_readdb(void) { //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++) { 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) - job_info[idx].base_sp[j] = pc_calc_basesp(j+1,idx); + job_info[idx].base_sp[j] = pc_calc_basesp(j+1,i); } } } diff --git a/src/map/script.c b/src/map/script.c index 82e6fe4cbe..c4f3a84d55 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -18301,7 +18301,7 @@ BUILDIN_FUNC(instance_id) if(!instance_id) { //ShowError("script:instance_id: No instance attached to NPC or player"); script_pushint(st, 0); - return 1; + return SCRIPT_CMD_SUCCESS; } script_pushint(st, instance_id); return SCRIPT_CMD_SUCCESS;