]> granicus.if.org Git - nethack/commitdiff
theft vs donning, round 2 (trunk only)
authornethack.rankin <nethack.rankin>
Sun, 5 Feb 2012 04:26:48 +0000 (04:26 +0000)
committernethack.rankin <nethack.rankin>
Sun, 5 Feb 2012 04:26:48 +0000 (04:26 +0000)
     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.

include/extern.h
src/do_wear.c
src/mhitu.c
src/steal.c

index abf3e410c7555f0ad18135bcc24a81711ab80b72..e21631c18559564bac1dda422650fcba003e6876 100644 (file)
@@ -416,6 +416,7 @@ E int NDECL(take_off);
 E void FDECL(off_msg, (struct obj *));
 E void FDECL(set_wear, (struct obj *));
 E boolean FDECL(donning, (struct obj *));
+E boolean FDECL(doffing, (struct obj *));
 E void NDECL(cancel_don);
 E int FDECL(stop_donning, (struct obj *));
 E int NDECL(Armor_off);
index def059815f95270c0e51fca887c11d8bc50f8195..42f23491aeafcd21768e3a77a1a5e063f79f1cbd 100644 (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
index 1f379388b47d559955a89f90cf4f82ccd04a6b45..1d650f23d25bf16862ddd91979297ee9e1617b06 100644 (file)
@@ -2263,7 +2263,7 @@ register struct monst *mon;
        else You_feel("very attracted to %s.", mon_nam(mon));
        /* if in the process of putting armor on or taking armor off,
           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 */
        if (welded(uwep)) tried_gloves = 1;
 
index 6016e41a9558c8e4b4645c652006cf58e3b1ac34..21712a3f297d7310527e7b30135158e3477b317b 100644 (file)
@@ -272,7 +272,8 @@ char *objnambuf;
 {
        struct obj *otmp;
        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';
        /* the following is true if successful on first of two attacks. */
@@ -391,6 +392,7 @@ gotobj:
            o_unleash(otmp);
        }
 
+       was_doffing = doffing(otmp);
        /* stop donning/doffing now so that afternmv won't be clobbered
           below; stop_occupation doesn't handle donning/doffing */
        olddelay = stop_donning(otmp);
@@ -429,13 +431,17 @@ gotobj:
                            pline("%s charms you.  You gladly %s your %s.",
                                  !seen ? "She" : Monnam(mtmp),
                                  curssv ? "let her take" :
-                                 slowly ? "start removing" : "hand over",
+                                   !slowly ? "hand over" :
+                                     was_doffing ? "continue removing" :
+                                       "start removing",
                                  equipname(otmp));
                        else
                            pline("%s seduces you and %s off your %s.",
                                  !seen ? "She" : Adjmonnam(mtmp, "beautiful"),
                                  curssv ? "helps you to take" :
-                                 slowly ? "you start taking" : "you take",
+                                   !slowly ? "you take" :
+                                     was_doffing ? "you continue taking" :
+                                       "you start taking",
                                  equipname(otmp));
                        named++;
                        /* the following is to set multi for later on */