Merge pull request #798 from ennorehling/develop

version 3.17, final preview
This commit is contained in:
Enno Rehling 2018-08-29 17:54:28 +02:00 committed by GitHub
commit 65a13d10ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1016,37 +1016,42 @@ static void eaten_by_monster(unit * u)
{ {
/* adjustment for smaller worlds */ /* adjustment for smaller worlds */
double multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0; double multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0;
int n = 0;
int horse = -1;
const resource_type *rhorse = get_resourcetype(R_HORSE); const resource_type *rhorse = get_resourcetype(R_HORSE);
const race *rc = u_race(u); const race *rc = u_race(u);
int scare; int p = rpeasants(u->region);
scare = rc_scare(rc); if (p > 0) {
if (scare>0) { int horse = -1;
int scare = rc_scare(rc);
int n = 0;
if (scare > 0) {
n = rng_int() % scare * u->number; n = rng_int() % scare * u->number;
} else { }
else {
n = rng_int() % (u->number / 20 + 1); n = rng_int() % (u->number / 20 + 1);
horse = 0; horse = 0;
} }
horse = horse ? i_get(u->items, rhorse->itype) : 0; horse = horse ? i_get(u->items, rhorse->itype) : 0;
if (horse > 0) {
i_change(&u->items, rhorse->itype, -horse);
ADDMSG(&u->region->msgs, msg_message("eathorse", "unit amount", u, horse));
}
n = (int)(n * multi); n = (int)(n * multi);
if (n > 0) { if (n > 0) {
n = lovar(n); n = lovar(n);
if (n > 0) {
int p = rpeasants(u->region);
if (p < n) n = p; if (p < n) n = p;
if (n > 0) {
if (n > 0) {
deathcounts(u->region, n); deathcounts(u->region, n);
rsetpeasants(u->region, rpeasants(u->region) - n); rsetpeasants(u->region, rpeasants(u->region) - n);
ADDMSG(&u->region->msgs, msg_message("eatpeasants", "unit amount", u, n)); ADDMSG(&u->region->msgs, msg_message("eatpeasants", "unit amount", u, n));
} }
} }
if (horse > 0) { }
i_change(&u->items, rhorse->itype, -horse);
ADDMSG(&u->region->msgs, msg_message("eathorse", "unit amount", u, horse));
} }
} }
@ -1059,12 +1064,14 @@ static void absorbed_by_monster(unit * u)
if (n > 0) { if (n > 0) {
int p = rpeasants(u->region); int p = rpeasants(u->region);
if (p < n) n = p; if (p < n) n = p;
if (n > 0) {
rsetpeasants(u->region, rpeasants(u->region) - n); rsetpeasants(u->region, rpeasants(u->region) - n);
scale_number(u, u->number + n); scale_number(u, u->number + n);
ADDMSG(&u->region->msgs, msg_message("absorbpeasants", ADDMSG(&u->region->msgs, msg_message("absorbpeasants",
"unit race amount", u, u_race(u), n)); "unit race amount", u, u_race(u), n));
} }
} }
}
} }
static int scareaway(region * r, int anzahl) static int scareaway(region * r, int anzahl)