DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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 override bool IsExplosive()
41 {
42 return true;
43 }
44
45 override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
46 {
47 super.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
48
50 {
51 EntityAI parent = this;
52 if (GetHierarchyParent())
53 {
54 parent = GetHierarchyParent();
55 }
56
58 m_ParticleExplosionArr.Insert(p);
60 }
61
63 }
64
65 override void EEDelete(EntityAI parent)
66 {
67 super.EEDelete(parent);
68
70 {
72 {
74 }
75 }
76 }
77
78 override void EEKilled(Object killer)
79 {
80 super.EEKilled(killer);
81
84
85 UnpairRemote();
86 }
87
88 override void OnCEUpdate()
89 {
90 super.OnCEUpdate();
91
92 if (!IsRuined() && GetArmed() && GetPairDevice())
93 {
95 {
97
98 return;
99 }
100 }
101
103 }
104
105 override void UnpairRemote()
106 {
108 {
109 if (GetPairDevice())
110 {
111 GetPairDevice().UnpairRemote();
112 }
114 }
115
116 }
117
118
119 protected void CreateLight()
120 {
122 }
123
124 protected void DestroyParticle(Particle p)
125 {
126 #ifndef SERVER
127 if (p != null)
128 {
129 p.Stop();
130 }
131 #endif
132 }
133
134 protected void InitiateExplosion()
135 {
136 int count = m_AmmoTypes.Count();
137 for (int i = 0; i < count; i++)
138 {
139 Explode(DamageType.EXPLOSION, m_AmmoTypes[i]);
140 }
141
142 OnExplode();
143 }
144
145 protected void OnExplode()
146 {
147 if (GetGame().IsServer())
148 {
149 m_DeleteTimer.Run(0.25, this, "DeleteSafe");
150 }
151 }
152
153 override void SetActions()
154 {
155 super.SetActions();
156
159 }
160
161 override bool IsInventoryVisible()
162 {
163 if (!super.IsInventoryVisible())
164 {
165 return false;
166 }
167
168 return GetAnimationPhase("Visibility") == 0;
169 }
170
171 override bool IsTakeable()
172 {
173 return super.IsTakeable() && GetAnimationPhase("Visibility") == 0;
174 }
175
177 {
178 return false;
179 }
180
181 void Arm()
182 {
183 SetArmed(true);
184
185 OnArmed();
186 }
187
188 void OnArmed();
189
191 {
192 return true;
193 }
194
195 void Disarm(bool pWithTool = false)
196 {
197 SetArmed(false);
198
199 OnDisarmed(pWithTool);
200 }
201
202 void OnDisarmed(bool pWithTool);
203
205 {
206 return false;
207 }
208
209 bool GetArmed()
210 {
211 return m_Armed;
212 }
213
214 protected void SetArmed(bool state)
215 {
216 m_Armed = state;
217 SetSynchDirty();
218 }
219
221 {
222 return m_Defused;
223 }
224
225 protected void SetDefused(bool state)
226 {
227 m_Defused = state;
228 SetSynchDirty();
229 }
230
231 void SetAmmoType(string pAmmoType)
232 {
233 SetAmmoTypes({pAmmoType});
234 }
235
237 {
238 m_AmmoTypes.Clear();
239 m_AmmoTypes = pAmmoTypes;
240 }
241
242 void SetParticleExplosion(int particle)
243 {
244 m_ParticleExplosionId = particle;
245 }
246
249 {
250 m_ParticlePosition = local_pos;
251
252 if (GetHierarchyParent())
253 {
254 m_ParticlePosition = GetHierarchyParent().WorldToModel(GetPosition());
255 }
256 }
257
259 {
260 m_ParticleOrientation = local_ori;
261
262 if (GetHierarchyParent())
263 {
264 m_ParticleOrientation = GetHierarchyParent().WorldToModel(GetOrientation());
265 }
266 }
267
269 {
270 super.OnStoreSave(ctx);
271
272 ctx.Write(m_Armed);
273 }
274
275 override bool OnStoreLoad(ParamsReadContext ctx, int version)
276 {
277 if (!super.OnStoreLoad(ctx, version))
278 return false;
279
280 if (version > 129)
281 {
282 bool armed = false;
283 if (!ctx.Read(armed))
284 {
285 return false;
286 }
287
288 SetArmed(armed);
289 }
290
291 return true;
292 }
293
295 void UpdateLED(int pState);
297 {
298 return false;
299 }
300
303
305 {
306 m_DeleteTimer = new Timer();
308
311 SetParticlePosition(WorldToModel(GetPosition()));
313
314 RegisterNetSyncVariableBool("m_Armed");
315 RegisterNetSyncVariableBool("m_Defused");
316 }
317}
AttachActionData ActionData ActionAttach()
Definition ActionAttach.c:9
void ActionDetach()
void AddAction(typename actionName)
vector GetOrientation()
protected void Disarm()
Definition ClockBase.c:198
DamageType
exposed from C++ (do not change)
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
ExplosiveLight DEFAULT_AMMO_TYPE
bool IsTimerDetonable()
override void OnCEUpdate()
protected vector m_ParticlePosition
protected ExplosiveLight m_Light
light
protected ref Timer m_DeleteTimer
bool GetArmed()
void SetAmmoTypes(array< string > pAmmoTypes)
override bool IsExplosive()
protected Particle m_ParticleExplosion
particle
protected bool m_Armed
protected void InitiateExplosion()
void SetParticleExplosion(int particle)
protected const string ANIM_PHASE_VISIBILITY
void SetParticlePosition(vector local_pos)
set position for smoke particle - needs to be in Local Space
void UnlockTriggerSlots()
protected void OnExplode()
bool GetDefused()
void OnDisarmed(bool pWithTool)
protected int m_ParticleExplosionId
override void UnpairRemote()
protected void DestroyParticle(Particle p)
protected void SetArmed(bool state)
void OnArmed()
protected ref array< ParticleSource > m_ParticleExplosionArr
protected void CreateLight()
void Arm()
protected bool m_Defused
void SetAmmoType(string pAmmoType)
bool CanBeDisarmed()
bool HasLockedTriggerSlots()
void SetParticleOrientation(vector local_ori)
protected void SetDefused(bool state)
protected vector m_ParticleOrientation
void ExplosivesBase()
void LockTriggerSlots()
bool CanBeArmed()
protected ref array< string > m_AmmoTypes
protected void UpdateLED(string selection, string color)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
ERemoteDetonatorLEDState
override void Explode(int damageType, string ammoType="")
class JsonUndergroundAreaTriggerData GetPosition
void ExplosiveLight()
static protected float m_DefaultBrightness
static protected float m_DefaultRadius
override bool IsInventoryVisible()
protected BlowtorchLight m_Light
Definition Blowtorch.c:7
override void OnStoreSave(ParamsWriteContext ctx)
Definition GardenBase.c:225
override void EEKilled(Object killer)
override void EEDelete(EntityAI parent)
Definition Edible_Base.c:44
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition GardenBase.c:147
override bool IsTakeable()
override void SetActions()
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
static const int INVALID
Entity which has the particle instance as an ObjectComponent.
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
const float EXPLOSIVE_REMOTE_ACTIVATION
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Definition EnConvert.c:110
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto native CGame GetGame()
static proto float SqrFloat(float f)
Returns squared value.