DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
FlashbangEffect.c
См. документацию.
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
26 protected PPERequester_FlashbangEffects m_Requester;
27
28 void FlashbangEffect(PlayerBase player, bool visual = true)
29 {
30 m_Player = player;
31 m_Visual = visual;
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 {
44 Class.CastTo(m_Requester,PPERequesterBank.GetRequester(PPERequester_FlashbangEffects));
45 m_Requester.Start();
46 }
47
48 m_DeferAttenuation = new ref Timer();
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 {
55 m_DayTimeToggle = 10;
56 }
57 }
58
60 {
61 if ( m_Visual )
62 {
64 }
65
66 if ( m_Player )
67 {
68 m_Player.OnPlayerReceiveFlashbangHitEnd();
69 }
70
71 if ( m_DeferAttenuation.IsRunning() )
72 {
73 m_DeferAttenuation.Stop();
74 }
75
76 m_DeferAttenuation = null;
78 }
79
80 void SetupFlashbangValues(float progress_mult = 1.0, float visual_value_max = 1.0, float sound_value_max = 1.0)
81 {
82 if ( !m_Initialized )
83 {
84 m_Initialized = true;
85 m_ProgressMultiplier = progress_mult;
86 m_AlphaMaxActual = visual_value_max;
87 m_SoundMaxActual = sound_value_max;
88
91 }
92 }
93
94 protected void PlaySound()
95 {
96 if ( !m_Initialized )
97 {
98 Error("" + this + " not initialized");
99 return;
100 }
101
102 vector pos;
103 MiscGameplayFunctions.GetHeadBonePos(m_Player, pos);
104
106 {
107 m_FlashbangEffectSound = SEffectManager.CreateSound("Tinnitus_SoundSet", pos);
108 }
109
110 if (!m_FlashbangEffectSound.IsPlaying())
111 {
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)); //TODO
117 m_FlashbangEffectSound.SetSoundFadeOut(m_SoundStopTime); //TODO
118 m_FlashbangEffectSound.SetSoundMaxVolume(Math.Clamp(m_SoundMaxActual,0.1,1.0)); //TODO
119 m_FlashbangEffectSound.SetSoundLoop(true);
120 m_FlashbangEffectSound.SoundPlay();
121 m_FlashbangEffectSound.SetAutodestroy(true);
122
124 }
125 }
126
127 protected void SetAttenuationFilter()
128 {
129 if ( !m_DeferAttenuation.IsRunning() || m_Player.GetMasterAttenuation() != "FlashbangAttenuation" )
130 {
131 m_Player.SetMasterAttenuation("FlashbangAttenuation");
132 }
133 }
134
135 protected void ResetAttenuationFilter()
136 {
137 m_Player.SetMasterAttenuation("");
138 }
139
140 protected void StopSound()
141 {
143 {
144 m_FlashbangEffectSound.SoundStop();
146 }
147 }
148
149 protected void ClearVisual()
150 {
151 if (m_Requester)
152 {
153 m_Requester.Stop();
154 }
155 }
156
157 protected void SetVisual(float val)
158 {
159 if (m_Requester && m_Requester.IsRequesterRunning())
160 {
161 m_Requester.SetFlashbangIntensity(val, m_DayTimeToggle);
162 }
163 }
164
165 void Stop()
166 {
167 StopSound();
168 }
169
170 void Update(float deltatime)
171 {
172 if ( !m_Initialized )
173 {
174 Error("" + this + " not initialized");
175 }
176 else if ( m_Visual )
177 {
178 float value;
179
180 if ( m_TimeActive <= m_BreakPoint )
181 {
182 value = m_AlphaMaxActual;
183 //Print("Flashbango | m_AlphaMaxActual: " + value);
184 }
185 else
186 {
188 value = Math.Clamp(value,0.0,1.0);
189 value = m_AlphaMaxActual - value * m_AlphaMaxActual;
190 //Print("Flashbango | tmp_value: " + value);
191 }
192 SetVisual(value);
193 }
194
195 m_TimeActive += deltatime;
196
198 {
199 StopSound();
200 }
201
203 {
205 delete this;
206 }
207 }
208}
DayZGame g_Game
Определения DayZGame.c:3868
WaveKind
Определения Sound.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
float m_BreakPoint
Определения FlashbangEffect.c:9
float m_SoundStopTime
Определения FlashbangEffect.c:22
float m_SoundMaxActual
Определения FlashbangEffect.c:14
const float ALPHA_MIN
Определения FlashbangEffect.c:3
bool m_Initialized
Определения FlashbangEffect.c:18
void FlashbangEffect(PlayerBase player, bool visual=true)
Определения FlashbangEffect.c:28
void Update(float deltatime)
Определения FlashbangEffect.c:170
float m_DayTimeToggle
Определения FlashbangEffect.c:11
void ~FlashbangEffect()
Определения FlashbangEffect.c:59
void Stop()
Определения FlashbangEffect.c:165
const float SOUND_DEFER_TIME
Определения FlashbangEffect.c:6
EffectSound m_FlashbangEffectSound
Определения FlashbangEffect.c:21
PlayerBase m_Player
Определения FlashbangEffect.c:20
float m_HitDuration
SFX will be played ~0.5s AFTER VFX.
Определения FlashbangEffect.c:8
void ResetAttenuationFilter()
Определения FlashbangEffect.c:135
bool m_Visual
Определения FlashbangEffect.c:17
void SetAttenuationFilter()
Определения FlashbangEffect.c:127
PPERequester_FlashbangEffects m_Requester
Определения FlashbangEffect.c:26
float m_AlphaMaxActual
Определения FlashbangEffect.c:13
const float ALPHA_MAX
Определения FlashbangEffect.c:4
float m_ProgressMultiplier
Определения FlashbangEffect.c:15
float m_TimeActive
Определения FlashbangEffect.c:10
void PlaySound()
Определения FlashbangEffect.c:94
void SetupFlashbangValues(float progress_mult=1.0, float visual_value_max=1.0, float sound_value_max=1.0)
Определения FlashbangEffect.c:80
ref Timer m_DeferAttenuation
Определения FlashbangEffect.c:24
void StopSound()
Определения FlashbangEffect.c:140
void SetVisual(float val)
Определения FlashbangEffect.c:157
void ClearVisual()
Определения FlashbangEffect.c:149
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
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.
Определения EffectManager.c:144
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Определения EffectManager.c:271
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
Определения DayZPlayerImplement.c:63
Определения EnConvert.c:106
void Error(string err)
Messagebox with error message.
Определения 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,...