- 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? // 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; int count = 0;
if (sound_id > 0) if (sound_id > 0)
{ {
for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan) for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan)
{ {
if (chann != -1 && chann != chan->EntChannel) continue;
if (chan->OrgID == sound_id && (sourcetype == SOURCE_Any || if (chan->OrgID == sound_id && (sourcetype == SOURCE_Any ||
(chan->SourceType == sourcetype && (chan->SourceType == sourcetype &&
chan->Source == source))) 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) 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))) if ((sourcetype == SOURCE_Any || (chan->SourceType == sourcetype && chan->Source == source)))
{ {
count++; count++;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -216,7 +216,7 @@ static void cast(PLAYER& plr, short i) {
if (spr.picnum == JUDYATTACK1 + 3) { if (spr.picnum == JUDYATTACK1 + 3) {
sprite[i].picnum = JUDYATTACK1; 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) { if (krand() % 100 > 70) {
castspell(plr, i); castspell(plr, i);
} }
@ -271,7 +271,7 @@ static void cast(PLAYER& plr, short i) {
} }
else if (spr.picnum == JUDYATTACK2 + 8) { else if (spr.picnum == JUDYATTACK2 + 8) {
sprite[i].picnum = JUDYATTACK2; 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) if (krand() % 100 > 50)
skullycastspell(plr, i); skullycastspell(plr, i);
else { else {

View file

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

View file

@ -12,7 +12,7 @@ static void chase(PLAYER& plr, short i) {
spr.lotag = 250; spr.lotag = 250;
if ((krand() % 100) > 98) 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; short osectnum = spr.sectnum;
if (cansee(plr.x, plr.y, plr.z, plr.sector, spr.x, spr.y, spr.z - (tileHeight(spr.picnum) << 7), 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) { static void search(PLAYER& plr, short i) {
if ((krand() % 100) > 98) 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); aisearch(plr, i, false);
if (!checksector6(i)) if (!checksector6(i))
checkexpl(plr, i); checkexpl(plr, i);

View file

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

View file

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

View file

@ -203,7 +203,7 @@ static void cast(PLAYER& plr, short i) {
if (spr.picnum == SKULLYATTACK + 2) { if (spr.picnum == SKULLYATTACK + 2) {
sprite[i].picnum = SKULLY; 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); skullycastspell(plr, i);
newstatus(i, CHASE); newstatus(i, CHASE);
} }

View file

@ -198,7 +198,7 @@ static void attack(PLAYER& plr, short i) {
spr.ang = (short)checksight_ang; spr.ang = (short)checksight_ang;
attack(plr, i); attack(plr, i);
if (krand() % 100 > ((plr.lvl * 7) + 20)) { 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.poisoned = 1;
plr.poisontime = 7200; plr.poisontime = 7200;
showmessage("Poisoned", 360); showmessage("Poisoned", 360);

View file

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

View file

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

View file

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

View file

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

View file

@ -1,44 +1,77 @@
#include "ns.h" #include "ns.h"
#include "wh.h" #include "wh.h"
#include "raze_sound.h" #include "raze_sound.h"
#include "g_input.h"
BEGIN_WH_NS BEGIN_WH_NS
class WHSoundEngine : public SoundEngine class WHSoundEngine : public SoundEngine
{ {
// client specific parts of the sound engine go in this class. // 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; 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; TArray<uint8_t> ReadSound(int lumpnum) override;
public: public:
WHSoundEngine() WHSoundEngine()
{ {
S_Rolloff.RolloffType = ROLLOFF_Doom; S_Rolloff.RolloffType = ROLLOFF_Doom;
S_Rolloff.MinDistance = 170; // these are the numbers I got when uncrunching the original sound code. S_Rolloff.MinDistance = 93;
S_Rolloff.MaxDistance = 850; 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);
}
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) 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) TArray<uint8_t> WHSoundEngine::ReadSound(int lumpnum)
{ {
auto wlump = fileSystem.OpenFileReader(lumpnum); auto wlump = fileSystem.OpenFileReader(lumpnum);
return wlump.Read(); 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)
if (pos != nullptr && type != SOURCE_None) {
{ vec3_t ppos = { player[pyrn].x, player[pyrn].y, player[pyrn].z };
FVector3 camera; FVector3 camera = GetSoundPos(&ppos);
if (gMe && gMe->pSprite) camera = GetSoundPos(&gMe->pSprite->pos);
else camera = { 0, 0, 0 }; // don't crash if there is no player.
if (vel) vel->Zero(); if (vel) vel->Zero();
if (type == SOURCE_Unattached) if (type == SOURCE_Unattached)
{ {
pos->X = pt[0]; pos->X = pt[0];
pos->Y = pt[1]; pos->Y = pt[1];
pos->Z = pt[2]; pos->Z = pt[2];
} }
else if (type == SOURCE_Actor) else if (type == SOURCE_Actor)
{ {
auto actor = (spritetype*)source; auto actor = (spritetype*)source;
assert(actor != nullptr); assert(actor != nullptr);
size_t index = actor - sprite; size_t index = actor - sprite;
// Engine expects velocity in units per second, not units per tic. if (vel) *vel = { 0, 0, 0 }; // this game has no velocity management usable here.
if (vel) *vel = { xvel[index] * (30 / 65536.f), zvel[index] * (-30 / 65536.f), yvel[index] * (-30 / 65536.f) }; *pos = GetSoundPos(&actor->pos);
*pos = GetSoundPos(&actor->pos); }
} else if (type == SOURCE_Ambient)
else if (type == SOURCE_Ambient) {
{ *pos = camera; // just to be safe. Ambient sounds are in the world but unpositioned
*pos = camera; // just to be safe. Ambient sounds are in the world but unpositioned }
} if ((chanflags & CHANF_LISTENERZ))
if ((chanflags & CHANF_LISTENERZ)) {
{ pos->Y = camera.Y;
pos->Y = camera.Y; }
} }
}
#endif
} }
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 END_WH_NS

View file

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

View file

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

View file

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

View file

@ -24,6 +24,7 @@ END_WH_NS
#include "gamecontrol.h" #include "gamecontrol.h"
#include "d_net.h" #include "d_net.h"
#include "screenjob.h" #include "screenjob.h"
#include "raze_sound.h"
BEGIN_WH_NS BEGIN_WH_NS
@ -294,7 +295,6 @@ extern boolean droptheshield;
extern int dahand; extern int dahand;
extern int weapondrop; extern int weapondrop;
extern int snakex, snakey; extern int snakex, snakey;
extern int enchantedsoundhandle;
boolean checkmedusadist(int i, int x, int y, int z, int lvl); boolean checkmedusadist(int i, int x, int y, int z, int lvl);
void autoweaponchange(PLAYER& plr, int dagun); void autoweaponchange(PLAYER& plr, int dagun);
@ -420,7 +420,29 @@ inline int BClampAngle(int a)
// placeholders // 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 startredflash(int)
{} {}
inline void startwhiteflash(int) inline void startwhiteflash(int)
@ -430,24 +452,21 @@ inline void startgreenflash(int)
inline void startblueflash(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) { inline int SND_Sound(int sn) {
return 0; return playsound(sn, 0, 0);
} }
inline int playsound_loc(int sn, int x, int y) { inline int spritesound(int sn, spritetype *s, int loop = 0, int channel = CHAN_AUTO) {
return 0; 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 startmusic(int);
void startsong(int); void startsong(int);
void setupmidi(); void setupmidi();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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