still more Master Key of Thievery
Make #untrap while carrying the non-cursed (for rogues) or blessed (for non-rogues) Key work the same as #invoke has been doing (without regard to its bless/curse state): when used on trapped door or chest, that trap will always be found and disarming it will always succeed. It should work when carried by monsters too: if they try to open a trapped door while carrying the Key (must be blessed since they're not rogues) the trap will be automatically disarmed. (Caveat: that hasn't been adequately tested.) TODO (maybe...): change the #invoke property to detect unseen/secret door detection instead of #untrap. The latter isn't completely redundant; it works when the Key is cursed. But quest artifacts strongly resist becoming cursed so that isn't a particularly useful distinction. Also, trap hints when wielding the Key without gloves didn't notice adjacent door and chest traps. Now it does. And the behavior is slightly different: known traps covered by objects or monsters are treated like unknown traps as far as the hot/cold hints go.
This commit is contained in:
100
src/artifact.c
100
src/artifact.c
@@ -2055,36 +2055,102 @@ int dropflag; /* 0==don't drop, 1==drop all, 2==drop weapon */
|
||||
static int mkot_trap_warn_count = 0;
|
||||
|
||||
STATIC_OVL int
|
||||
count_surround_traps(x,y)
|
||||
int x,y;
|
||||
count_surround_traps(x, y)
|
||||
int x, y;
|
||||
{
|
||||
int dx, dy, ret = 0;
|
||||
struct rm *levp;
|
||||
struct obj *otmp;
|
||||
struct trap *ttmp;
|
||||
int dx, dy, glyph, ret = 0;
|
||||
|
||||
for (dx = x-1; dx < x+2; dx++)
|
||||
for (dy = y-1; dy < y+2; dy++)
|
||||
if (isok(dx,dy) && (ttmp = t_at(dx,dy))
|
||||
&& !ttmp->tseen)
|
||||
ret++;
|
||||
for (dx = x - 1; dx < x + 2; ++dx)
|
||||
for (dy = y - 1; dy < y + 2; ++dy) {
|
||||
if (!isok(dx, dy))
|
||||
continue;
|
||||
/* If a trap is shown here, don't count it; the hero
|
||||
* should be expecting it. But if there is a trap here
|
||||
* that's not shown, either undiscovered or covered by
|
||||
* something, do count it.
|
||||
*/
|
||||
glyph = glyph_at(dx, dy);
|
||||
if (glyph_is_trap(glyph))
|
||||
continue;
|
||||
if ((ttmp = t_at(dx, dy)) != 0) {
|
||||
++ret;
|
||||
continue;
|
||||
}
|
||||
levp = &levl[dx][dy];
|
||||
if (IS_DOOR(levp->typ) && (levp->doormask & D_TRAPPED) != 0) {
|
||||
++ret;
|
||||
continue;
|
||||
}
|
||||
for (otmp = level.objects[dx][dy]; otmp; otmp = otmp->nexthere)
|
||||
if (Is_container(otmp) && otmp->otrapped) {
|
||||
++ret; /* we're counting locations, so just */
|
||||
break; /* count the first one in a pile */
|
||||
}
|
||||
}
|
||||
/*
|
||||
* [Shouldn't we also check inventory for a trapped container?
|
||||
* Even if its trap has already been found, there's no 'tknown'
|
||||
* flag to help hero remember that so we have nothing comparable
|
||||
* to a shown glyph to justify skipping it.]
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* sense adjacent traps if wielding MKoT without wearing gloves */
|
||||
void
|
||||
mkot_trap_warn()
|
||||
{
|
||||
if (!uarmg && uwep
|
||||
&& uwep->oartifact == ART_MASTER_KEY_OF_THIEVERY) {
|
||||
const char *const heat[7] = { "cold", "slightly warm", "warm",
|
||||
"very warm", "hot", "very hot",
|
||||
"like fire" };
|
||||
int ntraps = count_surround_traps(u.ux, u.uy);
|
||||
static const char *const heat[7] = {
|
||||
"cool", "slightly warm", "warm", "very warm",
|
||||
"hot", "very hot", "like fire"
|
||||
};
|
||||
|
||||
if (ntraps != mkot_trap_warn_count)
|
||||
pline_The("key feels %s%c", heat[(ntraps > 6) ? 6 : ntraps],
|
||||
ntraps > 3 ? '!' : '.');
|
||||
if (!uarmg && uwep && uwep->oartifact == ART_MASTER_KEY_OF_THIEVERY) {
|
||||
int idx, ntraps = count_surround_traps(u.ux, u.uy);
|
||||
|
||||
if (ntraps != mkot_trap_warn_count) {
|
||||
idx = min(ntraps, SIZE(heat) - 1);
|
||||
pline_The("Key feels %s%c", heat[idx], (ntraps > 3) ? '!' : '.');
|
||||
}
|
||||
mkot_trap_warn_count = ntraps;
|
||||
} else
|
||||
mkot_trap_warn_count = 0;
|
||||
}
|
||||
|
||||
/* Master Key is magic key if its bless/curse state meets our criteria:
|
||||
not cursed for rogues or blessed for non-rogues */
|
||||
boolean
|
||||
is_magic_key(mon, obj)
|
||||
struct monst *mon; /* if null, non-rogue is assumed */
|
||||
struct obj *obj;
|
||||
{
|
||||
if (((obj && obj->oartifact == ART_MASTER_KEY_OF_THIEVERY)
|
||||
&& ((mon == &youmonst) ? Role_if(PM_ROGUE)
|
||||
: (mon && mon->data == &mons[PM_ROGUE])))
|
||||
? !obj->cursed : obj->blessed)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* figure out whether 'mon' (usually youmonst) is carrying the magic key */
|
||||
struct obj *
|
||||
has_magic_key(mon)
|
||||
struct monst *mon; /* if null, hero assumed */
|
||||
{
|
||||
struct obj *o;
|
||||
short key = artilist[ART_MASTER_KEY_OF_THIEVERY].otyp;
|
||||
|
||||
if (!mon)
|
||||
mon = &youmonst;
|
||||
for (o = ((mon == &youmonst) ? invent : mon->minvent); o;
|
||||
o = nxtobj(o, key, FALSE)) {
|
||||
if (is_magic_key(mon, o))
|
||||
return o;
|
||||
}
|
||||
return (struct obj *) 0;
|
||||
}
|
||||
|
||||
/*artifact.c*/
|
||||
|
||||
Reference in New Issue
Block a user