Skip to content

Commit

Permalink
fix #H2060 - objects blanked by water while hero is blind
Browse files Browse the repository at this point in the history
     From a bug report, if you entered water
while blind and any spellbooks got blanked, you would know they became
"plain spellbooks" iff their original description was known.  The same
situation applied to scrolls and potions; if they had been previously
seen you'd learn they'd become blank or clear.  This fix resets the
obj->dknown flag during transformation so that altered objects are only
known by their class when blind, never their description, the same as
when they hadn't been seen before being blanked.  (When sighted, the
dknown flag gets set again the next time the object's name is formatted,
so the player shouldn't be able to notice that any reset took place.)

     Unpaid objects which get blanked should be treated as used up for
shop billing purposes (force the hero to buy), but there aren't any pools
in shops so aside from the added comment I'm going to pretend I didn't
notice that that isn't being done....

     Potions seen before becoming blind which become diluted while blind
will be known to be diluted since there's no way to know the description
without also knowing the dilution.  I don't think that's important enough
to track known-dilution separately, although I suppose we could overload
the cknown (contents-known) flag for that if necessary.

     This also removes an inaccurate comment about the effects of Luck.
Its maximum is always 13 regardless of whether the moon is full, so 5%
for the lowest chance of blanking via submersion was impossible.
  • Loading branch information
nethack.rankin committed Dec 15, 2009
1 parent 403dd4e commit 9269642
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
2 changes: 2 additions & 0 deletions doc/fixes34.4
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ prevent "object lost" panic if/when drinking a wielded potion of polymorph
documentation tidbit: change Guidebook and in-game help for pickup_burden
option to match game's 'O' command ("Unencumbered", not "Unburdened")
writing while blind no longer possible for books, might fail for scrolls
blanking items in pools while blind shouldn't reveal new obj description
for ones which had been seen before becoming blind


Platform- and/or Interface-Specific Fixes
Expand Down
30 changes: 21 additions & 9 deletions src/trap.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* NetHack 3.5 trap.c $Date$ $Revision$ */
/* SCCS Id: @(#)trap.c 3.5 2007/12/19 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */

Expand Down Expand Up @@ -3087,7 +3086,18 @@ boolean force, here;
}

/* Scrolls, spellbooks, potions, weapons and
pieces of armor may get affected by the water */
pieces of armor may get affected by the water.
[FIXME? The item transformations here lack shop price/billing
handling [costly_alteration()], which is okay as long as shops
don't contain any pools. However, that's probably not a valid
assumption; a broken fountain might spill new pools far enough
to put one inside a nearby shop, particularly if dug walls in
Minetown haven't been repaired yet. Note that water_damage()
might be getting called right now because we're in the midst
of creating such a pool, not just because one has already been
created and we've walked into it while carrying unpaid stuff.]
*/
for (; obj; obj = otmp) {
otmp = here ? obj->nexthere : obj->nobj;

Expand All @@ -3102,24 +3112,25 @@ boolean force, here;
water_damage(&obj->cobj, force, FALSE);
} else if (!force && (Luck + 5) > rn2(20)) {
/* chance per item of sustaining damage:
* max luck (full moon): 5%
* max luck (elsewhen): 10%
* max luck: 10%
* avg luck (Luck==0): 75%
* awful luck (Luck<-4): 100%
*/
continue;
} else if (obj->oclass == SCROLL_CLASS) {
#ifdef MAIL
if (obj->otyp != SCR_MAIL)
if (obj->otyp == SCR_MAIL) continue;
#endif
{
obj->otyp = SCR_BLANK_PAPER;
obj->dknown = 0;
obj->spe = 0;
}
} else if (obj->oclass == SPBOOK_CLASS) {
if (obj->otyp == SPE_BOOK_OF_THE_DEAD)
if (obj->otyp == SPE_BOOK_OF_THE_DEAD) {
pline("Steam rises from %s.", the(xname(obj)));
else obj->otyp = SPE_BLANK_PAPER;
continue;
}
obj->otyp = SPE_BLANK_PAPER;
obj->dknown = 0;
} else if (obj->oclass == POTION_CLASS) {
if (obj->otyp == POT_ACID) {
char *bufp, buf[BUFSZ];
Expand All @@ -3143,6 +3154,7 @@ boolean force, here;
continue;
} else if (obj->odiluted) {
obj->otyp = POT_WATER;
obj->dknown = 0;
obj->blessed = obj->cursed = 0;
obj->odiluted = 0;
} else if (obj->otyp != POT_WATER)
Expand Down

0 comments on commit 9269642

Please sign in to comment.