]> granicus.if.org Git - nethack/commitdiff
B16002
authornethack.allison <nethack.allison>
Fri, 10 Jan 2003 04:00:37 +0000 (04:00 +0000)
committernethack.allison <nethack.allison>
Fri, 10 Jan 2003 04:00:37 +0000 (04:00 +0000)
The complaint states:
It still won't let you unwield a cursed secondary weapon while
two-weaponing, even though you can drop such a weapon without problem.

You aren't supposed to be able to two-weapon
with a cursed alternate weapon at all.  It appears that there are some
checks to prevent twoweaponing if uswapwep is cursed when you try.
This patch ensures that two-weaping stops if uswapwep gets cursed
while two-weaponing.  I think this means the 'A' command will never
encounter the situation now in the complaint now.

The rules in wield.c state
 The secondary weapon (uswapwep):
 1.  Is filled by the x command, which swaps this slot
     with the main weapon.  If the "pushweapon" option is set,
     the w command will also store the old weapon in the
     secondary slot.
 2.  Can be field with anything that will fit in the main weapon
     slot; that is, any type of item.
 3.  Is usually NOT considered to be carried in the hands.
     That would force too many checks among the main weapon,
    second weapon, shield, gloves, and rings; and it would
     further be complicated by bimanual weapons.  A special
     exception is made for two-weapon combat.
 4.  Is used as the second weapon for two-weapon combat, and as
     a convenience to swap with the main weapon.
 5.  Never conveys intrinsics.
 6.  Cursed items never weld (see number 3 for reasons), but they also
     prevent two-weapon combat.

include/extern.h
src/mkobj.c
src/wield.c

index 88955cc313032feed7bce09c34bb51779083d36e..9385f41d41faaeef1ec9b07222bca10b14c04b37 100644 (file)
@@ -2237,6 +2237,7 @@ E int FDECL(chwepon, (struct obj *,int));
 E int FDECL(welded, (struct obj *));
 E void FDECL(weldmsg, (struct obj *));
 E void FDECL(setmnotwielded, (struct monst *,struct obj *));
+E void NDECL(drop_uswapwep);
 
 /* ### windows.c ### */
 
index 2068104bbbcc8ada825dc897352d55ffdd1c5f1d..156b06044c79e30dd5f96df5c72fea567d08d8ee 100644 (file)
@@ -714,6 +714,10 @@ register struct obj *otmp;
        otmp->cursed = 1;
        /* welded two-handed weapon interferes with some armor removal */
        if (otmp == uwep && bimanual(uwep)) reset_remarm();
+       /* rules at top of wield.c state that twoweapon cannot be done
+          with cursed alternate weapon */
+       if (otmp == uswapwep && u.twoweap)
+           drop_uswapwep();
        /* some cursed items need immediate updating */
        if (carried(otmp) && confers_luck(otmp))
            set_moreluck();
index fad266953090b487480c18cba8cfe36d64b09587..53daf89c8ad117f0b84facb21ff0e054d8811e85 100644 (file)
@@ -440,20 +440,26 @@ can_twoweapon()
                Sprintf(kbuf, "%s corpse", an(mons[uswapwep->corpsenm].mname));
                instapetrify(kbuf);
        } else if (Glib || uswapwep->cursed) {
-               char str[BUFSZ];
-               struct obj *obj = uswapwep;
-
-               /* Avoid trashing makeplural's static buffer */
-               Strcpy(str, makeplural(body_part(HAND)));
-               Your("%s from your %s!",  aobjnam(obj, "slip"), str);
                if (!Glib)
-                       obj->bknown = TRUE;
-               dropx(obj);
+                       uswapwep->bknown = TRUE;
+               drop_uswapwep();
        } else
                return (TRUE);
        return (FALSE);
 }
 
+void
+drop_uswapwep()
+{
+       char str[BUFSZ];
+       struct obj *obj = uswapwep;
+
+       /* Avoid trashing makeplural's static buffer */
+       Strcpy(str, makeplural(body_part(HAND)));
+       Your("%s from your %s!",  aobjnam(obj, "slip"), str);
+       dropx(obj);
+}
+
 int
 dotwoweapon()
 {