- implemented the sound system for Witchaven.

The sound system itself is as primitive as it can get, the main change was to link sounds to sprites and not just their coordinates.
This commit is contained in:
Christoph Oelckers 2020-10-29 00:56:54 +01:00
parent c77a072628
commit 82f23a4733
33 changed files with 399 additions and 339 deletions

View file

@ -1079,13 +1079,14 @@ void SoundEngine::SetPitch(FSoundChan *chan, float pitch)
// Is a sound being played by a specific emitter?
//==========================================================================
int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, int sound_id)
int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, int sound_id, int chann)
{
int count = 0;
if (sound_id > 0)
{
for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan)
{
if (chann != -1 && chann != chan->EntChannel) continue;
if (chan->OrgID == sound_id && (sourcetype == SOURCE_Any ||
(chan->SourceType == sourcetype &&
chan->Source == source)))
@ -1098,6 +1099,7 @@ int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, int so
{
for (FSoundChan* chan = Channels; chan != NULL; chan = chan->NextChan)
{
if (chann != -1 && chann != chan->EntChannel) continue;
if ((sourcetype == SOURCE_Any || (chan->SourceType == sourcetype && chan->Source == source)))
{
count++;

View file

@ -298,7 +298,7 @@ public:
bool IsSourcePlayingSomething(int sourcetype, const void* actor, int channel, int sound_id = -1);
// Stop and resume music, during game PAUSE.
int GetSoundPlayingInfo(int sourcetype, const void* source, int sound_id);
int GetSoundPlayingInfo(int sourcetype, const void* source, int sound_id, int chan = -1);
void UnloadAllSounds();
void Reset();
void MarkUsed(int num);

View file

@ -38,9 +38,9 @@ void showStatisticsScreen()
@Override
public void run() {
mapon++;
playsound_loc(S_CHAINDOOR1, plr.x, plr.y);
spritesound(S_CHAINDOOR1, &sprite[plr.spritenum]);
playertorch = 0;
playsound_loc(S_WARP, plr.x, plr.y);
spritesound(S_WARP, &sprite[plr.spritenum]);
loadnewlevel(mapon);
}
});

View file

@ -665,14 +665,14 @@ void attack(PLAYER& plr, int i) {
short a = getangle(sprite[i].x - plr.x, sprite[i].y - plr.y);
if ((a < plr.ang && plr.ang - a < 128) || (a > plr.ang && (((short)plr.ang + a) & 2047) < 128)) {
if (krand() % 100 > 80) {
playsound_loc(S_SWORD1 + krand() % 3, plr.x, plr.y);
spritesound(S_SWORD1 + krand() % 3, &sprite[plr.spritenum]);
return;
}
else {
s = krand() % 50;
plr.shieldpoints -= s;
if (krand() % 100 > 50) {
playsound_loc(S_SWORD1 + krand() % 3, plr.x, plr.y);
spritesound(S_SWORD1 + krand() % 3, &sprite[plr.spritenum]);
return;
}
}
@ -700,11 +700,11 @@ void attack(PLAYER& plr, int i) {
k = 3;
break;
case SKELETONTYPE:
playsound_loc(S_RIP1 + (krand() % 3), sprite[i].x, sprite[i].y);
spritesound(S_RIP1 + (krand() % 3), &sprite[i]);
if ((krand() % 2) != 0)
playsound_loc(S_GORE1 + (krand() % 4), sprite[i].x, sprite[i].y);
spritesound(S_GORE1 + (krand() % 4), &sprite[i]);
if ((krand() % 2) != 0)
playsound_loc(S_BREATH1 + (krand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_BREATH1 + (krand() % 6), &sprite[i]);
if (isWh2())
k = (krand() % 5) + 5;
@ -712,21 +712,21 @@ void attack(PLAYER& plr, int i) {
k >>= 2;
break;
case KATIETYPE: // damage 5 - 50
playsound_loc(S_DEMONTHROW, sprite[i].x, sprite[i].y);
spritesound(S_DEMONTHROW, &sprite[i]);
k = (krand() % 45) + 5;
break;
case DEVILTYPE:
playsound_loc(S_DEMONTHROW, sprite[i].x, sprite[i].y);
spritesound(S_DEMONTHROW, &sprite[i]);
if (!isWh2())
k >>= 2;
break;
case KOBOLDTYPE:
playsound_loc(S_GENSWING, sprite[i].x, sprite[i].y);
spritesound(S_GENSWING, &sprite[i]);
if ((krand() % 10) > 4) {
playsound_loc(S_KOBOLDHIT, plr.x, plr.y);
playsound_loc(S_BREATH1 + (krand() % 6), plr.x, plr.y);
spritesound(S_KOBOLDHIT, &sprite[plr.spritenum]);
spritesound(S_BREATH1 + (krand() % 6), &sprite[plr.spritenum]);
}
if (isWh2())
k = (krand() % 5) + 5;
@ -736,21 +736,21 @@ void attack(PLAYER& plr, int i) {
case FREDTYPE:
/* Sounds for Fred (currently copied from Goblin) */
playsound_loc(S_GENSWING, sprite[i].x, sprite[i].y);
spritesound(S_GENSWING, &sprite[i]);
if (rand() % 10 > 4)
playsound_loc(S_SWORD1 + (rand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_SWORD1 + (rand() % 6), &sprite[i]);
k >>= 3;
break;
case IMPTYPE:
if (!isWh2())
break;
playsound_loc(S_RIP1 + (krand() % 3), sprite[i].x, sprite[i].y);
spritesound(S_RIP1 + (krand() % 3), &sprite[i]);
if ((krand() % 2) != 0) {
playsound_loc(S_GORE1 + (krand() % 4), sprite[i].x, sprite[i].y);
spritesound(S_GORE1 + (krand() % 4), &sprite[i]);
}
if ((krand() % 2) != 0) {
playsound_loc(S_BREATH1 + (krand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_BREATH1 + (krand() % 6), &sprite[i]);
}
k = (krand() % 5) + 5;
@ -762,51 +762,51 @@ void attack(PLAYER& plr, int i) {
if (isWh2())
break;
playsound_loc(S_GENSWING, sprite[i].x, sprite[i].y);
spritesound(S_GENSWING, &sprite[i]);
if ((krand() % 10) > 4)
playsound_loc(S_SWORD1 + (krand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_SWORD1 + (krand() % 6), &sprite[i]);
k >>= 2;
break;
case NEWGUYTYPE:
if (sprite[i].picnum == NEWGUYMACE) { // damage 5 - 20
playsound_loc(S_PLRWEAPON2, sprite[i].x, sprite[i].y);
spritesound(S_PLRWEAPON2, &sprite[i]);
if (krand() % 10 > 4) {
playsound_loc(S_KOBOLDHIT, plr.x, plr.y);
playsound_loc(S_BREATH1 + (krand() % 6), plr.x, plr.y);
spritesound(S_KOBOLDHIT, &sprite[plr.spritenum]);
spritesound(S_BREATH1 + (krand() % 6), &sprite[plr.spritenum]);
}
k = (krand() % 15) + 5;
break;
}
case KURTTYPE:
case GONZOTYPE:
playsound_loc(S_GENSWING, sprite[i].x, sprite[i].y);
spritesound(S_GENSWING, &sprite[i]);
if (sprite[i].picnum == GONZOCSWAT || sprite[i].picnum == GONZOGSWAT) { // damage 5 - 15
if (krand() % 10 > 6)
playsound_loc(S_SWORD1 + (krand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_SWORD1 + (krand() % 6), &sprite[i]);
k = (krand() % 15) + 5;
}
else if (sprite[i].picnum == GONZOGHMAT) { // damage 5 - 15
if (krand() % 10 > 6)
playsound_loc(S_SWORD1 + (krand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_SWORD1 + (krand() % 6), &sprite[i]);
k = (krand() % 10) + 5;
}
else if (sprite[i].picnum == GONZOGSHAT) { // damage 5 - 20
if (krand() % 10 > 3)
playsound_loc(S_SWORD1 + (krand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_SWORD1 + (krand() % 6), &sprite[i]);
k = (krand() % 15) + 5;
}
else if (sprite[i].picnum == KURTAT) { // damage 5 - 15
playsound_loc(S_GENSWING, sprite[i].x, sprite[i].y);
spritesound(S_GENSWING, &sprite[i]);
if (krand() % 10 > 3) {
playsound_loc(S_SWORD1 + (krand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_SWORD1 + (krand() % 6), &sprite[i]);
}
k = (krand() % 10) + 5;
}
else {
playsound_loc(S_GENSWING, sprite[i].x, sprite[i].y);
spritesound(S_GENSWING, &sprite[i]);
if (krand() % 10 > 4) {
playsound_loc(S_SOCK1 + (krand() % 4), plr.x, plr.y);
playsound_loc(S_BREATH1 + (krand() % 6), plr.x, plr.y);
spritesound(S_SOCK1 + (krand() % 4), &sprite[plr.spritenum]);
spritesound(S_BREATH1 + (krand() % 6), &sprite[plr.spritenum]);
}
k = (krand() % 4) + 1;
}
@ -826,15 +826,15 @@ void attack(PLAYER& plr, int i) {
if (sprite[i].shade > 30)
k >>= 1;
}
playsound_loc(S_GENSWING, sprite[i].x, sprite[i].y);
spritesound(S_GENSWING, &sprite[i]);
if ((krand() % 10) > 3)
playsound_loc(S_SWORD1 + (krand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_SWORD1 + (krand() % 6), &sprite[i]);
break;
case MINOTAURTYPE:
playsound_loc(S_GENSWING, sprite[i].x, sprite[i].y);
spritesound(S_GENSWING, &sprite[i]);
if (krand() % 10 > 4)
playsound_loc(S_SWORD1 + (krand() % 6), sprite[i].x, sprite[i].y);
spritesound(S_SWORD1 + (krand() % 6), &sprite[i]);
if (isWh2())
k = (krand() % 25) + 5;
break;

View file

@ -244,7 +244,7 @@ static void cast(PLAYER& plr, short i) {
if (spr.picnum == DEVILATTACK + 2) {
spr.picnum = DEVIL;
playsound_loc(S_FIREBALL, sprite[i].x, sprite[i].y);
spritesound(S_FIREBALL, &sprite[i]);
castspell(plr, i);
newstatus(i, CHASE);
}

View file

@ -132,27 +132,27 @@ static void cast(PLAYER& plr, short i) {
case DRAGONATTACK + 17:
case DRAGONATTACK + 4:
if ((krand() % 2) != 0)
playsound_loc(S_FLAME1, spr.x, spr.y);
spritesound(S_FLAME1, &spr);
else
playsound_loc(S_FIREBALL, spr.x, spr.y);
spritesound(S_FIREBALL, &spr);
firebreath(plr, i, 1, 2, LOW);
break;
case DRAGONATTACK + 18:
case DRAGONATTACK + 5:
if ((krand() % 2) != 0)
playsound_loc(S_FLAME1, spr.x, spr.y);
spritesound(S_FLAME1, &spr);
else
playsound_loc(S_FIREBALL, spr.x, spr.y);
spritesound(S_FIREBALL, &spr);
firebreath(plr, i, 2, 1, LOW);
break;
case DRAGONATTACK + 19:
case DRAGONATTACK + 6:
if ((krand() % 2) != 0)
playsound_loc(S_FLAME1, spr.x, spr.y);
spritesound(S_FLAME1, &spr);
else
playsound_loc(S_FIREBALL, spr.x, spr.y);
spritesound(S_FIREBALL, &spr);
firebreath(plr, i, 4, 0, LOW);
break;
@ -167,9 +167,9 @@ static void cast(PLAYER& plr, short i) {
case DRAGONATTACK2 + 2:
if ((krand() % 2) != 0)
playsound_loc(S_FLAME1, spr.x, spr.y);
spritesound(S_FLAME1, &spr);
else
playsound_loc(S_FIREBALL, spr.x, spr.y);
spritesound(S_FIREBALL, &spr);
firebreath(plr, i, 1, -1, HIGH);
break;

View file

@ -233,7 +233,7 @@ static void throwspank(PLAYER& plr, int i) {
int j = insertsprite(sprite[i].sectnum, MISSILE);
if (j == -1)
return;
playsound_loc(S_WITCHTHROW, sprite[i].x, sprite[i].y);
spritesound(S_WITCHTHROW, &sprite[i]);
sprite[j].x = sprite[i].x;
sprite[j].y = sprite[i].y;

View file

@ -198,7 +198,7 @@ static void stand(PLAYER& plr, short i) {
switch (spr.picnum) {
case GOBLINCHILL:
spr.picnum = GOBLINSURPRISE;
playsound_loc(S_GOBPAIN1 + (krand() % 2), spr.x, spr.y);
spritesound(S_GOBPAIN1 + (krand() % 2), &spr);
newstatus(i, CHILL);
break;
default:
@ -425,9 +425,9 @@ static void goblinWar(PLAYER& plr, short i) {
// goblins are fighting
// JSA_DEMO
if (krand() % 10 > 6)
playsound_loc(S_GENSWING, spr.x, spr.y);
spritesound(S_GENSWING, &spr);
if (krand() % 10 > 6)
playsound_loc(S_SWORD1 + (krand() % 6), spr.x, spr.y);
spritesound(S_SWORD1 + (krand() % 6), &spr);
if (checkdist(plr, i))
addhealth(plr, -(krand() & 5));

View file

@ -474,7 +474,7 @@ static void cast(PLAYER& plr, short i) {
if (spr.picnum == GONZOCSWAT) {
spr.extra--;
playsound_loc(S_GENTHROW, spr.x, spr.y);
spritesound(S_GENTHROW, &spr);
gonzopike(i, plr);
newstatus(i, CHASE);
}

View file

@ -363,13 +363,13 @@ static void cast(PLAYER& plr, short i) {
if (spr.lotag < 0) {
if (spr.picnum == GRONHALATTACK) {
spr.extra--;
playsound_loc(S_THROWPIKE, sprite[i].x, sprite[i].y);
spritesound(S_THROWPIKE, &sprite[i]);
throwhalberd(i);
newstatus(i, CHASE);
}
else if (spr.picnum == GRONMUATTACK) {
spr.extra--;
playsound_loc(S_SPELL2, sprite[i].x, sprite[i].y);
spritesound(S_SPELL2, &sprite[i]);
castspell(plr, i);
newstatus(i, CHASE);
}

View file

@ -217,7 +217,7 @@ static void cast(PLAYER& plr, short i) {
if (spr.picnum == GUARDIANATTACK + 6) {
spr.picnum = GUARDIAN;
playsound_loc(S_FIREBALL, sprite[i].x, sprite[i].y);
spritesound(S_FIREBALL, &sprite[i]);
castspell(plr, i);
newstatus(i, CHASE);
}

View file

@ -216,7 +216,7 @@ static void cast(PLAYER& plr, short i) {
if (spr.picnum == JUDYATTACK1 + 3) {
sprite[i].picnum = JUDYATTACK1;
playsound_loc(S_JUDY1 + krand() % 4, sprite[i].x, sprite[i].y);
spritesound(S_JUDY1 + krand() % 4, &sprite[i]);
if (krand() % 100 > 70) {
castspell(plr, i);
}
@ -271,7 +271,7 @@ static void cast(PLAYER& plr, short i) {
}
else if (spr.picnum == JUDYATTACK2 + 8) {
sprite[i].picnum = JUDYATTACK2;
playsound_loc(S_JUDY1 + krand() % 4, sprite[i].x, sprite[i].y);
spritesound(S_JUDY1 + krand() % 4, &sprite[i]);
if (krand() % 100 > 50)
skullycastspell(plr, i);
else {

View file

@ -208,7 +208,7 @@ static void cast(PLAYER& plr, short i) {
}
spr.picnum = KATIE;
spr.extra--;
playsound_loc(S_FIREBALL, spr.x, spr.y);
spritesound(S_FIREBALL, &spr);
newstatus(i, CHASE);
}
}
@ -224,7 +224,7 @@ static void cast(PLAYER& plr, short i) {
}
}
spr.picnum = KATIE;
playsound_loc(S_FIREBALL, spr.x, spr.y);
spritesound(S_FIREBALL, &spr);
newstatus(i, CHASE);
spr.extra--;
}
@ -232,7 +232,7 @@ static void cast(PLAYER& plr, short i) {
if (spr.picnum == KATIEAT + 16) {
spr.picnum = KATIE;
playsound_loc(S_FIREBALL, spr.x, spr.y);
spritesound(S_FIREBALL, &spr);
castspell(plr, i);
newstatus(i, CHASE);
spr.extra++;

View file

@ -12,7 +12,7 @@ static void chase(PLAYER& plr, short i) {
spr.lotag = 250;
if ((krand() % 100) > 98)
playsound_loc(S_KSNARL1 + (krand() % 4), sprite[i].x, sprite[i].y);
spritesound(S_KSNARL1 + (krand() % 4), &sprite[i]);
short osectnum = spr.sectnum;
if (cansee(plr.x, plr.y, plr.z, plr.sector, spr.x, spr.y, spr.z - (tileHeight(spr.picnum) << 7),
@ -243,7 +243,7 @@ static void resurect(PLAYER& plr, short i) {
static void search(PLAYER& plr, short i) {
if ((krand() % 100) > 98)
playsound_loc(S_KSNARL1 + (krand() % 4), sprite[i].x, sprite[i].y);
spritesound(S_KSNARL1 + (krand() % 4), &sprite[i]);
aisearch(plr, i, false);
if (!checksector6(i))
checkexpl(plr, i);

View file

@ -327,14 +327,14 @@ static void cast(PLAYER& plr, short i) {
if (spr.picnum == NEWGUYCAST + 2) {
spr.extra--;
spr.picnum = NEWGUY;
playsound_loc(S_WISP, sprite[i].x, sprite[i].y);
spritesound(S_WISP, &sprite[i]);
skullycastspell(plr, i);
newstatus(i, CHASE);
}
if (spr.picnum == NEWGUYBOW + 2) {
spr.extra--;
spr.picnum = NEWGUY;
playsound_loc(S_PLRWEAPON3, sprite[i].x, sprite[i].y);
spritesound(S_PLRWEAPON3, &sprite[i]);
newguyarrow(i, plr);
newstatus(i, CHASE);
}

View file

@ -187,7 +187,7 @@ static void stand(PLAYER& plr, short i) {
if (spr.picnum == HANGMAN) {
newstatus(i, CHILL);
playsound_loc(S_SKELSEE, spr.x, spr.y);
spritesound(S_SKELSEE, &spr);
}
else {
if (plr.shadowtime > 0) {

View file

@ -203,7 +203,7 @@ static void cast(PLAYER& plr, short i) {
if (spr.picnum == SKULLYATTACK + 2) {
sprite[i].picnum = SKULLY;
playsound_loc(S_SKULLWITCH1 + krand() % 3, sprite[i].x, sprite[i].y);
spritesound(S_SKULLWITCH1 + krand() % 3, &sprite[i]);
skullycastspell(plr, i);
newstatus(i, CHASE);
}

View file

@ -198,7 +198,7 @@ static void attack(PLAYER& plr, short i) {
spr.ang = (short)checksight_ang;
attack(plr, i);
if (krand() % 100 > ((plr.lvl * 7) + 20)) {
playsound_loc(S_SPIDERBITE, sprite[i].x, sprite[i].y);
spritesound(S_SPIDERBITE, &sprite[i]);
plr.poisoned = 1;
plr.poisontime = 7200;
showmessage("Poisoned", 360);

View file

@ -256,7 +256,7 @@ static void willowDrain(PLAYER& plr, short i) {
spr.lotag -= TICSPERFRAME;
if (spr.lotag < 0) {
playsound_loc(S_FIREBALL, spr.x, spr.y);
spritesound(S_FIREBALL, &spr);
int oldz = spr.z;
spr.z += 6144;
castspell(plr, i);

View file

@ -85,7 +85,7 @@ void InitItems()
{
sprite[i].detail = 0;
treasuresfound++;
playsound_loc(S_TREASURE1, sprite[i].x, sprite[i].y);
spritesound(S_TREASURE1, &sprite[i]);
int j = krand() % 8;
switch (j) {
case 0:
@ -353,7 +353,7 @@ void InitItems()
case 6:
for (j = 0; j < 8; j++)
explosion(i, sprite[i].x, sprite[i].y, sprite[i].z, sprite[i].owner);
playsound_loc(S_EXPLODE, sprite[i].x, sprite[i].y);
spritesound(S_EXPLODE, &sprite[i]);
deletesprite(i);
break;
default:
@ -890,7 +890,7 @@ void InitItems()
addhealth(plr, -((krand() % 20) + 5)); // Inflict pain
// make it look and sound painful, too
if ((krand() % 9) == 0) {
playsound_loc(S_PLRPAIN1 + (rand() % 2), sprite[i].x, sprite[i].y);
spritesound(S_PLRPAIN1 + (rand() % 2), &sprite[i]);
}
startredflash(10);
deletesprite(i);
@ -1051,7 +1051,7 @@ void InitItems()
{
if (plr.manatime < 1 && plr.invincibletime <= 0 && !plr.godMode) {
playsound_loc(S_FIREBALL, sprite[i].x, sprite[i].y);
spritesound(S_FIREBALL, &sprite[i]);
addhealth(plr, -1);
startredflash(30);
}

View file

@ -90,10 +90,6 @@ void usapotion(PLAYER& plr) {
SND_Sound(S_DRINK);
plr.manatime=3200;
startwhiteflash(10);
if( lavasnd != -1 ) {
stopsound(lavasnd);
lavasnd = -1;
}
break;
case 4: // invisi
SND_Sound(S_DRINK);

View file

@ -1,3 +1,4 @@
#pragma once
#include "ns.h"
BEGIN_WH_NS

View file

@ -1,44 +1,77 @@
#include "ns.h"
#include "wh.h"
#include "raze_sound.h"
#include "g_input.h"
BEGIN_WH_NS
class WHSoundEngine : public SoundEngine
{
// client specific parts of the sound engine go in this class.
void CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan *channel) override;
TArray<uint8_t> ReadSound(int lumpnum) override;
// client specific parts of the sound engine go in this class.
void CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan* channel) override;
TArray<uint8_t> ReadSound(int lumpnum) override;
public:
WHSoundEngine()
{
S_Rolloff.RolloffType = ROLLOFF_Doom;
S_Rolloff.MinDistance = 170; // these are the numbers I got when uncrunching the original sound code.
S_Rolloff.MaxDistance = 850;
}
void StopChannel(FSoundChan* chan) override
{
if (chan && chan->SysChannel != NULL && !(chan->ChanFlags & CHANF_EVICTED) && chan->SourceType == SOURCE_Actor)
{
chan->Source = NULL;
chan->SourceType = SOURCE_Unattached;
}
SoundEngine::StopChannel(chan);
}
WHSoundEngine()
{
S_Rolloff.RolloffType = ROLLOFF_Doom;
S_Rolloff.MinDistance = 93;
S_Rolloff.MaxDistance = 1064; // was originally 532, this is a bit low.
}
void StopChannel(FSoundChan* chan) override
{
if (chan && chan->SysChannel != NULL && !(chan->ChanFlags & CHANF_EVICTED) && chan->SourceType == SOURCE_Actor)
{
chan->Source = NULL;
chan->SourceType = SOURCE_Unattached;
}
SoundEngine::StopChannel(chan);
}
};
int ambsoundarray[8];
void sfxInit(void)
{
soundEngine = new WHSoundEngine;
}
soundEngine = new WHSoundEngine;
void sfxTerm()
{
// These are not constants!
ambsoundarray[0] = 0;
ambsoundarray[1] = S_WINDLOOP1;
ambsoundarray[2] = S_WINDLOOP2;
ambsoundarray[3] = S_WAVELOOP1;
ambsoundarray[4] = S_LAVALOOP1;
ambsoundarray[5] = S_WATERY;
ambsoundarray[6] = S_STONELOOP1;
ambsoundarray[7] = S_BATSLOOP;
soundEngine->AddSoundLump("", sfx_empty, 0, -1, 6); // Index 0 is unused
auto& sfx = soundEngine->GetSounds();
int count = 0;
for (int i = 0; i < 1024; i++)
{
FStringf check("JOESND/%04d", i);
int lump = fileSystem.FindFile(check);
if (lump > 0)
{
int index = soundEngine->AddSoundLump(check, lump, 0, -1, 6);
if (index == S_STONELOOP1) sfx[index].bSingular = true;
sfx[index].bLoadRAW = true;
sfx[index].b16bit = false;
sfx[index].RawRate = 11025;
soundEngine->CacheSound(&sfx[index]);
if (((++count) & 31) == 0)
I_GetEvent();
}
else
soundEngine->AddSoundLump("", sfx_empty, 0, -1, 6);
}
}
//==========================================================================
@ -49,48 +82,79 @@ void sfxTerm()
TArray<uint8_t> WHSoundEngine::ReadSound(int lumpnum)
{
auto wlump = fileSystem.OpenFileReader(lumpnum);
return wlump.Read();
auto wlump = fileSystem.OpenFileReader(lumpnum);
return wlump.Read();
}
void WHSoundEngine::CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan *)
void WHSoundEngine::CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan*)
{
#if 0
if (pos != nullptr && type != SOURCE_None)
{
FVector3 camera;
if (gMe && gMe->pSprite) camera = GetSoundPos(&gMe->pSprite->pos);
else camera = { 0, 0, 0 }; // don't crash if there is no player.
if (pos != nullptr && type != SOURCE_None)
{
vec3_t ppos = { player[pyrn].x, player[pyrn].y, player[pyrn].z };
FVector3 camera = GetSoundPos(&ppos);
if (vel) vel->Zero();
if (vel) vel->Zero();
if (type == SOURCE_Unattached)
{
pos->X = pt[0];
pos->Y = pt[1];
pos->Z = pt[2];
}
else if (type == SOURCE_Actor)
{
auto actor = (spritetype*)source;
assert(actor != nullptr);
size_t index = actor - sprite;
// Engine expects velocity in units per second, not units per tic.
if (vel) *vel = { xvel[index] * (30 / 65536.f), zvel[index] * (-30 / 65536.f), yvel[index] * (-30 / 65536.f) };
*pos = GetSoundPos(&actor->pos);
}
else if (type == SOURCE_Ambient)
{
*pos = camera; // just to be safe. Ambient sounds are in the world but unpositioned
}
if ((chanflags & CHANF_LISTENERZ))
{
pos->Y = camera.Y;
}
}
#endif
if (type == SOURCE_Unattached)
{
pos->X = pt[0];
pos->Y = pt[1];
pos->Z = pt[2];
}
else if (type == SOURCE_Actor)
{
auto actor = (spritetype*)source;
assert(actor != nullptr);
size_t index = actor - sprite;
if (vel) *vel = { 0, 0, 0 }; // this game has no velocity management usable here.
*pos = GetSoundPos(&actor->pos);
}
else if (type == SOURCE_Ambient)
{
*pos = camera; // just to be safe. Ambient sounds are in the world but unpositioned
}
if ((chanflags & CHANF_LISTENERZ))
{
pos->Y = camera.Y;
}
}
}
void updatesounds()
{
// Handle timed loops.
soundEngine->EnumerateChannels([](FSoundChan* channel)
{
if (channel->UserData > 0)
{
channel->UserData -= (IntToFixed(TICSPERFRAME) / 360);
if (channel->UserData < 0)
{
soundEngine->StopChannel(channel);
}
}
return false;
});
soundEngine->UpdateSounds(I_GetTime());
}
int playsound_internal(int sn, spritetype *spr, int x, int y, int loop, int chan)
{
sn++;
if (!soundEngine->isValidSoundId(sn)) return -1;
int sourcetype = spr ? SOURCE_Actor : x != 0 || y != 0 ? SOURCE_Unattached : SOURCE_None;
vec3_t pos = { x, y, 0 };
auto spos = GetSoundPos(&pos);
float attn = sourcetype == SOURCE_None ? 0 : 1;
int flags = sourcetype == SOURCE_Unattached ? CHANF_LISTENERZ : CHANF_NONE;
if (loop != 0) flags |= CHANF_LOOP;
auto sfx = soundEngine->StartSound(sourcetype, spr, &spos, chan, EChanFlags::FromInt(flags), sn, 1.f, attn);
if (loop > 0 && sfx) sfx->UserData = IntToFixed(loop);
else sfx->UserData = 0;
return sfx ? 0 : -1;
}
END_WH_NS

View file

@ -51,7 +51,7 @@ void castaorb(PLAYER& plr) {
switch (plr.currentorb) {
case 0: // SCARE
if (isWh2())
playsound_loc(S_GENERALMAGIC4, plr.x, plr.y);
spritesound(S_GENERALMAGIC4, &sprite[plr.spritenum]);
plr.shadowtime = ((plr.lvl + 1) * 120) << 2;
break;
case 1: // NIGHTVISION
@ -59,16 +59,16 @@ void castaorb(PLAYER& plr) {
break;
case 2: // FREEZE
if (isWh2())
playsound_loc(S_GENERALMAGIC3, plr.x, plr.y);
spritesound(S_GENERALMAGIC3, &sprite[plr.spritenum]);
else
playsound_loc(S_SPELL1, plr.x, plr.y);
spritesound(S_SPELL1, &sprite[plr.spritenum]);
daang = plr.ang;
shootgun(plr, daang, 6);
break;
case 3: // MAGIC ARROW
if (isWh2()) {
lockon(plr,10,2);
playsound_loc(S_GENERALMAGIC2, plr.x, plr.y);
spritesound(S_GENERALMAGIC2, &sprite[plr.spritenum]);
}
else {
daang = BClampAngle(plr.ang - 36);
@ -76,42 +76,42 @@ void castaorb(PLAYER& plr) {
daang = BClampAngle(daang + (k << 1));
shootgun(plr, daang, 2);
}
playsound_loc(S_SPELL1, plr.x, plr.y);
spritesound(S_SPELL1, &sprite[plr.spritenum]);
}
break;
case 4: // OPEN DOORS
daang = plr.ang;
shootgun(plr, daang, 7);
if (isWh2())
playsound_loc(S_DOORSPELL, plr.x, plr.y);
spritesound(S_DOORSPELL, &sprite[plr.spritenum]);
else
playsound_loc(S_SPELL1, plr.x, plr.y);
spritesound(S_SPELL1, &sprite[plr.spritenum]);
break;
case 5: // FLY
plr.orbactive[plr.currentorb] = 3600 + (plr.lvl * 120);
if (isWh2())
playsound_loc(S_GENERALMAGIC1, plr.x, plr.y);
spritesound(S_GENERALMAGIC1, &sprite[plr.spritenum]);
else
playsound_loc(S_SPELL1, plr.x, plr.y);
spritesound(S_SPELL1, &sprite[plr.spritenum]);
break;
case 6: // FIREBALL
if (isWh2()) {
lockon(plr,3,3);
playsound_loc(S_FIRESPELL, plr.x, plr.y);
spritesound(S_FIRESPELL, &sprite[plr.spritenum]);
}
else {
daang = plr.ang;
shootgun(plr, daang, 3);
playsound_loc(S_SPELL1, plr.x, plr.y);
spritesound(S_SPELL1, &sprite[plr.spritenum]);
}
break;
case 7: // NUKE
daang = plr.ang;
shootgun(plr, daang, 4);
if (isWh2())
playsound_loc(S_NUKESPELL, plr.x, plr.y);
spritesound(S_NUKESPELL, &sprite[plr.spritenum]);
else
playsound_loc(S_SPELL1, plr.x, plr.y);
spritesound(S_SPELL1, &sprite[plr.spritenum]);
break;
}
}

View file

@ -15,7 +15,6 @@ boolean droptheshield = false;
int dahand = 0;
int weapondrop;
int snakex, snakey;
int enchantedsoundhandle = -1;
boolean checkmedusadist(int i, int x, int y, int z, int lvl) {
int attackdist = (isWh2() ? 8192 : 1024) + (lvl << 9);
@ -27,6 +26,12 @@ boolean checkmedusadist(int i, int x, int y, int z, int lvl) {
return false;
}
static void playEnchantedSound(int sndnum)
{
if (soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, 0, CHAN_ENCHANTED) == 0)
playsound(sndnum, 0, 0, -1, CHAN_ENCHANTED);
}
void autoweaponchange(PLAYER& plr, int dagun) {
if (plr.currweaponanim > 0 || dagun == plr.selectedgun || plr.currweaponflip > 0)
return;
@ -35,10 +40,7 @@ void autoweaponchange(PLAYER& plr, int dagun) {
plr.hasshot = 0;
plr.currweaponfired = 2; // drop weapon
if (enchantedsoundhandle != -1) {
SND_StopLoop(enchantedsoundhandle);
enchantedsoundhandle=-1;
}
soundEngine->StopSound(CHAN_ENCHANTED);
switch (plr.selectedgun) {
case 0:
weapondropgoal = 40;
@ -48,15 +50,15 @@ void autoweaponchange(PLAYER& plr, int dagun) {
weapondrop = 0;
break;
case 2:
if (enchantedsoundhandle == -1 && plr.weapon[plr.selectedgun] == 3) {
enchantedsoundhandle = playsound(S_FIREWEAPONLOOP, 0, 0, -1);
if (plr.weapon[plr.selectedgun] == 3) {
playEnchantedSound(S_FIREWEAPONLOOP);
}
weapondropgoal = (isWh2() ? 40 : 100);
weapondrop = 0;
break;
case 3:
if (enchantedsoundhandle == -1 && plr.weapon[plr.selectedgun] == 3) {
enchantedsoundhandle = playsound(S_ENERGYWEAPONLOOP, 0, 0, -1);
if (plr.weapon[plr.selectedgun] == 3) {
playEnchantedSound(S_ENERGYWEAPONLOOP);
}
weapondropgoal = 100;
weapondrop = 0;
@ -66,15 +68,15 @@ void autoweaponchange(PLAYER& plr, int dagun) {
weapondrop = 0;
break;
case 5:
if (enchantedsoundhandle == -1 && plr.weapon[plr.selectedgun] == 3) {
enchantedsoundhandle = playsound(S_ENERGYWEAPONLOOP, 0, 0, -1);
if (plr.weapon[plr.selectedgun] == 3) {
playEnchantedSound(S_ENERGYWEAPONLOOP);
}
weapondropgoal = 40;
weapondrop = 0;
break;
case 6:
if (enchantedsoundhandle == -1 && plr.weapon[plr.selectedgun] == 3) {
enchantedsoundhandle = playsound(S_FIREWEAPONLOOP, 0, 0, -1);
if (plr.weapon[plr.selectedgun] == 3) {
playEnchantedSound(S_FIREWEAPONLOOP);
}
weapondropgoal = 40;
weapondrop = 0;
@ -82,8 +84,8 @@ void autoweaponchange(PLAYER& plr, int dagun) {
plr.ammo[6] = 0;
break;
case 7:
if (enchantedsoundhandle == -1 && plr.weapon[plr.selectedgun] == 3) {
enchantedsoundhandle = playsound(S_ENERGYWEAPONLOOP, 0, 0, -1);
if (plr.weapon[plr.selectedgun] == 3) {
playEnchantedSound(S_ENERGYWEAPONLOOP);
}
weapondropgoal = 40;
weapondrop = 0;
@ -93,8 +95,8 @@ void autoweaponchange(PLAYER& plr, int dagun) {
}
break;
case 8:
// if (enchantedsoundhandle == -1 && plr.weapon[plr.selectedgun] == 3) {
// enchantedsoundhandle = playsound(S_FIREWEAPONLOOP, 0, 0, -1);
// if (plr.weapon[plr.selectedgun] == 3) {
// playEnchantedSound(S_FIREWEAPONLOOP);
// }
weapondropgoal = 40;
weapondrop = 0;
@ -131,10 +133,7 @@ void weaponchange(int snum) {
int gun = key;
if (plr.weapon[gun] > 0) {
if (plr.currweaponanim <= 0 && gun != plr.selectedgun && plr.currweaponflip <= 0) {
if (enchantedsoundhandle != -1) {
SND_StopLoop(enchantedsoundhandle);
enchantedsoundhandle = -1;
}
soundEngine->StopSound(CHAN_ENCHANTED);
}
autoweaponchange(plr, gun);
@ -173,10 +172,7 @@ void plrfireweapon(PLAYER& plr) {
if (plr.ammo[plr.selectedgun] == 0) {
plr.weapon[plr.selectedgun] = plr.preenchantedweapon[plr.selectedgun];
plr.ammo[plr.selectedgun] = plr.preenchantedammo[plr.selectedgun];
if (enchantedsoundhandle != -1) {
SND_StopLoop(enchantedsoundhandle);
enchantedsoundhandle = -1;
}
soundEngine->StopSound(CHAN_ENCHANTED);
}
}
@ -331,23 +327,14 @@ void weaponsprocess(int snum) {
if (plr.shadowtime <= 0) {
if (plr.weapon[plr.currweapon] == 3) {
if (enchantedsoundhandle == -1 && plr.weapon[plr.selectedgun] == 3) {
if (plr.weapon[plr.selectedgun] == 3) {
switch (plr.selectedgun) {
case 2:
enchantedsoundhandle = playsound(S_FIREWEAPONLOOP, 0, 0, -1);
break;
case 3:
case 5:
enchantedsoundhandle = playsound(S_ENERGYWEAPONLOOP, 0, 0, -1);
break;
case 6:
enchantedsoundhandle = playsound(S_FIREWEAPONLOOP, 0, 0, -1);
playEnchantedSound(S_FIREWEAPONLOOP);
break;
case 7:
enchantedsoundhandle = playsound(S_ENERGYWEAPONLOOP, 0, 0, -1);
break;
case 8:
enchantedsoundhandle = playsound(S_ENERGYWEAPONLOOP, 0, 0, -1);
default:
playEnchantedSound(S_ENERGYWEAPONLOOP);
break;
}
}
@ -1292,8 +1279,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (sprite[pHitInfo.hitsprite].picnum == SKELETON
|| sprite[pHitInfo.hitsprite].picnum == SKELETONATTACK
|| sprite[pHitInfo.hitsprite].picnum == SKELETONDIE)
playsound_loc(S_SKELHIT1 + (krand() % 2), sprite[pHitInfo.hitsprite].x,
sprite[pHitInfo.hitsprite].y);
spritesound(S_SKELHIT1 + (krand() % 2), &sprite[pHitInfo.hitsprite]);
}
// HERE
@ -1499,8 +1485,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (sprite[pHitInfo.hitsprite].picnum == SKELETON
|| sprite[pHitInfo.hitsprite].picnum == SKELETONATTACK
|| sprite[pHitInfo.hitsprite].picnum == SKELETONDIE)
playsound_loc(S_SKELHIT1 + (krand() % 2), sprite[pHitInfo.hitsprite].x,
sprite[pHitInfo.hitsprite].y);
spritesound(S_SKELHIT1 + (krand() % 2), &sprite[pHitInfo.hitsprite]);
}
// HERE
switch (plr.currweapon) {
@ -1620,8 +1605,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (sprite[pHitInfo.hitsprite].picnum == SKELETON
|| sprite[pHitInfo.hitsprite].picnum == SKELETONATTACK
|| sprite[pHitInfo.hitsprite].picnum == SKELETONDIE)
playsound_loc(S_SKELHIT1 + (krand() % 2), sprite[pHitInfo.hitsprite].x,
sprite[pHitInfo.hitsprite].y);
spritesound(S_SKELHIT1 + (krand() % 2), &sprite[pHitInfo.hitsprite]);
}
newstatus(pHitInfo.hitsprite, DIE);
}
@ -1651,7 +1635,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (sprite[pHitInfo.hitsprite].pal == 6) {
// JSA_NEW
SND_Sound(S_SOCK1 + (krand() % 4));
playsound_loc(S_FREEZEDIE, pHitInfo.hitx, pHitInfo.hity);
playsound(S_FREEZEDIE, pHitInfo.hitx, pHitInfo.hity);
for (k = 0; k < 32; k++)
icecubes(pHitInfo.hitsprite, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz,
pHitInfo.hitsprite);
@ -1728,7 +1712,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
sprite[j].owner = sprite[plr.spritenum].owner;
sprite[j].lotag = 32;
sprite[j].hitag = 0;
playsound_loc(S_ARROWHIT, sprite[j].x, sprite[j].y);
spritesound(S_ARROWHIT, &sprite[j]);
if (isWh2() && plr.weapon[6] == 3 && plr.currweapon == 6) {
j = insertsprite(pHitInfo.hitsect, FIRECHUNK);
@ -1843,7 +1827,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (sprite[pHitInfo.hitsprite].pal == 6) {
// JSA_NEW
SND_Sound(S_SOCK1 + (krand() % 4));
playsound_loc(S_FREEZEDIE, pHitInfo.hitx, pHitInfo.hity);
playsound(S_FREEZEDIE, pHitInfo.hitx, pHitInfo.hity);
for (k = 0; k < 32; k++)
icecubes(pHitInfo.hitsprite, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz,
pHitInfo.hitsprite);
@ -2308,7 +2292,7 @@ void swingdaweapon(PLAYER& plr) {
// || plr.currweaponframe == PIKEATTACK2+4
&& plr.weapon[7] == 2 && plr.ammo[7] > 0) {
shootgun(plr, daang, 10);
playsound_loc(S_THROWPIKE, plr.x, plr.y);
spritesound(S_THROWPIKE, &sprite[plr.spritenum]);
plr.hasshot = 1;
return;
}
@ -2333,12 +2317,12 @@ void swingdaweapon(PLAYER& plr) {
if (plr.currweaponframe == PIKEATTACK1 + 4 && plr.weapon[7] == 2 && plr.ammo[7] > 0) {
shootgun(plr, daang, 10);
playsound_loc(S_GENTHROW, plr.x, plr.y);
spritesound(S_GENTHROW, &sprite[plr.spritenum]);
plr.hasshot = 1;
return;
} else if (plr.currweaponframe == ZPIKEATTACK + 4 && plr.weapon[7] == 3 && plr.ammo[7] > 0) {
lockon(plr, 3, 10);
playsound_loc(S_GENTHROW, plr.x, plr.y);
spritesound(S_GENTHROW, &sprite[plr.spritenum]);
plr.hasshot = 1;
return;
}
@ -2370,15 +2354,15 @@ void swingdaweapon(PLAYER& plr) {
plr.hasshot = 1;
break;
case 5: // battleaxe
if (isWh2() && enchantedsoundhandle != -1) {
SND_Sound(S_ENERGYSWING);
}
if (isWh2() && soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, 0, CHAN_ENCHANTED) != 0)
SND_Sound(S_ENERGYSWING);
shootgun(plr, daang, 0);
plr.hasshot = 1;
break;
case 6: // bow
if (isWh2() && enchantedsoundhandle != -1) {
if (isWh2() && soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, 0, CHAN_ENCHANTED) != 0)
{
SND_Sound(S_FIREBALL);
SND_Sound(S_PLRWEAPON3);
}
@ -2404,44 +2388,44 @@ void swingdacrunch(PLAYER& plr, int daweapon) {
switch (daweapon) {
case 0: // fist
playsound_loc(S_SOCK1 + (krand() % 4), plr.x, plr.y);
spritesound(S_SOCK1 + (krand() % 4), &sprite[plr.spritenum]);
break;
case 1: // dagger
if ((krand() % 2) != 0)
playsound_loc(S_GORE1 + (krand() % 4), plr.x, plr.y);
spritesound(S_GORE1 + (krand() % 4), &sprite[plr.spritenum]);
break;
case 2: // short sword
playsound_loc(S_SWORD2 + (krand() % 3), plr.x, plr.y);
spritesound(S_SWORD2 + (krand() % 3), &sprite[plr.spritenum]);
break;
case 3: // morningstar
playsound_loc(S_SOCK1 + (krand() % 4), plr.x, plr.y);
spritesound(S_SOCK1 + (krand() % 4), &sprite[plr.spritenum]);
break;
case 4: // broad sword
playsound_loc(S_SWORD1 + (krand() % 3), plr.x, plr.y);
spritesound(S_SWORD1 + (krand() % 3), &sprite[plr.spritenum]);
break;
case 5: // battle axe
if ((krand() % 2) != 0)
playsound_loc(S_SOCK1 + (krand() % 4), plr.x, plr.y);
spritesound(S_SOCK1 + (krand() % 4), &sprite[plr.spritenum]);
else
playsound_loc(S_SWORD1 + (krand() % 3), plr.x, plr.y);
spritesound(S_SWORD1 + (krand() % 3), &sprite[plr.spritenum]);
break;
case 6: // bow
break;
case 7: // pike
if ((krand() % 2) != 0)
playsound_loc(S_SOCK1 + (krand() % 4), plr.x, plr.y);
spritesound(S_SOCK1 + (krand() % 4), &sprite[plr.spritenum]);
else
playsound_loc(S_SWORD1 + (krand() % 3), plr.x, plr.y);
spritesound(S_SWORD1 + (krand() % 3), &sprite[plr.spritenum]);
break;
case 8: // two handed sword
playsound_loc(S_SWORD1 + (krand() % 2), plr.x, plr.y);
spritesound(S_SWORD1 + (krand() % 2), &sprite[plr.spritenum]);
break;
case 9: // halberd
if ((krand() % 2) != 0)
playsound_loc(S_SOCK1 + (krand() % 4), plr.x, plr.y);
spritesound(S_SOCK1 + (krand() % 4), &sprite[plr.spritenum]);
else
playsound_loc(S_SWORD1 + (krand() % 3), plr.x, plr.y);
spritesound(S_SWORD1 + (krand() % 3), &sprite[plr.spritenum]);
break;
}
}

View file

@ -4,7 +4,7 @@
BEGIN_WH_NS
// Placeholders that will go away.
int attacktheme, lavasnd, cartsnd, batsnd;
int attacktheme;
int killcnt, kills;
int expgained;

View file

@ -24,6 +24,7 @@ END_WH_NS
#include "gamecontrol.h"
#include "d_net.h"
#include "screenjob.h"
#include "raze_sound.h"
BEGIN_WH_NS
@ -294,7 +295,6 @@ extern boolean droptheshield;
extern int dahand;
extern int weapondrop;
extern int snakex, snakey;
extern int enchantedsoundhandle;
boolean checkmedusadist(int i, int x, int y, int z, int lvl);
void autoweaponchange(PLAYER& plr, int dagun);
@ -420,7 +420,29 @@ inline int BClampAngle(int a)
// placeholders
extern int lavasnd, cartsnd, batsnd;
// This is for the 3 sounds that get explicitly checked outside the sound code.
enum
{
CHAN_ENCHANTED = 100,
CHAN_CART,
CHAN_BAT,
CHAN_AMBIENT1,
CHAN_AMBIENT2,
CHAN_AMBIENT3,
CHAN_AMBIENT4,
CHAN_AMBIENT5,
CHAN_AMBIENT6,
CHAN_AMBIENT7,
CHAN_AMBIENT8,
};
enum
{
MAX_AMB_SOUNDS = 8,
};
extern int ambsoundarray[8];
inline void startredflash(int)
{}
inline void startwhiteflash(int)
@ -430,24 +452,21 @@ inline void startgreenflash(int)
inline void startblueflash(int)
{}
int playsound_internal(int sn, spritetype* spr, int x, int y, int loop, int chan);
inline int playsound(int sn, int x, int y, int loop = 0, int channel = CHAN_AUTO) {
return playsound_internal(sn, nullptr, x, y, loop, channel);
}
inline int SND_Sound(int sn) {
return 0;
return playsound(sn, 0, 0);
}
inline int playsound_loc(int sn, int x, int y) {
return 0;
inline int spritesound(int sn, spritetype *s, int loop = 0, int channel = CHAN_AUTO) {
return playsound_internal(sn, s, 0, 0, loop, channel);
}
inline int playsound(int sn, int x, int y, int loop) {
return 0;
}
inline void stopsound(int snd)
{}
inline void SND_StopLoop(int)
{}
inline void SND_CheckLoops()
{}
void startmusic(int);
void startsong(int);
void setupmidi();

View file

@ -439,9 +439,8 @@ void animateobjs(PLAYER& plr) {
break;
case 2: // fly to roof and get deleted
if (sprite[i].lotag < 0) {
if (i == lastbat && batsnd != -1) {
stopsound(batsnd);
batsnd = -1;
if (i == lastbat) {
soundEngine->StopSound(CHAN_BAT);
}
deletesprite((short) i);
continue;
@ -451,9 +450,8 @@ void animateobjs(PLAYER& plr) {
(((int) sintable[sprite[i].ang & 2047]) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
setsprite(i, sprite[i].x, sprite[i].y, sprite[i].z);
if ((movestat & 0xc000) == 16384) {// Hits a ceiling / floor
if (i == lastbat && batsnd != -1) {
stopsound(batsnd);
batsnd = -1;
if (i == lastbat) {
soundEngine->StopSound(CHAN_BAT);
}
deletesprite((short) i);
continue;
@ -508,9 +506,8 @@ void animateobjs(PLAYER& plr) {
sprite[i].z -= (TICSPERFRAME << 6);
setsprite(i, sprite[i].x, sprite[i].y, sprite[i].z);
if (sprite[i].z <= sector[sprite[i].sectnum].ceilingz + 32768) {
stopsound(cartsnd);
cartsnd = -1;
playsound_loc(S_CLUNK, sprite[i].x, sprite[i].y);
soundEngine->StopSound(CHAN_CART);
spritesound(S_CLUNK, &sprite[i]);
changespritestat(i, (short) 0);
sprite[i].lotag = 1820;
sprite[i].z = sector[sprite[i].sectnum].ceilingz + 32768;
@ -551,9 +548,8 @@ void animateobjs(PLAYER& plr) {
sprite[i].z += ironbarmove;
setsprite(i, sprite[i].x, sprite[i].y, sprite[i].z);
if (sprite[i].z >= (sector[sprite[i].sectnum].floorz - 32768)) {
stopsound(cartsnd);
cartsnd = -1;
playsound_loc(S_CLUNK, sprite[i].x, sprite[i].y);
soundEngine->StopSound(CHAN_CART);
spritesound(S_CLUNK, &sprite[i]);
changespritestat(i, (short) 0);
sprite[i].lotag = 1821;
sprite[i].z = sector[sprite[i].sectnum].floorz - 32768;
@ -1168,7 +1164,7 @@ void animateobjs(PLAYER& plr) {
if (cansee(plr.x, plr.y, plr.z, plr.sector, sprite[i].x, sprite[i].y,
sprite[i].z - (tileHeight(sprite[i].picnum) << 7), sprite[i].sectnum)) {
// JSA_NEW
playsound_loc(S_FIREBALL, sprite[i].x, sprite[i].y);
spritesound(S_FIREBALL, &sprite[i]);
castspell(plr, i);
}
}

View file

@ -438,7 +438,7 @@ void teleporter() {
warpfxsprite(plr.spritenum);
plr.ang = (int) daang;
justwarpedfx = 48;
playsound_loc(S_WARP, plr.x, plr.y);
spritesound(S_WARP, &sprite[plr.spritenum]);
setsprite(plr.spritenum, plr.x, plr.y, plr.z + (32 << 8));
}
}
@ -464,13 +464,13 @@ void teleporter() {
}
mapon++;
playsound_loc(S_CHAINDOOR1, plr.x, plr.y);
spritesound(S_CHAINDOOR1, &sprite[plr.spritenum]);
playertorch = 0;
playsound_loc(S_WARP, plr.x, plr.y);
spritesound(S_WARP, &sprite[plr.spritenum]);
loadnewlevel(mapon);
break;
case 2: // ENDOFDEMO
playsound_loc(S_THUNDER1, plr.x, plr.y);
spritesound(S_THUNDER1, &sprite[plr.spritenum]);
justteleported = true;
showVictoryScreen();
break;
@ -596,30 +596,29 @@ void sectorsounds() {
if (!SoundEnabled())
return;
#pragma message("sectorspunds")
#if 0
PLAYER& plr = player[pyrn];
int sec = sector[plr.sector].extra & 0xFFFF;
if (sec != 0) {
if ((sec & 32768) != 0) { // loop on/off sector
if ((sec & 1) != 0) { // turn loop on if lsb is 1
if (sec != 0)
{
if ((sec & 32768) != 0)
{ // loop on/off sector
if ((sec & 1) != 0)
{ // turn loop on if lsb is 1
int index = (sec & ~0x8001) >> 1;
if (index < ambsoundarray.length && ambsoundarray[index].hsound == -1)
ambsoundarray[index].hsound = playsound(ambsoundarray[index].soundnum, 0, 0, -1);
if (index < MAX_AMB_SOUNDS && soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, 0, CHAN_AMBIENT1 + index) == 0)
{
playsound(ambsoundarray[index], 0, 0, 0, CHAN_AMBIENT1 + index);
}
} else { // turn loop off if lsb is 0 and its playing
int index = (sec & ~0x8000) >> 1;
if (index < ambsoundarray.length && ambsoundarray[index].hsound != -1) {
stopsound(ambsoundarray[index].hsound);
ambsoundarray[index].hsound = -1;
}
soundEngine->StopSound(CHAN_AMBIENT1 + index);
}
} else {
if (plr.z <= sector[plr.sector].floorz - (8 << 8))
playsound_loc(sec, plr.x, plr.y);
spritesound(sec, &sprite[plr.spritenum]);
}
}
#endif
}
@ -829,7 +828,7 @@ void makeasplash(int picnum, PLAYER& plr) {
if(!isWh2() && picnum == SLIMESPLASH)
break;
playsound_loc(S_SPLASH1 + (krand() % 3), sprite[j].x, sprite[j].y);
spritesound(S_SPLASH1 + (krand() % 3), &sprite[j]);
break;
case LAVASPLASH:
break;
@ -876,14 +875,14 @@ void makemonstersplash(int picnum, int i) {
if ((gotpic[WATER >> 3] & (1 << (WATER & 7))) > 0) {
gotpic[WATER >> 3] &= ~(1 << (WATER & 7));
if ((krand() % 2) != 0)
playsound_loc(S_SPLASH1 + (krand() % 3), sprite[j].x, sprite[j].y);
spritesound(S_SPLASH1 + (krand() % 3), &sprite[j]);
}
}
if ((krand() % 2) != 0) {
if ((gotpic[SLIME >> 3] & (1 << (SLIME & 7))) > 0) {
gotpic[SLIME >> 3] &= ~(1 << (SLIME & 7));
if ((krand() % 2) != 0)
playsound_loc(S_SPLASH1 + (krand() % 3), sprite[j].x, sprite[j].y);
spritesound(S_SPLASH1 + (krand() % 3), &sprite[j]);
}
}
break;

View file

@ -824,7 +824,7 @@ boolean prepareboard(const char* fname) {
// anit-missile for level only
// dont forget to cleanup values
plr.treasure[TONYXRING] = 0;
SND_CheckLoops();
soundEngine->StopAllChannels();
justteleported = false;
} else {

View file

@ -185,15 +185,15 @@ void newstatus(short sn, int seq) {
changespritestat(sn, BROKENVASE);
switch (sprite[sn].picnum) {
case VASEA:
playsound_loc(S_GLASSBREAK1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GLASSBREAK1 + (krand() % 3), &sprite[sn]);
sprite[sn].picnum = SHATTERVASE;
break;
case VASEB:
playsound_loc(S_GLASSBREAK1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GLASSBREAK1 + (krand() % 3), &sprite[sn]);
sprite[sn].picnum = SHATTERVASE2;
break;
case VASEC:
playsound_loc(S_GLASSBREAK1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GLASSBREAK1 + (krand() % 3), &sprite[sn]);
sprite[sn].picnum = SHATTERVASE3;
break;
case STAINGLASS1:
@ -210,7 +210,7 @@ void newstatus(short sn, int seq) {
break;
case FBARRELFALL:
case BARREL:
playsound_loc(S_BARRELBREAK, sprite[sn].x, sprite[sn].y);
spritesound(S_BARRELBREAK, &sprite[sn]);
sprite[sn].picnum = FSHATTERBARREL;
break;
}
@ -223,27 +223,27 @@ void newstatus(short sn, int seq) {
sprite[sn].pal = 7;
break;
case ANIMLEVERDN:
playsound_loc(S_PULLCHAIN1, sprite[sn].x, sprite[sn].y);
spritesound(S_PULLCHAIN1, &sprite[sn]);
sprite[sn].picnum = LEVERUP;
changespritestat(sn, ANIMLEVERDN);
sprite[sn].lotag = 24;
break;
case ANIMLEVERUP:
playsound_loc(S_PULLCHAIN1, sprite[sn].x, sprite[sn].y);
spritesound(S_PULLCHAIN1, &sprite[sn]);
sprite[sn].picnum = LEVERDOWN;
changespritestat(sn, ANIMLEVERUP);
sprite[sn].lotag = 24;
break;
case SKULLPULLCHAIN1:
case PULLTHECHAIN:
playsound_loc(S_PULLCHAIN1, sprite[sn].x, sprite[sn].y);
spritesound(S_PULLCHAIN1, &sprite[sn]);
changespritestat(sn, PULLTHECHAIN);
SND_Sound(S_CHAIN1);
sprite[sn].lotag = 24;
break;
case FROZEN:
// JSA_NEW
playsound_loc(S_FREEZE, sprite[sn].x, sprite[sn].y);
spritesound(S_FREEZE, &sprite[sn]);
changespritestat(sn, FROZEN);
sprite[sn].lotag = 3600;
break;
@ -265,7 +265,7 @@ void newstatus(short sn, int seq) {
switch (sprite[sn].detail) {
case DEMONTYPE:
sprite[sn].lotag = 24;
playsound_loc(S_GUARDIANPAIN1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_GUARDIANPAIN1 + (krand() % 2), &sprite[sn]);
sprite[sn].picnum = DEMON - 1;
changespritestat(sn, PAIN);
break;
@ -273,14 +273,14 @@ void newstatus(short sn, int seq) {
sprite[sn].lotag = 24;
sprite[sn].picnum = NEWGUYPAIN;
changespritestat(sn, PAIN);
playsound_loc(S_AGM_PAIN1, sprite[sn].x, sprite[sn].y);
spritesound(S_AGM_PAIN1, &sprite[sn]);
break;
case KURTTYPE:
sprite[sn].lotag = 24;
sprite[sn].picnum = GONZOCSWPAIN;
changespritestat(sn, PAIN);
playsound_loc(S_GRONPAINA + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GRONPAINA + (krand() % 3), &sprite[sn]);
break;
case GONZOTYPE:
@ -295,19 +295,19 @@ void newstatus(short sn, int seq) {
case KURTREADY + 1:
case GONZOCSW:
sprite[sn].picnum = GONZOCSWPAIN;
playsound_loc(S_GRONPAINA + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GRONPAINA + (krand() % 3), &sprite[sn]);
break;
case GONZOGSW:
sprite[sn].picnum = GONZOGSWPAIN;
playsound_loc(S_GRONPAINA + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GRONPAINA + (krand() % 3), &sprite[sn]);
break;
case GONZOGHM:
sprite[sn].picnum = GONZOGHMPAIN;
playsound_loc(S_GRONPAINA + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GRONPAINA + (krand() % 3), &sprite[sn]);
break;
case GONZOGSH:
sprite[sn].picnum = GONZOGSHPAIN;
playsound_loc(S_GRONPAINA, sprite[sn].x, sprite[sn].y);
spritesound(S_GRONPAINA, &sprite[sn]);
break;
default:
changespritestat(sn, FLEE);
@ -337,7 +337,7 @@ void newstatus(short sn, int seq) {
case GUARDIANTYPE:
sprite[sn].lotag = 24;
// sprite[sn].picnum=GUARDIANATTACK;
playsound_loc(S_GUARDIANPAIN1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_GUARDIANPAIN1 + (krand() % 2), &sprite[sn]);
if(isWh2()) sprite[sn].picnum = GUARDIAN;
else sprite[sn].picnum = GUARDIANCHAR;
@ -346,7 +346,7 @@ void newstatus(short sn, int seq) {
case GRONTYPE:
sprite[sn].lotag = 24;
changespritestat(sn, PAIN);
playsound_loc(S_GRONPAINA + krand() % 3, sprite[sn].x, sprite[sn].y);
spritesound(S_GRONPAINA + krand() % 3, &sprite[sn]);
if(sprite[sn].picnum == GRONHAL || sprite[sn].picnum == GRONHALATTACK)
sprite[sn].picnum = GRONHALPAIN;
@ -358,10 +358,10 @@ void newstatus(short sn, int seq) {
case KOBOLDTYPE:
sprite[sn].picnum = KOBOLDDIE;
changespritestat(sn, PAIN);
playsound_loc(S_KPAIN1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_KPAIN1 + (krand() % 2), &sprite[sn]);
break;
case DEVILTYPE:
playsound_loc(S_MPAIN1, sprite[sn].x, sprite[sn].y);
spritesound(S_MPAIN1, &sprite[sn]);
sprite[sn].picnum = DEVILPAIN;
changespritestat(sn, PAIN);
break;
@ -369,7 +369,7 @@ void newstatus(short sn, int seq) {
sprite[sn].picnum = FREDPAIN;
changespritestat(sn, PAIN);
// EG: Sounds for Fred (currently copied from ogre)
playsound_loc(S_KPAIN1 + (rand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_KPAIN1 + (rand() % 2), &sprite[sn]);
break;
case GOBLINTYPE:
case IMPTYPE:
@ -380,13 +380,13 @@ void newstatus(short sn, int seq) {
} else {
sprite[sn].picnum = GOBLINPAIN;
changespritestat(sn, PAIN);
playsound_loc(S_GOBPAIN1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_GOBPAIN1 + (krand() % 2), &sprite[sn]);
}
break;
case MINOTAURTYPE:
sprite[sn].picnum = MINOTAURPAIN;
changespritestat(sn, PAIN);
playsound_loc(S_MPAIN1, sprite[sn].x, sprite[sn].y);
spritesound(S_MPAIN1, &sprite[sn]);
break;
default:
changespritestat(sn, FLEE);
@ -501,19 +501,17 @@ void newstatus(short sn, int seq) {
changespritestat(sn, BOB);
break;
case LIFTUP:
if (cartsnd == -1) {
playsound_loc(S_CLUNK, sprite[sn].x, sprite[sn].y);
cartsnd = playsound(S_CHAIN1, sprite[sn].x, sprite[sn].y, 5);
if (soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, -1, CHAN_CART) == 0) {
spritesound(S_CLUNK, &sprite[sn]);
spritesound(S_CHAIN1, &sprite[sn], 5, CHAN_CART);
}
changespritestat(sn, LIFTUP);
break;
case LIFTDN:
if (cartsnd == -1) {
playsound_loc(S_CLUNK, sprite[sn].x, sprite[sn].y);
cartsnd = playsound(S_CHAIN1, sprite[sn].x, sprite[sn].y, 5);
if (soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, -1, CHAN_CART) == 0) {
spritesound(S_CLUNK, &sprite[sn]);
spritesound(S_CHAIN1, &sprite[sn], 5, CHAN_CART);
}
changespritestat(sn, LIFTDN);
break;
case SHOVE:
@ -538,7 +536,7 @@ void newstatus(short sn, int seq) {
sprite[sn].cstat |= 1;
changespritestat(sn, ATTACK2);
sprite[sn].picnum = DRAGONATTACK2;
playsound_loc(S_DRAGON1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_DRAGON1 + (krand() % 3), &sprite[sn]);
case ATTACK:
sprite[sn].lotag = 64;
sprite[sn].cstat |= 1;
@ -581,12 +579,12 @@ void newstatus(short sn, int seq) {
break;
case KATIETYPE:
if ((krand() % 10) > 4) {
playsound_loc(S_JUDY1, sprite[sn].x, sprite[sn].y);
spritesound(S_JUDY1, &sprite[sn]);
}
sprite[sn].picnum = KATIEAT;
break;
case DEMONTYPE:
playsound_loc(S_GUARDIAN1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_GUARDIAN1 + (krand() % 2), &sprite[sn]);
sprite[sn].picnum = DEMON;
break;
case GRONTYPE:
@ -600,17 +598,17 @@ void newstatus(short sn, int seq) {
case KOBOLDTYPE:
sprite[sn].picnum = KOBOLDATTACK;
if (krand() % 10 > 4)
playsound_loc(S_KSNARL1 + (krand() % 4), sprite[sn].x, sprite[sn].y);
spritesound(S_KSNARL1 + (krand() % 4), &sprite[sn]);
break;
case DRAGONTYPE:
if ((krand() % 10) > 3)
playsound_loc(S_DRAGON1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_DRAGON1 + (krand() % 2), &sprite[sn]);
sprite[sn].picnum = DRAGONATTACK;
break;
case DEVILTYPE:
if ((krand() % 10) > 4)
playsound_loc(S_DEMON1 + (krand() % 5), sprite[sn].x, sprite[sn].y);
spritesound(S_DEMON1 + (krand() % 5), &sprite[sn]);
sprite[sn].picnum = DEVILATTACK;
break;
@ -618,7 +616,7 @@ void newstatus(short sn, int seq) {
sprite[sn].picnum = FREDATTACK;
/* EG: Sounds for Fred (currently copied from Ogre) */
if (rand() % 10 > 4)
playsound_loc(S_KSNARL1 + (rand() % 4), sprite[sn].x, sprite[sn].y);
spritesound(S_KSNARL1 + (rand() % 4), &sprite[sn]);
break;
case SKELETONTYPE:
sprite[sn].picnum = SKELETONATTACK;
@ -626,17 +624,17 @@ void newstatus(short sn, int seq) {
case IMPTYPE:
sprite[sn].lotag = 92;
if ((krand() % 10) > 5)
playsound_loc(S_IMPGROWL1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_IMPGROWL1 + (krand() % 3), &sprite[sn]);
sprite[sn].picnum = IMPATTACK;
break;
case GOBLINTYPE:
if ((krand() % 10) > 5)
playsound_loc(S_GOBLIN1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GOBLIN1 + (krand() % 3), &sprite[sn]);
sprite[sn].picnum = GOBLINATTACK;
break;
case MINOTAURTYPE:
if ((krand() % 10) > 4)
playsound_loc(S_MSNARL1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_MSNARL1 + (krand() % 3), &sprite[sn]);
sprite[sn].picnum = MINOTAURATTACK;
break;
@ -645,7 +643,7 @@ void newstatus(short sn, int seq) {
break;
case FATWITCHTYPE:
if ((krand() % 10) > 4)
playsound_loc(S_FATLAUGH, sprite[sn].x, sprite[sn].y);
spritesound(S_FATLAUGH, &sprite[sn]);
sprite[sn].picnum = FATWITCHATTACK;
break;
case JUDYTYPE:
@ -656,11 +654,11 @@ void newstatus(short sn, int seq) {
sprite[sn].picnum = JUDYATTACK2;
break;
case WILLOWTYPE:
playsound_loc(S_WISP + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_WISP + (krand() % 2), &sprite[sn]);
sprite[sn].pal = 7;
break;
case GUARDIANTYPE:
playsound_loc(S_GUARDIAN1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_GUARDIAN1 + (krand() % 2), &sprite[sn]);
sprite[sn].picnum = GUARDIANATTACK;
break;
}
@ -749,14 +747,14 @@ void newstatus(short sn, int seq) {
sprite[sn].picnum = IMP;
} else {
if (krand() % 10 > 2)
playsound_loc(S_GOBLIN1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GOBLIN1 + (krand() % 3), &sprite[sn]);
sprite[sn].picnum = GOBLIN;
}
break;
case MINOTAURTYPE:
// JSA_DEMO3
playsound_loc(S_MSNARL1 + (krand() % 4), sprite[sn].x, sprite[sn].y);
spritesound(S_MSNARL1 + (krand() % 4), &sprite[sn]);
sprite[sn].picnum = MINOTAUR;
break;
case SKULLYTYPE:
@ -804,12 +802,12 @@ void newstatus(short sn, int seq) {
case NEWGUYTYPE:
sprite[sn].lotag = 20;
sprite[sn].picnum = NEWGUYDIE;
playsound_loc(S_AGM_DIE1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_AGM_DIE1 + (krand() % 3), &sprite[sn]);
break;
case KURTTYPE:
case GONZOTYPE:
sprite[sn].lotag = 20;
playsound_loc(S_GRONDEATHA + krand() % 3, sprite[sn].x, sprite[sn].y);
spritesound(S_GRONDEATHA + krand() % 3, &sprite[sn]);
switch (sprite[sn].picnum) {
case KURTSTAND:
case KURTKNEE:
@ -853,12 +851,12 @@ void newstatus(short sn, int seq) {
}
break;
case KATIETYPE:
playsound_loc(S_JUDYDIE, sprite[sn].x, sprite[sn].y);
spritesound(S_JUDYDIE, &sprite[sn]);
sprite[sn].lotag = 20;
sprite[sn].picnum = KATIEPAIN;
break;
case DEMONTYPE:
playsound_loc(S_GUARDIANDIE, sprite[sn].x, sprite[sn].y);
spritesound(S_GUARDIANDIE, &sprite[sn]);
explosion(sn, sprite[sn].x, sprite[sn].y, sprite[sn].z, sprite[sn].owner);
deletesprite((short) sn);
addscore(aiGetPlayerTarget(sn), 1500);
@ -866,7 +864,7 @@ void newstatus(short sn, int seq) {
return;
case GRONTYPE:
sprite[sn].lotag = 20;
playsound_loc(S_GRONDEATHA + krand() % 3, sprite[sn].x, sprite[sn].y);
spritesound(S_GRONDEATHA + krand() % 3, &sprite[sn]);
if(sprite[sn].picnum == GRONHAL || sprite[sn].picnum == GRONHALATTACK || sprite[sn].picnum == GRONHALPAIN)
sprite[sn].picnum = GRONHALDIE;
else if(sprite[sn].picnum == GRONSW || sprite[sn].picnum == GRONSWATTACK || sprite[sn].picnum == GRONSWPAIN)
@ -883,18 +881,18 @@ void newstatus(short sn, int seq) {
sprite[sn].lotag = 20;
break;
case KOBOLDTYPE:
playsound_loc(S_KDIE1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_KDIE1 + (krand() % 2), &sprite[sn]);
sprite[sn].lotag = 20;
sprite[sn].picnum = KOBOLDDIE;
break;
case DRAGONTYPE:
playsound_loc(S_DEMONDIE1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_DEMONDIE1 + (krand() % 2), &sprite[sn]);
sprite[sn].lotag = 20;
sprite[sn].picnum = DRAGONDIE;
break;
case DEVILTYPE:
playsound_loc(S_DEMONDIE1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_DEMONDIE1 + (krand() % 2), &sprite[sn]);
sprite[sn].lotag = 20;
sprite[sn].picnum = DEVILDIE;
break;
@ -902,25 +900,25 @@ void newstatus(short sn, int seq) {
sprite[sn].lotag = 20;
sprite[sn].picnum = FREDDIE;
/* EG: Sounds for Fred (currently copied from Ogre) */
playsound_loc(S_KDIE1 + (rand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_KDIE1 + (rand() % 2), &sprite[sn]);
break;
case SKELETONTYPE:
playsound_loc(S_SKELETONDIE, sprite[sn].x, sprite[sn].y);
spritesound(S_SKELETONDIE, &sprite[sn]);
sprite[sn].lotag = 20;
sprite[sn].picnum = SKELETONDIE;
break;
case IMPTYPE:
playsound_loc(S_IMPDIE1 + (krand() % 2), sprite[sn].x, sprite[sn].y);
spritesound(S_IMPDIE1 + (krand() % 2), &sprite[sn]);
sprite[sn].lotag = 20;
sprite[sn].picnum = IMPDIE;
break;
case GOBLINTYPE:
playsound_loc(S_GOBDIE1 + (krand() % 3), sprite[sn].x, sprite[sn].y);
spritesound(S_GOBDIE1 + (krand() % 3), &sprite[sn]);
sprite[sn].lotag = 20;
sprite[sn].picnum = GOBLINDIE;
break;
case MINOTAURTYPE:
playsound_loc(S_MDEATH1, sprite[sn].x, sprite[sn].y);
spritesound(S_MDEATH1, &sprite[sn]);
sprite[sn].lotag = 10;
sprite[sn].picnum = MINOTAURDIE;
break;
@ -931,12 +929,12 @@ void newstatus(short sn, int seq) {
case SKULLYTYPE:
sprite[sn].lotag = 20;
sprite[sn].picnum = SKULLYDIE;
playsound_loc(S_SKULLWITCHDIE, sprite[sn].x, sprite[sn].y);
spritesound(S_SKULLWITCHDIE, &sprite[sn]);
break;
case FATWITCHTYPE:
sprite[sn].lotag = 20;
sprite[sn].picnum = FATWITCHDIE;
playsound_loc(S_FATWITCHDIE, sprite[sn].x, sprite[sn].y);
spritesound(S_FATWITCHDIE, &sprite[sn]);
break;
case JUDYTYPE:
sprite[sn].lotag = 20;
@ -947,11 +945,11 @@ void newstatus(short sn, int seq) {
return;
} else {
sprite[sn].picnum = JUDYDIE;
playsound_loc(S_JUDYDIE, sprite[sn].x, sprite[sn].y);
spritesound(S_JUDYDIE, &sprite[sn]);
}
break;
case GUARDIANTYPE:
playsound_loc(S_GUARDIANDIE, sprite[sn].x, sprite[sn].y);
spritesound(S_GUARDIANDIE, &sprite[sn]);
for (int j = 0; j < 4; j++)
explosion(sn, sprite[sn].x, sprite[sn].y, sprite[sn].z, sprite[sn].owner);
deletesprite((short) sn);
@ -959,7 +957,7 @@ void newstatus(short sn, int seq) {
kills++;
return;
case WILLOWTYPE:
playsound_loc(S_WILLOWDIE, sprite[sn].x, sprite[sn].y);
spritesound(S_WILLOWDIE, &sprite[sn]);
sprite[sn].pal = 0;
sprite[sn].lotag = 20;
sprite[sn].picnum = WILLOWEXPLO;
@ -1583,7 +1581,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
// EG 21 Aug 2017: Move this here so as not to make ouch sounds unless pain is
// happening
if ((krand() & 9) == 0)
playsound_loc(S_PLRPAIN1 + (rand() % 2), sprite[i].x, sprite[i].y);
spritesound(S_PLRPAIN1 + (rand() % 2), &sprite[i]);
if (isWh2() && sprite[i].picnum == DART) {
plr.poisoned = 1;
@ -1597,7 +1595,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
if (sprite[i].picnum == PLASMA)
addhealth(plr, -((krand() & 15) + 15));
else if (sprite[i].picnum == FATSPANK) {
playsound_loc(S_GORE1A + (krand() % 3), plr.x, plr.y);
spritesound(S_GORE1A + (krand() % 3), &sprite[plr.spritenum]);
addhealth(plr, -((krand() & 10) + 10));
if ((krand() % 100) > 90) {
plr.poisoned = 1;
@ -1647,7 +1645,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
sprite[j].hitag -= 30;
if(sprite[i].picnum == THROWPIKE) {
if ((krand() % 2) != 0)
playsound_loc(S_GORE1A + krand() % 2, sprite[i].x, sprite[i].y);
spritesound(S_GORE1A + krand() % 2, &sprite[i]);
}
} else {
switch (sprite[i].picnum) {

View file

@ -47,7 +47,7 @@ void playerdead(PLAYER& plr) {
if (plr.spiked == 1) {
plr.spiketics = spikeanimtics[0].daweapontics;
playsound_loc(S_GORE1, plr.x, plr.y);
spritesound(S_GORE1, &sprite[plr.spritenum]);
SND_Sound(S_HEARTBEAT);
}
@ -261,7 +261,7 @@ void plruse(PLAYER& plr) {
showmessage("find door trigger", 360);
}
}
playsound_loc(S_PUSH1 + (krand() % 2), plr.x, plr.y);
spritesound(S_PUSH1 + (krand() % 2), &sprite[plr.spritenum]);
}
}
if (nt.tagsprite >= 0) {
@ -335,10 +335,10 @@ void chunksofmeat(PLAYER& plr, int hitsprite, int hitx, int hity, int hitz, shor
if (sprite[hitsprite].picnum == SKELETON || sprite[hitsprite].picnum == SKELETONATTACK
|| sprite[hitsprite].picnum == SKELETONDIE) {
playsound_loc(S_SKELHIT1 + (krand() % 2), sprite[hitsprite].x, sprite[hitsprite].y);
spritesound(S_SKELHIT1 + (krand() % 2), &sprite[hitsprite]);
} else {
if (krand() % 100 > 60)
playsound_loc(S_GORE1 + (krand() % 4), sprite[hitsprite].x, sprite[hitsprite].y);
spritesound(S_GORE1 + (krand() % 4), &sprite[hitsprite]);
}
if ((hitsprite >= 0) && (sprite[hitsprite].statnum < MAXSTATUS)) {

View file

@ -53,7 +53,7 @@ void operatesprite(PLAYER& plr, short s) {
case STAINSCENE:
switch (sprite[s].lotag) {
case 2:
playsound_loc(S_GLASSBREAK1 + (rand() % 3), sprite[s].x, sprite[s].y);
spritesound(S_GLASSBREAK1 + (rand() % 3), &sprite[s]);
for (int j = 0; j < 20; j++) {
shards(s, 2);
}
@ -832,9 +832,10 @@ void operatesector(PLAYER& plr, int s) {
for (k = 0; k < MAXSPRITES; k++) {
if (sector[s].hitag == sprite[k].hitag && sprite[k].extra < 1) {
newstatus(k, FLOCKSPAWN);
if (batsnd == -1)
batsnd = playsound(S_BATSLOOP, sprite[k].x, sprite[k].y, -1);
// sector[s].lotag = sector[s].hitag = 0;
if (soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, -1, CHAN_BAT) == 0) {
spritesound(S_BATSLOOP, &sprite[k], -1, CHAN_BAT);
// sector[s].lotag = sector[s].hitag = 0;
}
}
}
}