From c403df08611c857f43ebf708799974f06b4e8a8a Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 27 Sep 2020 02:03:36 +0300 Subject: [PATCH] processEngineDamage --- src/audio/AudioLogic.cpp | 33 +++++++++++++++++---------------- src/audio/AudioManager.h | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 60989aba..b174a924 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2265,34 +2265,36 @@ cAudioManager::HasAirBrakes(int32 model) const || model == COACH || model == PACKER || model == FLATBED; } -bool +void cAudioManager::ProcessEngineDamage(cVehicleParams *params) { const int engineDamageIntensity = 40; - CAutomobile *veh; - uint8 engineStatus; + float health; uint8 emittingVolume; if (params->m_fDistance >= SQR(engineDamageIntensity)) - return false; - veh = (CAutomobile *)params->m_pVehicle; - if (veh->bEngineOn) { - engineStatus = veh->Damage.GetEngineStatus(); - if (engineStatus > 250 || engineStatus < 100) - return true; - if (engineStatus < 225) { - m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - emittingVolume = 6; - m_sQueueSample.m_nReleasingVolumeModificator = 7; - m_sQueueSample.m_nFrequency = 40000; - } else { + return; + if (params->m_pVehicle->m_modelIndex == MI_CADDY) + return; + if (params->m_pVehicle->GetStatus() == STATUS_WRECKED) + return; + health = params->m_pVehicle->m_fHealth; + if (health < 390.0f) { + if (health < 250.0f) { emittingVolume = 60; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; m_sQueueSample.m_nReleasingVolumeModificator = 7; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); + } else { + emittingVolume = 30; + m_sQueueSample.m_nSampleIndex = SFX_PALM_TREE_LO; + m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nFrequency = 27000; } CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + if (params->m_pVehicle->bIsDrowning) + emittingVolume /= 2; m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 28; @@ -2311,7 +2313,6 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) AddSampleToRequestedQueue(); } } - return true; } bool diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 0cd86219..c3462291 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -323,7 +323,7 @@ public: bool ProcessCarBombTick(cVehicleParams *params); void ProcessCesna(cVehicleParams *params); //void ProcessCrane(); - bool ProcessEngineDamage(cVehicleParams *params); + void ProcessEngineDamage(cVehicleParams *params); //done void ProcessEntity(int32 sound); //done void ProcessExplosions(int32 explosion); void ProcessFireHydrant();