fix issue #1362 - carrying Mitre of Holiness
Issue reported by elunna: the definition of the Mitre of Holiness specifies that carrying it should confer fire resistance but that didn't work. The Mitre's definition (added in 3.1.0) has always included that, but such a capability had never been implemented. Wearing it didn't confer fire resistance either--its definition doesn't bother to specify a 'defend' attribute since the 'carry' one should cover that. This adds carrying capability for damage types fire, cold, sleep, disintegration, electrity, poison, acid, and petrification. Fire is still specified by the Mitre; none of the others are currently used. Fixes #1362
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 mondata.c $NHDT-Date: 1711620615 2024/03/28 10:10:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.132 $ */
|
||||
/* NetHack 3.7 mondata.c $NHDT-Date: 1738638877 2025/02/03 19:14:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.140 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -123,6 +123,65 @@ defended(struct monst *mon, int adtyp)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* returns True if monster resists particular elemental damage; mostly used
|
||||
in order to check effects of carried artifacts */
|
||||
boolean
|
||||
Resists_Elem(struct monst *mon, int restyp)
|
||||
{
|
||||
struct obj *o;
|
||||
long slotmask;
|
||||
boolean is_you = (mon == &gy.youmonst);
|
||||
int u_resist, dmgtyp = 0, proptyp = 0;
|
||||
|
||||
switch (restyp) {
|
||||
case MR_FIRE:
|
||||
case MR_COLD:
|
||||
case MR_SLEEP:
|
||||
case MR_DISINT:
|
||||
case MR_ELEC:
|
||||
case MR_POISON:
|
||||
case MR_ACID:
|
||||
case MR_STONE:
|
||||
dmgtyp = restyp;
|
||||
proptyp = dmgtyp - 1; /* valid for dmgtyp|restyp 2..9 */
|
||||
break;
|
||||
|
||||
/* accept these, but we expect callers to use their routines directly */
|
||||
case ANTIMAGIC:
|
||||
return resists_magm(mon);
|
||||
case DRAIN_RES:
|
||||
return resists_drli(mon);
|
||||
case BLND_RES:
|
||||
return resists_blnd(mon);
|
||||
|
||||
default:
|
||||
impossible("Resists_Elem(%d), unexpected resistance type", restyp);
|
||||
return FALSE;
|
||||
}
|
||||
u_resist = u.uprops[restyp].intrinsic || u.uprops[restyp].extrinsic;
|
||||
|
||||
if (is_you ? u_resist : ((mon_resistancebits(mon) & restyp) != 0))
|
||||
return TRUE;
|
||||
/* check for resistance granted by wielded weapon */
|
||||
o = is_you ? uwep : MON_WEP(mon);
|
||||
if (o && o->oartifact && defends(dmgtyp, o))
|
||||
return TRUE;
|
||||
/* check for resistance granted by worn or carried items */
|
||||
o = is_you ? gi.invent : mon->minvent;
|
||||
slotmask = W_ARMOR | W_ACCESSORY;
|
||||
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 & slotmask) != 0L
|
||||
&& objects[o->otyp].oc_oprop == restyp)
|
||||
|| (o->oartifact && defends_when_carried(dmgtyp, o)))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* returns True if monster is drain-life resistant */
|
||||
boolean
|
||||
resists_drli(struct monst *mon)
|
||||
|
||||
Reference in New Issue
Block a user