- spritesound

This commit is contained in:
Christoph Oelckers 2021-11-14 18:18:24 +01:00
parent 48f41a143f
commit e8101ed970
14 changed files with 74 additions and 74 deletions

View file

@ -697,14 +697,14 @@ void attack(PLAYER& plr, int const i) {
auto ang = plr.angle.ang.asbuild();
if ((a < ang && ang - a < 128) || (a > ang && ((ang + a) & 2047) < 128)) {
if (krand() % 100 > 80) {
spritesound(S_SWORD1 + krand() % 3, &pspr);
spritesound(S_SWORD1 + krand() % 3, plr.actor());
return;
}
else {
s = krand() % 50;
plr.shieldpoints -= s;
if (krand() % 100 > 50) {
spritesound(S_SWORD1 + krand() % 3, &pspr);
spritesound(S_SWORD1 + krand() % 3, plr.actor());
return;
}
}
@ -757,8 +757,8 @@ void attack(PLAYER& plr, int const i) {
case KOBOLDTYPE:
spritesound(S_GENSWING, actor);
if ((krand() % 10) > 4) {
spritesound(S_KOBOLDHIT, &pspr);
spritesound(S_BREATH1 + (krand() % 6), &pspr);
spritesound(S_KOBOLDHIT, plr.actor());
spritesound(S_BREATH1 + (krand() % 6), plr.actor());
}
if (isWh2())
k = (krand() % 5) + 5;
@ -803,8 +803,8 @@ void attack(PLAYER& plr, int const i) {
if (spr.picnum == NEWGUYMACE) { // damage 5 - 20
spritesound(S_PLRWEAPON2, actor);
if (krand() % 10 > 4) {
spritesound(S_KOBOLDHIT, &pspr);
spritesound(S_BREATH1 + (krand() % 6), &pspr);
spritesound(S_KOBOLDHIT, plr.actor());
spritesound(S_BREATH1 + (krand() % 6), plr.actor());
}
k = (krand() % 15) + 5;
break;
@ -837,8 +837,8 @@ void attack(PLAYER& plr, int const i) {
else {
spritesound(S_GENSWING, actor);
if (krand() % 10 > 4) {
spritesound(S_SOCK1 + (krand() % 4), &pspr);
spritesound(S_BREATH1 + (krand() % 6), &pspr);
spritesound(S_SOCK1 + (krand() % 4), plr.actor());
spritesound(S_BREATH1 + (krand() % 6), plr.actor());
}
k = (krand() % 4) + 1;
}

View file

@ -247,7 +247,6 @@ static void nukeddevil(PLAYER& plr, DWHActor* actor)
static void castdevil(PLAYER& plr, DWHActor* actor)
{
int i = actor->GetSpriteIndex();
SPRITE& spr = actor->s();
spr.lotag -= TICSPERFRAME;
@ -258,7 +257,7 @@ static void castdevil(PLAYER& plr, DWHActor* actor)
if (spr.picnum == DEVILATTACK + 2) {
spr.picnum = DEVIL;
spritesound(S_FIREBALL, &sprite[i]);
spritesound(S_FIREBALL, actor);
castspell(plr, actor);
SetNewStatus(actor, CHASE);
}

View file

@ -379,13 +379,13 @@ static void castgron(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0) {
if (spr.picnum == GRONHALATTACK) {
spr.extra--;
spritesound(S_THROWPIKE, &sprite[i]);
spritesound(S_THROWPIKE, actor);
throwhalberd(i);
SetNewStatus(actor, CHASE);
}
else if (spr.picnum == GRONMUATTACK) {
spr.extra--;
spritesound(S_SPELL2, &sprite[i]);
spritesound(S_SPELL2, actor);
castspell(plr, actor);
SetNewStatus(actor, CHASE);
}

View file

@ -347,14 +347,14 @@ static void castnewguy(PLAYER& plr, DWHActor* actor)
if (spr.picnum == NEWGUYCAST + 2) {
spr.extra--;
spr.picnum = NEWGUY;
spritesound(S_WISP, &sprite[i]);
spritesound(S_WISP, actor);
skullycastspell(plr, i);
SetNewStatus(actor, CHASE);
}
if (spr.picnum == NEWGUYBOW + 2) {
spr.extra--;
spr.picnum = NEWGUY;
spritesound(S_PLRWEAPON3, &sprite[i]);
spritesound(S_PLRWEAPON3, actor);
newguyarrow(i, plr);
SetNewStatus(actor, CHASE);
}

View file

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

View file

@ -404,15 +404,15 @@ void processinput(int num) {
if (!onground && plr.onsomething != 0) {
if (plr.fallz > 32768) {
if ((krand() % 2) != 0)
spritesound(S_PLRPAIN1 + (krand() % 2), &sprite[plr.spritenum]);
spritesound(S_PLRPAIN1 + (krand() % 2), plr.actor());
else
spritesound(S_PUSH1 + (krand() % 2), &sprite[plr.spritenum]);
spritesound(S_PUSH1 + (krand() % 2), plr.actor());
addhealth(plr, -(plr.fallz >> 13));
plr.fallz = 0;// wango
}
else if (plr.fallz > 8192) {
spritesound(S_BREATH1 + (krand() % 2), &sprite[plr.spritenum]);
spritesound(S_BREATH1 + (krand() % 2), plr.actor());
}
}
@ -527,7 +527,7 @@ void processinput(int num) {
break;
case SPIDER:
// STOMP
spritesound(S_DEADSTEP, &sprite[onsprite]);
spritesound(S_DEADSTEP, &whActors[onsprite]);
justplayed = 1;
newstatus(onsprite, DIE);
break;
@ -543,7 +543,7 @@ void processinput(int num) {
case 1952:
case 1941:
case 1940:
spritesound(S_DEADSTEP, &sprite[plr.spritenum]);
spritesound(S_DEADSTEP, plr.actor());
justplayed = 1;
break;
@ -554,7 +554,7 @@ void processinput(int num) {
if (sprite[onsprite].picnum == RAT)
{
spritesound(S_RATS1 + (krand() % 2), &sprite[onsprite]);
spritesound(S_RATS1 + (krand() % 2), &whActors[onsprite]);
justplayed = 1;
deletesprite(onsprite);
}

View file

@ -1054,7 +1054,7 @@ void InitItems()
{
if (plr.manatime < 1 && plr.invincibletime <= 0 && !plr.godMode) {
spritesound(S_FIREBALL, &actor->s());
spritesound(S_FIREBALL, actor);
addhealth(plr, -1);
startredflash(30);
}

View file

@ -51,7 +51,7 @@ void castaorb(PLAYER& plr) {
switch (plr.currentorb) {
case 0: // SCARE
if (isWh2())
spritesound(S_GENERALMAGIC4, &sprite[plr.spritenum]);
spritesound(S_GENERALMAGIC4, plr.actor());
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())
spritesound(S_GENERALMAGIC3, &sprite[plr.spritenum]);
spritesound(S_GENERALMAGIC3, plr.actor());
else
spritesound(S_SPELL1, &sprite[plr.spritenum]);
spritesound(S_SPELL1, plr.actor());
daang = plr.angle.ang.asbuild();
shootgun(plr, daang, 6);
break;
case 3: // MAGIC ARROW
if (isWh2()) {
lockon(plr,10,2);
spritesound(S_GENERALMAGIC2, &sprite[plr.spritenum]);
spritesound(S_GENERALMAGIC2, plr.actor());
}
else {
daang = (float)BClampAngle(plr.angle.ang.asbuild() - 36);
@ -76,42 +76,42 @@ void castaorb(PLAYER& plr) {
daang = (float)BClampAngle(int(daang) + (k << 1));
shootgun(plr, daang, 2);
}
spritesound(S_SPELL1, &sprite[plr.spritenum]);
spritesound(S_SPELL1, plr.actor());
}
break;
case 4: // OPEN DOORS
daang = plr.angle.ang.asbuild();
shootgun(plr, daang, 7);
if (isWh2())
spritesound(S_DOORSPELL, &sprite[plr.spritenum]);
spritesound(S_DOORSPELL, plr.actor());
else
spritesound(S_SPELL1, &sprite[plr.spritenum]);
spritesound(S_SPELL1, plr.actor());
break;
case 5: // FLY
plr.orbactive[plr.currentorb] = 3600 + (plr.lvl * 120);
if (isWh2())
spritesound(S_GENERALMAGIC1, &sprite[plr.spritenum]);
spritesound(S_GENERALMAGIC1, plr.actor());
else
spritesound(S_SPELL1, &sprite[plr.spritenum]);
spritesound(S_SPELL1, plr.actor());
break;
case 6: // FIREBALL
if (isWh2()) {
lockon(plr,3,3);
spritesound(S_FIRESPELL, &sprite[plr.spritenum]);
spritesound(S_FIRESPELL, plr.actor());
}
else {
daang = plr.angle.ang.asbuild();
shootgun(plr, daang, 3);
spritesound(S_SPELL1, &sprite[plr.spritenum]);
spritesound(S_SPELL1, plr.actor());
}
break;
case 7: // NUKE
daang = plr.angle.ang.asbuild();
shootgun(plr, daang, 4);
if (isWh2())
spritesound(S_NUKESPELL, &sprite[plr.spritenum]);
spritesound(S_NUKESPELL, plr.actor());
else
spritesound(S_SPELL1, &sprite[plr.spritenum]);
spritesound(S_SPELL1, plr.actor());
break;
}
}

View file

@ -1289,7 +1289,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (hitspr.picnum == SKELETON
|| hitspr.picnum == SKELETONATTACK
|| hitspr.picnum == SKELETONDIE)
spritesound(S_SKELHIT1 + (krand() % 2), &hitspr);
spritesound(S_SKELHIT1 + (krand() % 2), hitActor);
}
// HERE
@ -1495,7 +1495,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (hitspr.picnum == SKELETON
|| hitspr.picnum == SKELETONATTACK
|| hitspr.picnum == SKELETONDIE)
spritesound(S_SKELHIT1 + (krand() % 2), &hitspr);
spritesound(S_SKELHIT1 + (krand() % 2), hitActor);
}
// HERE
switch (plr.currweapon) {
@ -1615,7 +1615,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (hitspr.picnum == SKELETON
|| hitspr.picnum == SKELETONATTACK
|| hitspr.picnum == SKELETONDIE)
spritesound(S_SKELHIT1 + (krand() % 2), &hitspr);
spritesound(S_SKELHIT1 + (krand() % 2), hitActor);
}
newstatus(pHitInfo.hitsprite, DIE);
}
@ -1706,7 +1706,8 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (ntag.tagsector < 0) {
j = insertsprite(pHitInfo.hitsect, (short) 0);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
spawned.x = pHitInfo.hitx;
spawned.y = pHitInfo.hity;
spawned.z = pHitInfo.hitz + (8 << 8);
@ -1724,7 +1725,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spawned.lotag = 32;
spawned.hitag = 0;
spawned.backuploc();
spritesound(S_ARROWHIT, &spawned);
spritesound(S_ARROWHIT, spawnedactor);
if (isWh2() && plr.weapon[6] == 3 && plr.currweapon == 6) {
auto spawnedactor = &whActors[j];
@ -2347,7 +2348,7 @@ void swingdaweapon(PLAYER& plr) {
// || plr.currweaponframe == PIKEATTACK2+4
&& plr.weapon[7] == 2 && plr.ammo[7] > 0) {
shootgun(plr, daang, 10);
spritesound(S_THROWPIKE, &sprite[plr.spritenum]);
spritesound(S_THROWPIKE, plr.actor());
plr.hasshot = 1;
return;
}
@ -2372,12 +2373,12 @@ void swingdaweapon(PLAYER& plr) {
if (plr.currweaponframe == PIKEATTACK1 + 4 && plr.weapon[7] == 2 && plr.ammo[7] > 0) {
shootgun(plr, daang, 10);
spritesound(S_GENTHROW, &sprite[plr.spritenum]);
spritesound(S_GENTHROW, plr.actor());
plr.hasshot = 1;
return;
} else if (plr.currweaponframe == ZPIKEATTACK + 4 && plr.weapon[7] == 3 && plr.ammo[7] > 0) {
lockon(plr, 3, 10);
spritesound(S_GENTHROW, &sprite[plr.spritenum]);
spritesound(S_GENTHROW, plr.actor());
plr.hasshot = 1;
return;
}
@ -2444,44 +2445,44 @@ void swingdacrunch(PLAYER& plr, int daweapon) {
auto& pspr = sprite[player->spritenum];
switch (daweapon) {
case 0: // fist
spritesound(S_SOCK1 + (krand() % 4), &pspr);
spritesound(S_SOCK1 + (krand() % 4), plr.actor());
break;
case 1: // dagger
if ((krand() % 2) != 0)
spritesound(S_GORE1 + (krand() % 4), &pspr);
spritesound(S_GORE1 + (krand() % 4), plr.actor());
break;
case 2: // short sword
spritesound(S_SWORD2 + (krand() % 3), &pspr);
spritesound(S_SWORD2 + (krand() % 3), plr.actor());
break;
case 3: // morningstar
spritesound(S_SOCK1 + (krand() % 4), &pspr);
spritesound(S_SOCK1 + (krand() % 4), plr.actor());
break;
case 4: // broad sword
spritesound(S_SWORD1 + (krand() % 3), &pspr);
spritesound(S_SWORD1 + (krand() % 3), plr.actor());
break;
case 5: // battle axe
if ((krand() % 2) != 0)
spritesound(S_SOCK1 + (krand() % 4), &pspr);
spritesound(S_SOCK1 + (krand() % 4), plr.actor());
else
spritesound(S_SWORD1 + (krand() % 3), &pspr);
spritesound(S_SWORD1 + (krand() % 3), plr.actor());
break;
case 6: // bow
break;
case 7: // pike
if ((krand() % 2) != 0)
spritesound(S_SOCK1 + (krand() % 4), &pspr);
spritesound(S_SOCK1 + (krand() % 4), plr.actor());
else
spritesound(S_SWORD1 + (krand() % 3), &pspr);
spritesound(S_SWORD1 + (krand() % 3), plr.actor());
break;
case 8: // two handed sword
spritesound(S_SWORD1 + (krand() % 2), &pspr);
spritesound(S_SWORD1 + (krand() % 2), plr.actor());
break;
case 9: // halberd
if ((krand() % 2) != 0)
spritesound(S_SOCK1 + (krand() % 4), &pspr);
spritesound(S_SOCK1 + (krand() % 4), plr.actor());
else
spritesound(S_SWORD1 + (krand() % 3), &pspr);
spritesound(S_SWORD1 + (krand() % 3), plr.actor());
break;
}
}

View file

@ -471,9 +471,11 @@ inline int SND_Sound(int sn) {
return playsound(sn, 0, 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 spritesound(int sn, DWHActor* s, int loop = 0, int channel = CHAN_AUTO) {
return playsound_internal(sn, &s->s(), 0, 0, loop, channel);

View file

@ -442,7 +442,7 @@ void teleporter() {
warpfxsprite(plr.spritenum);
plr.angle.settarget(daang);
plr.justwarpedfx = 48;
spritesound(S_WARP, &sprite[plr.spritenum]);
spritesound(S_WARP, plr.actor());
setsprite(plr.spritenum, plr.x, plr.y, plr.z + (32 << 8));
}
}
@ -464,7 +464,7 @@ void teleporter() {
CompleteLevel(currentLevel);
break;
case 2: // ENDOFDEMO
spritesound(S_THUNDER1, &sprite[plr.spritenum]);
spritesound(S_THUNDER1, plr.actor());
justteleported = true;
CompleteLevel(nullptr);
break;
@ -611,7 +611,7 @@ void sectorsounds() {
}
} else {
if (plr.z <= plr.Sector()->floorz - (8 << 8))
spritesound(sec, &sprite[plr.spritenum]);
spritesound(sec, plr.actor());
}
}
}
@ -823,7 +823,7 @@ void makeasplash(int picnum, PLAYER& plr) {
if(!isWh2() && picnum == SLIMESPLASH)
break;
spritesound(S_SPLASH1 + (krand() % 3), &spawned);
spritesound(S_SPLASH1 + (krand() % 3), spawnedactor);
break;
case LAVASPLASH:
break;
@ -839,7 +839,8 @@ void makemonstersplash(int picnum, int i) {
return;
int j = insertsprite(sprite[i].sectnum, MASPLASH);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
spawned.x = sprite[i].x;
spawned.y = sprite[i].y;
spawned.z = sector[sprite[i].sectnum].floorz + (tileHeight(picnum) << 8);
@ -873,14 +874,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)
spritesound(S_SPLASH1 + (krand() % 3), &spawned);
spritesound(S_SPLASH1 + (krand() % 3), spawnedactor);
}
}
if ((krand() % 2) != 0) {
if ((gotpic[SLIME >> 3] & (1 << (SLIME & 7))) > 0) {
gotpic[SLIME >> 3] &= ~(1 << (SLIME & 7));
if ((krand() % 2) != 0)
spritesound(S_SPLASH1 + (krand() % 3), &spawned);
spritesound(S_SPLASH1 + (krand() % 3), spawnedactor);
}
}
break;

View file

@ -482,14 +482,14 @@ void newstatus(short sn, int seq) {
case LIFTUP:
if (soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, -1, CHAN_CART) == 0) {
spritesound(S_CLUNK, actor);
spritesound(S_CHAIN1, &spr, 5, CHAN_CART);
spritesound(S_CHAIN1, actor, 5, CHAN_CART);
}
ChangeActorStat(actor, LIFTUP);
break;
case LIFTDN:
if (soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, -1, CHAN_CART) == 0) {
spritesound(S_CLUNK, actor);
spritesound(S_CHAIN1, &spr, 5, CHAN_CART);
spritesound(S_CHAIN1, actor, 5, CHAN_CART);
}
ChangeActorStat(actor, LIFTDN);
break;
@ -1589,7 +1589,7 @@ boolean damageactor(PLAYER& plr, DWHActor* hitactor, DWHActor* actor)
if (spr.picnum == PLASMA)
addhealth(plr, -((krand() & 15) + 15));
else if (spr.picnum == FATSPANK) {
spritesound(S_GORE1A + (krand() % 3), &sprite[plr.spritenum]);
spritesound(S_GORE1A + (krand() % 3), plr.actor());
addhealth(plr, -((krand() & 10) + 10));
if ((krand() % 100) > 90) {
plr.poisoned = 1;

View file

@ -45,7 +45,7 @@ void playerdead(PLAYER& plr) {
if (plr.spiked == 1) {
plr.spiketics = spikeanimtics[0].daweapontics;
spritesound(S_GORE1, &sprite[plr.spritenum]);
spritesound(S_GORE1, plr.actor());
SND_Sound(S_HEARTBEAT);
}
@ -260,7 +260,7 @@ void plruse(PLAYER& plr) {
showmessage("find door trigger", 360);
}
}
spritesound(S_PUSH1 + (krand() % 2), &sprite[plr.spritenum]);
spritesound(S_PUSH1 + (krand() % 2), plr.actor());
}
}
if (nt.tagsprite >= 0) {
@ -336,10 +336,10 @@ void chunksofmeat(PLAYER& plr, DWHActor* hitActor, int hitx, int hity, int hitz,
if (hitspr.picnum == SKELETON || hitspr.picnum == SKELETONATTACK
|| hitspr.picnum == SKELETONDIE) {
spritesound(S_SKELHIT1 + (krand() % 2), &hitspr);
spritesound(S_SKELHIT1 + (krand() % 2), hitActor);
} else {
if (krand() % 100 > 60)
spritesound(S_GORE1 + (krand() % 4), &hitspr);
spritesound(S_GORE1 + (krand() % 4), hitActor);
}
if (hitActor != nullptr) {

View file

@ -55,7 +55,7 @@ void operatesprite(PLAYER& plr, short s) {
case STAINSCENE:
switch (spr.lotag) {
case 2:
spritesound(S_GLASSBREAK1 + (rand() % 3), &sprite[s]);
spritesound(S_GLASSBREAK1 + (rand() % 3), actor);
for (int j = 0; j < 20; j++) {
shards(s, 2);
}
@ -838,7 +838,6 @@ void operatesector(PLAYER& plr, int s) {
}
if (datag == 4000) {
// sector[s].lotag=0;
WHSpriteIterator it;
while (auto itActor = it.Next())
{
@ -846,14 +845,12 @@ void operatesector(PLAYER& plr, int s) {
if (sector[s].hitag == spk.hitag && spk.extra < 1) {
SetNewStatus(itActor, FLOCKSPAWN);
if (soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, -1, CHAN_BAT) == 0) {
spritesound(S_BATSLOOP, &spk, -1, CHAN_BAT);
// sector[s].lotag = sector[s].hitag = 0;
spritesound(S_BATSLOOP, itActor, -1, CHAN_BAT);
}
}
}
}
if (datag == 4001) {
// sector[s].lotag=0;
WHSpriteIterator it;
while (auto itActor = it.Next())
{