From: nethack.rankin Date: Thu, 30 Jan 2003 11:31:12 +0000 (+0000) Subject: fix B18002 and B18003 - #rub worn blindfold and wield_tool() feedback X-Git-Tag: MOVE2GIT~2216 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1114722335c8120d95881eb23392a3d0d0c44ae0;p=nethack fix B18002 and B18003 - #rub worn blindfold and wield_tool() feedback Prevent #rub from wielding an item that is already being worn (which should narrow things down to the various types of eyewear; other tools and weapons that go through wield_tool() can't be worn). Fix up the wield_tool message spacing in the process. This moves wield_tool() from apply.c to wield.c. Some plural handling for messages is included; it is feasible to try to #rub a "pair of lenses" or a stack of N candles. --- diff --git a/doc/fixes34.1 b/doc/fixes34.1 index 96feacdbd..79edb4e0c 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -367,6 +367,7 @@ when adding an object to inventory, it is possible for it to becomed both include rocks as likely candidates for quivering if alternate weapon is a sling Asmodeus fails an is_armed() check, so code in m_initweap() to give him wands of fire and cold never got called; move the code to m_initinv() +#rub would wield the target tool even when already being worn as eyewear Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index c5dcad1d7..232375adb 100644 --- a/include/extern.h +++ b/include/extern.h @@ -39,7 +39,6 @@ E void NDECL(unleash_all); E boolean NDECL(next_to_u); E struct obj *FDECL(get_mleash, (struct monst *)); E void FDECL(check_leash, (XCHAR_P,XCHAR_P)); -E boolean FDECL(wield_tool, (struct obj *)); E boolean FDECL(um_dist, (XCHAR_P,XCHAR_P,XCHAR_P)); E boolean FDECL(snuff_candle, (struct obj *)); E boolean FDECL(snuff_lit, (struct obj *)); @@ -2226,18 +2225,19 @@ E void FDECL(setuswapwep, (struct obj *)); E int NDECL(dowield); E int NDECL(doswapweapon); E int NDECL(dowieldquiver); -E int NDECL(dotwoweapon); +E boolean FDECL(wield_tool, (struct obj *,const char *)); E int NDECL(can_twoweapon); -E void NDECL(untwoweapon); +E void NDECL(drop_uswapwep); +E int NDECL(dotwoweapon); E void NDECL(uwepgone); E void NDECL(uswapwepgone); E void NDECL(uqwepgone); +E void NDECL(untwoweapon); E void FDECL(erode_obj, (struct obj *,BOOLEAN_P,BOOLEAN_P)); 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 ### */ diff --git a/src/apply.c b/src/apply.c index 44e274b5a..3459bc2ff 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)apply.c 3.4 2003/01/08 */ +/* SCCS Id: @(#)apply.c 3.4 2003/01/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -570,48 +570,6 @@ register xchar x, y; #endif /* OVL0 */ #ifdef OVLB -boolean -wield_tool(obj) -struct obj *obj; -{ - if(welded(uwep)) { - /* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */ - if(flags.verbose) { - pline("Since your weapon is welded to your %s,", - bimanual(uwep) ? - (const char *)makeplural(body_part(HAND)) - : body_part(HAND)); - pline("you cannot wield that %s.", xname(obj)); - } - return(FALSE); - } - if (cantwield(youmonst.data)) { - You_cant("hold it strongly enough."); - return(FALSE); - } - /* Check shield */ - if (uarms && bimanual(obj)) { - You("cannot wield a two-handed tool while wearing a shield."); - return(FALSE); - } - if(uquiver == obj) setuqwep((struct obj *)0); - if(uswapwep == obj) { - (void) doswapweapon(); - /* If doswapweapon failed... */ - if(uswapwep == obj) return (FALSE); - } else { - You("now wield %s.", doname(obj)); - setuwep(obj); - } - if (uwep != obj) return(FALSE); /* rewielded old object after dying */ - /* applying weapon or tool that gets wielded ends two-weapon combat */ - if (u.twoweap) - untwoweapon(); - if (obj->oclass != WEAPON_CLASS) - unweapon = TRUE; - return(TRUE); -} - #define WEAK 3 /* from eat.c */ static const char look_str[] = "look %s."; @@ -1188,7 +1146,7 @@ dorub() } } - if(!obj || (obj != uwep && !wield_tool(obj))) return 0; + if (!obj || !wield_tool(obj, "rub")) return 0; /* now uwep is obj */ if (uwep->otyp == MAGIC_LAMP) { @@ -2090,10 +2048,8 @@ struct obj *obj; const char *msg_snap = "Snap!"; if (obj != uwep) { - if (!wield_tool(obj)) return 0; + if (!wield_tool(obj, "lash")) return 0; else res = 1; - /* prevent bashing msg */ - unweapon = FALSE; } if (!getdir((char *)0)) return res; @@ -2351,7 +2307,7 @@ use_pole (obj) return (0); } if (obj != uwep) { - if (!wield_tool(obj)) return(0); + if (!wield_tool(obj, "swing")) return(0); else res = 1; } /* assert(obj == uwep); */ @@ -2452,7 +2408,7 @@ use_grapple (obj) return (0); } if (obj != uwep) { - if (!wield_tool(obj)) return(0); + if (!wield_tool(obj, "cast")) return(0); else res = 1; } /* assert(obj == uwep); */ diff --git a/src/dig.c b/src/dig.c index e6b69b319..a484f2c39 100644 --- a/src/dig.c +++ b/src/dig.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)dig.c 3.4 2003/01/08 */ +/* SCCS Id: @(#)dig.c 3.4 2003/01/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -820,7 +820,7 @@ struct obj *obj; /* Check tool */ if (obj != uwep) { - if (!wield_tool(obj)) return(0); + if (!wield_tool(obj, "swing")) return 0; else res = 1; } ispick = is_pick(obj); diff --git a/src/wield.c b/src/wield.c index 92e84cf91..04231166a 100644 --- a/src/wield.c +++ b/src/wield.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)wield.c 3.4 2002/08/03 */ +/* SCCS Id: @(#)wield.c 3.4 2003/01/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -397,6 +397,74 @@ dowieldquiver() return (0); } +/* used for #rub and for applying pick-axe, whip, grappling hook, or polearm */ +/* (moved from apply.c) */ +boolean +wield_tool(obj, verb) +struct obj *obj; +const char *verb; /* "rub",&c */ +{ + const char *what; + boolean more_than_1; + + if (obj == uwep) return TRUE; /* nothing to do if already wielding it */ + + if (!verb) verb = "wield"; + what = xname(obj); + more_than_1 = (obj->quan > 1L || + strstri(what, "pair of ") != 0 || + strstri(what, "s of ") != 0); + + if (obj->owornmask & (W_ARMOR|W_RING|W_AMUL|W_TOOL)) { + char yourbuf[BUFSZ]; + + You_cant("%s %s %s while wearing %s.", + verb, shk_your(yourbuf, obj), what, + more_than_1 ? "them" : "it"); + return FALSE; + } + if (welded(uwep)) { + if (flags.verbose) { + const char *hand = body_part(HAND); + + if (bimanual(uwep)) hand = makeplural(hand); + if (strstri(what, "pair of ") != 0) more_than_1 = FALSE; + pline( + "Since your weapon is welded to your %s, you cannot %s %s %s.", + hand, verb, more_than_1 ? "those" : "that", xname(obj)); + } else { + You_cant("do that."); + } + return FALSE; + } + if (cantwield(youmonst.data)) { + You_cant("hold %s strongly enough.", more_than_1 ? "them" : "it"); + return FALSE; + } + /* check shield */ + if (uarms && bimanual(obj)) { + You("cannot %s a two-handed %s while wearing a shield.", + verb, (obj->oclass == WEAPON_CLASS) ? "weapon" : "tool"); + return FALSE; + } + if (uquiver == obj) setuqwep((struct obj *)0); + if (uswapwep == obj) { + (void) doswapweapon(); + /* doswapweapon might fail */ + if (uswapwep == obj) return FALSE; + } else { + You("now wield %s.", doname(obj)); + setuwep(obj); + } + if (uwep != obj) return FALSE; /* rewielded old object after dying */ + /* applying weapon or tool that gets wielded ends two-weapon combat */ + if (u.twoweap) + untwoweapon(); + if (obj->oclass != WEAPON_CLASS) + unweapon = TRUE; + return TRUE; +} + int can_twoweapon() {