diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-11 04:17:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-12 00:47:35 +0300 |
commit | 3a5f48dc84b6ec95ca034093f9c199a0ca326a0a (patch) | |
tree | ef01ee826b70b7bd96dde9fd0e34f5b91ae2ab50 | |
parent | 61a240c20d46c00ee93b6861c1dfcfce5683ff15 (diff) | |
download | hercules-3a5f48dc84b6ec95ca034093f9c199a0ca326a0a.tar.gz hercules-3a5f48dc84b6ec95ca034093f9c199a0ca326a0a.tar.bz2 hercules-3a5f48dc84b6ec95ca034093f9c199a0ca326a0a.tar.xz hercules-3a5f48dc84b6ec95ca034093f9c199a0ca326a0a.zip |
Fix reading skill_db.conf
-rw-r--r-- | src/map/skill.c | 61 | ||||
-rw-r--r-- | src/map/skill.h | 1 |
2 files changed, 35 insertions, 27 deletions
diff --git a/src/map/skill.c b/src/map/skill.c index dceebb5b2..76ee3d3fd 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -19295,9 +19295,9 @@ void skill_validate_damagetype(struct config_setting_t *conf, struct s_skill_db } } else if (strcmpi(type, "SplashArea") == 0) { if (on) { - sk->nk |= NK_SPLASH; + sk->nk |= NK_SPLASH_ONLY; } else { - sk->nk &= ~NK_SPLASH; + sk->nk &= ~NK_SPLASH_ONLY; } } else if (strcmpi(type, "SplitDamage") == 0) { if (on) { @@ -19564,9 +19564,9 @@ int skill_validate_weapontype_sub(const char *type, bool on, struct s_skill_db * } } else if (strcmpi(type, "DWDaggerSword") == 0) { if (on) { - sk->weapon |= 1<<W_DOUBLE_DA; + sk->weapon |= 1<<W_DOUBLE_DS; } else { - sk->weapon &= ~(1<<W_DOUBLE_DA); + sk->weapon &= ~(1<<W_DOUBLE_DS); } } else if (strcmpi(type, "DWDaggerAxe") == 0) { if (on) { @@ -19583,6 +19583,7 @@ int skill_validate_weapontype_sub(const char *type, bool on, struct s_skill_db * } else if (strcmpi(type, "All") == 0) { sk->weapon = 0; } else { + ShowError("Item %d. Unknown weapon type %s\n", sk->nameid, type); return 1; // invalid type } @@ -19603,8 +19604,8 @@ void skill_validate_weapontype(struct config_setting_t *conf, struct s_skill_db if ((tt = libconfig->setting_get_member(conf, "WeaponTypes")) && config_setting_is_group(tt)) { int j = 0; - struct config_setting_t *wpt = { 0 }; - while ((wpt = libconfig->setting_get_elem(tt, j++)) && j < 30) { + struct config_setting_t *wpt = NULL; + while ((wpt = libconfig->setting_get_elem(tt, j++)) != NULL) { if (skill_validate_weapontype_sub(config_setting_name(wpt), libconfig->setting_get_bool_real(wpt), sk)) skilldb_invalid_error(config_setting_name(wpt), config_setting_name(tt), sk->nameid); } @@ -19749,7 +19750,7 @@ void skill_validate_state(struct config_setting_t *conf, struct s_skill_db *sk) else if (strcmpi(type,"PoisonWeapon") == 0 ) sk->state = ST_POISONINGWEAPON; else if (strcmpi(type,"RollingCutter") == 0 ) sk->state = ST_ROLLINGCUTTER; else if (strcmpi(type,"MH_Fighting") == 0 ) sk->state = ST_MH_FIGHTING; - else if (strcmpi(type,"MH_Grappling") == 0 ) sk->state = ST_MH_FIGHTING; + else if (strcmpi(type,"MH_Grappling") == 0 ) sk->state = ST_MH_GRAPPLING; else if (strcmpi(type,"Peco") == 0 ) sk->state = ST_PECO; else skilldb_invalid_error(type, "State", sk->nameid); @@ -19771,7 +19772,7 @@ void skill_validate_item_requirements(struct config_setting_t *conf, struct s_sk int itx=-1; struct config_setting_t *it; - while((it=libconfig->setting_get_elem(tt, itx++)) && itx < MAX_SKILL_ITEM_REQUIRE) { + while((it=libconfig->setting_get_elem(tt, ++itx)) && itx < MAX_SKILL_ITEM_REQUIRE) { const char *type = config_setting_name(it); if( type[0] == 'I' && type[1] == 'D' && itemdb->exists(atoi(type+2)) ) @@ -19781,7 +19782,13 @@ void skill_validate_item_requirements(struct config_setting_t *conf, struct s_sk continue; } - sk->amount[itx] = libconfig->setting_get_int(it); + if (config_setting_is_group(it)) { + // TODO: Per-level item requirements are not implemented yet! + // We just take the first level for the time being (old txt behavior) + sk->amount[itx] = libconfig->setting_get_int_elem(it, 0); + } else { + sk->amount[itx] = libconfig->setting_get_int(it); + } } } } @@ -19810,20 +19817,20 @@ void skill_validate_unit_target(struct config_setting_t *conf, struct s_skill_db else if(!strcmpi(type,"Enemy")) sk->unit_target = BCT_ENEMY; else if(!strcmpi(type,"Self")) sk->unit_target = BCT_SELF; else if(!strcmpi(type,"SameGuild")) sk->unit_target = BCT_GUILD|BCT_SAMEGUILD; + } - if (sk->unit_flag&UF_DEFNOTENEMY && battle_config.defnotenemy) - sk->unit_target = BCT_NOENEMY; + if (sk->unit_flag & UF_DEFNOTENEMY && battle_config.defnotenemy) + sk->unit_target = BCT_NOENEMY; - //By default, target just characters. - sk->unit_target |= BL_CHAR; + //By default, target just characters. + sk->unit_target |= BL_CHAR; - if (sk->unit_flag&UF_NOPC) - sk->unit_target &= ~BL_PC; - if (sk->unit_flag&UF_NOMOB) - sk->unit_target &= ~BL_MOB; - if (sk->unit_flag&UF_SKILL) - sk->unit_target |= BL_SKILL; - } + if (sk->unit_flag & UF_NOPC) + sk->unit_target &= ~BL_PC; + if (sk->unit_flag & UF_NOMOB) + sk->unit_target &= ~BL_MOB; + if (sk->unit_flag & UF_SKILL) + sk->unit_target |= BL_SKILL; } /** @@ -19969,7 +19976,7 @@ bool skill_validate_skilldb(struct s_skill_db *sk, const char *source) ShowWarning("skill_validate_skilldb: Invalid skill Id %d provided in '%s'! ... skipping\n", sk->nameid, source); ShowInfo("It is possible that the skill Id is 0 or unavailable (interferes with guild/homun/mercenary skill mapping).\n"); return false; - } else if (sk->max > MAX_SKILL_LEVEL || sk->max <= 0) { + } else if (sk->max <= 0) { ShowError("skill_validate_skilldb: Invalid Max Level %d specified for skill Id %d in '%s', skipping...\n", sk->max, sk->nameid, source); return false; } @@ -20088,8 +20095,8 @@ bool skill_read_skilldb(const char *filename) skill->level_set_value(tmp_db.num, 1); // Default 1 /* Interrupt Cast */ - if (libconfig->setting_lookup_bool(conf, "InterruptCast", &tmp_db.castcancel) == 0) - tmp_db.castcancel = 1; + if (libconfig->setting_lookup_bool(conf, "InterruptCast", &tmp_db.castcancel) == CONFIG_FALSE) + tmp_db.castcancel = 0; /* Cast Defense Rate */ libconfig->setting_lookup_int(conf, "CastDefRate", &tmp_db.cast_def_rate); @@ -20155,11 +20162,11 @@ bool skill_read_skilldb(const char *filename) skill->config_set_level(tt, tmp_db.sp); /* HP Rate */ - if ((tt = libconfig->setting_get_member(t, "HPRate"))) + if ((tt = libconfig->setting_get_member(t, "HPRateCost"))) skill->config_set_level(tt, tmp_db.hp_rate); /* SP Rate */ - if ((tt = libconfig->setting_get_member(t, "SPRate"))) + if ((tt = libconfig->setting_get_member(t, "SPRateCost"))) skill->config_set_level(tt, tmp_db.sp_rate); /* Zeny Cost */ @@ -20171,10 +20178,10 @@ bool skill_read_skilldb(const char *filename) skill->config_set_level(tt, tmp_db.spiritball); /* Weapon Types */ - skill->validate_weapontype(conf, &tmp_db); + skill->validate_weapontype(t, &tmp_db); /* Ammunition Types */ - skill->validate_ammotype(conf, &tmp_db); + skill->validate_ammotype(t, &tmp_db); /* Ammunition Amount */ if ((tt = libconfig->setting_get_member(t, "AmmoAmount"))) diff --git a/src/map/skill.h b/src/map/skill.h index 47cdee2d3..dfc2ecb3c 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -91,6 +91,7 @@ enum e_skill_inf { enum e_skill_nk { NK_NO_DAMAGE = 0x01, NK_SPLASH = 0x02|0x04, // 0x4 = splash & split + NK_SPLASH_ONLY = 0x02, NK_SPLASHSPLIT = 0x04, NK_NO_CARDFIX_ATK = 0x08, NK_NO_ELEFIX = 0x10, |