Master Key of Thievery warns about undetected traps

If the key is wielded and touching skin (that is, you're not
wearing gloves), it will give heat-related messages like
minesweeper, counting the undetected traps around player.
This commit is contained in:
Pasi Kallinen
2017-10-06 01:14:00 +03:00
parent 605227c0d6
commit 22ad104318
4 changed files with 39 additions and 0 deletions

View File

@@ -355,6 +355,7 @@ wielding Demonbane prevents demons summoning friends
wielding Dragonbane confers reflection
wielding Ogresmasher grants 25 constitution
Cleaver can hit three monsters with one swing
Master Key of Thievery warns about undetected traps if wielded
Elbereth must now be on a square by itself to function
Elbereth now erodes based on attacks by the player, not monsters scared
novels are made of paper, not gold

View File

@@ -92,6 +92,7 @@ E const char *FDECL(glow_color, (int));
E void FDECL(Sting_effects, (int));
E int FDECL(retouch_object, (struct obj **, BOOLEAN_P));
E void FDECL(retouch_equipment, (int));
E void NDECL(mkot_trap_warn);
/* ### attrib.c ### */

View File

@@ -267,6 +267,7 @@ boolean resuming;
(void) dosearch0(1);
if (Warning)
warnreveal();
mkot_trap_warn();
dosounds();
do_storms();
gethungry();

View File

@@ -27,6 +27,7 @@ STATIC_DCL boolean FDECL(Mb_hit, (struct monst * magr, struct monst *mdef,
STATIC_DCL unsigned long FDECL(abil_to_spfx, (long *));
STATIC_DCL uchar FDECL(abil_to_adtyp, (long *));
STATIC_DCL boolean FDECL(untouchable, (struct obj *, BOOLEAN_P));
STATIC_DCL int FDECL(count_surround_traps, (int, int));
/* The amount added to the victim's total hit points to insure that the
victim will be killed even after damage bonus/penalty adjustments.
@@ -2051,4 +2052,39 @@ int dropflag; /* 0==don't drop, 1==drop all, 2==drop weapon */
clear_bypasses(); /* reset upon final exit */
}
static int mkot_trap_warn_count = 0;
STATIC_OVL int
count_surround_traps(x,y)
int x,y;
{
int dx, dy, ret = 0;
struct trap *ttmp;
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++;
return ret;
}
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);
if (ntraps != mkot_trap_warn_count)
pline_The("key feels %s%c", heat[(ntraps > 6) ? 6 : ntraps],
ntraps > 3 ? '!' : '.');
mkot_trap_warn_count = ntraps;
} else
mkot_trap_warn_count = 0;
}
/*artifact.c*/