Skip to content

Commit

Permalink
squeaky boards (trunk only)
Browse files Browse the repository at this point in the history
There is a quote in data.base for squeaky board traps:
	A floorboard creaked.  Galder had spent many hours tuning them,
	always a wise precaution with an ambitious assistant who walked
	like a cat.
	D flat.  That meant he was just to the right of the door.
	"Ah, Trymon," he said, without turning, and noted with some
	satisfaction the faint indrawing of breath behind him.  "Good
	of you to come.  Shut the door, will you?"
		[ The Light Fantastic, by Terry Pratchett ]

This patch makes each squeaky board trap on a level produce
a unique sound. If you had visited the trap yourself prior
to hearing a monster on it, you could actually know where
a monster was by the unique pitch of the squeak.

If someone wants further refinement of the roles, this could
be adjusted to only work for musically adept roles/species,
with the others only hearing a generic squeak. As it stands
right now, everyone benefits.  Does anyone thing the
separation by role or species would be good? If so, which
roles/species are musically proficient, and which are not?

Since this patch increments editlevel anyway, it also sneaks in a
context structure change for an upcoming patch.
  • Loading branch information
nethack.allison committed Oct 8, 2006
1 parent 2c5d46f commit ab947c6
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/fixes35.0
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ closing magic activates bear traps and webs
locking converts a hole into a trap door; striking does the opposite
add Malcolm Ryan's Statue Glyphs patch
lembas and cram never rot unless cursed
multiple squeaks for squeaky boards


Platform- and/or Interface-Specific New Features
Expand Down
1 change: 1 addition & 0 deletions include/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ struct context_info {
/* 8: travel */
unsigned startingpet_mid;
int warnlevel;
int rndencode; /* randomized escape sequence introducer */
long next_attrib_check; /* next attribute check */
long stethoscope_move;
short stethoscope_movement;
Expand Down
2 changes: 1 addition & 1 deletion include/patchlevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files.
*/
#define EDITLEVEL 36
#define EDITLEVEL 37

#define COPYRIGHT_BANNER_A \
"NetHack, Copyright 1985-2006"
Expand Down
2 changes: 2 additions & 0 deletions include/trap.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ union vlaunchinfo {
short v_launch_otyp; /* type of object to be triggered */
coord v_launch2; /* secondary launch point (for boulders) */
uchar v_conjoined; /* conjoined pit locations */
short v_tnote; /* boards: 12 notes */
};

struct trap {
Expand All @@ -32,6 +33,7 @@ struct trap {
#define launch_otyp vl.v_launch_otyp
#define launch2 vl.v_launch2
#define conjoined vl.v_conjoined
#define tnote vl.v_tnote
};

extern struct trap *ftrap;
Expand Down
65 changes: 60 additions & 5 deletions src/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ STATIC_DCL void FDECL(launch_drop_spot, (struct obj *, XCHAR_P, XCHAR_P));
STATIC_DCL int FDECL(mkroll_launch,
(struct trap *,XCHAR_P,XCHAR_P,SHORT_P,long));
STATIC_DCL boolean FDECL(isclearpath,(coord *, int, SCHAR_P, SCHAR_P));
STATIC_DCL char *FDECL(trapnote, (struct trap *,BOOLEAN_P));
#if 0
STATIC_DCL void FDECL(join_adjacent_pits, (struct trap *));
#endif
Expand Down Expand Up @@ -248,6 +249,28 @@ register int x, y, typ;
}
ttmp->ttyp = typ;
switch(typ) {
case SQKY_BOARD:
{
int tavail[12], tpick[12], tcnt = 0, k;
struct trap *t;

for (k = 0; k < 12; ++k)
tavail[k] = 0;
for (t = ftrap; t; t = t->ntrap)
if (t->ttyp == SQKY_BOARD)
tavail[t->tnote] = 1;

/* Now populate tpick with the available indexes */
for (k = 0; k < 12; ++k) {
if (tavail[k] == 0)
tpick[tcnt++] = k;
}
if (tcnt > 0)
ttmp->tnote = (short)tpick[rn2(tcnt)];
else
ttmp->tnote = (short)rn2(12); /* all in use anyway */
break;
}
case STATUE_TRAP: /* create a "living" statue */
{ struct monst *mtmp;
struct obj *otmp, *statue;
Expand Down Expand Up @@ -806,7 +829,10 @@ unsigned trflags;
}
} else {
seetrap(trap);
pline("A board beneath you squeaks loudly.");
pline("A board beneath you %s%s%s.",
Deaf ? "vibrates" : "squeaks ",
Deaf ? "" : trapnote(trap,0),
Deaf ? "" : " loudly");
wake_nearby();
}
break;
Expand Down Expand Up @@ -1269,6 +1295,27 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst);
}
}

STATIC_OVL char *
trapnote(trap, noprefix)
struct trap *trap;
boolean noprefix;
{
static char tnbuf[12];
const char *tn, *tnnames[12] = {
"C note" , "D flat", "D note",
"E flat" , "E note", "F note",
"F sharp", "G note", "G sharp",
"A note" , "B flat", "B note"
};
tnbuf[0] = '\0';
tn = tnnames[trap->tnote];
if (!noprefix)
Sprintf(tnbuf, "%s ",
(*tn == 'A' || *tn == 'E' || *tn == 'F') ? "an" : "a");
Sprintf(eos(tnbuf), "%s", tn);
return tnbuf;
}

#ifdef STEED
STATIC_OVL int
steedintrap(trap, otmp)
Expand Down Expand Up @@ -1925,10 +1972,18 @@ register struct monst *mtmp;
if(is_flyer(mptr)) break;
/* stepped on a squeaky board */
if (in_sight) {
pline("A board beneath %s squeaks loudly.", mon_nam(mtmp));
seetrap(trap);
} else
You_hear("a distant squeak.");
if (!Deaf) {
pline("A board beneath %s squeaks %s loudly.",
mon_nam(mtmp), trapnote(trap,0));
seetrap(trap);
} else {
pline("%s stops momentarily and appears to cringe.",
Monnam(mtmp));
}
} else if (!Deaf) {
You_hear("a distant %s squeak.",
trapnote(trap,1));
}
/* wake up nearby monsters */
wake_nearto(mtmp->mx, mtmp->my, 40);
break;
Expand Down

0 comments on commit ab947c6

Please sign in to comment.