From d4310b1b5177618306933ec00c81f5caa69b0b99 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 May 2011 15:01:09 -0700 Subject: [PATCH] bad magic resistance zone implemented. this fixes http://bugs.eressea.de/view.php?id=1854 --- src/kernel/magic.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/kernel/magic.c b/src/kernel/magic.c index fdc206731..9cad61cb1 100644 --- a/src/kernel/magic.c +++ b/src/kernel/magic.c @@ -1128,6 +1128,7 @@ double magic_resistance(unit * target) attrib *a; curse *c; int n; + const curse_type * ct_goodresist = 0, * ct_badresist = 0; /* Bonus durch Rassenmagieresistenz */ double probability = target->race->magres; @@ -1149,21 +1150,24 @@ double magic_resistance(unit * target) /* Auswirkungen von Zaubern auf der Region */ a = a_find(target->region->attribs, &at_curse); + if (a) { + ct_badresist = ct_find("badmagicresistancezone"); + ct_goodresist = ct_find("goodmagicresistancezone"); + } while (a && a->type == &at_curse) { curse *c = (curse *) a->data.v; unit *mage = c->magician; if (mage != NULL) { - if (c->type == ct_find("goodmagicresistancezone")) { + if (ct_goodresist && c->type == ct_goodresist) { if (alliedunit(mage, target->faction, HELP_GUARD)) { probability += curse_geteffect(c) * 0.01; - break; + ct_goodresist = 0; /* only one effect per region */ } - } else if (c->type == ct_find("badmagicresistancezone")) { + } else if (ct_badresist && c->type == ct_badresist) { if (alliedunit(mage, target->faction, HELP_GUARD)) { - /* TODO: hier sollte doch sicher was passieren? */ - a = a->next; - continue; + probability -= curse_geteffect(c) * 0.01; + ct_badresist = 0; /* only one effect per region */ } } }