also prevent monsters from studying unarmed combat if they cannot learn things.

refactor the unit_can_study functionality into a separate function, we are now using it in multiple places.
This commit is contained in:
Enno Rehling 2014-12-14 16:17:01 +01:00
parent 595dc35fb0
commit c5774e652a
4 changed files with 8 additions and 3 deletions

View File

@ -1881,3 +1881,7 @@ bool unit_name_equals_race(const unit *u) {
} }
return false; return false;
} }
bool unit_can_study(const unit *u) {
return !((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE));
}

View File

@ -250,6 +250,7 @@ extern "C" {
const char *unitname(const struct unit *u); const char *unitname(const struct unit *u);
char *write_unitname(const struct unit *u, char *buffer, size_t size); char *write_unitname(const struct unit *u, char *buffer, size_t size);
bool unit_name_equals_race(const struct unit *u); bool unit_name_equals_race(const struct unit *u);
bool unit_can_study(const struct unit *u);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -580,7 +580,7 @@ static order *monster_learn(unit * u)
const struct locale *lang = u->faction->locale; const struct locale *lang = u->faction->locale;
/* can these monsters even study? */ /* can these monsters even study? */
if ((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) { if (!unit_can_study(u)) {
return NULL; return NULL;
} }
@ -830,7 +830,7 @@ void plan_monsters(faction * f)
} }
} }
if (long_order == NULL) { if (long_order == NULL && unit_can_study(u)) {
/* Einheiten, die Waffenlosen Kampf lernen könnten, lernen es um /* Einheiten, die Waffenlosen Kampf lernen könnten, lernen es um
* zu bewachen: */ * zu bewachen: */
if (u_race(u)->bonus[SK_WEAPONLESS] != -99) { if (u_race(u)->bonus[SK_WEAPONLESS] != -99) {

View File

@ -543,7 +543,7 @@ int learn_cmd(unit * u, order * ord)
else else
learn_newskills = 1; learn_newskills = 1;
} }
if ((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) { if (!unit_can_study(u)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race", ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race",
u_race(u))); u_race(u)));
return 0; return 0;