no more headless eyewear

Noticed while working on something else:  hero kept wearing a towel
after polymorphing into a form without any head.  And when not already
wearing one, could put on a blindfold/towel/lenses while in a headless
form.
This commit is contained in:
PatR
2020-01-21 15:36:33 -08:00
parent fa890fc7a2
commit a13d6c03c9
3 changed files with 41 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.69 $ $NHDT-Date: 1579261284 2020/01/17 11:41:24 $
$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ $NHDT-Date: 1579649788 2020/01/21 23:36:28 $
General Fixes and Modified Features
-----------------------------------
@@ -46,6 +46,7 @@ when poly'd into a giant and moving onto a boulder's spot, message given was
confused about whether autopickup would occur so could be misleading
random role selection wasn't honoring unwanted alignment(s) properly
if at the edge of the map window, trying to move farther fails but used a turn
hero can no longer wear blindfold/towel/lenses when poly'd into headless form
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do_wear.c $NHDT-Date: 1575768410 2019/12/08 01:26:50 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.126 $ */
/* NetHack 3.6 do_wear.c $NHDT-Date: 1579649788 2020/01/21 23:36:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.127 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1159,15 +1159,19 @@ void
Blindf_off(otmp)
struct obj *otmp;
{
boolean was_blind = Blind, changed = FALSE;
boolean was_blind = Blind, changed = FALSE,
nooffmsg = !otmp;
if (!otmp)
otmp = ublindf;
if (!otmp) {
impossible("Blindf_off without otmp");
impossible("Blindf_off without eyewear?");
return;
}
g.context.takeoff.mask &= ~W_TOOL;
setworn((struct obj *) 0, otmp->owornmask);
off_msg(otmp);
if (!nooffmsg)
off_msg(otmp);
if (Blind) {
if (was_blind) {
@@ -1895,6 +1899,15 @@ struct obj *obj;
return 1;
}
} else {
/*
* FIXME:
* except for the rings/nolimbs case, this allows you to put on
* accessories without having any hands to manipulate them, and
* to put them on when poly'd into a tiny or huge form where
* they shouldn't fit. [If the latter situation changes, make
* comparable change to break_armor(polyself.c).]
*/
/* accessory */
if (ring) {
char answer, qbuf[QBUFSZ];
@@ -1965,6 +1978,11 @@ struct obj *obj;
return 0;
}
} else if (eyewear) {
if (!has_head(g.youmonst.data)) {
You("have no head to wear %s on.", ansimpleoname(obj));
return 0;
}
if (ublindf) {
if (ublindf->otyp == TOWEL)
Your("%s is already covered by a towel.",

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 polyself.c $NHDT-Date: 1573290419 2019/11/09 09:06:59 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.135 $ */
/* NetHack 3.6 polyself.c $NHDT-Date: 1579649789 2020/01/21 23:36:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.148 $ */
/* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
@@ -934,7 +934,7 @@ break_armor()
useup(uarmu);
}
} else if (sliparm(g.youmonst.data)) {
if (((otmp = uarm) != 0) && (racial_exception(&g.youmonst, otmp) < 1)) {
if ((otmp = uarm) != 0 && racial_exception(&g.youmonst, otmp) < 1) {
if (donning(otmp))
cancel_don();
Your("armor falls around you!");
@@ -1016,6 +1016,21 @@ break_armor()
dropp(otmp);
}
}
/* not armor, but eyewear shouldn't stay worn without a head to wear
it/them on (should also come off if head is too tiny or too huge,
but putting accessories on doesn't reject those cases [yet?]);
amulet stays worn */
if ((otmp = ublindf) != 0 && !has_head(g.youmonst.data)) {
int l;
const char *eyewear = simpleonames(otmp); /* blindfold|towel|lenses */
if (!strncmp(eyewear, "pair of ", l = 8)) /* lenses */
eyewear += l;
Your("%s %s off!", eyewear, vtense(eyewear, "fall"));
(void) Blindf_off((struct obj *) 0); /* Null: skip usual off mesg */
dropp(otmp);
}
/* rings stay worn even when no hands */
}
static void