From 6b9f411a32f371d9e774023fde549515a56121dc Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 7 Feb 2024 19:46:53 +0200 Subject: [PATCH] Accessibility: mon_movement Adds a new boolean option, mon_movement. When hero notices monster movement, give a message. Use with spot_monsters and accessiblemsg. --- doc/Guidebook.mn | 5 +++++ doc/Guidebook.tex | 7 +++++++ doc/fixes3-7-0.txt | 5 +++-- include/flag.h | 1 + include/optlist.h | 3 +++ src/monmove.c | 21 +++++++++++++++++++++ 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index d27c4281a..15cdfd321 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -4179,6 +4179,8 @@ Default \(oq}\(cq. ." Format menu entries using TAB to separate columns (default off). ." Only applicable to some menus, and only useful to some interfaces. ." Debug mode only. +.lp mon_movement +Show a message when hero notices a monster movement (default is off). .lp monpolycontrol Prompt for new form whenever any monster changes shape (default off). Debug mode only. @@ -5947,6 +5949,9 @@ Prevent walking into water or lava. Adds direction or location information to messages. .lp spot_monsters Shows a message when hero notices a monster; combine with accessiblemsg. +.lp mon_movement +Shows a message when hero notices a monster movement; +combine with spot_monsters and accessiblemsg. .lp autodescribe Automatically describe the terrain under the cursor when targeting. .lp mention_walls diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 89c2874f0..5ba5e1c90 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -4572,6 +4572,9 @@ Default `{\tt \verb+}+}'. % Only applicable to some menus, and only useful to some interfaces. % Debug mode only. %.lp +\item[\ib{mon\verb+_+movement}] +Show a message when hero notices a monster movement (default is off). +%.lp \item[\ib{monpolycontrol}] Prompt for new form whenever any monster changes shape (default off). Debug mode only. @@ -6546,6 +6549,10 @@ Adds direction or location information to messages. \item[\ib{spot\verb+_+monsters}] Shows a message when hero notices a monster; combine with accessiblemsg. %.lp +\item[\ib{mon\verb+_+movement}] +Shows a message when hero notices a monster movement; +combine with spot\verb+_+monsters and accessiblemsg. +%.lp \item[\ib{autodescribe}] Automatically describe the terrain under the cursor when targeting. %.lp diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index a4bdf6e2d..9c194e9fe 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2470,8 +2470,9 @@ allow the ')', '[', '(', '=', '"', and '*' commands to be preceded by the 'm' hot ground (Gehennom / Plane of Fire) often destroys dropped potions erinyes overhaul; they now attempt to punish heroes who have violated their alignment and get stronger with greater alignment abuse -accessibility options to tell where on map a message happened (accessiblemsg) - and to notify when a monster is spotted (spot_monsters) +accessibility options to tell where on map a message happened (accessiblemsg), + to notify when a monster is spotted (spot_monsters), and when + a monster moved (mon_movement) Platform- and/or Interface-Specific New Features diff --git a/include/flag.h b/include/flag.h index e55d844ba..2a0dba48d 100644 --- a/include/flag.h +++ b/include/flag.h @@ -193,6 +193,7 @@ struct accessibility_data { coord msg_loc; /* accessiblemsg: location */ boolean mon_notices; /* msg when hero notices a monster */ int mon_notices_blocked; /* temp disable mon_notices */ + boolean mon_movement; /* msg when hero sees monster move */ }; /* Use notice_mon_off() / notice_mon_on() to temporarily disable diff --git a/include/optlist.h b/include/optlist.h index bc3cf1ec3..dc2f05466 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -460,6 +460,9 @@ static int optfn_##a(int, int, boolean, char *, char *); NHOPTO("message types", Advanced, o_message_types, BUFSZ, opt_in, set_in_game, No, Yes, No, NoAlias, "edit message types") + NHOPTB(mon_movement, Advanced, 0, opt_in, set_in_game, + Off, Yes, No, No, NoAlias, &a11y.mon_movement, Term_False, + "message when hero sees monster movement") NHOPTB(monpolycontrol, Advanced, 0, opt_in, set_wizonly, Off, Yes, No, No, NoAlias, &iflags.mon_polycontrol, Term_False, "control monster polymorphs") diff --git a/src/monmove.c b/src/monmove.c index a1297d537..b48540ba4 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -7,6 +7,7 @@ #include "mfndpos.h" #include "artifact.h" +static void msg_mon_movement(struct monst *, coordxy, coordxy) NONNULLARG1; static void watch_on_duty(struct monst *); static int disturb(struct monst *); static void release_hero(struct monst *); @@ -26,6 +27,25 @@ static boolean m_balks_at_approaching(struct monst *); static boolean stuff_prevents_passage(struct monst *); static int vamp_shift(struct monst *, struct permonst *, boolean); +/* a11y: give a message when monster moved */ +static void +msg_mon_movement(struct monst *mtmp, coordxy omx, coordxy omy) +{ + if (a11y.mon_movement && canspotmon(mtmp) && mtmp->mspotted) { + coordxy nix = mtmp->mx, niy = mtmp->my; + boolean n2u = next2u(nix, niy), + close = !n2u && (distu(nix, niy) <= (BOLT_LIM * BOLT_LIM)), + closer = !n2u && (distu(nix, niy) <= distu(omx, omy)); + + pline_xy(nix, niy, "%s %s%s.", Monnam(mtmp), + vtense((char *) 0, locomotion(mtmp->data, "move")), + n2u ? " next to you" + : (close && closer) ? " closer" + : (close && !closer) ? " further away" + : " in the distance"); + } +} + /* monster has triggered trapped door lock or was present when it got triggered remotely (at door spot, door hit by zap); returns True if mtmp dies */ @@ -1870,6 +1890,7 @@ m_move(register struct monst *mtmp, int after) place_monster() only manipulate the head; they leave tail as-is */ remove_monster(omx, omy); place_monster(mtmp, nix, niy); + msg_mon_movement(mtmp, omx, omy); /* for a long worm, insert a new segment to reconnect the head with the tail; worm_move() keeps the end of the tail if worm is scheduled to grow, removes that for move-without-growing */