fix permanent smurfs
This commit is contained in:
Enno Rehling 2021-03-18 21:02:22 +01:00
parent 1370b63b8b
commit 16edaf9dba
2 changed files with 23 additions and 18 deletions

View File

@ -287,22 +287,19 @@ struct order *ord)
change_effect(u, itype, 100 * amount); change_effect(u, itype, 100 * amount);
} }
else { else {
const race *irace = u_irace(u); const race *rcfailure = rc_find("smurf");
if (irace == u_race(u)) { if (!rcfailure) {
const race *rcfailure = rc_find("smurf"); rcfailure = rc_find("toad");
if (!rcfailure) { }
rcfailure = rc_find("toad"); if (rcfailure) {
} trigger *trestore = trigger_changerace(u, u_race(u), u->irace);
if (rcfailure) { if (trestore) {
trigger *trestore = trigger_changerace(u, u_race(u), irace); int duration = 2 + rng_int() % 8;
if (trestore) {
int duration = 2 + rng_int() % 8;
add_trigger(&u->attribs, "timer", trigger_timeout(duration, add_trigger(&u->attribs, "timer", trigger_timeout(duration,
trestore)); trestore));
u->irace = NULL; u->irace = NULL;
u_setrace(u, rcfailure); u_setrace(u, rcfailure);
}
} }
} }
} }

View File

@ -383,11 +383,12 @@ unit *read_unit(gamedata *data)
char obuf[DISPLAYSIZE]; char obuf[DISPLAYSIZE];
faction *f; faction *f;
char rname[32]; char rname[32];
static const struct race * rc_demon; static const struct race *rc_demon, *rc_smurf;
static int config; static int config;
if (rc_changed(&config)) { if (rc_changed(&config)) {
rc_demon = get_race(RC_DAEMON); rc_demon = get_race(RC_DAEMON);
rc_smurf = rc_find("smurf");
} }
READ_INT(data->store, &n); READ_INT(data->store, &n);
@ -529,11 +530,18 @@ unit *read_unit(gamedata *data)
} }
read_attribs(data, &u->attribs, u); read_attribs(data, &u->attribs, u);
if (rc_demon) { if (rc_demon) {
if (u_race(u) == rc_demon) { const struct race *rc = u_race(u);
if (rc == rc_smurf) {
if (!u->attribs) {
log_error("%s was a %s in a %s faction", unitname(u), rc->_name, u->faction->race->_name);
u->_race = u->faction->race;
}
}
if (rc == rc_demon) {
if (data->version < FIX_SHAPESHIFT_VERSION) { if (data->version < FIX_SHAPESHIFT_VERSION) {
const char* zRace = get_racename(u->attribs); const char* zRace = get_racename(u->attribs);
if (zRace) { if (zRace) {
const struct race* rc = rc_find(zRace); rc = rc_find(zRace);
if (rc) { if (rc) {
set_racename(&u->attribs, NULL); set_racename(&u->attribs, NULL);
u->irace = rc; u->irace = rc;