diff options
Diffstat (limited to 'src/audio/AudioLogic.cpp')
-rw-r--r-- | src/audio/AudioLogic.cpp | 783 |
1 files changed, 467 insertions, 316 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index d4ddbda8..b690882e 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -40,22 +40,13 @@ #include "Bike.h" #include "WindModifiers.h" #include "Fluff.h" +#include "Script.h" const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); const int policeChannel = channels + 1; const int allChannels = channels + 2; -uint32 gPornNextTime; -uint32 gSawMillNextTime; -uint32 gShopNextTime; -uint32 gAirportNextTime; -uint32 gCinemaNextTime; -uint32 gDocksNextTime; -uint32 gHomeNextTime; -uint32 gCellNextTime; -uint32 gNextCryTime; - enum PLAY_STATUS : uint8 { PLAY_STATUS_STOPPED = 0, PLAY_STATUS_PLAYING, PLAY_STATUS_FINISHED }; enum LOADING_STATUS : uint8 { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOADING_STATUS_FAILED }; @@ -187,7 +178,11 @@ cAudioManager::PostInitialiseGameSpecificSetup() field_5538 = 127; ResetAudioLogicTimers(CTimer::GetTimeInMilliseconds()); + m_bIsPlayerShutUp = false; + m_nPlayerMood = 0; + m_nPlayerMoodTimer = 0; } + void cAudioManager::PreTerminateGameSpecificShutdown() { @@ -240,15 +235,6 @@ cAudioManager::PostTerminateGameSpecificShutdown() void cAudioManager::ResetAudioLogicTimers(uint32 timer) { - gPornNextTime = timer; - gNextCryTime = timer; - gSawMillNextTime = timer; - gCellNextTime = timer; - gShopNextTime = timer; - gHomeNextTime = timer; - gAirportNextTime = timer; - gDocksNextTime = timer; - gCinemaNextTime = timer; for (int32 i = 0; i < m_nAudioEntitiesTotal; i++) { if (m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) { CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity; @@ -266,15 +252,14 @@ cAudioManager::ResetAudioLogicTimers(uint32 timer) void cAudioManager::ProcessReverb() const { - if (SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) { - for (uint32 i = 0; i < #ifdef FIX_BUGS - channels + const uint32 numChannels = channels; #else - 28 + const uint32 numChannels = 28; #endif - ; - i++) { + + if (SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) { + for (uint32 i = 0; i < numChannels; i++) { if (m_asActiveSamples[i].m_bReverbFlag) SampleManager.SetChannelReverbFlag(i, 1); } @@ -313,24 +298,66 @@ CVehicle *cAudioManager::FindVehicleOfPlayer() } void +cAudioManager::ProcessPlayerMood() +{ + CPlayerPed* playerPed; + uint32* lastMisstonPassedTime; + uint32 curTime = CTimer::GetTimeInMilliseconds(); + + if (m_nPlayerMoodTimer <= curTime) { + playerPed = FindPlayerPed(); + if (playerPed != nil) { +#ifdef 0 + if (playerPed->m_pWanted->m_nWantedLevel > 3) { + m_nPlayerMood = 2; + return; + } + if (playerPed->m_pWanted->m_nWantedLevel > 1) { + m_nPlayerMood = 1; + return; + } +#endif + if (playerPed->m_pWanted->m_nWantedLevel > 1) { + m_nPlayerMood = (playerPed->m_pWanted->m_nWantedLevel > 3) ? 2 : 1; + return; + } + lastMisstonPassedTime = CTheScripts::GetLastMissionPassedTime(); + if (*lastMisstonPassedTime != -1) { + if (curTime < *lastMisstonPassedTime) { + *lastMisstonPassedTime = curTime; + return; + } + if (curTime < *lastMisstonPassedTime + 180000) { + m_nPlayerMood = 3; + return; + } + } + m_nPlayerMood = 0; + } + } +} + +void cAudioManager::ProcessSpecial() { + CPlayerPed* playerPed; + if (m_nUserPause) { if (!m_nPreviousUserPause) { - MusicManager.ChangeMusicMode(MUSICMODE_FRONTEND); SampleManager.SetEffectsFadeVolume(MAX_VOLUME); SampleManager.SetMusicFadeVolume(MAX_VOLUME); } } else { - if (m_nPreviousUserPause) { - MusicManager.StopFrontEndTrack(); - MusicManager.ChangeMusicMode(MUSICMODE_GAME); - } - CPlayerPed *playerPed = FindPlayerPed(); - if (playerPed) { - const PedState &state = playerPed->m_nPedState; - if (state != PED_ENTER_CAR && state != PED_STEAL_CAR && !playerPed->bInVehicle) - SampleManager.StopChannel(m_nActiveSamples); + if (!CReplay::IsPlayingBack()) + ProcessPlayerMood(); + playerPed = FindPlayerPed(); + if (playerPed != nil) { + if (playerPed->m_audioEntityId >= 0 && m_asAudioEntities[playerPed->m_audioEntityId].m_bIsUsed) { + if (playerPed->m_nPedState != PED_ENTER_CAR && playerPed->m_nPedState != PED_CARJACK) { + if(!playerPed->bInVehicle&& CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle == nil) + SampleManager.StopChannel(m_nActiveSamples); + } + } } } } @@ -759,7 +786,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) automobile = (CAutomobile*)veh; UpdateGasPedalAudio(veh, params.m_VehicleType); if (veh->m_modelIndex == MI_RCBANDIT || veh->m_modelIndex == MI_RCBARON) { - ProcessModelCarEngine(¶ms); + ProcessModelVehicle(¶ms); ProcessEngineDamage(¶ms); } else if (veh->m_modelIndex == MI_RCRAIDER || veh->m_modelIndex == MI_RCGOBLIN) { //ProcessModelHeliVehicle(this, ¶ms); @@ -840,37 +867,42 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) } void -cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) +cAudioManager::ProcessRainOnVehicle(cVehicleParams* params) { - const int rainOnVehicleIntensity = 22; - if (params->m_fDistance < SQR(rainOnVehicleIntensity) && CWeather::Rain > 0.01f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) { - CVehicle *veh = params->m_pVehicle; - ++veh->m_bRainAudioCounter; - if (veh->m_bRainAudioCounter >= 2) { - veh->m_bRainAudioCounter = 0; - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - float emittingVol = 30.f * CWeather::Rain; - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, rainOnVehicleIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = veh->m_bRainSamplesCounter++; - if (veh->m_bRainSamplesCounter > 4) - veh->m_bRainSamplesCounter = 68; - m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 9; - m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 4000 + 28000; - m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nEmittingVolume = (uint8)emittingVol; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_fSoundIntensity = rainOnVehicleIntensity; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bReverbFlag = false; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } + const int SOUND_INTENSITY = 22.0f; + + CVehicle* veh; + uint8 emittingVol; + + if (params->m_fDistance >= SQR(SOUND_INTENSITY) || CWeather::Rain <= 0.01f || CCullZones::CamNoRain() && CCullZones::PlayerNoRain()) + return; + + veh = params->m_pVehicle; + veh->m_bRainAudioCounter++; + if (veh->m_bRainAudioCounter >= 2) { + veh->m_bRainAudioCounter = 0; + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + emittingVol = 30.0f * CWeather::Rain; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = veh->m_bRainSamplesCounter++; + if (veh->m_bRainSamplesCounter > 4) + veh->m_bRainSamplesCounter = 68; + m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 9; + m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 4000 + 28000; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_fSpeedMultiplier = 0.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReverbFlag = false; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); } } } @@ -930,64 +962,137 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) return true; } -// TODO(Miami): this becomes ProcessModelVehicle void -cAudioManager::ProcessModelCarEngine(cVehicleParams *params) +cAudioManager::ProcessModelVehicle(cVehicleParams *params) { -/* const float SOUND_INTENSITY = 30.0f; - CAutomobile *automobile; - float allowedVelocity; - int32 emittingVol; - float velocityChange; + const float SOUND_INTENSITY = 35.0f; + uint8 volume; + uint32 freq; + bool isPlayerVeh; - if (params->m_fDistance < SQR(SOUND_INTENSITY)) { - automobile = (CAutomobile *)params->m_pVehicle; - if (automobile->bEngineOn) { - if (automobile->m_nWheelsOnGround == 0) { - if (automobile->m_nDriveWheelsOnGround != 0) - automobile->m_fGasPedalAudio *= 0.4f; - velocityChange = automobile->m_fGasPedalAudio * params->m_pTransmission->fMaxVelocity; - } else { - velocityChange = Abs(params->m_fVelocityChange); + static uint8 prevVolume = 0; + static uint32 prevFreq = 14000; + int16 acceletateState; + int16 brakeState; + bool vehSlowdown; + + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) + return; + + if (FindPlayerVehicle() == params->m_pVehicle) + isPlayerVeh = true; + else +#ifdef FIX_BUGS + isPlayerVeh = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle == params->m_pVehicle; +#else + isPlayerVeh = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle != nil; +#endif + if (params->m_pVehicle->m_modelIndex == MI_RCBANDIT) { + if (((CAutomobile*)params->m_pVehicle)->m_nDriveWheelsOnGround != 0) { + volume = Min(127, 127.0f * Abs(params->m_fVelocityChange) * 3.0f); + freq = 8000.0f * Abs(params->m_fVelocityChange) + 14000; + } else { + volume = 127; + freq = 25000; + } + if (isPlayerVeh) { + volume = clamp2(volume, prevVolume, 7); + freq = clamp2(freq, prevFreq, 800); + } + if (volume > 0) { + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 2; + m_sQueueSample.m_nSampleIndex = SFX_RC_REV; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nFrequency = freq; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_RC_REV); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_RC_REV); + m_sQueueSample.m_fSpeedMultiplier = 3.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 4; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); } - if (velocityChange > 0.001f) { - allowedVelocity = 0.5f * params->m_pTransmission->fMaxVelocity; - if (velocityChange < allowedVelocity) - emittingVol = (90.f * velocityChange / allowedVelocity); - else - emittingVol = 90; - if (emittingVol) { - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 2; - m_sQueueSample.m_nSampleIndex = SFX_REMOTE_CONTROLLED_CAR; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nFrequency = (11025.f * velocityChange / params->m_pTransmission->fMaxVelocity + 11025.f); - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 3.0f; - m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } + } + if (isPlayerVeh) { + prevFreq = freq; + prevVolume = volume; + } + } else if (params->m_pVehicle != nil) { + if (isPlayerVeh) { + acceletateState = Pads[0].GetAccelerate(); + brakeState = Pads[0].GetBrake(); + } else { + acceletateState = 255.0f * params->m_pVehicle->m_fGasPedal; + brakeState = 255.0f * params->m_pVehicle->m_fBrakePedal; + } + if (acceletateState < brakeState) + acceletateState = brakeState; + if (acceletateState <= 0) { + vehSlowdown = true; + volume = 127; + freq = 18000; + } else { + vehSlowdown = false; + volume = Min(127, (127 * acceletateState / 255) * 3.0f * Abs(params->m_fVelocityChange)); + freq = Min(22000, (8000 * acceletateState / 255 + 14000) * 3.0f * Abs(params->m_fVelocityChange)); + } + if (isPlayerVeh && !vehSlowdown) { + volume = clamp2(volume, prevVolume, 7); + freq = clamp2(freq, prevFreq, 800); + } + if (!vehSlowdown) + freq += 8000.0f * Abs(params->m_pVehicle->GetUp().y); + if (params->m_pVehicle->bIsDrowning) + volume /= 4; + if (volume > 0) { + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + if (vehSlowdown) { + m_sQueueSample.m_nCounter = 0; + m_sQueueSample.m_nSampleIndex = SFX_RC_IDLE; + m_sQueueSample.m_nReleasingVolumeDivider = 6; + } else { + m_sQueueSample.m_nCounter = 2; + m_sQueueSample.m_nSampleIndex = SFX_RC_REV; + m_sQueueSample.m_nReleasingVolumeDivider = 4; } + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nFrequency = freq; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 3.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + if (isPlayerVeh) { + if (vehSlowdown) { + prevFreq = freq; + prevVolume = volume; } } - }*/ + } } - - bool -cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) +cAudioManager::ProcessVehicleRoadNoise(cVehicleParams* params) { const float SOUND_INTENSITY = 95.0f; @@ -996,51 +1101,66 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) float multiplier; int sampleFreq; float velocity; + uint8 wheelsOnGround; if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return false; - if (params->m_pTransmission != nil) { - if (((CAutomobile*)params->m_pVehicle)->m_nDriveWheelsOnGround != 0) { - velocity = Abs(params->m_fVelocityChange); - if (velocity > 0.0f) { - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - emittingVol = 30.f * Min(1.f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - if (params->m_pVehicle->m_nSurfaceTouched == SURFACE_WATER) { - m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; - freq = 6050 * emittingVol / 30 + 16000; - } else { - m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; - multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f; - sampleFreq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); - freq = (sampleFreq * multiplier) + ((3 * sampleFreq) / 4); - } - m_sQueueSample.m_nFrequency = freq; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } + + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) + return false; + switch (params->m_VehicleType) { + case VEHICLE_TYPE_CAR: + wheelsOnGround = ((CAutomobile*)params->m_pVehicle)->m_nWheelsOnGround; + break; + case VEHICLE_TYPE_BIKE: + wheelsOnGround = ((CBike*)params->m_pVehicle)->m_nWheelsOnGround; + break; + default: + wheelsOnGround = 4; + break; + } + if (params->m_pTransmission == nil || wheelsOnGround == 0) + return true; + + velocity = Abs(params->m_fVelocityChange); + if (velocity > 0.0f) { + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + emittingVol = 30.f * Min(1.f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 0; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + if (params->m_pVehicle->m_nSurfaceTouched == SURFACE_WATER) { + m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; + freq = 6050 * emittingVol / 30 + 16000; + } else { + m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; + multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f; + sampleFreq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); + freq = (sampleFreq * multiplier) + ((3 * sampleFreq) / 4); } + m_sQueueSample.m_nFrequency = freq; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 4; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); } } + return true; } bool -cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) +cAudioManager::ProcessWetRoadNoise(cVehicleParams* params) { const float SOUND_INTENSITY = 30.0f; @@ -1048,46 +1168,54 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) int32 emittingVol; float multiplier; int freq; - float velChange; + float velocity; + uint8 wheelsOnGround; if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return false; - if (params->m_pTransmission != nil) { - if (((CAutomobile *)params->m_pVehicle)->m_nDriveWheelsOnGround != 0) { - velChange = Abs(params->m_fVelocityChange); - if (velChange > 0.f) { - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - relativeVelocity = Min(1.0f, velChange / (0.5f * params->m_pTransmission->fMaxVelocity)); - emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 1; - m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; -#ifdef FIX_BUGS - multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f; -#else - multiplier = (m_sQueueSample.m_fDistance / 3.0f) * 0.5f; -#endif - freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); - m_sQueueSample.m_nFrequency = freq + freq * multiplier; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } + switch (params->m_VehicleType) { + case VEHICLE_TYPE_CAR: + wheelsOnGround = ((CAutomobile*)params->m_pVehicle)->m_nWheelsOnGround; + break; + case VEHICLE_TYPE_BIKE: + wheelsOnGround = ((CBike*)params->m_pVehicle)->m_nWheelsOnGround; + break; + default: + wheelsOnGround = 4; + break; + } + if (params->m_pTransmission == nil || wheelsOnGround == 0) + return true; + + velocity = Abs(params->m_fVelocityChange); + if (velocity > 0.0f) { + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + relativeVelocity = Min(1.0f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); + emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 1; + m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f; + freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); + m_sQueueSample.m_nFrequency = freq + freq * multiplier; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 4; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); } } + return true; } @@ -2000,140 +2128,147 @@ cAudioManager::GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automo return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f)); } -void -cAudioManager::ProcessVehicleHorn(cVehicleParams *params) +bool +cAudioManager::ProcessVehicleHorn(cVehicleParams* params) { const float SOUND_INTENSITY = 40.0f; - CAutomobile *automobile; + CVehicle *veh; + uint8 volume; - if (params->m_fDistance < SQR(SOUND_INTENSITY)) { - automobile = (CAutomobile *)params->m_pVehicle; - if ((!automobile->m_bSirenOrAlarm || !UsesSirenSwitching(params->m_nIndex)) && automobile->GetModelIndex() != MI_MRWHOOP) { - if (automobile->m_nCarHornTimer) { - if (params->m_pVehicle->GetStatus() != STATUS_PLAYER) { - automobile->m_nCarHornTimer = Min(44, automobile->m_nCarHornTimer); - if (automobile->m_nCarHornTimer == 44) - automobile->m_nCarHornPattern = (m_FrameCounter + m_sQueueSample.m_nEntityIndex) & 7; - if (!hornPatternsArray[automobile->m_nCarHornPattern][44 - automobile->m_nCarHornTimer]) - return; - } + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) + return false; - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - m_sQueueSample.m_nVolume = ComputeVolume(80, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 4; - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nHornSample; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 2; - m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nHornFrequency; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = 80; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 5.0f; - m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } + veh = params->m_pVehicle; + if (veh->m_bSirenOrAlarm && UsesSirenSwitching(params)) + return true; + + if (veh->m_modelIndex == MI_MRWHOOP) + return true; + + veh->m_nAlarmState; + if (veh->IsAlarmOn()) + return true; + + if (veh->m_nCarHornTimer != 0) { + if (veh->GetStatus() != STATUS_PLAYER) { + veh->m_nCarHornTimer = Min(44, veh->m_nCarHornTimer); + if (veh->m_nCarHornTimer == 44) + veh->m_nCarHornPattern = (m_FrameCounter + m_sQueueSample.m_nEntityIndex) & 7; + + if (!hornPatternsArray[veh->m_nCarHornPattern][44 - veh->m_nCarHornTimer]) + return true; + } + + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + volume = veh->bIsDrowning ? 20 : 80; + m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 4; + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nHornSample; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nHornFrequency; + m_sQueueSample.m_nLoopCount = 0; +#ifdef FIX_BUGS + m_sQueueSample.m_nEmittingVolume = volume; +#else + m_sQueueSample.m_nEmittingVolume = 80; +#endif + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 5.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 4; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); } } + return true; } bool -cAudioManager::UsesSiren(int32 model) const +cAudioManager::UsesSiren(cVehicleParams *params) const { - switch (model) { - case FIRETRUK: - case AMBULAN: - case FBICAR: - case POLICE: - case ENFORCER: - case PREDATOR: - return true; - default: - return false; - } + return params->m_pVehicle->UsesSiren(); } bool -cAudioManager::UsesSirenSwitching(int32 model) const +cAudioManager::UsesSirenSwitching(cVehicleParams *params) const { - switch (model) { - case AMBULAN: - case POLICE: - case ENFORCER: - case PREDATOR: - return true; - default: + if (params->m_nIndex == FIRETRUK || params->m_nIndex == MRWHOOP) return false; - } + return UsesSiren(params); } bool -cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) +cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams* params) { const float SOUND_INTENSITY = 110.0f; - if (params->m_fDistance < SQR(SOUND_INTENSITY)) { - CVehicle *veh = params->m_pVehicle; - if (veh->m_bSirenOrAlarm == false && !veh->IsAlarmOn()) - return true; + CVehicle* veh; + uint8 volume; - if (veh->IsAlarmOn()) { - if (CTimer::GetTimeInMilliseconds() > veh->m_bRainAudioCounter) - veh->m_bRainAudioCounter = CTimer::GetTimeInMilliseconds() + 750; + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) + return false; - if (veh->m_bRainAudioCounter < CTimer::GetTimeInMilliseconds() + 375) - return true; - } + veh = params->m_pVehicle; + if (!veh->m_bSirenOrAlarm && !veh->IsAlarmOn()) + return true; - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - m_sQueueSample.m_nVolume = ComputeVolume(veh->bIsDrowning ? 20 : 80, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 5; - if (UsesSiren(params->m_nIndex)) { - if (params->m_pVehicle->GetStatus() == STATUS_ABANDONED) - return true; - if (veh->m_nCarHornTimer && params->m_nIndex != FIRETRUK) { - m_sQueueSample.m_nSampleIndex = SFX_SIREN_FAST; - if (params->m_nIndex == FBICAR) - m_sQueueSample.m_nFrequency = 16113; - else - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SIREN_FAST); - m_sQueueSample.m_nCounter = 60; - } else { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmSample; - m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmFrequency; - } + if (veh->IsAlarmOn()) { + if (CTimer::GetTimeInMilliseconds() > veh->m_nCarHornTimer) + veh->m_nCarHornTimer = CTimer::GetTimeInMilliseconds() + 750; + + if (veh->m_nCarHornTimer < CTimer::GetTimeInMilliseconds() + 375) + return true; + } + + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + volume = veh->bIsDrowning ? 20 : 80; + m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 5; + if (UsesSiren(params)) { + if (params->m_pVehicle->GetStatus() == STATUS_ABANDONED) + return true; + if (veh->m_nCarHornTimer != 0 && params->m_nIndex != FIRETRUK && params->m_nIndex != MRWHOOP) { + m_sQueueSample.m_nSampleIndex = SFX_SIREN_FAST; + if (params->m_nIndex == FBIRANCH) + m_sQueueSample.m_nFrequency = 12668; + else + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SIREN_FAST); + m_sQueueSample.m_nCounter = 60; + } else if (params->m_nIndex == VICECHEE) { + m_sQueueSample.m_nSampleIndex = SFX_POLICE_SIREN_SLOW; + m_sQueueSample.m_nFrequency = 11440; } else { m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmSample; m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmFrequency; } - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = 80; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 7.0f; - m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - return true; - } else - return true; - } else - return false; + } else { + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nHornSample; + m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nHornFrequency; + } + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 7.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + return true; } bool @@ -2148,13 +2283,15 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) const float SOUND_INTENSITY = 50.0f; CVehicle *veh = params->m_pVehicle; + uint8 volume; if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return false; if (veh->bEngineOn && veh->m_fGasPedal < 0.0f) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - m_sQueueSample.m_nVolume = ComputeVolume(60, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + volume = veh->bIsDrowning ? 15 : 60; + m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING; @@ -2163,7 +2300,11 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING); m_sQueueSample.m_nLoopCount = 0; +#ifdef FIX_BUGS + m_sQueueSample.m_nEmittingVolume = volume; +#else m_sQueueSample.m_nEmittingVolume = 60; +#endif m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; @@ -2229,10 +2370,11 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) bool cAudioManager::ProcessAirBrakes(cVehicleParams *params) { + const float SOUND_INTENSITY = 30.0f; CAutomobile *automobile; - uint8 rand; + uint8 volume; - if (params->m_fDistance > SQR(30)) + if (params->m_fDistance > SQR(SOUND_INTENSITY)) return false; automobile = (CAutomobile *)params->m_pVehicle; if (!automobile->bEngineOn) @@ -2243,8 +2385,8 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) return true; CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - rand = m_anRandomTable[0] % 10 + 70; - m_sQueueSample.m_nVolume = ComputeVolume(rand, 30.0f, m_sQueueSample.m_fDistance); + volume = m_anRandomTable[0] % 10 + 70; + m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 13; m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; @@ -2254,11 +2396,11 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nEmittingVolume = rand; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_fSoundIntensity = 30.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -2818,6 +2960,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } } } + #ifdef GTA_TRAIN bool cAudioManager::ProcessTrainNoise(cVehicleParams *params) @@ -3801,7 +3944,7 @@ cAudioManager::ProcessPed(CPhysical *ped) m_sQueueSample.m_vecPos = ped->GetPosition(); - // params.m_bDistanceCalculated = false; + //params.m_bDistanceCalculated = false; params.m_pPed = (CPed *)ped; params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); ProcessPedOneShots(¶ms); @@ -4934,15 +5077,11 @@ cAudioManager::ProcessWaterCannon(int32) m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur]; float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(SOUND_INTENSITY)) { - m_sQueueSample.m_fDistance = Sqrt(distSquared); -#ifdef FIX_BUGS + m_sQueueSample.m_fDistance = distSquared <= 0.0f ? 0.0f : Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(50, SOUND_INTENSITY, m_sQueueSample.m_fDistance); -#else - m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); #endif if (m_sQueueSample.m_nVolume != 0) { -#ifdef FIX_BUGS - m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; //BUG IN III!!!! #else m_sQueueSample.m_fSoundIntensity = SQR(SOUND_INTENSITY); #endif @@ -5766,39 +5905,45 @@ cAudioManager::ProcessCrane() void cAudioManager::ProcessProjectiles() { - const int rocketLauncherIntensity = 90; - const int molotovIntensity = 30; - const int molotovVolume = 50; uint8 emittingVol; + float distSquared; for (int32 i = 0; i < NUM_PROJECTILES; i++) { if (CProjectileInfo::GetProjectileInfo(i)->m_bInUse) { switch (CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) { - case WEAPONTYPE_ROCKETLAUNCHER: - emittingVol = MAX_VOLUME; - m_sQueueSample.m_fSoundIntensity = rocketLauncherIntensity; - m_sQueueSample.m_nSampleIndex = SFX_ROCKET_FLY; + case WEAPONTYPE_TEARGAS: + emittingVol = 80; + m_sQueueSample.m_fSoundIntensity = 40.0f; + m_sQueueSample.m_nSampleIndex = SFX_PALM_TREE_LO; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_FLY); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nFrequency = 13879; + m_sQueueSample.m_nReleasingVolumeModificator = 7; break; case WEAPONTYPE_MOLOTOV: - emittingVol = molotovVolume; - m_sQueueSample.m_fSoundIntensity = molotovIntensity; + emittingVol = 50; + m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = SFX_PED_ON_FIRE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = 32 * SampleManager.GetSampleBaseFrequency(SFX_PED_ON_FIRE) / 25; m_sQueueSample.m_nReleasingVolumeModificator = 7; break; + case WEAPONTYPE_ROCKET: + emittingVol = 127; + m_sQueueSample.m_fSoundIntensity = 90.0f; + m_sQueueSample.m_nSampleIndex = SFX_ROCKET_FLY; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_FLY); + m_sQueueSample.m_nReleasingVolumeModificator = 3; + break; default: return; } m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_vecPos = CProjectileInfo::ms_apProjectile[i]->GetPosition(); - float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { - m_sQueueSample.m_fDistance = Sqrt(distSquared); + m_sQueueSample.m_fDistance = distSquared <= 0.0f ? 0.0f : Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i; @@ -6757,6 +6902,12 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) } void +cAudioManager::ProcessModelHeliVehicle(cVehicleParams* params) +{ + +} + +void cAudioManager::ProcessMissionAudio() { if (!m_bIsInitialised) return; |