theft vs donning, round 2 (trunk only)

The message "you stop taking off <that armor>" when interrupted by a
nymph's or monkey's theft attack would only be given if you were using 'A'
to take off the armor.  If you used 'T', you'd get "you stop putting on
<that armor>" instead.  The fix for that also makes it easy to vary the
nymph message "<the nymph persuades> you to start taking off" to be "<the
nymph persuades you to continue taking off" when taking that same piece
of armor off was interrupted by the theft.
This commit is contained in:
nethack.rankin
2012-02-05 04:26:48 +00:00
parent ef888e065a
commit a2f15cfd61
4 changed files with 50 additions and 11 deletions

View File

@@ -1158,6 +1158,7 @@ register struct obj *otmp;
long what = context.takeoff.what; /* if nonzero, occupation is implied */
boolean result = FALSE;
/* 'W' and 'T' set afternmv, 'A' sets context.takeoff.what */
if (otmp == uarm)
result = (afternmv == Armor_on || afternmv == Armor_off ||
what == WORN_ARMOR);
@@ -1185,6 +1186,36 @@ register struct obj *otmp;
return result;
}
/* check whether the target object is currently being taken off,
so that stop_donning() and steal() can vary messages */
boolean
doffing(otmp)
struct obj *otmp;
{
long what = context.takeoff.what;
boolean result = FALSE;
/* 'T' (also 'W') sets afternmv, 'A' sets context.takeoff.what */
if (otmp == uarm)
result = (afternmv == Armor_off || what == WORN_ARMOR);
#ifdef TOURIST
else if (otmp == uarmu)
result = (afternmv == Shirt_off || what == WORN_SHIRT);
#endif
else if (otmp == uarmc)
result = (afternmv == Cloak_off || what == WORN_CLOAK);
else if (otmp == uarmf)
result = (afternmv == Boots_off || what == WORN_BOOTS);
else if (otmp == uarmh)
result = (afternmv == Helmet_off || what == WORN_HELMET);
else if (otmp == uarmg)
result = (afternmv == Gloves_off || what == WORN_GLOVES);
else if (otmp == uarms)
result = (afternmv == Shield_off || what == WORN_SHIELD);
return result;
}
void
cancel_don()
{
@@ -1211,27 +1242,28 @@ struct obj *stolenobj; /* no message if stolenobj is already being doffing */
char buf[BUFSZ];
struct obj *otmp;
boolean putting_on;
int result;
int result = 0;
for (otmp = invent; otmp; otmp = otmp->nobj)
if ((otmp->owornmask & W_ARMOR) && donning(otmp)) break;
/* at most one item will pass donning() test at any given time */
if (!otmp) return 0;
result = -multi; /* remember this before calling unmul() */
/* donning() returns True when doffing too */
putting_on = !(context.takeoff.mask & otmp->owornmask);
/* donning() returns True when doffing too; doffing() is more specific */
putting_on = !doffing(otmp);
/* cancel_don() looks at afternmv; it also serves as cancel_doff() */
cancel_don();
/* don't want <armor>_on() or <armor>_off() being called
by unmul() since the on or off action isn't completing */
afternmv = 0;
if (putting_on || otmp != stolenobj)
if (putting_on || otmp != stolenobj) {
Sprintf(buf, "You stop %s %s.",
putting_on ? "putting on" : "taking off",
thesimpleoname(otmp));
else
buf[0] = '\0'; /* silently stop doffing stolenobj */
} else {
buf[0] = '\0'; /* silently stop doffing stolenobj */
result = -multi; /* remember this before calling unmul() */
}
unmul(buf);
/* while putting on, item becomes worn immediately but side-effects are
deferred until the delay expires; when interrupted, make it unworn