Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
smokegrenadebase.c
Go to the documentation of this file.
2{
4 START = 1,
5 LOOP = 2,
6 END = 3,
8 COUNT = 4
9}
10
12{
13 protected ref Timer m_TimerSmokeStart;
14 protected ref Timer m_TimerSmokeLoop;
15 protected ref Timer m_TimerSmokeEnd;
16
17 protected ref Timer m_TimerDefer;
18
21
26 protected int m_ParticleSmokeLoopId;
27 protected int m_ParticleSmokeEndId;
29
32 protected string m_SoundSmokeStartId;
33 protected string m_SoundSmokeLoopId;
34 protected string m_SoundSmokeEndId;
35
38
39 void SetParticleSmokeCurrent(int particle)
40 {
41 m_ParticleSmokeCurrentId = particle;
42 }
43
44 void SetParticleSmokeStart(int particle)
45 {
46 m_ParticleSmokeStartId = particle;
47 }
48
49 void SetParticleSmokeLoop(int particle)
50 {
51 m_ParticleSmokeLoopId = particle;
52 }
53
54 void SetParticleSmokeEnd(int particle)
55 {
56 m_ParticleSmokeEndId = particle;
57 }
58
59 void SetSoundSmokeStart(string sound)
60 {
61 m_SoundSmokeStartId = sound;
62 }
63
64 void SetSoundSmokeLoop(string sound)
65 {
66 m_SoundSmokeLoopId = sound;
67 }
68
69 void SetSoundSmokeEnd(string sound)
70 {
71 m_SoundSmokeEndId = sound;
72 }
73
74 protected void PlaySmokeParticle()
75 {
76 m_ParticleSmoke = ParticleManager.GetInstance().PlayOnObject(m_ParticleSmokeCurrentId, this, m_ParticlePosition, vector.Zero, true);
77 }
78
79 protected void SoundSmokeStart()
80 {
81 PlaySoundSetLoop(m_SoundSmoke, m_SoundSmokeStartId, 0.3, 1.0);
82 }
83
84 protected void SoundSmokeLoop()
85 {
86 PlaySoundSetLoop(m_SoundSmoke, m_SoundSmokeLoopId, 0.3, 1.0);
87 }
88
89 protected void SoundSmokeEnd()
90 {
91 PlaySoundSetLoop(m_SoundSmoke, m_SoundSmokeEndId, 1.0, 1.0);
92 }
93
94 //Stop
95 protected void SoundSmokeStop()
96 {
97 StopSoundSet(m_SoundSmoke);
98 }
99
100 protected void DestroySmokeGrenade()
101 {
103
104 if ( g_Game.IsServer() )
105 {
106 SetHealth("", "", 0);
107 }
108 }
109
111 {
113
114 if ( m_LastSmokeGrenadeState != state )
115 {
116 if ( state == ESmokeGrenadeState.START )
117 {
118 //Print("RefreshAudioVisual:: START");
121
125 }
126 else if ( state == ESmokeGrenadeState.LOOP )
127 {
128 //Print("RefreshAudioVisual:: LOOP");
131
135 }
136 else if ( state == ESmokeGrenadeState.END )
137 {
138 //Print("RefreshAudioVisual:: END");
141
145 }
146 else if ( state == ESmokeGrenadeState.NO_SMOKE )
147 {
148 //Print("RefreshAudioVisual:: NO_SMOKE");
150
152 }
153
155 }
156 }
157
158 override void Unpin()
159 {
160 super.Unpin();
161
162 Activate();
163
164 }
165
166 override void OnActivateFinished()
167 {
168 if ( GetCompEM() && GetCompEM().CanWork() )
169 {
170 GetCompEM().SwitchOn();
171 }
172 }
173
174 // When smoke starts
175 override void OnWorkStart()
176 {
178
179 if ( g_Game.IsServer() )
180 {
181 m_NoisePar = new NoiseParams();
182 m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseSmokeGrenade");
183 NoiseSystem noise = g_Game.GetNoiseSystem();
184 if ( noise )
185 {
186 noise.AddNoisePos( this, GetPosition(), m_NoisePar, NoiseAIEvaluate.GetNoiseReduction(g_Game.GetWeather()) );
187 }
188 }
189
190 Param1<ESmokeGrenadeState> par = new Param1<ESmokeGrenadeState>(ESmokeGrenadeState.LOOP);
191 m_TimerSmokeLoop.Run(5.0, this, "SetSmokeGrenadeState", par);
192 }
193
194 //When grenade makes smoke
195 override void OnWork(float consumed_energy)
196 {
197 if ( g_Game.IsServer() )
198 {
199 NoiseSystem noise = g_Game.GetNoiseSystem();
200 if ( noise )
201 {
202 noise.AddNoisePos( this, GetPosition(), m_NoisePar, NoiseAIEvaluate.GetNoiseReduction(g_Game.GetWeather()));
203 }
204 }
205 }
206
207 // When the smoke stops
208 override void OnWorkStop()
209 {
211
213 m_TimerDefer.Run(5.0, this, "DestroySmokeGrenade");
214 }
215
216 override bool CanPutInCargo( EntityAI parent )
217 {
218 return !GetCompEM().IsWorking();
219 }
220
221 override void OnActivatedByItem(notnull ItemBase item)
222 {
223 GetCompEM().SwitchOn();
224 }
225
226 override void SetActions()
227 {
228 super.SetActions();
229
230 RemoveAction(ActionPin);
231 }
232
234 {
235 super.OnVariablesSynchronized();
236
238 }
239
240 override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType) {}
241
246
247 override void EEDelete(EntityAI parent)
248 {
249 super.EEDelete(parent);
250
253 }
254
256 {
257 //Print("Setting SGS to: " + typename.EnumToString(ESmokeGrenadeState, state));
258
259 if ( g_Game.IsServer() )
260 {
261 if ( m_SmokeGrenadeState != state )
262 {
263 m_SmokeGrenadeState = state;
264
265 //synchronize
266 SetSynchDirty();
267 }
268 }
269 }
270
272 {
274
276 m_TimerDefer = new Timer;
277
278 SetAmmoType("");
279 SetPinnable(false);
280 SetGrenadeType(EGrenadeType.CHEMICAL);
284
285 RegisterNetSyncVariableInt("m_SmokeGrenadeState", ESmokeGrenadeState.NO_SMOKE, ESmokeGrenadeState.COUNT);
286 }
287
289}
eBleedingSourceType GetType()
ref NoiseParams m_NoisePar
void RemoveAction(typename actionName)
void SetActions()
Wrapper class for managing sound through SEffectManager.
Definition effectsound.c:5
Legacy way of using particles in the game.
Definition particle.c:7
override void EEDelete(EntityAI parent)
override void OnVariablesSynchronized()
DayZGame g_Game
Definition dayzgame.c:3942
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
class SEffectManager START
@ COUNT
void DestroyParticle(Particle p)
override bool CanPutInCargo(EntityAI parent)
void SetAmmoType(string pAmmoType)
vector m_ParticlePosition
EGrenadeType
Definition grenade_base.c:2
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
override void OnWorkStop()
void Activate()
class NoiseSystem NoiseParams()
Definition noise.c:15
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
void SoundSmokeLoop()
vector m_ParticleSmokePosition
void RefreshParticlesAndSounds()
void SoundSmokeStop()
ESmokeGrenadeState m_SmokeGrenadeState
int m_ParticleSmokeStartId
void SetSmokeGrenadeState(ESmokeGrenadeState state)
string m_SoundSmokeStartId
ESmokeGrenadeState
@ NO_SMOKE
@ LOOP
@ END
override void OnActivateFinished()
ESmokeGrenadeState m_LastSmokeGrenadeState
ref Timer m_TimerSmokeEnd
string m_SoundSmokeLoopId
string m_SoundSmokeEndId
void SetSoundSmokeEnd(string sound)
int m_ParticleSmokeEndId
void SoundSmokeStart()
EffectSound m_SoundSmoke
sounds
void SetParticleSmokeLoop(int particle)
void PlaySmokeParticle()
void SetSoundSmokeStart(string sound)
ESmokeGrenadeState GetSmokeGrenadeState()
ref Timer m_TimerSmokeLoop
ref Timer m_TimerDefer
enum ESmokeGrenadeState m_TimerSmokeStart
override void OnWork(float consumed_energy)
void DestroySmokeGrenade()
override void OnWorkStart()
Particle m_ParticleSmoke
particle
void SetParticleSmokeEnd(int particle)
void SetSoundSmokeLoop(string sound)
int m_ParticleSmokeLoopId
int m_ParticleSmokeCurrentId
void SoundSmokeEnd()
void SetParticleSmokeStart(int particle)
override void Unpin()
void SmokeGrenadeBase()
void SetParticleSmokeCurrent(int particle)
void ~SmokeGrenadeBase()