identify tweaks

Give better feedback if reading a scroll of identify when it is the
only item in inventory (making that empty when scroll is used up).

Reading a cursed scroll of identify used to always ID 1 item besides
itself.  Change it to behave like confused identify--only identifying
itself--if read when the scroll hasn't been discovered yet.  Same as
before when scroll has already been discovered:  identify 1 item.
This commit is contained in:
PatR
2020-07-28 13:10:11 -07:00
parent c8ad99fcdf
commit 0a575befcc

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 read.c $NHDT-Date: 1592875138 2020/06/23 01:18:58 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.198 $ */ /* NetHack 3.6 read.c $NHDT-Date: 1595966992 2020/07/28 20:09:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.199 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1345,34 +1345,36 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
break; break;
case SCR_IDENTIFY: case SCR_IDENTIFY:
/* known = TRUE; -- handled inline here */ /* known = TRUE; -- handled inline here */
/* use up the scroll first, before makeknown() performs a /* use up the scroll first, before learnscrolltyp() -> makeknown()
perm_invent update; also simplifies empty invent check */ performs perm_invent update; also simplifies empty invent check */
useup(sobj); useup(sobj);
sobj = 0; /* it's gone */ sobj = 0; /* it's gone */
if (confused) /* scroll just identifies itself for any scroll read while confused
or for cursed scroll read without knowing identify yet */
if (confused || (scursed && !already_known))
You("identify this as an identify scroll."); You("identify this as an identify scroll.");
else if (!already_known || !g.invent) else if (!already_known)
/* force feedback now if invent became
empty after using up this scroll */
pline("This is an identify scroll."); pline("This is an identify scroll.");
if (!already_known) if (!already_known)
(void) learnscrolltyp(SCR_IDENTIFY); (void) learnscrolltyp(SCR_IDENTIFY);
if (confused || (scursed && !already_known))
break;
/*FALLTHRU*/ /*FALLTHRU*/
case SPE_IDENTIFY: case SPE_IDENTIFY:
cval = 1; if (g.invent) {
if (sblessed || (!scursed && !rn2(5))) { cval = 1;
cval = rn2(5); if (sblessed || (!scursed && !rn2(5))) {
/* note: if cval==0, identify all items */ cval = rn2(5);
if (cval == 1 && sblessed && Luck > 0) /* note: if cval==0, identify all items */
++cval; if (cval == 1 && sblessed && Luck > 0)
} ++cval;
if (g.invent && !confused) { }
identify_pack(cval, !already_known); identify_pack(cval, !already_known);
} else if (otyp == SPE_IDENTIFY) { } else {
/* when casting a spell we know we're not confused, /* spell cast with inventory empty or scroll read when it's
so inventory must be empty (another message has the only item leaving empty inventory after being used up */
already been given above if reading a scroll) */ pline("You're not carrying anything%s to be identified.",
pline("You're not carrying anything to be identified."); (otyp == SCR_IDENTIFY) ? " else" : "");
} }
break; break;
case SCR_CHARGING: case SCR_CHARGING: