diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 2170b888e..e55d21b5c 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1881,3 +1881,7 @@ bool unit_name_equals_race(const unit *u) { } return false; } + +bool unit_can_study(const unit *u) { + return !((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE)); +} \ No newline at end of file diff --git a/src/kernel/unit.h b/src/kernel/unit.h index bb1d5d54c..45948bdb2 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -250,6 +250,7 @@ extern "C" { const char *unitname(const struct unit *u); char *write_unitname(const struct unit *u, char *buffer, size_t size); bool unit_name_equals_race(const struct unit *u); + bool unit_can_study(const struct unit *u); #ifdef __cplusplus } diff --git a/src/monsters.c b/src/monsters.c index a302b3d31..268e92de3 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -580,7 +580,7 @@ static order *monster_learn(unit * u) const struct locale *lang = u->faction->locale; /* can these monsters even study? */ - if ((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) { + if (!unit_can_study(u)) { 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 * zu bewachen: */ if (u_race(u)->bonus[SK_WEAPONLESS] != -99) { diff --git a/src/study.c b/src/study.c index 7211e1c98..173bc9d08 100644 --- a/src/study.c +++ b/src/study.c @@ -543,7 +543,7 @@ int learn_cmd(unit * u, order * ord) else 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", u_race(u))); return 0;