diff options
author | shennetsind <ind@henn.et> | 2013-07-09 18:06:42 -0300 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-07-09 18:06:42 -0300 |
commit | 55d42874dcf24c466f0104123d9efe280c0fd03c (patch) | |
tree | 7d4f517a84fcdf96b791ff5d93321b2fbfd4c4b1 | |
parent | 482c1ef58d94d8e124a9b8102f2503818bbc1c90 (diff) | |
download | hercules-55d42874dcf24c466f0104123d9efe280c0fd03c.tar.gz hercules-55d42874dcf24c466f0104123d9efe280c0fd03c.tar.bz2 hercules-55d42874dcf24c466f0104123d9efe280c0fd03c.tar.xz hercules-55d42874dcf24c466f0104123d9efe280c0fd03c.zip |
Mob Parse & Mob Skill Use fixes
Special Thanks to Masao for bringing this to us.
mob parser will now throw out warnings when a field in the mob db has a value higher than the field supported (e.g. if you get a monster with 70k hp it will tell you its higher and cap it to the maximum supported, which is 65k), this failsafe also works for def/mdef, str/agi/vit/int_/dex/luk.
Modified the formula that measures skill field data for skill levels higher than the maximum (e.g. mistress' high-level jupitel thunder), to match the previous version, also fixed a issue where depending on the level the blewcount could get higher than the systems' hardcoded 25-cell maximum.
Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r-- | src/map/mob.c | 36 | ||||
-rw-r--r-- | src/map/skill.c | 11 |
2 files changed, 33 insertions, 14 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index 71c81749a..601ecd110 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3634,7 +3634,17 @@ static void item_dropratio_adjust(int nameid, int mob_id, int *rate_adjust) *rate_adjust = item_drop_ratio_db[nameid]->drop_ratio; } } - +/* (mob_parse_dbrow)_cap_value */ +static inline int mob_parse_dbrow_cap_value(int class_, int min, int max, int value) { + if( value > max ) { + ShowError("mob_parse_dbrow: for class '%d', field value '%d' is higher than the maximum '%d'! capping...\n", class_, value, max); + return max; + } else if ( value < min ) { + ShowError("mob_parse_dbrow: for class '%d', field value '%d' is lower than the minimum '%d'! capping...\n", class_, value, min); + return min; + } + return value; +} /*========================================== * processes one mobdb entry *------------------------------------------*/ @@ -3683,16 +3693,20 @@ static bool mob_parse_dbrow(char** str) db->job_exp = (unsigned int)cap_value(exp, 0, UINT_MAX); status->rhw.range = atoi(str[9]); - status->rhw.atk = atoi(str[10]); - status->rhw.atk2 = atoi(str[11]); - status->def = atoi(str[12]); - status->mdef = atoi(str[13]); - status->str = atoi(str[14]); - status->agi = atoi(str[15]); - status->vit = atoi(str[16]); - status->int_ = atoi(str[17]); - status->dex = atoi(str[18]); - status->luk = atoi(str[19]); + + status->rhw.atk = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[10])); + status->rhw.atk2 = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[11])); + + status->def = mob_parse_dbrow_cap_value(class_,DEFTYPE_MIN,DEFTYPE_MAX,atoi(str[12])); + status->mdef = mob_parse_dbrow_cap_value(class_,DEFTYPE_MIN,DEFTYPE_MAX,atoi(str[13])); + + status->str = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[14])); + status->agi = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[15])); + status->vit = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[16])); + status->int_ = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[17])); + status->dex = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[18])); + status->luk = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[19])); + //All status should be min 1 to prevent divisions by zero from some skills. [Skotlex] if (status->str < 1) status->str = 1; if (status->agi < 1) status->agi = 1; diff --git a/src/map/skill.c b/src/map/skill.c index 78914869c..7b6652dda 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -179,9 +179,9 @@ void skill_chk(uint16* skill_id) { #define skill_get2(var,id,lv) { \ skill->chk(&id); \ if(!id) return 0; \ - if( lv >= MAX_SKILL_LEVEL && var > 1 ) { \ + if( lv > MAX_SKILL_LEVEL && var > 1 ) { \ int lv2 = lv; lv = skill_db[id].max; \ - return (var) + (lv2-lv);\ + return (var) + ((lv2-lv)/2);\ } \ return var;\ } @@ -2655,6 +2655,11 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds break; } + + /* monsters with skill lv higher than MAX_SKILL_LEVEL may get this value beyond the max depending on conditions, we cap to the system's limit */ + if( dsrc && dsrc->type == BL_MOB && skill_lv > MAX_SKILL_LEVEL && dmg.blewcount > 25 ) + dmg.blewcount = 25; + //blown-specific handling switch( skill_id ) { case LG_OVERBRAND: @@ -18087,7 +18092,7 @@ int do_init_skill (void) { iTimer->add_timer_func_list(skill->blockpc_end, "skill_blockpc_end"); iTimer->add_timer_interval(iTimer->gettick()+SKILLUNITTIMER_INTERVAL,skill->unit_timer,0,0,SKILLUNITTIMER_INTERVAL); - + return 0; } |