]> granicus.if.org Git - nethack/commitdiff
from_what()
authorPatR <rankin@nethack.org>
Fri, 25 Dec 2015 22:15:00 +0000 (14:15 -0800)
committerPatR <rankin@nethack.org>
Fri, 25 Dec 2015 22:15:00 +0000 (14:15 -0800)
Enlightenment/attribute disclosure while in wizard mode shows reasons
for some of the intrinsics.  This adds some more of those:  innately
due to polymorph for lots of things, and innately due to role for
knight's jumping.  (Drain_resistance from equipped item came with the
'resistance from Excalibur' patch.)

doc/fixes36.1
src/attrib.c

index 054b53ffa5c301ff6515e28af9e2f9ba5455a46c..852ab6ce87dd7b5600481da13c755a128390ba77 100644 (file)
@@ -59,6 +59,7 @@ allow optional parameter "true", "yes", "false", or "no" for boolean options
 actually make the castle chest not trapped
 level-drain resistance wasn't shown during enlightenment if it was conferred
        by worn/wielded equipment
+wizard mode enlightenment now shows more reasons for various intrinsics
 
 
 Platform- and/or Interface-Specific Fixes
index 3866dbf26e372354dc4d6d7612597d7e391c43be..76a9fc0e72d398d07afd8fcbf79b5641a5f7afa9 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 attrib.c        $NHDT-Date: 1449269911 2015/12/04 22:58:31 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.51 $ */
+/* NetHack 3.6 attrib.c        $NHDT-Date: 1451081651 2015/12/25 22:14:11 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.52 $ */
 /*      Copyright 1988, 1989, 1990, 1992, M. Stephenson           */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -707,31 +707,46 @@ long frommask;
     return (struct innate *) 0;
 }
 
-/*
- * returns 1 if FROMRACE or FROMEXPER and exper level == 1
- * returns 2 if FROMEXPER and exper level > 1
- * otherwise returns 0
- */
+/* reasons for innate ability */
+#define FROM_NONE 0
+#define FROM_ROLE 1 /* from experience at level 1 */
+#define FROM_RACE 2
+#define FROM_EXP  3 /* from experience for some level > 1 */
+#define FROM_FORM 4
+
+
+/* check whether particular ability has been obtained via innate attribute */
 STATIC_OVL int
 innately(ability)
 long *ability;
 {
     const struct innate *iptr;
 
+    if ((iptr = check_innate_abil(ability, FROMEXPER)) != 0)
+        return (iptr->ulevel == 1) ? FROM_ROLE : FROM_EXP;
     if ((iptr = check_innate_abil(ability, FROMRACE)) != 0)
-        return 1;
-    else if ((iptr = check_innate_abil(ability, FROMEXPER)) != 0)
-        return (iptr->ulevel == 1) ? 1 : 2;
-    return 0;
+        return FROM_RACE;
+    if ((*ability & FROMFORM) != 0L)
+        return FROM_FORM;
+   return FROM_NONE;
 }
 
 int
 is_innate(propidx)
 int propidx;
 {
+    int innateness = innately(&u.uprops[propidx].intrinsic);
+
+    if (innateness != FROM_NONE)
+        return innateness;
+    if (propidx == JUMPING && Role_if(PM_KNIGHT)
+        /* knight has intrinsic jumping, but extrinsic is more versatile so
+           ignore innateness if equipment is going to claim responsibility */
+        && !u.uprops[propidx].extrinsic)
+        return FROM_ROLE;
     if (propidx == BLINDED && !haseyes(youmonst.data))
-        return 1;
-    return innately(&u.uprops[propidx].intrinsic);
+        return FROM_FORM;
+    return FROM_NONE;
 }
 
 char *
@@ -750,14 +765,16 @@ int propidx; /* special cases can have negative values */
         if (propidx >= 0) {
             char *p;
             struct obj *obj = (struct obj *) 0;
-            int innate = is_innate(propidx);
+            int innateness = is_innate(propidx);
 
-            if (innate == 2)
+            if (innateness == FROM_EXP)
                 Strcpy(buf, " because of your experience");
-            else if (innate == 1)
+            else if (innateness == FROM_FORM)
+                Strcpy(buf, " from current creature form");
+            else if (innateness == FROM_ROLE || innateness == FROM_RACE)
                 Strcpy(buf, " innately");
             else if (wizard
-                     && (obj = what_gives(&u.uprops[propidx].extrinsic)))
+                     && (obj = what_gives(&u.uprops[propidx].extrinsic)) != 0)
                 Sprintf(buf, because_of, obj->oartifact
                                              ? bare_artifactname(obj)
                                              : ysimple_name(obj));