From 95729beb4a6bb5a0fa4a7e277a40c114e0767d97 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sat, 25 Nov 2006 04:57:33 +0000 Subject: [PATCH] inappropriate resistances Noticed when examining resists_magm() while working on anti-magic traps: if you were polymorphed, you would be granted magic resistance by keeping a cloak of same or gray dragon scales/mail in your quiver slot, your alternate weapon slot, or main weapon slot (ie, by wielding it). And you obtained light-based blindness resistance regardless of whether you were polymorphed if you carried a potion of blindness in any of those slots. --- doc/fixes34.4 | 5 +++++ src/mondata.c | 25 ++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index 9d7bad83e..0448c2643 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -272,6 +272,11 @@ prevent very large number of objects in # inventory slot from causing !fixinv config was using arbitrary characters instead of # for invent overflow don't report death by petrification if cockatrice kills hero via HP loss Riders are immune to green slime +wielding a cloak of magic resistance or gray dragon scales, or carrying one in + alternate weapon or quiver inventory slot, conferred magic resistance + to polymorphed hero +wielding a potion of blindness or carrying one in alternate weapon or quiver + slot conferred resistance against light-based blindness to any hero Platform- and/or Interface-Specific Fixes diff --git a/src/mondata.c b/src/mondata.c index dfbce3d55..e4d34d9ba 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)mondata.c 3.5 2006/08/26 */ +/* SCCS Id: @(#)mondata.c 3.5 2006/11/24 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -91,6 +91,8 @@ resists_magm(mon) /* TRUE if monster is magic-missile resistant */ struct monst *mon; { struct permonst *ptr = mon->data; + boolean is_you = (mon == &youmonst); + long slotmask; struct obj *o; /* as of 3.2.0: gray dragons, Angels, Oracle, Yeenoghu */ @@ -98,13 +100,19 @@ struct monst *mon; dmgtype(ptr, AD_RBRE)) /* Chromatic Dragon */ return TRUE; /* check for magic resistance granted by wielded weapon */ - o = (mon == &youmonst) ? uwep : MON_WEP(mon); + o = is_you ? uwep : MON_WEP(mon); if (o && o->oartifact && defends(AD_MAGM, o)) return TRUE; /* check for magic resistance granted by worn or carried items */ - o = (mon == &youmonst) ? invent : mon->minvent; + o = is_you ? invent : mon->minvent; + slotmask = W_ARMOR | W_RING | W_AMUL | W_TOOL; + if (!is_you || /* assumes monsters don't wield non-weapons */ + uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))) + slotmask |= W_WEP; + if (is_you && u.twoweap) slotmask |= W_SWAPWEP; for ( ; o; o = o->nobj) - if ((o->owornmask && objects[o->otyp].oc_oprop == ANTIMAGIC) || + if (((o->owornmask & slotmask) != 0L && + objects[o->otyp].oc_oprop == ANTIMAGIC) || (o->oartifact && protects(AD_MAGM, o))) return TRUE; return FALSE; @@ -117,6 +125,7 @@ struct monst *mon; { struct permonst *ptr = mon->data; boolean is_you = (mon == &youmonst); + long slotmask; struct obj *o; if (is_you ? (Blind || Unaware) : @@ -133,8 +142,14 @@ struct monst *mon; if (o && o->oartifact && defends(AD_BLND, o)) return TRUE; o = is_you ? invent : mon->minvent; + slotmask = W_ARMOR | W_RING | W_AMUL | W_TOOL; + if (!is_you || /* assumes monsters don't wield non-weapons */ + uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))) + slotmask |= W_WEP; + if (is_you && u.twoweap) slotmask |= W_SWAPWEP; for ( ; o; o = o->nobj) - if ((o->owornmask && objects[o->otyp].oc_oprop == BLINDED) || + if (((o->owornmask & slotmask) != 0L && + objects[o->otyp].oc_oprop == BLINDED) || (o->oartifact && protects(AD_BLND, o))) return TRUE; return FALSE;