Make ped comments update position and volume

This commit is contained in:
Sergeanur 2021-08-23 11:15:03 +03:00
parent 6110f74ad6
commit ceb65eafa5
4 changed files with 109 additions and 75 deletions

View File

@ -6077,9 +6077,12 @@ cPedComments::Process()
if (m_nCommentsInBank[m_nActiveBank]) {
sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex;
if (!SampleManager.IsPedCommentLoaded(sampleIndex))
switch (SampleManager.IsPedCommentLoaded(sampleIndex)) // yes, this was a switch
{
case FALSE:
SampleManager.LoadPedComment(sampleIndex);
// BUG? no break, VC has break in here
case TRUE:
AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex;
AudioManager.m_sQueueSample.m_nCounter = 0;
AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex;
@ -6099,7 +6102,13 @@ cPedComments::Process()
AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME;
#endif // FIX_BUGS
#endif // EXTERNAL_3D_SOUND
#ifdef ATTACH_PED_COMMENTS_TO_ENTITIES
// let's disable doppler because if sounds funny as the sound moves
// originally position of ped comment doesn't change so this has no effect anyway
AudioManager.m_sQueueSample.m_fSpeedMultiplier = 0.0f;
#else
AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f;
#endif
switch (sampleIndex) {
case SFX_POLICE_HELI_1:
case SFX_POLICE_HELI_2:
@ -6147,13 +6156,15 @@ cPedComments::Process()
AudioManager.m_sQueueSample.m_bReflections = FALSE;
#endif
#ifdef FIX_BUGS
} else if (sampleIndex >= SFX_POLICE_HELI_1 && sampleIndex <= SFX_POLICE_HELI_29) {
}
else if (sampleIndex >= SFX_POLICE_HELI_1 && sampleIndex <= SFX_POLICE_HELI_29) {
AudioManager.m_sQueueSample.m_bReverb = TRUE;
#ifdef AUDIO_REFLECTIONS
AudioManager.m_sQueueSample.m_bReflections = FALSE;
#endif // AUDIO_REFLECTIONS
#endif // FIX_BUGS
} else {
}
else {
AudioManager.m_sQueueSample.m_bReverb = TRUE;
#ifdef AUDIO_REFLECTIONS
AudioManager.m_sQueueSample.m_bReflections = TRUE;
@ -6167,6 +6178,9 @@ cPedComments::Process()
AudioManager.m_sQueueSample.m_nFrequency /= 2;
m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
AudioManager.AddSampleToRequestedQueue();
default:
break;
}
}
// Switch bank

View File

@ -10,6 +10,7 @@
#include "sampman.h"
#include "Camera.h"
#include "World.h"
#include "Entity.h"
cAudioManager AudioManager;
@ -903,6 +904,24 @@ cAudioManager::ProcessActiveQueues()
SampleManager.SetChannelVolume(j, sample.m_nVolume);
#endif
} else {
#ifdef ATTACH_PED_COMMENTS_TO_ENTITIES
if (sample.m_nCounter <= 255 && sample.m_nSampleIndex >= SAMPLEBANK_PED_START && sample.m_nSampleIndex <= SAMPLEBANK_PED_END) {
CEntity* entity = (CEntity*)GetEntityPointer(sample.m_nEntityIndex);
if (entity && m_asAudioEntities[sample.m_nEntityIndex].m_nType == AUDIOTYPE_PHYSICAL) {
sample.m_vecPos = entity->GetPosition();
sample.m_fDistance = Sqrt(GetDistanceSquared(sample.m_vecPos));
uint8 vol;
if (CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), sample.m_vecPos, true, false, false, false, false, false))
vol = MAX_VOLUME;
else
vol = 31;
#ifdef EXTERNAL_3D_SOUND
sample.m_nEmittingVolume = vol;
#endif
sample.m_nVolume = ComputeVolume(vol, sample.m_MaxDistance, sample.m_fDistance);
}
}
#endif
position2 = sample.m_fDistance;
position1 = m_asActiveSamples[j].m_fDistance;
m_asActiveSamples[j].m_fDistance = sample.m_fDistance;

View File

@ -23,7 +23,7 @@ VALIDATE_SIZE(cAMCrime, 20);
class cPoliceRadioQueue
{
public:
int32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES];
uint32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES];
uint8 m_nSamplesInQueue;
uint8 m_nAddOffset;
uint8 m_nRemoveOffset;

View File

@ -438,6 +438,7 @@ enum Config {
//#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder
#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files
#define PAUSE_RADIO_IN_FRONTEND // pause radio when game is paused
#define ATTACH_PED_COMMENTS_TO_ENTITIES // ped comments coordinates would update following ped entity
#define MULTITHREADED_AUDIO // for streams. requires C++11 or later
#ifdef AUDIO_OPUS