Skip to content

Commit

Permalink
fix steed-in-trap message grammar when hallucinating
Browse files Browse the repository at this point in the history
     Fix the recently reported bug about the wording of trap messsages
when hero's steed has a name but hallucination prevents that name from
being used, yielding "You lead poor wombat into a pit!" and the like.

     I accidentally deleted the message so can't reply to the sender.

[Before applying this patch, take a look at the POLY_TRAP case of the
switch statement in steedintrap().  A misplaced brace has drawn the
default case into one of its `if' statements.  Evidently it's valid C
syntax, but someone among us must have access to a compiler or lint
checking tool which is capable to diagnosing such things.]
  • Loading branch information
nethack.rankin committed Dec 27, 2003
1 parent 4a2dc92 commit 99413fc
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 97 deletions.
2 changes: 2 additions & 0 deletions doc/fixes34.4
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ don't #sit on an object in a pit if you're only on the precipice
fix message when pushing a boulder into a pool while riding
when you're teetering on the edge of a pit you can use '>' to enter the pit
plural of "Nazgul" is "Nazgul" not "Nazguls"
trap messages referring to named steed were ackwardly worded when hallucination
overrode use of the name


Platform- and/or Interface-Specific Fixes
Expand Down
186 changes: 89 additions & 97 deletions src/trap.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)trap.c 3.4 2003/11/26 */
/* SCCS Id: @(#)trap.c 3.4 2003/12/26 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */

Expand Down Expand Up @@ -578,6 +578,9 @@ unsigned trflags;
boolean webmsgok = (!(trflags & NOWEBMSG));
boolean forcebungle = (trflags & FORCEBUNGLE);
boolean plunged = (trflags & TOOKPLUNGE);
#ifdef STEED
int steed_article = ARTICLE_THE;
#endif

nomul(0);

Expand Down Expand Up @@ -617,7 +620,13 @@ unsigned trflags;
}

#ifdef STEED
if (u.usteed) u.usteed->mtrapseen |= (1 << (ttype-1));
if (u.usteed) {
u.usteed->mtrapseen |= (1 << (ttype - 1));
/* suppress article in various steed messages when using its
name (which won't occur when hallucinating) */
if (u.usteed->mnamelth && !Hallucination)
steed_article = ARTICLE_NONE;
}
#endif

switch(ttype) {
Expand Down Expand Up @@ -866,16 +875,14 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst);
char verbbuf[BUFSZ];
#ifdef STEED
if (u.usteed) {
if ((trflags & RECURSIVETRAP) != 0)
if ((trflags & RECURSIVETRAP) != 0)
Sprintf(verbbuf, "and %s fall",
x_monnam(u.usteed,
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE));
x_monnam(u.usteed, steed_article,
(char *)0, SUPPRESS_SADDLE, FALSE));
else
Sprintf(verbbuf,"lead %s",
x_monnam(u.usteed,
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
"poor", SUPPRESS_SADDLE, FALSE));
Sprintf(verbbuf, "lead %s",
x_monnam(u.usteed, steed_article,
"poor", SUPPRESS_SADDLE, FALSE));
} else
#endif
Strcpy(verbbuf, plunged ? "plunge" : "fall");
Expand All @@ -894,9 +901,8 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst);
#ifdef STEED
if (u.usteed) {
pline("%s lands %s!",
upstart(x_monnam(u.usteed,
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
"poor", SUPPRESS_SADDLE, FALSE)),
upstart(x_monnam(u.usteed, steed_article,
"poor", SUPPRESS_SADDLE, FALSE)),
predicament);
} else
#endif
Expand Down Expand Up @@ -980,18 +986,17 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst);
}
if (webmsgok) {
char verbbuf[BUFSZ];
verbbuf[0] = '\0';

#ifdef STEED
if (u.usteed)
Sprintf(verbbuf,"lead %s",
x_monnam(u.usteed,
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
"poor", SUPPRESS_SADDLE, FALSE));
Sprintf(verbbuf, "lead %s",
x_monnam(u.usteed, steed_article,
"poor", SUPPRESS_SADDLE, FALSE));
else
#endif

Sprintf(verbbuf, "%s", Levitation ? (const char *)"float" :
locomotion(youmonst.data, "stumble"));
locomotion(youmonst.data, "stumble"));
You("%s into %s spider web!",
verbbuf, a_your[trap->madeby_u]);
}
Expand Down Expand Up @@ -1077,9 +1082,8 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst);
#ifdef STEED
if (u.usteed)
Sprintf(verbbuf, "lead %s",
x_monnam(u.usteed,
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE));
x_monnam(u.usteed, steed_article,
(char *)0, SUPPRESS_SADDLE, FALSE));
else
#endif
Sprintf(verbbuf,"%s",
Expand Down Expand Up @@ -1185,89 +1189,77 @@ steedintrap(trap, otmp)
struct trap *trap;
struct obj *otmp;
{
struct monst *mtmp = u.usteed;
struct permonst *mptr;
struct monst *steed = u.usteed;
int tt;
boolean in_sight;
boolean trapkilled = FALSE;
boolean steedhit = FALSE;
boolean in_sight, trapkilled, steedhit;

if (!u.usteed || !trap) return 0;
mptr = mtmp->data;
if (!steed || !trap) return 0;
tt = trap->ttyp;
mtmp->mx = u.ux;
mtmp->my = u.uy;

steed->mx = u.ux;
steed->my = u.uy;
in_sight = !Blind;
trapkilled = steedhit = FALSE;

switch (tt) {
case ARROW_TRAP:
if(!otmp) {
impossible("steed hit by non-existant arrow?");
return 0;
}
if (thitm(8, mtmp, otmp, 0, FALSE)) trapkilled = TRUE;
steedhit = TRUE;
break;
case DART_TRAP:
if(!otmp) {
impossible("steed hit by non-existant dart?");
return 0;
}
if (thitm(7, mtmp, otmp, 0, FALSE)) trapkilled = TRUE;
steedhit = TRUE;
break;
case SLP_GAS_TRAP:
if (!resists_sleep(mtmp) && !breathless(mptr) &&
!mtmp->msleeping && mtmp->mcanmove) {
mtmp->mcanmove = 0;
mtmp->mfrozen = rnd(25);
if (in_sight) {
pline("%s suddenly falls asleep!",
Monnam(mtmp));
}
}
steedhit = TRUE;
break;
case LANDMINE:
if (thitm(0, mtmp, (struct obj *)0, rnd(16), FALSE))
trapkilled = TRUE;
steedhit = TRUE;
break;
case PIT:
case SPIKED_PIT:
if (mtmp->mhp <= 0 ||
thitm(0, mtmp, (struct obj *)0,
rnd((tt == PIT) ? 6 : 10), FALSE))
trapkilled = TRUE;
steedhit = TRUE;
break;
case POLY_TRAP:
if (!resists_magm(mtmp)) {
if (!resist(mtmp, WAND_CLASS, 0, NOTELL)) {
(void) newcham(mtmp, (struct permonst *)0,
FALSE, FALSE);
if (!can_saddle(mtmp) || !can_ride(mtmp)) {
dismount_steed(DISMOUNT_POLY);
} else {
You("have to adjust yourself in the saddle on %s.",
x_monnam(mtmp,
mtmp->mnamelth ? ARTICLE_NONE : ARTICLE_A,
(char *)0, SUPPRESS_SADDLE, FALSE));
}

}
steedhit = TRUE;
break;
default:
return 0;
case ARROW_TRAP:
if (!otmp) {
impossible("steed hit by non-existant arrow?");
return 0;
}
trapkilled = thitm(8, steed, otmp, 0, FALSE);
steedhit = TRUE;
break;
case DART_TRAP:
if (!otmp) {
impossible("steed hit by non-existant dart?");
return 0;
}
trapkilled = thitm(7, steed, otmp, 0, FALSE);
steedhit = TRUE;
break;
case SLP_GAS_TRAP:
if (!resists_sleep(steed) && !breathless(steed->data) &&
!steed->msleeping && steed->mcanmove) {
steed->mcanmove = 0;
steed->mfrozen = rnd(25);
if (in_sight)
pline("%s suddenly falls asleep!", Monnam(steed));
}
steedhit = TRUE;
break;
case LANDMINE:
trapkilled = thitm(0, steed, (struct obj *)0, rnd(16), FALSE);
steedhit = TRUE;
break;
case PIT:
case SPIKED_PIT:
trapkilled = (steed->mhp <= 0 ||
thitm(0, steed, (struct obj *)0,
rnd((tt == PIT) ? 6 : 10), FALSE));
steedhit = TRUE;
break;
case POLY_TRAP:
if (!resists_magm(steed) &&
!resist(steed, WAND_CLASS, 0, NOTELL)) {
(void) newcham(steed, (struct permonst *)0, FALSE, FALSE);
if (!can_saddle(steed) || !can_ride(steed))
dismount_steed(DISMOUNT_POLY);
else
You("have to adjust yourself in the saddle on %s.",
x_monnam(steed, ARTICLE_A,
(char *)0, SUPPRESS_SADDLE, FALSE));
}
steedhit = TRUE;
break;
default:
break;
}
if(trapkilled) {
dismount_steed(DISMOUNT_POLY);
return 2;

if (trapkilled) {
dismount_steed(DISMOUNT_POLY);
return 2;
}
else if(steedhit) return 1;
else return 0;
return steedhit ? 1 : 0;
}
#endif /*STEED*/

Expand Down

0 comments on commit 99413fc

Please sign in to comment.