Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
explosivesbase.c
Go to the documentation of this file.
2{
3 protected static float m_DefaultBrightness = 10;
4 protected static float m_DefaultRadius = 30;
5
7 {
8 SetVisibleDuringDaylight(false);
9 SetRadiusTo(m_DefaultRadius);
10 SetBrightnessTo(m_DefaultBrightness);
11 SetFlareVisible(false);
12 SetAmbientColor(1.0, 1.0, 0.3);
13 SetDiffuseColor(1.0, 1.0, 0.3);
14 SetLifetime(0.15);
15 SetDisableShadowsWithinRadius(-1);
16 }
17}
18
20{
21 protected const string DEFAULT_AMMO_TYPE = "Explosion_NonLethal";
22 protected const string ANIM_PHASE_VISIBILITY = "Visibility";
23
24 protected bool m_Armed;
25 protected bool m_Defused;
27
28 protected ref Timer m_DeleteTimer;
29
32
36 protected int m_ParticleExplosionId;
39
40 static protected ref map<string, ref map<string, int>> m_TypeToSurfaceParticleIDMap;
41
43 {
44 m_DeleteTimer = new Timer();
46
49 SetParticlePosition(WorldToModel(GetPosition()));
51
52 RegisterNetSyncVariableBool("m_Armed");
53 RegisterNetSyncVariableBool("m_Defused");
54
55 Init();
56 }
57
58
59 override bool IsExplosive()
60 {
61 return true;
62 }
63
64 override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
65 {
66 super.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
67
69 {
70 EntityAI parent = this;
71 if (GetHierarchyParent())
72 {
73 parent = GetHierarchyParent();
74 }
75
76 //SEffectManager.CreateParticleServer(pos, new TreeEffecterParameters("TreeEffecter", 1.0, 10 * explosionFactor));
77 int particleID = GetParticleExplosionID(surface);
78
79 ParticleSource p = ParticleManager.GetInstance().PlayOnObject(particleID, parent, m_ParticlePosition, m_ParticleOrientation);
80 m_ParticleExplosionArr.Insert(p);
82 }
83
85 }
86
87 override void EEDelete(EntityAI parent)
88 {
89 super.EEDelete(parent);
90
92 {
94 {
96 }
97 }
98 }
99
100 override void EEKilled(Object killer)
101 {
102 super.EEKilled(killer);
103
106
107 UnpairRemote();
108 }
109
110 override void OnCEUpdate()
111 {
112 super.OnCEUpdate();
113
114 if (!IsRuined() && GetArmed() && GetPairDevice())
115 {
116 if (vector.DistanceSq(GetPosition(), GetPairDevice().GetPosition()) <= Math.SqrFloat(UAMaxDistances.EXPLOSIVE_REMOTE_ACTIVATION))
117 {
119
120 return;
121 }
122 }
123
125 }
126
127 override void UnpairRemote()
128 {
130 {
131 if (GetPairDevice())
132 {
133 GetPairDevice().UnpairRemote();
134 }
136 }
137
138 }
139
140 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
141 {
142 super.OnPlacementComplete(player, position, orientation);
143
144 if (g_Game.IsServer())
145 {
146 SetOrientation(orientation);
147 SetPosition(position);
148 PlaceOnSurface();
149 }
150 }
151
153 {
154 return string.Empty;
155 }
156
158 {
159 return string.Empty;
160 }
161
163 {
164 return string.Empty;
165 }
166
167 override void InitItemSounds()
168 {
169 super.InitItemSounds();
170
172
173 if (GetArmSoundset() != string.Empty)
174 handler.AddSound(SoundConstants.ITEM_EXPLOSIVE_ARM, GetArmSoundset());
175
176 if (GetDisarmSoundset() != string.Empty)
177 handler.AddSound(SoundConstants.ITEM_EXPLOSIVE_DISARM, GetDisarmSoundset());
178
179 if (GetDisarmSoundsetUnpaired() != string.Empty)
180 handler.AddSound(SoundConstants.ITEM_EXPLOSIVE_DISARM_UNPAIRED, GetDisarmSoundsetUnpaired());
181 }
182
183 protected void CreateLight()
184 {
186 }
187
188 protected void DestroyParticle(Particle p)
189 {
190 #ifndef SERVER
191 if (p != null)
192 {
193 p.Stop();
194 }
195 #endif
196 }
197
198 protected void InitiateExplosion()
199 {
200 int count = m_AmmoTypes.Count();
201 for (int i = 0; i < count; i++)
202 {
203 Explode(DamageType.EXPLOSION, m_AmmoTypes[i]);
204 }
205
206 OnExplode();
207 }
208
209 protected void OnExplode()
210 {
211 if (g_Game.IsServer())
212 {
213 m_DeleteTimer.Run(0.25, this, "DeleteSafe");
214 }
215 }
216
217 override void SetActions()
218 {
219 super.SetActions();
220
223 }
224
225 override bool IsInventoryVisible()
226 {
227 if (!super.IsInventoryVisible())
228 {
229 return false;
230 }
231
232 return GetAnimationPhase("Visibility") == 0;
233 }
234
235 override bool IsTakeable()
236 {
237 return super.IsTakeable() && GetAnimationPhase("Visibility") == 0;
238 }
239
241 {
242 return false;
243 }
244
245 void Arm()
246 {
247 SetArmed(true);
248
249 OnArmed();
250 }
251
252 void OnArmed();
253
255 {
256 return true;
257 }
258
259 void Disarm(bool pWithTool = false)
260 {
261 SetArmed(false);
262
263 OnDisarmed(pWithTool);
264 }
265
267 void OnDisarmed(bool pWithTool);
268
270 {
271 return false;
272 }
273
274 bool GetArmed()
275 {
276 return m_Armed;
277 }
278
279 protected void SetArmed(bool state)
280 {
281 m_Armed = state;
282 SetSynchDirty();
283 }
284
285 override bool CanPutInCargo(EntityAI parent)
286 {
287 if (!super.CanPutInCargo(parent))
288 {
289 return false;
290 }
291
292 return IsTakeable();
293 }
294
295 override bool CanPutIntoHands(EntityAI parent)
296 {
297 if (!super.CanPutIntoHands(parent))
298 {
299 return false;
300 }
301
302 return IsTakeable();
303 }
304
305 override bool CanRemoveFromHands(EntityAI parent)
306 {
307 return IsTakeable();
308 }
309
311 {
312 return m_Defused;
313 }
314
315 protected void SetDefused(bool state)
316 {
317 m_Defused = state;
318 SetSynchDirty();
319 }
320
321 void SetAmmoType(string pAmmoType)
322 {
323 SetAmmoTypes({pAmmoType});
324 }
325
327 {
328 m_AmmoTypes.Clear();
329 m_AmmoTypes = pAmmoTypes;
330 }
331
332 void SetParticleExplosion(int particle)
333 {
334 m_ParticleExplosionId = particle;
335 }
336
339 {
340 m_ParticlePosition = local_pos;
341
342 if (GetHierarchyParent())
343 {
344 m_ParticlePosition = GetHierarchyParent().WorldToModel(GetPosition());
345 }
346 }
347
349 {
350 m_ParticleOrientation = local_ori;
351
352 if (GetHierarchyParent())
353 {
354 m_ParticleOrientation = GetHierarchyParent().WorldToModel(GetOrientation());
355 }
356 }
357
359 {
360 super.OnStoreSave(ctx);
361
362 ctx.Write(m_Armed);
363 }
364
365 override bool OnStoreLoad(ParamsReadContext ctx, int version)
366 {
367 if (!super.OnStoreLoad(ctx, version))
368 return false;
369
370 if (version > 129)
371 {
372 bool armed = false;
373 if (!ctx.Read(armed))
374 {
375 return false;
376 }
377
378 SetArmed(armed);
379 }
380
381 return true;
382 }
383
385 void UpdateLED(int pState);
387 {
388 return false;
389 }
390
393
396
397 void Init()
398 {
399 #ifndef SERVER
400 if (!m_TypeToSurfaceParticleIDMap)
401 {
402 m_TypeToSurfaceParticleIDMap = new map<string, ref map<string, int>>;
403 }
404
405 if(!m_TypeToSurfaceParticleIDMap.Contains(GetName()))
406 {
407 map<string, int> extraSurfaceeffect = new map<string, int>();
408 m_TypeToSurfaceParticleIDMap.Insert(GetName(), extraSurfaceeffect);
410 }
411 #endif
412 }
413
414 static void Cleanup()
415 {
416 if (m_TypeToSurfaceParticleIDMap)
417 {
418 m_TypeToSurfaceParticleIDMap.Clear();
419 }
420 }
421
423 {
424 //Here add in override call AddExplosionEffectForSurface for specific explosion on surface
425 }
426
427 void AddExplosionEffectForSurface(string surface, int effectID)
428 {
429 map<string, int> extraSurfaceeffect;
430 m_TypeToSurfaceParticleIDMap.Find(GetName(), extraSurfaceeffect);
431 extraSurfaceeffect.Insert(surface, effectID);
432 }
433
434 int GetParticleExplosionID(string surface)
435 {
436 map<string, int> extraSurfaceeffect;
437 m_TypeToSurfaceParticleIDMap.Find(GetName(), extraSurfaceeffect);
438
439 int particleID;
440 if (extraSurfaceeffect.Find(surface, particleID))
441 return particleID;
443 }
444}
AttachActionData ActionData ActionAttach()
Definition actionattach.c:9
void ActionDetach()
void AddAction(typename actionName)
class PASBroadcaster extends AdvancedCommunication IsInventoryVisible
void SetActions()
vector GetOrientation()
static float m_DefaultBrightness
void ExplosiveLight()
static float m_DefaultRadius
Definition enmath.c:7
Legacy way of using particles in the game.
Definition particle.c:7
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition particle.c:266
Entity which has the particle instance as an ObjectComponent.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void Disarm()
Definition clockbase.c:199
override void EEDelete(EntityAI parent)
DamageType
exposed from C++ (do not change)
DayZGame g_Game
Definition dayzgame.c:3942
override Widget Init()
Definition dayzgame.c:127
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
void UnlockExplosivesSlots()
string GetDisarmSoundset()
ExplosiveLight DEFAULT_AMMO_TYPE
void OnExplode()
bool IsTimerDetonable()
override void OnCEUpdate()
void AddExplosionEffectForSurface(string surface, int effectID)
void SetArmed(bool state)
void InitiateExplosion()
void OnBeforeDisarm()
void InitSpecificsExplosionEffectForSurface()
void DestroyParticle(Particle p)
ref array< string > m_AmmoTypes
override void EEKilled(Object killer)
override bool CanPutInCargo(EntityAI parent)
ref Timer m_DeleteTimer
Particle m_ParticleExplosion
particle
void SetDefused(bool state)
bool GetArmed()
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
void SetAmmoTypes(array< string > pAmmoTypes)
override bool IsExplosive()
void SetParticleExplosion(int particle)
void SetParticlePosition(vector local_pos)
set position for smoke particle - needs to be in Local Space
void UnlockTriggerSlots()
bool GetDefused()
void OnDisarmed(bool pWithTool)
void LockExplosivesSlots()
bool m_Defused
bool m_Armed
void CreateLight()
override bool CanPutIntoHands(EntityAI parent)
ref array< ParticleSource > m_ParticleExplosionArr
const string ANIM_PHASE_VISIBILITY
override void UnpairRemote()
string GetArmSoundset()
void OnArmed()
override bool IsTakeable()
void Arm()
int m_ParticleExplosionId
vector m_ParticleOrientation
void SetAmmoType(string pAmmoType)
bool CanBeDisarmed()
bool HasLockedTriggerSlots()
string GetDisarmSoundsetUnpaired()
void SetParticleOrientation(vector local_ori)
override bool CanRemoveFromHands(EntityAI parent)
void ExplosivesBase()
void LockTriggerSlots()
override void InitItemSounds()
bool CanBeArmed()
vector m_ParticlePosition
int GetParticleExplosionID(string surface)
Serializer ParamsReadContext
Definition gameplay.c:15
Serializer ParamsWriteContext
Definition gameplay.c:16
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition effect.c:463
proto string GetName()
Suite class name getter. Strictly for UI porposes!
Definition syncedvalue.c:50
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
Empty
Definition hand_states.c:14
ItemSoundHandler GetItemSoundHandler()
Definition itembase.c:9329
void ItemSoundHandler(ItemBase parent)
class Land_Buoy extends House m_Light
void UpdateLED(string selection, string color)
void OnStoreSave(ParamsWriteContext ctx)
bool OnStoreLoad(ParamsReadContext ctx, int version)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).
void Cleanup()
Definition ppemanager.c:70
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
ERemoteDetonatorLEDState
override void Explode(int damageType, string ammoType="")