From 658c931aad65c2729768de49a5f1597e9608ccf0 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Tue, 13 Feb 2007 04:54:35 +0000 Subject: [PATCH] wielded leash, monster bullwhip use Simplify '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 | 2 ++ src/muse.c | 22 ++++++++++++++++++---- src/polyself.c | 26 ++++++++++---------------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index c36634c4f..a000473c1 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -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 diff --git a/src/muse.c b/src/muse.c index a8466ad42..d76b56602 100644 --- a/src/muse.c +++ b/src/muse.c @@ -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), diff --git a/src/polyself.c b/src/polyself.c index 7327cd70b..da58d70c1 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -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(); }