DayZ 1.24
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{
16
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
43
48
53
58
60 {
62 }
63
65 {
67 }
68
70 {
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 SetHealth("", "", 0);
106 }
107
109 {
111
113 {
114 if (state == ESmokeGrenadeState.START)
115 {
116 //Print("RefreshAudioVisual:: START");
119
123 }
124 else if (state == ESmokeGrenadeState.LOOP)
125 {
126 //Print("RefreshAudioVisual:: LOOP");
129
133 }
134 else if (state == ESmokeGrenadeState.END)
135 {
136 //Print("RefreshAudioVisual:: END");
139
143 }
144 else if (state == ESmokeGrenadeState.NO_SMOKE)
145 {
146 //Print("RefreshAudioVisual:: NO_SMOKE");
148
150 }
151
153 }
154 }
155
156 override void Unpin()
157 {
158 super.Unpin();
159
160 Activate();
161
162 }
163
164 override void OnActivateFinished()
165 {
166 if (GetCompEM() && GetCompEM().CanWork())
167 GetCompEM().SwitchOn();
168 }
169
170 // When smoke starts
171 override void OnWorkStart()
172 {
174
175 if (GetGame().IsServer())
176 {
177 m_NoisePar = new NoiseParams();
178 m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseSmokeGrenade");
179 NoiseSystem noise = GetGame().GetNoiseSystem();
180 if (noise)
181 noise.AddNoisePos(this, GetPosition(), m_NoisePar);
182 }
183
185 m_TimerSmokeLoop.Run(5.0, this, "SetSmokeGrenadeState", par);
186 }
187
188 //When grenade makes smoke
189 override void OnWork(float consumed_energy)
190 {
191 if (GetGame().IsServer())
192 {
193 NoiseSystem noise = GetGame().GetNoiseSystem();
194 if (noise)
195 noise.AddNoisePos(this, GetPosition(), m_NoisePar);
196 }
197 }
198
199 // When the smoke stops
200 override void OnWorkStop()
201 {
203
205 m_TimerDefer.Run(5.0, this, "DestroySmokeGrenade");
206 }
207
208 override bool CanPutInCargo(EntityAI parent)
209 {
210 return !GetCompEM().IsWorking();
211 }
212
214 {
215 GetCompEM().SwitchOn();
216 }
217
218 override void SetActions()
219 {
220 super.SetActions();
221
222 RemoveAction(ActionPin);
223 }
224
226 {
227 super.OnVariablesSynchronized();
228
230 }
231
232 override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType) {}
233
238
239 override void EEDelete(EntityAI parent)
240 {
241 super.EEDelete(parent);
242
245 }
246
248 {
249 //Print("Setting SGS to: " + typename.EnumToString(ESmokeGrenadeState, state));
250
251 if (GetGame().IsServer())
252 {
254 {
256
257 //synchronize
258 SetSynchDirty();
259 }
260 }
261 }
262
264 {
266
268 m_TimerDefer = new Timer;
269
270 SetAmmoType("");
271 SetPinnable(false);
272 SetGrenadeType(EGrenadeType.CHEMICAL);
276
277 RegisterNetSyncVariableInt("m_SmokeGrenadeState", ESmokeGrenadeState.NO_SMOKE, ESmokeGrenadeState.COUNT);
278 }
279
281}
eBleedingSourceType GetType()
ref NoiseParams m_NoisePar
void RemoveAction(typename actionName)
void SetActions()
override void OnVariablesSynchronized()
override void EEDelete(EntityAI parent)
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
void DestroyParticle(Particle p)
override bool CanPutInCargo(EntityAI parent)
void SetAmmoType(string pAmmoType)
vector m_ParticlePosition
EGrenadeType
Definition Grenade_Base.c:2
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
@ COUNT
@ 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()
class JsonUndergroundAreaTriggerData GetPosition
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
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()