- playGenDudeSound.

This commit is contained in:
Christoph Oelckers 2021-05-05 19:15:25 +02:00
parent ea63229251
commit 75258c8b29
4 changed files with 39 additions and 30 deletions

View file

@ -2997,7 +2997,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
pSprite->flags &= ~kPhysMove;
actor->xvel() = actor->yvel() = 0;
playGenDudeSound(pSprite, kGenDudeSndTransforming);
playGenDudeSound(actor, kGenDudeSndTransforming);
int seqId = pXSprite->data2 + kGenDudeSeqTransform;
if (getSequence(seqId)) seqSpawn(seqId, actor, -1);
else
@ -3194,7 +3194,7 @@ static int checkDamageType(DBloodActor* actor, DAMAGE_TYPE damageType)
case kDudeModernCustom:
case kDudeModernCustomBurning:
{
playGenDudeSound(pSprite, kGenDudeSndDeathExplode);
playGenDudeSound(actor, kGenDudeSndDeathExplode);
GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
if (!pExtra->availDeaths[damageType])
{
@ -3339,7 +3339,7 @@ static void modernCustomDudeDeath(DBloodActor* actor, int nSeq, int damageType)
auto pSprite = &actor->s();
auto pXSprite = &actor->x();
playGenDudeSound(pSprite, kGenDudeSndDeathNormal);
playGenDudeSound(actor, kGenDudeSndDeathNormal);
int dudeToGib = (actCheckRespawn(actor)) ? -1 : ((nSeq == 3) ? nDudeToGibClient2 : nDudeToGibClient1);
if (nSeq == 3)
{
@ -3367,7 +3367,7 @@ static void modernCustomDudeBurningDeath(DBloodActor* actor, int nSeq)
{
auto pSprite = &actor->s();
playGenDudeSound(pSprite, kGenDudeSndDeathExplode);
playGenDudeSound(actor, kGenDudeSndDeathExplode);
int dudeToGib = (actCheckRespawn(actor)) ? -1 : nDudeToGibClient1;
if (Chance(0x4000)) spawnGibs(actor, GIBTYPE_27, -0xccccc);

View file

@ -456,7 +456,7 @@ void aiActivateDude(DBloodActor* actor)
}
else
{
if (Chance(0x4000)) playGenDudeSound(pSprite, kGenDudeSndTargetSpot);
if (Chance(0x4000)) playGenDudeSound(actor,kGenDudeSndTargetSpot);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL);
}
@ -1033,7 +1033,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
if (pSprite->type == kDudeModernCustomBurning)
{
if (Chance(0x2000) && actor->dudeExtra.time < PlayClock) {
playGenDudeSound(pSprite, kGenDudeSndBurning);
playGenDudeSound(actor,kGenDudeSndBurning);
actor->dudeExtra.time = PlayClock + 360;
}
@ -1075,7 +1075,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
if (pExtra->canBurn && pExtra->availDeaths[kDamageBurn] > 0) {
aiPlay3DSound(actor, 361, AI_SFX_PRIORITY_0, -1);
playGenDudeSound(pSprite, kGenDudeSndBurning);
playGenDudeSound(actor,kGenDudeSndBurning);
pSprite->type = kDudeModernCustomBurning;
if (pXSprite->data2 == kGenDudeDefaultSeq) // don't inherit palette for burning if using default animation
@ -1105,7 +1105,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
else aiGenDudeNewState(actor, &genDudeDodgeShortD);
if (Chance(0x0200))
playGenDudeSound(pSprite, kGenDudeSndGotHit);
playGenDudeSound(actor,kGenDudeSndGotHit);
}
else if (dudeIsPlayingSeq(actor, 13))
@ -1116,7 +1116,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
}
else if (Chance(0x0200))
{
playGenDudeSound(pSprite, kGenDudeSndGotHit);
playGenDudeSound(actor,kGenDudeSndGotHit);
}
}
return nDamage;
@ -1315,7 +1315,7 @@ void RecoilDude(DBloodActor* actor)
else if (rState == 2) pXSprite->aiState->nextState = &genDudeChaseD;
else pXSprite->aiState->nextState = &genDudeChaseW;
playGenDudeSound(pSprite, kGenDudeSndGotHit);
playGenDudeSound(actor,kGenDudeSndGotHit);
}

View file

@ -217,7 +217,7 @@ void punchCallback(int, DBloodActor* actor)
int dy = SinScale16(pSprite->ang);
int dz = nZOffset1 - nZOffset2;
if (!playGenDudeSound(pSprite, kGenDudeSndAttackMelee))
if (!playGenDudeSound(actor, kGenDudeSndAttackMelee))
sfxPlay3DSound(actor, 530, 1, 0);
actFireVector(actor, 0, 0, dx, dy, dz,kVectorGenDudePunch);
@ -255,7 +255,7 @@ void genDudeAttack1(int, DBloodActor* actor)
}
actFireVector(actor, 0, 0, dx, dy, dz,(VECTOR_TYPE)pExtra->curWeapon);
if (!playGenDudeSound(pSprite, kGenDudeSndAttackNormal))
if (!playGenDudeSound(actor, kGenDudeSndAttackNormal))
sfxPlayVectorSound(pSprite, pExtra->curWeapon);
}
else if (pExtra->weaponType == kGenDudeWeaponSummon)
@ -278,7 +278,7 @@ void genDudeAttack1(int, DBloodActor* actor)
gKillMgr.AddNewKill(1);
pExtra->slave[pExtra->slaveCount++] = pSpawned->index;
if (!playGenDudeSound(pSprite, kGenDudeSndAttackNormal))
if (!playGenDudeSound(actor, kGenDudeSndAttackNormal))
sfxPlay3DSoundCP(actor, 379, 1, 0, 0x10000 - Random3(0x3000));
}
}
@ -291,7 +291,7 @@ void genDudeAttack1(int, DBloodActor* actor)
dx += Random3(dispersion); dy += Random3(dispersion); dz += Random3(dispersion >> 1);
actFireMissile(actor, 0, 0, dx, dy, dz, pExtra->curWeapon);
if (!playGenDudeSound(pSprite, kGenDudeSndAttackNormal))
if (!playGenDudeSound(actor, kGenDudeSndAttackNormal))
sfxPlayMissileSound(pSprite, pExtra->curWeapon);
}
}
@ -330,7 +330,7 @@ static void ThrowThing(DBloodActor* actor, bool impact)
const THINGINFO* pThinkInfo = &thingInfo[curWeapon - kThingBase];
if (!gThingInfoExtra[curWeapon - kThingBase].allowThrow) return;
else if (!playGenDudeSound(pSprite, kGenDudeSndAttackThrow))
else if (!playGenDudeSound(actor, kGenDudeSndAttackThrow))
sfxPlay3DSound(actor, 455, -1, 0);
int zThrow = 14500;
@ -502,7 +502,7 @@ static void unicultThinkChase(DBloodActor* actor)
PLAYER* pPlayer = NULL;
if ((!IsPlayerSprite(pTarget)) || ((pPlayer = getPlayerById(pTarget->type)) != NULL && pPlayer->fraggerId == pSprite->index))
{
playGenDudeSound(pSprite, kGenDudeSndTargetDead);
playGenDudeSound(actor, kGenDudeSndTargetDead);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchShortW);
else aiGenDudeNewState(actor, &genDudeSearchShortL);
}
@ -565,7 +565,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (dist < pDudeInfo->seeDist && abs(losAngle) <= pDudeInfo->periphery) {
if ((PlayClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(pSprite, false))
playGenDudeSound(pSprite, kGenDudeSndChasing);
playGenDudeSound(actor, kGenDudeSndChasing);
actor->dudeSlope = DivScale(pTarget->z - pSprite->z, dist, 10);
@ -636,7 +636,7 @@ static void unicultThinkChase(DBloodActor* actor)
return;
case kModernThingThrowableRock:
if (Chance(0x4000)) aiGenDudeNewState(actor, &genDudeThrow2);
else playGenDudeSound(pSprite, kGenDudeSndTargetSpot);
else playGenDudeSound(actor, kGenDudeSndTargetSpot);
return;
default:
aiGenDudeNewState(actor, &genDudeThrow2);
@ -1324,12 +1324,14 @@ void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState)
//
//---------------------------------------------------------------------------
bool playGenDudeSound(spritetype* pSprite, int mode) {
bool playGenDudeSound(DBloodActor* actor, int mode)
{
auto const pSprite = &actor->s();
auto const pXSprite = &actor->x();
if (mode < kGenDudeSndTargetSpot || mode >= kGenDudeSndMax) return false;
auto actor = &bloodActors[pSprite->index];
const GENDUDESND* sndInfo = &gCustomDudeSnd[mode]; bool gotSnd = false;
short sndStartId = xsprite[pSprite->extra].sysData1; int rand = sndInfo->randomRange;
short sndStartId = pXSprite->sysData1;
int rand = sndInfo->randomRange;
int sndId = (sndStartId <= 0) ? sndInfo->defaultSndId : sndStartId + sndInfo->sndIdOffset;
GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
@ -1357,8 +1359,8 @@ bool playGenDudeSound(spritetype* pSprite, int mode) {
if (sndId < 0) return false;
else if (sndStartId <= 0) { sndId += Random(rand); gotSnd = true; }
else {
else
{
// Let's try to get random snd
int maxRetries = 5;
while (maxRetries-- > 0) {
@ -1370,9 +1372,11 @@ bool playGenDudeSound(spritetype* pSprite, int mode) {
}
// If no success in getting random snd, get first existing one
if (gotSnd == false) {
if (gotSnd == false)
{
int maxSndId = sndId + rand;
while (sndId++ < maxSndId) {
while (sndId++ < maxSndId)
{
if (!soundEngine->FindSoundByResID(sndId)) continue;
gotSnd = true;
break;
@ -1383,12 +1387,17 @@ bool playGenDudeSound(spritetype* pSprite, int mode) {
if (gotSnd == false) return false;
else if (sndInfo->aiPlaySound) aiPlay3DSound(actor, sndId, AI_SFX_PRIORITY_2, -1);
else sfxPlay3DSound(pSprite, sndId, -1, 0);
else sfxPlay3DSound(actor, sndId, -1, 0);
pExtra->sndPlaying = true;
return true;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool spriteIsUnderwater(spritetype* pSprite, bool oldWay) {
return ((sector[pSprite->sectnum].extra >= 0 && xsector[sector[pSprite->sectnum].extra].Underwater)

View file

@ -201,7 +201,7 @@ void removeLeech(spritetype* pLeech, bool delSprite = true);
void removeDudeStuff(spritetype* pSprite);
spritetype* leechIsDropped(spritetype* pSprite);
bool spriteIsUnderwater(spritetype* pSprite, bool oldWay = false);
bool playGenDudeSound(spritetype* pSprite, int mode);
bool playGenDudeSound(DBloodActor* actor, int mode);
void aiGenDudeMoveForward(DBloodActor* actor);
void aiGenDudeChooseDirection(DBloodActor* actor, int a3, int aXvel = -1, int aYvel = -1);
void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState);