Dayz Explorer 1.28.160049
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
19class ExplosivesBase : ItemBase
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
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 (GetGame().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
162 override void InitItemSounds()
163 {
164 super.InitItemSounds();
165
167
168 if (GetArmSoundset() != string.Empty)
169 handler.AddSound(SoundConstants.ITEM_EXPLOSIVE_ARM, GetArmSoundset());
170
171 if (GetDisarmSoundset() != string.Empty)
172 handler.AddSound(SoundConstants.ITEM_EXPLOSIVE_DISARM, GetDisarmSoundset());
173 }
174
175 protected void CreateLight()
176 {
178 }
179
180 protected void DestroyParticle(Particle p)
181 {
182 #ifndef SERVER
183 if (p != null)
184 {
185 p.Stop();
186 }
187 #endif
188 }
189
190 protected void InitiateExplosion()
191 {
192 int count = m_AmmoTypes.Count();
193 for (int i = 0; i < count; i++)
194 {
195 Explode(DamageType.EXPLOSION, m_AmmoTypes[i]);
196 }
197
198 OnExplode();
199 }
200
201 protected void OnExplode()
202 {
203 if (GetGame().IsServer())
204 {
205 m_DeleteTimer.Run(0.25, this, "DeleteSafe");
206 }
207 }
208
209 override void SetActions()
210 {
211 super.SetActions();
212
213 AddAction(ActionAttach);
215 }
216
217 override bool IsInventoryVisible()
218 {
219 if (!super.IsInventoryVisible())
220 {
221 return false;
222 }
223
224 return GetAnimationPhase("Visibility") == 0;
225 }
226
227 override bool IsTakeable()
228 {
229 return super.IsTakeable() && GetAnimationPhase("Visibility") == 0;
230 }
231
233 {
234 return false;
235 }
236
237 void Arm()
238 {
239 SetArmed(true);
240
241 OnArmed();
242 }
243
244 void OnArmed();
245
247 {
248 return true;
249 }
250
251 void Disarm(bool pWithTool = false)
252 {
253 SetArmed(false);
254
255 OnDisarmed(pWithTool);
256 }
257
259 void OnDisarmed(bool pWithTool);
260
262 {
263 return false;
264 }
265
266 bool GetArmed()
267 {
268 return m_Armed;
269 }
270
271 protected void SetArmed(bool state)
272 {
273 m_Armed = state;
274 SetSynchDirty();
275 }
276
277 override bool CanPutInCargo(EntityAI parent)
278 {
279 if (!super.CanPutInCargo(parent))
280 {
281 return false;
282 }
283
284 return IsTakeable();
285 }
286
287 override bool CanPutIntoHands(EntityAI parent)
288 {
289 if (!super.CanPutIntoHands(parent))
290 {
291 return false;
292 }
293
294 return IsTakeable();
295 }
296
297 override bool CanRemoveFromHands(EntityAI parent)
298 {
299 return IsTakeable();
300 }
301
303 {
304 return m_Defused;
305 }
306
307 protected void SetDefused(bool state)
308 {
309 m_Defused = state;
310 SetSynchDirty();
311 }
312
313 void SetAmmoType(string pAmmoType)
314 {
315 SetAmmoTypes({pAmmoType});
316 }
317
319 {
320 m_AmmoTypes.Clear();
321 m_AmmoTypes = pAmmoTypes;
322 }
323
324 void SetParticleExplosion(int particle)
325 {
326 m_ParticleExplosionId = particle;
327 }
328
331 {
332 m_ParticlePosition = local_pos;
333
334 if (GetHierarchyParent())
335 {
336 m_ParticlePosition = GetHierarchyParent().WorldToModel(GetPosition());
337 }
338 }
339
341 {
342 m_ParticleOrientation = local_ori;
343
344 if (GetHierarchyParent())
345 {
346 m_ParticleOrientation = GetHierarchyParent().WorldToModel(GetOrientation());
347 }
348 }
349
351 {
352 super.OnStoreSave(ctx);
353
354 ctx.Write(m_Armed);
355 }
356
357 override bool OnStoreLoad(ParamsReadContext ctx, int version)
358 {
359 if (!super.OnStoreLoad(ctx, version))
360 return false;
361
362 if (version > 129)
363 {
364 bool armed = false;
365 if (!ctx.Read(armed))
366 {
367 return false;
368 }
369
370 SetArmed(armed);
371 }
372
373 return true;
374 }
375
377 void UpdateLED(int pState);
379 {
380 return false;
381 }
382
385
388
389 void Init()
390 {
391 #ifndef SERVER
392 if (!m_TypeToSurfaceParticleIDMap)
393 {
394 m_TypeToSurfaceParticleIDMap = new map<string, ref map<string, int>>;
395 }
396
397 if(!m_TypeToSurfaceParticleIDMap.Contains(GetName()))
398 {
399 map<string, int> extraSurfaceeffect = new map<string, int>();
400 m_TypeToSurfaceParticleIDMap.Insert(GetName(), extraSurfaceeffect);
402 }
403 #endif
404 }
405
406 static void Cleanup()
407 {
408 if (m_TypeToSurfaceParticleIDMap)
409 {
410 m_TypeToSurfaceParticleIDMap.Clear();
411 }
412 }
413
415 {
416 //Here add in override call AddExplosionEffectForSurface for specific explosion on surface
417 }
418
419 void AddExplosionEffectForSurface(string surface, int effectID)
420 {
421 map<string, int> extraSurfaceeffect;
422 m_TypeToSurfaceParticleIDMap.Find(GetName(), extraSurfaceeffect);
423 extraSurfaceeffect.Insert(surface, effectID);
424 }
425
426 int GetParticleExplosionID(string surface)
427 {
428 map<string, int> extraSurfaceeffect;
429 m_TypeToSurfaceParticleIDMap.Find(GetName(), extraSurfaceeffect);
430
431 int particleID;
432 if (extraSurfaceeffect.Find(surface, particleID))
433 return particleID;
435 }
436}
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.
static override Particle PlayOnObject(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_world_rotation=false)
Creates a particle emitter, attaches it on the given object and activates it.
Serialization general interface. Serializer API works with:
Definition serializer.c:56
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)
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()
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)
proto native CGame GetGame()
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition effect.c:463
class JsonUndergroundAreaTriggerData GetPosition
Empty
Definition hand_states.c:14
ItemSoundHandler GetItemSoundHandler()
Definition itembase.c:9229
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="")