]> granicus.if.org Git - nethack/commitdiff
"fix" github issue #475 - Trollsbane
authorPatR <rankin@nethack.org>
Mon, 29 Mar 2021 18:48:24 +0000 (11:48 -0700)
committerPatR <rankin@nethack.org>
Mon, 29 Mar 2021 18:48:24 +0000 (11:48 -0700)
Player's pet killed a troll with Trollsbane and the corpse later
revived.  He assumed that killing a troll with Trollsbane is what
prevents troll corpse revival but that is inhibited by the hero
be wielding Trollsbane at the time revival is attempted.

Having killed-by-Trollsbane be the reason for blocking revival
would be much better but looks like a lot of work for something
which was supposed to be a one-line enhancement to an under-used
artifact.  This extends revival inhibition to having anyone on
the level be wielding Trollsbane rather than just the hero.
Not a proper fix but I think it's better than nothing.

Closes #475

doc/fixes37.0
include/extern.h
src/artifact.c
src/zap.c

index 9301c24ad1959cc710e7578a09e0ebd4bf644f67..8c1dd981334e9ea42a5421a8886ff5f8f404d718 100644 (file)
@@ -426,6 +426,8 @@ also show extended command name when showing what a key does in help
 poly'd hero who exploded when attacking a monster didn't wake up other
        monsters in the vicinity; when attacking thin air, hero's explosion
        woke other monsters within different radius than same monster's would
+troll corpse revival was inhibited by hero wielding Trollsbane; do that if
+       anyone on level is wielding it
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 0211662f2dc337b16e1b6b0f387f95f3bb6fa128..8b12864aa0818f6d21672c28609fa2de1487b032 100644 (file)
@@ -98,6 +98,7 @@ extern void retouch_equipment(int);
 extern void mkot_trap_warn(void);
 extern boolean is_magic_key(struct monst *, struct obj *);
 extern struct obj *has_magic_key(struct monst *);
+extern boolean Trollsbane_wielded(void);
 
 /* ### attrib.c ### */
 
index 1202369e1fc32716546139942381ced32bfa03b2..47b3ca03d5f1a6acac964e961044f655e9e5707f 100644 (file)
@@ -2176,4 +2176,25 @@ has_magic_key(struct monst *mon) /* if null, hero assumed */
     return (struct obj *) 0;
 }
 
+/* True if anyone on the level is wielding Trollsbane, False otherwise;
+   used to prevent troll resurrection (FIXME: really ought to be inhibited
+   when killed by Trollsbane rather than whether anyone wields that) */
+boolean
+Trollsbane_wielded(void)
+{
+    struct monst *mtmp;
+    struct obj *mw_tmp;
+
+    if (uwep && uwep->oartifact == ART_TROLLSBANE)
+        return TRUE;
+    for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
+        if (DEADMONSTER(mtmp))
+            continue;
+        if ((mw_tmp = MON_WEP(mtmp)) != 0
+            && mw_tmp->oartifact == ART_TROLLSBANE)
+            return TRUE;
+    }
+    return FALSE;
+}
+
 /*artifact.c*/
index 8b46940315c711993ad344d25af34ac4d3cc7440..a2de95a5d7b5c0f1a27df8f67476a4131b81191c 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -784,8 +784,7 @@ revive(struct obj *corpse, boolean by_hero)
     }
 
     if ((mons[montype].mlet == S_EEL && !IS_POOL(levl[x][y].typ))
-        || (mons[montype].mlet == S_TROLL
-            && uwep && uwep->oartifact == ART_TROLLSBANE)) {
+        || (mons[montype].mlet == S_TROLL && Trollsbane_wielded())) {
         if (by_hero && cansee(x, y))
             pline("%s twitches feebly.",
                 upstart(corpse_xname(corpse, (const char *) 0, CXN_PFX_THE)));