'T' failure feedback; suit_simple_name() (trunk only)

The post-3.4.3 ring removal bug also applied to suit when wearing a
cloak and shirt when wearing a suit or cloak or both, although it would
never give "you have nothing else to take off" because the covering item
was always present as a likely candidate.  The ring fix also fixed armor.
When testing that fix, I saw "you can't take that off" for trying to take
off a suit while wearing a cloak.  That isn't new or a bug, but it seemed
awfully terse so I've changed it to give "you can't take that off without
taking off your cloak first".  (Likewise, "cloak", "suit", or "cloak and
suit" as appropriate when trying to take off a shirt.)

     This adds new routine `suit_simple_name()', comparable to 3.4.3's
cloak_simple_name() and post-3.4.3 helm_simple_name().  No doubt there
are other places besides "without taking off your X first" that could
make use of it but I haven't attempted to track them down.  The "you are
already wearing _some armor_" one doesn't quite fit.  It would need to
adjust "some" to "a"/"an" at times ("some mail" or "some dragon scales"
vs "a suit" or "a jacket").
This commit is contained in:
nethack.rankin
2008-01-25 03:25:38 +00:00
parent c0b85902a8
commit c68ffb4607
3 changed files with 38 additions and 3 deletions

View File

@@ -1570,6 +1570,7 @@ E char *FDECL(makeplural, (const char *));
E char *FDECL(makesingular, (const char *));
E struct obj *FDECL(readobjnam, (char *,struct obj *));
E int FDECL(rnd_class, (int,int));
E const char *FDECL(suit_simple_name, (struct obj *));
E const char *FDECL(cloak_simple_name, (struct obj *));
E const char *FDECL(helm_simple_name, (struct obj *));
E const char *FDECL(mimic_obj_name, (struct monst *));

View File

@@ -1118,7 +1118,20 @@ dotakeoff()
|| ((otmp == uarmu) && (uarmc || uarm))
#endif
) {
You_cant("take that off.");
char why[BUFSZ], what[BUFSZ];
why[0] = what[0] = '\0';
if (otmp != uskin) {
if (uarmc) Strcat(what, cloak_simple_name(uarmc));
#ifdef TOURIST
if ((otmp == uarmu) && uarm) {
if (uarmc) Strcat(what, " and ");
Strcat(what, suit_simple_name(uarm));
}
#endif
Sprintf(why, " without taking off your %s first", what);
}
You_cant("take that off%s.", why);
return 0;
}
@@ -1406,7 +1419,8 @@ boolean noisy;
*mask = W_ARMC;
} else if (is_suit(otmp)) {
if (uarmc) {
if (noisy) You("cannot wear armor over a %s.", cloak_simple_name(uarmc));
if (noisy) You("cannot wear armor over a %s.",
cloak_simple_name(uarmc));
err++;
} else if (uarm) {
if (noisy) already_wearing("some armor");

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)objnam.c 3.5 2007/04/30 */
/* SCCS Id: @(#)objnam.c 3.5 2008/01/23 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3226,6 +3226,26 @@ int i;
return (const char *)0;
}
const char *
suit_simple_name(suit)
struct obj *suit;
{
const char *suitnm, *esuitp;
if (Is_dragon_mail(suit))
return "dragon mail"; /* <color> dragon scale mail */
else if (Is_dragon_scales(suit))
return "dragon scales";
suitnm = OBJ_NAME(objects[suit->otyp]);
esuitp = eos((char *)suitnm);
if (strlen(suitnm) > 5 && !strcmp(esuitp - 5, " mail"))
return "mail"; /* most suits fall into this category */
else if (strlen(suitnm) > 7 && !strcmp(esuitp - 7, " jacket"))
return "jacket"; /* leather jacket */
/* suit is lame but armor is ambiguous and body armor is absurd */
return "suit";
}
const char *
cloak_simple_name(cloak)
struct obj *cloak;