From 9b7d4adda5e75e3d4729542c54f1fdf3922547bb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 6 Dec 2015 20:48:22 +0100 Subject: [PATCH] https://bugs.eressea.de/view.php?id=2173#c6397 by request: magic resistance never higher than 90%, so highly skilled monsters cannot become completely invincible to magic. --- src/battle.test.c | 3 ++- src/magic.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/battle.test.c b/src/battle.test.c index be058913f..02fe195ba 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -330,8 +330,9 @@ static void test_magic_resistance(CuTest *tc) CuAssertDblEquals_Msg(tc, "race reduction", 0.4, magres, 0.01); rc->magres = 1.5; /* should not cause negative damage multiplier */ + CuAssertDblEquals_Msg(tc, "magic resistance is never > 0.9", 0.9, magic_resistance(du), 0.01); calculate_armor(dt, 0, 0, &magres); - CuAssertDblEquals_Msg(tc, "damage reduction is never < 0", 0.0, magres, 0.01); + CuAssertDblEquals_Msg(tc, "damage reduction is never < 0.1", 0.1, magres, 0.01); free_battle(b); test_cleanup(); diff --git a/src/magic.c b/src/magic.c index d65685aff..752b0bcd7 100644 --- a/src/magic.c +++ b/src/magic.c @@ -1177,7 +1177,8 @@ double magic_resistance(unit * target) if (btype) probability += btype->magresbonus * 0.01; } - return probability; + + return (probability<0.9) ? probability : 0.9; } /* ------------------------------------------------------------- */