DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
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
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 {
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
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 ( GetGame().IsServer() )
180 {
181 m_NoisePar = new NoiseParams();
182 m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseSmokeGrenade");
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 {
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
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
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
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()
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
protected vector m_ParticlePosition
override void EEDelete(EntityAI parent)
protected void DestroyParticle(Particle p)
void SetAmmoType(string pAmmoType)
EGrenadeType
Definition Grenade_Base.c:2
override void OnVariablesSynchronized()
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.
protected ref Timer m_TimerDefer
protected ref Timer m_TimerSmokeEnd
protected void SoundSmokeLoop()
void SetSmokeGrenadeState(ESmokeGrenadeState state)
protected void SoundSmokeEnd()
protected void RefreshParticlesAndSounds()
ESmokeGrenadeState
@ COUNT
@ NO_SMOKE
@ LOOP
@ END
protected int m_ParticleSmokeEndId
override void OnActivateFinished()
void SetSoundSmokeEnd(string sound)
protected int m_ParticleSmokeStartId
protected string m_SoundSmokeStartId
void SetParticleSmokeLoop(int particle)
override bool CanPutInCargo(EntityAI parent)
void SetSoundSmokeStart(string sound)
protected EffectSound m_SoundSmoke
sounds
protected string m_SoundSmokeEndId
protected ESmokeGrenadeState m_LastSmokeGrenadeState
ESmokeGrenadeState GetSmokeGrenadeState()
enum ESmokeGrenadeState m_TimerSmokeStart
override void OnWork(float consumed_energy)
protected ESmokeGrenadeState m_SmokeGrenadeState
protected Particle m_ParticleSmoke
particle
override void OnWorkStart()
protected void DestroySmokeGrenade()
protected vector m_ParticleSmokePosition
protected int m_ParticleSmokeLoopId
protected string m_SoundSmokeLoopId
protected int m_ParticleSmokeCurrentId
void SetParticleSmokeEnd(int particle)
void SetSoundSmokeLoop(string sound)
protected void PlaySmokeParticle()
protected void SoundSmokeStart()
protected ref Timer m_TimerSmokeLoop
void SetParticleSmokeStart(int particle)
override void Unpin()
void SetParticleSmokeCurrent(int particle)
protected void SoundSmokeStop()
void ~SmokeGrenadeBase()
class JsonUndergroundAreaTriggerData GetPosition
proto native NoiseSystem GetNoiseSystem()
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
proto void AddNoisePos(EntityAI source_entity, vector pos, NoiseParams noise_params, float external_strenght_multiplier=1.0)
Legacy way of using particles in the game.
Definition Particle.c:7
static const int INVALID
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()