From: PatR Date: Fri, 25 Dec 2015 22:15:00 +0000 (-0800) Subject: from_what() X-Git-Tag: NetHack-3.6.1_RC01~1118 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ed3d8be4cf8e58088611c64ba0beff752f51854;p=nethack from_what() 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.) --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 054b53ffa..852ab6ce8 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -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 diff --git a/src/attrib.c b/src/attrib.c index 3866dbf26..76a9fc0e7 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -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));