fix #H8215 - monster intrinsics from worn gear

Fixes #177

The monst struct has 'mintrinsics' field which attempts to handle
both mon->data->mresists and extrinsics supplied by worn armor, but
polymorph/shape-change was clobbering the extrinsics side of things.
Potentially fixing that by changing newcham() to use set_mon_data(...,1)
instead of (...,0) solved that but exposed two other bugs.  Intrinsics
from the old form carried over to the new form along with extrinsics
from worn armor, and update_mon_intrinsics() for armor being destroyed
or dropped only worked as intended if the armor->owornmask was cleared
beforehand--some places were clearing it after, so extrinsics from worn
gear could persist even after that gear was gone.

So, fixing the set_mon_data() call in newcham() was a no go.  This
fixes update_mon_intrinsics() and adopts the suggested code from
github pull request #177 to have mon->mintrinsics only handle worn
gear instead of trying to overload innate intrinsics with that.  This
is a superset of that; the flag argument to set_mon_data() is gone
and mon->mintrinsics has been renamed mon->mextrinsics.  (The routine
update_mon_intrinsics() ought to be renamed too, but I didn't do that.)
This commit is contained in:
PatR
2019-02-18 13:17:14 -08:00
parent 6b54456c45
commit a6ff7210be
12 changed files with 57 additions and 59 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1549921169 2019/02/11 21:39:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.693 $ */
/* NetHack 3.6 extern.h $NHDT-Date: 1550524545 2019/02/18 21:15:45 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.694 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1437,7 +1437,7 @@ E boolean FDECL(vamp_stone, (struct monst *));
/* ### mondata.c ### */
E void FDECL(set_mon_data, (struct monst *, struct permonst *, int));
E void FDECL(set_mon_data, (struct monst *, struct permonst *));
E struct attack *FDECL(attacktype_fordmg, (struct permonst *, int, int));
E boolean FDECL(attacktype, (struct permonst *, int));
E boolean FDECL(noattacks, (struct permonst *));

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mondata.h $NHDT-Date: 1548209737 2019/01/23 02:15:37 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.36 $ */
/* NetHack 3.6 mondata.h $NHDT-Date: 1550524558 2019/02/18 21:15:58 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.37 $ */
/* Copyright (c) 1989 Mike Threepoint */
/* NetHack may be freely redistributed. See license for details. */
@@ -10,14 +10,22 @@
#define pm_resistance(ptr, typ) (((ptr)->mresists & (typ)) != 0)
#define resists_fire(mon) (((mon)->mintrinsics & MR_FIRE) != 0)
#define resists_cold(mon) (((mon)->mintrinsics & MR_COLD) != 0)
#define resists_sleep(mon) (((mon)->mintrinsics & MR_SLEEP) != 0)
#define resists_disint(mon) (((mon)->mintrinsics & MR_DISINT) != 0)
#define resists_elec(mon) (((mon)->mintrinsics & MR_ELEC) != 0)
#define resists_poison(mon) (((mon)->mintrinsics & MR_POISON) != 0)
#define resists_acid(mon) (((mon)->mintrinsics & MR_ACID) != 0)
#define resists_ston(mon) (((mon)->mintrinsics & MR_STONE) != 0)
#define resists_fire(mon) \
((((mon)->data->mresists | (mon)->mextrinsics) & MR_FIRE) != 0)
#define resists_cold(mon) \
((((mon)->data->mresists | (mon)->mextrinsics) & MR_COLD) != 0)
#define resists_sleep(mon) \
((((mon)->data->mresists | (mon)->mextrinsics) & MR_SLEEP) != 0)
#define resists_disint(mon) \
((((mon)->data->mresists | (mon)->mextrinsics) & MR_DISINT) != 0)
#define resists_elec(mon) \
((((mon)->data->mresists | (mon)->mextrinsics) & MR_ELEC) != 0)
#define resists_poison(mon) \
((((mon)->data->mresists | (mon)->mextrinsics) & MR_POISON) != 0)
#define resists_acid(mon) \
((((mon)->data->mresists | (mon)->mextrinsics) & MR_ACID) != 0)
#define resists_ston(mon) \
((((mon)->data->mresists | (mon)->mextrinsics) & MR_STONE) != 0)
#define is_lminion(mon) \
(is_minion((mon)->data) && mon_aligntyp(mon) == A_LAWFUL)

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 monst.h $NHDT-Date: 1547428769 2019/01/14 01:19:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.27 $ */
/* NetHack 3.6 monst.h $NHDT-Date: 1550524559 2019/02/18 21:15:59 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.28 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2016. */
/* NetHack may be freely redistributed. See license for details. */
@@ -70,7 +70,7 @@ struct monst {
uchar m_ap_type; /* what mappearance is describing, m_ap_types */
schar mtame; /* level of tameness, implies peaceful */
unsigned short mintrinsics; /* low 8 correspond to mresists */
unsigned short mextrinsics; /* low 8 correspond to mresists */
int mspec_used; /* monster's special ability attack timeout */
Bitfield(female, 1); /* is female */