From: PatR Date: Wed, 19 Feb 2020 23:47:55 +0000 (-0800) Subject: Wounded_legs condition X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfd425d5db44b806a88c61dcb7ef3e80ab0ef16f;p=nethack Wounded_legs condition Mounting a steed while legs are wounded would offer to cure them but wasn't going through the heal_legs() routine so didn't update the status line when Wounded_legs condition is enabled. Move some common code for describing left/right/both legs into a new routine used for feedback by jumping, kicking, and ridiing. For ^X, distinguish between one wounded leg and both but don't bother with left vs right when it is just one. --- diff --git a/include/extern.h b/include/extern.h index 7fdfeb039..4edf4423a 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1581985538 2020/02/18 00:25:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.798 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1582155854 2020/02/19 23:44:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.799 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -418,6 +418,7 @@ E boolean FDECL(revive_corpse, (struct obj *)); E void FDECL(revive_mon, (ANY_P *, long)); E int NDECL(donull); E int NDECL(dowipe); +E void FDECL(legs_in_no_shape, (const char *, BOOLEAN_P)); E void FDECL(set_wounded_legs, (long, int)); E void FDECL(heal_legs, (int)); diff --git a/src/apply.c b/src/apply.c index 50967cebe..09414ecaf 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 apply.c $NHDT-Date: 1581886857 2020/02/16 21:00:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.317 $ */ +/* NetHack 3.6 apply.c $NHDT-Date: 1582155875 2020/02/19 23:44:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.318 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1747,18 +1747,7 @@ int magic; /* 0=Physical, otherwise skill level */ You("lack the strength to jump!"); return 0; } else if (!magic && Wounded_legs) { - long wl = (Wounded_legs & BOTH_SIDES); - const char *bp = body_part(LEG); - - if (wl == BOTH_SIDES) - bp = makeplural(bp); - if (u.usteed) - pline("%s is in no shape for jumping.", Monnam(u.usteed)); - else - Your("%s%s %s in no shape for jumping.", - (wl == LEFT_SIDE) ? "left " : (wl == RIGHT_SIDE) ? "right " - : "", - bp, (wl == BOTH_SIDES) ? "are" : "is"); + legs_in_no_shape("jumping", u.usteed != 0); return 0; } else if (u.usteed && u.utrap) { pline("%s is stuck in a trap.", Monnam(u.usteed)); diff --git a/src/do.c b/src/do.c index 5ea2e2c6a..33dc73006 100644 --- a/src/do.c +++ b/src/do.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 do.c $NHDT-Date: 1581886859 2020/02/16 21:00:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.227 $ */ +/* NetHack 3.6 do.c $NHDT-Date: 1582155879 2020/02/19 23:44:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.228 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1050,7 +1050,8 @@ dodown() if (trap) { const char *down_or_thru = trap->ttyp == HOLE ? "down" : "through"; - const char *actn = Flying ? "fly" : locomotion(g.youmonst.data, "jump"); + const char *actn = Flying ? "fly" + : locomotion(g.youmonst.data, "jump"); if (g.youmonst.data->msize >= MZ_HUGE) { char qbuf[QBUFSZ]; @@ -2008,6 +2009,26 @@ dowipe() return 1; } +/* common wounded legs feedback */ +void +legs_in_no_shape(for_what, by_steed) +const char *for_what; /* jumping, kicking, riding */ +boolean by_steed; +{ + if (by_steed && u.usteed) { + pline("%s is in no shape for %s.", Monnam(u.usteed), for_what); + } else { + long wl = (EWounded_legs & BOTH_SIDES); + const char *bp = body_part(LEG); + + if (wl == BOTH_SIDES) + bp = makeplural(bp); + Your("%s%s %s in no shape for %s.", + (wl == LEFT_SIDE) ? "left " : (wl == RIGHT_SIDE) ? "right " : "", + bp, (wl == BOTH_SIDES) ? "are" : "is", for_what); + } +} + void set_wounded_legs(side, timex) long side; diff --git a/src/dokick.c b/src/dokick.c index 212301d3b..7eb52bd94 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dokick.c $NHDT-Date: 1577674533 2019/12/30 02:55:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.152 $ */ +/* NetHack 3.6 dokick.c $NHDT-Date: 1582155880 2020/02/19 23:44:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.153 $ */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -788,15 +788,7 @@ dokick() return 0; } } else if (Wounded_legs) { - /* note: jump() has similar code */ - long wl = (EWounded_legs & BOTH_SIDES); - const char *bp = body_part(LEG); - - if (wl == BOTH_SIDES) - bp = makeplural(bp); - Your("%s%s %s in no shape for kicking.", - (wl == LEFT_SIDE) ? "left " : (wl == RIGHT_SIDE) ? "right " : "", - bp, (wl == BOTH_SIDES) ? "are" : "is"); + legs_in_no_shape("kicking", FALSE); no_kick = TRUE; } else if (near_capacity() > SLT_ENCUMBER) { Your("load is too heavy to balance yourself for a kick."); diff --git a/src/insight.c b/src/insight.c index c368c4403..60c8cb25f 100644 --- a/src/insight.c +++ b/src/insight.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 insight.c $NHDT-Date: 1581362470 2020/02/10 19:21:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.2 $ */ +/* NetHack 3.7 insight.c $NHDT-Date: 1582155881 2020/02/19 23:44:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.4 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -927,7 +927,12 @@ int final; enl_msg(buf, " has", " had", " wounded legs", ""); } } else { - Sprintf(buf, "wounded %s", makeplural(body_part(LEG))); + long wl = (EWounded_legs & BOTH_SIDES); + const char *bp = body_part(LEG), *article = "a "; + + if (wl == BOTH_SIDES) + bp = makeplural(bp), article = ""; + Sprintf(buf, "%swounded %s", article, bp); you_have(buf, ""); } } diff --git a/src/steed.c b/src/steed.c index bdd89a13b..84e18aa63 100644 --- a/src/steed.c +++ b/src/steed.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 steed.c $NHDT-Date: 1575245090 2019/12/02 00:04:50 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.68 $ */ +/* NetHack 3.7 steed.c $NHDT-Date: 1582155885 2020/02/19 23:44:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.79 $ */ /* Copyright (c) Kevin Hugo, 1998-1999. */ /* NetHack may be freely redistributed. See license for details. */ @@ -219,9 +219,13 @@ boolean force; /* Quietly force this animal */ * temporary 1 point Dex loss become permanent.] */ if (Wounded_legs) { - Your("%s are in no shape for riding.", makeplural(body_part(LEG))); - if (force && wizard && yn("Heal your legs?") == 'y') - HWounded_legs = EWounded_legs = 0L; + char qbuf[QBUFSZ]; + + legs_in_no_shape("riding", FALSE); + Sprintf(qbuf, "Heal your leg%s?", + ((HWounded_legs & BOTH_SIDES) == BOTH_SIDES) ? "s" : ""); + if (force && wizard && yn(qbuf) == 'y') + heal_legs(0); else return (FALSE); }