add soundeffects hooks to core

Insert the calls to trigger a number of potential soundeffects
into the core.

If no additional soundlib support is integrated into the
build, then the Soundeffect macro (sndprocs.h) expands to nothing:

[#define Soundeffect(seid, vol)
]

If, however, at least one additional soundlib support is integrated
into the build, then the Soundeffect macro gets defined as this
in sndprocs.h:

[#define Soundeffect(seid, vol) \
    do {                                                              \
        if (!Deaf && soundprocs.sound_soundeffect                     \
            && ((soundprocs.sndcap & SNDCAP_SOUNDEFFECTS) != 0))      \
            (*soundprocs.sound_soundeffect)(emptystr, (seid), (vol)); \
    } while(0)
]

That macro definition checks for the hero not being Deaf; it checks
to ensure that the active soundlib interface has a non-null
sound_soundeffect() function pointer; and it checks to ensure
that the active soundlib interface has declared that it supports
soundeffects by setting the SNDCAP_SOUNDEFFECTS bit in its sndcap
entry. That just means that the interface routines are prepared to
accept and deal with the calls from the core, whether or not it
actually produces the desired soundeffect.
This commit is contained in:
nhmall
2023-01-20 14:18:48 -05:00
parent b1fd7344e3
commit 8bbe9282aa
32 changed files with 529 additions and 106 deletions

View File

@@ -343,18 +343,22 @@ use_stethoscope(struct obj *obj)
mstatusline(u.ustuck);
return res;
} else if (u.dz) {
if (Underwater)
if (Underwater) {
Soundeffect(se_faint_splashing, 35);
You_hear("faint splashing.");
else if (u.dz < 0 || !can_reach_floor(TRUE))
} else if (u.dz < 0 || !can_reach_floor(TRUE)) {
cant_reach_floor(u.ux, u.uy, (u.dz < 0), TRUE);
else if (its_dead(u.ux, u.uy, &res))
} else if (its_dead(u.ux, u.uy, &res)) {
; /* message already given */
else if (Is_stronghold(&u.uz))
} else if (Is_stronghold(&u.uz)) {
Soundeffect(se_crackling_of_hellfire, 35);
You_hear("the crackling of hellfire.");
else
} else {
pline_The("%s seems healthy enough.", surface(u.ux, u.uy));
}
return res;
} else if (obj->cursed && !rn2(2)) {
Soundeffect(se_heart_beat, 100);
You_hear("your heart beat.");
return res;
}
@@ -366,6 +370,7 @@ use_stethoscope(struct obj *obj)
rx = u.ux + u.dx;
ry = u.uy + u.dy;
if (!isok(rx, ry)) {
Soundeffect(se_typing_noise, 100);
You_hear("a faint typing noise.");
return ECMD_OK;
}
@@ -431,6 +436,7 @@ use_stethoscope(struct obj *obj)
lev = &levl[rx][ry];
switch (lev->typ) {
case SDOOR:
Soundeffect(se_hollow_sound, 100);
You_hear(hollow_str, "door");
cvt_sdoor_to_door(lev); /* ->typ = DOOR */
feel_newsym(rx, ry);
@@ -3757,6 +3763,7 @@ do_break_wand(struct obj *obj)
goto discard_broken_wand;
case WAN_STRIKING:
/* we want this before the explosion instead of at the very end */
Soundeffect(se_wall_of_force, 65);
pline("A wall of force smashes down around you!");
dmg = d(1 + obj->spe, 6); /* normally 2d12 */
/*FALLTHRU*/
@@ -4202,14 +4209,17 @@ flip_through_book(struct obj *obj)
You("flip through the pages of %s.", thesimpleoname(obj));
if (obj->otyp == SPE_BOOK_OF_THE_DEAD) {
if (!Deaf)
if (!Deaf) {
if (!Hallucination)
Soundeffect(se_rustling_paper, 50);
You_hear("the pages make an unpleasant %s sound.",
Hallucination ? "chuckling"
: "rustling");
else if (!Blind)
} else if (!Blind) {
You_see("the pages glow faintly %s.", hcolor(NH_RED));
else
} else {
You_feel("the pages tremble.");
}
} else if (Blind) {
pline("The pages feel %s.",
Hallucination ? "freshly picked"