]> granicus.if.org Git - nethack/commitdiff
more starving pets
authornethack.rankin <nethack.rankin>
Sat, 14 Sep 2002 05:48:40 +0000 (05:48 +0000)
committernethack.rankin <nethack.rankin>
Sat, 14 Sep 2002 05:48:40 +0000 (05:48 +0000)
     The fact that a pet was starving to death got recorded with its
corpse; if that corpse was revived via undead turning, the resulting
monster would immediately starve again if it stayed tame.  Similarly,
if one got petrified while nearly starved, reanimating the statue would
produce a starving pet.  Make revival and reanimation use the same code
as life-saving, where hunger status gets reset.

doc/fixes34.1
src/dog.c
src/mon.c

index 0259499ec7d3d56cd88e379613feee99be850915..d86b57b79bb619f6b3eda0a911fbf3d1daa42843 100644 (file)
@@ -244,6 +244,7 @@ elevate the trouble priority of any cursed item which is preventing removal
        of a ring of levitation
 starving pets will eat more aggressively
 when a pet starves to death, say so instead of just "Fido dies."
+starved pet raised from dead shouldn't immediately starve again
 
 
 Platform- and/or Interface-Specific Fixes
index e482cdff8493d8f3b62c5ae16eef35b4faddce52..c1a38a6f1a8fd4ff87ceeea568eacd007b367b9f 100644 (file)
--- a/src/dog.c
+++ b/src/dog.c
@@ -790,19 +790,28 @@ register struct obj *obj;
  * If the pet wasn't abused and was very tame, it might revive tame.
  */
 void
-wary_dog(mtmp, quietly)
+wary_dog(mtmp, was_dead)
 struct monst *mtmp;
-boolean quietly;
+boolean was_dead;
 {
-    int has_edog;
+    struct edog *edog;
+    boolean quietly = was_dead;
 
+    mtmp->meating = 0;
     if (!mtmp->mtame) return;
-    has_edog = !mtmp->isminion;
-    if (has_edog &&
-               ((EDOG(mtmp)->killed_by_u == 1) || (EDOG(mtmp)->abuse > 2))) {
+    edog = !mtmp->isminion ? EDOG(mtmp) : 0;
+
+    /* if monster was starving when it died, undo that now */
+    if (edog && edog->mhpmax_penalty) {
+       mtmp->mhpmax += edog->mhpmax_penalty;
+       mtmp->mhp += edog->mhpmax_penalty;      /* heal it */
+       edog->mhpmax_penalty = 0;
+    }
+
+    if (edog && (edog->killed_by_u == 1 || edog->abuse > 2)) {
        mtmp->mpeaceful = mtmp->mtame = 0;
-       if (EDOG(mtmp)->abuse >= 0 && EDOG(mtmp)->abuse < 10)
-               if (!rn2(EDOG(mtmp)->abuse + 1)) mtmp->mpeaceful = 1;
+       if (edog->abuse >= 0 && edog->abuse < 10)
+           if (!rn2(edog->abuse + 1)) mtmp->mpeaceful = 1;
        if(!quietly && cansee(mtmp->mx, mtmp->my)) {
            if (haseyes(youmonst.data)) {
                if (haseyes(mtmp->data))
@@ -817,10 +826,10 @@ boolean quietly;
            }
        }
     } else {
-       /* chance it goes wild anyway - Pet Semetary */
-       if (!rn2(mtmp->mtame)) {
-               mtmp->mpeaceful = mtmp->mtame = 0;
-       }
+       /* chance it goes wild anyway - Pet Semetary */
+       if (!rn2(mtmp->mtame)) {
+           mtmp->mpeaceful = mtmp->mtame = 0;
+       }
     }
     if (!mtmp->mtame) {
        newsym(mtmp->mx, mtmp->my);
@@ -830,10 +839,19 @@ boolean quietly;
     }
 
     /* if its still a pet, start a clean pet-slate now */
-    if (has_edog && mtmp->mtame) {
-       EDOG(mtmp)->revivals++;
-       EDOG(mtmp)->killed_by_u = 0;
-       EDOG(mtmp)->abuse = 0;
+    if (edog && mtmp->mtame) {
+       edog->revivals++;
+       edog->killed_by_u = 0;
+       edog->abuse = 0;
+       edog->ogoal.x = edog->ogoal.y = -1;
+       if (was_dead || edog->hungrytime < monstermoves + 500L)
+           edog->hungrytime = monstermoves + 500L;
+       if (was_dead) {
+           edog->droptime = 0L;
+           edog->dropdist = 10000;
+           edog->whistletime = 0L;
+           edog->apport = 5;
+       } /* else lifesaved, so retain current values */
     }
 }
 
index 6d255d13c6e58350e837aabf461039e1069b53c9..c2a51f53e512c41734b3b56971f34f8d588243a0 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1334,14 +1334,6 @@ struct monst *mtmp;
                mtmp->mcanmove = 1;
                mtmp->mfrozen = 0;
                if (mtmp->mtame && !mtmp->isminion) {
-                       struct edog *edog = EDOG(mtmp);
-                       if (edog->hungrytime < moves+500)
-                               edog->hungrytime = moves+500;
-                       if (edog->mhpmax_penalty) {
-                               /* was starving */
-                               mtmp->mhpmax += edog->mhpmax_penalty;
-                               edog->mhpmax_penalty = 0;
-                       }
                        wary_dog(mtmp, FALSE);
                }
                if (mtmp->mhpmax <= 0) mtmp->mhpmax = 10;