3 protected const float ALPHA_MIN = 0.0;
4 protected const float ALPHA_MAX = 1.0;
6 protected const float SOUND_DEFER_TIME = 0.4;
8 protected float m_HitDuration;
9 protected float m_BreakPoint;
10 protected float m_TimeActive;
11 protected float m_DayTimeToggle;
13 protected float m_AlphaMaxActual;
14 protected float m_SoundMaxActual;
15 protected float m_ProgressMultiplier;
17 protected bool m_Visual;
18 protected bool m_Initialized;
22 protected float m_SoundStopTime;
24 protected ref
Timer m_DeferAttenuation;
26 protected PPERequester_FlashbangEffects m_Requester;
36 m_AlphaMaxActual = ALPHA_MAX;
37 m_SoundMaxActual = 1.0;
38 m_ProgressMultiplier = 1.0;
40 m_FlashbangEffectSound =
null;
44 Class.CastTo(
m_Requester,PPERequesterBank.GetRequester(PPERequester_FlashbangEffects));
48 m_DeferAttenuation =
new ref
Timer();
49 m_DeferAttenuation.Run(SOUND_DEFER_TIME,
this,
"PlaySound",
null,
false);
53 if (
g_Game.GetDayTime() >= 22.0 ||
g_Game.GetDayTime() < 7.0 )
68 m_Player.OnPlayerReceiveFlashbangHitEnd();
71 if ( m_DeferAttenuation.IsRunning() )
73 m_DeferAttenuation.Stop();
76 m_DeferAttenuation =
null;
80 void SetupFlashbangValues(
float progress_mult = 1.0,
float visual_value_max = 1.0,
float sound_value_max = 1.0)
85 m_ProgressMultiplier = progress_mult;
86 m_AlphaMaxActual = visual_value_max;
87 m_SoundMaxActual = sound_value_max;
89 m_HitDuration *= m_ProgressMultiplier;
90 m_BreakPoint *= m_ProgressMultiplier;
94 protected void PlaySound()
98 Error(
"" +
this +
" not initialized");
103 MiscGameplayFunctions.GetHeadBonePos(
m_Player, pos);
105 if (!m_FlashbangEffectSound)
107 m_FlashbangEffectSound =
SEffectManager.CreateSound(
"Tinnitus_SoundSet", pos);
110 if (!m_FlashbangEffectSound.IsPlaying())
112 m_FlashbangEffectSound.SetParent(
m_Player);
113 m_FlashbangEffectSound.SetAttachedLocalPos(
m_Player.WorldToModel(pos));
114 m_FlashbangEffectSound.SetSoundWaveKind(
WaveKind.WAVEEFFECTEX);
115 m_FlashbangEffectSound.SetSoundFadeIn(4 *
Math.Clamp(m_ProgressMultiplier,0.5,1.0));
116 m_SoundStopTime = 2 *
Math.Clamp(m_ProgressMultiplier,0.5,1.0);
117 m_FlashbangEffectSound.SetSoundFadeOut(m_SoundStopTime);
118 m_FlashbangEffectSound.SetSoundMaxVolume(
Math.Clamp(m_SoundMaxActual,0.1,1.0));
119 m_FlashbangEffectSound.SetSoundLoop(
true);
120 m_FlashbangEffectSound.SoundPlay();
121 m_FlashbangEffectSound.SetAutodestroy(
true);
123 SetAttenuationFilter();
127 protected void SetAttenuationFilter()
129 if ( !m_DeferAttenuation.IsRunning() ||
m_Player.GetMasterAttenuation() !=
"FlashbangAttenuation" )
131 m_Player.SetMasterAttenuation(
"FlashbangAttenuation");
135 protected void ResetAttenuationFilter()
140 protected void StopSound()
142 if (m_FlashbangEffectSound)
144 m_FlashbangEffectSound.SoundStop();
149 protected void ClearVisual()
157 protected void SetVisual(
float val)
161 m_Requester.SetFlashbangIntensity(val, m_DayTimeToggle);
170 void Update(
float deltatime)
174 Error(
"" +
this +
" not initialized");
182 value = m_AlphaMaxActual;
187 value =
Math.InverseLerp(m_HitDuration - m_BreakPoint, m_HitDuration,
m_TimeActive);
188 value =
Math.Clamp(value,0.0,1.0);
189 value = m_AlphaMaxActual - value * m_AlphaMaxActual;
204 ResetAttenuationFilter();