DayZ 1.24
Loading...
Searching...
No Matches
FlashbangEffect.c
Go to the documentation of this file.
2{
3 protected const float ALPHA_MIN = 0.0;
4 protected const float ALPHA_MAX = 1.0;
5
6 protected const float SOUND_DEFER_TIME = 0.4;
7
8 protected float m_HitDuration;
9 protected float m_BreakPoint;
10 protected float m_TimeActive;
11 protected float m_DayTimeToggle;
12
13 protected float m_AlphaMaxActual; //actual max alpha of the effect
14 protected float m_SoundMaxActual; //actual max volume of the sound
15 protected float m_ProgressMultiplier;
16
17 protected bool m_Visual;
18 protected bool m_Initialized;
19
22 protected float m_SoundStopTime;
23
25
27
29 {
32 m_Initialized = false;
33
34 m_HitDuration = 8.0;
35 m_BreakPoint = 2.5;
37 m_SoundMaxActual = 1.0;
39
41
42 if (m_Visual)
43 {
45 m_Requester.Start();
46 }
47
49 m_DeferAttenuation.Run(SOUND_DEFER_TIME, this, "PlaySound", null, false);
50
52 m_DayTimeToggle = 5;
53 if (g_Game.GetDayTime() >= 22.0 || g_Game.GetDayTime() < 7.0)
54 m_DayTimeToggle = 10;
55 }
56
58 {
59 if (m_Visual)
61
62 if (m_Player)
63 m_Player.OnPlayerReceiveFlashbangHitEnd();
64
65 if (m_DeferAttenuation.IsRunning())
66 m_DeferAttenuation.Stop();
67
70 }
71
85
86 protected void PlaySound()
87 {
88 if (!m_Initialized)
89 {
90 Error("" + this + " not initialized");
91 return;
92 }
93
94 vector pos;
95 MiscGameplayFunctions.GetHeadBonePos(m_Player, pos);
96
98 m_FlashbangEffectSound = SEffectManager.CreateSound("Tinnitus_SoundSet", pos);
99
101 {
103 m_FlashbangEffectSound.SetAttachedLocalPos(m_Player.WorldToModel(pos));
112
114 }
115 }
116
117 protected void SetAttenuationFilter()
118 {
119 if (!m_DeferAttenuation.IsRunning() || m_Player.GetMasterAttenuation() != "FlashbangAttenuation")
120 m_Player.SetMasterAttenuation("FlashbangAttenuation");
121 }
122
123 protected void ResetAttenuationFilter()
124 {
125 m_Player.SetMasterAttenuation("");
126 }
127
136
137 protected void ClearVisual()
138 {
139 if (m_Requester)
140 m_Requester.Stop();
141 }
142
143 protected void SetVisual(float val)
144 {
145 if (m_Requester && m_Requester.IsRequesterRunning())
146 m_Requester.SetFlashbangIntensity(val, m_DayTimeToggle);
147 }
148
149 void Stop()
150 {
151 StopSound();
152 }
153
154 void Update(float deltatime)
155 {
156 if (!m_Initialized)
157 Error("" + this + " not initialized");
158 else if (m_Visual)
159 {
160 float value;
161
163 {
165 //Print("Flashbango | m_AlphaMaxActual: " + value);
166 }
167 else
168 {
170 value = Math.Clamp(value, 0.0, 1.0);
172 //Print("Flashbango | tmp_value: " + value);
173 }
175 }
176
178
180 StopSound();
181
183 {
185 delete this;
186 }
187 }
188}
DayZGame g_Game
Definition DayZGame.c:3528
WaveKind
Definition Sound.c:2
Super root of all classes in Enforce script.
Definition EnScript.c:11
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
override bool IsPlaying()
Returns true when the effect is playing, false otherwise.
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
override void SetParent(Object parent_obj)
Set parent for the sound to follow.
void SetSoundMaxVolume(float volume)
Set the sound max volume.
void SetSoundLoop(bool loop)
Set if the sound loops.
void SetSoundFadeIn(float fade_in)
Set the sound fade in duration.
void SetSoundWaveKind(WaveKind wave_kind)
Set WaveKind for the sound.
void SetSoundFadeOut(float fade_out)
Set the sound fade out duration.
bool SoundPlay()
Plays sound.
void SoundStop()
Stops sound.
const float ALPHA_MIN
void FlashbangEffect(PlayerBase player, bool visual=true)
void Update(float deltatime)
const float SOUND_DEFER_TIME
EffectSound m_FlashbangEffectSound
PlayerBase m_Player
float m_HitDuration
SFX will be played ~0.5s AFTER VFX.
void ResetAttenuationFilter()
PPERequester_FlashbangEffects m_Requester
const float ALPHA_MAX
void SetupFlashbangValues(float progress_mult=1.0, float visual_value_max=1.0, float sound_value_max=1.0)
ref Timer m_DeferAttenuation
void SetVisual(float val)
Definition EnMath.c:7
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound CreateSound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false, bool enviroment=false)
Create an EffectSound.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...