]> granicus.if.org Git - nethack/commitdiff
class differentiation bit (trunk only)
authornethack.allison <nethack.allison>
Sat, 25 Oct 2003 22:20:24 +0000 (22:20 +0000)
committernethack.allison <nethack.allison>
Sat, 25 Oct 2003 22:20:24 +0000 (22:20 +0000)
Healers pick up on the fact that a wand of undead turning
revived a creature.

include/extern.h
src/mkobj.c
src/zap.c

index eb492c3209962c8aadb0b3998a6b3ddfa520f7f6..64cbb280356b25cbd440033c56e7054f275b11f4 100644 (file)
@@ -1057,6 +1057,7 @@ E int FDECL(weight, (struct obj *));
 E struct obj *FDECL(mkgold, (long,int,int));
 E struct obj *FDECL(mkcorpstat,
                (int,struct monst *,struct permonst *,int,int,BOOLEAN_P));
+E int FDECL(corpse_revive_type, (struct obj *));
 E struct obj *FDECL(obj_attach_mid, (struct obj *, unsigned));
 E struct monst *FDECL(get_mtraits, (struct obj *, BOOLEAN_P));
 E struct obj *FDECL(mk_tt_object, (int,int,int));
index 73f5a8397a2466f71b68fa2d9d6171c7d6aea36d..cb5102b6a4755db576223ff600010bdd000435a1 100644 (file)
@@ -926,6 +926,30 @@ boolean init;
        return(otmp);
 }
 
+/*
+ * Return the type of monster that this corpse will
+ * revive as, even if it has a monster structure
+ * attached to it. In that case, you can't just
+ * use obj->corpsenm, because the stored monster
+ * type can, and often is, different.
+ * The return value is an index into mons[].
+ */
+int
+corpse_revive_type(obj)
+struct obj *obj;
+{
+       int revivetype;
+       struct monst *mtmp;
+       if (obj->oxlth && obj->oattached == OATTACHED_MONST &&
+               ((mtmp = get_mtraits(obj, FALSE)) != (struct monst *)0)) {
+           /* mtmp is a temporary pointer to a monster's stored
+               attributes, not a real monster */
+           revivetype = mtmp->mnum;
+       } else
+           revivetype = obj->corpsenm;
+       return revivetype;
+}
+
 /*
  * Attach a monster id to an object, to provide
  * a lasting association between the two.
index 0a3bd88e5cb6a76a4fa59cd682b7e124d2135893..a7760496a38174b471bfa381d43293dc6d8681dc 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1559,8 +1559,27 @@ struct obj *obj, *otmp;
        case SPE_TURN_UNDEAD:
                if (obj->otyp == EGG)
                        revive_egg(obj);
-               else
+               else {
+                       int corpsenm = (obj->otyp == CORPSE) ?
+                                       corpse_revive_type(obj) : 0;
                        res = !!revive(obj);
+                       if (res && corpsenm && Role_if(PM_HEALER)) {
+                           boolean u_noticed = FALSE;
+                           if (Hallucination) {
+                               You_hear("the sound of a defibrillator.");
+                               u_noticed = TRUE;
+                           } else if (!Blind) {
+                               You("observe %s %s change dramatically.",
+                                       s_suffix(an(mons[corpsenm].mname)),
+                                       nonliving(&mons[corpsenm]) ?
+                                       "motility" : "health");
+                           }
+                           if (u_noticed) {
+                                   makeknown(otmp->otyp);
+                                   exercise(A_WIS, TRUE);
+                           }
+                       }
+               }
                break;
        case WAN_OPENING:
        case SPE_KNOCK: