Skip to content

Commit

Permalink
Glib messages when dropping weapons
Browse files Browse the repository at this point in the history
     <Someone> reported that she got "your weapon slips from your hands" when
inflicted with slippery fingers while wielding multiple daggers.  That
should be "weapons" plural and they're only being dropped from one "hand"
singular.  Fix that and also give more specific feedback than "weapon"
for non-swords based on their weapon skill category names.  This works
pretty well for most common weapons but might need some more tweaking for
ones where different types have gotten lumped together in the skills.

old feedback:
  Your weapon slips from your hands.
  Your tool slips from your hands.
  Your food slips from your hands.
twoweapon:
  Your sword slips from your hands.
  Your other sword also slips from your hands.

new feedback:
  Your daggers slip from your hand.
  Your <one-hander> slips from your hand.
  Your <two-hander> slips from your hands.
  Your pick-axe slips from your hand.
  The corpse slips from your hand.
twoweapon:
  Your sword slips from your left hand.
  Your other sword also slips from your right hand.
  • Loading branch information
nethack.rankin committed Nov 2, 2004
1 parent a6182d9 commit aa58ee1
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 21 deletions.
1 change: 1 addition & 0 deletions doc/fixes34.4
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ incorrect screen display if engulfer gets turned to stone when trying to
swallow while hero is poly'd into cockatrice
panic on subsequent move if engulfer gets turned to stone and poly'd hero
also has attached ball&chain
give more specific messages when dropping weapons due to slippery fingers


Platform- and/or Interface-Specific Fixes
Expand Down
1 change: 1 addition & 0 deletions include/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,7 @@ E int NDECL(dosuspend);

/* ### weapon.c ### */

E const char *FDECL(weapon_descr, (struct obj *));
E int FDECL(hitval, (struct obj *,struct monst *));
E int FDECL(dmgval, (struct obj *,struct monst *));
E struct obj *FDECL(select_rwep, (struct monst *));
Expand Down
62 changes: 42 additions & 20 deletions src/do_wear.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)do_wear.c 3.4 2004/06/30 */
/* SCCS Id: @(#)do_wear.c 3.4 2004/10/29 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */

Expand Down Expand Up @@ -1616,8 +1616,8 @@ glibr()
{
register struct obj *otmp;
int xfl = 0;
boolean leftfall, rightfall;
const char *otherwep = 0;
boolean leftfall, rightfall, wastwoweap = FALSE;
const char *otherwep = 0, *thiswep, *which, *hand;

leftfall = (uleft && !uleft->cursed &&
(!uwep || !welded(uwep) || !bimanual(uwep)));
Expand All @@ -1643,31 +1643,53 @@ glibr()

otmp = uswapwep;
if (u.twoweap && otmp) {
otherwep = is_sword(otmp) ? c_sword :
makesingular(oclass_names[(int)otmp->oclass]);
Your("%s %sslips from your %s.",
otherwep,
xfl ? "also " : "",
makeplural(body_part(HAND)));
setuswapwep((struct obj *)0);
/* secondary weapon doesn't need nearly as much handling as
primary; when in two-weapon mode, we know it's one-handed
with something else in the other hand and also that it's
a weapon or weptool rather than something unusual, plus
we don't need to compare its type with the primary */
otherwep = is_sword(otmp) ? c_sword : weapon_descr(otmp);
if (otmp->quan > 1L) otherwep = makeplural(otherwep);
hand = body_part(HAND);
which = "left ";
Your("%s %s%s from your %s%s.",
otherwep, xfl ? "also " : "",
otense(otmp, "slip"), which, hand);
xfl++;
wastwoweap = TRUE;
setuswapwep((struct obj *)0); /* clears u.twoweap */
if (otmp->otyp != LOADSTONE || !otmp->cursed)
dropx(otmp);
}
otmp = uwep;
if (otmp && !welded(otmp)) {
const char *thiswep;
long savequan = otmp->quan;

/* nice wording if both weapons are the same type */
thiswep = is_sword(otmp) ? c_sword :
makesingular(oclass_names[(int)otmp->oclass]);
if (otherwep && strcmp(thiswep, otherwep)) otherwep = 0;

/* changed so cursed weapons don't fall, GAN 10/30/86 */
Your("%s%s %sslips from your %s.",
otherwep ? "other " : "", thiswep,
xfl ? "also " : "",
makeplural(body_part(HAND)));
thiswep = is_sword(otmp) ? c_sword : weapon_descr(otmp);
if (otherwep && strcmp(thiswep, makesingular(otherwep)))
otherwep = 0;
if (otmp->quan > 1L) {
/* most class names for unconventional wielded items
are ok, but if wielding multiple apples or rations
we don't want "your foods slip", so force non-corpse
food to be singular; skipping makeplural() isn't
enough--we need to fool otense() too */
if (!strcmp(thiswep, "food")) otmp->quan = 1L;
else thiswep = makeplural(thiswep);
}
hand = body_part(HAND);
which = "";
if (bimanual(otmp))
hand = makeplural(hand);
else if (wastwoweap)
which = "right "; /* preceding msg was about left */
pline("%s %s%s %s%s from your %s%s.",
!strncmp(thiswep, "corpse", 6) ? "The" : "Your",
otherwep ? "other " : "", thiswep, xfl ? "also " : "",
otense(otmp, "slip"), which, hand);
/* xfl++; */
otmp->quan = savequan;
setuwep((struct obj *)0);
if (otmp->otyp != LOADSTONE || !otmp->cursed)
dropx(otmp);
Expand Down
43 changes: 42 additions & 1 deletion src/weapon.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)weapon.c 3.4 2004/06/12 */
/* SCCS Id: @(#)weapon.c 3.4 2004/10/29 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */

Expand Down Expand Up @@ -101,6 +101,47 @@ static NEARDATA const char kebabable[] = {
S_XORN, S_DRAGON, S_JABBERWOCK, S_NAGA, S_GIANT, '\0'
};

/* weapon's skill category name for use as generalized description of weapon */
const char *weapon_descr(obj)
struct obj *obj;
{
int skill = weapon_type(obj);
const char *descr = P_NAME(skill);

/* assorted special cases */
switch (skill) {
case P_NONE:
/* not a weapon: use item class name; override "food" for corpses */
descr = (obj->otyp == CORPSE) ? "corpse" :
oclass_names[(int)obj->oclass];
break;
case P_SLING:
if (is_ammo(obj))
descr = (obj->otyp == ROCK || is_graystone(obj)) ? "stone" :
/* avoid "rock"; what about known glass? */
(obj->oclass == GEM_CLASS) ? "gem" :
/* in case somebody adds odd sling ammo */
oclass_names[(int)obj->oclass];
break;
case P_BOW:
if (is_ammo(obj)) descr = "arrow";
break;
case P_CROSSBOW:
if (is_ammo(obj)) descr = "bolt";
break;
case P_FLAIL:
if (obj->otyp == GRAPPLING_HOOK) descr = "hook";
break;
case P_PICK_AXE:
/* even if "dwarvish mattock" hasn't been discovered yet */
if (obj->otyp == DWARVISH_MATTOCK) descr = "mattock";
break;
default:
break;
}
return makesingular(descr);
}

/*
* hitval returns an integer representing the "to hit" bonuses
* of "otmp" against the monster.
Expand Down

0 comments on commit aa58ee1

Please sign in to comment.