fix #K2154 - monster wearing alchemy smock

For the hero, a worn alchemy smock confers both poison resistance
and acid resistance.  For monsters, it was only conferring poison
resistance.  Change ut to add acid resistance too.
This commit is contained in:
PatR
2021-07-28 13:45:56 -07:00
parent 19599fa751
commit 0891ef4e22
2 changed files with 48 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.609 $ $NHDT-Date: 1627414178 2021/07/27 19:29:38 $ NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.610 $ $NHDT-Date: 1627505147 2021/07/28 20:45:47 $
General Fixes and Modified Features General Fixes and Modified Features
----------------------------------- -----------------------------------
@@ -576,6 +576,8 @@ some monsters should not have been scared of bugle playing
monsters that drowned would never leave a corpse (holdover from decades ago monsters that drowned would never leave a corpse (holdover from decades ago
when it wasn't possible to recover anything from a water location) when it wasn't possible to recover anything from a water location)
give alternate message if hero is blind when throne gives "your vision clears" give alternate message if hero is blind when throne gives "your vision clears"
monster wearing an alchemy smock was only getting poison resistance from it,
not acid resistance; give both properties, just like for hero
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository Fixes to 3.7.0-x Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 worn.c $NHDT-Date: 1606919259 2020/12/02 14:27:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ */ /* NetHack 3.7 worn.c $NHDT-Date: 1627505148 2021/07/28 20:45:48 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.77 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -333,6 +333,16 @@ mon_adjust_speed(struct monst *mon,
} }
} }
/* alchemy smock confers two properites, poison and acid resistance
but objects[ALCHEMY_SMOCK].oc_oprop can only describe one of them;
if it is poison resistance, alternate property is acid resistance;
if someone changes it to acid resistance, alt becomes posion resist;
if someone changes it to hallucination resistance, all bets are off */
#define altprop(o) \
(((o)->otyp == ALCHEMY_SMOCK) \
? (POISON_RES + ACID_RES - objects[(o)->otyp].oc_oprop) \
: 0)
/* armor put on or taken off; might be magical variety /* armor put on or taken off; might be magical variety
[TODO: rename to 'update_mon_extrinsics()' and change all callers...] */ [TODO: rename to 'update_mon_extrinsics()' and change all callers...] */
void void
@@ -342,12 +352,14 @@ update_mon_intrinsics(struct monst *mon, struct obj *obj, boolean on,
int unseen; int unseen;
uchar mask; uchar mask;
struct obj *otmp; struct obj *otmp;
int which = (int) objects[obj->otyp].oc_oprop; int which = (int) objects[obj->otyp].oc_oprop,
altwhich = altprop(obj);
unseen = !canseemon(mon); unseen = !canseemon(mon);
if (!which) if (!which)
goto maybe_blocks; goto maybe_blocks;
again:
if (on) { if (on) {
switch (which) { switch (which) {
case INVIS: case INVIS:
@@ -409,14 +421,30 @@ update_mon_intrinsics(struct monst *mon, struct obj *obj, boolean on,
case POISON_RES: case POISON_RES:
case ACID_RES: case ACID_RES:
case STONE_RES: case STONE_RES:
/*
* Update monster's extrinsics (for worn objects only;
* 'obj' itself might still be worn or already unworn).
*
* If an alchemy smock is being taken off, this code will
* be run twice (via 'goto again') and other worn gear
* gets tested for conferring poison resistance on the
* first pass and acid resistance on the second.
*
* If some other item is being taken off, there will be
* only one pass but a worn alchemy smock will be an
* alternate source for either of those two resistances.
*/
mask = (uchar) (1 << (which - 1)); mask = (uchar) (1 << (which - 1));
/* update monster's extrinsics (for worn objects only; for (otmp = mon->minvent; otmp; otmp = otmp->nobj) {
'obj' itself might still be worn or already unworn) */ if (otmp == obj || !otmp->owornmask)
for (otmp = mon->minvent; otmp; otmp = otmp->nobj) continue;
if (otmp != obj if ((int) objects[otmp->otyp].oc_oprop == which)
&& otmp->owornmask
&& (int) objects[otmp->otyp].oc_oprop == which)
break; break;
/* check whether 'otmp' confers target property as an extra
one rather than as the one specified for it in objects[] */
if (altprop(otmp) == which)
break;
}
if (!otmp) if (!otmp)
mon->mextrinsics &= ~((unsigned short) mask); mon->mextrinsics &= ~((unsigned short) mask);
break; break;
@@ -425,6 +453,13 @@ update_mon_intrinsics(struct monst *mon, struct obj *obj, boolean on,
} }
} }
/* worn alchemy smock/apron confers both poison resistance and acid
resistance to the hero so do likewise for monster who wears one */
if (altwhich && which != altwhich) {
which = altwhich;
goto again;
}
maybe_blocks: maybe_blocks:
/* obj->owornmask has been cleared by this point, so we can't use it. /* obj->owornmask has been cleared by this point, so we can't use it.
However, since monsters don't wield armor, we don't have to guard However, since monsters don't wield armor, we don't have to guard
@@ -446,6 +481,8 @@ update_mon_intrinsics(struct monst *mon, struct obj *obj, boolean on,
newsym(mon->mx, mon->my); newsym(mon->mx, mon->my);
} }
#undef altprop
int int
find_mac(struct monst *mon) find_mac(struct monst *mon)
{ {