]> granicus.if.org Git - nethack/commitdiff
montraits usage (trunk only)
authornethack.rankin <nethack.rankin>
Wed, 10 Dec 2003 06:33:25 +0000 (06:33 +0000)
committernethack.rankin <nethack.rankin>
Wed, 10 Dec 2003 06:33:25 +0000 (06:33 +0000)
     Move a couple of recently added corpse revival/statue animation
fixups into montraits() so that its callers don't have to worry about
them anymore.

src/trap.c
src/zap.c

index dc9f7b8509a9876c527eb49eb5a1a67aaaa2d14c..a3fbc065399a8be8bc979d560a00b41b8d0f11b6 100644 (file)
@@ -419,15 +419,8 @@ int *fail_reason;
            /* restore a petrified monster */
            cc.x = x,  cc.y = y;
            mon = montraits(statue, &cc);
-           if (mon) {
-               if (mon->mtame && !mon->isminion)
-                   wary_dog(mon, TRUE);
-               /* might be bringing quest leader back to life */
-               if (quest_status.leader_is_dead &&
-                       /* leader_is_dead implies that leader_m_id is valid */
-                       mon->m_id == quest_status.leader_m_id)
-                   quest_status.leader_is_dead = FALSE;
-           }
+           if (mon && mon->mtame && !mon->isminion)
+               wary_dog(mon, TRUE);
        } else {
            /* statues of unique monsters from bones or wishing end
               up here (cant_revive() sets mnum to be doppelganger;
@@ -477,9 +470,6 @@ int *fail_reason;
        /* mimic statue becomes seen mimic; other hiders won't be hidden */
        if (mon->m_ap_type) seemimic(mon);
        else mon->mundetected = FALSE;
-       /* when reanimating a stoned monster, protection from shape changers
-          might be different now than it was when the monster was petrified */
-       if (use_saved_traits) restore_cham(mon);
 
        if ((x == u.ux && y == u.uy) || cause == ANIMATE_SPELL) {
            const char *comes_to_life = nonliving(mon->data) ?
index 1c5a3827899ed2f2658cba5d50d2ea56bb857759..7e160bd081794aa9c22b1bd75ee60ee61ad9ecae 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -472,6 +472,11 @@ coord *cc;
                   (we cleared it when loading bones) */
                if (!mtmp2->m_id)
                    mtmp2->m_id = mtmp->m_id;
+               /* might be bringing quest leader back to life */
+               else if (quest_status.leader_is_dead &&
+                       /* leader_is_dead implies that leader_m_id is valid */
+                       mtmp2->m_id == quest_status.leader_m_id)
+                   quest_status.leader_is_dead = FALSE;
                mtmp2->mx   = mtmp->mx;
                mtmp2->my   = mtmp->my;
                mtmp2->mux  = mtmp->mux;
@@ -507,6 +512,10 @@ coord *cc;
                mtmp2->mstun = 0;
                mtmp2->mconf = 0;
                replmon(mtmp,mtmp2);
+
+               /* in case Protection_from_shape_changers is different
+                  now than it was when the traits were stored */
+               restore_cham(mtmp2);
        }
        return mtmp2;
 }
@@ -633,15 +642,8 @@ register struct obj *obj;
 
                        xy.x = x; xy.y = y;
                        mtmp = montraits(obj, &xy);
-                       if (mtmp) {
-                           if (mtmp->mtame && !mtmp->isminion)
-                               wary_dog(mtmp, TRUE);
-                           /* might be reviving quest leader */
-                           if (quest_status.leader_is_dead &&
-                                   /* _is_dead implies that _m_id is valid */
-                                   mtmp->m_id == quest_status.leader_m_id)
-                               quest_status.leader_is_dead = FALSE;
-                       }
+                       if (mtmp && mtmp->mtame && !mtmp->isminion)
+                           wary_dog(mtmp, TRUE);
                    } else
                        mtmp = makemon(&mons[montype], x, y,
                                       NO_MINVENT|MM_NOWAIT|MM_NOCOUNTBIRTH);
@@ -677,12 +679,6 @@ register struct obj *obj;
                                mtmp->mhp = eaten_stat(mtmp->mhp, obj);
                        /* track that this monster was revived at least once */
                        mtmp->mrevived = 1;
-                       /* in case this was a shapechanger corpse and
-                          Protection_from_shape_changers happens to be
-                          different now than it was when the monster
-                          was killed (probably a no-op here since
-                          KEEPTRAITS() doesn't include shapechangers) */
-                       restore_cham(mtmp);
 
                        if (recorporealization) {
                                /* If mtmp is revivification of former tame ghost*/