diff options
Diffstat (limited to 'src')
-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; } |