begin removing orcification

This commit is contained in:
Enno Rehling 2016-11-13 17:06:28 +01:00
parent 7557b97dee
commit 8b0ee77bda
2 changed files with 20 additions and 12 deletions

View file

@ -396,9 +396,14 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord)
message * disband_men(int n, unit * u, struct order *ord) { message * disband_men(int n, unit * u, struct order *ord) {
message * msg; message * msg;
static const race *rc_snotling;
static int rccache;
// TODO: cache RC_SNOTLING if (rc_changed(&rccache)) {
if (u_race(u) == get_race(RC_SNOTLING)) { rc_snotling = get_race(RC_SNOTLING);
}
if (u_race(u) == rc_snotling) {
/* snotlings may not be given to the peasants. */ /* snotlings may not be given to the peasants. */
return msg_error(u, ord, 307); return msg_error(u, ord, 307);
} }
@ -408,7 +413,7 @@ message * disband_men(int n, unit * u, struct order *ord) {
transfermen(u, NULL, n); transfermen(u, NULL, n);
//TODO: is ORCIFICATION still working? snotlings cannot be given to peasants //TODO: is ORCIFICATION still working? snotlings cannot be given to peasants
#ifdef ORCIFICATION #ifdef ORCIFICATION
if (u_race(u) == get_race(RC_SNOTLING) && !fval(u->region, RF_ORCIFIED)) { if (u_race(u) == rc_snotling && !fval(u->region, RF_ORCIFIED)) {
attrib *a = a_find(u->region->attribs, &at_orcification); attrib *a = a_find(u->region->attribs, &at_orcification);
if (!a) { if (!a) {
a = a_add(&u->region->attribs, a_new(&at_orcification)); a = a_add(&u->region->attribs, a_new(&at_orcification));

View file

@ -827,19 +827,22 @@ void randomevents(void)
else { else {
attrib *a = a_find(r->attribs, &at_orcification); attrib *a = a_find(r->attribs, &at_orcification);
if (a != NULL) { if (a != NULL) {
double probability = 0.0; if (rpeasants(r) <= 0) {
if (rpeasants(r) <= 0)
continue;
probability = a->data.i / (double)rpeasants(r);
if (chance(probability)) {
fset(r, RF_ORCIFIED);
a_remove(&r->attribs, a); a_remove(&r->attribs, a);
ADDMSG(&r->msgs, msg_message("orcified", "region", r));
} }
else { else {
a->data.i -= _max(10, a->data.i / 10); double probability = 0.0;
if (a->data.i <= 0) probability = a->data.i / (double)rpeasants(r);
if (chance(probability)) {
fset(r, RF_ORCIFIED);
a_remove(&r->attribs, a); a_remove(&r->attribs, a);
ADDMSG(&r->msgs, msg_message("orcified", "region", r));
}
else {
a->data.i -= _max(10, a->data.i / 10);
if (a->data.i <= 0)
a_remove(&r->attribs, a);
}
} }
} }
} }