DayZ 1.24
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
29
32
36 protected int m_ParticleExplosionId;
39
41 {
42 m_DeleteTimer = new Timer();
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 {
63
65 {
66 EntityAI parent = this;
67 if (GetHierarchyParent())
68 parent = GetHierarchyParent();
69
73 }
74
76 }
77
78 override void EEDelete(EntityAI parent)
79 {
80 super.EEDelete(parent);
81
83 {
86 }
87 }
88
89 override void EEKilled(Object killer)
90 {
91 super.EEKilled(killer);
92
95
97 }
98
99 override void OnCEUpdate()
100 {
101 super.OnCEUpdate();
102
103 if (!IsRuined() && GetArmed() && GetPairDevice())
104 {
106 {
108
109 return;
110 }
111 }
112
114 }
115
116 override void UnpairRemote()
117 {
119 {
120 if (GetPairDevice())
121 GetPairDevice().UnpairRemote();
123 }
124
125 }
126
127 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
128 {
129 super.OnPlacementComplete(player, position, orientation);
130
131 if (GetGame().IsServer())
132 {
133 SetOrientation(orientation);
135 PlaceOnSurface();
136 }
137 }
138
139 protected void CreateLight()
140 {
142 }
143
144 protected void DestroyParticle(Particle p)
145 {
146#ifndef SERVER
147 if (p != null)
148 p.Stop();
149#endif
150 }
151
152 protected void InitiateExplosion()
153 {
154 int count = m_AmmoTypes.Count();
155 for (int i = 0; i < count; i++)
156 Explode(DamageType.EXPLOSION, m_AmmoTypes[i]);
157
158 OnExplode();
159 }
160
161 protected void OnExplode()
162 {
163 if (GetGame().IsServer())
164 m_DeleteTimer.Run(0.25, this, "DeleteSafe");
165 }
166
167 override void SetActions()
168 {
169 super.SetActions();
170
171 AddAction(ActionAttach);
173 }
174
175 override bool IsInventoryVisible()
176 {
177 if (!super.IsInventoryVisible())
178 return false;
179
180 return GetAnimationPhase("Visibility") == 0;
181 }
182
183 override bool IsTakeable()
184 {
185 return super.IsTakeable() && GetAnimationPhase("Visibility") == 0;
186 }
187
189 {
190 return false;
191 }
192
193 void Arm()
194 {
195 SetArmed(true);
196
197 OnArmed();
198 }
199
200 void OnArmed();
201
203 {
204 return true;
205 }
206
207 void Disarm(bool pWithTool = false)
208 {
209 SetArmed(false);
210
212 }
213
216
218 {
219 return false;
220 }
221
222 bool GetArmed()
223 {
224 return m_Armed;
225 }
226
227 protected void SetArmed(bool state)
228 {
229 m_Armed = state;
230 SetSynchDirty();
231 }
232
233 override bool CanPutInCargo(EntityAI parent)
234 {
235 if (!super.CanPutInCargo(parent))
236 return false;
237
238 return IsTakeable();
239 }
240
241 override bool CanPutIntoHands(EntityAI parent)
242 {
243 if (!super.CanPutIntoHands(parent))
244 return false;
245
246 return IsTakeable();
247 }
248
249 override bool CanRemoveFromHands(EntityAI parent)
250 {
251 return IsTakeable();
252 }
253
255 {
256 return m_Defused;
257 }
258
259 protected void SetDefused(bool state)
260 {
262 SetSynchDirty();
263 }
264
266 {
268 }
269
275
280
283 {
285
286 if (GetHierarchyParent())
287 m_ParticlePosition = GetHierarchyParent().WorldToModel(GetPosition());
288 }
289
291 {
293
294 if (GetHierarchyParent())
295 m_ParticleOrientation = GetHierarchyParent().WorldToModel(GetOrientation());
296 }
297
299 {
300 super.OnStoreSave(ctx);
301
302 ctx.Write(m_Armed);
303 }
304
305 override bool OnStoreLoad(ParamsReadContext ctx, int version)
306 {
307 if (!super.OnStoreLoad(ctx, version))
308 return false;
309
310 if (version > 129)
311 {
312 bool armed = false;
313 if (!ctx.Read(armed))
314 return false;
315
317 }
318
319 return true;
320 }
321
323 void UpdateLED(int pState);
325 {
326 return false;
327 }
328
331
334
335}
void ActionDetach()
void AddAction(typename actionName)
class PASBroadcaster extends AdvancedCommunication IsInventoryVisible
void SetActions()
vector GetOrientation()
void Disarm()
Definition ClockBase.c:191
override void EEDelete(EntityAI parent)
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)
void UnlockExplosivesSlots()
ExplosiveLight DEFAULT_AMMO_TYPE
void OnExplode()
bool IsTimerDetonable()
override void OnCEUpdate()
ExplosiveLight m_Light
light
void SetArmed(bool state)
void InitiateExplosion()
void OnBeforeDisarm()
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()
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()
bool CanBeArmed()
vector m_ParticlePosition
void UpdateLED(string selection, string color)
void OnStoreSave(ParamsWriteContext ctx)
bool OnStoreLoad(ParamsReadContext ctx, int version)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
ERemoteDetonatorLEDState
override void Explode(int damageType, string ammoType="")
class JsonUndergroundAreaTriggerData GetPosition
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
static const int INVALID
Entity which has the particle instance as an ObjectComponent.
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
const float EXPLOSIVE_REMOTE_ACTIVATION
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition Effect.c:420
static proto float SqrFloat(float f)
Returns squared value.