refine #K4060 fix - affect of riding on stealth
Hide some of the details about new Stealth. Streamline mon_break_armor(). Move replicated bypass handling into m_lose_armor(). Also, eliminate a 'goto'.
This commit is contained in:
@@ -2232,6 +2232,7 @@ extern void nhassert_failed(const char *, const char *, int);
|
||||
|
||||
extern void set_uasmon(void);
|
||||
extern void float_vs_flight(void);
|
||||
extern void steed_vs_stealth(void);
|
||||
extern void change_sex(void);
|
||||
extern void livelog_newform(boolean, int, int);
|
||||
extern void polyself(int);
|
||||
|
||||
@@ -136,15 +136,21 @@ float_vs_flight(void)
|
||||
|
||||
/* 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;
|
||||
}
|
||||
steed_vs_stealth();
|
||||
|
||||
gc.context.botl = TRUE;
|
||||
}
|
||||
|
||||
/* riding blocks stealth unless hero+steed fly */
|
||||
void
|
||||
steed_vs_stealth(void)
|
||||
{
|
||||
if (u.usteed && !Flying && !Levitation)
|
||||
BStealth |= FROMOUTSIDE;
|
||||
else
|
||||
BStealth &= ~FROMOUTSIDE;
|
||||
}
|
||||
|
||||
/* for changing into form that's immune to strangulation */
|
||||
static void
|
||||
check_strangling(boolean on)
|
||||
|
||||
26
src/steed.c
26
src/steed.c
@@ -357,11 +357,11 @@ 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)
|
||||
steed_vs_stealth();
|
||||
if (was_stealthy && !Stealth)
|
||||
You("aren't stealthy anymore.");
|
||||
}
|
||||
remove_monster(mtmp->mx, mtmp->my);
|
||||
@@ -644,9 +644,11 @@ dismount_steed(
|
||||
/* Release the steed */
|
||||
u.usteed = (struct monst *) NULL;
|
||||
u.ugallop = 0L;
|
||||
if (BStealth) {
|
||||
BStealth &= ~FROMOUTSIDE;
|
||||
if (Stealth)
|
||||
{
|
||||
boolean was_stealthy = Stealth != 0;
|
||||
|
||||
steed_vs_stealth();
|
||||
if (Stealth && !was_stealthy)
|
||||
You("seem less noisy now.");
|
||||
}
|
||||
|
||||
@@ -839,9 +841,10 @@ poly_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);
|
||||
/* can't get here; newcham() -> mon_break_armor() -> m_lose_armor()
|
||||
removes saddle and/or forces hero to dismount, if applicable,
|
||||
before newcham() calls us */
|
||||
dismount_steed(DISMOUNT_FELL);
|
||||
} else {
|
||||
char buf[BUFSZ];
|
||||
|
||||
@@ -852,10 +855,7 @@ poly_steed(
|
||||
You("adjust yourself in the saddle on %s.", buf);
|
||||
|
||||
/* riding blocks stealth unless hero+steed fly */
|
||||
if (!Flying && !Levitation)
|
||||
BStealth |= FROMOUTSIDE;
|
||||
else
|
||||
BStealth &= ~FROMOUTSIDE;
|
||||
steed_vs_stealth();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
56
src/worn.c
56
src/worn.c
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
static void m_lose_armor(struct monst *, struct obj *);
|
||||
static void m_lose_armor(struct monst *, struct obj *, boolean);
|
||||
static void clear_bypass(struct obj *);
|
||||
static void m_dowear_type(struct monst *, long, boolean, boolean);
|
||||
static int extra_pref(struct monst *, struct obj *);
|
||||
@@ -802,10 +802,15 @@ which_armor(struct monst *mon, long flag)
|
||||
|
||||
/* remove an item of armor and then drop it */
|
||||
static void
|
||||
m_lose_armor(struct monst *mon, struct obj *obj)
|
||||
m_lose_armor(
|
||||
struct monst *mon,
|
||||
struct obj *obj,
|
||||
boolean polyspot)
|
||||
{
|
||||
extract_from_minvent(mon, obj, TRUE, FALSE);
|
||||
place_object(obj, mon->mx, mon->my);
|
||||
if (polyspot)
|
||||
bypass_obj(obj);
|
||||
/* call stackobj() if we ever drop anything that can merge */
|
||||
newsym(mon->mx, mon->my);
|
||||
}
|
||||
@@ -937,8 +942,9 @@ mon_break_armor(struct monst *mon, boolean polyspot)
|
||||
{
|
||||
register struct obj *otmp;
|
||||
struct permonst *mdat = mon->data;
|
||||
boolean vis = cansee(mon->mx, mon->my);
|
||||
boolean handless_or_tiny = (nohands(mdat) || verysmall(mdat));
|
||||
boolean vis = cansee(mon->mx, mon->my),
|
||||
handless_or_tiny = (nohands(mdat) || verysmall(mdat)),
|
||||
noride = FALSE;
|
||||
const char *pronoun = mhim(mon), *ppronoun = mhis(mon);
|
||||
|
||||
if (breakarm(mdat)) {
|
||||
@@ -964,9 +970,7 @@ mon_break_armor(struct monst *mon, boolean polyspot)
|
||||
if (vis)
|
||||
pline("%s %s falls off!", s_suffix(Monnam(mon)),
|
||||
cloak_simple_name(otmp));
|
||||
if (polyspot)
|
||||
bypass_obj(otmp);
|
||||
m_lose_armor(mon, otmp);
|
||||
m_lose_armor(mon, otmp, polyspot);
|
||||
} else {
|
||||
Soundeffect(se_ripping_sound, 100);
|
||||
if (vis)
|
||||
@@ -995,9 +999,7 @@ mon_break_armor(struct monst *mon, boolean polyspot)
|
||||
pronoun);
|
||||
else
|
||||
You_hear("a thud.");
|
||||
if (polyspot)
|
||||
bypass_obj(otmp);
|
||||
m_lose_armor(mon, otmp);
|
||||
m_lose_armor(mon, otmp, polyspot);
|
||||
}
|
||||
if ((otmp = which_armor(mon, W_ARMC)) != 0
|
||||
/* mummy wrapping adapts to small and very big sizes */
|
||||
@@ -1010,9 +1012,7 @@ mon_break_armor(struct monst *mon, boolean polyspot)
|
||||
pline("%s shrinks out of %s %s!", Monnam(mon), ppronoun,
|
||||
cloak_simple_name(otmp));
|
||||
}
|
||||
if (polyspot)
|
||||
bypass_obj(otmp);
|
||||
m_lose_armor(mon, otmp);
|
||||
m_lose_armor(mon, otmp, polyspot);
|
||||
}
|
||||
if ((otmp = which_armor(mon, W_ARMU)) != 0) {
|
||||
if (vis) {
|
||||
@@ -1023,9 +1023,7 @@ mon_break_armor(struct monst *mon, boolean polyspot)
|
||||
pline("%s becomes much too small for %s shirt!",
|
||||
Monnam(mon), ppronoun);
|
||||
}
|
||||
if (polyspot)
|
||||
bypass_obj(otmp);
|
||||
m_lose_armor(mon, otmp);
|
||||
m_lose_armor(mon, otmp, polyspot);
|
||||
}
|
||||
}
|
||||
if (handless_or_tiny) {
|
||||
@@ -1034,9 +1032,7 @@ mon_break_armor(struct monst *mon, boolean polyspot)
|
||||
if (vis)
|
||||
pline("%s drops %s gloves%s!", Monnam(mon), ppronoun,
|
||||
MON_WEP(mon) ? " and weapon" : "");
|
||||
if (polyspot)
|
||||
bypass_obj(otmp);
|
||||
m_lose_armor(mon, otmp);
|
||||
m_lose_armor(mon, otmp, polyspot);
|
||||
}
|
||||
if ((otmp = which_armor(mon, W_ARMS)) != 0) {
|
||||
Soundeffect(se_clank, 50);
|
||||
@@ -1045,9 +1041,7 @@ mon_break_armor(struct monst *mon, boolean polyspot)
|
||||
ppronoun);
|
||||
else
|
||||
You_hear("a clank.");
|
||||
if (polyspot)
|
||||
bypass_obj(otmp);
|
||||
m_lose_armor(mon, otmp);
|
||||
m_lose_armor(mon, otmp, polyspot);
|
||||
}
|
||||
}
|
||||
if (handless_or_tiny || has_horns(mdat)) {
|
||||
@@ -1059,9 +1053,7 @@ mon_break_armor(struct monst *mon, boolean polyspot)
|
||||
surface(mon->mx, mon->my));
|
||||
else
|
||||
You_hear("a clank.");
|
||||
if (polyspot)
|
||||
bypass_obj(otmp);
|
||||
m_lose_armor(mon, otmp);
|
||||
m_lose_armor(mon, otmp, polyspot);
|
||||
}
|
||||
}
|
||||
if (handless_or_tiny || slithy(mdat) || mdat->mlet == S_CENTAUR) {
|
||||
@@ -1073,23 +1065,19 @@ mon_break_armor(struct monst *mon, boolean polyspot)
|
||||
pline("%s boots %s off %s feet!", s_suffix(Monnam(mon)),
|
||||
verysmall(mdat) ? "slide" : "are pushed", ppronoun);
|
||||
}
|
||||
if (polyspot)
|
||||
bypass_obj(otmp);
|
||||
m_lose_armor(mon, otmp);
|
||||
m_lose_armor(mon, otmp, polyspot);
|
||||
}
|
||||
}
|
||||
if (!can_saddle(mon)) {
|
||||
if ((otmp = which_armor(mon, W_SADDLE)) != 0) {
|
||||
if (polyspot)
|
||||
bypass_obj(otmp);
|
||||
m_lose_armor(mon, otmp);
|
||||
m_lose_armor(mon, otmp, polyspot);
|
||||
if (vis)
|
||||
pline("%s saddle falls off.", s_suffix(Monnam(mon)));
|
||||
}
|
||||
if (mon == u.usteed)
|
||||
goto noride;
|
||||
} else if (mon == u.usteed && !can_ride(mon)) {
|
||||
noride:
|
||||
noride = TRUE;
|
||||
}
|
||||
if (noride || (mon == u.usteed && !can_ride(mon))) {
|
||||
You("can no longer ride %s.", mon_nam(mon));
|
||||
if (touch_petrifies(u.usteed->data) && !Stone_resistance && rnl(3)) {
|
||||
char buf[BUFSZ];
|
||||
|
||||
Reference in New Issue
Block a user