fix #K4060 - "you walk quietly" while riding

Donning elven boots while riding and not already stealthy, you'd get
the message "you walk quietly" when not walking at all.  Instead of
just changing the message, make riding a non-flying steed block
stealth.  Riding a flying steed (or one you take aloft with an amulet
of flying) does not.  It would have been quite a bit simpler to have
made riding anything block stealth, but the hard part is done.
This commit is contained in:
PatR
2023-12-10 22:09:26 -08:00
parent f3408b87ba
commit a7db78f7d6
10 changed files with 103 additions and 40 deletions

View File

@@ -85,7 +85,9 @@ on_msg(struct obj *otmp)
}
/* putting on or taking off an item which confers stealth;
give feedback and discover it iff stealth state is changing */
give feedback and discover it iff stealth state is changing;
stealth is blocked by riding unless hero+steed fly (handled with
BStealth by mount and dismount routines) */
static
void
toggle_stealth(
@@ -101,7 +103,7 @@ toggle_stealth(
&& !BStealth) { /* stealth blocked by something */
if (obj->otyp == RIN_STEALTH)
learnring(obj, TRUE);
else
else /* discover elven cloak or elven boots */
makeknown(obj->otyp);
if (on) {
@@ -112,7 +114,13 @@ toggle_stealth(
else
You("walk very quietly.");
} else {
You("sure are noisy.");
boolean riding = (u.usteed != NULL);
You("%s%s are noisy.", riding ? "and " : "sure",
riding ? x_monnam(u.usteed, ARTICLE_YOUR, (char *) NULL,
(SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION),
FALSE)
: "");
}
}
}
@@ -123,10 +131,11 @@ toggle_stealth(
hero is able to see self (or sense monsters); for timed, 'obj' is Null
and this is only called for the message */
void
toggle_displacement(struct obj *obj,
long oldprop, /* prop[].extrinsic, with obj->owornmask
stripped by caller */
boolean on)
toggle_displacement(
struct obj *obj,
long oldprop, /* prop[].extrinsic, with obj->owornmask
stripped by caller */
boolean on)
{
if (on ? gi.initial_don : gc.context.takeoff.cancelled_don)
return;

View File

@@ -1455,7 +1455,7 @@ attributes_enlightenment(
{
static NEARDATA const char
if_surroundings_permitted[] = " if surroundings permitted";
int ltmp, armpro;
int ltmp, armpro, warnspecies;
char buf[BUFSZ];
/*\
@@ -1566,9 +1566,10 @@ attributes_enlightenment(
: "certain monsters");
you_are(buf, "");
}
if (Warn_of_mon && gc.context.warntype.speciesidx >= LOW_PM) {
warnspecies = gc.context.warntype.speciesidx;
if (Warn_of_mon && warnspecies >= LOW_PM) {
Sprintf(buf, "aware of the presence of %s",
makeplural(mons[gc.context.warntype.speciesidx].pmnames[NEUTRAL]));
makeplural(mons[warnspecies].pmnames[NEUTRAL]));
you_are(buf, from_what(WARN_OF_MON));
}
if (Undead_warning)
@@ -1630,8 +1631,13 @@ attributes_enlightenment(
you_are("visible", from_what(-INVIS));
if (Displaced)
you_are("displaced", from_what(DISPLACED));
if (Stealth)
if (Stealth) {
you_are("stealthy", from_what(STEALTH));
} else if (BStealth && (HStealth || EStealth)) {
Sprintf(buf, " steathy%s",
(BStealth == FROMOUTSIDE) ? " if not mounted" : "");
enl_msg(You_, "would be", "would have been", buf, "");
}
if (Aggravate_monster)
enl_msg("You aggravate", "", "d", " monsters",
from_what(AGGRAVATE_MONSTER));

View File

@@ -5054,6 +5054,8 @@ newcham(
}
}
}
if (mtmp == u.usteed)
poly_steed(mtmp, olddata);
return 1;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 polyself.c $NHDT-Date: 1681429658 2023/04/13 23:47:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.197 $ */
/* NetHack 3.7 polyself.c $NHDT-Date: 1702274031 2023/12/11 05:53:51 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.204 $ */
/* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
@@ -133,6 +133,15 @@ float_vs_flight(void)
BLevitation |= I_SPECIAL;
else
BLevitation &= ~I_SPECIAL;
/* riding blocks stealth unless hero+steed fly, so a change in flying
might cause a change in stealth */
if (u.usteed) {
if (!Flying && !Levitation)
BStealth |= FROMOUTSIDE;
else
BStealth &= ~FROMOUTSIDE;
}
gc.context.botl = TRUE;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 steed.c $NHDT-Date: 1671838909 2022/12/23 23:41:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.108 $ */
/* NetHack 3.7 steed.c $NHDT-Date: 1702274036 2023/12/11 05:53:56 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.115 $ */
/* Copyright (c) Kevin Hugo, 1998-1999. */
/* NetHack may be freely redistributed. See license for details. */
@@ -226,8 +226,10 @@ mount_steed(
return (FALSE);
}
if (Upolyd && (!humanoid(gy.youmonst.data) || verysmall(gy.youmonst.data)
|| bigmonst(gy.youmonst.data) || slithy(gy.youmonst.data))) {
if (Upolyd && (!humanoid(gy.youmonst.data)
|| verysmall(gy.youmonst.data)
|| bigmonst(gy.youmonst.data)
|| slithy(gy.youmonst.data))) {
You("won't fit on a saddle.");
return (FALSE);
}
@@ -269,6 +271,7 @@ mount_steed(
pline("%s is not saddled.", Monnam(mtmp));
return (FALSE);
}
ptr = mtmp->data;
if (touch_petrifies(ptr) && !Stone_resistance) {
char kbuf[BUFSZ];
@@ -354,6 +357,13 @@ mount_steed(
if (uwep && is_pole(uwep))
gu.unweapon = FALSE;
u.usteed = mtmp;
if (!Flying && !Levitation) {
boolean was_stealthy = Stealth != 0;
BStealth |= FROMOUTSIDE;
if (was_stealthy)
You("aren't stealthy anymore.");
}
remove_monster(mtmp->mx, mtmp->my);
teleds(mtmp->mx, mtmp->my, TELEDS_ALLOW_DRAG);
gc.context.botl = TRUE;
@@ -631,9 +641,14 @@ dismount_steed(
if (repair_leg_damage)
heal_legs(1);
/* Release the steed and saddle */
u.usteed = 0;
/* Release the steed */
u.usteed = (struct monst *) NULL;
u.ugallop = 0L;
if (BStealth) {
BStealth &= ~FROMOUTSIDE;
if (Stealth)
You("seem less noisy now.");
}
if (u.utraptype == TT_BEARTRAP
|| u.utraptype == TT_PIT
@@ -817,6 +832,33 @@ maybewakesteed(struct monst* steed)
finish_meating(steed);
}
/* steed has taken on a new shape */
void
poly_steed(
struct monst *steed,
struct permonst *oldshape)
{
if (!can_saddle(steed) || !can_ride(steed)) {
/* removing of no longer wearable saddle was handled during the
shape change (newcham -> mon_break_armor -> m_lose_armor) */
dismount_steed(DISMOUNT_POLY);
} else {
char buf[BUFSZ];
Strcpy(buf, x_monnam(steed, ARTICLE_YOUR, (char *) 0,
SUPPRESS_SADDLE, FALSE));
if (oldshape != steed->data)
(void) strsubst(buf, "your ", "your new ");
You("adjust yourself in the saddle on %s.", buf);
/* riding blocks stealth unless hero+steed fly */
if (!Flying && !Levitation)
BStealth |= FROMOUTSIDE;
else
BStealth &= ~FROMOUTSIDE;
}
}
/* decide whether hero's steed is able to move;
doesn't check for holding traps--those affect the hero directly */
boolean

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 trap.c $NHDT-Date: 1699640827 2023/11/10 18:27:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.554 $ */
/* NetHack 3.7 trap.c $NHDT-Date: 1702274034 2023/12/11 05:53:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.559 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2923,20 +2923,8 @@ steedintrap(struct trap *trap, struct obj *otmp)
break;
case POLY_TRAP:
if (!resists_magm(steed) && !resist(steed, WAND_CLASS, 0, NOTELL)) {
struct permonst *mdat = steed->data;
/* newcham() will probably end up calling poly_steed() */
(void) newcham(steed, (struct permonst *) 0, NC_SHOW_MSG);
if (!can_saddle(steed) || !can_ride(steed)) {
dismount_steed(DISMOUNT_POLY);
} else {
char buf[BUFSZ];
Strcpy(buf, x_monnam(steed, ARTICLE_YOUR, (char *) 0,
SUPPRESS_SADDLE, FALSE));
if (mdat != steed->data)
(void) strsubst(buf, "your ", "your new ");
You("adjust yourself in the saddle on %s.", buf);
}
}
steedhit = TRUE;
break;