Bug 2609 VERGESSE Magie

This commit is contained in:
Enno Rehling 2019-09-18 20:55:44 +02:00
parent ea9e31d1b2
commit d5104fa55a
4 changed files with 28 additions and 4 deletions

View File

@ -282,9 +282,21 @@ static int forget_cmd(unit * u, order * ord)
sk = get_skill(s, u->faction->locale);
if (sk != NOSKILL) {
if (sk == SK_MAGIC && is_familiar(u)) {
/* some units cannot forget their innate magical abilities */
return 0;
if (sk == SK_MAGIC) {
if (is_familiar(u)) {
/* some units cannot forget their innate magical abilities */
return 0;
}
else {
unit *ufam = get_familiar(u);
if (ufam) {
a_removeall(&ufam->attribs, NULL);
u_setfaction(ufam, get_monsters());
unit_convert_race(ufam, NULL, "ghost");
}
a_removeall(&u->attribs, &at_mage);
a_removeall(&u->attribs, &at_familiar);
}
}
ADDMSG(&u->faction->msgs, msg_message("forget", "unit skill", u, sk));
set_level(u, sk, 0);

View File

@ -395,7 +395,7 @@ void save_special_items(unit *usrc)
/* some units have plural names, it would be neat if they aren't single: */
scale_number(u, 2);
}
set_racename(&u->attribs, "ghost");
unit_convert_race(u, rc_ghost, "ghost");
give_special_items(u, &usrc->items);
}

View File

@ -1833,3 +1833,14 @@ double u_heal_factor(const unit * u)
}
return 1.0;
}
void unit_convert_race(unit *u, const race *rc, const char *rcname)
{
if (rc && u->_race != rc) {
u_setrace(u, rc);
}
if (rcname && strcmp(rcname, u->_race->_name) != 0) {
set_racename(&u->attribs, rcname);
}
}

View File

@ -221,6 +221,7 @@ extern "C" {
char *write_unitname(const struct unit *u, char *buffer, size_t size);
bool unit_name_equals_race(const struct unit *u);
void unit_convert_race(struct unit *u, const struct race *rc, const char *rcname);
/* getunit results: */
#define GET_UNIT 0
#define GET_NOTFOUND 1