]> granicus.if.org Git - nethack/commitdiff
fix #H4428 - mon vs mon thrown cockatrice egg
authorPatR <rankin@nethack.org>
Sat, 9 Jul 2016 23:15:37 +0000 (16:15 -0700)
committerPatR <rankin@nethack.org>
Sat, 9 Jul 2016 23:15:37 +0000 (16:15 -0700)
There was no code in ohitmon() (for object thrown or launched at a
monster by someone or something other than the hero) to handle an egg
hitting a monster.  Cockatrice egg is monsters' preferred missile,
but if one hit a monster instead of hero it just did minimal damage
without any chance of the side-effect that makes it be preferred.

doc/fixes36.1
src/mthrowu.c

index 49e65e7e5105dc5f9c78a69992cc86c5b2412fd5..bac5863f33ee477a0fc59d551f35f809c1a97acd 100644 (file)
@@ -316,6 +316,8 @@ when confused scroll of light summoned lights, player would be asked what to
        call the scroll even if scroll of light was already identified
 if a visible monster becomes invisible, mark its spot with the 'remembered,
        unseen monster' glyph ('I' character or '?' tile)
+monsters can throw cockatrice eggs at hero, but there was no handling for eggs
+       when the missile hit an intervening monster
 
 
 Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
index a448ba8e61cd6eb858c7c88d6af6744a48fd4cb7..c36c0fe75a27dd352f7389ecf11d74d631088e48 100644 (file)
@@ -338,10 +338,15 @@ boolean verbose;    /* give message(s) even when you can't see what happened */
         if (ismimic)
             seemimic(mtmp);
         mtmp->msleeping = 0;
-        if (vis)
-            hit(distant_name(otmp, mshot_xname), mtmp, exclam(damage));
-        else if (verbose && !target)
-            pline("%s is hit%s", Monnam(mtmp), exclam(damage));
+        if (vis) {
+            if (otmp->otyp == EGG)
+                pline("Splat! %s is hit with %s egg!", Monnam(mtmp),
+                      otmp->known ? an(mons[otmp->corpsenm].mname) : "an");
+            else
+                hit(distant_name(otmp, mshot_xname), mtmp, exclam(damage));
+        } else if (verbose && !target)
+            pline("%s%s is hit%s", (otmp->otyp == EGG) ? "Splat! " : "",
+                  Monnam(mtmp), exclam(damage));
 
         if (otmp->opoisoned && is_poisonable(otmp)) {
             if (resists_poison(mtmp)) {
@@ -369,7 +374,6 @@ boolean verbose;    /* give message(s) even when you can't see what happened */
             if (resists_acid(mtmp)) {
                 if (vis || (verbose && !target))
                     pline("%s is unaffected.", Monnam(mtmp));
-                damage = 0;
             } else {
                 if (vis)
                     pline_The("%s burns %s!", hliquid("acid"), mon_nam(mtmp));
@@ -377,24 +381,36 @@ boolean verbose;    /* give message(s) even when you can't see what happened */
                     pline("It is burned!");
             }
         }
-        mtmp->mhp -= damage;
-        if (mtmp->mhp < 1) {
-            if (vis || (verbose && !target))
-                pline("%s is %s!", Monnam(mtmp),
-                      (nonliving(mtmp->data) || is_vampshifter(mtmp)
-                       || !canspotmon(mtmp)) ? "destroyed" : "killed");
-            /* don't blame hero for unknown rolling boulder trap */
-            if (!context.mon_moving
-                && (otmp->otyp != BOULDER || range >= 0 || otmp->otrapped))
-                xkilled(mtmp, XKILL_NOMSG);
-            else
-                mondied(mtmp);
+        if (otmp->otyp == EGG && touch_petrifies(&mons[otmp->corpsenm])) {
+            if (!munstone(mtmp, TRUE))
+                minstapetrify(mtmp, TRUE);
+            if (resists_ston(mtmp))
+                damage = 0;
+        }
+
+        if (mtmp->mhp > 0) { /* might already be dead (if petrified) */
+            mtmp->mhp -= damage;
+            if (mtmp->mhp < 1) {
+                if (vis || (verbose && !target))
+                    pline("%s is %s!", Monnam(mtmp),
+                          (nonliving(mtmp->data) || is_vampshifter(mtmp)
+                           || !canspotmon(mtmp)) ? "destroyed" : "killed");
+                /* don't blame hero for unknown rolling boulder trap */
+                if (!context.mon_moving && (otmp->otyp != BOULDER
+                                            || range >= 0 || otmp->otrapped))
+                    xkilled(mtmp, XKILL_NOMSG);
+                else
+                    mondied(mtmp);
+            }
         }
 
-        if (can_blnd((struct monst *) 0, mtmp,
-                     (uchar) ((otmp->otyp == BLINDING_VENOM) ? AT_SPIT
-                                                             : AT_WEAP),
-                     otmp)) {
+        /* blinding venom and cream pie do 0 damage, but verify
+           that the target is still alive anyway */
+        if (mtmp->mhp > 0
+            && can_blnd((struct monst *) 0, mtmp,
+                        (uchar) ((otmp->otyp == BLINDING_VENOM) ? AT_SPIT
+                                                                : AT_WEAP),
+                        otmp)) {
             if (vis && mtmp->mcansee)
                 pline("%s is blinded by %s.", Monnam(mtmp), the(xname(otmp)));
             mtmp->mcansee = 0;