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

@@ -416,6 +416,7 @@ E int NDECL(take_off);
E void FDECL(off_msg, (struct obj *)); E void FDECL(off_msg, (struct obj *));
E void FDECL(set_wear, (struct obj *)); E void FDECL(set_wear, (struct obj *));
E boolean FDECL(donning, (struct obj *)); E boolean FDECL(donning, (struct obj *));
E boolean FDECL(doffing, (struct obj *));
E void NDECL(cancel_don); E void NDECL(cancel_don);
E int FDECL(stop_donning, (struct obj *)); E int FDECL(stop_donning, (struct obj *));
E int NDECL(Armor_off); E int NDECL(Armor_off);

View File

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

View File

@@ -2263,7 +2263,7 @@ register struct monst *mon;
else You_feel("very attracted to %s.", mon_nam(mon)); else You_feel("very attracted to %s.", mon_nam(mon));
/* if in the process of putting armor on or taking armor off, /* if in the process of putting armor on or taking armor off,
interrupt that activity now */ interrupt that activity now */
stop_donning((struct obj *)0); (void) stop_donning((struct obj *)0);
/* don't try to take off gloves if cursed weapon blocks them */ /* don't try to take off gloves if cursed weapon blocks them */
if (welded(uwep)) tried_gloves = 1; if (welded(uwep)) tried_gloves = 1;

View File

@@ -272,7 +272,8 @@ char *objnambuf;
{ {
struct obj *otmp; struct obj *otmp;
int tmp, could_petrify, armordelay, olddelay, named = 0, retrycnt = 0; int tmp, could_petrify, armordelay, olddelay, named = 0, retrycnt = 0;
boolean monkey_business; /* true iff an animal is doing the thievery */ boolean monkey_business, /* true iff an animal is doing the thievery */
was_doffing;
if (objnambuf) *objnambuf = '\0'; if (objnambuf) *objnambuf = '\0';
/* the following is true if successful on first of two attacks. */ /* the following is true if successful on first of two attacks. */
@@ -391,6 +392,7 @@ gotobj:
o_unleash(otmp); o_unleash(otmp);
} }
was_doffing = doffing(otmp);
/* stop donning/doffing now so that afternmv won't be clobbered /* stop donning/doffing now so that afternmv won't be clobbered
below; stop_occupation doesn't handle donning/doffing */ below; stop_occupation doesn't handle donning/doffing */
olddelay = stop_donning(otmp); olddelay = stop_donning(otmp);
@@ -429,13 +431,17 @@ gotobj:
pline("%s charms you. You gladly %s your %s.", pline("%s charms you. You gladly %s your %s.",
!seen ? "She" : Monnam(mtmp), !seen ? "She" : Monnam(mtmp),
curssv ? "let her take" : curssv ? "let her take" :
slowly ? "start removing" : "hand over", !slowly ? "hand over" :
was_doffing ? "continue removing" :
"start removing",
equipname(otmp)); equipname(otmp));
else else
pline("%s seduces you and %s off your %s.", pline("%s seduces you and %s off your %s.",
!seen ? "She" : Adjmonnam(mtmp, "beautiful"), !seen ? "She" : Adjmonnam(mtmp, "beautiful"),
curssv ? "helps you to take" : curssv ? "helps you to take" :
slowly ? "you start taking" : "you take", !slowly ? "you take" :
was_doffing ? "you continue taking" :
"you start taking",
equipname(otmp)); equipname(otmp));
named++; named++;
/* the following is to set multi for later on */ /* the following is to set multi for later on */