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

@@ -1326,10 +1326,11 @@ prioritize paying shopkeeper next to you even if multiple are detected
avoid impossible "trapped without a trap (fmon)" from 'sanity_check' when a avoid impossible "trapped without a trap (fmon)" from 'sanity_check' when a
drum of earthquake made a pit at a monster's spot and pit creation drum of earthquake made a pit at a monster's spot and pit creation
caused adjacent pool/moat/lava to flood that spot; if a non-floater, caused adjacent pool/moat/lava to flood that spot; if a non-floater,
non-flyer monster survived that it got marked as trapped even though non-flyer monster survived that, it got marked as trapped even though
flooding deleted the trap flooding deleted the trap
demons cannot be frightened by showing them their reflection demons cannot be frightened by showing them their reflection
HP regeneration formula has changed, primarily to be less fast in the endgame HP regeneration formula has changed, primarily to be less fast in the endgame
riding negates stealth unless the steed is flying
Fixes to 3.7.0-x General Problems Exposed Via git Repository Fixes to 3.7.0-x General Problems Exposed Via git Repository

View File

@@ -2792,6 +2792,7 @@ extern void exercise_steed(void);
extern void kick_steed(void); extern void kick_steed(void);
extern void dismount_steed(int); extern void dismount_steed(int);
extern void place_monster(struct monst *, coordxy, coordxy); extern void place_monster(struct monst *, coordxy, coordxy);
extern void poly_steed(struct monst *, struct permonst *);
extern boolean stucksteed(boolean); extern boolean stucksteed(boolean);
/* ### symbols.c ### */ /* ### symbols.c ### */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 prop.h $NHDT-Date: 1596498555 2020/08/03 23:49:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.22 $ */ /* NetHack 3.7 prop.h $NHDT-Date: 1702274027 2023/12/11 05:53:47 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.24 $ */
/* Copyright (c) 1989 Mike Threepoint */ /* Copyright (c) 1989 Mike Threepoint */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -129,14 +129,14 @@ struct prop {
long intrinsic; long intrinsic;
/* Timed properties */ /* Timed properties */
#define TIMEOUT 0x00ffffffL /* Up to 16 million turns */ #define TIMEOUT 0x00ffffffL /* Up to 16 million turns */
/* Permanent properties */ /* Permanent properties */
#define FROMEXPER 0x01000000L /* Gain/lose with experience, for role */ #define FROMEXPER 0x01000000L /* Gain/lose with experience, for role */
#define FROMRACE 0x02000000L /* Gain/lose with experience, for race */ #define FROMRACE 0x02000000L /* Gain/lose with experience, for race */
#define FROMOUTSIDE 0x04000000L /* By corpses, prayer, thrones, etc. */ #define FROMOUTSIDE 0x04000000L /* By corpses, prayer, thrones, etc. */
#define INTRINSIC (FROMOUTSIDE | FROMRACE | FROMEXPER) #define INTRINSIC (FROMOUTSIDE | FROMRACE | FROMEXPER)
/* Control flags */ /* Control flags */
#define FROMFORM 0x10000000L /* Polyd; conferred by monster form */ #define FROMFORM 0x10000000L /* Polyd; conferred by monster form */
#define I_SPECIAL 0x20000000L /* Property is controllable */ #define I_SPECIAL 0x20000000L /* Property is controllable */
}; };
/*** Definitions for backwards compatibility ***/ /*** Definitions for backwards compatibility ***/

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 youprop.h $NHDT-Date: 1596498577 2020/08/03 23:49:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.32 $ */ /* NetHack 3.7 youprop.h $NHDT-Date: 1702274029 2023/12/11 05:53:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.44 $ */
/* Copyright (c) 1989 Mike Threepoint */ /* Copyright (c) 1989 Mike Threepoint */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -200,6 +200,7 @@
#define HStealth u.uprops[STEALTH].intrinsic #define HStealth u.uprops[STEALTH].intrinsic
#define EStealth u.uprops[STEALTH].extrinsic #define EStealth u.uprops[STEALTH].extrinsic
/* BStealth has FROMOUTSIDE set if mounted on non-flying steed */
#define BStealth u.uprops[STEALTH].blocked #define BStealth u.uprops[STEALTH].blocked
#define Stealth ((HStealth || EStealth) && !BStealth) #define Stealth ((HStealth || EStealth) && !BStealth)
@@ -384,6 +385,10 @@
* Some pseudo-properties. * Some pseudo-properties.
*/ */
/* the code will needs lots of updating to use this so leave it commented
#define Riding (u.usteed != NULL)
*/
/* unconscious() includes u.usleep but not is_fainted(); the multi test is /* unconscious() includes u.usleep but not is_fainted(); the multi test is
redundant but allows the function calls to be skipped most of the time */ redundant but allows the function calls to be skipped most of the time */
#define Unaware (gm.multi < 0 && (unconscious() || is_fainted())) #define Unaware (gm.multi < 0 && (unconscious() || is_fainted()))

View File

@@ -85,7 +85,9 @@ on_msg(struct obj *otmp)
} }
/* putting on or taking off an item which confers stealth; /* 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 static
void void
toggle_stealth( toggle_stealth(
@@ -101,7 +103,7 @@ toggle_stealth(
&& !BStealth) { /* stealth blocked by something */ && !BStealth) { /* stealth blocked by something */
if (obj->otyp == RIN_STEALTH) if (obj->otyp == RIN_STEALTH)
learnring(obj, TRUE); learnring(obj, TRUE);
else else /* discover elven cloak or elven boots */
makeknown(obj->otyp); makeknown(obj->otyp);
if (on) { if (on) {
@@ -112,7 +114,13 @@ toggle_stealth(
else else
You("walk very quietly."); You("walk very quietly.");
} else { } 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 hero is able to see self (or sense monsters); for timed, 'obj' is Null
and this is only called for the message */ and this is only called for the message */
void void
toggle_displacement(struct obj *obj, toggle_displacement(
long oldprop, /* prop[].extrinsic, with obj->owornmask struct obj *obj,
stripped by caller */ long oldprop, /* prop[].extrinsic, with obj->owornmask
boolean on) stripped by caller */
boolean on)
{ {
if (on ? gi.initial_don : gc.context.takeoff.cancelled_don) if (on ? gi.initial_don : gc.context.takeoff.cancelled_don)
return; return;

View File

@@ -1455,7 +1455,7 @@ attributes_enlightenment(
{ {
static NEARDATA const char static NEARDATA const char
if_surroundings_permitted[] = " if surroundings permitted"; if_surroundings_permitted[] = " if surroundings permitted";
int ltmp, armpro; int ltmp, armpro, warnspecies;
char buf[BUFSZ]; char buf[BUFSZ];
/*\ /*\
@@ -1566,9 +1566,10 @@ attributes_enlightenment(
: "certain monsters"); : "certain monsters");
you_are(buf, ""); 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", 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)); you_are(buf, from_what(WARN_OF_MON));
} }
if (Undead_warning) if (Undead_warning)
@@ -1630,8 +1631,13 @@ attributes_enlightenment(
you_are("visible", from_what(-INVIS)); you_are("visible", from_what(-INVIS));
if (Displaced) if (Displaced)
you_are("displaced", from_what(DISPLACED)); you_are("displaced", from_what(DISPLACED));
if (Stealth) if (Stealth) {
you_are("stealthy", from_what(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) if (Aggravate_monster)
enl_msg("You aggravate", "", "d", " monsters", enl_msg("You aggravate", "", "d", " monsters",
from_what(AGGRAVATE_MONSTER)); from_what(AGGRAVATE_MONSTER));

View File

@@ -5054,6 +5054,8 @@ newcham(
} }
} }
} }
if (mtmp == u.usteed)
poly_steed(mtmp, olddata);
return 1; 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 */ /* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -133,6 +133,15 @@ float_vs_flight(void)
BLevitation |= I_SPECIAL; BLevitation |= I_SPECIAL;
else else
BLevitation &= ~I_SPECIAL; 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; 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. */ /* Copyright (c) Kevin Hugo, 1998-1999. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -226,8 +226,10 @@ mount_steed(
return (FALSE); return (FALSE);
} }
if (Upolyd && (!humanoid(gy.youmonst.data) || verysmall(gy.youmonst.data) if (Upolyd && (!humanoid(gy.youmonst.data)
|| bigmonst(gy.youmonst.data) || slithy(gy.youmonst.data))) { || verysmall(gy.youmonst.data)
|| bigmonst(gy.youmonst.data)
|| slithy(gy.youmonst.data))) {
You("won't fit on a saddle."); You("won't fit on a saddle.");
return (FALSE); return (FALSE);
} }
@@ -269,6 +271,7 @@ mount_steed(
pline("%s is not saddled.", Monnam(mtmp)); pline("%s is not saddled.", Monnam(mtmp));
return (FALSE); return (FALSE);
} }
ptr = mtmp->data; ptr = mtmp->data;
if (touch_petrifies(ptr) && !Stone_resistance) { if (touch_petrifies(ptr) && !Stone_resistance) {
char kbuf[BUFSZ]; char kbuf[BUFSZ];
@@ -354,6 +357,13 @@ mount_steed(
if (uwep && is_pole(uwep)) if (uwep && is_pole(uwep))
gu.unweapon = FALSE; gu.unweapon = FALSE;
u.usteed = mtmp; 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); remove_monster(mtmp->mx, mtmp->my);
teleds(mtmp->mx, mtmp->my, TELEDS_ALLOW_DRAG); teleds(mtmp->mx, mtmp->my, TELEDS_ALLOW_DRAG);
gc.context.botl = TRUE; gc.context.botl = TRUE;
@@ -631,9 +641,14 @@ dismount_steed(
if (repair_leg_damage) if (repair_leg_damage)
heal_legs(1); heal_legs(1);
/* Release the steed and saddle */ /* Release the steed */
u.usteed = 0; u.usteed = (struct monst *) NULL;
u.ugallop = 0L; u.ugallop = 0L;
if (BStealth) {
BStealth &= ~FROMOUTSIDE;
if (Stealth)
You("seem less noisy now.");
}
if (u.utraptype == TT_BEARTRAP if (u.utraptype == TT_BEARTRAP
|| u.utraptype == TT_PIT || u.utraptype == TT_PIT
@@ -817,6 +832,33 @@ maybewakesteed(struct monst* steed)
finish_meating(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; /* decide whether hero's steed is able to move;
doesn't check for holding traps--those affect the hero directly */ doesn't check for holding traps--those affect the hero directly */
boolean 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) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -2923,20 +2923,8 @@ steedintrap(struct trap *trap, struct obj *otmp)
break; break;
case POLY_TRAP: case POLY_TRAP:
if (!resists_magm(steed) && !resist(steed, WAND_CLASS, 0, NOTELL)) { 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); (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; steedhit = TRUE;
break; break;