forked from github/server
braineaters outside of astral sapce lose 50% of their innate magic resistance.
This commit is contained in:
parent
e516f2d630
commit
2f70054d2f
3 changed files with 29 additions and 2 deletions
|
@ -1127,8 +1127,13 @@ double magic_resistance(unit * target)
|
|||
curse *c;
|
||||
const curse_type * ct_goodresist = 0, *ct_badresist = 0;
|
||||
const resource_type *rtype;
|
||||
double probability = u_race(target)->magres;
|
||||
const race *rc = u_race(target);
|
||||
double probability = rc->magres;
|
||||
const plane *pl = rplane(target->region);
|
||||
|
||||
if (rc == get_race(RC_HIRNTOETER) && pl!=get_astralplane()) {
|
||||
probability /= 2;
|
||||
}
|
||||
assert(target->number > 0);
|
||||
/* Magier haben einen Resistenzbonus vom Magietalent * 5% */
|
||||
probability += effskill(target, SK_MAGIC, 0) * 0.05;
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
#include "magic.h"
|
||||
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/spellbook.h>
|
||||
#include <kernel/teleport.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/pool.h>
|
||||
#include <quicklist.h>
|
||||
|
@ -402,6 +404,25 @@ void test_multi_cast(CuTest *tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_magic_resistance(CuTest *tc) {
|
||||
unit *u;
|
||||
race *rc;
|
||||
|
||||
test_cleanup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
|
||||
CuAssertDblEquals(tc, rc->magres, magic_resistance(u), 0.01);
|
||||
rc->magres = 1.0;
|
||||
CuAssertDblEquals_Msg(tc, "magic resistance is capped at 0.9", 0.9, magic_resistance(u), 0.01);
|
||||
rc = test_create_race("braineater");
|
||||
rc->magres = 1.0;
|
||||
u_setrace(u, rc);
|
||||
CuAssertDblEquals_Msg(tc, "brain eaters outside astral space have 50% magres", 0.5, magic_resistance(u), 0.01);
|
||||
u->region->_plane = get_astralplane();
|
||||
CuAssertDblEquals_Msg(tc, "brain eaters in astral space have full magres", 0.9, magic_resistance(u), 0.01);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_magic_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
|
@ -417,5 +438,6 @@ CuSuite *get_magic_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_set_main_combatspell);
|
||||
SUITE_ADD_TEST(suite, test_set_post_combatspell);
|
||||
SUITE_ADD_TEST(suite, test_hasspell);
|
||||
SUITE_ADD_TEST(suite, test_magic_resistance);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ extern "C" {
|
|||
struct seen_region *next;
|
||||
struct region *r;
|
||||
seen_t mode;
|
||||
bool disbelieves;
|
||||
bool disbelieves; /* potion of truth */
|
||||
} seen_region;
|
||||
|
||||
struct seen_region **seen_init(void);
|
||||
|
|
Loading…
Reference in a new issue