Do not mess up random seed in seq/qav

This commit is contained in:
nukeykt 2019-07-30 01:18:41 +09:00 committed by Christoph Oelckers
parent 935084ae52
commit e999e2058c
2 changed files with 20 additions and 7 deletions

View file

@ -94,7 +94,7 @@ void QAV::Play(int start, int end, int nCallback, void *pData)
SOUNDINFO *pSound = &pFrame->sound; SOUNDINFO *pSound = &pFrame->sound;
// by NoOne: handle Sound kill flags // by NoOne: handle Sound kill flags
if (pSound->sndFlags > 0 && pSound->sndFlags <= kFlagSoundKillAll) { if (!VanillaMode() && pSound->sndFlags > 0 && pSound->sndFlags <= kFlagSoundKillAll) {
for (int i = 0; i < nFrames; i++) { for (int i = 0; i < nFrames; i++) {
FRAMEINFO* pFrame2 = &frames[i]; FRAMEINFO* pFrame2 = &frames[i];
SOUNDINFO* pSound2 = &pFrame2->sound; SOUNDINFO* pSound2 = &pFrame2->sound;
@ -112,9 +112,14 @@ void QAV::Play(int start, int end, int nCallback, void *pData)
} }
if (pSound->sound > 0) { if (pSound->sound > 0) {
int sndRange = pSound->sndRange; int sound = pSound->sound;
if (nSprite == -1) PlaySound(pSound->sound + Random((sndRange == 1) ? 2 : sndRange));
else PlaySound3D(&sprite[nSprite], pSound->sound + Random((sndRange == 1) ? 2 : sndRange), 16+pSound->priority, 6); // by NoOne: add random rage sound feature
if (pSound->sndRange > 0 && !VanillaMode())
sound += Random((pSound->sndRange == 1) ? 2 : pSound->sndRange);
if (nSprite == -1) PlaySound(sound);
else PlaySound3D(&sprite[nSprite], sound, 16+pSound->priority, 6);
} }
if (pFrame->nCallbackId > 0 && nCallback != -1) { if (pFrame->nCallbackId > 0 && nCallback != -1) {

View file

@ -287,11 +287,19 @@ void SEQINST::Update(ACTIVE *pActive)
{ {
UpdateSprite(pActive->xindex, &pSequence->frames[frameIndex]); UpdateSprite(pActive->xindex, &pSequence->frames[frameIndex]);
if (pSequence->frames[frameIndex].at6_1) if (pSequence->frames[frameIndex].at6_1) {
sfxPlay3DSound(&sprite[xsprite[pActive->xindex].reference], pSequence->ata + Random(pSequence->frames[frameIndex].soundRange), -1, 0);
int sound = pSequence->ata;
// by NoOne: add random sound range feature
if (!VanillaMode() && pSequence->frames[frameIndex].soundRange > 0)
sound += Random(((pSequence->frames[frameIndex].soundRange == 1) ? 2 : pSequence->frames[frameIndex].soundRange));
sfxPlay3DSound(&sprite[xsprite[pActive->xindex].reference], sound, -1, 0);
}
spritetype* pSprite = &sprite[xsprite[pActive->xindex].reference]; spritetype* pSprite = &sprite[xsprite[pActive->xindex].reference];
if (pSequence->frames[frameIndex].surfaceSound && zvel[pSprite->xvel] == 0 && xvel[pSprite->xvel] != 0) { if (!VanillaMode() && pSequence->frames[frameIndex].surfaceSound && zvel[pSprite->xvel] == 0 && xvel[pSprite->xvel] != 0) {
// by NoOne: add surfaceSound trigger feature // by NoOne: add surfaceSound trigger feature
if (gUpperLink[pSprite->sectnum] >= 0) break; // don't play surface sound for stacked sectors if (gUpperLink[pSprite->sectnum] >= 0) break; // don't play surface sound for stacked sectors