diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/audio/AudioLogic.cpp | 1249 | ||||
-rw-r--r-- | src/audio/AudioManager.cpp | 4 | ||||
-rw-r--r-- | src/audio/AudioManager.h | 137 | ||||
-rw-r--r-- | src/audio/soundlist.h | 2 | ||||
-rw-r--r-- | src/control/Script.h | 1 | ||||
-rw-r--r-- | src/vehicles/Automobile.cpp | 2 |
6 files changed, 881 insertions, 514 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index e9c594cc..1fdba82a 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,62 @@ CVehicle *cAudioManager::FindVehicleOfPlayer() } void +cAudioManager::ProcessPlayerMood() +{ + CPlayerPed* playerPed; + uint32* lastMisstonPassedTime; + uint32 curTime = CTimer::GetTimeInMilliseconds(); + + if (m_nPlayerMoodTimer <= curTime) { + playerPed = FindPlayerPed(); + if (playerPed != nil) { + + if (playerPed->m_pWanted->m_nWantedLevel > 3) { + m_nPlayerMood = PLAYER_MOOD_ANGRY; + return; + } + if (playerPed->m_pWanted->m_nWantedLevel > 1) { + m_nPlayerMood = PLAYER_MOOD_PISSED_OFF; + return; + } + + lastMisstonPassedTime = CTheScripts::GetLastMissionPassedTime(); + if (*lastMisstonPassedTime != -1) { + if (curTime < *lastMisstonPassedTime) { + *lastMisstonPassedTime = curTime; + return; + } + if (curTime < *lastMisstonPassedTime + 180000) { + m_nPlayerMood = PLAYER_MOOD_WISECRACKING; + return; + } + } + m_nPlayerMood = PLAYER_MOOD_CALM; + } + } +} + +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,10 +782,10 @@ 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); + ProcessModelHeliVehicle(¶ms); ProcessEngineDamage(¶ms); } else { switch (veh->GetVehicleAppearance()) { @@ -840,37 +863,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 +958,196 @@ 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; - 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 uint32 prevFreq = 14000; + static uint8 prevVolume = 0; + + uint32 freq; + int16 acceletateState; + int16 brakeState; + uint8 volume; + bool isPlayerVeh; + 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; + } + } + } } +void +cAudioManager::ProcessModelHeliVehicle(cVehicleParams* params) +{ + const float SOUND_INTENSITY = 35.0f; + + static uint32 prevFreq = 22050; + + uint32 freq; + bool isPlayerVeh; + int16 acceletateState; + int16 brakeState; + 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 (isPlayerVeh) { + brakeState = Pads[0].GetBrake(); + acceletateState = Max(Pads[0].GetAccelerate(), Abs(Pads[0].GetCarGunUpDown()) * 2); + } else { + acceletateState = 255.0f * params->m_pVehicle->m_fGasPedal; + brakeState = 255.0f * params->m_pVehicle->m_fBrakePedal; + } + if (acceletateState < brakeState) + acceletateState = brakeState; + freq = clamp2(5 * acceletateState + 22050, prevFreq, 30); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(70, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 2; + m_sQueueSample.m_nSampleIndex = SFX_CAR_RC_HELI; + 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 = 70; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_CAR_RC_HELI); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_CAR_RC_HELI); + 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 (isPlayerVeh) + prevFreq = freq; +} bool -cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) +cAudioManager::ProcessVehicleRoadNoise(cVehicleParams* params) { const float SOUND_INTENSITY = 95.0f; @@ -996,51 +1156,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 +1223,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; } @@ -1868,6 +2051,13 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) const float SOUND_INTENSITY = 40.0f; CAutomobile *automobile; + CBike *bike; + uint8 numWheels; + uint8 wheelsOnGround; + float gasPedalAudio; + tWheelState* wheelStateArr; + + cTransmission *transmission; int32 emittingVol; float newSkidVal = 0.0f; @@ -1875,29 +2065,48 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return false; - automobile = (CAutomobile *)params->m_pVehicle; - if (automobile->m_nWheelsOnGround == 0) + switch (params->m_VehicleType) { + case VEHICLE_TYPE_CAR: + automobile = (CAutomobile*)params->m_pVehicle; + numWheels = 4; + wheelStateArr = automobile->m_aWheelState; + wheelsOnGround = automobile->m_nWheelsOnGround; + gasPedalAudio = automobile->m_fGasPedalAudio; + break; + case VEHICLE_TYPE_BIKE: + bike = (CBike*)params->m_pVehicle; + numWheels = 2; + wheelStateArr = bike->m_aWheelState; + wheelsOnGround = bike->m_nWheelsOnGround; + gasPedalAudio = bike->m_fGasPedalAudio; + break; + default: + debug("\n * AUDIOLOG: ProcessVehicleSkidding() Unsupported vehicle type %d * \n", params->m_VehicleType); + return true; + } + if (wheelsOnGround == 0) return true; CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { - if (automobile->m_aWheelState[i] == WHEEL_STATE_NORMAL || automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING) + + for (int32 i = 0; i < numWheels; i++) { + if (wheelStateArr[i] == WHEEL_STATE_NORMAL) continue; transmission = params->m_pTransmission; switch (transmission->nDriveType) { case '4': - newSkidVal = GetVehicleDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange); + newSkidVal = GetVehicleDriveWheelSkidValue(params->m_pVehicle, wheelStateArr[i], gasPedalAudio, transmission, params->m_fVelocityChange); break; case 'F': if (i == CARWHEEL_FRONT_LEFT || i == CARWHEEL_FRONT_RIGHT) - newSkidVal = GetVehicleDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange); + newSkidVal = GetVehicleDriveWheelSkidValue(params->m_pVehicle, wheelStateArr[i], gasPedalAudio, transmission, params->m_fVelocityChange); else - newSkidVal = GetVehicleNonDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange); + newSkidVal = GetVehicleNonDriveWheelSkidValue(params->m_pVehicle, wheelStateArr[i], transmission, params->m_fVelocityChange); break; case 'R': if (i == CARWHEEL_REAR_LEFT || i == CARWHEEL_REAR_RIGHT) - newSkidVal = GetVehicleDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange); + newSkidVal = GetVehicleDriveWheelSkidValue(params->m_pVehicle, wheelStateArr[i], gasPedalAudio, transmission, params->m_fVelocityChange); else - newSkidVal = GetVehicleNonDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange); + newSkidVal = GetVehicleNonDriveWheelSkidValue(params->m_pVehicle, wheelStateArr[i], transmission, params->m_fVelocityChange); break; default: break; @@ -1924,6 +2133,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) case SURFACE_MUD_DRY: case SURFACE_SAND: case SURFACE_WATER: + case SURFACE_SAND_BEACH: m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID; m_sQueueSample.m_nFrequency = 6000.f * skidVal + 10000.f; break; @@ -1931,6 +2141,8 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) default: m_sQueueSample.m_nSampleIndex = SFX_SKID; m_sQueueSample.m_nFrequency = 5000.f * skidVal + 11000.f; + if (params->m_VehicleType == VEHICLE_TYPE_BIKE) + m_sQueueSample.m_nFrequency += 2000; break; } @@ -1954,18 +2166,17 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) } float -cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange) +cAudioManager::GetVehicleDriveWheelSkidValue(CVehicle* veh, tWheelState wheelState, float gasPedalAudio, cTransmission *transmission, float velocityChange) { float relativeVelChange = 0.0f; - float gasPedalAudio = automobile->m_fGasPedalAudio; float velChange; float relativeVel; - switch (automobile->m_aWheelState[wheel]) + switch (wheelState) { case WHEEL_STATE_SPINNING: if (gasPedalAudio > 0.4f) - relativeVelChange = (gasPedalAudio - 0.4f) * (5.0f / 3.0f) / (4.0f / 3.0f); + relativeVelChange = (gasPedalAudio - 0.4f) * (5.0f / 3.0f) * 0.75f; break; case WHEEL_STATE_SKIDDING: relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity); @@ -1986,154 +2197,161 @@ cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobil break; } - return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f)); + return Max(relativeVelChange, Min(1.0f, Abs(veh->m_vecTurnSpeed.z) * 20.0f)); } float -cAudioManager::GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange) +cAudioManager::GetVehicleNonDriveWheelSkidValue(CVehicle* veh, tWheelState wheelState, cTransmission *transmission, float velocityChange) { float relativeVelChange = 0.0f; - if (automobile->m_aWheelState[wheel] == WHEEL_STATE_SKIDDING) + if (wheelState == WHEEL_STATE_SKIDDING) relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity); - return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f)); + return Max(relativeVelChange, Min(1.0f, Abs(veh->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 +2366,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 +2383,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 +2453,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 +2468,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 +2479,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; @@ -2384,11 +2609,17 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) float relVol; float vol; bool noReflections; + bool isHeli; float maxDist; cPedParams pedParams; + static uint8 GunIndex = 53; + pedParams.m_pPed = nil; + pedParams.m_bDistanceCalculated = false; + pedParams.m_fDistance = 0.0f; for (int i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { - noReflections = 0; + noReflections = false; + isHeli = false; m_sQueueSample.m_bRequireReflection = false; event = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]; switch (event) { @@ -2405,20 +2636,22 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case OLD_DOOR: m_sQueueSample.m_nSampleIndex = SFX_OLD_CAR_DOOR_CLOSE; break; - case NEW_DOOR: - default: - m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_CLOSE; - break; case TRUCK_DOOR: m_sQueueSample.m_nSampleIndex = SFX_TRUCK_DOOR_CLOSE; break; case BUS_DOOR: m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; break; + default: + m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_CLOSE; + break; } m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 22; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nCounter = event + 22; + if (params->m_pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI) + m_sQueueSample.m_nFrequency = 28062; + else + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -2439,20 +2672,22 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case OLD_DOOR: m_sQueueSample.m_nSampleIndex = SFX_OLD_CAR_DOOR_OPEN; break; - case NEW_DOOR: - default: - m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_OPEN; - break; case TRUCK_DOOR: m_sQueueSample.m_nSampleIndex = SFX_TRUCK_DOOR_OPEN; break; case BUS_DOOR: m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; break; + default: + m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_OPEN; + break; } m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 10; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nCounter = event + 10; + if (params->m_pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI) + m_sQueueSample.m_nFrequency = 23459; + else + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -2461,40 +2696,64 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) break; } case SOUND_CAR_WINDSHIELD_CRACK: { - const float SOUND_INTENSITY = 30.0f; + const float SOUND_INTENSITY = 40.0f; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 68; - emittingVol = m_anRandomTable[1] % 30 + 60; + emittingVol = m_anRandomTable[1] % 30 + 80; //GetRandomNumberInRange(1, 80, 109) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK); m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; } break; - case SOUND_CAR_JUMP: { + case SOUND_CAR_JUMP: + case SOUND_CAR_JUMP_2: { const float SOUND_INTENSITY = 35.0f; static uint8 WheelIndex = 82; - emittingVol = Max(80.f, 2 * (100.f * m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i])); maxDist = SQR(SOUND_INTENSITY); - m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP; + if (event == SOUND_CAR_JUMP_2) { + m_sQueueSample.m_nSampleIndex = SFX_TYRE_BURST_B; + emittingVol = Max(50.0f, 2 * (60.0f * m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i])); + } else { + m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP; + emittingVol = Max(80.f, 2 * (100.0f * m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i])); + } m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = WheelIndex++; if (WheelIndex > 85) WheelIndex = 82; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TYRE_BUMP); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - if (params->m_nIndex == RCBANDIT) { + if (params->m_VehicleType == VEHICLE_TYPE_BIKE) m_sQueueSample.m_nFrequency *= 2; - emittingVol /= 2; - } m_sQueueSample.m_nReleasingVolumeModificator = 6; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; break; } + case SOUND_CAR_TYRE_POP: { + const float SOUND_INTENSITY = 60.0f; + static uint8 WheelIndex = 91; + m_sQueueSample.m_nSampleIndex = SFX_TYRE_BURST; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = WheelIndex++; + if (WheelIndex > 94) + WheelIndex = 91; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TYRE_BURST); + m_sQueueSample.m_nFrequency += RandomDisplacement(2000); + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_fSpeedMultiplier = 0.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + maxDist = SQR(SOUND_INTENSITY); + emittingVol = m_anRandomTable[4] % 10 + 117; + break; + } case SOUND_CAR_ENGINE_START: { const float SOUND_INTENSITY = 40.0f; + if (params->m_pVehicle->GetVehicleAppearance() != VEHICLE_APPEARANCE_CAR + || params->m_pVehicle->m_modelIndex == MI_CADDY) + continue; emittingVol = 60; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_STARTER; @@ -2569,24 +2828,24 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) break; } case SOUND_CAR_SPLASH: { - const float SOUND_INTENSITY = 40.0f; + const float SOUND_INTENSITY = 60.0f; static uint8 WaveIndex = 41; vol = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]; - if (vol <= 300.f) + if (vol <= 150.0f) continue; - if (vol > 1200.f) - m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] = 1200.0f; - relVol = (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] - 300.f) / 900.f; + if (vol > 800.0f) + m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] = 800.0f; + relVol = (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] - 150.0f) / 650.0f; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[0] & 1) + SFX_BOAT_SPLASH_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = WaveIndex++; if (WaveIndex > 46) WaveIndex = 41; - m_sQueueSample.m_nFrequency = (7000.f * relVol) + 6000; + m_sQueueSample.m_nFrequency = (7000.0f * relVol) + 6000; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - emittingVol = (55.f * relVol); + emittingVol = (35.0f * relVol); maxDist = SQR(SOUND_INTENSITY); break; } @@ -2603,6 +2862,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) maxDist = SQR(SOUND_INTENSITY); break; }*/ +#ifdef GTA_TRAIN case SOUND_TRAIN_DOOR_CLOSE: case SOUND_TRAIN_DOOR_OPEN: { const float SOUND_INTENSITY = 35.0f; @@ -2617,20 +2877,21 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = m_anRandomTable[1] % 20 + 70; break; } +#endif case SOUND_CAR_TANK_TURRET_ROTATE: { const float SOUND_INTENSITY = 40.0f; vol = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]; - if (vol > 96.0f / 2500.0f) - vol = 96.0f / 2500.0f; + if (vol > 24.0f / 625.0f) + vol = 24.0f / 625.0f; m_sQueueSample.m_nSampleIndex = SFX_TANK_TURRET; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 79; - m_sQueueSample.m_nFrequency = (3000.f * vol * 2500.0f / 96.0f) + 9000; + m_sQueueSample.m_nFrequency = (3000.0f * vol * 625.0f / 24.0f) + 9000; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - emittingVol = (37.f * vol * 2500.0f / 96.0f) + 90; + emittingVol = (37.0f * vol * 625.0f / 24.0f) + 90; maxDist = SQR(SOUND_INTENSITY); noReflections = true; break; @@ -2662,9 +2923,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = m_anRandomTable[4] % 25 + 75; break; } - case SOUND_31:{ + case SOUND_HELI_BLADE:{ const float SOUND_INTENSITY = 35.0f; - static uint8 HeliIndex = 0; + static uint8 HeliIndex = 89; relVol = ((CAutomobile*)params->m_pVehicle)->m_aWheelSpeed[1] * 50.0f / 11.0f; if (relVol < 0.2f || relVol == 1.0f) continue; @@ -2672,8 +2933,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_ROT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = HeliIndex + 89; - HeliIndex = HeliIndex != 1 ? HeliIndex + 1 : 0; //maybe better use 1 and 0, to avoid extreme values + m_sQueueSample.m_nCounter = HeliIndex++; + if (HeliIndex > 90) + HeliIndex = 89; m_sQueueSample.m_nFrequency = (8000.0f * relVol) + 16000; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -2683,20 +2945,68 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } case SOUND_WEAPON_SHOT_FIRED: { const float SOUND_INTENSITY = 120.0f; - static uint8 GunIndex = 53; - emittingVol = m_anRandomTable[2]; - maxDist = SQR(SOUND_INTENSITY); - m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = GunIndex++; - emittingVol = emittingVol % 15 + 65; - if (GunIndex > 58) - GunIndex = 53; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT); - m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + CVehicle* playerVeh; + CPlayerPed* playerPed; + + switch (params->m_pVehicle->m_modelIndex) { + case MI_HUNTER: + case MI_CHOPPER: + case MI_SEASPAR: + case MI_SPARROW: + case MI_MAVERICK: + case MI_VCNMAV: + if (params->m_pVehicle->m_modelIndex == MI_HUNTER) { + if (Pads[0].GetHandBrake() == 0) { + playerVeh = FindPlayerVehicle(); + playerPed = FindPlayerPed(); + if (playerVeh == 0 && playerPed != 0) { + if (playerPed->m_attachedTo != nil && playerPed->m_attachedTo->GetType() == ENTITY_TYPE_VEHICLE) + playerVeh = (CVehicle*)playerPed->m_attachedTo; + } + if (playerVeh != params->m_pVehicle) { + m_sQueueSample.m_nSampleIndex = SFX_M60_LEFT; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + } else { + m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + } + } else { + m_sQueueSample.m_nSampleIndex = SFX_M60_LEFT; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + } + } else { + m_sQueueSample.m_nSampleIndex = SFX_M60_LEFT; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + } + maxDist = SQR(SOUND_INTENSITY); + m_sQueueSample.m_nCounter = GunIndex++; + emittingVol = MAX_VOLUME; + if (GunIndex > 58) + GunIndex = 53; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_M60_LEFT); + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_fSpeedMultiplier = 0.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bRequireReflection = true; + isHeli = true; + break; + default: + maxDist = SQR(SOUND_INTENSITY); + m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = GunIndex++; + emittingVol = m_anRandomTable[2] % 15 + 65; + if (GunIndex > 58) + GunIndex = 53; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT); + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_fSpeedMultiplier = 0.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bRequireReflection = true; + break; + } break; } case SOUND_WEAPON_HIT_VEHICLE: { @@ -2730,14 +3040,12 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) maxDist = SQR(SOUND_INTENSITY); break; } - case SOUND_PED_HELI_PLAYER_FOUND: - pedParams.m_pPed = nil; - pedParams.m_bDistanceCalculated = false; - pedParams.m_fDistance = 0.0f; + case SOUND_PED_HELI_PLAYER_FOUND: { pedParams.m_bDistanceCalculated = params->m_bDistanceCalculated; pedParams.m_fDistance = params->m_fDistance; SetupPedComments(&pedParams, SOUND_PED_HELI_PLAYER_FOUND); continue; + } /* case SOUND_PED_BODYCAST_HIT: pedParams.m_pPed = nil; pedParams.m_bDistanceCalculated = false; @@ -2746,8 +3054,17 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) pedParams.m_fDistance = params->m_fDistance; SetupPedComments(&pedParams, SOUND_PED_BODYCAST_HIT); continue; */ + case SOUND_115: { + pedParams.m_bDistanceCalculated = params->m_bDistanceCalculated; + pedParams.m_fDistance = params->m_fDistance; + SetupPedComments(&pedParams, SOUND_115); + } case SOUND_WATER_FALL: { const float SOUND_INTENSITY = 40.0f; + static uint32 WaterFallFrame = 0; + if (m_FrameCounter <= WaterFallFrame) + continue; + WaterFallFrame = m_FrameCounter + 6; m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 15; @@ -2766,10 +3083,10 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = CrunchOffset + SFX_PED_CRUNCH_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 48; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PED_CRUNCH_1) + RandomDisplacement(600); + m_sQueueSample.m_nFrequency = RandomDisplacement(6000) + 16000; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_fSoundIntensity = 40.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; ++CrunchOffset; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[4] % 20 + 55; @@ -2780,14 +3097,15 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_PED_COLLISION: { const float SOUND_INTENSITY = 40.0f; vol = Min(20.0f, m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]); - emittingVol = (vol / 20.0f * 127.f); - if (!emittingVol) + emittingVol = Min(127, (3 * (vol / 20.0f * 127.f)) / 2); + if (emittingVol == 0) continue; - m_sQueueSample.m_nSampleIndex = (m_anRandomTable[2] & 3) + SFX_FIGHT_1; + m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 50; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) / 2; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; @@ -2812,12 +3130,41 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bReverbFlag = true; + if (isHeli) { + if (0.2f * m_sQueueSample.m_fSoundIntensity > m_sQueueSample.m_fDistance) { + m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_nOffset = 0; + AddSampleToRequestedQueue(); + m_sQueueSample.m_nOffset = 127; + m_sQueueSample.m_nSampleIndex++; + m_sQueueSample.m_nCounter = GunIndex++; + if (GunIndex > 58) + GunIndex = 53; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + continue; + } + isHeli = false; + } m_sQueueSample.m_bIs2D = false; AddSampleToRequestedQueue(); +/* looks like this code ca't be reached(originaly it exist bcs used goto) + if (isHeli) { + m_sQueueSample.m_nOffset = 127; + m_sQueueSample.m_nSampleIndex++; + m_sQueueSample.m_nCounter = GunIndex++; + if (GunIndex > 58) + GunIndex = 53; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + }*/ + continue; + } } } } + #ifdef GTA_TRAIN bool cAudioManager::ProcessTrainNoise(cVehicleParams *params) @@ -3502,38 +3849,34 @@ DoJumboVolOffset() } void -cAudioManager::ProcessJumbo(cVehicleParams *params) +cAudioManager::ProcessJumbo(cVehicleParams* params) { - CPlane *plane; + CPlane* plane; float position; - if (params->m_fDistance < SQR(440)) { - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - plane = (CPlane *)params->m_pVehicle; - DoJumboVolOffset(); - position = PlanePathPosition[plane->m_nPlaneId]; - if (position <= TakeOffPoint) { - if (plane->m_fSpeed <= 0.103344f) { - ProcessJumboTaxi(); - return; - } + if (params->m_fDistance >= SQR(440)) + return; + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + plane = (CPlane*)params->m_pVehicle; + DoJumboVolOffset(); + position = PlanePathPosition[plane->m_nPlaneId]; + if (position <= TakeOffPoint) { + if (plane->m_fSpeed > 0.103344f) { ProcessJumboAccel(plane); - } else if (300.0f + TakeOffPoint >= position) { - ProcessJumboTakeOff(plane); - } else if (LandingPoint - 350.0f >= position) { - ProcessJumboFlying(); } else { - if (position > LandingPoint) { - if (plane->m_fSpeed > 0.103344f) { - ProcessJumboDecel(plane); - return; - } - ProcessJumboTaxi(); - return; - } - ProcessJumboLanding(plane); + ProcessJumboTaxi(); } + } else if (position <= TakeOffPoint + 300.0f) { + ProcessJumboTakeOff(plane); + } else if (position <= LandingPoint - 350.0f) { + ProcessJumboFlying(); + } else if (position <= LandingPoint) { + ProcessJumboLanding(plane); + } else if (plane->m_fSpeed > 0.103344f) { + ProcessJumboDecel(plane); + } else { + ProcessJumboTaxi(); } } @@ -3551,25 +3894,23 @@ cAudioManager::ProcessJumboAccel(CPlane *plane) { int32 engineFreq; int32 vol; - float whineSoundFreq; float modificator; + float freqModifier; if (SetupJumboFlySound(20)) { - modificator = (plane->m_fSpeed - 0.103344f) * 1.6760077f; - if (modificator > 1.0f) - modificator = 1.0f; + modificator = Min(1.0f, (plane->m_fSpeed - 0.103344f) * 1.6760077f); if (SetupJumboRumbleSound(MAX_VOLUME * modificator) && SetupJumboTaxiSound((1.0f - modificator) * 75.f)) { if (modificator < 0.2f) { - whineSoundFreq = modificator * 5.f * 14600.0f + 29500; - vol = modificator * 5.f * MAX_VOLUME; - engineFreq = modificator * 5.f * 6050.f + 16000; + freqModifier = modificator * 5.0f; + vol = MAX_VOLUME * freqModifier; + engineFreq = 6050.0f * freqModifier + 16000; } else { - whineSoundFreq = 44100; + freqModifier = 1.0f; engineFreq = 22050; vol = MAX_VOLUME; } SetupJumboEngineSound(vol, engineFreq); - SetupJumboWhineSound(18, whineSoundFreq); + SetupJumboWhineSound(18, 14600.0f * freqModifier + 29500); } } } @@ -3801,7 +4142,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); @@ -4868,7 +5209,7 @@ cAudioManager::ProcessFires(int32) if (entity) { switch (entity->GetType()) { case ENTITY_TYPE_BUILDING: - m_sQueueSample.m_fSoundIntensity = 50.0f; + m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; emittingVol = 100; m_sQueueSample.m_nFrequency = 8 * SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE) / 10; @@ -4884,7 +5225,7 @@ cAudioManager::ProcessFires(int32) m_sQueueSample.m_nReleasingVolumeModificator = 10; break; default: - m_sQueueSample.m_fSoundIntensity = 50.0f; + m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64); @@ -4892,17 +5233,17 @@ cAudioManager::ProcessFires(int32) m_sQueueSample.m_nReleasingVolumeModificator = 8; } } else { - m_sQueueSample.m_fSoundIntensity = 50.0f; + m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); - m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64); + //mb error in III emittingVol = 80; m_sQueueSample.m_nReleasingVolumeModificator = 8; } m_sQueueSample.m_vecPos = gFireManager.m_aFires[i].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; @@ -4920,6 +5261,30 @@ cAudioManager::ProcessFires(int32) AddSampleToRequestedQueue(); } } + if (gFireManager.m_aFires[i].m_bExtinguishedWithWater) { + gFireManager.m_aFires[i].m_bExtinguishedWithWater = false; + emittingVol = 100.0f * gFireManager.m_aFires[i].m_fWaterExtinguishCountdown; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; + m_sQueueSample.m_nFrequency = 19591; + m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64); + m_sQueueSample.m_nReleasingVolumeModificator = 9; + m_sQueueSample.m_nCounter = i + 40; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_fSpeedMultiplier = 2.0f; + m_sQueueSample.m_nReleasingVolumeDivider = 10; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; + 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_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } } } } @@ -4934,18 +5299,10 @@ 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; -#else - m_sQueueSample.m_fSoundIntensity = SQR(SOUND_INTENSITY); -#endif m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = 15591; @@ -5818,39 +6175,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; @@ -5996,32 +6359,32 @@ cAudioManager::ProcessGarages() void cAudioManager::ProcessFireHydrant() { - const int SOUND_INTENSITY = 35; + const float SOUND_INTENSITY = 35; float distSquared; + bool distCalculated = 0; m_sQueueSample.m_vecPos = ((CEntity *)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)->GetPosition(); distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(SOUND_INTENSITY)) { - m_sQueueSample.m_fDistance = distSquared <= 0.0f ? 0.0f : Sqrt(distSquared); + CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_nVolume = ComputeVolume(40, 35.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 4; m_sQueueSample.m_nFrequency = 15591; - m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nEmittingVolume = 40; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 2.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; + m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_fSpeedMultiplier = 2.0f; AddSampleToRequestedQueue(); } } diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 4b7039c6..516cc8af 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -275,6 +275,7 @@ cAudioManager::ResetTimers(uint32 time) SampleManager.SetEffectsFadeVolume(0); SampleManager.SetMusicFadeVolume(0); MusicManager.ResetMusicAfterReload(); + m_bIsPlayerShutUp = false; #ifdef AUDIO_OAL SampleManager.Service(); #endif @@ -437,6 +438,7 @@ cAudioManager::IsAudioInitialised() const void cAudioManager::ServiceSoundEffects() { + m_FrameCounter++; m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0; if (m_nUserPause && !m_nPreviousUserPause) { for (int32 i = 0; i < allChannels; i++) @@ -622,7 +624,6 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample; } -// --MIAMI: Done void cAudioManager::AddReflectionsToRequestedQueue() { @@ -684,7 +685,6 @@ cAudioManager::AddReflectionsToRequestedQueue() m_sQueueSample.m_fDistance = oldDist; } -// --MIAMI: Done void cAudioManager::UpdateReflections() { diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 665e5b27..97c332a2 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -4,6 +4,7 @@ #include "AudioCollision.h" #include "PoliceRadio.h" #include "VehicleModelInfo.h" +#include "Vehicle.h" class tSound { @@ -95,7 +96,7 @@ public: void Process(); }; -VALIDATE_SIZE(cPedComments, 1164); +VALIDATE_SIZE(cPedComments, 0x490); class CEntity; @@ -228,8 +229,8 @@ public: ~cAudioManager(); // getters - uint32 GetFrameCounter() const { return m_FrameCounter; } - float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } + uint32 GetFrameCounter() const { return m_FrameCounter; } // done + float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } // done int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; } int32 GetRandomNumberInRange(int32 idx, int32 low, int32 high) const { return (m_anRandomTable[idx] % (high - low + 1)) + low; } bool IsMissionAudioSamplePlaying(uint8 slot) const; // { return m_sMissionAudio.m_nPlayStatus == 1; } @@ -246,7 +247,7 @@ public: void CalculateDistance(bool &condition, float dist); // done bool CheckForAnAudioFileOnCD() const; // done void ClearActiveSamples(); // done - void ClearMissionAudio(uint8 slot); // done + void ClearMissionAudio(uint8 slot); // done (inlined in vc) void ClearRequestedQueue(); // done (inlined in vc) uint32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier) const; // done int32 ComputePan(float, CVector *); // done @@ -262,7 +263,7 @@ public: // TODO: miami // end of functions returning talk sfx - void GenerateIntegerRandomNumberTable(); + void GenerateIntegerRandomNumberTable(); // done char *Get3DProviderName(uint8 id) const; uint8 GetCDAudioDriveLetter() const; int8 GetCurrent3DProviderIndex() const; @@ -277,107 +278,109 @@ public: uint8 GetNum3DProvidersAvailable() const; // done int32 GetPedCommentSfx(CPed *ped, int32 sound); void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; - float GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); - float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); + float GetVehicleDriveWheelSkidValue(CVehicle *veh, tWheelState wheelState, float gasPedalAudio, cTransmission *transmission, float velocityChange); // done + float GetVehicleNonDriveWheelSkidValue(CVehicle *veh, tWheelState wheelState, cTransmission *transmission, float velocityChange); // done bool HasAirBrakes(int32 model) const; // done void Initialise(); // done - void InitialisePoliceRadio(); - void InitialisePoliceRadioZones(); + void InitialisePoliceRadio(); //done + void InitialisePoliceRadioZones(); //done void InterrogateAudioEntities(); // done - bool IsAudioInitialised() const; - bool IsMissionAudioSampleFinished(uint8 slot); + bool IsAudioInitialised() const; // done + bool IsMissionAudioSampleFinished(uint8 slot); // done bool IsMP3RadioChannelAvailable() const; // done - bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; + bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; //done void PlayLoadedMissionAudio(uint8 slot); // done void PlayOneShot(int32 index, int16 sound, float vol); // done - void PlaySuspectLastSeen(float x, float y, float z); // + void PlaySuspectLastSeen(float x, float y, float z); // done void PlayerJustGotInCar() const; // done void PlayerJustLeftCar() const; // done - void PostInitialiseGameSpecificSetup(); // + void PostInitialiseGameSpecificSetup(); // done void PostTerminateGameSpecificShutdown(); // done void PreInitialiseGameSpecificSetup() const; // done void PreloadMissionAudio(uint8 slot, Const char *name); // done void PreTerminateGameSpecificShutdown(); // done /// processX - main logic of adding new sounds - void ProcessActiveQueues(); //done - bool ProcessAirBrakes(cVehicleParams *params); - bool ProcessBoatEngine(cVehicleParams *params); - bool ProcessBoatMovingOverWater(cVehicleParams *params); + void ProcessActiveQueues(); // done + bool ProcessAirBrakes(cVehicleParams *params); // done + bool ProcessBoatEngine(cVehicleParams *params); + bool ProcessBoatMovingOverWater(cVehicleParams *params); #ifdef GTA_BRIDGE - void ProcessBridge(); - void ProcessBridgeMotor(); - void ProcessBridgeOneShots(); - void ProcessBridgeWarning(); + void ProcessBridge(); // done(bcs not exists in VC) + void ProcessBridgeMotor(); // done(bcs not exists in VC) + void ProcessBridgeOneShots(); // done(bcs not exists in VC) + void ProcessBridgeWarning(); // done(bcs not exists in VC) #endif bool ProcessCarBombTick(cVehicleParams *params); // done void ProcessCesna(cVehicleParams *params); // - //void ProcessCrane(); // + //void ProcessCrane(); // done(bcs not exists in VC) bool ProcessEngineDamage(cVehicleParams *params); // done void ProcessEntity(int32 sound); // done void ProcessExplosions(int32 explosion); // done void ProcessFireHydrant(); // done - void ProcessFires(int32 entity); // + void ProcessFires(int32 entity); // done void ProcessFrontEnd(); // done void ProcessGarages(); // void ProcessCarHeli(cVehicleParams* params); // done void ProcessVehicleFlatTyre(cVehicleParams* params); // done - void ProcessJumbo(cVehicleParams *); // - void ProcessJumboAccel(CPlane *plane); // - void ProcessJumboDecel(CPlane *plane); // - void ProcessJumboFlying(); // - void ProcessJumboLanding(CPlane *plane); // - void ProcessJumboTakeOff(CPlane *plane); // - void ProcessJumboTaxi(); // + void ProcessJumbo(cVehicleParams *); // done + void ProcessJumboAccel(CPlane *plane); // done + void ProcessJumboDecel(CPlane *plane); // done + void ProcessJumboFlying(); // done + void ProcessJumboLanding(CPlane *plane); // done + void ProcessJumboTakeOff(CPlane *plane); // done + void ProcessJumboTaxi(); // done void ProcessLoopingScriptObject(uint8 sound); // void ProcessMissionAudio(); // void ProcessMissionAudioSlot(uint8 slot); // - void ProcessModelCarEngine(cVehicleParams *params); // + void ProcessModelHeliVehicle(cVehicleParams* params); // done + void ProcessModelVehicle(cVehicleParams *params); // done void ProcessOneShotScriptObject(uint8 sound); // - void ProcessPed(CPhysical *ped); // + void ProcessPed(CPhysical *ped); // done void ProcessPedOneShots(cPedParams *params); // void ProcessPhysical(int32 id); // done void ProcessPlane(cVehicleParams *params); // done + void ProcessPlayerMood(); // done void ProcessPlayersVehicleEngine(cVehicleParams *params, CVehicle* veh); // done - void ProcessProjectiles(); // - void ProcessRainOnVehicle(cVehicleParams *params); // - void ProcessReverb() const; // + void ProcessProjectiles(); // done + void ProcessRainOnVehicle(cVehicleParams *params); // done + void ProcessReverb() const; // done bool ProcessReverseGear(cVehicleParams *params); // done void ProcessScriptObject(int32 id); // done - void ProcessSpecial(); + void ProcessSpecial(); // done #ifdef GTA_TRAIN - bool ProcessTrainNoise(cVehicleParams *params); + bool ProcessTrainNoise(cVehicleParams *params); //done(bcs not exists in VC) #endif - void ProcessVehicle(CVehicle *vehicle); //done, but need add model functions - bool ProcessVehicleDoors(cVehicleParams *params); //done - void ProcessVehicleEngine(cVehicleParams *params); //done - void UpdateGasPedalAudio(CVehicle* veh, int vehType); //done - void ProcessVehicleHorn(cVehicleParams *params); - void ProcessVehicleOneShots(cVehicleParams *params); - bool ProcessVehicleReverseWarning(cVehicleParams *params); - bool ProcessVehicleRoadNoise(cVehicleParams *params); - bool ProcessVehicleSirenOrAlarm(cVehicleParams *params); - bool ProcessVehicleSkidding(cVehicleParams *params); - void ProcessWaterCannon(int32); - void ProcessWeather(int32 id); //done - bool ProcessWetRoadNoise(cVehicleParams *params); - void ProcessEscalators(); //done - void ProcessExtraSounds(); //done - - int32 RandomDisplacement(uint32 seed) const; + void ProcessVehicle(CVehicle *vehicle); // done + bool ProcessVehicleDoors(cVehicleParams *params); // done + void ProcessVehicleEngine(cVehicleParams *params); // done + void UpdateGasPedalAudio(CVehicle* veh, int vehType); // done + bool ProcessVehicleHorn(cVehicleParams *params); // done + void ProcessVehicleOneShots(cVehicleParams *params); // done + bool ProcessVehicleReverseWarning(cVehicleParams *params); // done + bool ProcessVehicleRoadNoise(cVehicleParams *params); // done + bool ProcessVehicleSirenOrAlarm(cVehicleParams *params); // done + bool ProcessVehicleSkidding(cVehicleParams *params); // done + void ProcessWaterCannon(int32); // done + void ProcessWeather(int32 id); // done + bool ProcessWetRoadNoise(cVehicleParams *params); // done + void ProcessEscalators(); // done + void ProcessExtraSounds(); // done + + int32 RandomDisplacement(uint32 seed) const; // done void ReacquireDigitalHandle() const; // done void ReleaseDigitalHandle() const; // done void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower, float intensity2); // done - void ReportCrime(eCrimeType crime, const CVector &pos); // done - void ResetAudioLogicTimers(uint32 timer); - void ResetPoliceRadio(); - void ResetTimers(uint32 time); + void ReportCrime(eCrimeType crime, const CVector &pos); // done + void ResetAudioLogicTimers(uint32 timer); // done + void ResetPoliceRadio(); // done + void ResetTimers(uint32 time); // done - void Service(); - void ServiceCollisions(); + void Service(); //done + void ServiceCollisions(); //done void ServicePoliceRadio(); void ServicePoliceRadioChannel(uint8 wantedLevel); void ServiceSoundEffects(); @@ -405,13 +408,13 @@ public: void SetupPedComments(cPedParams *params, uint32 sound); void SetupSuspectLastSeenReport(); - void Terminate(); - void TranslateEntity(Const CVector *v1, CVector *v2) const; + void Terminate(); //done + void TranslateEntity(Const CVector *v1, CVector *v2) const; //done - void UpdateReflections(); - bool UsesReverseWarning(int32 model) const; //done - bool UsesSiren(int32 model) const; - bool UsesSirenSwitching(int32 model) const; + void UpdateReflections(); //done + bool UsesReverseWarning(int32 model) const; //done + bool UsesSiren(cVehicleParams *params) const; //done + bool UsesSirenSwitching(cVehicleParams* params) const; //done CVehicle *FindVehicleOfPlayer(); //done void SetPedTalkingStatus(CPed *ped, uint8 status); diff --git a/src/audio/soundlist.h b/src/audio/soundlist.h index f4a1d0a6..a4235d2b 100644 --- a/src/audio/soundlist.h +++ b/src/audio/soundlist.h @@ -33,7 +33,7 @@ enum eSound : uint16 SOUND_CAR_TANK_TURRET_ROTATE, SOUND_CAR_BOMB_TICK, SOUND_PLANE_ON_GROUND, - SOUND_31, + SOUND_HELI_BLADE, SOUND_32, SOUND_STEP_START, SOUND_STEP_END, diff --git a/src/control/Script.h b/src/control/Script.h index c63025b2..8949fe05 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -381,6 +381,7 @@ private: public: static void RemoveThisPed(CPed* pPed); + static uint32* GetLastMissionPassedTime() { return &LastMissionPassedTime; } #ifdef MISSION_SWITCHER static void SwitchToMission(int32 mission); #endif diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index d1a7505e..ddfc1441 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -1494,7 +1494,7 @@ CAutomobile::ProcessControl(void) blade = Multiply3x3(blade, GetMatrix()); camDist /= Max(Sqrt(distSq), 0.01f); if(Abs(DotProduct(camDist, blade)) > 0.95f){ - DMAudio.PlayOneShot(m_audioEntityId, SOUND_31, 0.0f); + DMAudio.PlayOneShot(m_audioEntityId, SOUND_HELI_BLADE, 0.0f); m_fPropellerRotation = m_aWheelRotation[1]; } } |