diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 05e62c36d..34502e489 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -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 diff --git a/include/extern.h b/include/extern.h index 3a55fc4d0..de4003739 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 ### */ diff --git a/src/allmain.c b/src/allmain.c index 170f8b1df..8834c6a60 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -267,6 +267,7 @@ boolean resuming; (void) dosearch0(1); if (Warning) warnreveal(); + mkot_trap_warn(); dosounds(); do_storms(); gethungry(); diff --git a/src/artifact.c b/src/artifact.c index 13e8be981..4fdfc828a 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -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*/