fix github issue #503 - bad Magic Key logic

When unlocking a trapped container, any blessed key was behaving
as if it was the rogue's Master Key of Thievery:  detecting the
trap, asking whether to untrap, and always succeeding if player
responds with yes.  The intended behavior is that the Master Key
will behave that way for a rogue if not cursed and for non-rogue
if blessed; it wasn't supposed to affect ordinary keys at all.

Fixes #503
This commit is contained in:
PatR
2021-05-06 11:42:14 -07:00
parent 9ba4b6ad4d
commit 86120d4574
2 changed files with 11 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.522 $ $NHDT-Date: 1620076691 2021/05/03 21:18:11 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.524 $ $NHDT-Date: 1620326528 2021/05/06 18:42:08 $
General Fixes and Modified Features
-----------------------------------
@@ -497,6 +497,8 @@ change "killed by <a foo>, while {paralyzed|frozen} by <a foo>" into
offended an unseen demon lord
Entering a special room, only wake up the monsters in that room instead of
doing a level-wide wake-up
any blessed key was behaving as if was the rogue's Master Key when unlocking
a trapped chest or box
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 artifact.c $NHDT-Date: 1606765210 2020/11/30 19:40:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.161 $ */
/* NetHack 3.7 artifact.c $NHDT-Date: 1620326528 2021/05/06 18:42:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.167 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2151,11 +2151,13 @@ boolean
is_magic_key(struct monst *mon, /* if null, non-rogue is assumed */
struct obj *obj)
{
if (((obj && obj->oartifact == ART_MASTER_KEY_OF_THIEVERY)
&& ((mon == &g.youmonst) ? Role_if(PM_ROGUE)
: (mon && mon->data == &mons[PM_ROGUE])))
? !obj->cursed : obj->blessed)
return TRUE;
if (obj && obj->oartifact == ART_MASTER_KEY_OF_THIEVERY) {
if ((mon == &g.youmonst) ? Role_if(PM_ROGUE)
: (mon && mon->data == &mons[PM_ROGUE]))
return !obj->cursed; /* a rogue; non-cursed suffices for magic */
/* not a rogue; key must be blessed to behave as a magic one */
return obj->blessed;
}
return FALSE;
}