From: PatR Date: Mon, 29 Mar 2021 18:48:24 +0000 (-0700) Subject: "fix" github issue #475 - Trollsbane X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3cd45b7c44c86570be7e8f17b304c2ccd65cc0af;p=nethack "fix" github issue #475 - Trollsbane 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 --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 9301c24ad..8c1dd9813 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 diff --git a/include/extern.h b/include/extern.h index 0211662f2..8b12864aa 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 ### */ diff --git a/src/artifact.c b/src/artifact.c index 1202369e1..47b3ca03d 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -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*/ diff --git a/src/zap.c b/src/zap.c index 8b4694031..a2de95a5d 100644 --- 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)));