]> granicus.if.org Git - nethack/commitdiff
fix issue #332 - mon vs mon double hit message
authorPatR <rankin@nethack.org>
Sun, 26 Apr 2020 02:06:18 +0000 (19:06 -0700)
committerPatR <rankin@nethack.org>
Sun, 26 Apr 2020 02:06:18 +0000 (19:06 -0700)
One monster hitting another with an artifact within the hero's view
gave "<Mon1> swings his <Artifact> at <Mon2>." followed either by
"<Mon1> misses <Mon2>." _or_ the two messages "<Mon1> hits <Mon2>."
and "The <Artifact> hits <Mon2>."  Defer the <Mon1> hits <Mon2> 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

doc/fixes37.0
src/mhitm.c
src/uhitm.c

index e18c633b061ba2b1c93a251246d266891d7e507f..83a70700ceb8d924f75f5dca8dadad0ddabe5679 100644 (file)
@@ -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
index 18655f46c4a3cb9081de3deb4ad44a32cd06ae6f..26b5982988db170afdd244d43500232b6173af88 100644 (file)
@@ -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));
             }
index 5c9b9a62a5fd3ebdf6494fc37f7a85db3a3ef63a..a317e16cd38355e04ef9c929d5f36e78263a1898 100644 (file)
@@ -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)