]> granicus.if.org Git - nethack/commitdiff
Praying on an altar with pet corpse on it can revive the pet
authorPasi Kallinen <paxed@alt.org>
Sun, 10 Jul 2022 09:56:20 +0000 (12:56 +0300)
committerPasi Kallinen <paxed@alt.org>
Sun, 10 Jul 2022 09:56:20 +0000 (12:56 +0300)
doc/fixes3-7-0.txt
src/pray.c

index 905a7186857075d4179a759fb1ecd288c4ee696b..0b54451d4361ee78c3ed2c6b13699318f8d520b1 100644 (file)
@@ -950,6 +950,7 @@ a hero on the quest home level who runs or travels past the quest leader and
 allow rush/run over water if wearing discovered water walking boots
 flying pets wouldn't target underwater food but if they happened to fly over
        such food they could and would eat it
+praying on an altar with pet corpse on it can revive the pet
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 14c5555b673ccfc471ffc47920ab08cf8e7b85a6..5d56f867fbe9e9ff0402bc71db5df936615c5e04 100644 (file)
@@ -22,6 +22,7 @@ static void gods_upset(aligntyp);
 static void consume_offering(struct obj *);
 static void offer_too_soon(aligntyp);
 static void desecrate_high_altar(aligntyp);
+static boolean pray_revive(void);
 static boolean water_prayer(boolean);
 static boolean blocked_boulder(int, int);
 
@@ -1994,6 +1995,23 @@ can_pray(boolean praying) /* false means no messages should be given */
     return !praying ? (boolean) (g.p_type == 3 && !Inhell) : TRUE;
 }
 
+/* return TRUE if praying revived a pet corpse */
+static boolean
+pray_revive(void)
+{
+    struct obj *otmp;
+
+    for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere)
+        if (otmp->otyp == CORPSE && has_omonst(otmp)
+            && OMONST(otmp)->mtame && !OMONST(otmp)->isminion)
+            break;
+
+    if (!otmp)
+        return FALSE;
+
+    return (revive(otmp, TRUE) != NULL);
+}
+
 /* #pray commmand */
 int
 dopray(void)
@@ -2102,8 +2120,10 @@ prayer_done(void) /* M. Stephenson (1.0.3b) */
             pleased(alignment);
     } else {
         /* coaligned */
-        if (on_altar())
+        if (on_altar()) {
+            (void) pray_revive();
             (void) water_prayer(TRUE);
+        }
         pleased(alignment); /* nice */
     }
     return 1;