]> granicus.if.org Git - nethack/commitdiff
feedback for monsters' health
authorPatR <rankin@nethack.org>
Wed, 23 Dec 2020 18:43:58 +0000 (10:43 -0800)
committerPatR <rankin@nethack.org>
Wed, 23 Dec 2020 18:43:58 +0000 (10:43 -0800)
For farlook description of a monster, and for "killed by monster"
when game ends, include an indication of the monster's health:
  uninjured          full health
  barely wounded     95%+ health
  slightly wounded   80%+
  wounded            20%..80%
  heavily wounded    20%-
  nearly deceased     5%-, or 1HP for really weak monsters
These descriptions and the criteria for choosing which one will
probably need some tuning.

Messages referring to the monster, including combat, do not
include the extra verbosity.

doc/fixes37.0
include/extern.h
src/do_name.c
src/end.c
src/pager.c

index 800e48d28b3d055a2ca4f230069717424c6e672c..d4a83e844cfa69420c12bd0c77045ae1a5f61a32 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.399 $ $NHDT-Date: 1608673688 2020/12/22 21:48:08 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.400 $ $NHDT-Date: 1608749030 2020/12/23 18:43:50 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -686,6 +686,9 @@ assign default key binding for <del> or <delete> to execute #terrain
 assign M-X to #exploremode
 make #herecmdmenu and #therecmdmenu autocomplete
 add 'sortdiscoveries' option to control output of '\' and '`' commands
+include an indication of monsters' health during farlook feedback (including
+       /M and autodescribe); also include it in death reason when killed by
+       a monster: "killed by {an uninjured newt,a heavily injured mumak}"
 
 
 Platform- and/or Interface-Specific New Features
index cc7fd8be974f4c9fdd2fd2785f6455758f5c44ab..ac8b1e72356f02d5cb71a27095199acde53a32dd 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 extern.h        $NHDT-Date: 1607945415 2020/12/14 11:30:15 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.932 $ */
+/* NetHack 3.7 extern.h        $NHDT-Date: 1608749030 2020/12/23 18:43:50 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.934 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1866,6 +1866,7 @@ E void NDECL(msgtype_free);
 /* ### pager.c ### */
 
 E char *FDECL(self_lookat, (char *));
+E char *FDECL(monhealthdescr, (struct monst *mon, BOOLEAN_P, char *));
 E void FDECL(mhidden_description, (struct monst *, BOOLEAN_P, char *));
 E boolean FDECL(object_from_map, (int,int,int,struct obj **));
 E int FDECL(do_screen_description, (coord, BOOLEAN_P, int, char *,
index 7a053186fb0d33a83770950adb1f6d31815c1212..c4c2f654c7cae6c4ab702a12374a988cffca9b70 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 do_name.c       $NHDT-Date: 1608343467 2020/12/19 02:04:27 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.185 $ */
+/* NetHack 3.7 do_name.c       $NHDT-Date: 1608749030 2020/12/23 18:43:50 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.186 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Pasi Kallinen, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -6,7 +6,8 @@
 #include "hack.h"
 
 static char *NDECL(nextmbuf);
-static void FDECL(getpos_help_keyxhelp, (winid, const char *, const char *, int));
+static void FDECL(getpos_help_keyxhelp, (winid, const char *,
+                                         const char *, int));
 static void FDECL(getpos_help, (BOOLEAN_P, const char *));
 static int FDECL(CFDECLSPEC cmp_coord_distu, (const void *, const void *));
 static int FDECL(gloc_filter_classify_glyph, (int));
index ba489f9a489a9c924042bad8fae0b2ff7c019c32..50f5932801dc6fa55f6ca16cedb1b487db7a8d98 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 end.c   $NHDT-Date: 1606009001 2020/11/22 01:36:41 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.215 $ */
+/* NetHack 3.7 end.c   $NHDT-Date: 1608749031 2020/12/23 18:43:51 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.216 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -419,6 +419,7 @@ int how;
         Strcat(buf, "the ");
         g.killer.format = KILLED_BY;
     }
+    (void) monhealthdescr(mtmp, TRUE, eos(buf));
     if (mtmp->minvis)
         Strcat(buf, "invisible ");
     if (distorted)
index 5d5fdcce48fdf2cb681d71b93aaa247c82b6b8f9..b573bb4aa27415fa43c1a5e447f5e0dba00b5973 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 pager.c $NHDT-Date: 1607735717 2020/12/12 01:15:17 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.191 $ */
+/* NetHack 3.7 pager.c $NHDT-Date: 1608749031 2020/12/23 18:43:51 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.192 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
 static boolean FDECL(is_swallow_sym, (int));
 static int FDECL(append_str, (char *, const char *));
 static void FDECL(look_at_object, (char *, int, int, int));
-static void FDECL(look_at_monster, (char *, char *,
-                                        struct monst *, int, int));
+static void FDECL(look_at_monster, (char *, char *, struct monst *, int, int));
 static struct permonst *FDECL(lookat, (int, int, char *, char *));
 static void FDECL(checkfile, (char *, struct permonst *,
-                                  BOOLEAN_P, BOOLEAN_P, char *));
+                              BOOLEAN_P, BOOLEAN_P, char *));
 static void FDECL(look_all, (BOOLEAN_P,BOOLEAN_P));
 static void FDECL(do_supplemental_info, (char *, struct permonst *,
-                                             BOOLEAN_P));
+                                         BOOLEAN_P));
 static void NDECL(whatdoes_help);
 static void NDECL(docontact);
 static void NDECL(dispfile_help);
@@ -103,6 +102,32 @@ char *outbuf;
     return outbuf;
 }
 
+/* format description of 'mon's health for look_at_monster(), done_in_by() */
+char *
+monhealthdescr(mon, addspace, outbuf)
+struct monst *mon;
+boolean addspace;
+char *outbuf;
+{
+    int mhp_max = max(mon->mhpmax, 1), /* bullet proofing */
+        pct = (mon->mhp * 100) / mhp_max;
+
+    if (mon->mhp >= mhp_max)
+        Strcpy(outbuf, "uninjured");
+    else if (mon->mhp <= 1 || pct < 5)
+        Sprintf(outbuf, "%s%s", (mon->mhp > 0) ? "nearly " : "",
+                !nonliving(mon->data) ? "deceased" : "defunct");
+    else
+        Sprintf(outbuf, "%swounded",
+                (pct >= 95) ? "barely "
+                : (pct >= 80) ? "slightly "
+                  : (pct < 20) ? "heavily "
+                    : "");
+    if (addspace)
+        (void) strkitten(outbuf, ' ');
+    return outbuf;
+}
+
 /* describe a hidden monster; used for look_at during extended monster
    detection and for probing; also when looking at self */
 void
@@ -280,16 +305,17 @@ char *buf, *monbuf; /* buf: output, monbuf: optional output */
 struct monst *mtmp;
 int x, y;
 {
-    char *name, monnambuf[BUFSZ];
+    char *name, monnambuf[BUFSZ], healthbuf[BUFSZ];
     boolean accurate = !Hallucination;
 
     name = (mtmp->data == &mons[PM_COYOTE] && accurate)
               ? coyotename(mtmp, monnambuf)
               : distant_monnam(mtmp, ARTICLE_NONE, monnambuf);
-    Sprintf(buf, "%s%s%s",
+    Sprintf(buf, "%s%s%s%s",
             (mtmp->mx != x || mtmp->my != y)
                 ? ((mtmp->isshk && accurate) ? "tail of " : "tail of a ")
                 : "",
+            accurate ? monhealthdescr(mtmp, TRUE, healthbuf) : "",
             (mtmp->mtame && accurate)
                 ? "tame "
                 : (mtmp->mpeaceful && accurate)