From: PatR Date: Wed, 23 Dec 2020 18:43:58 +0000 (-0800) Subject: feedback for monsters' health X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1971adbe45afc36278b5fff6ba6a78855fbc99e5;p=nethack feedback for monsters' health 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. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 800e48d28..d4a83e844 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 or 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 diff --git a/include/extern.h b/include/extern.h index cc7fd8be9..ac8b1e723 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 *, diff --git a/src/do_name.c b/src/do_name.c index 7a053186f..c4c2f654c 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -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)); diff --git a/src/end.c b/src/end.c index ba489f9a4..50f593280 100644 --- 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) diff --git a/src/pager.c b/src/pager.c index 5d5fdcce4..b573bb4aa 100644 --- a/src/pager.c +++ b/src/pager.c @@ -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. */ @@ -12,14 +12,13 @@ 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)