Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
6  void ExplosiveLight()
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;
26  protected ref array<string> m_AmmoTypes;
27 
28  protected ref Timer m_DeleteTimer;
29 
32 
36  protected int m_ParticleExplosionId;
39 
41  {
42  m_DeleteTimer = new Timer();
43  m_AmmoTypes = new array<string>();
44 
47  SetParticlePosition(WorldToModel(GetPosition()));
49 
50  RegisterNetSyncVariableBool("m_Armed");
51  RegisterNetSyncVariableBool("m_Defused");
52  }
53 
54 
55  override bool IsExplosive()
56  {
57  return true;
58  }
59 
60  override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
61  {
62  super.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
63 
64  if (m_ParticleExplosionId > ParticleList.INVALID)
65  {
66  EntityAI parent = this;
67  if (GetHierarchyParent())
68  {
69  parent = GetHierarchyParent();
70  }
71 
73  m_ParticleExplosionArr.Insert(p);
75  }
76 
77  CreateLight();
78  }
79 
80  override void EEDelete(EntityAI parent)
81  {
82  super.EEDelete(parent);
83 
85  {
87  {
88  DestroyParticle(p);
89  }
90  }
91  }
92 
93  override void EEKilled(Object killer)
94  {
95  super.EEKilled(killer);
96 
99 
100  UnpairRemote();
101  }
102 
103  override void OnCEUpdate()
104  {
105  super.OnCEUpdate();
106 
107  if (!IsRuined() && GetArmed() && GetPairDevice())
108  {
109  if (vector.DistanceSq(GetPosition(), GetPairDevice().GetPosition()) <= Math.SqrFloat(UAMaxDistances.EXPLOSIVE_REMOTE_ACTIVATION))
110  {
112 
113  return;
114  }
115  }
116 
118  }
119 
120  override void UnpairRemote()
121  {
123  {
124  if (GetPairDevice())
125  {
126  GetPairDevice().UnpairRemote();
127  }
129  }
130 
131  }
132 
133  override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
134  {
135  super.OnPlacementComplete(player, position, orientation);
136 
137  if (GetGame().IsServer())
138  {
139  SetOrientation(orientation);
140  SetPosition(position);
141  PlaceOnSurface();
142  }
143  }
144 
145  protected void CreateLight()
146  {
148  }
149 
150  protected void DestroyParticle(Particle p)
151  {
152  #ifndef SERVER
153  if (p != null)
154  {
155  p.Stop();
156  }
157  #endif
158  }
159 
160  protected void InitiateExplosion()
161  {
162  int count = m_AmmoTypes.Count();
163  for (int i = 0; i < count; i++)
164  {
165  Explode(DamageType.EXPLOSION, m_AmmoTypes[i]);
166  }
167 
168  OnExplode();
169  }
170 
171  protected void OnExplode()
172  {
173  if (GetGame().IsServer())
174  {
175  m_DeleteTimer.Run(0.25, this, "DeleteSafe");
176  }
177  }
178 
179  override void SetActions()
180  {
181  super.SetActions();
182 
185  }
186 
187  override bool IsInventoryVisible()
188  {
189  if (!super.IsInventoryVisible())
190  {
191  return false;
192  }
193 
194  return GetAnimationPhase("Visibility") == 0;
195  }
196 
197  override bool IsTakeable()
198  {
199  return super.IsTakeable() && GetAnimationPhase("Visibility") == 0;
200  }
201 
203  {
204  return false;
205  }
206 
207  void Arm()
208  {
209  SetArmed(true);
210 
211  OnArmed();
212  }
213 
214  void OnArmed();
215 
216  bool CanBeArmed()
217  {
218  return true;
219  }
220 
221  void Disarm(bool pWithTool = false)
222  {
223  SetArmed(false);
224 
225  OnDisarmed(pWithTool);
226  }
227 
228  void OnBeforeDisarm();
229  void OnDisarmed(bool pWithTool);
230 
232  {
233  return false;
234  }
235 
236  bool GetArmed()
237  {
238  return m_Armed;
239  }
240 
241  protected void SetArmed(bool state)
242  {
243  m_Armed = state;
244  SetSynchDirty();
245  }
246 
247  override bool CanPutInCargo(EntityAI parent)
248  {
249  if (!super.CanPutInCargo(parent))
250  {
251  return false;
252  }
253 
254  return IsTakeable();
255  }
256 
257  override bool CanPutIntoHands(EntityAI parent)
258  {
259  if (!super.CanPutIntoHands(parent))
260  {
261  return false;
262  }
263 
264  return IsTakeable();
265  }
266 
267  override bool CanRemoveFromHands(EntityAI parent)
268  {
269  return IsTakeable();
270  }
271 
272  bool GetDefused()
273  {
274  return m_Defused;
275  }
276 
277  protected void SetDefused(bool state)
278  {
279  m_Defused = state;
280  SetSynchDirty();
281  }
282 
283  void SetAmmoType(string pAmmoType)
284  {
285  SetAmmoTypes({pAmmoType});
286  }
287 
288  void SetAmmoTypes(array<string> pAmmoTypes)
289  {
290  m_AmmoTypes.Clear();
291  m_AmmoTypes = pAmmoTypes;
292  }
293 
294  void SetParticleExplosion(int particle)
295  {
296  m_ParticleExplosionId = particle;
297  }
298 
300  void SetParticlePosition(vector local_pos)
301  {
302  m_ParticlePosition = local_pos;
303 
304  if (GetHierarchyParent())
305  {
306  m_ParticlePosition = GetHierarchyParent().WorldToModel(GetPosition());
307  }
308  }
309 
311  {
312  m_ParticleOrientation = local_ori;
313 
314  if (GetHierarchyParent())
315  {
316  m_ParticleOrientation = GetHierarchyParent().WorldToModel(GetOrientation());
317  }
318  }
319 
320  override void OnStoreSave(ParamsWriteContext ctx)
321  {
322  super.OnStoreSave(ctx);
323 
324  ctx.Write(m_Armed);
325  }
326 
327  override bool OnStoreLoad(ParamsReadContext ctx, int version)
328  {
329  if (!super.OnStoreLoad(ctx, version))
330  return false;
331 
332  if (version > 129)
333  {
334  bool armed = false;
335  if (!ctx.Read(armed))
336  {
337  return false;
338  }
339 
340  SetArmed(armed);
341  }
342 
343  return true;
344  }
345 
347  void UpdateLED(int pState);
349  {
350  return false;
351  }
352 
353  void LockTriggerSlots();
354  void UnlockTriggerSlots();
355 
356  void LockExplosivesSlots();
357  void UnlockExplosivesSlots();
358 
359 }
ItemBase
Definition: inventoryitem.c:730
m_AmmoTypes
protected ref array< string > m_AmmoTypes
Definition: explosivesbase.c:26
GetGame
proto native CGame GetGame()
m_ParticleOrientation
protected vector m_ParticleOrientation
Definition: explosivesbase.c:38
SetParticleExplosion
void SetParticleExplosion(int particle)
Definition: explosivesbase.c:294
OnDisarmed
void OnDisarmed(bool pWithTool)
Particle
Legacy way of using particles in the game.
Definition: particle.c:6
ERemoteDetonatorLEDState
ERemoteDetonatorLEDState
Definition: remotedetonator.c:1
ActionDetach
void ActionDetach()
Definition: actiondetach.c:10
SetActions
override void SetActions()
Definition: explosivesbase.c:179
GetArmed
bool GetArmed()
Definition: explosivesbase.c:236
Arm
void Arm()
Definition: explosivesbase.c:207
PointLightBase
Definition: staticobj_roadblock_wood_small.c:27
EEDelete
override void EEDelete(EntityAI parent)
Definition: explosivesbase.c:80
IsTakeable
override bool IsTakeable()
Definition: explosivesbase.c:197
m_Light
protected ExplosiveLight m_Light
light
Definition: explosivesbase.c:31
EEKilled
override void EEKilled(Object killer)
Definition: explosivesbase.c:93
Explode
override void Explode(int damageType, string ammoType="")
Definition: trap_landmine.c:220
OnStoreLoad
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition: explosivesbase.c:327
m_DeleteTimer
protected ref Timer m_DeleteTimer
Definition: explosivesbase.c:28
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: explosivesbase.c:60
m_DefaultRadius
protected float m_DefaultRadius
Definition: contaminatedarea_dynamic.c:14
UAMaxDistances
Definition: actionconstants.c:104
InitiateExplosion
protected void InitiateExplosion()
Definition: explosivesbase.c:160
OnPlacementComplete
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition: explosivesbase.c:133
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
IsInventoryVisible
override bool IsInventoryVisible()
Definition: explosivesbase.c:187
ExplosivesBase
void ExplosivesBase()
Definition: explosivesbase.c:40
m_ParticleExplosionArr
protected ref array< ParticleSource > m_ParticleExplosionArr
Definition: explosivesbase.c:35
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
ParticleList
Definition: particlelist.c:11
OnStoreSave
override void OnStoreSave(ParamsWriteContext ctx)
Definition: explosivesbase.c:320
CanPutIntoHands
override bool CanPutIntoHands(EntityAI parent)
Definition: explosivesbase.c:257
vector
Definition: enconvert.c:105
CanPutInCargo
override bool CanPutInCargo(EntityAI parent)
Definition: explosivesbase.c:247
OnBeforeDisarm
void OnBeforeDisarm()
DEFAULT_AMMO_TYPE
ExplosiveLight DEFAULT_AMMO_TYPE
CanBeDisarmed
bool CanBeDisarmed()
Definition: explosivesbase.c:231
DestroyParticle
protected void DestroyParticle(Particle p)
Definition: explosivesbase.c:150
SetParticleOrientation
void SetParticleOrientation(vector local_ori)
Definition: explosivesbase.c:310
ExplosiveLight
Definition: explosivesbase.c:1
CreateLight
protected void CreateLight()
Definition: explosivesbase.c:145
SetDefused
protected void SetDefused(bool state)
Definition: explosivesbase.c:277
LockTriggerSlots
void LockTriggerSlots()
DamageType
DamageType
exposed from C++ (do not change)
Definition: damagesystem.c:10
m_Armed
protected bool m_Armed
Definition: explosivesbase.c:24
CanRemoveFromHands
override bool CanRemoveFromHands(EntityAI parent)
Definition: explosivesbase.c:267
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
Object
Definition: objecttyped.c:1
OnArmed
void OnArmed()
m_DefaultBrightness
enum eAreaDecayStage m_DefaultBrightness
ScriptedLightBase
Definition: pointlightbase.c:1
LockExplosivesSlots
void LockExplosivesSlots()
CanBeArmed
bool CanBeArmed()
Definition: explosivesbase.c:216
GetRemotelyActivatedItemBehaviour
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Definition: remotedetonator.c:82
OnExplode
protected void OnExplode()
Definition: explosivesbase.c:171
ActionAttach
ActionAttachWheels ActionAttach
array< string >
OnCEUpdate
override void OnCEUpdate()
Definition: explosivesbase.c:103
ParticleSource
Entity which has the particle instance as an ObjectComponent.
Definition: particlesource.c:123
UnpairRemote
override void UnpairRemote()
Definition: explosivesbase.c:120
m_ParticlePosition
protected vector m_ParticlePosition
Definition: explosivesbase.c:37
Disarm
void Disarm(bool pWithTool=false)
Definition: explosivesbase.c:221
UpdateLED
void UpdateLED(int pState)
HELPERS.
GetDefused
bool GetDefused()
Definition: explosivesbase.c:272
SetPosition
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition: effect.c:436
IsTimerDetonable
bool IsTimerDetonable()
Definition: explosivesbase.c:202
SetAmmoType
void SetAmmoType(string pAmmoType)
Definition: explosivesbase.c:283
SetParticlePosition
void SetParticlePosition(vector local_pos)
set position for smoke particle - needs to be in Local Space
Definition: explosivesbase.c:300
HasLockedTriggerSlots
bool HasLockedTriggerSlots()
Definition: explosivesbase.c:348
Timer
Definition: dayzplayerimplement.c:62
m_ParticleExplosion
protected Particle m_ParticleExplosion
particle
Definition: explosivesbase.c:34
UnlockTriggerSlots
void UnlockTriggerSlots()
ANIM_PHASE_VISIBILITY
const protected string ANIM_PHASE_VISIBILITY
Definition: explosivesbase.c:22
m_ParticleExplosionId
protected int m_ParticleExplosionId
Definition: explosivesbase.c:36
Math
Definition: enmath.c:6
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition: particlemanager.c:84
UnlockExplosivesSlots
void UnlockExplosivesSlots()
EntityAI
Definition: building.c:5
SetAmmoTypes
void SetAmmoTypes(array< string > pAmmoTypes)
Definition: explosivesbase.c:288
m_Defused
protected bool m_Defused
Definition: explosivesbase.c:25
SetArmed
protected void SetArmed(bool state)
Definition: explosivesbase.c:241
IsExplosive
override bool IsExplosive()
Definition: explosivesbase.c:55
GetOrientation
vector GetOrientation()
Definition: areadamagemanager.c:306