]> granicus.if.org Git - nethack/commitdiff
Eating garlic makes some monsters flee
authorPasi Kallinen <paxed@alt.org>
Tue, 24 Jan 2023 04:17:17 +0000 (06:17 +0200)
committerPasi Kallinen <paxed@alt.org>
Tue, 24 Jan 2023 04:17:17 +0000 (06:17 +0200)
doc/fixes3-7-0.txt
src/eat.c

index 5c3478a999fe2b19c991d70f87bce4d63c8772b5..d11b215f12c82711ce2329e47b0ef8cf2a27cb13 100644 (file)
@@ -1097,6 +1097,7 @@ fix bug making random subrooms never touching the right or bottom
 if a grave is created with the corpse lying on top (bones), don't find a
        corpse or release a zombie or mummy when digging it up
 kicking a headstone might summon a ghoul
+eating garlic makes nearby monsters flee
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index d593d7211e972628c2aaf499b05b4b4017bfb54e..e58b930026da3479cfd581f93a9fd56f131ef52c 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -28,6 +28,7 @@ static void consume_tin(const char *);
 static void start_tin(struct obj *);
 static int eatcorpse(struct obj *);
 static void start_eating(struct obj *, boolean);
+static void garlic_breath(struct monst *);
 static void fprefx(struct obj *);
 static void fpostfx(struct obj *);
 static int bite(void);
@@ -1972,6 +1973,14 @@ eating_glob(struct obj *glob)
     return (go.occupation == eatfood && glob == gc.context.victual.piece);
 }
 
+/* scare nearby monster when hero eats garlic */
+static void
+garlic_breath(struct monst *mtmp)
+{
+    if (olfaction(mtmp->data) && distu(mtmp->mx, mtmp->my) < 7)
+        monflee(mtmp, 0, FALSE, FALSE);
+}
+
 /*
  * Called on "first bite" of (non-corpse) food, after touchfood() has
  * marked it 'partly eaten'.  Used for non-rotten non-tin non-corpse food.
@@ -2030,6 +2039,7 @@ fprefx(struct obj *otmp)
             make_vomiting((long) rn1(gc.context.victual.reqtime, 5), FALSE);
             break;
         }
+        iter_mons(garlic_breath);
         /*FALLTHRU*/
     default:
         if (otmp->otyp == SLIME_MOLD && !otmp->cursed