Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
smokegrenadebase.c
Go to the documentation of this file.
2 {
3  NO_SMOKE = 0
4  START = 1,
5  LOOP = 2,
6  END = 3,
8  COUNT = 4
9 }
10 
11 class SmokeGrenadeBase extends Grenade_Base
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 
24  protected int m_ParticleSmokeCurrentId;
25  protected int m_ParticleSmokeStartId;
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 ( GetGame().IsServer() )
105  {
106  SetHealth("", "", 0);
107  }
108  }
109 
110  protected void RefreshParticlesAndSounds()
111  {
113 
114  if ( m_LastSmokeGrenadeState != state )
115  {
116  if ( state == ESmokeGrenadeState.START )
117  {
118  //Print("RefreshAudioVisual:: START");
119  SoundSmokeEnd();
120  SoundSmokeStart();
121 
125  }
126  else if ( state == ESmokeGrenadeState.LOOP )
127  {
128  //Print("RefreshAudioVisual:: LOOP");
129  SoundSmokeStop();
130  SoundSmokeLoop();
131 
135  }
136  else if ( state == ESmokeGrenadeState.END )
137  {
138  //Print("RefreshAudioVisual:: END");
139  SoundSmokeStop();
140  SoundSmokeEnd();
141 
145  }
146  else if ( state == ESmokeGrenadeState.NO_SMOKE )
147  {
148  //Print("RefreshAudioVisual:: NO_SMOKE");
149  SoundSmokeStop();
150 
152  }
153 
154  m_LastSmokeGrenadeState = state;
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 ( GetGame().IsServer() )
180  {
181  m_NoisePar = new NoiseParams();
182  m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseSmokeGrenade");
183  NoiseSystem noise = GetGame().GetNoiseSystem();
184  if ( noise )
185  {
186  noise.AddNoisePos( this, GetPosition(), m_NoisePar );
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 ( GetGame().IsServer() )
198  {
199  NoiseSystem noise = GetGame().GetNoiseSystem();
200  if ( noise )
201  {
202  noise.AddNoisePos( this, GetPosition(), m_NoisePar);
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 
233  override void OnVariablesSynchronized()
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 
243  {
244  return m_SmokeGrenadeState;
245  }
246 
247  override void EEDelete(EntityAI parent)
248  {
249  super.EEDelete(parent);
250 
251  SoundSmokeStop();
253  }
254 
256  {
257  //Print("Setting SGS to: " + typename.EnumToString(ESmokeGrenadeState, state));
258 
259  if ( GetGame().IsServer() )
260  {
261  if ( m_SmokeGrenadeState != state )
262  {
263  m_SmokeGrenadeState = state;
264 
265  //synchronize
266  SetSynchDirty();
267  }
268  }
269  }
270 
272  {
274 
275  m_TimerSmokeLoop = new Timer;
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 
288  void ~SmokeGrenadeBase();
289 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
SetSoundSmokeEnd
void SetSoundSmokeEnd(string sound)
Definition: smokegrenadebase.c:69
DestroySmokeGrenade
protected void DestroySmokeGrenade()
Definition: smokegrenadebase.c:100
ESmokeGrenadeState
ESmokeGrenadeState
Definition: smokegrenadebase.c:1
EEDelete
override void EEDelete(EntityAI parent)
Definition: smokegrenadebase.c:247
LOOP
@ LOOP
Definition: smokegrenadebase.c:5
Particle
Legacy way of using particles in the game.
Definition: particle.c:6
OnExplosionEffects
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
Definition: smokegrenadebase.c:240
Grenade_Base
Definition: flashgrenade.c:1
Activate
void Activate()
Definition: modifierbase.c:201
OnActivateFinished
override void OnActivateFinished()
Definition: smokegrenadebase.c:166
m_ParticleSmokeCurrentId
protected int m_ParticleSmokeCurrentId
Definition: smokegrenadebase.c:24
OnActivatedByItem
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Definition: smokegrenadebase.c:221
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: smokegrenadebase.c:233
~SmokeGrenadeBase
void ~SmokeGrenadeBase()
RemoveAction
void RemoveAction(typename actionName)
Definition: advancedcommunication.c:118
END
@ END
Definition: smokegrenadebase.c:6
OnWorkStop
override void OnWorkStop()
Definition: smokegrenadebase.c:208
SmokeGrenadeBase
void SmokeGrenadeBase()
Definition: smokegrenadebase.c:271
EGrenadeType
EGrenadeType
Definition: grenade_base.c:1
SetSoundSmokeLoop
void SetSoundSmokeLoop(string sound)
Definition: smokegrenadebase.c:64
m_SmokeGrenadeState
protected ESmokeGrenadeState m_SmokeGrenadeState
Definition: smokegrenadebase.c:19
SetParticleSmokeCurrent
void SetParticleSmokeCurrent(int particle)
Definition: smokegrenadebase.c:39
PlaySmokeParticle
protected void PlaySmokeParticle()
Definition: smokegrenadebase.c:74
m_TimerDefer
protected ref Timer m_TimerDefer
Definition: smokegrenadebase.c:17
SetActions
override void SetActions()
Definition: smokegrenadebase.c:226
RefreshParticlesAndSounds
protected void RefreshParticlesAndSounds()
Definition: smokegrenadebase.c:110
m_SoundSmokeStartId
protected string m_SoundSmokeStartId
Definition: smokegrenadebase.c:32
m_LastSmokeGrenadeState
protected ESmokeGrenadeState m_LastSmokeGrenadeState
Definition: smokegrenadebase.c:20
m_SoundSmokeLoopId
protected string m_SoundSmokeLoopId
Definition: smokegrenadebase.c:33
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
ParticleList
Definition: particlelist.c:11
vector
Definition: enconvert.c:105
START
@ START
Definition: contaminatedarea_dynamic.c:4
m_ParticleSmokeEndId
protected int m_ParticleSmokeEndId
Definition: smokegrenadebase.c:27
NoiseParams
class ObjectSpawnerHandler NoiseParams
DestroyParticle
protected void DestroyParticle(Particle p)
Definition: explosivesbase.c:150
SoundSmokeLoop
protected void SoundSmokeLoop()
Definition: smokegrenadebase.c:84
CanPutInCargo
override bool CanPutInCargo(EntityAI parent)
Definition: smokegrenadebase.c:216
SetSmokeGrenadeState
void SetSmokeGrenadeState(ESmokeGrenadeState state)
Definition: smokegrenadebase.c:255
SetParticleSmokeEnd
void SetParticleSmokeEnd(int particle)
Definition: smokegrenadebase.c:54
OnWork
override void OnWork(float consumed_energy)
Definition: smokegrenadebase.c:195
Object
Definition: objecttyped.c:1
m_TimerSmokeStart
enum ESmokeGrenadeState m_TimerSmokeStart
SoundSmokeStop
protected void SoundSmokeStop()
Definition: smokegrenadebase.c:95
GetSmokeGrenadeState
ESmokeGrenadeState GetSmokeGrenadeState()
Definition: smokegrenadebase.c:242
SmokeGrenadeBase
Definition: m18smokegrenade_colorbase.c:1
COUNT
@ COUNT
Definition: smokegrenadebase.c:8
SetParticleSmokeLoop
void SetParticleSmokeLoop(int particle)
Definition: smokegrenadebase.c:49
m_TimerSmokeEnd
protected ref Timer m_TimerSmokeEnd
Definition: smokegrenadebase.c:15
SetSoundSmokeStart
void SetSoundSmokeStart(string sound)
Definition: smokegrenadebase.c:59
NoiseSystem
Definition: noise.c:1
m_ParticlePosition
protected vector m_ParticlePosition
Definition: explosivesbase.c:37
SetParticleSmokeStart
void SetParticleSmokeStart(int particle)
Definition: smokegrenadebase.c:44
NO_SMOKE
@ NO_SMOKE
Definition: smokegrenadebase.c:3
SetAmmoType
void SetAmmoType(string pAmmoType)
Definition: explosivesbase.c:283
m_ParticleSmokePosition
protected vector m_ParticleSmokePosition
Definition: smokegrenadebase.c:28
Unpin
override void Unpin()
Definition: smokegrenadebase.c:158
SoundSmokeEnd
protected void SoundSmokeEnd()
Definition: smokegrenadebase.c:89
m_SoundSmoke
protected EffectSound m_SoundSmoke
sounds
Definition: smokegrenadebase.c:31
Timer
Definition: dayzplayerimplement.c:62
m_ParticleSmokeLoopId
protected int m_ParticleSmokeLoopId
Definition: smokegrenadebase.c:26
m_SoundSmokeEndId
protected string m_SoundSmokeEndId
Definition: smokegrenadebase.c:34
m_ParticleSmokeStartId
protected int m_ParticleSmokeStartId
Definition: smokegrenadebase.c:25
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition: particlemanager.c:84
m_NoisePar
ref NoiseParams m_NoisePar
Noise.
Definition: smokegrenadebase.c:37
SoundSmokeStart
protected void SoundSmokeStart()
Definition: smokegrenadebase.c:79
EntityAI
Definition: building.c:5
m_ParticleSmoke
protected Particle m_ParticleSmoke
particle
Definition: smokegrenadebase.c:23
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
OnWorkStart
override void OnWorkStart()
Definition: smokegrenadebase.c:175
m_TimerSmokeLoop
protected ref Timer m_TimerSmokeLoop
Definition: smokegrenadebase.c:14