16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 03:09:18 +02:00

passenger stop ai logic tweaks, engine turbo sound volume change rate unification

This commit is contained in:
tmj-fstate
2018-04-23 02:45:36 +02:00
parent c57f0097d3
commit 64ffdbf690
2 changed files with 72 additions and 79 deletions

View File

@@ -6117,40 +6117,31 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
if( Vehicle.TurboTest > 0 ) {
// udawanie turbo:
auto const goalpitch { std::max( 0.025, ( engine_volume + engine_turbo.m_frequencyoffset ) * engine_turbo.m_frequencyfactor ) };
auto const goalvolume { std::max( 0.0, ( engine_turbo_pitch + engine_turbo.m_amplitudeoffset ) * engine_turbo.m_amplitudefactor ) };
auto const goalvolume { (
( ( Vehicle.MainCtrlPos >= Vehicle.TurboTest ) && ( Vehicle.enrot > 0.1 ) ) ?
std::max( 0.0, ( engine_turbo_pitch + engine_turbo.m_amplitudeoffset ) * engine_turbo.m_amplitudefactor ) :
0.0 ) };
auto const currentvolume { engine_turbo.gain() };
auto const changerate { 0.4 * Deltatime };
if( ( Vehicle.MainCtrlPos >= Vehicle.TurboTest )
&& ( Vehicle.enrot > 0.1 ) ) {
engine_turbo_pitch = (
engine_turbo_pitch > goalpitch ?
std::max( goalpitch, engine_turbo_pitch - changerate * 0.5 ) :
std::min( goalpitch, engine_turbo_pitch + changerate ) );
engine_turbo_pitch = (
engine_turbo_pitch > goalpitch ?
std::max( goalpitch, engine_turbo_pitch - changerate * 0.5 ) :
std::min( goalpitch, engine_turbo_pitch + changerate ) );
volume = (
currentvolume > goalvolume ?
std::max( goalvolume, currentvolume - changerate ) :
std::min( goalvolume, currentvolume + changerate ) );
volume = (
currentvolume > goalvolume ?
std::max( goalvolume, currentvolume - changerate ) :
std::min( goalvolume, currentvolume + changerate ) );
if( volume > 0.05 ) {
engine_turbo
.pitch( 0.4 + engine_turbo_pitch * 0.4 )
.gain( volume )
.play( sound_flags::exclusive | sound_flags::looping );
}
else {
engine_turbo_pitch = std::max( goalpitch, engine_turbo_pitch - changerate * 0.5 );
volume = std::max( 0.0, engine_turbo.gain() - 2.0 * Deltatime );
if( volume > 0.05 ) {
engine_turbo
.pitch( 0.4 + engine_turbo_pitch * 0.4 )
.gain( volume );
}
else {
engine_turbo.stop();
engine_turbo_pitch = goalpitch;
}
engine_turbo.stop();
}
}