]> granicus.if.org Git - nethack/commitdiff
Wounded_legs condition
authorPatR <rankin@nethack.org>
Wed, 19 Feb 2020 23:47:55 +0000 (15:47 -0800)
committerPatR <rankin@nethack.org>
Wed, 19 Feb 2020 23:47:55 +0000 (15:47 -0800)
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.

include/extern.h
src/apply.c
src/do.c
src/dokick.c
src/insight.c
src/steed.c

index 7fdfeb039c14e06336c1611f5b107f72bcb006bb..4edf4423a710b7115bbd68b8bdeca7e506742a36 100644 (file)
@@ -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));
 
index 50967cebe0836d9a66f462d7fbb7d72af02c1fe5..09414ecaf16f94650d6ddaab1bad491af861b583 100644 (file)
@@ -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));
index 5ea2e2c6a8e8721df92e608a2244a9d54685a6fb..33dc73006fd202c616b4bfa3aa4c2ea5ac7bf246 100644 (file)
--- 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;
index 212301d3b3ef7ac68c3e024ee2cc36245784526f..7eb52bd94f73ed4f0a3d122937ad062d64515afb 100644 (file)
@@ -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.");
index c368c44031e98149b29545024b638c5197e61302..60c8cb25f9f4e1966e3d69f41228f8e498ee92cb 100644 (file)
@@ -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, "");
         }
     }
index bdd89a13b9c6bb5d39089d72242a73563d51072d..84e18aa6378c73188ea293dc7f286f4e81df2347 100644 (file)
@@ -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);
     }