diff --git a/src/kernel/race.c b/src/kernel/race.c index 0e9371e39..4dc347751 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -48,6 +48,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include /* attrib includes */ +#include #include /* libc includes */ @@ -290,10 +291,17 @@ double rc_maxaura(const race *rc) { return rc->maxaura / 100.0; } -int rc_armor_bonus(const race *rc) { +int rc_armor_bonus(const race *rc) +{ return get_param_int(rc->parameters, "armor.stamina", 0); } +int rc_scare(const struct race *rc) +{ + attrib *a = a_find(rc->attribs, &at_scare); + return a ? a->data.i : 0; +} + int rc_migrants_formula(const race *rc) { return (rc->flags&RCF_MIGRANTS) ? MIGRANTS_LOG10 : MIGRANTS_NONE; diff --git a/src/kernel/race.h b/src/kernel/race.h index b500ed6a1..6a4feb269 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -189,6 +189,7 @@ extern "C" { double rc_magres(const struct race *rc); double rc_maxaura(const struct race *rc); int rc_armor_bonus(const struct race *rc); + int rc_scare(const struct race *rc); #define MIGRANTS_NONE 0 #define MIGRANTS_LOG10 1 diff --git a/src/monsters.c b/src/monsters.c index bba1cbd50..a7678c701 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -31,7 +31,6 @@ #include "study.h" /* attributes includes */ -#include #include #include @@ -1013,11 +1012,11 @@ static void eaten_by_monster(unit * u) int horse = -1; const resource_type *rhorse = get_resourcetype(R_HORSE); const race *rc = u_race(u); - attrib *a; + int scare; - a = a_find(rc->attribs, &at_scare); - if (a) { - n = rng_int() & a->data.i * u->number; + scare = rc_scare(rc); + if (scare>0) { + n = rng_int() % scare * u->number; } else { n = rng_int() % (u->number / 20 + 1); horse = 0; @@ -1093,10 +1092,11 @@ static void scared_by_monster(unit * u) { int n; const race *rc = u_race(u); - attrib *a; - a = a_find(rc->attribs, &at_scare); - if (a) { - n = rng_int() & a->data.i * u->number; + int scare; + + scare = rc_scare(rc); + if (scare>0) { + n = rng_int() % scare * u->number; } else { n = rng_int() % (u->number / 4 + 1); }