]> granicus.if.org Git - nethack/commitdiff
Master Key of Thievery warns about undetected traps
authorPasi Kallinen <paxed@alt.org>
Thu, 5 Oct 2017 22:14:00 +0000 (01:14 +0300)
committerPasi Kallinen <paxed@alt.org>
Thu, 5 Oct 2017 22:21:06 +0000 (01:21 +0300)
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.

doc/fixes36.1
include/extern.h
src/allmain.c
src/artifact.c

index 05e62c36d5802d014fc07e0ebe58ddecce6ba30f..34502e489e71a29a7f125039224ebc131d4f12a7 100644 (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
index 3a55fc4d0da87b0ca6ee941b14a8ae40068824e9..de4003739e43fa0e56a2423b6a9abf4f001f06ac 100644 (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 ### */
 
index 170f8b1df86975b145d5e4b0a7900102213c40f5..8834c6a6017fe69afe147a322f238857891d650d 100644 (file)
@@ -267,6 +267,7 @@ boolean resuming;
                         (void) dosearch0(1);
                     if (Warning)
                         warnreveal();
+                    mkot_trap_warn();
                     dosounds();
                     do_storms();
                     gethungry();
index 13e8be981f919a9c0ce5ace4fa77f03248d1c771..4fdfc828aa66aa3b325b4e6f9301ec0e3ebae3e2 100644 (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*/