From: PatR Date: Sun, 26 Apr 2020 02:06:18 +0000 (-0700) Subject: fix issue #332 - mon vs mon double hit message X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b9ce40388cc75febe3c73a63431b91f4f95ddfa;p=nethack fix issue #332 - mon vs mon double hit message One monster hitting another with an artifact within the hero's view gave " swings his at ." followed either by " misses ." _or_ the two messages " hits ." and "The hits ." Defer the hits one when Mon1 is using an artifact and only deliver it if there is no artifact hit message. Tested but not exhaustively so.... Fixes #332 --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index e18c633b0..83a70700c 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -163,6 +163,7 @@ if riding or levitating, hero could apply bullwhip downward to pull up things some monster code was checking whether pets or engulfers were eating green slime by checking for green slime corpse instead of glob change light radius of stack of candles to square root +could get redundate "mon hits other-mon" messages when mon wields an artifact Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/mhitm.c b/src/mhitm.c index 18655f46c..26b598298 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -557,6 +557,7 @@ int dieroll; char magr_name[BUFSZ]; Strcpy(magr_name, Monnam(magr)); + buf[0] = '\0'; switch (mattk->aatyp) { case AT_BITE: Sprintf(buf, "%s bites", magr_name); @@ -580,9 +581,12 @@ int dieroll; } /*FALLTHRU*/ default: - Sprintf(buf, "%s hits", magr_name); + if (!weaponhit || !mwep || !mwep->oartifact) + Sprintf(buf, "%s hits", magr_name); + break; } - pline("%s %s.", buf, mon_nam_too(mdef, magr)); + if (*buf) + pline("%s %s.", buf, mon_nam_too(mdef, magr)); if (mon_hates_silver(mdef) && silverhit) { char *mdef_name = mon_nam_too(mdef, magr); @@ -967,8 +971,18 @@ int dieroll; if (tmp < 1) /* is this necessary? mhitu.c has it... */ tmp = 1; if (mwep->oartifact) { - (void) artifact_hit(magr, mdef, mwep, &tmp, dieroll); - if (DEADMONSTER(mdef)) + /* when magr's weapon is an artifact, caller suppressed its + usual 'hit' message in case artifact_hit() delivers one; + now we'll know and might need to deliver skipped message + (note: if there's no message there'll be no auxilliary + damage so the message here isn't coming too late) */ + if (!artifact_hit(magr, mdef, mwep, &tmp, dieroll)) + pline("%s hits %s.", Monnam(magr), + mon_nam_too(mdef, magr)); + /* artifact_hit updates 'tmp' but doesn't inflict any + damage; however, it might cause carried items to be + destroyed and they might do so */ + if (DEADMONSTER(mdef)) return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED)); } diff --git a/src/uhitm.c b/src/uhitm.c index 5c9b9a62a..a317e16cd 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -808,6 +808,9 @@ int dieroll; if (obj->oartifact && artifact_hit(&g.youmonst, mon, obj, &tmp, dieroll)) { + /* artifact_hit updates 'tmp' but doesn't inflict any + damage; however, it might cause carried items to be + destroyed and they might do so */ if (DEADMONSTER(mon)) /* artifact killed monster */ return FALSE; if (tmp == 0)