]> granicus.if.org Git - nethack/commitdiff
wielded leash, monster bullwhip use
authornethack.rankin <nethack.rankin>
Tue, 13 Feb 2007 04:54:35 +0000 (04:54 +0000)
committernethack.rankin <nethack.rankin>
Tue, 13 Feb 2007 04:54:35 +0000 (04:54 +0000)
     Simplify <Someone>'s patch (the part for the secondary weapon wasn't and
still isn't needed since dual-wielding can only occur when both primary
and alternate weapon slots contain weapons or weapon-tools, but we might
as well keep it).  There was at least one other case where wielded in-use
leash could be removed from inventory without becoming unleashed first:
a bullwhip-wielding monster could snatch it away.

     That lead to some other whip issues:  monsters who select disarming
via bullwhip as miscellaneous strategy had 80% chance of not using it on
any given turn, but had no chance to select another misc strategy on such
turns--they always resorted to ordinary nonMUSE behavior and usually just
attacked.  The adjacency check missed diagonal locations, also would aim
the disarm attempt accurately even when displacement or invisibility made
the hero's precise location unknown.  [I took the easy way out here and
only let them try to disarm when they know the hero's location.  It's
tempting to aim at the guessed location and sometimes accidentally disarm
a nearby monster, but disarming is an action which targets a particular
weapon rather than just a location.]  Lastly, disarming always targetted
hero's primary weapon, never a dual-wielder's secondary one.

doc/fixes34.4
src/muse.c
src/polyself.c

index c36634c4f318a858f9994231e10ab15eea6c70cb..a000473c1ad65f0fadfd8d9712c20246bf0a49da 100644 (file)
@@ -321,6 +321,8 @@ fix grammar errors in samurai quest, wakarimasu ka?
 fix spelling of Dr Dolittle
 hero's sleep resistance shouldn't protect steed from sleeping gas trap
 dropped wielded, in use leash should remain in inventory, since it's in-use
+wielded, in use leash can't be snatched by whip-wielding monster
+when using two weapons at once, whip-wielding monster can target either one
 
 
 Platform- and/or Interface-Specific Fixes
index a8466ad42a11d56a054d97ed850307c5beb994a9..d76b5660225eed3ae09ab4378f81c78fdeda5301 100644 (file)
@@ -1629,8 +1629,17 @@ struct monst *mtmp;
                        m.has_misc = MUSE_POT_GAIN_LEVEL;
                }
                nomore(MUSE_BULLWHIP);
-               if(obj->otyp == BULLWHIP && (MON_WEP(mtmp) == obj) &&
-                  distu(mtmp->mx,mtmp->my)==1 && uwep && !mtmp->mpeaceful) {
+               if (obj->otyp == BULLWHIP && !mtmp->mpeaceful &&
+                   /* the random test prevents whip-wielding
+                      monster from attempting disarm every turn */
+                   uwep && !rn2(5) && obj == MON_WEP(mtmp) &&
+                   /* hero's location must be known and adjacent */
+                   mtmp->mux == u.ux && mtmp->muy == u.uy &&
+                   distu(mtmp->mx, mtmp->my) <= 2 &&
+                   /* don't bother if it can't work (this doesn't
+                      prevent cursed weapons from being targetted) */
+                   (canletgo(uwep, "") ||
+                           (u.twoweap && canletgo(uswapwep, "")))) {
                        m.misc = obj;
                        m.has_misc = MUSE_BULLWHIP;
                }
@@ -1824,13 +1833,18 @@ skipmsg:
                return 2;
        case MUSE_BULLWHIP:
                /* attempt to disarm hero */
-               if (uwep && !rn2(5)) {
+               {
                    const char *The_whip = vismon ? "The bullwhip" : "A whip";
                    int where_to = rn2(4);
                    struct obj *obj = uwep;
                    const char *hand;
                    char the_weapon[BUFSZ];
 
+                   if (!obj || !canletgo(obj, "") ||
+                           (u.twoweap && canletgo(uswapwep, "") && rn2(2)))
+                       obj = uswapwep;
+                   if (!obj) break; /* shouldn't happen after find_misc() */
+
                    Strcpy(the_weapon, the(xname(obj)));
                    hand = body_part(HAND);
                    if (bimanual(obj)) hand = makeplural(hand);
@@ -1861,8 +1875,8 @@ skipmsg:
                           weapon; drop it at hero's feet instead */
                        where_to = 2;
                    }
+                   remove_worn_item(obj, FALSE);
                    freeinv(obj);
-                   uwepgone();
                    switch (where_to) {
                        case 1:         /* onto floor beneath mon */
                            pline("%s yanks %s from your %s!", Monnam(mtmp),
index 7327cd70be5ba2098ba3e07030bbc0564a9d30cf..da58d70c1a0348e8fd2d9a57c7e933944407f619 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)polyself.c 3.5     2006/12/01      */
+/*     SCCS Id: @(#)polyself.c 3.5     2007/02/12      */
 /*     Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -722,30 +722,24 @@ drop_weapon(alone)
 int alone;
 {
     struct obj *otmp;
-    struct obj *otmp2;
 
-    if ((otmp = uwep) != 0) {
+    if (uwep) {
        /* !alone check below is currently superfluous but in the
         * future it might not be so if there are monsters which cannot
         * wear gloves but can wield weapons
         */
        if (!alone || cantwield(youmonst.data)) {
-           struct obj *wep = uwep;
-
            if (alone) You("find you must drop your weapon%s!",
-                               u.twoweap ? "s" : "");
-           otmp2 = u.twoweap ? uswapwep : 0;
-           uwepgone();
-           if ((!wep->cursed || wep->otyp != LOADSTONE) &&
-               (wep->otyp != LEASH || wep->leashmon == 0))
-               dropx(otmp);
-           if (otmp2 != 0) {
+                          u.twoweap ? "s" : "");
+           if (u.twoweap) {
+               otmp = uswapwep;
                uswapwepgone();
-               if ((!otmp2->cursed || otmp2->otyp != LOADSTONE) &&
-                   (otmp2->otyp != LEASH || otmp2->leashmon == 0))
-                   dropx(otmp2);
+               if (canletgo(otmp, "")) dropx(otmp);
            }
-           untwoweapon();
+           otmp = uwep;
+           uwepgone();
+           if (canletgo(otmp, "")) dropx(otmp);
+           update_inventory();
        } else if (!could_twoweap(youmonst.data)) {
            untwoweapon();
        }